@stream-io/video-client 0.2.3 → 0.3.1

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 (71) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.browser.es.js +982 -675
  3. package/dist/index.browser.es.js.map +1 -1
  4. package/dist/index.cjs.js +984 -673
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.es.js +982 -675
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/src/Call.d.ts +21 -9
  9. package/dist/src/StreamVideoClient.d.ts +3 -1
  10. package/dist/src/devices/CameraManager.d.ts +31 -0
  11. package/dist/src/devices/CameraManagerState.d.ts +28 -0
  12. package/dist/src/devices/InputMediaDeviceManager.d.ts +47 -0
  13. package/dist/src/devices/InputMediaDeviceManagerState.d.ts +69 -0
  14. package/dist/src/devices/MicrophoneManager.d.ts +19 -0
  15. package/dist/src/devices/MicrophoneManagerState.d.ts +4 -0
  16. package/dist/src/devices/__tests__/mocks.d.ts +13 -0
  17. package/dist/src/devices/index.d.ts +4 -0
  18. package/dist/src/events/call-permissions.d.ts +0 -5
  19. package/dist/src/events/call.d.ts +0 -6
  20. package/dist/src/events/index.d.ts +0 -6
  21. package/dist/src/rtc/Dispatcher.d.ts +2 -2
  22. package/dist/src/rtc/Publisher.d.ts +0 -1
  23. package/dist/src/store/CallState.d.ts +164 -89
  24. package/dist/src/types.d.ts +5 -7
  25. package/dist/version.d.ts +1 -1
  26. package/package.json +1 -1
  27. package/src/Call.ts +130 -44
  28. package/src/StreamVideoClient.ts +14 -17
  29. package/src/__tests__/StreamVideoClient.test.ts +3 -0
  30. package/src/devices/CameraManager.ts +73 -0
  31. package/src/devices/CameraManagerState.ts +61 -0
  32. package/src/devices/InputMediaDeviceManager.ts +121 -0
  33. package/src/devices/InputMediaDeviceManagerState.ts +111 -0
  34. package/src/devices/MicrophoneManager.ts +45 -0
  35. package/src/devices/MicrophoneManagerState.ts +9 -0
  36. package/src/devices/__tests__/CameraManager.test.ts +150 -0
  37. package/src/devices/__tests__/InputMediaDeviceManager.test.ts +159 -0
  38. package/src/devices/__tests__/MicrophoneManager.test.ts +103 -0
  39. package/src/devices/__tests__/mocks.ts +98 -0
  40. package/src/devices/index.ts +4 -0
  41. package/src/events/__tests__/call-permissions.test.ts +1 -61
  42. package/src/events/__tests__/call.test.ts +5 -50
  43. package/src/events/call-permissions.ts +0 -14
  44. package/src/events/call.ts +5 -16
  45. package/src/events/callEventHandlers.ts +2 -57
  46. package/src/events/index.ts +0 -6
  47. package/src/rtc/Dispatcher.ts +2 -2
  48. package/src/rtc/Publisher.ts +4 -6
  49. package/src/store/CallState.ts +475 -119
  50. package/src/store/__tests__/CallState.test.ts +447 -1
  51. package/src/types.ts +4 -8
  52. package/dist/src/events/__tests__/sessions.test.d.ts +0 -1
  53. package/dist/src/events/backstage.d.ts +0 -6
  54. package/dist/src/events/members.d.ts +0 -18
  55. package/dist/src/events/moderation.d.ts +0 -14
  56. package/dist/src/events/reactions.d.ts +0 -8
  57. package/dist/src/events/recording.d.ts +0 -18
  58. package/dist/src/events/sessions.d.ts +0 -26
  59. package/src/events/__tests__/backstage.test.ts +0 -15
  60. package/src/events/__tests__/members.test.ts +0 -135
  61. package/src/events/__tests__/recording.test.ts +0 -65
  62. package/src/events/__tests__/sessions.test.ts +0 -135
  63. package/src/events/backstage.ts +0 -15
  64. package/src/events/members.ts +0 -62
  65. package/src/events/moderation.ts +0 -35
  66. package/src/events/reactions.ts +0 -30
  67. package/src/events/recording.ts +0 -64
  68. package/src/events/sessions.ts +0 -102
  69. /package/dist/src/{events/__tests__/backstage.test.d.ts → devices/__tests__/CameraManager.test.d.ts} +0 -0
  70. /package/dist/src/{events/__tests__/members.test.d.ts → devices/__tests__/InputMediaDeviceManager.test.d.ts} +0 -0
  71. /package/dist/src/{events/__tests__/recording.test.d.ts → devices/__tests__/MicrophoneManager.test.d.ts} +0 -0
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
2
2
  import type { Patch } from './rxUtils';
3
3
  import { StreamVideoLocalParticipant, StreamVideoParticipant, StreamVideoParticipantPatch, StreamVideoParticipantPatches } from '../types';
4
4
  import { CallStatsReport } from '../stats/types';
5
- import { CallRecording, CallResponse, MemberResponse, OwnCapability } from '../gen/coordinator';
5
+ import { CallIngressResponse, CallResponse, CallSessionResponse, CallSettingsResponse, EgressResponse, MemberResponse, OwnCapability, UserResponse, VideoEvent } from '../gen/coordinator';
6
6
  import { Pin } from '../gen/video/sfu/models/models';
7
7
  import { Comparator } from '../sorting';
8
8
  import { Logger } from '../coordinator/connection/types';
@@ -57,71 +57,29 @@ export declare enum CallingState {
57
57
  * @react You don't have to use this class directly, as we are exposing the state through Hooks.
58
58
  */
59
59
  export declare class CallState {
60
- /**
61
- * The raw call metadata object, as defined on the backend.
62
- *
63
- * @internal
64
- */
65
- private metadataSubject;
66
- /**
67
- * The list of members of the current call.
68
- *
69
- * @internal
70
- */
60
+ private backstageSubject;
61
+ private blockedUserIdsSubject;
62
+ private createdAtSubject;
63
+ private endedAtSubject;
64
+ private startsAtSubject;
65
+ private updatedAtSubject;
66
+ private createdBySubject;
67
+ private customSubject;
68
+ private egressSubject;
69
+ private ingressSubject;
70
+ private recordingSubject;
71
+ private sessionSubject;
72
+ private settingsSubject;
73
+ private transcribingSubject;
74
+ private endedBySubject;
71
75
  private membersSubject;
72
- /**
73
- * The list of capabilities of the current user.
74
- *
75
- * @private
76
- */
77
76
  private ownCapabilitiesSubject;
78
- /**
79
- * The calling state.
80
- *
81
- * @internal
82
- */
83
77
  private callingStateSubject;
84
- /**
85
- * The time the call session actually started.
86
- *
87
- * @internal
88
- */
89
78
  private startedAtSubject;
90
- /**
91
- * The server-side counted number of participants connected to the current call.
92
- * This number includes the anonymous participants as well.
93
- *
94
- * @internal
95
- */
96
79
  private participantCountSubject;
97
- /**
98
- * The server-side counted number of anonymous participants connected to the current call.
99
- * This number excludes the regular participants.
100
- *
101
- * @internal
102
- */
103
80
  private anonymousParticipantCountSubject;
104
- /**
105
- * All participants of the current call (including the logged-in user).
106
- *
107
- * @internal
108
- */
109
81
  private participantsSubject;
110
- /**
111
- * The latest stats report of the current call.
112
- * When stats gathering is enabled, this observable will emit a new value
113
- * at a regular (configurable) interval.
114
- *
115
- * Consumers of this observable can implement their own batching logic
116
- * in case they want to show historical stat data.
117
- *
118
- * @internal
119
- */
120
82
  private callStatsReportSubject;
121
- /**
122
- * Emits a list of details about recordings performed for the current call.
123
- */
124
- private callRecordingListSubject;
125
83
  /**
126
84
  * The time the call session actually started.
127
85
  * Useful for displaying the call duration.
@@ -176,14 +134,6 @@ export declare class CallState {
176
134
  * in case they want to show historical stats data.
177
135
  */
178
136
  callStatsReport$: Observable<CallStatsReport | undefined>;
179
- /**
180
- * Emits a list of details about recordings performed for the current call
181
- */
182
- callRecordingList$: Observable<CallRecording[]>;
183
- /**
184
- * The raw call metadata object, as defined on the backend.
185
- */
186
- metadata$: Observable<CallResponse | undefined>;
187
137
  /**
188
138
  * The list of members in the current call.
189
139
  */
@@ -196,6 +146,66 @@ export declare class CallState {
196
146
  * The calling state.
197
147
  */
198
148
  callingState$: Observable<CallingState>;
149
+ /**
150
+ * The backstage state.
151
+ */
152
+ backstage$: Observable<boolean>;
153
+ /**
154
+ * Will provide the list of blocked user IDs.
155
+ */
156
+ blockedUserIds$: Observable<string[]>;
157
+ /**
158
+ * Will provide the time when this call has been created.
159
+ */
160
+ createdAt$: Observable<Date>;
161
+ /**
162
+ * Will provide the time when this call has been ended.
163
+ */
164
+ endedAt$: Observable<Date | undefined>;
165
+ /**
166
+ * Will provide the time when this call has been scheduled to start.
167
+ */
168
+ startsAt$: Observable<Date | undefined>;
169
+ /**
170
+ * Will provide the time when this call has been updated.
171
+ */
172
+ updatedAt$: Observable<Date>;
173
+ /**
174
+ * Will provide the user who created this call.
175
+ */
176
+ createdBy$: Observable<UserResponse | undefined>;
177
+ /**
178
+ * Will provide the custom data of this call.
179
+ */
180
+ custom$: Observable<Record<string, any>>;
181
+ /**
182
+ * Will provide the egress data of this call.
183
+ */
184
+ egress$: Observable<EgressResponse | undefined>;
185
+ /**
186
+ * Will provide the ingress data of this call.
187
+ */
188
+ ingress$: Observable<CallIngressResponse | undefined>;
189
+ /**
190
+ * Will provide the recording state of this call.
191
+ */
192
+ recording$: Observable<boolean>;
193
+ /**
194
+ * Will provide the session data of this call.
195
+ */
196
+ session$: Observable<CallSessionResponse | undefined>;
197
+ /**
198
+ * Will provide the settings of this call.
199
+ */
200
+ settings$: Observable<CallSettingsResponse | undefined>;
201
+ /**
202
+ * Will provide the transcribing state of this call.
203
+ */
204
+ transcribing$: Observable<boolean>;
205
+ /**
206
+ * Will provide the user who ended this call.
207
+ */
208
+ endedBy$: Observable<UserResponse | undefined>;
199
209
  readonly logger: Logger;
200
210
  /**
201
211
  * A list of comparators that are used to sort the participants.
@@ -203,6 +213,7 @@ export declare class CallState {
203
213
  * @private
204
214
  */
205
215
  private sortParticipantsBy;
216
+ private readonly eventHandlers;
206
217
  /**
207
218
  * Creates a new instance of the CallState class.
208
219
  *
@@ -313,17 +324,6 @@ export declare class CallState {
313
324
  * @param state the new calling state.
314
325
  */
315
326
  setCallingState: (state: Patch<CallingState>) => CallingState;
316
- /**
317
- * The list of call recordings.
318
- */
319
- get callRecordingsList(): CallRecording[];
320
- /**
321
- * Sets the list of call recordings.
322
- *
323
- * @internal
324
- * @param recordings the list of call recordings.
325
- */
326
- setCallRecordingsList: (recordings: Patch<CallRecording[]>) => CallRecording[];
327
327
  /**
328
328
  * The call stats report.
329
329
  */
@@ -335,18 +335,6 @@ export declare class CallState {
335
335
  * @param report the report to set.
336
336
  */
337
337
  setCallStatsReport: (report: Patch<CallStatsReport | undefined>) => CallStatsReport | undefined;
338
- /**
339
- * The metadata of the current call.
340
- */
341
- get metadata(): CallResponse | undefined;
342
- /**
343
- * Sets the metadata of the current call.
344
- *
345
- * @internal
346
- *
347
- * @param metadata the metadata to set.
348
- */
349
- setMetadata: (metadata: Patch<CallResponse | undefined>) => CallResponse | undefined;
350
338
  /**
351
339
  * The members of the current call.
352
340
  */
@@ -369,6 +357,66 @@ export declare class CallState {
369
357
  * @param capabilities the capabilities to set.
370
358
  */
371
359
  setOwnCapabilities: (capabilities: Patch<OwnCapability[]>) => OwnCapability[];
360
+ /**
361
+ * The backstage state.
362
+ */
363
+ get backstage(): boolean;
364
+ /**
365
+ * Will provide the list of blocked user IDs.
366
+ */
367
+ get blockedUserIds(): string[];
368
+ /**
369
+ * Will provide the time when this call has been created.
370
+ */
371
+ get createdAt(): Date;
372
+ /**
373
+ * Will provide the time when this call has been ended.
374
+ */
375
+ get endedAt(): Date | undefined;
376
+ /**
377
+ * Will provide the time when this call has been scheduled to start.
378
+ */
379
+ get startsAt(): Date | undefined;
380
+ /**
381
+ * Will provide the time when this call has been updated.
382
+ */
383
+ get updatedAt(): Date;
384
+ /**
385
+ * Will provide the user who created this call.
386
+ */
387
+ get createdBy(): UserResponse | undefined;
388
+ /**
389
+ * Will provide the custom data of this call.
390
+ */
391
+ get custom(): Record<string, any>;
392
+ /**
393
+ * Will provide the egress data of this call.
394
+ */
395
+ get egress(): EgressResponse | undefined;
396
+ /**
397
+ * Will provide the ingress data of this call.
398
+ */
399
+ get ingress(): CallIngressResponse | undefined;
400
+ /**
401
+ * Will provide the recording state of this call.
402
+ */
403
+ get recording(): boolean;
404
+ /**
405
+ * Will provide the session data of this call.
406
+ */
407
+ get session(): CallSessionResponse | undefined;
408
+ /**
409
+ * Will provide the settings of this call.
410
+ */
411
+ get settings(): CallSettingsResponse | undefined;
412
+ /**
413
+ * Will provide the transcribing state of this call.
414
+ */
415
+ get transcribing(): boolean;
416
+ /**
417
+ * Will provide the user who ended this call.
418
+ */
419
+ get endedBy(): UserResponse | undefined;
372
420
  /**
373
421
  * Will try to find the participant with the given sessionId in the current call.
374
422
  *
@@ -412,10 +460,37 @@ export declare class CallState {
412
460
  * @returns all participants, with all patch applied.
413
461
  */
414
462
  updateParticipants: (patch: StreamVideoParticipantPatches) => StreamVideoParticipant[] | undefined;
463
+ /**
464
+ * Updates the call state with the data received from the server.
465
+ *
466
+ * @internal
467
+ *
468
+ * @param event the video event that our backend sent us.
469
+ */
470
+ updateFromEvent: (event: VideoEvent) => void;
415
471
  /**
416
472
  * Updates the participant pinned state with server side pinning data.
417
473
  *
418
474
  * @param pins the latest pins from the server.
419
475
  */
420
476
  setServerSidePins: (pins: Pin[]) => StreamVideoParticipant[];
477
+ /**
478
+ * Updates the call state with the data received from the server.
479
+ *
480
+ * @internal
481
+ *
482
+ * @param call the call response from the server.
483
+ */
484
+ updateFromCallResponse: (call: CallResponse) => void;
485
+ private updateFromMemberRemoved;
486
+ private updateFromMemberAdded;
487
+ private updateFromBroadcastStopped;
488
+ private updateFromBroadcastStarted;
489
+ private updateFromSessionParticipantLeft;
490
+ private updateFromSessionParticipantJoined;
491
+ private updateMembers;
492
+ private updateParticipantReaction;
493
+ private unblockUser;
494
+ private blockUser;
495
+ private updateOwnCapabilities;
421
496
  }
@@ -1,5 +1,5 @@
1
1
  import type { Participant, VideoDimension } from './gen/video/sfu/models/models';
2
- import type { CallResponse, JoinCallRequest, MemberResponse, OwnCapability, ReactionResponse } from './gen/coordinator';
2
+ import type { JoinCallRequest, MemberResponse, OwnCapability, ReactionResponse } from './gen/coordinator';
3
3
  import type { StreamClient } from './coordinator/connection/client';
4
4
  import type { Comparator } from './sorting';
5
5
  import type { StreamVideoWriteableStateStore } from './store';
@@ -65,10 +65,14 @@ export interface StreamVideoParticipant extends Participant {
65
65
  export interface StreamVideoLocalParticipant extends StreamVideoParticipant {
66
66
  /**
67
67
  * The device ID of the currently selected audio input device of the local participant (returned by the [MediaDevices API](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia))
68
+ *
69
+ * @deprecated use call.microphone.state.selectedDevice
68
70
  */
69
71
  audioDeviceId?: string;
70
72
  /**
71
73
  * The device ID of the currently selected video input device of the local participant (returned by the [MediaDevices API](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia))
74
+ *
75
+ * @deprecated use call.camera.state.selectedDevice
72
76
  */
73
77
  videoDeviceId?: string;
74
78
  /**
@@ -141,12 +145,6 @@ export type CallConstructor = {
141
145
  * The Call ID.
142
146
  */
143
147
  id: string;
144
- /**
145
- * An optional {@link CallResponse} metadata from the backend.
146
- * If provided, the call will be initialized with the data from this object.
147
- * This is useful when initializing a new "pending call" from an event.
148
- */
149
- metadata?: CallResponse;
150
148
  /**
151
149
  * An optional list of {@link MemberResponse} from the backend.
152
150
  * If provided, the call will be initialized with the data from this object.
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.2.3";
1
+ export declare const version = "0.3.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",