@stream-io/video-client 1.5.0-0 → 1.6.0-0

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,23 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.6.0-0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.5.0...@stream-io/video-client-1.6.0-0) (2024-08-22)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * call shall be considered as joined once joinResponse has been received ([1ed5b10](https://github.com/GetStream/stream-video-js/commit/1ed5b1097591604a3bb1884c2c664fb985873c3c))
11
+ * increment the reconnect attempt on every loop ([9fc54ae](https://github.com/GetStream/stream-video-js/commit/9fc54ae355d1c8bf9f474b708657d8d0a077b28b))
12
+ * **migration:** mark call as JOINED only after participantMigrationComplete is emitted ([60e4f28](https://github.com/GetStream/stream-video-js/commit/60e4f2872b5382a24158ffe340d3850190feab36))
13
+ * reduce the timeout to 7 seconds ([1a34c4d](https://github.com/GetStream/stream-video-js/commit/1a34c4da724290f6e4e69bd6070e370fcfbdee29))
14
+ * remove `participantMigrationComplete` workaround ([69ec50b](https://github.com/GetStream/stream-video-js/commit/69ec50b0226a9595bf49681d871e650aa51074a3))
15
+ * revert incorrect RN check ([d4c127b](https://github.com/GetStream/stream-video-js/commit/d4c127b3c5555184497b8b5a29153332094c28f4))
16
+ * shorter sleep time before attempts ([10db68e](https://github.com/GetStream/stream-video-js/commit/10db68ea101684d774561d1b3da1e8927a5eb981))
17
+
18
+
19
+ * remove todo ([ac24f43](https://github.com/GetStream/stream-video-js/commit/ac24f43811ede8b37203c5359e1d03e58bb57f2e))
20
+ * remove unused import ([8b2d5c1](https://github.com/GetStream/stream-video-js/commit/8b2d5c1de7263a317320af4834041eecfbb2aa11))
21
+
5
22
  ## [1.5.0-0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.4.8...@stream-io/video-client-1.5.0-0) (2024-08-19)
6
23
 
7
24
 
@@ -69,11 +86,10 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/s
69
86
  * use symbol per instance ([6d55e68](https://github.com/GetStream/stream-video-js/commit/6d55e687a8189cef00037b7cae3e269fc3ad947b))
70
87
 
71
88
 
89
+ * **@stream-io/video-client:** release version 1.5.0-0 ([c2c6c08](https://github.com/GetStream/stream-video-js/commit/c2c6c08a89c153ff7f478802eb75ba9dea826ed2))
72
90
  * **@stream-io/video-client:** release version 1.5.0-0 ([5357a57](https://github.com/GetStream/stream-video-js/commit/5357a5742e540d530136d3d75cf609250532dd0b))
73
91
  * **@stream-io/video-client:** release version 1.5.0-0 ([95f18b8](https://github.com/GetStream/stream-video-js/commit/95f18b8400a625d1abda766f4756b9e6acad1c13))
74
92
  * add logs for ice trickle ([990b19a](https://github.com/GetStream/stream-video-js/commit/990b19adcc03808c6b04d9767181a4fa6ceda610))
75
- * add tests for StreamVideoClient and Call ([#1459](https://github.com/GetStream/stream-video-js/issues/1459)) ([e11d234](https://github.com/GetStream/stream-video-js/commit/e11d234cd032b61d0079a4fec62de9605b92f375))
76
- * **client:** inform WS connect errors ([#1463](https://github.com/GetStream/stream-video-js/issues/1463)) ([bb75351](https://github.com/GetStream/stream-video-js/commit/bb753512a78e9105a7a3b7b76f0037bf985be0f2))
77
93
  * fix bad implicit default ([d076f00](https://github.com/GetStream/stream-video-js/commit/d076f006aab55ff9033619825a2bf64900577c53))
78
94
  * refactor the code a bit ([e56a668](https://github.com/GetStream/stream-video-js/commit/e56a668b7190483924c85f6053cabd614ab2fe54))
79
95
  * remove commented out code ([02cdfa2](https://github.com/GetStream/stream-video-js/commit/02cdfa23542bb49cb04541c1d423aca9f3be7cd3))
@@ -133,6 +149,7 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/s
133
149
  * recovering from failed SFU WS connection attempts ([2e00740](https://github.com/GetStream/stream-video-js/commit/2e00740079fa27c87d142824d9b1414525de21e6))
134
150
  * remove ended orphaned tracks from the call state ([d68529d](https://github.com/GetStream/stream-video-js/commit/d68529de4b2f4821da91d153377244dd3b7ffc64))
135
151
  * remove outdated migration tests ([4b57b19](https://github.com/GetStream/stream-video-js/commit/4b57b197352d6660a7737413f46e526193f9cf74))
152
+ * remove pre-releases ([ba9cf49](https://github.com/GetStream/stream-video-js/commit/ba9cf4968a80ec07831304ee8a791d9681ddc605))
136
153
  * reorganize restorePublishedTracks impl ([eaa8072](https://github.com/GetStream/stream-video-js/commit/eaa80723a5355ee4195e92530d74188ba98678fb))
137
154
  * restore IceTrickleBuffer ([47be308](https://github.com/GetStream/stream-video-js/commit/47be308ece0360dff66fff415f4f39e821ca2daf))
138
155
  * restore logging ([923fa74](https://github.com/GetStream/stream-video-js/commit/923fa74dc1c634a116b1a52ed5d466902d20d915))
@@ -147,6 +164,7 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/s
147
164
  * use symbol per instance ([6d55e68](https://github.com/GetStream/stream-video-js/commit/6d55e687a8189cef00037b7cae3e269fc3ad947b))
148
165
 
149
166
 
167
+ * **@stream-io/video-client:** release version 1.5.0-0 ([5357a57](https://github.com/GetStream/stream-video-js/commit/5357a5742e540d530136d3d75cf609250532dd0b))
150
168
  * **@stream-io/video-client:** release version 1.5.0-0 ([95f18b8](https://github.com/GetStream/stream-video-js/commit/95f18b8400a625d1abda766f4756b9e6acad1c13))
151
169
  * add logs for ice trickle ([990b19a](https://github.com/GetStream/stream-video-js/commit/990b19adcc03808c6b04d9767181a4fa6ceda610))
152
170
  * add tests for StreamVideoClient and Call ([#1459](https://github.com/GetStream/stream-video-js/issues/1459)) ([e11d234](https://github.com/GetStream/stream-video-js/commit/e11d234cd032b61d0079a4fec62de9605b92f375))
@@ -158,80 +176,13 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/s
158
176
  * specify baseBranch ([cc9b2fd](https://github.com/GetStream/stream-video-js/commit/cc9b2fd6d88f6aff7d8fdd8333c7aa33fdbb6857))
159
177
  * update log statement ([2245db7](https://github.com/GetStream/stream-video-js/commit/2245db7c362d1819e22e5e5831e82c251aff6117))
160
178
 
161
- ## [1.5.0-0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.4.8...@stream-io/video-client-1.5.0-0) (2024-08-19)
162
-
163
179
 
164
- ### Features
180
+ ## [1.5.0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.4.8...@stream-io/video-client-1.5.0) (2024-08-21)
165
181
 
166
- * break down the reconnect/join flows ([883d0ee](https://github.com/GetStream/stream-video-js/commit/883d0ee3b54e9b5704364d0c34e466c23aca631a))
167
- * don't trigger ice restart on the subscriber after a fast reconnect ([c7e2d6f](https://github.com/GetStream/stream-video-js/commit/c7e2d6f964e779f988b29d12763b1ee4d4859111))
168
- * fast-reconnect strategy ([e4e01d5](https://github.com/GetStream/stream-video-js/commit/e4e01d5dd8185a21652bb2dca2a88217b498c9b7))
169
- * handle `callEnded` ([7f93307](https://github.com/GetStream/stream-video-js/commit/7f933079193084ac58a93a961e035ddfd7616f67))
170
- * handle goAway ([d717f1a](https://github.com/GetStream/stream-video-js/commit/d717f1af00a87cf636396c4e0dc33ad106c9377e))
171
- * handle network change events ([f980f0b](https://github.com/GetStream/stream-video-js/commit/f980f0b93235f1923c06e2e8694c4ce8ff10abc0))
172
- * improved/linear code flow, clean reconnects ([a210365](https://github.com/GetStream/stream-video-js/commit/a210365dd83fb0e544b543c7144104ece80ac317))
173
- * migration ([9099a51](https://github.com/GetStream/stream-video-js/commit/9099a51d5cd29282a050bba196ba5a4f646f4341))
174
- * migration - wip ([3ad96b6](https://github.com/GetStream/stream-video-js/commit/3ad96b6a7d38c7e82effd26889a2fbbad20847b7))
175
- * Reconnects v2 ([d9f98dc](https://github.com/GetStream/stream-video-js/commit/d9f98dcd6237f7fc9eca263832e6d68753bb2ee1))
176
- * remove CLEAN strategy ([7e9544b](https://github.com/GetStream/stream-video-js/commit/7e9544b8beb29af4125f2e607865f0415426afcc))
177
- * send `muted` info about announced tracks ([ccd95c4](https://github.com/GetStream/stream-video-js/commit/ccd95c411650b44816b18d2e6562f9409b35faf2))
178
- * setup rc release flow ([f183232](https://github.com/GetStream/stream-video-js/commit/f18323254a43fe11c768656e10cd1b915f6ce607))
179
-
180
-
181
- ### Bug Fixes
182
-
183
- * add missing bracket ([1687722](https://github.com/GetStream/stream-video-js/commit/16877221f98ff277bb41cc04b26d0cdaebd4f22a))
184
- * adjust to the recent changes made in [#1451](https://github.com/GetStream/stream-video-js/issues/1451) ([9e47834](https://github.com/GetStream/stream-video-js/commit/9e4783480e7f29c9d102824a37fa9db19dda4fc1))
185
- * always respect local state for the local participant ([6b9cd1d](https://github.com/GetStream/stream-video-js/commit/6b9cd1de37b7f31426e83090b97c56f83062e31b))
186
- * attempt closing only open sockets ([2d6a388](https://github.com/GetStream/stream-video-js/commit/2d6a3888af9c697c5bcca0bf257cde63700f743a))
187
- * attempt reconnect after setPublisher fails to return valid SDP ([71ff58e](https://github.com/GetStream/stream-video-js/commit/71ff58e5e9f4a41db714ad39f0ad8a1f22cb8e85))
188
- * bubble migration errors, check for network availability before attempts, break the reconnect loop on leave ([e3cb2b0](https://github.com/GetStream/stream-video-js/commit/e3cb2b0dda8b34f03214cbdd1aa8f2cd1bb793b0))
189
- * clean joinData after migration ([16d186a](https://github.com/GetStream/stream-video-js/commit/16d186a6da0af1bfdcee447c4b2b4485604fb49d))
190
- * decouple network events from coordinator socket healthiness ([e453581](https://github.com/GetStream/stream-video-js/commit/e453581da6f8d4d07678636d7a520609b4486948))
191
- * disable excessive logging ([f8c63bf](https://github.com/GetStream/stream-video-js/commit/f8c63bf98a1a22c0f39668d723d4c69d841b13b5))
192
- * don't apply device settings after rejoining ([18a6a3c](https://github.com/GetStream/stream-video-js/commit/18a6a3c9d8e71d8e1ca8222df7319096d9f6bc54))
193
- * don't apply device settings after rejoining, improve the handling of own capabilities ([8ce0f1a](https://github.com/GetStream/stream-video-js/commit/8ce0f1a82181bf21f4c90b9b1e18b5390e983766))
194
- * failed test ([f78c943](https://github.com/GetStream/stream-video-js/commit/f78c943912e2292be8e31b575de1742e5c08a0cb))
195
- * failing tests ([5c0209b](https://github.com/GetStream/stream-video-js/commit/5c0209b46f931f47e439e6f3339d13d34765ba3c))
196
- * fast reconnect after network switch ([a49539c](https://github.com/GetStream/stream-video-js/commit/a49539c8a21988dfad04af5b7303412cef41c292))
197
- * handle errors ([5cf999d](https://github.com/GetStream/stream-video-js/commit/5cf999d018a17c0dd7cb92cf45808e070c69fc58))
198
- * handle orphaned tracks for the subscriber ([10fb269](https://github.com/GetStream/stream-video-js/commit/10fb26983589ee962fc14b464e13350bc17e9105))
199
- * handle screen share in remote mutes ([6255d36](https://github.com/GetStream/stream-video-js/commit/6255d366d65d4e8641cecb9f42a47876a8cd5e3b))
200
- * improve handing of ice trickles ([a2ae6b1](https://github.com/GetStream/stream-video-js/commit/a2ae6b105fde51f6cd9de36af9face0e69bca6ff))
201
- * improve ice trickling ([2fdb932](https://github.com/GetStream/stream-video-js/commit/2fdb9328d138d7067af225ae526fd06e9fe960d1))
202
- * improve logging ([a3ea1d9](https://github.com/GetStream/stream-video-js/commit/a3ea1d916cf50b445ecf1be7cd01c40f87a2db98))
203
- * improve logging, mark call as joined earlier ([2722e4d](https://github.com/GetStream/stream-video-js/commit/2722e4dd2a40fb7d3c30e1b4051fc32aa64cf629))
204
- * improve the migration ([c2495dd](https://github.com/GetStream/stream-video-js/commit/c2495dd01bf462d099214df711fe353001228ffb))
205
- * increase the migration end deadline ([6d56644](https://github.com/GetStream/stream-video-js/commit/6d566443d22b18ec50fba3752120f5eefd68a8bd))
206
- * incremental sfu client tag ([ce4432d](https://github.com/GetStream/stream-video-js/commit/ce4432d82256cff9868d91f01bb83daf8b256f55))
207
- * perform ice restart when state goes to disconnected ([2517625](https://github.com/GetStream/stream-video-js/commit/251762528641cea09a7d7c77e2c2be113ae82bac))
208
- * prevent assigning ice candidates to closed PC; prevent muting the publisher after migration; don't trigger fast reconnect after goAway migration ([5769097](https://github.com/GetStream/stream-video-js/commit/576909764b387da247bd48c721015cfbc7884e4a))
209
- * recovering from failed SFU WS connection attempts ([2e00740](https://github.com/GetStream/stream-video-js/commit/2e00740079fa27c87d142824d9b1414525de21e6))
210
- * remove ended orphaned tracks from the call state ([d68529d](https://github.com/GetStream/stream-video-js/commit/d68529de4b2f4821da91d153377244dd3b7ffc64))
211
- * remove outdated migration tests ([4b57b19](https://github.com/GetStream/stream-video-js/commit/4b57b197352d6660a7737413f46e526193f9cf74))
212
- * reorganize restorePublishedTracks impl ([eaa8072](https://github.com/GetStream/stream-video-js/commit/eaa80723a5355ee4195e92530d74188ba98678fb))
213
- * restore IceTrickleBuffer ([47be308](https://github.com/GetStream/stream-video-js/commit/47be308ece0360dff66fff415f4f39e821ca2daf))
214
- * restore logging ([923fa74](https://github.com/GetStream/stream-video-js/commit/923fa74dc1c634a116b1a52ed5d466902d20d915))
215
- * restore the original addIceCandidate behavior ([36245df](https://github.com/GetStream/stream-video-js/commit/36245df430ebb524ef99d7b07120e017b5fd4280))
216
- * restore tracks from the local state after reconnecting ([8204598](https://github.com/GetStream/stream-video-js/commit/820459800c8cd87635d020955f6f853d985c92c2))
217
- * retry failed rpc requests ([8c10922](https://github.com/GetStream/stream-video-js/commit/8c1092292d3b4657ee1ef4bb683bafeeea6568fb))
218
- * simplify updateParticipants ([d01367d](https://github.com/GetStream/stream-video-js/commit/d01367d1ff21d1c4d69bb5013ec6f967a1138199))
219
- * stats reporting ([cff501f](https://github.com/GetStream/stream-video-js/commit/cff501f8c6da22c9ccc4f98f8c688e573de94037))
220
- * stop sending healthcheck events when WS closes ([1c452df](https://github.com/GetStream/stream-video-js/commit/1c452dfa4d1eafe7a7dd46788691b46efc7b853a))
221
- * tidy up the codebase ([53674c2](https://github.com/GetStream/stream-video-js/commit/53674c294ff2e8ee0be64a3e2a8b6b1ccf34da1f))
222
- * use 30fps for all layers ([df393b0](https://github.com/GetStream/stream-video-js/commit/df393b07f2ec978b3f7ef2a2da9f319cd3efd477))
223
- * use symbol per instance ([6d55e68](https://github.com/GetStream/stream-video-js/commit/6d55e687a8189cef00037b7cae3e269fc3ad947b))
224
182
 
183
+ ### Features
225
184
 
226
- * add logs for ice trickle ([990b19a](https://github.com/GetStream/stream-video-js/commit/990b19adcc03808c6b04d9767181a4fa6ceda610))
227
- * add tests for StreamVideoClient and Call ([#1459](https://github.com/GetStream/stream-video-js/issues/1459)) ([e11d234](https://github.com/GetStream/stream-video-js/commit/e11d234cd032b61d0079a4fec62de9605b92f375))
228
- * **client:** inform WS connect errors ([#1463](https://github.com/GetStream/stream-video-js/issues/1463)) ([bb75351](https://github.com/GetStream/stream-video-js/commit/bb753512a78e9105a7a3b7b76f0037bf985be0f2))
229
- * fix bad implicit default ([d076f00](https://github.com/GetStream/stream-video-js/commit/d076f006aab55ff9033619825a2bf64900577c53))
230
- * refactor the code a bit ([e56a668](https://github.com/GetStream/stream-video-js/commit/e56a668b7190483924c85f6053cabd614ab2fe54))
231
- * remove commented out code ([02cdfa2](https://github.com/GetStream/stream-video-js/commit/02cdfa23542bb49cb04541c1d423aca9f3be7cd3))
232
- * remove the legacy migration code ([12c181b](https://github.com/GetStream/stream-video-js/commit/12c181be861030334f4e2555a432a8167242cf63))
233
- * specify baseBranch ([cc9b2fd](https://github.com/GetStream/stream-video-js/commit/cc9b2fd6d88f6aff7d8fdd8333c7aa33fdbb6857))
234
- * update log statement ([2245db7](https://github.com/GetStream/stream-video-js/commit/2245db7c362d1819e22e5e5831e82c251aff6117))
185
+ * **client:** add a instance getter ([#1461](https://github.com/GetStream/stream-video-js/issues/1461)) ([7f4d836](https://github.com/GetStream/stream-video-js/commit/7f4d836511d9afdcd61bf5c6317611d3725953a6))
235
186
 
236
187
  ### [1.4.8](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.4.7...@stream-io/video-client-1.4.8) (2024-07-31)
237
188
 
@@ -4,7 +4,7 @@ import { ServiceType, stackIntercept, RpcError } from '@protobuf-ts/runtime-rpc'
4
4
  import axios, { AxiosHeaders } from 'axios';
5
5
  export { AxiosError } from 'axios';
6
6
  import { TwirpFetchTransport, TwirpErrorCode } from '@protobuf-ts/twirp-transport';
7
- import { ReplaySubject, combineLatest, BehaviorSubject, map as map$1, shareReplay, distinctUntilChanged, takeWhile, distinctUntilKeyChanged, fromEventPattern, startWith, concatMap, merge, from, fromEvent, debounceTime, pairwise, of, filter, debounce, timer } from 'rxjs';
7
+ import { ReplaySubject, combineLatest, BehaviorSubject, map as map$1, shareReplay, distinctUntilChanged, takeWhile, distinctUntilKeyChanged, fromEventPattern, startWith, concatMap, merge, from, fromEvent, debounceTime, pairwise, of, debounce, timer } from 'rxjs';
8
8
  import * as SDP from 'sdp-transform';
9
9
  import { UAParser } from 'ua-parser-js';
10
10
  import WebSocket$1 from 'isomorphic-ws';
@@ -8711,7 +8711,7 @@ const enableHighQualityAudio = (sdp, trackMid, maxBitrate = 510000) => {
8711
8711
  return SDP.write(parsedSdp);
8712
8712
  };
8713
8713
 
8714
- const version = "1.5.0-0" ;
8714
+ const version = "1.6.0-0" ;
8715
8715
  const [major, minor, patch] = version.split('.');
8716
8716
  let sdkInfo = {
8717
8717
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -9587,8 +9587,6 @@ class Subscriber {
9587
9587
  this.pc = this.createPeerConnection(connectionConfig);
9588
9588
  const subscriberOfferConcurrencyTag = Symbol('subscriberOffer');
9589
9589
  this.unregisterOnSubscriberOffer = dispatcher.on('subscriberOffer', (subscriberOffer) => {
9590
- // TODO: use queue per peer connection, otherwise
9591
- // it could happen we consume an offer for a different peer connection
9592
9590
  withoutConcurrency(subscriberOfferConcurrencyTag, () => {
9593
9591
  return this.negotiate(subscriberOffer);
9594
9592
  }).catch((err) => {
@@ -9809,10 +9807,9 @@ class StreamSfuClient {
9809
9807
  };
9810
9808
  this.enterMigration = async (opts = {}) => {
9811
9809
  this.isLeaving = true;
9812
- const { timeout = 10000 } = opts;
9810
+ const { timeout = 7 * 1000 } = opts;
9813
9811
  this.migrationTask?.reject(new Error('Cancelled previous migration'));
9814
- this.migrationTask = promiseWithResolvers();
9815
- const task = this.migrationTask;
9812
+ const task = (this.migrationTask = promiseWithResolvers());
9816
9813
  const unsubscribe = this.dispatcher.on('participantMigrationComplete', () => {
9817
9814
  unsubscribe();
9818
9815
  clearTimeout(this.migrateAwayTimeout);
@@ -9820,12 +9817,9 @@ class StreamSfuClient {
9820
9817
  });
9821
9818
  this.migrateAwayTimeout = setTimeout(() => {
9822
9819
  unsubscribe();
9823
- // task.reject(new Error('Migration timeout'));
9824
- // FIXME OL: temporary, switch to `task.reject()` once the SFU starts sending
9825
- // the participantMigrationComplete event.
9826
- task.resolve();
9820
+ task.reject(new Error(`Migration (${this.logTag}) failed to complete in ${timeout}ms`));
9827
9821
  }, timeout);
9828
- return this.migrationTask.promise;
9822
+ return task.promise;
9829
9823
  };
9830
9824
  this.join = async (data) => {
9831
9825
  // wait for the signal web socket to be ready before sending "joinRequest"
@@ -11244,13 +11238,9 @@ class BrowserPermission {
11244
11238
  const signal = this.disposeController.signal;
11245
11239
  this.ready = (async () => {
11246
11240
  const assumeGranted = (error) => {
11247
- this.logger('warn', "Can't query permissions, assuming granted", {
11248
- permission,
11249
- error,
11250
- });
11251
11241
  this.setState('granted');
11252
11242
  };
11253
- if (!canQueryPermissions() && !isReactNative()) {
11243
+ if (!canQueryPermissions()) {
11254
11244
  return assumeGranted();
11255
11245
  }
11256
11246
  try {
@@ -11265,7 +11255,7 @@ class BrowserPermission {
11265
11255
  }
11266
11256
  }
11267
11257
  catch (err) {
11268
- assumeGranted(err);
11258
+ assumeGranted();
11269
11259
  }
11270
11260
  })();
11271
11261
  }
@@ -13212,7 +13202,10 @@ class Call {
13212
13202
  this.state.updateFromSfuCallState(callState, sfuClient.sessionId, reconnectDetails);
13213
13203
  }
13214
13204
  }
13215
- this.state.setCallingState(CallingState.JOINED);
13205
+ if (!performingMigration) {
13206
+ // in MIGRATION, `JOINED` state is set in `this.reconnectMigrate()`
13207
+ this.state.setCallingState(CallingState.JOINED);
13208
+ }
13216
13209
  this.hasJoinedOnce = true;
13217
13210
  // when performing fast reconnect, or when we reuse the same SFU client,
13218
13211
  // (ws remained healthy), we just need to restore the ICE connection
@@ -13392,6 +13385,7 @@ class Call {
13392
13385
  this.logger('info', `[Reconnect] Reconnecting with strategy ${WebsocketReconnectStrategy[strategy]}`);
13393
13386
  this.reconnectStrategy = strategy;
13394
13387
  do {
13388
+ this.reconnectAttempts++;
13395
13389
  const current = WebsocketReconnectStrategy[this.reconnectStrategy];
13396
13390
  try {
13397
13391
  // wait until the network is available
@@ -13418,9 +13412,8 @@ class Call {
13418
13412
  }
13419
13413
  catch (error) {
13420
13414
  this.logger('warn', `[Reconnect] ${current}(${this.reconnectAttempts}) failed. Attempting with REJOIN`, error);
13421
- await sleep(retryInterval(this.reconnectAttempts));
13415
+ await sleep(500);
13422
13416
  this.reconnectStrategy = WebsocketReconnectStrategy.REJOIN;
13423
- this.reconnectAttempts++;
13424
13417
  }
13425
13418
  } while (this.state.callingState !== CallingState.JOINED &&
13426
13419
  this.state.callingState !== CallingState.LEFT);
@@ -13478,6 +13471,10 @@ class Call {
13478
13471
  // and the peer connection instances. In case of failure, the migration
13479
13472
  // task would throw an error and REJOIN would be attempted.
13480
13473
  await migrationTask;
13474
+ // in MIGRATE, we can consider the call as joined only after
13475
+ // `participantMigrationComplete` event is received, signaled by
13476
+ // the `migrationTask`
13477
+ this.state.setCallingState(CallingState.JOINED);
13481
13478
  }
13482
13479
  finally {
13483
13480
  currentSubscriber?.close();
@@ -13836,9 +13833,14 @@ class Call {
13836
13833
  return this.publisher?.updateVideoPublishQuality(enabledLayers);
13837
13834
  };
13838
13835
  this.waitUntilCallJoined = () => {
13836
+ if (this.sfuClient) {
13837
+ // if we have an SFU client, we can wait for the join response
13838
+ return this.sfuClient.joinResponseTask.promise;
13839
+ }
13840
+ // otherwise, fall back to the calling state
13839
13841
  return new Promise((resolve) => {
13840
13842
  this.state.callingState$
13841
- .pipe(takeWhile((state) => state !== CallingState.JOINED, true), filter((state) => state === CallingState.JOINED))
13843
+ .pipe(takeWhile((state) => state !== CallingState.JOINED, true))
13842
13844
  .subscribe(() => resolve());
13843
13845
  });
13844
13846
  };
@@ -15367,7 +15369,7 @@ class TokenManager {
15367
15369
  if (this.user && !this.token) {
15368
15370
  return this.token;
15369
15371
  }
15370
- throw new Error(`Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called`);
15372
+ throw new Error(`User token is not set. Either client.connectUser wasn't called or client.disconnect was called`);
15371
15373
  };
15372
15374
  this.isStatic = () => this.type === 'static';
15373
15375
  this.loadTokenPromise = null;
@@ -16063,7 +16065,7 @@ class StreamClient {
16063
16065
  });
16064
16066
  };
16065
16067
  this.getUserAgent = () => {
16066
- const version = "1.5.0-0" ;
16068
+ const version = "1.6.0-0" ;
16067
16069
  return (this.userAgent ||
16068
16070
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
16069
16071
  };
@@ -16314,12 +16316,16 @@ class StreamVideoClient {
16314
16316
  if (!this.streamClient.user && !this.connectionPromise) {
16315
16317
  return;
16316
16318
  }
16319
+ const userId = this.streamClient.user?.id;
16317
16320
  const disconnectUser = () => this.streamClient.disconnectUser(timeout);
16318
16321
  this.disconnectionPromise = this.connectionPromise
16319
16322
  ? this.connectionPromise.then(() => disconnectUser())
16320
16323
  : disconnectUser();
16321
16324
  this.disconnectionPromise.finally(() => (this.disconnectionPromise = undefined));
16322
16325
  await this.disconnectionPromise;
16326
+ if (userId) {
16327
+ StreamVideoClient._instanceMap.delete(userId);
16328
+ }
16323
16329
  this.eventHandlersToUnregister.forEach((unregister) => unregister());
16324
16330
  this.eventHandlersToUnregister = [];
16325
16331
  this.writeableStateStore.setConnectedUser(undefined);
@@ -16539,12 +16545,44 @@ class StreamVideoClient {
16539
16545
  const user = apiKeyOrArgs.user;
16540
16546
  const token = apiKeyOrArgs.token || apiKeyOrArgs.tokenProvider;
16541
16547
  if (user) {
16548
+ let id = user.id;
16549
+ if (user.type === 'anonymous') {
16550
+ id = '!anon';
16551
+ }
16552
+ if (id) {
16553
+ if (StreamVideoClient._instanceMap.has(apiKeyOrArgs.apiKey + id)) {
16554
+ this.logger('warn', `A StreamVideoClient already exists for ${user.type === 'anonymous' ? 'an anyonymous user' : id}; Prefer using getOrCreateInstance method`);
16555
+ }
16556
+ user.id = id;
16557
+ StreamVideoClient._instanceMap.set(apiKeyOrArgs.apiKey + id, this);
16558
+ }
16542
16559
  this.connectUser(user, token).catch((err) => {
16543
16560
  this.logger('error', 'Failed to connect', err);
16544
16561
  });
16545
16562
  }
16546
16563
  }
16547
16564
  }
16565
+ static getOrCreateInstance(args) {
16566
+ const user = args.user;
16567
+ if (!user.id) {
16568
+ if (args.user.type === 'anonymous') {
16569
+ user.id = '!anon';
16570
+ }
16571
+ else {
16572
+ throw new Error('User ID is required for a non-anonymous user');
16573
+ }
16574
+ }
16575
+ if (!args.token && !args.tokenProvider) {
16576
+ if (args.user.type !== 'anonymous' && args.user.type !== 'guest') {
16577
+ throw new Error('TokenProvider or token is required for a user that is not a guest or anonymous');
16578
+ }
16579
+ }
16580
+ let instance = StreamVideoClient._instanceMap.get(args.apiKey + user.id);
16581
+ if (!instance) {
16582
+ instance = new StreamVideoClient({ ...args, user });
16583
+ }
16584
+ return instance;
16585
+ }
16548
16586
  /**
16549
16587
  * Return the reactive state store, use this if you want to be notified about changes to the client state
16550
16588
  */
@@ -16552,6 +16590,7 @@ class StreamVideoClient {
16552
16590
  return this.readOnlyStateStore;
16553
16591
  }
16554
16592
  }
16593
+ StreamVideoClient._instanceMap = new Map();
16555
16594
 
16556
16595
  export { AudioSettingsRequestDefaultDeviceEnum, AudioSettingsResponseDefaultDeviceEnum, BlockListOptionsBehaviorEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CameraManager, CameraManagerState, ChannelConfigWithInfoAutomodBehaviorEnum, ChannelConfigWithInfoAutomodEnum, ChannelConfigWithInfoBlocklistBehaviorEnum, CreateDeviceRequestPushProviderEnum, DebounceType, DynascaleManager, ErrorFromResponse, InputMediaDeviceManager, InputMediaDeviceManagerState, MicrophoneManager, MicrophoneManagerState, NoiseCancellationSettingsModeEnum, OwnCapability, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, ScreenShareManager, ScreenShareState, events as SfuEvents, models as SfuModels, SpeakerManager, SpeakerState, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoWriteableStateStore, TranscriptionSettingsRequestModeEnum, TranscriptionSettingsResponseModeEnum, VideoSettingsRequestCameraFacingEnum, VideoSettingsResponseCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, deviceIds$, disposeOfMediaStream, dominantSpeaker, getAudioBrowserPermission, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceInfo, getLogLevel, getLogger, getOSInfo, getScreenShareStream, getSdkInfo, getVideoBrowserPermission, getVideoDevices, getVideoStream, getWebRTCInfo, hasAudio, hasScreenShare, hasScreenShareAudio, hasVideo, isPinned, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, paginatedLayoutSortPreset, pinned, publishingAudio, publishingVideo, reactionType, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setSdkInfo, setWebRTCInfo, speakerLayoutSortPreset, speaking };
16557
16596
  //# sourceMappingURL=index.browser.es.js.map