livekit-client 2.9.5 → 2.9.7

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.
@@ -11169,7 +11169,7 @@ function getOSVersion(ua) {
11169
11169
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
11170
11170
  }
11171
11171
 
11172
- var version$1 = "2.9.5";
11172
+ var version$1 = "2.9.7";
11173
11173
 
11174
11174
  const version = version$1;
11175
11175
  const protocolVersion = 15;
@@ -12281,13 +12281,25 @@ function detectSilence(track_1) {
12281
12281
  * @internal
12282
12282
  */
12283
12283
  function getNewAudioContext() {
12284
+ var _a;
12284
12285
  const AudioContext =
12285
12286
  // @ts-ignore
12286
12287
  typeof window !== 'undefined' && (window.AudioContext || window.webkitAudioContext);
12287
12288
  if (AudioContext) {
12288
- return new AudioContext({
12289
+ const audioContext = new AudioContext({
12289
12290
  latencyHint: 'interactive'
12290
12291
  });
12292
+ // If the audio context is suspended, we need to resume it when the user clicks on the page
12293
+ if (audioContext.state === 'suspended' && typeof window !== 'undefined' && ((_a = window.document) === null || _a === void 0 ? void 0 : _a.body)) {
12294
+ const handleResume = () => {
12295
+ audioContext.resume().then(() => {
12296
+ var _a;
12297
+ (_a = window.document.body) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', handleResume);
12298
+ });
12299
+ };
12300
+ window.document.body.addEventListener('click', handleResume);
12301
+ }
12302
+ return audioContext;
12291
12303
  }
12292
12304
  }
12293
12305
  /**
@@ -13016,12 +13028,15 @@ class SignalClient {
13016
13028
  }
13017
13029
  connect(url, token, opts, abortSignal) {
13018
13030
  this.connectOptions = opts;
13019
- url = toWebsocketUrl(url);
13031
+ const urlObj = new URL(toWebsocketUrl(url));
13020
13032
  // strip trailing slash
13021
- url = url.replace(/\/$/, '');
13022
- url += '/rtc';
13033
+ urlObj.pathname = urlObj.pathname.replace(/\/$/, '');
13034
+ urlObj.pathname += '/rtc';
13023
13035
  const clientInfo = getClientInfo();
13024
13036
  const params = createConnectionParams(token, clientInfo, opts);
13037
+ for (const [key, value] of params) {
13038
+ urlObj.searchParams.set(key, value);
13039
+ }
13025
13040
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
13026
13041
  const unlock = yield this.connectionLock.lock();
13027
13042
  try {
@@ -13038,11 +13053,18 @@ class SignalClient {
13038
13053
  abortHandler();
13039
13054
  }
13040
13055
  abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener('abort', abortHandler);
13041
- this.log.debug("connecting to ".concat(url + params.replace(/access_token=([^&#$]*)/, 'access_token=<redacted>')), this.logContext);
13056
+ const redactedUrl = new URL(urlObj.toString());
13057
+ if (redactedUrl.searchParams.has('access_token')) {
13058
+ redactedUrl.searchParams.set('access_token', '<redacted>');
13059
+ }
13060
+ this.log.debug("connecting to ".concat(redactedUrl), Object.assign({
13061
+ reconnect: opts.reconnect,
13062
+ reconnectReason: opts.reconnectReason
13063
+ }, this.logContext));
13042
13064
  if (this.ws) {
13043
13065
  yield this.close(false);
13044
13066
  }
13045
- this.ws = new WebSocket(url + params);
13067
+ this.ws = new WebSocket(urlObj);
13046
13068
  this.ws.binaryType = 'arraybuffer';
13047
13069
  this.ws.onopen = () => {
13048
13070
  clearTimeout(wsTimeout);
@@ -13052,7 +13074,10 @@ class SignalClient {
13052
13074
  this.state = SignalConnectionState.DISCONNECTED;
13053
13075
  clearTimeout(wsTimeout);
13054
13076
  try {
13055
- const resp = yield fetch("http".concat(url.substring(2), "/validate").concat(params));
13077
+ const validateURL = new URL(urlObj.toString());
13078
+ validateURL.protocol = "http".concat(validateURL.protocol.substring(2));
13079
+ validateURL.pathname += '/validate';
13080
+ const resp = yield fetch(validateURL);
13056
13081
  if (resp.status.toFixed(0).startsWith('4')) {
13057
13082
  const msg = yield resp.text();
13058
13083
  reject(new ConnectionError(msg, ConnectionErrorReason.NotAllowed, resp.status));
@@ -13204,7 +13229,7 @@ class SignalClient {
13204
13229
  });
13205
13230
  }
13206
13231
  sendIceCandidate(candidate, target) {
13207
- this.log.trace('sending ice candidate', Object.assign(Object.assign({}, this.logContext), {
13232
+ this.log.debug('sending ice candidate', Object.assign(Object.assign({}, this.logContext), {
13208
13233
  candidate
13209
13234
  }));
13210
13235
  return this.sendRequest({
@@ -13594,7 +13619,7 @@ function createConnectionParams(token, info, opts) {
13594
13619
  // @ts-ignore
13595
13620
  params.set('network', navigator.connection.type);
13596
13621
  }
13597
- return "?".concat(params.toString());
13622
+ return params;
13598
13623
  }
13599
13624
 
13600
13625
  var lib = {};
@@ -15613,11 +15638,10 @@ class LocalTrack extends Track {
15613
15638
  if (!constraints) {
15614
15639
  constraints = this._constraints;
15615
15640
  }
15616
- const _a = this._constraints,
15617
- {
15641
+ const {
15618
15642
  deviceId
15619
- } = _a,
15620
- otherConstraints = __rest(_a, ["deviceId"]);
15643
+ } = constraints,
15644
+ otherConstraints = __rest(constraints, ["deviceId"]);
15621
15645
  this.log.debug('restarting track with constraints', Object.assign(Object.assign({}, this.logContext), {
15622
15646
  constraints
15623
15647
  }));
@@ -17469,7 +17493,7 @@ class RTCEngine extends eventsExports.EventEmitter {
17469
17493
  if (!this.pcManager) {
17470
17494
  return;
17471
17495
  }
17472
- this.log.trace('got ICE candidate from peer', Object.assign(Object.assign({}, this.logContext), {
17496
+ this.log.debug('got ICE candidate from peer', Object.assign(Object.assign({}, this.logContext), {
17473
17497
  candidate,
17474
17498
  target
17475
17499
  }));
@@ -20873,7 +20897,8 @@ class LocalParticipant extends Participant {
20873
20897
  totalSize: totalTextLength,
20874
20898
  destinationIdentities: options === null || options === void 0 ? void 0 : options.destinationIdentities,
20875
20899
  topic: options === null || options === void 0 ? void 0 : options.topic,
20876
- attachedStreamIds: fileIds
20900
+ attachedStreamIds: fileIds,
20901
+ attributes: options === null || options === void 0 ? void 0 : options.attributes
20877
20902
  });
20878
20903
  yield writer.write(text);
20879
20904
  // set text part of progress to 1
@@ -20906,7 +20931,8 @@ class LocalParticipant extends Participant {
20906
20931
  mimeType: 'text/plain',
20907
20932
  timestamp: Date.now(),
20908
20933
  topic: (_b = options === null || options === void 0 ? void 0 : options.topic) !== null && _b !== void 0 ? _b : '',
20909
- size: options === null || options === void 0 ? void 0 : options.totalSize
20934
+ size: options === null || options === void 0 ? void 0 : options.totalSize,
20935
+ attributes: options === null || options === void 0 ? void 0 : options.attributes
20910
20936
  };
20911
20937
  const header = new DataStream_Header({
20912
20938
  streamId,
@@ -20914,6 +20940,7 @@ class LocalParticipant extends Participant {
20914
20940
  topic: info.topic,
20915
20941
  timestamp: numberToBigInt(info.timestamp),
20916
20942
  totalLength: numberToBigInt(options === null || options === void 0 ? void 0 : options.totalSize),
20943
+ attributes: info.attributes,
20917
20944
  contentHeader: {
20918
20945
  case: 'textHeader',
20919
20946
  value: new DataStream_TextHeader({