@stream-io/video-client 0.7.9 → 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/dist/index.cjs.js CHANGED
@@ -6864,6 +6864,7 @@ class CallState {
6864
6864
  this.anonymousParticipantCountSubject = new rxjs.BehaviorSubject(0);
6865
6865
  this.participantsSubject = new rxjs.BehaviorSubject([]);
6866
6866
  this.callStatsReportSubject = new rxjs.BehaviorSubject(undefined);
6867
+ this.logger = getLogger(['CallState']);
6867
6868
  /**
6868
6869
  * A list of comparators that are used to sort the participants.
6869
6870
  *
@@ -7024,21 +7025,22 @@ class CallState {
7024
7025
  * @param participant the participant to update or add.
7025
7026
  */
7026
7027
  this.updateOrAddParticipant = (sessionId, participant) => {
7027
- if (!this.findParticipantBySessionId(sessionId)) {
7028
- return this.setParticipants((participants) => [
7029
- ...participants,
7030
- participant,
7031
- ]);
7032
- }
7033
- return this.setParticipants((participants) => participants.map((p) => {
7034
- if (p.sessionId === sessionId) {
7035
- return {
7036
- ...p,
7037
- ...participant,
7038
- };
7039
- }
7040
- return p;
7041
- }));
7028
+ return this.setParticipants((participants) => {
7029
+ let add = true;
7030
+ const nextParticipants = participants.map((p) => {
7031
+ if (p.sessionId === sessionId) {
7032
+ add = false;
7033
+ return {
7034
+ ...p,
7035
+ ...participant,
7036
+ };
7037
+ }
7038
+ return p;
7039
+ });
7040
+ if (add)
7041
+ nextParticipants.push(participant);
7042
+ return nextParticipants;
7043
+ });
7042
7044
  };
7043
7045
  /**
7044
7046
  * Updates all participants in the current call whose session ID is in the given `sessionIds`.
@@ -7263,7 +7265,6 @@ class CallState {
7263
7265
  this.setCurrentValue(this.ownCapabilitiesSubject, event.own_capabilities);
7264
7266
  }
7265
7267
  };
7266
- this.logger = getLogger(['CallState']);
7267
7268
  this.participants$ = this.participantsSubject.asObservable().pipe(
7268
7269
  // maintain stable-sort by mutating the participants stored
7269
7270
  // in the original subject
@@ -7273,30 +7274,52 @@ class CallState {
7273
7274
  this.pinnedParticipants$ = this.participants$.pipe(rxjs.map((participants) => participants.filter((p) => !!p.pin)), rxjs.shareReplay({ bufferSize: 1, refCount: true }));
7274
7275
  this.dominantSpeaker$ = this.participants$.pipe(rxjs.map((participants) => participants.find((p) => p.isDominantSpeaker)), rxjs.shareReplay({ bufferSize: 1, refCount: true }));
7275
7276
  this.hasOngoingScreenShare$ = this.participants$.pipe(rxjs.map((participants) => participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE))), rxjs.distinctUntilChanged(), rxjs.shareReplay({ bufferSize: 1, refCount: true }));
7276
- this.startedAt$ = this.startedAtSubject.asObservable();
7277
- this.participantCount$ = this.participantCountSubject.asObservable();
7278
- this.anonymousParticipantCount$ =
7279
- this.anonymousParticipantCountSubject.asObservable();
7280
- this.callStatsReport$ = this.callStatsReportSubject.asObservable();
7281
- this.members$ = this.membersSubject.asObservable();
7282
- this.ownCapabilities$ = this.ownCapabilitiesSubject.asObservable();
7283
- this.callingState$ = this.callingStateSubject.asObservable();
7284
- this.backstage$ = this.backstageSubject.asObservable();
7285
- this.blockedUserIds$ = this.blockedUserIdsSubject.asObservable();
7277
+ // dates
7286
7278
  this.createdAt$ = this.createdAtSubject.asObservable();
7287
7279
  this.endedAt$ = this.endedAtSubject.asObservable();
7288
7280
  this.startsAt$ = this.startsAtSubject.asObservable();
7281
+ this.startedAt$ = this.startedAtSubject.asObservable();
7289
7282
  this.updatedAt$ = this.updatedAtSubject.asObservable();
7283
+ this.callStatsReport$ = this.callStatsReportSubject.asObservable();
7284
+ this.members$ = this.membersSubject.asObservable();
7285
+ // complex objects should work as streams of data
7290
7286
  this.createdBy$ = this.createdBySubject.asObservable();
7291
7287
  this.custom$ = this.customSubject.asObservable();
7292
7288
  this.egress$ = this.egressSubject.asObservable();
7293
7289
  this.ingress$ = this.ingressSubject.asObservable();
7294
- this.recording$ = this.recordingSubject.asObservable();
7295
7290
  this.session$ = this.sessionSubject.asObservable();
7296
7291
  this.settings$ = this.settingsSubject.asObservable();
7297
- this.transcribing$ = this.transcribingSubject.asObservable();
7298
7292
  this.endedBy$ = this.endedBySubject.asObservable();
7299
7293
  this.thumbnails$ = this.thumbnailsSubject.asObservable();
7294
+ /**
7295
+ * Performs shallow comparison of two arrays.
7296
+ * Expects primitive values: [1, 2, 3] is equal to [2, 1, 3].
7297
+ */
7298
+ const isShallowEqual = (a, b) => {
7299
+ if (a.length !== b.length)
7300
+ return false;
7301
+ for (const item of a)
7302
+ if (!b.includes(item))
7303
+ return false;
7304
+ for (const item of b)
7305
+ if (!a.includes(item))
7306
+ return false;
7307
+ return true;
7308
+ };
7309
+ /**
7310
+ * Creates an Observable from the given subject by piping to the
7311
+ * `distinctUntilChanged()` operator.
7312
+ */
7313
+ const duc = (subject, comparator) => subject.asObservable().pipe(rxjs.distinctUntilChanged(comparator));
7314
+ // primitive values should only emit once the value they hold changes
7315
+ this.anonymousParticipantCount$ = duc(this.anonymousParticipantCountSubject);
7316
+ this.blockedUserIds$ = duc(this.blockedUserIdsSubject, isShallowEqual);
7317
+ this.backstage$ = duc(this.backstageSubject);
7318
+ this.callingState$ = duc(this.callingStateSubject);
7319
+ this.ownCapabilities$ = duc(this.ownCapabilitiesSubject, isShallowEqual);
7320
+ this.participantCount$ = duc(this.participantCountSubject);
7321
+ this.recording$ = duc(this.recordingSubject);
7322
+ this.transcribing$ = duc(this.transcribingSubject);
7300
7323
  this.eventHandlers = {
7301
7324
  // these events are not updating the call state:
7302
7325
  'call.closed_caption': undefined,
@@ -14861,7 +14884,7 @@ class StreamClient {
14861
14884
  });
14862
14885
  };
14863
14886
  this.getUserAgent = () => {
14864
- const version = "0.7.9" ;
14887
+ const version = "0.7.10" ;
14865
14888
  return (this.userAgent ||
14866
14889
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
14867
14890
  };