@stream-io/video-client 0.2.2 → 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 (53) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.browser.es.js +325 -421
  3. package/dist/index.browser.es.js.map +1 -1
  4. package/dist/index.cjs.js +325 -421
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.es.js +325 -421
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/src/Call.d.ts +8 -10
  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/gen/coordinator/index.d.ts +25 -0
  14. package/dist/src/rtc/Dispatcher.d.ts +2 -2
  15. package/dist/src/rtc/Publisher.d.ts +0 -1
  16. package/dist/src/store/CallState.d.ts +164 -89
  17. package/dist/src/types.d.ts +1 -7
  18. package/dist/version.d.ts +1 -1
  19. package/package.json +1 -1
  20. package/src/Call.ts +37 -44
  21. package/src/StreamVideoClient.ts +14 -17
  22. package/src/events/__tests__/call-permissions.test.ts +1 -61
  23. package/src/events/__tests__/call.test.ts +5 -50
  24. package/src/events/call-permissions.ts +0 -14
  25. package/src/events/call.ts +5 -16
  26. package/src/events/callEventHandlers.ts +2 -57
  27. package/src/events/index.ts +0 -6
  28. package/src/gen/coordinator/index.ts +25 -0
  29. package/src/rtc/Dispatcher.ts +2 -2
  30. package/src/rtc/Publisher.ts +4 -6
  31. package/src/store/CallState.ts +475 -119
  32. package/src/store/__tests__/CallState.test.ts +447 -1
  33. package/src/types.ts +0 -8
  34. package/dist/src/events/__tests__/backstage.test.d.ts +0 -1
  35. package/dist/src/events/__tests__/members.test.d.ts +0 -1
  36. package/dist/src/events/__tests__/recording.test.d.ts +0 -1
  37. package/dist/src/events/__tests__/sessions.test.d.ts +0 -1
  38. package/dist/src/events/backstage.d.ts +0 -6
  39. package/dist/src/events/members.d.ts +0 -18
  40. package/dist/src/events/moderation.d.ts +0 -14
  41. package/dist/src/events/reactions.d.ts +0 -8
  42. package/dist/src/events/recording.d.ts +0 -18
  43. package/dist/src/events/sessions.d.ts +0 -26
  44. package/src/events/__tests__/backstage.test.ts +0 -15
  45. package/src/events/__tests__/members.test.ts +0 -135
  46. package/src/events/__tests__/recording.test.ts +0 -65
  47. package/src/events/__tests__/sessions.test.ts +0 -135
  48. package/src/events/backstage.ts +0 -15
  49. package/src/events/members.ts +0 -62
  50. package/src/events/moderation.ts +0 -35
  51. package/src/events/reactions.ts +0 -30
  52. package/src/events/recording.ts +0 -64
  53. package/src/events/sessions.ts +0 -102
package/dist/index.es.js CHANGED
@@ -6523,8 +6523,8 @@ class Publisher {
6523
6523
  track.removeEventListener('ended', handleTrackEnded);
6524
6524
  });
6525
6525
  if (!transceiver) {
6526
- const metadata = this.state.metadata;
6527
- const targetResolution = metadata === null || metadata === void 0 ? void 0 : metadata.settings.video.target_resolution;
6526
+ const { settings } = this.state;
6527
+ const targetResolution = settings === null || settings === void 0 ? void 0 : settings.video.target_resolution;
6528
6528
  const videoEncodings = trackType === TrackType.VIDEO
6529
6529
  ? findOptimalVideoLayers(track, targetResolution)
6530
6530
  : undefined;
@@ -6802,8 +6802,8 @@ class Publisher {
6802
6802
  }
6803
6803
  return String(media.mid);
6804
6804
  };
6805
- const metadata = this.state.metadata;
6806
- const targetResolution = metadata === null || metadata === void 0 ? void 0 : metadata.settings.video.target_resolution;
6805
+ const { settings } = this.state;
6806
+ const targetResolution = settings === null || settings === void 0 ? void 0 : settings.video.target_resolution;
6807
6807
  return this.pc
6808
6808
  .getTransceivers()
6809
6809
  .filter((t) => t.direction === 'sendonly' && t.sender.track)
@@ -6896,7 +6896,6 @@ class Publisher {
6896
6896
  this.pc = this.createPeerConnection(connectionConfig);
6897
6897
  this.sfuClient = sfuClient;
6898
6898
  this.state = state;
6899
- this.dispatcher = dispatcher;
6900
6899
  this.isDtxEnabled = isDtxEnabled;
6901
6900
  this.isRedEnabled = isRedEnabled;
6902
6901
  this.preferredVideoCodec = preferredVideoCodec;
@@ -7524,17 +7523,6 @@ const retryable = (rpc, logger) => __awaiter(void 0, void 0, void 0, function* (
7524
7523
  return rpcCallResult;
7525
7524
  });
7526
7525
 
7527
- /**
7528
- * Watches for `call.live_started` events.
7529
- */
7530
- const watchCallLiveStarted = (state) => {
7531
- return function onCallLiveStarted(event) {
7532
- if (event.type !== 'call.live_started')
7533
- return;
7534
- state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { backstage: false })));
7535
- };
7536
- };
7537
-
7538
7526
  /**
7539
7527
  * Gets the current value of an observable, or undefined if the observable has
7540
7528
  * not emitted a value yet.
@@ -7977,71 +7965,29 @@ class CallState {
7977
7965
  *
7978
7966
  */
7979
7967
  constructor() {
7980
- /**
7981
- * The raw call metadata object, as defined on the backend.
7982
- *
7983
- * @internal
7984
- */
7985
- this.metadataSubject = new BehaviorSubject(undefined);
7986
- /**
7987
- * The list of members of the current call.
7988
- *
7989
- * @internal
7990
- */
7968
+ this.backstageSubject = new BehaviorSubject(false);
7969
+ this.blockedUserIdsSubject = new BehaviorSubject([]);
7970
+ this.createdAtSubject = new BehaviorSubject(new Date());
7971
+ this.endedAtSubject = new BehaviorSubject(undefined);
7972
+ this.startsAtSubject = new BehaviorSubject(undefined);
7973
+ this.updatedAtSubject = new BehaviorSubject(new Date());
7974
+ this.createdBySubject = new BehaviorSubject(undefined);
7975
+ this.customSubject = new BehaviorSubject({});
7976
+ this.egressSubject = new BehaviorSubject(undefined);
7977
+ this.ingressSubject = new BehaviorSubject(undefined);
7978
+ this.recordingSubject = new BehaviorSubject(false);
7979
+ this.sessionSubject = new BehaviorSubject(undefined);
7980
+ this.settingsSubject = new BehaviorSubject(undefined);
7981
+ this.transcribingSubject = new BehaviorSubject(false);
7982
+ this.endedBySubject = new BehaviorSubject(undefined);
7991
7983
  this.membersSubject = new BehaviorSubject([]);
7992
- /**
7993
- * The list of capabilities of the current user.
7994
- *
7995
- * @private
7996
- */
7997
7984
  this.ownCapabilitiesSubject = new BehaviorSubject([]);
7998
- /**
7999
- * The calling state.
8000
- *
8001
- * @internal
8002
- */
8003
7985
  this.callingStateSubject = new BehaviorSubject(CallingState.UNKNOWN);
8004
- /**
8005
- * The time the call session actually started.
8006
- *
8007
- * @internal
8008
- */
8009
7986
  this.startedAtSubject = new BehaviorSubject(undefined);
8010
- /**
8011
- * The server-side counted number of participants connected to the current call.
8012
- * This number includes the anonymous participants as well.
8013
- *
8014
- * @internal
8015
- */
8016
7987
  this.participantCountSubject = new BehaviorSubject(0);
8017
- /**
8018
- * The server-side counted number of anonymous participants connected to the current call.
8019
- * This number excludes the regular participants.
8020
- *
8021
- * @internal
8022
- */
8023
7988
  this.anonymousParticipantCountSubject = new BehaviorSubject(0);
8024
- /**
8025
- * All participants of the current call (including the logged-in user).
8026
- *
8027
- * @internal
8028
- */
8029
7989
  this.participantsSubject = new BehaviorSubject([]);
8030
- /**
8031
- * The latest stats report of the current call.
8032
- * When stats gathering is enabled, this observable will emit a new value
8033
- * at a regular (configurable) interval.
8034
- *
8035
- * Consumers of this observable can implement their own batching logic
8036
- * in case they want to show historical stat data.
8037
- *
8038
- * @internal
8039
- */
8040
7990
  this.callStatsReportSubject = new BehaviorSubject(undefined);
8041
- /**
8042
- * Emits a list of details about recordings performed for the current call.
8043
- */
8044
- this.callRecordingListSubject = new BehaviorSubject([]);
8045
7991
  /**
8046
7992
  * A list of comparators that are used to sort the participants.
8047
7993
  *
@@ -8124,15 +8070,6 @@ class CallState {
8124
8070
  this.setCallingState = (state) => {
8125
8071
  return this.setCurrentValue(this.callingStateSubject, state);
8126
8072
  };
8127
- /**
8128
- * Sets the list of call recordings.
8129
- *
8130
- * @internal
8131
- * @param recordings the list of call recordings.
8132
- */
8133
- this.setCallRecordingsList = (recordings) => {
8134
- return this.setCurrentValue(this.callRecordingListSubject, recordings);
8135
- };
8136
8073
  /**
8137
8074
  * Sets the call stats report.
8138
8075
  *
@@ -8142,16 +8079,6 @@ class CallState {
8142
8079
  this.setCallStatsReport = (report) => {
8143
8080
  return this.setCurrentValue(this.callStatsReportSubject, report);
8144
8081
  };
8145
- /**
8146
- * Sets the metadata of the current call.
8147
- *
8148
- * @internal
8149
- *
8150
- * @param metadata the metadata to set.
8151
- */
8152
- this.setMetadata = (metadata) => {
8153
- return this.setCurrentValue(this.metadataSubject, metadata);
8154
- };
8155
8082
  /**
8156
8083
  * Sets the members of the current call.
8157
8084
  *
@@ -8250,6 +8177,19 @@ class CallState {
8250
8177
  return p;
8251
8178
  }));
8252
8179
  };
8180
+ /**
8181
+ * Updates the call state with the data received from the server.
8182
+ *
8183
+ * @internal
8184
+ *
8185
+ * @param event the video event that our backend sent us.
8186
+ */
8187
+ this.updateFromEvent = (event) => {
8188
+ const update = this.eventHandlers[event.type];
8189
+ if (update) {
8190
+ update(event);
8191
+ }
8192
+ };
8253
8193
  /**
8254
8194
  * Updates the participant pinned state with server side pinning data.
8255
8195
  *
@@ -8278,25 +8218,174 @@ class CallState {
8278
8218
  return participant;
8279
8219
  }));
8280
8220
  };
8281
- this.logger = getLogger(['call-state']);
8221
+ /**
8222
+ * Updates the call state with the data received from the server.
8223
+ *
8224
+ * @internal
8225
+ *
8226
+ * @param call the call response from the server.
8227
+ */
8228
+ this.updateFromCallResponse = (call) => {
8229
+ this.setCurrentValue(this.backstageSubject, call.backstage);
8230
+ this.setCurrentValue(this.blockedUserIdsSubject, call.blocked_user_ids);
8231
+ this.setCurrentValue(this.createdAtSubject, new Date(call.created_at));
8232
+ this.setCurrentValue(this.updatedAtSubject, new Date(call.updated_at));
8233
+ this.setCurrentValue(this.startsAtSubject, call.starts_at ? new Date(call.starts_at) : undefined);
8234
+ this.setCurrentValue(this.endedAtSubject, call.ended_at ? new Date(call.ended_at) : undefined);
8235
+ this.setCurrentValue(this.createdBySubject, call.created_by);
8236
+ this.setCurrentValue(this.customSubject, call.custom);
8237
+ this.setCurrentValue(this.egressSubject, call.egress);
8238
+ this.setCurrentValue(this.ingressSubject, call.ingress);
8239
+ this.setCurrentValue(this.recordingSubject, call.recording);
8240
+ this.setCurrentValue(this.sessionSubject, call.session);
8241
+ this.setCurrentValue(this.settingsSubject, call.settings);
8242
+ this.setCurrentValue(this.transcribingSubject, call.transcribing);
8243
+ };
8244
+ this.updateFromMemberRemoved = (event) => {
8245
+ this.setCurrentValue(this.membersSubject, (members) => members.filter((m) => event.members.indexOf(m.user_id) === -1));
8246
+ };
8247
+ this.updateFromMemberAdded = (event) => {
8248
+ this.setCurrentValue(this.membersSubject, (members) => [
8249
+ ...members,
8250
+ ...event.members,
8251
+ ]);
8252
+ };
8253
+ this.updateFromBroadcastStopped = () => {
8254
+ this.setCurrentValue(this.egressSubject, (egress) => (Object.assign(Object.assign({}, egress), { broadcasting: false })));
8255
+ };
8256
+ this.updateFromBroadcastStarted = (event) => {
8257
+ this.setCurrentValue(this.egressSubject, (egress) => (Object.assign(Object.assign({}, egress), { broadcasting: true, hls: Object.assign(Object.assign({}, egress.hls), { playlist_url: event.hls_playlist_url }) })));
8258
+ };
8259
+ this.updateFromSessionParticipantLeft = (event) => {
8260
+ this.setCurrentValue(this.sessionSubject, (session) => {
8261
+ if (!session) {
8262
+ this.logger('warn', `Received call.session_participant_left event but no session is available.`, event);
8263
+ return session;
8264
+ }
8265
+ const { participants, participants_count_by_role } = session;
8266
+ const { user, user_session_id } = event.participant;
8267
+ return Object.assign(Object.assign({}, session), { participants: participants.filter((p) => p.user_session_id !== user_session_id), participants_count_by_role: Object.assign(Object.assign({}, participants_count_by_role), { [user.role]: Math.max(0, (participants_count_by_role[user.role] || 0) - 1) }) });
8268
+ });
8269
+ };
8270
+ this.updateFromSessionParticipantJoined = (event) => {
8271
+ this.setCurrentValue(this.sessionSubject, (session) => {
8272
+ if (!session) {
8273
+ this.logger('warn', `Received call.session_participant_joined event but no session is available.`, event);
8274
+ return session;
8275
+ }
8276
+ const { participants, participants_count_by_role } = session;
8277
+ const { user } = event.participant;
8278
+ return Object.assign(Object.assign({}, session), { participants: [...participants, event.participant], participants_count_by_role: Object.assign(Object.assign({}, participants_count_by_role), { [user.role]: (participants_count_by_role[user.role] || 0) + 1 }) });
8279
+ });
8280
+ };
8281
+ this.updateMembers = (event) => {
8282
+ this.setCurrentValue(this.membersSubject, (members) => members.map((member) => {
8283
+ const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
8284
+ return memberUpdate ? memberUpdate : member;
8285
+ }));
8286
+ };
8287
+ this.updateParticipantReaction = (event) => {
8288
+ const { user, custom, type, emoji_code } = event.reaction;
8289
+ this.setParticipants((participants) => {
8290
+ return participants.map((p) => {
8291
+ // skip if the reaction is not for this participant
8292
+ if (p.userId !== user.id)
8293
+ return p;
8294
+ // update the participant with the new reaction
8295
+ return Object.assign(Object.assign({}, p), { reaction: {
8296
+ type,
8297
+ emoji_code,
8298
+ custom,
8299
+ } });
8300
+ });
8301
+ });
8302
+ };
8303
+ this.unblockUser = (event) => {
8304
+ this.setCurrentValue(this.blockedUserIdsSubject, (current) => {
8305
+ if (!current)
8306
+ return current;
8307
+ return current.filter((id) => id !== event.user.id);
8308
+ });
8309
+ };
8310
+ this.blockUser = (event) => {
8311
+ this.setCurrentValue(this.blockedUserIdsSubject, (current) => [
8312
+ ...(current || []),
8313
+ event.user.id,
8314
+ ]);
8315
+ };
8316
+ this.updateOwnCapabilities = (event) => {
8317
+ var _a;
8318
+ if (event.user.id === ((_a = this.localParticipant) === null || _a === void 0 ? void 0 : _a.userId)) {
8319
+ this.setCurrentValue(this.ownCapabilitiesSubject, event.own_capabilities);
8320
+ }
8321
+ };
8322
+ this.logger = getLogger(['CallState']);
8282
8323
  this.participants$ = this.participantsSubject.pipe(map$1((ps) => ps.sort(this.sortParticipantsBy)));
8283
8324
  this.localParticipant$ = this.participants$.pipe(map$1((participants) => participants.find(isStreamVideoLocalParticipant)));
8284
8325
  this.remoteParticipants$ = this.participants$.pipe(map$1((participants) => participants.filter((p) => !p.isLocalParticipant)));
8285
8326
  this.pinnedParticipants$ = this.participants$.pipe(map$1((participants) => participants.filter((p) => !!p.pin)));
8286
8327
  this.dominantSpeaker$ = this.participants$.pipe(map$1((participants) => participants.find((p) => p.isDominantSpeaker)));
8287
- this.hasOngoingScreenShare$ = this.participants$.pipe(map$1((participants) => {
8288
- return participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE));
8289
- }), distinctUntilChanged());
8328
+ this.hasOngoingScreenShare$ = this.participants$.pipe(map$1((participants) => participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE))), distinctUntilChanged());
8290
8329
  this.startedAt$ = this.startedAtSubject.asObservable();
8291
8330
  this.participantCount$ = this.participantCountSubject.asObservable();
8292
8331
  this.anonymousParticipantCount$ =
8293
8332
  this.anonymousParticipantCountSubject.asObservable();
8294
8333
  this.callStatsReport$ = this.callStatsReportSubject.asObservable();
8295
- this.callRecordingList$ = this.callRecordingListSubject.asObservable();
8296
- this.metadata$ = this.metadataSubject.asObservable();
8297
8334
  this.members$ = this.membersSubject.asObservable();
8298
8335
  this.ownCapabilities$ = this.ownCapabilitiesSubject.asObservable();
8299
8336
  this.callingState$ = this.callingStateSubject.asObservable();
8337
+ this.backstage$ = this.backstageSubject.asObservable();
8338
+ this.blockedUserIds$ = this.blockedUserIdsSubject.asObservable();
8339
+ this.createdAt$ = this.createdAtSubject.asObservable();
8340
+ this.endedAt$ = this.endedAtSubject.asObservable();
8341
+ this.startsAt$ = this.startsAtSubject.asObservable();
8342
+ this.updatedAt$ = this.updatedAtSubject.asObservable();
8343
+ this.createdBy$ = this.createdBySubject.asObservable();
8344
+ this.custom$ = this.customSubject.asObservable();
8345
+ this.egress$ = this.egressSubject.asObservable();
8346
+ this.ingress$ = this.ingressSubject.asObservable();
8347
+ this.recording$ = this.recordingSubject.asObservable();
8348
+ this.session$ = this.sessionSubject.asObservable();
8349
+ this.settings$ = this.settingsSubject.asObservable();
8350
+ this.transcribing$ = this.transcribingSubject.asObservable();
8351
+ this.endedBy$ = this.endedBySubject.asObservable();
8352
+ this.eventHandlers = {
8353
+ // these events are not updating the call state:
8354
+ 'call.permission_request': undefined,
8355
+ 'call.user_muted': undefined,
8356
+ 'connection.error': undefined,
8357
+ 'connection.ok': undefined,
8358
+ 'health.check': undefined,
8359
+ custom: undefined,
8360
+ // events that update call state:
8361
+ 'call.accepted': (e) => this.updateFromCallResponse(e.call),
8362
+ 'call.created': (e) => this.updateFromCallResponse(e.call),
8363
+ 'call.notification': (e) => this.updateFromCallResponse(e.call),
8364
+ 'call.rejected': (e) => this.updateFromCallResponse(e.call),
8365
+ 'call.ring': (e) => this.updateFromCallResponse(e.call),
8366
+ 'call.live_started': (e) => this.updateFromCallResponse(e.call),
8367
+ 'call.updated': (e) => this.updateFromCallResponse(e.call),
8368
+ 'call.session_started': (e) => this.updateFromCallResponse(e.call),
8369
+ 'call.session_ended': (e) => this.updateFromCallResponse(e.call),
8370
+ 'call.ended': (e) => {
8371
+ this.updateFromCallResponse(e.call);
8372
+ this.setCurrentValue(this.endedBySubject, e.user);
8373
+ },
8374
+ 'call.recording_started': () => this.setCurrentValue(this.recordingSubject, true),
8375
+ 'call.recording_stopped': () => this.setCurrentValue(this.recordingSubject, false),
8376
+ 'call.broadcasting_started': this.updateFromBroadcastStarted,
8377
+ 'call.broadcasting_stopped': this.updateFromBroadcastStopped,
8378
+ 'call.session_participant_joined': this.updateFromSessionParticipantJoined,
8379
+ 'call.session_participant_left': this.updateFromSessionParticipantLeft,
8380
+ 'call.blocked_user': this.blockUser,
8381
+ 'call.unblocked_user': this.unblockUser,
8382
+ 'call.permissions_updated': this.updateOwnCapabilities,
8383
+ 'call.member_added': this.updateFromMemberAdded,
8384
+ 'call.member_removed': this.updateFromMemberRemoved,
8385
+ 'call.member_updated': this.updateMembers,
8386
+ 'call.member_updated_permission': this.updateMembers,
8387
+ 'call.reaction_new': this.updateParticipantReaction,
8388
+ };
8300
8389
  }
8301
8390
  /**
8302
8391
  * The server-side counted number of participants connected to the current call.
@@ -8361,24 +8450,12 @@ class CallState {
8361
8450
  get callingState() {
8362
8451
  return this.getCurrentValue(this.callingState$);
8363
8452
  }
8364
- /**
8365
- * The list of call recordings.
8366
- */
8367
- get callRecordingsList() {
8368
- return this.getCurrentValue(this.callRecordingList$);
8369
- }
8370
8453
  /**
8371
8454
  * The call stats report.
8372
8455
  */
8373
8456
  get callStatsReport() {
8374
8457
  return this.getCurrentValue(this.callStatsReport$);
8375
8458
  }
8376
- /**
8377
- * The metadata of the current call.
8378
- */
8379
- get metadata() {
8380
- return this.getCurrentValue(this.metadata$);
8381
- }
8382
8459
  /**
8383
8460
  * The members of the current call.
8384
8461
  */
@@ -8391,6 +8468,96 @@ class CallState {
8391
8468
  get ownCapabilities() {
8392
8469
  return this.getCurrentValue(this.ownCapabilities$);
8393
8470
  }
8471
+ /**
8472
+ * The backstage state.
8473
+ */
8474
+ get backstage() {
8475
+ return this.getCurrentValue(this.backstage$);
8476
+ }
8477
+ /**
8478
+ * Will provide the list of blocked user IDs.
8479
+ */
8480
+ get blockedUserIds() {
8481
+ return this.getCurrentValue(this.blockedUserIds$);
8482
+ }
8483
+ /**
8484
+ * Will provide the time when this call has been created.
8485
+ */
8486
+ get createdAt() {
8487
+ return this.getCurrentValue(this.createdAt$);
8488
+ }
8489
+ /**
8490
+ * Will provide the time when this call has been ended.
8491
+ */
8492
+ get endedAt() {
8493
+ return this.getCurrentValue(this.endedAt$);
8494
+ }
8495
+ /**
8496
+ * Will provide the time when this call has been scheduled to start.
8497
+ */
8498
+ get startsAt() {
8499
+ return this.getCurrentValue(this.startsAt$);
8500
+ }
8501
+ /**
8502
+ * Will provide the time when this call has been updated.
8503
+ */
8504
+ get updatedAt() {
8505
+ return this.getCurrentValue(this.updatedAt$);
8506
+ }
8507
+ /**
8508
+ * Will provide the user who created this call.
8509
+ */
8510
+ get createdBy() {
8511
+ return this.getCurrentValue(this.createdBy$);
8512
+ }
8513
+ /**
8514
+ * Will provide the custom data of this call.
8515
+ */
8516
+ get custom() {
8517
+ return this.getCurrentValue(this.custom$);
8518
+ }
8519
+ /**
8520
+ * Will provide the egress data of this call.
8521
+ */
8522
+ get egress() {
8523
+ return this.getCurrentValue(this.egress$);
8524
+ }
8525
+ /**
8526
+ * Will provide the ingress data of this call.
8527
+ */
8528
+ get ingress() {
8529
+ return this.getCurrentValue(this.ingress$);
8530
+ }
8531
+ /**
8532
+ * Will provide the recording state of this call.
8533
+ */
8534
+ get recording() {
8535
+ return this.getCurrentValue(this.recording$);
8536
+ }
8537
+ /**
8538
+ * Will provide the session data of this call.
8539
+ */
8540
+ get session() {
8541
+ return this.getCurrentValue(this.session$);
8542
+ }
8543
+ /**
8544
+ * Will provide the settings of this call.
8545
+ */
8546
+ get settings() {
8547
+ return this.getCurrentValue(this.settings$);
8548
+ }
8549
+ /**
8550
+ * Will provide the transcribing state of this call.
8551
+ */
8552
+ get transcribing() {
8553
+ return this.getCurrentValue(this.transcribing$);
8554
+ }
8555
+ /**
8556
+ * Will provide the user who ended this call.
8557
+ */
8558
+ get endedBy() {
8559
+ return this.getCurrentValue(this.endedBy$);
8560
+ }
8394
8561
  }
8395
8562
 
8396
8563
  /**
@@ -8462,40 +8629,16 @@ const watchCallEnded = (call) => {
8462
8629
  return __awaiter(this, void 0, void 0, function* () {
8463
8630
  if (event.type !== 'call.ended')
8464
8631
  return;
8465
- if (call.state.callingState === CallingState.RINGING ||
8466
- call.state.callingState === CallingState.JOINED ||
8467
- call.state.callingState === CallingState.JOINING) {
8468
- call.state.setMetadata(event.call);
8632
+ const { callingState } = call.state;
8633
+ if (callingState === CallingState.RINGING ||
8634
+ callingState === CallingState.JOINED ||
8635
+ callingState === CallingState.JOINING) {
8469
8636
  yield call.leave();
8470
8637
  }
8471
8638
  });
8472
8639
  };
8473
8640
  };
8474
- /**
8475
- * An event handler which listens to `call.updated` events
8476
- * and updates the given call state accordingly.
8477
- */
8478
- const watchCallUpdated = (state) => {
8479
- return function onCallUpdated(event) {
8480
- if (event.type !== 'call.updated')
8481
- return;
8482
- state.setMetadata(event.call);
8483
- };
8484
- };
8485
8641
 
8486
- /**
8487
- * Event handler that watches for `call.permissions_updated` events
8488
- */
8489
- const watchCallPermissionsUpdated = (state) => {
8490
- return function onCallPermissionsUpdated(event) {
8491
- if (event.type !== 'call.permissions_updated')
8492
- return;
8493
- const { localParticipant } = state;
8494
- if (event.user.id === (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.userId)) {
8495
- state.setOwnCapabilities(event.own_capabilities);
8496
- }
8497
- };
8498
- };
8499
8642
  /**
8500
8643
  * Event handler that watches for `callGrantsUpdated` events.
8501
8644
  *
@@ -8609,57 +8752,6 @@ const watchPinsUpdated = (state) => {
8609
8752
  };
8610
8753
  };
8611
8754
 
8612
- /**
8613
- * Watches for `call.member_added` events.
8614
- */
8615
- const watchCallMemberAdded = (state) => {
8616
- return function onCallMemberAdded(event) {
8617
- if (event.type !== 'call.member_added')
8618
- return;
8619
- state.setMembers((members) => [...members, ...event.members]);
8620
- };
8621
- };
8622
- /**
8623
- * Watches for `call.member_removed` events.
8624
- */
8625
- const watchCallMemberRemoved = (state) => {
8626
- return function onCallMemberRemoved(event) {
8627
- if (event.type !== 'call.member_removed')
8628
- return;
8629
- state.setMembers((members) => members.filter((m) => event.members.indexOf(m.user_id) === -1));
8630
- };
8631
- };
8632
- /**
8633
- * Watches for `call.member_updated_permission` events.
8634
- */
8635
- const watchCallMemberUpdatedPermission = (state) => {
8636
- return function onCallMemberUpdated(event) {
8637
- if (event.type !== 'call.member_updated_permission')
8638
- return;
8639
- state.setMembers((members) => members.map((member) => {
8640
- const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
8641
- if (memberUpdate) {
8642
- member.user.role = memberUpdate.role;
8643
- member = Object.assign({}, member);
8644
- }
8645
- return member;
8646
- }));
8647
- };
8648
- };
8649
- /**
8650
- * Watches for `call.member_updated` events.
8651
- */
8652
- const watchCallMemberUpdated = (state) => {
8653
- return function onCallMemberUpdated(event) {
8654
- if (event.type !== 'call.member_updated')
8655
- return;
8656
- state.setMembers((members) => members.map((member) => {
8657
- const memberUpdate = event.members.find((m) => m.user_id === member.user_id);
8658
- return memberUpdate ? memberUpdate : member;
8659
- }));
8660
- };
8661
- };
8662
-
8663
8755
  /**
8664
8756
  * An event responder which handles the `participantJoined` event.
8665
8757
  */
@@ -8741,74 +8833,6 @@ const watchTrackUnpublished = (state) => {
8741
8833
  };
8742
8834
  const unique = (v, i, arr) => arr.indexOf(v) === i;
8743
8835
 
8744
- /**
8745
- * Watches the delivery of CallReactionEvent.
8746
- *
8747
- * @param state the state store to update.
8748
- */
8749
- const watchNewReactions = (state) => {
8750
- return function onNewReactions(event) {
8751
- if (event.type !== 'call.reaction_new')
8752
- return;
8753
- const { reaction } = event;
8754
- const { user, custom, type, emoji_code } = reaction;
8755
- state.setParticipants((participants) => {
8756
- return participants.map((p) => {
8757
- // skip if the reaction is not for this participant
8758
- if (p.userId !== user.id)
8759
- return p;
8760
- // update the participant with the new reaction
8761
- return Object.assign(Object.assign({}, p), { reaction: {
8762
- type,
8763
- emoji_code,
8764
- custom,
8765
- } });
8766
- });
8767
- });
8768
- };
8769
- };
8770
-
8771
- /**
8772
- * Watches for `call.recording_started` events.
8773
- */
8774
- const watchCallRecordingStarted = (state) => {
8775
- return function onCallRecordingStarted(event) {
8776
- if (event.type !== 'call.recording_started')
8777
- return;
8778
- state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { recording: true })));
8779
- };
8780
- };
8781
- /**
8782
- * Watches for `call.recording_stopped` events.
8783
- */
8784
- const watchCallRecordingStopped = (state) => {
8785
- return function onCallRecordingStopped(event) {
8786
- if (event.type !== 'call.recording_stopped')
8787
- return;
8788
- state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { recording: false })));
8789
- };
8790
- };
8791
- /**
8792
- * Watches for `call.broadcasting_started` events.
8793
- */
8794
- const watchCallBroadcastingStarted = (state) => {
8795
- return function onCallBroadcastingStarted(event) {
8796
- if (event.type !== 'call.broadcasting_started')
8797
- return;
8798
- state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { egress: Object.assign(Object.assign({}, metadata.egress), { broadcasting: true, hls: Object.assign(Object.assign({}, metadata.egress.hls), { playlist_url: event.hls_playlist_url }) }) })));
8799
- };
8800
- };
8801
- /**
8802
- * Watches for `call.broadcasting_stopped` events.
8803
- */
8804
- const watchCallBroadcastingStopped = (state) => {
8805
- return function onCallBroadcastingStopped(event) {
8806
- if (event.type !== 'call.broadcasting_stopped')
8807
- return;
8808
- state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { egress: Object.assign(Object.assign({}, metadata.egress), { broadcasting: false }) })));
8809
- };
8810
- };
8811
-
8812
8836
  /**
8813
8837
  * Watches for `dominantSpeakerChanged` events.
8814
8838
  */
@@ -8851,98 +8875,6 @@ const watchAudioLevelChanged = (dispatcher, state) => {
8851
8875
  });
8852
8876
  };
8853
8877
 
8854
- /**
8855
- * Watch for call.session_started events and update the call metadata.
8856
- *
8857
- * @param state the call state.
8858
- */
8859
- const watchCallSessionStarted = (state) => {
8860
- return function onCallSessionStarted(event) {
8861
- if (event.type !== 'call.session_started')
8862
- return;
8863
- state.setMetadata(event.call);
8864
- };
8865
- };
8866
- /**
8867
- * Watch for call.session_ended events and update the call metadata.
8868
- *
8869
- * @param state the call state.
8870
- */
8871
- const watchCallSessionEnded = (state) => {
8872
- return function onCallSessionEnded(event) {
8873
- if (event.type !== 'call.session_ended')
8874
- return;
8875
- state.setMetadata(event.call);
8876
- };
8877
- };
8878
- /**
8879
- * Watch for call.session_participant_joined events and update the call metadata.
8880
- *
8881
- * @param state the call state.
8882
- */
8883
- const watchCallSessionParticipantJoined = (state) => {
8884
- return function onCallParticipantJoined(event) {
8885
- if (event.type !== 'call.session_participant_joined')
8886
- return;
8887
- const { participant } = event;
8888
- state.setMetadata((metadata) => {
8889
- if (!metadata || !metadata.session) {
8890
- state.logger('warn', `Received call.session_participant_joined event but the metadata structure is invalid.`, event);
8891
- return metadata;
8892
- }
8893
- const { session } = metadata;
8894
- const { participants, participants_count_by_role } = session;
8895
- const { user } = participant;
8896
- return Object.assign(Object.assign({}, metadata), { session: Object.assign(Object.assign({}, session), { participants: [...participants, participant], participants_count_by_role: Object.assign(Object.assign({}, participants_count_by_role), { [user.role]: (participants_count_by_role[user.role] || 0) + 1 }) }) });
8897
- });
8898
- };
8899
- };
8900
- /**
8901
- * Watch for call.session_participant_left events and update the call metadata.
8902
- *
8903
- * @param state the call state.
8904
- */
8905
- const watchCallSessionParticipantLeft = (state) => {
8906
- return function onCallParticipantLeft(event) {
8907
- if (event.type !== 'call.session_participant_left')
8908
- return;
8909
- const { user, user_session_id } = event.participant;
8910
- state.setMetadata((metadata) => {
8911
- if (!metadata || !metadata.session) {
8912
- state.logger('warn', `Received call.session_participant_left event but the metadata structure is invalid.`, event);
8913
- return metadata;
8914
- }
8915
- const { session } = metadata;
8916
- const { participants, participants_count_by_role } = session;
8917
- return Object.assign(Object.assign({}, metadata), { session: Object.assign(Object.assign({}, session), { participants: participants.filter((p) => p.user_session_id !== user_session_id), participants_count_by_role: Object.assign(Object.assign({}, participants_count_by_role), { [user.role]: Math.max(0, (participants_count_by_role[user.role] || 0) - 1) }) }) });
8918
- });
8919
- };
8920
- };
8921
-
8922
- /**
8923
- * Event handler that watches for `call.blocked_user` events,
8924
- * updates the call store `blocked_user_ids` property by adding
8925
- * `event.user_id` to the list
8926
- */
8927
- const watchBlockedUser = (state) => (event) => {
8928
- if (event.type !== 'call.blocked_user')
8929
- return;
8930
- state.setMetadata((metadata) => (Object.assign(Object.assign({}, metadata), { blocked_user_ids: [...((metadata === null || metadata === void 0 ? void 0 : metadata.blocked_user_ids) || []), event.user.id] })));
8931
- };
8932
- /**
8933
- * Event handler that watches for `call.unblocked_user` events,
8934
- * updates the call store `blocked_user_ids` property by
8935
- * removing `event.user_id` from the list
8936
- */
8937
- const watchUnblockedUser = (state) => (event) => {
8938
- if (event.type !== 'call.unblocked_user')
8939
- return;
8940
- state.setMetadata((metadata) => {
8941
- const blocked_user_ids = ((metadata === null || metadata === void 0 ? void 0 : metadata.blocked_user_ids) || []).filter((userId) => event.user.id !== userId);
8942
- return Object.assign(Object.assign({}, metadata), { blocked_user_ids });
8943
- });
8944
- };
8945
-
8946
8878
  /**
8947
8879
  * Registers the default event handlers for a call during its lifecycle.
8948
8880
  *
@@ -8951,29 +8883,8 @@ const watchUnblockedUser = (state) => (event) => {
8951
8883
  * @param dispatcher the dispatcher.
8952
8884
  */
8953
8885
  const registerEventHandlers = (call, state, dispatcher) => {
8954
- const coordinatorEvents = {
8955
- 'call.blocked_user': watchBlockedUser(state),
8956
- 'call.broadcasting_started': watchCallBroadcastingStarted(state),
8957
- 'call.broadcasting_stopped': watchCallBroadcastingStopped(state),
8958
- 'call.ended': watchCallEnded(call),
8959
- 'call.live_started': watchCallLiveStarted(state),
8960
- 'call.member_added': watchCallMemberAdded(state),
8961
- 'call.member_removed': watchCallMemberRemoved(state),
8962
- 'call.member_updated': watchCallMemberUpdated(state),
8963
- 'call.member_updated_permission': watchCallMemberUpdatedPermission(state),
8964
- 'call.permissions_updated': watchCallPermissionsUpdated(state),
8965
- 'call.reaction_new': watchNewReactions(state),
8966
- 'call.recording_started': watchCallRecordingStarted(state),
8967
- 'call.recording_stopped': watchCallRecordingStopped(state),
8968
- 'call.session_started': watchCallSessionStarted(state),
8969
- 'call.session_ended': watchCallSessionEnded(state),
8970
- 'call.session_participant_joined': watchCallSessionParticipantJoined(state),
8971
- 'call.session_participant_left': watchCallSessionParticipantLeft(state),
8972
- 'call.unblocked_user': watchUnblockedUser(state),
8973
- 'call.updated': watchCallUpdated(state),
8974
- 'call.user_muted': () => console.log('call.user_muted received'),
8975
- };
8976
8886
  const eventHandlers = [
8887
+ call.on('call.ended', watchCallEnded(call)),
8977
8888
  watchLiveEnded(dispatcher, call),
8978
8889
  watchSfuErrorReports(dispatcher),
8979
8890
  watchChangePublishQuality(dispatcher, call),
@@ -8988,10 +8899,6 @@ const registerEventHandlers = (call, state, dispatcher) => {
8988
8899
  call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
8989
8900
  call.on('pinsUpdated', watchPinsUpdated(state)),
8990
8901
  ];
8991
- Object.keys(coordinatorEvents).forEach((event) => {
8992
- const eventName = event;
8993
- eventHandlers.push(call.on(eventName, coordinatorEvents[eventName]));
8994
- });
8995
8902
  if (call.ringing) {
8996
8903
  // these events are only relevant when the call is ringing
8997
8904
  eventHandlers.push(registerRingingCallEventHandlers(call));
@@ -9621,7 +9528,7 @@ class Call {
9621
9528
  * Use the [`StreamVideoClient.call`](./StreamVideoClient.md/#call)
9622
9529
  * method to construct a `Call` instance.
9623
9530
  */
9624
- constructor({ type, id, streamClient, metadata, members, ownCapabilities, sortParticipantsBy, clientStore, ringing = false, watching = false, }) {
9531
+ constructor({ type, id, streamClient, members, ownCapabilities, sortParticipantsBy, clientStore, ringing = false, watching = false, }) {
9625
9532
  /**
9626
9533
  * ViewportTracker instance
9627
9534
  */
@@ -9700,7 +9607,7 @@ class Call {
9700
9607
  if ((params === null || params === void 0 ? void 0 : params.ring) && !this.ringing) {
9701
9608
  this.ringingSubject.next(true);
9702
9609
  }
9703
- this.state.setMetadata(response.call);
9610
+ this.state.updateFromCallResponse(response.call);
9704
9611
  this.state.setMembers(response.members);
9705
9612
  this.state.setOwnCapabilities(response.own_capabilities);
9706
9613
  if (this.streamClient._hasConnectionID()) {
@@ -9719,7 +9626,7 @@ class Call {
9719
9626
  if ((data === null || data === void 0 ? void 0 : data.ring) && !this.ringing) {
9720
9627
  this.ringingSubject.next(true);
9721
9628
  }
9722
- this.state.setMetadata(response.call);
9629
+ this.state.updateFromCallResponse(response.call);
9723
9630
  this.state.setMembers(response.members);
9724
9631
  this.state.setOwnCapabilities(response.own_capabilities);
9725
9632
  if (this.streamClient._hasConnectionID()) {
@@ -9800,7 +9707,7 @@ class Call {
9800
9707
  let connectionConfig;
9801
9708
  try {
9802
9709
  const call = yield join(this.streamClient, this.type, this.id, data);
9803
- this.state.setMetadata(call.metadata);
9710
+ this.state.updateFromCallResponse(call.metadata);
9804
9711
  this.state.setMembers(call.members);
9805
9712
  this.state.setOwnCapabilities(call.ownCapabilities);
9806
9713
  connectionConfig = call.connectionConfig;
@@ -9965,7 +9872,7 @@ class Call {
9965
9872
  connectionConfig,
9966
9873
  });
9967
9874
  }
9968
- const audioSettings = (_f = this.data) === null || _f === void 0 ? void 0 : _f.settings.audio;
9875
+ const audioSettings = (_f = this.state.settings) === null || _f === void 0 ? void 0 : _f.audio;
9969
9876
  const isDtxEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.opus_dtx_enabled);
9970
9877
  const isRedEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.redundant_coding_enabled);
9971
9878
  if (!this.publisher) {
@@ -10479,9 +10386,12 @@ class Call {
10479
10386
  });
10480
10387
  /**
10481
10388
  * Starts the livestreaming of the call.
10389
+ *
10390
+ * @param data the request data.
10391
+ * @param params the request params.
10482
10392
  */
10483
- this.goLive = (params) => __awaiter(this, void 0, void 0, function* () {
10484
- return this.streamClient.post(`${this.streamClientBasePath}/go_live`, {}, params);
10393
+ this.goLive = (data = {}, params) => __awaiter(this, void 0, void 0, function* () {
10394
+ return this.streamClient.post(`${this.streamClientBasePath}/go_live`, data, params);
10485
10395
  });
10486
10396
  /**
10487
10397
  * Stops the livestreaming of the call.
@@ -10509,7 +10419,7 @@ class Call {
10509
10419
  this.update = (updates) => __awaiter(this, void 0, void 0, function* () {
10510
10420
  const response = yield this.streamClient.patch(`${this.streamClientBasePath}`, updates);
10511
10421
  const { call, members, own_capabilities } = response;
10512
- this.state.setMetadata(call);
10422
+ this.state.updateFromCallResponse(call);
10513
10423
  this.state.setMembers(members);
10514
10424
  this.state.setOwnCapabilities(own_capabilities);
10515
10425
  return response;
@@ -10582,19 +10492,20 @@ class Call {
10582
10492
  this.scheduleAutoDrop = () => {
10583
10493
  if (this.dropTimeout)
10584
10494
  clearTimeout(this.dropTimeout);
10585
- const subscription = this.state.metadata$
10586
- .pipe(pairwise(), tap(([prevMeta, currentMeta]) => {
10587
- if (!(currentMeta && this.clientStore.connectedUser))
10495
+ const subscription = this.state.settings$
10496
+ .pipe(pairwise(), tap(([prevSettings, currentSettings]) => {
10497
+ var _a;
10498
+ if (!currentSettings || !this.clientStore.connectedUser)
10588
10499
  return;
10589
- const isOutgoingCall = this.currentUserId === currentMeta.created_by.id;
10500
+ const isOutgoingCall = this.currentUserId === ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id);
10590
10501
  const [prevTimeoutMs, timeoutMs] = isOutgoingCall
10591
10502
  ? [
10592
- prevMeta === null || prevMeta === void 0 ? void 0 : prevMeta.settings.ring.auto_cancel_timeout_ms,
10593
- currentMeta.settings.ring.auto_cancel_timeout_ms,
10503
+ prevSettings === null || prevSettings === void 0 ? void 0 : prevSettings.ring.auto_cancel_timeout_ms,
10504
+ currentSettings.ring.auto_cancel_timeout_ms,
10594
10505
  ]
10595
10506
  : [
10596
- prevMeta === null || prevMeta === void 0 ? void 0 : prevMeta.settings.ring.incoming_call_timeout_ms,
10597
- currentMeta.settings.ring.incoming_call_timeout_ms,
10507
+ prevSettings === null || prevSettings === void 0 ? void 0 : prevSettings.ring.incoming_call_timeout_ms,
10508
+ currentSettings.ring.incoming_call_timeout_ms,
10598
10509
  ];
10599
10510
  if (typeof timeoutMs === 'undefined' ||
10600
10511
  timeoutMs === prevTimeoutMs ||
@@ -10611,7 +10522,6 @@ class Call {
10611
10522
  };
10612
10523
  /**
10613
10524
  * Retrieves the list of recordings for the current call or call session.
10614
- * Updates the call state with the returned array of CallRecording objects.
10615
10525
  *
10616
10526
  * If `callSessionId` is provided, it will return the recordings for that call session.
10617
10527
  * Otherwise, all recordings for the current call will be returned.
@@ -10623,9 +10533,7 @@ class Call {
10623
10533
  if (callSessionId) {
10624
10534
  endpoint = `${endpoint}/${callSessionId}`;
10625
10535
  }
10626
- const response = yield this.streamClient.get(`${endpoint}/recordings`);
10627
- this.state.setCallRecordingsList(response.recordings);
10628
- return response;
10536
+ return this.streamClient.get(`${endpoint}/recordings`);
10629
10537
  });
10630
10538
  /**
10631
10539
  * Sends a custom event to all call participants.
@@ -10649,21 +10557,24 @@ class Call {
10649
10557
  if (participantSorter) {
10650
10558
  this.state.setSortParticipantsBy(participantSorter);
10651
10559
  }
10652
- this.state.setMetadata(metadata);
10653
10560
  this.state.setMembers(members || []);
10654
10561
  this.state.setOwnCapabilities(ownCapabilities || []);
10655
10562
  this.state.setCallingState(ringing ? CallingState.RINGING : CallingState.IDLE);
10563
+ this.on('all', (event) => {
10564
+ // update state with the latest event data
10565
+ this.state.updateFromEvent(event);
10566
+ });
10656
10567
  this.leaveCallHooks.push(registerEventHandlers(this, this.state, this.dispatcher));
10657
10568
  this.registerEffects();
10658
10569
  this.leaveCallHooks.push(createSubscription(this.trackSubscriptionsSubject.pipe(debounce((v) => timer(v.type)), map$2((v) => v.data)), (subscriptions) => { var _a; return (_a = this.sfuClient) === null || _a === void 0 ? void 0 : _a.updateSubscriptions(subscriptions); }));
10659
10570
  }
10660
10571
  registerEffects() {
10661
10572
  this.leaveCallHooks.push(
10662
- // handles updating the permissions context when the metadata changes.
10663
- createSubscription(this.state.metadata$, (metadata) => {
10664
- if (!metadata)
10573
+ // handles updating the permissions context when the settings change.
10574
+ createSubscription(this.state.settings$, (settings) => {
10575
+ if (!settings)
10665
10576
  return;
10666
- this.permissionsContext.setCallSettings(metadata.settings);
10577
+ this.permissionsContext.setCallSettings(settings);
10667
10578
  }),
10668
10579
  // handle the case when the user permissions are modified.
10669
10580
  createSubscription(this.state.ownCapabilities$, (ownCapabilities) => {
@@ -10687,12 +10598,11 @@ class Call {
10687
10598
  }
10688
10599
  }),
10689
10600
  // handles the case when the user is blocked by the call owner.
10690
- createSubscription(this.state.metadata$, (metadata) => __awaiter(this, void 0, void 0, function* () {
10691
- if (!metadata)
10601
+ createSubscription(this.state.blockedUserIds$, (blockedUserIds) => __awaiter(this, void 0, void 0, function* () {
10602
+ if (!blockedUserIds)
10692
10603
  return;
10693
10604
  const currentUserId = this.currentUserId;
10694
- if (currentUserId &&
10695
- metadata.blocked_user_ids.includes(currentUserId)) {
10605
+ if (currentUserId && blockedUserIds.includes(currentUserId)) {
10696
10606
  this.logger('info', 'Leaving call because of being blocked');
10697
10607
  yield this.leave();
10698
10608
  }
@@ -10744,12 +10654,6 @@ class Call {
10744
10654
  }
10745
10655
  }
10746
10656
  }
10747
- /**
10748
- * A getter for the call metadata.
10749
- */
10750
- get data() {
10751
- return this.state.metadata;
10752
- }
10753
10657
  /**
10754
10658
  * A flag indicating whether the call is "ringing" type of call.
10755
10659
  */
@@ -10768,7 +10672,7 @@ class Call {
10768
10672
  */
10769
10673
  get isCreatedByMe() {
10770
10674
  var _a;
10771
- return ((_a = this.state.metadata) === null || _a === void 0 ? void 0 : _a.created_by.id) === this.currentUserId;
10675
+ return ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id) === this.currentUserId;
10772
10676
  }
10773
10677
  }
10774
10678
 
@@ -11881,7 +11785,7 @@ class WSConnectionFallback {
11881
11785
  }
11882
11786
  }
11883
11787
 
11884
- const version = '0.2.2';
11788
+ const version = '0.3.0';
11885
11789
 
11886
11790
  const logger = getLogger(['location']);
11887
11791
  const HINT_URL = `https://hint.stream-io-video.com/`;
@@ -12575,12 +12479,12 @@ class StreamVideoClient {
12575
12479
  streamClient: this.streamClient,
12576
12480
  id: c.call.id,
12577
12481
  type: c.call.type,
12578
- metadata: c.call,
12579
12482
  members: c.members,
12580
12483
  ownCapabilities: c.own_capabilities,
12581
12484
  watching: data.watch,
12582
12485
  clientStore: this.writeableStateStore,
12583
12486
  });
12487
+ call.state.updateFromCallResponse(c.call);
12584
12488
  if (data.watch) {
12585
12489
  this.writeableStateStore.registerCall(call);
12586
12490
  }
@@ -12588,9 +12492,9 @@ class StreamVideoClient {
12588
12492
  });
12589
12493
  return Object.assign(Object.assign({}, response), { calls: calls });
12590
12494
  });
12591
- this.queryUsers = () => __awaiter(this, void 0, void 0, function* () {
12592
- console.log('Querying users is not implemented yet.');
12593
- });
12495
+ /**
12496
+ * Returns a list of available data centers available for hosting calls.
12497
+ */
12594
12498
  this.edges = () => __awaiter(this, void 0, void 0, function* () {
12595
12499
  return this.streamClient.get(`/edges`);
12596
12500
  });
@@ -12765,14 +12669,15 @@ class StreamVideoClient {
12765
12669
  return;
12766
12670
  }
12767
12671
  this.logger('info', `New call created and registered: ${call.cid}`);
12768
- this.writeableStateStore.registerCall(new Call({
12672
+ const newCall = new Call({
12769
12673
  streamClient: this.streamClient,
12770
12674
  type: call.type,
12771
12675
  id: call.id,
12772
- metadata: call,
12773
12676
  members,
12774
12677
  clientStore: this.writeableStateStore,
12775
- }));
12678
+ });
12679
+ newCall.state.updateFromCallResponse(call);
12680
+ this.writeableStateStore.registerCall(newCall);
12776
12681
  }));
12777
12682
  this.eventHandlersToUnregister.push(this.on('call.ring', (event) => __awaiter(this, void 0, void 0, function* () {
12778
12683
  if (event.type !== 'call.ring')
@@ -12786,7 +12691,6 @@ class StreamVideoClient {
12786
12691
  // if `call.created` was received before `call.ring`.
12787
12692
  // In that case, we cleanup the already tracked call.
12788
12693
  const prevCall = this.writeableStateStore.findCall(call.type, call.id);
12789
- const prevMetadata = prevCall === null || prevCall === void 0 ? void 0 : prevCall.state.metadata;
12790
12694
  yield (prevCall === null || prevCall === void 0 ? void 0 : prevCall.leave());
12791
12695
  // we create a new call
12792
12696
  const theCall = new Call({
@@ -12796,8 +12700,8 @@ class StreamVideoClient {
12796
12700
  members,
12797
12701
  clientStore: this.writeableStateStore,
12798
12702
  ringing: true,
12799
- metadata: prevMetadata,
12800
12703
  });
12704
+ theCall.state.updateFromCallResponse(call);
12801
12705
  // we fetch the latest metadata for the call from the server
12802
12706
  yield theCall.get();
12803
12707
  this.writeableStateStore.registerCall(theCall);