livekit-client 1.15.12 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/README.md +27 -15
  2. package/dist/livekit-client.esm.mjs +1750 -1581
  3. package/dist/livekit-client.esm.mjs.map +1 -1
  4. package/dist/livekit-client.umd.js +1 -1
  5. package/dist/livekit-client.umd.js.map +1 -1
  6. package/dist/src/api/SignalClient.d.ts +0 -2
  7. package/dist/src/api/SignalClient.d.ts.map +1 -1
  8. package/dist/src/index.d.ts +3 -3
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/options.d.ts +3 -9
  11. package/dist/src/options.d.ts.map +1 -1
  12. package/dist/src/proto/livekit_models_pb.d.ts +56 -1
  13. package/dist/src/proto/livekit_models_pb.d.ts.map +1 -1
  14. package/dist/src/proto/livekit_rtc_pb.d.ts +38 -0
  15. package/dist/src/proto/livekit_rtc_pb.d.ts.map +1 -1
  16. package/dist/src/room/PCTransport.d.ts +1 -2
  17. package/dist/src/room/PCTransport.d.ts.map +1 -1
  18. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  19. package/dist/src/room/RTCEngine.d.ts +1 -0
  20. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  21. package/dist/src/room/Room.d.ts +12 -15
  22. package/dist/src/room/Room.d.ts.map +1 -1
  23. package/dist/src/room/defaults.d.ts.map +1 -1
  24. package/dist/src/room/events.d.ts +8 -5
  25. package/dist/src/room/events.d.ts.map +1 -1
  26. package/dist/src/room/participant/LocalParticipant.d.ts +8 -25
  27. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  28. package/dist/src/room/participant/Participant.d.ts +6 -10
  29. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  30. package/dist/src/room/participant/RemoteParticipant.d.ts +9 -6
  31. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  32. package/dist/src/room/timers.d.ts +4 -5
  33. package/dist/src/room/timers.d.ts.map +1 -1
  34. package/dist/src/room/track/LocalVideoTrack.d.ts +3 -3
  35. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  36. package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -2
  37. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  38. package/dist/src/room/track/Track.d.ts +5 -0
  39. package/dist/src/room/track/Track.d.ts.map +1 -1
  40. package/dist/src/room/track/options.d.ts +0 -5
  41. package/dist/src/room/track/options.d.ts.map +1 -1
  42. package/dist/src/room/types.d.ts +11 -3
  43. package/dist/src/room/types.d.ts.map +1 -1
  44. package/dist/src/version.d.ts +1 -1
  45. package/dist/ts4.2/src/api/SignalClient.d.ts +0 -2
  46. package/dist/ts4.2/src/index.d.ts +3 -3
  47. package/dist/ts4.2/src/options.d.ts +3 -9
  48. package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +56 -1
  49. package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +38 -0
  50. package/dist/ts4.2/src/room/PCTransport.d.ts +1 -2
  51. package/dist/ts4.2/src/room/RTCEngine.d.ts +1 -0
  52. package/dist/ts4.2/src/room/Room.d.ts +12 -15
  53. package/dist/ts4.2/src/room/events.d.ts +8 -5
  54. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +8 -25
  55. package/dist/ts4.2/src/room/participant/Participant.d.ts +6 -10
  56. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +9 -6
  57. package/dist/ts4.2/src/room/timers.d.ts +4 -5
  58. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +3 -3
  59. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +2 -2
  60. package/dist/ts4.2/src/room/track/Track.d.ts +5 -0
  61. package/dist/ts4.2/src/room/track/options.d.ts +0 -5
  62. package/dist/ts4.2/src/room/types.d.ts +11 -3
  63. package/dist/ts4.2/src/version.d.ts +1 -1
  64. package/package.json +10 -9
  65. package/src/api/SignalClient.ts +2 -6
  66. package/src/e2ee/E2eeManager.ts +2 -2
  67. package/src/index.ts +2 -4
  68. package/src/options.ts +3 -10
  69. package/src/proto/livekit_models_pb.ts +78 -0
  70. package/src/proto/livekit_rtc_pb.ts +53 -0
  71. package/src/room/PCTransport.ts +3 -13
  72. package/src/room/PCTransportManager.ts +2 -3
  73. package/src/room/RTCEngine.ts +11 -1
  74. package/src/room/Room.ts +145 -114
  75. package/src/room/defaults.ts +1 -5
  76. package/src/room/events.ts +8 -6
  77. package/src/room/participant/LocalParticipant.ts +36 -77
  78. package/src/room/participant/Participant.ts +23 -24
  79. package/src/room/participant/RemoteParticipant.ts +27 -24
  80. package/src/room/track/LocalVideoTrack.test.ts +1 -1
  81. package/src/room/track/LocalVideoTrack.ts +11 -7
  82. package/src/room/track/RemoteTrackPublication.ts +2 -7
  83. package/src/room/track/Track.ts +10 -1
  84. package/src/room/track/options.ts +0 -6
  85. package/src/room/types.ts +11 -4
  86. package/src/version.ts +1 -1
@@ -191,7 +191,15 @@ export declare enum DisconnectReason {
191
191
  /**
192
192
  * @generated from enum value: JOIN_FAILURE = 7;
193
193
  */
194
- JOIN_FAILURE = 7
194
+ JOIN_FAILURE = 7,
195
+ /**
196
+ * @generated from enum value: MIGRATION = 8;
197
+ */
198
+ MIGRATION = 8,
199
+ /**
200
+ * @generated from enum value: SIGNAL_CLOSE = 9;
201
+ */
202
+ SIGNAL_CLOSE = 9
195
203
  }
196
204
  /**
197
205
  * @generated from enum livekit.ReconnectReason
@@ -283,6 +291,10 @@ export declare class Room extends Message<Room> {
283
291
  * @generated from field: bool active_recording = 10;
284
292
  */
285
293
  activeRecording: boolean;
294
+ /**
295
+ * @generated from field: livekit.TimedVersion version = 13;
296
+ */
297
+ version?: TimedVersion;
286
298
  constructor(data?: PartialMessage<Room>);
287
299
  static readonly runtime: typeof proto3;
288
300
  static readonly typeName = "livekit.Room";
@@ -452,6 +464,10 @@ export declare class ParticipantInfo extends Message<ParticipantInfo> {
452
464
  * @generated from field: bool is_publisher = 13;
453
465
  */
454
466
  isPublisher: boolean;
467
+ /**
468
+ * @generated from field: livekit.ParticipantInfo.Kind kind = 14;
469
+ */
470
+ kind: ParticipantInfo_Kind;
455
471
  constructor(data?: PartialMessage<ParticipantInfo>);
456
472
  static readonly runtime: typeof proto3;
457
473
  static readonly typeName = "livekit.ParticipantInfo";
@@ -490,6 +506,41 @@ export declare enum ParticipantInfo_State {
490
506
  */
491
507
  DISCONNECTED = 3
492
508
  }
509
+ /**
510
+ * @generated from enum livekit.ParticipantInfo.Kind
511
+ */
512
+ export declare enum ParticipantInfo_Kind {
513
+ /**
514
+ * standard participants, e.g. web clients
515
+ *
516
+ * @generated from enum value: STANDARD = 0;
517
+ */
518
+ STANDARD = 0,
519
+ /**
520
+ * only ingests streams
521
+ *
522
+ * @generated from enum value: INGRESS = 1;
523
+ */
524
+ INGRESS = 1,
525
+ /**
526
+ * only consumes streams
527
+ *
528
+ * @generated from enum value: EGRESS = 2;
529
+ */
530
+ EGRESS = 2,
531
+ /**
532
+ * SIP participants
533
+ *
534
+ * @generated from enum value: SIP = 3;
535
+ */
536
+ SIP = 3,
537
+ /**
538
+ * LiveKit agents
539
+ *
540
+ * @generated from enum value: AGENT = 4;
541
+ */
542
+ AGENT = 4
543
+ }
493
544
  /**
494
545
  * @generated from message livekit.Encryption
495
546
  */
@@ -636,6 +687,10 @@ export declare class TrackInfo extends Message<TrackInfo> {
636
687
  * @generated from field: string stream = 17;
637
688
  */
638
689
  stream: string;
690
+ /**
691
+ * @generated from field: livekit.TimedVersion version = 18;
692
+ */
693
+ version?: TimedVersion;
639
694
  constructor(data?: PartialMessage<TrackInfo>);
640
695
  static readonly runtime: typeof proto3;
641
696
  static readonly typeName = "livekit.TrackInfo";
@@ -778,6 +778,7 @@ export declare class LeaveRequest extends Message<LeaveRequest> {
778
778
  /**
779
779
  * sent when server initiates the disconnect due to server-restart
780
780
  * indicates clients should attempt full-reconnect sequence
781
+ * NOTE: `can_reconnect` obsoleted by `action` starting in protocol version 13
781
782
  *
782
783
  * @generated from field: bool can_reconnect = 1;
783
784
  */
@@ -786,6 +787,14 @@ export declare class LeaveRequest extends Message<LeaveRequest> {
786
787
  * @generated from field: livekit.DisconnectReason reason = 2;
787
788
  */
788
789
  reason: DisconnectReason;
790
+ /**
791
+ * @generated from field: livekit.LeaveRequest.Action action = 3;
792
+ */
793
+ action: LeaveRequest_Action;
794
+ /**
795
+ * @generated from field: livekit.RegionSettings regions = 4;
796
+ */
797
+ regions?: RegionSettings;
789
798
  constructor(data?: PartialMessage<LeaveRequest>);
790
799
  static readonly runtime: typeof proto3;
791
800
  static readonly typeName = "livekit.LeaveRequest";
@@ -795,6 +804,31 @@ export declare class LeaveRequest extends Message<LeaveRequest> {
795
804
  static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): LeaveRequest;
796
805
  static equals(a: LeaveRequest | PlainMessage<LeaveRequest> | undefined, b: LeaveRequest | PlainMessage<LeaveRequest> | undefined): boolean;
797
806
  }
807
+ /**
808
+ * indicates action clients should take on receiving this message
809
+ *
810
+ * @generated from enum livekit.LeaveRequest.Action
811
+ */
812
+ export declare enum LeaveRequest_Action {
813
+ /**
814
+ * should disconnect
815
+ *
816
+ * @generated from enum value: DISCONNECT = 0;
817
+ */
818
+ DISCONNECT = 0,
819
+ /**
820
+ * should attempt a resume with `reconnect=1` in join URL
821
+ *
822
+ * @generated from enum value: RESUME = 1;
823
+ */
824
+ RESUME = 1,
825
+ /**
826
+ * should attempt a reconnect, i. e. no `reconnect=1`
827
+ *
828
+ * @generated from enum value: RECONNECT = 2;
829
+ */
830
+ RECONNECT = 2
831
+ }
798
832
  /**
799
833
  * message to indicate published video track dimensions are changing
800
834
  *
@@ -1154,6 +1188,10 @@ export declare class SyncState extends Message<SyncState> {
1154
1188
  * @generated from field: livekit.SessionDescription offer = 5;
1155
1189
  */
1156
1190
  offer?: SessionDescription;
1191
+ /**
1192
+ * @generated from field: repeated string track_sids_disabled = 6;
1193
+ */
1194
+ trackSidsDisabled: string[];
1157
1195
  constructor(data?: PartialMessage<SyncState>);
1158
1196
  static readonly runtime: typeof proto3;
1159
1197
  static readonly typeName = "livekit.SyncState";
@@ -18,7 +18,6 @@ export default class PCTransport extends EventEmitter {
18
18
  private _pc;
19
19
  private get pc();
20
20
  private config?;
21
- private mediaConstraints;
22
21
  private log;
23
22
  private loggerOptions;
24
23
  pendingCandidates: RTCIceCandidateInit[];
@@ -35,7 +34,7 @@ export default class PCTransport extends EventEmitter {
35
34
  onSignalingStatechange?: (state: RTCSignalingState) => void;
36
35
  onDataChannel?: (ev: RTCDataChannelEvent) => void;
37
36
  onTrack?: (ev: RTCTrackEvent) => void;
38
- constructor(config?: RTCConfiguration, mediaConstraints?: Record<string, unknown>, loggerOptions?: LoggerOptions);
37
+ constructor(config?: RTCConfiguration, loggerOptions?: LoggerOptions);
39
38
  private createPC;
40
39
  private get logContext();
41
40
  get isICEConnected(): boolean;
@@ -29,6 +29,7 @@ export default class RTCEngine extends RTCEngine_base {
29
29
  */
30
30
  latestJoinResponse?: JoinResponse;
31
31
  get isClosed(): boolean;
32
+ get pendingReconnect(): boolean;
32
33
  private lossyDC?;
33
34
  private lossyDCSub?;
34
35
  private reliableDC?;
@@ -19,8 +19,6 @@ export declare enum ConnectionState {
19
19
  Connected = "connected",
20
20
  Reconnecting = "reconnecting"
21
21
  }
22
- /** @deprecated RoomState has been renamed to [[ConnectionState]] */
23
- export declare const RoomState: typeof ConnectionState;
24
22
  declare const Room_base: new () => TypedEmitter<RoomEventCallbacks>;
25
23
  /**
26
24
  * In LiveKit, a room is the logical grouping for a list of participants.
@@ -32,8 +30,10 @@ declare const Room_base: new () => TypedEmitter<RoomEventCallbacks>;
32
30
  */
33
31
  declare class Room extends Room_base {
34
32
  state: ConnectionState;
35
- /** map of sid: [[RemoteParticipant]] */
36
- participants: Map<string, RemoteParticipant>;
33
+ /**
34
+ * map of identity: [[RemoteParticipant]]
35
+ */
36
+ remoteParticipants: Map<string, RemoteParticipant>;
37
37
  /**
38
38
  * list of participants that are actively speaking. when this changes
39
39
  * a [[RoomEvent.ActiveSpeakersChanged]] event is fired
@@ -48,7 +48,7 @@ declare class Room extends Room_base {
48
48
  /** reflects the sender encryption status of the local participant */
49
49
  isE2EEEnabled: boolean;
50
50
  private roomInfo?;
51
- private identityToSid;
51
+ private sidToIdentity;
52
52
  /** connect options of room */
53
53
  private connOptions?;
54
54
  private audioEnabled;
@@ -65,6 +65,7 @@ declare class Room extends Room_base {
65
65
  private isVideoPlaybackBlocked;
66
66
  private log;
67
67
  private bufferedEvents;
68
+ private isResuming;
68
69
  /**
69
70
  * Creates a new Room, the primary construct for a LiveKit session.
70
71
  * @param options
@@ -80,8 +81,11 @@ declare class Room extends Room_base {
80
81
  * if the current room has a participant with `recorder: true` in its JWT grant
81
82
  **/
82
83
  get isRecording(): boolean;
83
- /** server assigned unique room id */
84
- get sid(): string;
84
+ /**
85
+ * server assigned unique room id.
86
+ * returns once a sid has been issued by the server.
87
+ */
88
+ getSid(): Promise<string>;
85
89
  /** user assigned name, derived from JWT token */
86
90
  get name(): string;
87
91
  /** room metadata */
@@ -145,12 +149,6 @@ declare class Room extends Room_base {
145
149
  * Returns true if video playback is enabled
146
150
  */
147
151
  get canPlaybackVideo(): boolean;
148
- /**
149
- * Returns the active audio output device used in this room.
150
- * @return the previously successfully set audio output device ID or an empty string if the default device is used.
151
- * @deprecated use `getActiveDevice('audiooutput')` instead
152
- */
153
- getActiveAudioOutputDevice(): string;
154
152
  getActiveDevice(kind: MediaDeviceKind): string | undefined;
155
153
  /**
156
154
  * Switches all active devices used in this room to the given device.
@@ -193,6 +191,7 @@ declare class Room extends Room_base {
193
191
  * subscription settings.
194
192
  */
195
193
  private updateSubscriptions;
194
+ private getRemoteParticipantBySid;
196
195
  private registerConnectionReconcile;
197
196
  private clearConnectionReconcile;
198
197
  private setAndEmitConnectionState;
@@ -221,8 +220,6 @@ export type RoomEventCallbacks = {
221
220
  reconnecting: () => void;
222
221
  reconnected: () => void;
223
222
  disconnected: (reason?: DisconnectReason) => void;
224
- /** @deprecated stateChanged has been renamed to connectionStateChanged */
225
- stateChanged: (state: ConnectionState) => void;
226
223
  connectionStateChanged: (state: ConnectionState) => void;
227
224
  mediaDevicesChanged: () => void;
228
225
  participantConnected: (participant: RemoteParticipant) => void;
@@ -23,7 +23,14 @@ export declare enum RoomEvent {
23
23
  Reconnected = "reconnected",
24
24
  /**
25
25
  * When disconnected from room. This fires when room.disconnect() is called or
26
- * when an unrecoverable connection issue had occured
26
+ * when an unrecoverable connection issue had occured.
27
+ *
28
+ * DisconnectReason can be used to determine why the participant was disconnected. Notable reasons are
29
+ * - DUPLICATE_IDENTITY: another client with the same identity has joined the room
30
+ * - PARTICIPANT_REMOVED: participant was removed by RemoveParticipant API
31
+ * - ROOM_DELETED: the room has ended via DeleteRoom API
32
+ *
33
+ * args: ([[DisconnectReason]])
27
34
  */
28
35
  Disconnected = "disconnected",
29
36
  /**
@@ -32,10 +39,6 @@ export declare enum RoomEvent {
32
39
  * args: ([[ConnectionState]])
33
40
  */
34
41
  ConnectionStateChanged = "connectionStateChanged",
35
- /**
36
- * @deprecated StateChanged has been renamed to ConnectionStateChanged
37
- */
38
- StateChanged = "connectionStateChanged",
39
42
  /**
40
43
  * When input or output devices on the machine have changed.
41
44
  */
@@ -1,5 +1,5 @@
1
1
  import type { InternalRoomOptions } from '../../options';
2
- import { DataPacket_Kind, ParticipantInfo, ParticipantPermission } from '../../proto/livekit_models_pb';
2
+ import { ParticipantInfo, ParticipantPermission } from '../../proto/livekit_models_pb';
3
3
  import type RTCEngine from '../RTCEngine';
4
4
  import LocalTrack from '../track/LocalTrack';
5
5
  import LocalTrackPublication from '../track/LocalTrackPublication';
@@ -8,12 +8,11 @@ import type { AudioCaptureOptions, BackupVideoCodec, CreateLocalTracksOptions, S
8
8
  import type { DataPublishOptions } from '../types';
9
9
  import Participant from './Participant';
10
10
  import type { ParticipantTrackPermission } from './ParticipantTrackPermission';
11
- import RemoteParticipant from './RemoteParticipant';
12
11
  export default class LocalParticipant extends Participant {
13
- audioTracks: Map<string, LocalTrackPublication>;
14
- videoTracks: Map<string, LocalTrackPublication>;
12
+ audioTrackPublications: Map<string, LocalTrackPublication>;
13
+ videoTrackPublications: Map<string, LocalTrackPublication>;
15
14
  /** map of track sid => all published tracks */
16
- tracks: Map<string, LocalTrackPublication>;
15
+ trackPublications: Map<string, LocalTrackPublication>;
17
16
  /** @internal */
18
17
  engine: RTCEngine;
19
18
  /** @internal */
@@ -32,8 +31,8 @@ export default class LocalParticipant extends Participant {
32
31
  get lastCameraError(): Error | undefined;
33
32
  get lastMicrophoneError(): Error | undefined;
34
33
  get isE2EEEnabled(): boolean;
35
- getTrack(source: Track.Source): LocalTrackPublication | undefined;
36
- getTrackByName(name: string): LocalTrackPublication | undefined;
34
+ getTrackPublication(source: Track.Source): LocalTrackPublication | undefined;
35
+ getTrackPublicationByName(name: string): LocalTrackPublication | undefined;
37
36
  /**
38
37
  * @internal
39
38
  */
@@ -123,25 +122,9 @@ export default class LocalParticipant extends Participant {
123
122
  * participant in the room if the destination field in publishOptions is empty
124
123
  *
125
124
  * @param data Uint8Array of the payload. To send string data, use TextEncoder.encode
126
- * @param kind whether to send this as reliable or lossy.
127
- * For data that you need delivery guarantee (such as chat messages), use Reliable.
128
- * For data that should arrive as quickly as possible, but you are ok with dropped
129
- * packets, use Lossy.
130
- * @param publishOptions optionally specify a `topic` and `destination`
125
+ * @param options optionally specify a `reliable`, `topic` and `destination`
131
126
  */
132
- publishData(data: Uint8Array, kind: DataPacket_Kind, publishOptions?: DataPublishOptions): Promise<void>;
133
- /**
134
- * Publish a new data payload to the room. Data will be forwarded to each
135
- * participant in the room if the destination argument is empty
136
- *
137
- * @param data Uint8Array of the payload. To send string data, use TextEncoder.encode
138
- * @param kind whether to send this as reliable or lossy.
139
- * For data that you need delivery guarantee (such as chat messages), use Reliable.
140
- * For data that should arrive as quickly as possible, but you are ok with dropped
141
- * packets, use Lossy.
142
- * @param destination the participants who will receive the message
143
- */
144
- publishData(data: Uint8Array, kind: DataPacket_Kind, destination?: RemoteParticipant[] | string[]): Promise<void>;
127
+ publishData(data: Uint8Array, options?: DataPublishOptions): Promise<void>;
145
128
  /**
146
129
  * Control who can subscribe to LocalParticipant's published tracks.
147
130
  *
@@ -21,10 +21,10 @@ export declare enum ConnectionQuality {
21
21
  declare const Participant_base: new () => TypedEmitter<ParticipantEventCallbacks>;
22
22
  export default class Participant extends Participant_base {
23
23
  protected participantInfo?: ParticipantInfo;
24
- audioTracks: Map<string, TrackPublication>;
25
- videoTracks: Map<string, TrackPublication>;
24
+ audioTrackPublications: Map<string, TrackPublication>;
25
+ videoTrackPublications: Map<string, TrackPublication>;
26
26
  /** map of track sid => all published tracks */
27
- tracks: Map<string, TrackPublication>;
27
+ trackPublications: Map<string, TrackPublication>;
28
28
  /** audio level between 0-1.0, 1 being loudest, 0 being softest */
29
29
  audioLevel: number;
30
30
  /** if participant is currently speaking */
@@ -51,20 +51,16 @@ export default class Participant extends Participant_base {
51
51
  get isAgent(): boolean;
52
52
  /** @internal */
53
53
  constructor(sid: string, identity: string, name?: string, metadata?: string, loggerOptions?: LoggerOptions);
54
- getTracks(): TrackPublication[];
54
+ getTrackPublications(): TrackPublication[];
55
55
  /**
56
56
  * Finds the first track that matches the source filter, for example, getting
57
57
  * the user's camera track with getTrackBySource(Track.Source.Camera).
58
- * @param source
59
- * @returns
60
58
  */
61
- getTrack(source: Track.Source): TrackPublication | undefined;
59
+ getTrackPublication(source: Track.Source): TrackPublication | undefined;
62
60
  /**
63
61
  * Finds the first track that matches the track's name.
64
- * @param name
65
- * @returns
66
62
  */
67
- getTrackByName(name: string): TrackPublication | undefined;
63
+ getTrackPublicationByName(name: string): TrackPublication | undefined;
68
64
  get connectionQuality(): ConnectionQuality;
69
65
  get isCameraEnabled(): boolean;
70
66
  get isMicrophoneEnabled(): boolean;
@@ -8,9 +8,9 @@ import type { LoggerOptions } from '../types';
8
8
  import Participant from './Participant';
9
9
  import type { ParticipantEventCallbacks } from './Participant';
10
10
  export default class RemoteParticipant extends Participant {
11
- audioTracks: Map<string, RemoteTrackPublication>;
12
- videoTracks: Map<string, RemoteTrackPublication>;
13
- tracks: Map<string, RemoteTrackPublication>;
11
+ audioTrackPublications: Map<string, RemoteTrackPublication>;
12
+ videoTrackPublications: Map<string, RemoteTrackPublication>;
13
+ trackPublications: Map<string, RemoteTrackPublication>;
14
14
  signalClient: SignalClient;
15
15
  private volumeMap;
16
16
  private audioOutput?;
@@ -19,8 +19,8 @@ export default class RemoteParticipant extends Participant {
19
19
  /** @internal */
20
20
  constructor(signalClient: SignalClient, sid: string, identity?: string, name?: string, metadata?: string, loggerOptions?: LoggerOptions);
21
21
  protected addTrackPublication(publication: RemoteTrackPublication): void;
22
- getTrack(source: Track.Source): RemoteTrackPublication | undefined;
23
- getTrackByName(name: string): RemoteTrackPublication | undefined;
22
+ getTrackPublication(source: Track.Source): RemoteTrackPublication | undefined;
23
+ getTrackPublicationByName(name: string): RemoteTrackPublication | undefined;
24
24
  /**
25
25
  * sets the volume on the participant's audio track
26
26
  * by default, this affects the microphone publication
@@ -36,7 +36,10 @@ export default class RemoteParticipant extends Participant {
36
36
  addSubscribedMediaTrack(mediaTrack: MediaStreamTrack, sid: Track.SID, mediaStream: MediaStream, receiver?: RTCRtpReceiver, adaptiveStreamSettings?: AdaptiveStreamSettings, triesLeft?: number): RemoteTrackPublication | undefined;
37
37
  /** @internal */
38
38
  get hasMetadata(): boolean;
39
- getTrackPublication(sid: Track.SID): RemoteTrackPublication | undefined;
39
+ /**
40
+ * @internal
41
+ */
42
+ getTrackPublicationBySid(sid: Track.SID): RemoteTrackPublication | undefined;
40
43
  /** @internal */
41
44
  updateInfo(info: ParticipantInfo): boolean;
42
45
  /** @internal */
@@ -1,13 +1,12 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * Timers that can be overridden with platform specific implementations
4
3
  * that ensure that they are fired. These should be used when it is critical
5
4
  * that the timer fires on time.
6
5
  */
7
6
  export default class CriticalTimers {
8
- static setTimeout: (callback: (args: void) => void, ms?: number | undefined) => NodeJS.Timeout;
9
- static setInterval: (callback: (args: void) => void, ms?: number | undefined) => NodeJS.Timeout;
10
- static clearTimeout: (timeoutId: string | number | NodeJS.Timeout | undefined) => void;
11
- static clearInterval: (intervalId: string | number | NodeJS.Timeout | undefined) => void;
7
+ static setTimeout: (handler: TimerHandler, timeout?: number | undefined, ...arguments: any[]) => number;
8
+ static setInterval: (handler: TimerHandler, timeout?: number | undefined, ...arguments: any[]) => number;
9
+ static clearTimeout: (id: number | undefined) => void;
10
+ static clearInterval: (id: number | undefined) => void;
12
11
  }
13
12
  //# sourceMappingURL=timers.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import type { SignalClient } from '../../api/SignalClient';
2
- import { VideoLayer, VideoQuality } from '../../proto/livekit_models_pb';
2
+ import { VideoLayer } from '../../proto/livekit_models_pb';
3
3
  import { SubscribedCodec, SubscribedQuality } from '../../proto/livekit_rtc_pb';
4
4
  import type { VideoSenderStats } from '../stats';
5
5
  import type { LoggerOptions } from '../types';
6
6
  import LocalTrack from './LocalTrack';
7
- import { Track } from './Track';
7
+ import { Track, VideoQuality } from './Track';
8
8
  import type { VideoCaptureOptions, VideoCodec } from './options';
9
9
  import type { TrackProcessor } from './processor/types';
10
10
  export declare class SimulcastTrackInfo {
@@ -41,7 +41,7 @@ export default class LocalVideoTrack extends LocalTrack {
41
41
  setDeviceId(deviceId: ConstrainDOMString): Promise<boolean>;
42
42
  restartTrack(options?: VideoCaptureOptions): Promise<void>;
43
43
  setProcessor(processor: TrackProcessor<Track.Kind>, showProcessedStreamLocally?: boolean): Promise<void>;
44
- addSimulcastTrack(codec: VideoCodec, encodings?: RTCRtpEncodingParameters[]): SimulcastTrackInfo;
44
+ addSimulcastTrack(codec: VideoCodec, encodings?: RTCRtpEncodingParameters[]): SimulcastTrackInfo | undefined;
45
45
  setSimulcastTrackSender(codec: VideoCodec, sender: RTCRtpSender): void;
46
46
  /**
47
47
  * @internal
@@ -1,7 +1,7 @@
1
- import { SubscriptionError, TrackInfo, VideoQuality } from '../../proto/livekit_models_pb';
1
+ import { SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
2
2
  import type { LoggerOptions } from '../types';
3
3
  import type RemoteTrack from './RemoteTrack';
4
- import { Track } from './Track';
4
+ import { Track, VideoQuality } from './Track';
5
5
  import { TrackPublication } from './TrackPublication';
6
6
  export default class RemoteTrackPublication extends TrackPublication {
7
7
  track?: RemoteTrack;
@@ -4,6 +4,11 @@ import { StructuredLogger } from '../../logger';
4
4
  import { TrackSource, TrackType } from '../../proto/livekit_models_pb';
5
5
  import { StreamState as ProtoStreamState } from '../../proto/livekit_rtc_pb';
6
6
  import type { LoggerOptions } from '../types';
7
+ export declare enum VideoQuality {
8
+ LOW = 0,
9
+ MEDIUM = 1,
10
+ HIGH = 2
11
+ }
7
12
  declare const Track_base: new () => TypedEventEmitter<TrackEventCallbacks>;
8
13
  export declare abstract class Track extends Track_base {
9
14
  kind: Track.Kind;
@@ -28,11 +28,6 @@ export interface TrackPublishDefaults {
28
28
  * as backup. (TBD)
29
29
  */
30
30
  videoCodec?: VideoCodec;
31
- /**
32
- * max audio bitrate, defaults to [[AudioPresets.music]]
33
- * @deprecated use `audioPreset` instead
34
- */
35
- audioBitrate?: number;
36
31
  /**
37
32
  * which audio preset should be used for publishing (audio) tracks
38
33
  * defaults to [[AudioPresets.music]]
@@ -1,4 +1,3 @@
1
- import type RemoteParticipant from './participant/RemoteParticipant';
2
1
  export type SimulationOptions = {
3
2
  publish?: {
4
3
  audio?: boolean;
@@ -13,8 +12,17 @@ export type SimulationOptions = {
13
12
  };
14
13
  };
15
14
  export type DataPublishOptions = {
16
- /** the participants who will receive the message, will be sent to every one if empty */
17
- destination?: RemoteParticipant[] | string[];
15
+ /**
16
+ * whether to send this as reliable or lossy.
17
+ * For data that you need delivery guarantee (such as chat messages), use Reliable.
18
+ * For data that should arrive as quickly as possible, but you are ok with dropped
19
+ * packets, use Lossy.
20
+ */
21
+ reliable?: boolean;
22
+ /**
23
+ * the identities of participants who will receive the message, will be sent to every one if empty
24
+ */
25
+ destinationIdentities?: string[];
18
26
  /** the topic under which the message gets published */
19
27
  topic?: string;
20
28
  };
@@ -1,3 +1,3 @@
1
1
  export declare const version: string;
2
- export declare const protocolVersion = 11;
2
+ export declare const protocolVersion = 12;
3
3
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livekit-client",
3
- "version": "1.15.12",
3
+ "version": "2.0.1",
4
4
  "description": "JavaScript/TypeScript client SDK for LiveKit",
5
5
  "main": "./dist/livekit-client.umd.js",
6
6
  "unpkg": "./dist/livekit-client.umd.js",
@@ -46,8 +46,8 @@
46
46
  "webrtc-adapter": "^8.1.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/core": "7.23.7",
50
- "@babel/preset-env": "7.23.7",
49
+ "@babel/core": "7.23.9",
50
+ "@babel/preset-env": "7.23.9",
51
51
  "@bufbuild/protoc-gen-es": "^1.3.0",
52
52
  "@changesets/cli": "2.27.1",
53
53
  "@livekit/changesets-changelog-github": "^0.0.4",
@@ -71,22 +71,23 @@
71
71
  "eslint-plugin-ecmascript-compat": "^3.0.0",
72
72
  "eslint-plugin-import": "2.29.1",
73
73
  "gh-pages": "6.1.1",
74
- "jsdom": "^23.0.0",
74
+ "jsdom": "^24.0.0",
75
75
  "prettier": "^3.0.0",
76
- "rollup": "4.9.2",
76
+ "rollup": "4.9.6",
77
77
  "rollup-plugin-delete": "^2.0.0",
78
78
  "rollup-plugin-re": "1.0.7",
79
79
  "rollup-plugin-typescript2": "0.36.0",
80
80
  "size-limit": "^8.2.4",
81
- "typedoc": "0.25.6",
81
+ "typedoc": "0.25.7",
82
82
  "typedoc-plugin-no-inherit": "1.4.0",
83
83
  "typescript": "5.3.3",
84
- "vite": "5.0.10",
84
+ "vite": "5.0.12",
85
85
  "vitest": "^1.0.0"
86
86
  },
87
87
  "scripts": {
88
88
  "build": "rollup --config --bundleConfigAsCjs && rollup --config rollup.config.worker.js --bundleConfigAsCjs && pnpm downlevel-dts",
89
- "build:watch": "rollup --watch --config rollup.config.js",
89
+ "build:watch": "rollup --watch --config --bundleConfigAsCjs",
90
+ "build:worker:watch": "rollup --watch --config rollup.config.worker.js --bundleConfigAsCjs",
90
91
  "build-docs": "typedoc",
91
92
  "proto": "protoc --es_out src/proto --es_opt target=ts -I./protocol ./protocol/livekit_rtc.proto ./protocol/livekit_models.proto",
92
93
  "sample": "vite example -c vite.config.mjs",
@@ -95,7 +96,7 @@
95
96
  "deploy": "gh-pages -d example/dist",
96
97
  "format": "prettier --write src example/sample.ts",
97
98
  "format:check": "prettier --check src",
98
- "ci:publish": "pnpm build && pnpm compat && changeset publish --tag legacy",
99
+ "ci:publish": "pnpm build && pnpm compat && changeset publish",
99
100
  "downlevel-dts": "downlevel-dts ./dist/ ./dist/ts4.2 --to=4.2",
100
101
  "compat": "eslint --no-eslintrc --config ./.eslintrc.dist.cjs ./dist/livekit-client.umd.js",
101
102
  "size-limit": "size-limit"
@@ -56,8 +56,6 @@ interface ConnectOpts extends SignalOptions {
56
56
  // public options
57
57
  export interface SignalOptions {
58
58
  autoSubscribe: boolean;
59
- /** @deprecated */
60
- publishOnly?: string;
61
59
  adaptiveStream?: boolean;
62
60
  maxRetries: number;
63
61
  e2eeEnabled: boolean;
@@ -396,6 +394,8 @@ export class SignalClient {
396
394
  this.log.warn(`websocket closed`, {
397
395
  ...this.logContext,
398
396
  reason: ev.reason,
397
+ code: ev.code,
398
+ wasClean: ev.wasClean,
399
399
  state: this.state,
400
400
  });
401
401
  this.handleOnClose(ev.reason);
@@ -853,10 +853,6 @@ function createConnectionParams(token: string, info: ClientInfo, opts: ConnectOp
853
853
  params.set('browser_version', info.browserVersion);
854
854
  }
855
855
 
856
- if (opts.publishOnly !== undefined) {
857
- params.set('publish', opts.publishOnly);
858
- }
859
-
860
856
  if (opts.adaptiveStream) {
861
857
  params.set('adaptive_stream', '1');
862
858
  }
@@ -168,8 +168,8 @@ export class E2EEManager extends (EventEmitter as new () => TypedEventEmitter<E2
168
168
  room
169
169
  .on(RoomEvent.ConnectionStateChanged, (state) => {
170
170
  if (state === ConnectionState.Connected) {
171
- room.participants.forEach((participant) => {
172
- participant.tracks.forEach((pub) => {
171
+ room.remoteParticipants.forEach((participant) => {
172
+ participant.trackPublications.forEach((pub) => {
173
173
  this.setParticipantCryptorEnabled(
174
174
  pub.trackInfo!.encryption !== Encryption_Type.NONE,
175
175
  participant.identity,