@dtelecom/livekit-client 1.12.20 → 1.12.22

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.
@@ -3647,8 +3647,12 @@ Reader$1.prototype.bytes = function read_bytes() {
3647
3647
  if (Array.isArray(this.buf))
3648
3648
  // plain array
3649
3649
  return this.buf.slice(start, end);
3650
- return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
3651
- ? new this.buf.constructor(0) : this._slice.call(this.buf, start, end);
3650
+ if (start === end) {
3651
+ // fix for IE 10/Win8 and others' subarray returning array of size 1
3652
+ var nativeBuffer = util$2.Buffer;
3653
+ return nativeBuffer ? nativeBuffer.alloc(0) : new this.buf.constructor(0);
3654
+ }
3655
+ return this._slice.call(this.buf, start, end);
3652
3656
  };
3653
3657
 
3654
3658
  /**
@@ -14198,7 +14202,7 @@ function getMatch(exp, ua) {
14198
14202
  return match && match.length >= id && match[id] || '';
14199
14203
  }
14200
14204
 
14201
- var version$1 = "1.12.20";
14205
+ var version$1 = "1.12.22";
14202
14206
 
14203
14207
  const version = version$1;
14204
14208
  const protocolVersion = 9;
@@ -15724,8 +15728,18 @@ class SignalClient {
15724
15728
  const clientInfo = getClientInfo();
15725
15729
  const params = createConnectionParams(token, clientInfo, opts);
15726
15730
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
15731
+ const cleanup = () => {
15732
+ clearTimeout(wsTimeout);
15733
+ abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
15734
+ };
15735
+ const wsTimeout = setTimeout(() => {
15736
+ livekitLogger.debug('websocket connection timeout');
15737
+ cleanup();
15738
+ reject(new ConnectionError(opts.reconnect ? 'signal reconnect timed out' : 'signal connection timed out', 1 /* ConnectionErrorReason.ServerUnreachable */));
15739
+ }, opts.websocketTimeout || 3000);
15727
15740
  const abortHandler = () => __awaiter(this, void 0, void 0, function* () {
15728
15741
  this.close();
15742
+ cleanup();
15729
15743
  reject(new ConnectionError('room connection has been cancelled (signal)'));
15730
15744
  });
15731
15745
  if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
@@ -15750,8 +15764,9 @@ class SignalClient {
15750
15764
  }
15751
15765
  } catch (e) {
15752
15766
  reject(new ConnectionError('server was not reachable', 1 /* ConnectionErrorReason.ServerUnreachable */));
15767
+ } finally {
15768
+ cleanup();
15753
15769
  }
15754
-
15755
15770
  return;
15756
15771
  }
15757
15772
  // other errors, handle
@@ -15775,7 +15790,7 @@ class SignalClient {
15775
15790
  // handle join message only
15776
15791
  if (((_a = resp.message) === null || _a === void 0 ? void 0 : _a.$case) === 'join') {
15777
15792
  this.isConnected = true;
15778
- abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
15793
+ cleanup();
15779
15794
  this.pingTimeoutDuration = resp.message.join.pingTimeout;
15780
15795
  this.pingIntervalDuration = resp.message.join.pingInterval;
15781
15796
  if (this.pingTimeoutDuration && this.pingTimeoutDuration > 0) {
@@ -15789,7 +15804,7 @@ class SignalClient {
15789
15804
  } else if (opts.reconnect) {
15790
15805
  // in reconnecting, any message received means signal reconnected
15791
15806
  this.isConnected = true;
15792
- abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
15807
+ cleanup();
15793
15808
  this.startPingInterval();
15794
15809
  if (((_b = resp.message) === null || _b === void 0 ? void 0 : _b.$case) === 'reconnect') {
15795
15810
  resolve((_c = resp.message) === null || _c === void 0 ? void 0 : _c.reconnect);
@@ -17171,6 +17186,34 @@ class E2EEManager extends EventEmitter {
17171
17186
  }
17172
17187
  }
17173
17188
 
17189
+ class FallbackUrlProvider {
17190
+ constructor(fallbackUrls) {
17191
+ this.attemptedUrls = [];
17192
+ this.fallbackUrls = fallbackUrls;
17193
+ }
17194
+ isAvailable() {
17195
+ return this.fallbackUrls && this.fallbackUrls.length > 0;
17196
+ }
17197
+ getNextUrl() {
17198
+ var _a;
17199
+ if (!this.isAvailable()) {
17200
+ throw Error('no fallback urls proviced');
17201
+ }
17202
+ const urlsLeft = (_a = this.fallbackUrls) === null || _a === void 0 ? void 0 : _a.filter(url => !this.attemptedUrls.find(attempted => attempted === url));
17203
+ if (urlsLeft && urlsLeft.length > 0) {
17204
+ const nextUrl = urlsLeft[0];
17205
+ this.attemptedUrls.push(nextUrl);
17206
+ livekitLogger.debug("next url: ".concat(nextUrl));
17207
+ return nextUrl;
17208
+ } else {
17209
+ return null;
17210
+ }
17211
+ }
17212
+ resetAttempts() {
17213
+ this.attemptedUrls = [];
17214
+ }
17215
+ }
17216
+
17174
17217
  var parser$1 = {};
17175
17218
 
17176
17219
  var grammar$2 = {exports: {}};
@@ -19274,38 +19317,11 @@ function videoLayersFromEncodings(width, height, encodings, svc) {
19274
19317
  });
19275
19318
  }
19276
19319
 
19277
- class FallbackUrlProvider {
19278
- constructor(fallbackUrls) {
19279
- this.attemptedUrls = [];
19280
- this.fallbackUrls = fallbackUrls;
19281
- }
19282
- isAvailable() {
19283
- return this.fallbackUrls && this.fallbackUrls.length > 0;
19284
- }
19285
- getNextUrl() {
19286
- var _a;
19287
- if (!this.isAvailable()) {
19288
- throw Error('no fallback urls proviced');
19289
- }
19290
- const urlsLeft = (_a = this.fallbackUrls) === null || _a === void 0 ? void 0 : _a.filter(url => !this.attemptedUrls.find(attempted => attempted === url));
19291
- if (urlsLeft && urlsLeft.length > 0) {
19292
- const nextUrl = urlsLeft[0];
19293
- this.attemptedUrls.push(nextUrl);
19294
- livekitLogger.debug("next url: ".concat(nextUrl));
19295
- return nextUrl;
19296
- } else {
19297
- return null;
19298
- }
19299
- }
19300
- resetAttempts() {
19301
- this.attemptedUrls = [];
19302
- }
19303
- }
19304
-
19305
19320
  const lossyDataChannel = '_lossy';
19306
19321
  const reliableDataChannel = '_reliable';
19307
19322
  const minReconnectWait = 2 * 1000;
19308
19323
  const leaveReconnect = 'leave-reconnect';
19324
+ const joinRetryDelayMs = 750;
19309
19325
  var PCState;
19310
19326
  (function (PCState) {
19311
19327
  PCState[PCState["New"] = 0] = "New";
@@ -19522,7 +19538,7 @@ class RTCEngine extends EventEmitter {
19522
19538
  if (e instanceof ConnectionError && navigator.onLine === true) {
19523
19539
  if (e.reason === 1 /* ConnectionErrorReason.ServerUnreachable */) {
19524
19540
  if (this.joinAttempts <= this.maxJoinAttempts) {
19525
- yield sleep(220 * this.joinAttempts);
19541
+ yield sleep(Math.min(joinRetryDelayMs * this.joinAttempts, 2000));
19526
19542
  livekitLogger.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts, " of ").concat(this.maxJoinAttempts));
19527
19543
  return this.join(url, token, opts, abortSignal);
19528
19544
  }
@@ -22417,7 +22433,7 @@ class LocalParticipant extends Participant {
22417
22433
  });
22418
22434
  }
22419
22435
  publish(track, opts, options, isStereo) {
22420
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
22436
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
22421
22437
  return __awaiter(this, void 0, void 0, function* () {
22422
22438
  const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => track instanceof LocalTrack && publishedTrack.source === track.source);
22423
22439
  if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
@@ -22465,8 +22481,8 @@ class LocalParticipant extends Participant {
22465
22481
  source: Track.sourceToProto(track.source),
22466
22482
  disableDtx: !((_a = opts.dtx) !== null && _a !== void 0 ? _a : true),
22467
22483
  encryption: this.encryptionType,
22468
- stereo: isStereo
22469
- // disableRed: !(opts.red ?? true),
22484
+ stereo: isStereo,
22485
+ disableRed: !((_b = opts.red) !== null && _b !== void 0 ? _b : true)
22470
22486
  });
22471
22487
  // compute encodings and layers for video
22472
22488
  let encodings;
@@ -22481,7 +22497,7 @@ class LocalParticipant extends Participant {
22481
22497
  } catch (e) {
22482
22498
  // use defaults, it's quite painful for congestion control without simulcast
22483
22499
  // so using default dims according to publish settings
22484
- const defaultRes = (_c = (_b = this.roomOptions.videoCaptureDefaults) === null || _b === void 0 ? void 0 : _b.resolution) !== null && _c !== void 0 ? _c : VideoPresets.h720.resolution;
22500
+ const defaultRes = (_d = (_c = this.roomOptions.videoCaptureDefaults) === null || _c === void 0 ? void 0 : _c.resolution) !== null && _d !== void 0 ? _d : VideoPresets.h720.resolution;
22485
22501
  dims = {
22486
22502
  width: defaultRes.width,
22487
22503
  height: defaultRes.height
@@ -22496,7 +22512,7 @@ class LocalParticipant extends Participant {
22496
22512
  if (track instanceof LocalVideoTrack) {
22497
22513
  if (isSVCCodec(opts.videoCodec)) {
22498
22514
  // set scalabilityMode to 'L3T3_KEY' by default
22499
- opts.scalabilityMode = (_d = opts.scalabilityMode) !== null && _d !== void 0 ? _d : 'L3T3_KEY';
22515
+ opts.scalabilityMode = (_e = opts.scalabilityMode) !== null && _e !== void 0 ? _e : 'L3T3_KEY';
22500
22516
  }
22501
22517
  // set up backup
22502
22518
  if (opts.videoCodec && opts.backupCodec && opts.videoCodec !== opts.backupCodec.codec) {
@@ -22518,7 +22534,7 @@ class LocalParticipant extends Participant {
22518
22534
  req.simulcastCodecs = [{
22519
22535
  codec: opts.videoCodec,
22520
22536
  cid: track.mediaStreamTrack.id,
22521
- enableSimulcastLayers: (_e = opts.simulcast) !== null && _e !== void 0 ? _e : false
22537
+ enableSimulcastLayers: (_f = opts.simulcast) !== null && _f !== void 0 ? _f : false
22522
22538
  }];
22523
22539
  }
22524
22540
  }
@@ -22526,9 +22542,9 @@ class LocalParticipant extends Participant {
22526
22542
  req.layers = videoLayersFromEncodings(req.width, req.height, encodings, isSVCCodec(opts.videoCodec));
22527
22543
  } else if (track.kind === Track.Kind.Audio) {
22528
22544
  encodings = [{
22529
- maxBitrate: (_g = (_f = opts.audioPreset) === null || _f === void 0 ? void 0 : _f.maxBitrate) !== null && _g !== void 0 ? _g : opts.audioBitrate,
22530
- priority: (_j = (_h = opts.audioPreset) === null || _h === void 0 ? void 0 : _h.priority) !== null && _j !== void 0 ? _j : 'high',
22531
- networkPriority: (_l = (_k = opts.audioPreset) === null || _k === void 0 ? void 0 : _k.priority) !== null && _l !== void 0 ? _l : 'high'
22545
+ maxBitrate: (_h = (_g = opts.audioPreset) === null || _g === void 0 ? void 0 : _g.maxBitrate) !== null && _h !== void 0 ? _h : opts.audioBitrate,
22546
+ priority: (_k = (_j = opts.audioPreset) === null || _j === void 0 ? void 0 : _j.priority) !== null && _k !== void 0 ? _k : 'high',
22547
+ networkPriority: (_m = (_l = opts.audioPreset) === null || _l === void 0 ? void 0 : _l.priority) !== null && _m !== void 0 ? _m : 'high'
22532
22548
  }];
22533
22549
  }
22534
22550
  if (!this.engine || this.engine.isClosed) {
@@ -22590,10 +22606,10 @@ class LocalParticipant extends Participant {
22590
22606
  this.engine.publisher.setTrackCodecBitrate({
22591
22607
  transceiver: trackTransceiver,
22592
22608
  codec: 'opus',
22593
- maxbr: ((_m = encodings[0]) === null || _m === void 0 ? void 0 : _m.maxBitrate) ? encodings[0].maxBitrate / 1000 : 0
22609
+ maxbr: ((_o = encodings[0]) === null || _o === void 0 ? void 0 : _o.maxBitrate) ? encodings[0].maxBitrate / 1000 : 0
22594
22610
  });
22595
22611
  }
22596
- } else if (track.codec && isSVCCodec(track.codec) && ((_o = encodings[0]) === null || _o === void 0 ? void 0 : _o.maxBitrate)) {
22612
+ } else if (track.codec && isSVCCodec(track.codec) && ((_p = encodings[0]) === null || _p === void 0 ? void 0 : _p.maxBitrate)) {
22597
22613
  this.engine.publisher.setTrackCodecBitrate({
22598
22614
  cid: req.cid,
22599
22615
  codec: track.codec,
@@ -23034,7 +23050,8 @@ class Room extends EventEmitter {
23034
23050
  adaptiveStream: typeof roomOptions.adaptiveStream === 'object' ? true : roomOptions.adaptiveStream,
23035
23051
  maxRetries: connectOptions.maxRetries,
23036
23052
  e2eeEnabled: !!this.e2eeManager,
23037
- fallbackUrs: connectOptions.fallbackUrls
23053
+ fallbackUrs: connectOptions.fallbackUrls,
23054
+ websocketTimeout: connectOptions.websocketTimeout
23038
23055
  }, abortController.signal);
23039
23056
  let serverInfo = joinResponse.serverInfo;
23040
23057
  if (!serverInfo) {