livekit-client 1.6.3 → 1.6.5

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 (50) hide show
  1. package/dist/livekit-client.esm.mjs +418 -70
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/api/SignalClient.d.ts +13 -2
  6. package/dist/src/api/SignalClient.d.ts.map +1 -1
  7. package/dist/src/connectionHelper/ConnectionCheck.d.ts +2 -2
  8. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
  9. package/dist/src/proto/livekit_models.d.ts +20 -3
  10. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  11. package/dist/src/proto/livekit_rtc.d.ts +2565 -464
  12. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  13. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  14. package/dist/src/room/Room.d.ts +1 -1
  15. package/dist/src/room/Room.d.ts.map +1 -1
  16. package/dist/src/room/errors.d.ts +3 -0
  17. package/dist/src/room/errors.d.ts.map +1 -1
  18. package/dist/src/room/participant/LocalParticipant.d.ts +1 -3
  19. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  20. package/dist/src/room/participant/Participant.d.ts +1 -1
  21. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  22. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  23. package/dist/src/room/track/create.d.ts.map +1 -1
  24. package/dist/src/room/track/options.d.ts +2 -2
  25. package/dist/src/room/track/options.d.ts.map +1 -1
  26. package/dist/src/test/mocks.d.ts +1 -1
  27. package/dist/ts4.2/src/api/SignalClient.d.ts +13 -2
  28. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +2 -2
  29. package/dist/ts4.2/src/proto/livekit_models.d.ts +24 -3
  30. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +2775 -540
  31. package/dist/ts4.2/src/room/Room.d.ts +1 -1
  32. package/dist/ts4.2/src/room/errors.d.ts +3 -0
  33. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -3
  34. package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -1
  35. package/dist/ts4.2/src/room/track/options.d.ts +2 -2
  36. package/dist/ts4.2/src/test/mocks.d.ts +1 -1
  37. package/package.json +17 -17
  38. package/src/api/SignalClient.ts +46 -3
  39. package/src/connectionHelper/ConnectionCheck.ts +1 -1
  40. package/src/proto/google/protobuf/timestamp.ts +2 -2
  41. package/src/proto/livekit_models.ts +93 -9
  42. package/src/proto/livekit_rtc.ts +308 -6
  43. package/src/room/RTCEngine.ts +37 -16
  44. package/src/room/Room.ts +12 -11
  45. package/src/room/errors.ts +6 -0
  46. package/src/room/participant/LocalParticipant.ts +19 -20
  47. package/src/room/participant/Participant.ts +10 -2
  48. package/src/room/track/LocalAudioTrack.ts +5 -1
  49. package/src/room/track/create.ts +6 -1
  50. package/src/room/track/options.ts +2 -2
@@ -3997,9 +3997,9 @@ var roots = {};
3997
3997
  var _m0 = /*@__PURE__*/getDefaultExportFromCjs(minimalExports);
3998
3998
 
3999
3999
  /* eslint-disable */
4000
- var globalThis$3 = (() => {
4001
- if (typeof globalThis$3 !== "undefined") {
4002
- return globalThis$3;
4000
+ (() => {
4001
+ if (typeof globalThis !== "undefined") {
4002
+ return globalThis;
4003
4003
  }
4004
4004
  if (typeof self !== "undefined") {
4005
4005
  return self;
@@ -4288,6 +4288,15 @@ function disconnectReasonToJSON(object) {
4288
4288
  return "UNRECOGNIZED";
4289
4289
  }
4290
4290
  }
4291
+ var ReconnectReason;
4292
+ (function (ReconnectReason) {
4293
+ ReconnectReason[ReconnectReason["REASON_UNKOWN"] = 0] = "REASON_UNKOWN";
4294
+ ReconnectReason[ReconnectReason["REASON_SIGNAL_DISCONNECTED"] = 1] = "REASON_SIGNAL_DISCONNECTED";
4295
+ ReconnectReason[ReconnectReason["REASON_PUBLISHER_FAILED"] = 2] = "REASON_PUBLISHER_FAILED";
4296
+ ReconnectReason[ReconnectReason["REASON_SUBSCRIBER_FAILED"] = 3] = "REASON_SUBSCRIBER_FAILED";
4297
+ ReconnectReason[ReconnectReason["REASON_SWITCH_CANDIDATE"] = 4] = "REASON_SWITCH_CANDIDATE";
4298
+ ReconnectReason[ReconnectReason["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
4299
+ })(ReconnectReason || (ReconnectReason = {}));
4291
4300
  var ParticipantInfo_State;
4292
4301
  (function (ParticipantInfo_State) {
4293
4302
  /** JOINING - websocket' connected, but not offered yet */
@@ -4698,6 +4707,7 @@ function createBaseParticipantPermission() {
4698
4707
  canSubscribe: false,
4699
4708
  canPublish: false,
4700
4709
  canPublishData: false,
4710
+ canPublishSources: [],
4701
4711
  hidden: false,
4702
4712
  recorder: false
4703
4713
  };
@@ -4714,6 +4724,11 @@ const ParticipantPermission = {
4714
4724
  if (message.canPublishData === true) {
4715
4725
  writer.uint32(24).bool(message.canPublishData);
4716
4726
  }
4727
+ writer.uint32(74).fork();
4728
+ for (const v of message.canPublishSources) {
4729
+ writer.int32(v);
4730
+ }
4731
+ writer.ldelim();
4717
4732
  if (message.hidden === true) {
4718
4733
  writer.uint32(56).bool(message.hidden);
4719
4734
  }
@@ -4738,6 +4753,16 @@ const ParticipantPermission = {
4738
4753
  case 3:
4739
4754
  message.canPublishData = reader.bool();
4740
4755
  break;
4756
+ case 9:
4757
+ if ((tag & 7) === 2) {
4758
+ const end2 = reader.uint32() + reader.pos;
4759
+ while (reader.pos < end2) {
4760
+ message.canPublishSources.push(reader.int32());
4761
+ }
4762
+ } else {
4763
+ message.canPublishSources.push(reader.int32());
4764
+ }
4765
+ break;
4741
4766
  case 7:
4742
4767
  message.hidden = reader.bool();
4743
4768
  break;
@@ -4756,6 +4781,7 @@ const ParticipantPermission = {
4756
4781
  canSubscribe: isSet$1(object.canSubscribe) ? Boolean(object.canSubscribe) : false,
4757
4782
  canPublish: isSet$1(object.canPublish) ? Boolean(object.canPublish) : false,
4758
4783
  canPublishData: isSet$1(object.canPublishData) ? Boolean(object.canPublishData) : false,
4784
+ canPublishSources: Array.isArray(object === null || object === void 0 ? void 0 : object.canPublishSources) ? object.canPublishSources.map(e => trackSourceFromJSON(e)) : [],
4759
4785
  hidden: isSet$1(object.hidden) ? Boolean(object.hidden) : false,
4760
4786
  recorder: isSet$1(object.recorder) ? Boolean(object.recorder) : false
4761
4787
  };
@@ -4765,18 +4791,24 @@ const ParticipantPermission = {
4765
4791
  message.canSubscribe !== undefined && (obj.canSubscribe = message.canSubscribe);
4766
4792
  message.canPublish !== undefined && (obj.canPublish = message.canPublish);
4767
4793
  message.canPublishData !== undefined && (obj.canPublishData = message.canPublishData);
4794
+ if (message.canPublishSources) {
4795
+ obj.canPublishSources = message.canPublishSources.map(e => trackSourceToJSON(e));
4796
+ } else {
4797
+ obj.canPublishSources = [];
4798
+ }
4768
4799
  message.hidden !== undefined && (obj.hidden = message.hidden);
4769
4800
  message.recorder !== undefined && (obj.recorder = message.recorder);
4770
4801
  return obj;
4771
4802
  },
4772
4803
  fromPartial(object) {
4773
- var _a, _b, _c, _d, _e;
4804
+ var _a, _b, _c, _d, _e, _f;
4774
4805
  const message = createBaseParticipantPermission();
4775
4806
  message.canSubscribe = (_a = object.canSubscribe) !== null && _a !== void 0 ? _a : false;
4776
4807
  message.canPublish = (_b = object.canPublish) !== null && _b !== void 0 ? _b : false;
4777
4808
  message.canPublishData = (_c = object.canPublishData) !== null && _c !== void 0 ? _c : false;
4778
- message.hidden = (_d = object.hidden) !== null && _d !== void 0 ? _d : false;
4779
- message.recorder = (_e = object.recorder) !== null && _e !== void 0 ? _e : false;
4809
+ message.canPublishSources = ((_d = object.canPublishSources) === null || _d === void 0 ? void 0 : _d.map(e => e)) || [];
4810
+ message.hidden = (_e = object.hidden) !== null && _e !== void 0 ? _e : false;
4811
+ message.recorder = (_f = object.recorder) !== null && _f !== void 0 ? _f : false;
4780
4812
  return message;
4781
4813
  }
4782
4814
  };
@@ -6062,9 +6094,9 @@ const DisabledCodecs = {
6062
6094
  return message;
6063
6095
  }
6064
6096
  };
6065
- var globalThis$2 = (() => {
6066
- if (typeof globalThis$2 !== "undefined") {
6067
- return globalThis$2;
6097
+ var tsProtoGlobalThis$1 = (() => {
6098
+ if (typeof globalThis !== "undefined") {
6099
+ return globalThis;
6068
6100
  }
6069
6101
  if (typeof self !== "undefined") {
6070
6102
  return self;
@@ -6078,10 +6110,10 @@ var globalThis$2 = (() => {
6078
6110
  throw "Unable to locate global object";
6079
6111
  })();
6080
6112
  function bytesFromBase64(b64) {
6081
- if (globalThis$2.Buffer) {
6082
- return Uint8Array.from(globalThis$2.Buffer.from(b64, "base64"));
6113
+ if (tsProtoGlobalThis$1.Buffer) {
6114
+ return Uint8Array.from(tsProtoGlobalThis$1.Buffer.from(b64, "base64"));
6083
6115
  } else {
6084
- const bin = globalThis$2.atob(b64);
6116
+ const bin = tsProtoGlobalThis$1.atob(b64);
6085
6117
  const arr = new Uint8Array(bin.length);
6086
6118
  for (let i = 0; i < bin.length; ++i) {
6087
6119
  arr[i] = bin.charCodeAt(i);
@@ -6090,19 +6122,19 @@ function bytesFromBase64(b64) {
6090
6122
  }
6091
6123
  }
6092
6124
  function base64FromBytes(arr) {
6093
- if (globalThis$2.Buffer) {
6094
- return globalThis$2.Buffer.from(arr).toString("base64");
6125
+ if (tsProtoGlobalThis$1.Buffer) {
6126
+ return tsProtoGlobalThis$1.Buffer.from(arr).toString("base64");
6095
6127
  } else {
6096
6128
  const bin = [];
6097
6129
  arr.forEach(byte => {
6098
6130
  bin.push(String.fromCharCode(byte));
6099
6131
  });
6100
- return globalThis$2.btoa(bin.join(""));
6132
+ return tsProtoGlobalThis$1.btoa(bin.join(""));
6101
6133
  }
6102
6134
  }
6103
6135
  function longToNumber$1(long) {
6104
6136
  if (long.gt(Number.MAX_SAFE_INTEGER)) {
6105
- throw new globalThis$2.Error("Value is larger than Number.MAX_SAFE_INTEGER");
6137
+ throw new tsProtoGlobalThis$1.Error("Value is larger than Number.MAX_SAFE_INTEGER");
6106
6138
  }
6107
6139
  return long.toNumber();
6108
6140
  }
@@ -9394,7 +9426,7 @@ function createBaseSignalRequest() {
9394
9426
  const SignalRequest = {
9395
9427
  encode(message) {
9396
9428
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
9397
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
9429
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
9398
9430
  if (((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "offer") {
9399
9431
  SessionDescription.encode(message.message.offer, writer.uint32(10).fork()).ldelim();
9400
9432
  }
@@ -9434,6 +9466,12 @@ const SignalRequest = {
9434
9466
  if (((_o = message.message) === null || _o === void 0 ? void 0 : _o.$case) === "ping") {
9435
9467
  writer.uint32(112).int64(message.message.ping);
9436
9468
  }
9469
+ if (((_p = message.message) === null || _p === void 0 ? void 0 : _p.$case) === "updateMetadata") {
9470
+ UpdateParticipantMetadata.encode(message.message.updateMetadata, writer.uint32(122).fork()).ldelim();
9471
+ }
9472
+ if (((_q = message.message) === null || _q === void 0 ? void 0 : _q.$case) === "pingReq") {
9473
+ Ping.encode(message.message.pingReq, writer.uint32(130).fork()).ldelim();
9474
+ }
9437
9475
  return writer;
9438
9476
  },
9439
9477
  decode(input, length) {
@@ -9521,6 +9559,18 @@ const SignalRequest = {
9521
9559
  ping: longToNumber(reader.int64())
9522
9560
  };
9523
9561
  break;
9562
+ case 15:
9563
+ message.message = {
9564
+ $case: "updateMetadata",
9565
+ updateMetadata: UpdateParticipantMetadata.decode(reader, reader.uint32())
9566
+ };
9567
+ break;
9568
+ case 16:
9569
+ message.message = {
9570
+ $case: "pingReq",
9571
+ pingReq: Ping.decode(reader, reader.uint32())
9572
+ };
9573
+ break;
9524
9574
  default:
9525
9575
  reader.skipType(tag & 7);
9526
9576
  break;
@@ -9569,11 +9619,17 @@ const SignalRequest = {
9569
9619
  } : isSet(object.ping) ? {
9570
9620
  $case: "ping",
9571
9621
  ping: Number(object.ping)
9622
+ } : isSet(object.updateMetadata) ? {
9623
+ $case: "updateMetadata",
9624
+ updateMetadata: UpdateParticipantMetadata.fromJSON(object.updateMetadata)
9625
+ } : isSet(object.pingReq) ? {
9626
+ $case: "pingReq",
9627
+ pingReq: Ping.fromJSON(object.pingReq)
9572
9628
  } : undefined
9573
9629
  };
9574
9630
  },
9575
9631
  toJSON(message) {
9576
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
9632
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
9577
9633
  const obj = {};
9578
9634
  ((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "offer" && (obj.offer = ((_b = message.message) === null || _b === void 0 ? void 0 : _b.offer) ? SessionDescription.toJSON((_c = message.message) === null || _c === void 0 ? void 0 : _c.offer) : undefined);
9579
9635
  ((_d = message.message) === null || _d === void 0 ? void 0 : _d.$case) === "answer" && (obj.answer = ((_e = message.message) === null || _e === void 0 ? void 0 : _e.answer) ? SessionDescription.toJSON((_f = message.message) === null || _f === void 0 ? void 0 : _f.answer) : undefined);
@@ -9588,10 +9644,12 @@ const SignalRequest = {
9588
9644
  ((_6 = message.message) === null || _6 === void 0 ? void 0 : _6.$case) === "syncState" && (obj.syncState = ((_7 = message.message) === null || _7 === void 0 ? void 0 : _7.syncState) ? SyncState.toJSON((_8 = message.message) === null || _8 === void 0 ? void 0 : _8.syncState) : undefined);
9589
9645
  ((_9 = message.message) === null || _9 === void 0 ? void 0 : _9.$case) === "simulate" && (obj.simulate = ((_10 = message.message) === null || _10 === void 0 ? void 0 : _10.simulate) ? SimulateScenario.toJSON((_11 = message.message) === null || _11 === void 0 ? void 0 : _11.simulate) : undefined);
9590
9646
  ((_12 = message.message) === null || _12 === void 0 ? void 0 : _12.$case) === "ping" && (obj.ping = Math.round((_13 = message.message) === null || _13 === void 0 ? void 0 : _13.ping));
9647
+ ((_14 = message.message) === null || _14 === void 0 ? void 0 : _14.$case) === "updateMetadata" && (obj.updateMetadata = ((_15 = message.message) === null || _15 === void 0 ? void 0 : _15.updateMetadata) ? UpdateParticipantMetadata.toJSON((_16 = message.message) === null || _16 === void 0 ? void 0 : _16.updateMetadata) : undefined);
9648
+ ((_17 = message.message) === null || _17 === void 0 ? void 0 : _17.$case) === "pingReq" && (obj.pingReq = ((_18 = message.message) === null || _18 === void 0 ? void 0 : _18.pingReq) ? Ping.toJSON((_19 = message.message) === null || _19 === void 0 ? void 0 : _19.pingReq) : undefined);
9591
9649
  return obj;
9592
9650
  },
9593
9651
  fromPartial(object) {
9594
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
9652
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
9595
9653
  const message = createBaseSignalRequest();
9596
9654
  if (((_a = object.message) === null || _a === void 0 ? void 0 : _a.$case) === "offer" && ((_b = object.message) === null || _b === void 0 ? void 0 : _b.offer) !== undefined && ((_c = object.message) === null || _c === void 0 ? void 0 : _c.offer) !== null) {
9597
9655
  message.message = {
@@ -9671,6 +9729,18 @@ const SignalRequest = {
9671
9729
  ping: object.message.ping
9672
9730
  };
9673
9731
  }
9732
+ if (((_15 = object.message) === null || _15 === void 0 ? void 0 : _15.$case) === "updateMetadata" && ((_16 = object.message) === null || _16 === void 0 ? void 0 : _16.updateMetadata) !== undefined && ((_17 = object.message) === null || _17 === void 0 ? void 0 : _17.updateMetadata) !== null) {
9733
+ message.message = {
9734
+ $case: "updateMetadata",
9735
+ updateMetadata: UpdateParticipantMetadata.fromPartial(object.message.updateMetadata)
9736
+ };
9737
+ }
9738
+ if (((_18 = object.message) === null || _18 === void 0 ? void 0 : _18.$case) === "pingReq" && ((_19 = object.message) === null || _19 === void 0 ? void 0 : _19.pingReq) !== undefined && ((_20 = object.message) === null || _20 === void 0 ? void 0 : _20.pingReq) !== null) {
9739
+ message.message = {
9740
+ $case: "pingReq",
9741
+ pingReq: Ping.fromPartial(object.message.pingReq)
9742
+ };
9743
+ }
9674
9744
  return message;
9675
9745
  }
9676
9746
  };
@@ -9682,7 +9752,7 @@ function createBaseSignalResponse() {
9682
9752
  const SignalResponse = {
9683
9753
  encode(message) {
9684
9754
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
9685
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
9755
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
9686
9756
  if (((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "join") {
9687
9757
  JoinResponse.encode(message.message.join, writer.uint32(10).fork()).ldelim();
9688
9758
  }
@@ -9737,6 +9807,9 @@ const SignalResponse = {
9737
9807
  if (((_t = message.message) === null || _t === void 0 ? void 0 : _t.$case) === "reconnect") {
9738
9808
  ReconnectResponse.encode(message.message.reconnect, writer.uint32(154).fork()).ldelim();
9739
9809
  }
9810
+ if (((_u = message.message) === null || _u === void 0 ? void 0 : _u.$case) === "pongResp") {
9811
+ Pong.encode(message.message.pongResp, writer.uint32(162).fork()).ldelim();
9812
+ }
9740
9813
  return writer;
9741
9814
  },
9742
9815
  decode(input, length) {
@@ -9854,6 +9927,12 @@ const SignalResponse = {
9854
9927
  reconnect: ReconnectResponse.decode(reader, reader.uint32())
9855
9928
  };
9856
9929
  break;
9930
+ case 20:
9931
+ message.message = {
9932
+ $case: "pongResp",
9933
+ pongResp: Pong.decode(reader, reader.uint32())
9934
+ };
9935
+ break;
9857
9936
  default:
9858
9937
  reader.skipType(tag & 7);
9859
9938
  break;
@@ -9917,11 +9996,14 @@ const SignalResponse = {
9917
9996
  } : isSet(object.reconnect) ? {
9918
9997
  $case: "reconnect",
9919
9998
  reconnect: ReconnectResponse.fromJSON(object.reconnect)
9999
+ } : isSet(object.pongResp) ? {
10000
+ $case: "pongResp",
10001
+ pongResp: Pong.fromJSON(object.pongResp)
9920
10002
  } : undefined
9921
10003
  };
9922
10004
  },
9923
10005
  toJSON(message) {
9924
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27;
10006
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30;
9925
10007
  const obj = {};
9926
10008
  ((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "join" && (obj.join = ((_b = message.message) === null || _b === void 0 ? void 0 : _b.join) ? JoinResponse.toJSON((_c = message.message) === null || _c === void 0 ? void 0 : _c.join) : undefined);
9927
10009
  ((_d = message.message) === null || _d === void 0 ? void 0 : _d.$case) === "answer" && (obj.answer = ((_e = message.message) === null || _e === void 0 ? void 0 : _e.answer) ? SessionDescription.toJSON((_f = message.message) === null || _f === void 0 ? void 0 : _f.answer) : undefined);
@@ -9941,10 +10023,11 @@ const SignalResponse = {
9941
10023
  ((_20 = message.message) === null || _20 === void 0 ? void 0 : _20.$case) === "trackUnpublished" && (obj.trackUnpublished = ((_21 = message.message) === null || _21 === void 0 ? void 0 : _21.trackUnpublished) ? TrackUnpublishedResponse.toJSON((_22 = message.message) === null || _22 === void 0 ? void 0 : _22.trackUnpublished) : undefined);
9942
10024
  ((_23 = message.message) === null || _23 === void 0 ? void 0 : _23.$case) === "pong" && (obj.pong = Math.round((_24 = message.message) === null || _24 === void 0 ? void 0 : _24.pong));
9943
10025
  ((_25 = message.message) === null || _25 === void 0 ? void 0 : _25.$case) === "reconnect" && (obj.reconnect = ((_26 = message.message) === null || _26 === void 0 ? void 0 : _26.reconnect) ? ReconnectResponse.toJSON((_27 = message.message) === null || _27 === void 0 ? void 0 : _27.reconnect) : undefined);
10026
+ ((_28 = message.message) === null || _28 === void 0 ? void 0 : _28.$case) === "pongResp" && (obj.pongResp = ((_29 = message.message) === null || _29 === void 0 ? void 0 : _29.pongResp) ? Pong.toJSON((_30 = message.message) === null || _30 === void 0 ? void 0 : _30.pongResp) : undefined);
9944
10027
  return obj;
9945
10028
  },
9946
10029
  fromPartial(object) {
9947
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29;
10030
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32;
9948
10031
  const message = createBaseSignalResponse();
9949
10032
  if (((_a = object.message) === null || _a === void 0 ? void 0 : _a.$case) === "join" && ((_b = object.message) === null || _b === void 0 ? void 0 : _b.join) !== undefined && ((_c = object.message) === null || _c === void 0 ? void 0 : _c.join) !== null) {
9950
10033
  message.message = {
@@ -10054,6 +10137,12 @@ const SignalResponse = {
10054
10137
  reconnect: ReconnectResponse.fromPartial(object.message.reconnect)
10055
10138
  };
10056
10139
  }
10140
+ if (((_30 = object.message) === null || _30 === void 0 ? void 0 : _30.$case) === "pongResp" && ((_31 = object.message) === null || _31 === void 0 ? void 0 : _31.pongResp) !== undefined && ((_32 = object.message) === null || _32 === void 0 ? void 0 : _32.pongResp) !== null) {
10141
+ message.message = {
10142
+ $case: "pongResp",
10143
+ pongResp: Pong.fromPartial(object.message.pongResp)
10144
+ };
10145
+ }
10057
10146
  return message;
10058
10147
  }
10059
10148
  };
@@ -10591,7 +10680,10 @@ const JoinResponse = {
10591
10680
  function createBaseReconnectResponse() {
10592
10681
  return {
10593
10682
  iceServers: [],
10594
- clientConfiguration: undefined
10683
+ clientConfiguration: undefined,
10684
+ room: undefined,
10685
+ participant: undefined,
10686
+ otherParticipants: []
10595
10687
  };
10596
10688
  }
10597
10689
  const ReconnectResponse = {
@@ -10603,6 +10695,15 @@ const ReconnectResponse = {
10603
10695
  if (message.clientConfiguration !== undefined) {
10604
10696
  ClientConfiguration.encode(message.clientConfiguration, writer.uint32(18).fork()).ldelim();
10605
10697
  }
10698
+ if (message.room !== undefined) {
10699
+ Room$1.encode(message.room, writer.uint32(26).fork()).ldelim();
10700
+ }
10701
+ if (message.participant !== undefined) {
10702
+ ParticipantInfo.encode(message.participant, writer.uint32(34).fork()).ldelim();
10703
+ }
10704
+ for (const v of message.otherParticipants) {
10705
+ ParticipantInfo.encode(v, writer.uint32(42).fork()).ldelim();
10706
+ }
10606
10707
  return writer;
10607
10708
  },
10608
10709
  decode(input, length) {
@@ -10618,6 +10719,15 @@ const ReconnectResponse = {
10618
10719
  case 2:
10619
10720
  message.clientConfiguration = ClientConfiguration.decode(reader, reader.uint32());
10620
10721
  break;
10722
+ case 3:
10723
+ message.room = Room$1.decode(reader, reader.uint32());
10724
+ break;
10725
+ case 4:
10726
+ message.participant = ParticipantInfo.decode(reader, reader.uint32());
10727
+ break;
10728
+ case 5:
10729
+ message.otherParticipants.push(ParticipantInfo.decode(reader, reader.uint32()));
10730
+ break;
10621
10731
  default:
10622
10732
  reader.skipType(tag & 7);
10623
10733
  break;
@@ -10628,7 +10738,10 @@ const ReconnectResponse = {
10628
10738
  fromJSON(object) {
10629
10739
  return {
10630
10740
  iceServers: Array.isArray(object === null || object === void 0 ? void 0 : object.iceServers) ? object.iceServers.map(e => ICEServer.fromJSON(e)) : [],
10631
- clientConfiguration: isSet(object.clientConfiguration) ? ClientConfiguration.fromJSON(object.clientConfiguration) : undefined
10741
+ clientConfiguration: isSet(object.clientConfiguration) ? ClientConfiguration.fromJSON(object.clientConfiguration) : undefined,
10742
+ room: isSet(object.room) ? Room$1.fromJSON(object.room) : undefined,
10743
+ participant: isSet(object.participant) ? ParticipantInfo.fromJSON(object.participant) : undefined,
10744
+ otherParticipants: Array.isArray(object === null || object === void 0 ? void 0 : object.otherParticipants) ? object.otherParticipants.map(e => ParticipantInfo.fromJSON(e)) : []
10632
10745
  };
10633
10746
  },
10634
10747
  toJSON(message) {
@@ -10639,13 +10752,23 @@ const ReconnectResponse = {
10639
10752
  obj.iceServers = [];
10640
10753
  }
10641
10754
  message.clientConfiguration !== undefined && (obj.clientConfiguration = message.clientConfiguration ? ClientConfiguration.toJSON(message.clientConfiguration) : undefined);
10755
+ message.room !== undefined && (obj.room = message.room ? Room$1.toJSON(message.room) : undefined);
10756
+ message.participant !== undefined && (obj.participant = message.participant ? ParticipantInfo.toJSON(message.participant) : undefined);
10757
+ if (message.otherParticipants) {
10758
+ obj.otherParticipants = message.otherParticipants.map(e => e ? ParticipantInfo.toJSON(e) : undefined);
10759
+ } else {
10760
+ obj.otherParticipants = [];
10761
+ }
10642
10762
  return obj;
10643
10763
  },
10644
10764
  fromPartial(object) {
10645
- var _a;
10765
+ var _a, _b;
10646
10766
  const message = createBaseReconnectResponse();
10647
10767
  message.iceServers = ((_a = object.iceServers) === null || _a === void 0 ? void 0 : _a.map(e => ICEServer.fromPartial(e))) || [];
10648
10768
  message.clientConfiguration = object.clientConfiguration !== undefined && object.clientConfiguration !== null ? ClientConfiguration.fromPartial(object.clientConfiguration) : undefined;
10769
+ message.room = object.room !== undefined && object.room !== null ? Room$1.fromPartial(object.room) : undefined;
10770
+ message.participant = object.participant !== undefined && object.participant !== null ? ParticipantInfo.fromPartial(object.participant) : undefined;
10771
+ message.otherParticipants = ((_b = object.otherParticipants) === null || _b === void 0 ? void 0 : _b.map(e => ParticipantInfo.fromPartial(e))) || [];
10649
10772
  return message;
10650
10773
  }
10651
10774
  };
@@ -10943,7 +11066,8 @@ function createBaseUpdateTrackSettings() {
10943
11066
  quality: 0,
10944
11067
  width: 0,
10945
11068
  height: 0,
10946
- fps: 0
11069
+ fps: 0,
11070
+ priority: 0
10947
11071
  };
10948
11072
  }
10949
11073
  const UpdateTrackSettings = {
@@ -10967,6 +11091,9 @@ const UpdateTrackSettings = {
10967
11091
  if (message.fps !== 0) {
10968
11092
  writer.uint32(56).uint32(message.fps);
10969
11093
  }
11094
+ if (message.priority !== 0) {
11095
+ writer.uint32(64).uint32(message.priority);
11096
+ }
10970
11097
  return writer;
10971
11098
  },
10972
11099
  decode(input, length) {
@@ -10994,6 +11121,9 @@ const UpdateTrackSettings = {
10994
11121
  case 7:
10995
11122
  message.fps = reader.uint32();
10996
11123
  break;
11124
+ case 8:
11125
+ message.priority = reader.uint32();
11126
+ break;
10997
11127
  default:
10998
11128
  reader.skipType(tag & 7);
10999
11129
  break;
@@ -11008,7 +11138,8 @@ const UpdateTrackSettings = {
11008
11138
  quality: isSet(object.quality) ? videoQualityFromJSON(object.quality) : 0,
11009
11139
  width: isSet(object.width) ? Number(object.width) : 0,
11010
11140
  height: isSet(object.height) ? Number(object.height) : 0,
11011
- fps: isSet(object.fps) ? Number(object.fps) : 0
11141
+ fps: isSet(object.fps) ? Number(object.fps) : 0,
11142
+ priority: isSet(object.priority) ? Number(object.priority) : 0
11012
11143
  };
11013
11144
  },
11014
11145
  toJSON(message) {
@@ -11023,10 +11154,11 @@ const UpdateTrackSettings = {
11023
11154
  message.width !== undefined && (obj.width = Math.round(message.width));
11024
11155
  message.height !== undefined && (obj.height = Math.round(message.height));
11025
11156
  message.fps !== undefined && (obj.fps = Math.round(message.fps));
11157
+ message.priority !== undefined && (obj.priority = Math.round(message.priority));
11026
11158
  return obj;
11027
11159
  },
11028
11160
  fromPartial(object) {
11029
- var _a, _b, _c, _d, _e, _f;
11161
+ var _a, _b, _c, _d, _e, _f, _g;
11030
11162
  const message = createBaseUpdateTrackSettings();
11031
11163
  message.trackSids = ((_a = object.trackSids) === null || _a === void 0 ? void 0 : _a.map(e => e)) || [];
11032
11164
  message.disabled = (_b = object.disabled) !== null && _b !== void 0 ? _b : false;
@@ -11034,6 +11166,7 @@ const UpdateTrackSettings = {
11034
11166
  message.width = (_d = object.width) !== null && _d !== void 0 ? _d : 0;
11035
11167
  message.height = (_e = object.height) !== null && _e !== void 0 ? _e : 0;
11036
11168
  message.fps = (_f = object.fps) !== null && _f !== void 0 ? _f : 0;
11169
+ message.priority = (_g = object.priority) !== null && _g !== void 0 ? _g : 0;
11037
11170
  return message;
11038
11171
  }
11039
11172
  };
@@ -11155,6 +11288,53 @@ const UpdateVideoLayers = {
11155
11288
  return message;
11156
11289
  }
11157
11290
  };
11291
+ function createBaseUpdateParticipantMetadata() {
11292
+ return {
11293
+ metadata: ""
11294
+ };
11295
+ }
11296
+ const UpdateParticipantMetadata = {
11297
+ encode(message) {
11298
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
11299
+ if (message.metadata !== "") {
11300
+ writer.uint32(10).string(message.metadata);
11301
+ }
11302
+ return writer;
11303
+ },
11304
+ decode(input, length) {
11305
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
11306
+ let end = length === undefined ? reader.len : reader.pos + length;
11307
+ const message = createBaseUpdateParticipantMetadata();
11308
+ while (reader.pos < end) {
11309
+ const tag = reader.uint32();
11310
+ switch (tag >>> 3) {
11311
+ case 1:
11312
+ message.metadata = reader.string();
11313
+ break;
11314
+ default:
11315
+ reader.skipType(tag & 7);
11316
+ break;
11317
+ }
11318
+ }
11319
+ return message;
11320
+ },
11321
+ fromJSON(object) {
11322
+ return {
11323
+ metadata: isSet(object.metadata) ? String(object.metadata) : ""
11324
+ };
11325
+ },
11326
+ toJSON(message) {
11327
+ const obj = {};
11328
+ message.metadata !== undefined && (obj.metadata = message.metadata);
11329
+ return obj;
11330
+ },
11331
+ fromPartial(object) {
11332
+ var _a;
11333
+ const message = createBaseUpdateParticipantMetadata();
11334
+ message.metadata = (_a = object.metadata) !== null && _a !== void 0 ? _a : "";
11335
+ return message;
11336
+ }
11337
+ };
11158
11338
  function createBaseICEServer() {
11159
11339
  return {
11160
11340
  urls: [],
@@ -12259,9 +12439,123 @@ const SimulateScenario = {
12259
12439
  return message;
12260
12440
  }
12261
12441
  };
12262
- var globalThis$1 = (() => {
12263
- if (typeof globalThis$1 !== "undefined") {
12264
- return globalThis$1;
12442
+ function createBasePing() {
12443
+ return {
12444
+ timestamp: 0,
12445
+ rtt: 0
12446
+ };
12447
+ }
12448
+ const Ping = {
12449
+ encode(message) {
12450
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
12451
+ if (message.timestamp !== 0) {
12452
+ writer.uint32(8).int64(message.timestamp);
12453
+ }
12454
+ if (message.rtt !== 0) {
12455
+ writer.uint32(16).int64(message.rtt);
12456
+ }
12457
+ return writer;
12458
+ },
12459
+ decode(input, length) {
12460
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
12461
+ let end = length === undefined ? reader.len : reader.pos + length;
12462
+ const message = createBasePing();
12463
+ while (reader.pos < end) {
12464
+ const tag = reader.uint32();
12465
+ switch (tag >>> 3) {
12466
+ case 1:
12467
+ message.timestamp = longToNumber(reader.int64());
12468
+ break;
12469
+ case 2:
12470
+ message.rtt = longToNumber(reader.int64());
12471
+ break;
12472
+ default:
12473
+ reader.skipType(tag & 7);
12474
+ break;
12475
+ }
12476
+ }
12477
+ return message;
12478
+ },
12479
+ fromJSON(object) {
12480
+ return {
12481
+ timestamp: isSet(object.timestamp) ? Number(object.timestamp) : 0,
12482
+ rtt: isSet(object.rtt) ? Number(object.rtt) : 0
12483
+ };
12484
+ },
12485
+ toJSON(message) {
12486
+ const obj = {};
12487
+ message.timestamp !== undefined && (obj.timestamp = Math.round(message.timestamp));
12488
+ message.rtt !== undefined && (obj.rtt = Math.round(message.rtt));
12489
+ return obj;
12490
+ },
12491
+ fromPartial(object) {
12492
+ var _a, _b;
12493
+ const message = createBasePing();
12494
+ message.timestamp = (_a = object.timestamp) !== null && _a !== void 0 ? _a : 0;
12495
+ message.rtt = (_b = object.rtt) !== null && _b !== void 0 ? _b : 0;
12496
+ return message;
12497
+ }
12498
+ };
12499
+ function createBasePong() {
12500
+ return {
12501
+ lastPingTimestamp: 0,
12502
+ timestamp: 0
12503
+ };
12504
+ }
12505
+ const Pong = {
12506
+ encode(message) {
12507
+ let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
12508
+ if (message.lastPingTimestamp !== 0) {
12509
+ writer.uint32(8).int64(message.lastPingTimestamp);
12510
+ }
12511
+ if (message.timestamp !== 0) {
12512
+ writer.uint32(16).int64(message.timestamp);
12513
+ }
12514
+ return writer;
12515
+ },
12516
+ decode(input, length) {
12517
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
12518
+ let end = length === undefined ? reader.len : reader.pos + length;
12519
+ const message = createBasePong();
12520
+ while (reader.pos < end) {
12521
+ const tag = reader.uint32();
12522
+ switch (tag >>> 3) {
12523
+ case 1:
12524
+ message.lastPingTimestamp = longToNumber(reader.int64());
12525
+ break;
12526
+ case 2:
12527
+ message.timestamp = longToNumber(reader.int64());
12528
+ break;
12529
+ default:
12530
+ reader.skipType(tag & 7);
12531
+ break;
12532
+ }
12533
+ }
12534
+ return message;
12535
+ },
12536
+ fromJSON(object) {
12537
+ return {
12538
+ lastPingTimestamp: isSet(object.lastPingTimestamp) ? Number(object.lastPingTimestamp) : 0,
12539
+ timestamp: isSet(object.timestamp) ? Number(object.timestamp) : 0
12540
+ };
12541
+ },
12542
+ toJSON(message) {
12543
+ const obj = {};
12544
+ message.lastPingTimestamp !== undefined && (obj.lastPingTimestamp = Math.round(message.lastPingTimestamp));
12545
+ message.timestamp !== undefined && (obj.timestamp = Math.round(message.timestamp));
12546
+ return obj;
12547
+ },
12548
+ fromPartial(object) {
12549
+ var _a, _b;
12550
+ const message = createBasePong();
12551
+ message.lastPingTimestamp = (_a = object.lastPingTimestamp) !== null && _a !== void 0 ? _a : 0;
12552
+ message.timestamp = (_b = object.timestamp) !== null && _b !== void 0 ? _b : 0;
12553
+ return message;
12554
+ }
12555
+ };
12556
+ var tsProtoGlobalThis = (() => {
12557
+ if (typeof globalThis !== "undefined") {
12558
+ return globalThis;
12265
12559
  }
12266
12560
  if (typeof self !== "undefined") {
12267
12561
  return self;
@@ -12276,7 +12570,7 @@ var globalThis$1 = (() => {
12276
12570
  })();
12277
12571
  function longToNumber(long) {
12278
12572
  if (long.gt(Number.MAX_SAFE_INTEGER)) {
12279
- throw new globalThis$1.Error("Value is larger than Number.MAX_SAFE_INTEGER");
12573
+ throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
12280
12574
  }
12281
12575
  return long.toNumber();
12282
12576
  }
@@ -12301,6 +12595,11 @@ class ConnectionError extends LivekitError {
12301
12595
  this.reason = reason;
12302
12596
  }
12303
12597
  }
12598
+ class DeviceUnsupportedError extends LivekitError {
12599
+ constructor(message) {
12600
+ super(21, message !== null && message !== void 0 ? message : 'device is unsupported');
12601
+ }
12602
+ }
12304
12603
  class TrackInvalidError extends LivekitError {
12305
12604
  constructor(message) {
12306
12605
  super(20, message !== null && message !== void 0 ? message : 'track is invalid');
@@ -13500,7 +13799,7 @@ var uaParser = {
13500
13799
  })(uaParser, uaParserExports);
13501
13800
  var UAParser = uaParserExports;
13502
13801
 
13503
- var version$1 = "1.6.3";
13802
+ var version$1 = "1.6.5";
13504
13803
 
13505
13804
  const version = version$1;
13506
13805
  const protocolVersion = 8;
@@ -15056,7 +15355,7 @@ class LocalAudioTrack extends LocalTrack {
15056
15355
  }
15057
15356
  async unmute() {
15058
15357
  await this.muteQueue.run(async () => {
15059
- if (this.source === Track.Source.Microphone && this.stopOnMute && !this.isUserProvided) {
15358
+ if (this.source === Track.Source.Microphone && (this.stopOnMute || this._mediaStreamTrack.readyState === 'ended') && !this.isUserProvided) {
15060
15359
  livekitLogger.debug('reacquiring mic track');
15061
15360
  await this.restartTrack();
15062
15361
  }
@@ -16405,8 +16704,15 @@ class Participant extends eventsExports.EventEmitter {
16405
16704
  /** @internal */
16406
16705
  setPermissions(permissions) {
16407
16706
  var _a, _b, _c, _d, _e;
16408
- const changed = permissions.canPublish !== ((_a = this.permissions) === null || _a === void 0 ? void 0 : _a.canPublish) || permissions.canSubscribe !== ((_b = this.permissions) === null || _b === void 0 ? void 0 : _b.canSubscribe) || permissions.canPublishData !== ((_c = this.permissions) === null || _c === void 0 ? void 0 : _c.canPublishData) || permissions.hidden !== ((_d = this.permissions) === null || _d === void 0 ? void 0 : _d.hidden) || permissions.recorder !== ((_e = this.permissions) === null || _e === void 0 ? void 0 : _e.recorder);
16707
+ const prevPermissions = this.permissions;
16708
+ const changed = permissions.canPublish !== ((_a = this.permissions) === null || _a === void 0 ? void 0 : _a.canPublish) || permissions.canSubscribe !== ((_b = this.permissions) === null || _b === void 0 ? void 0 : _b.canSubscribe) || permissions.canPublishData !== ((_c = this.permissions) === null || _c === void 0 ? void 0 : _c.canPublishData) || permissions.hidden !== ((_d = this.permissions) === null || _d === void 0 ? void 0 : _d.hidden) || permissions.recorder !== ((_e = this.permissions) === null || _e === void 0 ? void 0 : _e.recorder) || permissions.canPublishSources.length !== this.permissions.canPublishSources.length || permissions.canPublishSources.some((value, index) => {
16709
+ var _a;
16710
+ return value !== ((_a = this.permissions) === null || _a === void 0 ? void 0 : _a.canPublishSources[index]);
16711
+ });
16409
16712
  this.permissions = permissions;
16713
+ if (changed) {
16714
+ this.emit(ParticipantEvent.ParticipantPermissionsChanged, prevPermissions);
16715
+ }
16410
16716
  return changed;
16411
16717
  }
16412
16718
  /** @internal */
@@ -17318,7 +17624,9 @@ class LocalParticipant extends Participant {
17318
17624
  // detect granted change after permissions were denied to try and resume then
17319
17625
  currentPermissions.onchange = () => {
17320
17626
  if (currentPermissions.state !== 'denied') {
17321
- track.restartTrack();
17627
+ if (!track.isMuted) {
17628
+ track.restartTrack();
17629
+ }
17322
17630
  currentPermissions.onchange = null;
17323
17631
  }
17324
17632
  };
@@ -17328,8 +17636,10 @@ class LocalParticipant extends Participant {
17328
17636
  // permissions query fails for firefox, we continue and try to restart the track
17329
17637
  }
17330
17638
  }
17331
- livekitLogger.debug('track ended, attempting to use a different device');
17332
- await track.restartTrack();
17639
+ if (!track.isMuted) {
17640
+ livekitLogger.debug('track ended, attempting to use a different device');
17641
+ await track.restartTrack();
17642
+ }
17333
17643
  } catch (e) {
17334
17644
  livekitLogger.warn("could not restart track, muting instead");
17335
17645
  await track.mute();
@@ -17406,15 +17716,6 @@ class LocalParticipant extends Participant {
17406
17716
  setScreenShareEnabled(enabled, options, publishOptions) {
17407
17717
  return this.setTrackEnabled(Track.Source.ScreenShare, enabled, options, publishOptions);
17408
17718
  }
17409
- /** @internal */
17410
- setPermissions(permissions) {
17411
- const prevPermissions = this.permissions;
17412
- const changed = super.setPermissions(permissions);
17413
- if (changed && prevPermissions) {
17414
- this.emit(ParticipantEvent.ParticipantPermissionsChanged, prevPermissions);
17415
- }
17416
- return changed;
17417
- }
17418
17719
  async setTrackEnabled(source, enabled, options, publishOptions) {
17419
17720
  var _a, _b;
17420
17721
  livekitLogger.debug('setTrackEnabled', {
@@ -17593,6 +17894,9 @@ class LocalParticipant extends Participant {
17593
17894
  };
17594
17895
  }
17595
17896
  }
17897
+ if (navigator.mediaDevices.getDisplayMedia === undefined) {
17898
+ throw new DeviceUnsupportedError('getDisplayMedia not supported');
17899
+ }
17596
17900
  const stream = await navigator.mediaDevices.getDisplayMedia({
17597
17901
  audio: (_a = options.audio) !== null && _a !== void 0 ? _a : false,
17598
17902
  video: videoConstraints
@@ -17981,6 +18285,11 @@ class LocalParticipant extends Participant {
17981
18285
  }
17982
18286
  /** @internal */
17983
18287
  updateInfo(info) {
18288
+ if (info.sid !== this.sid) {
18289
+ // drop updates that specify a wrong sid.
18290
+ // the sid for local participant is only explicitly set on join and full reconnect
18291
+ return;
18292
+ }
17984
18293
  super.updateInfo(info);
17985
18294
  // reconcile track mute status.
17986
18295
  // if server's track mute status doesn't match actual, we'll have to update
@@ -18066,6 +18375,8 @@ function canPassThroughQueue(req) {
18066
18375
  class SignalClient {
18067
18376
  constructor() {
18068
18377
  let useJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
18378
+ /** signal rtt in milliseconds */
18379
+ this.rtt = 0;
18069
18380
  this.isConnected = false;
18070
18381
  this.isReconnecting = false;
18071
18382
  this.useJSON = useJSON;
@@ -18081,7 +18392,7 @@ class SignalClient {
18081
18392
  const res = await this.connect(url, token, opts, abortSignal);
18082
18393
  return res;
18083
18394
  }
18084
- async reconnect(url, token, sid) {
18395
+ async reconnect(url, token, sid, reason) {
18085
18396
  if (!this.options) {
18086
18397
  livekitLogger.warn('attempted to reconnect without signal options being set, ignoring');
18087
18398
  return;
@@ -18091,7 +18402,8 @@ class SignalClient {
18091
18402
  this.clearPingInterval();
18092
18403
  const res = await this.connect(url, token, _objectSpread2(_objectSpread2({}, this.options), {}, {
18093
18404
  reconnect: true,
18094
- sid
18405
+ sid,
18406
+ reconnectReason: reason
18095
18407
  }));
18096
18408
  return res;
18097
18409
  }
@@ -18313,10 +18625,18 @@ class SignalClient {
18313
18625
  });
18314
18626
  }
18315
18627
  sendPing() {
18628
+ /** send both of ping and pingReq for compatibility to old and new server */
18316
18629
  this.sendRequest({
18317
18630
  $case: 'ping',
18318
18631
  ping: Date.now()
18319
18632
  });
18633
+ this.sendRequest({
18634
+ $case: 'pingReq',
18635
+ pingReq: {
18636
+ timestamp: Date.now(),
18637
+ rtt: this.rtt
18638
+ }
18639
+ });
18320
18640
  }
18321
18641
  async sendLeave() {
18322
18642
  await this.sendRequest({
@@ -18367,6 +18687,10 @@ class SignalClient {
18367
18687
  handleSignalResponse(res) {
18368
18688
  var _a, _b;
18369
18689
  const msg = res.message;
18690
+ if (msg == undefined) {
18691
+ livekitLogger.debug('received unsupported message');
18692
+ return;
18693
+ }
18370
18694
  if (msg.$case === 'answer') {
18371
18695
  const sd = fromProtoSessionDescription(msg.answer);
18372
18696
  if (this.onAnswer) {
@@ -18432,6 +18756,9 @@ class SignalClient {
18432
18756
  }
18433
18757
  } else if (msg.$case === 'pong') {
18434
18758
  this.resetPingTimeout();
18759
+ } else if (msg.$case === 'pongResp') {
18760
+ this.rtt = Date.now() - msg.pongResp.lastPingTimestamp;
18761
+ this.resetPingTimeout();
18435
18762
  } else {
18436
18763
  livekitLogger.debug('unsupported message', msg);
18437
18764
  }
@@ -18448,6 +18775,10 @@ class SignalClient {
18448
18775
  handleWSError(ev) {
18449
18776
  livekitLogger.error('websocket error', ev);
18450
18777
  }
18778
+ /**
18779
+ * Resets the ping timeout and starts a new timeout.
18780
+ * Call this after receiving a pong message
18781
+ */
18451
18782
  resetPingTimeout() {
18452
18783
  this.clearPingTimeout();
18453
18784
  if (!this.pingTimeoutDuration) {
@@ -18461,6 +18792,9 @@ class SignalClient {
18461
18792
  }
18462
18793
  }, this.pingTimeoutDuration * 1000);
18463
18794
  }
18795
+ /**
18796
+ * Clears ping timeout (does not start a new timeout)
18797
+ */
18464
18798
  clearPingTimeout() {
18465
18799
  if (this.pingTimeout) {
18466
18800
  CriticalTimers.clearTimeout(this.pingTimeout);
@@ -18545,6 +18879,9 @@ function createConnectionParams(token, info, opts) {
18545
18879
  if (opts.adaptiveStream) {
18546
18880
  params.set('adaptive_stream', '1');
18547
18881
  }
18882
+ if (opts.reconnectReason) {
18883
+ params.set('reconnect_reason', opts.reconnectReason.toString());
18884
+ }
18548
18885
  // @ts-ignore
18549
18886
  if ((_a = navigator.connection) === null || _a === void 0 ? void 0 : _a.type) {
18550
18887
  // @ts-ignore
@@ -19606,16 +19943,17 @@ class RTCEngine extends eventsExports.EventEmitter {
19606
19943
  // after a number of retries, we'll close and give up permanently
19607
19944
  this.handleDisconnect = function (connection) {
19608
19945
  let signalEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19946
+ let disconnectReason = arguments.length > 2 ? arguments[2] : undefined;
19609
19947
  if (_this._isClosed) {
19610
19948
  return;
19611
19949
  }
19612
- livekitLogger.debug("".concat(connection, " disconnected"));
19950
+ livekitLogger.warn("".concat(connection, " disconnected"));
19613
19951
  if (_this.reconnectAttempts === 0) {
19614
19952
  // only reset start time on the first try
19615
19953
  _this.reconnectStart = Date.now();
19616
19954
  }
19617
19955
  const disconnect = duration => {
19618
- livekitLogger.info("could not recover connection after ".concat(_this.reconnectAttempts, " attempts, ").concat(duration, "ms. giving up"));
19956
+ livekitLogger.warn("could not recover connection after ".concat(_this.reconnectAttempts, " attempts, ").concat(duration, "ms. giving up"));
19619
19957
  _this.emit(EngineEvent.Disconnected);
19620
19958
  _this.close();
19621
19959
  };
@@ -19633,13 +19971,13 @@ class RTCEngine extends eventsExports.EventEmitter {
19633
19971
  }
19634
19972
  livekitLogger.debug("reconnecting in ".concat(delay, "ms"));
19635
19973
  _this.clearReconnectTimeout();
19636
- _this.reconnectTimeout = CriticalTimers.setTimeout(() => _this.attemptReconnect(signalEvents), delay);
19974
+ _this.reconnectTimeout = CriticalTimers.setTimeout(() => _this.attemptReconnect(signalEvents, disconnectReason), delay);
19637
19975
  };
19638
19976
  this.handleBrowserOnLine = () => {
19639
19977
  // in case the engine is currently reconnecting, attempt a reconnect immediately after the browser state has changed to 'onLine'
19640
19978
  if (this.client.isReconnecting) {
19641
19979
  this.clearReconnectTimeout();
19642
- this.attemptReconnect(true);
19980
+ this.attemptReconnect(true, ReconnectReason.REASON_SIGNAL_DISCONNECTED);
19643
19981
  }
19644
19982
  };
19645
19983
  this.client = new SignalClient();
@@ -19793,7 +20131,8 @@ class RTCEngine extends eventsExports.EventEmitter {
19793
20131
  };
19794
20132
  let primaryPC = this.publisher.pc;
19795
20133
  let secondaryPC = this.subscriber.pc;
19796
- if (joinResponse.subscriberPrimary) {
20134
+ let subscriberPrimary = joinResponse.subscriberPrimary;
20135
+ if (subscriberPrimary) {
19797
20136
  primaryPC = this.subscriber.pc;
19798
20137
  secondaryPC = this.publisher.pc;
19799
20138
  // in subscriber primary mode, server side opens sub data channels.
@@ -19819,7 +20158,7 @@ class RTCEngine extends eventsExports.EventEmitter {
19819
20158
  // on Safari, PeerConnection will switch to 'disconnected' during renegotiation
19820
20159
  if (this.pcState === PCState.Connected) {
19821
20160
  this.pcState = PCState.Disconnected;
19822
- this.handleDisconnect('primary peerconnection');
20161
+ this.handleDisconnect('primary peerconnection', false, subscriberPrimary ? ReconnectReason.REASON_SUBSCRIBER_FAILED : ReconnectReason.REASON_PUBLISHER_FAILED);
19823
20162
  }
19824
20163
  }
19825
20164
  };
@@ -19827,7 +20166,7 @@ class RTCEngine extends eventsExports.EventEmitter {
19827
20166
  livekitLogger.debug("secondary PC state changed ".concat(secondaryPC.connectionState));
19828
20167
  // also reconnect if secondary peerconnection fails
19829
20168
  if (secondaryPC.connectionState === 'failed') {
19830
- this.handleDisconnect('secondary peerconnection');
20169
+ this.handleDisconnect('secondary peerconnection', false, subscriberPrimary ? ReconnectReason.REASON_PUBLISHER_FAILED : ReconnectReason.REASON_SUBSCRIBER_FAILED);
19831
20170
  }
19832
20171
  };
19833
20172
  this.subscriber.pc.ontrack = ev => {
@@ -19890,7 +20229,7 @@ class RTCEngine extends eventsExports.EventEmitter {
19890
20229
  this.token = token;
19891
20230
  };
19892
20231
  this.client.onClose = () => {
19893
- this.handleDisconnect('signal');
20232
+ this.handleDisconnect('signal', false, ReconnectReason.REASON_SIGNAL_DISCONNECTED);
19894
20233
  };
19895
20234
  this.client.onLeave = leave => {
19896
20235
  if (leave === null || leave === void 0 ? void 0 : leave.canReconnect) {
@@ -20066,6 +20405,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20066
20405
  }
20067
20406
  async attemptReconnect() {
20068
20407
  let signalEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20408
+ let reason = arguments.length > 1 ? arguments[1] : undefined;
20069
20409
  var _a, _b, _c;
20070
20410
  if (this._isClosed) {
20071
20411
  return;
@@ -20085,7 +20425,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20085
20425
  if (this.fullReconnectOnNext) {
20086
20426
  await this.restartConnection(signalEvents);
20087
20427
  } else {
20088
- await this.resumeConnection(signalEvents);
20428
+ await this.resumeConnection(signalEvents, reason);
20089
20429
  }
20090
20430
  this.clearPendingReconnect();
20091
20431
  this.fullReconnectOnNext = false;
@@ -20111,7 +20451,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20111
20451
  requireSignalEvents = true;
20112
20452
  }
20113
20453
  if (recoverable) {
20114
- this.handleDisconnect('reconnect', requireSignalEvents);
20454
+ this.handleDisconnect('reconnect', requireSignalEvents, ReconnectReason.REASON_UNKOWN);
20115
20455
  } else {
20116
20456
  livekitLogger.info("could not recover connection after ".concat(this.reconnectAttempts, " attempts, ").concat(Date.now() - this.reconnectStart, "ms. giving up"));
20117
20457
  this.emit(EngineEvent.Disconnected);
@@ -20169,6 +20509,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20169
20509
  }
20170
20510
  async resumeConnection() {
20171
20511
  let emitResuming = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20512
+ let reason = arguments.length > 1 ? arguments[1] : undefined;
20172
20513
  var _a;
20173
20514
  if (!this.url || !this.token) {
20174
20515
  // permanent failure, don't attempt reconnection
@@ -20183,7 +20524,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20183
20524
  this.emit(EngineEvent.Resuming);
20184
20525
  }
20185
20526
  try {
20186
- const res = await this.client.reconnect(this.url, this.token, this.participantSid);
20527
+ const res = await this.client.reconnect(this.url, this.token, this.participantSid, reason);
20187
20528
  if (res) {
20188
20529
  const rtcConfig = this.makeRTCConfiguration(res);
20189
20530
  this.publisher.pc.setConfiguration(rtcConfig);
@@ -20308,7 +20649,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20308
20649
  this.on(EngineEvent.Closing, handleClosed);
20309
20650
  const negotiationTimeout = setTimeout(() => {
20310
20651
  reject('negotiation timed out');
20311
- this.handleDisconnect('negotiation');
20652
+ this.handleDisconnect('negotiation', false, ReconnectReason.REASON_SIGNAL_DISCONNECTED);
20312
20653
  }, this.peerConnectionTimeout);
20313
20654
  const cleanup = () => {
20314
20655
  clearTimeout(negotiationTimeout);
@@ -20327,7 +20668,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20327
20668
  if (e instanceof NegotiationError) {
20328
20669
  this.fullReconnectOnNext = true;
20329
20670
  }
20330
- this.handleDisconnect('negotiation');
20671
+ this.handleDisconnect('negotiation', false, ReconnectReason.REASON_UNKOWN);
20331
20672
  });
20332
20673
  });
20333
20674
  }
@@ -20534,14 +20875,18 @@ class Room extends eventsExports.EventEmitter {
20534
20875
  } catch (err) {
20535
20876
  this.recreateEngine();
20536
20877
  this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
20537
- let errorMessage = '';
20878
+ const resultingError = new ConnectionError("could not establish signal connection");
20538
20879
  if (err instanceof Error) {
20539
- errorMessage = err.message;
20540
- livekitLogger.debug("error trying to establish signal connection", {
20541
- error: err
20542
- });
20880
+ resultingError.message = "".concat(resultingError.message, ": ").concat(err.message);
20543
20881
  }
20544
- reject(new ConnectionError("could not establish signal connection: ".concat(errorMessage)));
20882
+ if (err instanceof ConnectionError) {
20883
+ resultingError.reason = err.reason;
20884
+ resultingError.status = err.status;
20885
+ }
20886
+ livekitLogger.debug("error trying to establish signal connection", {
20887
+ error: err
20888
+ });
20889
+ reject(resultingError);
20545
20890
  return;
20546
20891
  }
20547
20892
  // don't return until ICE connected
@@ -20670,7 +21015,7 @@ class Room extends eventsExports.EventEmitter {
20670
21015
  this.handleParticipantUpdates = participantInfos => {
20671
21016
  // handle changes to participant state, and send events
20672
21017
  participantInfos.forEach(info => {
20673
- if (info.sid === this.localParticipant.sid || info.identity === this.localParticipant.identity) {
21018
+ if (info.identity === this.localParticipant.identity) {
20674
21019
  this.localParticipant.updateInfo(info);
20675
21020
  return;
20676
21021
  }
@@ -21559,6 +21904,9 @@ async function createLocalScreenTracks(options) {
21559
21904
  height: options.resolution.height
21560
21905
  };
21561
21906
  }
21907
+ if (navigator.mediaDevices.getDisplayMedia === undefined) {
21908
+ throw new DeviceUnsupportedError('getDisplayMedia not supported');
21909
+ }
21562
21910
  // typescript definition is missing getDisplayMedia: https://github.com/microsoft/TypeScript/issues/33232
21563
21911
  // @ts-ignore
21564
21912
  const stream = await navigator.mediaDevices.getDisplayMedia({
@@ -21926,5 +22274,5 @@ class ConnectionCheck extends eventsExports {
21926
22274
  }
21927
22275
  }
21928
22276
 
21929
- export { AudioPresets, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, CriticalTimers, DataPacket_Kind, DefaultReconnectPolicy, DisconnectReason, EngineEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, MediaDeviceFailure, NegotiationError, Participant, ParticipantEvent, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RoomState, ScreenSharePresets, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createAudioAnalyser, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, detachTrack, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, isBackupCodec, isBrowserSupported, protocolVersion, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, version };
22277
+ export { AudioPresets, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, CriticalTimers, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EngineEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, MediaDeviceFailure, NegotiationError, Participant, ParticipantEvent, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RoomState, ScreenSharePresets, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createAudioAnalyser, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, detachTrack, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, isBackupCodec, isBrowserSupported, protocolVersion, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, version };
21930
22278
  //# sourceMappingURL=livekit-client.esm.mjs.map