Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit da383e8

Browse files
Update react client sdk (#76)
1 parent 0c77ed7 commit da383e8

8 files changed

+264
-260
lines changed

package-lock.json

+232-219
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,50 @@
1717
"lint:check": "eslint . --ext .ts,.tsx"
1818
},
1919
"dependencies": {
20-
"@jellyfish-dev/react-client-sdk": "^0.1.9",
20+
"@jellyfish-dev/react-client-sdk": "^0.2.0",
2121
"@types/chartist": "^1.0.0",
2222
"@types/ramda": "^0.29.10",
2323
"axios": "^1.6.7",
2424
"chartist": "^1.3.0",
2525
"clsx": "^2.1.0",
2626
"daisyui": "^3.9.4",
2727
"events": "^3.3.0",
28-
"hls.js": "^1.5.3",
29-
"jotai": "^2.6.3",
28+
"hls.js": "^1.5.7",
29+
"jotai": "^2.7.0",
3030
"lodash.isequal": "^4.5.0",
31-
"phoenix": "^1.7.10",
31+
"phoenix": "^1.7.11",
3232
"qrcode.react": "^3.1.0",
33-
"rambda": "^9.0.1",
33+
"rambda": "^9.1.0",
3434
"ramda": "^0.29.1",
3535
"react": "^18.2.0",
3636
"react-dom": "^18.2.0",
3737
"react-hot-toast": "^2.4.1",
3838
"react-icons": "^5.0.1",
39-
"react-router-dom": "^6.21.3",
39+
"react-router-dom": "^6.22.2",
4040
"uuid": "^9.0.1",
41-
"vite-plugin-mkcert": "^1.17.3"
41+
"vite-plugin-mkcert": "^1.17.4"
4242
},
4343
"devDependencies": {
4444
"@openapitools/openapi-generator-cli": "^2.9.0",
4545
"@types/events": "^3.0.3",
4646
"@types/lodash.isequal": "^4.5.8",
4747
"@types/phoenix": "^1.6.4",
48-
"@types/react": "^18.2.48",
49-
"@types/react-dom": "^18.2.18",
48+
"@types/react": "^18.2.60",
49+
"@types/react-dom": "^18.2.19",
5050
"@types/uuid": "^9.0.8",
51-
"@typescript-eslint/eslint-plugin": "^6.20.0",
51+
"@typescript-eslint/eslint-plugin": "^7.1.0",
5252
"@vitejs/plugin-react": "^4.2.1",
5353
"autoprefixer": "^10.4.17",
54-
"eslint": "^8.56.0",
54+
"eslint": "^8.57.0",
5555
"eslint-config-prettier": "^9.1.0",
5656
"eslint-plugin-react-hooks": "^4.6.0",
57-
"postcss": "^8.4.33",
58-
"prettier": "3.2.4",
57+
"postcss": "^8.4.35",
58+
"prettier": "3.2.5",
5959
"tailwindcss": "^3.4.1",
60-
"ts-proto": "^1.167.2",
60+
"ts-proto": "^1.167.9",
6161
"typed-emitter": "^2.1.0",
6262
"typescript": "5.3.3",
63-
"vite": "^5.0.12",
64-
"vite-plugin-checker": "^0.6.2"
63+
"vite": "^5.1.4",
64+
"vite-plugin-checker": "^0.6.4"
6565
}
6666
}

src/containers/Client.tsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { DeviceInfo, StreamingSettingsCard } from "./StreamingSettingsCard";
1919
import { checkJSON } from "./StreamingSettingsPanel";
2020
import { atomFamily, atomWithStorage } from "jotai/utils";
2121
import { useSetAtom } from "jotai";
22-
import { TrackMetadata } from "../jellyfish.types";
2322
import { ComponentOptionsHLSSubscribeModeEnum } from "../server-sdk";
2423

2524
type ClientProps = {
@@ -63,7 +62,7 @@ export type LocalTrack = {
6362

6463
export type TrackId = string;
6564
export const trackMetadataAtomFamily = atomFamily((clientId) =>
66-
atomWithStorage<Record<TrackId, TrackMetadata> | null>(`track-metadata-${clientId}`, null),
65+
atomWithStorage<Record<TrackId, unknown> | null>(`track-metadata-${clientId}`, null),
6766
);
6867

6968
const prepareHlsButtonMessage = (hlsMode?: ComponentOptionsHLSSubscribeModeEnum): string | null => {
@@ -215,19 +214,23 @@ export const Client = ({
215214
};
216215
const setUserTracksMetadata = useSetAtom(trackMetadataAtomFamily(id));
217216

218-
const addVideoTrack = (trackInfo: DeviceInfo) => {
217+
const addVideoTrack = async (trackInfo: DeviceInfo) => {
219218
const track: MediaStreamTrack = trackInfo.stream?.getVideoTracks()[0];
220219
if (!trackInfo.stream || !track) return;
221220

222221
const metadata = attachMetadata
223222
? JSON.parse(trackMetadata?.trim() || createDefaultTrackMetadata(trackInfo.type))
224223
: undefined;
225224

226-
const trackId = api?.addTrack(
225+
const trackId = await api?.addTrack(
227226
track,
228227
trackInfo.stream,
229228
metadata,
230-
{ enabled: trackInfo.type === "video" && simulcastTransfer, activeEncodings: currentEncodings },
229+
{
230+
enabled: trackInfo.type === "video" && simulcastTransfer,
231+
activeEncodings: currentEncodings,
232+
disabledEncodings: [],
233+
},
231234
parseInt(maxBandwidth || "0") || undefined,
232235
);
233236
dispatch({
@@ -245,10 +248,10 @@ export const Client = ({
245248
}));
246249
};
247250

248-
const addAudioTrack = (trackInfo: DeviceInfo) => {
251+
const addAudioTrack = async (trackInfo: DeviceInfo) => {
249252
const track: MediaStreamTrack = trackInfo.stream?.getAudioTracks()[0];
250253
if (!trackInfo.stream || !track) return;
251-
const trackId = api?.addTrack(
254+
const trackId = await api?.addTrack(
252255
track,
253256
trackInfo.stream,
254257
attachMetadata ? JSON.parse(trackMetadata?.trim() || createDefaultTrackMetadata(trackInfo.type)) : undefined,

src/containers/ReceivedTrackPanel.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { JsonComponent } from "../components/JsonComponent";
2-
import { TrackMetadata } from "../jellyfish.types";
32
import { useState } from "react";
43
import { SimulcastConfig, TrackEncoding } from "@jellyfish-dev/react-client-sdk";
54
import { CopyToClipboardButton } from "../components/CopyButton";
@@ -14,7 +13,7 @@ type TrackPanelProps = {
1413
clientId: string;
1514
trackId: string;
1615
stream: MediaStream | null;
17-
trackMetadata: TrackMetadata | null;
16+
trackMetadata: unknown | undefined;
1817
changeEncodingReceived: (trackId: string, encoding: TrackEncoding) => void;
1918
vadStatus: string | null;
2019
encodingReceived: TrackEncoding | null;

src/containers/RoomsContext.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { createContext, ReactNode, useContext, useReducer } from "react";
22
import { groupBy } from "rambda";
33
import { Peer as PeerApi, Room as RoomAPI } from "../server-sdk";
44
import { create, CreateJellyfishClient } from "@jellyfish-dev/react-client-sdk/experimental";
5-
import { PeerMetadata, TrackMetadata } from "../jellyfish.types";
65
import { LocalTrack } from "./Client";
76

87
export type RoomContext = {
@@ -19,7 +18,7 @@ type Props = {
1918
export type PeerState = {
2019
id: string;
2120
peerStatus: PeerApi;
22-
client: CreateJellyfishClient<PeerMetadata, TrackMetadata>;
21+
client: CreateJellyfishClient<unknown, unknown>;
2322
tracks: Record<string, LocalTrack>;
2423
};
2524

@@ -119,7 +118,7 @@ const roomReducer: Reducer = (state, action) => {
119118
const peersList: PeerState[] = action.room.peers.map((peer) => ({
120119
id: peer.id,
121120
peerStatus: peer,
122-
client: prevPeers?.[peer.id]?.client || create<PeerMetadata, TrackMetadata>(),
121+
client: prevPeers?.[peer.id]?.client || create<unknown, unknown>(),
123122
tracks: prevPeers?.[peer.id]?.tracks || [],
124123
}));
125124

src/containers/StreamedTrackCard.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Track } from "@jellyfish-dev/react-client-sdk";
22
import { CloseButton } from "../components/CloseButton";
3-
import { TrackMetadata } from "../jellyfish.types";
43
import { LocalTrack, trackMetadataAtomFamily } from "./Client";
54
import VideoPlayer from "../components/VideoPlayer";
65
import { JsonComponent } from "../components/JsonComponent";
@@ -18,7 +17,7 @@ type StreamedTrackCardProps = {
1817
roomId: string;
1918
peerId: string;
2019
trackMetadata: string;
21-
allTracks: Record<string, Track<TrackMetadata>> | undefined;
20+
allTracks: Record<string, Track<unknown>> | undefined;
2221
removeTrack: (trackId: string) => void;
2322
simulcastTransfer: boolean;
2423
changeEncoding: (trackId: string, encoding: TrackEncoding, desiredState: boolean) => void;

src/jellyfish.types.ts

-9
This file was deleted.

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
1616
"noEmit": true,
17-
"jsx": "react-jsx",
17+
"jsx": "react-jsx"
1818
},
1919
"include": ["./src"],
20-
"references": [{ "path": "./tsconfig.node.json" }],
20+
"references": [{ "path": "./tsconfig.node.json" }]
2121
}

0 commit comments

Comments
 (0)