@fishjam-cloud/react-client 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/DeviceManager.d.ts +3 -4
  2. package/dist/DeviceManager.d.ts.map +1 -1
  3. package/dist/DeviceManager.js +25 -20
  4. package/dist/constraints.d.ts +2 -21
  5. package/dist/constraints.d.ts.map +1 -1
  6. package/dist/constraints.js +3 -7
  7. package/dist/fishjamProvider.d.ts +2 -2
  8. package/dist/fishjamProvider.d.ts.map +1 -1
  9. package/dist/fishjamProvider.js +32 -23
  10. package/dist/hooks/deviceManagers/useAudioDeviceManager.d.ts +2 -0
  11. package/dist/hooks/deviceManagers/useAudioDeviceManager.d.ts.map +1 -0
  12. package/dist/hooks/deviceManagers/useAudioDeviceManager.js +7 -0
  13. package/dist/hooks/deviceManagers/useDeviceManager.d.ts +4 -0
  14. package/dist/hooks/deviceManagers/useDeviceManager.d.ts.map +1 -0
  15. package/dist/hooks/deviceManagers/useDeviceManager.js +39 -0
  16. package/dist/hooks/deviceManagers/useVideoDeviceManager.d.ts +2 -0
  17. package/dist/hooks/deviceManagers/useVideoDeviceManager.d.ts.map +1 -0
  18. package/dist/hooks/deviceManagers/useVideoDeviceManager.js +7 -0
  19. package/dist/hooks/internal.d.ts +2 -0
  20. package/dist/hooks/internal.d.ts.map +1 -0
  21. package/dist/hooks/internal.js +1 -0
  22. package/dist/hooks/public.d.ts +8 -6
  23. package/dist/hooks/public.d.ts.map +1 -1
  24. package/dist/hooks/public.js +8 -6
  25. package/dist/hooks/useConnection.d.ts +4 -0
  26. package/dist/hooks/useConnection.d.ts.map +1 -0
  27. package/dist/hooks/useConnection.js +12 -0
  28. package/dist/hooks/useDevices.d.ts +7 -0
  29. package/dist/hooks/useDevices.d.ts.map +1 -0
  30. package/dist/hooks/useDevices.js +84 -0
  31. package/dist/hooks/useFishjamClientState.d.ts +11 -0
  32. package/dist/hooks/useFishjamClientState.d.ts.map +1 -0
  33. package/dist/hooks/{clientState.js → useFishjamClientState.js} +53 -34
  34. package/dist/hooks/useFishjamClient_DO_NOT_USE.d.ts +2 -0
  35. package/dist/hooks/useFishjamClient_DO_NOT_USE.d.ts.map +1 -0
  36. package/dist/hooks/useFishjamClient_DO_NOT_USE.js +6 -0
  37. package/dist/hooks/useFishjamContext.d.ts +20 -0
  38. package/dist/hooks/useFishjamContext.d.ts.map +1 -0
  39. package/dist/hooks/useParticipantStatus.d.ts +8 -0
  40. package/dist/hooks/useParticipantStatus.d.ts.map +1 -0
  41. package/dist/hooks/useParticipantStatus.js +39 -0
  42. package/dist/hooks/{participants.d.ts → useParticipants.d.ts} +1 -1
  43. package/dist/hooks/useParticipants.d.ts.map +1 -0
  44. package/dist/hooks/useParticipants.js +16 -0
  45. package/dist/hooks/useProcessedPreviewStream.d.ts +3 -0
  46. package/dist/hooks/useProcessedPreviewStream.d.ts.map +1 -0
  47. package/dist/hooks/useProcessedPreviewStream.js +17 -0
  48. package/dist/hooks/useReconnection.d.ts +3 -0
  49. package/dist/hooks/useReconnection.d.ts.map +1 -0
  50. package/dist/hooks/useReconnection.js +27 -0
  51. package/dist/hooks/{screenShare.d.ts → useScreenShare.d.ts} +1 -1
  52. package/dist/hooks/useScreenShare.d.ts.map +1 -0
  53. package/dist/hooks/{screenShare.js → useScreenShare.js} +49 -24
  54. package/dist/hooks/useStatus.d.ts +2 -0
  55. package/dist/hooks/useStatus.d.ts.map +1 -0
  56. package/dist/hooks/useStatus.js +4 -0
  57. package/dist/hooks/useTrackManager.d.ts +11 -0
  58. package/dist/hooks/useTrackManager.d.ts.map +1 -0
  59. package/dist/hooks/useTrackManager.js +176 -0
  60. package/dist/index.d.ts +2 -4
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +0 -1
  63. package/dist/state.types.d.ts +11 -24
  64. package/dist/state.types.d.ts.map +1 -1
  65. package/dist/types.d.ts +56 -36
  66. package/dist/types.d.ts.map +1 -1
  67. package/package.json +12 -15
  68. package/dist/Client.d.ts +0 -198
  69. package/dist/Client.d.ts.map +0 -1
  70. package/dist/Client.js +0 -461
  71. package/dist/hooks/clientState.d.ts +0 -4
  72. package/dist/hooks/clientState.d.ts.map +0 -1
  73. package/dist/hooks/connection.d.ts +0 -6
  74. package/dist/hooks/connection.d.ts.map +0 -1
  75. package/dist/hooks/connection.js +0 -28
  76. package/dist/hooks/devices.d.ts +0 -4
  77. package/dist/hooks/devices.d.ts.map +0 -1
  78. package/dist/hooks/devices.js +0 -9
  79. package/dist/hooks/fishjamContext.d.ts +0 -4
  80. package/dist/hooks/fishjamContext.d.ts.map +0 -1
  81. package/dist/hooks/participants.d.ts.map +0 -1
  82. package/dist/hooks/participants.js +0 -13
  83. package/dist/hooks/screenShare.d.ts.map +0 -1
  84. package/dist/hooks/setupMedia.d.ts +0 -3
  85. package/dist/hooks/setupMedia.d.ts.map +0 -1
  86. package/dist/hooks/setupMedia.js +0 -200
  87. package/dist/hooks/state.d.ts +0 -6
  88. package/dist/hooks/state.d.ts.map +0 -1
  89. package/dist/hooks/state.js +0 -15
  90. package/dist/trackManager.d.ts +0 -9
  91. package/dist/trackManager.d.ts.map +0 -1
  92. package/dist/trackManager.js +0 -116
  93. /package/dist/hooks/{fishjamContext.js → useFishjamContext.js} +0 -0
package/dist/Client.js DELETED
@@ -1,461 +0,0 @@
1
- import EventEmitter from "events";
2
- import { FishjamClient } from "@fishjam-cloud/ts-client";
3
- import { DeviceManager } from "./DeviceManager";
4
- import { getAvailableMedia, getCorrectedResult } from "./mediaInitializer";
5
- export class Client extends EventEmitter {
6
- tsClient;
7
- local = null;
8
- peers = {};
9
- components = {};
10
- peersTracks = {};
11
- componentsTracks = {};
12
- bandwidthEstimation = BigInt(0);
13
- status = null;
14
- media = null;
15
- devices;
16
- reconnectionStatus = "idle";
17
- videoDeviceManager;
18
- audioDeviceManager;
19
- initialized = false;
20
- constructor(config) {
21
- super();
22
- this.tsClient = new FishjamClient(config?.clientConfig);
23
- this.videoDeviceManager = new DeviceManager("video", config?.deviceManagerDefaultConfig);
24
- this.audioDeviceManager = new DeviceManager("audio", config?.deviceManagerDefaultConfig);
25
- this.devices = {
26
- camera: {
27
- status: null,
28
- stream: null,
29
- track: null,
30
- enabled: false,
31
- mediaStatus: null,
32
- deviceInfo: null,
33
- error: null,
34
- devices: null,
35
- },
36
- microphone: {
37
- status: null,
38
- stream: null,
39
- track: null,
40
- enabled: false,
41
- mediaStatus: null,
42
- deviceInfo: null,
43
- error: null,
44
- devices: null,
45
- },
46
- };
47
- this.stateToSnapshot();
48
- this.tsClient.on("disconnected", () => {
49
- this.status = null;
50
- this.stateToSnapshot();
51
- this.emit("disconnected", this);
52
- });
53
- this.tsClient.on("socketOpen", (event) => {
54
- this.status = "connected";
55
- this.stateToSnapshot();
56
- this.emit("socketOpen", event, this);
57
- });
58
- this.tsClient.on("socketError", (event) => {
59
- this.stateToSnapshot();
60
- this.emit("socketError", event, this);
61
- });
62
- this.tsClient.on("socketClose", (event) => {
63
- this.stateToSnapshot();
64
- this.emit("socketClose", event, this);
65
- });
66
- this.tsClient.on("authSuccess", () => {
67
- this.status = "authenticated";
68
- this.stateToSnapshot();
69
- this.emit("authSuccess", this);
70
- });
71
- this.tsClient.on("authError", (reason) => {
72
- this.stateToSnapshot();
73
- this.status = "error";
74
- this.emit("authError", reason, this);
75
- });
76
- this.tsClient.on("joined", (peerId, peers, components) => {
77
- this.status = "joined";
78
- this.stateToSnapshot();
79
- this.emit("joined", { peerId, peers, components }, this);
80
- });
81
- this.tsClient.on("joinError", (metadata) => {
82
- this.status = "error";
83
- this.stateToSnapshot();
84
- this.emit("joinError", metadata, this);
85
- });
86
- this.tsClient.on("reconnectionStarted", () => {
87
- this.reconnectionStatus = "reconnecting";
88
- this.stateToSnapshot();
89
- this.emit("reconnectionStarted", this);
90
- });
91
- this.tsClient.on("reconnected", () => {
92
- this.reconnectionStatus = "idle";
93
- this.stateToSnapshot();
94
- this.emit("reconnected", this);
95
- });
96
- this.tsClient.on("reconnectionRetriesLimitReached", () => {
97
- this.reconnectionStatus = "error";
98
- this.stateToSnapshot();
99
- this.emit("reconnectionRetriesLimitReached", this);
100
- });
101
- this.tsClient.on("connectionError", (metadata) => {
102
- this.status = "error";
103
- this.stateToSnapshot();
104
- this.emit("connectionError", metadata, this);
105
- });
106
- this.tsClient.on("peerJoined", (peer) => {
107
- this.stateToSnapshot();
108
- this.emit("peerJoined", peer, this);
109
- });
110
- this.tsClient.on("peerUpdated", (peer) => {
111
- this.stateToSnapshot();
112
- this.emit("peerUpdated", peer, this);
113
- });
114
- this.tsClient.on("peerLeft", (peer) => {
115
- this.stateToSnapshot();
116
- this.emit("peerLeft", peer, this);
117
- });
118
- this.tsClient.on("componentAdded", (component) => {
119
- this.stateToSnapshot();
120
- this.emit("componentAdded", component, this);
121
- });
122
- this.tsClient.on("componentUpdated", (component) => {
123
- this.stateToSnapshot();
124
- this.emit("componentUpdated", component, this);
125
- });
126
- this.tsClient.on("componentRemoved", (component) => {
127
- this.stateToSnapshot();
128
- this.emit("componentRemoved", component, this);
129
- });
130
- this.tsClient.on("trackReady", (ctx) => {
131
- this.stateToSnapshot();
132
- this.emit("trackReady", ctx, this);
133
- });
134
- this.tsClient.on("trackAdded", (ctx) => {
135
- this.stateToSnapshot();
136
- this.emit("trackAdded", ctx, this);
137
- ctx.on("encodingChanged", () => {
138
- this.stateToSnapshot();
139
- this.emit("encodingChanged", ctx, this);
140
- });
141
- ctx.on("voiceActivityChanged", () => {
142
- this.stateToSnapshot();
143
- this.emit("voiceActivityChanged", ctx, this);
144
- });
145
- });
146
- this.tsClient.on("trackRemoved", (ctx) => {
147
- this.stateToSnapshot();
148
- this.emit("trackRemoved", ctx, this);
149
- ctx.removeAllListeners();
150
- });
151
- this.tsClient.on("trackUpdated", (ctx) => {
152
- this.stateToSnapshot();
153
- this.emit("trackUpdated", ctx, this);
154
- });
155
- this.tsClient.on("bandwidthEstimationChanged", (estimation) => {
156
- this.stateToSnapshot();
157
- this.emit("bandwidthEstimationChanged", estimation, this);
158
- });
159
- this.videoDeviceManager.on("deviceDisabled", (state) => {
160
- this.stateToSnapshot();
161
- this.emit("deviceDisabled", { ...state, trackType: "video", mediaDeviceType: "userMedia" }, this);
162
- });
163
- this.videoDeviceManager.on("deviceEnabled", (state) => {
164
- this.stateToSnapshot();
165
- this.emit("deviceEnabled", { ...state, trackType: "video", mediaDeviceType: "userMedia" }, this);
166
- });
167
- this.videoDeviceManager.on("managerStarted", (state) => {
168
- this.stateToSnapshot();
169
- this.emit("managerStarted", { ...state, trackType: "video", mediaDeviceType: "userMedia" }, this);
170
- });
171
- this.videoDeviceManager.on("deviceStopped", (state) => {
172
- this.stateToSnapshot();
173
- this.emit("deviceStopped", { ...state, trackType: "video", mediaDeviceType: "userMedia" }, this);
174
- });
175
- this.videoDeviceManager.on("deviceReady", ({ stream }) => {
176
- this.stateToSnapshot();
177
- this.emit("deviceReady", { trackType: "video", stream, mediaDeviceType: "userMedia" }, this);
178
- });
179
- this.videoDeviceManager.on("devicesStarted", (event) => {
180
- this.stateToSnapshot();
181
- this.emit("devicesStarted", { ...event, trackType: "video", mediaDeviceType: "userMedia" }, this);
182
- });
183
- this.videoDeviceManager.on("devicesReady", (event) => {
184
- this.stateToSnapshot();
185
- this.emit("devicesReady", { ...event, trackType: "video", mediaDeviceType: "userMedia" }, this);
186
- });
187
- this.videoDeviceManager.on("error", (event) => {
188
- this.stateToSnapshot();
189
- this.emit("error", event, this);
190
- });
191
- this.audioDeviceManager.on("deviceDisabled", (state) => {
192
- this.stateToSnapshot();
193
- this.emit("deviceDisabled", { ...state, trackType: "audio", mediaDeviceType: "userMedia" }, this);
194
- });
195
- this.audioDeviceManager.on("deviceEnabled", (state) => {
196
- this.stateToSnapshot();
197
- this.emit("deviceEnabled", { ...state, trackType: "audio", mediaDeviceType: "userMedia" }, this);
198
- });
199
- this.audioDeviceManager.on("managerStarted", (state) => {
200
- this.stateToSnapshot();
201
- this.emit("managerStarted", { ...state, trackType: "audio", mediaDeviceType: "userMedia" }, this);
202
- });
203
- this.audioDeviceManager.on("deviceStopped", (state) => {
204
- this.stateToSnapshot();
205
- this.emit("deviceStopped", { ...state, trackType: "audio", mediaDeviceType: "userMedia" }, this);
206
- });
207
- this.audioDeviceManager.on("deviceReady", ({ stream }) => {
208
- this.stateToSnapshot();
209
- this.emit("deviceReady", { trackType: "audio", stream, mediaDeviceType: "userMedia" }, this);
210
- });
211
- this.audioDeviceManager.on("devicesStarted", (event) => {
212
- this.stateToSnapshot();
213
- this.emit("devicesStarted", { ...event, trackType: "audio", mediaDeviceType: "userMedia" }, this);
214
- });
215
- this.audioDeviceManager.on("devicesReady", (event) => {
216
- this.stateToSnapshot();
217
- this.emit("devicesReady", { ...event, trackType: "audio", mediaDeviceType: "userMedia" }, this);
218
- });
219
- this.audioDeviceManager.on("error", (event) => {
220
- this.stateToSnapshot();
221
- this.emit("error", event, this);
222
- });
223
- this.tsClient?.on("targetTrackEncodingRequested", (event) => {
224
- this.stateToSnapshot();
225
- this.emit("targetTrackEncodingRequested", event, this);
226
- });
227
- this.tsClient?.on("localTrackAdded", (event) => {
228
- this.stateToSnapshot();
229
- this.emit("localTrackAdded", event, this);
230
- });
231
- this.tsClient?.on("localTrackRemoved", (event) => {
232
- this.stateToSnapshot();
233
- this.emit("localTrackRemoved", event, this);
234
- });
235
- this.tsClient?.on("localTrackReplaced", (event) => {
236
- this.stateToSnapshot();
237
- this.emit("localTrackReplaced", event, this);
238
- });
239
- this.tsClient?.on("localTrackMuted", (event) => {
240
- this.stateToSnapshot();
241
- this.emit("localTrackMuted", event, this);
242
- });
243
- this.tsClient?.on("localTrackUnmuted", (event) => {
244
- this.stateToSnapshot();
245
- this.emit("localTrackUnmuted", event, this);
246
- });
247
- this.tsClient?.on("localTrackBandwidthSet", (event) => {
248
- this.stateToSnapshot();
249
- this.emit("localTrackBandwidthSet", event, this);
250
- });
251
- this.tsClient?.on("localTrackEncodingBandwidthSet", (event) => {
252
- this.stateToSnapshot();
253
- this.emit("localTrackEncodingBandwidthSet", event, this);
254
- });
255
- this.tsClient?.on("localTrackEncodingEnabled", (event) => {
256
- this.stateToSnapshot();
257
- this.emit("localTrackEncodingEnabled", event, this);
258
- });
259
- this.tsClient?.on("localTrackEncodingDisabled", (event) => {
260
- this.stateToSnapshot();
261
- this.emit("localTrackEncodingDisabled", event, this);
262
- });
263
- this.tsClient?.on("localPeerMetadataChanged", (event) => {
264
- this.stateToSnapshot();
265
- this.emit("localPeerMetadataChanged", event, this);
266
- });
267
- this.tsClient?.on("localTrackMetadataChanged", (event) => {
268
- this.stateToSnapshot();
269
- this.emit("localTrackMetadataChanged", event, this);
270
- });
271
- this.tsClient?.on("disconnectRequested", (event) => {
272
- this.stateToSnapshot();
273
- this.emit("disconnectRequested", event, this);
274
- });
275
- }
276
- setDeviceManagerConfig(config) {
277
- this.videoDeviceManager.setConfig(config.storage, config.trackConstraints);
278
- this.audioDeviceManager.setConfig(config.storage, config.trackConstraints);
279
- }
280
- trackContextToTrack(track) {
281
- return {
282
- rawMetadata: track.rawMetadata,
283
- metadata: track.metadata,
284
- trackId: track.trackId,
285
- stream: track.stream,
286
- simulcastConfig: track.simulcastConfig || null,
287
- encoding: track.encoding || null,
288
- vadStatus: track.vadStatus,
289
- track: track.track,
290
- metadataParsingError: track.metadataParsingError,
291
- };
292
- }
293
- getTsClient = () => this.tsClient;
294
- connect(config) {
295
- this.status = "connecting";
296
- this.tsClient.connect({ ...config, peerMetadata: config?.peerMetadata ?? {} });
297
- }
298
- disconnect() {
299
- this.status = null;
300
- this.tsClient.disconnect();
301
- }
302
- addTrack(track, simulcastConfig = { enabled: false, activeEncodings: [], disabledEncodings: [] }, maxBandwidth = 0) {
303
- return this.tsClient.addTrack(track, undefined, simulcastConfig, maxBandwidth);
304
- }
305
- removeTrack(trackId) {
306
- return this.tsClient.removeTrack(trackId);
307
- }
308
- replaceTrack(trackId, newTrack) {
309
- return this.tsClient.replaceTrack(trackId, newTrack);
310
- }
311
- getStatistics(selector) {
312
- return this.tsClient.getStatistics(selector);
313
- }
314
- getBandwidthEstimation() {
315
- return this.tsClient.getBandwidthEstimation();
316
- }
317
- setTrackBandwidth(trackId, bandwidth) {
318
- return this.tsClient.setTrackBandwidth(trackId, bandwidth);
319
- }
320
- setEncodingBandwidth(trackId, rid, bandwidth) {
321
- return this.tsClient.setEncodingBandwidth(trackId, rid, bandwidth);
322
- }
323
- setTargetTrackEncoding(trackId, encoding) {
324
- return this.tsClient.setTargetTrackEncoding(trackId, encoding);
325
- }
326
- enableTrackEncoding(trackId, encoding) {
327
- return this.tsClient.enableTrackEncoding(trackId, encoding);
328
- }
329
- disableTrackEncoding(trackId, encoding) {
330
- return this.tsClient.disableTrackEncoding(trackId, encoding);
331
- }
332
- isReconnecting = () => {
333
- return this.tsClient.isReconnecting();
334
- };
335
- initializeDevices = async (config) => {
336
- // This function should be called only once.
337
- // Any subsequent calls to this function will be ignored.
338
- if (this.initialized)
339
- return;
340
- this.initialized = true;
341
- const constraints = {
342
- video: this.videoDeviceManager.getConstraints(config?.videoTrackConstraints),
343
- audio: this.audioDeviceManager.getConstraints(config?.audioTrackConstraints),
344
- };
345
- const previousDevices = {
346
- video: this.videoDeviceManager.getLastDevice(),
347
- audio: this.audioDeviceManager.getLastDevice(),
348
- };
349
- let [stream, deviceErrors] = await getAvailableMedia(constraints);
350
- const devices = await navigator.mediaDevices.enumerateDevices();
351
- const videoDevices = devices.filter(({ kind }) => kind === "videoinput");
352
- const audioDevices = devices.filter(({ kind }) => kind === "audioinput");
353
- if (stream) {
354
- [stream, deviceErrors] = await getCorrectedResult(stream, deviceErrors, devices, constraints, previousDevices);
355
- }
356
- const state = {
357
- video: this.videoDeviceManager.initialize(stream, stream?.getVideoTracks()?.[0] ?? null, videoDevices, !!constraints.video, deviceErrors.video),
358
- audio: this.audioDeviceManager.initialize(stream, stream?.getAudioTracks()?.[0] ?? null, audioDevices, !!constraints.audio, deviceErrors.audio),
359
- };
360
- this.stateToSnapshot();
361
- this.emit("managerInitialized", state, this);
362
- };
363
- startDevices = async (config) => {
364
- this.videoDeviceManager.start(config?.videoDeviceId);
365
- this.audioDeviceManager.start(config?.audioDeviceId);
366
- };
367
- stateToSnapshot() {
368
- const deviceManagerSnapshot = {
369
- audio: this?.audioDeviceManager?.deviceState,
370
- video: this?.videoDeviceManager?.deviceState,
371
- };
372
- const localEndpoint = this.tsClient.getLocalPeer();
373
- const localTracks = {};
374
- (localEndpoint?.tracks || new Map()).forEach((track) => {
375
- localTracks[track.trackId] = this.trackContextToTrack(track);
376
- });
377
- const devices = {
378
- camera: {
379
- status: deviceManagerSnapshot?.video?.devicesStatus || null,
380
- stream: deviceManagerSnapshot?.video.media?.stream || null,
381
- track: deviceManagerSnapshot?.video.media?.track || null,
382
- enabled: deviceManagerSnapshot?.video.media?.enabled || false,
383
- deviceInfo: deviceManagerSnapshot?.video.media?.deviceInfo || null,
384
- mediaStatus: deviceManagerSnapshot?.video.mediaStatus || null,
385
- error: deviceManagerSnapshot?.video?.error || null,
386
- devices: deviceManagerSnapshot?.video?.devices || null,
387
- },
388
- microphone: {
389
- status: deviceManagerSnapshot?.audio?.devicesStatus || null,
390
- stream: deviceManagerSnapshot?.audio.media?.stream || null,
391
- track: deviceManagerSnapshot?.audio.media?.track || null,
392
- enabled: deviceManagerSnapshot?.audio.media?.enabled || false,
393
- deviceInfo: deviceManagerSnapshot?.audio.media?.deviceInfo || null,
394
- mediaStatus: deviceManagerSnapshot?.video.mediaStatus || null,
395
- error: deviceManagerSnapshot?.audio?.error || null,
396
- devices: deviceManagerSnapshot?.audio?.devices || null,
397
- },
398
- };
399
- if (!this.tsClient["webrtc"]) {
400
- this.media = deviceManagerSnapshot || null;
401
- this.peersTracks = {};
402
- this.componentsTracks = {};
403
- this.devices = devices;
404
- this.peers = {};
405
- this.components = {};
406
- this.local = null;
407
- this.bandwidthEstimation = 0n;
408
- return;
409
- }
410
- const peers = {};
411
- const components = {};
412
- const peersTracks = {};
413
- const componentTracks = {};
414
- Object.values(this.tsClient.getRemotePeers()).forEach((remotePeer) => {
415
- const tracks = {};
416
- remotePeer.tracks.forEach((track) => {
417
- const mappedTrack = this.trackContextToTrack(track);
418
- tracks[track.trackId] = mappedTrack;
419
- peersTracks[track.trackId] = { ...mappedTrack, origin: remotePeer };
420
- });
421
- peers[remotePeer.id] = {
422
- rawMetadata: remotePeer.rawMetadata,
423
- metadata: remotePeer.metadata,
424
- metadataParsingError: remotePeer.metadataParsingError,
425
- id: remotePeer.id,
426
- tracks,
427
- };
428
- });
429
- Object.values(this.tsClient.getRemoteComponents()).forEach((remotePeer) => {
430
- const tracks = {};
431
- remotePeer.tracks.forEach((track) => {
432
- const mappedTrack = this.trackContextToTrack(track);
433
- tracks[track.trackId] = mappedTrack;
434
- componentTracks[track.trackId] = { ...mappedTrack, origin: remotePeer };
435
- });
436
- components[remotePeer.id] = {
437
- rawMetadata: remotePeer.rawMetadata,
438
- metadata: remotePeer.metadata,
439
- metadataParsingError: remotePeer.metadataParsingError,
440
- id: remotePeer.id,
441
- tracks,
442
- };
443
- });
444
- this.peersTracks = peersTracks;
445
- this.componentsTracks = componentTracks;
446
- this.media = deviceManagerSnapshot || null;
447
- this.local = localEndpoint
448
- ? {
449
- id: localEndpoint.id,
450
- metadata: localEndpoint.metadata,
451
- metadataParsingError: localEndpoint.metadataParsingError,
452
- rawMetadata: localEndpoint.rawMetadata,
453
- tracks: localTracks, // to record
454
- }
455
- : null;
456
- this.peers = peers;
457
- this.components = components;
458
- this.bandwidthEstimation = this.tsClient.getBandwidthEstimation();
459
- this.devices = devices;
460
- }
461
- }
@@ -1,4 +0,0 @@
1
- import type { State } from "../state.types";
2
- import type { Client } from "../Client";
3
- export declare const useClientState: (client: Client) => State;
4
- //# sourceMappingURL=clientState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientState.d.ts","sourceRoot":"","sources":["../../src/hooks/clientState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAmDxC,eAAO,MAAM,cAAc,WAAY,MAAM,UAwC5C,CAAC"}
@@ -1,6 +0,0 @@
1
- import type { UseConnect } from "../types";
2
- import type { UseReconnection } from "../state.types";
3
- export declare function useConnect(): UseConnect;
4
- export declare function useDisconnect(): () => void;
5
- export declare function useReconnection(): UseReconnection;
6
- //# sourceMappingURL=connection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/hooks/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,UAAU,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,wBAAgB,UAAU,IAAI,UAAU,CAWvC;AAED,wBAAgB,aAAa,eAM5B;AAED,wBAAgB,eAAe,IAAI,eAAe,CASjD"}
@@ -1,28 +0,0 @@
1
- import { useFishjamContext } from "./fishjamContext";
2
- import { useCallback, useMemo } from "react";
3
- export function useConnect() {
4
- const { state } = useFishjamContext();
5
- return useMemo(() => {
6
- return (config) => {
7
- state.client.connect(config);
8
- return () => {
9
- state.client.disconnect();
10
- };
11
- };
12
- }, [state.client]);
13
- }
14
- export function useDisconnect() {
15
- const { state } = useFishjamContext();
16
- return useCallback(() => {
17
- state.client.disconnect();
18
- }, [state.client]);
19
- }
20
- export function useReconnection() {
21
- const { state } = useFishjamContext();
22
- return {
23
- status: state.reconnectionStatus,
24
- isReconnecting: state.reconnectionStatus === "reconnecting",
25
- isError: state.reconnectionStatus === "error",
26
- isIdle: state.reconnectionStatus === "idle",
27
- };
28
- }
@@ -1,4 +0,0 @@
1
- import type { UserMediaAPI, TrackManager } from "../types";
2
- export declare function useCamera(): UserMediaAPI & TrackManager;
3
- export declare function useMicrophone(): UserMediaAPI & TrackManager;
4
- //# sourceMappingURL=devices.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["../../src/hooks/devices.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE3D,wBAAgB,SAAS,IAAI,YAAY,GAAG,YAAY,CAGvD;AAED,wBAAgB,aAAa,IAAI,YAAY,GAAG,YAAY,CAG3D"}
@@ -1,9 +0,0 @@
1
- import { useFishjamContext } from "./fishjamContext";
2
- export function useCamera() {
3
- const { state, videoTrackManager } = useFishjamContext();
4
- return { ...state.devices.camera, ...videoTrackManager };
5
- }
6
- export function useMicrophone() {
7
- const { state, audioTrackManager } = useFishjamContext();
8
- return { ...state.devices.microphone, ...audioTrackManager };
9
- }
@@ -1,4 +0,0 @@
1
- import type { FishjamContextType } from "../types";
2
- export declare const FishjamContext: import("react").Context<FishjamContextType | null>;
3
- export declare function useFishjamContext(): FishjamContextType;
4
- //# sourceMappingURL=fishjamContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fishjamContext.d.ts","sourceRoot":"","sources":["../../src/hooks/fishjamContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,eAAO,MAAM,cAAc,oDAAiD,CAAC;AAE7E,wBAAgB,iBAAiB,IAGb,kBAAkB,CACrC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"participants.d.ts","sourceRoot":"","sources":["../../src/hooks/participants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAWpD,wBAAgB,eAAe;;;EAQ9B"}
@@ -1,13 +0,0 @@
1
- import { useFishjamContext } from "./fishjamContext";
2
- function getPeerWithDistinguishedTracks(peerState) {
3
- const localTracks = Object.values(peerState.tracks ?? {});
4
- const videoTracks = localTracks.filter(({ track }) => track?.kind === "video");
5
- const audioTracks = localTracks.filter(({ track }) => track?.kind === "audio");
6
- return { ...peerState, videoTracks, audioTracks };
7
- }
8
- export function useParticipants() {
9
- const { state } = useFishjamContext();
10
- const localParticipant = state.local ? getPeerWithDistinguishedTracks(state.local) : null;
11
- const participants = Object.values(state.remote).map(getPeerWithDistinguishedTracks);
12
- return { localParticipant, participants };
13
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"screenShare.d.ts","sourceRoot":"","sources":["../../src/hooks/screenShare.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,UAAU,CAAC;AAUjE,eAAO,MAAM,cAAc,QAAO,cAwGjC,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { UseSetupMediaConfig, UseSetupMediaResult } from "../types";
2
- export declare const useSetupMedia: (config: UseSetupMediaConfig) => UseSetupMediaResult;
3
- //# sourceMappingURL=setupMedia.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setupMedia.d.ts","sourceRoot":"","sources":["../../src/hooks/setupMedia.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAYzE,eAAO,MAAM,aAAa,WAAY,mBAAmB,KAAG,mBA6O3D,CAAC"}