livekit-client 1.13.2 → 1.13.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2483,7 +2483,7 @@ function debugJsonValue(json) {
2483
2483
  case "string":
2484
2484
  return json.length > 100 ? "string" : "\"".concat(json.split('"').join('\\"'), "\"");
2485
2485
  default:
2486
- return json.toString();
2486
+ return String(json);
2487
2487
  }
2488
2488
  }
2489
2489
  // May throw an error. If the error message is non-blank, it should be shown.
@@ -2590,6 +2590,7 @@ function readEnum(type, json, ignoreUnknownFields) {
2590
2590
  break;
2591
2591
  case "string":
2592
2592
  const value = type.findName(json);
2593
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
2593
2594
  if (value || ignoreUnknownFields) {
2594
2595
  return value === null || value === void 0 ? void 0 : value.no;
2595
2596
  }
@@ -2786,6 +2787,8 @@ function makeUtilCommon() {
2786
2787
  let val = s[localName].value;
2787
2788
  if (sourceField && sourceField.kind == "message" && !(val instanceof sourceField.T)) {
2788
2789
  val = new sourceField.T(val);
2790
+ } else if (sourceField && sourceField.kind === "scalar" && sourceField.T === ScalarType.BYTES) {
2791
+ val = toU8Arr(val);
2789
2792
  }
2790
2793
  t[localName] = {
2791
2794
  case: sk,
@@ -2794,13 +2797,23 @@ function makeUtilCommon() {
2794
2797
  break;
2795
2798
  case "scalar":
2796
2799
  case "enum":
2797
- t[localName] = s[localName];
2800
+ let copy = s[localName];
2801
+ if (member.T === ScalarType.BYTES) {
2802
+ copy = member.repeated ? copy.map(toU8Arr) : toU8Arr(copy);
2803
+ }
2804
+ t[localName] = copy;
2798
2805
  break;
2799
2806
  case "map":
2800
2807
  switch (member.V.kind) {
2801
2808
  case "scalar":
2802
2809
  case "enum":
2803
- Object.assign(t[localName], s[localName]);
2810
+ if (member.V.T === ScalarType.BYTES) {
2811
+ for (const [k, v] of Object.entries(s[localName])) {
2812
+ t[localName][k] = toU8Arr(v);
2813
+ }
2814
+ } else {
2815
+ Object.assign(t[localName], s[localName]);
2816
+ }
2804
2817
  break;
2805
2818
  case "message":
2806
2819
  const messageType = member.V.T;
@@ -2823,7 +2836,13 @@ function makeUtilCommon() {
2823
2836
  } else if (s[localName] !== undefined) {
2824
2837
  const val = s[localName];
2825
2838
  if (mt.fieldWrapper) {
2826
- t[localName] = val;
2839
+ if (
2840
+ // We can't use BytesValue.typeName as that will create a circular import
2841
+ mt.typeName === "google.protobuf.BytesValue") {
2842
+ t[localName] = toU8Arr(val);
2843
+ } else {
2844
+ t[localName] = val;
2845
+ }
2827
2846
  } else {
2828
2847
  t[localName] = val instanceof mt ? val : new mt(val);
2829
2848
  }
@@ -2906,22 +2925,22 @@ function makeUtilCommon() {
2906
2925
  const source = message[member.localName];
2907
2926
  let copy;
2908
2927
  if (member.repeated) {
2909
- copy = source.map(e => cloneSingularField(member, e));
2928
+ copy = source.map(cloneSingularField);
2910
2929
  } else if (member.kind == "map") {
2911
2930
  copy = any[member.localName];
2912
2931
  for (const [key, v] of Object.entries(source)) {
2913
- copy[key] = cloneSingularField(member.V, v);
2932
+ copy[key] = cloneSingularField(v);
2914
2933
  }
2915
2934
  } else if (member.kind == "oneof") {
2916
2935
  const f = member.findField(source.case);
2917
2936
  copy = f ? {
2918
2937
  case: source.case,
2919
- value: cloneSingularField(f, source.value)
2938
+ value: cloneSingularField(source.value)
2920
2939
  } : {
2921
2940
  case: undefined
2922
2941
  };
2923
2942
  } else {
2924
- copy = cloneSingularField(member, source);
2943
+ copy = cloneSingularField(source);
2925
2944
  }
2926
2945
  any[member.localName] = copy;
2927
2946
  }
@@ -2930,7 +2949,7 @@ function makeUtilCommon() {
2930
2949
  };
2931
2950
  }
2932
2951
  // clone a single field value - i.e. the element type of repeated fields, the value type of maps
2933
- function cloneSingularField(field, value) {
2952
+ function cloneSingularField(value) {
2934
2953
  if (value === undefined) {
2935
2954
  return value;
2936
2955
  }
@@ -2944,6 +2963,10 @@ function cloneSingularField(field, value) {
2944
2963
  }
2945
2964
  return value;
2946
2965
  }
2966
+ // converts any ArrayLike<number> to Uint8Array if necessary.
2967
+ function toU8Arr(input) {
2968
+ return input instanceof Uint8Array ? input : new Uint8Array(input);
2969
+ }
2947
2970
 
2948
2971
  // Copyright 2021-2023 Buf Technologies, Inc.
2949
2972
  //
@@ -11840,7 +11863,7 @@ function getMatch(exp, ua) {
11840
11863
  return match && match.length >= id && match[id] || '';
11841
11864
  }
11842
11865
 
11843
- var version$1 = "1.13.2";
11866
+ var version$1 = "1.13.3";
11844
11867
 
11845
11868
  const version = version$1;
11846
11869
  const protocolVersion = 9;
@@ -11914,7 +11937,7 @@ const VideoPresets43 = {
11914
11937
  h120: new VideoPreset(160, 120, 70000, 20),
11915
11938
  h180: new VideoPreset(240, 180, 125000, 20),
11916
11939
  h240: new VideoPreset(320, 240, 140000, 20),
11917
- h360: new VideoPreset(480, 360, 225000, 20),
11940
+ h360: new VideoPreset(480, 360, 330000, 20),
11918
11941
  h480: new VideoPreset(640, 480, 500000, 20),
11919
11942
  h540: new VideoPreset(720, 540, 600000, 25),
11920
11943
  h720: new VideoPreset(960, 720, 1300000, 30),
@@ -13212,12 +13235,12 @@ function createAudioAnalyser(track, options) {
13212
13235
  const volume = Math.sqrt(sum / dataArray.length);
13213
13236
  return volume;
13214
13237
  };
13215
- const cleanup = () => {
13216
- audioContext.close();
13238
+ const cleanup = () => __awaiter(this, void 0, void 0, function* () {
13239
+ yield audioContext.close();
13217
13240
  if (opts.cloneTrack) {
13218
13241
  streamTrack.stop();
13219
13242
  }
13220
- };
13243
+ });
13221
13244
  return {
13222
13245
  calculateVolume,
13223
13246
  analyser,
@@ -19153,8 +19176,8 @@ class Participant extends eventsExports.EventEmitter {
19153
19176
  }
19154
19177
  this.identity = info.identity;
19155
19178
  this.sid = info.sid;
19156
- this.setName(info.name);
19157
- this.setMetadata(info.metadata);
19179
+ this._setName(info.name);
19180
+ this._setMetadata(info.metadata);
19158
19181
  if (info.permission) {
19159
19182
  this.setPermissions(info.permission);
19160
19183
  }
@@ -19165,8 +19188,10 @@ class Participant extends eventsExports.EventEmitter {
19165
19188
  });
19166
19189
  return true;
19167
19190
  }
19168
- /** @internal */
19169
- setMetadata(md) {
19191
+ /**
19192
+ * Updates metadata from server
19193
+ **/
19194
+ _setMetadata(md) {
19170
19195
  const changed = this.metadata !== md;
19171
19196
  const prevMetadata = this.metadata;
19172
19197
  this.metadata = md;
@@ -19174,7 +19199,7 @@ class Participant extends eventsExports.EventEmitter {
19174
19199
  this.emit(ParticipantEvent.ParticipantMetadataChanged, prevMetadata);
19175
19200
  }
19176
19201
  }
19177
- setName(name) {
19202
+ _setName(name) {
19178
19203
  const changed = this.name !== name;
19179
19204
  this.name = name;
19180
19205
  if (changed) {
@@ -19973,22 +19998,24 @@ class LocalParticipant extends Participant {
19973
19998
  }
19974
19999
  /**
19975
20000
  * Sets and updates the metadata of the local participant.
19976
- * Note: this requires `canUpdateOwnMetadata` permission encoded in the token.
20001
+ * The change does not take immediate effect.
20002
+ * If successful, a `ParticipantEvent.MetadataChanged` event will be emitted on the local participant.
20003
+ * Note: this requires `canUpdateOwnMetadata` permission.
19977
20004
  * @param metadata
19978
20005
  */
19979
20006
  setMetadata(metadata) {
19980
20007
  var _a;
19981
- super.setMetadata(metadata);
19982
20008
  this.engine.client.sendUpdateLocalMetadata(metadata, (_a = this.name) !== null && _a !== void 0 ? _a : '');
19983
20009
  }
19984
20010
  /**
19985
20011
  * Sets and updates the name of the local participant.
19986
- * Note: this requires `canUpdateOwnMetadata` permission encoded in the token.
20012
+ * The change does not take immediate effect.
20013
+ * If successful, a `ParticipantEvent.ParticipantNameChanged` event will be emitted on the local participant.
20014
+ * Note: this requires `canUpdateOwnMetadata` permission.
19987
20015
  * @param metadata
19988
20016
  */
19989
20017
  setName(name) {
19990
20018
  var _a;
19991
- super.setName(name);
19992
20019
  this.engine.client.sendUpdateLocalMetadata((_a = this.metadata) !== null && _a !== void 0 ? _a : '', name);
19993
20020
  }
19994
20021
  /**
@@ -20367,7 +20394,7 @@ class LocalParticipant extends Participant {
20367
20394
  disableDtx: !((_a = opts.dtx) !== null && _a !== void 0 ? _a : true),
20368
20395
  encryption: this.encryptionType,
20369
20396
  stereo: isStereo,
20370
- disableRed: !((_b = opts.red) !== null && _b !== void 0 ? _b : true)
20397
+ disableRed: this.isE2EEEnabled || !((_b = opts.red) !== null && _b !== void 0 ? _b : true)
20371
20398
  });
20372
20399
  // compute encodings and layers for video
20373
20400
  let encodings;