@dtelecom/livekit-client 1.12.19 → 1.12.21

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.
@@ -14198,7 +14198,7 @@ function getMatch(exp, ua) {
14198
14198
  return match && match.length >= id && match[id] || '';
14199
14199
  }
14200
14200
 
14201
- var version$1 = "1.12.19";
14201
+ var version$1 = "1.12.21";
14202
14202
 
14203
14203
  const version = version$1;
14204
14204
  const protocolVersion = 9;
@@ -19516,16 +19516,19 @@ class RTCEngine extends EventEmitter {
19516
19516
  }
19517
19517
  this.setupSignalClientCallbacks();
19518
19518
  this.clientConfiguration = joinResponse.clientConfiguration;
19519
+ this.joinAttempts = 0;
19519
19520
  return joinResponse;
19520
19521
  } catch (e) {
19521
- if (e instanceof ConnectionError) {
19522
+ if (e instanceof ConnectionError && navigator.onLine === true) {
19522
19523
  if (e.reason === 1 /* ConnectionErrorReason.ServerUnreachable */) {
19523
- livekitLogger.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts, " of ").concat(this.maxJoinAttempts));
19524
- if (this.joinAttempts < this.maxJoinAttempts) {
19524
+ if (this.joinAttempts <= this.maxJoinAttempts) {
19525
+ yield sleep(220 * this.joinAttempts);
19526
+ livekitLogger.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts, " of ").concat(this.maxJoinAttempts));
19525
19527
  return this.join(url, token, opts, abortSignal);
19526
19528
  }
19527
19529
  }
19528
19530
  }
19531
+ this.joinAttempts = 0;
19529
19532
  throw e;
19530
19533
  }
19531
19534
  });
@@ -20015,7 +20018,7 @@ class RTCEngine extends EventEmitter {
20015
20018
  return null;
20016
20019
  }
20017
20020
  restartConnection(regionUrl) {
20018
- var _a, _b, _c, _d, _e;
20021
+ var _a, _b, _c, _d, _e, _f, _g;
20019
20022
  return __awaiter(this, void 0, void 0, function* () {
20020
20023
  try {
20021
20024
  if (!this.url || !this.token) {
@@ -20055,7 +20058,13 @@ class RTCEngine extends EventEmitter {
20055
20058
  // reconnect success
20056
20059
  this.emit(EngineEvent.Restarted);
20057
20060
  } catch (error) {
20058
- let nextRegionUrl = yield (_c = this.regionUrlProvider) === null || _c === void 0 ? void 0 : _c.getNextBestRegionUrl();
20061
+ // Check if browser is offline first - no point cycling regions if offline
20062
+ if (navigator.onLine === false) {
20063
+ (_c = this.regionUrlProvider) === null || _c === void 0 ? void 0 : _c.resetAttempts();
20064
+ (_d = this.fallbackUrlProvider) === null || _d === void 0 ? void 0 : _d.resetAttempts();
20065
+ throw error;
20066
+ }
20067
+ let nextRegionUrl = yield (_e = this.regionUrlProvider) === null || _e === void 0 ? void 0 : _e.getNextBestRegionUrl();
20059
20068
  if (this.fallbackUrlProvider && !nextRegionUrl) {
20060
20069
  nextRegionUrl = this.fallbackUrlProvider.getNextUrl();
20061
20070
  }
@@ -20064,8 +20073,8 @@ class RTCEngine extends EventEmitter {
20064
20073
  return;
20065
20074
  } else {
20066
20075
  // no more regions to try (or we're not on cloud)
20067
- (_d = this.regionUrlProvider) === null || _d === void 0 ? void 0 : _d.resetAttempts();
20068
- (_e = this.fallbackUrlProvider) === null || _e === void 0 ? void 0 : _e.resetAttempts();
20076
+ (_f = this.regionUrlProvider) === null || _f === void 0 ? void 0 : _f.resetAttempts();
20077
+ (_g = this.fallbackUrlProvider) === null || _g === void 0 ? void 0 : _g.resetAttempts();
20069
20078
  throw error;
20070
20079
  }
20071
20080
  }
@@ -22408,7 +22417,7 @@ class LocalParticipant extends Participant {
22408
22417
  });
22409
22418
  }
22410
22419
  publish(track, opts, options, isStereo) {
22411
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
22420
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
22412
22421
  return __awaiter(this, void 0, void 0, function* () {
22413
22422
  const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => track instanceof LocalTrack && publishedTrack.source === track.source);
22414
22423
  if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
@@ -22456,8 +22465,8 @@ class LocalParticipant extends Participant {
22456
22465
  source: Track.sourceToProto(track.source),
22457
22466
  disableDtx: !((_a = opts.dtx) !== null && _a !== void 0 ? _a : true),
22458
22467
  encryption: this.encryptionType,
22459
- stereo: isStereo
22460
- // disableRed: !(opts.red ?? true),
22468
+ stereo: isStereo,
22469
+ disableRed: !((_b = opts.red) !== null && _b !== void 0 ? _b : true)
22461
22470
  });
22462
22471
  // compute encodings and layers for video
22463
22472
  let encodings;
@@ -22472,7 +22481,7 @@ class LocalParticipant extends Participant {
22472
22481
  } catch (e) {
22473
22482
  // use defaults, it's quite painful for congestion control without simulcast
22474
22483
  // so using default dims according to publish settings
22475
- const defaultRes = (_c = (_b = this.roomOptions.videoCaptureDefaults) === null || _b === void 0 ? void 0 : _b.resolution) !== null && _c !== void 0 ? _c : VideoPresets.h720.resolution;
22484
+ const defaultRes = (_d = (_c = this.roomOptions.videoCaptureDefaults) === null || _c === void 0 ? void 0 : _c.resolution) !== null && _d !== void 0 ? _d : VideoPresets.h720.resolution;
22476
22485
  dims = {
22477
22486
  width: defaultRes.width,
22478
22487
  height: defaultRes.height
@@ -22487,7 +22496,7 @@ class LocalParticipant extends Participant {
22487
22496
  if (track instanceof LocalVideoTrack) {
22488
22497
  if (isSVCCodec(opts.videoCodec)) {
22489
22498
  // set scalabilityMode to 'L3T3_KEY' by default
22490
- opts.scalabilityMode = (_d = opts.scalabilityMode) !== null && _d !== void 0 ? _d : 'L3T3_KEY';
22499
+ opts.scalabilityMode = (_e = opts.scalabilityMode) !== null && _e !== void 0 ? _e : 'L3T3_KEY';
22491
22500
  }
22492
22501
  // set up backup
22493
22502
  if (opts.videoCodec && opts.backupCodec && opts.videoCodec !== opts.backupCodec.codec) {
@@ -22509,7 +22518,7 @@ class LocalParticipant extends Participant {
22509
22518
  req.simulcastCodecs = [{
22510
22519
  codec: opts.videoCodec,
22511
22520
  cid: track.mediaStreamTrack.id,
22512
- enableSimulcastLayers: (_e = opts.simulcast) !== null && _e !== void 0 ? _e : false
22521
+ enableSimulcastLayers: (_f = opts.simulcast) !== null && _f !== void 0 ? _f : false
22513
22522
  }];
22514
22523
  }
22515
22524
  }
@@ -22517,9 +22526,9 @@ class LocalParticipant extends Participant {
22517
22526
  req.layers = videoLayersFromEncodings(req.width, req.height, encodings, isSVCCodec(opts.videoCodec));
22518
22527
  } else if (track.kind === Track.Kind.Audio) {
22519
22528
  encodings = [{
22520
- maxBitrate: (_g = (_f = opts.audioPreset) === null || _f === void 0 ? void 0 : _f.maxBitrate) !== null && _g !== void 0 ? _g : opts.audioBitrate,
22521
- priority: (_j = (_h = opts.audioPreset) === null || _h === void 0 ? void 0 : _h.priority) !== null && _j !== void 0 ? _j : 'high',
22522
- networkPriority: (_l = (_k = opts.audioPreset) === null || _k === void 0 ? void 0 : _k.priority) !== null && _l !== void 0 ? _l : 'high'
22529
+ maxBitrate: (_h = (_g = opts.audioPreset) === null || _g === void 0 ? void 0 : _g.maxBitrate) !== null && _h !== void 0 ? _h : opts.audioBitrate,
22530
+ priority: (_k = (_j = opts.audioPreset) === null || _j === void 0 ? void 0 : _j.priority) !== null && _k !== void 0 ? _k : 'high',
22531
+ networkPriority: (_m = (_l = opts.audioPreset) === null || _l === void 0 ? void 0 : _l.priority) !== null && _m !== void 0 ? _m : 'high'
22523
22532
  }];
22524
22533
  }
22525
22534
  if (!this.engine || this.engine.isClosed) {
@@ -22581,10 +22590,10 @@ class LocalParticipant extends Participant {
22581
22590
  this.engine.publisher.setTrackCodecBitrate({
22582
22591
  transceiver: trackTransceiver,
22583
22592
  codec: 'opus',
22584
- maxbr: ((_m = encodings[0]) === null || _m === void 0 ? void 0 : _m.maxBitrate) ? encodings[0].maxBitrate / 1000 : 0
22593
+ maxbr: ((_o = encodings[0]) === null || _o === void 0 ? void 0 : _o.maxBitrate) ? encodings[0].maxBitrate / 1000 : 0
22585
22594
  });
22586
22595
  }
22587
- } else if (track.codec && isSVCCodec(track.codec) && ((_o = encodings[0]) === null || _o === void 0 ? void 0 : _o.maxBitrate)) {
22596
+ } else if (track.codec && isSVCCodec(track.codec) && ((_p = encodings[0]) === null || _p === void 0 ? void 0 : _p.maxBitrate)) {
22588
22597
  this.engine.publisher.setTrackCodecBitrate({
22589
22598
  cid: req.cid,
22590
22599
  codec: track.codec,