@opentok/client 2.35.0-alpha.55 → 2.35.0-alpha.57

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.0 5b7d62ce7
2
+ * @license OpenTok.js 2.35.0 929017bbf
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: Tue, 16 Jun 2026 08:15:22 GMT
8
+ * Date: Fri, 19 Jun 2026 06:02:39 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -39202,7 +39202,7 @@ function staticConfigFactory(_temp) {
39202
39202
  _ref$axios = _ref.axios,
39203
39203
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
39204
39204
  _ref$properties = _ref.properties,
39205
- properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"5b7d62ce7","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;
39205
+ properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"929017bbf","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;
39206
39206
  /** @type builtInConfig */
39207
39207
  const builtInConfig = (0, _cloneDeep.default)(properties);
39208
39208
  /**
@@ -41014,6 +41014,7 @@ function PublisherFactory(_ref) {
41014
41014
  let _preferredWidth;
41015
41015
  let _preferredHeight;
41016
41016
  let _preferredFrameRate;
41017
+ let _suppressVideoDimensionsSignaling = false;
41017
41018
  let _targetScalabilityMode;
41018
41019
  let _peerId;
41019
41020
  let _raptorUri;
@@ -43018,7 +43019,7 @@ function PublisherFactory(_ref) {
43018
43019
  if (!properties.publishVideo) {
43019
43020
  return;
43020
43021
  }
43021
- if (_this.stream) {
43022
+ if (_this.stream && !_suppressVideoDimensionsSignaling) {
43022
43023
  _this.stream.setVideoDimensions(newValue.width, newValue.height);
43023
43024
  }
43024
43025
  _this.dispatchEvent(new Events.VideoDimensionsChangedEvent(_this, oldValue, newValue));
@@ -45464,6 +45465,20 @@ function PublisherFactory(_ref) {
45464
45465
  this._setScalableVideoLayers(properties.scalableVideoLayers);
45465
45466
  configureScalabilityMode().catch(() => {});
45466
45467
 
45468
+ // Propagate any preferred resolution/frameRate set before publish via signaling
45469
+ if (this.stream && (_preferredWidth || _preferredHeight || _preferredFrameRate)) {
45470
+ const _getPreferredVideoTra = getPreferredVideoTrackSettings(),
45471
+ width = _getPreferredVideoTra.width,
45472
+ height = _getPreferredVideoTra.height,
45473
+ actualFrameRate = _getPreferredVideoTra.frameRate;
45474
+ if (width && height && (_preferredWidth || _preferredHeight)) {
45475
+ this.stream.setVideoDimensions(width, height);
45476
+ }
45477
+ if (actualFrameRate && _preferredFrameRate) {
45478
+ this.stream.setVideoFrameRate(actualFrameRate);
45479
+ }
45480
+ }
45481
+
45467
45482
  // See OPENTOK-45935
45468
45483
  // Some users reuse the publisher when disconnecting and reconnecting
45469
45484
  // to a session. This re-synchronizes the state of the stream channels.
@@ -47412,9 +47427,17 @@ function PublisherFactory(_ref) {
47412
47427
  };
47413
47428
  return (0, _videoConstraints.default)(track, constraints);
47414
47429
  };
47430
+
47431
+ // Returns the settings of the most authoritative video track, using the same
47432
+ // priority order as applyVideoConstraints (original track before processed track).
47433
+ const getPreferredVideoTrackSettings = () => {
47434
+ var _videoMediaProcessorC, _webRTCStream, _webRTCStream$getVide6, _track$getSettings;
47435
+ const track = typeof (mediaProcessor == null ? void 0 : mediaProcessor.getOriginalVideoTrack) === 'function' && mediaProcessor.getOriginalVideoTrack() || ((_videoMediaProcessorC = _videoMediaProcessorConnector) == null ? void 0 : _videoMediaProcessorC.originalTrack) || ((_webRTCStream = webRTCStream) == null ? void 0 : (_webRTCStream$getVide6 = _webRTCStream.getVideoTracks()) == null ? void 0 : _webRTCStream$getVide6[0]);
47436
+ return (_track$getSettings = track == null ? void 0 : track.getSettings()) != null ? _track$getSettings : {};
47437
+ };
47415
47438
  const applyVideoConstraints = () => {
47416
- var _videoMediaProcessorC;
47417
- const videoTracks = [mediaProcessor == null ? void 0 : mediaProcessor.getOriginalVideoTrack(), (_videoMediaProcessorC = _videoMediaProcessorConnector) == null ? void 0 : _videoMediaProcessorC.originalTrack, ...webRTCStream.getVideoTracks()].filter(track => {
47439
+ var _videoMediaProcessorC2;
47440
+ const videoTracks = [typeof (mediaProcessor == null ? void 0 : mediaProcessor.getOriginalVideoTrack) === 'function' && mediaProcessor.getOriginalVideoTrack(), (_videoMediaProcessorC2 = _videoMediaProcessorConnector) == null ? void 0 : _videoMediaProcessorC2.originalTrack, ...webRTCStream.getVideoTracks()].filter(track => {
47418
47441
  var _window$MediaStreamTr;
47419
47442
  return track && (
47420
47443
  // On Chrome both original and filtered track (instance of MediaStreamTrackGenerator) need to
@@ -47449,15 +47472,15 @@ function PublisherFactory(_ref) {
47449
47472
  */
47450
47473
  this.setPreferredResolution = /*#__PURE__*/function () {
47451
47474
  var _ref71 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee64(preferredResolution) {
47452
- var _webRTCStream, _webRTCStream$getVide6, _properties$videoDime3, _properties$videoDime4;
47453
- var message, startingWidth, startingHeight, startingArea, preferredArea, result;
47475
+ var _webRTCStream2, _webRTCStream2$getVid, _properties$videoDime3, _properties$videoDime4;
47476
+ var message, startingWidth, startingHeight, startingArea, preferredArea, result, _getPreferredVideoTra2, width, height;
47454
47477
  return _regenerator.default.wrap(function _callee64$(_context64) {
47455
47478
  while (1) switch (_context64.prev = _context64.next) {
47456
47479
  case 0:
47457
47480
  logAnalyticsEvent('setPreferredResolution', 'Attempt', {
47458
47481
  preferredResolution
47459
47482
  });
47460
- if (!(!properties.publishVideo || !((_webRTCStream = webRTCStream) != null && (_webRTCStream$getVide6 = _webRTCStream.getVideoTracks()) != null && _webRTCStream$getVide6.length))) {
47483
+ if (!(!properties.publishVideo || !((_webRTCStream2 = webRTCStream) != null && (_webRTCStream2$getVid = _webRTCStream2.getVideoTracks()) != null && _webRTCStream2$getVid.length))) {
47461
47484
  _context64.next = 5;
47462
47485
  break;
47463
47486
  }
@@ -47496,28 +47519,46 @@ function PublisherFactory(_ref) {
47496
47519
  case 17:
47497
47520
  _preferredWidth = preferredResolution.width;
47498
47521
  _preferredHeight = preferredResolution.height;
47499
- _context64.prev = 19;
47500
- _context64.next = 22;
47522
+ // Suppress videoDimensionsChanged before applying constraints: the video element
47523
+ // resize triggered by applyVideoConstraints() would otherwise cause a duplicate
47524
+ // streamChannelUpdate. We do the signaling ourselves below with the actual track settings.
47525
+ _suppressVideoDimensionsSignaling = true;
47526
+ _context64.prev = 20;
47527
+ _context64.prev = 21;
47528
+ _context64.next = 24;
47501
47529
  return applyVideoConstraints();
47502
- case 22:
47530
+ case 24:
47503
47531
  result = _context64.sent;
47532
+ if (_this.stream) {
47533
+ _getPreferredVideoTra2 = getPreferredVideoTrackSettings(), width = _getPreferredVideoTra2.width, height = _getPreferredVideoTra2.height;
47534
+ if (width && height) {
47535
+ _this.stream.setVideoDimensions(width, height);
47536
+ }
47537
+ }
47504
47538
  logAnalyticsEvent('setPreferredResolution', 'Success', {
47505
47539
  preferredResolution
47506
47540
  });
47507
47541
  return _context64.abrupt("return", result);
47508
- case 27:
47509
- _context64.prev = 27;
47510
- _context64.t0 = _context64["catch"](19);
47542
+ case 28:
47543
+ _context64.prev = 28;
47544
+ _suppressVideoDimensionsSignaling = false;
47545
+ return _context64.finish(28);
47546
+ case 31:
47547
+ _context64.next = 37;
47548
+ break;
47549
+ case 33:
47550
+ _context64.prev = 33;
47551
+ _context64.t0 = _context64["catch"](20);
47511
47552
  logAnalyticsEvent('setPreferredResolution', 'Failure', {
47512
47553
  preferredResolution,
47513
47554
  message: _context64.t0.message
47514
47555
  });
47515
47556
  throw _context64.t0;
47516
- case 31:
47557
+ case 37:
47517
47558
  case "end":
47518
47559
  return _context64.stop();
47519
47560
  }
47520
- }, _callee64, null, [[19, 27]]);
47561
+ }, _callee64, null, [[20, 33], [21,, 28, 31]]);
47521
47562
  }));
47522
47563
  return function (_x52) {
47523
47564
  return _ref71.apply(this, arguments);
@@ -47542,15 +47583,15 @@ function PublisherFactory(_ref) {
47542
47583
  */
47543
47584
  this.setPreferredFrameRate = /*#__PURE__*/function () {
47544
47585
  var _ref72 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee65(frameRate) {
47545
- var _webRTCStream2, _webRTCStream2$getVid;
47546
- var message, result;
47586
+ var _webRTCStream3, _webRTCStream3$getVid;
47587
+ var message, result, _getPreferredVideoTra3, actualFrameRate;
47547
47588
  return _regenerator.default.wrap(function _callee65$(_context65) {
47548
47589
  while (1) switch (_context65.prev = _context65.next) {
47549
47590
  case 0:
47550
47591
  logAnalyticsEvent('setPreferredFrameRate', 'Attempt', {
47551
47592
  frameRate
47552
47593
  });
47553
- if (!(!properties.publishVideo || !((_webRTCStream2 = webRTCStream) != null && (_webRTCStream2$getVid = _webRTCStream2.getVideoTracks()) != null && _webRTCStream2$getVid.length))) {
47594
+ if (!(!properties.publishVideo || !((_webRTCStream3 = webRTCStream) != null && (_webRTCStream3$getVid = _webRTCStream3.getVideoTracks()) != null && _webRTCStream3$getVid.length))) {
47554
47595
  _context65.next = 5;
47555
47596
  break;
47556
47597
  }
@@ -47578,23 +47619,29 @@ function PublisherFactory(_ref) {
47578
47619
  return applyVideoConstraints();
47579
47620
  case 13:
47580
47621
  result = _context65.sent;
47622
+ if (_this.stream) {
47623
+ _getPreferredVideoTra3 = getPreferredVideoTrackSettings(), actualFrameRate = _getPreferredVideoTra3.frameRate;
47624
+ if (actualFrameRate) {
47625
+ _this.stream.setVideoFrameRate(actualFrameRate);
47626
+ }
47627
+ }
47581
47628
  logAnalyticsEvent('setPreferredFrameRate', 'Success', {
47582
47629
  frameRate
47583
47630
  });
47584
47631
  return _context65.abrupt("return", result);
47585
- case 18:
47586
- _context65.prev = 18;
47632
+ case 19:
47633
+ _context65.prev = 19;
47587
47634
  _context65.t0 = _context65["catch"](10);
47588
47635
  logAnalyticsEvent('setPreferredFrameRate', 'Failure', {
47589
47636
  frameRate,
47590
47637
  message: _context65.t0.message
47591
47638
  });
47592
47639
  throw _context65.t0;
47593
- case 22:
47640
+ case 23:
47594
47641
  case "end":
47595
47642
  return _context65.stop();
47596
47643
  }
47597
- }, _callee65, null, [[10, 18]]);
47644
+ }, _callee65, null, [[10, 19]]);
47598
47645
  }));
47599
47646
  return function (_x53) {
47600
47647
  return _ref72.apply(this, arguments);
@@ -62427,7 +62474,6 @@ function PeerConnectionFactory(deps) {
62427
62474
  options
62428
62475
  });
62429
62476
  const sdpTransforms = sdpTransformDefaults;
62430
- const shouldFilterCandidate = candidate => iceConfig.transportPolicy === 'relay' && candidate != null && candidate.candidate.indexOf('typ relay') === -1;
62431
62477
  const config = (0, _omit.default)(options, ['isPublisher', 'logAnalyticsEvent', 'offerOverrides', 'answerOverrides', 'sendMessage']);
62432
62478
  let _peerConnection, _channels, _offer, _answer, _transitionToFailedTimeOut;
62433
62479
  let _peerConnectionCompletionHandlers = [];
@@ -62559,16 +62605,23 @@ function PeerConnectionFactory(deps) {
62559
62605
  }
62560
62606
  };
62561
62607
  })();
62562
- const _readyToCompleteOffer = {
62608
+ let candidateReadyTimer;
62609
+ let candidatesReadyResolved = false;
62610
+ const _candidatesReady = {
62563
62611
  clean() {
62612
+ if (candidateReadyTimer) {
62613
+ clearTimeout(candidateReadyTimer);
62614
+ candidateReadyTimer = null;
62615
+ }
62616
+ candidatesReadyResolved = true;
62564
62617
  delete this.promise;
62565
62618
  delete this.resolve;
62566
62619
  delete this.reject;
62567
62620
  }
62568
62621
  };
62569
- _readyToCompleteOffer.promise = new Promise((resolve, reject) => {
62570
- _readyToCompleteOffer.resolve = resolve;
62571
- _readyToCompleteOffer.reject = reject;
62622
+ _candidatesReady.promise = new Promise((resolve, reject) => {
62623
+ _candidatesReady.resolve = resolve;
62624
+ _candidatesReady.reject = reject;
62572
62625
  });
62573
62626
  let _iceProcessor = new IceCandidateProcessor();
62574
62627
  let _state = 'new';
@@ -62733,7 +62786,6 @@ function PeerConnectionFactory(deps) {
62733
62786
  return _ref6.apply(this, arguments);
62734
62787
  };
62735
62788
  }();
62736
- _readyToCompleteOffer.resolve();
62737
62789
  const getOrCreateSFrameReceiverClient = /*#__PURE__*/function () {
62738
62790
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(sFrameSenderId) {
62739
62791
  return _regenerator.default.wrap(function _callee6$(_context6) {
@@ -62903,12 +62955,45 @@ function PeerConnectionFactory(deps) {
62903
62955
  logging,
62904
62956
  logAnalyticsEvent
62905
62957
  });
62958
+
62959
+ // Wait for a relay candidate before completing the offer so that relay
62960
+ // candidates are available as fallback when iceTransportPolicy is 'all'.
62961
+ const CANDIDATE_READY_TIMEOUT = 2000;
62962
+ const resolveCandidatesReady = function resolveCandidatesReady(timeoutReached) {
62963
+ if (timeoutReached === void 0) {
62964
+ timeoutReached = false;
62965
+ }
62966
+ if (candidateReadyTimer) {
62967
+ clearTimeout(candidateReadyTimer);
62968
+ candidateReadyTimer = null;
62969
+ }
62970
+ if (candidatesReadyResolved) return;
62971
+ candidatesReadyResolved = true;
62972
+ _candidatesReady.resolve();
62973
+ if (timeoutReached) {
62974
+ const msg = `In ${CANDIDATE_READY_TIMEOUT}ms the ICE gathering didn't finish and no relay candidate was received`;
62975
+ logging.warn(msg);
62976
+ logAnalyticsEvent('iceCandidatesReady', 'Event', {
62977
+ msg
62978
+ });
62979
+ }
62980
+ };
62981
+ if (candidateReadyTimer) {
62982
+ clearTimeout(candidateReadyTimer);
62983
+ }
62984
+ candidateReadyTimer = setTimeout(resolveCandidatesReady, CANDIDATE_READY_TIMEOUT, true);
62906
62985
  const onIceCandidate = event => {
62907
- _readyToCompleteOffer.resolve();
62908
- if (shouldFilterCandidate(event.candidate)) {
62909
- logging.debug('Ignore candidate', event.candidate.candidate);
62986
+ var _candidate$candidate;
62987
+ const candidate = event.candidate;
62988
+ const isRelayCandidate = candidate == null ? void 0 : (_candidate$candidate = candidate.candidate) == null ? void 0 : _candidate$candidate.includes('typ relay');
62989
+ if (candidate !== null && iceConfig.transportPolicy === 'relay' && !isRelayCandidate) {
62910
62990
  return;
62911
62991
  }
62992
+ if (isRelayCandidate || candidate === null) {
62993
+ // If we have a relay candidate or the gathering is completed (candidate === null),
62994
+ // resolve immediately
62995
+ resolveCandidatesReady();
62996
+ }
62912
62997
  forwarder(event);
62913
62998
  };
62914
62999
  const onTrackAdded = /*#__PURE__*/function () {
@@ -62982,11 +63067,18 @@ function PeerConnectionFactory(deps) {
62982
63067
  }
62983
63068
  api.trigger('negotiationNeeded');
62984
63069
  };
63070
+ const onIceGatheringStateChange = () => {
63071
+ if (_peerConnection.iceGatheringState === 'complete') {
63072
+ // Gathering is done — resolve even if no relay candidate arrived
63073
+ resolveCandidatesReady();
63074
+ }
63075
+ };
62985
63076
  _peerConnection.addEventListener('track', onTrackAdded);
62986
63077
  _peerConnection.addEventListener('icecandidate', onIceCandidate);
62987
63078
  _peerConnection.addEventListener('signalingstatechange', routeStateChanged);
62988
63079
  _peerConnection.addEventListener('negotiationneeded', onNegotiationNeeded);
62989
63080
  _peerConnection.addEventListener('iceconnectionstatechange', onIceConnectionStateChanged);
63081
+ _peerConnection.addEventListener('icegatheringstatechange', onIceGatheringStateChange);
62990
63082
  cleanupJobs.add(() => {
62991
63083
  if (!_peerConnection) {
62992
63084
  return;
@@ -62996,6 +63088,7 @@ function PeerConnectionFactory(deps) {
62996
63088
  _peerConnection.removeEventListener('signalingstatechange', routeStateChanged);
62997
63089
  _peerConnection.removeEventListener('negotiationneeded', onNegotiationNeeded);
62998
63090
  _peerConnection.removeEventListener('iceconnectionstatechange', onIceConnectionStateChanged);
63091
+ _peerConnection.removeEventListener('icegatheringstatechange', onIceGatheringStateChange);
62999
63092
  });
63000
63093
  triggerPeerConnectionCompletion(null);
63001
63094
  };
@@ -63017,7 +63110,7 @@ function PeerConnectionFactory(deps) {
63017
63110
  _peerConnectionCompletionHandlers = [];
63018
63111
  qos.stopCollecting();
63019
63112
  cleanupJobs.releaseAll();
63020
- _readyToCompleteOffer.clean();
63113
+ _candidatesReady.clean();
63021
63114
  statsCache.destroy();
63022
63115
  if (_peerConnection !== null) {
63023
63116
  if (_peerConnection.destroy) {
@@ -63140,7 +63233,7 @@ function PeerConnectionFactory(deps) {
63140
63233
  };
63141
63234
  const onRemoteVideoSupported = supported => api.trigger('remoteVideoSupported', supported);
63142
63235
  internalCreatePeerConnection(() => {
63143
- offerProcessor(_peerConnection, windowMock.RTCPeerConnection, windowMock.RTCSessionDescription, NativeRTCSessionDescription, sdpTransforms, offer, codecFlags, p2p, relayAnswer, reportError, onRemoteVideoSupported, replaceBaselineProfile, sourceStreamId);
63236
+ offerProcessor(_peerConnection, windowMock.RTCPeerConnection, windowMock.RTCSessionDescription, NativeRTCSessionDescription, sdpTransforms, offer, codecFlags, p2p, (answer, modifiedOffer) => _candidatesReady.promise.then(() => relayAnswer(answer, modifiedOffer)), reportError, onRemoteVideoSupported, replaceBaselineProfile, sourceStreamId);
63144
63237
  });
63145
63238
  };
63146
63239
  const processAnswer = message => {
@@ -63221,7 +63314,7 @@ function PeerConnectionFactory(deps) {
63221
63314
  }).then(offer => {
63222
63315
  logging.debug('processSubscribe: got offer, waiting for ' + '_readyToCompleteOffer');
63223
63316
  _offer = offer;
63224
- _readyToCompleteOffer.promise.then(() => onOfferCreated(_offer));
63317
+ _candidatesReady.promise.then(() => onOfferCreated(_offer));
63225
63318
  logAnalyticsEvent('peerConnection:processSubscribe', 'Success', {
63226
63319
  sdp: _offer.sdp
63227
63320
  });
@@ -106050,6 +106143,9 @@ function Stream(id, name, creationTime, connection, session, channel, initials,
106050
106143
  case 'videoDimensions':
106051
106144
  self.videoDimensions = newValue;
106052
106145
  break;
106146
+ case 'frameRate':
106147
+ self.frameRate = newValue;
106148
+ break;
106053
106149
  case 'orientation':
106054
106150
  case 'width':
106055
106151
  case 'height':
@@ -106154,6 +106250,11 @@ function Stream(id, name, creationTime, connection, session, channel, initials,
106154
106250
  orientation: 0
106155
106251
  });
106156
106252
  };
106253
+ this.setVideoFrameRate = function setVideoFrameRate(frameRate) {
106254
+ updateChannelsOfType('video', {
106255
+ frameRate
106256
+ });
106257
+ };
106157
106258
  this.setRestrictFrameRate = function setRestrictFrameRate(restrict, completion) {
106158
106259
  if (completion === void 0) {
106159
106260
  completion = () => {};