livekit-client 1.11.0 → 1.11.1

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.
@@ -14187,7 +14187,7 @@ function getMatch(exp, ua) {
14187
14187
  return match && match.length >= id && match[id] || '';
14188
14188
  }
14189
14189
 
14190
- var version$1 = "1.11.0";
14190
+ var version$1 = "1.11.1";
14191
14191
 
14192
14192
  const version = version$1;
14193
14193
  const protocolVersion = 9;
@@ -18377,8 +18377,56 @@ class LocalTrack extends Track {
18377
18377
  if (this.isInBackground) {
18378
18378
  this.reacquireTrack = true;
18379
18379
  }
18380
+ this._mediaStreamTrack.removeEventListener('mute', this.pauseUpstream);
18381
+ this._mediaStreamTrack.removeEventListener('unmute', this.resumeUpstream);
18380
18382
  this.emit(TrackEvent.Ended, this);
18381
18383
  };
18384
+ /**
18385
+ * pauses publishing to the server without disabling the local MediaStreamTrack
18386
+ * this is used to display a user's own video locally while pausing publishing to
18387
+ * the server.
18388
+ * this API is unsupported on Safari < 12 due to a bug
18389
+ **/
18390
+ this.pauseUpstream = () => __awaiter(this, void 0, void 0, function* () {
18391
+ const unlock = yield this.pauseUpstreamLock.lock();
18392
+ try {
18393
+ if (this._isUpstreamPaused === true) {
18394
+ return;
18395
+ }
18396
+ if (!this.sender) {
18397
+ livekitLogger.warn('unable to pause upstream for an unpublished track');
18398
+ return;
18399
+ }
18400
+ this._isUpstreamPaused = true;
18401
+ this.emit(TrackEvent.UpstreamPaused, this);
18402
+ const browser = getBrowser();
18403
+ if ((browser === null || browser === void 0 ? void 0 : browser.name) === 'Safari' && compareVersions(browser.version, '12.0') < 0) {
18404
+ // https://bugs.webkit.org/show_bug.cgi?id=184911
18405
+ throw new DeviceUnsupportedError('pauseUpstream is not supported on Safari < 12.');
18406
+ }
18407
+ yield this.sender.replaceTrack(null);
18408
+ } finally {
18409
+ unlock();
18410
+ }
18411
+ });
18412
+ this.resumeUpstream = () => __awaiter(this, void 0, void 0, function* () {
18413
+ const unlock = yield this.pauseUpstreamLock.lock();
18414
+ try {
18415
+ if (this._isUpstreamPaused === false) {
18416
+ return;
18417
+ }
18418
+ if (!this.sender) {
18419
+ livekitLogger.warn('unable to resume upstream for an unpublished track');
18420
+ return;
18421
+ }
18422
+ this._isUpstreamPaused = false;
18423
+ this.emit(TrackEvent.UpstreamResumed, this);
18424
+ // this operation is noop if mediastreamtrack is already being sent
18425
+ yield this.sender.replaceTrack(this._mediaStreamTrack);
18426
+ } finally {
18427
+ unlock();
18428
+ }
18429
+ });
18382
18430
  this.reacquireTrack = false;
18383
18431
  this.providedByUser = userProvidedTrack;
18384
18432
  this.muteLock = new Mutex();
@@ -18444,10 +18492,7 @@ class LocalTrack extends Track {
18444
18492
  // the track is "muted"
18445
18493
  // note this is different from LocalTrack.mute because we do not want to
18446
18494
  // touch MediaStreamTrack.enabled
18447
- newTrack.addEventListener('mute', () => {
18448
- livekitLogger.info('pausing upstream due to device mute');
18449
- this.pauseUpstream();
18450
- });
18495
+ newTrack.addEventListener('mute', this.pauseUpstream);
18451
18496
  newTrack.addEventListener('unmute', this.resumeUpstream);
18452
18497
  this.constraints = newTrack.getConstraints();
18453
18498
  }
@@ -18605,59 +18650,12 @@ class LocalTrack extends Track {
18605
18650
  stop() {
18606
18651
  var _a;
18607
18652
  super.stop();
18653
+ this._mediaStreamTrack.removeEventListener('ended', this.handleEnded);
18654
+ this._mediaStreamTrack.removeEventListener('mute', this.pauseUpstream);
18655
+ this._mediaStreamTrack.removeEventListener('unmute', this.resumeUpstream);
18608
18656
  (_a = this.processor) === null || _a === void 0 ? void 0 : _a.destroy();
18609
18657
  this.processor = undefined;
18610
18658
  }
18611
- /**
18612
- * pauses publishing to the server without disabling the local MediaStreamTrack
18613
- * this is used to display a user's own video locally while pausing publishing to
18614
- * the server.
18615
- * this API is unsupported on Safari < 12 due to a bug
18616
- **/
18617
- pauseUpstream() {
18618
- return __awaiter(this, void 0, void 0, function* () {
18619
- const unlock = yield this.pauseUpstreamLock.lock();
18620
- try {
18621
- if (this._isUpstreamPaused === true) {
18622
- return;
18623
- }
18624
- if (!this.sender) {
18625
- livekitLogger.warn('unable to pause upstream for an unpublished track');
18626
- return;
18627
- }
18628
- this._isUpstreamPaused = true;
18629
- this.emit(TrackEvent.UpstreamPaused, this);
18630
- const browser = getBrowser();
18631
- if ((browser === null || browser === void 0 ? void 0 : browser.name) === 'Safari' && compareVersions(browser.version, '12.0') < 0) {
18632
- // https://bugs.webkit.org/show_bug.cgi?id=184911
18633
- throw new DeviceUnsupportedError('pauseUpstream is not supported on Safari < 12.');
18634
- }
18635
- yield this.sender.replaceTrack(null);
18636
- } finally {
18637
- unlock();
18638
- }
18639
- });
18640
- }
18641
- resumeUpstream() {
18642
- return __awaiter(this, void 0, void 0, function* () {
18643
- const unlock = yield this.pauseUpstreamLock.lock();
18644
- try {
18645
- if (this._isUpstreamPaused === false) {
18646
- return;
18647
- }
18648
- if (!this.sender) {
18649
- livekitLogger.warn('unable to resume upstream for an unpublished track');
18650
- return;
18651
- }
18652
- this._isUpstreamPaused = false;
18653
- this.emit(TrackEvent.UpstreamResumed, this);
18654
- // this operation is noop if mediastreamtrack is already being sent
18655
- yield this.sender.replaceTrack(this._mediaStreamTrack);
18656
- } finally {
18657
- unlock();
18658
- }
18659
- });
18660
- }
18661
18659
  /**
18662
18660
  * Sets a processor on this track.
18663
18661
  * See https://github.com/livekit/track-processors-js for example usage