@opentok/client 2.36.0-alpha.14 → 2.36.0-alpha.16

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.
@@ -488,6 +488,8 @@ declare namespace OT {
488
488
  promise: (value: boolean) => Promise<void>;
489
489
  }
490
490
  publishCaptions(value: boolean): Promise<void>;
491
+ setCaptionsInputLanguage(langCode: CaptionsLanguageCode | null): Promise<void>;
492
+ getCaptionsInputLanguage(): CaptionsLanguageCode | null;
491
493
  cycleVideo(): Promise<{ deviceId: string }>;
492
494
  setAudioSource(audioSource:string | MediaStreamTrack): Promise<undefined>;
493
495
  getAudioSource(): MediaStreamTrack;
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.36.0 4ced01c04
2
+ * @license OpenTok.js 2.36.0 80ef11d29
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: Wed, 29 Jul 2026 10:18:19 GMT
8
+ * Date: Wed, 29 Jul 2026 11:28:57 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -9863,29 +9863,17 @@ var _interopRequireDefault = __webpack_require__(95709);
9863
9863
  exports.__esModule = true;
9864
9864
  exports["default"] = void 0;
9865
9865
  var _getProtocolFromPriority = _interopRequireDefault(__webpack_require__(85045));
9866
- var _default = (selectedCandidatePairId, stats) => {
9867
- let localRelayProtocol = '';
9868
- if (!selectedCandidatePairId || !stats) {
9869
- return localRelayProtocol;
9870
- }
9871
- const activeCandidatePair = stats.get(selectedCandidatePairId);
9872
- if (activeCandidatePair) {
9873
- const localCandidateId = activeCandidatePair.localCandidateId;
9874
- if (localCandidateId) {
9875
- const localCandidate = stats.get(localCandidateId);
9876
- if (localCandidate) {
9877
- const relayProtocol = localCandidate.relayProtocol,
9878
- priority = localCandidate.priority;
9879
- if (relayProtocol) {
9880
- const RELAY_PROTOCOL = relayProtocol.toUpperCase();
9881
- localRelayProtocol = `TURN/${RELAY_PROTOCOL}`;
9882
- } else {
9883
- localRelayProtocol = (0, _getProtocolFromPriority.default)(priority);
9884
- }
9885
- }
9866
+ var _default = localCandidate => {
9867
+ if (localCandidate) {
9868
+ const relayProtocol = localCandidate.relayProtocol,
9869
+ priority = localCandidate.priority;
9870
+ if (relayProtocol) {
9871
+ const RELAY_PROTOCOL = relayProtocol.toUpperCase();
9872
+ return `TURN/${RELAY_PROTOCOL}`;
9886
9873
  }
9874
+ return (0, _getProtocolFromPriority.default)(priority);
9887
9875
  }
9888
- return localRelayProtocol;
9876
+ return '';
9889
9877
  };
9890
9878
  exports["default"] = _default;
9891
9879
 
@@ -14472,6 +14460,40 @@ const getAddress = res => {
14472
14460
  const ip = res.ipAddress || res.address || res.ip;
14473
14461
  return `${ip}:${port}`;
14474
14462
  };
14463
+ const getCandidatesInfo = (activeCandidatePair, stats) => {
14464
+ let localRelayProtocol;
14465
+ let localCandidateType;
14466
+ let localAddress;
14467
+ let transportType;
14468
+ let remoteCandidateType;
14469
+ let remoteAddress;
14470
+ const localCandidateId = activeCandidatePair.localCandidateId,
14471
+ remoteCandidateId = activeCandidatePair.remoteCandidateId;
14472
+ if (localCandidateId) {
14473
+ const localCandidate = stats.get(localCandidateId);
14474
+ if (localCandidate) {
14475
+ localRelayProtocol = (0, _getLocalRelayProtocol.default)(localCandidate);
14476
+ localCandidateType = localCandidate.candidateType;
14477
+ localAddress = getAddress(localCandidate);
14478
+ transportType = localCandidate.protocol || localCandidate.transport;
14479
+ }
14480
+ }
14481
+ if (remoteCandidateId) {
14482
+ const remoteCandidate = stats.get(remoteCandidateId);
14483
+ if (remoteCandidate) {
14484
+ remoteCandidateType = remoteCandidate.candidateType;
14485
+ remoteAddress = getAddress(remoteCandidate);
14486
+ }
14487
+ }
14488
+ return {
14489
+ localRelayProtocol,
14490
+ localCandidateType,
14491
+ localAddress,
14492
+ transportType,
14493
+ remoteCandidateType,
14494
+ remoteAddress
14495
+ };
14496
+ };
14475
14497
 
14476
14498
  // Get Stats using the older API. Used by Chrome up until v58.
14477
14499
  function parseStatsOldAPI(statsCache, prevStats, currentStats, isPublisher, completion) {
@@ -14791,15 +14813,27 @@ function parseStatsNewAPI(statsCache, prevStats, currentStats, isPublisher, comp
14791
14813
  srtpCipher = res.srtpCipher;
14792
14814
  currentStats.srtpCipher = srtpCipher;
14793
14815
  if (selectedCandidatePairId) {
14794
- localRelayProtocol = (0, _getLocalRelayProtocol.default)(selectedCandidatePairId, stats);
14816
+ const activeCandidatePair = stats.get(selectedCandidatePairId);
14817
+ if (activeCandidatePair) {
14818
+ var _getCandidatesInfo = getCandidatesInfo(activeCandidatePair, stats);
14819
+ localRelayProtocol = _getCandidatesInfo.localRelayProtocol;
14820
+ localCandidateType = _getCandidatesInfo.localCandidateType;
14821
+ localAddress = _getCandidatesInfo.localAddress;
14822
+ transportType = _getCandidatesInfo.transportType;
14823
+ remoteCandidateType = _getCandidatesInfo.remoteCandidateType;
14824
+ remoteAddress = _getCandidatesInfo.remoteAddress;
14825
+ }
14795
14826
  }
14796
14827
  } else if (strippedType === 'localcandidate') {
14797
- localCandidateType = res.candidateType;
14798
- localAddress = getAddress(res);
14799
- transportType = res.protocol || res.transport;
14828
+ var _localRelayProtocol, _localCandidateType, _localAddress, _transportType;
14829
+ (_localRelayProtocol = localRelayProtocol) != null ? _localRelayProtocol : localRelayProtocol = (0, _getLocalRelayProtocol.default)(res);
14830
+ (_localCandidateType = localCandidateType) != null ? _localCandidateType : localCandidateType = res.candidateType;
14831
+ (_localAddress = localAddress) != null ? _localAddress : localAddress = getAddress(res);
14832
+ (_transportType = transportType) != null ? _transportType : transportType = res.protocol || res.transport;
14800
14833
  } else if (strippedType === 'remotecandidate') {
14801
- remoteCandidateType = res.candidateType;
14802
- remoteAddress = getAddress(res);
14834
+ var _remoteCandidateType, _remoteAddress;
14835
+ (_remoteCandidateType = remoteCandidateType) != null ? _remoteCandidateType : remoteCandidateType = res.candidateType;
14836
+ (_remoteAddress = remoteAddress) != null ? _remoteAddress : remoteAddress = getAddress(res);
14803
14837
  } else if (strippedType === 'track' && lowercaseId.indexOf('video') !== 0) {
14804
14838
  frameWidth = res.frameWidth;
14805
14839
  frameHeight = res.frameHeight;
@@ -14819,6 +14853,15 @@ function parseStatsNewAPI(statsCache, prevStats, currentStats, isPublisher, comp
14819
14853
  const estimatedStat = `video${isPublisher ? 'Sent' : 'Recv'}EstimatedBandwidth`;
14820
14854
  currentStats[estimatedStat] = parseInt(res.availableOutgoingBitrate, 10);
14821
14855
  }
14856
+ if (res.selected) {
14857
+ var _getCandidatesInfo2 = getCandidatesInfo(res, stats);
14858
+ localRelayProtocol = _getCandidatesInfo2.localRelayProtocol;
14859
+ localCandidateType = _getCandidatesInfo2.localCandidateType;
14860
+ localAddress = _getCandidatesInfo2.localAddress;
14861
+ transportType = _getCandidatesInfo2.transportType;
14862
+ remoteCandidateType = _getCandidatesInfo2.remoteCandidateType;
14863
+ remoteAddress = _getCandidatesInfo2.remoteAddress;
14864
+ }
14822
14865
  }
14823
14866
  };
14824
14867
 
@@ -27480,6 +27523,12 @@ function RaptorSocketFactory(deps) {
27480
27523
  }
27481
27524
  this.publish(RaptorMessage.streamChannels.update(_apiKey, _sessionId, streamId, channelId, attributes), {}, true, completion);
27482
27525
  };
27526
+ this.publisherChannelUpdate = function (streamId, channelId, attributes, completion) {
27527
+ if (completion === void 0) {
27528
+ completion = () => {};
27529
+ }
27530
+ this.publish(RaptorMessage.streamChannels.update(_apiKey, _sessionId, streamId, channelId, attributes), {}, true, completion);
27531
+ };
27483
27532
  this.streamChannelSendData = function (streamId, channelId, data, completion) {
27484
27533
  this.publish(RaptorMessage.streamChannels.data(_apiKey, _sessionId, streamId, channelId, data), {}, true, completion);
27485
27534
  };
@@ -39823,7 +39872,7 @@ function staticConfigFactory(_temp) {
39823
39872
  _ref$axios = _ref.axios,
39824
39873
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
39825
39874
  _ref$properties = _ref.properties,
39826
- properties = _ref$properties === void 0 ? {"version":"v2.36.0","buildHash":"4ced01c04","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;
39875
+ properties = _ref$properties === void 0 ? {"version":"v2.36.0","buildHash":"80ef11d29","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;
39827
39876
  /** @type builtInConfig */
39828
39877
  const builtInConfig = (0, _cloneDeep.default)(properties);
39829
39878
  /**
@@ -41473,6 +41522,7 @@ var _getSpatialResolution = _interopRequireDefault(__webpack_require__(39841));
41473
41522
  var _VideoBitratePreset = _interopRequireDefault(__webpack_require__(51831));
41474
41523
  var _videoConstraints = _interopRequireDefault(__webpack_require__(49474));
41475
41524
  var _networkConditionConstants = __webpack_require__(46179);
41525
+ var _languageCodes = __webpack_require__(38891);
41476
41526
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41477
41527
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41478
41528
  /* eslint-disable global-require, func-names, max-len */
@@ -41674,6 +41724,9 @@ function PublisherFactory(_ref) {
41674
41724
  let networkCondition = _networkConditionConstants.NETWORK_CONDITION.GOOD;
41675
41725
  let getStatsCalled = false;
41676
41726
  let filteredVideoTrackId;
41727
+ let _captionsInputLanguage = null;
41728
+ let _pendingSetCaptionsInputLanguageArgs;
41729
+ let _setCaptionsInputLanguageInFlight = false;
41677
41730
 
41678
41731
  /** @type IntervalRunnerDefault | undefined */
41679
41732
  let connectivityAttemptPinger;
@@ -44132,6 +44185,102 @@ function PublisherFactory(_ref) {
44132
44185
  streamReadyJobs.add(() => finishPublishCaptions(value, resolve, reject));
44133
44186
  }
44134
44187
  });
44188
+ const sendCaptionsInputLanguageUpdate = () => {
44189
+ var _this$session22, _this$stream;
44190
+ _setCaptionsInputLanguageInFlight = true;
44191
+ const _pendingSetCaptionsIn = _pendingSetCaptionsInputLanguageArgs,
44192
+ langCode = _pendingSetCaptionsIn.langCode,
44193
+ resolve = _pendingSetCaptionsIn.resolve,
44194
+ reject = _pendingSetCaptionsIn.reject;
44195
+ _pendingSetCaptionsInputLanguageArgs = null;
44196
+ const attributes = {
44197
+ category: langCode === null ? '' : langCode
44198
+ };
44199
+ const socket = (_this$session22 = this.session) == null ? void 0 : _this$session22._.getSocket();
44200
+ const streamId = ((_this$stream = this.stream) == null ? void 0 : _this$stream.id) || this.streamId;
44201
+ socket.publisherChannelUpdate(streamId, 'caption1', attributes, err => {
44202
+ _setCaptionsInputLanguageInFlight = false;
44203
+ if (err) {
44204
+ reject(err);
44205
+ } else {
44206
+ _captionsInputLanguage = langCode;
44207
+ logAnalyticsEvent('setCaptionsInputLanguage', 'Event', {
44208
+ captionsInputLanguage: langCode
44209
+ });
44210
+ resolve();
44211
+ }
44212
+ // If there's a pending call queued while we were in-flight, process it now
44213
+ if (_pendingSetCaptionsInputLanguageArgs) {
44214
+ if (_pendingSetCaptionsInputLanguageArgs.langCode === _captionsInputLanguage) {
44215
+ // Same language as what just succeeded, resolve without another network call
44216
+ _pendingSetCaptionsInputLanguageArgs.resolve();
44217
+ _pendingSetCaptionsInputLanguageArgs = null;
44218
+ } else {
44219
+ sendCaptionsInputLanguageUpdate();
44220
+ }
44221
+ }
44222
+ });
44223
+ };
44224
+
44225
+ /**
44226
+ * Sets the language used for captions input on the publisher. The language code
44227
+ * is sent to the captions service to indicate the spoken language of the audio.
44228
+ * Pass <code>null</code> to clear the captions input language.
44229
+ *
44230
+ * <p>
44231
+ * If the publisher is not yet publishing to a session, the language will be applied
44232
+ * once publishing begins.
44233
+ *
44234
+ * @param {String|null} langCode A BCP-47 language code (for example, <code>"en-US"</code>,
44235
+ * <code>"es"</code>), or <code>null</code> to clear the captions input language.
44236
+ *
44237
+ * @see <a href="#getCaptionsInputLanguage">Publisher.getCaptionsInputLanguage()</a>
44238
+ * @see <a href="#publishCaptions">Publisher.publishCaptions()</a>
44239
+ * @returns {Promise<void>} A promise that resolves when the language has been set,
44240
+ * or rejects with an error if the language code is invalid or the operation fails.
44241
+ * @method #setCaptionsInputLanguage
44242
+ * @memberOf Publisher
44243
+ */
44244
+ this.setCaptionsInputLanguage = langCode => new Promise((resolve, reject) => {
44245
+ if (langCode !== null && !(0, _languageCodes.validateLanguageCode)(langCode)) {
44246
+ const message = `Invalid captions input language ${langCode}`;
44247
+ logging.warn(`setCaptionsInputLanguage: ${message}`);
44248
+ reject(otError(Errors.INVALID_PARAMETER, new Error(`setCaptionsInputLanguage: ${message}`)));
44249
+ return;
44250
+ }
44251
+ if (_pendingSetCaptionsInputLanguageArgs) {
44252
+ streamReadyJobs.remove(sendCaptionsInputLanguageUpdate);
44253
+ _pendingSetCaptionsInputLanguageArgs.reject(new Error('setCaptionsInputLanguage: call superseded by a newer setCaptionsInputLanguage call'));
44254
+ _pendingSetCaptionsInputLanguageArgs = undefined;
44255
+ }
44256
+ if (langCode === _captionsInputLanguage && !_setCaptionsInputLanguageInFlight) {
44257
+ resolve();
44258
+ return;
44259
+ }
44260
+ _pendingSetCaptionsInputLanguageArgs = {
44261
+ langCode,
44262
+ resolve,
44263
+ reject
44264
+ };
44265
+ if (this.stream) {
44266
+ if (!_setCaptionsInputLanguageInFlight) {
44267
+ sendCaptionsInputLanguageUpdate();
44268
+ }
44269
+ } else {
44270
+ streamReadyJobs.add(sendCaptionsInputLanguageUpdate);
44271
+ }
44272
+ });
44273
+
44274
+ /**
44275
+ * Returns the current captions input language set for the publisher.
44276
+ *
44277
+ * @return {String|null} The BCP-47 language code (for example, <code>"en-US"</code>)
44278
+ * currently set for captions input, or <code>null</code> if no language has been set.
44279
+ * @see <a href="#setCaptionsInputLanguage">Publisher.setCaptionsInputLanguage()</a>
44280
+ * @method #getCaptionsInputLanguage
44281
+ * @memberOf Publisher
44282
+ */
44283
+ this.getCaptionsInputLanguage = () => _captionsInputLanguage;
44135
44284
  let updateVideoSenderParametersSentinel;
44136
44285
 
44137
44286
  // keeps track of if the client has called mediaStreamTrack.stop(), so that we don't restart
@@ -45002,8 +45151,8 @@ function PublisherFactory(_ref) {
45002
45151
  break;
45003
45152
  default:
45004
45153
  if (!futurePeerConnection) {
45005
- var _this$session22, _this$session22$sessi;
45006
- if (!state.isMigrating() && (_this$session22 = this.session) != null && (_this$session22$sessi = _this$session22.sessionInfo) != null && _this$session22$sessi.isAdaptiveEnabled && getP2pPeerConnection()) {
45154
+ var _this$session23, _this$session23$sessi;
45155
+ if (!state.isMigrating() && (_this$session23 = this.session) != null && (_this$session23$sessi = _this$session23.sessionInfo) != null && _this$session23$sessi.isAdaptiveEnabled && getP2pPeerConnection()) {
45007
45156
  // In the case Rumor sends two generateOffers for the P2P leg,
45008
45157
  // we need to ignore the second one.
45009
45158
  return;
@@ -45544,7 +45693,7 @@ function PublisherFactory(_ref) {
45544
45693
  document.addEventListener('visibilitychange', visibilityHandler);
45545
45694
  };
45546
45695
  const handleBuggedUnMutedLocalAudioTrack = audioTrack => {
45547
- var _this$session23;
45696
+ var _this$session24;
45548
45697
  if (hasAudio()) {
45549
45698
  if (!hasVideo()) {
45550
45699
  // We only need to reset the audio source when the publisher is audio only.
@@ -45559,7 +45708,7 @@ function PublisherFactory(_ref) {
45559
45708
  this.videoElement().pause();
45560
45709
  }
45561
45710
  }
45562
- this == null ? void 0 : (_this$session23 = this.session) == null ? void 0 : _this$session23.trigger('gsmCallEnded');
45711
+ this == null ? void 0 : (_this$session24 = this.session) == null ? void 0 : _this$session24.trigger('gsmCallEnded');
45563
45712
  };
45564
45713
 
45565
45714
  /**
@@ -46372,7 +46521,7 @@ function PublisherFactory(_ref) {
46372
46521
  },
46373
46522
  startMigration: function () {
46374
46523
  var _startMigration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee49() {
46375
- var _publisherSenderStats6, _this$session24, _this$session24$sessi;
46524
+ var _publisherSenderStats6, _this$session25, _this$session25$sessi;
46376
46525
  var relayedPeerConnection, onCreateStreamError;
46377
46526
  return _regenerator.default.wrap(function _callee49$(_context49) {
46378
46527
  while (1) switch (_context49.prev = _context49.next) {
@@ -46394,7 +46543,7 @@ function PublisherFactory(_ref) {
46394
46543
  throw new Error(error);
46395
46544
  }
46396
46545
  };
46397
- if (!((_this$session24 = _this.session) != null && (_this$session24$sessi = _this$session24.sessionInfo) != null && _this$session24$sessi.p2pEnabled)) {
46546
+ if (!((_this$session25 = _this.session) != null && (_this$session25$sessi = _this$session25.sessionInfo) != null && _this$session25$sessi.p2pEnabled)) {
46398
46547
  _context49.next = 13;
46399
46548
  break;
46400
46549
  }
@@ -46419,7 +46568,7 @@ function PublisherFactory(_ref) {
46419
46568
  return startMigration;
46420
46569
  }(),
46421
46570
  finishMigration: () => {
46422
- var _this$session25, _this$session25$sessi;
46571
+ var _this$session26, _this$session26$sessi;
46423
46572
  clearTimeout(_migrationTimeoutId);
46424
46573
  const destroyPeerConnection = /*#__PURE__*/function () {
46425
46574
  var _ref61 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee50(pc) {
@@ -46454,7 +46603,7 @@ function PublisherFactory(_ref) {
46454
46603
  _previousPeerConnection = null;
46455
46604
 
46456
46605
  // In case we don't transition to P2P after migration, clear P2P leg.
46457
- if ((_this$session25 = this.session) != null && (_this$session25$sessi = _this$session25.sessionInfo) != null && _this$session25$sessi.isAdaptiveEnabled && activeSourceStreamId === 'MANTIS') {
46606
+ if ((_this$session26 = this.session) != null && (_this$session26$sessi = _this$session26.sessionInfo) != null && _this$session26$sessi.isAdaptiveEnabled && activeSourceStreamId === 'MANTIS') {
46458
46607
  var _getP2pPeerConnection;
46459
46608
  (_getP2pPeerConnection = getP2pPeerConnection()) == null ? void 0 : _getP2pPeerConnection.then(destroyPeerConnection);
46460
46609
  }
@@ -94782,6 +94931,7 @@ module.exports = isString;
94782
94931
  exports.__esModule = true;
94783
94932
  exports["default"] = void 0;
94784
94933
  var _default = priority => {
94934
+ if (typeof priority !== 'number') return '';
94785
94935
  switch (priority >> 24) {
94786
94936
  // eslint-disable-line no-bitwise
94787
94937
  case 0: