livekit-client 2.22.2 → 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 (245) 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 +488 -438
  5. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  6. package/dist/livekit-client.esm.mjs +954 -301
  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 +10 -2
  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.map +1 -1
  17. package/dist/src/api/utils.d.ts +1 -0
  18. package/dist/src/api/utils.d.ts.map +1 -1
  19. package/dist/src/e2ee/E2eeManager.d.ts +26 -0
  20. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  21. package/dist/src/e2ee/types.d.ts +15 -1
  22. package/dist/src/e2ee/types.d.ts.map +1 -1
  23. package/dist/src/e2ee/worker/DataCryptor.d.ts.map +1 -1
  24. package/dist/src/e2ee/worker/ErrorRateLimiter.d.ts +21 -0
  25. package/dist/src/e2ee/worker/ErrorRateLimiter.d.ts.map +1 -0
  26. package/dist/src/e2ee/worker/FrameCryptor.d.ts +1 -18
  27. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  28. package/dist/src/logger.d.ts +4 -0
  29. package/dist/src/logger.d.ts.map +1 -1
  30. package/dist/src/options.d.ts +14 -0
  31. package/dist/src/options.d.ts.map +1 -1
  32. package/dist/src/room/PCTransport.d.ts +78 -7
  33. package/dist/src/room/PCTransport.d.ts.map +1 -1
  34. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  35. package/dist/src/room/RTCEngine.d.ts +9 -0
  36. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  37. package/dist/src/room/Room.d.ts +1 -1
  38. package/dist/src/room/Room.d.ts.map +1 -1
  39. package/dist/src/room/defaults.d.ts.map +1 -1
  40. package/dist/src/room/errors.d.ts +18 -0
  41. package/dist/src/room/errors.d.ts.map +1 -1
  42. package/dist/src/room/events.d.ts +3 -2
  43. package/dist/src/room/events.d.ts.map +1 -1
  44. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  45. package/dist/src/room/participant/publishUtils.d.ts +16 -0
  46. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  47. package/dist/src/room/rpc/client/RpcClientManager.d.ts.map +1 -1
  48. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  49. package/dist/src/room/track/LocalVideoTrack.d.ts +9 -0
  50. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  51. package/dist/src/room/track/options.d.ts +1 -1
  52. package/dist/src/room/track/utils.d.ts +13 -0
  53. package/dist/src/room/track/utils.d.ts.map +1 -1
  54. package/dist/src/room/utils.d.ts +66 -0
  55. package/dist/src/room/utils.d.ts.map +1 -1
  56. package/dist/src/test/compressionStreamStubs.d.ts +12 -0
  57. package/dist/src/test/compressionStreamStubs.d.ts.map +1 -0
  58. package/dist/ts4.2/api/SignalClient.d.ts +187 -185
  59. package/dist/ts4.2/api/SignalClientStateMachine.d.ts +85 -85
  60. package/dist/ts4.2/api/WebSocketStream.d.ts +33 -33
  61. package/dist/ts4.2/api/utils.d.ts +9 -8
  62. package/dist/ts4.2/connectionHelper/ConnectionCheck.d.ts +30 -30
  63. package/dist/ts4.2/connectionHelper/checks/Checker.d.ts +62 -62
  64. package/dist/ts4.2/connectionHelper/checks/cloudRegion.d.ts +18 -18
  65. package/dist/ts4.2/connectionHelper/checks/connectionProtocol.d.ts +20 -20
  66. package/dist/ts4.2/connectionHelper/checks/publishAudio.d.ts +6 -6
  67. package/dist/ts4.2/connectionHelper/checks/publishVideo.d.ts +7 -7
  68. package/dist/ts4.2/connectionHelper/checks/reconnect.d.ts +6 -6
  69. package/dist/ts4.2/connectionHelper/checks/turn.d.ts +6 -6
  70. package/dist/ts4.2/connectionHelper/checks/webrtc.d.ts +6 -6
  71. package/dist/ts4.2/connectionHelper/checks/websocket.d.ts +6 -6
  72. package/dist/ts4.2/e2ee/E2eeManager.d.ts +111 -85
  73. package/dist/ts4.2/e2ee/KeyProvider.d.ts +54 -54
  74. package/dist/ts4.2/e2ee/constants.d.ts +21 -21
  75. package/dist/ts4.2/e2ee/errors.d.ts +12 -12
  76. package/dist/ts4.2/e2ee/events.d.ts +39 -39
  77. package/dist/ts4.2/e2ee/index.d.ts +6 -6
  78. package/dist/ts4.2/e2ee/types.d.ts +231 -217
  79. package/dist/ts4.2/e2ee/utils.d.ts +32 -32
  80. package/dist/ts4.2/e2ee/worker/DataCryptor.d.ts +16 -16
  81. package/dist/ts4.2/e2ee/worker/ErrorRateLimiter.d.ts +21 -0
  82. package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +209 -226
  83. package/dist/ts4.2/e2ee/worker/ParticipantKeyHandler.d.ts +81 -84
  84. package/dist/ts4.2/e2ee/worker/e2ee.worker.d.ts +2 -2
  85. package/dist/ts4.2/e2ee/worker/naluUtils.d.ts +28 -28
  86. package/dist/ts4.2/e2ee/worker/sifPayload.d.ts +23 -23
  87. package/dist/ts4.2/frameMetadata/FrameMetadataManager.d.ts +53 -53
  88. package/dist/ts4.2/frameMetadata/frameMetadata.d.ts +33 -33
  89. package/dist/ts4.2/frameMetadata/types.d.ts +62 -62
  90. package/dist/ts4.2/frameMetadata/utils.d.ts +9 -9
  91. package/dist/ts4.2/frameMetadata/worker/frameMetadata.worker.d.ts +2 -2
  92. package/dist/ts4.2/index.d.ts +76 -76
  93. package/dist/ts4.2/logger.d.ts +66 -62
  94. package/dist/ts4.2/options.d.ts +163 -149
  95. package/dist/ts4.2/room/BackOffStrategy.d.ts +27 -27
  96. package/dist/ts4.2/room/DefaultReconnectPolicy.d.ts +8 -8
  97. package/dist/ts4.2/room/DeviceManager.d.ts +12 -12
  98. package/dist/ts4.2/room/PCTransport.d.ts +246 -175
  99. package/dist/ts4.2/room/PCTransportManager.d.ts +77 -77
  100. package/dist/ts4.2/room/RTCEngine.d.ts +269 -261
  101. package/dist/ts4.2/room/ReconnectPolicy.d.ts +24 -24
  102. package/dist/ts4.2/room/RegionUrlProvider.d.ts +36 -36
  103. package/dist/ts4.2/room/Room.d.ts +354 -365
  104. package/dist/ts4.2/room/attribute-typings.d.ts +35 -35
  105. package/dist/ts4.2/room/data-channel/DataChannelManager.d.ts +62 -62
  106. package/dist/ts4.2/room/data-channel/FlowControlledDataChannel.d.ts +94 -95
  107. package/dist/ts4.2/room/data-channel/LossyDataChannel.d.ts +41 -41
  108. package/dist/ts4.2/room/data-channel/ReliableDataChannel.d.ts +57 -57
  109. package/dist/ts4.2/room/data-channel/types.d.ts +12 -12
  110. package/dist/ts4.2/room/data-stream/compression.d.ts +49 -49
  111. package/dist/ts4.2/room/data-stream/constants.d.ts +18 -18
  112. package/dist/ts4.2/room/data-stream/incoming/IncomingDataStreamManager.d.ts +29 -29
  113. package/dist/ts4.2/room/data-stream/incoming/StreamReader.d.ts +80 -80
  114. package/dist/ts4.2/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts +73 -73
  115. package/dist/ts4.2/room/data-stream/outgoing/StreamWriter.d.ts +16 -16
  116. package/dist/ts4.2/room/data-stream/outgoing/header-utils.d.ts +18 -18
  117. package/dist/ts4.2/room/data-track/LocalDataTrack.d.ts +79 -80
  118. package/dist/ts4.2/room/data-track/RemoteDataTrack.d.ts +50 -50
  119. package/dist/ts4.2/room/data-track/depacketizer.d.ts +59 -59
  120. package/dist/ts4.2/room/data-track/frame.d.ts +22 -22
  121. package/dist/ts4.2/room/data-track/handle.d.ts +27 -27
  122. package/dist/ts4.2/room/data-track/incoming/IncomingDataTrackManager.d.ts +124 -124
  123. package/dist/ts4.2/room/data-track/incoming/errors.d.ts +24 -24
  124. package/dist/ts4.2/room/data-track/incoming/pipeline.d.ts +41 -41
  125. package/dist/ts4.2/room/data-track/incoming/types.d.ts +20 -20
  126. package/dist/ts4.2/room/data-track/outgoing/OutgoingDataTrackManager.d.ts +126 -126
  127. package/dist/ts4.2/room/data-track/outgoing/errors.d.ts +74 -74
  128. package/dist/ts4.2/room/data-track/outgoing/pipeline.d.ts +23 -23
  129. package/dist/ts4.2/room/data-track/outgoing/types.d.ts +48 -48
  130. package/dist/ts4.2/room/data-track/packet/constants.d.ts +20 -20
  131. package/dist/ts4.2/room/data-track/packet/errors.d.ts +40 -40
  132. package/dist/ts4.2/room/data-track/packet/extensions.d.ts +69 -69
  133. package/dist/ts4.2/room/data-track/packet/index.d.ts +98 -98
  134. package/dist/ts4.2/room/data-track/packet/serializable.d.ts +13 -13
  135. package/dist/ts4.2/room/data-track/packetizer.d.ts +43 -43
  136. package/dist/ts4.2/room/data-track/track-interfaces.d.ts +23 -23
  137. package/dist/ts4.2/room/data-track/types.d.ts +22 -22
  138. package/dist/ts4.2/room/data-track/utils.d.ts +60 -60
  139. package/dist/ts4.2/room/debounce.d.ts +11 -11
  140. package/dist/ts4.2/room/defaults.d.ts +9 -9
  141. package/dist/ts4.2/room/errors.d.ts +180 -162
  142. package/dist/ts4.2/room/events.d.ts +638 -637
  143. package/dist/ts4.2/room/participant/LocalParticipant.d.ts +287 -287
  144. package/dist/ts4.2/room/participant/Participant.d.ts +142 -144
  145. package/dist/ts4.2/room/participant/ParticipantTrackPermission.d.ts +26 -26
  146. package/dist/ts4.2/room/participant/RemoteParticipant.d.ts +85 -86
  147. package/dist/ts4.2/room/participant/publishUtils.d.ts +53 -37
  148. package/dist/ts4.2/room/rpc/client/RpcClientManager.d.ts +43 -43
  149. package/dist/ts4.2/room/rpc/client/events.d.ts +8 -8
  150. package/dist/ts4.2/room/rpc/index.d.ts +7 -7
  151. package/dist/ts4.2/room/rpc/server/RpcServerManager.d.ts +44 -44
  152. package/dist/ts4.2/room/rpc/server/events.d.ts +8 -8
  153. package/dist/ts4.2/room/rpc/utils.d.ts +131 -131
  154. package/dist/ts4.2/room/stats.d.ts +71 -71
  155. package/dist/ts4.2/room/statsSummary.d.ts +13 -13
  156. package/dist/ts4.2/room/timers.d.ts +12 -12
  157. package/dist/ts4.2/room/token-source/TokenSource.d.ts +82 -82
  158. package/dist/ts4.2/room/token-source/types.d.ts +70 -70
  159. package/dist/ts4.2/room/token-source/utils.d.ts +8 -8
  160. package/dist/ts4.2/room/track/FrameMetadataExtractor.d.ts +19 -19
  161. package/dist/ts4.2/room/track/LocalAudioTrack.d.ts +39 -42
  162. package/dist/ts4.2/room/track/LocalTrack.d.ts +125 -125
  163. package/dist/ts4.2/room/track/LocalTrackPublication.d.ts +42 -42
  164. package/dist/ts4.2/room/track/LocalVideoTrack.d.ts +102 -93
  165. package/dist/ts4.2/room/track/RemoteAudioTrack.d.ts +55 -55
  166. package/dist/ts4.2/room/track/RemoteTrack.d.ts +38 -38
  167. package/dist/ts4.2/room/track/RemoteTrackPublication.d.ts +72 -75
  168. package/dist/ts4.2/room/track/RemoteVideoTrack.d.ts +73 -76
  169. package/dist/ts4.2/room/track/Track.d.ts +156 -166
  170. package/dist/ts4.2/room/track/TrackPublication.d.ts +75 -81
  171. package/dist/ts4.2/room/track/create.d.ts +25 -25
  172. package/dist/ts4.2/room/track/facingMode.d.ts +41 -41
  173. package/dist/ts4.2/room/track/options.d.ts +403 -403
  174. package/dist/ts4.2/room/track/processor/types.d.ts +31 -31
  175. package/dist/ts4.2/room/track/record.d.ts +13 -13
  176. package/dist/ts4.2/room/track/types.d.ts +28 -28
  177. package/dist/ts4.2/room/track/utils.d.ts +60 -47
  178. package/dist/ts4.2/room/types.d.ts +127 -127
  179. package/dist/ts4.2/room/utils.d.ts +246 -180
  180. package/dist/ts4.2/test/MockMediaStreamTrack.d.ts +26 -26
  181. package/dist/ts4.2/test/compressionStreamStubs.d.ts +12 -0
  182. package/dist/ts4.2/test/mocks.d.ts +12 -12
  183. package/dist/ts4.2/test/promiseState.d.ts +12 -12
  184. package/dist/ts4.2/test/signalToken.d.ts +26 -26
  185. package/dist/ts4.2/type-polyfills/non-shared-typed-arrays.d.ts +2 -2
  186. package/dist/ts4.2/utils/AsyncQueue.d.ts +23 -23
  187. package/dist/ts4.2/utils/TypedPromise.d.ts +17 -17
  188. package/dist/ts4.2/utils/abort-signal-polyfill.d.ts +13 -13
  189. package/dist/ts4.2/utils/browserParser.d.ts +13 -13
  190. package/dist/ts4.2/utils/camelToSnakeCase.d.ts +8 -8
  191. package/dist/ts4.2/utils/cloneDeep.d.ts +2 -2
  192. package/dist/ts4.2/utils/dataPacketBuffer.d.ts +34 -34
  193. package/dist/ts4.2/utils/deferrable-map.d.ts +32 -32
  194. package/dist/ts4.2/utils/machineInspector.d.ts +54 -54
  195. package/dist/ts4.2/utils/serializer.d.ts +48 -48
  196. package/dist/ts4.2/utils/subscribeToEvents.d.ts +15 -15
  197. package/dist/ts4.2/utils/ttlmap.d.ts +20 -20
  198. package/dist/ts4.2/version.d.ts +15 -15
  199. package/package.json +5 -4
  200. package/src/api/SignalClient.e2e.test.ts +1 -3
  201. package/src/api/SignalClient.test.ts +160 -10
  202. package/src/api/SignalClient.ts +75 -54
  203. package/src/api/WebSocketStream.ts +3 -8
  204. package/src/api/utils.ts +10 -0
  205. package/src/e2ee/E2eeManager.test.ts +196 -0
  206. package/src/e2ee/E2eeManager.ts +114 -19
  207. package/src/e2ee/types.ts +19 -1
  208. package/src/e2ee/worker/DataCryptor.ts +2 -1
  209. package/src/e2ee/worker/ErrorRateLimiter.test.ts +53 -0
  210. package/src/e2ee/worker/ErrorRateLimiter.ts +52 -0
  211. package/src/e2ee/worker/FrameCryptor.ts +20 -70
  212. package/src/e2ee/worker/e2ee.worker.ts +34 -11
  213. package/src/logger.ts +22 -0
  214. package/src/options.ts +16 -0
  215. package/src/room/PCTransport.test.ts +183 -7
  216. package/src/room/PCTransport.ts +197 -36
  217. package/src/room/PCTransportManager.ts +3 -1
  218. package/src/room/RTCEngine.test.ts +84 -0
  219. package/src/room/RTCEngine.ts +52 -12
  220. package/src/room/Room.test.ts +32 -6
  221. package/src/room/Room.ts +27 -7
  222. package/src/room/data-stream/incoming/IncomingDataStreamManager.test.ts +16 -20
  223. package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +5 -5
  224. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.test.ts +60 -39
  225. package/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts +4 -4
  226. package/src/room/defaults.ts +1 -0
  227. package/src/room/errors.test.ts +36 -0
  228. package/src/room/errors.ts +27 -0
  229. package/src/room/events.ts +2 -1
  230. package/src/room/participant/LocalParticipant.ts +30 -14
  231. package/src/room/participant/publishUtils.test.ts +133 -0
  232. package/src/room/participant/publishUtils.ts +54 -38
  233. package/src/room/rpc/client/RpcClientManager.test.ts +51 -0
  234. package/src/room/rpc/client/RpcClientManager.ts +32 -15
  235. package/src/room/track/LocalTrack.ts +18 -7
  236. package/src/room/track/LocalVideoTrack.ts +25 -8
  237. package/src/room/track/RemoteAudioTrack.ts +3 -3
  238. package/src/room/track/RemoteVideoTrack.test.ts +210 -0
  239. package/src/room/track/RemoteVideoTrack.ts +29 -3
  240. package/src/room/track/options.ts +1 -1
  241. package/src/room/track/utils.test.ts +201 -2
  242. package/src/room/track/utils.ts +88 -0
  243. package/src/room/utils.test.ts +211 -0
  244. package/src/room/utils.ts +129 -0
  245. package/src/test/compressionStreamStubs.ts +53 -0
@@ -1,185 +1,187 @@
1
- import { AddTrackRequest, AudioTrackFeature, ClientInfo_Capability, ConnectionQualityUpdate, DataTrackSubscriberHandles, JoinResponse, LeaveRequest, MediaSectionsRequirement, ParticipantInfo, PublishDataTrackResponse, ReconnectReason, ReconnectResponse, RequestResponse, Room, RoomMovedResponse, SessionDescription, SignalResponse, SignalTarget, SimulateScenario, SpeakerInfo, StreamStateUpdate, SubscribedQualityUpdate, SubscriptionPermissionUpdate, SubscriptionResponse, SyncState, TrackPermission, TrackPublishedResponse, TrackUnpublishedResponse, UnpublishDataTrackResponse, UpdateSubscription, UpdateTrackSettings, VideoLayer } from '@livekit/protocol';
2
- import type { DataTrackHandle } from '../room/data-track/handle';
3
- import type { DataTrackSid } from '../room/data-track/types';
4
- import type { LoggerOptions } from '../room/types';
5
- import { AsyncQueue } from '../utils/AsyncQueue';
6
- import { WebSocketStream } from './WebSocketStream';
7
- interface ConnectOpts extends SignalOptions {
8
- /** internal */
9
- reconnect?: boolean;
10
- /** internal */
11
- reconnectReason?: number;
12
- /** internal */
13
- sid?: string;
14
- }
15
- export interface SignalOptions {
16
- autoSubscribe: boolean;
17
- adaptiveStream?: boolean;
18
- clientInfoCapabilities?: ClientInfo_Capability[];
19
- maxRetries: number;
20
- e2eeEnabled: boolean;
21
- websocketTimeout: number;
22
- }
23
- export declare enum SignalConnectionState {
24
- CONNECTING = 0,
25
- CONNECTED = 1,
26
- RECONNECTING = 2,
27
- DISCONNECTING = 3,
28
- DISCONNECTED = 4
29
- }
30
- /** @internal */
31
- export declare class SignalClient {
32
- requestQueue: AsyncQueue;
33
- queuedRequests: Array<() => Promise<void>>;
34
- useJSON: boolean;
35
- /** signal rtt in milliseconds */
36
- rtt: number;
37
- /** simulate signaling latency by delaying messages */
38
- signalLatency?: number;
39
- onClose?: (reason: string) => void;
40
- onAnswer?: (sd: RTCSessionDescriptionInit, offerId: number, midToTrackId: {
41
- [key: string]: string;
42
- }) => void;
43
- onOffer?: (sd: RTCSessionDescriptionInit, offerId: number, midToTrackId: {
44
- [key: string]: string;
45
- }) => void;
46
- onTrickle?: (sd: RTCIceCandidateInit, target: SignalTarget) => void;
47
- onParticipantUpdate?: (updates: ParticipantInfo[]) => void;
48
- onLocalTrackPublished?: (res: TrackPublishedResponse) => void;
49
- onNegotiateRequested?: () => void;
50
- onSpeakersChanged?: (res: SpeakerInfo[]) => void;
51
- onRemoteMuteChanged?: (trackSid: string, muted: boolean) => void;
52
- onRoomUpdate?: (room: Room) => void;
53
- onConnectionQuality?: (update: ConnectionQualityUpdate) => void;
54
- onStreamStateUpdate?: (update: StreamStateUpdate) => void;
55
- onSubscribedQualityUpdate?: (update: SubscribedQualityUpdate) => void;
56
- onSubscriptionPermissionUpdate?: (update: SubscriptionPermissionUpdate) => void;
57
- onSubscriptionError?: (update: SubscriptionResponse) => void;
58
- onLocalTrackUnpublished?: (res: TrackUnpublishedResponse) => void;
59
- onTokenRefresh?: (token: string) => void;
60
- onLeave?: (leave: LeaveRequest) => void;
61
- onRequestResponse?: (response: RequestResponse) => void;
62
- onLocalTrackSubscribed?: (trackSid: string) => void;
63
- onRoomMoved?: (res: RoomMovedResponse) => void;
64
- onMediaSectionsRequirement?: (requirement: MediaSectionsRequirement) => void;
65
- onPublishDataTrackResponse?: (event: PublishDataTrackResponse) => void;
66
- onUnPublishDataTrackResponse?: (event: UnpublishDataTrackResponse) => void;
67
- onDataTrackSubscriberHandles?: (event: DataTrackSubscriberHandles) => void;
68
- onJoined?: (event: JoinResponse) => void;
69
- connectOptions?: ConnectOpts;
70
- ws?: WebSocketStream;
71
- get currentState(): SignalConnectionState;
72
- get isDisconnected(): boolean;
73
- /** Runtime lifecycle state, finer grained than the public {@link currentState} projection. */
74
- private get lifecycleState();
75
- /** Id of the current connection attempt and of the transport it owns. */
76
- private get attemptId();
77
- /**
78
- * Applies a lifecycle input and reports whether it moved the machine
79
- */
80
- private sendLifecycleInput;
81
- /**
82
- * Waits out a close that is already in flight. Establishing a session while one is tearing down
83
- * would race it for the transport — the teardown can close the socket the new attempt just
84
- * opened.
85
- */
86
- private settleInFlightClose;
87
- private get isEstablishingConnection();
88
- private getNextRequestId;
89
- private options?;
90
- private pingTimeout;
91
- private pingTimeoutDuration;
92
- private pingIntervalDuration;
93
- private pingInterval;
94
- private closingLock;
95
- private machine;
96
- private connectionLock;
97
- private log;
98
- private loggerContextCb?;
99
- private _requestId;
100
- private streamWriter;
101
- private useV0SignalPath;
102
- constructor(useJSON?: boolean, loggerOptions?: LoggerOptions);
103
- private get logContext();
104
- join(url: string, token: string, opts: SignalOptions, abortSignal?: AbortSignal, useV0Path?: boolean, publisherOffer?: SessionDescription): Promise<JoinResponse>;
105
- reconnect(url: string, token: string, sid?: string, reason?: ReconnectReason): Promise<ReconnectResponse | undefined>;
106
- private connect;
107
- startReadingLoop(signalReader: ReadableStreamDefaultReader<string | ArrayBuffer>, firstMessage?: SignalResponse): Promise<void>;
108
- /** @internal */
109
- resetCallbacks: () => void;
110
- close(updateState?: boolean, reason?: string): Promise<void>;
111
- /**
112
- * Releases the transport and everything tied to it, without touching the lifecycle state. Used
113
- * both by {@link close} and by paths that replace the transport under a live lifecycle (a new
114
- * attempt, or an unexpected close that leaves the client in `offline`).
115
- */
116
- private teardownTransport;
117
- sendOffer(offer: RTCSessionDescriptionInit, offerId: number): void;
118
- sendAnswer(answer: RTCSessionDescriptionInit, offerId: number): Promise<void>;
119
- sendIceCandidate(candidate: RTCIceCandidateInit, target: SignalTarget): Promise<void>;
120
- sendMuteTrack(trackSid: string, muted: boolean): Promise<void>;
121
- sendAddTrack(req: AddTrackRequest): Promise<void>;
122
- sendUpdateLocalMetadata(metadata: string, name: string, attributes?: Record<string, string>): Promise<number>;
123
- sendUpdateTrackSettings(settings: UpdateTrackSettings): void;
124
- sendUpdateSubscription(sub: UpdateSubscription): Promise<void>;
125
- sendSyncState(sync: SyncState): Promise<void>;
126
- sendUpdateVideoLayers(trackSid: string, layers: VideoLayer[]): Promise<void>;
127
- sendUpdateSubscriptionPermissions(allParticipants: boolean, trackPermissions: TrackPermission[]): Promise<void>;
128
- sendSimulateScenario(scenario: SimulateScenario): Promise<void>;
129
- sendPing(): Promise<[
130
- void,
131
- void
132
- ]>;
133
- sendUpdateLocalAudioTrack(trackSid: string, features: AudioTrackFeature[]): Promise<void>;
134
- sendLeave(): Promise<void>;
135
- sendPublishDataTrackRequest(handle: DataTrackHandle, name: string, usesE2ee: boolean): Promise<void>;
136
- sendUnPublishDataTrackRequest(handle: DataTrackHandle): Promise<void>;
137
- sendUpdateDataSubscription(sid: DataTrackSid, subscribe: boolean): Promise<void>;
138
- private sendRequest;
139
- private handleSignalResponse;
140
- setReconnected(): void;
141
- /**
142
- * Handles a transport we lost without asking to. The client goes to `offline` rather than
143
- * `closed`: whether this session gets resumed, restarted or given up on is the engine's call.
144
- */
145
- private handleOnClose;
146
- private handleWSError;
147
- /**
148
- * Resets the ping timeout and starts a new timeout.
149
- * Call this after receiving a pong message
150
- */
151
- private resetPingTimeout;
152
- /**
153
- * Clears ping timeout (does not start a new timeout)
154
- */
155
- private clearPingTimeout;
156
- private startPingInterval;
157
- private clearPingInterval;
158
- /**
159
- * Handles the successful connection to the signal server
160
- * @param connection The WebSocket connection
161
- * @param timeoutHandle The timeout handle to clear
162
- * @param firstMessage Optional first message to process
163
- * @internal
164
- */
165
- private handleSignalConnected;
166
- /**
167
- * Validates the first message received from the signal server
168
- * @param firstSignalResponse The first signal response received
169
- * @param isReconnect Whether this is a reconnection attempt
170
- * @returns Validation result with response or error
171
- * @internal
172
- */
173
- private validateFirstMessage;
174
- /**
175
- * Handles WebSocket connection errors by validating with the server
176
- * @param reason The error that occurred
177
- * @param validateUrl The URL to validate the connection with
178
- * @returns A ConnectionError with appropriate reason and status
179
- * @internal
180
- */
181
- private handleConnectionError;
182
- }
183
- export declare function toProtoSessionDescription(rsd: RTCSessionDescription | RTCSessionDescriptionInit, id?: number): SessionDescription;
184
- export {};
185
- //# sourceMappingURL=SignalClient.d.ts.map
1
+ import { AddTrackRequest, AudioTrackFeature, ClientInfo_Capability, ConnectionQualityUpdate, DataTrackSubscriberHandles, JoinResponse, LeaveRequest, MediaSectionsRequirement, ParticipantInfo, PublishDataTrackResponse, ReconnectReason, ReconnectResponse, RequestResponse, Room, RoomMovedResponse, SessionDescription, SignalTarget, SimulateScenario, SpeakerInfo, StreamStateUpdate, SubscribedQualityUpdate, SubscriptionPermissionUpdate, SubscriptionResponse, SyncState, TrackPermission, TrackPublishedResponse, TrackUnpublishedResponse, UnpublishDataTrackResponse, UpdateSubscription, UpdateTrackSettings, VideoLayer } from '@livekit/protocol';
2
+ import type { DataTrackHandle } from '../room/data-track/handle';
3
+ import type { DataTrackSid } from '../room/data-track/types';
4
+ import type { LoggerOptions } from '../room/types';
5
+ import { AsyncQueue } from '../utils/AsyncQueue';
6
+ import { WebSocketStream } from './WebSocketStream';
7
+ interface ConnectOpts extends SignalOptions {
8
+ /** internal */
9
+ reconnect?: boolean;
10
+ /** internal */
11
+ reconnectReason?: number;
12
+ /** internal */
13
+ sid?: string;
14
+ }
15
+ export interface SignalOptions {
16
+ autoSubscribe: boolean;
17
+ adaptiveStream?: boolean;
18
+ disableIceLite?: boolean;
19
+ subscriberAllowPause?: boolean;
20
+ clientInfoCapabilities?: ClientInfo_Capability[];
21
+ maxRetries: number;
22
+ e2eeEnabled: boolean;
23
+ websocketTimeout: number;
24
+ }
25
+ export declare enum SignalConnectionState {
26
+ CONNECTING = 0,
27
+ CONNECTED = 1,
28
+ RECONNECTING = 2,
29
+ DISCONNECTING = 3,
30
+ DISCONNECTED = 4
31
+ }
32
+ /** @internal */
33
+ export declare class SignalClient {
34
+ requestQueue: AsyncQueue;
35
+ queuedRequests: Array<() => Promise<void>>;
36
+ useJSON: boolean;
37
+ /** signal rtt in milliseconds */
38
+ rtt: number;
39
+ /** simulate signaling latency by delaying messages */
40
+ signalLatency?: number;
41
+ onClose?: (reason: string) => void;
42
+ onAnswer?: (sd: RTCSessionDescriptionInit, offerId: number, midToTrackId: {
43
+ [key: string]: string;
44
+ }) => void;
45
+ onOffer?: (sd: RTCSessionDescriptionInit, offerId: number, midToTrackId: {
46
+ [key: string]: string;
47
+ }) => void;
48
+ onTrickle?: (sd: RTCIceCandidateInit, target: SignalTarget) => void;
49
+ onParticipantUpdate?: (updates: ParticipantInfo[]) => void;
50
+ onLocalTrackPublished?: (res: TrackPublishedResponse) => void;
51
+ onNegotiateRequested?: () => void;
52
+ onSpeakersChanged?: (res: SpeakerInfo[]) => void;
53
+ onRemoteMuteChanged?: (trackSid: string, muted: boolean) => void;
54
+ onRoomUpdate?: (room: Room) => void;
55
+ onConnectionQuality?: (update: ConnectionQualityUpdate) => void;
56
+ onStreamStateUpdate?: (update: StreamStateUpdate) => void;
57
+ onSubscribedQualityUpdate?: (update: SubscribedQualityUpdate) => void;
58
+ onSubscriptionPermissionUpdate?: (update: SubscriptionPermissionUpdate) => void;
59
+ onSubscriptionError?: (update: SubscriptionResponse) => void;
60
+ onLocalTrackUnpublished?: (res: TrackUnpublishedResponse) => void;
61
+ onTokenRefresh?: (token: string) => void;
62
+ onLeave?: (leave: LeaveRequest) => void;
63
+ onRequestResponse?: (response: RequestResponse) => void;
64
+ onLocalTrackSubscribed?: (trackSid: string) => void;
65
+ onRoomMoved?: (res: RoomMovedResponse) => void;
66
+ onMediaSectionsRequirement?: (requirement: MediaSectionsRequirement) => void;
67
+ onPublishDataTrackResponse?: (event: PublishDataTrackResponse) => void;
68
+ onUnPublishDataTrackResponse?: (event: UnpublishDataTrackResponse) => void;
69
+ onDataTrackSubscriberHandles?: (event: DataTrackSubscriberHandles) => void;
70
+ onJoined?: (event: JoinResponse) => void;
71
+ connectOptions?: ConnectOpts;
72
+ ws?: WebSocketStream;
73
+ get currentState(): SignalConnectionState;
74
+ get isDisconnected(): boolean;
75
+ /** Runtime lifecycle state, finer grained than the public {@link currentState} projection. */
76
+ private get lifecycleState();
77
+ /** Id of the current connection attempt and of the transport it owns. */
78
+ private get attemptId();
79
+ /**
80
+ * Applies a lifecycle input and reports whether it moved the machine
81
+ */
82
+ private sendLifecycleInput;
83
+ /**
84
+ * Waits out a close that is already in flight. Establishing a session while one is tearing down
85
+ * would race it for the transport — the teardown can close the socket the new attempt just
86
+ * opened.
87
+ */
88
+ private settleInFlightClose;
89
+ private get isEstablishingConnection();
90
+ private getNextRequestId;
91
+ private options?;
92
+ private pingTimeout;
93
+ private pingTimeoutDuration;
94
+ private pingIntervalDuration;
95
+ private pingInterval;
96
+ private closingLock;
97
+ private machine;
98
+ private connectionLock;
99
+ private log;
100
+ private loggerContextCb?;
101
+ private _requestId;
102
+ private streamWriter;
103
+ private useV0SignalPath;
104
+ constructor(useJSON?: boolean, loggerOptions?: LoggerOptions);
105
+ private get logContext();
106
+ join(url: string, token: string, opts: SignalOptions, abortSignal?: AbortSignal, useV0Path?: boolean, publisherOffer?: SessionDescription): Promise<JoinResponse>;
107
+ reconnect(url: string, token: string, sid?: string, reason?: ReconnectReason): Promise<ReconnectResponse | undefined>;
108
+ private connect;
109
+ startReadingLoop(signalReader: ReadableStreamDefaultReader<string | ArrayBuffer>): Promise<void>;
110
+ /** @internal */
111
+ resetCallbacks: () => void;
112
+ close(updateState?: boolean, reason?: string): Promise<void>;
113
+ /**
114
+ * Releases the transport and everything tied to it, without touching the lifecycle state. Used
115
+ * both by {@link close} and by paths that replace the transport under a live lifecycle (a new
116
+ * attempt, or an unexpected close that leaves the client in `offline`).
117
+ */
118
+ private teardownTransport;
119
+ sendOffer(offer: RTCSessionDescriptionInit, offerId: number): void;
120
+ sendAnswer(answer: RTCSessionDescriptionInit, offerId: number): Promise<void>;
121
+ sendIceCandidate(candidate: RTCIceCandidateInit, target: SignalTarget): Promise<void>;
122
+ sendMuteTrack(trackSid: string, muted: boolean): Promise<void>;
123
+ sendAddTrack(req: AddTrackRequest): Promise<void>;
124
+ sendUpdateLocalMetadata(metadata: string, name: string, attributes?: Record<string, string>): Promise<number>;
125
+ sendUpdateTrackSettings(settings: UpdateTrackSettings): void;
126
+ sendUpdateSubscription(sub: UpdateSubscription): Promise<void>;
127
+ sendSyncState(sync: SyncState): Promise<void>;
128
+ sendUpdateVideoLayers(trackSid: string, layers: VideoLayer[]): Promise<void>;
129
+ sendUpdateSubscriptionPermissions(allParticipants: boolean, trackPermissions: TrackPermission[]): Promise<void>;
130
+ sendSimulateScenario(scenario: SimulateScenario): Promise<void>;
131
+ sendPing(): Promise<[
132
+ void,
133
+ void
134
+ ]>;
135
+ sendUpdateLocalAudioTrack(trackSid: string, features: AudioTrackFeature[]): Promise<void>;
136
+ sendLeave(): Promise<void>;
137
+ sendPublishDataTrackRequest(handle: DataTrackHandle, name: string, usesE2ee: boolean): Promise<void>;
138
+ sendUnPublishDataTrackRequest(handle: DataTrackHandle): Promise<void>;
139
+ sendUpdateDataSubscription(sid: DataTrackSid, subscribe: boolean): Promise<void>;
140
+ private sendRequest;
141
+ private handleSignalResponse;
142
+ setReconnected(): void;
143
+ /**
144
+ * Handles a transport we lost without asking to. The client goes to `offline` rather than
145
+ * `closed`: whether this session gets resumed, restarted or given up on is the engine's call.
146
+ */
147
+ private handleOnClose;
148
+ private handleWSError;
149
+ /**
150
+ * Resets the ping timeout and starts a new timeout.
151
+ * Call this after receiving a pong message
152
+ */
153
+ private resetPingTimeout;
154
+ /**
155
+ * Clears ping timeout (does not start a new timeout)
156
+ */
157
+ private clearPingTimeout;
158
+ private startPingInterval;
159
+ private clearPingInterval;
160
+ /**
161
+ * Handles the successful connection to the signal server
162
+ * @param connection The WebSocket connection
163
+ * @param timeoutHandle The timeout handle to clear
164
+ * @param firstMessage Optional first message to process
165
+ * @internal
166
+ */
167
+ private handleSignalConnected;
168
+ /**
169
+ * Validates the first message received from the signal server
170
+ * @param firstSignalResponse The first signal response received
171
+ * @param isReconnect Whether this is a reconnection attempt
172
+ * @returns Validation result with response or error
173
+ * @internal
174
+ */
175
+ private validateFirstMessage;
176
+ /**
177
+ * Handles WebSocket connection errors by validating with the server
178
+ * @param reason The error that occurred
179
+ * @param validateUrl The URL to validate the connection with
180
+ * @returns A ConnectionError with appropriate reason and status
181
+ * @internal
182
+ */
183
+ private handleConnectionError;
184
+ }
185
+ export declare function toProtoSessionDescription(rsd: RTCSessionDescription | RTCSessionDescriptionInit, id?: number): SessionDescription;
186
+ export {};
187
+ //# sourceMappingURL=SignalClient.d.ts.map
@@ -1,85 +1,85 @@
1
- /**
2
- * Runtime lifecycle states of the signal connection.
3
- *
4
- * `offline` is the resting state after the transport was lost without an explicit close: no
5
- * attempt is in flight, but a resume is still legal. It is what makes retrying a failed resume
6
- * expressible — `closed` is only reached by an explicit close or by a terminal attempt failure.
7
- */
8
- export type SignalLifecycleState = 'new' | 'connecting' | 'connected' | 'offline' | 'reconnecting' | 'disconnecting' | 'closed';
9
- export interface SignalMachineContext {
10
- /** Monotonic id of the current (re)connection attempt and of the transport it owns */
11
- attemptId: number;
12
- /** Error or reason that ended the last attempt, kept for diagnostics. */
13
- lastError?: unknown;
14
- /** Reason passed to the last close request. */
15
- closeReason?: string;
16
- }
17
- export type SignalMachineInput =
18
- /**
19
- * Start an initial session, or restart from scratch (full reconnect).
20
- *
21
- * Establishing is legal exactly where no transport and no attempt are in play: `new`, `offline`
22
- * and `closed`. `closed` is included because it means "no transport", not "session over" — a
23
- * deliberate close and an unexpected loss leave the session equally resumable, and the engine
24
- * recovers from both. Establishing over a live session, or over an attempt already in flight, is
25
- * a caller error; `disconnecting` is waited out rather than refused.
26
- */
27
- {
28
- type: 'connect';
29
- }
30
- /**
31
- * Resume the existing session: legal wherever establishing is, minus `new` (nothing to resume
32
- * yet), plus `connected` — the peer connection can be severed while signalling stays up.
33
- */
34
- | {
35
- type: 'reconnect';
36
- }
37
- /**
38
- * An attempt established its transport. Carries the attempt it belongs to: an attempt that a
39
- * newer one has already superseded must not declare the session live.
40
- */
41
- | {
42
- type: 'connectComplete';
43
- attemptId: number;
44
- } | {
45
- type: 'connectFailed';
46
- error?: unknown;
47
- } | {
48
- type: 'reconnectComplete';
49
- attemptId: number;
50
- }
51
- /**
52
- * A resume attempt ended. `recoverable` distinguishes "another resume may follow" (→ `offline`)
53
- * from a terminal outcome such as a server leave or an expired token (→ `closed`).
54
- */
55
- | {
56
- type: 'reconnectFailed';
57
- error?: unknown;
58
- recoverable: boolean;
59
- }
60
- /** The transport identified by `attemptId` was lost (unexpected ws close, ping timeout). */
61
- | {
62
- type: 'transportFailed';
63
- attemptId: number;
64
- reason: string;
65
- } | {
66
- type: 'close';
67
- reason: string;
68
- } | {
69
- type: 'closeComplete';
70
- };
71
- /**
72
- * Lifecycle model of the signal connection.
73
- *
74
- * The machine deliberately does not own connection attempts: `SignalClient` performs the
75
- * asynchronous work and reports the outcome. It also does not decide *whether* to reconnect —
76
- * that policy (backoff, resume vs. full reconnect, region failover, giving up) belongs to
77
- * `RTCEngine`, so transport loss lands in `offline` rather than starting a reconnect on its own.
78
- *
79
- * Each client gets its own instance: the context is mutable and per-connection.
80
- */
81
- export declare function createSignalMachine(initialState?: SignalLifecycleState): import("machina").Fsm<SignalMachineContext, "new" | "connecting" | "connected" | "offline" | "reconnecting" | "disconnecting" | "closed", "connect" | "reconnect" | "connectComplete" | "connectFailed" | "reconnectComplete" | "reconnectFailed" | "transportFailed" | "close" | "closeComplete", never>;
82
- export type SignalMachine = ReturnType<typeof createSignalMachine>;
83
- /** All lifecycle states, derived from the machine itself so the two cannot drift. */
84
- export declare const signalLifecycleStates: Array<SignalLifecycleState>;
85
- //# sourceMappingURL=SignalClientStateMachine.d.ts.map
1
+ /**
2
+ * Runtime lifecycle states of the signal connection.
3
+ *
4
+ * `offline` is the resting state after the transport was lost without an explicit close: no
5
+ * attempt is in flight, but a resume is still legal. It is what makes retrying a failed resume
6
+ * expressible — `closed` is only reached by an explicit close or by a terminal attempt failure.
7
+ */
8
+ export type SignalLifecycleState = 'new' | 'connecting' | 'connected' | 'offline' | 'reconnecting' | 'disconnecting' | 'closed';
9
+ export interface SignalMachineContext {
10
+ /** Monotonic id of the current (re)connection attempt and of the transport it owns */
11
+ attemptId: number;
12
+ /** Error or reason that ended the last attempt, kept for diagnostics. */
13
+ lastError?: unknown;
14
+ /** Reason passed to the last close request. */
15
+ closeReason?: string;
16
+ }
17
+ export type SignalMachineInput =
18
+ /**
19
+ * Start an initial session, or restart from scratch (full reconnect).
20
+ *
21
+ * Establishing is legal exactly where no transport and no attempt are in play: `new`, `offline`
22
+ * and `closed`. `closed` is included because it means "no transport", not "session over" — a
23
+ * deliberate close and an unexpected loss leave the session equally resumable, and the engine
24
+ * recovers from both. Establishing over a live session, or over an attempt already in flight, is
25
+ * a caller error; `disconnecting` is waited out rather than refused.
26
+ */
27
+ {
28
+ type: 'connect';
29
+ }
30
+ /**
31
+ * Resume the existing session: legal wherever establishing is, minus `new` (nothing to resume
32
+ * yet), plus `connected` — the peer connection can be severed while signalling stays up.
33
+ */
34
+ | {
35
+ type: 'reconnect';
36
+ }
37
+ /**
38
+ * An attempt established its transport. Carries the attempt it belongs to: an attempt that a
39
+ * newer one has already superseded must not declare the session live.
40
+ */
41
+ | {
42
+ type: 'connectComplete';
43
+ attemptId: number;
44
+ } | {
45
+ type: 'connectFailed';
46
+ error?: unknown;
47
+ } | {
48
+ type: 'reconnectComplete';
49
+ attemptId: number;
50
+ }
51
+ /**
52
+ * A resume attempt ended. `recoverable` distinguishes "another resume may follow" (→ `offline`)
53
+ * from a terminal outcome such as a server leave or an expired token (→ `closed`).
54
+ */
55
+ | {
56
+ type: 'reconnectFailed';
57
+ error?: unknown;
58
+ recoverable: boolean;
59
+ }
60
+ /** The transport identified by `attemptId` was lost (unexpected ws close, ping timeout). */
61
+ | {
62
+ type: 'transportFailed';
63
+ attemptId: number;
64
+ reason: string;
65
+ } | {
66
+ type: 'close';
67
+ reason: string;
68
+ } | {
69
+ type: 'closeComplete';
70
+ };
71
+ /**
72
+ * Lifecycle model of the signal connection.
73
+ *
74
+ * The machine deliberately does not own connection attempts: `SignalClient` performs the
75
+ * asynchronous work and reports the outcome. It also does not decide *whether* to reconnect —
76
+ * that policy (backoff, resume vs. full reconnect, region failover, giving up) belongs to
77
+ * `RTCEngine`, so transport loss lands in `offline` rather than starting a reconnect on its own.
78
+ *
79
+ * Each client gets its own instance: the context is mutable and per-connection.
80
+ */
81
+ export declare function createSignalMachine(initialState?: SignalLifecycleState): import("machina").Fsm<SignalMachineContext, "new" | "connecting" | "connected" | "offline" | "reconnecting" | "disconnecting" | "closed", "connect" | "reconnect" | "connectComplete" | "connectFailed" | "reconnectComplete" | "reconnectFailed" | "transportFailed" | "close" | "closeComplete", never>;
82
+ export type SignalMachine = ReturnType<typeof createSignalMachine>;
83
+ /** All lifecycle states, derived from the machine itself so the two cannot drift. */
84
+ export declare const signalLifecycleStates: Array<SignalLifecycleState>;
85
+ //# sourceMappingURL=SignalClientStateMachine.d.ts.map
@@ -1,33 +1,33 @@
1
- import { ConnectionError } from '../room/errors';
2
- import TypedPromise from '../utils/TypedPromise';
3
- export interface WebSocketConnection<T extends ArrayBuffer | string = ArrayBuffer | string> {
4
- readable: ReadableStream<T>;
5
- writable: WritableStream<T>;
6
- protocol: string;
7
- extensions: string;
8
- }
9
- export interface WebSocketCloseInfo {
10
- closeCode?: number;
11
- reason?: string;
12
- }
13
- export interface WebSocketStreamOptions {
14
- protocols?: string[];
15
- signal?: AbortSignal;
16
- }
17
- type WebsocketError = ReturnType<typeof ConnectionError.websocket>;
18
- /**
19
- * [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) with [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
20
- *
21
- * @see https://web.dev/websocketstream/
22
- */
23
- export declare class WebSocketStream<T extends ArrayBuffer | string = ArrayBuffer | string> {
24
- readonly url: string;
25
- readonly opened: TypedPromise<WebSocketConnection<T>, WebsocketError>;
26
- readonly closed: TypedPromise<WebSocketCloseInfo, WebsocketError>;
27
- readonly close: (closeInfo?: WebSocketCloseInfo) => void;
28
- get readyState(): number;
29
- private ws;
30
- constructor(url: string, options?: WebSocketStreamOptions);
31
- }
32
- export {};
33
- //# sourceMappingURL=WebSocketStream.d.ts.map
1
+ import { ConnectionError } from '../room/errors';
2
+ import TypedPromise from '../utils/TypedPromise';
3
+ export interface WebSocketConnection<T extends ArrayBuffer | string = ArrayBuffer | string> {
4
+ readable: ReadableStream<T>;
5
+ writable: WritableStream<T>;
6
+ protocol: string;
7
+ extensions: string;
8
+ }
9
+ export interface WebSocketCloseInfo {
10
+ closeCode?: number;
11
+ reason?: string;
12
+ }
13
+ export interface WebSocketStreamOptions {
14
+ protocols?: string[];
15
+ signal?: AbortSignal;
16
+ }
17
+ type WebsocketError = ReturnType<typeof ConnectionError.websocket>;
18
+ /**
19
+ * [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) with [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
20
+ *
21
+ * @see https://web.dev/websocketstream/
22
+ */
23
+ export declare class WebSocketStream<T extends ArrayBuffer | string = ArrayBuffer | string> {
24
+ readonly url: string;
25
+ readonly opened: TypedPromise<WebSocketConnection<T>, WebsocketError>;
26
+ readonly closed: TypedPromise<WebSocketCloseInfo, WebsocketError>;
27
+ readonly close: (closeInfo?: WebSocketCloseInfo) => void;
28
+ get readyState(): number;
29
+ private ws;
30
+ constructor(url: string, options?: WebSocketStreamOptions);
31
+ }
32
+ export {};
33
+ //# sourceMappingURL=WebSocketStream.d.ts.map