livekit-client 2.22.3 → 2.23.0

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 (272) 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 +71 -8
  5. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  6. package/dist/livekit-client.esm.mjs +1746 -547
  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/api/WebSocketStream.d.ts +1 -0
  17. package/dist/src/api/WebSocketStream.d.ts.map +1 -1
  18. package/dist/src/api/utils.d.ts +1 -1
  19. package/dist/src/api/utils.d.ts.map +1 -1
  20. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  21. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  22. package/dist/src/e2ee/worker/naluUtils.d.ts +12 -1
  23. package/dist/src/e2ee/worker/naluUtils.d.ts.map +1 -1
  24. package/dist/src/index.d.ts +2 -2
  25. package/dist/src/index.d.ts.map +1 -1
  26. package/dist/src/options.d.ts +14 -0
  27. package/dist/src/options.d.ts.map +1 -1
  28. package/dist/src/room/DefaultReconnectPolicy.d.ts.map +1 -1
  29. package/dist/src/room/PCTransport.d.ts +100 -7
  30. package/dist/src/room/PCTransport.d.ts.map +1 -1
  31. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  32. package/dist/src/room/RTCEngine.d.ts +16 -0
  33. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  34. package/dist/src/room/Room.d.ts +54 -1
  35. package/dist/src/room/Room.d.ts.map +1 -1
  36. package/dist/src/room/data-channel/DataChannelManager.d.ts +9 -8
  37. package/dist/src/room/data-channel/DataChannelManager.d.ts.map +1 -1
  38. package/dist/src/room/data-channel/FlowControlledDataChannel.d.ts +25 -12
  39. package/dist/src/room/data-channel/FlowControlledDataChannel.d.ts.map +1 -1
  40. package/dist/src/room/data-channel/LossyDataChannel.d.ts.map +1 -1
  41. package/dist/src/room/data-channel/ReliableDataChannel.d.ts.map +1 -1
  42. package/dist/src/room/data-stream/incoming/IncomingDataStreamManager.d.ts.map +1 -1
  43. package/dist/src/room/defaults.d.ts.map +1 -1
  44. package/dist/src/room/errors.d.ts +18 -0
  45. package/dist/src/room/errors.d.ts.map +1 -1
  46. package/dist/src/room/events.d.ts +3 -2
  47. package/dist/src/room/events.d.ts.map +1 -1
  48. package/dist/src/room/participant/LocalParticipant.d.ts +4 -0
  49. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  50. package/dist/src/room/participant/Participant.d.ts +1 -1
  51. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  52. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  53. package/dist/src/room/rpc/client/RpcClientManager.d.ts.map +1 -1
  54. package/dist/src/room/rpc/utils.d.ts.map +1 -1
  55. package/dist/src/room/track/LocalAudioTrack.d.ts +24 -1
  56. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  57. package/dist/src/room/track/LocalTrack.d.ts +18 -0
  58. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  59. package/dist/src/room/track/LocalVideoTrack.d.ts +9 -0
  60. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  61. package/dist/src/room/track/RemoteAudioTrack.d.ts +6 -0
  62. package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
  63. package/dist/src/room/track/processor/types.d.ts +11 -0
  64. package/dist/src/room/track/processor/types.d.ts.map +1 -1
  65. package/dist/src/room/track/utils.d.ts +13 -0
  66. package/dist/src/room/track/utils.d.ts.map +1 -1
  67. package/dist/src/room/utils.d.ts +60 -1
  68. package/dist/src/room/utils.d.ts.map +1 -1
  69. package/dist/src/test/compressionStreamStubs.d.ts +12 -0
  70. package/dist/src/test/compressionStreamStubs.d.ts.map +1 -0
  71. package/dist/ts4.2/api/SignalClient.d.ts +187 -185
  72. package/dist/ts4.2/api/SignalClientStateMachine.d.ts +85 -85
  73. package/dist/ts4.2/api/WebSocketStream.d.ts +34 -33
  74. package/dist/ts4.2/api/utils.d.ts +9 -9
  75. package/dist/ts4.2/connectionHelper/ConnectionCheck.d.ts +30 -30
  76. package/dist/ts4.2/connectionHelper/checks/Checker.d.ts +62 -62
  77. package/dist/ts4.2/connectionHelper/checks/cloudRegion.d.ts +18 -18
  78. package/dist/ts4.2/connectionHelper/checks/connectionProtocol.d.ts +20 -20
  79. package/dist/ts4.2/connectionHelper/checks/publishAudio.d.ts +6 -6
  80. package/dist/ts4.2/connectionHelper/checks/publishVideo.d.ts +7 -7
  81. package/dist/ts4.2/connectionHelper/checks/reconnect.d.ts +6 -6
  82. package/dist/ts4.2/connectionHelper/checks/turn.d.ts +6 -6
  83. package/dist/ts4.2/connectionHelper/checks/webrtc.d.ts +6 -6
  84. package/dist/ts4.2/connectionHelper/checks/websocket.d.ts +6 -6
  85. package/dist/ts4.2/e2ee/E2eeManager.d.ts +111 -111
  86. package/dist/ts4.2/e2ee/KeyProvider.d.ts +54 -54
  87. package/dist/ts4.2/e2ee/constants.d.ts +21 -21
  88. package/dist/ts4.2/e2ee/errors.d.ts +12 -12
  89. package/dist/ts4.2/e2ee/events.d.ts +39 -39
  90. package/dist/ts4.2/e2ee/index.d.ts +6 -6
  91. package/dist/ts4.2/e2ee/types.d.ts +231 -231
  92. package/dist/ts4.2/e2ee/utils.d.ts +32 -32
  93. package/dist/ts4.2/e2ee/worker/DataCryptor.d.ts +16 -16
  94. package/dist/ts4.2/e2ee/worker/ErrorRateLimiter.d.ts +21 -21
  95. package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +209 -209
  96. package/dist/ts4.2/e2ee/worker/ParticipantKeyHandler.d.ts +81 -84
  97. package/dist/ts4.2/e2ee/worker/e2ee.worker.d.ts +2 -2
  98. package/dist/ts4.2/e2ee/worker/naluUtils.d.ts +39 -28
  99. package/dist/ts4.2/e2ee/worker/sifPayload.d.ts +23 -23
  100. package/dist/ts4.2/frameMetadata/FrameMetadataManager.d.ts +53 -53
  101. package/dist/ts4.2/frameMetadata/frameMetadata.d.ts +33 -33
  102. package/dist/ts4.2/frameMetadata/types.d.ts +62 -62
  103. package/dist/ts4.2/frameMetadata/utils.d.ts +9 -9
  104. package/dist/ts4.2/frameMetadata/worker/frameMetadata.worker.d.ts +2 -2
  105. package/dist/ts4.2/index.d.ts +76 -76
  106. package/dist/ts4.2/logger.d.ts +66 -66
  107. package/dist/ts4.2/options.d.ts +163 -149
  108. package/dist/ts4.2/room/BackOffStrategy.d.ts +27 -27
  109. package/dist/ts4.2/room/DefaultReconnectPolicy.d.ts +8 -8
  110. package/dist/ts4.2/room/DeviceManager.d.ts +12 -12
  111. package/dist/ts4.2/room/PCTransport.d.ts +268 -175
  112. package/dist/ts4.2/room/PCTransportManager.d.ts +77 -77
  113. package/dist/ts4.2/room/RTCEngine.d.ts +277 -262
  114. package/dist/ts4.2/room/ReconnectPolicy.d.ts +24 -24
  115. package/dist/ts4.2/room/RegionUrlProvider.d.ts +36 -36
  116. package/dist/ts4.2/room/Room.d.ts +407 -365
  117. package/dist/ts4.2/room/attribute-typings.d.ts +35 -35
  118. package/dist/ts4.2/room/data-channel/DataChannelManager.d.ts +63 -62
  119. package/dist/ts4.2/room/data-channel/FlowControlledDataChannel.d.ts +107 -95
  120. package/dist/ts4.2/room/data-channel/LossyDataChannel.d.ts +41 -41
  121. package/dist/ts4.2/room/data-channel/ReliableDataChannel.d.ts +57 -57
  122. package/dist/ts4.2/room/data-channel/types.d.ts +12 -12
  123. package/dist/ts4.2/room/data-stream/compression.d.ts +49 -49
  124. package/dist/ts4.2/room/data-stream/constants.d.ts +18 -18
  125. package/dist/ts4.2/room/data-stream/incoming/IncomingDataStreamManager.d.ts +29 -29
  126. package/dist/ts4.2/room/data-stream/incoming/StreamReader.d.ts +80 -80
  127. package/dist/ts4.2/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts +73 -73
  128. package/dist/ts4.2/room/data-stream/outgoing/StreamWriter.d.ts +16 -16
  129. package/dist/ts4.2/room/data-stream/outgoing/header-utils.d.ts +18 -18
  130. package/dist/ts4.2/room/data-track/LocalDataTrack.d.ts +79 -80
  131. package/dist/ts4.2/room/data-track/RemoteDataTrack.d.ts +50 -50
  132. package/dist/ts4.2/room/data-track/depacketizer.d.ts +59 -59
  133. package/dist/ts4.2/room/data-track/frame.d.ts +22 -22
  134. package/dist/ts4.2/room/data-track/handle.d.ts +27 -27
  135. package/dist/ts4.2/room/data-track/incoming/IncomingDataTrackManager.d.ts +124 -124
  136. package/dist/ts4.2/room/data-track/incoming/errors.d.ts +24 -24
  137. package/dist/ts4.2/room/data-track/incoming/pipeline.d.ts +41 -41
  138. package/dist/ts4.2/room/data-track/incoming/types.d.ts +20 -20
  139. package/dist/ts4.2/room/data-track/outgoing/OutgoingDataTrackManager.d.ts +126 -126
  140. package/dist/ts4.2/room/data-track/outgoing/errors.d.ts +74 -74
  141. package/dist/ts4.2/room/data-track/outgoing/pipeline.d.ts +23 -23
  142. package/dist/ts4.2/room/data-track/outgoing/types.d.ts +48 -48
  143. package/dist/ts4.2/room/data-track/packet/constants.d.ts +20 -20
  144. package/dist/ts4.2/room/data-track/packet/errors.d.ts +40 -40
  145. package/dist/ts4.2/room/data-track/packet/extensions.d.ts +69 -69
  146. package/dist/ts4.2/room/data-track/packet/index.d.ts +98 -98
  147. package/dist/ts4.2/room/data-track/packet/serializable.d.ts +13 -13
  148. package/dist/ts4.2/room/data-track/packetizer.d.ts +43 -43
  149. package/dist/ts4.2/room/data-track/track-interfaces.d.ts +23 -23
  150. package/dist/ts4.2/room/data-track/types.d.ts +22 -22
  151. package/dist/ts4.2/room/data-track/utils.d.ts +60 -60
  152. package/dist/ts4.2/room/debounce.d.ts +11 -11
  153. package/dist/ts4.2/room/defaults.d.ts +9 -9
  154. package/dist/ts4.2/room/errors.d.ts +180 -162
  155. package/dist/ts4.2/room/events.d.ts +638 -637
  156. package/dist/ts4.2/room/participant/LocalParticipant.d.ts +291 -287
  157. package/dist/ts4.2/room/participant/Participant.d.ts +142 -144
  158. package/dist/ts4.2/room/participant/ParticipantTrackPermission.d.ts +26 -26
  159. package/dist/ts4.2/room/participant/RemoteParticipant.d.ts +85 -86
  160. package/dist/ts4.2/room/participant/publishUtils.d.ts +53 -53
  161. package/dist/ts4.2/room/rpc/client/RpcClientManager.d.ts +43 -43
  162. package/dist/ts4.2/room/rpc/client/events.d.ts +8 -8
  163. package/dist/ts4.2/room/rpc/index.d.ts +7 -7
  164. package/dist/ts4.2/room/rpc/server/RpcServerManager.d.ts +44 -44
  165. package/dist/ts4.2/room/rpc/server/events.d.ts +8 -8
  166. package/dist/ts4.2/room/rpc/utils.d.ts +131 -131
  167. package/dist/ts4.2/room/stats.d.ts +71 -71
  168. package/dist/ts4.2/room/statsSummary.d.ts +13 -13
  169. package/dist/ts4.2/room/timers.d.ts +12 -12
  170. package/dist/ts4.2/room/token-source/TokenSource.d.ts +82 -82
  171. package/dist/ts4.2/room/token-source/types.d.ts +70 -70
  172. package/dist/ts4.2/room/token-source/utils.d.ts +8 -8
  173. package/dist/ts4.2/room/track/FrameMetadataExtractor.d.ts +19 -19
  174. package/dist/ts4.2/room/track/LocalAudioTrack.d.ts +62 -42
  175. package/dist/ts4.2/room/track/LocalTrack.d.ts +143 -125
  176. package/dist/ts4.2/room/track/LocalTrackPublication.d.ts +42 -42
  177. package/dist/ts4.2/room/track/LocalVideoTrack.d.ts +109 -100
  178. package/dist/ts4.2/room/track/RemoteAudioTrack.d.ts +61 -55
  179. package/dist/ts4.2/room/track/RemoteTrack.d.ts +38 -38
  180. package/dist/ts4.2/room/track/RemoteTrackPublication.d.ts +72 -75
  181. package/dist/ts4.2/room/track/RemoteVideoTrack.d.ts +73 -76
  182. package/dist/ts4.2/room/track/Track.d.ts +156 -166
  183. package/dist/ts4.2/room/track/TrackPublication.d.ts +75 -81
  184. package/dist/ts4.2/room/track/create.d.ts +25 -25
  185. package/dist/ts4.2/room/track/facingMode.d.ts +41 -41
  186. package/dist/ts4.2/room/track/options.d.ts +403 -403
  187. package/dist/ts4.2/room/track/processor/types.d.ts +42 -31
  188. package/dist/ts4.2/room/track/record.d.ts +13 -13
  189. package/dist/ts4.2/room/track/types.d.ts +28 -28
  190. package/dist/ts4.2/room/track/utils.d.ts +60 -47
  191. package/dist/ts4.2/room/types.d.ts +127 -127
  192. package/dist/ts4.2/room/utils.d.ts +273 -214
  193. package/dist/ts4.2/test/MockMediaStreamTrack.d.ts +26 -26
  194. package/dist/ts4.2/test/compressionStreamStubs.d.ts +12 -0
  195. package/dist/ts4.2/test/mocks.d.ts +12 -12
  196. package/dist/ts4.2/test/promiseState.d.ts +12 -12
  197. package/dist/ts4.2/test/signalToken.d.ts +26 -26
  198. package/dist/ts4.2/type-polyfills/non-shared-typed-arrays.d.ts +2 -2
  199. package/dist/ts4.2/utils/AsyncQueue.d.ts +23 -23
  200. package/dist/ts4.2/utils/TypedPromise.d.ts +17 -17
  201. package/dist/ts4.2/utils/abort-signal-polyfill.d.ts +13 -13
  202. package/dist/ts4.2/utils/browserParser.d.ts +13 -13
  203. package/dist/ts4.2/utils/camelToSnakeCase.d.ts +8 -8
  204. package/dist/ts4.2/utils/cloneDeep.d.ts +2 -2
  205. package/dist/ts4.2/utils/dataPacketBuffer.d.ts +34 -34
  206. package/dist/ts4.2/utils/deferrable-map.d.ts +32 -32
  207. package/dist/ts4.2/utils/machineInspector.d.ts +54 -54
  208. package/dist/ts4.2/utils/serializer.d.ts +48 -48
  209. package/dist/ts4.2/utils/subscribeToEvents.d.ts +15 -15
  210. package/dist/ts4.2/utils/ttlmap.d.ts +20 -20
  211. package/dist/ts4.2/version.d.ts +15 -15
  212. package/package.json +5 -4
  213. package/src/api/SignalClient.e2e.test.ts +1 -3
  214. package/src/api/SignalClient.test.ts +394 -10
  215. package/src/api/SignalClient.ts +132 -76
  216. package/src/api/WebSocketStream.test.ts +11 -0
  217. package/src/api/WebSocketStream.ts +22 -1
  218. package/src/api/utils.ts +1 -1
  219. package/src/e2ee/E2eeManager.test.ts +43 -0
  220. package/src/e2ee/E2eeManager.ts +6 -2
  221. package/src/e2ee/worker/FrameCryptor.test.ts +212 -90
  222. package/src/e2ee/worker/FrameCryptor.ts +21 -4
  223. package/src/e2ee/worker/naluUtils.test.ts +123 -0
  224. package/src/e2ee/worker/naluUtils.ts +57 -2
  225. package/src/index.ts +2 -0
  226. package/src/options.ts +16 -0
  227. package/src/room/DefaultReconnectPolicy.test.ts +58 -0
  228. package/src/room/DefaultReconnectPolicy.ts +14 -2
  229. package/src/room/PCTransport.test.ts +327 -9
  230. package/src/room/PCTransport.ts +339 -36
  231. package/src/room/PCTransportManager.ts +3 -1
  232. package/src/room/RTCEngine.test.ts +318 -2
  233. package/src/room/RTCEngine.ts +126 -12
  234. package/src/room/Room.test.ts +148 -6
  235. package/src/room/Room.ts +312 -80
  236. package/src/room/data-channel/DataChannelManager.test.ts +24 -7
  237. package/src/room/data-channel/DataChannelManager.ts +43 -38
  238. package/src/room/data-channel/FlowControlledDataChannel.test.ts +60 -18
  239. package/src/room/data-channel/FlowControlledDataChannel.ts +40 -22
  240. package/src/room/data-channel/LossyDataChannel.test.ts +38 -0
  241. package/src/room/data-channel/LossyDataChannel.ts +10 -1
  242. package/src/room/data-channel/ReliableDataChannel.test.ts +72 -0
  243. package/src/room/data-channel/ReliableDataChannel.ts +16 -5
  244. package/src/room/data-stream/incoming/IncomingDataStreamManager.test.ts +47 -20
  245. package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +16 -5
  246. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.test.ts +60 -39
  247. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts +4 -4
  248. package/src/room/defaults.ts +1 -0
  249. package/src/room/errors.test.ts +36 -0
  250. package/src/room/errors.ts +27 -0
  251. package/src/room/events.ts +2 -1
  252. package/src/room/participant/LocalParticipant.test.ts +136 -1
  253. package/src/room/participant/LocalParticipant.ts +66 -17
  254. package/src/room/participant/Participant.ts +6 -3
  255. package/src/room/participant/publishUtils.ts +0 -19
  256. package/src/room/participant/restartOnDefaultAudioDevice.test.ts +177 -0
  257. package/src/room/rpc/client/RpcClientManager.test.ts +51 -0
  258. package/src/room/rpc/client/RpcClientManager.ts +32 -15
  259. package/src/room/rpc/utils.test.ts +32 -0
  260. package/src/room/rpc/utils.ts +7 -0
  261. package/src/room/track/LocalAudioTrack.ts +101 -10
  262. package/src/room/track/LocalTrack.ts +87 -19
  263. package/src/room/track/LocalVideoTrack.ts +17 -3
  264. package/src/room/track/RemoteAudioTrack.ts +59 -14
  265. package/src/room/track/RemoteVideoTrack.test.ts +210 -0
  266. package/src/room/track/RemoteVideoTrack.ts +29 -3
  267. package/src/room/track/processor/types.ts +11 -0
  268. package/src/room/track/utils.test.ts +206 -2
  269. package/src/room/track/utils.ts +117 -5
  270. package/src/room/utils.test.ts +250 -0
  271. package/src/room/utils.ts +152 -19
  272. 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,63 @@
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 close the
27
+ * released handle and reject parked headroom waiters as a built-in — there is no separate
28
+ * invalidation step to forget.
29
+ */
30
+ export declare class DataChannelManager {
31
+ readonly reliable: ReliableDataChannel;
32
+ readonly lossy: LossyDataChannel;
33
+ readonly dataTrack: LossyDataChannel;
34
+ private reliableSub?;
35
+ private lossySub?;
36
+ private dataTrackSub?;
37
+ private opts;
38
+ constructor(opts: DataChannelManagerOptions);
39
+ /** The flow-control wrapper for `kind`. */
40
+ channelFor(kind: DataChannelKind): FlowControlledDataChannel;
41
+ /** The raw RTCDataChannel handle for `kind`, publisher side by default. */
42
+ getHandle(kind: DataChannelKind, subscriber?: boolean): RTCDataChannel | undefined;
43
+ get hasPublisherChannels(): boolean;
44
+ /**
45
+ * Creates the three publisher data channels on the given transport, wires their handlers, and
46
+ * attaches them to the wrappers — attaching closes any replaced channel objects and rejects the
47
+ * waiters still parked on them.
48
+ */
49
+ createPublisherChannels(pcManager: PCTransportManager): void;
50
+ /**
51
+ * Adopts a subscriber-side data channel by label, wiring the matching receive handler.
52
+ * Returns false for labels this manager doesn't own.
53
+ */
54
+ adoptSubscriberChannel(channel: RTCDataChannel): boolean;
55
+ /**
56
+ * Tears down all channels for a peer-connection cleanup: strips handlers, closes the handles,
57
+ * and resets the reliable session state. Detaching the publisher handles closes them and
58
+ * rejects parked waiters (the spec allows `pc.close()` to transition channels to 'closed'
59
+ * without firing events, so waiting for browser close events is not an option).
60
+ */
61
+ teardown(): void;
62
+ }
63
+ //# sourceMappingURL=DataChannelManager.d.ts.map
@@ -1,95 +1,107 @@
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. {@link attach} and {@link detach} do this, and close the released
29
+ * handle, as part of handle turnover.
30
+ */
31
+ export declare class FlowControlledDataChannel {
32
+ readonly kind: DataChannelKind;
33
+ readonly lowWaterMark: number;
34
+ readonly highWaterMark: number;
35
+ protected isEngineClosed: () => boolean;
36
+ private onBufferStatusChanged?;
37
+ /** Last emitted low-water status; starts true (an empty buffer is below the mark). */
38
+ private bufferStatusLow;
39
+ private handle?;
40
+ private headroomLock;
41
+ /** Cancels parked headroom waiters when the handle is replaced or torn down. */
42
+ private waiterAbortController;
43
+ constructor(opts: FlowControlledDataChannelOptions);
44
+ get channelHandle(): (RTCDataChannel | undefined);
45
+ /**
46
+ * Attaches the channel handle this wrapper controls. Replacing an existing handle closes it and
47
+ * rejects parked waiters — their events would never fire again on the abandoned object — and
48
+ * installs a fresh controller. Wrappers outlive their handles: this is the one place handle
49
+ * turnover happens, so a handle the wrapper lets go of is never left open, and stranding a
50
+ * waiter is structurally impossible.
51
+ */
52
+ attach(dc: RTCDataChannel): void;
53
+ /** Detaches and closes the handle on teardown, rejecting parked waiters. */
54
+ detach(reason?: string): void;
55
+ /**
56
+ * Closes a handle the wrapper no longer controls. `close()` moves it to `closing` synchronously,
57
+ * so senders still holding it (queued on the headroom lock) fail the open check once they get
58
+ * the lock. Parked waiters are aborted directly instead of relying on the `close` event, which
59
+ * fires asynchronously, if at all (the spec lets `pc.close()` skip it). Strip any handlers that
60
+ * must not observe the close before calling this.
61
+ */
62
+ private release;
63
+ protected getChannel(): RTCDataChannel | undefined;
64
+ /**
65
+ * Whether the send buffer has room to accept more data (the send gate). Senders proceed while
66
+ * this is true and block once it goes false. Callers resolve the handle (and decide what an
67
+ * absent one means) before asking.
68
+ */
69
+ isBelowHighWaterMark(dc: RTCDataChannel): boolean;
70
+ /**
71
+ * Whether the send buffer has drained to its low-water mark. Drives the engine's public
72
+ * DCBufferStatusChanged event.
73
+ */
74
+ isBelowLowWaterMark(dc: RTCDataChannel): boolean;
75
+ /**
76
+ * Acquires the headroom lock, resolving with the unlock function. Batch senders (the resume
77
+ * replay) hold it across all of their sends so no other sender can interleave, calling
78
+ * {@link waitForHeadroomWithoutLock} per message to respect flow control within the batch.
79
+ */
80
+ lockHeadroom(): Promise<() => void>;
81
+ /**
82
+ * Resolves once the caller may send on `dc`: immediately while its send buffer is at or below
83
+ * the high-water mark, otherwise once the buffer has drained to the low-water mark (the
84
+ * `bufferedamountlow` event). Callers are serialized through the headroom lock so that, when
85
+ * the buffer drains, they refill it one at a time (up to the high-water mark) rather than all
86
+ * sending at once and overflowing the SCTP send buffer (see livekit/client-sdk-js#1995). The
87
+ * checks run inside the lock so queued callers proceed in FIFO order.
88
+ *
89
+ * The caller passes the handle it resolved before queueing, and the wait is against that one
90
+ * handle throughout: if it was replaced meanwhile, it has been closed, so the wait rejects
91
+ * rather than letting the caller send on the replacement out of turn.
92
+ */
93
+ waitForHeadroomWithLock(dc: RTCDataChannel): Promise<void>;
94
+ /** Core wait of {@link waitForHeadroomWithLock}. The caller must hold the headroom lock. */
95
+ waitForHeadroomWithoutLock(dc: RTCDataChannel): Promise<void>;
96
+ /** Rejects all parked headroom waiters; the next waiter gets a fresh controller. */
97
+ invalidateWaiters(reason: string): void;
98
+ /**
99
+ * Recomputes whether the buffer has drained to the low-water mark and, if that changed since the
100
+ * last check, notifies the status listener. Two independent triggers land here: a send (which
101
+ * raises the buffer) and the `bufferedamountlow` drain event (which lowers it) — the latter has
102
+ * no send to hang the work off, which is why this is a shared entry point rather than a tail of
103
+ * `send`.
104
+ */
105
+ refreshBufferStatus(): void;
106
+ }
107
+ //# 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