@vonage/client-sdk-video 2.35.0-alpha.36 → 2.35.0-alpha.38

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 c21053e02
2
+ * @license OpenTok.js 2.35.0 2592e1f
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, 27 May 2026 10:59:03 GMT
8
+ * Date: Fri, 29 May 2026 07:34:13 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -31880,7 +31880,7 @@ if (isWorker()) {
31880
31880
  initWorker();
31881
31881
  }
31882
31882
  var Module = (() => {
31883
- var _scriptDir = "file:///Users/ec2-user/Desktop/webrtc-js-runner/actions-runner/_work/webrtc-js/webrtc-js/node_modules/@vonage/js-sframe/dist/js-sframe.es.js";
31883
+ var _scriptDir = "file:///Users/ec2-user/actions-runner/webrtc-js/_work/webrtc-js/webrtc-js/node_modules/@vonage/js-sframe/dist/js-sframe.es.js";
31884
31884
  return function(Module2) {
31885
31885
  Module2 = Module2 || {};
31886
31886
  var Module2 = typeof Module2 != "undefined" ? Module2 : {};
@@ -41920,7 +41920,7 @@ function staticConfigFactory(_temp) {
41920
41920
  _ref$axios = _ref.axios,
41921
41921
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
41922
41922
  _ref$properties = _ref.properties,
41923
- properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"c21053e02","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;
41923
+ properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"2592e1f","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;
41924
41924
  /** @type builtInConfig */
41925
41925
  const builtInConfig = (0, _cloneDeep.default)(properties);
41926
41926
  /**
@@ -45066,47 +45066,39 @@ function PublisherFactory(_ref) {
45066
45066
  case 0:
45067
45067
  isStaticContent = isStaticContentHint();
45068
45068
  if (!_targetScalabilityMode) {
45069
- _context12.next = 19;
45069
+ _context12.next = 17;
45070
45070
  break;
45071
45071
  }
45072
45072
  _context12.prev = 2;
45073
- logAnalyticsEvent('setScalabilityMode', 'Attempt', {
45074
- scalabilityMode: _targetScalabilityMode
45075
- });
45076
45073
  if (!isStaticContent) {
45077
- _context12.next = 9;
45074
+ _context12.next = 8;
45078
45075
  break;
45079
45076
  }
45080
- _context12.next = 7;
45077
+ _context12.next = 6;
45081
45078
  return _this._setScalabilityMode(getTemporalOnlyScalabilityMode(_targetScalabilityMode));
45082
- case 7:
45083
- _context12.next = 11;
45079
+ case 6:
45080
+ _context12.next = 10;
45084
45081
  break;
45085
- case 9:
45086
- _context12.next = 11;
45082
+ case 8:
45083
+ _context12.next = 10;
45087
45084
  return Promise.all([_this._setScalabilityMode(_targetScalabilityMode, TARGET_SCALABILITY_MODE_SVC_CODECS), _this._setScalabilityMode(getTemporalOnlyScalabilityMode(_targetScalabilityMode), TARGET_SCALABILITY_MODE_NON_SVC_CODECS)]);
45088
- case 11:
45089
- logAnalyticsEvent('setScalabilityMode', 'Success', {
45090
- scalabilityMode: _targetScalabilityMode
45091
- });
45092
- _context12.next = 18;
45085
+ case 10:
45086
+ _context12.next = 16;
45093
45087
  break;
45094
- case 14:
45095
- _context12.prev = 14;
45088
+ case 12:
45089
+ _context12.prev = 12;
45096
45090
  _context12.t0 = _context12["catch"](2);
45097
- logging.error('OT.Publisher failed to apply scalability mode', _context12.t0);
45098
- logAnalyticsEvent('setScalabilityMode', 'Failure', {
45099
- message: _context12.t0.message
45100
- });
45101
- case 18:
45091
+ logging.error('OT.Publisher failed to apply target scalability mode', _context12.t0);
45092
+ throw _context12.t0;
45093
+ case 16:
45102
45094
  return _context12.abrupt("return");
45103
- case 19:
45095
+ case 17:
45104
45096
  if (!(!properties.constraints.video || !sessionSimulcastEnabled || capableSimulcastStreams < 2)) {
45105
- _context12.next = 21;
45097
+ _context12.next = 19;
45106
45098
  break;
45107
45099
  }
45108
45100
  return _context12.abrupt("return");
45109
- case 21:
45101
+ case 19:
45110
45102
  codecsWhitelist = ['VP9'];
45111
45103
  isCamera = !isScreenSharing && !isCustomVideoTrack;
45112
45104
  if (isCamera) {
@@ -45116,24 +45108,24 @@ function PublisherFactory(_ref) {
45116
45108
  scalabilityMode = (0, _getScalabilityModeFromContentHint.default)(_this.getVideoContentHint());
45117
45109
  }
45118
45110
  if (!scalabilityMode) {
45119
- _context12.next = 33;
45111
+ _context12.next = 31;
45120
45112
  break;
45121
45113
  }
45122
- _context12.prev = 25;
45123
- _context12.next = 28;
45114
+ _context12.prev = 23;
45115
+ _context12.next = 26;
45124
45116
  return _this._setScalabilityMode(scalabilityMode, codecsWhitelist);
45125
- case 28:
45126
- _context12.next = 33;
45117
+ case 26:
45118
+ _context12.next = 31;
45127
45119
  break;
45128
- case 30:
45129
- _context12.prev = 30;
45130
- _context12.t1 = _context12["catch"](25);
45120
+ case 28:
45121
+ _context12.prev = 28;
45122
+ _context12.t1 = _context12["catch"](23);
45131
45123
  logging.error('OT.Publisher failed to apply scalability mode', _context12.t1);
45132
- case 33:
45124
+ case 31:
45133
45125
  case "end":
45134
45126
  return _context12.stop();
45135
45127
  }
45136
- }, _callee12, null, [[2, 14], [25, 30]]);
45128
+ }, _callee12, null, [[2, 12], [23, 28]]);
45137
45129
  }));
45138
45130
  return function configureScalabilityMode() {
45139
45131
  return _ref21.apply(this, arguments);
@@ -45688,172 +45680,201 @@ function PublisherFactory(_ref) {
45688
45680
  this.destroy();
45689
45681
  }, this.session.MIGRATION_TIMEOUT);
45690
45682
  };
45691
- this.publish = targetElement => {
45692
- logging.debug('OT.Publisher: publish');
45693
- if (state.isAttemptingToPublish() || state.isPublishing()) {
45694
- reset();
45695
- }
45696
- state.set('GetUserMedia');
45697
- if (properties.style) {
45698
- this.setStyle(properties.style, null, true);
45683
+ const publishWithCallback = function publishWithCallback(targetElement, callback) {
45684
+ if (callback === void 0) {
45685
+ callback = () => {};
45699
45686
  }
45700
- properties.classNames = 'OT_root OT_publisher';
45701
-
45702
- // Defer actually creating the publisher DOM nodes until we know
45703
- // the DOM is actually loaded.
45704
- EnvironmentLoader.onLoad(() => {
45705
- logging.debug('OT.Publisher: publish: environment loaded');
45706
- // @note If ever replacing the widgetView with a new one elsewhere, you'll need to be
45707
- // mindful that audioLevelBehaviour has a reference to this one, and it will need to be
45708
- // updated accordingly.
45709
- // widgetView = new WidgetView(targetElement, properties);
45710
- widgetView = new WidgetView(targetElement, Object.assign({}, properties, {
45711
- widgetType: 'publisher'
45712
- }));
45713
- if (shouldAllowAudio) {
45714
- (0, _audioLevelBehaviour.default)({
45715
- publisher: this,
45716
- widgetView
45717
- });
45718
- }
45719
- widgetView.on('error', onVideoError);
45720
- this.id = widgetView.domId();
45721
- this.element = widgetView.domElement;
45722
- if (this.element && chromeMixin) {
45723
- // Only create the chrome if we have an element to insert it into
45724
- // for insertDefautlUI:false we don't create the chrome
45725
- chromeMixin.init(widgetView);
45726
- }
45727
- widgetView.on('videoDimensionsChanged', (oldValue, newValue) => {
45728
- // Ignore this event since there is no video.
45729
- if (!properties.publishVideo) {
45730
- return;
45731
- }
45732
- if (this.stream) {
45733
- this.stream.setVideoDimensions(newValue.width, newValue.height);
45734
- }
45735
- this.dispatchEvent(new Events.VideoDimensionsChangedEvent(this, oldValue, newValue));
45736
- });
45737
- widgetView.on('mediaStopped', track => {
45738
- const event = new Events.MediaStoppedEvent(this, track);
45739
-
45740
- // When we have a disabled and transformed media track, we don't dispatch the event since
45741
- // it is not a media source stop. This is the case when we call publishVideo(false) or
45742
- // cycleVideo(), where the transformed track is stopped.
45743
- const isDisabledTransformedTrack = (track == null ? void 0 : track.readyState) === 'ended' &&
45744
- // Only transformed tracks have the writable property.
45745
- // See: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrackGenerator/writable
45746
- !!(track != null && track.writable);
45747
- if (!isDisabledTransformedTrack) {
45748
- this.dispatchEvent(event);
45687
+ logging.debug('OT.Publisher: publish');
45688
+ try {
45689
+ if (state.isAttemptingToPublish() || state.isPublishing()) {
45690
+ reset();
45691
+ }
45692
+ state.set('GetUserMedia');
45693
+ if (properties.style) {
45694
+ _this.setStyle(properties.style, null, true);
45695
+ }
45696
+ properties.classNames = 'OT_root OT_publisher';
45697
+
45698
+ // Defer actually creating the publisher DOM nodes until we know
45699
+ // the DOM is actually loaded.
45700
+ EnvironmentLoader.onLoad(() => {
45701
+ logging.debug('OT.Publisher: publish: environment loaded');
45702
+ // @note If ever replacing the widgetView with a new one elsewhere, you'll need to be
45703
+ // mindful that audioLevelBehaviour has a reference to this one, and it will need to be
45704
+ // updated accordingly.
45705
+ // widgetView = new WidgetView(targetElement, properties);
45706
+ widgetView = new WidgetView(targetElement, Object.assign({}, properties, {
45707
+ widgetType: 'publisher'
45708
+ }));
45709
+ if (shouldAllowAudio) {
45710
+ (0, _audioLevelBehaviour.default)({
45711
+ publisher: _this,
45712
+ widgetView
45713
+ });
45749
45714
  }
45750
- if (event.isDefaultPrevented()) {
45751
- return;
45715
+ widgetView.on('error', err => {
45716
+ onVideoError(err);
45717
+ });
45718
+ _this.id = widgetView.domId();
45719
+ _this.element = widgetView.domElement;
45720
+ if (_this.element && chromeMixin) {
45721
+ // Only create the chrome if we have an element to insert it into
45722
+ // for insertDefautlUI:false we don't create the chrome
45723
+ chromeMixin.init(widgetView);
45752
45724
  }
45753
- if (track) {
45754
- const kind = String(track.kind).toLowerCase();
45755
- // If we are publishing this kind when the track stops then
45756
- // make sure we start publishing again if we switch to a new track
45757
- if (kind === 'audio') {
45758
- updateAudio();
45759
- } else if (kind === 'video') {
45760
- updateVideo();
45725
+ widgetView.on('videoDimensionsChanged', (oldValue, newValue) => {
45726
+ // Ignore this event since there is no video.
45727
+ if (!properties.publishVideo) {
45728
+ return;
45729
+ }
45730
+ if (_this.stream) {
45731
+ _this.stream.setVideoDimensions(newValue.width, newValue.height);
45732
+ }
45733
+ _this.dispatchEvent(new Events.VideoDimensionsChangedEvent(_this, oldValue, newValue));
45734
+ });
45735
+ widgetView.on('mediaStopped', track => {
45736
+ const event = new Events.MediaStoppedEvent(_this, track);
45737
+
45738
+ // When we have a disabled and transformed media track, we don't dispatch the event since
45739
+ // it is not a media source stop. This is the case when we call publishVideo(false) or
45740
+ // cycleVideo(), where the transformed track is stopped.
45741
+ const isDisabledTransformedTrack = (track == null ? void 0 : track.readyState) === 'ended' &&
45742
+ // Only transformed tracks have the writable property.
45743
+ // See: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrackGenerator/writable
45744
+ !!(track != null && track.writable);
45745
+ if (!isDisabledTransformedTrack) {
45746
+ _this.dispatchEvent(event);
45747
+ }
45748
+ if (event.isDefaultPrevented()) {
45749
+ return;
45750
+ }
45751
+ if (track) {
45752
+ const kind = String(track.kind).toLowerCase();
45753
+ // If we are publishing this kind when the track stops then
45754
+ // make sure we start publishing again if we switch to a new track
45755
+ if (kind === 'audio') {
45756
+ updateAudio();
45757
+ } else if (kind === 'video') {
45758
+ updateVideo();
45759
+ } else {
45760
+ logging.warn(`Track with invalid kind has ended: ${track.kind}`);
45761
+ }
45762
+ logAnalyticsEvent('mediaStopped', 'Event', {
45763
+ kind
45764
+ });
45765
+ return;
45766
+ }
45767
+ if (_this.session) {
45768
+ _this._.unpublishFromSession(_this.session, 'mediaStopped');
45761
45769
  } else {
45762
- logging.warn(`Track with invalid kind has ended: ${track.kind}`);
45770
+ _this.destroy('mediaStopped');
45763
45771
  }
45764
- logAnalyticsEvent('mediaStopped', 'Event', {
45765
- kind
45766
- });
45767
- return;
45768
- }
45769
- if (this.session) {
45770
- this._.unpublishFromSession(this.session, 'mediaStopped');
45771
- } else {
45772
- this.destroy('mediaStopped');
45773
- }
45774
- });
45775
- widgetView.on('videoElementCreated', element => {
45776
- this.dispatchEvent(new Events.MediaStreamAvailableEvent(webRTCStream));
45777
- const event = new Events.VideoElementCreatedEvent(element);
45778
- this.dispatchEvent(event);
45779
- });
45780
- getUserMedia().catch(userMediaError).then( /*#__PURE__*/function () {
45781
- var _ref30 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(stream) {
45782
- var _audioDevices, _videoDevices;
45783
- var hasVideoFilter, addAudioInputDevicesChangeListener, hasAudioVideoDevices;
45784
- return _regenerator.default.wrap(function _callee20$(_context20) {
45785
- while (1) switch (_context20.prev = _context20.next) {
45786
- case 0:
45787
- // this comes from deviceHelpers.shouldAskForDevices in a round-about way
45788
- audioDevices = processedOptions.audioDevices;
45789
- videoDevices = processedOptions.videoDevices;
45790
- hasVideoFilter = !!properties.videoFilter;
45791
- if (!properties.disableAudioInputDeviceManagement) {
45792
- // this is needed to refresh current audio input device after previous one was disconnected
45793
- addAudioInputDevicesChangeListener = addAudioInputDevicesChangeListenerFactory();
45794
- removeDeviceChangeListener = addAudioInputDevicesChangeListener(_this);
45795
- }
45796
- hasAudioVideoDevices = ((_audioDevices = audioDevices) == null ? void 0 : _audioDevices.length) > 0 || ((_videoDevices = videoDevices) == null ? void 0 : _videoDevices.length) > 0;
45797
- if (hasAudioVideoDevices) {
45798
- (0, _permissionListener.default)().then(listener => {
45799
- listener.on('accessDenied', device => {
45800
- _this.accessAllowed = false;
45801
- _this.dispatchEvent((0, _accessDeniedEvent.default)(device, 'during the call'));
45772
+ });
45773
+ widgetView.on('videoElementCreated', element => {
45774
+ _this.dispatchEvent(new Events.MediaStreamAvailableEvent(webRTCStream));
45775
+ const event = new Events.VideoElementCreatedEvent(element);
45776
+ _this.dispatchEvent(event);
45777
+ });
45778
+ getUserMedia().catch(err => {
45779
+ callback(err);
45780
+ userMediaError(err);
45781
+ }).then( /*#__PURE__*/function () {
45782
+ var _ref30 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(stream) {
45783
+ var _audioDevices, _videoDevices;
45784
+ var hasVideoFilter, addAudioInputDevicesChangeListener, hasAudioVideoDevices;
45785
+ return _regenerator.default.wrap(function _callee20$(_context20) {
45786
+ while (1) switch (_context20.prev = _context20.next) {
45787
+ case 0:
45788
+ // this comes from deviceHelpers.shouldAskForDevices in a round-about way
45789
+ audioDevices = processedOptions.audioDevices;
45790
+ videoDevices = processedOptions.videoDevices;
45791
+ hasVideoFilter = !!properties.videoFilter;
45792
+ if (!properties.disableAudioInputDeviceManagement) {
45793
+ // this is needed to refresh current audio input device after previous one was disconnected
45794
+ addAudioInputDevicesChangeListener = addAudioInputDevicesChangeListenerFactory();
45795
+ removeDeviceChangeListener = addAudioInputDevicesChangeListener(_this);
45796
+ }
45797
+ hasAudioVideoDevices = ((_audioDevices = audioDevices) == null ? void 0 : _audioDevices.length) > 0 || ((_videoDevices = videoDevices) == null ? void 0 : _videoDevices.length) > 0;
45798
+ if (hasAudioVideoDevices) {
45799
+ (0, _permissionListener.default)().then(listener => {
45800
+ listener.on('accessDenied', device => {
45801
+ _this.accessAllowed = false;
45802
+ const errorEvent = (0, _accessDeniedEvent.default)(device, 'during the call');
45803
+ _this.dispatchEvent(errorEvent);
45804
+ });
45802
45805
  });
45803
- });
45804
- }
45805
- if (hasVideoFilter) {
45806
- // We need to get the device now, before the filter is applied
45807
- // else the wrong device will be returned/nonsensical
45808
- currentDeviceId = (0, _getDeviceIdFromStream.default)(stream, videoDevices);
45809
- }
45810
- _context20.next = 9;
45811
- return onStreamAvailable(stream);
45812
- case 9:
45813
- if (!properties.publishVideo) {
45814
- _this._toggleVideo(properties.publishVideo, getVideoDimensions());
45815
- }
45816
- if (!isScreenSharing && !isCustomVideoTrack
45817
- // For filtered video, we stored the currentDeviceId already.
45818
- // (see note above)
45819
- && !hasVideoFilter) {
45820
- currentDeviceId = (0, _getDeviceIdFromStream.default)(stream, videoDevices);
45821
- if (properties.publishVideo) {
45822
- setCurrentTrackDeviceId(currentDeviceId);
45823
45806
  }
45824
- }
45825
- return _context20.abrupt("return", bindVideo().catch(error => {
45826
- if (error instanceof _cancel.CancellationError) {
45827
- // If we get a CancellationError, it means something newer tried
45828
- // to bindVideo before the old one succeeded, perhaps they called
45829
- // switchTracks.. It should be rare, and they shouldn't be doing
45830
- // this before loaded, but we'll handle it anyway.
45831
- return undefined;
45807
+ if (hasVideoFilter) {
45808
+ // We need to get the device now, before the filter is applied
45809
+ // else the wrong device will be returned/nonsensical
45810
+ currentDeviceId = (0, _getDeviceIdFromStream.default)(stream, videoDevices);
45832
45811
  }
45833
- throw error;
45834
- }).then(() => {
45835
- onLoaded();
45836
- if (!state.isDestroyed()) {
45837
- _this.trigger('initSuccess');
45838
- _this.trigger('loaded', _this);
45812
+ _context20.next = 9;
45813
+ return onStreamAvailable(stream);
45814
+ case 9:
45815
+ if (!properties.publishVideo) {
45816
+ _this._toggleVideo(properties.publishVideo, getVideoDimensions());
45839
45817
  }
45840
- }, err => {
45841
- logging.error(`OT.Publisher.publish failed to bind video: ${err}`);
45842
- onLoadFailure(err);
45843
- }));
45844
- case 12:
45845
- case "end":
45846
- return _context20.stop();
45847
- }
45848
- }, _callee20);
45849
- }));
45850
- return function (_x12) {
45851
- return _ref30.apply(this, arguments);
45852
- };
45853
- }());
45854
- });
45818
+ if (!isScreenSharing && !isCustomVideoTrack
45819
+ // For filtered video, we stored the currentDeviceId already.
45820
+ // (see note above)
45821
+ && !hasVideoFilter) {
45822
+ currentDeviceId = (0, _getDeviceIdFromStream.default)(stream, videoDevices);
45823
+ if (properties.publishVideo) {
45824
+ setCurrentTrackDeviceId(currentDeviceId);
45825
+ }
45826
+ }
45827
+ return _context20.abrupt("return", bindVideo().catch(error => {
45828
+ if (error instanceof _cancel.CancellationError) {
45829
+ // If we get a CancellationError, it means something newer tried
45830
+ // to bindVideo before the old one succeeded, perhaps they called
45831
+ // switchTracks.. It should be rare, and they shouldn't be doing
45832
+ // this before loaded, but we'll handle it anyway.
45833
+ return undefined;
45834
+ }
45835
+ throw error;
45836
+ }).then(() => {
45837
+ onLoaded();
45838
+ if (!state.isDestroyed()) {
45839
+ _this.trigger('initSuccess');
45840
+ _this.trigger('loaded', _this);
45841
+ callback();
45842
+ } else {
45843
+ callback(new Error('publisher destroyed'));
45844
+ }
45845
+ }, err => {
45846
+ logging.error(`OT.Publisher.publish failed to bind video: ${err}`);
45847
+ onLoadFailure(err);
45848
+ callback(err);
45849
+ }));
45850
+ case 12:
45851
+ case "end":
45852
+ return _context20.stop();
45853
+ }
45854
+ }, _callee20);
45855
+ }));
45856
+ return function (_x12) {
45857
+ return _ref30.apply(this, arguments);
45858
+ };
45859
+ }());
45860
+ });
45861
+ } catch (err) {
45862
+ callback(err);
45863
+ }
45864
+ };
45865
+ this.publish = targetElement => {
45866
+ publishWithCallback(targetElement);
45855
45867
  return this;
45856
45868
  };
45869
+ this.publish.promise = targetElement => new Promise((resolve, reject) => {
45870
+ publishWithCallback(targetElement, err => {
45871
+ if (err) {
45872
+ reject(err);
45873
+ } else {
45874
+ resolve(this);
45875
+ }
45876
+ });
45877
+ });
45857
45878
  this._getRoutedVideoSenders = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
45858
45879
  var routedPeerConnection;
45859
45880
  return _regenerator.default.wrap(function _callee21$(_context21) {
@@ -46022,6 +46043,30 @@ function PublisherFactory(_ref) {
46022
46043
  }
46023
46044
  refreshAudioVideoUI(activeReason);
46024
46045
  };
46046
+ const publishAudioWithCallback = function publishAudioWithCallback(value, callback) {
46047
+ if (callback === void 0) {
46048
+ callback = () => {};
46049
+ }
46050
+ logAnalyticsEvent('publishAudio', 'Attempt', {
46051
+ publishAudio: value
46052
+ });
46053
+ const attemptStart = Date.now();
46054
+ properties.publishAudio = value;
46055
+ try {
46056
+ updateAudio();
46057
+ logAnalyticsEvent('publishAudio', 'Success', {
46058
+ publishAudio: value
46059
+ }, {
46060
+ attemptDuration: Date.now() - attemptStart
46061
+ });
46062
+ callback();
46063
+ } catch (err) {
46064
+ logAnalyticsEvent('publishAudio', 'Failure', {
46065
+ message: err.message
46066
+ });
46067
+ callback(err);
46068
+ }
46069
+ };
46025
46070
 
46026
46071
  /**
46027
46072
  * Starts publishing audio (if it is currently not being published)
@@ -46038,26 +46083,44 @@ function PublisherFactory(_ref) {
46038
46083
  * @memberOf Publisher
46039
46084
  */
46040
46085
  this.publishAudio = value => {
46041
- logAnalyticsEvent('publishAudio', 'Attempt', {
46042
- publishAudio: value
46043
- });
46044
- const attemptStart = Date.now();
46045
- properties.publishAudio = value;
46046
- try {
46047
- updateAudio();
46048
- logAnalyticsEvent('publishAudio', 'Success', {
46049
- publishAudio: value
46050
- }, {
46051
- attemptDuration: Date.now() - attemptStart
46052
- });
46053
- } catch (e) {
46054
- logAnalyticsEvent('publishAudio', 'Failure', {
46055
- message: e.message
46056
- });
46057
- }
46086
+ publishAudioWithCallback(value);
46058
46087
  return this;
46059
46088
  };
46060
- const finishPublishCaptions = value => {
46089
+
46090
+ /**
46091
+ * Promise-based variant of {@link Publisher#publishAudio}.
46092
+ * Resolves when the session confirms the audio state change via a
46093
+ * <code>streamPropertyChanged</code> event, or rejects with an error if it fails.
46094
+ *
46095
+ * @param {Boolean} value Whether to start publishing audio (<code>true</code>)
46096
+ * or not (<code>false</code>).
46097
+ * @returns {Promise<void>} Resolves on success, rejects with an
46098
+ * <code><a href="Error.html">Error</a></code> on failure.
46099
+ *
46100
+ * @example
46101
+ * await publisher.publishAudio.promise(false);
46102
+ *
46103
+ * @method #publishAudio.promise
46104
+ * @memberOf Publisher
46105
+ */
46106
+ this.publishAudio.promise = value => new Promise((resolve, reject) => {
46107
+ if (!this.session) {
46108
+ reject(new Error('Cannot publish audio before publishing to a session'));
46109
+ return;
46110
+ }
46111
+ if (properties.publishAudio === value) {
46112
+ resolve();
46113
+ return;
46114
+ }
46115
+ publishAudioWithCallback(value, err => {
46116
+ if (err) {
46117
+ reject(err);
46118
+ } else {
46119
+ resolve();
46120
+ }
46121
+ });
46122
+ });
46123
+ const finishPublishCaptions = (value, resolve, reject) => {
46061
46124
  try {
46062
46125
  privateEvents.dispatchEvent(new Events.PublisherCaptionsEnabled(value));
46063
46126
  this.stream.setChannelActiveState({
@@ -46067,11 +46130,13 @@ function PublisherFactory(_ref) {
46067
46130
  logAnalyticsEvent('publishCaptions', 'Success', {
46068
46131
  publishCaptions: value
46069
46132
  });
46133
+ resolve();
46070
46134
  } catch (e) {
46071
46135
  logAnalyticsEvent('publishCaptions', 'Failure', {
46072
46136
  message: e.message,
46073
46137
  publishCaptions: value
46074
46138
  });
46139
+ reject(e);
46075
46140
  }
46076
46141
  };
46077
46142
 
@@ -46096,20 +46161,20 @@ function PublisherFactory(_ref) {
46096
46161
  * @see <a href="Subscriber.html#isSubscribedToCaptions">isSubscribedToCaptions()</a>
46097
46162
  * @see <a href="Stream.html#hasCaptions">Stream.hasCaptions</a>
46098
46163
  * @see StreamPropertyChangedEvent
46164
+ * @returns {Promise}
46099
46165
  * @method #publishCaptions
46100
46166
  * @memberOf Publisher
46101
46167
  */
46102
-
46103
- this.publishCaptions = value => {
46168
+ this.publishCaptions = value => new Promise((resolve, reject) => {
46104
46169
  logAnalyticsEvent('publishCaptions', 'Attempt', {
46105
46170
  publishCaptions: value
46106
46171
  });
46107
46172
  if (this.stream) {
46108
- finishPublishCaptions(value);
46173
+ finishPublishCaptions(value, resolve, reject);
46109
46174
  } else {
46110
- streamReadyJobs.add(() => finishPublishCaptions(value));
46175
+ streamReadyJobs.add(() => finishPublishCaptions(value, resolve, reject));
46111
46176
  }
46112
- };
46177
+ });
46113
46178
  let updateVideoSenderParametersSentinel;
46114
46179
 
46115
46180
  // keeps track of if the client has called mediaStreamTrack.stop(), so that we don't restart
@@ -46606,6 +46671,31 @@ function PublisherFactory(_ref) {
46606
46671
  });
46607
46672
  return this;
46608
46673
  };
46674
+
46675
+ /**
46676
+ * Promise-based variant of {@link Publisher#publishVideo}.
46677
+ * Resolves when the operation completes, or rejects with an error if it fails.
46678
+ *
46679
+ * @param {Boolean} value Whether to start publishing video (<code>true</code>)
46680
+ * or not (<code>false</code>).
46681
+ * @returns {Promise<void>} Resolves on success, rejects with an
46682
+ * <code><a href="Error.html">Error</a></code> on failure.
46683
+ *
46684
+ * @example
46685
+ * await publisher.publishVideo.promise(true);
46686
+ *
46687
+ * @method #publishVideo.promise
46688
+ * @memberOf Publisher
46689
+ */
46690
+ this.publishVideo.promise = value => new Promise((resolve, reject) => {
46691
+ this.publishVideo(value, err => {
46692
+ if (err) {
46693
+ reject(err);
46694
+ } else {
46695
+ resolve();
46696
+ }
46697
+ });
46698
+ });
46609
46699
  this._publishVideo = /*#__PURE__*/function () {
46610
46700
  var _ref44 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee32(value) {
46611
46701
  var videoDimensions;
@@ -46685,7 +46775,7 @@ function PublisherFactory(_ref) {
46685
46775
  _targetContentHint = videoContentHint;
46686
46776
  (0, _videoContentHint.setVideoContentHint)(webRTCStream, videoContentHint);
46687
46777
  if (changedStaticContent || isScreenSharing && properties._setDefaultScalabilityMode) {
46688
- configureScalabilityMode();
46778
+ configureScalabilityMode().catch(() => {});
46689
46779
  }
46690
46780
  };
46691
46781
 
@@ -46731,11 +46821,30 @@ function PublisherFactory(_ref) {
46731
46821
  * @memberOf Publisher
46732
46822
  */
46733
46823
  this.setTargetScalabilityMode = scalabilityMode => {
46824
+ logAnalyticsEvent('setTargetScalabilityMode', 'Attempt', undefined, {
46825
+ targetScalabilityMode: scalabilityMode
46826
+ });
46734
46827
  if (!VALID_TARGET_SCALABILITY_MODES.has(scalabilityMode)) {
46735
- throw otError(Errors.INVALID_PARAMETER, new Error(INVALID_TARGET_SCALABILITY_MODE_MESSAGE));
46828
+ const error = otError(Errors.INVALID_PARAMETER, new Error(INVALID_TARGET_SCALABILITY_MODE_MESSAGE));
46829
+ logAnalyticsEvent('setTargetScalabilityMode', 'Failure', {
46830
+ message: error.message
46831
+ }, {
46832
+ targetScalabilityMode: scalabilityMode
46833
+ });
46834
+ throw error;
46736
46835
  }
46737
46836
  _targetScalabilityMode = scalabilityMode;
46738
- configureScalabilityMode();
46837
+ configureScalabilityMode().then(() => {
46838
+ logAnalyticsEvent('setTargetScalabilityMode', 'Success', undefined, {
46839
+ targetScalabilityMode: scalabilityMode
46840
+ });
46841
+ }).catch(err => {
46842
+ logAnalyticsEvent('setTargetScalabilityMode', 'Failure', {
46843
+ message: err.message
46844
+ }, {
46845
+ targetScalabilityMode: scalabilityMode
46846
+ });
46847
+ });
46739
46848
  };
46740
46849
 
46741
46850
  /**
@@ -47401,7 +47510,7 @@ function PublisherFactory(_ref) {
47401
47510
  let shouldRePublishVideo = false;
47402
47511
  if (properties.publishVideo && document.hidden) {
47403
47512
  shouldRePublishVideo = true;
47404
- // turning the video off to prevent that videotrack is ended
47513
+ // Turning the video off to prevent that videotrack is ended.
47405
47514
  this.publishVideo(false);
47406
47515
  }
47407
47516
  // trigger the handler onVisibilityChange
@@ -48032,7 +48141,7 @@ function PublisherFactory(_ref) {
48032
48141
  }
48033
48142
  this._setScalableFramerates(properties.scalableFramerates);
48034
48143
  this._setScalableVideoLayers(properties.scalableVideoLayers);
48035
- configureScalabilityMode();
48144
+ configureScalabilityMode().catch(() => {});
48036
48145
 
48037
48146
  // See OPENTOK-45935
48038
48147
  // Some users reuse the publisher when disconnecting and reconnecting