@stream-io/video-client 0.7.8 → 0.7.10

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.7.10](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.7.9...@stream-io/video-client-0.7.10) (2024-04-30)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **state:** optimized Call State updates ([#1330](https://github.com/GetStream/stream-video-js/issues/1330)) ([e5f9f88](https://github.com/GetStream/stream-video-js/commit/e5f9f882df95761bfecbd6b38832f013b0e7a75e))
11
+
12
+ ### [0.7.9](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.7.8...@stream-io/video-client-0.7.9) (2024-04-26)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * update call state with transcription events ([ab933ae](https://github.com/GetStream/stream-video-js/commit/ab933aee820fae199935380c7bab6edc7790f0ca))
18
+
5
19
  ### [0.7.8](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.7.7...@stream-io/video-client-0.7.8) (2024-04-25)
6
20
 
7
21
 
@@ -6843,6 +6843,7 @@ class CallState {
6843
6843
  this.anonymousParticipantCountSubject = new BehaviorSubject(0);
6844
6844
  this.participantsSubject = new BehaviorSubject([]);
6845
6845
  this.callStatsReportSubject = new BehaviorSubject(undefined);
6846
+ this.logger = getLogger(['CallState']);
6846
6847
  /**
6847
6848
  * A list of comparators that are used to sort the participants.
6848
6849
  *
@@ -7003,21 +7004,22 @@ class CallState {
7003
7004
  * @param participant the participant to update or add.
7004
7005
  */
7005
7006
  this.updateOrAddParticipant = (sessionId, participant) => {
7006
- if (!this.findParticipantBySessionId(sessionId)) {
7007
- return this.setParticipants((participants) => [
7008
- ...participants,
7009
- participant,
7010
- ]);
7011
- }
7012
- return this.setParticipants((participants) => participants.map((p) => {
7013
- if (p.sessionId === sessionId) {
7014
- return {
7015
- ...p,
7016
- ...participant,
7017
- };
7018
- }
7019
- return p;
7020
- }));
7007
+ return this.setParticipants((participants) => {
7008
+ let add = true;
7009
+ const nextParticipants = participants.map((p) => {
7010
+ if (p.sessionId === sessionId) {
7011
+ add = false;
7012
+ return {
7013
+ ...p,
7014
+ ...participant,
7015
+ };
7016
+ }
7017
+ return p;
7018
+ });
7019
+ if (add)
7020
+ nextParticipants.push(participant);
7021
+ return nextParticipants;
7022
+ });
7021
7023
  };
7022
7024
  /**
7023
7025
  * Updates all participants in the current call whose session ID is in the given `sessionIds`.
@@ -7242,7 +7244,6 @@ class CallState {
7242
7244
  this.setCurrentValue(this.ownCapabilitiesSubject, event.own_capabilities);
7243
7245
  }
7244
7246
  };
7245
- this.logger = getLogger(['CallState']);
7246
7247
  this.participants$ = this.participantsSubject.asObservable().pipe(
7247
7248
  // maintain stable-sort by mutating the participants stored
7248
7249
  // in the original subject
@@ -7252,40 +7253,60 @@ class CallState {
7252
7253
  this.pinnedParticipants$ = this.participants$.pipe(map$1((participants) => participants.filter((p) => !!p.pin)), shareReplay({ bufferSize: 1, refCount: true }));
7253
7254
  this.dominantSpeaker$ = this.participants$.pipe(map$1((participants) => participants.find((p) => p.isDominantSpeaker)), shareReplay({ bufferSize: 1, refCount: true }));
7254
7255
  this.hasOngoingScreenShare$ = this.participants$.pipe(map$1((participants) => participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE))), distinctUntilChanged(), shareReplay({ bufferSize: 1, refCount: true }));
7255
- this.startedAt$ = this.startedAtSubject.asObservable();
7256
- this.participantCount$ = this.participantCountSubject.asObservable();
7257
- this.anonymousParticipantCount$ =
7258
- this.anonymousParticipantCountSubject.asObservable();
7259
- this.callStatsReport$ = this.callStatsReportSubject.asObservable();
7260
- this.members$ = this.membersSubject.asObservable();
7261
- this.ownCapabilities$ = this.ownCapabilitiesSubject.asObservable();
7262
- this.callingState$ = this.callingStateSubject.asObservable();
7263
- this.backstage$ = this.backstageSubject.asObservable();
7264
- this.blockedUserIds$ = this.blockedUserIdsSubject.asObservable();
7256
+ // dates
7265
7257
  this.createdAt$ = this.createdAtSubject.asObservable();
7266
7258
  this.endedAt$ = this.endedAtSubject.asObservable();
7267
7259
  this.startsAt$ = this.startsAtSubject.asObservable();
7260
+ this.startedAt$ = this.startedAtSubject.asObservable();
7268
7261
  this.updatedAt$ = this.updatedAtSubject.asObservable();
7262
+ this.callStatsReport$ = this.callStatsReportSubject.asObservable();
7263
+ this.members$ = this.membersSubject.asObservable();
7264
+ // complex objects should work as streams of data
7269
7265
  this.createdBy$ = this.createdBySubject.asObservable();
7270
7266
  this.custom$ = this.customSubject.asObservable();
7271
7267
  this.egress$ = this.egressSubject.asObservable();
7272
7268
  this.ingress$ = this.ingressSubject.asObservable();
7273
- this.recording$ = this.recordingSubject.asObservable();
7274
7269
  this.session$ = this.sessionSubject.asObservable();
7275
7270
  this.settings$ = this.settingsSubject.asObservable();
7276
- this.transcribing$ = this.transcribingSubject.asObservable();
7277
7271
  this.endedBy$ = this.endedBySubject.asObservable();
7278
7272
  this.thumbnails$ = this.thumbnailsSubject.asObservable();
7273
+ /**
7274
+ * Performs shallow comparison of two arrays.
7275
+ * Expects primitive values: [1, 2, 3] is equal to [2, 1, 3].
7276
+ */
7277
+ const isShallowEqual = (a, b) => {
7278
+ if (a.length !== b.length)
7279
+ return false;
7280
+ for (const item of a)
7281
+ if (!b.includes(item))
7282
+ return false;
7283
+ for (const item of b)
7284
+ if (!a.includes(item))
7285
+ return false;
7286
+ return true;
7287
+ };
7288
+ /**
7289
+ * Creates an Observable from the given subject by piping to the
7290
+ * `distinctUntilChanged()` operator.
7291
+ */
7292
+ const duc = (subject, comparator) => subject.asObservable().pipe(distinctUntilChanged(comparator));
7293
+ // primitive values should only emit once the value they hold changes
7294
+ this.anonymousParticipantCount$ = duc(this.anonymousParticipantCountSubject);
7295
+ this.blockedUserIds$ = duc(this.blockedUserIdsSubject, isShallowEqual);
7296
+ this.backstage$ = duc(this.backstageSubject);
7297
+ this.callingState$ = duc(this.callingStateSubject);
7298
+ this.ownCapabilities$ = duc(this.ownCapabilitiesSubject, isShallowEqual);
7299
+ this.participantCount$ = duc(this.participantCountSubject);
7300
+ this.recording$ = duc(this.recordingSubject);
7301
+ this.transcribing$ = duc(this.transcribingSubject);
7279
7302
  this.eventHandlers = {
7280
7303
  // these events are not updating the call state:
7281
7304
  'call.closed_caption': undefined,
7305
+ 'call.deleted': undefined,
7282
7306
  'call.permission_request': undefined,
7283
7307
  'call.recording_failed': undefined,
7284
7308
  'call.recording_ready': undefined,
7285
- 'call.transcription_started': undefined,
7286
- 'call.transcription_stopped': undefined,
7287
7309
  'call.transcription_ready': undefined,
7288
- 'call.transcription_failed': undefined,
7289
7310
  'call.user_muted': undefined,
7290
7311
  'connection.error': undefined,
7291
7312
  'connection.ok': undefined,
@@ -7321,9 +7342,17 @@ class CallState {
7321
7342
  'call.session_participant_joined': this.updateFromSessionParticipantJoined,
7322
7343
  'call.session_participant_left': this.updateFromSessionParticipantLeft,
7323
7344
  'call.session_started': (e) => this.updateFromCallResponse(e.call),
7345
+ 'call.transcription_started': () => {
7346
+ this.setCurrentValue(this.transcribingSubject, true);
7347
+ },
7348
+ 'call.transcription_stopped': () => {
7349
+ this.setCurrentValue(this.transcribingSubject, false);
7350
+ },
7351
+ 'call.transcription_failed': () => {
7352
+ this.setCurrentValue(this.transcribingSubject, false);
7353
+ },
7324
7354
  'call.unblocked_user': this.unblockUser,
7325
7355
  'call.updated': (e) => this.updateFromCallResponse(e.call),
7326
- 'call.deleted': undefined,
7327
7356
  };
7328
7357
  }
7329
7358
  /**
@@ -14836,7 +14865,7 @@ class StreamClient {
14836
14865
  });
14837
14866
  };
14838
14867
  this.getUserAgent = () => {
14839
- const version = "0.7.8" ;
14868
+ const version = "0.7.10" ;
14840
14869
  return (this.userAgent ||
14841
14870
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
14842
14871
  };