livekit-client 1.6.7 → 1.6.8

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 (40) hide show
  1. package/dist/livekit-client.esm.mjs +429 -250
  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/proto/google/protobuf/timestamp.d.ts +9 -2
  6. package/dist/src/proto/google/protobuf/timestamp.d.ts.map +1 -1
  7. package/dist/src/proto/livekit_models.d.ts +958 -58
  8. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  9. package/dist/src/proto/livekit_rtc.d.ts +8394 -3725
  10. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  11. package/dist/src/room/Room.d.ts +1 -1
  12. package/dist/src/room/Room.d.ts.map +1 -1
  13. package/dist/src/room/events.d.ts +1 -1
  14. package/dist/src/room/participant/LocalParticipant.d.ts +18 -0
  15. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  16. package/dist/src/room/track/options.d.ts +8 -0
  17. package/dist/src/room/track/options.d.ts.map +1 -1
  18. package/dist/src/room/types.d.ts +7 -0
  19. package/dist/src/room/types.d.ts.map +1 -1
  20. package/dist/src/version.d.ts +1 -1
  21. package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +11 -2
  22. package/dist/ts4.2/src/proto/livekit_models.d.ts +1199 -177
  23. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +9260 -4023
  24. package/dist/ts4.2/src/room/Room.d.ts +1 -1
  25. package/dist/ts4.2/src/room/events.d.ts +1 -1
  26. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +18 -0
  27. package/dist/ts4.2/src/room/track/options.d.ts +8 -0
  28. package/dist/ts4.2/src/room/types.d.ts +7 -0
  29. package/dist/ts4.2/src/version.d.ts +1 -1
  30. package/package.json +2 -2
  31. package/src/proto/google/protobuf/timestamp.ts +4 -0
  32. package/src/proto/livekit_models.ts +128 -31
  33. package/src/proto/livekit_rtc.ts +262 -161
  34. package/src/room/RTCEngine.ts +9 -9
  35. package/src/room/Room.ts +50 -43
  36. package/src/room/events.ts +1 -1
  37. package/src/room/participant/LocalParticipant.ts +99 -21
  38. package/src/room/track/options.ts +12 -0
  39. package/src/room/types.ts +9 -0
  40. package/src/version.ts +1 -1
@@ -4290,11 +4290,11 @@ function disconnectReasonToJSON(object) {
4290
4290
  }
4291
4291
  var ReconnectReason;
4292
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";
4293
+ ReconnectReason[ReconnectReason["RR_UNKOWN"] = 0] = "RR_UNKOWN";
4294
+ ReconnectReason[ReconnectReason["RR_SIGNAL_DISCONNECTED"] = 1] = "RR_SIGNAL_DISCONNECTED";
4295
+ ReconnectReason[ReconnectReason["RR_PUBLISHER_FAILED"] = 2] = "RR_PUBLISHER_FAILED";
4296
+ ReconnectReason[ReconnectReason["RR_SUBSCRIBER_FAILED"] = 3] = "RR_SUBSCRIBER_FAILED";
4297
+ ReconnectReason[ReconnectReason["RR_SWITCH_CANDIDATE"] = 4] = "RR_SWITCH_CANDIDATE";
4298
4298
  ReconnectReason[ReconnectReason["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
4299
4299
  })(ReconnectReason || (ReconnectReason = {}));
4300
4300
  var ParticipantInfo_State;
@@ -4629,6 +4629,9 @@ const Room$1 = {
4629
4629
  message.activeRecording !== undefined && (obj.activeRecording = message.activeRecording);
4630
4630
  return obj;
4631
4631
  },
4632
+ create(base) {
4633
+ return Room$1.fromPartial(base !== null && base !== void 0 ? base : {});
4634
+ },
4632
4635
  fromPartial(object) {
4633
4636
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4634
4637
  const message = createBaseRoom();
@@ -4694,6 +4697,9 @@ const Codec = {
4694
4697
  message.fmtpLine !== undefined && (obj.fmtpLine = message.fmtpLine);
4695
4698
  return obj;
4696
4699
  },
4700
+ create(base) {
4701
+ return Codec.fromPartial(base !== null && base !== void 0 ? base : {});
4702
+ },
4697
4703
  fromPartial(object) {
4698
4704
  var _a, _b;
4699
4705
  const message = createBaseCodec();
@@ -4800,6 +4806,9 @@ const ParticipantPermission = {
4800
4806
  message.recorder !== undefined && (obj.recorder = message.recorder);
4801
4807
  return obj;
4802
4808
  },
4809
+ create(base) {
4810
+ return ParticipantPermission.fromPartial(base !== null && base !== void 0 ? base : {});
4811
+ },
4803
4812
  fromPartial(object) {
4804
4813
  var _a, _b, _c, _d, _e, _f;
4805
4814
  const message = createBaseParticipantPermission();
@@ -4946,6 +4955,9 @@ const ParticipantInfo = {
4946
4955
  message.isPublisher !== undefined && (obj.isPublisher = message.isPublisher);
4947
4956
  return obj;
4948
4957
  },
4958
+ create(base) {
4959
+ return ParticipantInfo.fromPartial(base !== null && base !== void 0 ? base : {});
4960
+ },
4949
4961
  fromPartial(object) {
4950
4962
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4951
4963
  const message = createBaseParticipantInfo();
@@ -5034,6 +5046,9 @@ const SimulcastCodecInfo = {
5034
5046
  }
5035
5047
  return obj;
5036
5048
  },
5049
+ create(base) {
5050
+ return SimulcastCodecInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5051
+ },
5037
5052
  fromPartial(object) {
5038
5053
  var _a, _b, _c, _d;
5039
5054
  const message = createBaseSimulcastCodecInfo();
@@ -5227,6 +5242,9 @@ const TrackInfo = {
5227
5242
  message.encryption !== undefined && (obj.encryption = encryption_TypeToJSON(message.encryption));
5228
5243
  return obj;
5229
5244
  },
5245
+ create(base) {
5246
+ return TrackInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5247
+ },
5230
5248
  fromPartial(object) {
5231
5249
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
5232
5250
  const message = createBaseTrackInfo();
@@ -5325,6 +5343,9 @@ const VideoLayer = {
5325
5343
  message.ssrc !== undefined && (obj.ssrc = Math.round(message.ssrc));
5326
5344
  return obj;
5327
5345
  },
5346
+ create(base) {
5347
+ return VideoLayer.fromPartial(base !== null && base !== void 0 ? base : {});
5348
+ },
5328
5349
  fromPartial(object) {
5329
5350
  var _a, _b, _c, _d, _e;
5330
5351
  const message = createBaseVideoLayer();
@@ -5345,15 +5366,17 @@ function createBaseDataPacket() {
5345
5366
  const DataPacket = {
5346
5367
  encode(message) {
5347
5368
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
5348
- var _a, _b;
5369
+ var _a;
5349
5370
  if (message.kind !== 0) {
5350
5371
  writer.uint32(8).int32(message.kind);
5351
5372
  }
5352
- if (((_a = message.value) === null || _a === void 0 ? void 0 : _a.$case) === "user") {
5353
- UserPacket.encode(message.value.user, writer.uint32(18).fork()).ldelim();
5354
- }
5355
- if (((_b = message.value) === null || _b === void 0 ? void 0 : _b.$case) === "speaker") {
5356
- ActiveSpeakerUpdate.encode(message.value.speaker, writer.uint32(26).fork()).ldelim();
5373
+ switch ((_a = message.value) === null || _a === void 0 ? void 0 : _a.$case) {
5374
+ case "user":
5375
+ UserPacket.encode(message.value.user, writer.uint32(18).fork()).ldelim();
5376
+ break;
5377
+ case "speaker":
5378
+ ActiveSpeakerUpdate.encode(message.value.speaker, writer.uint32(26).fork()).ldelim();
5379
+ break;
5357
5380
  }
5358
5381
  return writer;
5359
5382
  },
@@ -5406,6 +5429,9 @@ const DataPacket = {
5406
5429
  ((_d = message.value) === null || _d === void 0 ? void 0 : _d.$case) === "speaker" && (obj.speaker = ((_e = message.value) === null || _e === void 0 ? void 0 : _e.speaker) ? ActiveSpeakerUpdate.toJSON((_f = message.value) === null || _f === void 0 ? void 0 : _f.speaker) : undefined);
5407
5430
  return obj;
5408
5431
  },
5432
+ create(base) {
5433
+ return DataPacket.fromPartial(base !== null && base !== void 0 ? base : {});
5434
+ },
5409
5435
  fromPartial(object) {
5410
5436
  var _a, _b, _c, _d, _e, _f, _g;
5411
5437
  const message = createBaseDataPacket();
@@ -5469,6 +5495,9 @@ const ActiveSpeakerUpdate = {
5469
5495
  }
5470
5496
  return obj;
5471
5497
  },
5498
+ create(base) {
5499
+ return ActiveSpeakerUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
5500
+ },
5472
5501
  fromPartial(object) {
5473
5502
  var _a;
5474
5503
  const message = createBaseActiveSpeakerUpdate();
@@ -5534,6 +5563,9 @@ const SpeakerInfo = {
5534
5563
  message.active !== undefined && (obj.active = message.active);
5535
5564
  return obj;
5536
5565
  },
5566
+ create(base) {
5567
+ return SpeakerInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5568
+ },
5537
5569
  fromPartial(object) {
5538
5570
  var _a, _b, _c;
5539
5571
  const message = createBaseSpeakerInfo();
@@ -5547,7 +5579,8 @@ function createBaseUserPacket() {
5547
5579
  return {
5548
5580
  participantSid: "",
5549
5581
  payload: new Uint8Array(),
5550
- destinationSids: []
5582
+ destinationSids: [],
5583
+ topic: undefined
5551
5584
  };
5552
5585
  }
5553
5586
  const UserPacket = {
@@ -5562,6 +5595,9 @@ const UserPacket = {
5562
5595
  for (const v of message.destinationSids) {
5563
5596
  writer.uint32(26).string(v);
5564
5597
  }
5598
+ if (message.topic !== undefined) {
5599
+ writer.uint32(34).string(message.topic);
5600
+ }
5565
5601
  return writer;
5566
5602
  },
5567
5603
  decode(input, length) {
@@ -5580,6 +5616,9 @@ const UserPacket = {
5580
5616
  case 3:
5581
5617
  message.destinationSids.push(reader.string());
5582
5618
  break;
5619
+ case 4:
5620
+ message.topic = reader.string();
5621
+ break;
5583
5622
  default:
5584
5623
  reader.skipType(tag & 7);
5585
5624
  break;
@@ -5591,7 +5630,8 @@ const UserPacket = {
5591
5630
  return {
5592
5631
  participantSid: isSet$1(object.participantSid) ? String(object.participantSid) : "",
5593
5632
  payload: isSet$1(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(),
5594
- destinationSids: Array.isArray(object === null || object === void 0 ? void 0 : object.destinationSids) ? object.destinationSids.map(e => String(e)) : []
5633
+ destinationSids: Array.isArray(object === null || object === void 0 ? void 0 : object.destinationSids) ? object.destinationSids.map(e => String(e)) : [],
5634
+ topic: isSet$1(object.topic) ? String(object.topic) : undefined
5595
5635
  };
5596
5636
  },
5597
5637
  toJSON(message) {
@@ -5603,14 +5643,19 @@ const UserPacket = {
5603
5643
  } else {
5604
5644
  obj.destinationSids = [];
5605
5645
  }
5646
+ message.topic !== undefined && (obj.topic = message.topic);
5606
5647
  return obj;
5607
5648
  },
5649
+ create(base) {
5650
+ return UserPacket.fromPartial(base !== null && base !== void 0 ? base : {});
5651
+ },
5608
5652
  fromPartial(object) {
5609
- var _a, _b, _c;
5653
+ var _a, _b, _c, _d;
5610
5654
  const message = createBaseUserPacket();
5611
5655
  message.participantSid = (_a = object.participantSid) !== null && _a !== void 0 ? _a : "";
5612
5656
  message.payload = (_b = object.payload) !== null && _b !== void 0 ? _b : new Uint8Array();
5613
5657
  message.destinationSids = ((_c = object.destinationSids) === null || _c === void 0 ? void 0 : _c.map(e => e)) || [];
5658
+ message.topic = (_d = object.topic) !== null && _d !== void 0 ? _d : undefined;
5614
5659
  return message;
5615
5660
  }
5616
5661
  };
@@ -5667,6 +5712,9 @@ const ParticipantTracks = {
5667
5712
  }
5668
5713
  return obj;
5669
5714
  },
5715
+ create(base) {
5716
+ return ParticipantTracks.fromPartial(base !== null && base !== void 0 ? base : {});
5717
+ },
5670
5718
  fromPartial(object) {
5671
5719
  var _a, _b;
5672
5720
  const message = createBaseParticipantTracks();
@@ -5760,6 +5808,9 @@ const ServerInfo = {
5760
5808
  message.debugInfo !== undefined && (obj.debugInfo = message.debugInfo);
5761
5809
  return obj;
5762
5810
  },
5811
+ create(base) {
5812
+ return ServerInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5813
+ },
5763
5814
  fromPartial(object) {
5764
5815
  var _a, _b, _c, _d, _e, _f;
5765
5816
  const message = createBaseServerInfo();
@@ -5893,6 +5944,9 @@ const ClientInfo = {
5893
5944
  message.network !== undefined && (obj.network = message.network);
5894
5945
  return obj;
5895
5946
  },
5947
+ create(base) {
5948
+ return ClientInfo.fromPartial(base !== null && base !== void 0 ? base : {});
5949
+ },
5896
5950
  fromPartial(object) {
5897
5951
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5898
5952
  const message = createBaseClientInfo();
@@ -5985,6 +6039,9 @@ const ClientConfiguration = {
5985
6039
  message.forceRelay !== undefined && (obj.forceRelay = clientConfigSettingToJSON(message.forceRelay));
5986
6040
  return obj;
5987
6041
  },
6042
+ create(base) {
6043
+ return ClientConfiguration.fromPartial(base !== null && base !== void 0 ? base : {});
6044
+ },
5988
6045
  fromPartial(object) {
5989
6046
  var _a, _b;
5990
6047
  const message = createBaseClientConfiguration();
@@ -6036,6 +6093,9 @@ const VideoConfiguration = {
6036
6093
  message.hardwareEncoder !== undefined && (obj.hardwareEncoder = clientConfigSettingToJSON(message.hardwareEncoder));
6037
6094
  return obj;
6038
6095
  },
6096
+ create(base) {
6097
+ return VideoConfiguration.fromPartial(base !== null && base !== void 0 ? base : {});
6098
+ },
6039
6099
  fromPartial(object) {
6040
6100
  var _a;
6041
6101
  const message = createBaseVideoConfiguration();
@@ -6087,6 +6147,9 @@ const DisabledCodecs = {
6087
6147
  }
6088
6148
  return obj;
6089
6149
  },
6150
+ create(base) {
6151
+ return DisabledCodecs.fromPartial(base !== null && base !== void 0 ? base : {});
6152
+ },
6090
6153
  fromPartial(object) {
6091
6154
  var _a;
6092
6155
  const message = createBaseDisabledCodecs();
@@ -9426,51 +9489,53 @@ function createBaseSignalRequest() {
9426
9489
  const SignalRequest = {
9427
9490
  encode(message) {
9428
9491
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
9429
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
9430
- if (((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "offer") {
9431
- SessionDescription.encode(message.message.offer, writer.uint32(10).fork()).ldelim();
9432
- }
9433
- if (((_b = message.message) === null || _b === void 0 ? void 0 : _b.$case) === "answer") {
9434
- SessionDescription.encode(message.message.answer, writer.uint32(18).fork()).ldelim();
9435
- }
9436
- if (((_c = message.message) === null || _c === void 0 ? void 0 : _c.$case) === "trickle") {
9437
- TrickleRequest.encode(message.message.trickle, writer.uint32(26).fork()).ldelim();
9438
- }
9439
- if (((_d = message.message) === null || _d === void 0 ? void 0 : _d.$case) === "addTrack") {
9440
- AddTrackRequest.encode(message.message.addTrack, writer.uint32(34).fork()).ldelim();
9441
- }
9442
- if (((_e = message.message) === null || _e === void 0 ? void 0 : _e.$case) === "mute") {
9443
- MuteTrackRequest.encode(message.message.mute, writer.uint32(42).fork()).ldelim();
9444
- }
9445
- if (((_f = message.message) === null || _f === void 0 ? void 0 : _f.$case) === "subscription") {
9446
- UpdateSubscription.encode(message.message.subscription, writer.uint32(50).fork()).ldelim();
9447
- }
9448
- if (((_g = message.message) === null || _g === void 0 ? void 0 : _g.$case) === "trackSetting") {
9449
- UpdateTrackSettings.encode(message.message.trackSetting, writer.uint32(58).fork()).ldelim();
9450
- }
9451
- if (((_h = message.message) === null || _h === void 0 ? void 0 : _h.$case) === "leave") {
9452
- LeaveRequest.encode(message.message.leave, writer.uint32(66).fork()).ldelim();
9453
- }
9454
- if (((_j = message.message) === null || _j === void 0 ? void 0 : _j.$case) === "updateLayers") {
9455
- UpdateVideoLayers.encode(message.message.updateLayers, writer.uint32(82).fork()).ldelim();
9456
- }
9457
- if (((_k = message.message) === null || _k === void 0 ? void 0 : _k.$case) === "subscriptionPermission") {
9458
- SubscriptionPermission.encode(message.message.subscriptionPermission, writer.uint32(90).fork()).ldelim();
9459
- }
9460
- if (((_l = message.message) === null || _l === void 0 ? void 0 : _l.$case) === "syncState") {
9461
- SyncState.encode(message.message.syncState, writer.uint32(98).fork()).ldelim();
9462
- }
9463
- if (((_m = message.message) === null || _m === void 0 ? void 0 : _m.$case) === "simulate") {
9464
- SimulateScenario.encode(message.message.simulate, writer.uint32(106).fork()).ldelim();
9465
- }
9466
- if (((_o = message.message) === null || _o === void 0 ? void 0 : _o.$case) === "ping") {
9467
- writer.uint32(112).int64(message.message.ping);
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();
9492
+ var _a;
9493
+ switch ((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) {
9494
+ case "offer":
9495
+ SessionDescription.encode(message.message.offer, writer.uint32(10).fork()).ldelim();
9496
+ break;
9497
+ case "answer":
9498
+ SessionDescription.encode(message.message.answer, writer.uint32(18).fork()).ldelim();
9499
+ break;
9500
+ case "trickle":
9501
+ TrickleRequest.encode(message.message.trickle, writer.uint32(26).fork()).ldelim();
9502
+ break;
9503
+ case "addTrack":
9504
+ AddTrackRequest.encode(message.message.addTrack, writer.uint32(34).fork()).ldelim();
9505
+ break;
9506
+ case "mute":
9507
+ MuteTrackRequest.encode(message.message.mute, writer.uint32(42).fork()).ldelim();
9508
+ break;
9509
+ case "subscription":
9510
+ UpdateSubscription.encode(message.message.subscription, writer.uint32(50).fork()).ldelim();
9511
+ break;
9512
+ case "trackSetting":
9513
+ UpdateTrackSettings.encode(message.message.trackSetting, writer.uint32(58).fork()).ldelim();
9514
+ break;
9515
+ case "leave":
9516
+ LeaveRequest.encode(message.message.leave, writer.uint32(66).fork()).ldelim();
9517
+ break;
9518
+ case "updateLayers":
9519
+ UpdateVideoLayers.encode(message.message.updateLayers, writer.uint32(82).fork()).ldelim();
9520
+ break;
9521
+ case "subscriptionPermission":
9522
+ SubscriptionPermission.encode(message.message.subscriptionPermission, writer.uint32(90).fork()).ldelim();
9523
+ break;
9524
+ case "syncState":
9525
+ SyncState.encode(message.message.syncState, writer.uint32(98).fork()).ldelim();
9526
+ break;
9527
+ case "simulate":
9528
+ SimulateScenario.encode(message.message.simulate, writer.uint32(106).fork()).ldelim();
9529
+ break;
9530
+ case "ping":
9531
+ writer.uint32(112).int64(message.message.ping);
9532
+ break;
9533
+ case "updateMetadata":
9534
+ UpdateParticipantMetadata.encode(message.message.updateMetadata, writer.uint32(122).fork()).ldelim();
9535
+ break;
9536
+ case "pingReq":
9537
+ Ping.encode(message.message.pingReq, writer.uint32(130).fork()).ldelim();
9538
+ break;
9474
9539
  }
9475
9540
  return writer;
9476
9541
  },
@@ -9648,6 +9713,9 @@ const SignalRequest = {
9648
9713
  ((_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);
9649
9714
  return obj;
9650
9715
  },
9716
+ create(base) {
9717
+ return SignalRequest.fromPartial(base !== null && base !== void 0 ? base : {});
9718
+ },
9651
9719
  fromPartial(object) {
9652
9720
  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;
9653
9721
  const message = createBaseSignalRequest();
@@ -9752,63 +9820,65 @@ function createBaseSignalResponse() {
9752
9820
  const SignalResponse = {
9753
9821
  encode(message) {
9754
9822
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
9755
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
9756
- if (((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) === "join") {
9757
- JoinResponse.encode(message.message.join, writer.uint32(10).fork()).ldelim();
9758
- }
9759
- if (((_b = message.message) === null || _b === void 0 ? void 0 : _b.$case) === "answer") {
9760
- SessionDescription.encode(message.message.answer, writer.uint32(18).fork()).ldelim();
9761
- }
9762
- if (((_c = message.message) === null || _c === void 0 ? void 0 : _c.$case) === "offer") {
9763
- SessionDescription.encode(message.message.offer, writer.uint32(26).fork()).ldelim();
9764
- }
9765
- if (((_d = message.message) === null || _d === void 0 ? void 0 : _d.$case) === "trickle") {
9766
- TrickleRequest.encode(message.message.trickle, writer.uint32(34).fork()).ldelim();
9767
- }
9768
- if (((_e = message.message) === null || _e === void 0 ? void 0 : _e.$case) === "update") {
9769
- ParticipantUpdate.encode(message.message.update, writer.uint32(42).fork()).ldelim();
9770
- }
9771
- if (((_f = message.message) === null || _f === void 0 ? void 0 : _f.$case) === "trackPublished") {
9772
- TrackPublishedResponse.encode(message.message.trackPublished, writer.uint32(50).fork()).ldelim();
9773
- }
9774
- if (((_g = message.message) === null || _g === void 0 ? void 0 : _g.$case) === "leave") {
9775
- LeaveRequest.encode(message.message.leave, writer.uint32(66).fork()).ldelim();
9776
- }
9777
- if (((_h = message.message) === null || _h === void 0 ? void 0 : _h.$case) === "mute") {
9778
- MuteTrackRequest.encode(message.message.mute, writer.uint32(74).fork()).ldelim();
9779
- }
9780
- if (((_j = message.message) === null || _j === void 0 ? void 0 : _j.$case) === "speakersChanged") {
9781
- SpeakersChanged.encode(message.message.speakersChanged, writer.uint32(82).fork()).ldelim();
9782
- }
9783
- if (((_k = message.message) === null || _k === void 0 ? void 0 : _k.$case) === "roomUpdate") {
9784
- RoomUpdate.encode(message.message.roomUpdate, writer.uint32(90).fork()).ldelim();
9785
- }
9786
- if (((_l = message.message) === null || _l === void 0 ? void 0 : _l.$case) === "connectionQuality") {
9787
- ConnectionQualityUpdate.encode(message.message.connectionQuality, writer.uint32(98).fork()).ldelim();
9788
- }
9789
- if (((_m = message.message) === null || _m === void 0 ? void 0 : _m.$case) === "streamStateUpdate") {
9790
- StreamStateUpdate.encode(message.message.streamStateUpdate, writer.uint32(106).fork()).ldelim();
9791
- }
9792
- if (((_o = message.message) === null || _o === void 0 ? void 0 : _o.$case) === "subscribedQualityUpdate") {
9793
- SubscribedQualityUpdate.encode(message.message.subscribedQualityUpdate, writer.uint32(114).fork()).ldelim();
9794
- }
9795
- if (((_p = message.message) === null || _p === void 0 ? void 0 : _p.$case) === "subscriptionPermissionUpdate") {
9796
- SubscriptionPermissionUpdate.encode(message.message.subscriptionPermissionUpdate, writer.uint32(122).fork()).ldelim();
9797
- }
9798
- if (((_q = message.message) === null || _q === void 0 ? void 0 : _q.$case) === "refreshToken") {
9799
- writer.uint32(130).string(message.message.refreshToken);
9800
- }
9801
- if (((_r = message.message) === null || _r === void 0 ? void 0 : _r.$case) === "trackUnpublished") {
9802
- TrackUnpublishedResponse.encode(message.message.trackUnpublished, writer.uint32(138).fork()).ldelim();
9803
- }
9804
- if (((_s = message.message) === null || _s === void 0 ? void 0 : _s.$case) === "pong") {
9805
- writer.uint32(144).int64(message.message.pong);
9806
- }
9807
- if (((_t = message.message) === null || _t === void 0 ? void 0 : _t.$case) === "reconnect") {
9808
- ReconnectResponse.encode(message.message.reconnect, writer.uint32(154).fork()).ldelim();
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();
9823
+ var _a;
9824
+ switch ((_a = message.message) === null || _a === void 0 ? void 0 : _a.$case) {
9825
+ case "join":
9826
+ JoinResponse.encode(message.message.join, writer.uint32(10).fork()).ldelim();
9827
+ break;
9828
+ case "answer":
9829
+ SessionDescription.encode(message.message.answer, writer.uint32(18).fork()).ldelim();
9830
+ break;
9831
+ case "offer":
9832
+ SessionDescription.encode(message.message.offer, writer.uint32(26).fork()).ldelim();
9833
+ break;
9834
+ case "trickle":
9835
+ TrickleRequest.encode(message.message.trickle, writer.uint32(34).fork()).ldelim();
9836
+ break;
9837
+ case "update":
9838
+ ParticipantUpdate.encode(message.message.update, writer.uint32(42).fork()).ldelim();
9839
+ break;
9840
+ case "trackPublished":
9841
+ TrackPublishedResponse.encode(message.message.trackPublished, writer.uint32(50).fork()).ldelim();
9842
+ break;
9843
+ case "leave":
9844
+ LeaveRequest.encode(message.message.leave, writer.uint32(66).fork()).ldelim();
9845
+ break;
9846
+ case "mute":
9847
+ MuteTrackRequest.encode(message.message.mute, writer.uint32(74).fork()).ldelim();
9848
+ break;
9849
+ case "speakersChanged":
9850
+ SpeakersChanged.encode(message.message.speakersChanged, writer.uint32(82).fork()).ldelim();
9851
+ break;
9852
+ case "roomUpdate":
9853
+ RoomUpdate.encode(message.message.roomUpdate, writer.uint32(90).fork()).ldelim();
9854
+ break;
9855
+ case "connectionQuality":
9856
+ ConnectionQualityUpdate.encode(message.message.connectionQuality, writer.uint32(98).fork()).ldelim();
9857
+ break;
9858
+ case "streamStateUpdate":
9859
+ StreamStateUpdate.encode(message.message.streamStateUpdate, writer.uint32(106).fork()).ldelim();
9860
+ break;
9861
+ case "subscribedQualityUpdate":
9862
+ SubscribedQualityUpdate.encode(message.message.subscribedQualityUpdate, writer.uint32(114).fork()).ldelim();
9863
+ break;
9864
+ case "subscriptionPermissionUpdate":
9865
+ SubscriptionPermissionUpdate.encode(message.message.subscriptionPermissionUpdate, writer.uint32(122).fork()).ldelim();
9866
+ break;
9867
+ case "refreshToken":
9868
+ writer.uint32(130).string(message.message.refreshToken);
9869
+ break;
9870
+ case "trackUnpublished":
9871
+ TrackUnpublishedResponse.encode(message.message.trackUnpublished, writer.uint32(138).fork()).ldelim();
9872
+ break;
9873
+ case "pong":
9874
+ writer.uint32(144).int64(message.message.pong);
9875
+ break;
9876
+ case "reconnect":
9877
+ ReconnectResponse.encode(message.message.reconnect, writer.uint32(154).fork()).ldelim();
9878
+ break;
9879
+ case "pongResp":
9880
+ Pong.encode(message.message.pongResp, writer.uint32(162).fork()).ldelim();
9881
+ break;
9812
9882
  }
9813
9883
  return writer;
9814
9884
  },
@@ -10026,6 +10096,9 @@ const SignalResponse = {
10026
10096
  ((_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);
10027
10097
  return obj;
10028
10098
  },
10099
+ create(base) {
10100
+ return SignalResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10101
+ },
10029
10102
  fromPartial(object) {
10030
10103
  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;
10031
10104
  const message = createBaseSignalResponse();
@@ -10204,6 +10277,9 @@ const SimulcastCodec = {
10204
10277
  message.enableSimulcastLayers !== undefined && (obj.enableSimulcastLayers = message.enableSimulcastLayers);
10205
10278
  return obj;
10206
10279
  },
10280
+ create(base) {
10281
+ return SimulcastCodec.fromPartial(base !== null && base !== void 0 ? base : {});
10282
+ },
10207
10283
  fromPartial(object) {
10208
10284
  var _a, _b, _c;
10209
10285
  const message = createBaseSimulcastCodec();
@@ -10378,6 +10454,9 @@ const AddTrackRequest = {
10378
10454
  message.encryption !== undefined && (obj.encryption = encryption_TypeToJSON(message.encryption));
10379
10455
  return obj;
10380
10456
  },
10457
+ create(base) {
10458
+ return AddTrackRequest.fromPartial(base !== null && base !== void 0 ? base : {});
10459
+ },
10381
10460
  fromPartial(object) {
10382
10461
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
10383
10462
  const message = createBaseAddTrackRequest();
@@ -10447,6 +10526,9 @@ const TrickleRequest = {
10447
10526
  message.target !== undefined && (obj.target = signalTargetToJSON(message.target));
10448
10527
  return obj;
10449
10528
  },
10529
+ create(base) {
10530
+ return TrickleRequest.fromPartial(base !== null && base !== void 0 ? base : {});
10531
+ },
10450
10532
  fromPartial(object) {
10451
10533
  var _a, _b;
10452
10534
  const message = createBaseTrickleRequest();
@@ -10504,6 +10586,9 @@ const MuteTrackRequest = {
10504
10586
  message.muted !== undefined && (obj.muted = message.muted);
10505
10587
  return obj;
10506
10588
  },
10589
+ create(base) {
10590
+ return MuteTrackRequest.fromPartial(base !== null && base !== void 0 ? base : {});
10591
+ },
10507
10592
  fromPartial(object) {
10508
10593
  var _a, _b;
10509
10594
  const message = createBaseMuteTrackRequest();
@@ -10659,6 +10744,9 @@ const JoinResponse = {
10659
10744
  message.serverInfo !== undefined && (obj.serverInfo = message.serverInfo ? ServerInfo.toJSON(message.serverInfo) : undefined);
10660
10745
  return obj;
10661
10746
  },
10747
+ create(base) {
10748
+ return JoinResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10749
+ },
10662
10750
  fromPartial(object) {
10663
10751
  var _a, _b, _c, _d, _e, _f, _g, _h;
10664
10752
  const message = createBaseJoinResponse();
@@ -10680,10 +10768,7 @@ const JoinResponse = {
10680
10768
  function createBaseReconnectResponse() {
10681
10769
  return {
10682
10770
  iceServers: [],
10683
- clientConfiguration: undefined,
10684
- room: undefined,
10685
- participant: undefined,
10686
- otherParticipants: []
10771
+ clientConfiguration: undefined
10687
10772
  };
10688
10773
  }
10689
10774
  const ReconnectResponse = {
@@ -10695,15 +10780,6 @@ const ReconnectResponse = {
10695
10780
  if (message.clientConfiguration !== undefined) {
10696
10781
  ClientConfiguration.encode(message.clientConfiguration, writer.uint32(18).fork()).ldelim();
10697
10782
  }
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
- }
10707
10783
  return writer;
10708
10784
  },
10709
10785
  decode(input, length) {
@@ -10719,15 +10795,6 @@ const ReconnectResponse = {
10719
10795
  case 2:
10720
10796
  message.clientConfiguration = ClientConfiguration.decode(reader, reader.uint32());
10721
10797
  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;
10731
10798
  default:
10732
10799
  reader.skipType(tag & 7);
10733
10800
  break;
@@ -10738,10 +10805,7 @@ const ReconnectResponse = {
10738
10805
  fromJSON(object) {
10739
10806
  return {
10740
10807
  iceServers: Array.isArray(object === null || object === void 0 ? void 0 : object.iceServers) ? object.iceServers.map(e => ICEServer.fromJSON(e)) : [],
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)) : []
10808
+ clientConfiguration: isSet(object.clientConfiguration) ? ClientConfiguration.fromJSON(object.clientConfiguration) : undefined
10745
10809
  };
10746
10810
  },
10747
10811
  toJSON(message) {
@@ -10752,23 +10816,16 @@ const ReconnectResponse = {
10752
10816
  obj.iceServers = [];
10753
10817
  }
10754
10818
  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
- }
10762
10819
  return obj;
10763
10820
  },
10821
+ create(base) {
10822
+ return ReconnectResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10823
+ },
10764
10824
  fromPartial(object) {
10765
- var _a, _b;
10825
+ var _a;
10766
10826
  const message = createBaseReconnectResponse();
10767
10827
  message.iceServers = ((_a = object.iceServers) === null || _a === void 0 ? void 0 : _a.map(e => ICEServer.fromPartial(e))) || [];
10768
10828
  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))) || [];
10772
10829
  return message;
10773
10830
  }
10774
10831
  };
@@ -10821,6 +10878,9 @@ const TrackPublishedResponse = {
10821
10878
  message.track !== undefined && (obj.track = message.track ? TrackInfo.toJSON(message.track) : undefined);
10822
10879
  return obj;
10823
10880
  },
10881
+ create(base) {
10882
+ return TrackPublishedResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10883
+ },
10824
10884
  fromPartial(object) {
10825
10885
  var _a;
10826
10886
  const message = createBaseTrackPublishedResponse();
@@ -10869,6 +10929,9 @@ const TrackUnpublishedResponse = {
10869
10929
  message.trackSid !== undefined && (obj.trackSid = message.trackSid);
10870
10930
  return obj;
10871
10931
  },
10932
+ create(base) {
10933
+ return TrackUnpublishedResponse.fromPartial(base !== null && base !== void 0 ? base : {});
10934
+ },
10872
10935
  fromPartial(object) {
10873
10936
  var _a;
10874
10937
  const message = createBaseTrackUnpublishedResponse();
@@ -10925,6 +10988,9 @@ const SessionDescription = {
10925
10988
  message.sdp !== undefined && (obj.sdp = message.sdp);
10926
10989
  return obj;
10927
10990
  },
10991
+ create(base) {
10992
+ return SessionDescription.fromPartial(base !== null && base !== void 0 ? base : {});
10993
+ },
10928
10994
  fromPartial(object) {
10929
10995
  var _a, _b;
10930
10996
  const message = createBaseSessionDescription();
@@ -10977,6 +11043,9 @@ const ParticipantUpdate = {
10977
11043
  }
10978
11044
  return obj;
10979
11045
  },
11046
+ create(base) {
11047
+ return ParticipantUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
11048
+ },
10980
11049
  fromPartial(object) {
10981
11050
  var _a;
10982
11051
  const message = createBaseParticipantUpdate();
@@ -11050,6 +11119,9 @@ const UpdateSubscription = {
11050
11119
  }
11051
11120
  return obj;
11052
11121
  },
11122
+ create(base) {
11123
+ return UpdateSubscription.fromPartial(base !== null && base !== void 0 ? base : {});
11124
+ },
11053
11125
  fromPartial(object) {
11054
11126
  var _a, _b, _c;
11055
11127
  const message = createBaseUpdateSubscription();
@@ -11157,6 +11229,9 @@ const UpdateTrackSettings = {
11157
11229
  message.priority !== undefined && (obj.priority = Math.round(message.priority));
11158
11230
  return obj;
11159
11231
  },
11232
+ create(base) {
11233
+ return UpdateTrackSettings.fromPartial(base !== null && base !== void 0 ? base : {});
11234
+ },
11160
11235
  fromPartial(object) {
11161
11236
  var _a, _b, _c, _d, _e, _f, _g;
11162
11237
  const message = createBaseUpdateTrackSettings();
@@ -11219,6 +11294,9 @@ const LeaveRequest = {
11219
11294
  message.reason !== undefined && (obj.reason = disconnectReasonToJSON(message.reason));
11220
11295
  return obj;
11221
11296
  },
11297
+ create(base) {
11298
+ return LeaveRequest.fromPartial(base !== null && base !== void 0 ? base : {});
11299
+ },
11222
11300
  fromPartial(object) {
11223
11301
  var _a, _b;
11224
11302
  const message = createBaseLeaveRequest();
@@ -11280,6 +11358,9 @@ const UpdateVideoLayers = {
11280
11358
  }
11281
11359
  return obj;
11282
11360
  },
11361
+ create(base) {
11362
+ return UpdateVideoLayers.fromPartial(base !== null && base !== void 0 ? base : {});
11363
+ },
11283
11364
  fromPartial(object) {
11284
11365
  var _a, _b;
11285
11366
  const message = createBaseUpdateVideoLayers();
@@ -11328,6 +11409,9 @@ const UpdateParticipantMetadata = {
11328
11409
  message.metadata !== undefined && (obj.metadata = message.metadata);
11329
11410
  return obj;
11330
11411
  },
11412
+ create(base) {
11413
+ return UpdateParticipantMetadata.fromPartial(base !== null && base !== void 0 ? base : {});
11414
+ },
11331
11415
  fromPartial(object) {
11332
11416
  var _a;
11333
11417
  const message = createBaseUpdateParticipantMetadata();
@@ -11397,6 +11481,9 @@ const ICEServer = {
11397
11481
  message.credential !== undefined && (obj.credential = message.credential);
11398
11482
  return obj;
11399
11483
  },
11484
+ create(base) {
11485
+ return ICEServer.fromPartial(base !== null && base !== void 0 ? base : {});
11486
+ },
11400
11487
  fromPartial(object) {
11401
11488
  var _a, _b, _c;
11402
11489
  const message = createBaseICEServer();
@@ -11450,6 +11537,9 @@ const SpeakersChanged = {
11450
11537
  }
11451
11538
  return obj;
11452
11539
  },
11540
+ create(base) {
11541
+ return SpeakersChanged.fromPartial(base !== null && base !== void 0 ? base : {});
11542
+ },
11453
11543
  fromPartial(object) {
11454
11544
  var _a;
11455
11545
  const message = createBaseSpeakersChanged();
@@ -11497,6 +11587,9 @@ const RoomUpdate = {
11497
11587
  message.room !== undefined && (obj.room = message.room ? Room$1.toJSON(message.room) : undefined);
11498
11588
  return obj;
11499
11589
  },
11590
+ create(base) {
11591
+ return RoomUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
11592
+ },
11500
11593
  fromPartial(object) {
11501
11594
  const message = createBaseRoomUpdate();
11502
11595
  message.room = object.room !== undefined && object.room !== null ? Room$1.fromPartial(object.room) : undefined;
@@ -11561,6 +11654,9 @@ const ConnectionQualityInfo = {
11561
11654
  message.score !== undefined && (obj.score = message.score);
11562
11655
  return obj;
11563
11656
  },
11657
+ create(base) {
11658
+ return ConnectionQualityInfo.fromPartial(base !== null && base !== void 0 ? base : {});
11659
+ },
11564
11660
  fromPartial(object) {
11565
11661
  var _a, _b, _c;
11566
11662
  const message = createBaseConnectionQualityInfo();
@@ -11614,6 +11710,9 @@ const ConnectionQualityUpdate = {
11614
11710
  }
11615
11711
  return obj;
11616
11712
  },
11713
+ create(base) {
11714
+ return ConnectionQualityUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
11715
+ },
11617
11716
  fromPartial(object) {
11618
11717
  var _a;
11619
11718
  const message = createBaseConnectionQualityUpdate();
@@ -11679,6 +11778,9 @@ const StreamStateInfo = {
11679
11778
  message.state !== undefined && (obj.state = streamStateToJSON(message.state));
11680
11779
  return obj;
11681
11780
  },
11781
+ create(base) {
11782
+ return StreamStateInfo.fromPartial(base !== null && base !== void 0 ? base : {});
11783
+ },
11682
11784
  fromPartial(object) {
11683
11785
  var _a, _b, _c;
11684
11786
  const message = createBaseStreamStateInfo();
@@ -11732,6 +11834,9 @@ const StreamStateUpdate = {
11732
11834
  }
11733
11835
  return obj;
11734
11836
  },
11837
+ create(base) {
11838
+ return StreamStateUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
11839
+ },
11735
11840
  fromPartial(object) {
11736
11841
  var _a;
11737
11842
  const message = createBaseStreamStateUpdate();
@@ -11788,6 +11893,9 @@ const SubscribedQuality = {
11788
11893
  message.enabled !== undefined && (obj.enabled = message.enabled);
11789
11894
  return obj;
11790
11895
  },
11896
+ create(base) {
11897
+ return SubscribedQuality.fromPartial(base !== null && base !== void 0 ? base : {});
11898
+ },
11791
11899
  fromPartial(object) {
11792
11900
  var _a, _b;
11793
11901
  const message = createBaseSubscribedQuality();
@@ -11849,6 +11957,9 @@ const SubscribedCodec = {
11849
11957
  }
11850
11958
  return obj;
11851
11959
  },
11960
+ create(base) {
11961
+ return SubscribedCodec.fromPartial(base !== null && base !== void 0 ? base : {});
11962
+ },
11852
11963
  fromPartial(object) {
11853
11964
  var _a, _b;
11854
11965
  const message = createBaseSubscribedCodec();
@@ -11923,6 +12034,9 @@ const SubscribedQualityUpdate = {
11923
12034
  }
11924
12035
  return obj;
11925
12036
  },
12037
+ create(base) {
12038
+ return SubscribedQualityUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
12039
+ },
11926
12040
  fromPartial(object) {
11927
12041
  var _a, _b, _c;
11928
12042
  const message = createBaseSubscribedQualityUpdate();
@@ -12003,6 +12117,9 @@ const TrackPermission = {
12003
12117
  message.participantIdentity !== undefined && (obj.participantIdentity = message.participantIdentity);
12004
12118
  return obj;
12005
12119
  },
12120
+ create(base) {
12121
+ return TrackPermission.fromPartial(base !== null && base !== void 0 ? base : {});
12122
+ },
12006
12123
  fromPartial(object) {
12007
12124
  var _a, _b, _c, _d;
12008
12125
  const message = createBaseTrackPermission();
@@ -12066,6 +12183,9 @@ const SubscriptionPermission = {
12066
12183
  }
12067
12184
  return obj;
12068
12185
  },
12186
+ create(base) {
12187
+ return SubscriptionPermission.fromPartial(base !== null && base !== void 0 ? base : {});
12188
+ },
12069
12189
  fromPartial(object) {
12070
12190
  var _a, _b;
12071
12191
  const message = createBaseSubscriptionPermission();
@@ -12132,6 +12252,9 @@ const SubscriptionPermissionUpdate = {
12132
12252
  message.allowed !== undefined && (obj.allowed = message.allowed);
12133
12253
  return obj;
12134
12254
  },
12255
+ create(base) {
12256
+ return SubscriptionPermissionUpdate.fromPartial(base !== null && base !== void 0 ? base : {});
12257
+ },
12135
12258
  fromPartial(object) {
12136
12259
  var _a, _b, _c;
12137
12260
  const message = createBaseSubscriptionPermissionUpdate();
@@ -12225,6 +12348,9 @@ const SyncState = {
12225
12348
  message.offer !== undefined && (obj.offer = message.offer ? SessionDescription.toJSON(message.offer) : undefined);
12226
12349
  return obj;
12227
12350
  },
12351
+ create(base) {
12352
+ return SyncState.fromPartial(base !== null && base !== void 0 ? base : {});
12353
+ },
12228
12354
  fromPartial(object) {
12229
12355
  var _a, _b;
12230
12356
  const message = createBaseSyncState();
@@ -12294,6 +12420,9 @@ const DataChannelInfo = {
12294
12420
  message.target !== undefined && (obj.target = signalTargetToJSON(message.target));
12295
12421
  return obj;
12296
12422
  },
12423
+ create(base) {
12424
+ return DataChannelInfo.fromPartial(base !== null && base !== void 0 ? base : {});
12425
+ },
12297
12426
  fromPartial(object) {
12298
12427
  var _a, _b, _c;
12299
12428
  const message = createBaseDataChannelInfo();
@@ -12311,21 +12440,23 @@ function createBaseSimulateScenario() {
12311
12440
  const SimulateScenario = {
12312
12441
  encode(message) {
12313
12442
  let writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
12314
- var _a, _b, _c, _d, _e;
12315
- if (((_a = message.scenario) === null || _a === void 0 ? void 0 : _a.$case) === "speakerUpdate") {
12316
- writer.uint32(8).int32(message.scenario.speakerUpdate);
12317
- }
12318
- if (((_b = message.scenario) === null || _b === void 0 ? void 0 : _b.$case) === "nodeFailure") {
12319
- writer.uint32(16).bool(message.scenario.nodeFailure);
12320
- }
12321
- if (((_c = message.scenario) === null || _c === void 0 ? void 0 : _c.$case) === "migration") {
12322
- writer.uint32(24).bool(message.scenario.migration);
12323
- }
12324
- if (((_d = message.scenario) === null || _d === void 0 ? void 0 : _d.$case) === "serverLeave") {
12325
- writer.uint32(32).bool(message.scenario.serverLeave);
12326
- }
12327
- if (((_e = message.scenario) === null || _e === void 0 ? void 0 : _e.$case) === "switchCandidateProtocol") {
12328
- writer.uint32(40).int32(message.scenario.switchCandidateProtocol);
12443
+ var _a;
12444
+ switch ((_a = message.scenario) === null || _a === void 0 ? void 0 : _a.$case) {
12445
+ case "speakerUpdate":
12446
+ writer.uint32(8).int32(message.scenario.speakerUpdate);
12447
+ break;
12448
+ case "nodeFailure":
12449
+ writer.uint32(16).bool(message.scenario.nodeFailure);
12450
+ break;
12451
+ case "migration":
12452
+ writer.uint32(24).bool(message.scenario.migration);
12453
+ break;
12454
+ case "serverLeave":
12455
+ writer.uint32(32).bool(message.scenario.serverLeave);
12456
+ break;
12457
+ case "switchCandidateProtocol":
12458
+ writer.uint32(40).int32(message.scenario.switchCandidateProtocol);
12459
+ break;
12329
12460
  }
12330
12461
  return writer;
12331
12462
  },
@@ -12403,6 +12534,9 @@ const SimulateScenario = {
12403
12534
  ((_j = message.scenario) === null || _j === void 0 ? void 0 : _j.$case) === "switchCandidateProtocol" && (obj.switchCandidateProtocol = ((_k = message.scenario) === null || _k === void 0 ? void 0 : _k.switchCandidateProtocol) !== undefined ? candidateProtocolToJSON((_l = message.scenario) === null || _l === void 0 ? void 0 : _l.switchCandidateProtocol) : undefined);
12404
12535
  return obj;
12405
12536
  },
12537
+ create(base) {
12538
+ return SimulateScenario.fromPartial(base !== null && base !== void 0 ? base : {});
12539
+ },
12406
12540
  fromPartial(object) {
12407
12541
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
12408
12542
  const message = createBaseSimulateScenario();
@@ -12488,6 +12622,9 @@ const Ping = {
12488
12622
  message.rtt !== undefined && (obj.rtt = Math.round(message.rtt));
12489
12623
  return obj;
12490
12624
  },
12625
+ create(base) {
12626
+ return Ping.fromPartial(base !== null && base !== void 0 ? base : {});
12627
+ },
12491
12628
  fromPartial(object) {
12492
12629
  var _a, _b;
12493
12630
  const message = createBasePing();
@@ -12545,6 +12682,9 @@ const Pong = {
12545
12682
  message.timestamp !== undefined && (obj.timestamp = Math.round(message.timestamp));
12546
12683
  return obj;
12547
12684
  },
12685
+ create(base) {
12686
+ return Pong.fromPartial(base !== null && base !== void 0 ? base : {});
12687
+ },
12548
12688
  fromPartial(object) {
12549
12689
  var _a, _b;
12550
12690
  const message = createBasePong();
@@ -12809,7 +12949,7 @@ var RoomEvent;
12809
12949
  * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
12810
12950
  * All participants in the room will receive the messages sent to the room.
12811
12951
  *
12812
- * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]])
12952
+ * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]], topic?: string)
12813
12953
  */
12814
12954
  RoomEvent["DataReceived"] = "dataReceived";
12815
12955
  /**
@@ -13800,10 +13940,10 @@ var uaParser = {
13800
13940
  })(uaParser, uaParserExports);
13801
13941
  var UAParser = uaParserExports;
13802
13942
 
13803
- var version$1 = "1.6.7";
13943
+ var version$1 = "1.6.8";
13804
13944
 
13805
13945
  const version = version$1;
13806
- const protocolVersion = 8;
13946
+ const protocolVersion = 9;
13807
13947
 
13808
13948
  function mergeDefaultOptions(options, audioDefaults, videoDefaults) {
13809
13949
  const opts = _objectSpread2({}, options);
@@ -17515,8 +17655,20 @@ class LocalParticipant extends Participant {
17515
17655
  constructor(sid, identity, engine, options) {
17516
17656
  super(sid, identity);
17517
17657
  this.pendingPublishing = new Set();
17658
+ this.pendingPublishPromises = new Map();
17518
17659
  this.participantTrackPermissions = [];
17519
17660
  this.allParticipantsAllowedToSubscribe = true;
17661
+ this.handleReconnecting = () => {
17662
+ if (!this.reconnectFuture) {
17663
+ this.reconnectFuture = new Future();
17664
+ }
17665
+ };
17666
+ this.handleReconnected = () => {
17667
+ var _a, _b;
17668
+ (_b = (_a = this.reconnectFuture) === null || _a === void 0 ? void 0 : _a.resolve) === null || _b === void 0 ? void 0 : _b.call(_a);
17669
+ this.reconnectFuture = undefined;
17670
+ this.updateTrackSubscriptionPermissions();
17671
+ };
17520
17672
  this.updateTrackSubscriptionPermissions = () => {
17521
17673
  livekitLogger.debug('updating track subscription permissions', {
17522
17674
  allParticipantsAllowed: this.allParticipantsAllowedToSubscribe,
@@ -17695,7 +17847,7 @@ class LocalParticipant extends Participant {
17695
17847
  };
17696
17848
  this.engine.client.onSubscribedQualityUpdate = this.handleSubscribedQualityUpdate;
17697
17849
  this.engine.client.onLocalTrackUnpublished = this.handleLocalTrackUnpublished;
17698
- this.engine.on(EngineEvent.Connected, this.updateTrackSubscriptionPermissions).on(EngineEvent.Restarted, this.updateTrackSubscriptionPermissions).on(EngineEvent.Resumed, this.updateTrackSubscriptionPermissions);
17850
+ this.engine.on(EngineEvent.Connected, this.handleReconnected).on(EngineEvent.Restarted, this.handleReconnected).on(EngineEvent.Resumed, this.handleReconnected).on(EngineEvent.Restarting, this.handleReconnecting).on(EngineEvent.Resuming, this.handleReconnecting);
17699
17851
  }
17700
17852
  /**
17701
17853
  * Enable or disable a participant's camera track.
@@ -17905,7 +18057,12 @@ class LocalParticipant extends Participant {
17905
18057
  }
17906
18058
  const stream = await navigator.mediaDevices.getDisplayMedia({
17907
18059
  audio: (_a = options.audio) !== null && _a !== void 0 ? _a : false,
17908
- video: videoConstraints
18060
+ video: videoConstraints,
18061
+ // @ts-expect-error support for experimental display media features
18062
+ controller: options.controller,
18063
+ selfBrowserSurface: options.selfBrowserSurface,
18064
+ surfaceSwitching: options.surfaceSwitching,
18065
+ systemAudio: options.systemAudio
17909
18066
  });
17910
18067
  const tracks = stream.getVideoTracks();
17911
18068
  if (tracks.length === 0) {
@@ -17927,7 +18084,11 @@ class LocalParticipant extends Participant {
17927
18084
  * @param options
17928
18085
  */
17929
18086
  async publishTrack(track, options) {
17930
- var _a, _b, _c, _d, _e, _f;
18087
+ var _a, _b, _c;
18088
+ await ((_a = this.reconnectFuture) === null || _a === void 0 ? void 0 : _a.promise);
18089
+ if (track instanceof LocalTrack && this.pendingPublishPromises.has(track)) {
18090
+ await this.pendingPublishPromises.get(track);
18091
+ }
17931
18092
  // convert raw media track into audio or video track
17932
18093
  if (track instanceof MediaStreamTrack) {
17933
18094
  switch (track.kind) {
@@ -17941,6 +18102,20 @@ class LocalParticipant extends Participant {
17941
18102
  throw new TrackInvalidError("unsupported MediaStreamTrack kind ".concat(track.kind));
17942
18103
  }
17943
18104
  }
18105
+ // is it already published? if so skip
18106
+ let existingPublication;
18107
+ this.tracks.forEach(publication => {
18108
+ if (!publication.track) {
18109
+ return;
18110
+ }
18111
+ if (publication.track === track) {
18112
+ existingPublication = publication;
18113
+ }
18114
+ });
18115
+ if (existingPublication) {
18116
+ livekitLogger.warn('track has already been published, skipping');
18117
+ return existingPublication;
18118
+ }
17944
18119
  const isStereo = (options === null || options === void 0 ? void 0 : options.forceStereo) || 'channelCount' in track.mediaStreamTrack.getSettings() &&
17945
18120
  // @ts-ignore `channelCount` on getSettings() is currently only available for Safari, but is generally the best way to determine a stereo track https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/channelCount
17946
18121
  track.mediaStreamTrack.getSettings().channelCount === 2 || track.mediaStreamTrack.getConstraints().channelCount === 2;
@@ -17955,24 +18130,26 @@ class LocalParticipant extends Participant {
17955
18130
  if (options.red === undefined) {
17956
18131
  livekitLogger.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work.");
17957
18132
  }
17958
- (_a = options.dtx) !== null && _a !== void 0 ? _a : options.dtx = false;
17959
- (_b = options.red) !== null && _b !== void 0 ? _b : options.red = false;
18133
+ (_b = options.dtx) !== null && _b !== void 0 ? _b : options.dtx = false;
18134
+ (_c = options.red) !== null && _c !== void 0 ? _c : options.red = false;
17960
18135
  }
17961
18136
  const opts = _objectSpread2(_objectSpread2({}, this.roomOptions.publishDefaults), options);
17962
- // is it already published? if so skip
17963
- let existingPublication;
17964
- this.tracks.forEach(publication => {
17965
- if (!publication.track) {
17966
- return;
17967
- }
17968
- if (publication.track === track) {
17969
- existingPublication = publication;
17970
- }
17971
- });
17972
- if (existingPublication) return existingPublication;
17973
18137
  if (opts.source) {
17974
18138
  track.source = opts.source;
17975
18139
  }
18140
+ const publishPromise = this.publish(track, opts, options, isStereo);
18141
+ this.pendingPublishPromises.set(track, publishPromise);
18142
+ try {
18143
+ const publication = await publishPromise;
18144
+ return publication;
18145
+ } catch (e) {
18146
+ throw e;
18147
+ } finally {
18148
+ this.pendingPublishPromises.delete(track);
18149
+ }
18150
+ }
18151
+ async publish(track, opts, options, isStereo) {
18152
+ var _a, _b, _c, _d;
17976
18153
  const existingTrackOfSource = Array.from(this.tracks.values()).find(publishedTrack => track instanceof LocalTrack && publishedTrack.source === track.source);
17977
18154
  if (existingTrackOfSource && track.source !== Track.Source.Unknown) {
17978
18155
  try {
@@ -18014,9 +18191,9 @@ class LocalParticipant extends Participant {
18014
18191
  type: Track.kindToProto(track.kind),
18015
18192
  muted: track.isMuted,
18016
18193
  source: Track.sourceToProto(track.source),
18017
- disableDtx: !((_c = opts.dtx) !== null && _c !== void 0 ? _c : true),
18194
+ disableDtx: !((_a = opts.dtx) !== null && _a !== void 0 ? _a : true),
18018
18195
  stereo: isStereo,
18019
- disableRed: !((_d = opts.red) !== null && _d !== void 0 ? _d : true)
18196
+ disableRed: !((_b = opts.red) !== null && _b !== void 0 ? _b : true)
18020
18197
  });
18021
18198
  // compute encodings and layers for video
18022
18199
  let encodings;
@@ -18039,7 +18216,7 @@ class LocalParticipant extends Participant {
18039
18216
  if (track instanceof LocalVideoTrack) {
18040
18217
  if ((opts === null || opts === void 0 ? void 0 : opts.videoCodec) === 'av1') {
18041
18218
  // set scalabilityMode to 'L3T3' by default
18042
- opts.scalabilityMode = (_e = opts.scalabilityMode) !== null && _e !== void 0 ? _e : 'L3T3';
18219
+ opts.scalabilityMode = (_c = opts.scalabilityMode) !== null && _c !== void 0 ? _c : 'L3T3';
18043
18220
  }
18044
18221
  // set up backup
18045
18222
  if (opts.videoCodec && opts.backupCodec && opts.videoCodec !== opts.backupCodec.codec) {
@@ -18081,7 +18258,7 @@ class LocalParticipant extends Participant {
18081
18258
  });
18082
18259
  // store RTPSender
18083
18260
  track.sender = await this.engine.createSender(track, opts, encodings);
18084
- if (track.codec === 'av1' && encodings && ((_f = encodings[0]) === null || _f === void 0 ? void 0 : _f.maxBitrate)) {
18261
+ if (track.codec === 'av1' && encodings && ((_d = encodings[0]) === null || _d === void 0 ? void 0 : _d.maxBitrate)) {
18085
18262
  this.engine.publisher.setTrackCodecBitrate(req.cid, track.codec, encodings[0].maxBitrate / 1000);
18086
18263
  }
18087
18264
  this.engine.negotiate();
@@ -18240,25 +18417,17 @@ class LocalParticipant extends Participant {
18240
18417
  await this.publishTrack(track, pub.options);
18241
18418
  }));
18242
18419
  }
18243
- /**
18244
- * Publish a new data payload to the room. Data will be forwarded to each
18245
- * participant in the room if the destination argument is empty
18246
- *
18247
- * @param data Uint8Array of the payload. To send string data, use TextEncoder.encode
18248
- * @param kind whether to send this as reliable or lossy.
18249
- * For data that you need delivery guarantee (such as chat messages), use Reliable.
18250
- * For data that should arrive as quickly as possible, but you are ok with dropped
18251
- * packets, use Lossy.
18252
- * @param destination the participants who will receive the message
18253
- */
18254
- async publishData(data, kind, destination) {
18255
- const dest = [];
18420
+ async publishData(data, kind) {
18421
+ let publishOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
18422
+ const destination = Array.isArray(publishOptions) ? publishOptions : publishOptions === null || publishOptions === void 0 ? void 0 : publishOptions.destination;
18423
+ const destinationSids = [];
18424
+ const topic = !Array.isArray(publishOptions) ? publishOptions.topic : undefined;
18256
18425
  if (destination !== undefined) {
18257
18426
  destination.forEach(val => {
18258
18427
  if (val instanceof RemoteParticipant) {
18259
- dest.push(val.sid);
18428
+ destinationSids.push(val.sid);
18260
18429
  } else {
18261
- dest.push(val);
18430
+ destinationSids.push(val);
18262
18431
  }
18263
18432
  });
18264
18433
  }
@@ -18269,7 +18438,8 @@ class LocalParticipant extends Participant {
18269
18438
  user: {
18270
18439
  participantSid: this.sid,
18271
18440
  payload: data,
18272
- destinationSids: dest
18441
+ destinationSids: destinationSids,
18442
+ topic
18273
18443
  }
18274
18444
  }
18275
18445
  };
@@ -19993,7 +20163,7 @@ class RTCEngine extends eventsExports.EventEmitter {
19993
20163
  // in case the engine is currently reconnecting, attempt a reconnect immediately after the browser state has changed to 'onLine'
19994
20164
  if (this.client.isReconnecting) {
19995
20165
  this.clearReconnectTimeout();
19996
- this.attemptReconnect(ReconnectReason.REASON_SIGNAL_DISCONNECTED);
20166
+ this.attemptReconnect(ReconnectReason.RR_SIGNAL_DISCONNECTED);
19997
20167
  }
19998
20168
  };
19999
20169
  this.client = new SignalClient();
@@ -20178,7 +20348,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20178
20348
  // on Safari, PeerConnection will switch to 'disconnected' during renegotiation
20179
20349
  if (this.pcState === PCState.Connected) {
20180
20350
  this.pcState = PCState.Disconnected;
20181
- this.handleDisconnect('primary peerconnection', subscriberPrimary ? ReconnectReason.REASON_SUBSCRIBER_FAILED : ReconnectReason.REASON_PUBLISHER_FAILED);
20351
+ this.handleDisconnect('primary peerconnection', subscriberPrimary ? ReconnectReason.RR_SUBSCRIBER_FAILED : ReconnectReason.RR_PUBLISHER_FAILED);
20182
20352
  }
20183
20353
  }
20184
20354
  };
@@ -20186,7 +20356,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20186
20356
  livekitLogger.debug("secondary PC state changed ".concat(secondaryPC.connectionState));
20187
20357
  // also reconnect if secondary peerconnection fails
20188
20358
  if (secondaryPC.connectionState === 'failed') {
20189
- this.handleDisconnect('secondary peerconnection', subscriberPrimary ? ReconnectReason.REASON_PUBLISHER_FAILED : ReconnectReason.REASON_SUBSCRIBER_FAILED);
20359
+ this.handleDisconnect('secondary peerconnection', subscriberPrimary ? ReconnectReason.RR_PUBLISHER_FAILED : ReconnectReason.RR_SUBSCRIBER_FAILED);
20190
20360
  }
20191
20361
  };
20192
20362
  this.subscriber.pc.ontrack = ev => {
@@ -20249,7 +20419,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20249
20419
  this.token = token;
20250
20420
  };
20251
20421
  this.client.onClose = () => {
20252
- this.handleDisconnect('signal', ReconnectReason.REASON_SIGNAL_DISCONNECTED);
20422
+ this.handleDisconnect('signal', ReconnectReason.RR_SIGNAL_DISCONNECTED);
20253
20423
  };
20254
20424
  this.client.onLeave = leave => {
20255
20425
  if (leave === null || leave === void 0 ? void 0 : leave.canReconnect) {
@@ -20461,7 +20631,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20461
20631
  this.fullReconnectOnNext = true;
20462
20632
  }
20463
20633
  if (recoverable) {
20464
- this.handleDisconnect('reconnect', ReconnectReason.REASON_UNKOWN);
20634
+ this.handleDisconnect('reconnect', ReconnectReason.RR_UNKOWN);
20465
20635
  } else {
20466
20636
  livekitLogger.info("could not recover connection after ".concat(this.reconnectAttempts, " attempts, ").concat(Date.now() - this.reconnectStart, "ms. giving up"));
20467
20637
  this.emit(EngineEvent.Disconnected);
@@ -20653,7 +20823,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20653
20823
  this.on(EngineEvent.Closing, handleClosed);
20654
20824
  const negotiationTimeout = setTimeout(() => {
20655
20825
  reject('negotiation timed out');
20656
- this.handleDisconnect('negotiation', ReconnectReason.REASON_SIGNAL_DISCONNECTED);
20826
+ this.handleDisconnect('negotiation', ReconnectReason.RR_SIGNAL_DISCONNECTED);
20657
20827
  }, this.peerConnectionTimeout);
20658
20828
  const cleanup = () => {
20659
20829
  clearTimeout(negotiationTimeout);
@@ -20672,7 +20842,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20672
20842
  if (e instanceof NegotiationError) {
20673
20843
  this.fullReconnectOnNext = true;
20674
20844
  }
20675
- this.handleDisconnect('negotiation', ReconnectReason.REASON_UNKOWN);
20845
+ this.handleDisconnect('negotiation', ReconnectReason.RR_UNKOWN);
20676
20846
  });
20677
20847
  });
20678
20848
  }
@@ -20989,40 +21159,47 @@ class Room extends eventsExports.EventEmitter {
20989
21159
  livekitLogger.debug("reconnected to server", {
20990
21160
  region: joinResponse.serverRegion
20991
21161
  });
20992
- this.setAndEmitConnectionState(ConnectionState.Connected);
20993
- this.emit(RoomEvent.Reconnected);
20994
- // rehydrate participants
20995
- if (joinResponse.participant) {
20996
- // with a restart, the sid will have changed, we'll map our understanding to it
20997
- this.localParticipant.sid = joinResponse.participant.sid;
20998
- this.handleParticipantUpdates([joinResponse.participant]);
20999
- }
21000
- this.handleParticipantUpdates(joinResponse.otherParticipants);
21001
- // unpublish & republish tracks
21002
- const localPubs = [];
21003
- this.localParticipant.tracks.forEach(pub => {
21004
- if (pub.track) {
21005
- localPubs.push(pub);
21162
+ try {
21163
+ // rehydrate participants
21164
+ if (joinResponse.participant) {
21165
+ // with a restart, the sid will have changed, we'll map our understanding to it
21166
+ this.localParticipant.sid = joinResponse.participant.sid;
21167
+ this.handleParticipantUpdates([joinResponse.participant]);
21006
21168
  }
21007
- });
21008
- await Promise.all(localPubs.map(async pub => {
21009
- const track = pub.track;
21010
- this.localParticipant.unpublishTrack(track, false);
21011
- if (!track.isMuted) {
21012
- if ((track instanceof LocalAudioTrack || track instanceof LocalVideoTrack) && !track.isUserProvided) {
21013
- // we need to restart the track before publishing, often a full reconnect
21014
- // is necessary because computer had gone to sleep.
21015
- livekitLogger.debug('restarting existing track', {
21169
+ this.handleParticipantUpdates(joinResponse.otherParticipants);
21170
+ // unpublish & republish tracks
21171
+ const localPubs = [];
21172
+ this.localParticipant.tracks.forEach(pub => {
21173
+ if (pub.track) {
21174
+ localPubs.push(pub);
21175
+ }
21176
+ });
21177
+ await Promise.all(localPubs.map(async pub => {
21178
+ const track = pub.track;
21179
+ this.localParticipant.unpublishTrack(track, false);
21180
+ if (!track.isMuted) {
21181
+ if ((track instanceof LocalAudioTrack || track instanceof LocalVideoTrack) && !track.isUserProvided) {
21182
+ // we need to restart the track before publishing, often a full reconnect
21183
+ // is necessary because computer had gone to sleep.
21184
+ livekitLogger.debug('restarting existing track', {
21185
+ track: pub.trackSid
21186
+ });
21187
+ await track.restartTrack();
21188
+ }
21189
+ livekitLogger.debug('publishing new track', {
21016
21190
  track: pub.trackSid
21017
21191
  });
21018
- await track.restartTrack();
21192
+ await this.localParticipant.publishTrack(track, pub.options);
21019
21193
  }
21020
- livekitLogger.debug('publishing new track', {
21021
- track: pub.trackSid
21022
- });
21023
- await this.localParticipant.publishTrack(track, pub.options);
21024
- }
21025
- }));
21194
+ }));
21195
+ } catch (error) {
21196
+ livekitLogger.error('error trying to re-publish tracks after reconnection', {
21197
+ error
21198
+ });
21199
+ } finally {
21200
+ this.setAndEmitConnectionState(ConnectionState.Connected);
21201
+ this.emit(RoomEvent.Reconnected);
21202
+ }
21026
21203
  };
21027
21204
  this.handleParticipantUpdates = participantInfos => {
21028
21205
  // handle changes to participant state, and send events
@@ -21039,14 +21216,16 @@ class Room extends eventsExports.EventEmitter {
21039
21216
  }
21040
21217
  let remoteParticipant = this.participants.get(info.sid);
21041
21218
  const isNewParticipant = !remoteParticipant;
21042
- // create participant if doesn't exist
21043
- remoteParticipant = this.getOrCreateParticipant(info.sid, info);
21044
21219
  // when it's disconnected, send updates
21045
21220
  if (info.state === ParticipantInfo_State.DISCONNECTED) {
21046
21221
  this.handleParticipantDisconnected(info.sid, remoteParticipant);
21047
- } else if (!isNewParticipant) {
21048
- // just update, no events
21049
- remoteParticipant.updateInfo(info);
21222
+ } else {
21223
+ // create participant if doesn't exist
21224
+ remoteParticipant = this.getOrCreateParticipant(info.sid, info);
21225
+ if (!isNewParticipant) {
21226
+ // just update, no events
21227
+ remoteParticipant.updateInfo(info);
21228
+ }
21050
21229
  }
21051
21230
  });
21052
21231
  };
@@ -21138,7 +21317,7 @@ class Room extends eventsExports.EventEmitter {
21138
21317
  this.handleDataPacket = (userPacket, kind) => {
21139
21318
  // find the participant
21140
21319
  const participant = this.participants.get(userPacket.participantSid);
21141
- this.emit(RoomEvent.DataReceived, userPacket.payload, participant, kind);
21320
+ this.emit(RoomEvent.DataReceived, userPacket.payload, participant, kind, userPacket.topic);
21142
21321
  // also emit on the participant
21143
21322
  participant === null || participant === void 0 ? void 0 : participant.emit(ParticipantEvent.DataReceived, userPacket.payload, kind);
21144
21323
  };