livekit-client 0.18.2 → 0.18.3

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.
@@ -4672,7 +4672,7 @@ const Room$1 = {
4672
4672
  maxParticipants: isSet$1(object.maxParticipants) ? Number(object.maxParticipants) : 0,
4673
4673
  creationTime: isSet$1(object.creationTime) ? Number(object.creationTime) : 0,
4674
4674
  turnPassword: isSet$1(object.turnPassword) ? String(object.turnPassword) : '',
4675
- enabledCodecs: Array.isArray(object?.enabledCodecs)
4675
+ enabledCodecs: Array.isArray(object === null || object === void 0 ? void 0 : object.enabledCodecs)
4676
4676
  ? object.enabledCodecs.map((e) => Codec.fromJSON(e))
4677
4677
  : [],
4678
4678
  metadata: isSet$1(object.metadata) ? String(object.metadata) : '',
@@ -4702,17 +4702,18 @@ const Room$1 = {
4702
4702
  return obj;
4703
4703
  },
4704
4704
  fromPartial(object) {
4705
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4705
4706
  const message = createBaseRoom();
4706
- message.sid = object.sid ?? '';
4707
- message.name = object.name ?? '';
4708
- message.emptyTimeout = object.emptyTimeout ?? 0;
4709
- message.maxParticipants = object.maxParticipants ?? 0;
4710
- message.creationTime = object.creationTime ?? 0;
4711
- message.turnPassword = object.turnPassword ?? '';
4712
- message.enabledCodecs = object.enabledCodecs?.map((e) => Codec.fromPartial(e)) || [];
4713
- message.metadata = object.metadata ?? '';
4714
- message.numParticipants = object.numParticipants ?? 0;
4715
- message.activeRecording = object.activeRecording ?? false;
4707
+ message.sid = (_a = object.sid) !== null && _a !== void 0 ? _a : '';
4708
+ message.name = (_b = object.name) !== null && _b !== void 0 ? _b : '';
4709
+ message.emptyTimeout = (_c = object.emptyTimeout) !== null && _c !== void 0 ? _c : 0;
4710
+ message.maxParticipants = (_d = object.maxParticipants) !== null && _d !== void 0 ? _d : 0;
4711
+ message.creationTime = (_e = object.creationTime) !== null && _e !== void 0 ? _e : 0;
4712
+ message.turnPassword = (_f = object.turnPassword) !== null && _f !== void 0 ? _f : '';
4713
+ message.enabledCodecs = ((_g = object.enabledCodecs) === null || _g === void 0 ? void 0 : _g.map((e) => Codec.fromPartial(e))) || [];
4714
+ message.metadata = (_h = object.metadata) !== null && _h !== void 0 ? _h : '';
4715
+ message.numParticipants = (_j = object.numParticipants) !== null && _j !== void 0 ? _j : 0;
4716
+ message.activeRecording = (_k = object.activeRecording) !== null && _k !== void 0 ? _k : false;
4716
4717
  return message;
4717
4718
  },
4718
4719
  };
@@ -4762,9 +4763,10 @@ const Codec = {
4762
4763
  return obj;
4763
4764
  },
4764
4765
  fromPartial(object) {
4766
+ var _a, _b;
4765
4767
  const message = createBaseCodec();
4766
- message.mime = object.mime ?? '';
4767
- message.fmtpLine = object.fmtpLine ?? '';
4768
+ message.mime = (_a = object.mime) !== null && _a !== void 0 ? _a : '';
4769
+ message.fmtpLine = (_b = object.fmtpLine) !== null && _b !== void 0 ? _b : '';
4768
4770
  return message;
4769
4771
  },
4770
4772
  };
@@ -4844,12 +4846,13 @@ const ParticipantPermission = {
4844
4846
  return obj;
4845
4847
  },
4846
4848
  fromPartial(object) {
4849
+ var _a, _b, _c, _d, _e;
4847
4850
  const message = createBaseParticipantPermission();
4848
- message.canSubscribe = object.canSubscribe ?? false;
4849
- message.canPublish = object.canPublish ?? false;
4850
- message.canPublishData = object.canPublishData ?? false;
4851
- message.hidden = object.hidden ?? false;
4852
- message.recorder = object.recorder ?? false;
4851
+ message.canSubscribe = (_a = object.canSubscribe) !== null && _a !== void 0 ? _a : false;
4852
+ message.canPublish = (_b = object.canPublish) !== null && _b !== void 0 ? _b : false;
4853
+ message.canPublishData = (_c = object.canPublishData) !== null && _c !== void 0 ? _c : false;
4854
+ message.hidden = (_d = object.hidden) !== null && _d !== void 0 ? _d : false;
4855
+ message.recorder = (_e = object.recorder) !== null && _e !== void 0 ? _e : false;
4853
4856
  return message;
4854
4857
  },
4855
4858
  };
@@ -4950,7 +4953,7 @@ const ParticipantInfo = {
4950
4953
  sid: isSet$1(object.sid) ? String(object.sid) : '',
4951
4954
  identity: isSet$1(object.identity) ? String(object.identity) : '',
4952
4955
  state: isSet$1(object.state) ? participantInfo_StateFromJSON(object.state) : 0,
4953
- tracks: Array.isArray(object?.tracks)
4956
+ tracks: Array.isArray(object === null || object === void 0 ? void 0 : object.tracks)
4954
4957
  ? object.tracks.map((e) => TrackInfo.fromJSON(e))
4955
4958
  : [],
4956
4959
  metadata: isSet$1(object.metadata) ? String(object.metadata) : '',
@@ -4986,20 +4989,21 @@ const ParticipantInfo = {
4986
4989
  return obj;
4987
4990
  },
4988
4991
  fromPartial(object) {
4992
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4989
4993
  const message = createBaseParticipantInfo();
4990
- message.sid = object.sid ?? '';
4991
- message.identity = object.identity ?? '';
4992
- message.state = object.state ?? 0;
4993
- message.tracks = object.tracks?.map((e) => TrackInfo.fromPartial(e)) || [];
4994
- message.metadata = object.metadata ?? '';
4995
- message.joinedAt = object.joinedAt ?? 0;
4996
- message.name = object.name ?? '';
4997
- message.version = object.version ?? 0;
4994
+ message.sid = (_a = object.sid) !== null && _a !== void 0 ? _a : '';
4995
+ message.identity = (_b = object.identity) !== null && _b !== void 0 ? _b : '';
4996
+ message.state = (_c = object.state) !== null && _c !== void 0 ? _c : 0;
4997
+ message.tracks = ((_d = object.tracks) === null || _d === void 0 ? void 0 : _d.map((e) => TrackInfo.fromPartial(e))) || [];
4998
+ message.metadata = (_e = object.metadata) !== null && _e !== void 0 ? _e : '';
4999
+ message.joinedAt = (_f = object.joinedAt) !== null && _f !== void 0 ? _f : 0;
5000
+ message.name = (_g = object.name) !== null && _g !== void 0 ? _g : '';
5001
+ message.version = (_h = object.version) !== null && _h !== void 0 ? _h : 0;
4998
5002
  message.permission =
4999
5003
  object.permission !== undefined && object.permission !== null
5000
5004
  ? ParticipantPermission.fromPartial(object.permission)
5001
5005
  : undefined;
5002
- message.region = object.region ?? '';
5006
+ message.region = (_j = object.region) !== null && _j !== void 0 ? _j : '';
5003
5007
  return message;
5004
5008
  },
5005
5009
  };
@@ -5120,7 +5124,7 @@ const TrackInfo = {
5120
5124
  simulcast: isSet$1(object.simulcast) ? Boolean(object.simulcast) : false,
5121
5125
  disableDtx: isSet$1(object.disableDtx) ? Boolean(object.disableDtx) : false,
5122
5126
  source: isSet$1(object.source) ? trackSourceFromJSON(object.source) : 0,
5123
- layers: Array.isArray(object?.layers)
5127
+ layers: Array.isArray(object === null || object === void 0 ? void 0 : object.layers)
5124
5128
  ? object.layers.map((e) => VideoLayer.fromJSON(e))
5125
5129
  : [],
5126
5130
  mimeType: isSet$1(object.mimeType) ? String(object.mimeType) : '',
@@ -5149,19 +5153,20 @@ const TrackInfo = {
5149
5153
  return obj;
5150
5154
  },
5151
5155
  fromPartial(object) {
5156
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
5152
5157
  const message = createBaseTrackInfo();
5153
- message.sid = object.sid ?? '';
5154
- message.type = object.type ?? 0;
5155
- message.name = object.name ?? '';
5156
- message.muted = object.muted ?? false;
5157
- message.width = object.width ?? 0;
5158
- message.height = object.height ?? 0;
5159
- message.simulcast = object.simulcast ?? false;
5160
- message.disableDtx = object.disableDtx ?? false;
5161
- message.source = object.source ?? 0;
5162
- message.layers = object.layers?.map((e) => VideoLayer.fromPartial(e)) || [];
5163
- message.mimeType = object.mimeType ?? '';
5164
- message.mid = object.mid ?? '';
5158
+ message.sid = (_a = object.sid) !== null && _a !== void 0 ? _a : '';
5159
+ message.type = (_b = object.type) !== null && _b !== void 0 ? _b : 0;
5160
+ message.name = (_c = object.name) !== null && _c !== void 0 ? _c : '';
5161
+ message.muted = (_d = object.muted) !== null && _d !== void 0 ? _d : false;
5162
+ message.width = (_e = object.width) !== null && _e !== void 0 ? _e : 0;
5163
+ message.height = (_f = object.height) !== null && _f !== void 0 ? _f : 0;
5164
+ message.simulcast = (_g = object.simulcast) !== null && _g !== void 0 ? _g : false;
5165
+ message.disableDtx = (_h = object.disableDtx) !== null && _h !== void 0 ? _h : false;
5166
+ message.source = (_j = object.source) !== null && _j !== void 0 ? _j : 0;
5167
+ message.layers = ((_k = object.layers) === null || _k === void 0 ? void 0 : _k.map((e) => VideoLayer.fromPartial(e))) || [];
5168
+ message.mimeType = (_l = object.mimeType) !== null && _l !== void 0 ? _l : '';
5169
+ message.mid = (_m = object.mid) !== null && _m !== void 0 ? _m : '';
5165
5170
  return message;
5166
5171
  },
5167
5172
  };
@@ -5235,12 +5240,13 @@ const VideoLayer = {
5235
5240
  return obj;
5236
5241
  },
5237
5242
  fromPartial(object) {
5243
+ var _a, _b, _c, _d, _e;
5238
5244
  const message = createBaseVideoLayer();
5239
- message.quality = object.quality ?? 0;
5240
- message.width = object.width ?? 0;
5241
- message.height = object.height ?? 0;
5242
- message.bitrate = object.bitrate ?? 0;
5243
- message.ssrc = object.ssrc ?? 0;
5245
+ message.quality = (_a = object.quality) !== null && _a !== void 0 ? _a : 0;
5246
+ message.width = (_b = object.width) !== null && _b !== void 0 ? _b : 0;
5247
+ message.height = (_c = object.height) !== null && _c !== void 0 ? _c : 0;
5248
+ message.bitrate = (_d = object.bitrate) !== null && _d !== void 0 ? _d : 0;
5249
+ message.ssrc = (_e = object.ssrc) !== null && _e !== void 0 ? _e : 0;
5244
5250
  return message;
5245
5251
  },
5246
5252
  };
@@ -5300,8 +5306,9 @@ const DataPacket = {
5300
5306
  return obj;
5301
5307
  },
5302
5308
  fromPartial(object) {
5309
+ var _a;
5303
5310
  const message = createBaseDataPacket();
5304
- message.kind = object.kind ?? 0;
5311
+ message.kind = (_a = object.kind) !== null && _a !== void 0 ? _a : 0;
5305
5312
  message.user =
5306
5313
  object.user !== undefined && object.user !== null
5307
5314
  ? UserPacket.fromPartial(object.user)
@@ -5342,7 +5349,7 @@ const ActiveSpeakerUpdate = {
5342
5349
  },
5343
5350
  fromJSON(object) {
5344
5351
  return {
5345
- speakers: Array.isArray(object?.speakers)
5352
+ speakers: Array.isArray(object === null || object === void 0 ? void 0 : object.speakers)
5346
5353
  ? object.speakers.map((e) => SpeakerInfo.fromJSON(e))
5347
5354
  : [],
5348
5355
  };
@@ -5358,8 +5365,9 @@ const ActiveSpeakerUpdate = {
5358
5365
  return obj;
5359
5366
  },
5360
5367
  fromPartial(object) {
5368
+ var _a;
5361
5369
  const message = createBaseActiveSpeakerUpdate();
5362
- message.speakers = object.speakers?.map((e) => SpeakerInfo.fromPartial(e)) || [];
5370
+ message.speakers = ((_a = object.speakers) === null || _a === void 0 ? void 0 : _a.map((e) => SpeakerInfo.fromPartial(e))) || [];
5363
5371
  return message;
5364
5372
  },
5365
5373
  };
@@ -5417,10 +5425,11 @@ const SpeakerInfo = {
5417
5425
  return obj;
5418
5426
  },
5419
5427
  fromPartial(object) {
5428
+ var _a, _b, _c;
5420
5429
  const message = createBaseSpeakerInfo();
5421
- message.sid = object.sid ?? '';
5422
- message.level = object.level ?? 0;
5423
- message.active = object.active ?? false;
5430
+ message.sid = (_a = object.sid) !== null && _a !== void 0 ? _a : '';
5431
+ message.level = (_b = object.level) !== null && _b !== void 0 ? _b : 0;
5432
+ message.active = (_c = object.active) !== null && _c !== void 0 ? _c : false;
5424
5433
  return message;
5425
5434
  },
5426
5435
  };
@@ -5467,7 +5476,7 @@ const UserPacket = {
5467
5476
  return {
5468
5477
  participantSid: isSet$1(object.participantSid) ? String(object.participantSid) : '',
5469
5478
  payload: isSet$1(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(),
5470
- destinationSids: Array.isArray(object?.destinationSids)
5479
+ destinationSids: Array.isArray(object === null || object === void 0 ? void 0 : object.destinationSids)
5471
5480
  ? object.destinationSids.map((e) => String(e))
5472
5481
  : [],
5473
5482
  };
@@ -5486,10 +5495,11 @@ const UserPacket = {
5486
5495
  return obj;
5487
5496
  },
5488
5497
  fromPartial(object) {
5498
+ var _a, _b, _c;
5489
5499
  const message = createBaseUserPacket();
5490
- message.participantSid = object.participantSid ?? '';
5491
- message.payload = object.payload ?? new Uint8Array();
5492
- message.destinationSids = object.destinationSids?.map((e) => e) || [];
5500
+ message.participantSid = (_a = object.participantSid) !== null && _a !== void 0 ? _a : '';
5501
+ message.payload = (_b = object.payload) !== null && _b !== void 0 ? _b : new Uint8Array();
5502
+ message.destinationSids = ((_c = object.destinationSids) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
5493
5503
  return message;
5494
5504
  },
5495
5505
  };
@@ -5529,7 +5539,7 @@ const ParticipantTracks = {
5529
5539
  fromJSON(object) {
5530
5540
  return {
5531
5541
  participantSid: isSet$1(object.participantSid) ? String(object.participantSid) : '',
5532
- trackSids: Array.isArray(object?.trackSids)
5542
+ trackSids: Array.isArray(object === null || object === void 0 ? void 0 : object.trackSids)
5533
5543
  ? object.trackSids.map((e) => String(e))
5534
5544
  : [],
5535
5545
  };
@@ -5546,9 +5556,10 @@ const ParticipantTracks = {
5546
5556
  return obj;
5547
5557
  },
5548
5558
  fromPartial(object) {
5559
+ var _a, _b;
5549
5560
  const message = createBaseParticipantTracks();
5550
- message.participantSid = object.participantSid ?? '';
5551
- message.trackSids = object.trackSids?.map((e) => e) || [];
5561
+ message.participantSid = (_a = object.participantSid) !== null && _a !== void 0 ? _a : '';
5562
+ message.trackSids = ((_b = object.trackSids) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
5552
5563
  return message;
5553
5564
  },
5554
5565
  };
@@ -5664,16 +5675,17 @@ const ClientInfo = {
5664
5675
  return obj;
5665
5676
  },
5666
5677
  fromPartial(object) {
5678
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
5667
5679
  const message = createBaseClientInfo();
5668
- message.sdk = object.sdk ?? 0;
5669
- message.version = object.version ?? '';
5670
- message.protocol = object.protocol ?? 0;
5671
- message.os = object.os ?? '';
5672
- message.osVersion = object.osVersion ?? '';
5673
- message.deviceModel = object.deviceModel ?? '';
5674
- message.browser = object.browser ?? '';
5675
- message.browserVersion = object.browserVersion ?? '';
5676
- message.address = object.address ?? '';
5680
+ message.sdk = (_a = object.sdk) !== null && _a !== void 0 ? _a : 0;
5681
+ message.version = (_b = object.version) !== null && _b !== void 0 ? _b : '';
5682
+ message.protocol = (_c = object.protocol) !== null && _c !== void 0 ? _c : 0;
5683
+ message.os = (_d = object.os) !== null && _d !== void 0 ? _d : '';
5684
+ message.osVersion = (_e = object.osVersion) !== null && _e !== void 0 ? _e : '';
5685
+ message.deviceModel = (_f = object.deviceModel) !== null && _f !== void 0 ? _f : '';
5686
+ message.browser = (_g = object.browser) !== null && _g !== void 0 ? _g : '';
5687
+ message.browserVersion = (_h = object.browserVersion) !== null && _h !== void 0 ? _h : '';
5688
+ message.address = (_j = object.address) !== null && _j !== void 0 ? _j : '';
5677
5689
  return message;
5678
5690
  },
5679
5691
  };
@@ -5736,6 +5748,7 @@ const ClientConfiguration = {
5736
5748
  return obj;
5737
5749
  },
5738
5750
  fromPartial(object) {
5751
+ var _a;
5739
5752
  const message = createBaseClientConfiguration();
5740
5753
  message.video =
5741
5754
  object.video !== undefined && object.video !== null
@@ -5745,7 +5758,7 @@ const ClientConfiguration = {
5745
5758
  object.screen !== undefined && object.screen !== null
5746
5759
  ? VideoConfiguration.fromPartial(object.screen)
5747
5760
  : undefined;
5748
- message.resumeConnection = object.resumeConnection ?? 0;
5761
+ message.resumeConnection = (_a = object.resumeConnection) !== null && _a !== void 0 ? _a : 0;
5749
5762
  return message;
5750
5763
  },
5751
5764
  };
@@ -5790,8 +5803,9 @@ const VideoConfiguration = {
5790
5803
  return obj;
5791
5804
  },
5792
5805
  fromPartial(object) {
5806
+ var _a;
5793
5807
  const message = createBaseVideoConfiguration();
5794
- message.hardwareEncoder = object.hardwareEncoder ?? 0;
5808
+ message.hardwareEncoder = (_a = object.hardwareEncoder) !== null && _a !== void 0 ? _a : 0;
5795
5809
  return message;
5796
5810
  },
5797
5811
  };
@@ -6335,6 +6349,7 @@ const SignalResponse = {
6335
6349
  return obj;
6336
6350
  },
6337
6351
  fromPartial(object) {
6352
+ var _a;
6338
6353
  const message = createBaseSignalResponse();
6339
6354
  message.join =
6340
6355
  object.join !== undefined && object.join !== null
@@ -6393,7 +6408,7 @@ const SignalResponse = {
6393
6408
  object.subscriptionPermissionUpdate !== null
6394
6409
  ? SubscriptionPermissionUpdate.fromPartial(object.subscriptionPermissionUpdate)
6395
6410
  : undefined;
6396
- message.refreshToken = object.refreshToken ?? undefined;
6411
+ message.refreshToken = (_a = object.refreshToken) !== null && _a !== void 0 ? _a : undefined;
6397
6412
  message.trackUnpublished =
6398
6413
  object.trackUnpublished !== undefined && object.trackUnpublished !== null
6399
6414
  ? TrackUnpublishedResponse.fromPartial(object.trackUnpublished)
@@ -6496,7 +6511,7 @@ const AddTrackRequest = {
6496
6511
  muted: isSet(object.muted) ? Boolean(object.muted) : false,
6497
6512
  disableDtx: isSet(object.disableDtx) ? Boolean(object.disableDtx) : false,
6498
6513
  source: isSet(object.source) ? trackSourceFromJSON(object.source) : 0,
6499
- layers: Array.isArray(object?.layers)
6514
+ layers: Array.isArray(object === null || object === void 0 ? void 0 : object.layers)
6500
6515
  ? object.layers.map((e) => VideoLayer.fromJSON(e))
6501
6516
  : [],
6502
6517
  };
@@ -6520,16 +6535,17 @@ const AddTrackRequest = {
6520
6535
  return obj;
6521
6536
  },
6522
6537
  fromPartial(object) {
6538
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6523
6539
  const message = createBaseAddTrackRequest();
6524
- message.cid = object.cid ?? '';
6525
- message.name = object.name ?? '';
6526
- message.type = object.type ?? 0;
6527
- message.width = object.width ?? 0;
6528
- message.height = object.height ?? 0;
6529
- message.muted = object.muted ?? false;
6530
- message.disableDtx = object.disableDtx ?? false;
6531
- message.source = object.source ?? 0;
6532
- message.layers = object.layers?.map((e) => VideoLayer.fromPartial(e)) || [];
6540
+ message.cid = (_a = object.cid) !== null && _a !== void 0 ? _a : '';
6541
+ message.name = (_b = object.name) !== null && _b !== void 0 ? _b : '';
6542
+ message.type = (_c = object.type) !== null && _c !== void 0 ? _c : 0;
6543
+ message.width = (_d = object.width) !== null && _d !== void 0 ? _d : 0;
6544
+ message.height = (_e = object.height) !== null && _e !== void 0 ? _e : 0;
6545
+ message.muted = (_f = object.muted) !== null && _f !== void 0 ? _f : false;
6546
+ message.disableDtx = (_g = object.disableDtx) !== null && _g !== void 0 ? _g : false;
6547
+ message.source = (_h = object.source) !== null && _h !== void 0 ? _h : 0;
6548
+ message.layers = ((_j = object.layers) === null || _j === void 0 ? void 0 : _j.map((e) => VideoLayer.fromPartial(e))) || [];
6533
6549
  return message;
6534
6550
  },
6535
6551
  };
@@ -6579,9 +6595,10 @@ const TrickleRequest = {
6579
6595
  return obj;
6580
6596
  },
6581
6597
  fromPartial(object) {
6598
+ var _a, _b;
6582
6599
  const message = createBaseTrickleRequest();
6583
- message.candidateInit = object.candidateInit ?? '';
6584
- message.target = object.target ?? 0;
6600
+ message.candidateInit = (_a = object.candidateInit) !== null && _a !== void 0 ? _a : '';
6601
+ message.target = (_b = object.target) !== null && _b !== void 0 ? _b : 0;
6585
6602
  return message;
6586
6603
  },
6587
6604
  };
@@ -6631,9 +6648,10 @@ const MuteTrackRequest = {
6631
6648
  return obj;
6632
6649
  },
6633
6650
  fromPartial(object) {
6651
+ var _a, _b;
6634
6652
  const message = createBaseMuteTrackRequest();
6635
- message.sid = object.sid ?? '';
6636
- message.muted = object.muted ?? false;
6653
+ message.sid = (_a = object.sid) !== null && _a !== void 0 ? _a : '';
6654
+ message.muted = (_b = object.muted) !== null && _b !== void 0 ? _b : false;
6637
6655
  return message;
6638
6656
  },
6639
6657
  };
@@ -6728,11 +6746,11 @@ const JoinResponse = {
6728
6746
  participant: isSet(object.participant)
6729
6747
  ? ParticipantInfo.fromJSON(object.participant)
6730
6748
  : undefined,
6731
- otherParticipants: Array.isArray(object?.otherParticipants)
6749
+ otherParticipants: Array.isArray(object === null || object === void 0 ? void 0 : object.otherParticipants)
6732
6750
  ? object.otherParticipants.map((e) => ParticipantInfo.fromJSON(e))
6733
6751
  : [],
6734
6752
  serverVersion: isSet(object.serverVersion) ? String(object.serverVersion) : '',
6735
- iceServers: Array.isArray(object?.iceServers)
6753
+ iceServers: Array.isArray(object === null || object === void 0 ? void 0 : object.iceServers)
6736
6754
  ? object.iceServers.map((e) => ICEServer.fromJSON(e))
6737
6755
  : [],
6738
6756
  subscriberPrimary: isSet(object.subscriberPrimary)
@@ -6775,6 +6793,7 @@ const JoinResponse = {
6775
6793
  return obj;
6776
6794
  },
6777
6795
  fromPartial(object) {
6796
+ var _a, _b, _c, _d, _e, _f;
6778
6797
  const message = createBaseJoinResponse();
6779
6798
  message.room =
6780
6799
  object.room !== undefined && object.room !== null ? Room$1.fromPartial(object.room) : undefined;
@@ -6783,16 +6802,16 @@ const JoinResponse = {
6783
6802
  ? ParticipantInfo.fromPartial(object.participant)
6784
6803
  : undefined;
6785
6804
  message.otherParticipants =
6786
- object.otherParticipants?.map((e) => ParticipantInfo.fromPartial(e)) || [];
6787
- message.serverVersion = object.serverVersion ?? '';
6788
- message.iceServers = object.iceServers?.map((e) => ICEServer.fromPartial(e)) || [];
6789
- message.subscriberPrimary = object.subscriberPrimary ?? false;
6790
- message.alternativeUrl = object.alternativeUrl ?? '';
6805
+ ((_a = object.otherParticipants) === null || _a === void 0 ? void 0 : _a.map((e) => ParticipantInfo.fromPartial(e))) || [];
6806
+ message.serverVersion = (_b = object.serverVersion) !== null && _b !== void 0 ? _b : '';
6807
+ message.iceServers = ((_c = object.iceServers) === null || _c === void 0 ? void 0 : _c.map((e) => ICEServer.fromPartial(e))) || [];
6808
+ message.subscriberPrimary = (_d = object.subscriberPrimary) !== null && _d !== void 0 ? _d : false;
6809
+ message.alternativeUrl = (_e = object.alternativeUrl) !== null && _e !== void 0 ? _e : '';
6791
6810
  message.clientConfiguration =
6792
6811
  object.clientConfiguration !== undefined && object.clientConfiguration !== null
6793
6812
  ? ClientConfiguration.fromPartial(object.clientConfiguration)
6794
6813
  : undefined;
6795
- message.serverRegion = object.serverRegion ?? '';
6814
+ message.serverRegion = (_f = object.serverRegion) !== null && _f !== void 0 ? _f : '';
6796
6815
  return message;
6797
6816
  },
6798
6817
  };
@@ -6843,8 +6862,9 @@ const TrackPublishedResponse = {
6843
6862
  return obj;
6844
6863
  },
6845
6864
  fromPartial(object) {
6865
+ var _a;
6846
6866
  const message = createBaseTrackPublishedResponse();
6847
- message.cid = object.cid ?? '';
6867
+ message.cid = (_a = object.cid) !== null && _a !== void 0 ? _a : '';
6848
6868
  message.track =
6849
6869
  object.track !== undefined && object.track !== null
6850
6870
  ? TrackInfo.fromPartial(object.track)
@@ -6890,8 +6910,9 @@ const TrackUnpublishedResponse = {
6890
6910
  return obj;
6891
6911
  },
6892
6912
  fromPartial(object) {
6913
+ var _a;
6893
6914
  const message = createBaseTrackUnpublishedResponse();
6894
- message.trackSid = object.trackSid ?? '';
6915
+ message.trackSid = (_a = object.trackSid) !== null && _a !== void 0 ? _a : '';
6895
6916
  return message;
6896
6917
  },
6897
6918
  };
@@ -6941,9 +6962,10 @@ const SessionDescription = {
6941
6962
  return obj;
6942
6963
  },
6943
6964
  fromPartial(object) {
6965
+ var _a, _b;
6944
6966
  const message = createBaseSessionDescription();
6945
- message.type = object.type ?? '';
6946
- message.sdp = object.sdp ?? '';
6967
+ message.type = (_a = object.type) !== null && _a !== void 0 ? _a : '';
6968
+ message.sdp = (_b = object.sdp) !== null && _b !== void 0 ? _b : '';
6947
6969
  return message;
6948
6970
  },
6949
6971
  };
@@ -6976,7 +6998,7 @@ const ParticipantUpdate = {
6976
6998
  },
6977
6999
  fromJSON(object) {
6978
7000
  return {
6979
- participants: Array.isArray(object?.participants)
7001
+ participants: Array.isArray(object === null || object === void 0 ? void 0 : object.participants)
6980
7002
  ? object.participants.map((e) => ParticipantInfo.fromJSON(e))
6981
7003
  : [],
6982
7004
  };
@@ -6992,8 +7014,9 @@ const ParticipantUpdate = {
6992
7014
  return obj;
6993
7015
  },
6994
7016
  fromPartial(object) {
7017
+ var _a;
6995
7018
  const message = createBaseParticipantUpdate();
6996
- message.participants = object.participants?.map((e) => ParticipantInfo.fromPartial(e)) || [];
7019
+ message.participants = ((_a = object.participants) === null || _a === void 0 ? void 0 : _a.map((e) => ParticipantInfo.fromPartial(e))) || [];
6997
7020
  return message;
6998
7021
  },
6999
7022
  };
@@ -7038,11 +7061,11 @@ const UpdateSubscription = {
7038
7061
  },
7039
7062
  fromJSON(object) {
7040
7063
  return {
7041
- trackSids: Array.isArray(object?.trackSids)
7064
+ trackSids: Array.isArray(object === null || object === void 0 ? void 0 : object.trackSids)
7042
7065
  ? object.trackSids.map((e) => String(e))
7043
7066
  : [],
7044
7067
  subscribe: isSet(object.subscribe) ? Boolean(object.subscribe) : false,
7045
- participantTracks: Array.isArray(object?.participantTracks)
7068
+ participantTracks: Array.isArray(object === null || object === void 0 ? void 0 : object.participantTracks)
7046
7069
  ? object.participantTracks.map((e) => ParticipantTracks.fromJSON(e))
7047
7070
  : [],
7048
7071
  };
@@ -7065,11 +7088,12 @@ const UpdateSubscription = {
7065
7088
  return obj;
7066
7089
  },
7067
7090
  fromPartial(object) {
7091
+ var _a, _b, _c;
7068
7092
  const message = createBaseUpdateSubscription();
7069
- message.trackSids = object.trackSids?.map((e) => e) || [];
7070
- message.subscribe = object.subscribe ?? false;
7093
+ message.trackSids = ((_a = object.trackSids) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
7094
+ message.subscribe = (_b = object.subscribe) !== null && _b !== void 0 ? _b : false;
7071
7095
  message.participantTracks =
7072
- object.participantTracks?.map((e) => ParticipantTracks.fromPartial(e)) || [];
7096
+ ((_c = object.participantTracks) === null || _c === void 0 ? void 0 : _c.map((e) => ParticipantTracks.fromPartial(e))) || [];
7073
7097
  return message;
7074
7098
  },
7075
7099
  };
@@ -7126,7 +7150,7 @@ const UpdateTrackSettings = {
7126
7150
  },
7127
7151
  fromJSON(object) {
7128
7152
  return {
7129
- trackSids: Array.isArray(object?.trackSids)
7153
+ trackSids: Array.isArray(object === null || object === void 0 ? void 0 : object.trackSids)
7130
7154
  ? object.trackSids.map((e) => String(e))
7131
7155
  : [],
7132
7156
  disabled: isSet(object.disabled) ? Boolean(object.disabled) : false,
@@ -7150,12 +7174,13 @@ const UpdateTrackSettings = {
7150
7174
  return obj;
7151
7175
  },
7152
7176
  fromPartial(object) {
7177
+ var _a, _b, _c, _d, _e;
7153
7178
  const message = createBaseUpdateTrackSettings();
7154
- message.trackSids = object.trackSids?.map((e) => e) || [];
7155
- message.disabled = object.disabled ?? false;
7156
- message.quality = object.quality ?? 0;
7157
- message.width = object.width ?? 0;
7158
- message.height = object.height ?? 0;
7179
+ message.trackSids = ((_a = object.trackSids) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
7180
+ message.disabled = (_b = object.disabled) !== null && _b !== void 0 ? _b : false;
7181
+ message.quality = (_c = object.quality) !== null && _c !== void 0 ? _c : 0;
7182
+ message.width = (_d = object.width) !== null && _d !== void 0 ? _d : 0;
7183
+ message.height = (_e = object.height) !== null && _e !== void 0 ? _e : 0;
7159
7184
  return message;
7160
7185
  },
7161
7186
  };
@@ -7197,8 +7222,9 @@ const LeaveRequest = {
7197
7222
  return obj;
7198
7223
  },
7199
7224
  fromPartial(object) {
7225
+ var _a;
7200
7226
  const message = createBaseLeaveRequest();
7201
- message.canReconnect = object.canReconnect ?? false;
7227
+ message.canReconnect = (_a = object.canReconnect) !== null && _a !== void 0 ? _a : false;
7202
7228
  return message;
7203
7229
  },
7204
7230
  };
@@ -7238,7 +7264,7 @@ const UpdateVideoLayers = {
7238
7264
  fromJSON(object) {
7239
7265
  return {
7240
7266
  trackSid: isSet(object.trackSid) ? String(object.trackSid) : '',
7241
- layers: Array.isArray(object?.layers)
7267
+ layers: Array.isArray(object === null || object === void 0 ? void 0 : object.layers)
7242
7268
  ? object.layers.map((e) => VideoLayer.fromJSON(e))
7243
7269
  : [],
7244
7270
  };
@@ -7255,9 +7281,10 @@ const UpdateVideoLayers = {
7255
7281
  return obj;
7256
7282
  },
7257
7283
  fromPartial(object) {
7284
+ var _a, _b;
7258
7285
  const message = createBaseUpdateVideoLayers();
7259
- message.trackSid = object.trackSid ?? '';
7260
- message.layers = object.layers?.map((e) => VideoLayer.fromPartial(e)) || [];
7286
+ message.trackSid = (_a = object.trackSid) !== null && _a !== void 0 ? _a : '';
7287
+ message.layers = ((_b = object.layers) === null || _b === void 0 ? void 0 : _b.map((e) => VideoLayer.fromPartial(e))) || [];
7261
7288
  return message;
7262
7289
  },
7263
7290
  };
@@ -7302,7 +7329,7 @@ const ICEServer = {
7302
7329
  },
7303
7330
  fromJSON(object) {
7304
7331
  return {
7305
- urls: Array.isArray(object?.urls) ? object.urls.map((e) => String(e)) : [],
7332
+ urls: Array.isArray(object === null || object === void 0 ? void 0 : object.urls) ? object.urls.map((e) => String(e)) : [],
7306
7333
  username: isSet(object.username) ? String(object.username) : '',
7307
7334
  credential: isSet(object.credential) ? String(object.credential) : '',
7308
7335
  };
@@ -7320,10 +7347,11 @@ const ICEServer = {
7320
7347
  return obj;
7321
7348
  },
7322
7349
  fromPartial(object) {
7350
+ var _a, _b, _c;
7323
7351
  const message = createBaseICEServer();
7324
- message.urls = object.urls?.map((e) => e) || [];
7325
- message.username = object.username ?? '';
7326
- message.credential = object.credential ?? '';
7352
+ message.urls = ((_a = object.urls) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
7353
+ message.username = (_b = object.username) !== null && _b !== void 0 ? _b : '';
7354
+ message.credential = (_c = object.credential) !== null && _c !== void 0 ? _c : '';
7327
7355
  return message;
7328
7356
  },
7329
7357
  };
@@ -7356,7 +7384,7 @@ const SpeakersChanged = {
7356
7384
  },
7357
7385
  fromJSON(object) {
7358
7386
  return {
7359
- speakers: Array.isArray(object?.speakers)
7387
+ speakers: Array.isArray(object === null || object === void 0 ? void 0 : object.speakers)
7360
7388
  ? object.speakers.map((e) => SpeakerInfo.fromJSON(e))
7361
7389
  : [],
7362
7390
  };
@@ -7372,8 +7400,9 @@ const SpeakersChanged = {
7372
7400
  return obj;
7373
7401
  },
7374
7402
  fromPartial(object) {
7403
+ var _a;
7375
7404
  const message = createBaseSpeakersChanged();
7376
- message.speakers = object.speakers?.map((e) => SpeakerInfo.fromPartial(e)) || [];
7405
+ message.speakers = ((_a = object.speakers) === null || _a === void 0 ? void 0 : _a.map((e) => SpeakerInfo.fromPartial(e))) || [];
7377
7406
  return message;
7378
7407
  },
7379
7408
  };
@@ -7475,10 +7504,11 @@ const ConnectionQualityInfo = {
7475
7504
  return obj;
7476
7505
  },
7477
7506
  fromPartial(object) {
7507
+ var _a, _b, _c;
7478
7508
  const message = createBaseConnectionQualityInfo();
7479
- message.participantSid = object.participantSid ?? '';
7480
- message.quality = object.quality ?? 0;
7481
- message.score = object.score ?? 0;
7509
+ message.participantSid = (_a = object.participantSid) !== null && _a !== void 0 ? _a : '';
7510
+ message.quality = (_b = object.quality) !== null && _b !== void 0 ? _b : 0;
7511
+ message.score = (_c = object.score) !== null && _c !== void 0 ? _c : 0;
7482
7512
  return message;
7483
7513
  },
7484
7514
  };
@@ -7511,7 +7541,7 @@ const ConnectionQualityUpdate = {
7511
7541
  },
7512
7542
  fromJSON(object) {
7513
7543
  return {
7514
- updates: Array.isArray(object?.updates)
7544
+ updates: Array.isArray(object === null || object === void 0 ? void 0 : object.updates)
7515
7545
  ? object.updates.map((e) => ConnectionQualityInfo.fromJSON(e))
7516
7546
  : [],
7517
7547
  };
@@ -7527,8 +7557,9 @@ const ConnectionQualityUpdate = {
7527
7557
  return obj;
7528
7558
  },
7529
7559
  fromPartial(object) {
7560
+ var _a;
7530
7561
  const message = createBaseConnectionQualityUpdate();
7531
- message.updates = object.updates?.map((e) => ConnectionQualityInfo.fromPartial(e)) || [];
7562
+ message.updates = ((_a = object.updates) === null || _a === void 0 ? void 0 : _a.map((e) => ConnectionQualityInfo.fromPartial(e))) || [];
7532
7563
  return message;
7533
7564
  },
7534
7565
  };
@@ -7586,10 +7617,11 @@ const StreamStateInfo = {
7586
7617
  return obj;
7587
7618
  },
7588
7619
  fromPartial(object) {
7620
+ var _a, _b, _c;
7589
7621
  const message = createBaseStreamStateInfo();
7590
- message.participantSid = object.participantSid ?? '';
7591
- message.trackSid = object.trackSid ?? '';
7592
- message.state = object.state ?? 0;
7622
+ message.participantSid = (_a = object.participantSid) !== null && _a !== void 0 ? _a : '';
7623
+ message.trackSid = (_b = object.trackSid) !== null && _b !== void 0 ? _b : '';
7624
+ message.state = (_c = object.state) !== null && _c !== void 0 ? _c : 0;
7593
7625
  return message;
7594
7626
  },
7595
7627
  };
@@ -7622,7 +7654,7 @@ const StreamStateUpdate = {
7622
7654
  },
7623
7655
  fromJSON(object) {
7624
7656
  return {
7625
- streamStates: Array.isArray(object?.streamStates)
7657
+ streamStates: Array.isArray(object === null || object === void 0 ? void 0 : object.streamStates)
7626
7658
  ? object.streamStates.map((e) => StreamStateInfo.fromJSON(e))
7627
7659
  : [],
7628
7660
  };
@@ -7638,8 +7670,9 @@ const StreamStateUpdate = {
7638
7670
  return obj;
7639
7671
  },
7640
7672
  fromPartial(object) {
7673
+ var _a;
7641
7674
  const message = createBaseStreamStateUpdate();
7642
- message.streamStates = object.streamStates?.map((e) => StreamStateInfo.fromPartial(e)) || [];
7675
+ message.streamStates = ((_a = object.streamStates) === null || _a === void 0 ? void 0 : _a.map((e) => StreamStateInfo.fromPartial(e))) || [];
7643
7676
  return message;
7644
7677
  },
7645
7678
  };
@@ -7689,9 +7722,10 @@ const SubscribedQuality = {
7689
7722
  return obj;
7690
7723
  },
7691
7724
  fromPartial(object) {
7725
+ var _a, _b;
7692
7726
  const message = createBaseSubscribedQuality();
7693
- message.quality = object.quality ?? 0;
7694
- message.enabled = object.enabled ?? false;
7727
+ message.quality = (_a = object.quality) !== null && _a !== void 0 ? _a : 0;
7728
+ message.enabled = (_b = object.enabled) !== null && _b !== void 0 ? _b : false;
7695
7729
  return message;
7696
7730
  },
7697
7731
  };
@@ -7731,7 +7765,7 @@ const SubscribedQualityUpdate = {
7731
7765
  fromJSON(object) {
7732
7766
  return {
7733
7767
  trackSid: isSet(object.trackSid) ? String(object.trackSid) : '',
7734
- subscribedQualities: Array.isArray(object?.subscribedQualities)
7768
+ subscribedQualities: Array.isArray(object === null || object === void 0 ? void 0 : object.subscribedQualities)
7735
7769
  ? object.subscribedQualities.map((e) => SubscribedQuality.fromJSON(e))
7736
7770
  : [],
7737
7771
  };
@@ -7748,10 +7782,11 @@ const SubscribedQualityUpdate = {
7748
7782
  return obj;
7749
7783
  },
7750
7784
  fromPartial(object) {
7785
+ var _a, _b;
7751
7786
  const message = createBaseSubscribedQualityUpdate();
7752
- message.trackSid = object.trackSid ?? '';
7787
+ message.trackSid = (_a = object.trackSid) !== null && _a !== void 0 ? _a : '';
7753
7788
  message.subscribedQualities =
7754
- object.subscribedQualities?.map((e) => SubscribedQuality.fromPartial(e)) || [];
7789
+ ((_b = object.subscribedQualities) === null || _b === void 0 ? void 0 : _b.map((e) => SubscribedQuality.fromPartial(e))) || [];
7755
7790
  return message;
7756
7791
  },
7757
7792
  };
@@ -7798,7 +7833,7 @@ const TrackPermission = {
7798
7833
  return {
7799
7834
  participantSid: isSet(object.participantSid) ? String(object.participantSid) : '',
7800
7835
  allTracks: isSet(object.allTracks) ? Boolean(object.allTracks) : false,
7801
- trackSids: Array.isArray(object?.trackSids)
7836
+ trackSids: Array.isArray(object === null || object === void 0 ? void 0 : object.trackSids)
7802
7837
  ? object.trackSids.map((e) => String(e))
7803
7838
  : [],
7804
7839
  };
@@ -7816,10 +7851,11 @@ const TrackPermission = {
7816
7851
  return obj;
7817
7852
  },
7818
7853
  fromPartial(object) {
7854
+ var _a, _b, _c;
7819
7855
  const message = createBaseTrackPermission();
7820
- message.participantSid = object.participantSid ?? '';
7821
- message.allTracks = object.allTracks ?? false;
7822
- message.trackSids = object.trackSids?.map((e) => e) || [];
7856
+ message.participantSid = (_a = object.participantSid) !== null && _a !== void 0 ? _a : '';
7857
+ message.allTracks = (_b = object.allTracks) !== null && _b !== void 0 ? _b : false;
7858
+ message.trackSids = ((_c = object.trackSids) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
7823
7859
  return message;
7824
7860
  },
7825
7861
  };
@@ -7859,7 +7895,7 @@ const SubscriptionPermission = {
7859
7895
  fromJSON(object) {
7860
7896
  return {
7861
7897
  allParticipants: isSet(object.allParticipants) ? Boolean(object.allParticipants) : false,
7862
- trackPermissions: Array.isArray(object?.trackPermissions)
7898
+ trackPermissions: Array.isArray(object === null || object === void 0 ? void 0 : object.trackPermissions)
7863
7899
  ? object.trackPermissions.map((e) => TrackPermission.fromJSON(e))
7864
7900
  : [],
7865
7901
  };
@@ -7876,10 +7912,11 @@ const SubscriptionPermission = {
7876
7912
  return obj;
7877
7913
  },
7878
7914
  fromPartial(object) {
7915
+ var _a, _b;
7879
7916
  const message = createBaseSubscriptionPermission();
7880
- message.allParticipants = object.allParticipants ?? false;
7917
+ message.allParticipants = (_a = object.allParticipants) !== null && _a !== void 0 ? _a : false;
7881
7918
  message.trackPermissions =
7882
- object.trackPermissions?.map((e) => TrackPermission.fromPartial(e)) || [];
7919
+ ((_b = object.trackPermissions) === null || _b === void 0 ? void 0 : _b.map((e) => TrackPermission.fromPartial(e))) || [];
7883
7920
  return message;
7884
7921
  },
7885
7922
  };
@@ -7937,10 +7974,11 @@ const SubscriptionPermissionUpdate = {
7937
7974
  return obj;
7938
7975
  },
7939
7976
  fromPartial(object) {
7977
+ var _a, _b, _c;
7940
7978
  const message = createBaseSubscriptionPermissionUpdate();
7941
- message.participantSid = object.participantSid ?? '';
7942
- message.trackSid = object.trackSid ?? '';
7943
- message.allowed = object.allowed ?? false;
7979
+ message.participantSid = (_a = object.participantSid) !== null && _a !== void 0 ? _a : '';
7980
+ message.trackSid = (_b = object.trackSid) !== null && _b !== void 0 ? _b : '';
7981
+ message.allowed = (_c = object.allowed) !== null && _c !== void 0 ? _c : false;
7944
7982
  return message;
7945
7983
  },
7946
7984
  };
@@ -7995,10 +8033,10 @@ const SyncState = {
7995
8033
  subscription: isSet(object.subscription)
7996
8034
  ? UpdateSubscription.fromJSON(object.subscription)
7997
8035
  : undefined,
7998
- publishTracks: Array.isArray(object?.publishTracks)
8036
+ publishTracks: Array.isArray(object === null || object === void 0 ? void 0 : object.publishTracks)
7999
8037
  ? object.publishTracks.map((e) => TrackPublishedResponse.fromJSON(e))
8000
8038
  : [],
8001
- dataChannels: Array.isArray(object?.dataChannels)
8039
+ dataChannels: Array.isArray(object === null || object === void 0 ? void 0 : object.dataChannels)
8002
8040
  ? object.dataChannels.map((e) => DataChannelInfo.fromJSON(e))
8003
8041
  : [],
8004
8042
  };
@@ -8026,6 +8064,7 @@ const SyncState = {
8026
8064
  return obj;
8027
8065
  },
8028
8066
  fromPartial(object) {
8067
+ var _a, _b;
8029
8068
  const message = createBaseSyncState();
8030
8069
  message.answer =
8031
8070
  object.answer !== undefined && object.answer !== null
@@ -8036,8 +8075,8 @@ const SyncState = {
8036
8075
  ? UpdateSubscription.fromPartial(object.subscription)
8037
8076
  : undefined;
8038
8077
  message.publishTracks =
8039
- object.publishTracks?.map((e) => TrackPublishedResponse.fromPartial(e)) || [];
8040
- message.dataChannels = object.dataChannels?.map((e) => DataChannelInfo.fromPartial(e)) || [];
8078
+ ((_a = object.publishTracks) === null || _a === void 0 ? void 0 : _a.map((e) => TrackPublishedResponse.fromPartial(e))) || [];
8079
+ message.dataChannels = ((_b = object.dataChannels) === null || _b === void 0 ? void 0 : _b.map((e) => DataChannelInfo.fromPartial(e))) || [];
8041
8080
  return message;
8042
8081
  },
8043
8082
  };
@@ -8095,10 +8134,11 @@ const DataChannelInfo = {
8095
8134
  return obj;
8096
8135
  },
8097
8136
  fromPartial(object) {
8137
+ var _a, _b, _c;
8098
8138
  const message = createBaseDataChannelInfo();
8099
- message.label = object.label ?? '';
8100
- message.id = object.id ?? 0;
8101
- message.target = object.target ?? 0;
8139
+ message.label = (_a = object.label) !== null && _a !== void 0 ? _a : '';
8140
+ message.id = (_b = object.id) !== null && _b !== void 0 ? _b : 0;
8141
+ message.target = (_c = object.target) !== null && _c !== void 0 ? _c : 0;
8102
8142
  return message;
8103
8143
  },
8104
8144
  };
@@ -8169,11 +8209,12 @@ const SimulateScenario = {
8169
8209
  return obj;
8170
8210
  },
8171
8211
  fromPartial(object) {
8212
+ var _a, _b, _c, _d;
8172
8213
  const message = createBaseSimulateScenario();
8173
- message.speakerUpdate = object.speakerUpdate ?? undefined;
8174
- message.nodeFailure = object.nodeFailure ?? undefined;
8175
- message.migration = object.migration ?? undefined;
8176
- message.serverLeave = object.serverLeave ?? undefined;
8214
+ message.speakerUpdate = (_a = object.speakerUpdate) !== null && _a !== void 0 ? _a : undefined;
8215
+ message.nodeFailure = (_b = object.nodeFailure) !== null && _b !== void 0 ? _b : undefined;
8216
+ message.migration = (_c = object.migration) !== null && _c !== void 0 ? _c : undefined;
8217
+ message.serverLeave = (_d = object.serverLeave) !== null && _d !== void 0 ? _d : undefined;
8177
8218
  return message;
8178
8219
  },
8179
8220
  };
@@ -8628,6 +8669,16 @@ var TrackEvent;
8628
8669
  TrackEvent["ElementAttached"] = "elementAttached";
8629
8670
  /** @internal */
8630
8671
  TrackEvent["ElementDetached"] = "elementDetached";
8672
+ /**
8673
+ * @internal
8674
+ * Only fires on LocalTracks
8675
+ */
8676
+ TrackEvent["UpstreamPaused"] = "upstreamPaused";
8677
+ /**
8678
+ * @internal
8679
+ * Only fires on LocalTracks
8680
+ */
8681
+ TrackEvent["UpstreamResumed"] = "upstreamResumed";
8631
8682
  })(TrackEvent || (TrackEvent = {}));
8632
8683
 
8633
8684
  const monitorFrequency = 2000;
@@ -8709,7 +8760,7 @@ class DeviceManager {
8709
8760
  // device has been chosen
8710
8761
  const devices = await this.getDevices(kind);
8711
8762
  const device = devices.find((d) => d.groupId === groupId && d.deviceId !== defaultId);
8712
- return device?.deviceId;
8763
+ return device === null || device === void 0 ? void 0 : device.deviceId;
8713
8764
  }
8714
8765
  }
8715
8766
  DeviceManager.mediaDeviceKinds = ['audioinput', 'audiooutput', 'videoinput'];
@@ -8779,6 +8830,22 @@ function getClientInfo() {
8779
8830
  });
8780
8831
  return info;
8781
8832
  }
8833
+ let emptyMediaStreamTrack;
8834
+ function getEmptyMediaStreamTrack() {
8835
+ if (!emptyMediaStreamTrack) {
8836
+ const canvas = document.createElement('canvas');
8837
+ canvas.width = 2;
8838
+ canvas.height = 2;
8839
+ // @ts-ignore
8840
+ const emptyStream = canvas.captureStream();
8841
+ [emptyMediaStreamTrack] = emptyStream.getTracks();
8842
+ if (!emptyMediaStreamTrack) {
8843
+ throw Error('Could not get empty media stream track');
8844
+ }
8845
+ emptyMediaStreamTrack.enabled = false;
8846
+ }
8847
+ return emptyMediaStreamTrack;
8848
+ }
8782
8849
 
8783
8850
  var events = {exports: {}};
8784
8851
 
@@ -9499,6 +9566,7 @@ function detachTrack(track, element) {
9499
9566
  class LocalTrack extends Track {
9500
9567
  constructor(mediaTrack, kind, constraints) {
9501
9568
  super(mediaTrack, kind);
9569
+ this._isUpstreamPaused = false;
9502
9570
  this.handleEnded = () => {
9503
9571
  if (this.isInBackground) {
9504
9572
  this.reacquireTrack = true;
@@ -9506,7 +9574,7 @@ class LocalTrack extends Track {
9506
9574
  this.emit(TrackEvent.Ended, this);
9507
9575
  };
9508
9576
  this.mediaStreamTrack.addEventListener('ended', this.handleEnded);
9509
- this.constraints = constraints ?? mediaTrack.getConstraints();
9577
+ this.constraints = constraints !== null && constraints !== void 0 ? constraints : mediaTrack.getConstraints();
9510
9578
  this.reacquireTrack = false;
9511
9579
  this.wasMuted = false;
9512
9580
  }
@@ -9526,6 +9594,9 @@ class LocalTrack extends Track {
9526
9594
  }
9527
9595
  return undefined;
9528
9596
  }
9597
+ get isUpstreamPaused() {
9598
+ return this._isUpstreamPaused;
9599
+ }
9529
9600
  /**
9530
9601
  * @returns DeviceID of the device that is currently being used for this track
9531
9602
  */
@@ -9546,6 +9617,29 @@ class LocalTrack extends Track {
9546
9617
  this.setTrackMuted(false);
9547
9618
  return this;
9548
9619
  }
9620
+ async replaceTrack(track) {
9621
+ if (!this.sender) {
9622
+ throw new TrackInvalidError('unable to replace an unpublished track');
9623
+ }
9624
+ // detach
9625
+ this.attachedElements.forEach((el) => {
9626
+ detachTrack(this.mediaStreamTrack, el);
9627
+ });
9628
+ this.mediaStreamTrack.removeEventListener('ended', this.handleEnded);
9629
+ // on Safari, the old audio track must be stopped before attempting to acquire
9630
+ // the new track, otherwise the new track will stop with
9631
+ // 'A MediaStreamTrack ended due to a capture failure`
9632
+ this.mediaStreamTrack.stop();
9633
+ track.addEventListener('ended', this.handleEnded);
9634
+ livekitLogger.debug('re-acquired MediaStreamTrack');
9635
+ await this.sender.replaceTrack(track);
9636
+ this.mediaStreamTrack = track;
9637
+ this.attachedElements.forEach((el) => {
9638
+ attachToElement(track, el);
9639
+ });
9640
+ this.mediaStream = new MediaStream([track]);
9641
+ return this;
9642
+ }
9549
9643
  async restart(constraints) {
9550
9644
  if (!this.sender) {
9551
9645
  throw new TrackInvalidError('unable to restart an unpublished track');
@@ -9618,6 +9712,30 @@ class LocalTrack extends Track {
9618
9712
  this.wasMuted = this.isMuted;
9619
9713
  }
9620
9714
  }
9715
+ async pauseUpstream() {
9716
+ if (this._isUpstreamPaused === true) {
9717
+ return;
9718
+ }
9719
+ if (!this.sender) {
9720
+ livekitLogger.warn('unable to pause upstream for an unpublished track');
9721
+ return;
9722
+ }
9723
+ this._isUpstreamPaused = true;
9724
+ this.emit(TrackEvent.UpstreamPaused, this);
9725
+ await this.sender.replaceTrack(getEmptyMediaStreamTrack());
9726
+ }
9727
+ async resumeUpstream() {
9728
+ if (this._isUpstreamPaused === false) {
9729
+ return;
9730
+ }
9731
+ if (!this.sender) {
9732
+ livekitLogger.warn('unable to resume upstream for an unpublished track');
9733
+ return;
9734
+ }
9735
+ this._isUpstreamPaused = false;
9736
+ this.emit(TrackEvent.UpstreamResumed, this);
9737
+ await this.sender.replaceTrack(this.mediaStreamTrack);
9738
+ }
9621
9739
  }
9622
9740
 
9623
9741
  function mergeDefaultOptions(options, audioDefaults, videoDefaults) {
@@ -9845,7 +9963,8 @@ class LocalVideoTrack extends LocalTrack {
9845
9963
  if (this.prevStats) {
9846
9964
  let totalBitrate = 0;
9847
9965
  statsMap.forEach((s, key) => {
9848
- const prev = this.prevStats?.get(key);
9966
+ var _a;
9967
+ const prev = (_a = this.prevStats) === null || _a === void 0 ? void 0 : _a.get(key);
9849
9968
  totalBitrate += computeBitrate(s, prev);
9850
9969
  });
9851
9970
  this._currentBitrate = totalBitrate;
@@ -9864,9 +9983,10 @@ class LocalVideoTrack extends LocalTrack {
9864
9983
  }
9865
9984
  /* @internal */
9866
9985
  startMonitor(signalClient) {
9986
+ var _a;
9867
9987
  this.signalClient = signalClient;
9868
9988
  // save original encodings
9869
- const params = this.sender?.getParameters();
9989
+ const params = (_a = this.sender) === null || _a === void 0 ? void 0 : _a.getParameters();
9870
9990
  if (params) {
9871
9991
  this.encodings = params.encodings;
9872
9992
  }
@@ -9903,6 +10023,7 @@ class LocalVideoTrack extends LocalTrack {
9903
10023
  const items = [];
9904
10024
  const stats = await this.sender.getStats();
9905
10025
  stats.forEach((v) => {
10026
+ var _a;
9906
10027
  if (v.type === 'outbound-rtp') {
9907
10028
  const vs = {
9908
10029
  type: 'video',
@@ -9916,7 +10037,7 @@ class LocalVideoTrack extends LocalTrack {
9916
10037
  bytesSent: v.bytesSent,
9917
10038
  framesSent: v.framesSent,
9918
10039
  timestamp: v.timestamp,
9919
- rid: v.rid ?? '',
10040
+ rid: (_a = v.rid) !== null && _a !== void 0 ? _a : '',
9920
10041
  retransmittedPacketsSent: v.retransmittedPacketsSent,
9921
10042
  qualityLimitationReason: v.qualityLimitationReason,
9922
10043
  qualityLimitationResolutionChanges: v.qualityLimitationResolutionChanges,
@@ -9985,7 +10106,8 @@ class LocalVideoTrack extends LocalTrack {
9985
10106
  }
9986
10107
  let hasChanged = false;
9987
10108
  encodings.forEach((encoding, idx) => {
9988
- let rid = encoding.rid ?? '';
10109
+ var _a;
10110
+ let rid = (_a = encoding.rid) !== null && _a !== void 0 ? _a : '';
9989
10111
  if (rid === '') {
9990
10112
  rid = 'q';
9991
10113
  }
@@ -10056,8 +10178,9 @@ function videoLayersFromEncodings(width, height, encodings) {
10056
10178
  ];
10057
10179
  }
10058
10180
  return encodings.map((encoding) => {
10059
- const scale = encoding.scaleResolutionDownBy ?? 1;
10060
- let quality = videoQualityForRid(encoding.rid ?? '');
10181
+ var _a, _b, _c;
10182
+ const scale = (_a = encoding.scaleResolutionDownBy) !== null && _a !== void 0 ? _a : 1;
10183
+ let quality = videoQualityForRid((_b = encoding.rid) !== null && _b !== void 0 ? _b : '');
10061
10184
  if (quality === VideoQuality.UNRECOGNIZED && encodings.length === 1) {
10062
10185
  quality = VideoQuality.HIGH;
10063
10186
  }
@@ -10065,7 +10188,7 @@ function videoLayersFromEncodings(width, height, encodings) {
10065
10188
  quality,
10066
10189
  width: width / scale,
10067
10190
  height: height / scale,
10068
- bitrate: encoding.maxBitrate ?? 0,
10191
+ bitrate: (_c = encoding.maxBitrate) !== null && _c !== void 0 ? _c : 0,
10069
10192
  ssrc: 0,
10070
10193
  };
10071
10194
  });
@@ -10350,8 +10473,9 @@ class RemoteVideoTrack extends RemoteTrack {
10350
10473
  return receiverStats;
10351
10474
  }
10352
10475
  stopObservingElement(element) {
10353
- getIntersectionObserver()?.unobserve(element);
10354
- getResizeObserver()?.unobserve(element);
10476
+ var _a, _b;
10477
+ (_a = getIntersectionObserver()) === null || _a === void 0 ? void 0 : _a.unobserve(element);
10478
+ (_b = getResizeObserver()) === null || _b === void 0 ? void 0 : _b.unobserve(element);
10355
10479
  this.elementInfos = this.elementInfos.filter((info) => info.element !== element);
10356
10480
  }
10357
10481
  async handleAppVisibilityChanged() {
@@ -10380,10 +10504,11 @@ class RemoteVideoTrack extends RemoteTrack {
10380
10504
  this.emit(TrackEvent.VisibilityChanged, isVisible, this);
10381
10505
  }
10382
10506
  updateDimensions() {
10507
+ var _a, _b, _c, _d;
10383
10508
  let maxWidth = 0;
10384
10509
  let maxHeight = 0;
10385
10510
  for (const info of this.elementInfos) {
10386
- const pixelDensity = this.adaptiveStreamSettings?.pixelDensity ?? 1;
10511
+ const pixelDensity = (_b = (_a = this.adaptiveStreamSettings) === null || _a === void 0 ? void 0 : _a.pixelDensity) !== null && _b !== void 0 ? _b : 1;
10387
10512
  const pixelDensityValue = pixelDensity === 'screen' ? window.devicePixelRatio : pixelDensity;
10388
10513
  const currentElementWidth = info.element.clientWidth * pixelDensityValue;
10389
10514
  const currentElementHeight = info.element.clientHeight * pixelDensityValue;
@@ -10392,7 +10517,7 @@ class RemoteVideoTrack extends RemoteTrack {
10392
10517
  maxHeight = currentElementHeight;
10393
10518
  }
10394
10519
  }
10395
- if (this.lastDimensions?.width === maxWidth && this.lastDimensions?.height === maxHeight) {
10520
+ if (((_c = this.lastDimensions) === null || _c === void 0 ? void 0 : _c.width) === maxWidth && ((_d = this.lastDimensions) === null || _d === void 0 ? void 0 : _d.height) === maxHeight) {
10396
10521
  return;
10397
10522
  }
10398
10523
  this.lastDimensions = {
@@ -10483,12 +10608,17 @@ class TrackPublication extends events.exports.EventEmitter {
10483
10608
  class LocalTrackPublication extends TrackPublication {
10484
10609
  constructor(kind, ti, track) {
10485
10610
  super(kind, ti.sid, ti.name);
10486
- this.handleTrackEnded = (track) => {
10487
- this.emit(TrackEvent.Ended, track);
10611
+ this.track = undefined;
10612
+ this.handleTrackEnded = () => {
10613
+ this.emit(TrackEvent.Ended);
10488
10614
  };
10489
10615
  this.updateInfo(ti);
10490
10616
  this.setTrack(track);
10491
10617
  }
10618
+ get isUpstreamPaused() {
10619
+ var _a;
10620
+ return (_a = this.track) === null || _a === void 0 ? void 0 : _a.isUpstreamPaused;
10621
+ }
10492
10622
  setTrack(track) {
10493
10623
  if (this.track) {
10494
10624
  this.track.off(TrackEvent.Ended, this.handleTrackEnded);
@@ -10514,13 +10644,32 @@ class LocalTrackPublication extends TrackPublication {
10514
10644
  * Mute the track associated with this publication
10515
10645
  */
10516
10646
  async mute() {
10517
- return this.track?.mute();
10647
+ var _a;
10648
+ return (_a = this.track) === null || _a === void 0 ? void 0 : _a.mute();
10518
10649
  }
10519
10650
  /**
10520
10651
  * Unmute track associated with this publication
10521
10652
  */
10522
10653
  async unmute() {
10523
- return this.track?.unmute();
10654
+ var _a;
10655
+ return (_a = this.track) === null || _a === void 0 ? void 0 : _a.unmute();
10656
+ }
10657
+ /**
10658
+ * Pauses the media stream track associated with this publication from being sent to the server
10659
+ * and signals "muted" event to other participants
10660
+ * Useful if you want to pause the stream without pausing the local media stream track
10661
+ */
10662
+ async pauseUpstream() {
10663
+ var _a;
10664
+ await ((_a = this.track) === null || _a === void 0 ? void 0 : _a.pauseUpstream());
10665
+ }
10666
+ /**
10667
+ * Resumes sending the media stream track associated with this publication to the server after a call to [[pauseUpstream()]]
10668
+ * and signals "unmuted" event to other participants (unless the track is explicitly muted)
10669
+ */
10670
+ async resumeUpstream() {
10671
+ var _a;
10672
+ await ((_a = this.track) === null || _a === void 0 ? void 0 : _a.resumeUpstream());
10524
10673
  }
10525
10674
  }
10526
10675
 
@@ -10545,79 +10694,79 @@ class VideoPreset {
10545
10694
  var AudioPresets;
10546
10695
  (function (AudioPresets) {
10547
10696
  AudioPresets.telephone = {
10548
- maxBitrate: 12_000,
10697
+ maxBitrate: 12000,
10549
10698
  };
10550
10699
  AudioPresets.speech = {
10551
- maxBitrate: 20_000,
10700
+ maxBitrate: 20000,
10552
10701
  };
10553
10702
  AudioPresets.music = {
10554
- maxBitrate: 32_000,
10703
+ maxBitrate: 32000,
10555
10704
  };
10556
10705
  })(AudioPresets || (AudioPresets = {}));
10557
10706
  /**
10558
10707
  * Sane presets for video resolution/encoding
10559
10708
  */
10560
10709
  const VideoPresets = {
10561
- h90: new VideoPreset(160, 90, 60_000, 15),
10562
- h180: new VideoPreset(320, 180, 120_000, 15),
10563
- h216: new VideoPreset(384, 216, 180_000, 15),
10564
- h360: new VideoPreset(640, 360, 300_000, 20),
10565
- h540: new VideoPreset(960, 540, 600_000, 25),
10566
- h720: new VideoPreset(1280, 720, 2_000_000, 30),
10567
- h1080: new VideoPreset(1920, 1080, 3_000_000, 30),
10568
- h1440: new VideoPreset(2560, 1440, 5_000_000, 30),
10569
- h2160: new VideoPreset(3840, 2160, 8_000_000, 30),
10710
+ h90: new VideoPreset(160, 90, 60000, 15),
10711
+ h180: new VideoPreset(320, 180, 120000, 15),
10712
+ h216: new VideoPreset(384, 216, 180000, 15),
10713
+ h360: new VideoPreset(640, 360, 300000, 20),
10714
+ h540: new VideoPreset(960, 540, 600000, 25),
10715
+ h720: new VideoPreset(1280, 720, 2000000, 30),
10716
+ h1080: new VideoPreset(1920, 1080, 3000000, 30),
10717
+ h1440: new VideoPreset(2560, 1440, 5000000, 30),
10718
+ h2160: new VideoPreset(3840, 2160, 8000000, 30),
10570
10719
  /** @deprecated */
10571
- qvga: new VideoPreset(320, 180, 120_000, 10),
10720
+ qvga: new VideoPreset(320, 180, 120000, 10),
10572
10721
  /** @deprecated */
10573
- vga: new VideoPreset(640, 360, 300_000, 20),
10722
+ vga: new VideoPreset(640, 360, 300000, 20),
10574
10723
  /** @deprecated */
10575
- qhd: new VideoPreset(960, 540, 600_000, 25),
10724
+ qhd: new VideoPreset(960, 540, 600000, 25),
10576
10725
  /** @deprecated */
10577
- hd: new VideoPreset(1280, 720, 2_000_000, 30),
10726
+ hd: new VideoPreset(1280, 720, 2000000, 30),
10578
10727
  /** @deprecated */
10579
- fhd: new VideoPreset(1920, 1080, 3_000_000, 30),
10728
+ fhd: new VideoPreset(1920, 1080, 3000000, 30),
10580
10729
  };
10581
10730
  /**
10582
10731
  * Four by three presets
10583
10732
  */
10584
10733
  const VideoPresets43 = {
10585
- h120: new VideoPreset(160, 120, 80_000, 15),
10586
- h180: new VideoPreset(240, 180, 100_000, 15),
10587
- h240: new VideoPreset(320, 240, 150_000, 15),
10588
- h360: new VideoPreset(480, 360, 225_000, 20),
10589
- h480: new VideoPreset(640, 480, 300_000, 20),
10590
- h540: new VideoPreset(720, 540, 450_000, 25),
10591
- h720: new VideoPreset(960, 720, 1_500_000, 30),
10592
- h1080: new VideoPreset(1440, 1080, 2_500_000, 30),
10593
- h1440: new VideoPreset(1920, 1440, 3_500_000, 30),
10734
+ h120: new VideoPreset(160, 120, 80000, 15),
10735
+ h180: new VideoPreset(240, 180, 100000, 15),
10736
+ h240: new VideoPreset(320, 240, 150000, 15),
10737
+ h360: new VideoPreset(480, 360, 225000, 20),
10738
+ h480: new VideoPreset(640, 480, 300000, 20),
10739
+ h540: new VideoPreset(720, 540, 450000, 25),
10740
+ h720: new VideoPreset(960, 720, 1500000, 30),
10741
+ h1080: new VideoPreset(1440, 1080, 2500000, 30),
10742
+ h1440: new VideoPreset(1920, 1440, 3500000, 30),
10594
10743
  /** @deprecated */
10595
- qvga: new VideoPreset(240, 180, 90_000, 10),
10744
+ qvga: new VideoPreset(240, 180, 90000, 10),
10596
10745
  /** @deprecated */
10597
- vga: new VideoPreset(480, 360, 225_000, 20),
10746
+ vga: new VideoPreset(480, 360, 225000, 20),
10598
10747
  /** @deprecated */
10599
- qhd: new VideoPreset(720, 540, 450_000, 25),
10748
+ qhd: new VideoPreset(720, 540, 450000, 25),
10600
10749
  /** @deprecated */
10601
- hd: new VideoPreset(960, 720, 1_500_000, 30),
10750
+ hd: new VideoPreset(960, 720, 1500000, 30),
10602
10751
  /** @deprecated */
10603
- fhd: new VideoPreset(1440, 1080, 2_800_000, 30),
10752
+ fhd: new VideoPreset(1440, 1080, 2800000, 30),
10604
10753
  };
10605
10754
  const ScreenSharePresets = {
10606
- h360fps3: new VideoPreset(640, 360, 200_000, 3),
10607
- h720fps5: new VideoPreset(1280, 720, 400_000, 5),
10608
- h720fps15: new VideoPreset(1280, 720, 1_000_000, 15),
10609
- h1080fps15: new VideoPreset(1920, 1080, 1_500_000, 15),
10610
- h1080fps30: new VideoPreset(1920, 1080, 3_000_000, 30),
10755
+ h360fps3: new VideoPreset(640, 360, 200000, 3),
10756
+ h720fps5: new VideoPreset(1280, 720, 400000, 5),
10757
+ h720fps15: new VideoPreset(1280, 720, 1000000, 15),
10758
+ h1080fps15: new VideoPreset(1920, 1080, 1500000, 15),
10759
+ h1080fps30: new VideoPreset(1920, 1080, 3000000, 30),
10611
10760
  /** @deprecated */
10612
- vga: new VideoPreset(640, 360, 200_000, 3),
10761
+ vga: new VideoPreset(640, 360, 200000, 3),
10613
10762
  /** @deprecated */
10614
- hd_8: new VideoPreset(1280, 720, 400_000, 5),
10763
+ hd_8: new VideoPreset(1280, 720, 400000, 5),
10615
10764
  /** @deprecated */
10616
- hd_15: new VideoPreset(1280, 720, 1_000_000, 15),
10765
+ hd_15: new VideoPreset(1280, 720, 1000000, 15),
10617
10766
  /** @deprecated */
10618
- fhd_15: new VideoPreset(1920, 1080, 1_500_000, 15),
10767
+ fhd_15: new VideoPreset(1920, 1080, 1500000, 15),
10619
10768
  /** @deprecated */
10620
- fhd_30: new VideoPreset(1920, 1080, 3_000_000, 30),
10769
+ fhd_30: new VideoPreset(1920, 1080, 3000000, 30),
10621
10770
  };
10622
10771
 
10623
10772
  var ConnectionQuality;
@@ -10711,12 +10860,14 @@ class Participant extends events.exports.EventEmitter {
10711
10860
  return this._connectionQuality;
10712
10861
  }
10713
10862
  get isCameraEnabled() {
10863
+ var _a;
10714
10864
  const track = this.getTrack(Track.Source.Camera);
10715
- return !(track?.isMuted ?? true);
10865
+ return !((_a = track === null || track === void 0 ? void 0 : track.isMuted) !== null && _a !== void 0 ? _a : true);
10716
10866
  }
10717
10867
  get isMicrophoneEnabled() {
10868
+ var _a;
10718
10869
  const track = this.getTrack(Track.Source.Microphone);
10719
- return !(track?.isMuted ?? true);
10870
+ return !((_a = track === null || track === void 0 ? void 0 : track.isMuted) !== null && _a !== void 0 ? _a : true);
10720
10871
  }
10721
10872
  get isScreenShareEnabled() {
10722
10873
  const track = this.getTrack(Track.Source.ScreenShare);
@@ -10753,11 +10904,12 @@ class Participant extends events.exports.EventEmitter {
10753
10904
  }
10754
10905
  /** @internal */
10755
10906
  setPermissions(permissions) {
10756
- const changed = permissions.canPublish !== this.permissions?.canPublish ||
10757
- permissions.canSubscribe !== this.permissions?.canSubscribe ||
10758
- permissions.canPublishData !== this.permissions?.canPublishData ||
10759
- permissions.hidden !== this.permissions?.hidden ||
10760
- permissions.recorder !== this.permissions?.recorder;
10907
+ var _a, _b, _c, _d, _e;
10908
+ const changed = permissions.canPublish !== ((_a = this.permissions) === null || _a === void 0 ? void 0 : _a.canPublish) ||
10909
+ permissions.canSubscribe !== ((_b = this.permissions) === null || _b === void 0 ? void 0 : _b.canSubscribe) ||
10910
+ permissions.canPublishData !== ((_c = this.permissions) === null || _c === void 0 ? void 0 : _c.canPublishData) ||
10911
+ permissions.hidden !== ((_d = this.permissions) === null || _d === void 0 ? void 0 : _d.hidden) ||
10912
+ permissions.recorder !== ((_e = this.permissions) === null || _e === void 0 ? void 0 : _e.recorder);
10761
10913
  this.permissions = permissions;
10762
10914
  return changed;
10763
10915
  }
@@ -10805,12 +10957,13 @@ class Participant extends events.exports.EventEmitter {
10805
10957
  }
10806
10958
 
10807
10959
  function trackPermissionToProto(perms) {
10960
+ var _a;
10808
10961
  if (!perms.participantSid) {
10809
10962
  throw new Error('Invalid track permission, missing participantSid');
10810
10963
  }
10811
10964
  return {
10812
10965
  participantSid: perms.participantSid,
10813
- allTracks: perms.allowAll ?? false,
10966
+ allTracks: (_a = perms.allowAll) !== null && _a !== void 0 ? _a : false,
10814
10967
  trackSids: perms.allowedTrackSids || [],
10815
10968
  };
10816
10969
  }
@@ -10839,17 +10992,21 @@ const defaultSimulcastPresets43 = [VideoPresets43.h180, VideoPresets43.h360];
10839
10992
  /* @internal */
10840
10993
  const computeDefaultScreenShareSimulcastPresets = (fromPreset) => {
10841
10994
  const layers = [{ scaleResolutionDownBy: 2, fps: 3 }];
10842
- return layers.map((t) => new VideoPreset(Math.floor(fromPreset.width / t.scaleResolutionDownBy), Math.floor(fromPreset.height / t.scaleResolutionDownBy), Math.max(150_000, Math.floor(fromPreset.encoding.maxBitrate /
10843
- (t.scaleResolutionDownBy ** 2 * ((fromPreset.encoding.maxFramerate ?? 30) / t.fps)))), t.fps));
10995
+ return layers.map((t) => {
10996
+ var _a;
10997
+ return new VideoPreset(Math.floor(fromPreset.width / t.scaleResolutionDownBy), Math.floor(fromPreset.height / t.scaleResolutionDownBy), Math.max(150000, Math.floor(fromPreset.encoding.maxBitrate /
10998
+ (t.scaleResolutionDownBy ** 2 * (((_a = fromPreset.encoding.maxFramerate) !== null && _a !== void 0 ? _a : 30) / t.fps)))), t.fps);
10999
+ });
10844
11000
  };
10845
11001
  const videoRids = ['q', 'h', 'f'];
10846
11002
  /* @internal */
10847
11003
  function computeVideoEncodings(isScreenShare, width, height, options) {
10848
- let videoEncoding = options?.videoEncoding;
11004
+ var _a, _b;
11005
+ let videoEncoding = options === null || options === void 0 ? void 0 : options.videoEncoding;
10849
11006
  if (isScreenShare) {
10850
- videoEncoding = options?.screenShareEncoding;
11007
+ videoEncoding = options === null || options === void 0 ? void 0 : options.screenShareEncoding;
10851
11008
  }
10852
- const useSimulcast = options?.simulcast;
11009
+ const useSimulcast = options === null || options === void 0 ? void 0 : options.simulcast;
10853
11010
  if ((!videoEncoding && !useSimulcast) || !width || !height) {
10854
11011
  // when we aren't simulcasting, will need to return a single encoding without
10855
11012
  // capping bandwidth. we always require a encoding for dynacast
@@ -10867,12 +11024,11 @@ function computeVideoEncodings(isScreenShare, width, height, options) {
10867
11024
  let presets = [];
10868
11025
  if (isScreenShare) {
10869
11026
  presets =
10870
- sortPresets(options?.screenShareSimulcastLayers) ??
10871
- defaultSimulcastLayers(isScreenShare, original);
11027
+ (_a = sortPresets(options === null || options === void 0 ? void 0 : options.screenShareSimulcastLayers)) !== null && _a !== void 0 ? _a : defaultSimulcastLayers(isScreenShare, original);
10872
11028
  }
10873
11029
  else {
10874
11030
  presets =
10875
- sortPresets(options?.videoSimulcastLayers) ?? defaultSimulcastLayers(isScreenShare, original);
11031
+ (_b = sortPresets(options === null || options === void 0 ? void 0 : options.videoSimulcastLayers)) !== null && _b !== void 0 ? _b : defaultSimulcastLayers(isScreenShare, original);
10876
11032
  }
10877
11033
  let midPreset;
10878
11034
  const lowPreset = presets[0];
@@ -11071,11 +11227,12 @@ class RemoteTrackPublication extends TrackPublication {
11071
11227
  this.emitTrackUpdate();
11072
11228
  }
11073
11229
  setVideoDimensions(dimensions) {
11230
+ var _a, _b;
11074
11231
  if (!this.isManualOperationAllowed()) {
11075
11232
  return;
11076
11233
  }
11077
- if (this.videoDimensions?.width === dimensions.width &&
11078
- this.videoDimensions?.height === dimensions.height) {
11234
+ if (((_a = this.videoDimensions) === null || _a === void 0 ? void 0 : _a.width) === dimensions.width &&
11235
+ ((_b = this.videoDimensions) === null || _b === void 0 ? void 0 : _b.height) === dimensions.height) {
11079
11236
  return;
11080
11237
  }
11081
11238
  if (this.track instanceof RemoteVideoTrack) {
@@ -11104,9 +11261,10 @@ class RemoteTrackPublication extends TrackPublication {
11104
11261
  }
11105
11262
  /** @internal */
11106
11263
  updateInfo(info) {
11264
+ var _a;
11107
11265
  super.updateInfo(info);
11108
11266
  this.metadataMuted = info.muted;
11109
- this.track?.setMuted(info.muted);
11267
+ (_a = this.track) === null || _a === void 0 ? void 0 : _a.setMuted(info.muted);
11110
11268
  }
11111
11269
  isManualOperationAllowed() {
11112
11270
  if (this.isAdaptiveStream) {
@@ -11350,7 +11508,7 @@ class LocalParticipant extends Participant {
11350
11508
  this.pendingPublishing = new Set();
11351
11509
  /** @internal */
11352
11510
  this.onTrackUnmuted = (track) => {
11353
- this.onTrackMuted(track, false);
11511
+ this.onTrackMuted(track, track.isUpstreamPaused);
11354
11512
  };
11355
11513
  // when the local track changes in mute status, we'll notify server as such
11356
11514
  /** @internal */
@@ -11364,8 +11522,17 @@ class LocalParticipant extends Participant {
11364
11522
  }
11365
11523
  this.engine.updateMuteStatus(track.sid, muted);
11366
11524
  };
11525
+ this.onTrackUpstreamPaused = (track) => {
11526
+ livekitLogger.debug('upstream paused');
11527
+ this.onTrackMuted(track, true);
11528
+ };
11529
+ this.onTrackUpstreamResumed = (track) => {
11530
+ livekitLogger.debug('upstream resumed');
11531
+ this.onTrackMuted(track, track.isMuted);
11532
+ };
11367
11533
  this.handleSubscribedQualityUpdate = (update) => {
11368
- if (!this.roomOptions?.dynacast) {
11534
+ var _a, _b;
11535
+ if (!((_a = this.roomOptions) === null || _a === void 0 ? void 0 : _a.dynacast)) {
11369
11536
  return;
11370
11537
  }
11371
11538
  const pub = this.videoTracks.get(update.trackSid);
@@ -11376,7 +11543,7 @@ class LocalParticipant extends Participant {
11376
11543
  });
11377
11544
  return;
11378
11545
  }
11379
- pub.videoTrack?.setPublishingLayers(update.subscribedQualities);
11546
+ (_b = pub.videoTrack) === null || _b === void 0 ? void 0 : _b.setPublishingLayers(update.subscribedQualities);
11380
11547
  };
11381
11548
  this.handleLocalTrackUnpublished = (unpublished) => {
11382
11549
  const track = this.tracks.get(unpublished.trackSid);
@@ -11556,7 +11723,8 @@ class LocalParticipant extends Participant {
11556
11723
  * @returns
11557
11724
  */
11558
11725
  async createTracks(options) {
11559
- const opts = mergeDefaultOptions(options, this.roomOptions?.audioCaptureDefaults, this.roomOptions?.videoCaptureDefaults);
11726
+ var _a, _b;
11727
+ const opts = mergeDefaultOptions(options, (_a = this.roomOptions) === null || _a === void 0 ? void 0 : _a.audioCaptureDefaults, (_b = this.roomOptions) === null || _b === void 0 ? void 0 : _b.videoCaptureDefaults);
11560
11728
  const constraints = constraintsForOptions(opts);
11561
11729
  let stream;
11562
11730
  try {
@@ -11604,6 +11772,7 @@ class LocalParticipant extends Participant {
11604
11772
  * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
11605
11773
  */
11606
11774
  async createScreenTracks(options) {
11775
+ var _a;
11607
11776
  if (options === undefined) {
11608
11777
  options = {};
11609
11778
  }
@@ -11621,7 +11790,7 @@ class LocalParticipant extends Participant {
11621
11790
  // typescript definition is missing getDisplayMedia: https://github.com/microsoft/TypeScript/issues/33232
11622
11791
  // @ts-ignore
11623
11792
  const stream = await navigator.mediaDevices.getDisplayMedia({
11624
- audio: options.audio ?? false,
11793
+ audio: (_a = options.audio) !== null && _a !== void 0 ? _a : false,
11625
11794
  video: videoConstraints,
11626
11795
  });
11627
11796
  const tracks = stream.getVideoTracks();
@@ -11644,8 +11813,9 @@ class LocalParticipant extends Participant {
11644
11813
  * @param options
11645
11814
  */
11646
11815
  async publishTrack(track, options) {
11816
+ var _a, _b, _c, _d, _e, _f;
11647
11817
  const opts = {
11648
- ...this.roomOptions?.publishDefaults,
11818
+ ...(_a = this.roomOptions) === null || _a === void 0 ? void 0 : _a.publishDefaults,
11649
11819
  ...options,
11650
11820
  };
11651
11821
  // convert raw media track into audio or video track
@@ -11688,26 +11858,28 @@ class LocalParticipant extends Participant {
11688
11858
  track.on(TrackEvent.Muted, this.onTrackMuted);
11689
11859
  track.on(TrackEvent.Unmuted, this.onTrackUnmuted);
11690
11860
  track.on(TrackEvent.Ended, this.onTrackUnpublish);
11861
+ track.on(TrackEvent.UpstreamPaused, this.onTrackUpstreamPaused);
11862
+ track.on(TrackEvent.UpstreamResumed, this.onTrackUpstreamResumed);
11691
11863
  // create track publication from track
11692
11864
  const req = AddTrackRequest.fromPartial({
11693
11865
  // get local track id for use during publishing
11694
11866
  cid: track.mediaStreamTrack.id,
11695
- name: options?.name,
11867
+ name: options === null || options === void 0 ? void 0 : options.name,
11696
11868
  type: Track.kindToProto(track.kind),
11697
11869
  muted: track.isMuted,
11698
11870
  source: Track.sourceToProto(track.source),
11699
- disableDtx: !(opts?.dtx ?? true),
11871
+ disableDtx: !((_b = opts === null || opts === void 0 ? void 0 : opts.dtx) !== null && _b !== void 0 ? _b : true),
11700
11872
  });
11701
11873
  // compute encodings and layers for video
11702
11874
  let encodings;
11703
11875
  if (track.kind === Track.Kind.Video) {
11704
11876
  // TODO: support react native, which doesn't expose getSettings
11705
11877
  const settings = track.mediaStreamTrack.getSettings();
11706
- const width = settings.width ?? track.dimensions?.width;
11707
- const height = settings.height ?? track.dimensions?.height;
11878
+ const width = (_c = settings.width) !== null && _c !== void 0 ? _c : (_d = track.dimensions) === null || _d === void 0 ? void 0 : _d.width;
11879
+ const height = (_e = settings.height) !== null && _e !== void 0 ? _e : (_f = track.dimensions) === null || _f === void 0 ? void 0 : _f.height;
11708
11880
  // width and height should be defined for video
11709
- req.width = width ?? 0;
11710
- req.height = height ?? 0;
11881
+ req.width = width !== null && width !== void 0 ? width : 0;
11882
+ req.height = height !== null && height !== void 0 ? height : 0;
11711
11883
  encodings = computeVideoEncodings(track.source === Track.Source.ScreenShare, width, height, opts);
11712
11884
  req.layers = videoLayersFromEncodings(req.width, req.height, encodings);
11713
11885
  }
@@ -11748,6 +11920,7 @@ class LocalParticipant extends Participant {
11748
11920
  return publication;
11749
11921
  }
11750
11922
  unpublishTrack(track, stopOnUnpublish) {
11923
+ var _a, _b;
11751
11924
  // look through all published tracks to find the right ones
11752
11925
  const publication = this.getPublicationForTrack(track);
11753
11926
  livekitLogger.debug('unpublishing track', { track, method: 'unpublishTrack' });
@@ -11762,8 +11935,10 @@ class LocalParticipant extends Participant {
11762
11935
  track.off(TrackEvent.Muted, this.onTrackMuted);
11763
11936
  track.off(TrackEvent.Unmuted, this.onTrackUnmuted);
11764
11937
  track.off(TrackEvent.Ended, this.onTrackUnpublish);
11938
+ track.off(TrackEvent.UpstreamPaused, this.onTrackUpstreamPaused);
11939
+ track.off(TrackEvent.UpstreamResumed, this.onTrackUpstreamResumed);
11765
11940
  if (stopOnUnpublish === undefined) {
11766
- stopOnUnpublish = this.roomOptions?.stopLocalTrackOnUnpublish ?? true;
11941
+ stopOnUnpublish = (_b = (_a = this.roomOptions) === null || _a === void 0 ? void 0 : _a.stopLocalTrackOnUnpublish) !== null && _b !== void 0 ? _b : true;
11767
11942
  }
11768
11943
  if (stopOnUnpublish) {
11769
11944
  track.stop();
@@ -11772,9 +11947,10 @@ class LocalParticipant extends Participant {
11772
11947
  if (this.engine.publisher) {
11773
11948
  const senders = this.engine.publisher.pc.getSenders();
11774
11949
  senders.forEach((sender) => {
11950
+ var _a;
11775
11951
  if (sender.track === mediaStreamTrack) {
11776
11952
  try {
11777
- this.engine.publisher?.pc.removeTrack(sender);
11953
+ (_a = this.engine.publisher) === null || _a === void 0 ? void 0 : _a.pc.removeTrack(sender);
11778
11954
  this.engine.negotiate();
11779
11955
  }
11780
11956
  catch (e) {
@@ -11920,7 +12096,7 @@ class LocalParticipant extends Participant {
11920
12096
  dataChannelsInfo() {
11921
12097
  const infos = [];
11922
12098
  const getInfo = (dc, target) => {
11923
- if (dc?.id !== undefined && dc.id !== null) {
12099
+ if ((dc === null || dc === void 0 ? void 0 : dc.id) !== undefined && dc.id !== null) {
11924
12100
  infos.push({
11925
12101
  label: dc.label,
11926
12102
  id: dc.id,
@@ -15491,9 +15667,9 @@ class SignalClient {
15491
15667
  // connected
15492
15668
  this.isConnected = false;
15493
15669
  const res = await this.connect(url, token, {
15494
- autoSubscribe: opts?.autoSubscribe,
15495
- publishOnly: opts?.publishOnly,
15496
- adaptiveStream: opts?.adaptiveStream,
15670
+ autoSubscribe: opts === null || opts === void 0 ? void 0 : opts.autoSubscribe,
15671
+ publishOnly: opts === null || opts === void 0 ? void 0 : opts.publishOnly,
15672
+ adaptiveStream: opts === null || opts === void 0 ? void 0 : opts.adaptiveStream,
15497
15673
  });
15498
15674
  return res;
15499
15675
  }
@@ -15589,10 +15765,11 @@ class SignalClient {
15589
15765
  });
15590
15766
  }
15591
15767
  close() {
15768
+ var _a;
15592
15769
  this.isConnected = false;
15593
15770
  if (this.ws)
15594
15771
  this.ws.onclose = null;
15595
- this.ws?.close();
15772
+ (_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
15596
15773
  this.ws = undefined;
15597
15774
  }
15598
15775
  // initial offer after joining
@@ -15809,10 +15986,10 @@ function createConnectionParams(token, info, opts) {
15809
15986
  const params = new URLSearchParams();
15810
15987
  params.set('access_token', token);
15811
15988
  // opts
15812
- if (opts?.reconnect) {
15989
+ if (opts === null || opts === void 0 ? void 0 : opts.reconnect) {
15813
15990
  params.set('reconnect', '1');
15814
15991
  }
15815
- if (opts?.autoSubscribe !== undefined) {
15992
+ if ((opts === null || opts === void 0 ? void 0 : opts.autoSubscribe) !== undefined) {
15816
15993
  params.set('auto_subscribe', opts.autoSubscribe ? '1' : '0');
15817
15994
  }
15818
15995
  // ClientInfo
@@ -15834,10 +16011,10 @@ function createConnectionParams(token, info, opts) {
15834
16011
  if (info.browserVersion) {
15835
16012
  params.set('browser_version', info.browserVersion);
15836
16013
  }
15837
- if (opts?.publishOnly !== undefined) {
16014
+ if ((opts === null || opts === void 0 ? void 0 : opts.publishOnly) !== undefined) {
15838
16015
  params.set('publish', opts.publishOnly);
15839
16016
  }
15840
- if (opts?.adaptiveStream) {
16017
+ if (opts === null || opts === void 0 ? void 0 : opts.adaptiveStream) {
15841
16018
  params.set('adaptive_stream', '1');
15842
16019
  }
15843
16020
  return `?${params.toString()}`;
@@ -15880,7 +16057,7 @@ class PCTransport {
15880
16057
  if (this.onOffer === undefined) {
15881
16058
  return;
15882
16059
  }
15883
- if (options?.iceRestart) {
16060
+ if (options === null || options === void 0 ? void 0 : options.iceRestart) {
15884
16061
  livekitLogger.debug('restarting ICE');
15885
16062
  this.restartingIce = true;
15886
16063
  }
@@ -15888,7 +16065,7 @@ class PCTransport {
15888
16065
  // we're waiting for the peer to accept our offer, so we'll just wait
15889
16066
  // the only exception to this is when ICE restart is needed
15890
16067
  const currentSD = this.pc.remoteDescription;
15891
- if (options?.iceRestart && currentSD) {
16068
+ if ((options === null || options === void 0 ? void 0 : options.iceRestart) && currentSD) {
15892
16069
  // TODO: handle when ICE restart is needed but we don't have a remote description
15893
16070
  // the best thing to do is to recreate the peerconnection
15894
16071
  await this.pc.setRemoteDescription(currentSD);
@@ -15916,16 +16093,24 @@ class PCTransport {
15916
16093
  const lossyDataChannel = '_lossy';
15917
16094
  const reliableDataChannel = '_reliable';
15918
16095
  const maxReconnectRetries = 10;
15919
- const minReconnectWait = 1 * 1000;
16096
+ const minReconnectWait = 2 * 1000;
15920
16097
  const maxReconnectDuration = 60 * 1000;
15921
16098
  const maxICEConnectTimeout = 15 * 1000;
16099
+ var PCState;
16100
+ (function (PCState) {
16101
+ PCState[PCState["New"] = 0] = "New";
16102
+ PCState[PCState["Connected"] = 1] = "Connected";
16103
+ PCState[PCState["Disconnected"] = 2] = "Disconnected";
16104
+ PCState[PCState["Reconnecting"] = 3] = "Reconnecting";
16105
+ PCState[PCState["Closed"] = 4] = "Closed";
16106
+ })(PCState || (PCState = {}));
15922
16107
  /** @internal */
15923
16108
  class RTCEngine extends events.exports.EventEmitter {
15924
16109
  constructor() {
15925
16110
  super();
15926
16111
  this.rtcConfig = {};
15927
16112
  this.subscriberPrimary = false;
15928
- this.pcConnected = false;
16113
+ this.pcState = PCState.New;
15929
16114
  this.isClosed = true;
15930
16115
  this.pendingTrackResolvers = {};
15931
16116
  // true if publisher connection has already been established.
@@ -15997,11 +16182,12 @@ class RTCEngine extends events.exports.EventEmitter {
15997
16182
  }
15998
16183
  const delay = this.reconnectAttempts * this.reconnectAttempts * 300;
15999
16184
  setTimeout(async () => {
16185
+ var _a;
16000
16186
  if (this.isClosed) {
16001
16187
  return;
16002
16188
  }
16003
16189
  if (isFireFox() || // TODO remove once clientConfiguration handles firefox case server side
16004
- this.clientConfiguration?.resumeConnection === ClientConfigSetting.DISABLED) {
16190
+ ((_a = this.clientConfiguration) === null || _a === void 0 ? void 0 : _a.resumeConnection) === ClientConfigSetting.DISABLED) {
16005
16191
  this.fullReconnectOnNext = true;
16006
16192
  }
16007
16193
  try {
@@ -16065,10 +16251,11 @@ class RTCEngine extends events.exports.EventEmitter {
16065
16251
  this.removeAllListeners();
16066
16252
  if (this.publisher && this.publisher.pc.signalingState !== 'closed') {
16067
16253
  this.publisher.pc.getSenders().forEach((sender) => {
16254
+ var _a, _b;
16068
16255
  try {
16069
16256
  // TODO: react-native-webrtc doesn't have removeTrack yet.
16070
- if (this.publisher?.pc.removeTrack) {
16071
- this.publisher?.pc.removeTrack(sender);
16257
+ if ((_a = this.publisher) === null || _a === void 0 ? void 0 : _a.pc.removeTrack) {
16258
+ (_b = this.publisher) === null || _b === void 0 ? void 0 : _b.pc.removeTrack(sender);
16072
16259
  }
16073
16260
  }
16074
16261
  catch (e) {
@@ -16097,7 +16284,8 @@ class RTCEngine extends events.exports.EventEmitter {
16097
16284
  this.client.sendMuteTrack(trackSid, muted);
16098
16285
  }
16099
16286
  get dataSubscriberReadyState() {
16100
- return this.reliableDCSub?.readyState;
16287
+ var _a;
16288
+ return (_a = this.reliableDCSub) === null || _a === void 0 ? void 0 : _a.readyState;
16101
16289
  }
16102
16290
  get connectedServerAddress() {
16103
16291
  return this.connectedServerAddr;
@@ -16152,24 +16340,26 @@ class RTCEngine extends events.exports.EventEmitter {
16152
16340
  }
16153
16341
  this.primaryPC = primaryPC;
16154
16342
  primaryPC.onconnectionstatechange = async () => {
16343
+ livekitLogger.trace('connection state changed', {
16344
+ state: primaryPC.connectionState,
16345
+ });
16155
16346
  if (primaryPC.connectionState === 'connected') {
16156
- livekitLogger.trace('pc connected');
16157
16347
  try {
16158
16348
  this.connectedServerAddr = await getConnectedAddress(primaryPC);
16159
16349
  }
16160
16350
  catch (e) {
16161
16351
  livekitLogger.warn('could not get connected server address', { error: e });
16162
16352
  }
16163
- if (!this.pcConnected) {
16164
- this.pcConnected = true;
16353
+ const shouldEmit = this.pcState === PCState.New;
16354
+ this.pcState = PCState.Connected;
16355
+ if (shouldEmit) {
16165
16356
  this.emit(EngineEvent.Connected);
16166
16357
  }
16167
16358
  }
16168
16359
  else if (primaryPC.connectionState === 'failed') {
16169
16360
  // on Safari, PeerConnection will switch to 'disconnected' during renegotiation
16170
- livekitLogger.trace('pc disconnected');
16171
- if (this.pcConnected) {
16172
- this.pcConnected = false;
16361
+ if (this.pcState === PCState.Connected) {
16362
+ this.pcState = PCState.Disconnected;
16173
16363
  this.handleDisconnect('peerconnection');
16174
16364
  }
16175
16365
  }
@@ -16258,7 +16448,7 @@ class RTCEngine extends events.exports.EventEmitter {
16258
16448
  this.handleDisconnect('signal');
16259
16449
  };
16260
16450
  this.client.onLeave = (leave) => {
16261
- if (leave?.canReconnect) {
16451
+ if (leave === null || leave === void 0 ? void 0 : leave.canReconnect) {
16262
16452
  this.fullReconnectOnNext = true;
16263
16453
  this.primaryPC = undefined;
16264
16454
  }
@@ -16269,6 +16459,7 @@ class RTCEngine extends events.exports.EventEmitter {
16269
16459
  };
16270
16460
  }
16271
16461
  async restartConnection() {
16462
+ var _a, _b;
16272
16463
  if (!this.url || !this.token) {
16273
16464
  // permanent failure, don't attempt reconnection
16274
16465
  throw new UnexpectedConnectionState('could not reconnect, url or token not saved');
@@ -16278,9 +16469,9 @@ class RTCEngine extends events.exports.EventEmitter {
16278
16469
  this.emit(EngineEvent.Restarting);
16279
16470
  }
16280
16471
  this.primaryPC = undefined;
16281
- this.publisher?.close();
16472
+ (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.close();
16282
16473
  this.publisher = undefined;
16283
- this.subscriber?.close();
16474
+ (_b = this.subscriber) === null || _b === void 0 ? void 0 : _b.close();
16284
16475
  this.subscriber = undefined;
16285
16476
  let joinResponse;
16286
16477
  try {
@@ -16325,25 +16516,35 @@ class RTCEngine extends events.exports.EventEmitter {
16325
16516
  this.emit(EngineEvent.Resumed);
16326
16517
  }
16327
16518
  async waitForPCConnected() {
16328
- const startTime = new Date().getTime();
16519
+ var _a;
16520
+ const startTime = Date.now();
16329
16521
  let now = startTime;
16330
- this.pcConnected = false;
16522
+ this.pcState = PCState.Reconnecting;
16523
+ livekitLogger.debug('waiting for peer connection to reconnect');
16331
16524
  while (now - startTime < maxICEConnectTimeout) {
16332
- // if there is no connectionstatechange callback fired
16333
- // check connectionstate after minReconnectWait
16334
16525
  if (this.primaryPC === undefined) {
16335
16526
  // we can abort early, connection is hosed
16336
16527
  break;
16337
16528
  }
16338
- else if (now - startTime > minReconnectWait &&
16339
- this.primaryPC?.connectionState === 'connected') {
16340
- this.pcConnected = true;
16529
+ else if (
16530
+ // on Safari, we don't get a connectionstatechanged event during ICE restart
16531
+ // this means we'd have to check its status manually and update address
16532
+ // manually
16533
+ now - startTime > minReconnectWait &&
16534
+ ((_a = this.primaryPC) === null || _a === void 0 ? void 0 : _a.connectionState) === 'connected') {
16535
+ this.pcState = PCState.Connected;
16536
+ try {
16537
+ this.connectedServerAddr = await getConnectedAddress(this.primaryPC);
16538
+ }
16539
+ catch (e) {
16540
+ livekitLogger.warn('could not get connected server address', { error: e });
16541
+ }
16341
16542
  }
16342
- if (this.pcConnected) {
16543
+ if (this.pcState === PCState.Connected) {
16343
16544
  return;
16344
16545
  }
16345
16546
  await sleep(100);
16346
- now = new Date().getTime();
16547
+ now = Date.now();
16347
16548
  }
16348
16549
  // have not reconnected, throw
16349
16550
  throw new ConnectionError('could not establish PC connection');
@@ -16361,6 +16562,7 @@ class RTCEngine extends events.exports.EventEmitter {
16361
16562
  }
16362
16563
  }
16363
16564
  async ensurePublisherConnected(kind) {
16565
+ var _a, _b;
16364
16566
  if (!this.subscriberPrimary) {
16365
16567
  return;
16366
16568
  }
@@ -16372,18 +16574,18 @@ class RTCEngine extends events.exports.EventEmitter {
16372
16574
  this.negotiate();
16373
16575
  }
16374
16576
  const targetChannel = this.dataChannelForKind(kind);
16375
- if (targetChannel?.readyState === 'open') {
16577
+ if ((targetChannel === null || targetChannel === void 0 ? void 0 : targetChannel.readyState) === 'open') {
16376
16578
  return;
16377
16579
  }
16378
16580
  // wait until publisher ICE connected
16379
16581
  const endTime = new Date().getTime() + maxICEConnectTimeout;
16380
16582
  while (new Date().getTime() < endTime) {
16381
- if (this.publisher.isICEConnected && this.dataChannelForKind(kind)?.readyState === 'open') {
16583
+ if (this.publisher.isICEConnected && ((_a = this.dataChannelForKind(kind)) === null || _a === void 0 ? void 0 : _a.readyState) === 'open') {
16382
16584
  return;
16383
16585
  }
16384
16586
  await sleep(50);
16385
16587
  }
16386
- throw new ConnectionError(`could not establish publisher connection, state ${this.publisher?.pc.iceConnectionState}`);
16588
+ throw new ConnectionError(`could not establish publisher connection, state ${(_b = this.publisher) === null || _b === void 0 ? void 0 : _b.pc.iceConnectionState}`);
16387
16589
  }
16388
16590
  /** @internal */
16389
16591
  negotiate() {
@@ -16413,6 +16615,7 @@ class RTCEngine extends events.exports.EventEmitter {
16413
16615
  }
16414
16616
  }
16415
16617
  async function getConnectedAddress(pc) {
16618
+ var _a;
16416
16619
  let selectedCandidatePairId = '';
16417
16620
  const candidatePairs = new Map();
16418
16621
  // id -> candidate ip
@@ -16437,7 +16640,7 @@ async function getConnectedAddress(pc) {
16437
16640
  if (selectedCandidatePairId === '') {
16438
16641
  return undefined;
16439
16642
  }
16440
- const selectedID = candidatePairs.get(selectedCandidatePairId)?.remoteCandidateId;
16643
+ const selectedID = (_a = candidatePairs.get(selectedCandidatePairId)) === null || _a === void 0 ? void 0 : _a.remoteCandidateId;
16441
16644
  if (selectedID === undefined) {
16442
16645
  return undefined;
16443
16646
  }
@@ -16483,6 +16686,7 @@ class Room extends events.exports.EventEmitter {
16483
16686
  * @param options
16484
16687
  */
16485
16688
  constructor(options) {
16689
+ var _a, _b;
16486
16690
  super();
16487
16691
  this.state = RoomState.Disconnected;
16488
16692
  /**
@@ -16499,6 +16703,7 @@ class Room extends events.exports.EventEmitter {
16499
16703
  this.metadata = undefined;
16500
16704
  this.audioEnabled = true;
16501
16705
  this.connect = async (url, token, opts) => {
16706
+ var _a, _b;
16502
16707
  // guard against calling connect
16503
16708
  if (this.state !== RoomState.Disconnected) {
16504
16709
  livekitLogger.warn(`already connected to room ${this.name}`);
@@ -16507,15 +16712,15 @@ class Room extends events.exports.EventEmitter {
16507
16712
  // recreate engine if previously disconnected
16508
16713
  this.createEngine();
16509
16714
  this.acquireAudioContext();
16510
- if (opts?.rtcConfig) {
16715
+ if (opts === null || opts === void 0 ? void 0 : opts.rtcConfig) {
16511
16716
  this.engine.rtcConfig = opts.rtcConfig;
16512
16717
  }
16513
16718
  this.connOptions = opts;
16514
16719
  try {
16515
16720
  const joinResponse = await this.engine.join(url, token, {
16516
- autoSubscribe: opts?.autoSubscribe,
16517
- publishOnly: opts?.publishOnly,
16518
- adaptiveStream: typeof this.options?.adaptiveStream === 'object' ? true : this.options?.adaptiveStream,
16721
+ autoSubscribe: opts === null || opts === void 0 ? void 0 : opts.autoSubscribe,
16722
+ publishOnly: opts === null || opts === void 0 ? void 0 : opts.publishOnly,
16723
+ adaptiveStream: typeof ((_a = this.options) === null || _a === void 0 ? void 0 : _a.adaptiveStream) === 'object' ? true : (_b = this.options) === null || _b === void 0 ? void 0 : _b.adaptiveStream,
16519
16724
  });
16520
16725
  livekitLogger.debug(`connected to Livekit Server version: ${joinResponse.serverVersion}, region: ${joinResponse.serverRegion}`);
16521
16726
  if (!joinResponse.serverVersion) {
@@ -16581,11 +16786,12 @@ class Room extends events.exports.EventEmitter {
16581
16786
  reject(new ConnectionError('could not connect after timeout'));
16582
16787
  }, maxICEConnectTimeout);
16583
16788
  this.engine.once(EngineEvent.Connected, () => {
16789
+ var _a;
16584
16790
  clearTimeout(connectTimeout);
16585
16791
  // also hook unload event
16586
16792
  if (isWeb()) {
16587
16793
  window.addEventListener('beforeunload', this.onBeforeUnload);
16588
- navigator.mediaDevices?.addEventListener('devicechange', this.handleDeviceChange);
16794
+ (_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.addEventListener('devicechange', this.handleDeviceChange);
16589
16795
  }
16590
16796
  resolve(this);
16591
16797
  });
@@ -16761,7 +16967,7 @@ class Room extends events.exports.EventEmitter {
16761
16967
  const participant = this.participants.get(userPacket.participantSid);
16762
16968
  this.emit(RoomEvent.DataReceived, userPacket.payload, participant, kind);
16763
16969
  // also emit on the participant
16764
- participant?.emit(ParticipantEvent.DataReceived, userPacket.payload, kind);
16970
+ participant === null || participant === void 0 ? void 0 : participant.emit(ParticipantEvent.DataReceived, userPacket.payload, kind);
16765
16971
  };
16766
16972
  this.handleAudioPlaybackStarted = () => {
16767
16973
  if (this.canPlaybackAudio) {
@@ -16799,7 +17005,7 @@ class Room extends events.exports.EventEmitter {
16799
17005
  };
16800
17006
  this.participants = new Map();
16801
17007
  this.options = options || {};
16802
- switch (this.options?.publishDefaults?.videoCodec) {
17008
+ switch ((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.publishDefaults) === null || _b === void 0 ? void 0 : _b.videoCodec) {
16803
17009
  case 'av1':
16804
17010
  case 'vp9':
16805
17011
  this.options.publishDefaults.simulcast = undefined;
@@ -16807,15 +17013,15 @@ class Room extends events.exports.EventEmitter {
16807
17013
  }
16808
17014
  this.options.audioCaptureDefaults = {
16809
17015
  ...audioDefaults,
16810
- ...options?.audioCaptureDefaults,
17016
+ ...options === null || options === void 0 ? void 0 : options.audioCaptureDefaults,
16811
17017
  };
16812
17018
  this.options.videoCaptureDefaults = {
16813
17019
  ...videoDefaults,
16814
- ...options?.videoCaptureDefaults,
17020
+ ...options === null || options === void 0 ? void 0 : options.videoCaptureDefaults,
16815
17021
  };
16816
17022
  this.options.publishDefaults = {
16817
17023
  ...publishDefaults,
16818
- ...options?.publishDefaults,
17024
+ ...options === null || options === void 0 ? void 0 : options.publishDefaults,
16819
17025
  };
16820
17026
  this.createEngine();
16821
17027
  this.localParticipant = new LocalParticipant('', '', this.engine, this.options);
@@ -16964,12 +17170,12 @@ class Room extends events.exports.EventEmitter {
16964
17170
  async switchActiveDevice(kind, deviceId) {
16965
17171
  if (kind === 'audioinput') {
16966
17172
  const tracks = Array.from(this.localParticipant.audioTracks.values()).filter((track) => track.source === Track.Source.Microphone);
16967
- await Promise.all(tracks.map((t) => t.audioTrack?.setDeviceId(deviceId)));
17173
+ await Promise.all(tracks.map((t) => { var _a; return (_a = t.audioTrack) === null || _a === void 0 ? void 0 : _a.setDeviceId(deviceId); }));
16968
17174
  this.options.audioCaptureDefaults.deviceId = deviceId;
16969
17175
  }
16970
17176
  else if (kind === 'videoinput') {
16971
17177
  const tracks = Array.from(this.localParticipant.videoTracks.values()).filter((track) => track.source === Track.Source.Camera);
16972
- await Promise.all(tracks.map((t) => t.videoTrack?.setDeviceId(deviceId)));
17178
+ await Promise.all(tracks.map((t) => { var _a; return (_a = t.videoTrack) === null || _a === void 0 ? void 0 : _a.setDeviceId(deviceId); }));
16973
17179
  this.options.videoCaptureDefaults.deviceId = deviceId;
16974
17180
  }
16975
17181
  else if (kind === 'audiooutput') {
@@ -17010,6 +17216,7 @@ class Room extends events.exports.EventEmitter {
17010
17216
  participant.addSubscribedMediaTrack(mediaTrack, trackId, stream, receiver, adaptiveStreamSettings);
17011
17217
  }
17012
17218
  handleDisconnect(shouldStopTracks = true) {
17219
+ var _a;
17013
17220
  if (this.state === RoomState.Disconnected) {
17014
17221
  return;
17015
17222
  }
@@ -17019,12 +17226,13 @@ class Room extends events.exports.EventEmitter {
17019
17226
  });
17020
17227
  });
17021
17228
  this.localParticipant.tracks.forEach((pub) => {
17229
+ var _a, _b;
17022
17230
  if (pub.track) {
17023
17231
  this.localParticipant.unpublishTrack(pub.track);
17024
17232
  }
17025
17233
  if (shouldStopTracks) {
17026
- pub.track?.detach();
17027
- pub.track?.stop();
17234
+ (_a = pub.track) === null || _a === void 0 ? void 0 : _a.detach();
17235
+ (_b = pub.track) === null || _b === void 0 ? void 0 : _b.stop();
17028
17236
  }
17029
17237
  });
17030
17238
  this.participants.clear();
@@ -17035,7 +17243,7 @@ class Room extends events.exports.EventEmitter {
17035
17243
  }
17036
17244
  if (isWeb()) {
17037
17245
  window.removeEventListener('beforeunload', this.onBeforeUnload);
17038
- navigator.mediaDevices?.removeEventListener('devicechange', this.handleDeviceChange);
17246
+ (_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.removeEventListener('devicechange', this.handleDeviceChange);
17039
17247
  }
17040
17248
  this.state = RoomState.Disconnected;
17041
17249
  this.emit(RoomEvent.Disconnected);
@@ -17126,6 +17334,7 @@ class Room extends events.exports.EventEmitter {
17126
17334
  return participant;
17127
17335
  }
17128
17336
  sendSyncState() {
17337
+ var _a;
17129
17338
  if (this.engine.subscriber === undefined ||
17130
17339
  this.engine.subscriber.pc.localDescription === null) {
17131
17340
  return;
@@ -17136,7 +17345,7 @@ class Room extends events.exports.EventEmitter {
17136
17345
  subscribe pc and unsub special tracks from it.
17137
17346
  2. autosubscribe off, we send subscribed tracks.
17138
17347
  */
17139
- const sendUnsub = this.connOptions?.autoSubscribe || false;
17348
+ const sendUnsub = ((_a = this.connOptions) === null || _a === void 0 ? void 0 : _a.autoSubscribe) || false;
17140
17349
  const trackSids = new Array();
17141
17350
  this.participants.forEach((participant) => {
17142
17351
  participant.tracks.forEach((track) => {
@@ -17199,20 +17408,21 @@ class Room extends events.exports.EventEmitter {
17199
17408
  * @param options
17200
17409
  */
17201
17410
  async function connect(url, token, options) {
17202
- options ??= {};
17411
+ var _a, _b, _c, _d;
17412
+ options !== null && options !== void 0 ? options : (options = {});
17203
17413
  if (options.adaptiveStream === undefined) {
17204
17414
  options.adaptiveStream = options.autoManageVideo === true ? {} : undefined;
17205
17415
  }
17206
- setLogLevel(options.logLevel ?? LogLevel.warn);
17207
- const config = options.rtcConfig ?? {};
17416
+ setLogLevel((_a = options.logLevel) !== null && _a !== void 0 ? _a : LogLevel.warn);
17417
+ const config = (_b = options.rtcConfig) !== null && _b !== void 0 ? _b : {};
17208
17418
  if (options.iceServers) {
17209
17419
  config.iceServers = options.iceServers;
17210
17420
  }
17211
17421
  const room = new Room(options);
17212
17422
  // connect to room
17213
17423
  await room.connect(url, token, options);
17214
- const publishAudio = options.audio ?? false;
17215
- const publishVideo = options.video ?? false;
17424
+ const publishAudio = (_c = options.audio) !== null && _c !== void 0 ? _c : false;
17425
+ const publishVideo = (_d = options.video) !== null && _d !== void 0 ? _d : false;
17216
17426
  if (publishAudio || publishVideo) {
17217
17427
  setTimeout(async () => {
17218
17428
  // if publishing both
@@ -17274,10 +17484,11 @@ async function connect(url, token, options) {
17274
17484
  * @param options
17275
17485
  */
17276
17486
  async function createLocalTracks(options) {
17487
+ var _a, _b;
17277
17488
  // set default options to true
17278
- options ??= {};
17279
- options.audio ??= true;
17280
- options.video ??= true;
17489
+ options !== null && options !== void 0 ? options : (options = {});
17490
+ (_a = options.audio) !== null && _a !== void 0 ? _a : (options.audio = true);
17491
+ (_b = options.video) !== null && _b !== void 0 ? _b : (options.video = true);
17281
17492
  const opts = mergeDefaultOptions(options, audioDefaults, videoDefaults);
17282
17493
  const constraints = constraintsForOptions(opts);
17283
17494
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
@@ -17324,6 +17535,7 @@ async function createLocalAudioTrack(options) {
17324
17535
  * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
17325
17536
  */
17326
17537
  async function createLocalScreenTracks(options) {
17538
+ var _a;
17327
17539
  if (options === undefined) {
17328
17540
  options = {};
17329
17541
  }
@@ -17340,7 +17552,7 @@ async function createLocalScreenTracks(options) {
17340
17552
  // typescript definition is missing getDisplayMedia: https://github.com/microsoft/TypeScript/issues/33232
17341
17553
  // @ts-ignore
17342
17554
  const stream = await navigator.mediaDevices.getDisplayMedia({
17343
- audio: options.audio ?? false,
17555
+ audio: (_a = options.audio) !== null && _a !== void 0 ? _a : false,
17344
17556
  video: videoConstraints,
17345
17557
  });
17346
17558
  const tracks = stream.getVideoTracks();