@opentok/client 2.35.2-alpha.1 → 2.35.2-alpha.2

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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.35.2 c0c0842af
2
+ * @license OpenTok.js 2.35.2 57b73084b
3
3
  *
4
4
  * Copyright (c) 2010-2026 TokBox, Inc.
5
5
  * Subject to the applicable Software Development Kit (SDK) License Agreement:
6
6
  * https://www.vonage.com/legal/communications-apis/terms-of-use/
7
7
  *
8
- * Date: Fri, 21 Aug 2026 13:40:51 GMT
8
+ * Date: Mon, 24 Aug 2026 10:31:07 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -9407,6 +9407,9 @@ var _default = _ref => {
9407
9407
  reason
9408
9408
  });
9409
9409
  };
9410
+ _proto.resetReconnectDurationTimer = function resetReconnectDurationTimer() {
9411
+ this.readyStateMachine.resetReconnectDurationTimer();
9412
+ };
9410
9413
  _proto._resetPingTimers = function _resetPingTimers() {
9411
9414
  this._pingWarningTimer.clear();
9412
9415
  this._pingTimer.reset(() => {
@@ -17869,7 +17872,7 @@ var _default = _ref => {
17869
17872
  let hasReconnectMaxDurationElapsed;
17870
17873
  function handleDisconnect(_ref2) {
17871
17874
  let code = _ref2.code;
17872
- if (this.state === 'open' || !hasReconnectMaxDurationElapsed) {
17875
+ if (!hasReconnectMaxDurationElapsed) {
17873
17876
  hasReconnectMaxDurationElapsed = (0, _elapsed.default)(reconnectMaxDuration);
17874
17877
  }
17875
17878
  const shouldReconnect = reconnectMaxDuration > 0 && !hasReconnectMaxDurationElapsed() && [CLOSE_UNSUPPORTED, CLOSE_UNEXPECTED_CONDITION].indexOf(code) === -1 && [CLOSED, CLOSING].indexOf(this.readyState) === -1;
@@ -17878,7 +17881,7 @@ var _default = _ref => {
17878
17881
  }
17879
17882
  return 'closing';
17880
17883
  }
17881
- return new _javascriptStateMachine.default({
17884
+ const stateMachine = new _javascriptStateMachine.default({
17882
17885
  init: 'connecting',
17883
17886
  methods: {
17884
17887
  onInvalidTransition(transition, from, to) {
@@ -17907,6 +17910,10 @@ var _default = _ref => {
17907
17910
  to: handleDisconnect
17908
17911
  }]
17909
17912
  });
17913
+ stateMachine.resetReconnectDurationTimer = () => {
17914
+ hasReconnectMaxDurationElapsed = undefined;
17915
+ };
17916
+ return stateMachine;
17910
17917
  };
17911
17918
  exports["default"] = _default;
17912
17919
 
@@ -18556,6 +18563,8 @@ var _default = _ref => {
18556
18563
  _this._opened = false;
18557
18564
  _this._socket = void 0;
18558
18565
  _this._reconnectAttempts = 0;
18566
+ _this._isReconnecting = false;
18567
+ _this._awaitingReconnectRecovery = false;
18559
18568
  _this._socketID = (0, _uuid.v4)();
18560
18569
  _this._receivedTransactionIDs = new _AutoClearingSet.default(30000, 10000);
18561
18570
  _this._notifyDisconnectAddress = void 0;
@@ -18592,6 +18601,8 @@ var _default = _ref => {
18592
18601
  }
18593
18602
  const onOpen = () => {
18594
18603
  _this._opened = true;
18604
+ _this._isReconnecting = false;
18605
+ _this._awaitingReconnectRecovery = false;
18595
18606
  _this._socket.send({
18596
18607
  data: _RumorMessage.default.Connect(_this.id, notifyDisconnectAddress).serialize(),
18597
18608
  retryAfterReconnect: true,
@@ -18603,6 +18614,8 @@ var _default = _ref => {
18603
18614
  _this._socket.on('message', event => _this._receiveMessage(event));
18604
18615
  _this._socket.once('close', closeEvent => {
18605
18616
  _this._logger.debug(`ReconnectableSocket closed (code: ${closeEvent.code})`);
18617
+ _this._isReconnecting = false;
18618
+ _this._awaitingReconnectRecovery = false;
18606
18619
  _this._clearPendingMessages();
18607
18620
 
18608
18621
  // We don't emit an error for these close codes because they are normal and TIMEOUT has a
@@ -18631,7 +18644,12 @@ var _default = _ref => {
18631
18644
  if (!_this._opened) {
18632
18645
  return;
18633
18646
  } // ignore reconnect events when we haven't opened yet
18647
+ _this._awaitingReconnectRecovery = false;
18634
18648
  _this._clearPendingMessagesWhichShouldntRetry();
18649
+ if (_this._isReconnecting) {
18650
+ return;
18651
+ }
18652
+ _this._isReconnecting = true;
18635
18653
  _this.emit('reconnecting');
18636
18654
  _this._reconnectAttempts = 0;
18637
18655
  });
@@ -18655,21 +18673,16 @@ var _default = _ref => {
18655
18673
  onOpen();
18656
18674
  return;
18657
18675
  } // ignore reconnect events when we haven't opened yet
18658
- // Resend pending messages (unacknowledged messages)
18659
- _this._pendingMessages.forEach(msg => {
18660
- _this._socket.send({
18661
- data: msg.rumorMessage.serialize(),
18662
- retryAfterReconnect: true,
18663
- expectAck: true
18664
- });
18665
- });
18666
- _this.emit('reconnected');
18676
+ _this._awaitingReconnectRecovery = true;
18677
+ _this._resendPendingMessages();
18667
18678
  });
18668
18679
  _this._socket.on('reconnectFailure', () => {
18669
18680
  if (!_this._opened) {
18670
18681
  return;
18671
18682
  } // ignore reconnect events when we haven't opened yet
18672
18683
  _this._logger.debug('Reconnecting failed as connectivity was not restored within ' + `${reconnectMaxDuration}ms`);
18684
+ _this._isReconnecting = false;
18685
+ _this._awaitingReconnectRecovery = false;
18673
18686
 
18674
18687
  // TODO: This was picked when porting over the old code, but we should be able to set use a
18675
18688
  // better code and message here.
@@ -18696,6 +18709,41 @@ var _default = _ref => {
18696
18709
  });
18697
18710
  this._pendingMessages.clear();
18698
18711
  };
18712
+ _proto._onRumorMessagingResumed = function _onRumorMessagingResumed() {
18713
+ var _this$_socket;
18714
+ if (!this._awaitingReconnectRecovery) {
18715
+ return;
18716
+ }
18717
+ this._awaitingReconnectRecovery = false;
18718
+ this._isReconnecting = false;
18719
+ (_this$_socket = this._socket) == null ? void 0 : _this$_socket.resetReconnectDurationTimer();
18720
+ this.emit('reconnected');
18721
+ };
18722
+ _proto._resendPendingMessages = function _resendPendingMessages() {
18723
+ this._pendingMessages.forEach(msg => {
18724
+ this._sendPendingMessage(msg);
18725
+ });
18726
+ };
18727
+ _proto.injectQueuedMessages = function injectQueuedMessages(queuedMessages) {
18728
+ if (queuedMessages === void 0) {
18729
+ queuedMessages = new Map();
18730
+ }
18731
+ queuedMessages.forEach((message, transactionId) => {
18732
+ this._pendingMessages.set(transactionId, message);
18733
+ });
18734
+ if (this._opened && this.readyState === RumorSocket.OPEN) {
18735
+ queuedMessages.forEach(message => {
18736
+ this._sendPendingMessage(message);
18737
+ });
18738
+ }
18739
+ };
18740
+ _proto._sendPendingMessage = function _sendPendingMessage(message) {
18741
+ this._socket.send({
18742
+ data: message.rumorMessage.serialize(),
18743
+ retryAfterReconnect: true,
18744
+ expectAck: true
18745
+ });
18746
+ };
18699
18747
  _proto._sendAck = function _sendAck(msg) {
18700
18748
  this._socket.send({
18701
18749
  data: _RumorMessage.default.Status([msg.fromAddress], {
@@ -18716,6 +18764,8 @@ var _default = _ref => {
18716
18764
  errorMsg: 'Deserialize RumorMessage failure.'
18717
18765
  };
18718
18766
  this.emit('error#message', error);
18767
+ } else {
18768
+ this._onRumorMessagingResumed();
18719
18769
  }
18720
18770
  if (msg.type === RumorMessageTypes.PONG) {
18721
18771
  return;
@@ -18813,6 +18863,8 @@ var _default = _ref => {
18813
18863
  });
18814
18864
  };
18815
18865
  _proto.disconnect = function disconnect() {
18866
+ this._isReconnecting = false;
18867
+ this._awaitingReconnectRecovery = false;
18816
18868
  if (this.readyState === RumorSocket.OPEN) {
18817
18869
  const message = _RumorMessage.default.Disconnect();
18818
18870
  this._socket.send({
@@ -39663,7 +39715,7 @@ function staticConfigFactory(_temp) {
39663
39715
  _ref$axios = _ref.axios,
39664
39716
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
39665
39717
  _ref$properties = _ref.properties,
39666
- properties = _ref$properties === void 0 ? {"version":"v2.35.2","buildHash":"c0c0842af","minimumVersion":{"firefox":52,"chrome":49},"debug":false,"websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com","vonageApiURL":""} : _ref$properties;
39718
+ properties = _ref$properties === void 0 ? {"version":"v2.35.2","buildHash":"57b73084b","minimumVersion":{"firefox":52,"chrome":49},"debug":false,"websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com","vonageApiURL":""} : _ref$properties;
39667
39719
  /** @type builtInConfig */
39668
39720
  const builtInConfig = (0, _cloneDeep.default)(properties);
39669
39721
  /**