@reactoo/watchtogether-sdk-js 2.6.26 → 2.6.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.6.26",
3
+ "version": "2.6.28",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -2041,7 +2041,7 @@ class RoomSession {
2041
2041
  this._log(e);
2042
2042
  }
2043
2043
  config.stream.removeTrack(oldAudioStream);
2044
- config.stream.dispatchEvent(new Event("trackremoved", {detail: oldAudioStream}))
2044
+ config.stream.dispatchEvent(new CustomEvent("trackremoved", {detail: {track: oldAudioStream, source}}))
2045
2045
  }
2046
2046
 
2047
2047
  // remove old video track related to this source
@@ -2053,7 +2053,7 @@ class RoomSession {
2053
2053
  this._log(e);
2054
2054
  }
2055
2055
  config.stream.removeTrack(oldVideoStream);
2056
- config.stream.dispatchEvent(new Event("trackremoved", {detail: oldVideoStream}))
2056
+ config.stream.dispatchEvent(new CustomEvent("trackremoved", {detail: {track: oldVideoStream, source}}))
2057
2057
  }
2058
2058
 
2059
2059
  let audioTrackReplacePromise = Promise.resolve();
@@ -2179,16 +2179,22 @@ class RoomSession {
2179
2179
  config.stream.onremovetrack = (ev) => {};
2180
2180
 
2181
2181
  let trackremoved = (ev) => {
2182
+
2183
+ config.streamMap[ev.detail.source] = config.streamMap[ev.detail.source].filter(id => id !== ev.detail.track.id);
2184
+ if(config.streamMap[ev.detail.source].length === 0) {
2185
+ delete config.streamMap[ev.detail.source];
2186
+ }
2187
+
2182
2188
  this.emit('addLocalParticipant', {
2183
2189
  tid: generateUUID(),
2184
2190
  id: handle.handleId,
2185
2191
  constructId: this.constructId,
2186
2192
  userId: decodeJanusDisplay(handle.userId)?.userId,
2187
2193
  role: decodeJanusDisplay(this.display)?.role,
2188
- track: ev.detail,
2194
+ track: ev.detail.track,
2189
2195
  stream: config.stream,
2190
2196
  streamMap: structuredClone(config.streamMap),
2191
- source,
2197
+ source: ev.detail.source,
2192
2198
  adding: false,
2193
2199
  removing: true,
2194
2200
  hasAudioTrack: hasAudio,
@@ -2225,7 +2231,7 @@ class RoomSession {
2225
2231
 
2226
2232
  track.onended = (ev) => {
2227
2233
  config.stream.removeTrack(track);
2228
- config.stream.dispatchEvent(new Event("trackremoved", {detail: track}))
2234
+ config.stream.dispatchEvent(new CustomEvent("trackremoved", {detail: {track, source}}))
2229
2235
  this._republishOnTrackEnded(source);
2230
2236
  }
2231
2237
  }