@stream-io/video-client 0.0.1-alpha.174 → 0.0.1-alpha.176

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,19 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.1-alpha.176](https://github.com/GetStream/stream-video-js/compare/client0.0.1-alpha.175...client0.0.1-alpha.176) (2023-05-23)
6
+
7
+
8
+ ### Features
9
+
10
+ * Participant information from track events ([#536](https://github.com/GetStream/stream-video-js/issues/536)) ([e8c8d7b](https://github.com/GetStream/stream-video-js/commit/e8c8d7bdf6d21321908ce1cb3a113b445b41d5c8))
11
+
12
+
13
+
14
+ ## [0.0.1-alpha.175](https://github.com/GetStream/stream-video-js/compare/client0.0.1-alpha.174...client0.0.1-alpha.175) (2023-05-23)
15
+
16
+
17
+
5
18
  ## [0.0.1-alpha.174](https://github.com/GetStream/stream-video-js/compare/client0.0.1-alpha.173...client0.0.1-alpha.174) (2023-05-23)
6
19
 
7
20
 
@@ -6815,6 +6815,28 @@ class CallState {
6815
6815
  const updatedParticipant = Object.assign(Object.assign({}, participant), thePatch);
6816
6816
  return this.setParticipants((participants) => participants.map((p) => p.sessionId === sessionId ? updatedParticipant : p));
6817
6817
  };
6818
+ /**
6819
+ * Updates a participant in the current call identified by the given `sessionId`.
6820
+ * If a participant with matching `sessionId` can't be found, the provided
6821
+ * `participant` is added to the list of participants.
6822
+ *
6823
+ * @param sessionId the session ID of the participant to update.
6824
+ * @param participant the participant to update or add.
6825
+ */
6826
+ this.updateOrAddParticipant = (sessionId, participant) => {
6827
+ if (!this.findParticipantBySessionId(sessionId)) {
6828
+ return this.setParticipants((participants) => [
6829
+ ...participants,
6830
+ participant,
6831
+ ]);
6832
+ }
6833
+ return this.setParticipants((participants) => participants.map((p) => {
6834
+ if (p.sessionId === sessionId) {
6835
+ return Object.assign(Object.assign({}, p), participant);
6836
+ }
6837
+ return p;
6838
+ }));
6839
+ };
6818
6840
  /**
6819
6841
  * Updates all participants in the current call whose session ID is in the given `sessionIds`.
6820
6842
  * If no patches are provided, this operation is no-op.
@@ -7311,10 +7333,19 @@ const watchTrackPublished = (dispatcher, state) => {
7311
7333
  return dispatcher.on('trackPublished', (e) => {
7312
7334
  if (e.eventPayload.oneofKind !== 'trackPublished')
7313
7335
  return;
7314
- const { trackPublished: { type, sessionId }, } = e.eventPayload;
7315
- state.updateParticipant(sessionId, (p) => ({
7316
- publishedTracks: [...p.publishedTracks, type].filter(unique),
7317
- }));
7336
+ const { trackPublished: { type, sessionId, participant }, } = e.eventPayload;
7337
+ // An optimization for large calls.
7338
+ // After a certain threshold, the SFU would stop emitting `participantJoined`
7339
+ // events, and instead, it would only provide the participant's information
7340
+ // once they start publishing a track.
7341
+ if (participant) {
7342
+ state.updateOrAddParticipant(participant.sessionId, participant);
7343
+ }
7344
+ else {
7345
+ state.updateParticipant(sessionId, (p) => ({
7346
+ publishedTracks: [...p.publishedTracks, type].filter(unique),
7347
+ }));
7348
+ }
7318
7349
  });
7319
7350
  };
7320
7351
  /**
@@ -7325,10 +7356,16 @@ const watchTrackUnpublished = (dispatcher, state) => {
7325
7356
  return dispatcher.on('trackUnpublished', (e) => {
7326
7357
  if (e.eventPayload.oneofKind !== 'trackUnpublished')
7327
7358
  return;
7328
- const { trackUnpublished: { type, sessionId }, } = e.eventPayload;
7329
- state.updateParticipant(sessionId, (p) => ({
7330
- publishedTracks: p.publishedTracks.filter((t) => t !== type),
7331
- }));
7359
+ const { trackUnpublished: { type, sessionId, participant }, } = e.eventPayload;
7360
+ // An optimization for large calls. See `watchTrackPublished`.
7361
+ if (participant) {
7362
+ state.updateOrAddParticipant(participant.sessionId, participant);
7363
+ }
7364
+ else {
7365
+ state.updateParticipant(sessionId, (p) => ({
7366
+ publishedTracks: p.publishedTracks.filter((t) => t !== type),
7367
+ }));
7368
+ }
7332
7369
  });
7333
7370
  };
7334
7371
  const unique = (v, i, arr) => arr.indexOf(v) === i;
@@ -10759,7 +10796,7 @@ class StreamClient {
10759
10796
  }
10760
10797
  getUserAgent() {
10761
10798
  return (this.userAgent ||
10762
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.1-alpha.174"}`);
10799
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.1-alpha.175"}`);
10763
10800
  }
10764
10801
  setUserAgent(userAgent) {
10765
10802
  this.userAgent = userAgent;