@opentok/client 2.35.0-alpha.22 → 2.35.0-alpha.24

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 d34b5dbad
2
+ * @license OpenTok.js 2.35.0 6076fa4b4
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, 13 May 2026 07:26:42 GMT
8
+ * Date: Mon, 18 May 2026 08:41:01 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -4628,43 +4628,58 @@ const _deviceHelpers = (0, _deviceHelpers2.default)(),
4628
4628
 
4629
4629
  /**
4630
4630
  * Enumerates the audio input devices (such as microphones) and video input devices
4631
- * (cameras) available to the browser.
4631
+ * (cameras) available to the browser. This returns a promise containing the array of
4632
+ * devices. Each object has three properties: <code>kind</code>,
4633
+ * <code>deviceId</code>, and <code>label</code>, each of which are strings.
4632
4634
  * <p>
4633
- * The array of devices is passed in as the <code>devices</code> parameter of
4634
- * the <code>callback</code> function passed into the method.
4635
+ * The <code>kind</code> property is set to <code>"audioInput"</code> for audio input
4636
+ * devices or <code>"videoInput"</code> for video input devices.
4637
+ * <p>
4638
+ * The <code>deviceId</code> property is a unique ID for the device. You can pass
4639
+ * the <code>deviceId</code> in as the <code>audioSource</code> or <code>videoSource</code>
4640
+ * property of the <code>options</code> parameter of the
4641
+ * <a href="#initPublisher">OT.initPublisher()</a> method.
4642
+ * <p>
4643
+ * The <code>label</code> property identifies the device. The <code>label</code>
4644
+ * property is set to an empty string if the user has not previously granted access to
4645
+ * a camera and microphone.
4635
4646
  *
4636
- * @param callback {Function} The callback function invoked when the list of devices
4647
+ * @param callback {Function} Optional callback function invoked when the list of devices
4637
4648
  * devices is available. This function takes two parameters:
4638
4649
  * <ul>
4639
4650
  * <li><code>error</code> &mdash; This is set to an error object when
4640
4651
  * there is an error in calling this method; it is set to <code>null</code>
4641
4652
  * when the call succeeds.</li>
4642
- *
4643
4653
  * <li><p><code>devices</code> &mdash; An array of objects corresponding to
4644
- * available microphones and cameras. Each object has three properties: <code>kind</code>,
4645
- * <code>deviceId</code>, and <code>label</code>, each of which are strings.
4646
- * <p>
4647
- * The <code>kind</code> property is set to <code>"audioInput"</code> for audio input
4648
- * devices or <code>"videoInput"</code> for video input devices.
4649
- * <p>
4650
- * The <code>deviceId</code> property is a unique ID for the device. You can pass
4651
- * the <code>deviceId</code> in as the <code>audioSource</code> or <code>videoSource</code>
4652
- * property of the <code>options</code> parameter of the
4653
- * <a href="#initPublisher">OT.initPublisher()</a> method.
4654
- * <p>
4655
- * The <code>label</code> property identifies the device. The <code>label</code>
4656
- * property is set to an empty string if the user has not previously granted access to
4657
- * a camera and microphone.</li>
4654
+ * available microphones and cameras.
4655
+ * </li>
4658
4656
  * </ul>
4659
4657
  * <i>Note:</i> The browser may limit the number of returned audio and video input devices
4660
4658
  * to one each before the user has granted access to a camera or microphone.
4661
4659
  *
4660
+ * @returns {Promise<Device[]>} A promise containing the list of devices
4661
+ *
4662
4662
  * @see <a href="#initPublisher">OT.initPublisher()</a>
4663
4663
  * @method OT.getDevices
4664
4664
  * @memberof OT
4665
4665
  */
4666
4666
  function getDevices(callback) {
4667
- getInputMediaDevices().then(devices => callback(undefined, devices), callback);
4667
+ const hasCallback = typeof callback === 'function';
4668
+ const promise = getInputMediaDevices().then(devices => {
4669
+ if (hasCallback) {
4670
+ callback(undefined, devices);
4671
+ }
4672
+ return devices;
4673
+ }, err => {
4674
+ if (hasCallback) {
4675
+ callback(err);
4676
+ }
4677
+ throw err;
4678
+ });
4679
+ if (hasCallback) {
4680
+ promise.catch(() => {});
4681
+ }
4682
+ return promise;
4668
4683
  }
4669
4684
 
4670
4685
  /***/ }),
@@ -5059,6 +5074,7 @@ function SinglePeerConnectionAdapterFactory(deps) {
5059
5074
  };
5060
5075
 
5061
5076
  // SPC events wrapper for PeerConnection
5077
+ const _onIceRestartAttempt = ev => this.trigger('iceRestartAttempt', ev);
5062
5078
  const _onClosed = () => this.trigger('close');
5063
5079
  const _onRemoteVideoSupported = supported => this.trigger('remoteVideoSupported', supported);
5064
5080
  const _onPeerError = _ref => {
@@ -5100,6 +5116,7 @@ function SinglePeerConnectionAdapterFactory(deps) {
5100
5116
  error: _onPeerError,
5101
5117
  qos: _onQoS,
5102
5118
  iceConnectionStateChange: _onIceConnectionStateChanged,
5119
+ iceRestartAttempt: _onIceRestartAttempt,
5103
5120
  remoteVideoSupported: _onRemoteVideoSupported,
5104
5121
  decryptFailed: _onDecryptFailed,
5105
5122
  decryptRestored: _onDecryptRestored
@@ -5210,7 +5227,7 @@ function SinglePeerConnectionAdapterFactory(deps) {
5210
5227
  };
5211
5228
  this.remoteStreams = () => _peerConnection.remoteStreams();
5212
5229
  this.hasRelayCandidates = () => _peerConnection.hasRelayCandidates();
5213
- this.iceRestart = () => _peerConnection.iceRestart();
5230
+ this.iceRestart = (reason, forcedRestart) => _peerConnection.iceRestart(reason, forcedRestart);
5214
5231
  this.iceConnectionStateIsConnected = () => _peerConnection.iceConnectionStateIsConnected();
5215
5232
  this.startDecryption = (connectionId, transceiver) => _peerConnection.startDecryption(connectionId, transceiver);
5216
5233
  };
@@ -6437,6 +6454,10 @@ function PublisherPeerConnectionFactory(deps) {
6437
6454
  const statsHelpers = getStatsHelpers();
6438
6455
 
6439
6456
  // Private
6457
+ const _onIceRestartAttempt = ev => {
6458
+ _awaitingIceRestart = true;
6459
+ this.trigger('iceRestartAttempt', ev);
6460
+ };
6440
6461
  const _onPeerClosed = function _onPeerClosed() {
6441
6462
  this.destroy();
6442
6463
  if (_awaitingIceRestart) {
@@ -6622,7 +6643,8 @@ function PublisherPeerConnectionFactory(deps) {
6622
6643
  close: _onPeerClosed,
6623
6644
  error: _onPeerError,
6624
6645
  qos: _qos => this.trigger('qos', _qos),
6625
- iceConnectionStateChange: _onIceConnectionStateChange
6646
+ iceConnectionStateChange: _onIceConnectionStateChange,
6647
+ iceRestartAttempt: _onIceRestartAttempt
6626
6648
  }, this);
6627
6649
  _peerConnection.addLocalStream(webRTCStream).then(() => {
6628
6650
  completion(undefined);
@@ -6638,11 +6660,9 @@ function PublisherPeerConnectionFactory(deps) {
6638
6660
  this.getSenders = function () {
6639
6661
  return _peerConnection.getSenders();
6640
6662
  };
6641
- this.iceRestart = function () {
6642
- if (_peerConnection) {
6643
- _awaitingIceRestart = true;
6644
- _peerConnection.iceRestart();
6645
- }
6663
+ this.iceRestart = function (reason, forcedRestart) {
6664
+ var _peerConnection2;
6665
+ (_peerConnection2 = _peerConnection) == null ? void 0 : _peerConnection2.iceRestart(reason, forcedRestart);
6646
6666
  };
6647
6667
  this.hasRelayCandidates = () => _peerConnection.hasRelayCandidates();
6648
6668
  this.iceConnectionStateIsConnected = function () {
@@ -20048,6 +20068,10 @@ function SubscriberPeerConnectionFactory(deps) {
20048
20068
  const _audioTracks = [];
20049
20069
 
20050
20070
  // Private
20071
+ const _onIceRestartAttempt = ev => {
20072
+ _awaitingIceRestart = true;
20073
+ this.trigger('iceRestartAttempt', ev);
20074
+ };
20051
20075
  const _onPeerClosed = function _onPeerClosed() {
20052
20076
  this.destroy();
20053
20077
  if (_awaitingIceRestart) {
@@ -20239,9 +20263,8 @@ function SubscriberPeerConnectionFactory(deps) {
20239
20263
  this.hasRelayCandidates = function () {
20240
20264
  return _peerConnection.hasRelayCandidates();
20241
20265
  };
20242
- this.iceRestart = function () {
20243
- _awaitingIceRestart = true;
20244
- return _peerConnection.iceRestart();
20266
+ this.iceRestart = function (reason, forcedRestart) {
20267
+ return _peerConnection.iceRestart(reason, forcedRestart);
20245
20268
  };
20246
20269
  this.iceConnectionStateIsConnected = function () {
20247
20270
  return _peerConnection.iceConnectionStateIsConnected();
@@ -20292,6 +20315,7 @@ function SubscriberPeerConnectionFactory(deps) {
20292
20315
  error: _onPeerError,
20293
20316
  qos: _qos => this.trigger('qos', _qos),
20294
20317
  iceConnectionStateChange: _onIceConnectionStateChange,
20318
+ iceRestartAttempt: _onIceRestartAttempt,
20295
20319
  remoteVideoSupported: _onRemoteVideoSupported,
20296
20320
  decryptFailed: _onDecryptFailed,
20297
20321
  decryptRestored: _onDecryptRestored
@@ -24498,8 +24522,8 @@ function SubscriberFactory(_ref2) {
24498
24522
  logAnalyticsEvent('Subscribe', variation, payload, options);
24499
24523
  }
24500
24524
  };
24501
- const logResubscribe = (variation, payload) => {
24502
- logAnalyticsEvent('ICERestart', variation, payload);
24525
+ const logResubscribe = (variation, payload, options) => {
24526
+ logAnalyticsEvent('ICERestart', variation, payload, options);
24503
24527
  };
24504
24528
  const recordQOS = _ref13 => {
24505
24529
  var _session$connection$c, _session8, _session8$connection, _properties$preferred, _properties$preferred2, _socket;
@@ -25223,13 +25247,17 @@ function SubscriberFactory(_ref2) {
25223
25247
  _subscriberConnectionState = currentConnectionState;
25224
25248
  }
25225
25249
  };
25226
- const onIceRestartSuccess = () => {
25227
- logResubscribe('Success');
25228
- };
25229
- const onIceRestartFailure = () => {
25230
- logResubscribe('Failure', {
25231
- reason: 'ICEWorkflow',
25232
- message: 'OT.Subscriber PeerConnection Error: ' + 'The stream was unable to connect due to a network error.' + ' Make sure your connection isn\'t blocked by a firewall.'
25250
+ const onIceRestartAction = (ev, variation, peerConnection, peerId) => {
25251
+ const sourceStreamId = peerConnection.getSourceStreamId();
25252
+ const payload = {
25253
+ isActive: sourceStreamId === _activeSourceStreamId
25254
+ };
25255
+ if (variation === 'Attempt' && ev != null && ev.reason) {
25256
+ payload.reason = ev.reason;
25257
+ }
25258
+ logResubscribe(variation, payload, {
25259
+ peerId,
25260
+ sourceStreamId
25233
25261
  });
25234
25262
  };
25235
25263
  const streamUpdated = event => {
@@ -25518,7 +25546,7 @@ function SubscriberFactory(_ref2) {
25518
25546
  return _ref22.apply(this, arguments);
25519
25547
  };
25520
25548
  }();
25521
- const setPeerConnectionEvents = (peerConnection, sourceStreamId) => {
25549
+ const setPeerConnectionEvents = (peerConnection, sourceStreamId, peerId) => {
25522
25550
  if (_peerConnectionEvents[sourceStreamId]) {
25523
25551
  _peerConnectionEvents[sourceStreamId].removeAll();
25524
25552
  const onDisconnected = () => {
@@ -25576,8 +25604,9 @@ function SubscriberFactory(_ref2) {
25576
25604
  }, _callee13);
25577
25605
  })));
25578
25606
  peerConnectionEvents.on('iceConnectionStateChange', state => onIceConnectionStateChange(state, peerConnection));
25579
- peerConnectionEvents.on('iceRestartSuccess', onIceRestartSuccess);
25580
- peerConnectionEvents.on('iceRestartFailure', onIceRestartFailure);
25607
+ peerConnectionEvents.on('iceRestartAttempt', ev => onIceRestartAction(ev, 'Attempt', peerConnection, peerId));
25608
+ peerConnectionEvents.on('iceRestartSuccess', ev => onIceRestartAction(ev, 'Success', peerConnection, peerId));
25609
+ peerConnectionEvents.on('iceRestartFailure', ev => onIceRestartAction(ev, 'Failure', peerConnection, peerId));
25581
25610
  peerConnectionEvents.on('remoteVideoSupported', onRemoteVideoSupported);
25582
25611
  peerConnectionEvents.on('decryptFailed', () => {
25583
25612
  this.trigger('encryptionSecretMismatch');
@@ -25877,7 +25906,8 @@ function SubscriberFactory(_ref2) {
25877
25906
  send,
25878
25907
  log,
25879
25908
  logQoS,
25880
- sourceStreamId
25909
+ sourceStreamId,
25910
+ peerId
25881
25911
  }));
25882
25912
  case 6:
25883
25913
  case "end":
@@ -26735,11 +26765,11 @@ function SubscriberFactory(_ref2) {
26735
26765
  };
26736
26766
  this._setupPeerConnection = /*#__PURE__*/function () {
26737
26767
  var _ref35 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(_ref34) {
26738
- var send, log, logQoS, sourceStreamId;
26768
+ var send, log, logQoS, sourceStreamId, peerId;
26739
26769
  return _regenerator.default.wrap(function _callee19$(_context19) {
26740
26770
  while (1) switch (_context19.prev = _context19.next) {
26741
26771
  case 0:
26742
- send = _ref34.send, log = _ref34.log, logQoS = _ref34.logQoS, sourceStreamId = _ref34.sourceStreamId;
26772
+ send = _ref34.send, log = _ref34.log, logQoS = _ref34.logQoS, sourceStreamId = _ref34.sourceStreamId, peerId = _ref34.peerId;
26743
26773
  if (_properties.testNetwork) {
26744
26774
  _this.setAudioVolume(0);
26745
26775
  }
@@ -26779,7 +26809,7 @@ function SubscriberFactory(_ref2) {
26779
26809
  peerConnection.once('iceConnected', _pcConnected.resolve);
26780
26810
  peerConnection.once('error', _pcConnected.reject);
26781
26811
  peerConnection.on('qos', logQoS);
26782
- setPeerConnectionEvents(peerConnection, sourceStreamId);
26812
+ setPeerConnectionEvents(peerConnection, sourceStreamId, peerId);
26783
26813
 
26784
26814
  // initialize the peer connection AFTER we've added the event listeners
26785
26815
  peerConnection.init(err => {
@@ -26911,15 +26941,9 @@ function SubscriberFactory(_ref2) {
26911
26941
  logging.debug('Subscriber: Skipping ice restart, we have no peer connection');
26912
26942
  return _context21.abrupt("return");
26913
26943
  case 12:
26914
- logResubscribe('Attempt', {
26915
- reason
26916
- });
26917
26944
  logging.debug('Subscriber: iceRestart attempt');
26918
- peerConnection.iceRestart();
26919
- if (forcedRestart) {
26920
- peerConnection.generateOffer();
26921
- }
26922
- case 16:
26945
+ peerConnection.iceRestart(reason, forcedRestart);
26946
+ case 14:
26923
26947
  case "end":
26924
26948
  return _context21.stop();
26925
26949
  }
@@ -29209,6 +29233,8 @@ function RaptorSocketFactory(deps) {
29209
29233
  var _interopRequireDefault = __webpack_require__(95709);
29210
29234
  exports.__esModule = true;
29211
29235
  exports["default"] = getUserMediaFactory;
29236
+ var _regenerator = _interopRequireDefault(__webpack_require__(92207));
29237
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(79092));
29212
29238
  var _assign = _interopRequireDefault(__webpack_require__(86139));
29213
29239
  var _isObject = _interopRequireDefault(__webpack_require__(23805));
29214
29240
  var _eventing = _interopRequireDefault(__webpack_require__(12607));
@@ -29496,23 +29522,41 @@ function getUserMediaFactory(deps) {
29496
29522
  // it when creating `finalized` above.
29497
29523
  const error = parseErrorEvent(browserError);
29498
29524
  if (error.name === Errors.UNABLE_TO_CAPTURE_SCREEN) {
29499
- return new Promise((resolve, reject) => {
29500
- screenSharing.checkCapability(response => {
29501
- if (response.extensionRequired === 'chrome') {
29502
- if (response.extensionRegistered && !response.extensionInstalled) {
29503
- const newErr = otError(Errors.SCREEN_SHARING_EXTENSION_NOT_INSTALLED, error);
29504
- newErr.message = 'Screen sharing extension not installed see https://tokbox.com/developer/guides/screen-sharing/js/#chrome-extension';
29505
- reject(newErr);
29506
- } else if (!response.extensionRegistered) {
29507
- const newErr = otError(Errors.SCREEN_SHARING_EXTENSION_NOT_REGISTERED, error);
29508
- newErr.message = 'Screen sharing extension not registered see https://tokbox.com/developer/guides/screen-sharing/js/#chrome-extension';
29509
- reject(newErr);
29525
+ return new Promise( /*#__PURE__*/function () {
29526
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_, reject) {
29527
+ var response, newErr;
29528
+ return _regenerator.default.wrap(function _callee$(_context2) {
29529
+ while (1) switch (_context2.prev = _context2.next) {
29530
+ case 0:
29531
+ _context2.next = 2;
29532
+ return screenSharing.checkCapability();
29533
+ case 2:
29534
+ response = _context2.sent;
29535
+ if (response.extensionRequired === 'chrome') {
29536
+ if (response.extensionRegistered && !response.extensionInstalled) {
29537
+ newErr = otError(Errors.SCREEN_SHARING_EXTENSION_NOT_INSTALLED, error);
29538
+ newErr.message = 'Screen sharing extension not installed see https://tokbox.com/developer/guides/screen-sharing/js/#chrome-extension';
29539
+ reject(newErr);
29540
+ } else if (!response.extensionRegistered) {
29541
+ newErr = otError(Errors.SCREEN_SHARING_EXTENSION_NOT_REGISTERED, error);
29542
+ newErr.message = 'Screen sharing extension not registered see https://tokbox.com/developer/guides/screen-sharing/js/#chrome-extension';
29543
+ reject(newErr);
29544
+ } else {
29545
+ reject(error);
29546
+ }
29547
+ } else {
29548
+ reject(error);
29549
+ }
29550
+ case 4:
29551
+ case "end":
29552
+ return _context2.stop();
29510
29553
  }
29511
- } else {
29512
- reject(error);
29513
- }
29514
- });
29515
- });
29554
+ }, _callee);
29555
+ }));
29556
+ return function (_x, _x2) {
29557
+ return _ref.apply(this, arguments);
29558
+ };
29559
+ }());
29516
29560
  }
29517
29561
  throw error;
29518
29562
  }).then(stream => {
@@ -41649,7 +41693,7 @@ function staticConfigFactory(_temp) {
41649
41693
  _ref$axios = _ref.axios,
41650
41694
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
41651
41695
  _ref$properties = _ref.properties,
41652
- properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"d34b5dbad","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;
41696
+ properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"6076fa4b4","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;
41653
41697
  /** @type builtInConfig */
41654
41698
  const builtInConfig = (0, _cloneDeep.default)(properties);
41655
41699
  /**
@@ -43878,8 +43922,8 @@ function PublisherFactory(_ref) {
43878
43922
  logAnalyticsEvent('Publish', variation, payload, logOptions);
43879
43923
  }
43880
43924
  };
43881
- const logRepublish = (variation, payload) => {
43882
- logAnalyticsEvent('ICERestart', variation, payload);
43925
+ const logRepublish = (variation, payload, logOptions) => {
43926
+ logAnalyticsEvent('ICERestart', variation, payload, logOptions);
43883
43927
  };
43884
43928
  const logHybridSessionTransition = (action, variation, payload) => {
43885
43929
  if (variation === 'Attempt') {
@@ -44398,34 +44442,29 @@ function PublisherFactory(_ref) {
44398
44442
  var _this$session8, _this$session8$sessio;
44399
44443
  return ((_this$session8 = this.session) == null ? void 0 : (_this$session8$sessio = _this$session8.sessionInfo) == null ? void 0 : _this$session8$sessio.isAdaptiveEnabled) && peerConnection.getSourceStreamId() === 'P2P';
44400
44444
  };
44401
- const onIceRestartSuccess = peerConnection => {
44445
+ const onIceRestartAction = (ev, variation, peerConnection) => {
44402
44446
  const _getPeerConnectionMet4 = getPeerConnectionMeta(peerConnection),
44447
+ peerId = _getPeerConnectionMet4.peerId,
44403
44448
  remoteConnectionId = _getPeerConnectionMet4.remoteConnectionId,
44404
44449
  sourceStreamId = _getPeerConnectionMet4.sourceStreamId;
44405
- logRepublish('Success', {
44406
- remoteConnectionId
44407
- });
44408
- if (sourceStreamId === 'MANTIS' && activeSourceStreamId === 'P2P') {
44450
+ if (variation === 'Success' && sourceStreamId === 'MANTIS' && activeSourceStreamId === 'P2P') {
44409
44451
  _keepSendingRtcpToMantis(true);
44410
44452
  }
44411
- };
44412
- const onIceRestartFailure = peerConnection => {
44413
- const _getPeerConnectionMet5 = getPeerConnectionMeta(peerConnection),
44414
- remoteConnectionId = _getPeerConnectionMet5.remoteConnectionId;
44415
- logRepublish('Failure', {
44416
- reason: 'ICEWorkflow',
44417
- message: 'OT.Publisher PeerConnection Error: ' + 'The stream was unable to connect due to a network error.' + ' Make sure your connection isn\'t blocked by a firewall.',
44418
- remoteConnectionId
44453
+ const payload = {
44454
+ remoteConnectionId,
44455
+ isActive: sourceStreamId === activeSourceStreamId
44456
+ };
44457
+ if (variation === 'Attempt' && ev != null && ev.reason) {
44458
+ payload.reason = ev.reason;
44459
+ }
44460
+ logRepublish(variation, payload, {
44461
+ peerId,
44462
+ sourceStreamId
44419
44463
  });
44420
44464
  };
44421
44465
  const handleDisconnect = peerConnection => {
44422
44466
  if (_session._.isSocketConnected()) {
44423
- const _getPeerConnectionMet6 = getPeerConnectionMeta(peerConnection),
44424
- remoteConnectionId = _getPeerConnectionMet6.remoteConnectionId;
44425
- logRepublish('Attempt', {
44426
- remoteConnectionId
44427
- });
44428
- peerConnection.iceRestart();
44467
+ peerConnection.iceRestart('peer connection disconnected');
44429
44468
  }
44430
44469
  };
44431
44470
  const handleConnect = /*#__PURE__*/function () {
@@ -44564,9 +44603,9 @@ function PublisherFactory(_ref) {
44564
44603
  if (isRoutedToRelayedTransitionComplete(peerConnection)) {
44565
44604
  logRoutedToRelayedTransition('Success');
44566
44605
  }
44567
- const _getPeerConnectionMet7 = getPeerConnectionMeta(peerConnection),
44568
- peerConnectionId = _getPeerConnectionMet7.peerConnectionId,
44569
- remoteSubscriberId = _getPeerConnectionMet7.remoteSubscriberId;
44606
+ const _getPeerConnectionMet5 = getPeerConnectionMeta(peerConnection),
44607
+ peerConnectionId = _getPeerConnectionMet5.peerConnectionId,
44608
+ remoteSubscriberId = _getPeerConnectionMet5.remoteSubscriberId;
44570
44609
  (_publisherSenderStats2 = publisherSenderStats) == null ? void 0 : _publisherSenderStats2.addConnection(peerConnection, peerConnectionId, remoteSubscriberId);
44571
44610
  if (properties.publishVideo) {
44572
44611
  if (videoQualityChangedListenersCount > 0) {
@@ -44704,8 +44743,9 @@ function PublisherFactory(_ref) {
44704
44743
  });
44705
44744
  },
44706
44745
  qos: logQoS,
44707
- iceRestartSuccess: () => onIceRestartSuccess(peerConnection),
44708
- iceRestartFailure: () => onIceRestartFailure(peerConnection),
44746
+ iceRestartAttempt: ev => onIceRestartAction(ev, 'Attempt', peerConnection),
44747
+ iceRestartSuccess: ev => onIceRestartAction(ev, 'Success', peerConnection),
44748
+ iceRestartFailure: ev => onIceRestartAction(ev, 'Failure', peerConnection),
44709
44749
  iceConnectionStateChange: newState => onIceConnectionStateChange(newState, peerConnection),
44710
44750
  audioAcquisitionProblem: () => {
44711
44751
  audioAcquisitionProblemDetected = true;
@@ -44726,9 +44766,9 @@ function PublisherFactory(_ref) {
44726
44766
  peerId: getPeerConnectionMeta(peerConnection).peerId
44727
44767
  })),
44728
44768
  videoQualityChanged: ev => {
44729
- const _getPeerConnectionMet8 = getPeerConnectionMeta(peerConnection),
44730
- remoteConnectionId = _getPeerConnectionMet8.remoteConnectionId,
44731
- remoteSubscriberId = _getPeerConnectionMet8.remoteSubscriberId;
44769
+ const _getPeerConnectionMet6 = getPeerConnectionMeta(peerConnection),
44770
+ remoteConnectionId = _getPeerConnectionMet6.remoteConnectionId,
44771
+ remoteSubscriberId = _getPeerConnectionMet6.remoteSubscriberId;
44732
44772
  const statsContainer = (0, _assign.default)(remoteConnectionId.match(/^symphony\./) ? {} : {
44733
44773
  subscriberId: remoteSubscriberId,
44734
44774
  connectionId: remoteConnectionId
@@ -44957,9 +44997,9 @@ function PublisherFactory(_ref) {
44957
44997
  results = pcsAndStats.map(_ref22 => {
44958
44998
  let pc = _ref22.pc,
44959
44999
  stats = _ref22.stats;
44960
- const _getPeerConnectionMet9 = getPeerConnectionMeta(pc),
44961
- remoteConnectionId = _getPeerConnectionMet9.remoteConnectionId,
44962
- remoteSubscriberId = _getPeerConnectionMet9.remoteSubscriberId;
45000
+ const _getPeerConnectionMet7 = getPeerConnectionMeta(pc),
45001
+ remoteConnectionId = _getPeerConnectionMet7.remoteConnectionId,
45002
+ remoteSubscriberId = _getPeerConnectionMet7.remoteSubscriberId;
44963
45003
  return (0, _assign.default)(remoteConnectionId.match(/^symphony\./) ? {} : {
44964
45004
  subscriberId: remoteSubscriberId,
44965
45005
  connectionId: remoteConnectionId
@@ -47879,7 +47919,7 @@ function PublisherFactory(_ref) {
47879
47919
  clearTimeout(_migrationTimeoutId);
47880
47920
  const destroyPeerConnection = /*#__PURE__*/function () {
47881
47921
  var _ref59 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee49(pc) {
47882
- var _getPeerConnectionMet10, peerConnectionId;
47922
+ var _getPeerConnectionMet8, peerConnectionId;
47883
47923
  return _regenerator.default.wrap(function _callee49$(_context49) {
47884
47924
  while (1) switch (_context49.prev = _context49.next) {
47885
47925
  case 0:
@@ -47890,7 +47930,7 @@ function PublisherFactory(_ref) {
47890
47930
  _context49.next = 3;
47891
47931
  return _publisherStatsHelper.removePeerConnection(pc);
47892
47932
  case 3:
47893
- _getPeerConnectionMet10 = getPeerConnectionMeta(pc), peerConnectionId = _getPeerConnectionMet10.peerConnectionId;
47933
+ _getPeerConnectionMet8 = getPeerConnectionMeta(pc), peerConnectionId = _getPeerConnectionMet8.peerConnectionId;
47894
47934
  delete peerConnectionsAsync[peerConnectionId];
47895
47935
  pc.off('iceConnectionStateChange');
47896
47936
  pc.destroy();
@@ -48005,22 +48045,14 @@ function PublisherFactory(_ref) {
48005
48045
  peerConnection.getDataChannel(label, getOptions, completion);
48006
48046
  });
48007
48047
  },
48008
- iceRestart(forcedRestart) {
48048
+ iceRestart(reason, forcedRestart) {
48009
48049
  if (forcedRestart === void 0) {
48010
48050
  forcedRestart = false;
48011
48051
  }
48012
48052
  getAllPeerConnections().then(peerConnections => {
48013
48053
  peerConnections.forEach(peerConnection => {
48014
- const _getPeerConnectionMet11 = getPeerConnectionMeta(peerConnection),
48015
- remoteConnectionId = _getPeerConnectionMet11.remoteConnectionId;
48016
- logRepublish('Attempt', {
48017
- remoteConnectionId
48018
- });
48019
48054
  logging.debug('Publisher: ice restart attempt');
48020
- peerConnection.iceRestart();
48021
- if (forcedRestart) {
48022
- peerConnection.generateOffer();
48023
- }
48055
+ peerConnection.iceRestart(reason, forcedRestart);
48024
48056
  });
48025
48057
  });
48026
48058
  },
@@ -59403,42 +59435,24 @@ function screenSharingFactory(deps) {
59403
59435
  screenSharing.pickHelper = () => screenSharingPickHelper();
59404
59436
 
59405
59437
  /**
59406
- * Checks for support for publishing screen-sharing streams on the client browser. The object
59407
- * passed to the callback function defines whether screen sharing is supported, as well as
59438
+ * Checks for support for publishing screen-sharing streams on the client browser. The returned
59439
+ * object in the promise defines whether screen sharing is supported, as well as
59408
59440
  * which screen-sharing sources (application, screen, or window) are supported. It also indicates
59409
59441
  * whether an extension is required, installed, and registered (if needed).
59410
59442
  * <p>
59411
59443
  * <pre>
59412
- * OT.checkScreenSharingCapability(function(response) {
59413
- * if (!response.supported || response.extensionRegistered === false) {
59414
- * // This browser does not support screen sharing
59415
- * } else if (response.extensionInstalled === false) {
59416
- * // Prompt to install the extension
59417
- * } else {
59418
- * // Screen sharing is available.
59419
- * }
59420
- * });
59444
+ * const response = await OT.checkScreenSharingCapability();
59445
+ * if (!response.supported || response.extensionRegistered === false) {
59446
+ * // This browser does not support screen sharing
59447
+ * } else if (response.extensionInstalled === false) {
59448
+ * // Prompt to install the extension
59449
+ * } else {
59450
+ * // Screen sharing is available.
59451
+ * }
59421
59452
  * </pre>
59422
59453
  * <p>
59423
- * Chrome 72+, Firefox 52+, Safari 13+, Edge 79+, and Opera 59+ have screen-sharing
59424
- * support built-in, with no extension required. (Note that support for the Vonage Video API
59425
- * plugin for Internet Explorer is removed in Vonage Video API 2.17.) Screen sharing is
59426
- * <i>not</i> supported in mobile browsers. In Electron, screen sharing is supported if
59427
- * the <code>webPreferences.contextIsolation</code> option of the Electron BrowserWindow is
59428
- * set to <code>false</code> or if the app uses a preload script to access the desktop capturer.
59429
- * (The default value of <code>webPreferences.contextIsolation</code> option is <code>true</code>
59430
- * in Electron 12 and <code>false</code> in previous versions). To publish a screen-sharing video
59431
- * in older versions of Chrome or Opera, the client adds an extension that enables publishing a
59432
- * screen-sharing video stream on your domain. The Vonage Video API
59433
- * <a href="https://github.com/opentok/screensharing-extensions">screensharing-extensions</a>
59434
- * sample includes code for creating an extension for screen-sharing support in
59435
- * older versions of Chrome and Opera.
59436
- * <p>
59437
- * For more information, see the <a href="https://tokbox.com/developer/guides/screen-sharing/js/">
59438
- * Vonage Video API Screen Sharing</a> developer guide.
59439
59454
  *
59440
- * @param {function} callback The callback invoked with the support options object passed as
59441
- * the parameter. This object has the following properties that indicate support for publishing
59455
+ * This object has the following properties that indicate support for publishing
59442
59456
  * screen-sharing streams in the client:
59443
59457
  * <p>
59444
59458
  * <ul>
@@ -59485,47 +59499,80 @@ function screenSharingFactory(deps) {
59485
59499
  * </li>
59486
59500
  * </ul>
59487
59501
  *
59502
+ * Chrome 72+, Firefox 52+, Safari 13+, Edge 79+, and Opera 59+ have screen-sharing
59503
+ * support built-in, with no extension required. (Note that support for the Vonage Video API
59504
+ * plugin for Internet Explorer is removed in Vonage Video API 2.17.) Screen sharing is
59505
+ * <i>not</i> supported in mobile browsers. In Electron, screen sharing is supported if
59506
+ * the <code>webPreferences.contextIsolation</code> option of the Electron BrowserWindow is
59507
+ * set to <code>false</code> or if the app uses a preload script to access the desktop capturer.
59508
+ * (The default value of <code>webPreferences.contextIsolation</code> option is <code>true</code>
59509
+ * in Electron 12 and <code>false</code> in previous versions). To publish a screen-sharing video
59510
+ * in older versions of Chrome or Opera, the client adds an extension that enables publishing a
59511
+ * screen-sharing video stream on your domain. The Vonage Video API
59512
+ * <a href="https://github.com/opentok/screensharing-extensions">screensharing-extensions</a>
59513
+ * sample includes code for creating an extension for screen-sharing support in
59514
+ * older versions of Chrome and Opera.
59515
+ * <p>
59516
+ * For more information, see the <a href="https://tokbox.com/developer/guides/screen-sharing/js/">
59517
+ * Vonage Video API Screen Sharing</a> developer guide.
59518
+ *
59519
+ * @param {function} callback Optional callback invoked with the support options object passed as
59520
+ * the parameter.
59521
+ *
59522
+ * @returns {Promise<ScreenSharingCapabilityResponse>} A promise with the capability
59523
+ *
59488
59524
  * @see <a href="OT.html#initPublisher">OT.initPublisher()</a>
59489
59525
  * @see <a href="OT.html#registerScreenSharingExtension">OT.registerScreenSharingExtension()</a>
59490
59526
  * @method OT.checkScreenSharingCapability
59491
59527
  * @memberof OT
59492
59528
  */
59493
- screenSharing.checkCapability = callback => {
59494
- const response = {
59495
- supported: false,
59496
- extensionRequired: undefined,
59497
- extensionRegistered: undefined,
59498
- extensionInstalled: undefined,
59499
- supportedSources: {}
59500
- };
59501
-
59502
- // find a supported browser
59529
+ screenSharing.checkCapability = function (callback) {
59530
+ if (callback === void 0) {
59531
+ callback = () => {};
59532
+ }
59533
+ return new Promise(resolve => {
59534
+ const response = {
59535
+ supported: false,
59536
+ extensionRequired: undefined,
59537
+ extensionRegistered: undefined,
59538
+ extensionInstalled: undefined,
59539
+ supportedSources: {}
59540
+ };
59503
59541
 
59504
- const helper = screenSharingPickHelper();
59505
- if (helper.name === undefined) {
59506
- setTimeout(callback.bind(null, response));
59507
- return;
59508
- }
59509
- response.supported = true;
59510
- response.extensionRequired = helper.proto.extensionRequired ? helper.name : undefined;
59511
- response.supportedSources = {
59512
- screen: helper.proto.sources.screen,
59513
- application: helper.proto.sources.application,
59514
- window: helper.proto.sources.window,
59515
- browser: helper.proto.sources.browser
59516
- };
59517
- if (!helper.instance) {
59518
- response.extensionRegistered = false;
59519
- if (response.extensionRequired) {
59520
- response.extensionInstalled = false;
59542
+ // find a supported browser
59543
+ const helper = screenSharingPickHelper();
59544
+ if (helper.name === undefined) {
59545
+ setTimeout(() => {
59546
+ callback(response);
59547
+ });
59548
+ resolve(response);
59549
+ return;
59521
59550
  }
59522
- setTimeout(callback.bind(null, response));
59523
- return;
59524
- }
59525
- response.extensionRegistered = response.extensionRequired ? true : undefined;
59526
- helper.instance.isInstalled(installed => {
59527
- response.extensionInstalled = response.extensionRequired || OTHelpers.env.name === 'Firefox' ? installed : undefined;
59528
- callback(response);
59551
+ response.supported = true;
59552
+ response.extensionRequired = helper.proto.extensionRequired ? helper.name : undefined;
59553
+ response.supportedSources = {
59554
+ screen: helper.proto.sources.screen,
59555
+ application: helper.proto.sources.application,
59556
+ window: helper.proto.sources.window,
59557
+ browser: helper.proto.sources.browser
59558
+ };
59559
+ if (!helper.instance) {
59560
+ response.extensionRegistered = false;
59561
+ if (response.extensionRequired) {
59562
+ response.extensionInstalled = false;
59563
+ }
59564
+ setTimeout(() => {
59565
+ callback(response);
59566
+ });
59567
+ resolve(response);
59568
+ return;
59569
+ }
59570
+ response.extensionRegistered = response.extensionRequired ? true : undefined;
59571
+ helper.instance.isInstalled(installed => {
59572
+ response.extensionInstalled = response.extensionRequired || OTHelpers.env.name === 'Firefox' ? installed : undefined;
59573
+ callback(response);
59574
+ resolve(response);
59575
+ });
59529
59576
  });
59530
59577
  };
59531
59578
  screenSharing.registerExtensionHelper('electron', electronExtensionHelper);
@@ -59541,7 +59588,7 @@ function screenSharingFactory(deps) {
59541
59588
  videoSource = opt.videoSource,
59542
59589
  constraints = opt.constraints;
59543
59590
  return new Promise((resolve, reject) => {
59544
- screenSharing.checkCapability(response => {
59591
+ screenSharing.checkCapability().then(response => {
59545
59592
  if (!response.supported) {
59546
59593
  let errorMessage = 'Screen Sharing is not supported in this browser';
59547
59594
  if (OTHelpers.env.isElectron) {
@@ -61742,41 +61789,51 @@ function reportIssueFactory(deps) {
61742
61789
  * <a href="https://tokbox.com/developer/tools/inspector/">Inspector</a> or when discussing
61743
61790
  * an issue with the Vonage API support team.
61744
61791
  *
61745
- * @param completionHandler {Function} A function that is called when the call to this method
61792
+ * @param completionHandler {Function} Optional Function that is called when the call to this method
61746
61793
  * succeeds or fails. This function has two parameters. The first parameter is an
61747
61794
  * <a href="Error.html">Error</a> object that is set when the call to the
61748
61795
  * <code>reportIssue()</code> method fails (for example, if the client is not connected to the
61749
61796
  * network) or <code>null</code> when the call to the <code>reportIssue()</code> method succeeds.
61750
61797
  * The second parameter is set to the report ID (a unique string) when the call succeeds.
61751
61798
  *
61799
+ * @returns {Promise<string>} A promise resolving to the report ID
61800
+ *
61752
61801
  * @method OT.reportIssue
61753
61802
  * @memberof OT
61754
61803
  */
61755
61804
  return function reportIssue(completionHandler) {
61756
- if (completionHandler === void 0) {
61757
- completionHandler = () => {};
61758
- }
61759
- const reportIssueId = uuid();
61760
- function onDone(err) {
61761
- if (err) {
61762
- completionHandler(otError(errors.REPORT_ISSUE_FAILED, new Error('Error calling OT.reportIssue(). Check the client\'s network connection.'), ExceptionCodes.REPORT_ISSUE_ERROR));
61805
+ const hasCompletionHandler = typeof completionHandler === 'function';
61806
+ const callback = hasCompletionHandler ? completionHandler : () => {};
61807
+ const promise = new Promise((resolve, reject) => {
61808
+ const reportIssueId = uuid();
61809
+ function onDone(err) {
61810
+ if (err) {
61811
+ const error = otError(errors.REPORT_ISSUE_FAILED, new Error('Error calling OT.reportIssue(). Check the client\'s network connection.'), ExceptionCodes.REPORT_ISSUE_ERROR);
61812
+ callback(error);
61813
+ reject(error);
61814
+ } else {
61815
+ callback(null, reportIssueId);
61816
+ resolve(reportIssueId);
61817
+ }
61818
+ }
61819
+ if (sessionObjects.sessions.length() === 0) {
61820
+ analytics.logEvent({
61821
+ action: 'ReportIssue',
61822
+ variation: 'Event',
61823
+ payload: {
61824
+ reportIssueId
61825
+ }
61826
+ }, null, onDone);
61763
61827
  } else {
61764
- completionHandler(null, reportIssueId);
61828
+ Promise.all(sessionObjects.sessions.map(session => session.reportIssue({
61829
+ id: reportIssueId
61830
+ }))).then(() => onDone(), err => onDone(err));
61765
61831
  }
61832
+ });
61833
+ if (hasCompletionHandler) {
61834
+ promise.catch(() => {});
61766
61835
  }
61767
- if (sessionObjects.sessions.length() === 0) {
61768
- analytics.logEvent({
61769
- action: 'ReportIssue',
61770
- variation: 'Event',
61771
- payload: {
61772
- reportIssueId
61773
- }
61774
- }, null, onDone);
61775
- } else {
61776
- Promise.all(sessionObjects.sessions.map(session => session.reportIssue({
61777
- id: reportIssueId
61778
- }))).then(() => onDone(), err => onDone(err));
61779
- }
61836
+ return promise;
61780
61837
  };
61781
61838
  }
61782
61839
 
@@ -65924,13 +65981,16 @@ function PeerConnectionFactory(deps) {
65924
65981
  iceRestartTimeout = null;
65925
65982
  }
65926
65983
  };
65927
- const _createOfferWithIceRestart = force => {
65984
+ const _createOfferWithIceRestart = (reason, forcedRestart, recentlyIceRestartNeeded) => {
65928
65985
  clearIceRestartTimeout();
65929
- if (!api.iceConnectionStateIsConnected()) {
65930
- if (force) {
65986
+ if (forcedRestart || !api.iceConnectionStateIsConnected()) {
65987
+ if (forcedRestart || recentlyIceRestartNeeded) {
65988
+ api.trigger('iceRestartAttempt', {
65989
+ reason
65990
+ });
65931
65991
  api.generateOfferAndSend();
65932
65992
  } else {
65933
- debouncedGenerateOfferAndSend();
65993
+ debouncedGenerateOfferAndSend(reason);
65934
65994
  }
65935
65995
  } else {
65936
65996
  logging.debug('iceRestart is going to wait until we disconnect or negotiationNeeded' + ' and then restart ice');
@@ -65941,20 +66001,25 @@ function PeerConnectionFactory(deps) {
65941
66001
  };
65942
66002
  const _iceRestartNeeded = (() => {
65943
66003
  let value = false;
66004
+ let reason;
65944
66005
  let lastIceRestartNeededTime = 0;
65945
66006
  return {
65946
66007
  get() {
65947
66008
  return value;
65948
66009
  },
65949
- set(newValueParam) {
66010
+ set(newValueParam, iceRestartReason, forcedRestart) {
66011
+ if (forcedRestart === void 0) {
66012
+ forcedRestart = false;
66013
+ }
65950
66014
  const newValue = Boolean(newValueParam);
65951
66015
  if (newValue !== value) {
65952
66016
  value = newValue;
66017
+ reason = iceRestartReason;
65953
66018
  if (value) {
65954
66019
  const prevIceRestartNeededTime = lastIceRestartNeededTime;
65955
66020
  lastIceRestartNeededTime = Date.now();
65956
66021
  const recentlyIceRestartNeeded = lastIceRestartNeededTime - prevIceRestartNeededTime < 10000;
65957
- _createOfferWithIceRestart(recentlyIceRestartNeeded);
66022
+ _createOfferWithIceRestart(reason, forcedRestart, recentlyIceRestartNeeded);
65958
66023
  } else {
65959
66024
  clearIceRestartTimeout();
65960
66025
  debouncedGenerateOfferAndSend.cancel();
@@ -65964,7 +66029,7 @@ function PeerConnectionFactory(deps) {
65964
66029
  run() {
65965
66030
  if (value) {
65966
66031
  clearIceRestartTimeout();
65967
- debouncedGenerateOfferAndSend();
66032
+ debouncedGenerateOfferAndSend(reason);
65968
66033
  }
65969
66034
  return value;
65970
66035
  }
@@ -66665,7 +66730,12 @@ function PeerConnectionFactory(deps) {
66665
66730
  };
66666
66731
  api.generateOffer(offerSender);
66667
66732
  };
66668
- const debouncedGenerateOfferAndSend = debounce(api.generateOfferAndSend, 2000);
66733
+ const debouncedGenerateOfferAndSend = debounce(reason => {
66734
+ api.trigger('iceRestartAttempt', {
66735
+ reason
66736
+ });
66737
+ api.generateOfferAndSend();
66738
+ }, 2000);
66669
66739
  api.generateOffer = debounce(function (onOfferCreated) {
66670
66740
  if (onOfferCreated === void 0) {
66671
66741
  onOfferCreated = () => {};
@@ -66834,7 +66904,7 @@ function PeerConnectionFactory(deps) {
66834
66904
  setTimeout(tearDownPeerConnection);
66835
66905
  }
66836
66906
  };
66837
- api.iceRestart = () => _iceRestartNeeded.set(true);
66907
+ api.iceRestart = (reason, forcedRestart) => _iceRestartNeeded.set(true, reason, forcedRestart);
66838
66908
  api.clearFailedTimeout = () => {
66839
66909
  if (_transitionToFailedTimeOut) {
66840
66910
  clearTimeout(_transitionToFailedTimeOut);
@@ -67244,6 +67314,7 @@ exports["default"] = _default;
67244
67314
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
67245
67315
 
67246
67316
  "use strict";
67317
+ /* provided dependency */ var Promise = __webpack_require__(86964);
67247
67318
 
67248
67319
 
67249
67320
  var _interopRequireDefault = __webpack_require__(95709);
@@ -67948,7 +68019,7 @@ function initPublisherFactory(deps) {
67948
68019
  * @method OT.initPublisher
67949
68020
  * @memberof OT
67950
68021
  */
67951
- return function initPublisher(targetElement, properties, completionHandler) {
68022
+ function initPublisher(targetElement, properties, completionHandler) {
67952
68023
  logging.debug(`OT.initPublisher(${targetElement})`);
67953
68024
 
67954
68025
  // To support legacy (apikey, targetElement, properties) users
@@ -68005,7 +68076,6 @@ function initPublisherFactory(deps) {
68005
68076
  };
68006
68077
  let removeHandlersAndCallComplete = function removeHandlersAndCallComplete(err) {
68007
68078
  publisher.off('initSuccess', removeInitSuccessAndCallComplete);
68008
-
68009
68079
  // We're only handling the error case here as we're just
68010
68080
  // initing the publisher, not actually attempting to publish.
68011
68081
  if (err) {
@@ -68016,7 +68086,24 @@ function initPublisherFactory(deps) {
68016
68086
  publisher.once('publishComplete', removeHandlersAndCallComplete);
68017
68087
  publisher.publish(targetElement);
68018
68088
  return publisher;
68019
- };
68089
+ }
68090
+
68091
+ /**
68092
+ * The <code>initPublisher</code> function is also available in a promisifed flavour.
68093
+ * Note that this function will only resolve to a publisher object if there were no
68094
+ * errors involved in its creation.
68095
+ */
68096
+ initPublisher.promise = (targetElement, properties) => new Promise((resolve, reject) => {
68097
+ const args = [targetElement, properties].filter(arg => arg !== undefined);
68098
+ const publisher = initPublisher(...args, error => {
68099
+ if (error) {
68100
+ reject(error);
68101
+ } else {
68102
+ resolve(publisher);
68103
+ }
68104
+ });
68105
+ });
68106
+ return initPublisher;
68020
68107
  }
68021
68108
 
68022
68109
  /***/ }),
@@ -68166,6 +68253,7 @@ module.exports = baseRest;
68166
68253
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
68167
68254
 
68168
68255
  "use strict";
68256
+ /* provided dependency */ var Promise = __webpack_require__(86964);
68169
68257
 
68170
68258
 
68171
68259
  var _interopRequireDefault = __webpack_require__(95709);
@@ -68175,13 +68263,24 @@ var _get_rtc_stats_report_adapter = _interopRequireDefault(__webpack_require__(5
68175
68263
  var _createRtcStatsReportParser = _interopRequireDefault(__webpack_require__(14848));
68176
68264
  // This returns the array-ified list of stats our users are accustomed to
68177
68265
  var _default = (peerConnection, track, completion) => {
68178
- (0, _get_rtc_stats_report_adapter.default)(peerConnection, track, (err, rtcStatsReport) => {
68179
- if (err) {
68180
- completion(err);
68181
- return;
68182
- }
68183
- completion(null, (0, _createRtcStatsReportParser.default)()(rtcStatsReport));
68266
+ const hasCompletion = typeof completion === 'function';
68267
+ const callback = hasCompletion ? completion : () => {};
68268
+ const promise = new Promise((resolve, reject) => {
68269
+ (0, _get_rtc_stats_report_adapter.default)(peerConnection, track, (err, rtcStatsReport) => {
68270
+ if (err) {
68271
+ callback(err);
68272
+ reject(err);
68273
+ return;
68274
+ }
68275
+ const parsedReport = (0, _createRtcStatsReportParser.default)()(rtcStatsReport);
68276
+ callback(null, parsedReport);
68277
+ resolve(parsedReport);
68278
+ });
68184
68279
  });
68280
+ if (hasCompletion) {
68281
+ promise.catch(() => {});
68282
+ }
68283
+ return promise;
68185
68284
  };
68186
68285
  exports["default"] = _default;
68187
68286
 
@@ -71083,7 +71182,7 @@ function SessionFactory(deps) {
71083
71182
  sessionObjects.publishers.where({
71084
71183
  session: this
71085
71184
  }).forEach(publisher => {
71086
- publisher._.iceRestart();
71185
+ publisher._.iceRestart('socket reconnected');
71087
71186
  });
71088
71187
  if (!((_this$session = this.session) != null && (_this$session$session = _this$session.sessionInfo) != null && _this$session$session.p2pEnabled)) {
71089
71188
  sessionObjects.subscribers.where({