livekit-client 2.22.3 → 2.22.4

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 (214) hide show
  1. package/README.md +35 -0
  2. package/dist/livekit-client.e2ee.worker.js +1 -1
  3. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  4. package/dist/livekit-client.e2ee.worker.mjs +2 -1
  5. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  6. package/dist/livekit-client.esm.mjs +602 -247
  7. package/dist/livekit-client.esm.mjs.map +1 -1
  8. package/dist/livekit-client.fm.worker.js +1 -1
  9. package/dist/livekit-client.fm.worker.js.map +1 -1
  10. package/dist/livekit-client.fm.worker.mjs +2 -1
  11. package/dist/livekit-client.fm.worker.mjs.map +1 -1
  12. package/dist/livekit-client.umd.js +1 -1
  13. package/dist/livekit-client.umd.js.map +1 -1
  14. package/dist/src/api/SignalClient.d.ts +4 -2
  15. package/dist/src/api/SignalClient.d.ts.map +1 -1
  16. package/dist/src/options.d.ts +14 -0
  17. package/dist/src/options.d.ts.map +1 -1
  18. package/dist/src/room/PCTransport.d.ts +78 -7
  19. package/dist/src/room/PCTransport.d.ts.map +1 -1
  20. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  21. package/dist/src/room/RTCEngine.d.ts +8 -0
  22. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  23. package/dist/src/room/Room.d.ts +1 -1
  24. package/dist/src/room/Room.d.ts.map +1 -1
  25. package/dist/src/room/defaults.d.ts.map +1 -1
  26. package/dist/src/room/errors.d.ts +18 -0
  27. package/dist/src/room/errors.d.ts.map +1 -1
  28. package/dist/src/room/events.d.ts +3 -2
  29. package/dist/src/room/events.d.ts.map +1 -1
  30. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  31. package/dist/src/room/rpc/client/RpcClientManager.d.ts.map +1 -1
  32. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  33. package/dist/src/room/track/LocalVideoTrack.d.ts +2 -0
  34. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  35. package/dist/src/room/track/utils.d.ts +13 -0
  36. package/dist/src/room/track/utils.d.ts.map +1 -1
  37. package/dist/src/room/utils.d.ts +32 -0
  38. package/dist/src/room/utils.d.ts.map +1 -1
  39. package/dist/src/test/compressionStreamStubs.d.ts +12 -0
  40. package/dist/src/test/compressionStreamStubs.d.ts.map +1 -0
  41. package/dist/ts4.2/api/SignalClient.d.ts +187 -185
  42. package/dist/ts4.2/api/SignalClientStateMachine.d.ts +85 -85
  43. package/dist/ts4.2/api/WebSocketStream.d.ts +33 -33
  44. package/dist/ts4.2/api/utils.d.ts +9 -9
  45. package/dist/ts4.2/connectionHelper/ConnectionCheck.d.ts +30 -30
  46. package/dist/ts4.2/connectionHelper/checks/Checker.d.ts +62 -62
  47. package/dist/ts4.2/connectionHelper/checks/cloudRegion.d.ts +18 -18
  48. package/dist/ts4.2/connectionHelper/checks/connectionProtocol.d.ts +20 -20
  49. package/dist/ts4.2/connectionHelper/checks/publishAudio.d.ts +6 -6
  50. package/dist/ts4.2/connectionHelper/checks/publishVideo.d.ts +7 -7
  51. package/dist/ts4.2/connectionHelper/checks/reconnect.d.ts +6 -6
  52. package/dist/ts4.2/connectionHelper/checks/turn.d.ts +6 -6
  53. package/dist/ts4.2/connectionHelper/checks/webrtc.d.ts +6 -6
  54. package/dist/ts4.2/connectionHelper/checks/websocket.d.ts +6 -6
  55. package/dist/ts4.2/e2ee/E2eeManager.d.ts +111 -111
  56. package/dist/ts4.2/e2ee/KeyProvider.d.ts +54 -54
  57. package/dist/ts4.2/e2ee/constants.d.ts +21 -21
  58. package/dist/ts4.2/e2ee/errors.d.ts +12 -12
  59. package/dist/ts4.2/e2ee/events.d.ts +39 -39
  60. package/dist/ts4.2/e2ee/index.d.ts +6 -6
  61. package/dist/ts4.2/e2ee/types.d.ts +231 -231
  62. package/dist/ts4.2/e2ee/utils.d.ts +32 -32
  63. package/dist/ts4.2/e2ee/worker/DataCryptor.d.ts +16 -16
  64. package/dist/ts4.2/e2ee/worker/ErrorRateLimiter.d.ts +21 -21
  65. package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +209 -209
  66. package/dist/ts4.2/e2ee/worker/ParticipantKeyHandler.d.ts +81 -84
  67. package/dist/ts4.2/e2ee/worker/e2ee.worker.d.ts +2 -2
  68. package/dist/ts4.2/e2ee/worker/naluUtils.d.ts +28 -28
  69. package/dist/ts4.2/e2ee/worker/sifPayload.d.ts +23 -23
  70. package/dist/ts4.2/frameMetadata/FrameMetadataManager.d.ts +53 -53
  71. package/dist/ts4.2/frameMetadata/frameMetadata.d.ts +33 -33
  72. package/dist/ts4.2/frameMetadata/types.d.ts +62 -62
  73. package/dist/ts4.2/frameMetadata/utils.d.ts +9 -9
  74. package/dist/ts4.2/frameMetadata/worker/frameMetadata.worker.d.ts +2 -2
  75. package/dist/ts4.2/index.d.ts +76 -76
  76. package/dist/ts4.2/logger.d.ts +66 -66
  77. package/dist/ts4.2/options.d.ts +163 -149
  78. package/dist/ts4.2/room/BackOffStrategy.d.ts +27 -27
  79. package/dist/ts4.2/room/DefaultReconnectPolicy.d.ts +8 -8
  80. package/dist/ts4.2/room/DeviceManager.d.ts +12 -12
  81. package/dist/ts4.2/room/PCTransport.d.ts +246 -175
  82. package/dist/ts4.2/room/PCTransportManager.d.ts +77 -77
  83. package/dist/ts4.2/room/RTCEngine.d.ts +269 -262
  84. package/dist/ts4.2/room/ReconnectPolicy.d.ts +24 -24
  85. package/dist/ts4.2/room/RegionUrlProvider.d.ts +36 -36
  86. package/dist/ts4.2/room/Room.d.ts +354 -365
  87. package/dist/ts4.2/room/attribute-typings.d.ts +35 -35
  88. package/dist/ts4.2/room/data-channel/DataChannelManager.d.ts +62 -62
  89. package/dist/ts4.2/room/data-channel/FlowControlledDataChannel.d.ts +94 -95
  90. package/dist/ts4.2/room/data-channel/LossyDataChannel.d.ts +41 -41
  91. package/dist/ts4.2/room/data-channel/ReliableDataChannel.d.ts +57 -57
  92. package/dist/ts4.2/room/data-channel/types.d.ts +12 -12
  93. package/dist/ts4.2/room/data-stream/compression.d.ts +49 -49
  94. package/dist/ts4.2/room/data-stream/constants.d.ts +18 -18
  95. package/dist/ts4.2/room/data-stream/incoming/IncomingDataStreamManager.d.ts +29 -29
  96. package/dist/ts4.2/room/data-stream/incoming/StreamReader.d.ts +80 -80
  97. package/dist/ts4.2/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts +73 -73
  98. package/dist/ts4.2/room/data-stream/outgoing/StreamWriter.d.ts +16 -16
  99. package/dist/ts4.2/room/data-stream/outgoing/header-utils.d.ts +18 -18
  100. package/dist/ts4.2/room/data-track/LocalDataTrack.d.ts +79 -80
  101. package/dist/ts4.2/room/data-track/RemoteDataTrack.d.ts +50 -50
  102. package/dist/ts4.2/room/data-track/depacketizer.d.ts +59 -59
  103. package/dist/ts4.2/room/data-track/frame.d.ts +22 -22
  104. package/dist/ts4.2/room/data-track/handle.d.ts +27 -27
  105. package/dist/ts4.2/room/data-track/incoming/IncomingDataTrackManager.d.ts +124 -124
  106. package/dist/ts4.2/room/data-track/incoming/errors.d.ts +24 -24
  107. package/dist/ts4.2/room/data-track/incoming/pipeline.d.ts +41 -41
  108. package/dist/ts4.2/room/data-track/incoming/types.d.ts +20 -20
  109. package/dist/ts4.2/room/data-track/outgoing/OutgoingDataTrackManager.d.ts +126 -126
  110. package/dist/ts4.2/room/data-track/outgoing/errors.d.ts +74 -74
  111. package/dist/ts4.2/room/data-track/outgoing/pipeline.d.ts +23 -23
  112. package/dist/ts4.2/room/data-track/outgoing/types.d.ts +48 -48
  113. package/dist/ts4.2/room/data-track/packet/constants.d.ts +20 -20
  114. package/dist/ts4.2/room/data-track/packet/errors.d.ts +40 -40
  115. package/dist/ts4.2/room/data-track/packet/extensions.d.ts +69 -69
  116. package/dist/ts4.2/room/data-track/packet/index.d.ts +98 -98
  117. package/dist/ts4.2/room/data-track/packet/serializable.d.ts +13 -13
  118. package/dist/ts4.2/room/data-track/packetizer.d.ts +43 -43
  119. package/dist/ts4.2/room/data-track/track-interfaces.d.ts +23 -23
  120. package/dist/ts4.2/room/data-track/types.d.ts +22 -22
  121. package/dist/ts4.2/room/data-track/utils.d.ts +60 -60
  122. package/dist/ts4.2/room/debounce.d.ts +11 -11
  123. package/dist/ts4.2/room/defaults.d.ts +9 -9
  124. package/dist/ts4.2/room/errors.d.ts +180 -162
  125. package/dist/ts4.2/room/events.d.ts +638 -637
  126. package/dist/ts4.2/room/participant/LocalParticipant.d.ts +287 -287
  127. package/dist/ts4.2/room/participant/Participant.d.ts +142 -144
  128. package/dist/ts4.2/room/participant/ParticipantTrackPermission.d.ts +26 -26
  129. package/dist/ts4.2/room/participant/RemoteParticipant.d.ts +85 -86
  130. package/dist/ts4.2/room/participant/publishUtils.d.ts +53 -53
  131. package/dist/ts4.2/room/rpc/client/RpcClientManager.d.ts +43 -43
  132. package/dist/ts4.2/room/rpc/client/events.d.ts +8 -8
  133. package/dist/ts4.2/room/rpc/index.d.ts +7 -7
  134. package/dist/ts4.2/room/rpc/server/RpcServerManager.d.ts +44 -44
  135. package/dist/ts4.2/room/rpc/server/events.d.ts +8 -8
  136. package/dist/ts4.2/room/rpc/utils.d.ts +131 -131
  137. package/dist/ts4.2/room/stats.d.ts +71 -71
  138. package/dist/ts4.2/room/statsSummary.d.ts +13 -13
  139. package/dist/ts4.2/room/timers.d.ts +12 -12
  140. package/dist/ts4.2/room/token-source/TokenSource.d.ts +82 -82
  141. package/dist/ts4.2/room/token-source/types.d.ts +70 -70
  142. package/dist/ts4.2/room/token-source/utils.d.ts +8 -8
  143. package/dist/ts4.2/room/track/FrameMetadataExtractor.d.ts +19 -19
  144. package/dist/ts4.2/room/track/LocalAudioTrack.d.ts +39 -42
  145. package/dist/ts4.2/room/track/LocalTrack.d.ts +125 -125
  146. package/dist/ts4.2/room/track/LocalTrackPublication.d.ts +42 -42
  147. package/dist/ts4.2/room/track/LocalVideoTrack.d.ts +102 -100
  148. package/dist/ts4.2/room/track/RemoteAudioTrack.d.ts +55 -55
  149. package/dist/ts4.2/room/track/RemoteTrack.d.ts +38 -38
  150. package/dist/ts4.2/room/track/RemoteTrackPublication.d.ts +72 -75
  151. package/dist/ts4.2/room/track/RemoteVideoTrack.d.ts +73 -76
  152. package/dist/ts4.2/room/track/Track.d.ts +156 -166
  153. package/dist/ts4.2/room/track/TrackPublication.d.ts +75 -81
  154. package/dist/ts4.2/room/track/create.d.ts +25 -25
  155. package/dist/ts4.2/room/track/facingMode.d.ts +41 -41
  156. package/dist/ts4.2/room/track/options.d.ts +403 -403
  157. package/dist/ts4.2/room/track/processor/types.d.ts +31 -31
  158. package/dist/ts4.2/room/track/record.d.ts +13 -13
  159. package/dist/ts4.2/room/track/types.d.ts +28 -28
  160. package/dist/ts4.2/room/track/utils.d.ts +60 -47
  161. package/dist/ts4.2/room/types.d.ts +127 -127
  162. package/dist/ts4.2/room/utils.d.ts +246 -214
  163. package/dist/ts4.2/test/MockMediaStreamTrack.d.ts +26 -26
  164. package/dist/ts4.2/test/compressionStreamStubs.d.ts +12 -0
  165. package/dist/ts4.2/test/mocks.d.ts +12 -12
  166. package/dist/ts4.2/test/promiseState.d.ts +12 -12
  167. package/dist/ts4.2/test/signalToken.d.ts +26 -26
  168. package/dist/ts4.2/type-polyfills/non-shared-typed-arrays.d.ts +2 -2
  169. package/dist/ts4.2/utils/AsyncQueue.d.ts +23 -23
  170. package/dist/ts4.2/utils/TypedPromise.d.ts +17 -17
  171. package/dist/ts4.2/utils/abort-signal-polyfill.d.ts +13 -13
  172. package/dist/ts4.2/utils/browserParser.d.ts +13 -13
  173. package/dist/ts4.2/utils/camelToSnakeCase.d.ts +8 -8
  174. package/dist/ts4.2/utils/cloneDeep.d.ts +2 -2
  175. package/dist/ts4.2/utils/dataPacketBuffer.d.ts +34 -34
  176. package/dist/ts4.2/utils/deferrable-map.d.ts +32 -32
  177. package/dist/ts4.2/utils/machineInspector.d.ts +54 -54
  178. package/dist/ts4.2/utils/serializer.d.ts +48 -48
  179. package/dist/ts4.2/utils/subscribeToEvents.d.ts +15 -15
  180. package/dist/ts4.2/utils/ttlmap.d.ts +20 -20
  181. package/dist/ts4.2/version.d.ts +15 -15
  182. package/package.json +5 -4
  183. package/src/api/SignalClient.e2e.test.ts +1 -3
  184. package/src/api/SignalClient.test.ts +160 -10
  185. package/src/api/SignalClient.ts +75 -54
  186. package/src/options.ts +16 -0
  187. package/src/room/PCTransport.test.ts +183 -7
  188. package/src/room/PCTransport.ts +197 -36
  189. package/src/room/PCTransportManager.ts +3 -1
  190. package/src/room/RTCEngine.test.ts +84 -0
  191. package/src/room/RTCEngine.ts +24 -5
  192. package/src/room/Room.test.ts +32 -6
  193. package/src/room/Room.ts +26 -6
  194. package/src/room/data-stream/incoming/IncomingDataStreamManager.test.ts +16 -20
  195. package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +5 -5
  196. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.test.ts +60 -39
  197. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts +4 -4
  198. package/src/room/defaults.ts +1 -0
  199. package/src/room/errors.test.ts +36 -0
  200. package/src/room/errors.ts +27 -0
  201. package/src/room/events.ts +2 -1
  202. package/src/room/participant/publishUtils.ts +0 -19
  203. package/src/room/rpc/client/RpcClientManager.test.ts +51 -0
  204. package/src/room/rpc/client/RpcClientManager.ts +32 -15
  205. package/src/room/track/LocalTrack.ts +18 -7
  206. package/src/room/track/LocalVideoTrack.ts +10 -3
  207. package/src/room/track/RemoteAudioTrack.ts +3 -3
  208. package/src/room/track/RemoteVideoTrack.test.ts +210 -0
  209. package/src/room/track/RemoteVideoTrack.ts +29 -3
  210. package/src/room/track/utils.test.ts +201 -2
  211. package/src/room/track/utils.ts +88 -0
  212. package/src/room/utils.test.ts +124 -0
  213. package/src/room/utils.ts +70 -0
  214. package/src/test/compressionStreamStubs.ts +53 -0
@@ -1,35 +1,35 @@
1
- export interface AgentAttributes {
2
- 'lk.agent.inputs'?: AgentInput[];
3
- 'lk.agent.outputs'?: AgentOutput[];
4
- 'lk.agent.state'?: AgentState;
5
- 'lk.publish_on_behalf'?: string;
6
- [property: string]: any;
7
- }
8
- export type AgentInput = 'audio' | 'video' | 'text';
9
- export type AgentOutput = 'transcription' | 'audio';
10
- export type AgentState = 'idle' | 'initializing' | 'listening' | 'thinking' | 'speaking';
11
- /**
12
- * Schema for transcription-related attributes
13
- */
14
- export interface TranscriptionAttributes {
15
- /**
16
- * The segment id of the transcription
17
- */
18
- 'lk.segment_id'?: string;
19
- /**
20
- * The associated track id of the transcription
21
- */
22
- 'lk.transcribed_track_id'?: string;
23
- /**
24
- * Whether the transcription is final
25
- */
26
- 'lk.transcription_final'?: boolean;
27
- [property: string]: any;
28
- }
29
- export declare class Convert {
30
- static toAgentAttributes(json: string): AgentAttributes;
31
- static agentAttributesToJson(value: AgentAttributes): string;
32
- static toTranscriptionAttributes(json: string): TranscriptionAttributes;
33
- static transcriptionAttributesToJson(value: TranscriptionAttributes): string;
34
- }
35
- //# sourceMappingURL=attribute-typings.d.ts.map
1
+ export interface AgentAttributes {
2
+ 'lk.agent.inputs'?: AgentInput[];
3
+ 'lk.agent.outputs'?: AgentOutput[];
4
+ 'lk.agent.state'?: AgentState;
5
+ 'lk.publish_on_behalf'?: string;
6
+ [property: string]: any;
7
+ }
8
+ export type AgentInput = 'audio' | 'video' | 'text';
9
+ export type AgentOutput = 'transcription' | 'audio';
10
+ export type AgentState = 'idle' | 'initializing' | 'listening' | 'thinking' | 'speaking';
11
+ /**
12
+ * Schema for transcription-related attributes
13
+ */
14
+ export interface TranscriptionAttributes {
15
+ /**
16
+ * The segment id of the transcription
17
+ */
18
+ 'lk.segment_id'?: string;
19
+ /**
20
+ * The associated track id of the transcription
21
+ */
22
+ 'lk.transcribed_track_id'?: string;
23
+ /**
24
+ * Whether the transcription is final
25
+ */
26
+ 'lk.transcription_final'?: boolean;
27
+ [property: string]: any;
28
+ }
29
+ export declare class Convert {
30
+ static toAgentAttributes(json: string): AgentAttributes;
31
+ static agentAttributesToJson(value: AgentAttributes): string;
32
+ static toTranscriptionAttributes(json: string): TranscriptionAttributes;
33
+ static transcriptionAttributesToJson(value: TranscriptionAttributes): string;
34
+ }
35
+ //# sourceMappingURL=attribute-typings.d.ts.map
@@ -1,62 +1,62 @@
1
- import type { PCTransportManager } from '../PCTransportManager';
2
- import { FlowControlledDataChannel } from './FlowControlledDataChannel';
3
- import { LossyDataChannel } from './LossyDataChannel';
4
- import { ReliableDataChannel } from './ReliableDataChannel';
5
- import { DataChannelKind } from './types';
6
- export interface DataChannelManagerOptions {
7
- /** Whether the owning engine has been closed — a closed engine rejects headroom waiters. */
8
- isEngineClosed: () => boolean;
9
- /**
10
- * Whether a reconnect attempt is underway: reliable sends defer to the resume replay and lossy
11
- * sends are skipped while this is true.
12
- */
13
- isReconnecting: () => boolean;
14
- onDataMessage: (message: MessageEvent) => void;
15
- onDataTrackMessage: (message: MessageEvent) => void;
16
- onDataError: (event: Event) => void;
17
- onChannelClose: (kind: DataChannelKind) => void;
18
- /** A channel's buffer crossed its low-water mark (debounced). Drives DCBufferStatusChanged. */
19
- onBufferStatusChanged: (kind: DataChannelKind, isLow: boolean) => void;
20
- }
21
- /**
22
- * Owns the engine's data channels: the three flow-controlled publisher channel wrappers (which
23
- * live for the engine's lifetime and have RTCDataChannel handles attached/detached as peer
24
- * connections come and go) plus the subscriber-side receive handles adopted by label.
25
- *
26
- * Handle turnover goes through {@link FlowControlledDataChannel.attach}/`detach`, which reject
27
- * parked headroom waiters as a built-in — there is no separate invalidation step to forget.
28
- */
29
- export declare class DataChannelManager {
30
- readonly reliable: ReliableDataChannel;
31
- readonly lossy: LossyDataChannel;
32
- readonly dataTrack: LossyDataChannel;
33
- private reliableSub?;
34
- private lossySub?;
35
- private dataTrackSub?;
36
- private opts;
37
- constructor(opts: DataChannelManagerOptions);
38
- /** The flow-control wrapper for `kind`. */
39
- channelFor(kind: DataChannelKind): FlowControlledDataChannel;
40
- /** The raw RTCDataChannel handle for `kind`, publisher side by default. */
41
- getHandle(kind: DataChannelKind, subscriber?: boolean): RTCDataChannel | undefined;
42
- get hasPublisherChannels(): boolean;
43
- /**
44
- * Creates the three publisher data channels on the given transport, wires their handlers, and
45
- * attaches them to the wrappers — attaching rejects any waiters still parked on replaced
46
- * channel objects.
47
- */
48
- createPublisherChannels(pcManager: PCTransportManager): void;
49
- /**
50
- * Adopts a subscriber-side data channel by label, wiring the matching receive handler.
51
- * Returns false for labels this manager doesn't own.
52
- */
53
- adoptSubscriberChannel(channel: RTCDataChannel): boolean;
54
- /**
55
- * Tears down all channels for a peer-connection cleanup: rejects parked waiters (detach — the
56
- * spec allows `pc.close()` to transition channels to 'closed' without firing events, so waiting
57
- * for browser close events is not an option), strips handlers, closes the handles, and resets
58
- * the reliable session state.
59
- */
60
- teardown(): void;
61
- }
62
- //# sourceMappingURL=DataChannelManager.d.ts.map
1
+ import type { PCTransportManager } from '../PCTransportManager';
2
+ import { FlowControlledDataChannel } from './FlowControlledDataChannel';
3
+ import { LossyDataChannel } from './LossyDataChannel';
4
+ import { ReliableDataChannel } from './ReliableDataChannel';
5
+ import { DataChannelKind } from './types';
6
+ export interface DataChannelManagerOptions {
7
+ /** Whether the owning engine has been closed — a closed engine rejects headroom waiters. */
8
+ isEngineClosed: () => boolean;
9
+ /**
10
+ * Whether a reconnect attempt is underway: reliable sends defer to the resume replay and lossy
11
+ * sends are skipped while this is true.
12
+ */
13
+ isReconnecting: () => boolean;
14
+ onDataMessage: (message: MessageEvent) => void;
15
+ onDataTrackMessage: (message: MessageEvent) => void;
16
+ onDataError: (event: Event) => void;
17
+ onChannelClose: (kind: DataChannelKind) => void;
18
+ /** A channel's buffer crossed its low-water mark (debounced). Drives DCBufferStatusChanged. */
19
+ onBufferStatusChanged: (kind: DataChannelKind, isLow: boolean) => void;
20
+ }
21
+ /**
22
+ * Owns the engine's data channels: the three flow-controlled publisher channel wrappers (which
23
+ * live for the engine's lifetime and have RTCDataChannel handles attached/detached as peer
24
+ * connections come and go) plus the subscriber-side receive handles adopted by label.
25
+ *
26
+ * Handle turnover goes through {@link FlowControlledDataChannel.attach}/`detach`, which reject
27
+ * parked headroom waiters as a built-in — there is no separate invalidation step to forget.
28
+ */
29
+ export declare class DataChannelManager {
30
+ readonly reliable: ReliableDataChannel;
31
+ readonly lossy: LossyDataChannel;
32
+ readonly dataTrack: LossyDataChannel;
33
+ private reliableSub?;
34
+ private lossySub?;
35
+ private dataTrackSub?;
36
+ private opts;
37
+ constructor(opts: DataChannelManagerOptions);
38
+ /** The flow-control wrapper for `kind`. */
39
+ channelFor(kind: DataChannelKind): FlowControlledDataChannel;
40
+ /** The raw RTCDataChannel handle for `kind`, publisher side by default. */
41
+ getHandle(kind: DataChannelKind, subscriber?: boolean): RTCDataChannel | undefined;
42
+ get hasPublisherChannels(): boolean;
43
+ /**
44
+ * Creates the three publisher data channels on the given transport, wires their handlers, and
45
+ * attaches them to the wrappers — attaching rejects any waiters still parked on replaced
46
+ * channel objects.
47
+ */
48
+ createPublisherChannels(pcManager: PCTransportManager): void;
49
+ /**
50
+ * Adopts a subscriber-side data channel by label, wiring the matching receive handler.
51
+ * Returns false for labels this manager doesn't own.
52
+ */
53
+ adoptSubscriberChannel(channel: RTCDataChannel): boolean;
54
+ /**
55
+ * Tears down all channels for a peer-connection cleanup: rejects parked waiters (detach — the
56
+ * spec allows `pc.close()` to transition channels to 'closed' without firing events, so waiting
57
+ * for browser close events is not an option), strips handlers, closes the handles, and resets
58
+ * the reliable session state.
59
+ */
60
+ teardown(): void;
61
+ }
62
+ //# sourceMappingURL=DataChannelManager.d.ts.map
@@ -1,95 +1,94 @@
1
- import type { DataChannelKind } from './types';
2
- export interface FlowControlledDataChannelOptions {
3
- kind: DataChannelKind;
4
- /** Buffer level (bytes) at which blocked senders resume; armed as `bufferedAmountLowThreshold`. */
5
- lowWaterMark: number;
6
- /** Buffer level (bytes) above which senders block until the buffer drains to the low mark. */
7
- highWaterMark: number;
8
- /** Whether the owning engine has been closed — a closed engine rejects waiters immediately. */
9
- isEngineClosed: () => boolean;
10
- /**
11
- * Notified when the buffer crosses the low-water mark in either direction (debounced: fires only
12
- * on an actual change). Drives the engine's public DCBufferStatusChanged event.
13
- */
14
- onBufferStatusChanged?: (isLow: boolean) => void;
15
- }
16
- /**
17
- * Two-watermark flow control for one data channel kind.
18
- *
19
- * Owns the per-kind headroom gate: senders proceed freely while the buffer is at or below the
20
- * high-water mark and otherwise block — serialized FIFO through a mutex — until the browser's
21
- * `bufferedamountlow` event (armed at the low-water mark) signals the buffer has drained. The
22
- * serialization prevents woken senders from all refilling at once and overflowing the SCTP send
23
- * buffer (see livekit/client-sdk-js#1995).
24
- *
25
- * Waiters are parked on the channel object captured at wait entry. If that object stops being
26
- * current — replaced or torn down — its events may never fire again, so the owner must call
27
- * {@link invalidateWaiters}, which aborts parked waiters (releasing the gate); the next waiter
28
- * gets a fresh controller.
29
- */
30
- export declare class FlowControlledDataChannel {
31
- readonly kind: DataChannelKind;
32
- readonly lowWaterMark: number;
33
- readonly highWaterMark: number;
34
- protected isEngineClosed: () => boolean;
35
- private onBufferStatusChanged?;
36
- /** Last emitted low-water status; starts true (an empty buffer is below the mark). */
37
- private bufferStatusLow;
38
- private handle?;
39
- private headroomLock;
40
- /** Cancels parked headroom waiters when the handle is replaced or torn down. */
41
- private waiterAbortController;
42
- constructor(opts: FlowControlledDataChannelOptions);
43
- /** The currently attached RTCDataChannel handle, if any. */
44
- get channelHandle(): RTCDataChannel | undefined;
45
- /**
46
- * Attaches the channel handle this wrapper controls. Replacing an existing handle rejects
47
- * parked waiters — their events would never fire again on the abandoned object — and installs a
48
- * fresh controller, so queued senders re-check against the new channel. Wrappers outlive their
49
- * handles: this is the one place handle turnover happens, which is what makes stranding a
50
- * waiter structurally impossible.
51
- */
52
- attach(dc: RTCDataChannel): void;
53
- /** Detaches the handle on teardown, rejecting parked waiters. */
54
- detach(reason?: string): void;
55
- protected getChannel(): RTCDataChannel | undefined;
56
- /**
57
- * Whether the send buffer has room to accept more data (the send gate). Senders proceed while
58
- * this is true and block once it goes false. Callers resolve the handle (and decide what an
59
- * absent one means) before asking.
60
- */
61
- isBelowHighWaterMark(dc: RTCDataChannel): boolean;
62
- /**
63
- * Whether the send buffer has drained to its low-water mark. Drives the engine's public
64
- * DCBufferStatusChanged event.
65
- */
66
- isBelowLowWaterMark(dc: RTCDataChannel): boolean;
67
- /**
68
- * Acquires the headroom lock, resolving with the unlock function. Batch senders (the resume
69
- * replay) hold it across all of their sends so no other sender can interleave, calling
70
- * {@link waitForHeadroomWithoutLock} per message to respect flow control within the batch.
71
- */
72
- lockHeadroom(): Promise<() => void>;
73
- /**
74
- * Resolves once the caller may send on this channel: immediately while the send buffer is at or
75
- * below its high-water mark, otherwise once the buffer has drained to the low-water mark (the
76
- * `bufferedamountlow` event). Callers are serialized through the headroom lock so that, when
77
- * the buffer drains, they refill it one at a time (up to the high-water mark) rather than all
78
- * sending at once and overflowing the SCTP send buffer (see livekit/client-sdk-js#1995). The
79
- * closed/buffer checks run inside the lock so queued callers proceed in FIFO order.
80
- */
81
- waitForHeadroomWithLock(): Promise<void>;
82
- /** Core wait of {@link waitForHeadroomWithLock}. The caller must hold the headroom lock. */
83
- waitForHeadroomWithoutLock(): Promise<void>;
84
- /** Rejects all parked headroom waiters; the next waiter gets a fresh controller. */
85
- invalidateWaiters(reason: string): void;
86
- /**
87
- * Recomputes whether the buffer has drained to the low-water mark and, if that changed since the
88
- * last check, notifies the status listener. Two independent triggers land here: a send (which
89
- * raises the buffer) and the `bufferedamountlow` drain event (which lowers it) — the latter has
90
- * no send to hang the work off, which is why this is a shared entry point rather than a tail of
91
- * `send`.
92
- */
93
- refreshBufferStatus(): void;
94
- }
95
- //# sourceMappingURL=FlowControlledDataChannel.d.ts.map
1
+ import type { DataChannelKind } from './types';
2
+ export interface FlowControlledDataChannelOptions {
3
+ kind: DataChannelKind;
4
+ /** Buffer level (bytes) at which blocked senders resume; armed as `bufferedAmountLowThreshold`. */
5
+ lowWaterMark: number;
6
+ /** Buffer level (bytes) above which senders block until the buffer drains to the low mark. */
7
+ highWaterMark: number;
8
+ /** Whether the owning engine has been closed — a closed engine rejects waiters immediately. */
9
+ isEngineClosed: () => boolean;
10
+ /**
11
+ * Notified when the buffer crosses the low-water mark in either direction (debounced: fires only
12
+ * on an actual change). Drives the engine's public DCBufferStatusChanged event.
13
+ */
14
+ onBufferStatusChanged?: (isLow: boolean) => void;
15
+ }
16
+ /**
17
+ * Two-watermark flow control for one data channel kind.
18
+ *
19
+ * Owns the per-kind headroom gate: senders proceed freely while the buffer is at or below the
20
+ * high-water mark and otherwise block — serialized FIFO through a mutex — until the browser's
21
+ * `bufferedamountlow` event (armed at the low-water mark) signals the buffer has drained. The
22
+ * serialization prevents woken senders from all refilling at once and overflowing the SCTP send
23
+ * buffer (see livekit/client-sdk-js#1995).
24
+ *
25
+ * Waiters are parked on the channel object captured at wait entry. If that object stops being
26
+ * current — replaced or torn down — its events may never fire again, so the owner must call
27
+ * {@link invalidateWaiters}, which aborts parked waiters (releasing the gate); the next waiter
28
+ * gets a fresh controller.
29
+ */
30
+ export declare class FlowControlledDataChannel {
31
+ readonly kind: DataChannelKind;
32
+ readonly lowWaterMark: number;
33
+ readonly highWaterMark: number;
34
+ protected isEngineClosed: () => boolean;
35
+ private onBufferStatusChanged?;
36
+ /** Last emitted low-water status; starts true (an empty buffer is below the mark). */
37
+ private bufferStatusLow;
38
+ private handle?;
39
+ private headroomLock;
40
+ /** Cancels parked headroom waiters when the handle is replaced or torn down. */
41
+ private waiterAbortController;
42
+ constructor(opts: FlowControlledDataChannelOptions);
43
+ get channelHandle(): (RTCDataChannel | undefined);
44
+ /**
45
+ * Attaches the channel handle this wrapper controls. Replacing an existing handle rejects
46
+ * parked waiters — their events would never fire again on the abandoned object — and installs a
47
+ * fresh controller, so queued senders re-check against the new channel. Wrappers outlive their
48
+ * handles: this is the one place handle turnover happens, which is what makes stranding a
49
+ * waiter structurally impossible.
50
+ */
51
+ attach(dc: RTCDataChannel): void;
52
+ /** Detaches the handle on teardown, rejecting parked waiters. */
53
+ detach(reason?: string): void;
54
+ protected getChannel(): RTCDataChannel | undefined;
55
+ /**
56
+ * Whether the send buffer has room to accept more data (the send gate). Senders proceed while
57
+ * this is true and block once it goes false. Callers resolve the handle (and decide what an
58
+ * absent one means) before asking.
59
+ */
60
+ isBelowHighWaterMark(dc: RTCDataChannel): boolean;
61
+ /**
62
+ * Whether the send buffer has drained to its low-water mark. Drives the engine's public
63
+ * DCBufferStatusChanged event.
64
+ */
65
+ isBelowLowWaterMark(dc: RTCDataChannel): boolean;
66
+ /**
67
+ * Acquires the headroom lock, resolving with the unlock function. Batch senders (the resume
68
+ * replay) hold it across all of their sends so no other sender can interleave, calling
69
+ * {@link waitForHeadroomWithoutLock} per message to respect flow control within the batch.
70
+ */
71
+ lockHeadroom(): Promise<() => void>;
72
+ /**
73
+ * Resolves once the caller may send on this channel: immediately while the send buffer is at or
74
+ * below its high-water mark, otherwise once the buffer has drained to the low-water mark (the
75
+ * `bufferedamountlow` event). Callers are serialized through the headroom lock so that, when
76
+ * the buffer drains, they refill it one at a time (up to the high-water mark) rather than all
77
+ * sending at once and overflowing the SCTP send buffer (see livekit/client-sdk-js#1995). The
78
+ * closed/buffer checks run inside the lock so queued callers proceed in FIFO order.
79
+ */
80
+ waitForHeadroomWithLock(): Promise<void>;
81
+ /** Core wait of {@link waitForHeadroomWithLock}. The caller must hold the headroom lock. */
82
+ waitForHeadroomWithoutLock(): Promise<void>;
83
+ /** Rejects all parked headroom waiters; the next waiter gets a fresh controller. */
84
+ invalidateWaiters(reason: string): void;
85
+ /**
86
+ * Recomputes whether the buffer has drained to the low-water mark and, if that changed since the
87
+ * last check, notifies the status listener. Two independent triggers land here: a send (which
88
+ * raises the buffer) and the `bufferedamountlow` drain event (which lowers it) — the latter has
89
+ * no send to hang the work off, which is why this is a shared entry point rather than a tail of
90
+ * `send`.
91
+ */
92
+ refreshBufferStatus(): void;
93
+ }
94
+ //# sourceMappingURL=FlowControlledDataChannel.d.ts.map
@@ -1,41 +1,41 @@
1
- import type { NonSharedUint8Array } from '../../type-polyfills/non-shared-typed-arrays';
2
- import type { FlowControlledDataChannelOptions } from './FlowControlledDataChannel';
3
- import { FlowControlledDataChannel } from './FlowControlledDataChannel';
4
- export interface LossyDataChannelOptions extends FlowControlledDataChannelOptions {
5
- /**
6
- * What to do with a send while the buffer is full: `drop` discards it to keep latency bounded
7
- * (the classic lossy channel), `wait` backpressures the producer until there is headroom (the
8
- * data-track channel, whose producer decides what to skip at frame granularity).
9
- */
10
- bufferFullBehavior: 'drop' | 'wait';
11
- /** Sends are silently discarded while this is true (a reconnect attempt is underway). */
12
- shouldSkipSends: () => boolean;
13
- }
14
- /**
15
- * A lossy channel: flow control plus a per-instance full-buffer policy.
16
- *
17
- * Each instance owns its own byterate stat, drop counter, and (when tuning is started) the
18
- * dynamic `bufferedAmountLowThreshold` adjustment that keeps the drop gate at roughly 100ms of
19
- * buffered latency. Keeping these per instance is what prevents one channel's traffic from
20
- * steering another channel's policy.
21
- */
22
- export declare class LossyDataChannel extends FlowControlledDataChannel {
23
- private bufferFullBehavior;
24
- private shouldSkipSends;
25
- private statCurrentBytes;
26
- private statByterate;
27
- private statInterval;
28
- private dropCount;
29
- constructor(opts: LossyDataChannelOptions);
30
- /** Sends prepared bytes with this channel's full-buffer policy (drop or wait). */
31
- send(msg: NonSharedUint8Array): Promise<void>;
32
- /**
33
- * Starts the once-per-second adjustment of the channel's `bufferedAmountLowThreshold` to the
34
- * observed byterate, keeping the drop gate at roughly 100ms of buffered latency (clamped to
35
- * the watermarks). Restarts cleanly if already running.
36
- */
37
- startThresholdTuning(): void;
38
- /** Stops the threshold tuning and resets the stats and drop counter. */
39
- stopThresholdTuning(): void;
40
- }
41
- //# sourceMappingURL=LossyDataChannel.d.ts.map
1
+ import type { NonSharedUint8Array } from '../../type-polyfills/non-shared-typed-arrays';
2
+ import type { FlowControlledDataChannelOptions } from './FlowControlledDataChannel';
3
+ import { FlowControlledDataChannel } from './FlowControlledDataChannel';
4
+ export interface LossyDataChannelOptions extends FlowControlledDataChannelOptions {
5
+ /**
6
+ * What to do with a send while the buffer is full: `drop` discards it to keep latency bounded
7
+ * (the classic lossy channel), `wait` backpressures the producer until there is headroom (the
8
+ * data-track channel, whose producer decides what to skip at frame granularity).
9
+ */
10
+ bufferFullBehavior: 'drop' | 'wait';
11
+ /** Sends are silently discarded while this is true (a reconnect attempt is underway). */
12
+ shouldSkipSends: () => boolean;
13
+ }
14
+ /**
15
+ * A lossy channel: flow control plus a per-instance full-buffer policy.
16
+ *
17
+ * Each instance owns its own byterate stat, drop counter, and (when tuning is started) the
18
+ * dynamic `bufferedAmountLowThreshold` adjustment that keeps the drop gate at roughly 100ms of
19
+ * buffered latency. Keeping these per instance is what prevents one channel's traffic from
20
+ * steering another channel's policy.
21
+ */
22
+ export declare class LossyDataChannel extends FlowControlledDataChannel {
23
+ private bufferFullBehavior;
24
+ private shouldSkipSends;
25
+ private statCurrentBytes;
26
+ private statByterate;
27
+ private statInterval;
28
+ private dropCount;
29
+ constructor(opts: LossyDataChannelOptions);
30
+ /** Sends prepared bytes with this channel's full-buffer policy (drop or wait). */
31
+ send(msg: NonSharedUint8Array): Promise<void>;
32
+ /**
33
+ * Starts the once-per-second adjustment of the channel's `bufferedAmountLowThreshold` to the
34
+ * observed byterate, keeping the drop gate at roughly 100ms of buffered latency (clamped to
35
+ * the watermarks). Restarts cleanly if already running.
36
+ */
37
+ startThresholdTuning(): void;
38
+ /** Stops the threshold tuning and resets the stats and drop counter. */
39
+ stopThresholdTuning(): void;
40
+ }
41
+ //# sourceMappingURL=LossyDataChannel.d.ts.map
@@ -1,57 +1,57 @@
1
- import type { NonSharedUint8Array } from '../../type-polyfills/non-shared-typed-arrays';
2
- import type { FlowControlledDataChannelOptions } from './FlowControlledDataChannel';
3
- import { FlowControlledDataChannel } from './FlowControlledDataChannel';
4
- export interface ReliableDataChannelOptions extends FlowControlledDataChannelOptions {
5
- /**
6
- * Whether sends should currently be deferred to the resume replay instead of hitting the wire
7
- * (i.e. a reconnect attempt is underway). Read at send time so the reliable channel matches the
8
- * engine's reconnect state without owning it.
9
- */
10
- isDeferringSends: () => boolean;
11
- }
12
- /**
13
- * The reliable channel: flow control plus delivery-across-resume semantics.
14
- *
15
- * Every packet gets a monotonic sequence (stamped into the protobuf by the caller before
16
- * serialization, via {@link nextSequence}) and is retained in a replay buffer until the channel's
17
- * `bufferedAmount` confirms it has been handed to the transport. Sends that land in a reconnect
18
- * window — or whose headroom wait is torn down transiently — are queued unsent and resolve;
19
- * {@link replay} delivers them (plus any unacked packets) after a resume. Only an engine close
20
- * rejects, because no replay is coming after that.
21
- */
22
- export declare class ReliableDataChannel extends FlowControlledDataChannel {
23
- private messageBuffer;
24
- private sequence;
25
- private isDeferringSends;
26
- constructor(opts: ReliableDataChannelOptions);
27
- /**
28
- * Claims the next packet sequence. The caller stamps it into the packet before serialization,
29
- * then passes it back to {@link send} so the replay buffer stays keyed by wire sequence.
30
- */
31
- nextSequence(): number;
32
- /**
33
- * Sends prepared bytes with reliable semantics. Resolves once the packet has either been handed
34
- * to the channel or queued for the resume replay; throws only when the engine is closed.
35
- */
36
- send(msg: NonSharedUint8Array, sequence: number): Promise<void>;
37
- /**
38
- * Replays the buffered backlog after a resume: drops everything the server acked
39
- * (`lastMessageSeq`), then re-sends the rest in order. The headroom lock is held across the
40
- * whole replay — releasing it between messages would let a concurrent send (whose newer
41
- * sequence was already assigned before it queued on the lock) hit the wire mid-replay, and
42
- * receivers would then discard the remaining lower-sequence resent messages as duplicates.
43
- */
44
- replay(lastMessageSeq: number): Promise<void>;
45
- /**
46
- * Before recomputing status, trim packets the transport has now delivered — a send or a drain
47
- * may have acked buffered packets, and the replay buffer is keyed off the channel's buffered
48
- * bytes.
49
- */
50
- refreshBufferStatus(): void;
51
- /**
52
- * Drops all replay state and restarts sequencing. Only valid on a full reconnect, where the
53
- * session (and the receivers' sequence tracking) starts over.
54
- */
55
- reset(): void;
56
- }
57
- //# sourceMappingURL=ReliableDataChannel.d.ts.map
1
+ import type { NonSharedUint8Array } from '../../type-polyfills/non-shared-typed-arrays';
2
+ import type { FlowControlledDataChannelOptions } from './FlowControlledDataChannel';
3
+ import { FlowControlledDataChannel } from './FlowControlledDataChannel';
4
+ export interface ReliableDataChannelOptions extends FlowControlledDataChannelOptions {
5
+ /**
6
+ * Whether sends should currently be deferred to the resume replay instead of hitting the wire
7
+ * (i.e. a reconnect attempt is underway). Read at send time so the reliable channel matches the
8
+ * engine's reconnect state without owning it.
9
+ */
10
+ isDeferringSends: () => boolean;
11
+ }
12
+ /**
13
+ * The reliable channel: flow control plus delivery-across-resume semantics.
14
+ *
15
+ * Every packet gets a monotonic sequence (stamped into the protobuf by the caller before
16
+ * serialization, via {@link nextSequence}) and is retained in a replay buffer until the channel's
17
+ * `bufferedAmount` confirms it has been handed to the transport. Sends that land in a reconnect
18
+ * window — or whose headroom wait is torn down transiently — are queued unsent and resolve;
19
+ * {@link replay} delivers them (plus any unacked packets) after a resume. Only an engine close
20
+ * rejects, because no replay is coming after that.
21
+ */
22
+ export declare class ReliableDataChannel extends FlowControlledDataChannel {
23
+ private messageBuffer;
24
+ private sequence;
25
+ private isDeferringSends;
26
+ constructor(opts: ReliableDataChannelOptions);
27
+ /**
28
+ * Claims the next packet sequence. The caller stamps it into the packet before serialization,
29
+ * then passes it back to {@link send} so the replay buffer stays keyed by wire sequence.
30
+ */
31
+ nextSequence(): number;
32
+ /**
33
+ * Sends prepared bytes with reliable semantics. Resolves once the packet has either been handed
34
+ * to the channel or queued for the resume replay; throws only when the engine is closed.
35
+ */
36
+ send(msg: NonSharedUint8Array, sequence: number): Promise<void>;
37
+ /**
38
+ * Replays the buffered backlog after a resume: drops everything the server acked
39
+ * (`lastMessageSeq`), then re-sends the rest in order. The headroom lock is held across the
40
+ * whole replay — releasing it between messages would let a concurrent send (whose newer
41
+ * sequence was already assigned before it queued on the lock) hit the wire mid-replay, and
42
+ * receivers would then discard the remaining lower-sequence resent messages as duplicates.
43
+ */
44
+ replay(lastMessageSeq: number): Promise<void>;
45
+ /**
46
+ * Before recomputing status, trim packets the transport has now delivered — a send or a drain
47
+ * may have acked buffered packets, and the replay buffer is keyed off the channel's buffered
48
+ * bytes.
49
+ */
50
+ refreshBufferStatus(): void;
51
+ /**
52
+ * Drops all replay state and restarts sequencing. Only valid on a full reconnect, where the
53
+ * session (and the receivers' sequence tracking) starts over.
54
+ */
55
+ reset(): void;
56
+ }
57
+ //# sourceMappingURL=ReliableDataChannel.d.ts.map
@@ -1,12 +1,12 @@
1
- export declare enum DataChannelKind {
2
- RELIABLE = 0,
3
- LOSSY = 1,
4
- DATA_TRACK_LOSSY = 2
5
- }
6
- export declare const reliableDataChannelWaterMarkLow: number;
7
- export declare const reliableDataChannelWaterMarkHigh: number;
8
- export declare const lossyDataChannelWaterMarkLow: number;
9
- export declare const lossyDataChannelWaterMarkHigh: number;
10
- export declare function dataChannelLowWaterMark(kind: DataChannelKind): number;
11
- export declare function dataChannelHighWaterMark(kind: DataChannelKind): number;
12
- //# sourceMappingURL=types.d.ts.map
1
+ export declare enum DataChannelKind {
2
+ RELIABLE = 0,
3
+ LOSSY = 1,
4
+ DATA_TRACK_LOSSY = 2
5
+ }
6
+ export declare const reliableDataChannelWaterMarkLow: number;
7
+ export declare const reliableDataChannelWaterMarkHigh: number;
8
+ export declare const lossyDataChannelWaterMarkLow: number;
9
+ export declare const lossyDataChannelWaterMarkHigh: number;
10
+ export declare function dataChannelLowWaterMark(kind: DataChannelKind): number;
11
+ export declare function dataChannelHighWaterMark(kind: DataChannelKind): number;
12
+ //# sourceMappingURL=types.d.ts.map