@stream-io/video-client 1.5.0 → 1.5.2

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
@@ -6556,7 +6556,7 @@ function getIceCandidate(candidate) {
6556
6556
  }
6557
6557
  }
6558
6558
 
6559
- const version = "1.5.0" ;
6559
+ const version = "1.5.2" ;
6560
6560
  const [major, minor, patch] = version.split('.');
6561
6561
  let sdkInfo = {
6562
6562
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -7554,7 +7554,8 @@ class CallState {
7554
7554
  this.setCurrentValue(this.egressSubject, call.egress);
7555
7555
  this.setCurrentValue(this.ingressSubject, call.ingress);
7556
7556
  this.setCurrentValue(this.recordingSubject, call.recording);
7557
- this.setCurrentValue(this.sessionSubject, call.session);
7557
+ const s = this.setCurrentValue(this.sessionSubject, call.session);
7558
+ this.updateParticipantCountFromSession(s);
7558
7559
  this.setCurrentValue(this.settingsSubject, call.settings);
7559
7560
  this.setCurrentValue(this.transcribingSubject, call.transcribing);
7560
7561
  this.setCurrentValue(this.thumbnailsSubject, call.thumbnails);
@@ -7592,12 +7593,32 @@ class CallState {
7592
7593
  },
7593
7594
  }));
7594
7595
  };
7596
+ this.updateParticipantCountFromSession = (session) => {
7597
+ // when in JOINED state, we should use the participant count coming through
7598
+ // the SFU healthcheck event, as it's more accurate.
7599
+ if (!session || this.callingState === exports.CallingState.JOINED)
7600
+ return;
7601
+ const byRoleCount = Object.values(session.participants_count_by_role).reduce((total, countByRole) => total + countByRole, 0);
7602
+ const participantCount = Math.max(byRoleCount, session.participants.length);
7603
+ this.setParticipantCount(participantCount);
7604
+ this.setAnonymousParticipantCount(session.anonymous_participant_count || 0);
7605
+ };
7606
+ this.updateFromSessionParticipantCountUpdate = (event) => {
7607
+ const s = this.setCurrentValue(this.sessionSubject, (session) => {
7608
+ if (!session)
7609
+ return session;
7610
+ return {
7611
+ ...session,
7612
+ anonymous_participant_count: event.anonymous_participant_count,
7613
+ participants_count_by_role: event.participants_count_by_role,
7614
+ };
7615
+ });
7616
+ this.updateParticipantCountFromSession(s);
7617
+ };
7595
7618
  this.updateFromSessionParticipantLeft = (event) => {
7596
- this.setCurrentValue(this.sessionSubject, (session) => {
7597
- if (!session) {
7598
- this.logger('warn', `Received call.session_participant_left event but no session is available.`, event);
7619
+ const s = this.setCurrentValue(this.sessionSubject, (session) => {
7620
+ if (!session)
7599
7621
  return session;
7600
- }
7601
7622
  const { participants, participants_count_by_role } = session;
7602
7623
  const { user, user_session_id } = event.participant;
7603
7624
  return {
@@ -7609,13 +7630,12 @@ class CallState {
7609
7630
  },
7610
7631
  };
7611
7632
  });
7633
+ this.updateParticipantCountFromSession(s);
7612
7634
  };
7613
7635
  this.updateFromSessionParticipantJoined = (event) => {
7614
- this.setCurrentValue(this.sessionSubject, (session) => {
7615
- if (!session) {
7616
- this.logger('warn', `Received call.session_participant_joined event but no session is available.`, event);
7636
+ const s = this.setCurrentValue(this.sessionSubject, (session) => {
7637
+ if (!session)
7617
7638
  return session;
7618
- }
7619
7639
  const { participants, participants_count_by_role } = session;
7620
7640
  const { user, user_session_id } = event.participant;
7621
7641
  // It could happen that the backend delivers the same participant more than once.
@@ -7646,6 +7666,7 @@ class CallState {
7646
7666
  },
7647
7667
  };
7648
7668
  });
7669
+ this.updateParticipantCountFromSession(s);
7649
7670
  };
7650
7671
  this.updateMembers = (event) => {
7651
7672
  this.updateFromCallResponse(event.call);
@@ -7795,6 +7816,7 @@ class CallState {
7795
7816
  'call.ring': (e) => this.updateFromCallResponse(e.call),
7796
7817
  'call.missed': (e) => this.updateFromCallResponse(e.call),
7797
7818
  'call.session_ended': (e) => this.updateFromCallResponse(e.call),
7819
+ 'call.session_participant_count_updated': this.updateFromSessionParticipantCountUpdate,
7798
7820
  'call.session_participant_joined': this.updateFromSessionParticipantJoined,
7799
7821
  'call.session_participant_left': this.updateFromSessionParticipantLeft,
7800
7822
  'call.session_started': (e) => this.updateFromCallResponse(e.call),
@@ -13952,12 +13974,12 @@ class Call {
13952
13974
  return;
13953
13975
  const callSession = this.state.session;
13954
13976
  const receiver_id = this.clientStore.connectedUser?.id;
13955
- const endedAt = this.state.endedAt;
13977
+ const ended_at = callSession?.ended_at;
13956
13978
  const created_by_id = this.state.createdBy?.id;
13957
13979
  const rejected_by = callSession?.rejected_by;
13958
13980
  const accepted_by = callSession?.accepted_by;
13959
13981
  let leaveCallIdle = false;
13960
- if (endedAt) {
13982
+ if (ended_at) {
13961
13983
  // call was ended before it was accepted or rejected so we should leave it to idle
13962
13984
  leaveCallIdle = true;
13963
13985
  }
@@ -13985,10 +14007,10 @@ class Call {
13985
14007
  }
13986
14008
  }
13987
14009
  else {
13988
- this.scheduleAutoDrop();
13989
14010
  if (this.state.callingState === exports.CallingState.IDLE) {
13990
14011
  this.state.setCallingState(exports.CallingState.RINGING);
13991
14012
  }
14013
+ this.scheduleAutoDrop();
13992
14014
  this.leaveCallHooks.add(registerRingingCallEventHandlers(this));
13993
14015
  }
13994
14016
  }));
@@ -15591,7 +15613,7 @@ class StreamClient {
15591
15613
  });
15592
15614
  };
15593
15615
  this.getUserAgent = () => {
15594
- const version = "1.5.0" ;
15616
+ const version = "1.5.2" ;
15595
15617
  return (this.userAgent ||
15596
15618
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
15597
15619
  };