@stream-io/video-client 0.2.3 → 0.3.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 (51) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/index.browser.es.js +320 -419
  3. package/dist/index.browser.es.js.map +1 -1
  4. package/dist/index.cjs.js +320 -419
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.es.js +320 -419
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/src/Call.d.ts +3 -8
  9. package/dist/src/StreamVideoClient.d.ts +3 -1
  10. package/dist/src/events/call-permissions.d.ts +0 -5
  11. package/dist/src/events/call.d.ts +0 -6
  12. package/dist/src/events/index.d.ts +0 -6
  13. package/dist/src/rtc/Dispatcher.d.ts +2 -2
  14. package/dist/src/rtc/Publisher.d.ts +0 -1
  15. package/dist/src/store/CallState.d.ts +164 -89
  16. package/dist/src/types.d.ts +1 -7
  17. package/dist/version.d.ts +1 -1
  18. package/package.json +1 -1
  19. package/src/Call.ts +30 -41
  20. package/src/StreamVideoClient.ts +14 -17
  21. package/src/events/__tests__/call-permissions.test.ts +1 -61
  22. package/src/events/__tests__/call.test.ts +5 -50
  23. package/src/events/call-permissions.ts +0 -14
  24. package/src/events/call.ts +5 -16
  25. package/src/events/callEventHandlers.ts +2 -57
  26. package/src/events/index.ts +0 -6
  27. package/src/rtc/Dispatcher.ts +2 -2
  28. package/src/rtc/Publisher.ts +4 -6
  29. package/src/store/CallState.ts +475 -119
  30. package/src/store/__tests__/CallState.test.ts +447 -1
  31. package/src/types.ts +0 -8
  32. package/dist/src/events/__tests__/backstage.test.d.ts +0 -1
  33. package/dist/src/events/__tests__/members.test.d.ts +0 -1
  34. package/dist/src/events/__tests__/recording.test.d.ts +0 -1
  35. package/dist/src/events/__tests__/sessions.test.d.ts +0 -1
  36. package/dist/src/events/backstage.d.ts +0 -6
  37. package/dist/src/events/members.d.ts +0 -18
  38. package/dist/src/events/moderation.d.ts +0 -14
  39. package/dist/src/events/reactions.d.ts +0 -8
  40. package/dist/src/events/recording.d.ts +0 -18
  41. package/dist/src/events/sessions.d.ts +0 -26
  42. package/src/events/__tests__/backstage.test.ts +0 -15
  43. package/src/events/__tests__/members.test.ts +0 -135
  44. package/src/events/__tests__/recording.test.ts +0 -65
  45. package/src/events/__tests__/sessions.test.ts +0 -135
  46. package/src/events/backstage.ts +0 -15
  47. package/src/events/members.ts +0 -62
  48. package/src/events/moderation.ts +0 -35
  49. package/src/events/reactions.ts +0 -30
  50. package/src/events/recording.ts +0 -64
  51. package/src/events/sessions.ts +0 -102
@@ -5,7 +5,7 @@ import { AcceptCallResponse, BlockUserResponse, EndCallResponse, GetCallResponse
5
5
  import { CallConstructor, CallLeaveOptions, DebounceType, JoinCallData, PublishOptions, SubscriptionChanges } from './types';
6
6
  import { ViewportTracker } from './helpers/ViewportTracker';
7
7
  import { PermissionsContext } from './permissions';
8
- import { CallEventHandler, CallEventTypes, Logger } from './coordinator/connection/types';
8
+ import { CallEventHandler, CallEventTypes, EventTypes, Logger } from './coordinator/connection/types';
9
9
  /**
10
10
  * An object representation of a `Call`.
11
11
  */
@@ -74,7 +74,7 @@ export declare class Call {
74
74
  * Use the [`StreamVideoClient.call`](./StreamVideoClient.md/#call)
75
75
  * method to construct a `Call` instance.
76
76
  */
77
- constructor({ type, id, streamClient, metadata, members, ownCapabilities, sortParticipantsBy, clientStore, ringing, watching, }: CallConstructor);
77
+ constructor({ type, id, streamClient, members, ownCapabilities, sortParticipantsBy, clientStore, ringing, watching, }: CallConstructor);
78
78
  private registerEffects;
79
79
  /**
80
80
  * You can subscribe to WebSocket events provided by the API. To remove a subscription, call the `off` method.
@@ -84,7 +84,7 @@ export declare class Call {
84
84
  * @returns a function which can be called to unsubscribe from the given event(s)
85
85
  */
86
86
  on(eventName: SfuEventKinds, fn: SfuEventListener): () => void;
87
- on(eventName: CallEventTypes, fn: CallEventHandler): () => void;
87
+ on(eventName: EventTypes, fn: CallEventHandler): () => void;
88
88
  /**
89
89
  * Remove subscription for WebSocket events that were created by the `on` method.
90
90
  * @param eventName
@@ -97,10 +97,6 @@ export declare class Call {
97
97
  * Leave the call and stop the media streams that were published by the call.
98
98
  */
99
99
  leave: ({ reject }?: CallLeaveOptions) => Promise<void>;
100
- /**
101
- * A getter for the call metadata.
102
- */
103
- get data(): import("./gen/coordinator").CallResponse | undefined;
104
100
  /**
105
101
  * A flag indicating whether the call is "ringing" type of call.
106
102
  */
@@ -448,7 +444,6 @@ export declare class Call {
448
444
  private scheduleAutoDrop;
449
445
  /**
450
446
  * Retrieves the list of recordings for the current call or call session.
451
- * Updates the call state with the returned array of CallRecording objects.
452
447
  *
453
448
  * If `callSessionId` is provided, it will return the recordings for that call session.
454
449
  * Otherwise, all recordings for the current call will be returned.
@@ -92,7 +92,9 @@ export declare class StreamVideoClient {
92
92
  next?: string | undefined;
93
93
  prev?: string | undefined;
94
94
  }>;
95
- queryUsers: () => Promise<void>;
95
+ /**
96
+ * Returns a list of available data centers available for hosting calls.
97
+ */
96
98
  edges: () => Promise<GetEdgesResponse>;
97
99
  /**
98
100
  * addDevice - Adds a push device for a user.
@@ -1,10 +1,5 @@
1
- import { StreamVideoEvent } from '../coordinator/connection/types';
2
1
  import { CallState } from '../store';
3
2
  import { SfuEvent } from '../gen/video/sfu/event/events';
4
- /**
5
- * Event handler that watches for `call.permissions_updated` events
6
- */
7
- export declare const watchCallPermissionsUpdated: (state: CallState) => (event: StreamVideoEvent) => void;
8
3
  /**
9
4
  * Event handler that watches for `callGrantsUpdated` events.
10
5
  *
@@ -1,4 +1,3 @@
1
- import { CallState } from '../store';
2
1
  import { StreamVideoEvent } from '../coordinator/connection/types';
3
2
  import { Call } from '../Call';
4
3
  /**
@@ -15,8 +14,3 @@ export declare const watchCallRejected: (call: Call) => (event: StreamVideoEvent
15
14
  * Event handler that watches the delivery of `call.ended` Websocket event.
16
15
  */
17
16
  export declare const watchCallEnded: (call: Call) => (event: StreamVideoEvent) => Promise<void>;
18
- /**
19
- * An event handler which listens to `call.updated` events
20
- * and updates the given call state accordingly.
21
- */
22
- export declare const watchCallUpdated: (state: CallState) => (event: StreamVideoEvent) => void;
@@ -1,11 +1,5 @@
1
- export * from './backstage';
2
1
  export * from './call';
3
2
  export * from './call-permissions';
4
3
  export * from './internal';
5
- export * from './members';
6
4
  export * from './participant';
7
- export * from './reactions';
8
- export * from './recording';
9
5
  export * from './speaker';
10
- export * from './sessions';
11
- export * from './moderation';
@@ -1,7 +1,7 @@
1
- import { CallEventTypes } from '../coordinator/connection/types';
1
+ import { EventTypes } from '../coordinator/connection/types';
2
2
  import type { SfuEvent } from '../gen/video/sfu/event/events';
3
3
  export type SfuEventKinds = NonNullable<SfuEvent['eventPayload']['oneofKind']>;
4
- export declare const isSfuEvent: (eventName: SfuEventKinds | CallEventTypes) => eventName is SfuEventKinds;
4
+ export declare const isSfuEvent: (eventName: SfuEventKinds | EventTypes) => eventName is SfuEventKinds;
5
5
  export type SfuEventListener = (event: SfuEvent) => void;
6
6
  export declare class Dispatcher {
7
7
  private subscribers;
@@ -20,7 +20,6 @@ export type PublisherOpts = {
20
20
  export declare class Publisher {
21
21
  private pc;
22
22
  private readonly state;
23
- private readonly dispatcher;
24
23
  private readonly transceiverRegistry;
25
24
  /**
26
25
  * An array maintaining the order how transceivers were added to the peer connection.
@@ -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';
@@ -141,12 +141,6 @@ export type CallConstructor = {
141
141
  * The Call ID.
142
142
  */
143
143
  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
144
  /**
151
145
  * An optional list of {@link MemberResponse} from the backend.
152
146
  * 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.0";
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.0",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
package/src/Call.ts CHANGED
@@ -105,6 +105,7 @@ import {
105
105
  CallEventHandler,
106
106
  CallEventTypes,
107
107
  EventHandler,
108
+ EventTypes,
108
109
  Logger,
109
110
  StreamCallEvent,
110
111
  } from './coordinator/connection/types';
@@ -200,7 +201,6 @@ export class Call {
200
201
  type,
201
202
  id,
202
203
  streamClient,
203
- metadata,
204
204
  members,
205
205
  ownCapabilities,
206
206
  sortParticipantsBy,
@@ -225,13 +225,17 @@ export class Call {
225
225
  this.state.setSortParticipantsBy(participantSorter);
226
226
  }
227
227
 
228
- this.state.setMetadata(metadata);
229
228
  this.state.setMembers(members || []);
230
229
  this.state.setOwnCapabilities(ownCapabilities || []);
231
230
  this.state.setCallingState(
232
231
  ringing ? CallingState.RINGING : CallingState.IDLE,
233
232
  );
234
233
 
234
+ this.on('all', (event) => {
235
+ // update state with the latest event data
236
+ this.state.updateFromEvent(event);
237
+ });
238
+
235
239
  this.leaveCallHooks.push(
236
240
  registerEventHandlers(this, this.state, this.dispatcher),
237
241
  );
@@ -250,10 +254,10 @@ export class Call {
250
254
 
251
255
  private registerEffects() {
252
256
  this.leaveCallHooks.push(
253
- // handles updating the permissions context when the metadata changes.
254
- createSubscription(this.state.metadata$, (metadata) => {
255
- if (!metadata) return;
256
- this.permissionsContext.setCallSettings(metadata.settings);
257
+ // handles updating the permissions context when the settings change.
258
+ createSubscription(this.state.settings$, (settings) => {
259
+ if (!settings) return;
260
+ this.permissionsContext.setCallSettings(settings);
257
261
  }),
258
262
 
259
263
  // handle the case when the user permissions are modified.
@@ -284,13 +288,10 @@ export class Call {
284
288
  }),
285
289
 
286
290
  // handles the case when the user is blocked by the call owner.
287
- createSubscription(this.state.metadata$, async (metadata) => {
288
- if (!metadata) return;
291
+ createSubscription(this.state.blockedUserIds$, async (blockedUserIds) => {
292
+ if (!blockedUserIds) return;
289
293
  const currentUserId = this.currentUserId;
290
- if (
291
- currentUserId &&
292
- metadata.blocked_user_ids.includes(currentUserId)
293
- ) {
294
+ if (currentUserId && blockedUserIds.includes(currentUserId)) {
294
295
  this.logger('info', 'Leaving call because of being blocked');
295
296
  await this.leave();
296
297
  }
@@ -329,9 +330,9 @@ export class Call {
329
330
  * @returns a function which can be called to unsubscribe from the given event(s)
330
331
  */
331
332
  on(eventName: SfuEventKinds, fn: SfuEventListener): () => void;
332
- on(eventName: CallEventTypes, fn: CallEventHandler): () => void;
333
+ on(eventName: EventTypes, fn: CallEventHandler): () => void;
333
334
  on(
334
- eventName: SfuEventKinds | CallEventTypes,
335
+ eventName: SfuEventKinds | EventTypes,
335
336
  fn: SfuEventListener | CallEventHandler,
336
337
  ) {
337
338
  if (isSfuEvent(eventName)) {
@@ -420,13 +421,6 @@ export class Call {
420
421
  this.state.setCallingState(CallingState.LEFT);
421
422
  };
422
423
 
423
- /**
424
- * A getter for the call metadata.
425
- */
426
- get data() {
427
- return this.state.metadata;
428
- }
429
-
430
424
  /**
431
425
  * A flag indicating whether the call is "ringing" type of call.
432
426
  */
@@ -445,7 +439,7 @@ export class Call {
445
439
  * A flag indicating whether the call was created by the current user.
446
440
  */
447
441
  get isCreatedByMe() {
448
- return this.state.metadata?.created_by.id === this.currentUserId;
442
+ return this.state.createdBy?.id === this.currentUserId;
449
443
  }
450
444
 
451
445
  /**
@@ -469,7 +463,7 @@ export class Call {
469
463
  this.ringingSubject.next(true);
470
464
  }
471
465
 
472
- this.state.setMetadata(response.call);
466
+ this.state.updateFromCallResponse(response.call);
473
467
  this.state.setMembers(response.members);
474
468
  this.state.setOwnCapabilities(response.own_capabilities);
475
469
 
@@ -496,7 +490,7 @@ export class Call {
496
490
  this.ringingSubject.next(true);
497
491
  }
498
492
 
499
- this.state.setMetadata(response.call);
493
+ this.state.updateFromCallResponse(response.call);
500
494
  this.state.setMembers(response.members);
501
495
  this.state.setOwnCapabilities(response.own_capabilities);
502
496
 
@@ -598,7 +592,7 @@ export class Call {
598
592
  let connectionConfig: RTCConfiguration | undefined;
599
593
  try {
600
594
  const call = await join(this.streamClient, this.type, this.id, data);
601
- this.state.setMetadata(call.metadata);
595
+ this.state.updateFromCallResponse(call.metadata);
602
596
  this.state.setMembers(call.members);
603
597
  this.state.setOwnCapabilities(call.ownCapabilities);
604
598
  connectionConfig = call.connectionConfig;
@@ -815,7 +809,7 @@ export class Call {
815
809
  });
816
810
  }
817
811
 
818
- const audioSettings = this.data?.settings.audio;
812
+ const audioSettings = this.state.settings?.audio;
819
813
  const isDtxEnabled = !!audioSettings?.opus_dtx_enabled;
820
814
  const isRedEnabled = !!audioSettings?.redundant_coding_enabled;
821
815
 
@@ -1516,7 +1510,7 @@ export class Call {
1516
1510
  >(`${this.streamClientBasePath}`, updates);
1517
1511
 
1518
1512
  const { call, members, own_capabilities } = response;
1519
- this.state.setMetadata(call);
1513
+ this.state.updateFromCallResponse(call);
1520
1514
  this.state.setMembers(members);
1521
1515
  this.state.setOwnCapabilities(own_capabilities);
1522
1516
 
@@ -1617,23 +1611,23 @@ export class Call {
1617
1611
 
1618
1612
  private scheduleAutoDrop = () => {
1619
1613
  if (this.dropTimeout) clearTimeout(this.dropTimeout);
1620
- const subscription = this.state.metadata$
1614
+ const subscription = this.state.settings$
1621
1615
  .pipe(
1622
1616
  pairwise(),
1623
- tap(([prevMeta, currentMeta]) => {
1624
- if (!(currentMeta && this.clientStore.connectedUser)) return;
1617
+ tap(([prevSettings, currentSettings]) => {
1618
+ if (!currentSettings || !this.clientStore.connectedUser) return;
1625
1619
 
1626
1620
  const isOutgoingCall =
1627
- this.currentUserId === currentMeta.created_by.id;
1621
+ this.currentUserId === this.state.createdBy?.id;
1628
1622
 
1629
1623
  const [prevTimeoutMs, timeoutMs] = isOutgoingCall
1630
1624
  ? [
1631
- prevMeta?.settings.ring.auto_cancel_timeout_ms,
1632
- currentMeta.settings.ring.auto_cancel_timeout_ms,
1625
+ prevSettings?.ring.auto_cancel_timeout_ms,
1626
+ currentSettings.ring.auto_cancel_timeout_ms,
1633
1627
  ]
1634
1628
  : [
1635
- prevMeta?.settings.ring.incoming_call_timeout_ms,
1636
- currentMeta.settings.ring.incoming_call_timeout_ms,
1629
+ prevSettings?.ring.incoming_call_timeout_ms,
1630
+ currentSettings.ring.incoming_call_timeout_ms,
1637
1631
  ];
1638
1632
  if (
1639
1633
  typeof timeoutMs === 'undefined' ||
@@ -1658,7 +1652,6 @@ export class Call {
1658
1652
 
1659
1653
  /**
1660
1654
  * Retrieves the list of recordings for the current call or call session.
1661
- * Updates the call state with the returned array of CallRecording objects.
1662
1655
  *
1663
1656
  * If `callSessionId` is provided, it will return the recordings for that call session.
1664
1657
  * Otherwise, all recordings for the current call will be returned.
@@ -1672,13 +1665,9 @@ export class Call {
1672
1665
  if (callSessionId) {
1673
1666
  endpoint = `${endpoint}/${callSessionId}`;
1674
1667
  }
1675
- const response = await this.streamClient.get<ListRecordingsResponse>(
1668
+ return this.streamClient.get<ListRecordingsResponse>(
1676
1669
  `${endpoint}/recordings`,
1677
1670
  );
1678
-
1679
- this.state.setCallRecordingsList(response.recordings);
1680
-
1681
- return response;
1682
1671
  };
1683
1672
 
1684
1673
  /**