@stream-io/video-client 0.0.30 → 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 +7 -0
- package/dist/index.browser.es.js +30 -23
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +30 -23
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +30 -23
- package/dist/index.es.js.map +1 -1
- package/dist/src/events/participant.d.ts +5 -5
- package/package.json +1 -1
- package/src/events/__tests__/participant.test.ts +16 -32
- package/src/events/callEventHandlers.ts +4 -4
- package/src/events/participant.ts +33 -32
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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
|
+
|
|
5
12
|
### [0.0.30](https://github.com/GetStream/stream-video-js/compare/client0.0.29...client0.0.30) (2023-07-03)
|
|
6
13
|
|
|
7
14
|
|
package/dist/index.browser.es.js
CHANGED
|
@@ -8162,38 +8162,45 @@ const watchCallMemberUpdated = (state) => {
|
|
|
8162
8162
|
/**
|
|
8163
8163
|
* An event responder which handles the `participantJoined` event.
|
|
8164
8164
|
*/
|
|
8165
|
-
const watchParticipantJoined = (
|
|
8166
|
-
return
|
|
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.
|
|
8173
|
-
|
|
8174
|
-
|
|
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 = (
|
|
8182
|
-
return
|
|
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 = (
|
|
8196
|
-
return
|
|
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(
|
|
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 = (
|
|
8219
|
-
return
|
|
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(
|
|
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
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
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)),
|
|
@@ -11871,7 +11878,7 @@ class StreamClient {
|
|
|
11871
11878
|
}
|
|
11872
11879
|
getUserAgent() {
|
|
11873
11880
|
return (this.userAgent ||
|
|
11874
|
-
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.
|
|
11881
|
+
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.30"}`);
|
|
11875
11882
|
}
|
|
11876
11883
|
setUserAgent(userAgent) {
|
|
11877
11884
|
this.userAgent = userAgent;
|