@stream-io/video-client 0.0.29 → 0.0.31

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.0.31](https://github.com/GetStream/stream-video-js/compare/client0.0.30...client0.0.31) (2023-07-03)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * safeguard against potential race conditions during join-flow ([#741](https://github.com/GetStream/stream-video-js/issues/741)) ([54f1ef6](https://github.com/GetStream/stream-video-js/commit/54f1ef636d3c46b29c538a8c2c7bc5031fde43c9))
11
+
12
+ ### [0.0.30](https://github.com/GetStream/stream-video-js/compare/client0.0.29...client0.0.30) (2023-07-03)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * dont use window search in react native ([4883512](https://github.com/GetStream/stream-video-js/commit/4883512692bf6626b5ac9df6e80384843ec0917d))
18
+
5
19
  ### [0.0.29](https://github.com/GetStream/stream-video-js/compare/client0.0.28...client0.0.29) (2023-07-03)
6
20
 
7
21
 
@@ -8162,38 +8162,45 @@ const watchCallMemberUpdated = (state) => {
8162
8162
  /**
8163
8163
  * An event responder which handles the `participantJoined` event.
8164
8164
  */
8165
- const watchParticipantJoined = (dispatcher, state) => {
8166
- return dispatcher.on('participantJoined', (e) => {
8165
+ const watchParticipantJoined = (state) => {
8166
+ return function onParticipantJoined(e) {
8167
8167
  if (e.eventPayload.oneofKind !== 'participantJoined')
8168
8168
  return;
8169
8169
  const { participant } = e.eventPayload.participantJoined;
8170
8170
  if (!participant)
8171
8171
  return;
8172
- state.setParticipants((participants) => [
8173
- ...participants,
8174
- Object.assign(Object.assign({}, participant), { viewportVisibilityState: VisibilityState.UNKNOWN }),
8175
- ]);
8176
- });
8172
+ // `state.updateOrAddParticipant` acts as a safeguard against
8173
+ // potential duplicate events from the SFU.
8174
+ //
8175
+ // Although the SFU should not send duplicate events, we have seen
8176
+ // some race conditions in the past during the `join-flow` where
8177
+ // the SFU would send participant info as part of the `join`
8178
+ // response and then follow up with a `participantJoined` event for
8179
+ // already announced participants.
8180
+ state.updateOrAddParticipant(participant.sessionId, Object.assign(participant, {
8181
+ viewportVisibilityState: VisibilityState.UNKNOWN,
8182
+ }));
8183
+ };
8177
8184
  };
8178
8185
  /**
8179
8186
  * An event responder which handles the `participantLeft` event.
8180
8187
  */
8181
- const watchParticipantLeft = (dispatcher, state) => {
8182
- return dispatcher.on('participantLeft', (e) => {
8188
+ const watchParticipantLeft = (state) => {
8189
+ return function onParticipantLeft(e) {
8183
8190
  if (e.eventPayload.oneofKind !== 'participantLeft')
8184
8191
  return;
8185
8192
  const { participant } = e.eventPayload.participantLeft;
8186
8193
  if (!participant)
8187
8194
  return;
8188
8195
  state.setParticipants((participants) => participants.filter((p) => p.sessionId !== participant.sessionId));
8189
- });
8196
+ };
8190
8197
  };
8191
8198
  /**
8192
8199
  * An event responder which handles the `trackPublished` event.
8193
8200
  * The SFU will send this event when a participant publishes a track.
8194
8201
  */
8195
- const watchTrackPublished = (dispatcher, state) => {
8196
- return dispatcher.on('trackPublished', (e) => {
8202
+ const watchTrackPublished = (state) => {
8203
+ return function onTrackPublished(e) {
8197
8204
  if (e.eventPayload.oneofKind !== 'trackPublished')
8198
8205
  return;
8199
8206
  const { trackPublished: { type, sessionId, participant }, } = e.eventPayload;
@@ -8202,34 +8209,34 @@ const watchTrackPublished = (dispatcher, state) => {
8202
8209
  // events, and instead, it would only provide the participant's information
8203
8210
  // once they start publishing a track.
8204
8211
  if (participant) {
8205
- state.updateOrAddParticipant(participant.sessionId, participant);
8212
+ state.updateOrAddParticipant(sessionId, participant);
8206
8213
  }
8207
8214
  else {
8208
8215
  state.updateParticipant(sessionId, (p) => ({
8209
8216
  publishedTracks: [...p.publishedTracks, type].filter(unique),
8210
8217
  }));
8211
8218
  }
8212
- });
8219
+ };
8213
8220
  };
8214
8221
  /**
8215
8222
  * An event responder which handles the `trackUnpublished` event.
8216
8223
  * The SFU will send this event when a participant unpublishes a track.
8217
8224
  */
8218
- const watchTrackUnpublished = (dispatcher, state) => {
8219
- return dispatcher.on('trackUnpublished', (e) => {
8225
+ const watchTrackUnpublished = (state) => {
8226
+ return function onTrackUnpublished(e) {
8220
8227
  if (e.eventPayload.oneofKind !== 'trackUnpublished')
8221
8228
  return;
8222
8229
  const { trackUnpublished: { type, sessionId, participant }, } = e.eventPayload;
8223
8230
  // An optimization for large calls. See `watchTrackPublished`.
8224
8231
  if (participant) {
8225
- state.updateOrAddParticipant(participant.sessionId, participant);
8232
+ state.updateOrAddParticipant(sessionId, participant);
8226
8233
  }
8227
8234
  else {
8228
8235
  state.updateParticipant(sessionId, (p) => ({
8229
8236
  publishedTracks: p.publishedTracks.filter((t) => t !== type),
8230
8237
  }));
8231
8238
  }
8232
- });
8239
+ };
8233
8240
  };
8234
8241
  const unique = (v, i, arr) => arr.indexOf(v) === i;
8235
8242
 
@@ -8477,10 +8484,10 @@ const registerEventHandlers = (call, state, dispatcher) => {
8477
8484
  watchChangePublishQuality(dispatcher, call),
8478
8485
  watchConnectionQualityChanged(dispatcher, state),
8479
8486
  watchParticipantCountChanged(dispatcher, state),
8480
- watchParticipantJoined(dispatcher, state),
8481
- watchParticipantLeft(dispatcher, state),
8482
- watchTrackPublished(dispatcher, state),
8483
- watchTrackUnpublished(dispatcher, state),
8487
+ call.on('participantJoined', watchParticipantJoined(state)),
8488
+ call.on('participantLeft', watchParticipantLeft(state)),
8489
+ call.on('trackPublished', watchTrackPublished(state)),
8490
+ call.on('trackUnpublished', watchTrackUnpublished(state)),
8484
8491
  watchAudioLevelChanged(dispatcher, state),
8485
8492
  watchDominantSpeakerChanged(dispatcher, state),
8486
8493
  call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
@@ -8589,9 +8596,10 @@ const toRtcConfiguration = (config) => {
8589
8596
  return rtcConfig;
8590
8597
  };
8591
8598
  const getCascadingModeParams = () => {
8599
+ var _a;
8592
8600
  if (typeof window === 'undefined')
8593
8601
  return null;
8594
- const params = new URLSearchParams(window.location.search);
8602
+ const params = new URLSearchParams((_a = window.location) === null || _a === void 0 ? void 0 : _a.search);
8595
8603
  const cascadingEnabled = params.get('cascading') !== null;
8596
8604
  if (cascadingEnabled) {
8597
8605
  const rawParams = {};
@@ -9299,7 +9307,7 @@ class Call {
9299
9307
  * @returns a promise which resolves once the call join-flow has finished.
9300
9308
  */
9301
9309
  this.join = (data) => __awaiter(this, void 0, void 0, function* () {
9302
- var _e;
9310
+ var _e, _f;
9303
9311
  const callingState = this.state.callingState;
9304
9312
  if ([CallingState.JOINED, CallingState.JOINING].includes(callingState)) {
9305
9313
  this.logger('warn', 'Join method called twice, you should only call this once');
@@ -9340,7 +9348,7 @@ class Call {
9340
9348
  throw error;
9341
9349
  }
9342
9350
  // FIXME OL: remove once cascading is implemented
9343
- if (typeof window !== 'undefined' && window.location.search) {
9351
+ if (typeof window !== 'undefined' && ((_e = window.location) === null || _e === void 0 ? void 0 : _e.search)) {
9344
9352
  const params = new URLSearchParams(window.location.search);
9345
9353
  sfuServer.url = params.get('sfuUrl') || sfuServer.url;
9346
9354
  sfuServer.ws_endpoint = params.get('sfuWsUrl') || sfuServer.ws_endpoint;
@@ -9486,7 +9494,7 @@ class Call {
9486
9494
  connectionConfig,
9487
9495
  });
9488
9496
  }
9489
- const audioSettings = (_e = this.data) === null || _e === void 0 ? void 0 : _e.settings.audio;
9497
+ const audioSettings = (_f = this.data) === null || _f === void 0 ? void 0 : _f.settings.audio;
9490
9498
  const isDtxEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.opus_dtx_enabled);
9491
9499
  const isRedEnabled = !!(audioSettings === null || audioSettings === void 0 ? void 0 : audioSettings.redundant_coding_enabled);
9492
9500
  if (!this.publisher) {
@@ -9684,9 +9692,9 @@ class Call {
9684
9692
  * @param trackType the track type to stop publishing.
9685
9693
  */
9686
9694
  this.stopPublish = (trackType) => __awaiter(this, void 0, void 0, function* () {
9687
- var _f;
9695
+ var _g;
9688
9696
  this.logger('info', `stopPublish ${TrackType[trackType]}`);
9689
- yield ((_f = this.publisher) === null || _f === void 0 ? void 0 : _f.unpublishStream(trackType));
9697
+ yield ((_g = this.publisher) === null || _g === void 0 ? void 0 : _g.unpublishStream(trackType));
9690
9698
  });
9691
9699
  /**
9692
9700
  * Update track subscription configuration for one or more participants.
@@ -9827,8 +9835,8 @@ class Call {
9827
9835
  * @returns
9828
9836
  */
9829
9837
  this.updatePublishQuality = (enabledRids) => __awaiter(this, void 0, void 0, function* () {
9830
- var _g;
9831
- return (_g = this.publisher) === null || _g === void 0 ? void 0 : _g.updateVideoPublishQuality(enabledRids);
9838
+ var _h;
9839
+ return (_h = this.publisher) === null || _h === void 0 ? void 0 : _h.updateVideoPublishQuality(enabledRids);
9832
9840
  });
9833
9841
  /**
9834
9842
  * Sends a reaction to the other call participants.
@@ -11870,7 +11878,7 @@ class StreamClient {
11870
11878
  }
11871
11879
  getUserAgent() {
11872
11880
  return (this.userAgent ||
11873
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.28"}`);
11881
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.30"}`);
11874
11882
  }
11875
11883
  setUserAgent(userAgent) {
11876
11884
  this.userAgent = userAgent;