Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
86c463c
Use shiki instead of prism for snippets
PiotrWodecki Jun 12, 2025
e7ebc13
Use Shiki/Twoslash for snippets
PiotrWodecki Jun 24, 2025
135c7dc
Fix all type errors in docs apart from api ref
PiotrWodecki Jun 25, 2025
03f2b99
Bump packages
PiotrWodecki Jun 26, 2025
675ce30
Bump packages
PiotrWodecki Jun 26, 2025
6327d24
Bump typedoc
PiotrWodecki Jun 26, 2025
9437ac9
Bump mobile sdk as a test
PiotrWodecki Jun 30, 2025
3bf7a61
Bump docusaurus
PiotrWodecki Jun 30, 2025
107aff5
Fix broken typedoc links
PiotrWodecki Jun 30, 2025
b63e6d6
Update package refs
PiotrWodecki Jun 30, 2025
0e67a68
Update browsers data
PiotrWodecki Jun 30, 2025
794daf0
Merge branch 'main' into FCE-1631-typecheck-snippets
PiotrWodecki Jun 30, 2025
1993a14
Fix lockfile after merge
PiotrWodecki Jun 30, 2025
0ddaa8a
Update packages with main
PiotrWodecki Jun 30, 2025
f503adf
Use yarn workspaces instead of imports
PiotrWodecki Jun 30, 2025
3162b2e
Fix type errors from merge
PiotrWodecki Jun 30, 2025
17a2a67
Update package to fix type error from merge
PiotrWodecki Jun 30, 2025
4f1404e
Init submodules on static checks
PiotrWodecki Jun 30, 2025
96dcf01
Remove Fishjam npm packages
PiotrWodecki Jun 30, 2025
b7e1ef4
Prettier formatting
PiotrWodecki Jun 30, 2025
4ba4c92
Exclude packages from default type checking
PiotrWodecki Jun 30, 2025
b543110
Fix type errors in docusaurus components
PiotrWodecki Jun 30, 2025
8bc162c
Use real package versions instead of force fetching
PiotrWodecki Jun 30, 2025
a4e3678
Forcefully init and update submodules
PiotrWodecki Jul 1, 2025
2e6892e
Revert "Use yarn workspaces instead of imports"
PiotrWodecki Jul 1, 2025
a7a19c7
Use file imports for submodules
PiotrWodecki Jul 2, 2025
d15f382
Switch to tgz package imports
PiotrWodecki Jul 2, 2025
d58f2f1
Pack deps in prepare
PiotrWodecki Jul 2, 2025
f19d44e
Run prepare early in checks
PiotrWodecki Jul 2, 2025
6792737
Hack around prepare circular dependency
PiotrWodecki Jul 2, 2025
44cb3ae
Use links instead of files in yarn
PiotrWodecki Jul 2, 2025
fbdce58
Revert CI hacks
PiotrWodecki Jul 2, 2025
d4a37dc
Do not build examples in prepare
PiotrWodecki Jul 2, 2025
1d86128
Update web-sdk to fix lock file
PiotrWodecki Jul 2, 2025
df4ce74
Fix code render
PiotrWodecki Jul 3, 2025
4815f2d
Use simpler renderer
PiotrWodecki Jul 3, 2025
38fb9ca
Add smelter deps as packages
PiotrWodecki Jul 3, 2025
d46354b
Replace accepted errors with off-page inits
PiotrWodecki Jul 3, 2025
3330d71
Bump mobile sdk
PiotrWodecki Jul 3, 2025
da3c7c6
Add a simple code snippet copy button
PiotrWodecki Jul 3, 2025
9c84b27
Bump web
PiotrWodecki Jul 3, 2025
198882c
Bump mobile
PiotrWodecki Jul 3, 2025
8ae39e5
Bump yarn
PiotrWodecki Jul 3, 2025
4033be7
Bump mobile
PiotrWodecki Jul 3, 2025
bad7be4
Use LTS node in GH actions
PiotrWodecki Jul 3, 2025
eb9a47a
Bump corepack
PiotrWodecki Jul 3, 2025
b9c9537
Bump web
PiotrWodecki Jul 3, 2025
01fd96e
Bump web
PiotrWodecki Jul 3, 2025
3f1ad87
Prettier
PiotrWodecki Jul 3, 2025
03e4d54
reattach mobile and web
PiotrWodecki Jul 3, 2025
0048f55
Merge branch 'main' into FCE-1631-typecheck-snippets
PiotrWodecki Jul 3, 2025
bae2c8d
Fix highlight and a mistake addition
PiotrWodecki Jul 4, 2025
34c6217
Remove commented out import
PiotrWodecki Jul 4, 2025
07954fc
Use a type guard instead of wild casting
PiotrWodecki Jul 4, 2025
68473e1
replace class components
PiotrWodecki Jul 4, 2025
5aee5bf
Format
PiotrWodecki Jul 4, 2025
4631842
Highlight outside of tsx
PiotrWodecki Jul 4, 2025
2667fac
Update docs/react/stream-middleware.mdx
PiotrWodecki Jul 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
# 👇 Build steps
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Use corepack
run: corepack enable
- name: Install dependencies
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/static_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: init and update submodules
run: git submodule update --init --recursive
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Use corepack
run: corepack enable
- name: Run prepare
run: scripts/prepare.sh
- name: Install node dependencies
run: yarn --immutable
- name: Spellcheck
Expand All @@ -17,7 +27,5 @@ jobs:
run: yarn format:check
- name: Check types
run: yarn typecheck
- name: Fetch packages
run: yarn prepare
- name: Check build
run: yarn build
6 changes: 6 additions & 0 deletions docs/audio-calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Using this feature is as easy as setting the `roomType` field to `audio_only` wh
<TabItem value="ts" label="Typescript">

```ts
import { FishjamClient } from '@fishjam-cloud/js-server-sdk';
const fishjamClient = new FishjamClient({
fishjamUrl: "aaa",
managementToken: "bbb",
});
// ---cut---
const createdRoom = await fishjamClient.createRoom({ roomType: 'audio_only' });
```

Expand Down
14 changes: 14 additions & 0 deletions docs/livestreaming.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ https://fishjam.io/api/v1/connect/${ROOM_MANAGER_ID}/room-manager?roomName=foo&p
<TabItem value="ts" label="Typescript">

```ts
import { FishjamClient } from '@fishjam-cloud/js-server-sdk';
const fishjamClient = new FishjamClient({
fishjamUrl: "aaa",
managementToken: "bbb",
});
// ---cut---
const createdRoom = await fishjamClient.createRoom({ roomType: 'livestream' });

const peer = await fishjamClient.createPeer(createdRoom.id)
Expand Down Expand Up @@ -71,6 +77,14 @@ https://fishjam.io/api/v1/connect/${ROOM_MANAGER_ID}/room-manager/<ROOM_NAME>/li
<TabItem value="ts" label="Typescript">

```ts
import { FishjamClient } from '@fishjam-cloud/js-server-sdk';
const fishjamClient = new FishjamClient({
fishjamUrl: "aaa",
managementToken: "bbb",
});
const room = await fishjamClient.createRoom({ roomType: 'livestream' });
// ---cut---

const viewerToken = await fishjamClient.createLivestreamViewerToken(room.id)
```

Expand Down
116 changes: 97 additions & 19 deletions docs/production/examples/fastify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If you wish to see more general info, visit [**set up your server**](/production
Use [`@fastify/env` package](https://github.com/fastify/fastify-env) to load and set environment variables in your Fastify instance.

```ts title='main.ts'
import { Fastify } from "fastify";
import Fastify from "fastify";
import fastifyEnv from "@fastify/env";

const fastify = Fastify();
Expand Down Expand Up @@ -55,13 +55,17 @@ import { FishjamClient } from "@fishjam-cloud/js-server-sdk";
declare module "fastify" {
interface FastifyInstance {
fishjam: FishjamClient;
config: {
FISHJAM_URL: string;
FISHJAM_MANAGEMENT_TOKEN: string;
};
}
}

export const fishjamPlugin = fastifyPlugin((fastify) => {
const fishjamClient = new FishjamClient({
fishjamUrl: fastify.config.FISHJAM_URL,
managementToken: fastify.config.FISHJAM_SERVER_TOKEN,
managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN,
});

fastify.decorate("fishjam", fishjamClient);
Expand All @@ -71,13 +75,32 @@ export const fishjamPlugin = fastifyPlugin((fastify) => {
Now, after registering the plugin, we will be able to use Fishjam client by accessing the `fastify.fishjam` property.

```ts title='main.ts'
import { Fastify } from "fastify";
import fastifyEnv from "@fastify/env";
import fastifyPlugin from "fastify-plugin";
import { FishjamClient } from "@fishjam-cloud/js-server-sdk";
import Fastify from "fastify";

import { fishjamPlugin } from "./fishjamPlugin";
declare module "fastify" {
interface FastifyInstance {
fishjam: FishjamClient;
config: {
FISHJAM_URL: string;
FISHJAM_MANAGEMENT_TOKEN: string;
};
}
}

export const fishjamPlugin = fastifyPlugin((fastify) => {
const fishjamClient = new FishjamClient({
fishjamUrl: fastify.config.FISHJAM_URL,
managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN,
});

fastify.decorate("fishjam", fishjamClient);
});

const fastify = Fastify();
// ... skipping env loading code for convenience

// ---cut---
await fastify.register(fishjamPlugin);

fastify.get("/rooms", () => fastify.fishjam.getAllRooms());
Expand All @@ -97,20 +120,21 @@ To receive and parse the Fishjam protobuf messages, add a content type parser to
Then, you will be able to access the parsed message at `request.Body`.

```ts title='main.ts'
import { Fastify } from "fastify";
import Fastify, { FastifyRequest } from "fastify";
import { ServerMessage } from "@fishjam-cloud/js-server-sdk/proto";

const fastify = Fastify();

fastify.addContentTypeParser(
"application/x-protobuf",
{ parseAs: "buffer" },
async (_: FastifyRequest, body: Buffer) => ServerMessage.decode(body),
async (_: FastifyRequest, body: Buffer) =>
ServerMessage.decode(new Uint8Array(body)),
);

fastify.post<{ Body: ServerMessage }>("/fishjam-webhook", (request) => {
// handle the message
console.log(request.Body);
console.log(request.body);
});
```

Expand All @@ -122,6 +146,32 @@ Let's create another plugin in `fishjamNotifierPlugin.ts` file.
In this case, we don't need to extend the Fastify instance type, because the plugin doesn't decorate the Fastify instance with any properties. It will work in the background.

```ts title='fishjamNotifierPlugin.ts'
import fastifyPlugin from "fastify-plugin";
import { FishjamClient } from "@fishjam-cloud/js-server-sdk";
import Fastify from "fastify";

declare module "fastify" {
interface FastifyInstance {
fishjam: FishjamClient;
config: {
FISHJAM_URL: string;
FISHJAM_MANAGEMENT_TOKEN: string;
};
}
}

export const fishjamPlugin = fastifyPlugin((fastify) => {
const fishjamClient = new FishjamClient({
fishjamUrl: fastify.config.FISHJAM_URL,
managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN,
});

fastify.decorate("fishjam", fishjamClient);
});

const fastify = Fastify();

// ---cut---
import { type FastifyInstance } from "fastify";
import fp from "fastify-plugin";
import { FishjamWSNotifier } from "@fishjam-cloud/js-server-sdk";
Expand All @@ -132,31 +182,59 @@ export const fishjamNotifierPlugin = fp((fastify) => {

const fishjamNotifier = new FishjamWSNotifier(
{ fishjamUrl, managementToken },
onError: (err) => fastify.log.error(err),
onClose: () => fastify.log.info("Websocket connection to Fishjam closed"),
onConnectionFailed: () => fastify.log.error("Failed to connect Fishjam notifier")
(err) => fastify.log.error(err),
() => fastify.log.info("Websocket connection to Fishjam closed"),
() => fastify.log.error("Failed to connect Fishjam notifier"),
);

// handle the messages
const handleRoomCreated = console.log;
const handlePeerCreated = console.log;
const handlePeerAdded = console.log;

fishjamNotifier.on("roomCreated", handleRoomCreated);
fishjamNotifier.on("peerCreated", handlePeerCreated);
fishjamNotifier.on("peerAdded", handlePeerAdded);
});
```

Don't forget to register your plugin.

```ts title='main.ts'
import { Fastify } from "fastify";
import fastifyEnv from "@fastify/env";
import fastifyPlugin from "fastify-plugin";
import { FishjamClient } from "@fishjam-cloud/js-server-sdk";
import Fastify from "fastify";
import { FishjamWSNotifier } from "@fishjam-cloud/js-server-sdk";

declare module "fastify" {
interface FastifyInstance {
fishjam: FishjamClient;
config: {
FISHJAM_URL: string;
FISHJAM_MANAGEMENT_TOKEN: string;
};
}
}

export const fishjamPlugin = fastifyPlugin((fastify) => {
const fishjamClient = new FishjamClient({
fishjamUrl: "aaa",
managementToken: "bbb",
});

import { fishjamPlugin } from "./fishjamPlugin";
import { fishjamNotifierPlugin } from "./fishjamNotifierPlugin";
fastify.decorate("fishjam", fishjamClient);
});

const fastify = Fastify();
// ...

const fishjamNotifierPlugin = fastifyPlugin((fastify) => {
const fishjamNotifier = new FishjamWSNotifier(
{ fishjamUrl: "aaa", managementToken: "bbb" },
(err) => fastify.log.error(err),
() => fastify.log.info("Websocket connection to Fishjam closed"),
() => fastify.log.error("Failed to connect Fishjam notifier"),
);
});
// ---cut---

await fastify.register(fishjamPlugin);
await fastify.register(fishjamNotifierPlugin);
```
41 changes: 38 additions & 3 deletions docs/production/server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ They are required to proceed. Now, we are ready to dive into the code.
<TabItem value="ts" label="Typescript">

```ts
process.env.FISHJAM_URL = "https://fishjam.io";
process.env.FISHJAM_MANAGEMENT_TOKEN = "bbb";
// ---cut---

import { FishjamClient } from '@fishjam-cloud/js-server-sdk';

const fishjamUrl = process.env.FISHJAM_URL;
Expand Down Expand Up @@ -89,6 +93,13 @@ Create a room to get the `roomId` and be able to start adding peers.
<TabItem value="ts" label="Typescript">

```ts
import { FishjamClient } from '@fishjam-cloud/js-server-sdk';
const fishjamClient = new FishjamClient({

fishjamUrl: "https://fishjam.io",
managementToken: "bbb",
});
// ---cut---
const createdRoom = await fishjamClient.createRoom();

const theSameRoom = await fishjamClient.getRoom(createdRoom.id);
Expand Down Expand Up @@ -125,9 +136,16 @@ At any time you can terminate user's access by deleting the peer.
<TabItem value="ts" label="Typescript">

```ts
const { peer, peerToken } = await fishjamClient.createPeer(roomId);
import { FishjamClient } from '@fishjam-cloud/js-server-sdk';
const fishjamClient = new FishjamClient({
fishjamUrl: "https://fishjam.io",
managementToken: "bbb",
});
const created_room = await fishjamClient.createRoom();
// ---cut---
const { peer, peerToken } = await fishjamClient.createPeer(created_room.id);

await fishjamClient.deletePeer(roomId, peer.id);
await fishjamClient.deletePeer(created_room.id, peer.id);
```

</TabItem>
Expand All @@ -153,7 +171,14 @@ or [web SDK](/react/metadata). This metadata can be only set when creating the p
<TabItem value="ts" label="Typescript">

```ts
const { peer, peerToken } = await fishjamClient.createPeer(roomId, {
import { FishjamClient } from '@fishjam-cloud/js-server-sdk';
const fishjamClient = new FishjamClient({
fishjamUrl: "https://fishjam.io",
managementToken: "bbb",
});
const created_room = await fishjamClient.createRoom();
// ---cut---
const { peer, peerToken } = await fishjamClient.createPeer(created_room.id, {
metadata: { realName: 'Keanu Reeves' },
});
```
Expand Down Expand Up @@ -186,6 +211,13 @@ Simply pass the your webhook url as a `webhookUrl` parameter when creating a roo
<TabItem value="ts" label="Typescript">

```ts
import { FishjamClient } from '@fishjam-cloud/js-server-sdk';

const fishjamClient = new FishjamClient({
fishjamUrl: "https://fishjam.io",
managementToken: "bbb",
});
// ---cut---
const webhookUrl = "https://example.com/";
await fishjamClient.createRoom({ webhookUrl });
```
Expand Down Expand Up @@ -215,6 +247,9 @@ It sets up a websocket connection with a Fishjam instance and provides a simple
<TabItem value="ts" label="Typescript">

```ts
const fishjamUrl = "https://fishjam.io";
const managementToken = "bbb";
// ---cut---
import { FishjamWSNotifier } from '@fishjam-cloud/js-server-sdk';

const onClose = console.log;
Expand Down
13 changes: 11 additions & 2 deletions docs/react-native/background.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,26 @@ You need to modify `AndroidManifest.xml` file and add below service:

<TabItem value="android" label="Android">

You can use [`useForegroundService`](/api/mobile/functions/useForegroundService) hook to handle how foreground service behaves on Android.
You can use [`useForegroundService`](/api/mobile/variables/useForegroundService) hook to handle how foreground service behaves on Android.

:::important[Permissions]

If you want to use [`enableCamera`](/api/mobile/type-aliases/ForegroundServiceConfig#enablecamera) or [`enableMicrophone`](/api/mobile/type-aliases/ForegroundServiceConfig#enablemicrophone),
user must first grant permission for this resource. [`useForegroundService`](/api/mobile/functions/useForegroundService) will check if permission is
user must first grant permission for this resource. [`useForegroundService`](/api/mobile/variables/useForegroundService) will check if permission is
granted and only then allow to start a service.

:::

```tsx
import {
useForegroundService,
useCamera,
useMicrophone,
} from "@fishjam-cloud/react-native-client";

const { isCameraOn } = useCamera();
const { isMicrophoneOn } = useMicrophone();

useForegroundService({
channelId: "io.fishjam.example.fishjamchat.foregroundservice.channel",
channelName: "Fishjam Chat Notifications",
Expand Down
Loading