livekit-client 1.4.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/dist/livekit-client.esm.mjs +510 -38
  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 +25 -0
  6. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -0
  7. package/dist/src/connectionHelper/checks/Checker.d.ts +59 -0
  8. package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -0
  9. package/dist/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  10. package/dist/src/connectionHelper/checks/publishAudio.d.ts.map +1 -0
  11. package/dist/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  12. package/dist/src/connectionHelper/checks/publishVideo.d.ts.map +1 -0
  13. package/dist/src/connectionHelper/checks/reconnect.d.ts +6 -0
  14. package/dist/src/connectionHelper/checks/reconnect.d.ts.map +1 -0
  15. package/dist/src/connectionHelper/checks/turn.d.ts +6 -0
  16. package/dist/src/connectionHelper/checks/turn.d.ts.map +1 -0
  17. package/dist/src/connectionHelper/checks/webrtc.d.ts +6 -0
  18. package/dist/src/connectionHelper/checks/webrtc.d.ts.map +1 -0
  19. package/dist/src/connectionHelper/checks/websocket.d.ts +6 -0
  20. package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -0
  21. package/dist/src/index.d.ts +3 -1
  22. package/dist/src/index.d.ts.map +1 -1
  23. package/dist/src/proto/livekit_rtc.d.ts +8 -0
  24. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  25. package/dist/src/room/DeviceManager.d.ts.map +1 -1
  26. package/dist/src/room/Room.d.ts +6 -0
  27. package/dist/src/room/Room.d.ts.map +1 -1
  28. package/dist/src/room/events.d.ts +5 -1
  29. package/dist/src/room/events.d.ts.map +1 -1
  30. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  31. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  32. package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -0
  33. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  34. package/dist/ts4.2/src/api/SignalClient.d.ts +85 -0
  35. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +25 -0
  36. package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +59 -0
  37. package/dist/ts4.2/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  38. package/dist/ts4.2/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  39. package/dist/ts4.2/src/connectionHelper/checks/reconnect.d.ts +6 -0
  40. package/dist/ts4.2/src/connectionHelper/checks/turn.d.ts +6 -0
  41. package/dist/ts4.2/src/connectionHelper/checks/webrtc.d.ts +6 -0
  42. package/dist/ts4.2/src/connectionHelper/checks/websocket.d.ts +6 -0
  43. package/dist/ts4.2/src/index.d.ts +30 -0
  44. package/dist/ts4.2/src/logger.d.ts +26 -0
  45. package/dist/ts4.2/src/options.d.ts +91 -0
  46. package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +141 -0
  47. package/dist/ts4.2/src/proto/livekit_models.d.ts +1421 -0
  48. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +7122 -0
  49. package/dist/ts4.2/src/room/DefaultReconnectPolicy.d.ts +8 -0
  50. package/dist/ts4.2/src/room/DeviceManager.d.ts +9 -0
  51. package/dist/ts4.2/src/room/PCTransport.d.ts +33 -0
  52. package/dist/ts4.2/src/room/RTCEngine.d.ts +96 -0
  53. package/dist/ts4.2/src/room/ReconnectPolicy.d.ts +23 -0
  54. package/dist/ts4.2/src/room/Room.d.ts +203 -0
  55. package/dist/ts4.2/src/room/defaults.d.ts +8 -0
  56. package/dist/ts4.2/src/room/errors.d.ts +39 -0
  57. package/dist/ts4.2/src/room/events.d.ts +422 -0
  58. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +141 -0
  59. package/dist/ts4.2/src/room/participant/Participant.d.ts +92 -0
  60. package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +26 -0
  61. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +52 -0
  62. package/dist/ts4.2/src/room/participant/publishUtils.d.ts +19 -0
  63. package/dist/ts4.2/src/room/stats.d.ts +67 -0
  64. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +25 -0
  65. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +42 -0
  66. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +38 -0
  67. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +53 -0
  68. package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +53 -0
  69. package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +15 -0
  70. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +61 -0
  71. package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +52 -0
  72. package/dist/ts4.2/src/room/track/Track.d.ts +121 -0
  73. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +68 -0
  74. package/dist/ts4.2/src/room/track/create.d.ts +24 -0
  75. package/dist/ts4.2/src/room/track/options.d.ts +241 -0
  76. package/dist/ts4.2/src/room/track/types.d.ts +23 -0
  77. package/dist/ts4.2/src/room/track/utils.d.ts +14 -0
  78. package/dist/ts4.2/src/room/utils.d.ts +35 -0
  79. package/dist/ts4.2/src/test/MockMediaStreamTrack.d.ts +26 -0
  80. package/dist/ts4.2/src/test/mocks.d.ts +11 -0
  81. package/dist/ts4.2/src/version.d.ts +3 -0
  82. package/package.json +13 -3
  83. package/src/api/SignalClient.ts +2 -2
  84. package/src/connectionHelper/ConnectionCheck.ts +90 -0
  85. package/src/connectionHelper/checks/Checker.ts +164 -0
  86. package/src/connectionHelper/checks/publishAudio.ts +33 -0
  87. package/src/connectionHelper/checks/publishVideo.ts +33 -0
  88. package/src/connectionHelper/checks/reconnect.ts +45 -0
  89. package/src/connectionHelper/checks/turn.ts +53 -0
  90. package/src/connectionHelper/checks/webrtc.ts +18 -0
  91. package/src/connectionHelper/checks/websocket.ts +22 -0
  92. package/src/index.ts +3 -1
  93. package/src/proto/livekit_rtc.ts +12 -1
  94. package/src/room/DeviceManager.ts +0 -17
  95. package/src/room/Room.ts +22 -2
  96. package/src/room/events.ts +5 -0
  97. package/src/room/participant/LocalParticipant.ts +15 -8
  98. package/src/room/track/LocalTrack.ts +3 -0
  99. package/src/room/track/RemoteTrackPublication.ts +20 -0
@@ -0,0 +1,24 @@
1
+ import LocalAudioTrack from './LocalAudioTrack';
2
+ import type LocalTrack from './LocalTrack';
3
+ import LocalVideoTrack from './LocalVideoTrack';
4
+ import { AudioCaptureOptions, CreateLocalTracksOptions, ScreenShareCaptureOptions, VideoCaptureOptions } from './options';
5
+ /**
6
+ * Creates a local video and audio track at the same time. When acquiring both
7
+ * audio and video tracks together, it'll display a single permission prompt to
8
+ * the user instead of two separate ones.
9
+ * @param options
10
+ */
11
+ export declare function createLocalTracks(options?: CreateLocalTracksOptions): Promise<Array<LocalTrack>>;
12
+ /**
13
+ * Creates a [[LocalVideoTrack]] with getUserMedia()
14
+ * @param options
15
+ */
16
+ export declare function createLocalVideoTrack(options?: VideoCaptureOptions): Promise<LocalVideoTrack>;
17
+ export declare function createLocalAudioTrack(options?: AudioCaptureOptions): Promise<LocalAudioTrack>;
18
+ /**
19
+ * Creates a screen capture tracks with getDisplayMedia().
20
+ * A LocalVideoTrack is always created and returned.
21
+ * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
22
+ */
23
+ export declare function createLocalScreenTracks(options?: ScreenShareCaptureOptions): Promise<Array<LocalTrack>>;
24
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1,241 @@
1
+ import type { Track } from './Track';
2
+ export interface TrackPublishDefaults {
3
+ /**
4
+ * encoding parameters for camera track
5
+ */
6
+ videoEncoding?: VideoEncoding;
7
+ /**
8
+ * @experimental
9
+ */
10
+ backupCodec?: {
11
+ codec: BackupVideoCodec;
12
+ encoding: VideoEncoding;
13
+ } | false;
14
+ /**
15
+ * encoding parameters for screen share track
16
+ */
17
+ screenShareEncoding?: VideoEncoding;
18
+ /**
19
+ * codec, defaults to vp8; for svc codecs, auto enable vp8
20
+ * as backup. (TBD)
21
+ */
22
+ videoCodec?: VideoCodec;
23
+ /**
24
+ * max audio bitrate, defaults to [[AudioPresets.speech]]
25
+ */
26
+ audioBitrate?: number;
27
+ /**
28
+ * dtx (Discontinuous Transmission of audio), defaults to true
29
+ */
30
+ dtx?: boolean;
31
+ /**
32
+ * red (Redundant Audio Data), defaults to true
33
+ */
34
+ red?: boolean;
35
+ /**
36
+ * stereo audio track. defaults determined by capture channel count.
37
+ */
38
+ forceStereo?: boolean;
39
+ /**
40
+ * use simulcast, defaults to true.
41
+ * When using simulcast, LiveKit will publish up to three versions of the stream
42
+ * at various resolutions.
43
+ */
44
+ simulcast?: boolean;
45
+ /**
46
+ * scalability mode for svc codecs, defaults to 'L3T3'.
47
+ * for svc codecs, simulcast is disabled.
48
+ */
49
+ scalabilityMode?: ScalabilityMode;
50
+ /**
51
+ * custom video simulcast layers for camera tracks, defaults to h180, h360, h540
52
+ * You can specify up to two custom layers that will be used instead of
53
+ * the LiveKit default layers.
54
+ * Note: the layers need to be ordered from lowest to highest quality
55
+ */
56
+ videoSimulcastLayers?: Array<VideoPreset>;
57
+ /**
58
+ * custom video simulcast layers for screen tracks
59
+ * Note: the layers need to be ordered from lowest to highest quality
60
+ */
61
+ screenShareSimulcastLayers?: Array<VideoPreset>;
62
+ /**
63
+ * For local tracks, stop the underlying MediaStreamTrack when the track is muted (or paused)
64
+ * on some platforms, this option is necessary to disable the microphone recording indicator.
65
+ * Note: when this is enabled, and BT devices are connected, they will transition between
66
+ * profiles (e.g. HFP to A2DP) and there will be an audible difference in playback.
67
+ *
68
+ * defaults to false
69
+ */
70
+ stopMicTrackOnMute?: boolean;
71
+ }
72
+ /**
73
+ * Options when publishing tracks
74
+ */
75
+ export interface TrackPublishOptions extends TrackPublishDefaults {
76
+ /**
77
+ * set a track name
78
+ */
79
+ name?: string;
80
+ /**
81
+ * Source of track, camera, microphone, or screen
82
+ */
83
+ source?: Track.Source;
84
+ }
85
+ export interface CreateLocalTracksOptions {
86
+ /**
87
+ * audio track options, true to create with defaults. false if audio shouldn't be created
88
+ * default true
89
+ */
90
+ audio?: boolean | AudioCaptureOptions;
91
+ /**
92
+ * video track options, true to create with defaults. false if video shouldn't be created
93
+ * default true
94
+ */
95
+ video?: boolean | VideoCaptureOptions;
96
+ }
97
+ export interface VideoCaptureOptions {
98
+ /**
99
+ * A ConstrainDOMString object specifying a device ID or an array of device
100
+ * IDs which are acceptable and/or required.
101
+ */
102
+ deviceId?: ConstrainDOMString;
103
+ /**
104
+ * a facing or an array of facings which are acceptable and/or required.
105
+ */
106
+ facingMode?: 'user' | 'environment' | 'left' | 'right';
107
+ resolution?: VideoResolution;
108
+ }
109
+ export interface ScreenShareCaptureOptions {
110
+ /**
111
+ * true to capture audio shared. browser support for audio capturing in
112
+ * screenshare is limited: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#browser_compatibility
113
+ */
114
+ audio?: boolean | AudioCaptureOptions;
115
+ /** capture resolution, defaults to full HD */
116
+ resolution?: VideoResolution;
117
+ }
118
+ export interface AudioCaptureOptions {
119
+ /**
120
+ * specifies whether automatic gain control is preferred and/or required
121
+ */
122
+ autoGainControl?: ConstrainBoolean;
123
+ /**
124
+ * the channel count or range of channel counts which are acceptable and/or required
125
+ */
126
+ channelCount?: ConstrainULong;
127
+ /**
128
+ * A ConstrainDOMString object specifying a device ID or an array of device
129
+ * IDs which are acceptable and/or required.
130
+ */
131
+ deviceId?: ConstrainDOMString;
132
+ /**
133
+ * whether or not echo cancellation is preferred and/or required
134
+ */
135
+ echoCancellation?: ConstrainBoolean;
136
+ /**
137
+ * the latency or range of latencies which are acceptable and/or required.
138
+ */
139
+ latency?: ConstrainDouble;
140
+ /**
141
+ * whether noise suppression is preferred and/or required.
142
+ */
143
+ noiseSuppression?: ConstrainBoolean;
144
+ /**
145
+ * the sample rate or range of sample rates which are acceptable and/or required.
146
+ */
147
+ sampleRate?: ConstrainULong;
148
+ /**
149
+ * sample size or range of sample sizes which are acceptable and/or required.
150
+ */
151
+ sampleSize?: ConstrainULong;
152
+ }
153
+ export interface AudioOutputOptions {
154
+ /**
155
+ * deviceId to output audio
156
+ *
157
+ * Only supported on browsers where `setSinkId` is available
158
+ */
159
+ deviceId?: string;
160
+ }
161
+ export interface VideoResolution {
162
+ width: number;
163
+ height: number;
164
+ frameRate?: number;
165
+ aspectRatio?: number;
166
+ }
167
+ export interface VideoEncoding {
168
+ maxBitrate: number;
169
+ maxFramerate?: number;
170
+ }
171
+ export declare class VideoPreset {
172
+ encoding: VideoEncoding;
173
+ width: number;
174
+ height: number;
175
+ constructor(width: number, height: number, maxBitrate: number, maxFramerate?: number);
176
+ get resolution(): VideoResolution;
177
+ }
178
+ export interface AudioPreset {
179
+ maxBitrate: number;
180
+ }
181
+ declare const codecs: readonly [
182
+ "vp8",
183
+ "h264",
184
+ "av1"
185
+ ];
186
+ declare const backupCodecs: readonly [
187
+ "vp8",
188
+ "h264"
189
+ ];
190
+ export declare type VideoCodec = typeof codecs[number];
191
+ export declare type BackupVideoCodec = typeof backupCodecs[number];
192
+ export declare function isBackupCodec(codec: string): codec is BackupVideoCodec;
193
+ /**
194
+ * scalability modes for svc, only supprot l3t3 now.
195
+ */
196
+ export declare type ScalabilityMode = 'L3T3';
197
+ export declare namespace AudioPresets {
198
+ const telephone: AudioPreset;
199
+ const speech: AudioPreset;
200
+ const music: AudioPreset;
201
+ const musicStereo: AudioPreset;
202
+ const musicHighQuality: AudioPreset;
203
+ const musicHighQualityStereo: AudioPreset;
204
+ }
205
+ /**
206
+ * Sane presets for video resolution/encoding
207
+ */
208
+ export declare const VideoPresets: {
209
+ readonly h90: VideoPreset;
210
+ readonly h180: VideoPreset;
211
+ readonly h216: VideoPreset;
212
+ readonly h360: VideoPreset;
213
+ readonly h540: VideoPreset;
214
+ readonly h720: VideoPreset;
215
+ readonly h1080: VideoPreset;
216
+ readonly h1440: VideoPreset;
217
+ readonly h2160: VideoPreset;
218
+ };
219
+ /**
220
+ * Four by three presets
221
+ */
222
+ export declare const VideoPresets43: {
223
+ readonly h120: VideoPreset;
224
+ readonly h180: VideoPreset;
225
+ readonly h240: VideoPreset;
226
+ readonly h360: VideoPreset;
227
+ readonly h480: VideoPreset;
228
+ readonly h540: VideoPreset;
229
+ readonly h720: VideoPreset;
230
+ readonly h1080: VideoPreset;
231
+ readonly h1440: VideoPreset;
232
+ };
233
+ export declare const ScreenSharePresets: {
234
+ readonly h360fps3: VideoPreset;
235
+ readonly h720fps5: VideoPreset;
236
+ readonly h720fps15: VideoPreset;
237
+ readonly h1080fps15: VideoPreset;
238
+ readonly h1080fps30: VideoPreset;
239
+ };
240
+ export {};
241
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1,23 @@
1
+ import type LocalAudioTrack from './LocalAudioTrack';
2
+ import type LocalVideoTrack from './LocalVideoTrack';
3
+ import type RemoteAudioTrack from './RemoteAudioTrack';
4
+ import type RemoteVideoTrack from './RemoteVideoTrack';
5
+ export declare type AudioTrack = RemoteAudioTrack | LocalAudioTrack;
6
+ export declare type VideoTrack = RemoteVideoTrack | LocalVideoTrack;
7
+ export declare type AdaptiveStreamSettings = {
8
+ /**
9
+ * Set a custom pixel density, defaults to 1
10
+ * When streaming videos on a ultra high definition screen this setting
11
+ * let's you account for the devicePixelRatio of those screens.
12
+ * Set it to `screen` to use the actual pixel density of the screen
13
+ * Note: this might significantly increase the bandwidth consumed by people
14
+ * streaming on high definition screens.
15
+ */
16
+ pixelDensity?: number | 'screen';
17
+ /**
18
+ * If true, video gets paused when switching to another tab.
19
+ * Defaults to true.
20
+ */
21
+ pauseVideoInBackground?: boolean;
22
+ };
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { AudioCaptureOptions, CreateLocalTracksOptions, VideoCaptureOptions } from './options';
2
+ import type { AudioTrack } from './types';
3
+ export declare function mergeDefaultOptions(options?: CreateLocalTracksOptions, audioDefaults?: AudioCaptureOptions, videoDefaults?: VideoCaptureOptions): CreateLocalTracksOptions;
4
+ export declare function constraintsForOptions(options: CreateLocalTracksOptions): MediaStreamConstraints;
5
+ /**
6
+ * This function detects silence on a given [[Track]] instance.
7
+ * Returns true if the track seems to be entirely silent.
8
+ */
9
+ export declare function detectSilence(track: AudioTrack, timeOffset?: number): Promise<boolean>;
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare function getNewAudioContext(): AudioContext | void;
14
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { ClientInfo } from '../proto/livekit_models';
2
+ export declare function unpackStreamId(packed: string): string[];
3
+ export declare function sleep(duration: number): Promise<void>;
4
+ /** @internal */
5
+ export declare function supportsTransceiver(): boolean;
6
+ /** @internal */
7
+ export declare function supportsAddTrack(): boolean;
8
+ export declare function supportsAdaptiveStream(): boolean;
9
+ export declare function supportsDynacast(): boolean;
10
+ export declare function supportsAV1(): boolean;
11
+ export declare function supportsSetSinkId(elm?: HTMLMediaElement): boolean;
12
+ export declare function supportsSetCodecPreferences(transceiver: RTCRtpTransceiver): boolean;
13
+ export declare function isBrowserSupported(): boolean;
14
+ export declare function isFireFox(): boolean;
15
+ export declare function isSafari(): boolean;
16
+ export declare function isMobile(): boolean;
17
+ export declare function isWeb(): boolean;
18
+ export declare function compareVersions(v1: string, v2: string): number;
19
+ export declare const getResizeObserver: () => ResizeObserver;
20
+ export declare const getIntersectionObserver: () => IntersectionObserver;
21
+ export interface ObservableMediaElement extends HTMLMediaElement {
22
+ handleResize: (entry: ResizeObserverEntry) => void;
23
+ handleVisibilityChanged: (entry: IntersectionObserverEntry) => void;
24
+ }
25
+ export declare function getClientInfo(): ClientInfo;
26
+ export declare function getEmptyVideoStreamTrack(): MediaStreamTrack;
27
+ export declare function getEmptyAudioStreamTrack(): MediaStreamTrack;
28
+ export declare class Future<T> {
29
+ promise: Promise<T>;
30
+ resolve?: (arg: T) => void;
31
+ reject?: (e: any) => void;
32
+ onFinally?: () => void;
33
+ constructor(futureBase?: (resolve: (arg: T) => void, reject: (e: any) => void) => void, onFinally?: () => void);
34
+ }
35
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,26 @@
1
+ export default class MockMediaStreamTrack implements MediaStreamTrack {
2
+ contentHint: string;
3
+ enabled: boolean;
4
+ id: string;
5
+ kind: string;
6
+ label: string;
7
+ muted: boolean;
8
+ onended: ((this: MediaStreamTrack, ev: Event) => any) | null;
9
+ onmute: ((this: MediaStreamTrack, ev: Event) => any) | null;
10
+ onunmute: ((this: MediaStreamTrack, ev: Event) => any) | null;
11
+ readyState: MediaStreamTrackState;
12
+ isolated: boolean;
13
+ onisolationchange: ((this: MediaStreamTrack, ev: Event) => any) | null;
14
+ applyConstraints(constraints?: MediaTrackConstraints): Promise<void>;
15
+ clone(): MediaStreamTrack;
16
+ getCapabilities(): MediaTrackCapabilities;
17
+ getConstraints(): MediaTrackConstraints;
18
+ getSettings(): MediaTrackSettings;
19
+ stop(): void;
20
+ addEventListener<K extends keyof MediaStreamTrackEventMap>(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
21
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
22
+ removeEventListener<K extends keyof MediaStreamTrackEventMap>(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
23
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
24
+ dispatchEvent(event: Event): boolean;
25
+ }
26
+ //# sourceMappingURL=MockMediaStreamTrack.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { SignalClient } from '../api/SignalClient';
2
+ import RTCEngine from '../room/RTCEngine';
3
+ declare const mocks: {
4
+ SignalClient: jest.MockedClass<typeof SignalClient>;
5
+ RTCEngine: jest.MockedClass<typeof RTCEngine>;
6
+ MockLocalVideoTrack: {
7
+ stop: jest.Mock<any, any>;
8
+ };
9
+ };
10
+ export default mocks;
11
+ //# sourceMappingURL=mocks.d.ts.map
@@ -0,0 +1,3 @@
1
+ export declare const version: string;
2
+ export declare const protocolVersion = 8;
3
+ //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livekit-client",
3
- "version": "1.4.4",
3
+ "version": "1.5.0",
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",
@@ -15,11 +15,18 @@
15
15
  "src"
16
16
  ],
17
17
  "types": "dist/src/index.d.ts",
18
+ "typesVersions": {
19
+ "<4.8": {
20
+ "./dist/src/index.d.ts": [
21
+ "./dist/src/ts4.2/index.d.ts"
22
+ ]
23
+ }
24
+ },
18
25
  "repository": "git@github.com:livekit/client-sdk-js.git",
19
26
  "author": "David Zhao <david@davidzhao.com>",
20
27
  "license": "Apache-2.0",
21
28
  "scripts": {
22
- "build": "rollup --config",
29
+ "build": "rollup --config && yarn downlevel-dts",
23
30
  "build:watch": "rollup --watch --config rollup.config.js",
24
31
  "build-docs": "typedoc",
25
32
  "proto": "protoc --plugin=node_modules/ts-proto/protoc-gen-ts_proto --ts_proto_opt=esModuleInterop=true --ts_proto_out=./src/proto --ts_proto_opt=outputClientImpl=false,useOptionals=messages,oneof=unions -I./protocol ./protocol/livekit_rtc.proto ./protocol/livekit_models.proto",
@@ -29,7 +36,8 @@
29
36
  "deploy": "gh-pages -d example/dist",
30
37
  "format": "prettier --write src example/sample.ts",
31
38
  "format:check": "prettier --check src",
32
- "release": "yarn build && changeset publish"
39
+ "release": "yarn build && changeset publish",
40
+ "downlevel-dts": "downlevel-dts ./dist/ ./dist/ts4.2 --to=4.2"
33
41
  },
34
42
  "dependencies": {
35
43
  "async-await-queue": "^1.2.1",
@@ -57,6 +65,7 @@
57
65
  "@types/ws": "8.5.3",
58
66
  "@typescript-eslint/eslint-plugin": "5.38.1",
59
67
  "@typescript-eslint/parser": "5.38.1",
68
+ "downlevel-dts": "^0.11.0",
60
69
  "eslint": "8.24.0",
61
70
  "eslint-config-airbnb-typescript": "17.0.0",
62
71
  "eslint-config-prettier": "8.5.0",
@@ -65,6 +74,7 @@
65
74
  "jest": "29.1.2",
66
75
  "prettier": "2.7.1",
67
76
  "rollup": "2.79.1",
77
+ "rollup-plugin-delete": "^2.0.0",
68
78
  "rollup-plugin-filesize": "9.1.2",
69
79
  "rollup-plugin-re": "1.0.7",
70
80
  "rollup-plugin-terser": "7.0.2",
@@ -441,8 +441,8 @@ export class SignalClient {
441
441
  if (this.signalLatency) {
442
442
  await sleep(this.signalLatency);
443
443
  }
444
- if (!this.ws) {
445
- log.error('cannot send signal request before connected');
444
+ if (!this.ws || this.ws.readyState < this.ws.OPEN) {
445
+ log.error(`cannot send signal request before connected, type: ${message?.$case}`);
446
446
  return;
447
447
  }
448
448
 
@@ -0,0 +1,90 @@
1
+ import EventEmitter from 'events';
2
+ import type TypedEmitter from 'typed-emitter';
3
+
4
+ import { Checker, CheckInfo, CheckStatus, InstantiableCheck } from './checks/Checker';
5
+ import { PublishAudioCheck } from './checks/publishAudio';
6
+ import { PublishVideoCheck } from './checks/publishVideo';
7
+ import { ReconnectCheck } from './checks/reconnect';
8
+ import { TURNCheck } from './checks/turn';
9
+ import { WebRTCCheck } from './checks/webrtc';
10
+ import { WebSocketCheck } from './checks/websocket';
11
+
12
+ export type { CheckInfo };
13
+
14
+ export class ConnectionCheck extends (EventEmitter as new () => TypedEmitter<ConnectionCheckCallbacks>) {
15
+ token: string;
16
+
17
+ url: string;
18
+
19
+ private checkResults: Map<number, CheckInfo> = new Map();
20
+
21
+ constructor(url: string, token: string) {
22
+ super();
23
+ this.url = url;
24
+ this.token = token;
25
+ }
26
+
27
+ private getNextCheckId() {
28
+ const nextId = this.checkResults.size;
29
+ this.checkResults.set(nextId, {
30
+ logs: [],
31
+ status: CheckStatus.IDLE,
32
+ name: '',
33
+ description: '',
34
+ });
35
+ return nextId;
36
+ }
37
+
38
+ private updateCheck(checkId: number, info: CheckInfo) {
39
+ this.checkResults.set(checkId, info);
40
+ this.emit('checkUpdate', checkId, info);
41
+ }
42
+
43
+ isSuccess() {
44
+ return Array.from(this.checkResults.values()).every((r) => r.status !== CheckStatus.FAILED);
45
+ }
46
+
47
+ getResults() {
48
+ return Array.from(this.checkResults.values());
49
+ }
50
+
51
+ async createAndRunCheck<T extends Checker>(check: InstantiableCheck<T>) {
52
+ const checkId = this.getNextCheckId();
53
+ const test = new check(this.url, this.token);
54
+ const handleUpdate = (info: CheckInfo) => {
55
+ this.updateCheck(checkId, info);
56
+ };
57
+ test.on('update', handleUpdate);
58
+ const result = await test.run();
59
+ test.off('update', handleUpdate);
60
+ return result;
61
+ }
62
+
63
+ async checkWebsocket() {
64
+ return this.createAndRunCheck(WebSocketCheck);
65
+ }
66
+
67
+ async checkWebRTC() {
68
+ return this.createAndRunCheck(WebRTCCheck);
69
+ }
70
+
71
+ async checkTURN() {
72
+ return this.createAndRunCheck(TURNCheck);
73
+ }
74
+
75
+ async checkReconnect() {
76
+ return this.createAndRunCheck(ReconnectCheck);
77
+ }
78
+
79
+ async checkPublishAudio() {
80
+ return this.createAndRunCheck(PublishAudioCheck);
81
+ }
82
+
83
+ async checkPublishVideo() {
84
+ return this.createAndRunCheck(PublishVideoCheck);
85
+ }
86
+ }
87
+
88
+ type ConnectionCheckCallbacks = {
89
+ checkUpdate: (id: number, info: CheckInfo) => void;
90
+ };