@stream-io/video-client 0.0.6 → 0.0.8

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.8](https://github.com/GetStream/stream-video-js/compare/client0.0.7...client0.0.8) (2023-06-09)
6
+
7
+
8
+ ### Features
9
+
10
+ * **react-native:** support reconnection flow ([#458](https://github.com/GetStream/stream-video-js/issues/458)) ([89f2dda](https://github.com/GetStream/stream-video-js/commit/89f2ddafd1397d91f8ddea5a3c69dd62ae027313))
11
+
12
+ ### [0.0.7](https://github.com/GetStream/stream-video-js/compare/client0.0.6...client0.0.7) (2023-06-08)
13
+
14
+
15
+ ### Features
16
+
17
+ * StreamCall signature, video client creation ([#596](https://github.com/GetStream/stream-video-js/issues/596)) ([5c3000c](https://github.com/GetStream/stream-video-js/commit/5c3000cc6fc3f8b7904609d7b11fa025b7458cad))
18
+
5
19
  ### [0.0.6](https://github.com/GetStream/stream-video-js/compare/client0.0.5...client0.0.6) (2023-06-07)
6
20
 
7
21
 
@@ -5969,13 +5969,13 @@ const createWebSocketSignalChannel = (opts) => {
5969
5969
  const ws = new WebSocket(endpoint);
5970
5970
  ws.binaryType = 'arraybuffer'; // do we need this?
5971
5971
  ws.addEventListener('error', (e) => {
5972
- console.error('Error', e);
5972
+ console.log('Signaling WS channel error', e);
5973
5973
  });
5974
5974
  ws.addEventListener('close', (e) => {
5975
- console.warn('Signalling channel is closed', e);
5975
+ console.log('Signaling WS channel is closed', e);
5976
5976
  });
5977
5977
  ws.addEventListener('open', (e) => {
5978
- console.log('Signalling channel is open', e);
5978
+ console.log('Signaling WS channel is open', e);
5979
5979
  });
5980
5980
  if (onMessage) {
5981
5981
  ws.addEventListener('message', (e) => {
@@ -8318,6 +8318,13 @@ const getSdkInfo = () => {
8318
8318
  * An object representation of a `Call`.
8319
8319
  */
8320
8320
  class Call {
8321
+ /**
8322
+ * A promise that exposes the reconnection logic
8323
+ * The use-case is for the react-native platform where online/offline events are not available in the window
8324
+ */
8325
+ get rejoin() {
8326
+ return this.rejoinPromise;
8327
+ }
8321
8328
  /**
8322
8329
  * Constructs a new `Call` instance.
8323
8330
  *
@@ -8363,6 +8370,7 @@ class Call {
8363
8370
  if (callingState === CallingState.LEFT) {
8364
8371
  throw new Error('Cannot leave call that has already been left.');
8365
8372
  }
8373
+ this.rejoinPromise = undefined;
8366
8374
  if (this.ringing) {
8367
8375
  // I'm the one who started the call, so I should cancel it.
8368
8376
  const hasOtherParticipants = this.state.remoteParticipants.length > 0;
@@ -8555,7 +8563,7 @@ class Call {
8555
8563
  yield sleep(retryInterval(this.reconnectAttempts));
8556
8564
  yield this.join(data);
8557
8565
  console.log(`Rejoin: ${this.reconnectAttempts} successful!`);
8558
- if (localParticipant) {
8566
+ if (localParticipant && !isReactNative()) {
8559
8567
  const { audioStream, videoStream, screenShareStream: screenShare, } = localParticipant;
8560
8568
  // restore previous publishing state
8561
8569
  if (audioStream)
@@ -8567,6 +8575,7 @@ class Call {
8567
8575
  }
8568
8576
  console.log(`Rejoin: state restored ${this.reconnectAttempts}`);
8569
8577
  });
8578
+ this.rejoinPromise = rejoin;
8570
8579
  // reconnect if the connection was closed unexpectedly. example:
8571
8580
  // - SFU crash or restart
8572
8581
  // - network change
@@ -8579,6 +8588,9 @@ class Call {
8579
8588
  // e.g., the user has been blocked by an admin or moderator
8580
8589
  if (e.code === KnownCodes.WS_POLICY_VIOLATION)
8581
8590
  return;
8591
+ // do nothing for react-native as its handled by SDK
8592
+ if (isReactNative())
8593
+ return;
8582
8594
  if (this.reconnectAttempts < this.maxReconnectAttempts) {
8583
8595
  rejoin().catch(() => {
8584
8596
  console.log(`Rejoin failed for ${this.reconnectAttempts} times. Giving up.`);
@@ -10993,7 +11005,7 @@ class StreamClient {
10993
11005
  }
10994
11006
  getUserAgent() {
10995
11007
  return (this.userAgent ||
10996
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.5"}`);
11008
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.7"}`);
10997
11009
  }
10998
11010
  setUserAgent(userAgent) {
10999
11011
  this.userAgent = userAgent;
@@ -11075,9 +11087,17 @@ class StreamVideoClient {
11075
11087
  * @param tokenOrProvider a token or a function that returns a token.
11076
11088
  */
11077
11089
  this.connectUser = (user, tokenOrProvider) => __awaiter(this, void 0, void 0, function* () {
11078
- const connectUserResponse = yield this.streamClient.connectUser(
11079
- // @ts-expect-error
11080
- user, tokenOrProvider);
11090
+ var _a;
11091
+ const connectUser = () => {
11092
+ return this.streamClient.connectUser(
11093
+ // @ts-expect-error
11094
+ user, tokenOrProvider);
11095
+ };
11096
+ this.connectionPromise = this.disconnectionPromise
11097
+ ? this.disconnectionPromise.then(() => connectUser())
11098
+ : connectUser();
11099
+ (_a = this.connectionPromise) === null || _a === void 0 ? void 0 : _a.finally(() => (this.connectionPromise = undefined));
11100
+ const connectUserResponse = yield this.connectionPromise;
11081
11101
  this.writeableStateStore.setConnectedUser(user);
11082
11102
  this.eventHandlersToUnregister.push(this.on('connection.changed', (e) => {
11083
11103
  const event = e;
@@ -11151,8 +11171,14 @@ class StreamVideoClient {
11151
11171
  * @param tokenOrProvider a token or a function that returns a token.
11152
11172
  */
11153
11173
  this.connectAnonymousUser = (user, tokenOrProvider) => __awaiter(this, void 0, void 0, function* () {
11174
+ const connectAnonymousUser = () =>
11154
11175
  // @ts-expect-error
11155
- return this.streamClient.connectAnonymousUser(user, tokenOrProvider);
11176
+ this.streamClient.connectAnonymousUser(user, tokenOrProvider);
11177
+ this.connectionPromise = this.disconnectionPromise
11178
+ ? this.disconnectionPromise.then(() => connectAnonymousUser())
11179
+ : connectAnonymousUser();
11180
+ this.connectionPromise.finally(() => (this.connectionPromise = undefined));
11181
+ return this.connectionPromise;
11156
11182
  });
11157
11183
  /**
11158
11184
  * Disconnects the currently connected user from the client.
@@ -11163,7 +11189,12 @@ class StreamVideoClient {
11163
11189
  * https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
11164
11190
  */
11165
11191
  this.disconnectUser = (timeout) => __awaiter(this, void 0, void 0, function* () {
11166
- yield this.streamClient.disconnectUser(timeout);
11192
+ const disconnectUser = () => this.streamClient.disconnectUser(timeout);
11193
+ this.disconnectionPromise = this.connectionPromise
11194
+ ? this.connectionPromise.then(() => disconnectUser())
11195
+ : disconnectUser();
11196
+ this.disconnectionPromise.finally(() => (this.disconnectionPromise = undefined));
11197
+ yield this.disconnectionPromise;
11167
11198
  this.eventHandlersToUnregister.forEach((unregister) => unregister());
11168
11199
  this.eventHandlersToUnregister = [];
11169
11200
  this.writeableStateStore.setConnectedUser(undefined);