livekit-client 2.18.1 → 2.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/livekit-client.esm.mjs +533 -344
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/connectionHelper/ConnectionCheck.d.ts +1 -1
  6. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
  7. package/dist/src/index.d.ts +1 -0
  8. package/dist/src/index.d.ts.map +1 -1
  9. package/dist/src/room/RTCEngine.d.ts +6 -5
  10. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  11. package/dist/src/room/Room.d.ts +1 -0
  12. package/dist/src/room/Room.d.ts.map +1 -1
  13. package/dist/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts +5 -1
  14. package/dist/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts.map +1 -1
  15. package/dist/src/room/data-track/incoming/IncomingDataTrackManager.d.ts.map +1 -1
  16. package/dist/src/room/participant/LocalParticipant.d.ts +1 -0
  17. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  18. package/dist/src/utils/serializer.d.ts +48 -0
  19. package/dist/src/utils/serializer.d.ts.map +1 -0
  20. package/dist/ts4.2/connectionHelper/ConnectionCheck.d.ts +2 -1
  21. package/dist/ts4.2/index.d.ts +2 -0
  22. package/dist/ts4.2/room/RTCEngine.d.ts +6 -5
  23. package/dist/ts4.2/room/Room.d.ts +1 -0
  24. package/dist/ts4.2/room/data-stream/incoming/IncomingDataStreamManager.d.ts +5 -1
  25. package/dist/ts4.2/room/participant/LocalParticipant.d.ts +1 -0
  26. package/dist/ts4.2/utils/serializer.d.ts +48 -0
  27. package/package.json +2 -2
  28. package/src/connectionHelper/ConnectionCheck.ts +1 -1
  29. package/src/index.ts +7 -0
  30. package/src/room/RTCEngine.ts +47 -15
  31. package/src/room/Room.ts +19 -23
  32. package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +26 -2
  33. package/src/room/data-track/incoming/IncomingDataTrackManager.ts +7 -0
  34. package/src/room/participant/LocalParticipant.ts +17 -2
  35. package/src/room/token-source/utils.ts +3 -3
  36. package/src/utils/serializer.ts +72 -0
@@ -3869,6 +3869,9 @@ const DisconnectReason = /* @__PURE__ */proto3.makeEnum("livekit.DisconnectReaso
3869
3869
  }, {
3870
3870
  no: 15,
3871
3871
  name: "MEDIA_FAILURE"
3872
+ }, {
3873
+ no: 16,
3874
+ name: "AGENT_ERROR"
3872
3875
  }]);
3873
3876
  const ReconnectReason = /* @__PURE__ */proto3.makeEnum("livekit.ReconnectReason", [{
3874
3877
  no: 0,
@@ -3918,6 +3921,13 @@ const AudioTrackFeature = /* @__PURE__ */proto3.makeEnum("livekit.AudioTrackFeat
3918
3921
  no: 6,
3919
3922
  name: "TF_PRECONNECT_BUFFER"
3920
3923
  }]);
3924
+ const PacketTrailerFeature = /* @__PURE__ */proto3.makeEnum("livekit.PacketTrailerFeature", [{
3925
+ no: 0,
3926
+ name: "PTF_USER_TIMESTAMP"
3927
+ }, {
3928
+ no: 1,
3929
+ name: "PTF_FRAME_ID"
3930
+ }]);
3921
3931
  const Room$1 = /* @__PURE__ */proto3.makeMessageType("livekit.Room", () => [{
3922
3932
  no: 1,
3923
3933
  name: "sid",
@@ -4069,6 +4079,12 @@ const ParticipantPermission = /* @__PURE__ */proto3.makeMessageType("livekit.Par
4069
4079
  kind: "scalar",
4070
4080
  T: 8
4071
4081
  /* ScalarType.BOOL */
4082
+ }, {
4083
+ no: 13,
4084
+ name: "can_manage_agent_session",
4085
+ kind: "scalar",
4086
+ T: 8
4087
+ /* ScalarType.BOOL */
4072
4088
  }]);
4073
4089
  const ParticipantInfo = /* @__PURE__ */proto3.makeMessageType("livekit.ParticipantInfo", () => [{
4074
4090
  no: 1,
@@ -4172,6 +4188,12 @@ const ParticipantInfo = /* @__PURE__ */proto3.makeMessageType("livekit.Participa
4172
4188
  kind: "message",
4173
4189
  T: DataTrackInfo$1,
4174
4190
  repeated: true
4191
+ }, {
4192
+ no: 20,
4193
+ name: "client_protocol",
4194
+ kind: "scalar",
4195
+ T: 5
4196
+ /* ScalarType.INT32 */
4175
4197
  }]);
4176
4198
  const ParticipantInfo_State = /* @__PURE__ */proto3.makeEnum("livekit.ParticipantInfo.State", [{
4177
4199
  no: 0,
@@ -4385,6 +4407,12 @@ const TrackInfo = /* @__PURE__ */proto3.makeMessageType("livekit.TrackInfo", ()
4385
4407
  name: "backup_codec_policy",
4386
4408
  kind: "enum",
4387
4409
  T: proto3.getEnumType(BackupCodecPolicy$1)
4410
+ }, {
4411
+ no: 21,
4412
+ name: "packet_trailer_features",
4413
+ kind: "enum",
4414
+ T: proto3.getEnumType(PacketTrailerFeature),
4415
+ repeated: true
4388
4416
  }]);
4389
4417
  const DataTrackInfo$1 = /* @__PURE__ */proto3.makeMessageType("livekit.DataTrackInfo", () => [{
4390
4418
  no: 1,
@@ -4889,6 +4917,12 @@ const RpcRequest = /* @__PURE__ */proto3.makeMessageType("livekit.RpcRequest", (
4889
4917
  kind: "scalar",
4890
4918
  T: 13
4891
4919
  /* ScalarType.UINT32 */
4920
+ }, {
4921
+ no: 6,
4922
+ name: "compressed_payload",
4923
+ kind: "scalar",
4924
+ T: 12
4925
+ /* ScalarType.BYTES */
4892
4926
  }]);
4893
4927
  const RpcAck = /* @__PURE__ */proto3.makeMessageType("livekit.RpcAck", () => [{
4894
4928
  no: 1,
@@ -4915,6 +4949,12 @@ const RpcResponse = /* @__PURE__ */proto3.makeMessageType("livekit.RpcResponse",
4915
4949
  kind: "message",
4916
4950
  T: RpcError$1,
4917
4951
  oneof: "value"
4952
+ }, {
4953
+ no: 4,
4954
+ name: "compressed_payload",
4955
+ kind: "scalar",
4956
+ T: 12,
4957
+ oneof: "value"
4918
4958
  }]);
4919
4959
  const RpcError$1 = /* @__PURE__ */proto3.makeMessageType("livekit.RpcError", () => [{
4920
4960
  no: 1,
@@ -5062,6 +5102,12 @@ const ClientInfo = /* @__PURE__ */proto3.makeMessageType("livekit.ClientInfo", (
5062
5102
  kind: "scalar",
5063
5103
  T: 9
5064
5104
  /* ScalarType.STRING */
5105
+ }, {
5106
+ no: 12,
5107
+ name: "client_protocol",
5108
+ kind: "scalar",
5109
+ T: 5
5110
+ /* ScalarType.INT32 */
5065
5111
  }]);
5066
5112
  const ClientInfo_SDK = /* @__PURE__ */proto3.makeEnum("livekit.ClientInfo.SDK", [{
5067
5113
  no: 0,
@@ -5383,6 +5429,13 @@ const SubscribedAudioCodec = /* @__PURE__ */proto3.makeMessageType("livekit.Subs
5383
5429
  T: 8
5384
5430
  /* ScalarType.BOOL */
5385
5431
  }]);
5432
+ const JobRestartPolicy = /* @__PURE__ */proto3.makeEnum("livekit.JobRestartPolicy", [{
5433
+ no: 0,
5434
+ name: "JRP_ON_FAILURE"
5435
+ }, {
5436
+ no: 1,
5437
+ name: "JRP_NEVER"
5438
+ }]);
5386
5439
  const RoomAgentDispatch = /* @__PURE__ */proto3.makeMessageType("livekit.RoomAgentDispatch", () => [{
5387
5440
  no: 1,
5388
5441
  name: "agent_name",
@@ -5395,6 +5448,11 @@ const RoomAgentDispatch = /* @__PURE__ */proto3.makeMessageType("livekit.RoomAge
5395
5448
  kind: "scalar",
5396
5449
  T: 9
5397
5450
  /* ScalarType.STRING */
5451
+ }, {
5452
+ no: 3,
5453
+ name: "restart_policy",
5454
+ kind: "enum",
5455
+ T: proto3.getEnumType(JobRestartPolicy)
5398
5456
  }]);
5399
5457
  const SignalTarget = /* @__PURE__ */proto3.makeEnum("livekit.SignalTarget", [{
5400
5458
  no: 0,
@@ -5832,6 +5890,12 @@ const AddTrackRequest = /* @__PURE__ */proto3.makeMessageType("livekit.AddTrackR
5832
5890
  kind: "enum",
5833
5891
  T: proto3.getEnumType(AudioTrackFeature),
5834
5892
  repeated: true
5893
+ }, {
5894
+ no: 18,
5895
+ name: "packet_trailer_features",
5896
+ kind: "enum",
5897
+ T: proto3.getEnumType(PacketTrailerFeature),
5898
+ repeated: true
5835
5899
  }]);
5836
5900
  const PublishDataTrackRequest = /* @__PURE__ */proto3.makeMessageType("livekit.PublishDataTrackRequest", () => [{
5837
5901
  no: 1,
@@ -6936,6 +7000,31 @@ const MediaSectionsRequirement = /* @__PURE__ */proto3.makeMessageType("livekit.
6936
7000
  T: 13
6937
7001
  /* ScalarType.UINT32 */
6938
7002
  }]);
7003
+ const EncodingOptionsPreset = /* @__PURE__ */proto3.makeEnum("livekit.EncodingOptionsPreset", [{
7004
+ no: 0,
7005
+ name: "H264_720P_30"
7006
+ }, {
7007
+ no: 1,
7008
+ name: "H264_720P_60"
7009
+ }, {
7010
+ no: 2,
7011
+ name: "H264_1080P_30"
7012
+ }, {
7013
+ no: 3,
7014
+ name: "H264_1080P_60"
7015
+ }, {
7016
+ no: 4,
7017
+ name: "PORTRAIT_H264_720P_30"
7018
+ }, {
7019
+ no: 5,
7020
+ name: "PORTRAIT_H264_720P_60"
7021
+ }, {
7022
+ no: 6,
7023
+ name: "PORTRAIT_H264_1080P_30"
7024
+ }, {
7025
+ no: 7,
7026
+ name: "PORTRAIT_H264_1080P_60"
7027
+ }]);
6939
7028
  const EncodedFileType = /* @__PURE__ */proto3.makeEnum("livekit.EncodedFileType", [{
6940
7029
  no: 0,
6941
7030
  name: "DEFAULT_FILETYPE"
@@ -6949,6 +7038,19 @@ const EncodedFileType = /* @__PURE__ */proto3.makeEnum("livekit.EncodedFileType"
6949
7038
  no: 3,
6950
7039
  name: "MP3"
6951
7040
  }]);
7041
+ const StreamProtocol = /* @__PURE__ */proto3.makeEnum("livekit.StreamProtocol", [{
7042
+ no: 0,
7043
+ name: "DEFAULT_PROTOCOL"
7044
+ }, {
7045
+ no: 1,
7046
+ name: "RTMP"
7047
+ }, {
7048
+ no: 2,
7049
+ name: "SRT"
7050
+ }, {
7051
+ no: 3,
7052
+ name: "WEBSOCKET"
7053
+ }]);
6952
7054
  const SegmentedFileProtocol = /* @__PURE__ */proto3.makeEnum("livekit.SegmentedFileProtocol", [{
6953
7055
  no: 0,
6954
7056
  name: "DEFAULT_SEGMENTED_FILE_PROTOCOL"
@@ -6973,16 +7075,6 @@ const ImageFileSuffix = /* @__PURE__ */proto3.makeEnum("livekit.ImageFileSuffix"
6973
7075
  no: 2,
6974
7076
  name: "IMAGE_SUFFIX_NONE_OVERWRITE"
6975
7077
  }]);
6976
- const StreamProtocol = /* @__PURE__ */proto3.makeEnum("livekit.StreamProtocol", [{
6977
- no: 0,
6978
- name: "DEFAULT_PROTOCOL"
6979
- }, {
6980
- no: 1,
6981
- name: "RTMP"
6982
- }, {
6983
- no: 2,
6984
- name: "SRT"
6985
- }]);
6986
7078
  const AudioMixing = /* @__PURE__ */proto3.makeEnum("livekit.AudioMixing", [{
6987
7079
  no: 0,
6988
7080
  name: "DEFAULT_MIXING"
@@ -6993,168 +7085,88 @@ const AudioMixing = /* @__PURE__ */proto3.makeEnum("livekit.AudioMixing", [{
6993
7085
  no: 2,
6994
7086
  name: "DUAL_CHANNEL_ALTERNATE"
6995
7087
  }]);
6996
- const EncodingOptionsPreset = /* @__PURE__ */proto3.makeEnum("livekit.EncodingOptionsPreset", [{
6997
- no: 0,
6998
- name: "H264_720P_30"
6999
- }, {
7000
- no: 1,
7001
- name: "H264_720P_60"
7002
- }, {
7003
- no: 2,
7004
- name: "H264_1080P_30"
7005
- }, {
7006
- no: 3,
7007
- name: "H264_1080P_60"
7008
- }, {
7009
- no: 4,
7010
- name: "PORTRAIT_H264_720P_30"
7011
- }, {
7012
- no: 5,
7013
- name: "PORTRAIT_H264_720P_60"
7014
- }, {
7015
- no: 6,
7016
- name: "PORTRAIT_H264_1080P_30"
7017
- }, {
7018
- no: 7,
7019
- name: "PORTRAIT_H264_1080P_60"
7020
- }]);
7021
- const RoomCompositeEgressRequest = /* @__PURE__ */proto3.makeMessageType("livekit.RoomCompositeEgressRequest", () => [{
7088
+ const EncodingOptions = /* @__PURE__ */proto3.makeMessageType("livekit.EncodingOptions", () => [{
7022
7089
  no: 1,
7023
- name: "room_name",
7090
+ name: "width",
7024
7091
  kind: "scalar",
7025
- T: 9
7026
- /* ScalarType.STRING */
7092
+ T: 5
7093
+ /* ScalarType.INT32 */
7027
7094
  }, {
7028
7095
  no: 2,
7029
- name: "layout",
7096
+ name: "height",
7030
7097
  kind: "scalar",
7031
- T: 9
7032
- /* ScalarType.STRING */
7098
+ T: 5
7099
+ /* ScalarType.INT32 */
7033
7100
  }, {
7034
7101
  no: 3,
7035
- name: "audio_only",
7102
+ name: "depth",
7036
7103
  kind: "scalar",
7037
- T: 8
7038
- /* ScalarType.BOOL */
7039
- }, {
7040
- no: 15,
7041
- name: "audio_mixing",
7042
- kind: "enum",
7043
- T: proto3.getEnumType(AudioMixing)
7104
+ T: 5
7105
+ /* ScalarType.INT32 */
7044
7106
  }, {
7045
7107
  no: 4,
7046
- name: "video_only",
7108
+ name: "framerate",
7047
7109
  kind: "scalar",
7048
- T: 8
7049
- /* ScalarType.BOOL */
7110
+ T: 5
7111
+ /* ScalarType.INT32 */
7050
7112
  }, {
7051
7113
  no: 5,
7052
- name: "custom_base_url",
7053
- kind: "scalar",
7054
- T: 9
7055
- /* ScalarType.STRING */
7114
+ name: "audio_codec",
7115
+ kind: "enum",
7116
+ T: proto3.getEnumType(AudioCodec)
7056
7117
  }, {
7057
7118
  no: 6,
7058
- name: "file",
7059
- kind: "message",
7060
- T: EncodedFileOutput,
7061
- oneof: "output"
7119
+ name: "audio_bitrate",
7120
+ kind: "scalar",
7121
+ T: 5
7122
+ /* ScalarType.INT32 */
7062
7123
  }, {
7063
7124
  no: 7,
7064
- name: "stream",
7065
- kind: "message",
7066
- T: StreamOutput,
7067
- oneof: "output"
7068
- }, {
7069
- no: 10,
7070
- name: "segments",
7071
- kind: "message",
7072
- T: SegmentedFileOutput,
7073
- oneof: "output"
7125
+ name: "audio_frequency",
7126
+ kind: "scalar",
7127
+ T: 5
7128
+ /* ScalarType.INT32 */
7074
7129
  }, {
7075
7130
  no: 8,
7076
- name: "preset",
7131
+ name: "video_codec",
7077
7132
  kind: "enum",
7078
- T: proto3.getEnumType(EncodingOptionsPreset),
7079
- oneof: "options"
7133
+ T: proto3.getEnumType(VideoCodec)
7080
7134
  }, {
7081
7135
  no: 9,
7082
- name: "advanced",
7083
- kind: "message",
7084
- T: EncodingOptions,
7085
- oneof: "options"
7136
+ name: "video_bitrate",
7137
+ kind: "scalar",
7138
+ T: 5
7139
+ /* ScalarType.INT32 */
7140
+ }, {
7141
+ no: 10,
7142
+ name: "key_frame_interval",
7143
+ kind: "scalar",
7144
+ T: 1
7145
+ /* ScalarType.DOUBLE */
7086
7146
  }, {
7087
7147
  no: 11,
7088
- name: "file_outputs",
7089
- kind: "message",
7090
- T: EncodedFileOutput,
7091
- repeated: true
7148
+ name: "audio_quality",
7149
+ kind: "scalar",
7150
+ T: 5
7151
+ /* ScalarType.INT32 */
7092
7152
  }, {
7093
7153
  no: 12,
7094
- name: "stream_outputs",
7095
- kind: "message",
7096
- T: StreamOutput,
7097
- repeated: true
7098
- }, {
7099
- no: 13,
7100
- name: "segment_outputs",
7101
- kind: "message",
7102
- T: SegmentedFileOutput,
7103
- repeated: true
7104
- }, {
7105
- no: 14,
7106
- name: "image_outputs",
7107
- kind: "message",
7108
- T: ImageOutput,
7109
- repeated: true
7110
- }, {
7111
- no: 16,
7112
- name: "webhooks",
7113
- kind: "message",
7114
- T: WebhookConfig,
7115
- repeated: true
7154
+ name: "video_quality",
7155
+ kind: "scalar",
7156
+ T: 5
7157
+ /* ScalarType.INT32 */
7116
7158
  }]);
7117
- const EncodedFileOutput = /* @__PURE__ */proto3.makeMessageType("livekit.EncodedFileOutput", () => [{
7159
+ const StreamOutput = /* @__PURE__ */proto3.makeMessageType("livekit.StreamOutput", () => [{
7118
7160
  no: 1,
7119
- name: "file_type",
7161
+ name: "protocol",
7120
7162
  kind: "enum",
7121
- T: proto3.getEnumType(EncodedFileType)
7163
+ T: proto3.getEnumType(StreamProtocol)
7122
7164
  }, {
7123
7165
  no: 2,
7124
- name: "filepath",
7125
- kind: "scalar",
7126
- T: 9
7127
- /* ScalarType.STRING */
7128
- }, {
7129
- no: 6,
7130
- name: "disable_manifest",
7166
+ name: "urls",
7131
7167
  kind: "scalar",
7132
- T: 8
7133
- /* ScalarType.BOOL */
7134
- }, {
7135
- no: 3,
7136
- name: "s3",
7137
- kind: "message",
7138
- T: S3Upload,
7139
- oneof: "output"
7140
- }, {
7141
- no: 4,
7142
- name: "gcp",
7143
- kind: "message",
7144
- T: GCPUpload,
7145
- oneof: "output"
7146
- }, {
7147
- no: 5,
7148
- name: "azure",
7149
- kind: "message",
7150
- T: AzureBlobUpload,
7151
- oneof: "output"
7152
- }, {
7153
- no: 7,
7154
- name: "aliOSS",
7155
- kind: "message",
7156
- T: AliOSSUpload,
7157
- oneof: "output"
7168
+ T: 9,
7169
+ repeated: true
7158
7170
  }]);
7159
7171
  const SegmentedFileOutput = /* @__PURE__ */proto3.makeMessageType("livekit.SegmentedFileOutput", () => [{
7160
7172
  no: 1,
@@ -7455,146 +7467,201 @@ const ProxyConfig = /* @__PURE__ */proto3.makeMessageType("livekit.ProxyConfig",
7455
7467
  T: 9
7456
7468
  /* ScalarType.STRING */
7457
7469
  }]);
7458
- const StreamOutput = /* @__PURE__ */proto3.makeMessageType("livekit.StreamOutput", () => [{
7470
+ const AutoParticipantEgress = /* @__PURE__ */proto3.makeMessageType("livekit.AutoParticipantEgress", () => [{
7459
7471
  no: 1,
7460
- name: "protocol",
7472
+ name: "preset",
7461
7473
  kind: "enum",
7462
- T: proto3.getEnumType(StreamProtocol)
7474
+ T: proto3.getEnumType(EncodingOptionsPreset),
7475
+ oneof: "options"
7463
7476
  }, {
7464
7477
  no: 2,
7465
- name: "urls",
7466
- kind: "scalar",
7467
- T: 9,
7478
+ name: "advanced",
7479
+ kind: "message",
7480
+ T: EncodingOptions,
7481
+ oneof: "options"
7482
+ }, {
7483
+ no: 3,
7484
+ name: "file_outputs",
7485
+ kind: "message",
7486
+ T: EncodedFileOutput,
7487
+ repeated: true
7488
+ }, {
7489
+ no: 4,
7490
+ name: "segment_outputs",
7491
+ kind: "message",
7492
+ T: SegmentedFileOutput,
7468
7493
  repeated: true
7469
7494
  }]);
7470
- const EncodingOptions = /* @__PURE__ */proto3.makeMessageType("livekit.EncodingOptions", () => [{
7495
+ const AutoTrackEgress = /* @__PURE__ */proto3.makeMessageType("livekit.AutoTrackEgress", () => [{
7471
7496
  no: 1,
7472
- name: "width",
7497
+ name: "filepath",
7498
+ kind: "scalar",
7499
+ T: 9
7500
+ /* ScalarType.STRING */
7501
+ }, {
7502
+ no: 5,
7503
+ name: "disable_manifest",
7504
+ kind: "scalar",
7505
+ T: 8
7506
+ /* ScalarType.BOOL */
7507
+ }, {
7508
+ no: 2,
7509
+ name: "s3",
7510
+ kind: "message",
7511
+ T: S3Upload,
7512
+ oneof: "output"
7513
+ }, {
7514
+ no: 3,
7515
+ name: "gcp",
7516
+ kind: "message",
7517
+ T: GCPUpload,
7518
+ oneof: "output"
7519
+ }, {
7520
+ no: 4,
7521
+ name: "azure",
7522
+ kind: "message",
7523
+ T: AzureBlobUpload,
7524
+ oneof: "output"
7525
+ }, {
7526
+ no: 6,
7527
+ name: "aliOSS",
7528
+ kind: "message",
7529
+ T: AliOSSUpload,
7530
+ oneof: "output"
7531
+ }]);
7532
+ const RoomCompositeEgressRequest = /* @__PURE__ */proto3.makeMessageType("livekit.RoomCompositeEgressRequest", () => [{
7533
+ no: 1,
7534
+ name: "room_name",
7473
7535
  kind: "scalar",
7474
- T: 5
7475
- /* ScalarType.INT32 */
7536
+ T: 9
7537
+ /* ScalarType.STRING */
7476
7538
  }, {
7477
7539
  no: 2,
7478
- name: "height",
7540
+ name: "layout",
7479
7541
  kind: "scalar",
7480
- T: 5
7481
- /* ScalarType.INT32 */
7542
+ T: 9
7543
+ /* ScalarType.STRING */
7482
7544
  }, {
7483
7545
  no: 3,
7484
- name: "depth",
7546
+ name: "audio_only",
7485
7547
  kind: "scalar",
7486
- T: 5
7487
- /* ScalarType.INT32 */
7548
+ T: 8
7549
+ /* ScalarType.BOOL */
7550
+ }, {
7551
+ no: 15,
7552
+ name: "audio_mixing",
7553
+ kind: "enum",
7554
+ T: proto3.getEnumType(AudioMixing)
7488
7555
  }, {
7489
7556
  no: 4,
7490
- name: "framerate",
7557
+ name: "video_only",
7491
7558
  kind: "scalar",
7492
- T: 5
7493
- /* ScalarType.INT32 */
7559
+ T: 8
7560
+ /* ScalarType.BOOL */
7494
7561
  }, {
7495
7562
  no: 5,
7496
- name: "audio_codec",
7497
- kind: "enum",
7498
- T: proto3.getEnumType(AudioCodec)
7499
- }, {
7500
- no: 6,
7501
- name: "audio_bitrate",
7563
+ name: "custom_base_url",
7502
7564
  kind: "scalar",
7503
- T: 5
7504
- /* ScalarType.INT32 */
7565
+ T: 9
7566
+ /* ScalarType.STRING */
7505
7567
  }, {
7506
- no: 11,
7507
- name: "audio_quality",
7508
- kind: "scalar",
7509
- T: 5
7510
- /* ScalarType.INT32 */
7568
+ no: 6,
7569
+ name: "file",
7570
+ kind: "message",
7571
+ T: EncodedFileOutput,
7572
+ oneof: "output"
7511
7573
  }, {
7512
7574
  no: 7,
7513
- name: "audio_frequency",
7514
- kind: "scalar",
7515
- T: 5
7516
- /* ScalarType.INT32 */
7517
- }, {
7518
- no: 8,
7519
- name: "video_codec",
7520
- kind: "enum",
7521
- T: proto3.getEnumType(VideoCodec)
7522
- }, {
7523
- no: 9,
7524
- name: "video_bitrate",
7525
- kind: "scalar",
7526
- T: 5
7527
- /* ScalarType.INT32 */
7528
- }, {
7529
- no: 12,
7530
- name: "video_quality",
7531
- kind: "scalar",
7532
- T: 5
7533
- /* ScalarType.INT32 */
7575
+ name: "stream",
7576
+ kind: "message",
7577
+ T: StreamOutput,
7578
+ oneof: "output"
7534
7579
  }, {
7535
7580
  no: 10,
7536
- name: "key_frame_interval",
7537
- kind: "scalar",
7538
- T: 1
7539
- /* ScalarType.DOUBLE */
7540
- }]);
7541
- const AutoParticipantEgress = /* @__PURE__ */proto3.makeMessageType("livekit.AutoParticipantEgress", () => [{
7542
- no: 1,
7581
+ name: "segments",
7582
+ kind: "message",
7583
+ T: SegmentedFileOutput,
7584
+ oneof: "output"
7585
+ }, {
7586
+ no: 8,
7543
7587
  name: "preset",
7544
7588
  kind: "enum",
7545
7589
  T: proto3.getEnumType(EncodingOptionsPreset),
7546
7590
  oneof: "options"
7547
7591
  }, {
7548
- no: 2,
7592
+ no: 9,
7549
7593
  name: "advanced",
7550
7594
  kind: "message",
7551
7595
  T: EncodingOptions,
7552
7596
  oneof: "options"
7553
7597
  }, {
7554
- no: 3,
7598
+ no: 11,
7555
7599
  name: "file_outputs",
7556
7600
  kind: "message",
7557
7601
  T: EncodedFileOutput,
7558
7602
  repeated: true
7559
7603
  }, {
7560
- no: 4,
7604
+ no: 12,
7605
+ name: "stream_outputs",
7606
+ kind: "message",
7607
+ T: StreamOutput,
7608
+ repeated: true
7609
+ }, {
7610
+ no: 13,
7561
7611
  name: "segment_outputs",
7562
7612
  kind: "message",
7563
7613
  T: SegmentedFileOutput,
7564
7614
  repeated: true
7615
+ }, {
7616
+ no: 14,
7617
+ name: "image_outputs",
7618
+ kind: "message",
7619
+ T: ImageOutput,
7620
+ repeated: true
7621
+ }, {
7622
+ no: 16,
7623
+ name: "webhooks",
7624
+ kind: "message",
7625
+ T: WebhookConfig,
7626
+ repeated: true
7565
7627
  }]);
7566
- const AutoTrackEgress = /* @__PURE__ */proto3.makeMessageType("livekit.AutoTrackEgress", () => [{
7628
+ const EncodedFileOutput = /* @__PURE__ */proto3.makeMessageType("livekit.EncodedFileOutput", () => [{
7567
7629
  no: 1,
7630
+ name: "file_type",
7631
+ kind: "enum",
7632
+ T: proto3.getEnumType(EncodedFileType)
7633
+ }, {
7634
+ no: 2,
7568
7635
  name: "filepath",
7569
7636
  kind: "scalar",
7570
7637
  T: 9
7571
7638
  /* ScalarType.STRING */
7572
7639
  }, {
7573
- no: 5,
7640
+ no: 6,
7574
7641
  name: "disable_manifest",
7575
7642
  kind: "scalar",
7576
7643
  T: 8
7577
7644
  /* ScalarType.BOOL */
7578
7645
  }, {
7579
- no: 2,
7646
+ no: 3,
7580
7647
  name: "s3",
7581
7648
  kind: "message",
7582
7649
  T: S3Upload,
7583
7650
  oneof: "output"
7584
7651
  }, {
7585
- no: 3,
7652
+ no: 4,
7586
7653
  name: "gcp",
7587
7654
  kind: "message",
7588
7655
  T: GCPUpload,
7589
7656
  oneof: "output"
7590
7657
  }, {
7591
- no: 4,
7658
+ no: 5,
7592
7659
  name: "azure",
7593
7660
  kind: "message",
7594
7661
  T: AzureBlobUpload,
7595
7662
  oneof: "output"
7596
7663
  }, {
7597
- no: 6,
7664
+ no: 7,
7598
7665
  name: "aliOSS",
7599
7666
  kind: "message",
7600
7667
  T: AliOSSUpload,
@@ -7675,6 +7742,16 @@ const RoomConfiguration = /* @__PURE__ */proto3.makeMessageType("livekit.RoomCon
7675
7742
  kind: "message",
7676
7743
  T: RoomAgentDispatch,
7677
7744
  repeated: true
7745
+ }, {
7746
+ no: 12,
7747
+ name: "tags",
7748
+ kind: "map",
7749
+ K: 9,
7750
+ V: {
7751
+ kind: "scalar",
7752
+ T: 9
7753
+ /* ScalarType.STRING */
7754
+ }
7678
7755
  }]);
7679
7756
  const TokenSourceRequest = /* @__PURE__ */proto3.makeMessageType("livekit.TokenSourceRequest", () => [{
7680
7757
  no: 1,
@@ -11629,7 +11706,7 @@ function getMatch(exp, ua) {
11629
11706
  }
11630
11707
  function getOSVersion(ua) {
11631
11708
  return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
11632
- }var version$1 = "2.18.1";const version = version$1;
11709
+ }var version$1 = "2.18.3";const version = version$1;
11633
11710
  const protocolVersion = 16;/** Base error that all LiveKit specific custom errors inherit from. */
11634
11711
  class LivekitError extends Error {
11635
11712
  constructor(code, message, options) {
@@ -20533,7 +20610,7 @@ class RTCEngine extends eventsExports.EventEmitter {
20533
20610
  var _this2 = this;
20534
20611
  let useV0Path = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
20535
20612
  return function* () {
20536
- var _a, _b, _c;
20613
+ var _a, _b, _c, _d, _e, _f;
20537
20614
  _this2._isNewlyCreated = false;
20538
20615
  _this2.url = url;
20539
20616
  _this2.token = token;
@@ -20578,7 +20655,25 @@ class RTCEngine extends eventsExports.EventEmitter {
20578
20655
  _this2.registerOnLineListener();
20579
20656
  _this2.clientConfiguration = joinResponse.clientConfiguration;
20580
20657
  _this2.emit(EngineEvent.SignalConnected, joinResponse);
20581
- return joinResponse;
20658
+ let serverInfo = joinResponse.serverInfo;
20659
+ if (!serverInfo) {
20660
+ serverInfo = {
20661
+ version: joinResponse.serverVersion,
20662
+ region: joinResponse.serverRegion
20663
+ };
20664
+ }
20665
+ _this2.log.debug("connected to Livekit Server ".concat(Object.entries(serverInfo).map(_ref2 => {
20666
+ let [key, value] = _ref2;
20667
+ return "".concat(key, ": ").concat(value);
20668
+ }).join(', ')), {
20669
+ room: (_d = joinResponse.room) === null || _d === void 0 ? void 0 : _d.name,
20670
+ roomSid: (_e = joinResponse.room) === null || _e === void 0 ? void 0 : _e.sid,
20671
+ identity: (_f = joinResponse.participant) === null || _f === void 0 ? void 0 : _f.identity
20672
+ });
20673
+ return {
20674
+ joinResponse,
20675
+ serverInfo
20676
+ };
20582
20677
  } catch (e) {
20583
20678
  if (e instanceof ConnectionError) {
20584
20679
  if (e.reason === ConnectionErrorReason.ServerUnreachable) {
@@ -21179,7 +21274,7 @@ class RTCEngine extends eventsExports.EventEmitter {
21179
21274
  throw new SignalReconnectError();
21180
21275
  }
21181
21276
  // in case a regionUrl is passed, the region URL takes precedence
21182
- joinResponse = yield this.join(regionUrl !== null && regionUrl !== void 0 ? regionUrl : this.url, this.token, this.signalOpts, undefined, !this.options.singlePeerConnection);
21277
+ joinResponse = (yield this.join(regionUrl !== null && regionUrl !== void 0 ? regionUrl : this.url, this.token, this.signalOpts, undefined, !this.options.singlePeerConnection)).joinResponse;
21183
21278
  } catch (e) {
21184
21279
  if (e instanceof ConnectionError && e.reason === ConnectionErrorReason.NotAllowed) {
21185
21280
  throw new UnexpectedConnectionState('could not reconnect, token might be expired');
@@ -21441,19 +21536,30 @@ class RTCEngine extends eventsExports.EventEmitter {
21441
21536
  });
21442
21537
  }
21443
21538
  waitForBufferStatusLow(kind) {
21444
- return new TypedPromise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
21445
- if (this.isBufferStatusLow(kind)) {
21446
- resolve();
21447
- } else {
21448
- const onClosing = () => reject(new UnexpectedConnectionState('engine closed'));
21449
- this.once(EngineEvent.Closing, onClosing);
21450
- while (!this.dcBufferStatus.get(kind)) {
21451
- yield sleep(10);
21539
+ return __awaiter(this, void 0, void 0, function* () {
21540
+ return new TypedPromise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
21541
+ if (this.isClosed) {
21542
+ reject(new UnexpectedConnectionState('engine closed'));
21452
21543
  }
21453
- this.off(EngineEvent.Closing, onClosing);
21454
- resolve();
21455
- }
21456
- }));
21544
+ if (this.isBufferStatusLow(kind)) {
21545
+ resolve();
21546
+ } else {
21547
+ const onClosing = () => reject(new UnexpectedConnectionState('engine closed'));
21548
+ this.once(EngineEvent.Closing, onClosing);
21549
+ const dc = this.dataChannelForKind(kind);
21550
+ if (!dc) {
21551
+ reject(new UnexpectedConnectionState("DataChannel not found, kind: ".concat(kind)));
21552
+ return;
21553
+ }
21554
+ dc.addEventListener('bufferedamountlow', () => {
21555
+ this.off(EngineEvent.Closing, onClosing);
21556
+ resolve();
21557
+ }, {
21558
+ once: true
21559
+ });
21560
+ }
21561
+ }));
21562
+ });
21457
21563
  }
21458
21564
  /**
21459
21565
  * @internal
@@ -21719,8 +21825,8 @@ class RTCEngine extends eventsExports.EventEmitter {
21719
21825
  var _a;
21720
21826
  const mid = (_a = this.pcManager) === null || _a === void 0 ? void 0 : _a.getMidForReceiver(receiver);
21721
21827
  if (mid) {
21722
- const match = Object.entries(this.midToTrackId).find(_ref2 => {
21723
- let [key] = _ref2;
21828
+ const match = Object.entries(this.midToTrackId).find(_ref3 => {
21829
+ let [key] = _ref3;
21724
21830
  return key === mid;
21725
21831
  });
21726
21832
  if (match) {
@@ -22017,6 +22123,24 @@ class TextStreamReader extends BaseStreamReader {
22017
22123
  this.textStreamControllers = new Map();
22018
22124
  this.byteStreamHandlers = new Map();
22019
22125
  this.textStreamHandlers = new Map();
22126
+ this.isConnected = false;
22127
+ this.bufferedPackets = [];
22128
+ }
22129
+ setConnected(connected) {
22130
+ this.isConnected = connected;
22131
+ if (connected) {
22132
+ this.flushBufferedPackets();
22133
+ }
22134
+ }
22135
+ flushBufferedPackets() {
22136
+ const packets = this.bufferedPackets;
22137
+ this.bufferedPackets = [];
22138
+ for (const {
22139
+ packet,
22140
+ encryptionType
22141
+ } of packets) {
22142
+ this.handleDataStreamPacket(packet, encryptionType);
22143
+ }
22020
22144
  }
22021
22145
  registerTextStreamHandler(topic, callback) {
22022
22146
  if (this.textStreamHandlers.has(topic)) {
@@ -22039,6 +22163,7 @@ class TextStreamReader extends BaseStreamReader {
22039
22163
  clearControllers() {
22040
22164
  this.byteStreamControllers.clear();
22041
22165
  this.textStreamControllers.clear();
22166
+ this.bufferedPackets = [];
22042
22167
  }
22043
22168
  validateParticipantHasNoActiveDataStreams(participantIdentity) {
22044
22169
  // Terminate any in flight data stream receives from the given participant
@@ -22057,92 +22182,95 @@ class TextStreamReader extends BaseStreamReader {
22057
22182
  }
22058
22183
  }
22059
22184
  handleDataStreamPacket(packet, encryptionType) {
22060
- return __awaiter(this, void 0, void 0, function* () {
22061
- switch (packet.value.case) {
22062
- case 'streamHeader':
22063
- return this.handleStreamHeader(packet.value.value, packet.participantIdentity, encryptionType);
22064
- case 'streamChunk':
22065
- return this.handleStreamChunk(packet.value.value, encryptionType);
22066
- case 'streamTrailer':
22067
- return this.handleStreamTrailer(packet.value.value, encryptionType);
22068
- default:
22069
- throw new Error("DataPacket of value \"".concat(packet.value.case, "\" is not data stream related!"));
22070
- }
22071
- });
22185
+ if (!this.isConnected) {
22186
+ this.bufferedPackets.push({
22187
+ packet,
22188
+ encryptionType
22189
+ });
22190
+ return;
22191
+ }
22192
+ switch (packet.value.case) {
22193
+ case 'streamHeader':
22194
+ return this.handleStreamHeader(packet.value.value, packet.participantIdentity, encryptionType);
22195
+ case 'streamChunk':
22196
+ return this.handleStreamChunk(packet.value.value, encryptionType);
22197
+ case 'streamTrailer':
22198
+ return this.handleStreamTrailer(packet.value.value, encryptionType);
22199
+ default:
22200
+ throw new Error("DataPacket of value \"".concat(packet.value.case, "\" is not data stream related!"));
22201
+ }
22072
22202
  }
22073
22203
  handleStreamHeader(streamHeader, participantIdentity, encryptionType) {
22074
- return __awaiter(this, void 0, void 0, function* () {
22075
- var _a;
22076
- if (streamHeader.contentHeader.case === 'byteHeader') {
22077
- const streamHandlerCallback = this.byteStreamHandlers.get(streamHeader.topic);
22078
- if (!streamHandlerCallback) {
22079
- this.log.debug('ignoring incoming byte stream due to no handler for topic', streamHeader.topic);
22080
- return;
22081
- }
22082
- let streamController;
22083
- const info = {
22084
- id: streamHeader.streamId,
22085
- name: (_a = streamHeader.contentHeader.value.name) !== null && _a !== void 0 ? _a : 'unknown',
22086
- mimeType: streamHeader.mimeType,
22087
- size: streamHeader.totalLength ? Number(streamHeader.totalLength) : undefined,
22088
- topic: streamHeader.topic,
22089
- timestamp: bigIntToNumber(streamHeader.timestamp),
22090
- attributes: streamHeader.attributes,
22091
- encryptionType
22092
- };
22093
- const stream = new ReadableStream({
22094
- start: controller => {
22095
- streamController = controller;
22096
- if (this.textStreamControllers.has(streamHeader.streamId)) {
22097
- throw new DataStreamError("A data stream read is already in progress for a stream with id ".concat(streamHeader.streamId, "."), DataStreamErrorReason.AlreadyOpened);
22098
- }
22099
- this.byteStreamControllers.set(streamHeader.streamId, {
22100
- info,
22101
- controller: streamController,
22102
- startTime: Date.now(),
22103
- sendingParticipantIdentity: participantIdentity
22104
- });
22204
+ var _a;
22205
+ if (streamHeader.contentHeader.case === 'byteHeader') {
22206
+ const streamHandlerCallback = this.byteStreamHandlers.get(streamHeader.topic);
22207
+ if (!streamHandlerCallback) {
22208
+ this.log.debug('ignoring incoming byte stream due to no handler for topic', streamHeader.topic);
22209
+ return;
22210
+ }
22211
+ let streamController;
22212
+ const info = {
22213
+ id: streamHeader.streamId,
22214
+ name: (_a = streamHeader.contentHeader.value.name) !== null && _a !== void 0 ? _a : 'unknown',
22215
+ mimeType: streamHeader.mimeType,
22216
+ size: streamHeader.totalLength ? Number(streamHeader.totalLength) : undefined,
22217
+ topic: streamHeader.topic,
22218
+ timestamp: bigIntToNumber(streamHeader.timestamp),
22219
+ attributes: streamHeader.attributes,
22220
+ encryptionType
22221
+ };
22222
+ const stream = new ReadableStream({
22223
+ start: controller => {
22224
+ streamController = controller;
22225
+ if (this.textStreamControllers.has(streamHeader.streamId)) {
22226
+ throw new DataStreamError("A data stream read is already in progress for a stream with id ".concat(streamHeader.streamId, "."), DataStreamErrorReason.AlreadyOpened);
22105
22227
  }
22106
- });
22107
- streamHandlerCallback(new ByteStreamReader(info, stream, bigIntToNumber(streamHeader.totalLength)), {
22108
- identity: participantIdentity
22109
- });
22110
- } else if (streamHeader.contentHeader.case === 'textHeader') {
22111
- const streamHandlerCallback = this.textStreamHandlers.get(streamHeader.topic);
22112
- if (!streamHandlerCallback) {
22113
- this.log.debug('ignoring incoming text stream due to no handler for topic', streamHeader.topic);
22114
- return;
22228
+ this.byteStreamControllers.set(streamHeader.streamId, {
22229
+ info,
22230
+ controller: streamController,
22231
+ startTime: Date.now(),
22232
+ sendingParticipantIdentity: participantIdentity
22233
+ });
22115
22234
  }
22116
- let streamController;
22117
- const info = {
22118
- id: streamHeader.streamId,
22119
- mimeType: streamHeader.mimeType,
22120
- size: streamHeader.totalLength ? Number(streamHeader.totalLength) : undefined,
22121
- topic: streamHeader.topic,
22122
- timestamp: Number(streamHeader.timestamp),
22123
- attributes: streamHeader.attributes,
22124
- encryptionType,
22125
- attachedStreamIds: streamHeader.contentHeader.value.attachedStreamIds
22126
- };
22127
- const stream = new ReadableStream({
22128
- start: controller => {
22129
- streamController = controller;
22130
- if (this.textStreamControllers.has(streamHeader.streamId)) {
22131
- throw new DataStreamError("A data stream read is already in progress for a stream with id ".concat(streamHeader.streamId, "."), DataStreamErrorReason.AlreadyOpened);
22132
- }
22133
- this.textStreamControllers.set(streamHeader.streamId, {
22134
- info,
22135
- controller: streamController,
22136
- startTime: Date.now(),
22137
- sendingParticipantIdentity: participantIdentity
22138
- });
22139
- }
22140
- });
22141
- streamHandlerCallback(new TextStreamReader(info, stream, bigIntToNumber(streamHeader.totalLength)), {
22142
- identity: participantIdentity
22143
- });
22235
+ });
22236
+ streamHandlerCallback(new ByteStreamReader(info, stream, bigIntToNumber(streamHeader.totalLength)), {
22237
+ identity: participantIdentity
22238
+ });
22239
+ } else if (streamHeader.contentHeader.case === 'textHeader') {
22240
+ const streamHandlerCallback = this.textStreamHandlers.get(streamHeader.topic);
22241
+ if (!streamHandlerCallback) {
22242
+ this.log.debug('ignoring incoming text stream due to no handler for topic', streamHeader.topic);
22243
+ return;
22144
22244
  }
22145
- });
22245
+ let streamController;
22246
+ const info = {
22247
+ id: streamHeader.streamId,
22248
+ mimeType: streamHeader.mimeType,
22249
+ size: streamHeader.totalLength ? Number(streamHeader.totalLength) : undefined,
22250
+ topic: streamHeader.topic,
22251
+ timestamp: Number(streamHeader.timestamp),
22252
+ attributes: streamHeader.attributes,
22253
+ encryptionType,
22254
+ attachedStreamIds: streamHeader.contentHeader.value.attachedStreamIds
22255
+ };
22256
+ const stream = new ReadableStream({
22257
+ start: controller => {
22258
+ streamController = controller;
22259
+ if (this.textStreamControllers.has(streamHeader.streamId)) {
22260
+ throw new DataStreamError("A data stream read is already in progress for a stream with id ".concat(streamHeader.streamId, "."), DataStreamErrorReason.AlreadyOpened);
22261
+ }
22262
+ this.textStreamControllers.set(streamHeader.streamId, {
22263
+ info,
22264
+ controller: streamController,
22265
+ startTime: Date.now(),
22266
+ sendingParticipantIdentity: participantIdentity
22267
+ });
22268
+ }
22269
+ });
22270
+ streamHandlerCallback(new TextStreamReader(info, stream, bigIntToNumber(streamHeader.totalLength)), {
22271
+ identity: participantIdentity
22272
+ });
22273
+ }
22146
22274
  }
22147
22275
  handleStreamChunk(chunk, encryptionType) {
22148
22276
  const fileBuffer = this.byteStreamControllers.get(chunk.streamId);
@@ -23694,6 +23822,9 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
23694
23822
  }
23695
23823
  this.descriptors.delete(sid);
23696
23824
  if (descriptor.subscription.type === 'active') {
23825
+ descriptor.subscription.streamControllers.forEach(controller => {
23826
+ controller.close();
23827
+ });
23697
23828
  this.subscriptionHandles.delete(descriptor.subscription.subcriptionHandle);
23698
23829
  }
23699
23830
  this.emit('trackUnpublished', {
@@ -23837,6 +23968,9 @@ class IncomingDataTrackManager extends eventsExports.EventEmitter {
23837
23968
  if (descriptor.subscription.type === 'pending') {
23838
23969
  (_b = (_a = descriptor.subscription.completionFuture).reject) === null || _b === void 0 ? void 0 : _b.call(_a, DataTrackSubscribeError.disconnected());
23839
23970
  }
23971
+ if (descriptor.subscription.type === 'active') {
23972
+ descriptor.subscription.streamControllers.forEach(controller => controller.close());
23973
+ }
23840
23974
  }
23841
23975
  this.descriptors.clear();
23842
23976
  }
@@ -25794,6 +25928,7 @@ class Participant extends eventsExports.EventEmitter {
25794
25928
  this.participantTrackPermissions = [];
25795
25929
  this.allParticipantsAllowedToSubscribe = true;
25796
25930
  this.encryptionType = Encryption_Type.NONE;
25931
+ this.e2eeStateMutex = new _();
25797
25932
  this.enabledPublishVideoCodecs = [];
25798
25933
  this.pendingAcks = new Map();
25799
25934
  this.pendingResponses = new Map();
@@ -26209,8 +26344,17 @@ class Participant extends eventsExports.EventEmitter {
26209
26344
  /** @internal */
26210
26345
  setE2EEEnabled(enabled) {
26211
26346
  return __awaiter(this, void 0, void 0, function* () {
26212
- this.encryptionType = enabled ? Encryption_Type.GCM : Encryption_Type.NONE;
26213
- yield this.republishAllTracks(undefined, false);
26347
+ const unlock = yield this.e2eeStateMutex.lock();
26348
+ try {
26349
+ this.encryptionType = enabled ? Encryption_Type.GCM : Encryption_Type.NONE;
26350
+ yield Promise.all(this.pendingPublishPromises.values());
26351
+ if (this.trackPublications.size === 0 || Array.from(this.trackPublications.values()).every(pub => pub.isEncrypted === enabled)) {
26352
+ return;
26353
+ }
26354
+ yield this.republishAllTracks(undefined, false);
26355
+ } finally {
26356
+ unlock();
26357
+ }
26214
26358
  });
26215
26359
  }
26216
26360
  setTrackEnabled(source, enabled, options, publishOptions) {
@@ -28227,6 +28371,7 @@ class Room extends eventsExports.EventEmitter {
28227
28371
  /** reflects the sender encryption status of the local participant */
28228
28372
  this.isE2EEEnabled = false;
28229
28373
  this.audioEnabled = true;
28374
+ this.e2eeStateMutex = new _();
28230
28375
  this.isVideoPlaybackBlocked = false;
28231
28376
  this.log = livekitLogger;
28232
28377
  this.bufferedEvents = [];
@@ -28341,30 +28486,17 @@ class Room extends eventsExports.EventEmitter {
28341
28486
  return this.connectFuture.promise;
28342
28487
  });
28343
28488
  this.connectSignal = (url, token, engine, connectOptions, roomOptions, abortController) => __awaiter(this, void 0, void 0, function* () {
28344
- var _a, _b, _c;
28345
- const joinResponse = yield engine.join(url, token, {
28489
+ const {
28490
+ joinResponse,
28491
+ serverInfo
28492
+ } = yield engine.join(url, token, {
28346
28493
  autoSubscribe: connectOptions.autoSubscribe,
28347
28494
  adaptiveStream: typeof roomOptions.adaptiveStream === 'object' ? true : roomOptions.adaptiveStream,
28348
28495
  maxRetries: connectOptions.maxRetries,
28349
28496
  e2eeEnabled: !!this.e2eeManager,
28350
28497
  websocketTimeout: connectOptions.websocketTimeout
28351
28498
  }, abortController.signal, !roomOptions.singlePeerConnection);
28352
- let serverInfo = joinResponse.serverInfo;
28353
- if (!serverInfo) {
28354
- serverInfo = {
28355
- version: joinResponse.serverVersion,
28356
- region: joinResponse.serverRegion
28357
- };
28358
- }
28359
28499
  this.serverInfo = serverInfo;
28360
- this.log.debug("connected to Livekit Server ".concat(Object.entries(serverInfo).map(_ref => {
28361
- let [key, value] = _ref;
28362
- return "".concat(key, ": ").concat(value);
28363
- }).join(', ')), {
28364
- room: (_a = joinResponse.room) === null || _a === void 0 ? void 0 : _a.name,
28365
- roomSid: (_b = joinResponse.room) === null || _b === void 0 ? void 0 : _b.sid,
28366
- identity: (_c = joinResponse.participant) === null || _c === void 0 ? void 0 : _c.identity
28367
- });
28368
28500
  if (!serverInfo.version) {
28369
28501
  throw new UnsupportedServer('unknown server version');
28370
28502
  }
@@ -29002,10 +29134,10 @@ class Room extends eventsExports.EventEmitter {
29002
29134
  this.emit(RoomEvent.LocalDataTrackPublished, event.track);
29003
29135
  }).on('trackUnpublished', event => {
29004
29136
  this.emit(RoomEvent.LocalDataTrackUnpublished, event.sid);
29005
- }).on('packetAvailable', _ref2 => {
29137
+ }).on('packetAvailable', _ref => {
29006
29138
  let {
29007
29139
  bytes
29008
- } = _ref2;
29140
+ } = _ref;
29009
29141
  this.engine.sendLossyBytes(bytes, DataChannelKind.DATA_TRACK_LOSSY, 'wait');
29010
29142
  });
29011
29143
  this.disconnectLock = new _();
@@ -29095,19 +29227,26 @@ class Room extends eventsExports.EventEmitter {
29095
29227
  */
29096
29228
  setE2EEEnabled(enabled) {
29097
29229
  return __awaiter(this, void 0, void 0, function* () {
29098
- if (this.e2eeManager) {
29099
- yield Promise.all([this.localParticipant.setE2EEEnabled(enabled)]);
29100
- if (this.localParticipant.identity !== '') {
29101
- this.e2eeManager.setParticipantCryptorEnabled(enabled, this.localParticipant.identity);
29230
+ const unlock = yield this.e2eeStateMutex.lock();
29231
+ try {
29232
+ if (this.e2eeManager) {
29233
+ if (this.isE2EEEnabled !== enabled) {
29234
+ yield this.localParticipant.setE2EEEnabled(enabled);
29235
+ if (this.localParticipant.identity !== '') {
29236
+ this.e2eeManager.setParticipantCryptorEnabled(enabled, this.localParticipant.identity);
29237
+ }
29238
+ }
29239
+ } else {
29240
+ throw Error('e2ee not configured, please set e2ee settings within the room options');
29102
29241
  }
29103
- } else {
29104
- throw Error('e2ee not configured, please set e2ee settings within the room options');
29242
+ } finally {
29243
+ unlock();
29105
29244
  }
29106
29245
  });
29107
29246
  }
29108
29247
  setupE2EE() {
29109
29248
  // when encryption is enabled via `options.encryption`, we enable data channel encryption
29110
- var _a;
29249
+ var _a, _b;
29111
29250
  const dcEncryptionEnabled = !!this.options.encryption;
29112
29251
  const e2eeOptions = this.options.encryption || this.options.e2ee;
29113
29252
  if (e2eeOptions) {
@@ -29128,6 +29267,7 @@ class Room extends eventsExports.EventEmitter {
29128
29267
  this.emit(RoomEvent.EncryptionError, error, participant);
29129
29268
  });
29130
29269
  (_a = this.e2eeManager) === null || _a === void 0 ? void 0 : _a.setup(this);
29270
+ (_b = this.e2eeManager) === null || _b === void 0 ? void 0 : _b.setupEngine(this.engine);
29131
29271
  }
29132
29272
  }
29133
29273
  get logContext() {
@@ -29227,10 +29367,10 @@ class Room extends eventsExports.EventEmitter {
29227
29367
  }).on(EngineEvent.DCBufferStatusChanged, (status, kind) => {
29228
29368
  this.emit(RoomEvent.DCBufferStatusChanged, status, kind);
29229
29369
  }).on(EngineEvent.LocalTrackSubscribed, subscribedSid => {
29230
- const trackPublication = this.localParticipant.getTrackPublications().find(_ref3 => {
29370
+ const trackPublication = this.localParticipant.getTrackPublications().find(_ref2 => {
29231
29371
  let {
29232
29372
  trackSid
29233
- } = _ref3;
29373
+ } = _ref2;
29234
29374
  return trackSid === subscribedSid;
29235
29375
  });
29236
29376
  if (!trackPublication) {
@@ -29274,8 +29414,8 @@ class Room extends eventsExports.EventEmitter {
29274
29414
  }
29275
29415
  this.outgoingDataTrackManager.receivedSfuUnpublishResponse(event.info.pubHandle);
29276
29416
  }).on(EngineEvent.DataTrackSubscriberHandles, event => {
29277
- const handleToSidMapping = new Map(Object.entries(event.subHandles).map(_ref4 => {
29278
- let [key, value] = _ref4;
29417
+ const handleToSidMapping = new Map(Object.entries(event.subHandles).map(_ref3 => {
29418
+ let [key, value] = _ref3;
29279
29419
  return [parseInt(key, 10), value.trackSid];
29280
29420
  }));
29281
29421
  this.incomingDataTrackManager.receivedSfuSubscriberHandles(handleToSidMapping);
@@ -30058,12 +30198,13 @@ class Room extends eventsExports.EventEmitter {
30058
30198
  return false;
30059
30199
  }
30060
30200
  this.state = state;
30201
+ this.incomingDataStreamManager.setConnected(state === ConnectionState.Connected);
30061
30202
  this.emit(RoomEvent.ConnectionStateChanged, this.state);
30062
30203
  return true;
30063
30204
  }
30064
30205
  emitBufferedEvents() {
30065
- this.bufferedEvents.forEach(_ref5 => {
30066
- let [ev, args] = _ref5;
30206
+ this.bufferedEvents.forEach(_ref4 => {
30207
+ let [ev, args] = _ref4;
30067
30208
  this.emit(ev, ...args);
30068
30209
  });
30069
30210
  this.bufferedEvents = [];
@@ -31268,7 +31409,9 @@ function decodeTokenPayload(token) {
31268
31409
  } = payload,
31269
31410
  rest = __rest(payload, ["roomConfig"]);
31270
31411
  const mappedPayload = Object.assign(Object.assign({}, rest), {
31271
- roomConfig: payload.roomConfig ? RoomConfiguration.fromJson(payload.roomConfig) : undefined
31412
+ roomConfig: payload.roomConfig ? RoomConfiguration.fromJson(payload.roomConfig, {
31413
+ ignoreUnknownFields: true
31414
+ }) : undefined
31272
31415
  });
31273
31416
  return mappedPayload;
31274
31417
  }
@@ -31601,4 +31744,50 @@ function facingModeFromDeviceLabel(deviceLabel) {
31601
31744
  function isFacingModeValue(item) {
31602
31745
  const allowedValues = ['user', 'environment', 'left', 'right'];
31603
31746
  return item === undefined || allowedValues.includes(item);
31604
- }export{AudioPresets,BackupCodecPolicy,BaseKeyProvider,CheckStatus,Checker,ConnectionCheck,ConnectionError,ConnectionErrorReason,ConnectionQuality,ConnectionState,CriticalTimers,CryptorError,CryptorErrorReason,CryptorEvent,DataPacket_Kind,DataStreamError,DataStreamErrorReason,DataTrackPacket,DefaultReconnectPolicy,DeviceUnsupportedError,DisconnectReason,EncryptionEvent,Encryption_Type,EngineEvent,ExternalE2EEKeyProvider,KeyHandlerEvent,KeyProviderEvent,LivekitError,LivekitReasonedError,LocalAudioTrack,LocalDataTrack,LocalParticipant,LocalTrack,LocalTrackPublication,LocalTrackRecorder,LocalVideoTrack,LogLevel,LoggerNames,MediaDeviceFailure,_ as Mutex,NegotiationError,Participant,ParticipantEvent,ParticipantInfo_Kind as ParticipantKind,PublishDataError,PublishTrackError,RemoteAudioTrack,RemoteDataTrack,RemoteParticipant,RemoteTrack,RemoteTrackPublication,RemoteVideoTrack,Room,RoomEvent,RpcError,ScreenSharePresets,SignalReconnectError,SignalRequestError,SimulatedError,SubscriptionError,TokenSource,TokenSourceConfigurable,TokenSourceFixed,Track,TrackEvent,TrackInvalidError,TrackPublication,TrackType,UnexpectedConnectionState,UnsupportedServer,VideoPreset,VideoPresets,VideoPresets43,VideoQuality,areTokenSourceFetchOptionsEqual,asEncryptablePacket,attachToElement,attributeTypings as attributes,audioCodecs,compareVersions,createAudioAnalyser,createE2EEKey,createKeyMaterialFromBuffer,createKeyMaterialFromString,createLocalAudioTrack,createLocalScreenTracks,createLocalTracks,createLocalVideoTrack,decodeTokenPayload,deriveKeys,detachTrack,facingModeFromDeviceLabel,facingModeFromLocalTrack,getBrowser,getEmptyAudioStreamTrack,getEmptyVideoStreamTrack,getLogger,importKey,isAudioCodec,isAudioTrack,isBackupCodec,isBackupVideoCodec,isBrowserSupported,isE2EESupported,isInsertableStreamSupported,isLocalParticipant,isLocalTrack,isRemoteParticipant,isRemoteTrack,isScriptTransformSupported,isVideoCodec,isVideoFrame,isVideoTrack,needsRbspUnescaping,parseRbsp,protocolVersion,ratchet,setLogExtension,setLogLevel,supportsAV1,supportsAdaptiveStream,supportsAudioOutputSelection,supportsDynacast,supportsVP9,version,videoCodecs,writeRbsp};//# sourceMappingURL=livekit-client.esm.mjs.map
31747
+ }const SerializerSymbol = Symbol.for('lk.serializer');
31748
+ function isSerializer(v) {
31749
+ return typeof v === 'object' && v !== null && 'symbol' in v && v.symbol === SerializerSymbol;
31750
+ }
31751
+ /** @internal */
31752
+ function base(params) {
31753
+ return Object.assign(Object.assign({}, params), {
31754
+ symbol: SerializerSymbol
31755
+ });
31756
+ }
31757
+ /**
31758
+ * JSON serializer — `JSON.parse` on the way in, `JSON.stringify` on the way out.
31759
+ * Defaults to `any` so individual handlers can annotate their own payload types.
31760
+ */
31761
+ function json() {
31762
+ return base({
31763
+ parse: rawString => JSON.parse(rawString),
31764
+ serialize: val => JSON.stringify(val)
31765
+ });
31766
+ }
31767
+ /** Raw string serializer — passes payloads through as plain strings with no encoding. */
31768
+ function raw() {
31769
+ return base({
31770
+ parse: rawString => rawString,
31771
+ serialize: val => val
31772
+ });
31773
+ }
31774
+ /** Custom serializer - allows custom defined parse and serialize functions */
31775
+ function custom(params) {
31776
+ return base(params);
31777
+ }
31778
+ /**
31779
+ * Serializer helpers for message payload encoding.
31780
+ *
31781
+ * @example
31782
+ * ```ts
31783
+ * const a = serializers.raw(); // Serializer<string, string>
31784
+ * const b = serializer.json<{ foo: string }, { bar: string }>(); // Serializer<{ foo: string }, { bar: string }>
31785
+ * ```
31786
+ *
31787
+ * @beta
31788
+ */
31789
+ const serializers = {
31790
+ json,
31791
+ raw,
31792
+ custom
31793
+ };export{AudioPresets,BackupCodecPolicy,BaseKeyProvider,CheckStatus,Checker,ConnectionCheck,ConnectionError,ConnectionErrorReason,ConnectionQuality,ConnectionState,CriticalTimers,CryptorError,CryptorErrorReason,CryptorEvent,DataPacket_Kind,DataStreamError,DataStreamErrorReason,DataTrackPacket,DefaultReconnectPolicy,DeviceUnsupportedError,DisconnectReason,EncryptionEvent,Encryption_Type,EngineEvent,ExternalE2EEKeyProvider,KeyHandlerEvent,KeyProviderEvent,LivekitError,LivekitReasonedError,LocalAudioTrack,LocalDataTrack,LocalParticipant,LocalTrack,LocalTrackPublication,LocalTrackRecorder,LocalVideoTrack,LogLevel,LoggerNames,MediaDeviceFailure,_ as Mutex,NegotiationError,Participant,ParticipantEvent,ParticipantInfo_Kind as ParticipantKind,PublishDataError,PublishTrackError,RemoteAudioTrack,RemoteDataTrack,RemoteParticipant,RemoteTrack,RemoteTrackPublication,RemoteVideoTrack,Room,RoomEvent,RpcError,ScreenSharePresets,SignalReconnectError,SignalRequestError,SimulatedError,SubscriptionError,TokenSource,TokenSourceConfigurable,TokenSourceFixed,Track,TrackEvent,TrackInvalidError,TrackPublication,TrackType,UnexpectedConnectionState,UnsupportedServer,VideoPreset,VideoPresets,VideoPresets43,VideoQuality,areTokenSourceFetchOptionsEqual,asEncryptablePacket,attachToElement,attributeTypings as attributes,audioCodecs,compareVersions,createAudioAnalyser,createE2EEKey,createKeyMaterialFromBuffer,createKeyMaterialFromString,createLocalAudioTrack,createLocalScreenTracks,createLocalTracks,createLocalVideoTrack,decodeTokenPayload,deriveKeys,detachTrack,facingModeFromDeviceLabel,facingModeFromLocalTrack,getBrowser,getEmptyAudioStreamTrack,getEmptyVideoStreamTrack,getLogger,importKey,isAudioCodec,isAudioTrack,isBackupCodec,isBackupVideoCodec,isBrowserSupported,isE2EESupported,isInsertableStreamSupported,isLocalParticipant,isLocalTrack,isRemoteParticipant,isRemoteTrack,isScriptTransformSupported,isSerializer,isVideoCodec,isVideoFrame,isVideoTrack,needsRbspUnescaping,parseRbsp,protocolVersion,ratchet,serializers,setLogExtension,setLogLevel,supportsAV1,supportsAdaptiveStream,supportsAudioOutputSelection,supportsDynacast,supportsVP9,version,videoCodecs,writeRbsp};//# sourceMappingURL=livekit-client.esm.mjs.map