livekit-client 2.19.1 → 2.20.0

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.
Files changed (124) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +204 -145
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +664 -526
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.fm.worker.js +2 -0
  8. package/dist/{livekit-client.pt.worker.js.map → livekit-client.fm.worker.js.map} +1 -1
  9. package/dist/{livekit-client.pt.worker.mjs → livekit-client.fm.worker.mjs} +133 -99
  10. package/dist/livekit-client.fm.worker.mjs.map +1 -0
  11. package/dist/livekit-client.umd.js +1 -1
  12. package/dist/livekit-client.umd.js.map +1 -1
  13. package/dist/src/api/SignalClient.d.ts.map +1 -1
  14. package/dist/src/e2ee/E2eeManager.d.ts +1 -1
  15. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  16. package/dist/src/e2ee/types.d.ts +5 -5
  17. package/dist/src/e2ee/types.d.ts.map +1 -1
  18. package/dist/src/e2ee/worker/FrameCryptor.d.ts +20 -10
  19. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  20. package/dist/src/{packetTrailer/PacketTrailerManager.d.ts → frameMetadata/FrameMetadataManager.d.ts} +8 -4
  21. package/dist/src/{packetTrailer/PacketTrailerManager.d.ts.map → frameMetadata/FrameMetadataManager.d.ts.map} +1 -1
  22. package/dist/src/{packetTrailer/packetTrailer.d.ts → frameMetadata/frameMetadata.d.ts} +7 -7
  23. package/dist/src/frameMetadata/frameMetadata.d.ts.map +1 -0
  24. package/dist/src/{packetTrailer → frameMetadata}/types.d.ts +10 -6
  25. package/dist/src/frameMetadata/types.d.ts.map +1 -0
  26. package/dist/src/frameMetadata/utils.d.ts +9 -0
  27. package/dist/src/{packetTrailer → frameMetadata}/utils.d.ts.map +1 -1
  28. package/dist/src/frameMetadata/worker/frameMetadata.worker.d.ts +2 -0
  29. package/dist/src/frameMetadata/worker/frameMetadata.worker.d.ts.map +1 -0
  30. package/dist/src/index.d.ts +10 -2
  31. package/dist/src/index.d.ts.map +1 -1
  32. package/dist/src/options.d.ts +8 -4
  33. package/dist/src/options.d.ts.map +1 -1
  34. package/dist/src/room/PCTransport.d.ts +1 -0
  35. package/dist/src/room/PCTransport.d.ts.map +1 -1
  36. package/dist/src/room/PCTransportManager.d.ts +1 -0
  37. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  38. package/dist/src/room/RTCEngine.d.ts +11 -1
  39. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  40. package/dist/src/room/Room.d.ts +2 -2
  41. package/dist/src/room/Room.d.ts.map +1 -1
  42. package/dist/src/room/participant/LocalParticipant.d.ts +2 -2
  43. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  44. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  45. package/dist/src/room/rpc/client/RpcClientManager.d.ts.map +1 -1
  46. package/dist/src/room/token-source/TokenSource.d.ts.map +1 -1
  47. package/dist/src/room/token-source/types.d.ts +1 -0
  48. package/dist/src/room/token-source/types.d.ts.map +1 -1
  49. package/dist/src/room/token-source/utils.d.ts.map +1 -1
  50. package/dist/src/room/track/FrameMetadataExtractor.d.ts +19 -0
  51. package/dist/src/room/track/FrameMetadataExtractor.d.ts.map +1 -0
  52. package/dist/src/room/track/RemoteVideoTrack.d.ts +7 -7
  53. package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
  54. package/dist/src/room/track/options.d.ts +17 -5
  55. package/dist/src/room/track/options.d.ts.map +1 -1
  56. package/dist/ts4.2/e2ee/E2eeManager.d.ts +1 -1
  57. package/dist/ts4.2/e2ee/types.d.ts +5 -5
  58. package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +19 -9
  59. package/dist/ts4.2/{packetTrailer/PacketTrailerManager.d.ts → frameMetadata/FrameMetadataManager.d.ts} +8 -4
  60. package/dist/ts4.2/{packetTrailer/packetTrailer.d.ts → frameMetadata/frameMetadata.d.ts} +7 -7
  61. package/dist/ts4.2/{packetTrailer → frameMetadata}/types.d.ts +10 -6
  62. package/dist/ts4.2/frameMetadata/utils.d.ts +9 -0
  63. package/dist/ts4.2/frameMetadata/worker/frameMetadata.worker.d.ts +2 -0
  64. package/dist/ts4.2/index.d.ts +9 -3
  65. package/dist/ts4.2/options.d.ts +8 -4
  66. package/dist/ts4.2/room/PCTransport.d.ts +1 -0
  67. package/dist/ts4.2/room/PCTransportManager.d.ts +1 -0
  68. package/dist/ts4.2/room/RTCEngine.d.ts +11 -1
  69. package/dist/ts4.2/room/Room.d.ts +2 -2
  70. package/dist/ts4.2/room/participant/LocalParticipant.d.ts +2 -2
  71. package/dist/ts4.2/room/token-source/types.d.ts +1 -0
  72. package/dist/ts4.2/room/track/FrameMetadataExtractor.d.ts +19 -0
  73. package/dist/ts4.2/room/track/RemoteVideoTrack.d.ts +7 -7
  74. package/dist/ts4.2/room/track/options.d.ts +17 -5
  75. package/package.json +25 -20
  76. package/src/api/SignalClient.test.ts +4 -4
  77. package/src/api/SignalClient.ts +7 -3
  78. package/src/api/WebSocketStream.test.ts +7 -7
  79. package/src/e2ee/E2eeManager.ts +13 -11
  80. package/src/e2ee/types.ts +5 -5
  81. package/src/e2ee/worker/FrameCryptor.test.ts +5 -5
  82. package/src/e2ee/worker/FrameCryptor.ts +69 -30
  83. package/src/e2ee/worker/e2ee.worker.ts +5 -5
  84. package/src/e2ee/worker/tsconfig.json +4 -1
  85. package/src/{packetTrailer/PacketTrailerManager.test.ts → frameMetadata/FrameMetadataManager.test.ts} +10 -8
  86. package/src/{packetTrailer/PacketTrailerManager.ts → frameMetadata/FrameMetadataManager.ts} +21 -15
  87. package/src/{packetTrailer/packetTrailer.test.ts → frameMetadata/frameMetadata.test.ts} +1 -1
  88. package/src/{packetTrailer/packetTrailer.ts → frameMetadata/frameMetadata.ts} +9 -9
  89. package/src/{packetTrailer → frameMetadata}/types.ts +12 -6
  90. package/src/{packetTrailer → frameMetadata}/utils.test.ts +19 -19
  91. package/src/{packetTrailer → frameMetadata}/utils.ts +11 -11
  92. package/src/{packetTrailer/worker/packetTrailer.worker.ts → frameMetadata/worker/frameMetadata.worker.ts} +5 -5
  93. package/src/{packetTrailer → frameMetadata}/worker/tsconfig.json +4 -1
  94. package/src/index.ts +13 -2
  95. package/src/options.ts +9 -4
  96. package/src/room/PCTransport.ts +4 -0
  97. package/src/room/PCTransportManager.ts +4 -0
  98. package/src/room/RTCEngine.test.ts +143 -9
  99. package/src/room/RTCEngine.ts +156 -48
  100. package/src/room/Room.ts +10 -10
  101. package/src/room/participant/LocalParticipant.test.ts +19 -19
  102. package/src/room/participant/LocalParticipant.ts +21 -16
  103. package/src/room/participant/publishUtils.test.ts +6 -0
  104. package/src/room/participant/publishUtils.ts +4 -1
  105. package/src/room/rpc/client/RpcClientManager.ts +6 -3
  106. package/src/room/rpc/server/RpcServerManager.ts +1 -1
  107. package/src/room/token-source/TokenSource.ts +9 -23
  108. package/src/room/token-source/types.ts +1 -0
  109. package/src/room/token-source/utils.ts +1 -0
  110. package/src/room/track/{PacketTrailerExtractor.ts → FrameMetadataExtractor.ts} +8 -8
  111. package/src/room/track/RemoteVideoTrack.ts +7 -11
  112. package/src/room/track/options.ts +19 -5
  113. package/dist/livekit-client.pt.worker.js +0 -2
  114. package/dist/livekit-client.pt.worker.mjs.map +0 -1
  115. package/dist/src/packetTrailer/packetTrailer.d.ts.map +0 -1
  116. package/dist/src/packetTrailer/types.d.ts.map +0 -1
  117. package/dist/src/packetTrailer/utils.d.ts +0 -9
  118. package/dist/src/packetTrailer/worker/packetTrailer.worker.d.ts +0 -2
  119. package/dist/src/packetTrailer/worker/packetTrailer.worker.d.ts.map +0 -1
  120. package/dist/src/room/track/PacketTrailerExtractor.d.ts +0 -19
  121. package/dist/src/room/track/PacketTrailerExtractor.d.ts.map +0 -1
  122. package/dist/ts4.2/packetTrailer/utils.d.ts +0 -9
  123. package/dist/ts4.2/packetTrailer/worker/packetTrailer.worker.d.ts +0 -2
  124. package/dist/ts4.2/room/track/PacketTrailerExtractor.d.ts +0 -19
@@ -509,16 +509,15 @@ function int64ToString(lo, hi) {
509
509
  * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10
510
510
  */
511
511
  function uInt64ToString(lo, hi) {
512
- ({
513
- lo,
514
- hi
515
- } = toUnsigned(lo, hi));
516
512
  // Skip the expensive conversion if the number is small enough to use the
517
513
  // built-in conversions.
518
514
  // Number.MAX_SAFE_INTEGER = 0x001FFFFF FFFFFFFF, thus any number with
519
515
  // highBits <= 0x1FFFFF can be safely expressed with a double and retain
520
516
  // integer precision.
521
517
  // Proven by: Number.isSafeInteger(0x1FFFFF * 2**32 + 0xFFFFFFFF) == true.
518
+ var _toUnsigned = toUnsigned(lo, hi);
519
+ lo = _toUnsigned.lo;
520
+ hi = _toUnsigned.hi;
522
521
  if (hi <= 0x1FFFFF) {
523
522
  return String(TWO_PWR_32_DBL * hi + lo);
524
523
  }
@@ -931,20 +930,76 @@ function isScalarZeroValue(type, value) {
931
930
  return value == 0;
932
931
  // Loose comparison matches 0n, 0 and "0"
933
932
  }
934
- }// Copyright 2021-2024 Buf Technologies, Inc.
935
- //
936
- // Licensed under the Apache License, Version 2.0 (the "License");
937
- // you may not use this file except in compliance with the License.
938
- // You may obtain a copy of the License at
939
- //
940
- // http://www.apache.org/licenses/LICENSE-2.0
941
- //
942
- // Unless required by applicable law or agreed to in writing, software
943
- // distributed under the License is distributed on an "AS IS" BASIS,
944
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
945
- // See the License for the specific language governing permissions and
946
- // limitations under the License.
947
- /* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/restrict-plus-operands */
933
+ }function _arrayLikeToArray(r, a) {
934
+ (null == a || a > r.length) && (a = r.length);
935
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
936
+ return n;
937
+ }
938
+ function _arrayWithHoles(r) {
939
+ if (Array.isArray(r)) return r;
940
+ }
941
+ function _defineProperty(e, r, t) {
942
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
943
+ value: t,
944
+ enumerable: true,
945
+ configurable: true,
946
+ writable: true
947
+ }) : e[r] = t, e;
948
+ }
949
+ function _iterableToArrayLimit(r, l) {
950
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
951
+ if (null != t) {
952
+ var e,
953
+ n,
954
+ i,
955
+ u,
956
+ a = [],
957
+ f = true,
958
+ o = false;
959
+ try {
960
+ if (i = (t = t.call(r)).next, 0 === l) {
961
+ if (Object(t) !== t) return;
962
+ f = !1;
963
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
964
+ } catch (r) {
965
+ o = true, n = r;
966
+ } finally {
967
+ try {
968
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
969
+ } finally {
970
+ if (o) throw n;
971
+ }
972
+ }
973
+ return a;
974
+ }
975
+ }
976
+ function _nonIterableRest() {
977
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
978
+ }
979
+ function _slicedToArray(r, e) {
980
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
981
+ }
982
+ function _toPrimitive(t, r) {
983
+ if ("object" != typeof t || !t) return t;
984
+ var e = t[Symbol.toPrimitive];
985
+ if (void 0 !== e) {
986
+ var i = e.call(t, r);
987
+ if ("object" != typeof i) return i;
988
+ throw new TypeError("@@toPrimitive must return a primitive value.");
989
+ }
990
+ return ("string" === r ? String : Number)(t);
991
+ }
992
+ function _toPropertyKey(t) {
993
+ var i = _toPrimitive(t, "string");
994
+ return "symbol" == typeof i ? i : i + "";
995
+ }
996
+ function _unsupportedIterableToArray(r, a) {
997
+ if (r) {
998
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
999
+ var t = {}.toString.call(r).slice(8, -1);
1000
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
1001
+ }
1002
+ }/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/restrict-plus-operands */
948
1003
  /**
949
1004
  * Protobuf binary format wire types.
950
1005
  *
@@ -1256,7 +1311,10 @@ class BinaryReader {
1256
1311
  break;
1257
1312
  case WireType.StartGroup:
1258
1313
  for (;;) {
1259
- const [fn, wt] = this.tag();
1314
+ const _this$tag = this.tag(),
1315
+ _this$tag2 = _slicedToArray(_this$tag, 2),
1316
+ fn = _this$tag2[0],
1317
+ wt = _this$tag2[1];
1260
1318
  if (wt === WireType.EndGroup) {
1261
1319
  if (fieldNo !== undefined && fn !== fieldNo) {
1262
1320
  throw new Error("invalid end group tag");
@@ -1308,7 +1366,10 @@ class BinaryReader {
1308
1366
  * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
1309
1367
  */
1310
1368
  sint64() {
1311
- let [lo, hi] = this.varint64();
1369
+ let _this$varint = this.varint64(),
1370
+ _this$varint2 = _slicedToArray(_this$varint, 2),
1371
+ lo = _this$varint2[0],
1372
+ hi = _this$varint2[1];
1312
1373
  // decode zig zag
1313
1374
  let s = -(lo & 1);
1314
1375
  lo = (lo >>> 1 | (hi & 1) << 31) ^ s;
@@ -1319,7 +1380,10 @@ class BinaryReader {
1319
1380
  * Read a `bool` field, a variant.
1320
1381
  */
1321
1382
  bool() {
1322
- let [lo, hi] = this.varint64();
1383
+ let _this$varint3 = this.varint64(),
1384
+ _this$varint4 = _slicedToArray(_this$varint3, 2),
1385
+ lo = _this$varint4[0],
1386
+ hi = _this$varint4[1];
1323
1387
  return lo !== 0 || hi !== 0;
1324
1388
  }
1325
1389
  /**
@@ -1580,20 +1644,7 @@ const protoBase64 = {
1580
1644
  }
1581
1645
  return base64;
1582
1646
  }
1583
- };// Copyright 2021-2024 Buf Technologies, Inc.
1584
- //
1585
- // Licensed under the Apache License, Version 2.0 (the "License");
1586
- // you may not use this file except in compliance with the License.
1587
- // You may obtain a copy of the License at
1588
- //
1589
- // http://www.apache.org/licenses/LICENSE-2.0
1590
- //
1591
- // Unless required by applicable law or agreed to in writing, software
1592
- // distributed under the License is distributed on an "AS IS" BASIS,
1593
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1594
- // See the License for the specific language governing permissions and
1595
- // limitations under the License.
1596
- /**
1647
+ };/**
1597
1648
  * Retrieve an extension value from a message.
1598
1649
  *
1599
1650
  * The function never returns undefined. Use hasExtension() to check whether an
@@ -1611,7 +1662,10 @@ function getExtension(message, extension, options) {
1611
1662
  assertExtendee(extension, message);
1612
1663
  const opt = extension.runtime.bin.makeReadOptions(options);
1613
1664
  const ufs = filterUnknownFields(message.getType().runtime.bin.listUnknownFields(message), extension.field);
1614
- const [container, get] = createExtensionContainer(extension);
1665
+ const _createExtensionConta = createExtensionContainer(extension),
1666
+ _createExtensionConta2 = _slicedToArray(_createExtensionConta, 2),
1667
+ container = _createExtensionConta2[0],
1668
+ get = _createExtensionConta2[1];
1615
1669
  for (const uf of ufs) {
1616
1670
  extension.runtime.bin.readField(container, opt.readerFactory(uf.data), extension.field, uf.wireType, opt);
1617
1671
  }
@@ -1646,7 +1700,10 @@ function setExtension(message, extension, value, options) {
1646
1700
  extension.runtime.bin.writeField(f, value, writer, writeOpt);
1647
1701
  const reader = readOpt.readerFactory(writer.finish());
1648
1702
  while (reader.pos < reader.len) {
1649
- const [no, wireType] = reader.tag();
1703
+ const _reader$tag = reader.tag(),
1704
+ _reader$tag2 = _slicedToArray(_reader$tag, 2),
1705
+ no = _reader$tag2[0],
1706
+ wireType = _reader$tag2[1];
1650
1707
  const data = reader.skip(wireType, no);
1651
1708
  message.getType().runtime.bin.onUnknownField(message, no, wireType, data);
1652
1709
  }
@@ -1807,20 +1864,7 @@ function wrapField(type, value) {
1807
1864
  "google.protobuf.BoolValue": ScalarType.BOOL,
1808
1865
  "google.protobuf.StringValue": ScalarType.STRING,
1809
1866
  "google.protobuf.BytesValue": ScalarType.BYTES
1810
- });// Copyright 2021-2024 Buf Technologies, Inc.
1811
- //
1812
- // Licensed under the Apache License, Version 2.0 (the "License");
1813
- // you may not use this file except in compliance with the License.
1814
- // You may obtain a copy of the License at
1815
- //
1816
- // http://www.apache.org/licenses/LICENSE-2.0
1817
- //
1818
- // Unless required by applicable law or agreed to in writing, software
1819
- // distributed under the License is distributed on an "AS IS" BASIS,
1820
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1821
- // See the License for the specific language governing permissions and
1822
- // limitations under the License.
1823
- /* eslint-disable no-case-declarations,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */
1867
+ });/* eslint-disable no-case-declarations,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */
1824
1868
  // Default options for parsing JSON.
1825
1869
  const jsonReadDefaults = {
1826
1870
  ignoreUnknownFields: false
@@ -1851,7 +1895,10 @@ function makeJsonFormat() {
1851
1895
  message = message !== null && message !== void 0 ? message : new type();
1852
1896
  const oneofSeen = new Map();
1853
1897
  const registry = options.typeRegistry;
1854
- for (const [jsonKey, jsonValue] of Object.entries(json)) {
1898
+ for (const _ref of Object.entries(json)) {
1899
+ var _ref2 = _slicedToArray(_ref, 2);
1900
+ const jsonKey = _ref2[0];
1901
+ const jsonValue = _ref2[1];
1855
1902
  const field = type.fields.findJsonName(jsonKey);
1856
1903
  if (field) {
1857
1904
  if (field.oneof) {
@@ -1872,7 +1919,10 @@ function makeJsonFormat() {
1872
1919
  const ext = registry.findExtension(jsonKey.substring(1, jsonKey.length - 1));
1873
1920
  if (ext && ext.extendee.typeName == type.typeName) {
1874
1921
  found = true;
1875
- const [container, get] = createExtensionContainer(ext);
1922
+ const _createExtensionConta = createExtensionContainer(ext),
1923
+ _createExtensionConta2 = _slicedToArray(_createExtensionConta, 2),
1924
+ container = _createExtensionConta2[0],
1925
+ get = _createExtensionConta2[1];
1876
1926
  readField$1(container, jsonValue, ext.field, options, ext);
1877
1927
  // We pass on the options as BinaryReadOptions/BinaryWriteOptions,
1878
1928
  // so that users can bring their own binary reader and writer factories
@@ -2015,7 +2065,10 @@ function readField$1(target, jsonValue, field, options, parentType) {
2015
2065
  throw new Error("cannot decode field ".concat(parentType.typeName, ".").concat(field.name, " from JSON: ").concat(debugJsonValue(jsonValue)));
2016
2066
  }
2017
2067
  const targetMap = target[localName];
2018
- for (const [jsonMapKey, jsonMapValue] of Object.entries(jsonValue)) {
2068
+ for (const _ref3 of Object.entries(jsonValue)) {
2069
+ var _ref4 = _slicedToArray(_ref3, 2);
2070
+ const jsonMapKey = _ref4[0];
2071
+ const jsonMapValue = _ref4[1];
2019
2072
  if (jsonMapValue === null) {
2020
2073
  throw new Error("cannot decode field ".concat(parentType.typeName, ".").concat(field.name, " from JSON: map value null"));
2021
2074
  }
@@ -2270,19 +2323,28 @@ function writeField$1(field, value, options) {
2270
2323
  const entries = Object.entries(value);
2271
2324
  switch (field.V.kind) {
2272
2325
  case "scalar":
2273
- for (const [entryKey, entryValue] of entries) {
2326
+ for (const _ref5 of entries) {
2327
+ var _ref6 = _slicedToArray(_ref5, 2);
2328
+ const entryKey = _ref6[0];
2329
+ const entryValue = _ref6[1];
2274
2330
  jsonObj[entryKey.toString()] = writeScalar$1(field.V.T, entryValue); // JSON standard allows only (double quoted) string as property key
2275
2331
  }
2276
2332
  break;
2277
2333
  case "message":
2278
- for (const [entryKey, entryValue] of entries) {
2334
+ for (const _ref7 of entries) {
2335
+ var _ref8 = _slicedToArray(_ref7, 2);
2336
+ const entryKey = _ref8[0];
2337
+ const entryValue = _ref8[1];
2279
2338
  // JSON standard allows only (double quoted) string as property key
2280
2339
  jsonObj[entryKey.toString()] = entryValue.toJson(options);
2281
2340
  }
2282
2341
  break;
2283
2342
  case "enum":
2284
2343
  const enumType = field.V.T;
2285
- for (const [entryKey, entryValue] of entries) {
2344
+ for (const _ref9 of entries) {
2345
+ var _ref0 = _slicedToArray(_ref9, 2);
2346
+ const entryKey = _ref0[0];
2347
+ const entryValue = _ref0[1];
2286
2348
  // JSON standard allows only (double quoted) string as property key
2287
2349
  jsonObj[entryKey.toString()] = writeEnum(enumType, entryValue, options.enumAsInteger);
2288
2350
  }
@@ -2376,20 +2438,7 @@ function writeScalar$1(type, value) {
2376
2438
  assert(value instanceof Uint8Array);
2377
2439
  return protoBase64.enc(value);
2378
2440
  }
2379
- }// Copyright 2021-2024 Buf Technologies, Inc.
2380
- //
2381
- // Licensed under the Apache License, Version 2.0 (the "License");
2382
- // you may not use this file except in compliance with the License.
2383
- // You may obtain a copy of the License at
2384
- //
2385
- // http://www.apache.org/licenses/LICENSE-2.0
2386
- //
2387
- // Unless required by applicable law or agreed to in writing, software
2388
- // distributed under the License is distributed on an "AS IS" BASIS,
2389
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2390
- // See the License for the specific language governing permissions and
2391
- // limitations under the License.
2392
- /* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return */
2441
+ }/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return */
2393
2442
  const unknownFieldsSymbol = Symbol("@bufbuild/protobuf/unknown-fields");
2394
2443
  // Default options for parsing binary data.
2395
2444
  const readDefaults = {
@@ -2444,7 +2493,10 @@ function makeBinaryFormat() {
2444
2493
  const end = delimitedMessageEncoding ? reader.len : reader.pos + lengthOrEndTagFieldNo;
2445
2494
  let fieldNo, wireType;
2446
2495
  while (reader.pos < end) {
2447
- [fieldNo, wireType] = reader.tag();
2496
+ var _reader$tag = reader.tag();
2497
+ var _reader$tag2 = _slicedToArray(_reader$tag, 2);
2498
+ fieldNo = _reader$tag2[0];
2499
+ wireType = _reader$tag2[1];
2448
2500
  if (delimitedMessageEncoding === true && wireType == WireType.EndGroup) {
2449
2501
  break;
2450
2502
  }
@@ -2497,10 +2549,8 @@ function makeBinaryFormat() {
2497
2549
  function readField(target,
2498
2550
  // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
2499
2551
  reader, field, wireType, options) {
2500
- let {
2501
- repeated,
2502
- localName
2503
- } = field;
2552
+ let repeated = field.repeated,
2553
+ localName = field.localName;
2504
2554
  if (field.oneof) {
2505
2555
  target = target[field.oneof.localName];
2506
2556
  if (target.case != localName) {
@@ -2550,7 +2600,10 @@ reader, field, wireType, options) {
2550
2600
  }
2551
2601
  break;
2552
2602
  case "map":
2553
- let [mapKey, mapVal] = readMapEntry(field, reader, options);
2603
+ let _readMapEntry = readMapEntry(field, reader, options),
2604
+ _readMapEntry2 = _slicedToArray(_readMapEntry, 2),
2605
+ mapKey = _readMapEntry2[0],
2606
+ mapVal = _readMapEntry2[1];
2554
2607
  // safe to assume presence of map object, oneof cannot contain repeated values
2555
2608
  target[localName][mapKey] = mapVal;
2556
2609
  break;
@@ -2572,7 +2625,9 @@ function readMapEntry(field, reader, options) {
2572
2625
  end = reader.pos + length;
2573
2626
  let key, val;
2574
2627
  while (reader.pos < end) {
2575
- const [fieldNo] = reader.tag();
2628
+ const _reader$tag3 = reader.tag(),
2629
+ _reader$tag4 = _slicedToArray(_reader$tag3, 1),
2630
+ fieldNo = _reader$tag4[0];
2576
2631
  switch (fieldNo) {
2577
2632
  case 1:
2578
2633
  key = readScalar(reader, field.K);
@@ -2686,7 +2741,10 @@ function writeField(field, value, writer, options) {
2686
2741
  break;
2687
2742
  case "map":
2688
2743
  assert(typeof value == "object" && value != null);
2689
- for (const [key, val] of Object.entries(value)) {
2744
+ for (const _ref of Object.entries(value)) {
2745
+ var _ref2 = _slicedToArray(_ref, 2);
2746
+ const key = _ref2[0];
2747
+ const val = _ref2[1];
2690
2748
  writeMapEntry(writer, options, field, key, val);
2691
2749
  }
2692
2750
  break;
@@ -2737,7 +2795,10 @@ function writeMessageField(writer, options, field, value) {
2737
2795
  }
2738
2796
  function writeScalar(writer, type, fieldNo, value) {
2739
2797
  assert(value !== undefined);
2740
- let [wireType, method] = scalarTypeInfo(type);
2798
+ let _scalarTypeInfo = scalarTypeInfo(type),
2799
+ _scalarTypeInfo2 = _slicedToArray(_scalarTypeInfo, 2),
2800
+ wireType = _scalarTypeInfo2[0],
2801
+ method = _scalarTypeInfo2[1];
2741
2802
  writer.tag(fieldNo, wireType)[method](value);
2742
2803
  }
2743
2804
  function writePacked(writer, type, fieldNo, value) {
@@ -2745,7 +2806,9 @@ function writePacked(writer, type, fieldNo, value) {
2745
2806
  return;
2746
2807
  }
2747
2808
  writer.tag(fieldNo, WireType.LengthDelimited).fork();
2748
- let [, method] = scalarTypeInfo(type);
2809
+ let _scalarTypeInfo3 = scalarTypeInfo(type),
2810
+ _scalarTypeInfo4 = _slicedToArray(_scalarTypeInfo3, 2),
2811
+ method = _scalarTypeInfo4[1];
2749
2812
  for (let i = 0; i < value.length; i++) {
2750
2813
  writer[method](value[i]);
2751
2814
  }
@@ -2783,20 +2846,7 @@ function scalarTypeInfo(type) {
2783
2846
  }
2784
2847
  const method = ScalarType[type].toLowerCase();
2785
2848
  return [wireType, method];
2786
- }// Copyright 2021-2024 Buf Technologies, Inc.
2787
- //
2788
- // Licensed under the Apache License, Version 2.0 (the "License");
2789
- // you may not use this file except in compliance with the License.
2790
- // You may obtain a copy of the License at
2791
- //
2792
- // http://www.apache.org/licenses/LICENSE-2.0
2793
- //
2794
- // Unless required by applicable law or agreed to in writing, software
2795
- // distributed under the License is distributed on an "AS IS" BASIS,
2796
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2797
- // See the License for the specific language governing permissions and
2798
- // limitations under the License.
2799
- /* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument,no-case-declarations */
2849
+ }/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument,no-case-declarations */
2800
2850
  function makeUtilCommon() {
2801
2851
  return {
2802
2852
  setEnumType,
@@ -2844,7 +2894,10 @@ function makeUtilCommon() {
2844
2894
  case "scalar":
2845
2895
  case "enum":
2846
2896
  if (member.V.T === ScalarType.BYTES) {
2847
- for (const [k, v] of Object.entries(s[localName])) {
2897
+ for (const _ref of Object.entries(s[localName])) {
2898
+ var _ref2 = _slicedToArray(_ref, 2);
2899
+ const k = _ref2[0];
2900
+ const v = _ref2[1];
2848
2901
  t[localName][k] = toU8Arr(v);
2849
2902
  }
2850
2903
  } else {
@@ -2976,7 +3029,10 @@ function makeUtilCommon() {
2976
3029
  copy = source.map(cloneSingularField);
2977
3030
  } else if (member.kind == "map") {
2978
3031
  copy = any[member.localName];
2979
- for (const [key, v] of Object.entries(source)) {
3032
+ for (const _ref3 of Object.entries(source)) {
3033
+ var _ref4 = _slicedToArray(_ref3, 2);
3034
+ const key = _ref4[0];
3035
+ const v = _ref4[1];
2980
3036
  copy[key] = cloneSingularField(v);
2981
3037
  }
2982
3038
  } else if (member.kind == "oneof") {
@@ -8720,8 +8776,7 @@ function requireEvents() {
8720
8776
  }
8721
8777
  }
8722
8778
  return events.exports;
8723
- }var eventsExports = requireEvents();
8724
- var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventsExports);/*
8779
+ }var eventsExports = requireEvents();/*
8725
8780
  * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
8726
8781
  *
8727
8782
  * Use of this source code is governed by a BSD-style license
@@ -8874,9 +8929,7 @@ function detectBrowser(window) {
8874
8929
  result.browser = 'Not a browser.';
8875
8930
  return result;
8876
8931
  }
8877
- const {
8878
- navigator
8879
- } = window;
8932
+ const navigator = window.navigator;
8880
8933
 
8881
8934
  // Prefer navigator.userAgentData.
8882
8935
  if (navigator.userAgentData && navigator.userAgentData.brands) {
@@ -9868,7 +9921,10 @@ function shimGetStats(window, browserDetails) {
9868
9921
  };
9869
9922
  const nativeGetStats = window.RTCPeerConnection.prototype.getStats;
9870
9923
  window.RTCPeerConnection.prototype.getStats = function getStats() {
9871
- const [selector, onSucc, onErr] = arguments;
9924
+ const _arguments = Array.prototype.slice.call(arguments),
9925
+ selector = _arguments[0],
9926
+ onSucc = _arguments[1],
9927
+ onErr = _arguments[2];
9872
9928
  if (this.signalingState === 'closed') {
9873
9929
  // No longer required in FF151+
9874
9930
  return Promise.resolve(new Map());
@@ -10015,9 +10071,7 @@ function shimAddTransceiver(window) {
10015
10071
  // Also note that after the createoffer we are not 100% sure that
10016
10072
  // the params were asynchronously applied so we might miss the
10017
10073
  // opportunity to recreate offer.
10018
- const {
10019
- sender
10020
- } = transceiver;
10074
+ const sender = transceiver.sender;
10021
10075
  const params = sender.getParameters();
10022
10076
  if (!('encodings' in params) ||
10023
10077
  // Avoid being fooled by patched getParameters() below.
@@ -11324,9 +11378,8 @@ function shimMaxMessageSize(window, browserDetails) {
11324
11378
  // As usual, adapter.js has to do an 'ugly worakaround'
11325
11379
  // to cover up the mess.
11326
11380
  if (browserDetails.browser === 'chrome' && browserDetails.version >= 76) {
11327
- const {
11328
- sdpSemantics
11329
- } = this.getConfiguration();
11381
+ const _this$getConfiguratio = this.getConfiguration(),
11382
+ sdpSemantics = _this$getConfiguratio.sdpSemantics;
11330
11383
  if (sdpSemantics === 'plan-b') {
11331
11384
  Object.defineProperty(this, 'sctp', {
11332
11385
  get() {
@@ -11580,9 +11633,8 @@ function shimParameterlessSetLocalDescription(window, browserDetails) {
11580
11633
 
11581
11634
  // Shimming starts here.
11582
11635
  function adapterFactory() {
11583
- let {
11584
- window
11585
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11636
+ let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
11637
+ window = _ref.window;
11586
11638
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
11587
11639
  shimChrome: true,
11588
11640
  shimFirefox: true,
@@ -11742,9 +11794,7 @@ function getBrowser(userAgent) {
11742
11794
  const ua = (userAgent !== null && userAgent !== void 0 ? userAgent : navigator.userAgent).toLowerCase();
11743
11795
  if (browserDetails === undefined || force) {
11744
11796
  const browser = browsersList.find(_ref => {
11745
- let {
11746
- test
11747
- } = _ref;
11797
+ let test = _ref.test;
11748
11798
  return test.test(ua);
11749
11799
  });
11750
11800
  browserDetails = browser === null || browser === void 0 ? void 0 : browser.describe(ua);
@@ -11793,7 +11843,7 @@ function getMatch(exp, ua) {
11793
11843
  }
11794
11844
  function getOSVersion(ua) {
11795
11845
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
11796
- }var version$1 = "2.19.1";const version = version$1;
11846
+ }var version$1 = "2.20.0";const version = version$1;
11797
11847
  const protocolVersion = 17;
11798
11848
  /** Initial client protocol. */
11799
11849
  const CLIENT_PROTOCOL_DEFAULT = 0;
@@ -12765,11 +12815,10 @@ const ScreenSharePresets = {
12765
12815
  };function mergeDefaultOptions(options, audioDefaults, videoDefaults) {
12766
12816
  var _a, _b;
12767
12817
  var _c, _d;
12768
- const {
12769
- optionsWithoutProcessor,
12770
- audioProcessor,
12771
- videoProcessor
12772
- } = extractProcessorsFromOptions(options !== null && options !== void 0 ? options : {});
12818
+ const _extractProcessorsFro = extractProcessorsFromOptions(options !== null && options !== void 0 ? options : {}),
12819
+ optionsWithoutProcessor = _extractProcessorsFro.optionsWithoutProcessor,
12820
+ audioProcessor = _extractProcessorsFro.audioProcessor,
12821
+ videoProcessor = _extractProcessorsFro.videoProcessor;
12773
12822
  const defaultAudioProcessor = audioDefaults === null || audioDefaults === void 0 ? void 0 : audioDefaults.processor;
12774
12823
  const defaultVideoProcessor = videoDefaults === null || videoDefaults === void 0 ? void 0 : videoDefaults.processor;
12775
12824
  const clonedOptions = optionsWithoutProcessor !== null && optionsWithoutProcessor !== void 0 ? optionsWithoutProcessor : {};
@@ -13769,7 +13818,9 @@ function createDummyVideoStreamTrack() {
13769
13818
  }
13770
13819
  // @ts-ignore
13771
13820
  const dummyStream = canvas.captureStream();
13772
- const [dummyTrack] = dummyStream.getTracks();
13821
+ const _dummyStream$getTrack = dummyStream.getTracks(),
13822
+ _dummyStream$getTrack2 = _slicedToArray(_dummyStream$getTrack, 1),
13823
+ dummyTrack = _dummyStream$getTrack2[0];
13773
13824
  if (!dummyTrack) {
13774
13825
  throw Error('Could not get empty media stream video track');
13775
13826
  }
@@ -13788,7 +13839,9 @@ function getEmptyAudioStreamTrack() {
13788
13839
  oscillator.connect(gain);
13789
13840
  gain.connect(dst);
13790
13841
  oscillator.start();
13791
- [emptyAudioStreamTrack] = dst.stream.getAudioTracks();
13842
+ var _dst$stream$getAudioT = dst.stream.getAudioTracks();
13843
+ var _dst$stream$getAudioT2 = _slicedToArray(_dst$stream$getAudioT, 1);
13844
+ emptyAudioStreamTrack = _dst$stream$getAudioT2[0];
13792
13845
  if (!emptyAudioStreamTrack) {
13793
13846
  throw Error('Could not get empty media stream audio track');
13794
13847
  }
@@ -13911,14 +13964,12 @@ function toHttpUrl(url) {
13911
13964
  }
13912
13965
  function extractTranscriptionSegments(transcription, firstReceivedTimesMap) {
13913
13966
  return transcription.segments.map(_ref => {
13914
- let {
13915
- id,
13916
- text,
13917
- language,
13918
- startTime,
13919
- endTime,
13920
- final
13921
- } = _ref;
13967
+ let id = _ref.id,
13968
+ text = _ref.text,
13969
+ language = _ref.language,
13970
+ startTime = _ref.startTime,
13971
+ endTime = _ref.endTime,
13972
+ final = _ref.final;
13922
13973
  var _a;
13923
13974
  const firstReceivedTime = (_a = firstReceivedTimesMap.get(id)) !== null && _a !== void 0 ? _a : Date.now();
13924
13975
  const lastReceivedTime = Date.now();
@@ -13940,12 +13991,10 @@ function extractTranscriptionSegments(transcription, firstReceivedTimesMap) {
13940
13991
  });
13941
13992
  }
13942
13993
  function extractChatMessage(msg) {
13943
- const {
13944
- id,
13945
- timestamp,
13946
- message,
13947
- editTimestamp
13948
- } = msg;
13994
+ const id = msg.id,
13995
+ timestamp = msg.timestamp,
13996
+ message = msg.message,
13997
+ editTimestamp = msg.editTimestamp;
13949
13998
  return {
13950
13999
  id,
13951
14000
  timestamp: Number.parseInt(timestamp.toString()),
@@ -14393,16 +14442,16 @@ class CryptorError extends LivekitError {
14393
14442
  this.reason = reason;
14394
14443
  this.participantIdentity = participantIdentity;
14395
14444
  }
14396
- }function shouldUsePacketTrailerScriptTransform() {
14445
+ }function shouldUseFrameMetadataScriptTransform() {
14397
14446
  return isScriptTransformSupportedForWorker();
14398
14447
  }
14399
- function isPacketTrailerSupported(options) {
14400
- return !!(options === null || options === void 0 ? void 0 : options.worker) && (isInsertableStreamSupported() || shouldUsePacketTrailerScriptTransform());
14448
+ function isFrameMetadataSupported(options) {
14449
+ return !!(options === null || options === void 0 ? void 0 : options.worker) && (isInsertableStreamSupported() || shouldUseFrameMetadataScriptTransform());
14401
14450
  }
14402
- function hasPacketTrailerPublishOptions(options) {
14451
+ function hasFrameMetadataPublishOptions(options) {
14403
14452
  return !!((options === null || options === void 0 ? void 0 : options.timestamp) || (options === null || options === void 0 ? void 0 : options.frameId));
14404
14453
  }
14405
- function getPacketTrailerFeatures(options) {
14454
+ function getFrameMetadataFeatures(options) {
14406
14455
  const features = [];
14407
14456
  if (options === null || options === void 0 ? void 0 : options.timestamp) {
14408
14457
  features.push(PacketTrailerFeature.PTF_USER_TIMESTAMP);
@@ -14412,7 +14461,7 @@ function getPacketTrailerFeatures(options) {
14412
14461
  }
14413
14462
  return features;
14414
14463
  }
14415
- function getPacketTrailerPublishOptions(features) {
14464
+ function getFrameMetadataPublishOptions(features) {
14416
14465
  if (!features || features.length === 0) {
14417
14466
  return undefined;
14418
14467
  }
@@ -14486,9 +14535,7 @@ function debounce(func) {
14486
14535
  callback && callback(result);
14487
14536
  // biome-ignore lint/suspicious/useIterableCallbackReturn: vendored code
14488
14537
  promises.forEach(_ref => {
14489
- let {
14490
- resolve
14491
- } = _ref;
14538
+ let resolve = _ref.resolve;
14492
14539
  return resolve(result);
14493
14540
  });
14494
14541
  promises = [];
@@ -14516,9 +14563,7 @@ function debounce(func) {
14516
14563
  }
14517
14564
  // biome-ignore lint/suspicious/useIterableCallbackReturn: vendored code
14518
14565
  promises.forEach(_ref2 => {
14519
- let {
14520
- reject
14521
- } = _ref2;
14566
+ let reject = _ref2.reject;
14522
14567
  return reject(reason);
14523
14568
  });
14524
14569
  promises = [];
@@ -14648,10 +14693,8 @@ function computeBitrate(currentStats, prevStats) {
14648
14693
  this.timeSyncHandle = requestAnimationFrame(() => loop());
14649
14694
  const sources = (_a = this.receiver) === null || _a === void 0 ? void 0 : _a.getSynchronizationSources()[0];
14650
14695
  if (sources) {
14651
- const {
14652
- timestamp,
14653
- rtpTimestamp
14654
- } = sources;
14696
+ const timestamp = sources.timestamp,
14697
+ rtpTimestamp = sources.rtpTimestamp;
14655
14698
  if (rtpTimestamp && this.rtpTimestamp !== rtpTimestamp) {
14656
14699
  this.emit(TrackEvent.TimeSyncUpdate, {
14657
14700
  timestamp,
@@ -14692,16 +14735,14 @@ class RemoteVideoTrack extends RemoteTrack {
14692
14735
  * Use with the `TrackEvent.TimeSyncUpdate` event to correlate displayed frames
14693
14736
  * with their capture-time metadata.
14694
14737
  *
14695
- * Requires the room to be configured with the `packetTrailer` worker option
14696
- * and the publishing track to have packet trailer features enabled.
14738
+ * Requires the room to be configured with the `frameMetadata` worker option
14739
+ * and the publishing track to have frame metadata features enabled.
14697
14740
  *
14698
14741
  */
14699
14742
  lookupFrameMetadata(_ref) {
14700
- let {
14701
- rtpTimestamp
14702
- } = _ref;
14743
+ let rtpTimestamp = _ref.rtpTimestamp;
14703
14744
  var _a;
14704
- return (_a = this.packetTrailerExtractor) === null || _a === void 0 ? void 0 : _a.lookupMetadata(rtpTimestamp);
14745
+ return (_a = this.frameMetadataExtractor) === null || _a === void 0 ? void 0 : _a.lookupMetadata(rtpTimestamp);
14705
14746
  }
14706
14747
  setStreamState(value) {
14707
14748
  super.setStreamState(value);
@@ -14931,10 +14972,8 @@ class HTMLElementInfo {
14931
14972
  constructor(element, visible) {
14932
14973
  this.onVisibilityChanged = entry => {
14933
14974
  var _a;
14934
- const {
14935
- target,
14936
- isIntersecting
14937
- } = entry;
14975
+ const target = entry.target,
14976
+ isIntersecting = entry.isIntersecting;
14938
14977
  if (target === this.element) {
14939
14978
  this.isIntersecting = isIntersecting;
14940
14979
  this.isPiP = isElementInPiP(this.element);
@@ -15013,12 +15052,10 @@ function isElementInViewport(el, win) {
15013
15052
  let left = el.offsetLeft;
15014
15053
  const width = el.offsetWidth;
15015
15054
  const height = el.offsetHeight;
15016
- const {
15017
- hidden
15018
- } = el;
15019
- const {
15020
- display
15021
- } = getComputedStyle(el);
15055
+ const _el = el,
15056
+ hidden = _el.hidden;
15057
+ const _getComputedStyle = getComputedStyle(el),
15058
+ display = _getComputedStyle.display;
15022
15059
  while (el.offsetParent) {
15023
15060
  el = el.offsetParent;
15024
15061
  top += el.offsetTop;
@@ -15035,10 +15072,9 @@ class E2EEManager extends eventsExports.EventEmitter {
15035
15072
  this.encryptDataRequests = new Map();
15036
15073
  this.onWorkerMessage = ev => {
15037
15074
  var _a, _b;
15038
- const {
15039
- kind,
15040
- data
15041
- } = ev.data;
15075
+ const _ev$data = ev.data,
15076
+ kind = _ev$data.kind,
15077
+ data = _ev$data.data;
15042
15078
  switch (kind) {
15043
15079
  case 'error':
15044
15080
  livekitLogger.error(data.error.message);
@@ -15099,7 +15135,7 @@ class E2EEManager extends eventsExports.EventEmitter {
15099
15135
  }
15100
15136
  break;
15101
15137
  case 'packetTrailerMetadata':
15102
- this.handlePacketTrailerMetadata(data.trackId, data.rtpTimestamp, data.ssrc, data.metadata);
15138
+ this.handleFrameMetadata(data.trackId, data.rtpTimestamp, data.ssrc, data.metadata);
15103
15139
  break;
15104
15140
  }
15105
15141
  };
@@ -15166,14 +15202,14 @@ class E2EEManager extends eventsExports.EventEmitter {
15166
15202
  this.postSifTrailer(trailer);
15167
15203
  }
15168
15204
  }
15169
- handlePacketTrailerMetadata(trackId, rtpTimestamp, ssrc, metadata) {
15205
+ handleFrameMetadata(trackId, rtpTimestamp, ssrc, metadata) {
15170
15206
  if (!this.room) {
15171
15207
  return;
15172
15208
  }
15173
15209
  for (const participant of [this.room.localParticipant, ...this.room.remoteParticipants.values()]) {
15174
15210
  for (const pub of participant.trackPublications.values()) {
15175
- if (pub.track && pub.track.mediaStreamID === trackId && pub.track instanceof RemoteVideoTrack && pub.track.packetTrailerExtractor) {
15176
- pub.track.packetTrailerExtractor.storeMetadata(rtpTimestamp, ssrc, metadata);
15211
+ if (pub.track && pub.track.mediaStreamID === trackId && pub.track instanceof RemoteVideoTrack && pub.track.frameMetadataExtractor) {
15212
+ pub.track.frameMetadataExtractor.storeMetadata(rtpTimestamp, ssrc, metadata);
15177
15213
  return;
15178
15214
  }
15179
15215
  }
@@ -15298,11 +15334,9 @@ class E2EEManager extends eventsExports.EventEmitter {
15298
15334
  this.worker.postMessage(msg);
15299
15335
  }
15300
15336
  postKey(_ref, updateCurrentKeyIndex) {
15301
- let {
15302
- key,
15303
- participantIdentity,
15304
- keyIndex
15305
- } = _ref;
15337
+ let key = _ref.key,
15338
+ participantIdentity = _ref.participantIdentity,
15339
+ keyIndex = _ref.keyIndex;
15306
15340
  var _a;
15307
15341
  if (!this.worker) {
15308
15342
  throw Error('could not set key, worker is missing');
@@ -15373,12 +15407,12 @@ class E2EEManager extends eventsExports.EventEmitter {
15373
15407
  this.handleReceiver(track.receiver, track.mediaStreamID, remoteId, track.kind === 'video' ? mimeTypeToVideoCodecString(trackInfo.mimeType) : undefined, hasPacketTrailer);
15374
15408
  }
15375
15409
  setupE2EESender(track, sender) {
15376
- var _a;
15410
+ var _a, _b, _c;
15377
15411
  if (!isLocalTrack(track) || !sender) {
15378
15412
  if (!sender) livekitLogger.warn('early return because sender is not ready');
15379
15413
  return;
15380
15414
  }
15381
- this.handleSender(sender, track.mediaStreamID, undefined, isVideoTrack(track) ? (_a = track.publishOptions) === null || _a === void 0 ? void 0 : _a.packetTrailer : undefined);
15415
+ this.handleSender(sender, track.mediaStreamID, undefined, isVideoTrack(track) ? (_b = (_a = track.publishOptions) === null || _a === void 0 ? void 0 : _a.frameMetadata) !== null && _b !== void 0 ? _b : (_c = track.publishOptions) === null || _c === void 0 ? void 0 : _c.packetTrailer : undefined);
15382
15416
  }
15383
15417
  /**
15384
15418
  * Handles the given {@code RTCRtpReceiver} by creating a {@code TransformStream} which will inject
@@ -15452,7 +15486,7 @@ class E2EEManager extends eventsExports.EventEmitter {
15452
15486
  * a frame encoder.
15453
15487
  *
15454
15488
  */
15455
- handleSender(sender, trackId, codec, packetTrailer) {
15489
+ handleSender(sender, trackId, codec, frameMetadata) {
15456
15490
  var _a;
15457
15491
  if (E2EE_FLAG in sender || !this.worker) {
15458
15492
  return;
@@ -15467,8 +15501,8 @@ class E2EEManager extends eventsExports.EventEmitter {
15467
15501
  participantIdentity: this.room.localParticipant.identity,
15468
15502
  trackId,
15469
15503
  codec,
15470
- hasPacketTrailer: hasPacketTrailerPublishOptions(packetTrailer),
15471
- packetTrailer
15504
+ hasPacketTrailer: hasFrameMetadataPublishOptions(frameMetadata),
15505
+ packetTrailer: frameMetadata
15472
15506
  };
15473
15507
  // @ts-ignore
15474
15508
  sender.transform = new RTCRtpScriptTransform(this.worker, options);
@@ -15485,8 +15519,8 @@ class E2EEManager extends eventsExports.EventEmitter {
15485
15519
  trackId,
15486
15520
  participantIdentity: this.room.localParticipant.identity,
15487
15521
  isReuse: false,
15488
- hasPacketTrailer: hasPacketTrailerPublishOptions(packetTrailer),
15489
- packetTrailer
15522
+ hasPacketTrailer: hasFrameMetadataPublishOptions(frameMetadata),
15523
+ packetTrailer: frameMetadata
15490
15524
  }
15491
15525
  };
15492
15526
  this.worker.postMessage(msg, [senderStreams.readable, senderStreams.writable]);
@@ -15496,16 +15530,16 @@ class E2EEManager extends eventsExports.EventEmitter {
15496
15530
  }
15497
15531
  }const MAX_ENTRIES = 300;
15498
15532
  /**
15499
- * Caches packet trailer metadata extracted from received video frames,
15533
+ * Caches frame metadata extracted from received video frames,
15500
15534
  * keyed by RTP timestamp so it can be looked up when the frame is displayed.
15501
15535
  *
15502
- * Metadata is populated either by the packet trailer worker managed by
15503
- * `PacketTrailerManager` (non-E2EE) or by the E2EE FrameCryptor worker
15536
+ * Metadata is populated either by the frame metadata worker managed by
15537
+ * `FrameMetadataManager` (non-E2EE) or by the E2EE FrameCryptor worker
15504
15538
  * after decryption (E2EE).
15505
15539
  *
15506
15540
  * @experimental
15507
15541
  */
15508
- class PacketTrailerExtractor {
15542
+ class FrameMetadataExtractor {
15509
15543
  constructor() {
15510
15544
  this.metadataMap = new Map();
15511
15545
  this.activeSsrc = 0;
@@ -15545,7 +15579,7 @@ class PacketTrailerExtractor {
15545
15579
  *
15546
15580
  * @experimental
15547
15581
  */
15548
- class PacketTrailerManager {
15582
+ class FrameMetadataManager {
15549
15583
  constructor(options) {
15550
15584
  this.extractors = new Map();
15551
15585
  /**
@@ -15565,7 +15599,7 @@ class PacketTrailerManager {
15565
15599
  }
15566
15600
  };
15567
15601
  this.onWorkerError = ev => {
15568
- livekitLogger.error('packet trailer worker encountered an error:', {
15602
+ livekitLogger.error('frame metadata worker encountered an error:', {
15569
15603
  error: ev.error
15570
15604
  });
15571
15605
  };
@@ -15611,16 +15645,16 @@ class PacketTrailerManager {
15611
15645
  }
15612
15646
  return;
15613
15647
  }
15614
- if (!isPacketTrailerSupported(this.worker ? {
15648
+ if (!isFrameMetadataSupported(this.worker ? {
15615
15649
  worker: this.worker
15616
15650
  } : undefined) && !((_b = this.room) === null || _b === void 0 ? void 0 : _b.hasE2EESetup)) {
15617
- livekitLogger.warn('packet trailer transform not supported; skipping extraction');
15651
+ livekitLogger.warn('frame metadata transform not supported; skipping extraction');
15618
15652
  return;
15619
15653
  }
15620
- const extractor = new PacketTrailerExtractor();
15654
+ const extractor = new FrameMetadataExtractor();
15621
15655
  const trackId = track.mediaStreamID;
15622
15656
  this.extractors.set(trackId, extractor);
15623
- track.packetTrailerExtractor = extractor;
15657
+ track.frameMetadataExtractor = extractor;
15624
15658
  if ((_c = this.room) === null || _c === void 0 ? void 0 : _c.hasE2EESetup) {
15625
15659
  // E2EE worker strips the trailer and injects metadata directly into
15626
15660
  // the extractor via E2eeManager; no pipeline is needed here.
@@ -15629,14 +15663,14 @@ class PacketTrailerManager {
15629
15663
  this.setupWorkerReceiver(receiver, trackId, true);
15630
15664
  }
15631
15665
  setupPassthroughReceiver(receiver, trackId) {
15632
- if (shouldUsePacketTrailerScriptTransform()) {
15666
+ if (shouldUseFrameMetadataScriptTransform()) {
15633
15667
  if ('transform' in receiver) {
15634
15668
  // @ts-ignore
15635
15669
  receiver.transform = null;
15636
15670
  }
15637
15671
  return;
15638
15672
  }
15639
- if (this.worker && isPacketTrailerSupported({
15673
+ if (this.worker && isFrameMetadataSupported({
15640
15674
  worker: this.worker
15641
15675
  }) && !this.workerPipelines.has(receiver)) {
15642
15676
  this.setupWorkerReceiver(receiver, trackId, false);
@@ -15652,7 +15686,7 @@ class PacketTrailerManager {
15652
15686
  if (!worker) {
15653
15687
  return;
15654
15688
  }
15655
- if (shouldUsePacketTrailerScriptTransform()) {
15689
+ if (shouldUseFrameMetadataScriptTransform()) {
15656
15690
  // @ts-ignore
15657
15691
  receiver.transform = new RTCRtpScriptTransform(worker, {
15658
15692
  kind: 'decode',
@@ -15711,7 +15745,7 @@ class PacketTrailerManager {
15711
15745
  this.extractors.delete(trackId);
15712
15746
  }
15713
15747
  if (track instanceof RemoteVideoTrack) {
15714
- track.packetTrailerExtractor = undefined;
15748
+ track.frameMetadataExtractor = undefined;
15715
15749
  }
15716
15750
  // The receiver pipeline is intentionally left running. If the receiver is
15717
15751
  // reused for a new track, `setupReceiver` will remap it. If the room
@@ -15728,7 +15762,9 @@ class PacketTrailerManager {
15728
15762
  this.workerPipelines.clear();
15729
15763
  (_a = this.worker) === null || _a === void 0 ? void 0 : _a.terminate();
15730
15764
  }
15731
- }const CONNECTION_BACKOFF_MIN_MS = 500;
15765
+ }
15766
+ /** @deprecated Use {@link FrameMetadataManager} instead. */
15767
+ const PacketTrailerManager = FrameMetadataManager;const CONNECTION_BACKOFF_MIN_MS = 500;
15732
15768
  const CONNECTION_BACKOFF_MAX_MS = 15000;
15733
15769
  /**
15734
15770
  * BackOffStrategy implements exponential backoff for connection failures.
@@ -16152,10 +16188,9 @@ class WebSocketStream {
16152
16188
  ws.binaryType = 'arraybuffer';
16153
16189
  this.ws = ws;
16154
16190
  const closeWithInfo = function () {
16155
- let {
16156
- closeCode: code,
16157
- reason
16158
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16191
+ let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
16192
+ code = _ref.closeCode,
16193
+ reason = _ref.reason;
16159
16194
  return ws.close(code, reason);
16160
16195
  };
16161
16196
  this.opened = new TypedPromise((resolve, reject) => {
@@ -16166,10 +16201,8 @@ class WebSocketStream {
16166
16201
  resolve({
16167
16202
  readable: new ReadableStream({
16168
16203
  start(controller) {
16169
- ws.onmessage = _ref => {
16170
- let {
16171
- data
16172
- } = _ref;
16204
+ ws.onmessage = _ref2 => {
16205
+ let data = _ref2.data;
16173
16206
  return controller.enqueue(data);
16174
16207
  };
16175
16208
  ws.onerror = e => controller.error(e);
@@ -16211,11 +16244,9 @@ class WebSocketStream {
16211
16244
  resolve(reason);
16212
16245
  }
16213
16246
  });
16214
- ws.onclose = _ref2 => {
16215
- let {
16216
- code,
16217
- reason
16218
- } = _ref2;
16247
+ ws.onclose = _ref3 => {
16248
+ let code = _ref3.code,
16249
+ reason = _ref3.reason;
16219
16250
  resolve({
16220
16251
  closeCode: code,
16221
16252
  reason
@@ -16384,13 +16415,15 @@ class SignalClient {
16384
16415
  if (redactedUrl.searchParams.has('access_token')) {
16385
16416
  redactedUrl.searchParams.set('access_token', '<redacted>');
16386
16417
  }
16418
+ if (this.ws) {
16419
+ const startClose = performance.now();
16420
+ yield this.close(false);
16421
+ this.log.debug("closed previous ws connection in ".concat(performance.now() - startClose, "ms"));
16422
+ }
16387
16423
  this.log.info("signal connecting to ".concat(redactedUrl), {
16388
16424
  reconnect: opts.reconnect,
16389
16425
  reconnectReason: opts.reconnectReason
16390
16426
  });
16391
- if (this.ws) {
16392
- yield this.close(false);
16393
- }
16394
16427
  this.ws = new WebSocketStream(rtcUrl);
16395
16428
  try {
16396
16429
  this.ws.closed.then(closeInfo => {
@@ -16486,10 +16519,9 @@ class SignalClient {
16486
16519
  if (this.signalLatency) {
16487
16520
  yield sleep(this.signalLatency);
16488
16521
  }
16489
- const {
16490
- done,
16491
- value
16492
- } = yield signalReader.read();
16522
+ const _yield$signalReader$r = yield signalReader.read(),
16523
+ done = _yield$signalReader$r.done,
16524
+ value = _yield$signalReader$r.value;
16493
16525
  if (done) {
16494
16526
  break;
16495
16527
  }
@@ -17138,10 +17170,9 @@ function createJoinRequestConnectionParams(token, info, opts, publisherOffer) {
17138
17170
  const chunks = [];
17139
17171
  const reader = stream.readable.getReader();
17140
17172
  while (true) {
17141
- const {
17142
- done,
17143
- value
17144
- } = yield reader.read();
17173
+ const _yield$reader$read = yield reader.read(),
17174
+ done = _yield$reader$read.done,
17175
+ value = _yield$reader$read.value;
17145
17176
  if (done) break;
17146
17177
  chunks.push(value);
17147
17178
  }
@@ -17258,7 +17289,10 @@ function createJoinRequestConnectionParams(token, info, opts, publisherOffer) {
17258
17289
  }
17259
17290
  cleanup() {
17260
17291
  const now = Date.now();
17261
- for (const [key, entry] of this._map.entries()) {
17292
+ for (const _ref of this._map.entries()) {
17293
+ var _ref2 = _slicedToArray(_ref, 2);
17294
+ const key = _ref2[0];
17295
+ const entry = _ref2[1];
17262
17296
  if (entry.expiresAt < now) {
17263
17297
  this._map.delete(key);
17264
17298
  }
@@ -17271,7 +17305,10 @@ function createJoinRequestConnectionParams(token, info, opts, publisherOffer) {
17271
17305
  }
17272
17306
  forEach(callback) {
17273
17307
  this.cleanup();
17274
- for (const [key, entry] of this._map.entries()) {
17308
+ for (const _ref3 of this._map.entries()) {
17309
+ var _ref4 = _slicedToArray(_ref3, 2);
17310
+ const key = _ref4[0];
17311
+ const entry = _ref4[1];
17275
17312
  if (entry.expiresAt >= Date.now()) {
17276
17313
  callback(entry.value, key, this.asValueMap());
17277
17314
  }
@@ -17281,14 +17318,20 @@ function createJoinRequestConnectionParams(token, info, opts, publisherOffer) {
17281
17318
  this.cleanup();
17282
17319
  const result = [];
17283
17320
  const valueMap = this.asValueMap();
17284
- for (const [key, value] of valueMap.entries()) {
17321
+ for (const _ref5 of valueMap.entries()) {
17322
+ var _ref6 = _slicedToArray(_ref5, 2);
17323
+ const key = _ref6[0];
17324
+ const value = _ref6[1];
17285
17325
  result.push(callback(value, key, valueMap));
17286
17326
  }
17287
17327
  return result;
17288
17328
  }
17289
17329
  asValueMap() {
17290
17330
  const result = new Map();
17291
- for (const [key, entry] of this._map.entries()) {
17331
+ for (const _ref7 of this._map.entries()) {
17332
+ var _ref8 = _slicedToArray(_ref7, 2);
17333
+ const key = _ref8[0];
17334
+ const entry = _ref8[1];
17292
17335
  if (entry.expiresAt >= Date.now()) {
17293
17336
  result.set(key, entry.value);
17294
17337
  }
@@ -17740,7 +17783,7 @@ function requireGrammar() {
17740
17783
  function requireParser() {
17741
17784
  if (hasRequiredParser) return parser;
17742
17785
  hasRequiredParser = 1;
17743
- (function (exports$1) {
17786
+ (function (exports) {
17744
17787
  var toIntIfInt = function (v) {
17745
17788
  return String(Number(v)) === v ? Number(v) : v;
17746
17789
  };
@@ -17773,7 +17816,7 @@ function requireParser() {
17773
17816
  };
17774
17817
  var grammar = requireGrammar();
17775
17818
  var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/);
17776
- exports$1.parse = function (sdp) {
17819
+ exports.parse = function (sdp) {
17777
17820
  var session = {},
17778
17821
  media = [],
17779
17822
  location = session; // points at where properties go under (one of the above)
@@ -17808,16 +17851,16 @@ function requireParser() {
17808
17851
  }
17809
17852
  return acc;
17810
17853
  };
17811
- exports$1.parseParams = function (str) {
17854
+ exports.parseParams = function (str) {
17812
17855
  return str.split(/;\s?/).reduce(paramReducer, {});
17813
17856
  };
17814
17857
 
17815
17858
  // For backward compatibility - alias will be removed in 3.0.0
17816
- exports$1.parseFmtpConfig = exports$1.parseParams;
17817
- exports$1.parsePayloads = function (str) {
17859
+ exports.parseFmtpConfig = exports.parseParams;
17860
+ exports.parsePayloads = function (str) {
17818
17861
  return str.toString().split(' ').map(Number);
17819
17862
  };
17820
- exports$1.parseRemoteCandidates = function (str) {
17863
+ exports.parseRemoteCandidates = function (str) {
17821
17864
  var candidates = [];
17822
17865
  var parts = str.split(' ').map(toIntIfInt);
17823
17866
  for (var i = 0; i < parts.length; i += 3) {
@@ -17829,12 +17872,12 @@ function requireParser() {
17829
17872
  }
17830
17873
  return candidates;
17831
17874
  };
17832
- exports$1.parseImageAttributes = function (str) {
17875
+ exports.parseImageAttributes = function (str) {
17833
17876
  return str.split(' ').map(function (item) {
17834
17877
  return item.substring(1, item.length - 1).split(',').reduce(paramReducer, {});
17835
17878
  });
17836
17879
  };
17837
- exports$1.parseSimulcastStreamList = function (str) {
17880
+ exports.parseSimulcastStreamList = function (str) {
17838
17881
  return str.split(';').map(function (stream) {
17839
17882
  return stream.split(',').map(function (format) {
17840
17883
  var scid,
@@ -18113,10 +18156,9 @@ class PCTransport extends eventsExports.EventEmitter {
18113
18156
  }
18114
18157
  let mungedSDP = undefined;
18115
18158
  if (sd.type === 'offer') {
18116
- let {
18117
- stereoMids,
18118
- nackMids
18119
- } = extractStereoAndNackAudioFromOffer(sd);
18159
+ let _extractStereoAndNack = extractStereoAndNackAudioFromOffer(sd),
18160
+ stereoMids = _extractStereoAndNack.stereoMids,
18161
+ nackMids = _extractStereoAndNack.nackMids;
18120
18162
  this.remoteStereoMids = stereoMids;
18121
18163
  this.remoteNackMids = nackMids;
18122
18164
  } else if (sd.type === 'answer') {
@@ -18410,6 +18452,10 @@ class PCTransport extends eventsExports.EventEmitter {
18410
18452
  getStats() {
18411
18453
  return this.pc.getStats();
18412
18454
  }
18455
+ getMaxMessageSize() {
18456
+ var _a, _b;
18457
+ return (_b = (_a = this._pc) === null || _a === void 0 ? void 0 : _a.sctp) === null || _b === void 0 ? void 0 : _b.maxMessageSize;
18458
+ }
18413
18459
  getConnectedAddress() {
18414
18460
  return __awaiter(this, void 0, void 0, function* () {
18415
18461
  var _a;
@@ -18921,6 +18967,9 @@ class PCTransportManager {
18921
18967
  const matchingTransceiver = transceivers.find(transceiver => transceiver.receiver === receiver);
18922
18968
  return matchingTransceiver === null || matchingTransceiver === void 0 ? void 0 : matchingTransceiver.mid;
18923
18969
  }
18970
+ getMaxPublisherMessageSize() {
18971
+ return this.publisher.getMaxMessageSize();
18972
+ }
18924
18973
  addPublisherTrack(track) {
18925
18974
  return this.publisher.addTrack(track);
18926
18975
  }
@@ -19123,10 +19172,9 @@ class LocalTrack extends Track {
19123
19172
  if (this.kind !== Track.Kind.Video) {
19124
19173
  return undefined;
19125
19174
  }
19126
- const {
19127
- width,
19128
- height
19129
- } = this._mediaStreamTrack.getSettings();
19175
+ const _this$_mediaStreamTra = this._mediaStreamTrack.getSettings(),
19176
+ width = _this$_mediaStreamTra.width,
19177
+ height = _this$_mediaStreamTra.height;
19130
19178
  if (width && height) {
19131
19179
  return {
19132
19180
  width,
@@ -19277,10 +19325,9 @@ class LocalTrack extends Track {
19277
19325
  if (_this2.source === Track.Source.ScreenShare) {
19278
19326
  return;
19279
19327
  }
19280
- const {
19281
- deviceId,
19282
- groupId
19283
- } = _this2._mediaStreamTrack.getSettings();
19328
+ const _this2$_mediaStreamTr = _this2._mediaStreamTrack.getSettings(),
19329
+ deviceId = _this2$_mediaStreamTr.deviceId,
19330
+ groupId = _this2$_mediaStreamTr.groupId;
19284
19331
  const kind = _this2.kind === Track.Kind.Audio ? 'audioinput' : 'videoinput';
19285
19332
  return normalize ? DeviceManager.getInstance().normalizeDeviceId(kind, deviceId, groupId) : deviceId;
19286
19333
  }();
@@ -19348,10 +19395,9 @@ class LocalTrack extends Track {
19348
19395
  if (!constraints) {
19349
19396
  constraints = this._constraints;
19350
19397
  }
19351
- const {
19352
- deviceId,
19353
- facingMode
19354
- } = constraints,
19398
+ const _constraints = constraints,
19399
+ deviceId = _constraints.deviceId,
19400
+ facingMode = _constraints.facingMode,
19355
19401
  otherConstraints = __rest(constraints, ["deviceId", "facingMode"]);
19356
19402
  this.log.debug('restarting track with constraints', Object.assign(Object.assign({}, this.logContext), {
19357
19403
  constraints
@@ -20033,7 +20079,9 @@ function computeVideoEncodings(isScreenShare, width, height, options) {
20033
20079
  if (presets.length > 0) {
20034
20080
  const lowPreset = presets[0];
20035
20081
  if (presets.length > 1) {
20036
- [, midPreset] = presets;
20082
+ var _presets = presets;
20083
+ var _presets2 = _slicedToArray(_presets, 2);
20084
+ midPreset = _presets2[1];
20037
20085
  }
20038
20086
  // NOTE:
20039
20087
  // 1. Ordering of these encodings is important. Chrome seems
@@ -20083,9 +20131,7 @@ function computeTrackBackupEncodings(track, videoCodec, opts) {
20083
20131
  /* @internal */
20084
20132
  function determineAppropriateEncoding(isScreenShare, width, height, codec) {
20085
20133
  const presets = presetsForResolution(isScreenShare, width, height);
20086
- let {
20087
- encoding
20088
- } = presets[0];
20134
+ let encoding = presets[0].encoding;
20089
20135
  // handle portrait by swapping dimensions
20090
20136
  const size = Math.max(width, height);
20091
20137
  for (let i = 0; i < presets.length; i += 1) {
@@ -20131,10 +20177,8 @@ function defaultSimulcastLayers(isScreenShare, original) {
20131
20177
  if (isScreenShare) {
20132
20178
  return computeDefaultScreenShareSimulcastPresets(original);
20133
20179
  }
20134
- const {
20135
- width,
20136
- height
20137
- } = original;
20180
+ const width = original.width,
20181
+ height = original.height;
20138
20182
  const aspect = width > height ? width / height : height / width;
20139
20183
  if (Math.abs(aspect - 16.0 / 9) < Math.abs(aspect - 4.0 / 3)) {
20140
20184
  return defaultSimulcastPresets169;
@@ -20197,13 +20241,12 @@ function encodingsFromPresets(width, height, presets, sourceFramerate) {
20197
20241
  /** @internal */
20198
20242
  function sortPresets(presets) {
20199
20243
  if (!presets) return;
20200
- return presets.sort((a, b) => {
20201
- const {
20202
- encoding: aEnc
20203
- } = a;
20204
- const {
20205
- encoding: bEnc
20206
- } = b;
20244
+ // Sort a copy so we don't mutate the caller's array in place. Mutating the
20245
+ // passed-in simulcast layers can cause consumers that compare options by value
20246
+ // (e.g. components-react's useLiveKitRoom) to detect a spurious change.
20247
+ return presets.slice().sort((a, b) => {
20248
+ const aEnc = a.encoding;
20249
+ const bEnc = b.encoding;
20207
20250
  if (aEnc.maxBitrate > bEnc.maxBitrate) {
20208
20251
  return 1;
20209
20252
  }
@@ -20596,7 +20639,10 @@ class LocalVideoTrack extends LocalTrack {
20596
20639
  yield this.applyEncodingsToSender(this.sender, newEncodings);
20597
20640
  this.encodings = newEncodings;
20598
20641
  this.lastEncodedDimensions = dims;
20599
- for (const [codec, sc] of this.simulcastCodecs) {
20642
+ for (const _ref of this.simulcastCodecs) {
20643
+ var _ref2 = _slicedToArray(_ref, 2);
20644
+ const codec = _ref2[0];
20645
+ const sc = _ref2[1];
20600
20646
  if (!sc.sender || ((_a = sc.sender.transport) === null || _a === void 0 ? void 0 : _a.state) === 'closed') {
20601
20647
  continue;
20602
20648
  }
@@ -20878,9 +20924,7 @@ function setPublishingLayersForSender(sender, senderEncodings, qualities, sender
20878
20924
  }));
20879
20925
  try {
20880
20926
  const params = sender.getParameters();
20881
- const {
20882
- encodings
20883
- } = params;
20927
+ const encodings = params.encodings;
20884
20928
  if (!encodings) {
20885
20929
  return;
20886
20930
  }
@@ -21029,6 +21073,10 @@ var DataChannelKind;
21029
21073
  DataChannelKind[DataChannelKind["LOSSY"] = 1] = "LOSSY";
21030
21074
  DataChannelKind[DataChannelKind["DATA_TRACK_LOSSY"] = 2] = "DATA_TRACK_LOSSY";
21031
21075
  })(DataChannelKind || (DataChannelKind = {}));
21076
+ // Default data-channel max message size (bytes), used when the remote SDP
21077
+ // answer does not advertise an `a=max-message-size` attribute (RFC 8841).
21078
+ // `0` means "no limit".
21079
+ const DEFAULT_MAX_MESSAGE_SIZE = 64000;
21032
21080
  /** @internal */
21033
21081
  class RTCEngine extends eventsExports.EventEmitter {
21034
21082
  get isClosed() {
@@ -21078,9 +21126,7 @@ class RTCEngine extends eventsExports.EventEmitter {
21078
21126
  this.bufferStatusLowClosingFuture = new Future();
21079
21127
  this.handleDataChannel = _a => __awaiter(this, [_a], void 0, function (_ref) {
21080
21128
  var _this = this;
21081
- let {
21082
- channel
21083
- } = _ref;
21129
+ let channel = _ref.channel;
21084
21130
  return function* () {
21085
21131
  if (!channel) {
21086
21132
  return;
@@ -21175,14 +21221,21 @@ class RTCEngine extends eventsExports.EventEmitter {
21175
21221
  this.emit('dataTrackPacketReceived', new Uint8Array(buffer));
21176
21222
  });
21177
21223
  this.handleDataError = event => {
21224
+ // Errors fired while we're tearing the connection down (e.g. the SCTP transport aborting as
21225
+ // the peer connection closes) carry no actionable information — the channel is going away
21226
+ // regardless. Suppress them so a graceful disconnect doesn't surface spurious errors.
21227
+ // See livekit/client-sdk-js#1953.
21228
+ if (this._isClosed) {
21229
+ return;
21230
+ }
21178
21231
  const channel = event.currentTarget;
21179
21232
  const channelKind = channel.maxRetransmits === 0 ? 'lossy' : 'reliable';
21180
- if (event instanceof ErrorEvent && event.error) {
21181
- const {
21182
- error
21183
- } = event.error;
21184
- this.log.error("DataChannel error on ".concat(channelKind, ": ").concat(event.message), {
21185
- error
21233
+ if (typeof RTCErrorEvent !== 'undefined' && event instanceof RTCErrorEvent && event.error) {
21234
+ const error = event.error;
21235
+ this.log.error("DataChannel error on ".concat(channelKind, ": ").concat(error.message), {
21236
+ error,
21237
+ errorDetail: error.errorDetail,
21238
+ sctpCauseCode: error.sctpCauseCode
21186
21239
  });
21187
21240
  } else {
21188
21241
  this.log.error("Unknown DataChannel error on ".concat(channelKind), {
@@ -21190,6 +21243,15 @@ class RTCEngine extends eventsExports.EventEmitter {
21190
21243
  });
21191
21244
  }
21192
21245
  };
21246
+ this.handleDataChannelClose = kind => () => {
21247
+ var _a;
21248
+ // A publisher DC closing while the session is up and the publisher PC is still
21249
+ // connected is the signature of an oversized message having aborted the channel
21250
+ // (see livekit/rust-sdks#1137). Surface it; do not attempt renegotiation.
21251
+ if (!this._isClosed && ((_a = this.pcManager) === null || _a === void 0 ? void 0 : _a.publisher.getConnectionState()) === 'connected') {
21252
+ this.log.error("publisher data channel '".concat(DataChannelKind[kind], "' closed unexpectedly"), this.logContext);
21253
+ }
21254
+ };
21193
21255
  this.handleBufferedAmountLow = channelKind => {
21194
21256
  this.updateAndEmitDCBufferStatus(channelKind);
21195
21257
  };
@@ -21267,6 +21329,16 @@ class RTCEngine extends eventsExports.EventEmitter {
21267
21329
  return dc.bufferedAmount <= dc.bufferedAmountLowThreshold;
21268
21330
  }
21269
21331
  };
21332
+ this.onRtpMapAvailable = rtpTypes => {
21333
+ const rtpMap = new Map();
21334
+ rtpTypes.forEach(rtp => {
21335
+ const codec = rtp.codec.toLowerCase();
21336
+ if (isVideoCodec(codec)) {
21337
+ rtpMap.set(rtp.payload, codec);
21338
+ }
21339
+ });
21340
+ this.emit(EngineEvent.RTPVideoMapUpdate, rtpMap);
21341
+ };
21270
21342
  this.handleBrowserOnLine = () => __awaiter(this, void 0, void 0, function* () {
21271
21343
  if (!this.url) {
21272
21344
  return;
@@ -21359,12 +21431,20 @@ class RTCEngine extends eventsExports.EventEmitter {
21359
21431
  try {
21360
21432
  _this2.joinAttempts += 1;
21361
21433
  _this2.setupSignalClientCallbacks();
21434
+ // Whether the initial publisher offer is bundled with the join request. Computed once and
21435
+ // reused after the join below. Only the (non-Firefox) offer-with-join path does this.
21436
+ const sendOfferWithJoin = !useV0Path && isPublisherOfferWithJoinSupported();
21362
21437
  let offerProto;
21363
- if (!useV0Path && isPublisherOfferWithJoinSupported()) {
21438
+ if (sendOfferWithJoin) {
21364
21439
  if (!_this2.pcManager) {
21440
+ // Firefox is excluded from offer-with-join (see isPublisherOfferWithJoinSupported):
21441
+ // customers reported ICE connectivity problems for FF on this path (#1919) that we were
21442
+ // never able to reproduce, so out of caution FF stays on the deferred path below. The
21443
+ // exact cause is unknown — note that ICE gathering does not actually start here, since
21444
+ // createInitialOffer() defers setLocalDescription (via pendingInitialOffer) until the
21445
+ // answer is applied, after updateConfiguration() has set the server's TURN servers.
21365
21446
  yield _this2.configure();
21366
- _this2.createDataChannels();
21367
- _this2.addMediaSections(initialMediaSectionsAudio, initialMediaSectionsVideo);
21447
+ _this2.applyInitialPublisherLayout();
21368
21448
  }
21369
21449
  const offer = yield (_a = _this2.pcManager) === null || _a === void 0 ? void 0 : _a.publisher.createInitialOffer();
21370
21450
  if (offer) {
@@ -21383,11 +21463,20 @@ class RTCEngine extends eventsExports.EventEmitter {
21383
21463
  _this2.latestJoinResponse = joinResponse;
21384
21464
  _this2.participantSid = (_b = joinResponse.participant) === null || _b === void 0 ? void 0 : _b.sid;
21385
21465
  _this2.subscriberPrimary = joinResponse.subscriberPrimary;
21386
- if (!useV0Path && isPublisherOfferWithJoinSupported()) {
21466
+ if (sendOfferWithJoin) {
21387
21467
  (_c = _this2.pcManager) === null || _c === void 0 ? void 0 : _c.updateConfiguration(_this2.makeRTCConfiguration(joinResponse));
21388
21468
  } else {
21389
21469
  if (!_this2.pcManager) {
21470
+ // Deferred path (Firefox, and V0): configure with the join response so the PC picks up
21471
+ // the server's ICE servers and topology, then negotiate separately rather than bundling
21472
+ // the offer with the join.
21390
21473
  yield _this2.configure(joinResponse, !useV0Path);
21474
+ if (!useV0Path) {
21475
+ // The V1 first offer must carry the media layout so Firefox binds receive decoders for
21476
+ // subscribed tracks — without it, subscribed audio/video arrive as RTP but
21477
+ // never decode. V0 (legacy dual-PC) keeps its original lazy behavior.
21478
+ _this2.applyInitialPublisherLayout();
21479
+ }
21391
21480
  }
21392
21481
  // create offer
21393
21482
  if (!_this2.subscriberPrimary || joinResponse.fastPublish) {
@@ -21407,7 +21496,9 @@ class RTCEngine extends eventsExports.EventEmitter {
21407
21496
  };
21408
21497
  }
21409
21498
  _this2.log.info("connected to Livekit Server ".concat(Object.entries(serverInfo).map(_ref2 => {
21410
- let [key, value] = _ref2;
21499
+ let _ref3 = _slicedToArray(_ref2, 2),
21500
+ key = _ref3[0],
21501
+ value = _ref3[1];
21411
21502
  return "".concat(key, ": ").concat(value);
21412
21503
  }).join(', ')));
21413
21504
  return {
@@ -21460,17 +21551,23 @@ class RTCEngine extends eventsExports.EventEmitter {
21460
21551
  cleanupPeerConnections() {
21461
21552
  return __awaiter(this, void 0, void 0, function* () {
21462
21553
  var _a;
21463
- yield (_a = this.pcManager) === null || _a === void 0 ? void 0 : _a.close();
21464
- this.pcManager = undefined;
21465
21554
  const dcCleanup = dc => {
21466
- if (!dc) return;
21467
- dc.close();
21555
+ if (!dc) {
21556
+ return;
21557
+ }
21558
+ // Detach the data channel handlers before closing anything. Closing a peer connection tears
21559
+ // down the SCTP transport, which can dispatch `error`/`close` events on the still-open data
21560
+ // channels; if our handlers are still attached at that point, handleDataError logs a spurious
21561
+ // "Unknown DataChannel error" during an otherwise graceful disconnect. Removing the handlers
21562
+ // before dc.close()/pcManager.close() makes this deterministic regardless of how/when the
21563
+ // browser dispatches those teardown events. See livekit/client-sdk-js#1953.
21468
21564
  dc.onbufferedamountlow = null;
21469
21565
  dc.onclose = null;
21470
21566
  dc.onclosing = null;
21471
21567
  dc.onerror = null;
21472
21568
  dc.onmessage = null;
21473
21569
  dc.onopen = null;
21570
+ dc.close();
21474
21571
  };
21475
21572
  dcCleanup(this.lossyDC);
21476
21573
  dcCleanup(this.lossyDCSub);
@@ -21478,6 +21575,8 @@ class RTCEngine extends eventsExports.EventEmitter {
21478
21575
  dcCleanup(this.reliableDCSub);
21479
21576
  dcCleanup(this.dataTrackDC);
21480
21577
  dcCleanup(this.dataTrackDCSub);
21578
+ yield (_a = this.pcManager) === null || _a === void 0 ? void 0 : _a.close();
21579
+ this.pcManager = undefined;
21481
21580
  this.lossyDC = undefined;
21482
21581
  this.lossyDCSub = undefined;
21483
21582
  this.reliableDC = undefined;
@@ -21542,9 +21641,7 @@ class RTCEngine extends eventsExports.EventEmitter {
21542
21641
  */
21543
21642
  removeTrack(sender) {
21544
21643
  if (sender.track && this.pendingTrackResolvers[sender.track.id]) {
21545
- const {
21546
- reject
21547
- } = this.pendingTrackResolvers[sender.track.id];
21644
+ const reject = this.pendingTrackResolvers[sender.track.id].reject;
21548
21645
  if (reject) {
21549
21646
  reject();
21550
21647
  }
@@ -21683,9 +21780,7 @@ class RTCEngine extends eventsExports.EventEmitter {
21683
21780
  });
21684
21781
  return;
21685
21782
  }
21686
- const {
21687
- resolve
21688
- } = this.pendingTrackResolvers[res.cid];
21783
+ const resolve = this.pendingTrackResolvers[res.cid].resolve;
21689
21784
  delete this.pendingTrackResolvers[res.cid];
21690
21785
  resolve(res.track);
21691
21786
  };
@@ -21754,12 +21849,12 @@ class RTCEngine extends eventsExports.EventEmitter {
21754
21849
  };
21755
21850
  }
21756
21851
  makeRTCConfiguration(serverResponse) {
21757
- var _a, _b;
21852
+ var _a;
21758
21853
  const rtcConfig = Object.assign({}, this.rtcConfig);
21759
21854
  // E2EE and packet trailer extraction both rely on encoded frame transforms.
21760
21855
  // Only opt into the createEncodedStreams flavor when that path will be
21761
21856
  // used; RTCRtpScriptTransform does not need the PeerConnection flag.
21762
- const needsInsertableStreams = ((_a = this.signalOpts) === null || _a === void 0 ? void 0 : _a.e2eeEnabled) || ((_b = this.options.packetTrailer) === null || _b === void 0 ? void 0 : _b.worker) && !shouldUsePacketTrailerScriptTransform();
21857
+ const needsInsertableStreams = ((_a = this.signalOpts) === null || _a === void 0 ? void 0 : _a.e2eeEnabled) || this.frameMetadataWorker && !shouldUseFrameMetadataScriptTransform();
21763
21858
  if (needsInsertableStreams && isInsertableStreamSupported()) {
21764
21859
  this.log.debug('E2EE - setting up transports with insertable streams');
21765
21860
  // this makes sure that no data is sent before the transforms are ready
@@ -21793,6 +21888,24 @@ class RTCEngine extends eventsExports.EventEmitter {
21793
21888
  }
21794
21889
  return rtcConfig;
21795
21890
  }
21891
+ /**
21892
+ * Populate the publisher PC so its first offer carries the data channels + recvonly media
21893
+ * sections. Required for every V1 connection: Firefox only binds receive decoders for media
21894
+ * present in that first offer, and the offer-with-join path needs the sections to
21895
+ * build a meaningful initial offer. Must be called on a configured pcManager.
21896
+ */
21897
+ applyInitialPublisherLayout() {
21898
+ this.createDataChannels();
21899
+ /**
21900
+ * Native libwebrtc does not support pre-populating the media sections,
21901
+ * so we skip it for React Native.
21902
+ *
21903
+ * Related: https://github.com/livekit/rust-sdks/pull/1151
21904
+ */
21905
+ if (!isReactNative()) {
21906
+ this.addMediaSections(initialMediaSectionsAudio, initialMediaSectionsVideo);
21907
+ }
21908
+ }
21796
21909
  addMediaSections(numAudios, numVideos) {
21797
21910
  var _a, _b;
21798
21911
  const transceiverInit = {
@@ -21813,14 +21926,17 @@ class RTCEngine extends eventsExports.EventEmitter {
21813
21926
  if (this.lossyDC) {
21814
21927
  this.lossyDC.onmessage = null;
21815
21928
  this.lossyDC.onerror = null;
21929
+ this.lossyDC.onclose = null;
21816
21930
  }
21817
21931
  if (this.reliableDC) {
21818
21932
  this.reliableDC.onmessage = null;
21819
21933
  this.reliableDC.onerror = null;
21934
+ this.reliableDC.onclose = null;
21820
21935
  }
21821
21936
  if (this.dataTrackDC) {
21822
21937
  this.dataTrackDC.onmessage = null;
21823
21938
  this.dataTrackDC.onerror = null;
21939
+ this.dataTrackDC.onclose = null;
21824
21940
  }
21825
21941
  // create data channels
21826
21942
  this.lossyDC = this.pcManager.createPublisherDataChannel(lossyDataChannel, {
@@ -21842,6 +21958,10 @@ class RTCEngine extends eventsExports.EventEmitter {
21842
21958
  this.lossyDC.onerror = this.handleDataError;
21843
21959
  this.reliableDC.onerror = this.handleDataError;
21844
21960
  this.dataTrackDC.onerror = this.handleDataError;
21961
+ // detect unexpected publisher data channel closes
21962
+ this.lossyDC.onclose = this.handleDataChannelClose(DataChannelKind.LOSSY);
21963
+ this.reliableDC.onclose = this.handleDataChannelClose(DataChannelKind.RELIABLE);
21964
+ this.dataTrackDC.onclose = this.handleDataChannelClose(DataChannelKind.DATA_TRACK_LOSSY);
21845
21965
  // set up dc buffer threshold, set to 64kB (otherwise 0 by default)
21846
21966
  this.lossyDC.bufferedAmountLowThreshold = 65535;
21847
21967
  this.reliableDC.bufferedAmountLowThreshold = 65535;
@@ -21873,7 +21993,7 @@ class RTCEngine extends eventsExports.EventEmitter {
21873
21993
  } else {
21874
21994
  throw new UnexpectedConnectionState('Required webRTC APIs not supported on this device');
21875
21995
  }
21876
- this.setupPacketTrailerSender(sender, opts);
21996
+ this.setupFrameMetadataSender(sender, opts);
21877
21997
  return sender;
21878
21998
  });
21879
21999
  }
@@ -21889,47 +22009,51 @@ class RTCEngine extends eventsExports.EventEmitter {
21889
22009
  throw new UnexpectedConnectionState('Cannot stream on this device');
21890
22010
  }
21891
22011
  if (sender) {
21892
- this.setupPacketTrailerSender(sender, opts);
22012
+ this.setupFrameMetadataSender(sender, opts);
21893
22013
  }
21894
22014
  return sender;
21895
22015
  });
21896
22016
  }
21897
- setupPacketTrailerSender(sender) {
21898
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
22017
+ get frameMetadataWorker() {
21899
22018
  var _a, _b;
21900
- if (!((_a = this.options.packetTrailer) === null || _a === void 0 ? void 0 : _a.worker) || ((_b = this.signalOpts) === null || _b === void 0 ? void 0 : _b.e2eeEnabled)) {
22019
+ return (_b = (_a = this.options.frameMetadata) !== null && _a !== void 0 ? _a : this.options.packetTrailer) === null || _b === void 0 ? void 0 : _b.worker;
22020
+ }
22021
+ setupFrameMetadataSender(sender) {
22022
+ let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
22023
+ var _a, _b, _c;
22024
+ const worker = this.frameMetadataWorker;
22025
+ if (!worker || ((_a = this.signalOpts) === null || _a === void 0 ? void 0 : _a.e2eeEnabled)) {
21901
22026
  return;
21902
22027
  }
21903
- const packetTrailer = opts.packetTrailer;
21904
- const hasPacketTrailer = hasPacketTrailerPublishOptions(packetTrailer);
21905
- if (shouldUsePacketTrailerScriptTransform()) {
21906
- if (hasPacketTrailer) {
22028
+ const frameMetadata = (_b = opts.frameMetadata) !== null && _b !== void 0 ? _b : opts.packetTrailer;
22029
+ const hasMetadata = hasFrameMetadataPublishOptions(frameMetadata);
22030
+ if (shouldUseFrameMetadataScriptTransform()) {
22031
+ if (hasMetadata) {
21907
22032
  // @ts-ignore
21908
- sender.transform = new RTCRtpScriptTransform(this.options.packetTrailer.worker, {
22033
+ sender.transform = new RTCRtpScriptTransform(worker, {
21909
22034
  kind: 'encode',
21910
- packetTrailer
22035
+ packetTrailer: frameMetadata
21911
22036
  });
21912
22037
  }
21913
22038
  return;
21914
22039
  }
21915
- if (!isPacketTrailerSupported(this.options.packetTrailer) || !('createEncodedStreams' in sender)) {
21916
- if (hasPacketTrailer) {
21917
- this.log.warn('packet trailer transform not supported; skipping write', this.logContext);
22040
+ if (!isFrameMetadataSupported((_c = this.options.frameMetadata) !== null && _c !== void 0 ? _c : this.options.packetTrailer) || !('createEncodedStreams' in sender)) {
22041
+ if (hasMetadata) {
22042
+ this.log.warn('frame metadata transform not supported; skipping write', this.logContext);
21918
22043
  }
21919
22044
  return;
21920
22045
  }
21921
22046
  // @ts-ignore
21922
- const {
21923
- readable,
21924
- writable
21925
- } = sender.createEncodedStreams();
21926
- if (hasPacketTrailer) {
21927
- this.options.packetTrailer.worker.postMessage({
22047
+ const _sender$createEncoded = sender.createEncodedStreams(),
22048
+ readable = _sender$createEncoded.readable,
22049
+ writable = _sender$createEncoded.writable;
22050
+ if (hasMetadata) {
22051
+ worker.postMessage({
21928
22052
  kind: 'encode',
21929
22053
  data: {
21930
22054
  readableStream: readable,
21931
22055
  writableStream: writable,
21932
- packetTrailer
22056
+ packetTrailer: frameMetadata
21933
22057
  }
21934
22058
  }, [readable, writable]);
21935
22059
  } else {
@@ -22217,6 +22341,7 @@ class RTCEngine extends eventsExports.EventEmitter {
22217
22341
  /* @internal */
22218
22342
  sendDataPacket(packet, kind) {
22219
22343
  return __awaiter(this, void 0, void 0, function* () {
22344
+ var _a, _b;
22220
22345
  // make sure we do have a data connection
22221
22346
  yield this.ensurePublisherConnected(kind);
22222
22347
  if (this.e2eeManager && this.e2eeManager.isDataChannelEncryptionEnabled) {
@@ -22238,6 +22363,13 @@ class RTCEngine extends eventsExports.EventEmitter {
22238
22363
  this.reliableDataSequence += 1;
22239
22364
  }
22240
22365
  const msg = packet.toBinary();
22366
+ // Clamp to the SDK default - libwebrtc advertises larger (~256 KiB)
22367
+ // than LiveKit/pion can deliver end-to-end (~64 KiB), so we trust
22368
+ // the answer up untilthe built in ceiling.
22369
+ const maxPublisherMessageSizeBytes = Math.min((_b = (_a = this.pcManager) === null || _a === void 0 ? void 0 : _a.getMaxPublisherMessageSize()) !== null && _b !== void 0 ? _b : DEFAULT_MAX_MESSAGE_SIZE, DEFAULT_MAX_MESSAGE_SIZE);
22370
+ if (typeof maxPublisherMessageSizeBytes !== 'undefined' && maxPublisherMessageSizeBytes !== 0 /* 0 means "no limit" */ && msg.byteLength > maxPublisherMessageSizeBytes) {
22371
+ throw new PublishDataError("cannot publish data packet larger than ".concat(maxPublisherMessageSizeBytes, " bytes (got ").concat(msg.byteLength, ")"));
22372
+ }
22241
22373
  switch (kind) {
22242
22374
  case DataChannelKind.LOSSY:
22243
22375
  case DataChannelKind.DATA_TRACK_LOSSY:
@@ -22428,16 +22560,8 @@ class RTCEngine extends eventsExports.EventEmitter {
22428
22560
  }
22429
22561
  this.on(EngineEvent.Closing, handleClosed);
22430
22562
  this.on(EngineEvent.Restarting, handleClosed);
22431
- this.pcManager.publisher.once(PCEvents.RTPVideoPayloadTypes, rtpTypes => {
22432
- const rtpMap = new Map();
22433
- rtpTypes.forEach(rtp => {
22434
- const codec = rtp.codec.toLowerCase();
22435
- if (isVideoCodec(codec)) {
22436
- rtpMap.set(rtp.payload, codec);
22437
- }
22438
- });
22439
- this.emit(EngineEvent.RTPVideoMapUpdate, rtpMap);
22440
- });
22563
+ this.pcManager.publisher.off(PCEvents.RTPVideoPayloadTypes, this.onRtpMapAvailable);
22564
+ this.pcManager.publisher.once(PCEvents.RTPVideoPayloadTypes, this.onRtpMapAvailable);
22441
22565
  try {
22442
22566
  yield this.pcManager.negotiate(abortController);
22443
22567
  resolve();
@@ -22601,8 +22725,9 @@ class RTCEngine extends eventsExports.EventEmitter {
22601
22725
  var _a;
22602
22726
  const mid = (_a = this.pcManager) === null || _a === void 0 ? void 0 : _a.getMidForReceiver(receiver);
22603
22727
  if (mid) {
22604
- const match = Object.entries(this.midToTrackId).find(_ref3 => {
22605
- let [key] = _ref3;
22728
+ const match = Object.entries(this.midToTrackId).find(_ref4 => {
22729
+ let _ref5 = _slicedToArray(_ref4, 1),
22730
+ key = _ref5[0];
22606
22731
  return key === mid;
22607
22732
  });
22608
22733
  if (match) {
@@ -23101,10 +23226,9 @@ class TextStreamReader extends BaseStreamReader {
23101
23226
  flushBufferedPackets() {
23102
23227
  const packets = this.bufferedPackets;
23103
23228
  this.bufferedPackets = [];
23104
- for (const {
23105
- packet,
23106
- encryptionType
23107
- } of packets) {
23229
+ for (const _ref of packets) {
23230
+ const packet = _ref.packet;
23231
+ const encryptionType = _ref.encryptionType;
23108
23232
  this.handleDataStreamPacket(packet, encryptionType);
23109
23233
  }
23110
23234
  }
@@ -23137,11 +23261,17 @@ class TextStreamReader extends BaseStreamReader {
23137
23261
  const byteStreamsBeingSentByDisconnectingParticipant = Array.from(this.byteStreamControllers.entries()).filter(entry => entry[1].sendingParticipantIdentity === participantIdentity);
23138
23262
  if (textStreamsBeingSentByDisconnectingParticipant.length > 0 || byteStreamsBeingSentByDisconnectingParticipant.length > 0) {
23139
23263
  const abnormalEndError = new DataStreamError("Participant ".concat(participantIdentity, " unexpectedly disconnected in the middle of sending data"), DataStreamErrorReason.AbnormalEnd);
23140
- for (const [id, controller] of byteStreamsBeingSentByDisconnectingParticipant) {
23264
+ for (const _ref2 of byteStreamsBeingSentByDisconnectingParticipant) {
23265
+ var _ref3 = _slicedToArray(_ref2, 2);
23266
+ const id = _ref3[0];
23267
+ const controller = _ref3[1];
23141
23268
  controller.controller.error(abnormalEndError);
23142
23269
  this.byteStreamControllers.delete(id);
23143
23270
  }
23144
- for (const [id, controller] of textStreamsBeingSentByDisconnectingParticipant) {
23271
+ for (const _ref4 of textStreamsBeingSentByDisconnectingParticipant) {
23272
+ var _ref5 = _slicedToArray(_ref4, 2);
23273
+ const id = _ref5[0];
23274
+ const controller = _ref5[1];
23145
23275
  controller.controller.error(abnormalEndError);
23146
23276
  this.textStreamControllers.delete(id);
23147
23277
  }
@@ -23471,10 +23601,9 @@ class OutgoingDataStreamManager {
23471
23601
  });
23472
23602
  const reader = file.stream().getReader();
23473
23603
  while (true) {
23474
- const {
23475
- done,
23476
- value
23477
- } = yield reader.read();
23604
+ const _yield$reader$read = yield reader.read(),
23605
+ done = _yield$reader$read.done,
23606
+ value = _yield$reader$read.value;
23478
23607
  if (done) {
23479
23608
  break;
23480
23609
  }
@@ -23938,7 +24067,10 @@ const DataTrackSymbol = Symbol.for('lk.data-track');class RemoteDataTrack {
23938
24067
  */
23939
24068
  subscribe(options) {
23940
24069
  try {
23941
- const [stream, sfuSubscriptionComplete] = this.manager.openSubscriptionStream(this.info.sid, options === null || options === void 0 ? void 0 : options.signal, options === null || options === void 0 ? void 0 : options.bufferSize);
24070
+ const _this$manager$openSub = this.manager.openSubscriptionStream(this.info.sid, options === null || options === void 0 ? void 0 : options.signal, options === null || options === void 0 ? void 0 : options.bufferSize),
24071
+ _this$manager$openSub2 = _slicedToArray(_this$manager$openSub, 2),
24072
+ stream = _this$manager$openSub2[0],
24073
+ sfuSubscriptionComplete = _this$manager$openSub2[1];
23942
24074
  // Prevent uncaught promise rejections from bubbling up if rejections occur after the
23943
24075
  // readable stream is discarded.
23944
24076
  sfuSubscriptionComplete.catch(() => {});
@@ -23977,10 +24109,9 @@ class DataTrackPacketHeader extends Serializable {
23977
24109
  };
23978
24110
  }
23979
24111
  toBinaryLengthBytes() {
23980
- const {
23981
- lengthBytes: extLengthBytes,
23982
- paddingLengthBytes: extPaddingLengthBytes
23983
- } = this.extensionsMetrics();
24112
+ const _this$extensionsMetri = this.extensionsMetrics(),
24113
+ extLengthBytes = _this$extensionsMetri.lengthBytes,
24114
+ extPaddingLengthBytes = _this$extensionsMetri.paddingLengthBytes;
23984
24115
  let totalLengthBytes = BASE_HEADER_LEN;
23985
24116
  if (extLengthBytes > 0) {
23986
24117
  totalLengthBytes += EXT_WORDS_INDICATOR_SIZE + extLengthBytes + extPaddingLengthBytes;
@@ -24008,11 +24139,10 @@ class DataTrackPacketHeader extends Serializable {
24008
24139
  break;
24009
24140
  }
24010
24141
  initial |= marker << FRAME_MARKER_SHIFT;
24011
- const {
24012
- lengthBytes: extensionsLengthBytes,
24013
- lengthWords: extensionsLengthWords,
24014
- paddingLengthBytes: extensionsPaddingLengthBytes
24015
- } = this.extensionsMetrics();
24142
+ const _this$extensionsMetri2 = this.extensionsMetrics(),
24143
+ extensionsLengthBytes = _this$extensionsMetri2.lengthBytes,
24144
+ extensionsLengthWords = _this$extensionsMetri2.lengthWords,
24145
+ extensionsPaddingLengthBytes = _this$extensionsMetri2.paddingLengthBytes;
24016
24146
  if (extensionsLengthBytes > 0) {
24017
24147
  initial |= 1 << EXT_FLAG_SHIFT;
24018
24148
  }
@@ -24115,7 +24245,10 @@ class DataTrackPacketHeader extends Serializable {
24115
24245
  throw DataTrackDeserializeError.headerOverrun();
24116
24246
  }
24117
24247
  let extensionDataView = new DataView(dataView.buffer, dataView.byteOffset + byteIndex, extensionLengthBytes);
24118
- const [result, readBytes] = DataTrackExtensions.fromBinary(extensionDataView);
24248
+ const _DataTrackExtensions$ = DataTrackExtensions.fromBinary(extensionDataView),
24249
+ _DataTrackExtensions$2 = _slicedToArray(_DataTrackExtensions$, 2),
24250
+ result = _DataTrackExtensions$2[0],
24251
+ readBytes = _DataTrackExtensions$2[1];
24119
24252
  extensions = result;
24120
24253
  byteIndex += readBytes;
24121
24254
  }
@@ -24181,7 +24314,10 @@ class DataTrackPacket extends Serializable {
24181
24314
  }
24182
24315
  static fromBinary(input) {
24183
24316
  const dataView = coerceToDataView(input);
24184
- const [header, headerByteLength] = DataTrackPacketHeader.fromBinary(dataView);
24317
+ const _DataTrackPacketHeade = DataTrackPacketHeader.fromBinary(dataView),
24318
+ _DataTrackPacketHeade2 = _slicedToArray(_DataTrackPacketHeade, 2),
24319
+ header = _DataTrackPacketHeade2[0],
24320
+ headerByteLength = _DataTrackPacketHeade2[1];
24185
24321
  const payload = dataView.buffer.slice(dataView.byteOffset + headerByteLength, dataView.byteOffset + dataView.byteLength);
24186
24322
  return [new DataTrackPacket(header, new Uint8Array(payload)), dataView.byteLength];
24187
24323
  }
@@ -24783,7 +24919,10 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
24783
24919
  * subscription. Used when the subscription is being torn down by the manager (unsubscribe,
24784
24920
  * unpublish, or shutdown). */
24785
24921
  closeStreamControllers(streamControllers, sid) {
24786
- for (const [controller, detachSignal] of streamControllers) {
24922
+ for (const _ref of streamControllers) {
24923
+ var _ref2 = _slicedToArray(_ref, 2);
24924
+ const controller = _ref2[0];
24925
+ const detachSignal = _ref2[1];
24787
24926
  // Detach before close so we don't leak a listener on the user's AbortSignal.
24788
24927
  detachSignal();
24789
24928
  try {
@@ -24812,7 +24951,10 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
24812
24951
  }
24813
24952
  // Detect published track
24814
24953
  const publisherParticipantToSidsInUpdate = new Map();
24815
- for (const [publisherIdentity, infos] of updates.entries()) {
24954
+ for (const _ref3 of updates.entries()) {
24955
+ var _ref4 = _slicedToArray(_ref3, 2);
24956
+ const publisherIdentity = _ref4[0];
24957
+ const infos = _ref4[1];
24816
24958
  const sidsInUpdate = new Set();
24817
24959
  for (const info of infos) {
24818
24960
  sidsInUpdate.add(info.sid);
@@ -24824,12 +24966,18 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
24824
24966
  publisherParticipantToSidsInUpdate.set(publisherIdentity, sidsInUpdate);
24825
24967
  }
24826
24968
  // Detect unpublished tracks
24827
- for (const [publisherIdentity, sidsInUpdate] of publisherParticipantToSidsInUpdate.entries()) {
24828
- const descriptorsForPublisher = Array.from(this.descriptors.entries()).filter(_ref => {
24829
- let [_sid, descriptor] = _ref;
24969
+ for (const _ref5 of publisherParticipantToSidsInUpdate.entries()) {
24970
+ var _ref6 = _slicedToArray(_ref5, 2);
24971
+ const publisherIdentity = _ref6[0];
24972
+ const sidsInUpdate = _ref6[1];
24973
+ const descriptorsForPublisher = Array.from(this.descriptors.entries()).filter(_ref7 => {
24974
+ let _ref8 = _slicedToArray(_ref7, 2);
24975
+ _ref8[0];
24976
+ let descriptor = _ref8[1];
24830
24977
  return descriptor.publisherIdentity === publisherIdentity;
24831
- }).map(_ref2 => {
24832
- let [sid] = _ref2;
24978
+ }).map(_ref9 => {
24979
+ let _ref0 = _slicedToArray(_ref9, 1),
24980
+ sid = _ref0[0];
24833
24981
  return sid;
24834
24982
  });
24835
24983
  let unpublishedSids = descriptorsForPublisher.filter(sid => !sidsInUpdate.has(sid));
@@ -24891,7 +25039,10 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
24891
25039
  /** Mapping between track handles attached to incoming packets to the
24892
25040
  * track SIDs they belong to. */
24893
25041
  mapping) {
24894
- for (const [handle, sid] of mapping.entries()) {
25042
+ for (const _ref1 of mapping.entries()) {
25043
+ var _ref10 = _slicedToArray(_ref1, 2);
25044
+ const handle = _ref10[0];
25045
+ const sid = _ref10[1];
24895
25046
  this.registerSubscriberHandle(handle, sid);
24896
25047
  }
24897
25048
  }
@@ -24941,7 +25092,9 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
24941
25092
  return __awaiter(this, void 0, void 0, function* () {
24942
25093
  let packet;
24943
25094
  try {
24944
- [packet] = DataTrackPacket.fromBinary(bytes);
25095
+ var _DataTrackPacket$from = DataTrackPacket.fromBinary(bytes);
25096
+ var _DataTrackPacket$from2 = _slicedToArray(_DataTrackPacket$from, 1);
25097
+ packet = _DataTrackPacket$from2[0];
24945
25098
  } catch (err) {
24946
25099
  log$1.error("Failed to deserialize packet: ".concat(err));
24947
25100
  return;
@@ -24982,7 +25135,10 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
24982
25135
  * tracks are subscribed to locally.
24983
25136
  */
24984
25137
  resendSubscriptionUpdates() {
24985
- for (const [sid, descriptor] of this.descriptors) {
25138
+ for (const _ref11 of this.descriptors) {
25139
+ var _ref12 = _slicedToArray(_ref11, 2);
25140
+ const sid = _ref12[0];
25141
+ const descriptor = _ref12[1];
24986
25142
  if (descriptor.subscription.type === 'none') {
24987
25143
  continue;
24988
25144
  }
@@ -25091,7 +25247,8 @@ class DataTrackPacketizer {
25091
25247
  }
25092
25248
  const maxPayloadSizeBytes = this.mtuSizeBytes - headerSerializedLengthBytes;
25093
25249
  const packetCount = Math.ceil(frame.payload.byteLength / maxPayloadSizeBytes);
25094
- for (let index = 0, indexBytes = 0; indexBytes < frame.payload.byteLength; [index, indexBytes] = [index + 1, indexBytes + maxPayloadSizeBytes]) {
25250
+ for (let index = 0, indexBytes = 0; indexBytes < frame.payload.byteLength; _ref = [index + 1, indexBytes + maxPayloadSizeBytes], index = _ref[0], indexBytes = _ref[1], _ref) {
25251
+ var _ref;
25095
25252
  const sequence = this.sequence.getThenIncrement();
25096
25253
  const packetHeader = new DataTrackPacketHeader(Object.assign(Object.assign({}, headerParams), {
25097
25254
  marker: DataTrackPacketizer.computeFrameMarker(index, packetCount),
@@ -25699,7 +25856,10 @@ class OutgoingDataTrackManager extends eventsExports.EventEmitter {
25699
25856
  */
25700
25857
  sfuWillRepublishTracks() {
25701
25858
  var _a, _b;
25702
- for (const [handle, descriptor] of this.descriptors.entries()) {
25859
+ for (const _ref of this.descriptors.entries()) {
25860
+ var _ref2 = _slicedToArray(_ref, 2);
25861
+ const handle = _ref2[0];
25862
+ const descriptor = _ref2[1];
25703
25863
  switch (descriptor.type) {
25704
25864
  case 'pending':
25705
25865
  // TODO: support republish for pending publications
@@ -25889,7 +26049,7 @@ function truncateBytes(str, maxBytes) {
25889
26049
  * ack/response state, and handling incoming ack/response packets.
25890
26050
  * @internal
25891
26051
  */
25892
- class RpcClientManager extends EventEmitter {
26052
+ class RpcClientManager extends eventsExports.EventEmitter {
25893
26053
  constructor(log, outgoingDataStreamManager, getRemoteParticipantClientProtocol, getServerVersion) {
25894
26054
  super();
25895
26055
  this.pendingAcks = new Map();
@@ -25902,12 +26062,11 @@ class RpcClientManager extends EventEmitter {
25902
26062
  performRpc(_a) {
25903
26063
  return __awaiter(this, arguments, void 0, function (_ref) {
25904
26064
  var _this = this;
25905
- let {
25906
- destinationIdentity,
25907
- method,
25908
- payload,
25909
- responseTimeout: responseTimeoutMs = 15000
25910
- } = _ref;
26065
+ let destinationIdentity = _ref.destinationIdentity,
26066
+ method = _ref.method,
26067
+ payload = _ref.payload,
26068
+ _ref$responseTimeout = _ref.responseTimeout,
26069
+ responseTimeoutMs = _ref$responseTimeout === void 0 ? 15000 : _ref$responseTimeout;
25911
26070
  return function* () {
25912
26071
  const maxRoundTripLatencyMs = 7000;
25913
26072
  const minEffectiveTimeoutMs = maxRoundTripLatencyMs + 1000;
@@ -25924,12 +26083,15 @@ class RpcClientManager extends EventEmitter {
25924
26083
  const effectiveTimeoutMs = Math.max(responseTimeoutMs, minEffectiveTimeoutMs);
25925
26084
  const id = crypto.randomUUID();
25926
26085
  const completionFuture = new Future();
26086
+ let responseTimeoutId = null;
25927
26087
  const ackTimeoutId = setTimeout(() => {
25928
26088
  var _a;
25929
26089
  _this.pendingAcks.delete(id);
25930
26090
  (_a = completionFuture.reject) === null || _a === void 0 ? void 0 : _a.call(completionFuture, RpcError.builtIn('CONNECTION_TIMEOUT'));
25931
26091
  _this.pendingResponses.delete(id);
25932
- clearTimeout(responseTimeoutId);
26092
+ if (responseTimeoutId !== null) {
26093
+ clearTimeout(responseTimeoutId);
26094
+ }
25933
26095
  }, maxRoundTripLatencyMs);
25934
26096
  _this.pendingAcks.set(id, {
25935
26097
  resolve: () => {
@@ -25942,7 +26104,7 @@ class RpcClientManager extends EventEmitter {
25942
26104
  participantIdentity: destinationIdentity
25943
26105
  });
25944
26106
  yield _this.publishRpcRequest(destinationIdentity, id, method, payload, effectiveTimeoutMs, remoteClientProtocol);
25945
- const responseTimeoutId = setTimeout(() => {
26107
+ responseTimeoutId = setTimeout(() => {
25946
26108
  var _a;
25947
26109
  _this.pendingResponses.delete(id);
25948
26110
  (_a = completionFuture.reject) === null || _a === void 0 ? void 0 : _a.call(completionFuture, RpcError.builtIn('RESPONSE_TIMEOUT'));
@@ -26062,17 +26224,20 @@ class RpcClientManager extends EventEmitter {
26062
26224
  /** @internal */
26063
26225
  handleParticipantDisconnected(participantIdentity) {
26064
26226
  var _a;
26065
- for (const [id, {
26066
- participantIdentity: pendingIdentity
26067
- }] of this.pendingAcks) {
26227
+ for (const _ref2 of this.pendingAcks) {
26228
+ var _ref3 = _slicedToArray(_ref2, 2);
26229
+ const id = _ref3[0];
26230
+ const pendingIdentity = _ref3[1].participantIdentity;
26068
26231
  if (pendingIdentity === participantIdentity) {
26069
26232
  this.pendingAcks.delete(id);
26070
26233
  }
26071
26234
  }
26072
- for (const [id, {
26073
- participantIdentity: pendingIdentity,
26074
- completionFuture
26075
- }] of this.pendingResponses) {
26235
+ for (const _ref4 of this.pendingResponses) {
26236
+ var _ref5 = _slicedToArray(_ref4, 2);
26237
+ const id = _ref5[0];
26238
+ var _ref5$ = _ref5[1];
26239
+ const pendingIdentity = _ref5$.participantIdentity;
26240
+ const completionFuture = _ref5$.completionFuture;
26076
26241
  if (pendingIdentity === participantIdentity) {
26077
26242
  (_a = completionFuture.reject) === null || _a === void 0 ? void 0 : _a.call(completionFuture, RpcError.builtIn('RECIPIENT_DISCONNECTED'));
26078
26243
  this.pendingResponses.delete(id);
@@ -26084,7 +26249,7 @@ class RpcClientManager extends EventEmitter {
26084
26249
  * managing registered method handlers, and sending responses.
26085
26250
  * @internal
26086
26251
  */
26087
- class RpcServerManager extends EventEmitter {
26252
+ class RpcServerManager extends eventsExports.EventEmitter {
26088
26253
  constructor(log, outgoingDataStreamManager, getRemoteParticipantClientProtocol) {
26089
26254
  super();
26090
26255
  this.rpcHandlers = new Map();
@@ -26681,11 +26846,10 @@ function createLocalTracks(options, loggerOptions) {
26681
26846
  return __awaiter(this, void 0, void 0, function* () {
26682
26847
  options !== null && options !== void 0 ? options : options = {};
26683
26848
  let attemptExactMatch = false;
26684
- const {
26685
- audioProcessor,
26686
- videoProcessor,
26687
- optionsWithoutProcessor: internalOptions
26688
- } = extractProcessorsFromOptions(options);
26849
+ const _extractProcessorsFro = extractProcessorsFromOptions(options),
26850
+ audioProcessor = _extractProcessorsFro.audioProcessor,
26851
+ videoProcessor = _extractProcessorsFro.videoProcessor,
26852
+ internalOptions = _extractProcessorsFro.optionsWithoutProcessor;
26689
26853
  let retryAudioOptions = internalOptions.audio;
26690
26854
  let retryVideoOptions = internalOptions.video;
26691
26855
  if (audioProcessor && typeof internalOptions.audio === 'object') {
@@ -26927,7 +27091,9 @@ class Participant extends eventsExports.EventEmitter {
26927
27091
  * the user's camera track with getTrackBySource(Track.Source.Camera).
26928
27092
  */
26929
27093
  getTrackPublication(source) {
26930
- for (const [, pub] of this.trackPublications) {
27094
+ for (const _ref of this.trackPublications) {
27095
+ var _ref2 = _slicedToArray(_ref, 2);
27096
+ const pub = _ref2[1];
26931
27097
  if (pub.source === source) {
26932
27098
  return pub;
26933
27099
  }
@@ -26937,7 +27103,9 @@ class Participant extends eventsExports.EventEmitter {
26937
27103
  * Finds the first track that matches the track's name.
26938
27104
  */
26939
27105
  getTrackPublicationByName(name) {
26940
- for (const [, pub] of this.trackPublications) {
27106
+ for (const _ref3 of this.trackPublications) {
27107
+ var _ref4 = _slicedToArray(_ref3, 2);
27108
+ const pub = _ref4[1];
26941
27109
  if (pub.trackName === name) {
26942
27110
  return pub;
26943
27111
  }
@@ -27180,11 +27348,9 @@ class Participant extends eventsExports.EventEmitter {
27180
27348
  (_b = (_a = this.signalConnectedFuture).resolve) === null || _b === void 0 ? void 0 : _b.call(_a);
27181
27349
  };
27182
27350
  this.handleSignalRequestResponse = response => {
27183
- const {
27184
- requestId,
27185
- reason,
27186
- message
27187
- } = response;
27351
+ const requestId = response.requestId,
27352
+ reason = response.reason,
27353
+ message = response.message;
27188
27354
  const targetRequest = this.pendingSignalRequests.get(requestId);
27189
27355
  if (targetRequest) {
27190
27356
  if (reason !== RequestResponse_Reason.OK) {
@@ -27460,11 +27626,9 @@ class Participant extends eventsExports.EventEmitter {
27460
27626
  requestMetadataUpdate(_a) {
27461
27627
  return __awaiter(this, arguments, void 0, function (_ref) {
27462
27628
  var _this = this;
27463
- let {
27464
- metadata,
27465
- name,
27466
- attributes
27467
- } = _ref;
27629
+ let metadata = _ref.metadata,
27630
+ name = _ref.name,
27631
+ attributes = _ref.attributes;
27468
27632
  return function* () {
27469
27633
  return new TypedPromise((resolve, reject) => __awaiter(_this, void 0, void 0, function* () {
27470
27634
  var _a, _b;
@@ -27486,7 +27650,9 @@ class Participant extends eventsExports.EventEmitter {
27486
27650
  });
27487
27651
  while (performance.now() - startTime < 5000 && !isRejected) {
27488
27652
  if ((!name || this.name === name) && (!metadata || this.metadata === metadata) && (!attributes || Object.entries(attributes).every(_ref2 => {
27489
- let [key, value] = _ref2;
27653
+ let _ref3 = _slicedToArray(_ref2, 2),
27654
+ key = _ref3[0],
27655
+ value = _ref3[1];
27490
27656
  return this.attributes[key] === value || value === '' && !this.attributes[key];
27491
27657
  }))) {
27492
27658
  this.pendingSignalRequests.delete(requestId);
@@ -27619,7 +27785,8 @@ class Participant extends eventsExports.EventEmitter {
27619
27785
  const publishedTracks = yield Promise.all(publishPromises);
27620
27786
  // for screen share publications including audio, this will only return the screen share publication, not the screen share audio one
27621
27787
  // revisit if we want to return an array of tracks instead for v2
27622
- [track] = publishedTracks;
27788
+ var _publishedTracks = _slicedToArray(publishedTracks, 1);
27789
+ track = _publishedTracks[0];
27623
27790
  } catch (e) {
27624
27791
  localTracks === null || localTracks === void 0 ? void 0 : localTracks.forEach(tr => {
27625
27792
  tr.stop();
@@ -27647,7 +27814,9 @@ class Participant extends eventsExports.EventEmitter {
27647
27814
  if (screenAudioTrack && screenAudioTrack.track) {
27648
27815
  unpublishPromises.push(this.unpublishTrack(screenAudioTrack.track));
27649
27816
  }
27650
- [track] = yield Promise.all(unpublishPromises);
27817
+ var _yield$Promise$all = yield Promise.all(unpublishPromises);
27818
+ var _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 1);
27819
+ track = _yield$Promise$all2[0];
27651
27820
  } else {
27652
27821
  yield track.mute();
27653
27822
  }
@@ -27970,10 +28139,9 @@ class Participant extends eventsExports.EventEmitter {
27970
28139
  this.log.warn('no permissions present for publishing track', getLogContextFromTrack(track));
27971
28140
  return false;
27972
28141
  }
27973
- const {
27974
- canPublish,
27975
- canPublishSources
27976
- } = this.permissions;
28142
+ const _this$permissions = this.permissions,
28143
+ canPublish = _this$permissions.canPublish,
28144
+ canPublishSources = _this$permissions.canPublishSources;
27977
28145
  if (canPublish && (canPublishSources.length === 0 || canPublishSources.map(source => getTrackSourceFromProto(source)).includes(track.source))) {
27978
28146
  return true;
27979
28147
  }
@@ -28043,7 +28211,7 @@ class Participant extends eventsExports.EventEmitter {
28043
28211
  if (isLocalAudioTrack(track) && track.hasPreConnectBuffer) {
28044
28212
  audioFeatures.push(AudioTrackFeature.TF_PRECONNECT_BUFFER);
28045
28213
  }
28046
- const packetTrailerFeatures = this.normalizeRequestedPacketTrailerOptions(track, opts);
28214
+ const packetTrailerFeatures = this.normalizeRequestedFrameMetadataOptions(track, opts);
28047
28215
  // create track publication from track
28048
28216
  const req = new AddTrackRequest({
28049
28217
  // get local track id for use during publishing
@@ -28339,21 +28507,28 @@ class Participant extends eventsExports.EventEmitter {
28339
28507
  return publication;
28340
28508
  });
28341
28509
  }
28342
- canPublishPacketTrailer() {
28343
- return !!(this.roomOptions.e2ee || this.roomOptions.encryption || isPacketTrailerSupported(this.roomOptions.packetTrailer));
28510
+ canPublishFrameMetadata() {
28511
+ var _a;
28512
+ return !!(this.roomOptions.e2ee || this.roomOptions.encryption || isFrameMetadataSupported((_a = this.roomOptions.frameMetadata) !== null && _a !== void 0 ? _a : this.roomOptions.packetTrailer));
28344
28513
  }
28345
- normalizeRequestedPacketTrailerOptions(track, opts) {
28346
- if (track.kind !== Track.Kind.Video || !hasPacketTrailerPublishOptions(opts.packetTrailer)) {
28514
+ normalizeRequestedFrameMetadataOptions(track, opts) {
28515
+ var _a;
28516
+ const fmOpts = (_a = opts.frameMetadata) !== null && _a !== void 0 ? _a : opts.packetTrailer;
28517
+ if (track.kind !== Track.Kind.Video || !hasFrameMetadataPublishOptions(fmOpts)) {
28518
+ opts.frameMetadata = undefined;
28347
28519
  opts.packetTrailer = undefined;
28348
28520
  return [];
28349
28521
  }
28350
- if (!this.canPublishPacketTrailer()) {
28351
- this.log.warn('packet trailer transform not supported; not advertising features', Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(track)));
28522
+ if (!this.canPublishFrameMetadata()) {
28523
+ this.log.warn('frame metadata transform not supported; not advertising features', Object.assign(Object.assign({}, this.logContext), getLogContextFromTrack(track)));
28524
+ opts.frameMetadata = undefined;
28352
28525
  opts.packetTrailer = undefined;
28353
28526
  return [];
28354
28527
  }
28355
- const features = getPacketTrailerFeatures(opts.packetTrailer);
28356
- opts.packetTrailer = getPacketTrailerPublishOptions(features);
28528
+ const features = getFrameMetadataFeatures(fmOpts);
28529
+ const normalized = getFrameMetadataPublishOptions(features);
28530
+ opts.frameMetadata = normalized;
28531
+ opts.packetTrailer = normalized;
28357
28532
  return features;
28358
28533
  }
28359
28534
  get isLocal() {
@@ -28395,7 +28570,7 @@ class Participant extends eventsExports.EventEmitter {
28395
28570
  if (!simulcastTrack) {
28396
28571
  return;
28397
28572
  }
28398
- const packetTrailerFeatures = this.normalizeRequestedPacketTrailerOptions(track, opts);
28573
+ const packetTrailerFeatures = this.normalizeRequestedFrameMetadataOptions(track, opts);
28399
28574
  const req = new AddTrackRequest({
28400
28575
  cid: simulcastTrack.mediaStreamTrack.id,
28401
28576
  type: Track.kindToProto(track.kind),
@@ -28479,7 +28654,9 @@ class Participant extends eventsExports.EventEmitter {
28479
28654
  negotiationNeeded = true;
28480
28655
  }
28481
28656
  if (isLocalVideoTrack(track)) {
28482
- for (const [, trackInfo] of track.simulcastCodecs) {
28657
+ for (const _ref4 of track.simulcastCodecs) {
28658
+ var _ref5 = _slicedToArray(_ref4, 2);
28659
+ const trackInfo = _ref5[1];
28483
28660
  if (trackInfo.sender) {
28484
28661
  try {
28485
28662
  negotiationNeeded = this.engine.removeTrack(trackInfo.sender);
@@ -28720,8 +28897,10 @@ class Participant extends eventsExports.EventEmitter {
28720
28897
  * @throws Error on failure. Details in `message`.
28721
28898
  */
28722
28899
  performRpc(params) {
28723
- return this.rpcClientManager.performRpc(params).then(_ref3 => {
28724
- let [_id, completionPromise] = _ref3;
28900
+ return this.rpcClientManager.performRpc(params).then(_ref6 => {
28901
+ let _ref7 = _slicedToArray(_ref6, 2);
28902
+ _ref7[0];
28903
+ let completionPromise = _ref7[1];
28725
28904
  return completionPromise;
28726
28905
  });
28727
28906
  }
@@ -28837,8 +29016,9 @@ class Participant extends eventsExports.EventEmitter {
28837
29016
  const waitForPendingTimeout = 10000;
28838
29017
  const startTime = Date.now();
28839
29018
  while (Date.now() < startTime + waitForPendingTimeout) {
28840
- const publishPromiseEntry = Array.from(this.pendingPublishPromises.entries()).find(_ref4 => {
28841
- let [pendingTrack] = _ref4;
29019
+ const publishPromiseEntry = Array.from(this.pendingPublishPromises.entries()).find(_ref8 => {
29020
+ let _ref9 = _slicedToArray(_ref8, 1),
29021
+ pendingTrack = _ref9[0];
28842
29022
  return pendingTrack.source === source;
28843
29023
  });
28844
29024
  if (publishPromiseEntry) {
@@ -29447,9 +29627,7 @@ class DeferrableMap extends Map {
29447
29627
  return;
29448
29628
  }
29449
29629
  // also send unsubscribe, if track is actively subscribed
29450
- const {
29451
- track
29452
- } = publication;
29630
+ const track = publication.track;
29453
29631
  if (track) {
29454
29632
  track.stop();
29455
29633
  publication.setTrack(undefined);
@@ -29491,7 +29669,10 @@ class DeferrableMap extends Map {
29491
29669
  }
29492
29670
  /** @internal */
29493
29671
  removeRemoteDataTrack(remoteDataTrackSid) {
29494
- for (const [name, dataTrack] of this.dataTracks.entries()) {
29672
+ for (const _ref of this.dataTracks.entries()) {
29673
+ var _ref2 = _slicedToArray(_ref, 2);
29674
+ const name = _ref2[0];
29675
+ const dataTrack = _ref2[1];
29495
29676
  if (remoteDataTrackSid === dataTrack.info.sid) {
29496
29677
  this.dataTracks.delete(name);
29497
29678
  }
@@ -29661,17 +29842,17 @@ class Room extends eventsExports.EventEmitter {
29661
29842
  return this.connectFuture.promise;
29662
29843
  });
29663
29844
  this.connectSignal = (url, token, engine, connectOptions, roomOptions, abortController) => __awaiter(this, void 0, void 0, function* () {
29664
- const {
29665
- joinResponse,
29666
- serverInfo
29667
- } = yield engine.join(url, token, {
29668
- autoSubscribe: connectOptions.autoSubscribe,
29669
- adaptiveStream: typeof roomOptions.adaptiveStream === 'object' ? true : roomOptions.adaptiveStream,
29670
- clientInfoCapabilities: isPacketTrailerSupported(roomOptions.packetTrailer) || !!this.e2eeManager ? [ClientInfo_Capability.CAP_PACKET_TRAILER] : undefined,
29671
- maxRetries: connectOptions.maxRetries,
29672
- e2eeEnabled: !!this.e2eeManager,
29673
- websocketTimeout: connectOptions.websocketTimeout
29674
- }, abortController.signal, !roomOptions.singlePeerConnection);
29845
+ var _a;
29846
+ const _yield$engine$join = yield engine.join(url, token, {
29847
+ autoSubscribe: connectOptions.autoSubscribe,
29848
+ adaptiveStream: typeof roomOptions.adaptiveStream === 'object' ? true : roomOptions.adaptiveStream,
29849
+ clientInfoCapabilities: isFrameMetadataSupported((_a = roomOptions.frameMetadata) !== null && _a !== void 0 ? _a : roomOptions.packetTrailer) || !!this.e2eeManager ? [ClientInfo_Capability.CAP_PACKET_TRAILER] : undefined,
29850
+ maxRetries: connectOptions.maxRetries,
29851
+ e2eeEnabled: !!this.e2eeManager,
29852
+ websocketTimeout: connectOptions.websocketTimeout
29853
+ }, abortController.signal, !roomOptions.singlePeerConnection),
29854
+ joinResponse = _yield$engine$join.joinResponse,
29855
+ serverInfo = _yield$engine$join.serverInfo;
29675
29856
  this.serverInfo = serverInfo;
29676
29857
  if (!serverInfo.version) {
29677
29858
  throw new UnsupportedServer('unknown server version');
@@ -30330,10 +30511,8 @@ class Room extends eventsExports.EventEmitter {
30330
30511
  }).on('trackUnpublished', event => {
30331
30512
  this.emit(RoomEvent.LocalDataTrackUnpublished, event.sid);
30332
30513
  }).on('packetAvailable', _ref => {
30333
- let {
30334
- handle,
30335
- bytes
30336
- } = _ref;
30514
+ let handle = _ref.handle,
30515
+ bytes = _ref.bytes;
30337
30516
  this.engine.sendLossyBytes(bytes, DataChannelKind.DATA_TRACK_LOSSY, 'wait').finally(() => this.outgoingDataTrackManager.handlePacketSendComplete(handle));
30338
30517
  });
30339
30518
  this.registerRpcDataStreamHandler();
@@ -30342,23 +30521,19 @@ class Room extends eventsExports.EventEmitter {
30342
30521
  return (_b = (_a = this.engine.latestJoinResponse) === null || _a === void 0 ? void 0 : _a.serverInfo) === null || _b === void 0 ? void 0 : _b.version;
30343
30522
  });
30344
30523
  this.rpcClientManager.on('sendDataPacket', _ref2 => {
30345
- let {
30346
- packet
30347
- } = _ref2;
30524
+ let packet = _ref2.packet;
30348
30525
  var _a;
30349
30526
  (_a = this.engine) === null || _a === void 0 ? void 0 : _a.sendDataPacket(packet, DataChannelKind.RELIABLE);
30350
30527
  });
30351
30528
  this.rpcServerManager = new RpcServerManager(this.log, this.outgoingDataStreamManager, this.getRemoteParticipantClientProtocol);
30352
30529
  this.rpcServerManager.on('sendDataPacket', _ref3 => {
30353
- let {
30354
- packet
30355
- } = _ref3;
30530
+ let packet = _ref3.packet;
30356
30531
  var _a;
30357
30532
  (_a = this.engine) === null || _a === void 0 ? void 0 : _a.sendDataPacket(packet, DataChannelKind.RELIABLE);
30358
30533
  });
30359
30534
  this.disconnectLock = new _();
30360
30535
  this.localParticipant = new LocalParticipant('', '', this.engine, this.options, this.outgoingDataStreamManager, this.outgoingDataTrackManager, this.rpcClientManager, this.rpcServerManager);
30361
- this.setupPacketTrailer();
30536
+ this.setupFrameMetadata();
30362
30537
  if (this.options.e2ee || this.options.encryption) {
30363
30538
  this.setupE2EE();
30364
30539
  }
@@ -30500,11 +30675,11 @@ class Room extends eventsExports.EventEmitter {
30500
30675
  (_b = this.e2eeManager) === null || _b === void 0 ? void 0 : _b.setupEngine(this.engine);
30501
30676
  }
30502
30677
  }
30503
- setupPacketTrailer() {
30504
- // The manager is always created so tracks that advertise packet trailer
30505
- // features can be wired up when the app passes a packet trailer worker.
30506
- this.packetTrailerManager = new PacketTrailerManager(this.options.packetTrailer);
30507
- this.packetTrailerManager.setup(this);
30678
+ setupFrameMetadata() {
30679
+ var _a;
30680
+ const opts = (_a = this.options.frameMetadata) !== null && _a !== void 0 ? _a : this.options.packetTrailer;
30681
+ this.frameMetadataManager = new FrameMetadataManager(opts);
30682
+ this.frameMetadataManager.setup(this);
30508
30683
  }
30509
30684
  get logContext() {
30510
30685
  var _a, _b, _c;
@@ -30640,7 +30815,9 @@ class Room extends eventsExports.EventEmitter {
30640
30815
  this.outgoingDataTrackManager.receivedSfuUnpublishResponse(event.info.pubHandle);
30641
30816
  }).on(EngineEvent.DataTrackSubscriberHandles, event => {
30642
30817
  const handleToSidMapping = new Map(Object.entries(event.subHandles).map(_ref4 => {
30643
- let [key, value] = _ref4;
30818
+ let _ref5 = _slicedToArray(_ref4, 2),
30819
+ key = _ref5[0],
30820
+ value = _ref5[1];
30644
30821
  return [parseInt(key, 10), value.trackSid];
30645
30822
  }));
30646
30823
  this.incomingDataTrackManager.receivedSfuSubscriberHandles(handleToSidMapping);
@@ -31094,10 +31271,8 @@ class Room extends eventsExports.EventEmitter {
31094
31271
  }
31095
31272
  }
31096
31273
  handleLocalTrackSubscribed(subscribedSid) {
31097
- const findPublication = () => this.localParticipant.getTrackPublications().find(_ref5 => {
31098
- let {
31099
- trackSid
31100
- } = _ref5;
31274
+ const findPublication = () => this.localParticipant.getTrackPublications().find(_ref6 => {
31275
+ let trackSid = _ref6.trackSid;
31101
31276
  return trackSid === subscribedSid;
31102
31277
  });
31103
31278
  const trackPublication = findPublication();
@@ -31422,22 +31597,18 @@ class Room extends eventsExports.EventEmitter {
31422
31597
  }
31423
31598
  }
31424
31599
  registerRpcDataStreamHandler() {
31425
- this.incomingDataStreamManager.registerTextStreamHandler(RPC_REQUEST_DATA_STREAM_TOPIC, (reader_1, _a) => __awaiter(this, [reader_1, _a], void 0, function (reader, _ref6) {
31600
+ this.incomingDataStreamManager.registerTextStreamHandler(RPC_REQUEST_DATA_STREAM_TOPIC, (reader_1, _a) => __awaiter(this, [reader_1, _a], void 0, function (reader, _ref7) {
31426
31601
  var _this4 = this;
31427
- let {
31428
- identity
31429
- } = _ref6;
31602
+ let identity = _ref7.identity;
31430
31603
  return function* () {
31431
31604
  var _b;
31432
31605
  const attributes = (_b = reader.info.attributes) !== null && _b !== void 0 ? _b : {};
31433
31606
  yield _this4.rpcServerManager.handleIncomingDataStream(reader, identity, attributes);
31434
31607
  }();
31435
31608
  }));
31436
- this.incomingDataStreamManager.registerTextStreamHandler(RPC_RESPONSE_DATA_STREAM_TOPIC, (reader_1, _a) => __awaiter(this, [reader_1, _a], void 0, function (reader, _ref7) {
31609
+ this.incomingDataStreamManager.registerTextStreamHandler(RPC_RESPONSE_DATA_STREAM_TOPIC, (reader_1, _a) => __awaiter(this, [reader_1, _a], void 0, function (reader, _ref8) {
31437
31610
  var _this5 = this;
31438
- let {
31439
- identity
31440
- } = _ref7;
31611
+ let identity = _ref8.identity;
31441
31612
  return function* () {
31442
31613
  var _b;
31443
31614
  const attributes = (_b = reader.info.attributes) !== null && _b !== void 0 ? _b : {};
@@ -31490,8 +31661,10 @@ class Room extends eventsExports.EventEmitter {
31490
31661
  return true;
31491
31662
  }
31492
31663
  emitBufferedEvents() {
31493
- this.bufferedEvents.forEach(_ref8 => {
31494
- let [ev, args] = _ref8;
31664
+ this.bufferedEvents.forEach(_ref9 => {
31665
+ let _ref0 = _slicedToArray(_ref9, 2),
31666
+ ev = _ref0[0],
31667
+ args = _ref0[1];
31495
31668
  this.emit(ev, ...args);
31496
31669
  });
31497
31670
  this.bufferedEvents = [];
@@ -32444,28 +32617,7 @@ class TokenSourceFixed {}
32444
32617
  * A few common downstream implementers are {@link TokenSourceEndpoint}
32445
32618
  * and {@link TokenSourceCustom}.
32446
32619
  */
32447
- class TokenSourceConfigurable {}function _defineProperty(e, r, t) {
32448
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
32449
- value: t,
32450
- enumerable: true,
32451
- configurable: true,
32452
- writable: true
32453
- }) : e[r] = t, e;
32454
- }
32455
- function _toPrimitive(t, r) {
32456
- if ("object" != typeof t || !t) return t;
32457
- var e = t[Symbol.toPrimitive];
32458
- if (void 0 !== e) {
32459
- var i = e.call(t, r);
32460
- if ("object" != typeof i) return i;
32461
- throw new TypeError("@@toPrimitive must return a primitive value.");
32462
- }
32463
- return ("string" === r ? String : Number)(t);
32464
- }
32465
- function _toPropertyKey(t) {
32466
- var i = _toPrimitive(t, "string");
32467
- return "symbol" == typeof i ? i : i + "";
32468
- }new TextEncoder();
32620
+ class TokenSourceConfigurable {}new TextEncoder();
32469
32621
  const decoder = new TextDecoder();function decodeBase64(encoded) {
32470
32622
  if (Uint8Array.fromBase64) {
32471
32623
  return Uint8Array.fromBase64(encoded);
@@ -32653,10 +32805,9 @@ function isObject(input) {
32653
32805
  return Object.getPrototypeOf(input) === proto;
32654
32806
  }function decodeJwt(jwt) {
32655
32807
  if (typeof jwt !== 'string') throw new JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');
32656
- const {
32657
- 1: payload,
32658
- length
32659
- } = jwt.split('.');
32808
+ const _jwt$split = jwt.split('.'),
32809
+ payload = _jwt$split[1],
32810
+ length = _jwt$split.length;
32660
32811
  if (length === 5) throw new JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');
32661
32812
  if (length !== 3) throw new JWTInvalid('Invalid JWT');
32662
32813
  if (!payload) throw new JWTInvalid('JWTs must contain a payload');
@@ -32691,10 +32842,8 @@ function isResponseTokenValid(response) {
32691
32842
  /** Given a LiveKit generated participant token, decodes and returns the associated {@link TokenPayload} data. */
32692
32843
  function decodeTokenPayload(token) {
32693
32844
  const payload = decodeJwt(token);
32694
- const {
32695
- roomConfig
32696
- } = payload,
32697
- rest = __rest(payload, ["roomConfig"]);
32845
+ payload.roomConfig;
32846
+ const rest = __rest(payload, ["roomConfig"]);
32698
32847
  const mappedPayload = Object.assign(Object.assign({}, rest), {
32699
32848
  roomConfig: payload.roomConfig ? RoomConfiguration.fromJson(payload.roomConfig, {
32700
32849
  ignoreUnknownFields: true
@@ -32714,6 +32863,7 @@ function areTokenSourceFetchOptionsEqual(a, b) {
32714
32863
  case 'participantAttributes':
32715
32864
  case 'agentName':
32716
32865
  case 'agentMetadata':
32866
+ case 'deployment':
32717
32867
  if (a[key] !== b[key]) {
32718
32868
  return false;
32719
32869
  }
@@ -32738,26 +32888,7 @@ class TokenSourceCached extends TokenSourceConfigurable {
32738
32888
  if (!this.cachedFetchOptions) {
32739
32889
  return false;
32740
32890
  }
32741
- for (const key of Object.keys(this.cachedFetchOptions)) {
32742
- switch (key) {
32743
- case 'roomName':
32744
- case 'participantName':
32745
- case 'participantIdentity':
32746
- case 'participantMetadata':
32747
- case 'participantAttributes':
32748
- case 'agentName':
32749
- case 'agentMetadata':
32750
- if (this.cachedFetchOptions[key] !== options[key]) {
32751
- return false;
32752
- }
32753
- break;
32754
- default:
32755
- // ref: https://stackoverflow.com/a/58009992
32756
- const exhaustiveCheckedKey = key;
32757
- throw new Error("Options key ".concat(exhaustiveCheckedKey, " not being checked for equality!"));
32758
- }
32759
- }
32760
- return true;
32891
+ return areTokenSourceFetchOptionsEqual(options, this.cachedFetchOptions);
32761
32892
  }
32762
32893
  shouldReturnCachedValueFromFetch(fetchOptions) {
32763
32894
  if (!this.cachedResponse) {
@@ -32842,7 +32973,7 @@ class TokenSourceEndpoint extends TokenSourceCached {
32842
32973
  this.endpointOptions = options;
32843
32974
  }
32844
32975
  createRequestFromOptions(options) {
32845
- var _a, _b, _c;
32976
+ var _a, _b, _c, _d;
32846
32977
  const request = new TokenSourceRequest();
32847
32978
  for (const key of Object.keys(options)) {
32848
32979
  switch (key) {
@@ -32869,6 +33000,13 @@ class TokenSourceEndpoint extends TokenSourceCached {
32869
33000
  }
32870
33001
  request.roomConfig.agents[0].metadata = options.agentMetadata;
32871
33002
  break;
33003
+ case 'deployment':
33004
+ request.roomConfig = (_d = request.roomConfig) !== null && _d !== void 0 ? _d : new RoomConfiguration();
33005
+ if (request.roomConfig.agents.length === 0) {
33006
+ request.roomConfig.agents.push(new RoomAgentDispatch());
33007
+ }
33008
+ request.roomConfig.agents[0].deployment = options.deployment;
33009
+ break;
32872
33010
  default:
32873
33011
  // ref: https://stackoverflow.com/a/58009992
32874
33012
  const exhaustiveCheckedKey = key;
@@ -32904,9 +33042,8 @@ class TokenSourceEndpoint extends TokenSourceCached {
32904
33042
  }
32905
33043
  class TokenSourceSandboxTokenServer extends TokenSourceEndpoint {
32906
33044
  constructor(sandboxId, options) {
32907
- const {
32908
- baseUrl = 'https://cloud-api.livekit.io'
32909
- } = options,
33045
+ const _options$baseUrl = options.baseUrl,
33046
+ baseUrl = _options$baseUrl === void 0 ? 'https://cloud-api.livekit.io' : _options$baseUrl,
32910
33047
  rest = __rest(options, ["baseUrl"]);
32911
33048
  super("".concat(baseUrl, "/api/v2/sandbox/connection-details"), Object.assign(Object.assign({}, rest), {
32912
33049
  headers: {
@@ -33024,7 +33161,8 @@ function facingModeFromDeviceLabel(deviceLabel) {
33024
33161
  }
33025
33162
  // Can we match against sections of the device label.
33026
33163
  return (_a = Array.from(knownDeviceLabelSections.entries()).find(_ref => {
33027
- let [section] = _ref;
33164
+ let _ref2 = _slicedToArray(_ref, 1),
33165
+ section = _ref2[0];
33028
33166
  return label.includes(section);
33029
33167
  })) === null || _a === void 0 ? void 0 : _a[1];
33030
33168
  }
@@ -33077,4 +33215,4 @@ const serializers = {
33077
33215
  json,
33078
33216
  raw,
33079
33217
  custom
33080
- };export{AudioPresets,BackupCodecPolicy,BaseKeyProvider,CLIENT_PROTOCOL_DATA_STREAM_RPC,CLIENT_PROTOCOL_DEFAULT,CheckStatus,Checker,ConnectionCheck,ConnectionError,ConnectionErrorReason,ConnectionQuality,ConnectionState,CriticalTimers,CryptorError,CryptorErrorReason,CryptorEvent,DataPacket_Kind,DataStreamError,DataStreamErrorReason,DataTrackPacket,DefaultReconnectPolicy,DeviceUnsupportedError,DisconnectReason,EncryptionEvent,Encryption_Type,EngineEvent,ExternalE2EEKeyProvider,KeyHandlerEvent,KeyProviderEvent,LivekitError,LivekitReasonedError,LocalAudioTrack,LocalDataTrack,LocalParticipant,LocalTrack,LocalTrackPublication,LocalTrackRecorder,LocalVideoTrack,LogLevel,LoggerNames,MediaDeviceFailure,_ as Mutex,NegotiationError,PacketTrailerManager,Participant,ParticipantEvent,ParticipantInfo_Kind as ParticipantKind,PublishDataError,PublishTrackError,RemoteAudioTrack,RemoteDataTrack,RemoteParticipant,RemoteTrack,RemoteTrackPublication,RemoteVideoTrack,Room,RoomEvent,RpcError,ScreenSharePresets,SignalReconnectError,SignalRequestError,SimulatedError,SubscriptionError,TokenSource,TokenSourceConfigurable,TokenSourceFixed,Track,TrackEvent,TrackInvalidError,TrackPublication,TrackType,UnexpectedConnectionState,UnsupportedServer,VideoPreset,VideoPresets,VideoPresets43,VideoQuality,areTokenSourceFetchOptionsEqual,asEncryptablePacket,attachToElement,attributeTypings as attributes,audioCodecs,clientProtocol,compareVersions,createAudioAnalyser,createE2EEKey,createKeyMaterialFromBuffer,createKeyMaterialFromString,createLocalAudioTrack,createLocalScreenTracks,createLocalTracks,createLocalVideoTrack,decodeTokenPayload,deriveKeys,detachTrack,facingModeFromDeviceLabel,facingModeFromLocalTrack,getBrowser,getEmptyAudioStreamTrack,getEmptyVideoStreamTrack,getLogger,importKey,isAudioCodec,isAudioTrack,isBackupCodec,isBackupVideoCodec,isBrowserSupported,isE2EESupported,isInsertableStreamSupported,isLocalParticipant,isLocalTrack,isRemoteParticipant,isRemoteTrack,isScriptTransformSupported,isSerializer,isVideoCodec,isVideoFrame,isVideoTrack,needsRbspUnescaping,parseRbsp,protocolVersion,ratchet,serializers,setLogExtension,setLogLevel,supportsAV1,supportsAdaptiveStream,supportsAudioOutputSelection,supportsDynacast,supportsVP9,version,videoCodecs,writeRbsp};//# sourceMappingURL=livekit-client.esm.mjs.map
33218
+ };export{AudioPresets,BackupCodecPolicy,BaseKeyProvider,CLIENT_PROTOCOL_DATA_STREAM_RPC,CLIENT_PROTOCOL_DEFAULT,CheckStatus,Checker,ConnectionCheck,ConnectionError,ConnectionErrorReason,ConnectionQuality,ConnectionState,CriticalTimers,CryptorError,CryptorErrorReason,CryptorEvent,DataPacket_Kind,DataStreamError,DataStreamErrorReason,DataTrackPacket,DefaultReconnectPolicy,DeviceUnsupportedError,DisconnectReason,EncryptionEvent,Encryption_Type,EngineEvent,ExternalE2EEKeyProvider,FrameMetadataManager,KeyHandlerEvent,KeyProviderEvent,LivekitError,LivekitReasonedError,LocalAudioTrack,LocalDataTrack,LocalParticipant,LocalTrack,LocalTrackPublication,LocalTrackRecorder,LocalVideoTrack,LogLevel,LoggerNames,MediaDeviceFailure,_ as Mutex,NegotiationError,PacketTrailerManager,Participant,ParticipantEvent,ParticipantInfo_Kind as ParticipantKind,PublishDataError,PublishTrackError,RemoteAudioTrack,RemoteDataTrack,RemoteParticipant,RemoteTrack,RemoteTrackPublication,RemoteVideoTrack,Room,RoomEvent,RpcError,ScreenSharePresets,SignalReconnectError,SignalRequestError,SimulatedError,SubscriptionError,TokenSource,TokenSourceConfigurable,TokenSourceFixed,Track,TrackEvent,TrackInvalidError,TrackPublication,TrackType,UnexpectedConnectionState,UnsupportedServer,VideoPreset,VideoPresets,VideoPresets43,VideoQuality,areTokenSourceFetchOptionsEqual,asEncryptablePacket,attachToElement,attributeTypings as attributes,audioCodecs,clientProtocol,compareVersions,createAudioAnalyser,createE2EEKey,createKeyMaterialFromBuffer,createKeyMaterialFromString,createLocalAudioTrack,createLocalScreenTracks,createLocalTracks,createLocalVideoTrack,decodeTokenPayload,deriveKeys,detachTrack,facingModeFromDeviceLabel,facingModeFromLocalTrack,getBrowser,getEmptyAudioStreamTrack,getEmptyVideoStreamTrack,getLogger,importKey,isAudioCodec,isAudioTrack,isBackupCodec,isBackupVideoCodec,isBrowserSupported,isE2EESupported,isInsertableStreamSupported,isLocalParticipant,isLocalTrack,isRemoteParticipant,isRemoteTrack,isScriptTransformSupported,isSerializer,isVideoCodec,isVideoFrame,isVideoTrack,needsRbspUnescaping,parseRbsp,protocolVersion,ratchet,serializers,setLogExtension,setLogLevel,supportsAV1,supportsAdaptiveStream,supportsAudioOutputSelection,supportsDynacast,supportsVP9,version,videoCodecs,writeRbsp};//# sourceMappingURL=livekit-client.esm.mjs.map