@opentok/client 2.35.0-alpha.23 → 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.
@@ -28,7 +28,7 @@ declare namespace OT {
28
28
 
29
29
  export function checkScreenSharingCapability(
30
30
  callback: (response: ScreenSharingCapabilityResponse) => void
31
- ): void;
31
+ ): Promise<ScreenSharingCapabilityResponse>;
32
32
 
33
33
  export function checkSystemRequirements(): number;
34
34
 
@@ -67,7 +67,7 @@ declare namespace OT {
67
67
 
68
68
  export function getDevices(
69
69
  callback: (error: OTError | undefined, devices?: Device[]) => void
70
- ): void;
70
+ ): Promise<Device[]>;
71
71
 
72
72
  export function getAudioOutputDevices(): Promise<AudioOutputDevice[]>;
73
73
 
@@ -485,6 +485,15 @@ declare namespace OT {
485
485
  callback?: (error?: OTError) => void
486
486
  ): Publisher;
487
487
 
488
+ export namespace initPublisher {
489
+ var promise: (
490
+ targetElement?: HTMLElement | string,
491
+ properties?: PublisherProperties,
492
+ callback?: (error?: OTError) => void
493
+ ) =>
494
+ Promise<Publisher>;
495
+ }
496
+
488
497
  export function log(message: string): void;
489
498
 
490
499
  export function off(
@@ -845,7 +854,7 @@ declare namespace OT {
845
854
  version: number
846
855
  ): void;
847
856
 
848
- export function reportIssue(callback: (error?: OTError, reportId?: string) => void): void;
857
+ export function reportIssue(callback: (error?: OTError, reportId?: string) => void): Promise<string>;
849
858
 
850
859
  export function setAudioOutputDevice(deviceId: string): Promise<void>;
851
860
 
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.35.0 b3cd7abe5
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 13:03:31 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
  /***/ }),
@@ -29218,6 +29233,8 @@ function RaptorSocketFactory(deps) {
29218
29233
  var _interopRequireDefault = __webpack_require__(95709);
29219
29234
  exports.__esModule = true;
29220
29235
  exports["default"] = getUserMediaFactory;
29236
+ var _regenerator = _interopRequireDefault(__webpack_require__(92207));
29237
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(79092));
29221
29238
  var _assign = _interopRequireDefault(__webpack_require__(86139));
29222
29239
  var _isObject = _interopRequireDefault(__webpack_require__(23805));
29223
29240
  var _eventing = _interopRequireDefault(__webpack_require__(12607));
@@ -29505,23 +29522,41 @@ function getUserMediaFactory(deps) {
29505
29522
  // it when creating `finalized` above.
29506
29523
  const error = parseErrorEvent(browserError);
29507
29524
  if (error.name === Errors.UNABLE_TO_CAPTURE_SCREEN) {
29508
- return new Promise((resolve, reject) => {
29509
- screenSharing.checkCapability(response => {
29510
- if (response.extensionRequired === 'chrome') {
29511
- if (response.extensionRegistered && !response.extensionInstalled) {
29512
- const newErr = otError(Errors.SCREEN_SHARING_EXTENSION_NOT_INSTALLED, error);
29513
- newErr.message = 'Screen sharing extension not installed see https://tokbox.com/developer/guides/screen-sharing/js/#chrome-extension';
29514
- reject(newErr);
29515
- } else if (!response.extensionRegistered) {
29516
- const newErr = otError(Errors.SCREEN_SHARING_EXTENSION_NOT_REGISTERED, error);
29517
- newErr.message = 'Screen sharing extension not registered see https://tokbox.com/developer/guides/screen-sharing/js/#chrome-extension';
29518
- 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();
29519
29553
  }
29520
- } else {
29521
- reject(error);
29522
- }
29523
- });
29524
- });
29554
+ }, _callee);
29555
+ }));
29556
+ return function (_x, _x2) {
29557
+ return _ref.apply(this, arguments);
29558
+ };
29559
+ }());
29525
29560
  }
29526
29561
  throw error;
29527
29562
  }).then(stream => {
@@ -41658,7 +41693,7 @@ function staticConfigFactory(_temp) {
41658
41693
  _ref$axios = _ref.axios,
41659
41694
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
41660
41695
  _ref$properties = _ref.properties,
41661
- properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"b3cd7abe5","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;
41662
41697
  /** @type builtInConfig */
41663
41698
  const builtInConfig = (0, _cloneDeep.default)(properties);
41664
41699
  /**
@@ -59400,42 +59435,24 @@ function screenSharingFactory(deps) {
59400
59435
  screenSharing.pickHelper = () => screenSharingPickHelper();
59401
59436
 
59402
59437
  /**
59403
- * Checks for support for publishing screen-sharing streams on the client browser. The object
59404
- * 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
59405
59440
  * which screen-sharing sources (application, screen, or window) are supported. It also indicates
59406
59441
  * whether an extension is required, installed, and registered (if needed).
59407
59442
  * <p>
59408
59443
  * <pre>
59409
- * OT.checkScreenSharingCapability(function(response) {
59410
- * if (!response.supported || response.extensionRegistered === false) {
59411
- * // This browser does not support screen sharing
59412
- * } else if (response.extensionInstalled === false) {
59413
- * // Prompt to install the extension
59414
- * } else {
59415
- * // Screen sharing is available.
59416
- * }
59417
- * });
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
+ * }
59418
59452
  * </pre>
59419
59453
  * <p>
59420
- * Chrome 72+, Firefox 52+, Safari 13+, Edge 79+, and Opera 59+ have screen-sharing
59421
- * support built-in, with no extension required. (Note that support for the Vonage Video API
59422
- * plugin for Internet Explorer is removed in Vonage Video API 2.17.) Screen sharing is
59423
- * <i>not</i> supported in mobile browsers. In Electron, screen sharing is supported if
59424
- * the <code>webPreferences.contextIsolation</code> option of the Electron BrowserWindow is
59425
- * set to <code>false</code> or if the app uses a preload script to access the desktop capturer.
59426
- * (The default value of <code>webPreferences.contextIsolation</code> option is <code>true</code>
59427
- * in Electron 12 and <code>false</code> in previous versions). To publish a screen-sharing video
59428
- * in older versions of Chrome or Opera, the client adds an extension that enables publishing a
59429
- * screen-sharing video stream on your domain. The Vonage Video API
59430
- * <a href="https://github.com/opentok/screensharing-extensions">screensharing-extensions</a>
59431
- * sample includes code for creating an extension for screen-sharing support in
59432
- * older versions of Chrome and Opera.
59433
- * <p>
59434
- * For more information, see the <a href="https://tokbox.com/developer/guides/screen-sharing/js/">
59435
- * Vonage Video API Screen Sharing</a> developer guide.
59436
59454
  *
59437
- * @param {function} callback The callback invoked with the support options object passed as
59438
- * 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
59439
59456
  * screen-sharing streams in the client:
59440
59457
  * <p>
59441
59458
  * <ul>
@@ -59482,47 +59499,80 @@ function screenSharingFactory(deps) {
59482
59499
  * </li>
59483
59500
  * </ul>
59484
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
+ *
59485
59524
  * @see <a href="OT.html#initPublisher">OT.initPublisher()</a>
59486
59525
  * @see <a href="OT.html#registerScreenSharingExtension">OT.registerScreenSharingExtension()</a>
59487
59526
  * @method OT.checkScreenSharingCapability
59488
59527
  * @memberof OT
59489
59528
  */
59490
- screenSharing.checkCapability = callback => {
59491
- const response = {
59492
- supported: false,
59493
- extensionRequired: undefined,
59494
- extensionRegistered: undefined,
59495
- extensionInstalled: undefined,
59496
- supportedSources: {}
59497
- };
59498
-
59499
- // 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
+ };
59500
59541
 
59501
- const helper = screenSharingPickHelper();
59502
- if (helper.name === undefined) {
59503
- setTimeout(callback.bind(null, response));
59504
- return;
59505
- }
59506
- response.supported = true;
59507
- response.extensionRequired = helper.proto.extensionRequired ? helper.name : undefined;
59508
- response.supportedSources = {
59509
- screen: helper.proto.sources.screen,
59510
- application: helper.proto.sources.application,
59511
- window: helper.proto.sources.window,
59512
- browser: helper.proto.sources.browser
59513
- };
59514
- if (!helper.instance) {
59515
- response.extensionRegistered = false;
59516
- if (response.extensionRequired) {
59517
- 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;
59518
59550
  }
59519
- setTimeout(callback.bind(null, response));
59520
- return;
59521
- }
59522
- response.extensionRegistered = response.extensionRequired ? true : undefined;
59523
- helper.instance.isInstalled(installed => {
59524
- response.extensionInstalled = response.extensionRequired || OTHelpers.env.name === 'Firefox' ? installed : undefined;
59525
- 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
+ });
59526
59576
  });
59527
59577
  };
59528
59578
  screenSharing.registerExtensionHelper('electron', electronExtensionHelper);
@@ -59538,7 +59588,7 @@ function screenSharingFactory(deps) {
59538
59588
  videoSource = opt.videoSource,
59539
59589
  constraints = opt.constraints;
59540
59590
  return new Promise((resolve, reject) => {
59541
- screenSharing.checkCapability(response => {
59591
+ screenSharing.checkCapability().then(response => {
59542
59592
  if (!response.supported) {
59543
59593
  let errorMessage = 'Screen Sharing is not supported in this browser';
59544
59594
  if (OTHelpers.env.isElectron) {
@@ -61739,41 +61789,51 @@ function reportIssueFactory(deps) {
61739
61789
  * <a href="https://tokbox.com/developer/tools/inspector/">Inspector</a> or when discussing
61740
61790
  * an issue with the Vonage API support team.
61741
61791
  *
61742
- * @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
61743
61793
  * succeeds or fails. This function has two parameters. The first parameter is an
61744
61794
  * <a href="Error.html">Error</a> object that is set when the call to the
61745
61795
  * <code>reportIssue()</code> method fails (for example, if the client is not connected to the
61746
61796
  * network) or <code>null</code> when the call to the <code>reportIssue()</code> method succeeds.
61747
61797
  * The second parameter is set to the report ID (a unique string) when the call succeeds.
61748
61798
  *
61799
+ * @returns {Promise<string>} A promise resolving to the report ID
61800
+ *
61749
61801
  * @method OT.reportIssue
61750
61802
  * @memberof OT
61751
61803
  */
61752
61804
  return function reportIssue(completionHandler) {
61753
- if (completionHandler === void 0) {
61754
- completionHandler = () => {};
61755
- }
61756
- const reportIssueId = uuid();
61757
- function onDone(err) {
61758
- if (err) {
61759
- 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);
61760
61827
  } else {
61761
- completionHandler(null, reportIssueId);
61828
+ Promise.all(sessionObjects.sessions.map(session => session.reportIssue({
61829
+ id: reportIssueId
61830
+ }))).then(() => onDone(), err => onDone(err));
61762
61831
  }
61832
+ });
61833
+ if (hasCompletionHandler) {
61834
+ promise.catch(() => {});
61763
61835
  }
61764
- if (sessionObjects.sessions.length() === 0) {
61765
- analytics.logEvent({
61766
- action: 'ReportIssue',
61767
- variation: 'Event',
61768
- payload: {
61769
- reportIssueId
61770
- }
61771
- }, null, onDone);
61772
- } else {
61773
- Promise.all(sessionObjects.sessions.map(session => session.reportIssue({
61774
- id: reportIssueId
61775
- }))).then(() => onDone(), err => onDone(err));
61776
- }
61836
+ return promise;
61777
61837
  };
61778
61838
  }
61779
61839
 
@@ -67254,6 +67314,7 @@ exports["default"] = _default;
67254
67314
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
67255
67315
 
67256
67316
  "use strict";
67317
+ /* provided dependency */ var Promise = __webpack_require__(86964);
67257
67318
 
67258
67319
 
67259
67320
  var _interopRequireDefault = __webpack_require__(95709);
@@ -67958,7 +68019,7 @@ function initPublisherFactory(deps) {
67958
68019
  * @method OT.initPublisher
67959
68020
  * @memberof OT
67960
68021
  */
67961
- return function initPublisher(targetElement, properties, completionHandler) {
68022
+ function initPublisher(targetElement, properties, completionHandler) {
67962
68023
  logging.debug(`OT.initPublisher(${targetElement})`);
67963
68024
 
67964
68025
  // To support legacy (apikey, targetElement, properties) users
@@ -68015,7 +68076,6 @@ function initPublisherFactory(deps) {
68015
68076
  };
68016
68077
  let removeHandlersAndCallComplete = function removeHandlersAndCallComplete(err) {
68017
68078
  publisher.off('initSuccess', removeInitSuccessAndCallComplete);
68018
-
68019
68079
  // We're only handling the error case here as we're just
68020
68080
  // initing the publisher, not actually attempting to publish.
68021
68081
  if (err) {
@@ -68026,7 +68086,24 @@ function initPublisherFactory(deps) {
68026
68086
  publisher.once('publishComplete', removeHandlersAndCallComplete);
68027
68087
  publisher.publish(targetElement);
68028
68088
  return publisher;
68029
- };
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;
68030
68107
  }
68031
68108
 
68032
68109
  /***/ }),
@@ -68176,6 +68253,7 @@ module.exports = baseRest;
68176
68253
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
68177
68254
 
68178
68255
  "use strict";
68256
+ /* provided dependency */ var Promise = __webpack_require__(86964);
68179
68257
 
68180
68258
 
68181
68259
  var _interopRequireDefault = __webpack_require__(95709);
@@ -68185,13 +68263,24 @@ var _get_rtc_stats_report_adapter = _interopRequireDefault(__webpack_require__(5
68185
68263
  var _createRtcStatsReportParser = _interopRequireDefault(__webpack_require__(14848));
68186
68264
  // This returns the array-ified list of stats our users are accustomed to
68187
68265
  var _default = (peerConnection, track, completion) => {
68188
- (0, _get_rtc_stats_report_adapter.default)(peerConnection, track, (err, rtcStatsReport) => {
68189
- if (err) {
68190
- completion(err);
68191
- return;
68192
- }
68193
- 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
+ });
68194
68279
  });
68280
+ if (hasCompletion) {
68281
+ promise.catch(() => {});
68282
+ }
68283
+ return promise;
68195
68284
  };
68196
68285
  exports["default"] = _default;
68197
68286