livekit-client 0.18.1 → 0.18.4-RC1

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
  };
@@ -8624,6 +8665,20 @@ var TrackEvent;
8624
8665
  TrackEvent["VisibilityChanged"] = "visibilityChanged";
8625
8666
  /** @internal */
8626
8667
  TrackEvent["VideoDimensionsChanged"] = "videoDimensionsChanged";
8668
+ /** @internal */
8669
+ TrackEvent["ElementAttached"] = "elementAttached";
8670
+ /** @internal */
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";
8627
8682
  })(TrackEvent || (TrackEvent = {}));
8628
8683
 
8629
8684
  const monitorFrequency = 2000;
@@ -8705,12 +8760,12 @@ class DeviceManager {
8705
8760
  // device has been chosen
8706
8761
  const devices = await this.getDevices(kind);
8707
8762
  const device = devices.find((d) => d.groupId === groupId && d.deviceId !== defaultId);
8708
- return device?.deviceId;
8763
+ return device === null || device === void 0 ? void 0 : device.deviceId;
8709
8764
  }
8710
8765
  }
8711
8766
  DeviceManager.mediaDeviceKinds = ['audioinput', 'audiooutput', 'videoinput'];
8712
8767
 
8713
- const version = '0.18.1';
8768
+ const version = '0.18.2';
8714
8769
  const protocolVersion = 7;
8715
8770
 
8716
8771
  const separator = '|';
@@ -8775,6 +8830,22 @@ function getClientInfo() {
8775
8830
  });
8776
8831
  return info;
8777
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
+ }
8778
8849
 
8779
8850
  var events = {exports: {}};
8780
8851
 
@@ -9287,6 +9358,7 @@ class Track extends events.exports.EventEmitter {
9287
9358
  this.emit(TrackEvent.AudioPlaybackFailed, e);
9288
9359
  });
9289
9360
  }
9361
+ this.emit(TrackEvent.ElementAttached, element);
9290
9362
  return element;
9291
9363
  }
9292
9364
  detach(element) {
@@ -9297,6 +9369,7 @@ class Track extends events.exports.EventEmitter {
9297
9369
  if (idx >= 0) {
9298
9370
  this.attachedElements.splice(idx, 1);
9299
9371
  this.recycleElement(element);
9372
+ this.emit(TrackEvent.ElementDetached, element);
9300
9373
  }
9301
9374
  return element;
9302
9375
  }
@@ -9305,6 +9378,7 @@ class Track extends events.exports.EventEmitter {
9305
9378
  detachTrack(this.mediaStreamTrack, elm);
9306
9379
  detached.push(elm);
9307
9380
  this.recycleElement(elm);
9381
+ this.emit(TrackEvent.ElementDetached, elm);
9308
9382
  });
9309
9383
  // remove all tracks
9310
9384
  this.attachedElements = [];
@@ -9492,6 +9566,7 @@ function detachTrack(track, element) {
9492
9566
  class LocalTrack extends Track {
9493
9567
  constructor(mediaTrack, kind, constraints) {
9494
9568
  super(mediaTrack, kind);
9569
+ this._isUpstreamPaused = false;
9495
9570
  this.handleEnded = () => {
9496
9571
  if (this.isInBackground) {
9497
9572
  this.reacquireTrack = true;
@@ -9499,7 +9574,7 @@ class LocalTrack extends Track {
9499
9574
  this.emit(TrackEvent.Ended, this);
9500
9575
  };
9501
9576
  this.mediaStreamTrack.addEventListener('ended', this.handleEnded);
9502
- this.constraints = constraints ?? mediaTrack.getConstraints();
9577
+ this.constraints = constraints !== null && constraints !== void 0 ? constraints : mediaTrack.getConstraints();
9503
9578
  this.reacquireTrack = false;
9504
9579
  this.wasMuted = false;
9505
9580
  }
@@ -9519,6 +9594,9 @@ class LocalTrack extends Track {
9519
9594
  }
9520
9595
  return undefined;
9521
9596
  }
9597
+ get isUpstreamPaused() {
9598
+ return this._isUpstreamPaused;
9599
+ }
9522
9600
  /**
9523
9601
  * @returns DeviceID of the device that is currently being used for this track
9524
9602
  */
@@ -9539,6 +9617,29 @@ class LocalTrack extends Track {
9539
9617
  this.setTrackMuted(false);
9540
9618
  return this;
9541
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
+ }
9542
9643
  async restart(constraints) {
9543
9644
  if (!this.sender) {
9544
9645
  throw new TrackInvalidError('unable to restart an unpublished track');
@@ -9611,6 +9712,30 @@ class LocalTrack extends Track {
9611
9712
  this.wasMuted = this.isMuted;
9612
9713
  }
9613
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
+ }
9614
9739
  }
9615
9740
 
9616
9741
  function mergeDefaultOptions(options, audioDefaults, videoDefaults) {
@@ -9838,7 +9963,8 @@ class LocalVideoTrack extends LocalTrack {
9838
9963
  if (this.prevStats) {
9839
9964
  let totalBitrate = 0;
9840
9965
  statsMap.forEach((s, key) => {
9841
- const prev = this.prevStats?.get(key);
9966
+ var _a;
9967
+ const prev = (_a = this.prevStats) === null || _a === void 0 ? void 0 : _a.get(key);
9842
9968
  totalBitrate += computeBitrate(s, prev);
9843
9969
  });
9844
9970
  this._currentBitrate = totalBitrate;
@@ -9857,9 +9983,10 @@ class LocalVideoTrack extends LocalTrack {
9857
9983
  }
9858
9984
  /* @internal */
9859
9985
  startMonitor(signalClient) {
9986
+ var _a;
9860
9987
  this.signalClient = signalClient;
9861
9988
  // save original encodings
9862
- const params = this.sender?.getParameters();
9989
+ const params = (_a = this.sender) === null || _a === void 0 ? void 0 : _a.getParameters();
9863
9990
  if (params) {
9864
9991
  this.encodings = params.encodings;
9865
9992
  }
@@ -9896,6 +10023,7 @@ class LocalVideoTrack extends LocalTrack {
9896
10023
  const items = [];
9897
10024
  const stats = await this.sender.getStats();
9898
10025
  stats.forEach((v) => {
10026
+ var _a;
9899
10027
  if (v.type === 'outbound-rtp') {
9900
10028
  const vs = {
9901
10029
  type: 'video',
@@ -9909,7 +10037,7 @@ class LocalVideoTrack extends LocalTrack {
9909
10037
  bytesSent: v.bytesSent,
9910
10038
  framesSent: v.framesSent,
9911
10039
  timestamp: v.timestamp,
9912
- rid: v.rid ?? '',
10040
+ rid: (_a = v.rid) !== null && _a !== void 0 ? _a : '',
9913
10041
  retransmittedPacketsSent: v.retransmittedPacketsSent,
9914
10042
  qualityLimitationReason: v.qualityLimitationReason,
9915
10043
  qualityLimitationResolutionChanges: v.qualityLimitationResolutionChanges,
@@ -9978,7 +10106,8 @@ class LocalVideoTrack extends LocalTrack {
9978
10106
  }
9979
10107
  let hasChanged = false;
9980
10108
  encodings.forEach((encoding, idx) => {
9981
- let rid = encoding.rid ?? '';
10109
+ var _a;
10110
+ let rid = (_a = encoding.rid) !== null && _a !== void 0 ? _a : '';
9982
10111
  if (rid === '') {
9983
10112
  rid = 'q';
9984
10113
  }
@@ -10049,8 +10178,9 @@ function videoLayersFromEncodings(width, height, encodings) {
10049
10178
  ];
10050
10179
  }
10051
10180
  return encodings.map((encoding) => {
10052
- const scale = encoding.scaleResolutionDownBy ?? 1;
10053
- 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 : '');
10054
10184
  if (quality === VideoQuality.UNRECOGNIZED && encodings.length === 1) {
10055
10185
  quality = VideoQuality.HIGH;
10056
10186
  }
@@ -10058,7 +10188,7 @@ function videoLayersFromEncodings(width, height, encodings) {
10058
10188
  quality,
10059
10189
  width: width / scale,
10060
10190
  height: height / scale,
10061
- bitrate: encoding.maxBitrate ?? 0,
10191
+ bitrate: (_c = encoding.maxBitrate) !== null && _c !== void 0 ? _c : 0,
10062
10192
  ssrc: 0,
10063
10193
  };
10064
10194
  });
@@ -10343,8 +10473,9 @@ class RemoteVideoTrack extends RemoteTrack {
10343
10473
  return receiverStats;
10344
10474
  }
10345
10475
  stopObservingElement(element) {
10346
- getIntersectionObserver()?.unobserve(element);
10347
- 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);
10348
10479
  this.elementInfos = this.elementInfos.filter((info) => info.element !== element);
10349
10480
  }
10350
10481
  async handleAppVisibilityChanged() {
@@ -10373,10 +10504,11 @@ class RemoteVideoTrack extends RemoteTrack {
10373
10504
  this.emit(TrackEvent.VisibilityChanged, isVisible, this);
10374
10505
  }
10375
10506
  updateDimensions() {
10507
+ var _a, _b, _c, _d;
10376
10508
  let maxWidth = 0;
10377
10509
  let maxHeight = 0;
10378
10510
  for (const info of this.elementInfos) {
10379
- 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;
10380
10512
  const pixelDensityValue = pixelDensity === 'screen' ? window.devicePixelRatio : pixelDensity;
10381
10513
  const currentElementWidth = info.element.clientWidth * pixelDensityValue;
10382
10514
  const currentElementHeight = info.element.clientHeight * pixelDensityValue;
@@ -10385,7 +10517,7 @@ class RemoteVideoTrack extends RemoteTrack {
10385
10517
  maxHeight = currentElementHeight;
10386
10518
  }
10387
10519
  }
10388
- 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) {
10389
10521
  return;
10390
10522
  }
10391
10523
  this.lastDimensions = {
@@ -10476,12 +10608,17 @@ class TrackPublication extends events.exports.EventEmitter {
10476
10608
  class LocalTrackPublication extends TrackPublication {
10477
10609
  constructor(kind, ti, track) {
10478
10610
  super(kind, ti.sid, ti.name);
10479
- this.handleTrackEnded = (track) => {
10480
- this.emit(TrackEvent.Ended, track);
10611
+ this.track = undefined;
10612
+ this.handleTrackEnded = () => {
10613
+ this.emit(TrackEvent.Ended);
10481
10614
  };
10482
10615
  this.updateInfo(ti);
10483
10616
  this.setTrack(track);
10484
10617
  }
10618
+ get isUpstreamPaused() {
10619
+ var _a;
10620
+ return (_a = this.track) === null || _a === void 0 ? void 0 : _a.isUpstreamPaused;
10621
+ }
10485
10622
  setTrack(track) {
10486
10623
  if (this.track) {
10487
10624
  this.track.off(TrackEvent.Ended, this.handleTrackEnded);
@@ -10507,13 +10644,32 @@ class LocalTrackPublication extends TrackPublication {
10507
10644
  * Mute the track associated with this publication
10508
10645
  */
10509
10646
  async mute() {
10510
- return this.track?.mute();
10647
+ var _a;
10648
+ return (_a = this.track) === null || _a === void 0 ? void 0 : _a.mute();
10511
10649
  }
10512
10650
  /**
10513
10651
  * Unmute track associated with this publication
10514
10652
  */
10515
10653
  async unmute() {
10516
- 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());
10517
10673
  }
10518
10674
  }
10519
10675
 
@@ -10538,79 +10694,79 @@ class VideoPreset {
10538
10694
  var AudioPresets;
10539
10695
  (function (AudioPresets) {
10540
10696
  AudioPresets.telephone = {
10541
- maxBitrate: 12_000,
10697
+ maxBitrate: 12000,
10542
10698
  };
10543
10699
  AudioPresets.speech = {
10544
- maxBitrate: 20_000,
10700
+ maxBitrate: 20000,
10545
10701
  };
10546
10702
  AudioPresets.music = {
10547
- maxBitrate: 32_000,
10703
+ maxBitrate: 32000,
10548
10704
  };
10549
10705
  })(AudioPresets || (AudioPresets = {}));
10550
10706
  /**
10551
10707
  * Sane presets for video resolution/encoding
10552
10708
  */
10553
10709
  const VideoPresets = {
10554
- h90: new VideoPreset(160, 90, 60_000, 15),
10555
- h180: new VideoPreset(320, 180, 120_000, 15),
10556
- h216: new VideoPreset(384, 216, 180_000, 15),
10557
- h360: new VideoPreset(640, 360, 300_000, 20),
10558
- h540: new VideoPreset(960, 540, 600_000, 25),
10559
- h720: new VideoPreset(1280, 720, 2_000_000, 30),
10560
- h1080: new VideoPreset(1920, 1080, 3_000_000, 30),
10561
- h1440: new VideoPreset(2560, 1440, 5_000_000, 30),
10562
- 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),
10563
10719
  /** @deprecated */
10564
- qvga: new VideoPreset(320, 180, 120_000, 10),
10720
+ qvga: new VideoPreset(320, 180, 120000, 10),
10565
10721
  /** @deprecated */
10566
- vga: new VideoPreset(640, 360, 300_000, 20),
10722
+ vga: new VideoPreset(640, 360, 300000, 20),
10567
10723
  /** @deprecated */
10568
- qhd: new VideoPreset(960, 540, 600_000, 25),
10724
+ qhd: new VideoPreset(960, 540, 600000, 25),
10569
10725
  /** @deprecated */
10570
- hd: new VideoPreset(1280, 720, 2_000_000, 30),
10726
+ hd: new VideoPreset(1280, 720, 2000000, 30),
10571
10727
  /** @deprecated */
10572
- fhd: new VideoPreset(1920, 1080, 3_000_000, 30),
10728
+ fhd: new VideoPreset(1920, 1080, 3000000, 30),
10573
10729
  };
10574
10730
  /**
10575
10731
  * Four by three presets
10576
10732
  */
10577
10733
  const VideoPresets43 = {
10578
- h120: new VideoPreset(160, 120, 80_000, 15),
10579
- h180: new VideoPreset(240, 180, 100_000, 15),
10580
- h240: new VideoPreset(320, 240, 150_000, 15),
10581
- h360: new VideoPreset(480, 360, 225_000, 20),
10582
- h480: new VideoPreset(640, 480, 300_000, 20),
10583
- h540: new VideoPreset(720, 540, 450_000, 25),
10584
- h720: new VideoPreset(960, 720, 1_500_000, 30),
10585
- h1080: new VideoPreset(1440, 1080, 2_500_000, 30),
10586
- 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),
10587
10743
  /** @deprecated */
10588
- qvga: new VideoPreset(240, 180, 90_000, 10),
10744
+ qvga: new VideoPreset(240, 180, 90000, 10),
10589
10745
  /** @deprecated */
10590
- vga: new VideoPreset(480, 360, 225_000, 20),
10746
+ vga: new VideoPreset(480, 360, 225000, 20),
10591
10747
  /** @deprecated */
10592
- qhd: new VideoPreset(720, 540, 450_000, 25),
10748
+ qhd: new VideoPreset(720, 540, 450000, 25),
10593
10749
  /** @deprecated */
10594
- hd: new VideoPreset(960, 720, 1_500_000, 30),
10750
+ hd: new VideoPreset(960, 720, 1500000, 30),
10595
10751
  /** @deprecated */
10596
- fhd: new VideoPreset(1440, 1080, 2_800_000, 30),
10752
+ fhd: new VideoPreset(1440, 1080, 2800000, 30),
10597
10753
  };
10598
10754
  const ScreenSharePresets = {
10599
- h360fps3: new VideoPreset(640, 360, 200_000, 3),
10600
- h720fps5: new VideoPreset(1280, 720, 400_000, 5),
10601
- h720fps15: new VideoPreset(1280, 720, 1_000_000, 15),
10602
- h1080fps15: new VideoPreset(1920, 1080, 1_500_000, 15),
10603
- 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),
10604
10760
  /** @deprecated */
10605
- vga: new VideoPreset(640, 360, 200_000, 3),
10761
+ vga: new VideoPreset(640, 360, 200000, 3),
10606
10762
  /** @deprecated */
10607
- hd_8: new VideoPreset(1280, 720, 400_000, 5),
10763
+ hd_8: new VideoPreset(1280, 720, 400000, 5),
10608
10764
  /** @deprecated */
10609
- hd_15: new VideoPreset(1280, 720, 1_000_000, 15),
10765
+ hd_15: new VideoPreset(1280, 720, 1000000, 15),
10610
10766
  /** @deprecated */
10611
- fhd_15: new VideoPreset(1920, 1080, 1_500_000, 15),
10767
+ fhd_15: new VideoPreset(1920, 1080, 1500000, 15),
10612
10768
  /** @deprecated */
10613
- fhd_30: new VideoPreset(1920, 1080, 3_000_000, 30),
10769
+ fhd_30: new VideoPreset(1920, 1080, 3000000, 30),
10614
10770
  };
10615
10771
 
10616
10772
  var ConnectionQuality;
@@ -10704,12 +10860,14 @@ class Participant extends events.exports.EventEmitter {
10704
10860
  return this._connectionQuality;
10705
10861
  }
10706
10862
  get isCameraEnabled() {
10863
+ var _a;
10707
10864
  const track = this.getTrack(Track.Source.Camera);
10708
- return !(track?.isMuted ?? true);
10865
+ return !((_a = track === null || track === void 0 ? void 0 : track.isMuted) !== null && _a !== void 0 ? _a : true);
10709
10866
  }
10710
10867
  get isMicrophoneEnabled() {
10868
+ var _a;
10711
10869
  const track = this.getTrack(Track.Source.Microphone);
10712
- return !(track?.isMuted ?? true);
10870
+ return !((_a = track === null || track === void 0 ? void 0 : track.isMuted) !== null && _a !== void 0 ? _a : true);
10713
10871
  }
10714
10872
  get isScreenShareEnabled() {
10715
10873
  const track = this.getTrack(Track.Source.ScreenShare);
@@ -10746,11 +10904,12 @@ class Participant extends events.exports.EventEmitter {
10746
10904
  }
10747
10905
  /** @internal */
10748
10906
  setPermissions(permissions) {
10749
- const changed = permissions.canPublish !== this.permissions?.canPublish ||
10750
- permissions.canSubscribe !== this.permissions?.canSubscribe ||
10751
- permissions.canPublishData !== this.permissions?.canPublishData ||
10752
- permissions.hidden !== this.permissions?.hidden ||
10753
- 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);
10754
10913
  this.permissions = permissions;
10755
10914
  return changed;
10756
10915
  }
@@ -10798,12 +10957,13 @@ class Participant extends events.exports.EventEmitter {
10798
10957
  }
10799
10958
 
10800
10959
  function trackPermissionToProto(perms) {
10960
+ var _a;
10801
10961
  if (!perms.participantSid) {
10802
10962
  throw new Error('Invalid track permission, missing participantSid');
10803
10963
  }
10804
10964
  return {
10805
10965
  participantSid: perms.participantSid,
10806
- allTracks: perms.allowAll ?? false,
10966
+ allTracks: (_a = perms.allowAll) !== null && _a !== void 0 ? _a : false,
10807
10967
  trackSids: perms.allowedTrackSids || [],
10808
10968
  };
10809
10969
  }
@@ -10832,17 +10992,21 @@ const defaultSimulcastPresets43 = [VideoPresets43.h180, VideoPresets43.h360];
10832
10992
  /* @internal */
10833
10993
  const computeDefaultScreenShareSimulcastPresets = (fromPreset) => {
10834
10994
  const layers = [{ scaleResolutionDownBy: 2, fps: 3 }];
10835
- 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 /
10836
- (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
+ });
10837
11000
  };
10838
11001
  const videoRids = ['q', 'h', 'f'];
10839
11002
  /* @internal */
10840
11003
  function computeVideoEncodings(isScreenShare, width, height, options) {
10841
- let videoEncoding = options?.videoEncoding;
11004
+ var _a, _b;
11005
+ let videoEncoding = options === null || options === void 0 ? void 0 : options.videoEncoding;
10842
11006
  if (isScreenShare) {
10843
- videoEncoding = options?.screenShareEncoding;
11007
+ videoEncoding = options === null || options === void 0 ? void 0 : options.screenShareEncoding;
10844
11008
  }
10845
- const useSimulcast = options?.simulcast;
11009
+ const useSimulcast = options === null || options === void 0 ? void 0 : options.simulcast;
10846
11010
  if ((!videoEncoding && !useSimulcast) || !width || !height) {
10847
11011
  // when we aren't simulcasting, will need to return a single encoding without
10848
11012
  // capping bandwidth. we always require a encoding for dynacast
@@ -10860,12 +11024,11 @@ function computeVideoEncodings(isScreenShare, width, height, options) {
10860
11024
  let presets = [];
10861
11025
  if (isScreenShare) {
10862
11026
  presets =
10863
- sortPresets(options?.screenShareSimulcastLayers) ??
10864
- defaultSimulcastLayers(isScreenShare, original);
11027
+ (_a = sortPresets(options === null || options === void 0 ? void 0 : options.screenShareSimulcastLayers)) !== null && _a !== void 0 ? _a : defaultSimulcastLayers(isScreenShare, original);
10865
11028
  }
10866
11029
  else {
10867
11030
  presets =
10868
- 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);
10869
11032
  }
10870
11033
  let midPreset;
10871
11034
  const lowPreset = presets[0];
@@ -11064,11 +11227,12 @@ class RemoteTrackPublication extends TrackPublication {
11064
11227
  this.emitTrackUpdate();
11065
11228
  }
11066
11229
  setVideoDimensions(dimensions) {
11230
+ var _a, _b;
11067
11231
  if (!this.isManualOperationAllowed()) {
11068
11232
  return;
11069
11233
  }
11070
- if (this.videoDimensions?.width === dimensions.width &&
11071
- 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) {
11072
11236
  return;
11073
11237
  }
11074
11238
  if (this.track instanceof RemoteVideoTrack) {
@@ -11097,9 +11261,10 @@ class RemoteTrackPublication extends TrackPublication {
11097
11261
  }
11098
11262
  /** @internal */
11099
11263
  updateInfo(info) {
11264
+ var _a;
11100
11265
  super.updateInfo(info);
11101
11266
  this.metadataMuted = info.muted;
11102
- this.track?.setMuted(info.muted);
11267
+ (_a = this.track) === null || _a === void 0 ? void 0 : _a.setMuted(info.muted);
11103
11268
  }
11104
11269
  isManualOperationAllowed() {
11105
11270
  if (this.isAdaptiveStream) {
@@ -11343,7 +11508,7 @@ class LocalParticipant extends Participant {
11343
11508
  this.pendingPublishing = new Set();
11344
11509
  /** @internal */
11345
11510
  this.onTrackUnmuted = (track) => {
11346
- this.onTrackMuted(track, false);
11511
+ this.onTrackMuted(track, track.isUpstreamPaused);
11347
11512
  };
11348
11513
  // when the local track changes in mute status, we'll notify server as such
11349
11514
  /** @internal */
@@ -11357,8 +11522,17 @@ class LocalParticipant extends Participant {
11357
11522
  }
11358
11523
  this.engine.updateMuteStatus(track.sid, muted);
11359
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
+ };
11360
11533
  this.handleSubscribedQualityUpdate = (update) => {
11361
- if (!this.roomOptions?.dynacast) {
11534
+ var _a, _b;
11535
+ if (!((_a = this.roomOptions) === null || _a === void 0 ? void 0 : _a.dynacast)) {
11362
11536
  return;
11363
11537
  }
11364
11538
  const pub = this.videoTracks.get(update.trackSid);
@@ -11369,7 +11543,7 @@ class LocalParticipant extends Participant {
11369
11543
  });
11370
11544
  return;
11371
11545
  }
11372
- pub.videoTrack?.setPublishingLayers(update.subscribedQualities);
11546
+ (_b = pub.videoTrack) === null || _b === void 0 ? void 0 : _b.setPublishingLayers(update.subscribedQualities);
11373
11547
  };
11374
11548
  this.handleLocalTrackUnpublished = (unpublished) => {
11375
11549
  const track = this.tracks.get(unpublished.trackSid);
@@ -11549,7 +11723,8 @@ class LocalParticipant extends Participant {
11549
11723
  * @returns
11550
11724
  */
11551
11725
  async createTracks(options) {
11552
- 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);
11553
11728
  const constraints = constraintsForOptions(opts);
11554
11729
  let stream;
11555
11730
  try {
@@ -11597,6 +11772,7 @@ class LocalParticipant extends Participant {
11597
11772
  * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
11598
11773
  */
11599
11774
  async createScreenTracks(options) {
11775
+ var _a;
11600
11776
  if (options === undefined) {
11601
11777
  options = {};
11602
11778
  }
@@ -11614,7 +11790,7 @@ class LocalParticipant extends Participant {
11614
11790
  // typescript definition is missing getDisplayMedia: https://github.com/microsoft/TypeScript/issues/33232
11615
11791
  // @ts-ignore
11616
11792
  const stream = await navigator.mediaDevices.getDisplayMedia({
11617
- audio: options.audio ?? false,
11793
+ audio: (_a = options.audio) !== null && _a !== void 0 ? _a : false,
11618
11794
  video: videoConstraints,
11619
11795
  });
11620
11796
  const tracks = stream.getVideoTracks();
@@ -11637,8 +11813,9 @@ class LocalParticipant extends Participant {
11637
11813
  * @param options
11638
11814
  */
11639
11815
  async publishTrack(track, options) {
11816
+ var _a, _b, _c, _d, _e, _f;
11640
11817
  const opts = {
11641
- ...this.roomOptions?.publishDefaults,
11818
+ ...(_a = this.roomOptions) === null || _a === void 0 ? void 0 : _a.publishDefaults,
11642
11819
  ...options,
11643
11820
  };
11644
11821
  // convert raw media track into audio or video track
@@ -11681,26 +11858,28 @@ class LocalParticipant extends Participant {
11681
11858
  track.on(TrackEvent.Muted, this.onTrackMuted);
11682
11859
  track.on(TrackEvent.Unmuted, this.onTrackUnmuted);
11683
11860
  track.on(TrackEvent.Ended, this.onTrackUnpublish);
11861
+ track.on(TrackEvent.UpstreamPaused, this.onTrackUpstreamPaused);
11862
+ track.on(TrackEvent.UpstreamResumed, this.onTrackUpstreamResumed);
11684
11863
  // create track publication from track
11685
11864
  const req = AddTrackRequest.fromPartial({
11686
11865
  // get local track id for use during publishing
11687
11866
  cid: track.mediaStreamTrack.id,
11688
- name: options?.name,
11867
+ name: options === null || options === void 0 ? void 0 : options.name,
11689
11868
  type: Track.kindToProto(track.kind),
11690
11869
  muted: track.isMuted,
11691
11870
  source: Track.sourceToProto(track.source),
11692
- disableDtx: !(opts?.dtx ?? true),
11871
+ disableDtx: !((_b = opts === null || opts === void 0 ? void 0 : opts.dtx) !== null && _b !== void 0 ? _b : true),
11693
11872
  });
11694
11873
  // compute encodings and layers for video
11695
11874
  let encodings;
11696
11875
  if (track.kind === Track.Kind.Video) {
11697
11876
  // TODO: support react native, which doesn't expose getSettings
11698
11877
  const settings = track.mediaStreamTrack.getSettings();
11699
- const width = settings.width ?? track.dimensions?.width;
11700
- 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;
11701
11880
  // width and height should be defined for video
11702
- req.width = width ?? 0;
11703
- req.height = height ?? 0;
11881
+ req.width = width !== null && width !== void 0 ? width : 0;
11882
+ req.height = height !== null && height !== void 0 ? height : 0;
11704
11883
  encodings = computeVideoEncodings(track.source === Track.Source.ScreenShare, width, height, opts);
11705
11884
  req.layers = videoLayersFromEncodings(req.width, req.height, encodings);
11706
11885
  }
@@ -11741,6 +11920,7 @@ class LocalParticipant extends Participant {
11741
11920
  return publication;
11742
11921
  }
11743
11922
  unpublishTrack(track, stopOnUnpublish) {
11923
+ var _a, _b;
11744
11924
  // look through all published tracks to find the right ones
11745
11925
  const publication = this.getPublicationForTrack(track);
11746
11926
  livekitLogger.debug('unpublishing track', { track, method: 'unpublishTrack' });
@@ -11755,8 +11935,10 @@ class LocalParticipant extends Participant {
11755
11935
  track.off(TrackEvent.Muted, this.onTrackMuted);
11756
11936
  track.off(TrackEvent.Unmuted, this.onTrackUnmuted);
11757
11937
  track.off(TrackEvent.Ended, this.onTrackUnpublish);
11938
+ track.off(TrackEvent.UpstreamPaused, this.onTrackUpstreamPaused);
11939
+ track.off(TrackEvent.UpstreamResumed, this.onTrackUpstreamResumed);
11758
11940
  if (stopOnUnpublish === undefined) {
11759
- 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;
11760
11942
  }
11761
11943
  if (stopOnUnpublish) {
11762
11944
  track.stop();
@@ -11765,9 +11947,10 @@ class LocalParticipant extends Participant {
11765
11947
  if (this.engine.publisher) {
11766
11948
  const senders = this.engine.publisher.pc.getSenders();
11767
11949
  senders.forEach((sender) => {
11950
+ var _a;
11768
11951
  if (sender.track === mediaStreamTrack) {
11769
11952
  try {
11770
- this.engine.publisher?.pc.removeTrack(sender);
11953
+ (_a = this.engine.publisher) === null || _a === void 0 ? void 0 : _a.pc.removeTrack(sender);
11771
11954
  this.engine.negotiate();
11772
11955
  }
11773
11956
  catch (e) {
@@ -11913,7 +12096,7 @@ class LocalParticipant extends Participant {
11913
12096
  dataChannelsInfo() {
11914
12097
  const infos = [];
11915
12098
  const getInfo = (dc, target) => {
11916
- if (dc?.id !== undefined && dc.id !== null) {
12099
+ if ((dc === null || dc === void 0 ? void 0 : dc.id) !== undefined && dc.id !== null) {
11917
12100
  infos.push({
11918
12101
  label: dc.label,
11919
12102
  id: dc.id,
@@ -15484,8 +15667,9 @@ class SignalClient {
15484
15667
  // connected
15485
15668
  this.isConnected = false;
15486
15669
  const res = await this.connect(url, token, {
15487
- autoSubscribe: opts?.autoSubscribe,
15488
- publishOnly: opts?.publishOnly,
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,
15489
15673
  });
15490
15674
  return res;
15491
15675
  }
@@ -15581,10 +15765,11 @@ class SignalClient {
15581
15765
  });
15582
15766
  }
15583
15767
  close() {
15768
+ var _a;
15584
15769
  this.isConnected = false;
15585
15770
  if (this.ws)
15586
15771
  this.ws.onclose = null;
15587
- this.ws?.close();
15772
+ (_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
15588
15773
  this.ws = undefined;
15589
15774
  }
15590
15775
  // initial offer after joining
@@ -15801,10 +15986,10 @@ function createConnectionParams(token, info, opts) {
15801
15986
  const params = new URLSearchParams();
15802
15987
  params.set('access_token', token);
15803
15988
  // opts
15804
- if (opts?.reconnect) {
15989
+ if (opts === null || opts === void 0 ? void 0 : opts.reconnect) {
15805
15990
  params.set('reconnect', '1');
15806
15991
  }
15807
- if (opts?.autoSubscribe !== undefined) {
15992
+ if ((opts === null || opts === void 0 ? void 0 : opts.autoSubscribe) !== undefined) {
15808
15993
  params.set('auto_subscribe', opts.autoSubscribe ? '1' : '0');
15809
15994
  }
15810
15995
  // ClientInfo
@@ -15826,9 +16011,12 @@ function createConnectionParams(token, info, opts) {
15826
16011
  if (info.browserVersion) {
15827
16012
  params.set('browser_version', info.browserVersion);
15828
16013
  }
15829
- if (opts?.publishOnly !== undefined) {
16014
+ if ((opts === null || opts === void 0 ? void 0 : opts.publishOnly) !== undefined) {
15830
16015
  params.set('publish', opts.publishOnly);
15831
16016
  }
16017
+ if (opts === null || opts === void 0 ? void 0 : opts.adaptiveStream) {
16018
+ params.set('adaptive_stream', '1');
16019
+ }
15832
16020
  return `?${params.toString()}`;
15833
16021
  }
15834
16022
 
@@ -15869,7 +16057,7 @@ class PCTransport {
15869
16057
  if (this.onOffer === undefined) {
15870
16058
  return;
15871
16059
  }
15872
- if (options?.iceRestart) {
16060
+ if (options === null || options === void 0 ? void 0 : options.iceRestart) {
15873
16061
  livekitLogger.debug('restarting ICE');
15874
16062
  this.restartingIce = true;
15875
16063
  }
@@ -15877,7 +16065,7 @@ class PCTransport {
15877
16065
  // we're waiting for the peer to accept our offer, so we'll just wait
15878
16066
  // the only exception to this is when ICE restart is needed
15879
16067
  const currentSD = this.pc.remoteDescription;
15880
- if (options?.iceRestart && currentSD) {
16068
+ if ((options === null || options === void 0 ? void 0 : options.iceRestart) && currentSD) {
15881
16069
  // TODO: handle when ICE restart is needed but we don't have a remote description
15882
16070
  // the best thing to do is to recreate the peerconnection
15883
16071
  await this.pc.setRemoteDescription(currentSD);
@@ -15905,16 +16093,24 @@ class PCTransport {
15905
16093
  const lossyDataChannel = '_lossy';
15906
16094
  const reliableDataChannel = '_reliable';
15907
16095
  const maxReconnectRetries = 10;
15908
- const minReconnectWait = 1 * 1000;
16096
+ const minReconnectWait = 2 * 1000;
15909
16097
  const maxReconnectDuration = 60 * 1000;
15910
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 = {}));
15911
16107
  /** @internal */
15912
16108
  class RTCEngine extends events.exports.EventEmitter {
15913
16109
  constructor() {
15914
16110
  super();
15915
16111
  this.rtcConfig = {};
15916
16112
  this.subscriberPrimary = false;
15917
- this.pcConnected = false;
16113
+ this.pcState = PCState.New;
15918
16114
  this.isClosed = true;
15919
16115
  this.pendingTrackResolvers = {};
15920
16116
  // true if publisher connection has already been established.
@@ -15986,11 +16182,12 @@ class RTCEngine extends events.exports.EventEmitter {
15986
16182
  }
15987
16183
  const delay = this.reconnectAttempts * this.reconnectAttempts * 300;
15988
16184
  setTimeout(async () => {
16185
+ var _a;
15989
16186
  if (this.isClosed) {
15990
16187
  return;
15991
16188
  }
15992
16189
  if (isFireFox() || // TODO remove once clientConfiguration handles firefox case server side
15993
- this.clientConfiguration?.resumeConnection === ClientConfigSetting.DISABLED) {
16190
+ ((_a = this.clientConfiguration) === null || _a === void 0 ? void 0 : _a.resumeConnection) === ClientConfigSetting.DISABLED) {
15994
16191
  this.fullReconnectOnNext = true;
15995
16192
  }
15996
16193
  try {
@@ -16054,10 +16251,11 @@ class RTCEngine extends events.exports.EventEmitter {
16054
16251
  this.removeAllListeners();
16055
16252
  if (this.publisher && this.publisher.pc.signalingState !== 'closed') {
16056
16253
  this.publisher.pc.getSenders().forEach((sender) => {
16254
+ var _a, _b;
16057
16255
  try {
16058
16256
  // TODO: react-native-webrtc doesn't have removeTrack yet.
16059
- if (this.publisher?.pc.removeTrack) {
16060
- 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);
16061
16259
  }
16062
16260
  }
16063
16261
  catch (e) {
@@ -16086,7 +16284,8 @@ class RTCEngine extends events.exports.EventEmitter {
16086
16284
  this.client.sendMuteTrack(trackSid, muted);
16087
16285
  }
16088
16286
  get dataSubscriberReadyState() {
16089
- return this.reliableDCSub?.readyState;
16287
+ var _a;
16288
+ return (_a = this.reliableDCSub) === null || _a === void 0 ? void 0 : _a.readyState;
16090
16289
  }
16091
16290
  get connectedServerAddress() {
16092
16291
  return this.connectedServerAddr;
@@ -16141,24 +16340,26 @@ class RTCEngine extends events.exports.EventEmitter {
16141
16340
  }
16142
16341
  this.primaryPC = primaryPC;
16143
16342
  primaryPC.onconnectionstatechange = async () => {
16343
+ livekitLogger.trace('connection state changed', {
16344
+ state: primaryPC.connectionState,
16345
+ });
16144
16346
  if (primaryPC.connectionState === 'connected') {
16145
- livekitLogger.trace('pc connected');
16146
16347
  try {
16147
16348
  this.connectedServerAddr = await getConnectedAddress(primaryPC);
16148
16349
  }
16149
16350
  catch (e) {
16150
16351
  livekitLogger.warn('could not get connected server address', { error: e });
16151
16352
  }
16152
- if (!this.pcConnected) {
16153
- this.pcConnected = true;
16353
+ const shouldEmit = this.pcState === PCState.New;
16354
+ this.pcState = PCState.Connected;
16355
+ if (shouldEmit) {
16154
16356
  this.emit(EngineEvent.Connected);
16155
16357
  }
16156
16358
  }
16157
16359
  else if (primaryPC.connectionState === 'failed') {
16158
16360
  // on Safari, PeerConnection will switch to 'disconnected' during renegotiation
16159
- livekitLogger.trace('pc disconnected');
16160
- if (this.pcConnected) {
16161
- this.pcConnected = false;
16361
+ if (this.pcState === PCState.Connected) {
16362
+ this.pcState = PCState.Disconnected;
16162
16363
  this.handleDisconnect('peerconnection');
16163
16364
  }
16164
16365
  }
@@ -16247,7 +16448,7 @@ class RTCEngine extends events.exports.EventEmitter {
16247
16448
  this.handleDisconnect('signal');
16248
16449
  };
16249
16450
  this.client.onLeave = (leave) => {
16250
- if (leave?.canReconnect) {
16451
+ if (leave === null || leave === void 0 ? void 0 : leave.canReconnect) {
16251
16452
  this.fullReconnectOnNext = true;
16252
16453
  this.primaryPC = undefined;
16253
16454
  }
@@ -16258,6 +16459,7 @@ class RTCEngine extends events.exports.EventEmitter {
16258
16459
  };
16259
16460
  }
16260
16461
  async restartConnection() {
16462
+ var _a, _b;
16261
16463
  if (!this.url || !this.token) {
16262
16464
  // permanent failure, don't attempt reconnection
16263
16465
  throw new UnexpectedConnectionState('could not reconnect, url or token not saved');
@@ -16267,9 +16469,9 @@ class RTCEngine extends events.exports.EventEmitter {
16267
16469
  this.emit(EngineEvent.Restarting);
16268
16470
  }
16269
16471
  this.primaryPC = undefined;
16270
- this.publisher?.close();
16472
+ (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.close();
16271
16473
  this.publisher = undefined;
16272
- this.subscriber?.close();
16474
+ (_b = this.subscriber) === null || _b === void 0 ? void 0 : _b.close();
16273
16475
  this.subscriber = undefined;
16274
16476
  let joinResponse;
16275
16477
  try {
@@ -16314,25 +16516,35 @@ class RTCEngine extends events.exports.EventEmitter {
16314
16516
  this.emit(EngineEvent.Resumed);
16315
16517
  }
16316
16518
  async waitForPCConnected() {
16317
- const startTime = new Date().getTime();
16519
+ var _a;
16520
+ const startTime = Date.now();
16318
16521
  let now = startTime;
16319
- this.pcConnected = false;
16522
+ this.pcState = PCState.Reconnecting;
16523
+ livekitLogger.debug('waiting for peer connection to reconnect');
16320
16524
  while (now - startTime < maxICEConnectTimeout) {
16321
- // if there is no connectionstatechange callback fired
16322
- // check connectionstate after minReconnectWait
16323
16525
  if (this.primaryPC === undefined) {
16324
16526
  // we can abort early, connection is hosed
16325
16527
  break;
16326
16528
  }
16327
- else if (now - startTime > minReconnectWait &&
16328
- this.primaryPC?.connectionState === 'connected') {
16329
- 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
+ }
16330
16542
  }
16331
- if (this.pcConnected) {
16543
+ if (this.pcState === PCState.Connected) {
16332
16544
  return;
16333
16545
  }
16334
16546
  await sleep(100);
16335
- now = new Date().getTime();
16547
+ now = Date.now();
16336
16548
  }
16337
16549
  // have not reconnected, throw
16338
16550
  throw new ConnectionError('could not establish PC connection');
@@ -16350,6 +16562,7 @@ class RTCEngine extends events.exports.EventEmitter {
16350
16562
  }
16351
16563
  }
16352
16564
  async ensurePublisherConnected(kind) {
16565
+ var _a, _b;
16353
16566
  if (!this.subscriberPrimary) {
16354
16567
  return;
16355
16568
  }
@@ -16361,18 +16574,18 @@ class RTCEngine extends events.exports.EventEmitter {
16361
16574
  this.negotiate();
16362
16575
  }
16363
16576
  const targetChannel = this.dataChannelForKind(kind);
16364
- if (targetChannel?.readyState === 'open') {
16577
+ if ((targetChannel === null || targetChannel === void 0 ? void 0 : targetChannel.readyState) === 'open') {
16365
16578
  return;
16366
16579
  }
16367
16580
  // wait until publisher ICE connected
16368
16581
  const endTime = new Date().getTime() + maxICEConnectTimeout;
16369
16582
  while (new Date().getTime() < endTime) {
16370
- 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') {
16371
16584
  return;
16372
16585
  }
16373
16586
  await sleep(50);
16374
16587
  }
16375
- 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}`);
16376
16589
  }
16377
16590
  /** @internal */
16378
16591
  negotiate() {
@@ -16402,6 +16615,7 @@ class RTCEngine extends events.exports.EventEmitter {
16402
16615
  }
16403
16616
  }
16404
16617
  async function getConnectedAddress(pc) {
16618
+ var _a;
16405
16619
  let selectedCandidatePairId = '';
16406
16620
  const candidatePairs = new Map();
16407
16621
  // id -> candidate ip
@@ -16426,7 +16640,7 @@ async function getConnectedAddress(pc) {
16426
16640
  if (selectedCandidatePairId === '') {
16427
16641
  return undefined;
16428
16642
  }
16429
- const selectedID = candidatePairs.get(selectedCandidatePairId)?.remoteCandidateId;
16643
+ const selectedID = (_a = candidatePairs.get(selectedCandidatePairId)) === null || _a === void 0 ? void 0 : _a.remoteCandidateId;
16430
16644
  if (selectedID === undefined) {
16431
16645
  return undefined;
16432
16646
  }
@@ -16472,6 +16686,7 @@ class Room extends events.exports.EventEmitter {
16472
16686
  * @param options
16473
16687
  */
16474
16688
  constructor(options) {
16689
+ var _a, _b;
16475
16690
  super();
16476
16691
  this.state = RoomState.Disconnected;
16477
16692
  /**
@@ -16488,6 +16703,7 @@ class Room extends events.exports.EventEmitter {
16488
16703
  this.metadata = undefined;
16489
16704
  this.audioEnabled = true;
16490
16705
  this.connect = async (url, token, opts) => {
16706
+ var _a, _b;
16491
16707
  // guard against calling connect
16492
16708
  if (this.state !== RoomState.Disconnected) {
16493
16709
  livekitLogger.warn(`already connected to room ${this.name}`);
@@ -16496,12 +16712,16 @@ class Room extends events.exports.EventEmitter {
16496
16712
  // recreate engine if previously disconnected
16497
16713
  this.createEngine();
16498
16714
  this.acquireAudioContext();
16499
- if (opts?.rtcConfig) {
16715
+ if (opts === null || opts === void 0 ? void 0 : opts.rtcConfig) {
16500
16716
  this.engine.rtcConfig = opts.rtcConfig;
16501
16717
  }
16502
16718
  this.connOptions = opts;
16503
16719
  try {
16504
- const joinResponse = await this.engine.join(url, token, opts);
16720
+ const joinResponse = await this.engine.join(url, token, {
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,
16724
+ });
16505
16725
  livekitLogger.debug(`connected to Livekit Server version: ${joinResponse.serverVersion}, region: ${joinResponse.serverRegion}`);
16506
16726
  if (!joinResponse.serverVersion) {
16507
16727
  throw new UnsupportedServer('unknown server version');
@@ -16566,11 +16786,12 @@ class Room extends events.exports.EventEmitter {
16566
16786
  reject(new ConnectionError('could not connect after timeout'));
16567
16787
  }, maxICEConnectTimeout);
16568
16788
  this.engine.once(EngineEvent.Connected, () => {
16789
+ var _a;
16569
16790
  clearTimeout(connectTimeout);
16570
16791
  // also hook unload event
16571
16792
  if (isWeb()) {
16572
16793
  window.addEventListener('beforeunload', this.onBeforeUnload);
16573
- navigator.mediaDevices?.addEventListener('devicechange', this.handleDeviceChange);
16794
+ (_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.addEventListener('devicechange', this.handleDeviceChange);
16574
16795
  }
16575
16796
  resolve(this);
16576
16797
  });
@@ -16746,7 +16967,7 @@ class Room extends events.exports.EventEmitter {
16746
16967
  const participant = this.participants.get(userPacket.participantSid);
16747
16968
  this.emit(RoomEvent.DataReceived, userPacket.payload, participant, kind);
16748
16969
  // also emit on the participant
16749
- participant?.emit(ParticipantEvent.DataReceived, userPacket.payload, kind);
16970
+ participant === null || participant === void 0 ? void 0 : participant.emit(ParticipantEvent.DataReceived, userPacket.payload, kind);
16750
16971
  };
16751
16972
  this.handleAudioPlaybackStarted = () => {
16752
16973
  if (this.canPlaybackAudio) {
@@ -16784,7 +17005,7 @@ class Room extends events.exports.EventEmitter {
16784
17005
  };
16785
17006
  this.participants = new Map();
16786
17007
  this.options = options || {};
16787
- 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) {
16788
17009
  case 'av1':
16789
17010
  case 'vp9':
16790
17011
  this.options.publishDefaults.simulcast = undefined;
@@ -16792,15 +17013,15 @@ class Room extends events.exports.EventEmitter {
16792
17013
  }
16793
17014
  this.options.audioCaptureDefaults = {
16794
17015
  ...audioDefaults,
16795
- ...options?.audioCaptureDefaults,
17016
+ ...options === null || options === void 0 ? void 0 : options.audioCaptureDefaults,
16796
17017
  };
16797
17018
  this.options.videoCaptureDefaults = {
16798
17019
  ...videoDefaults,
16799
- ...options?.videoCaptureDefaults,
17020
+ ...options === null || options === void 0 ? void 0 : options.videoCaptureDefaults,
16800
17021
  };
16801
17022
  this.options.publishDefaults = {
16802
17023
  ...publishDefaults,
16803
- ...options?.publishDefaults,
17024
+ ...options === null || options === void 0 ? void 0 : options.publishDefaults,
16804
17025
  };
16805
17026
  this.createEngine();
16806
17027
  this.localParticipant = new LocalParticipant('', '', this.engine, this.options);
@@ -16949,12 +17170,12 @@ class Room extends events.exports.EventEmitter {
16949
17170
  async switchActiveDevice(kind, deviceId) {
16950
17171
  if (kind === 'audioinput') {
16951
17172
  const tracks = Array.from(this.localParticipant.audioTracks.values()).filter((track) => track.source === Track.Source.Microphone);
16952
- 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); }));
16953
17174
  this.options.audioCaptureDefaults.deviceId = deviceId;
16954
17175
  }
16955
17176
  else if (kind === 'videoinput') {
16956
17177
  const tracks = Array.from(this.localParticipant.videoTracks.values()).filter((track) => track.source === Track.Source.Camera);
16957
- 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); }));
16958
17179
  this.options.videoCaptureDefaults.deviceId = deviceId;
16959
17180
  }
16960
17181
  else if (kind === 'audiooutput') {
@@ -16995,6 +17216,7 @@ class Room extends events.exports.EventEmitter {
16995
17216
  participant.addSubscribedMediaTrack(mediaTrack, trackId, stream, receiver, adaptiveStreamSettings);
16996
17217
  }
16997
17218
  handleDisconnect(shouldStopTracks = true) {
17219
+ var _a;
16998
17220
  if (this.state === RoomState.Disconnected) {
16999
17221
  return;
17000
17222
  }
@@ -17004,12 +17226,13 @@ class Room extends events.exports.EventEmitter {
17004
17226
  });
17005
17227
  });
17006
17228
  this.localParticipant.tracks.forEach((pub) => {
17229
+ var _a, _b;
17007
17230
  if (pub.track) {
17008
17231
  this.localParticipant.unpublishTrack(pub.track);
17009
17232
  }
17010
17233
  if (shouldStopTracks) {
17011
- pub.track?.detach();
17012
- 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();
17013
17236
  }
17014
17237
  });
17015
17238
  this.participants.clear();
@@ -17020,7 +17243,7 @@ class Room extends events.exports.EventEmitter {
17020
17243
  }
17021
17244
  if (isWeb()) {
17022
17245
  window.removeEventListener('beforeunload', this.onBeforeUnload);
17023
- navigator.mediaDevices?.removeEventListener('devicechange', this.handleDeviceChange);
17246
+ (_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.removeEventListener('devicechange', this.handleDeviceChange);
17024
17247
  }
17025
17248
  this.state = RoomState.Disconnected;
17026
17249
  this.emit(RoomEvent.Disconnected);
@@ -17111,6 +17334,7 @@ class Room extends events.exports.EventEmitter {
17111
17334
  return participant;
17112
17335
  }
17113
17336
  sendSyncState() {
17337
+ var _a;
17114
17338
  if (this.engine.subscriber === undefined ||
17115
17339
  this.engine.subscriber.pc.localDescription === null) {
17116
17340
  return;
@@ -17121,7 +17345,7 @@ class Room extends events.exports.EventEmitter {
17121
17345
  subscribe pc and unsub special tracks from it.
17122
17346
  2. autosubscribe off, we send subscribed tracks.
17123
17347
  */
17124
- const sendUnsub = this.connOptions?.autoSubscribe || false;
17348
+ const sendUnsub = ((_a = this.connOptions) === null || _a === void 0 ? void 0 : _a.autoSubscribe) || false;
17125
17349
  const trackSids = new Array();
17126
17350
  this.participants.forEach((participant) => {
17127
17351
  participant.tracks.forEach((track) => {
@@ -17184,20 +17408,21 @@ class Room extends events.exports.EventEmitter {
17184
17408
  * @param options
17185
17409
  */
17186
17410
  async function connect(url, token, options) {
17187
- options ??= {};
17411
+ var _a, _b, _c, _d;
17412
+ options !== null && options !== void 0 ? options : (options = {});
17188
17413
  if (options.adaptiveStream === undefined) {
17189
17414
  options.adaptiveStream = options.autoManageVideo === true ? {} : undefined;
17190
17415
  }
17191
- setLogLevel(options.logLevel ?? LogLevel.warn);
17192
- 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 : {};
17193
17418
  if (options.iceServers) {
17194
17419
  config.iceServers = options.iceServers;
17195
17420
  }
17196
17421
  const room = new Room(options);
17197
17422
  // connect to room
17198
17423
  await room.connect(url, token, options);
17199
- const publishAudio = options.audio ?? false;
17200
- 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;
17201
17426
  if (publishAudio || publishVideo) {
17202
17427
  setTimeout(async () => {
17203
17428
  // if publishing both
@@ -17259,10 +17484,11 @@ async function connect(url, token, options) {
17259
17484
  * @param options
17260
17485
  */
17261
17486
  async function createLocalTracks(options) {
17487
+ var _a, _b;
17262
17488
  // set default options to true
17263
- options ??= {};
17264
- options.audio ??= true;
17265
- 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);
17266
17492
  const opts = mergeDefaultOptions(options, audioDefaults, videoDefaults);
17267
17493
  const constraints = constraintsForOptions(opts);
17268
17494
  const stream = await navigator.mediaDevices.getUserMedia(constraints);
@@ -17309,6 +17535,7 @@ async function createLocalAudioTrack(options) {
17309
17535
  * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
17310
17536
  */
17311
17537
  async function createLocalScreenTracks(options) {
17538
+ var _a;
17312
17539
  if (options === undefined) {
17313
17540
  options = {};
17314
17541
  }
@@ -17325,7 +17552,7 @@ async function createLocalScreenTracks(options) {
17325
17552
  // typescript definition is missing getDisplayMedia: https://github.com/microsoft/TypeScript/issues/33232
17326
17553
  // @ts-ignore
17327
17554
  const stream = await navigator.mediaDevices.getDisplayMedia({
17328
- audio: options.audio ?? false,
17555
+ audio: (_a = options.audio) !== null && _a !== void 0 ? _a : false,
17329
17556
  video: videoConstraints,
17330
17557
  });
17331
17558
  const tracks = stream.getVideoTracks();