@opentok/client 2.30.1-alpha.2 → 2.30.1-alpha.4

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.
@@ -183,6 +183,7 @@ declare namespace OT {
183
183
  creationTime: number;
184
184
  frameRate: number;
185
185
  hasAudio: boolean;
186
+ hasCaptions: boolean;
186
187
  hasVideo: boolean;
187
188
  initials: string;
188
189
  name: string;
@@ -521,6 +522,7 @@ declare namespace OT {
521
522
  stream: Stream;
522
523
  } & (
523
524
  { changedProperty: 'hasAudio'; oldValue: boolean; newValue: boolean; } |
525
+ { changedProperty: 'hasCaptions'; oldValue: boolean; newValue: boolean; } |
524
526
  { changedProperty: 'hasVideo'; oldValue: boolean; newValue: boolean; } |
525
527
  { changedProperty: 'videoDimensions'; oldValue: Dimensions; newValue: Dimensions; }
526
528
  )
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.30.1 8989bb63b
2
+ * @license OpenTok.js 2.30.1 b842fa8df
3
3
  *
4
4
  * Copyright (c) 2010-2025 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: Thu, 15 May 2025 16:31:07 GMT
8
+ * Date: Wed, 28 May 2025 22:09:19 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -4169,7 +4169,7 @@ function EventsFactory(deps) {
4169
4169
  *
4170
4170
  * @class StreamPropertyChangedEvent
4171
4171
  * @property {String} changedProperty The property of the stream that changed. This value
4172
- * is either <code>"hasAudio"</code>, <code>"hasVideo"</code>, or <code>"videoDimensions"</code>.
4172
+ * is either <code>"hasAudio"</code>, <code>"hasVideo"</code>, <code>"hasCaptions"</code>, or <code>"videoDimensions"</code>.
4173
4173
  * @property {Object} newValue The new value of the property (after the change).
4174
4174
  * @property {Object} oldValue The old value of the property (before the change).
4175
4175
  * @property {Stream} stream The Stream object for which a property has changed.
@@ -8672,7 +8672,7 @@ const logging = (0, _log.default)('StaticConfig');
8672
8672
  */
8673
8673
 
8674
8674
  /** @type builtInConfig */
8675
- const builtInConfig = (0, _cloneDeep.default)({"version":"v2.30.1","buildHash":"8989bb63b","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"});
8675
+ const builtInConfig = (0, _cloneDeep.default)({"version":"v2.30.1","buildHash":"b842fa8df","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"});
8676
8676
  const whitelistAllowedRuntimeProperties = (0, _pick.default)(['apiURL', 'assetURL', 'cdnURL', 'sessionInfoOverrides', 'loggingURL']);
8677
8677
  const liveConfigMap = {
8678
8678
  apiUrl: 'apiURL',
@@ -17776,8 +17776,9 @@ function PublisherFactory(_ref) {
17776
17776
  });
17777
17777
  });
17778
17778
  function getCommonAnalyticsFields() {
17779
+ var _getSession, _getSession2, _getSession2$connecti;
17779
17780
  return {
17780
- connectionId: getSession().isConnected() ? getSession().connection.connectionId : null,
17781
+ connectionId: (_getSession = getSession()) != null && _getSession.isConnected() ? (_getSession2 = getSession()) == null ? void 0 : (_getSession2$connecti = _getSession2.connection) == null ? void 0 : _getSession2$connecti.connectionId : null,
17781
17782
  streamId: getStreamId(),
17782
17783
  widgetType: 'Publisher'
17783
17784
  };
@@ -18079,7 +18080,7 @@ function PublisherFactory(_ref) {
18079
18080
  logAnalyticsEvent('GetRtcStatsReport', 'Called');
18080
18081
  });
18081
18082
  const recordQOS = _ref4 => {
18082
- var _properties$audioFall;
18083
+ var _this$session2, _this$session3, _this$session3$connec, _properties$audioFall;
18083
18084
  let parsedStats = _ref4.parsedStats,
18084
18085
  simulcastEnabled = _ref4.simulcastEnabled,
18085
18086
  remoteConnectionId = _ref4.remoteConnectionId,
@@ -18088,7 +18089,7 @@ function PublisherFactory(_ref) {
18088
18089
  const QoSBlob = {
18089
18090
  peerId,
18090
18091
  widgetType: 'Publisher',
18091
- connectionId: this.session && this.session.isConnected() ? this.session.connection.connectionId : null,
18092
+ connectionId: (_this$session2 = this.session) != null && _this$session2.isConnected() ? (_this$session3 = this.session) == null ? void 0 : (_this$session3$connec = _this$session3.connection) == null ? void 0 : _this$session3$connec.connectionId : null,
18092
18093
  streamId: this.streamId,
18093
18094
  width: widgetView.width,
18094
18095
  height: widgetView.height,
@@ -19625,6 +19626,8 @@ function PublisherFactory(_ref) {
19625
19626
  * @see <a href="OT.html#initPublisher">OT.initPublisher()</a>
19626
19627
  * @see <a href="Subscriber.html#subscribeToCaptions">subscribeToCaptions()</a>
19627
19628
  * @see <a href="Subscriber.html#isSubscribedToCaptions">isSubscribedToCaptions()</a>
19629
+ * @see <a href="Stream.html#hasCaptions">Stream.hasCaptions</a>
19630
+ * @see StreamPropertyChangedEvent
19628
19631
  * @method #publishCaptions
19629
19632
  * @memberOf Publisher
19630
19633
  */
@@ -20892,7 +20895,7 @@ function PublisherFactory(_ref) {
20892
20895
  document.addEventListener('visibilitychange', visibilityHandler);
20893
20896
  };
20894
20897
  const handleBuggedUnMutedLocalAudioTrack = audioTrack => {
20895
- var _this$session2;
20898
+ var _this$session4;
20896
20899
  if (hasAudio()) {
20897
20900
  if (!hasVideo()) {
20898
20901
  // We only need to reset the audio source when the publisher is audio only.
@@ -20907,7 +20910,7 @@ function PublisherFactory(_ref) {
20907
20910
  this.videoElement().pause();
20908
20911
  }
20909
20912
  }
20910
- this == null ? void 0 : (_this$session2 = this.session) == null ? void 0 : _this$session2.trigger('gsmCallEnded');
20913
+ this == null ? void 0 : (_this$session4 = this.session) == null ? void 0 : _this$session4.trigger('gsmCallEnded');
20911
20914
  };
20912
20915
 
20913
20916
  /**
@@ -23992,6 +23995,12 @@ const validPropertyNames = ['name', 'archiving'];
23992
23995
  * the publisher of the stream specifies a frame rate when calling the
23993
23996
  * <code>OT.initPublisher()</code> method; otherwise, this property is undefined.
23994
23997
  *
23998
+ * @property {Boolean} hasCaptions Whether the stream has captions. This property can change if the
23999
+ * publisher turns on or off captions (by calling
24000
+ * <a href="Publisher.html#publishCaptions">Publisher.publishCaptions()</a>). When this occurs, the
24001
+ * {@link Session} object dispatches a <code>streamPropertyChanged</code> event (see
24002
+ * {@link StreamPropertyChangedEvent}).
24003
+ *
23995
24004
  * @property {Boolean} hasAudio Whether the stream has audio. This property can change if the
23996
24005
  * publisher turns on or off audio (by calling
23997
24006
  * <a href="Publisher.html#publishAudio">Publisher.publishAudio()</a>). When this occurs, the
@@ -24055,7 +24064,13 @@ function Stream(id, name, creationTime, connection, session, channel, initials)
24055
24064
  let _key = key;
24056
24065
  switch (_key) {
24057
24066
  case 'active':
24058
- _key = channel.type === 'audio' ? 'hasAudio' : 'hasVideo';
24067
+ if (channel.type === 'audio') {
24068
+ _key = 'hasAudio';
24069
+ } else if (channel.type === 'video') {
24070
+ _key = 'hasVideo';
24071
+ } else if (channel.type === 'data' && channel.id === 'caption1') {
24072
+ _key = 'hasCaptions';
24073
+ }
24059
24074
  self[_key] = newValue;
24060
24075
  break;
24061
24076
  case 'disableWarning':
@@ -24129,11 +24144,13 @@ function Stream(id, name, creationTime, connection, session, channel, initials)
24129
24144
 
24130
24145
  const audioChannel = this.getChannelsOfType('audio')[0];
24131
24146
  const videoChannel = this.getChannelsOfType('video')[0];
24147
+ const captionChannel = this.getChannelsOfType('data').find(channel => channel.id === 'caption1');
24132
24148
 
24133
24149
  // @todo this should really be: "has at least one video/audio track" instead of
24134
24150
  // "the first video/audio track"
24135
- this.hasAudio = audioChannel != null && audioChannel.active;
24136
- this.hasVideo = videoChannel != null && videoChannel.active;
24151
+ this.hasAudio = !!(audioChannel != null && audioChannel.active);
24152
+ this.hasVideo = !!(videoChannel != null && videoChannel.active);
24153
+ this.hasCaptions = !!(captionChannel != null && captionChannel.active);
24137
24154
  this.videoType = videoChannel && videoChannel.source;
24138
24155
  this.defaultFitMode = videoChannel && videoChannel.fitMode;
24139
24156
  this.videoDimensions = {};
@@ -24144,9 +24161,8 @@ function Stream(id, name, creationTime, connection, session, channel, initials)
24144
24161
  videoChannel.on('update', onChannelUpdate);
24145
24162
  this.frameRate = videoChannel.frameRate;
24146
24163
  }
24147
- if (audioChannel) {
24148
- audioChannel.on('update', onChannelUpdate);
24149
- }
24164
+ audioChannel == null ? void 0 : audioChannel.on('update', onChannelUpdate);
24165
+ captionChannel == null ? void 0 : captionChannel.on('update', onChannelUpdate);
24150
24166
  this.setChannelActiveState = function setChannelActiveState(_ref) {
24151
24167
  let channelType = _ref.channelType,
24152
24168
  activeState = _ref.activeState,
@@ -37157,18 +37173,18 @@ function SubscriberFactory(_ref2) {
37157
37173
  return _webRTCStream.getAudioTracks().length > 0;
37158
37174
  };
37159
37175
  const logAnalyticsEvent = (action, variation, payload, options, throttle) => {
37160
- var _session2;
37176
+ var _session2, _session3, _session3$connection, _session$sessionInfo$, _session4, _session4$sessionInfo, _session5;
37161
37177
  let stats = (0, _assign.default)({
37162
37178
  action,
37163
37179
  variation,
37164
37180
  payload,
37165
37181
  streamId: _stream ? _stream.id : null,
37166
37182
  sessionId: _session ? _session.sessionId : null,
37167
- connectionId: _session && _session.isConnected() ? _session.connection.connectionId : null,
37168
- partnerId: _session && _session.sessionInfo ? _session.sessionInfo.partnerId : null,
37183
+ connectionId: (_session2 = _session) != null && _session2.isConnected() ? (_session3 = _session) == null ? void 0 : (_session3$connection = _session3.connection) == null ? void 0 : _session3$connection.connectionId : null,
37184
+ partnerId: (_session$sessionInfo$ = (_session4 = _session) == null ? void 0 : (_session4$sessionInfo = _session4.sessionInfo) == null ? void 0 : _session4$sessionInfo.partnerId) != null ? _session$sessionInfo$ : null,
37169
37185
  subscriberId: _widgetId,
37170
37186
  widgetType: 'Subscriber',
37171
- singlePeerConnection: !!((_session2 = _session) != null && _session2._singlePeerConnectionController)
37187
+ singlePeerConnection: !!((_session5 = _session) != null && _session5._singlePeerConnectionController)
37172
37188
  }, options);
37173
37189
  if (variation === 'Failure' || variation === 'iceconnectionstatechange' && payload === 'closed') {
37174
37190
  stats = (0, _assign.default)(stats, _preDisconnectStats);
@@ -37340,8 +37356,9 @@ function SubscriberFactory(_ref2) {
37340
37356
  (0, _connectivityAttemptPinger.default)({
37341
37357
  connectivityState,
37342
37358
  logAttempt() {
37359
+ var _session6, _session7, _session7$connection;
37343
37360
  logAnalyticsEvent('Subscribe', 'Attempting', null, {
37344
- connectionId: _session && _session.isConnected() ? _session.connection.connectionId : null
37361
+ connectionId: (_session6 = _session) != null && _session6.isConnected() ? (_session7 = _session) == null ? void 0 : (_session7$connection = _session7.connection) == null ? void 0 : _session7$connection.connectionId : null
37345
37362
  });
37346
37363
  }
37347
37364
  });
@@ -37366,7 +37383,7 @@ function SubscriberFactory(_ref2) {
37366
37383
  logAnalyticsEvent('ICERestart', variation, payload);
37367
37384
  };
37368
37385
  const recordQOS = _ref12 => {
37369
- var _properties$preferred, _properties$preferred2;
37386
+ var _session$connection$c, _session8, _session8$connection, _properties$preferred, _properties$preferred2;
37370
37387
  let parsedStats = _ref12.parsedStats,
37371
37388
  remoteConnectionId = _ref12.remoteConnectionId,
37372
37389
  peerId = _ref12.peerId,
@@ -37380,7 +37397,7 @@ function SubscriberFactory(_ref2) {
37380
37397
  subscribeToAudio: _isSubscribingToAudio,
37381
37398
  audioVolume: this.getAudioVolume(),
37382
37399
  videoTrack: _streamHasTracks('video'),
37383
- connectionId: _session ? _session.connection.connectionId : null,
37400
+ connectionId: (_session$connection$c = (_session8 = _session) == null ? void 0 : (_session8$connection = _session8.connection) == null ? void 0 : _session8$connection.connectionId) != null ? _session$connection$c : null,
37384
37401
  hasVideo: _stream && _stream.hasVideo,
37385
37402
  subscribeToVideo: _properties.subscribeToVideo,
37386
37403
  congestionLevel: _congestionLevel,
@@ -37904,13 +37921,13 @@ function SubscriberFactory(_ref2) {
37904
37921
  }();
37905
37922
  const onRemoteStreamAdded = (0, _queue.default)( /*#__PURE__*/function () {
37906
37923
  var _ref21 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(_ref20, done) {
37907
- var webRTCStream, peerConnection, sourceStreamId, _session3, sessionInfo, forceDisable;
37924
+ var webRTCStream, peerConnection, sourceStreamId, _session9, sessionInfo, forceDisable;
37908
37925
  return _regenerator.default.wrap(function _callee11$(_context11) {
37909
37926
  while (1) switch (_context11.prev = _context11.next) {
37910
37927
  case 0:
37911
37928
  webRTCStream = _ref20.webRTCStream, peerConnection = _ref20.peerConnection;
37912
37929
  sourceStreamId = peerConnection == null ? void 0 : peerConnection.getSourceStreamId();
37913
- _session3 = _session, sessionInfo = _session3.sessionInfo;
37930
+ _session9 = _session, sessionInfo = _session9.sessionInfo;
37914
37931
  setStream(webRTCStream, sourceStreamId);
37915
37932
  logging.debug('OT.Subscriber.onRemoteStreamAdded with sourceStreamId', sourceStreamId);
37916
37933
  if (!_state.isMigrating()) {
@@ -38619,6 +38636,7 @@ function SubscriberFactory(_ref2) {
38619
38636
  };
38620
38637
  }();
38621
38638
  this._destroy = _ref30 => {
38639
+ var _session10, _session11, _session11$connection, _session$sessionInfo$2, _session12, _session12$sessionInf;
38622
38640
  let _ref30$reason = _ref30.reason,
38623
38641
  reason = _ref30$reason === void 0 ? 'Unknown' : _ref30$reason,
38624
38642
  quiet = _ref30.quiet,
@@ -38634,8 +38652,8 @@ function SubscriberFactory(_ref2) {
38634
38652
  }
38635
38653
  _preDisconnectStats = {
38636
38654
  sessionId: _session.sessionId,
38637
- connectionId: _session && _session.isConnected() ? _session.connection.connectionId : null,
38638
- partnerId: _session && _session.sessionInfo ? _session.sessionInfo.partnerId : null,
38655
+ connectionId: (_session10 = _session) != null && _session10.isConnected() ? (_session11 = _session) == null ? void 0 : (_session11$connection = _session11.connection) == null ? void 0 : _session11$connection.connectionId : null,
38656
+ partnerId: (_session$sessionInfo$2 = (_session12 = _session) == null ? void 0 : (_session12$sessionInf = _session12.sessionInfo) == null ? void 0 : _session12$sessionInf.partnerId) != null ? _session$sessionInfo$2 : null,
38639
38657
  streamId: _stream && !_stream.destroyed ? _stream.id : null
38640
38658
  };
38641
38659
  this._disconnect({
@@ -39631,7 +39649,7 @@ function SubscriberFactory(_ref2) {
39631
39649
  _activeSourceStreamId = sourceStreamId;
39632
39650
  peerConnectionsAsync[sourceStreamId] = new Promise((resolve, reject) => {
39633
39651
  _session._.getIceConfig().then(iceConfig => {
39634
- var _session4;
39652
+ var _session13;
39635
39653
  if (iceConfig.needRumorIceServersFallback) {
39636
39654
  iceConfig.servers = [...(fallbackIceServers || []), ...(iceConfig.servers || [])];
39637
39655
  }
@@ -39648,7 +39666,7 @@ function SubscriberFactory(_ref2) {
39648
39666
  keyStore: _session.keyStore,
39649
39667
  sFrameClientStore: _session.sFrameClientStore,
39650
39668
  isE2ee: _session._.isE2ee(),
39651
- sessionId: (_session4 = _session) == null ? void 0 : _session4.sessionId
39669
+ sessionId: (_session13 = _session) == null ? void 0 : _session13.sessionId
39652
39670
  };
39653
39671
  if (Object.prototype.hasOwnProperty.call(_properties, 'codecFlags')) {
39654
39672
  props.codecFlags = _properties.codecFlags;
@@ -40028,6 +40046,7 @@ function SubscriberFactory(_ref2) {
40028
40046
  *
40029
40047
  * @see <a href="#isSubscribedToCaptions">isSubscribedToCaptions()</a>
40030
40048
  * @see <a href="#event:captionReceived">captionReceived</a> event
40049
+ * @see <a href="StreamPropertyChangedEvent.html">StreamPropertyChangedEvent</a>
40031
40050
  *
40032
40051
  * @method #subscribeToCaptions
40033
40052
  * @memberOf Subscriber
@@ -44809,6 +44828,7 @@ function SessionFactory(deps) {
44809
44828
  * @memberOf Session
44810
44829
  */
44811
44830
  this.subscribe = function (stream, targetElement, properties, completionHandler) {
44831
+ var _this$connection;
44812
44832
  if (typeof targetElement === 'function') {
44813
44833
  completionHandler = targetElement;
44814
44834
  targetElement = undefined;
@@ -44819,7 +44839,7 @@ function SessionFactory(deps) {
44819
44839
  properties = undefined;
44820
44840
  }
44821
44841
  completionHandler = completionHandler || function () {};
44822
- if (!this.connection || !this.connection.connectionId) {
44842
+ if (!((_this$connection = this.connection) != null && _this$connection.connectionId)) {
44823
44843
  dispatchOTError(otError(errors.NOT_CONNECTED, new Error('Session.subscribe :: Connection required to subscribe'), ExceptionCodes.UNABLE_TO_SUBSCRIBE), completionHandler);
44824
44844
  return undefined;
44825
44845
  }
@@ -45017,12 +45037,13 @@ function SessionFactory(deps) {
45017
45037
  _isSocketReconnecting = false;
45018
45038
  this.dispatchEvent(new Events.SessionReconnectedEvent());
45019
45039
  if (this.sessionInfo.reconnection) {
45040
+ var _this$session, _this$session$session;
45020
45041
  sessionObjects.publishers.where({
45021
45042
  session: this
45022
45043
  }).forEach(publisher => {
45023
45044
  publisher._.iceRestart();
45024
45045
  });
45025
- if (!this.session.sessionInfo.p2pEnabled) {
45046
+ if (!((_this$session = this.session) != null && (_this$session$session = _this$session.sessionInfo) != null && _this$session$session.p2pEnabled)) {
45026
45047
  sessionObjects.subscribers.where({
45027
45048
  session: this
45028
45049
  }).forEach(subscriber => {
@@ -46200,8 +46221,9 @@ function SessionFactory(deps) {
46200
46221
  * in the following conditions:
46201
46222
  * <p>
46202
46223
  * <ul>
46203
- * <li> A stream has started or stopped publishing audio or video (see
46204
- * <a href="Publisher.html#publishAudio">Publisher.publishAudio()</a> and
46224
+ * <li> A stream has started or stopped publishing audio, captions, or video (see
46225
+ * <a href="Publisher.html#publishAudio">Publisher.publishAudio()</a>,
46226
+ * <a href="Publisher.html#publishCaptions">Publisher.publishCaptions()</a> and
46205
46227
  * <a href="Publisher.html#publishVideo">Publisher.publishVideo()</a>). Note
46206
46228
  * that a subscriber's video can be disabled or enabled for reasons other than
46207
46229
  * the publisher disabling or enabling it. A Subscriber object dispatches
@@ -46222,8 +46244,10 @@ function SessionFactory(deps) {
46222
46244
  * @memberof Session
46223
46245
  * @see StreamPropertyChangedEvent
46224
46246
  * @see <a href="Publisher.html#publishAudio">Publisher.publishAudio()</a>
46247
+ * @see <a href="Publisher.html#publishCaptions">Publisher.publishCaptions()</a>
46225
46248
  * @see <a href="Publisher.html#publishVideo">Publisher.publishVideo()</a>
46226
46249
  * @see <a href="Stream.html#hasAudio">Stream.hasAudio</a>
46250
+ * @see <a href="Stream.html#hasCaptions">Stream.hasCaptions</a>
46227
46251
  * @see <a href="Stream.html#hasVideo">Stream.hasVideo</a>
46228
46252
  * @see <a href="Stream.html#videoDimensions">Stream.videoDimensions</a>
46229
46253
  * @see <a href="Subscriber.html#event:videoDisabled">Subscriber videoDisabled event</a>