react-websocket 4.0.0 → 4.18.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 (52) hide show
  1. package/README.md +27 -3
  2. package/dist/ag-ui.cjs +421 -0
  3. package/dist/ag-ui.cjs.map +1 -0
  4. package/dist/ag-ui.d.cts +493 -0
  5. package/dist/ag-ui.d.ts +171 -0
  6. package/dist/ag-ui.js +418 -0
  7. package/dist/ag-ui.js.map +1 -0
  8. package/dist/core.cjs +689 -153
  9. package/dist/core.cjs.map +1 -1
  10. package/dist/core.d.cts +459 -53
  11. package/dist/core.d.ts +459 -53
  12. package/dist/core.js +686 -154
  13. package/dist/core.js.map +1 -1
  14. package/dist/devtools.cjs +186 -0
  15. package/dist/devtools.cjs.map +1 -0
  16. package/dist/devtools.d.cts +32 -0
  17. package/dist/devtools.d.ts +32 -0
  18. package/dist/devtools.js +185 -0
  19. package/dist/devtools.js.map +1 -0
  20. package/dist/index.cjs +182 -23
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +663 -48
  23. package/dist/index.d.ts +393 -22
  24. package/dist/index.js +178 -24
  25. package/dist/index.js.map +1 -1
  26. package/dist/outbox.cjs +222 -0
  27. package/dist/outbox.cjs.map +1 -0
  28. package/dist/outbox.d.cts +127 -0
  29. package/dist/outbox.d.ts +127 -0
  30. package/dist/outbox.js +219 -0
  31. package/dist/outbox.js.map +1 -0
  32. package/dist/replay.cjs +324 -0
  33. package/dist/replay.cjs.map +1 -0
  34. package/dist/replay.d.cts +124 -0
  35. package/dist/replay.d.ts +124 -0
  36. package/dist/replay.js +322 -0
  37. package/dist/replay.js.map +1 -0
  38. package/dist/tabs.cjs +336 -0
  39. package/dist/tabs.cjs.map +1 -0
  40. package/dist/tabs.d.cts +81 -0
  41. package/dist/tabs.d.ts +81 -0
  42. package/dist/tabs.js +335 -0
  43. package/dist/tabs.js.map +1 -0
  44. package/dist/timeline.d.cts +1 -216
  45. package/dist/types-BEecFqIB.d.cts +268 -0
  46. package/dist/webtransport.cjs +243 -0
  47. package/dist/webtransport.cjs.map +1 -0
  48. package/dist/webtransport.d.cts +67 -0
  49. package/dist/webtransport.d.ts +67 -0
  50. package/dist/webtransport.js +242 -0
  51. package/dist/webtransport.js.map +1 -0
  52. package/package.json +139 -3
@@ -1,219 +1,4 @@
1
- //#region src/types.d.ts
2
- /**
3
- * Where to connect: a URL, or a function that returns one (sync or async).
4
- *
5
- * A function is called before **every** connection attempt, including reconnects,
6
- * so it can put a fresh auth token in the URL. If it throws or rejects, that counts
7
- * as a failed attempt and is retried with backoff.
8
- *
9
- * @example
10
- * ```ts
11
- * createWebSocket(async () => `wss://api.example.com/live?token=${await getToken()}`);
12
- * ```
13
- */
14
- type UrlSource = string | (() => string | Promise<string>);
15
- /**
16
- * Connection state.
17
- *
18
- * - `idle`: not connected and not trying to be. Nobody is using the client yet, or everyone stopped.
19
- * - `connecting`: the first attempt is in progress.
20
- * - `open`: connected. `send()` goes out immediately.
21
- * - `reconnecting`: the connection dropped (or an attempt failed) and a retry is scheduled or in progress.
22
- * - `closed`: stopped for good, by `close()` or after giving up on reconnecting.
23
- * It stays closed until `connect()` or `reconnect()` is called, or every hook unmounts.
24
- */
25
- type Status = 'idle' | 'connecting' | 'open' | 'reconnecting' | 'closed';
26
- /** The client's state as seen by React. A new object is created on every change. */
27
- interface Snapshot<In> {
28
- /** Connection state. */
29
- readonly status: Status;
30
- /** Most recent message (after `parse`/`json` and `schema`), kept across reconnects. */
31
- readonly lastMessage: In | undefined;
32
- /**
33
- * Consecutive failed attempts since the last stable connection. A connection that closes
34
- * within `reconnect.minUptime` of opening counts as failed. `0` while open.
35
- */
36
- readonly attempt: number;
37
- }
38
- /** Details of a closed connection, from the browser's `CloseEvent`. */
39
- interface CloseInfo {
40
- /** Close code: `1000` is a normal close, `1006` an abnormal one (e.g. network loss), `4000`–`4999` are yours. */
41
- readonly code: number;
42
- /** Close reason sent by the side that closed the connection. Often empty. */
43
- readonly reason: string;
44
- /** Whether the closing handshake completed. */
45
- readonly wasClean: boolean;
46
- }
47
- /** Per-message options for `send()`. */
48
- interface SendOptions {
49
- /**
50
- * Drop the message instead of queueing it when the socket isn't open. For data that
51
- * is stale by the time a reconnect finishes, such as player input or cursor positions.
52
- * @default false
53
- */
54
- volatile?: boolean;
55
- /**
56
- * Keep only the newest queued message with this key. Sending again with the same key
57
- * while disconnected replaces the earlier one, which moves to the back of the queue
58
- * (or of the `priority` messages, for a priority one).
59
- * For state where only the latest value matters, such as "my position is now (x, y)".
60
- */
61
- key?: string;
62
- /**
63
- * Queue this message ahead of every message queued without `priority`, after earlier
64
- * priority messages. For control messages that must not wait behind a backlog, such as
65
- * cancel, interrupt or a token refresh. Messages sent from `open` listeners still go first.
66
- *
67
- * It only matters while the socket isn't open: once a message is handed to the browser,
68
- * nothing can overtake it. To keep that buffer short, send bulky streams with `maxBuffered`.
69
- * @default false
70
- */
71
- priority?: boolean;
72
- /**
73
- * Drop the message instead of sending it while more than this many bytes are already
74
- * waiting in the browser's send buffer (`socket.bufferedAmount`). For high-rate streams on
75
- * a slow link, such as audio frames or per-tick input, where a late message is worse than
76
- * none. `send()` returns `false`, and `onDrop` isn't called.
77
- *
78
- * Only checked while the socket is open: a message queued while disconnected is sent on
79
- * open regardless. `bufferedAmount` includes what you sent earlier in the same task, so set
80
- * it well above one burst of messages.
81
- *
82
- * @example
83
- * ```ts
84
- * voice.send(frame, { volatile: true, maxBuffered: 64 * 1024 });
85
- * ```
86
- */
87
- maxBuffered?: number;
88
- /**
89
- * Called if the message is dropped from the queue without being sent: replaced by a
90
- * newer message with the same `key`, or evicted by `queue.limit`. Not called when the
91
- * queue is cleared because the client closed or gave up, or when `send()` drops the
92
- * message right away (`volatile` while not open, or `maxBuffered`) and returns `false`.
93
- */
94
- onDrop?: () => void;
95
- }
96
- /**
97
- * Reported via the `error` event (and `onError`) when an incoming message can't be
98
- * decoded by `parse`/`json` or fails `schema` validation. The message is not delivered.
99
- *
100
- * @example
101
- * ```ts
102
- * onError(error) {
103
- * if (error instanceof MessageError) report(error.data, error.issues);
104
- * }
105
- * ```
106
- */
107
- declare class MessageError extends Error {
108
- /** The raw `event.data` that failed. */
109
- readonly data: unknown;
110
- /** Schema validation issues, when the message failed `schema`. */
111
- readonly issues: ReadonlyArray<{
112
- readonly message: string;
113
- }> | undefined;
114
- constructor(message: string, data: unknown, options?: {
115
- cause?: unknown;
116
- issues?: ReadonlyArray<{
117
- readonly message: string;
118
- }>;
119
- });
120
- }
121
- /** Events emitted by a client. Subscribe with `client.on(type, listener)` or `useWebSocketEvent`. */
122
- interface EventMap<In> {
123
- /**
124
- * The socket opened (initially or after a reconnect). Listeners run before queued
125
- * messages are sent, so a handshake sent from here goes out first.
126
- */
127
- open: (event: Event) => void;
128
- /** A message arrived and passed `parse` and `schema`. */
129
- message: (message: In, event: MessageEvent) => void;
130
- /** A socket closed, whether it will be retried or not. */
131
- close: (close: CloseInfo) => void;
132
- /**
133
- * A socket error `Event`, a {@link MessageError} for an undecodable or invalid message,
134
- * or the `Error` thrown by the `WebSocket` constructor or a `url` function.
135
- */
136
- error: (error: Event | MessageError | Error) => void;
137
- }
138
- /**
139
- * A WebSocket connection that reconnects, queues, decodes and can be shared.
140
- * Create one with `createWebSocket()`.
141
- *
142
- * The connection is reference-counted: it opens when the first hook mounts (or
143
- * `ready` is read) and closes one tick after the last hook unmounts. Calling
144
- * `connect()` keeps it open regardless, until `close()`.
145
- *
146
- * @typeParam In - Type of incoming messages.
147
- * @typeParam Out - Type accepted by `send()`.
148
- */
149
- interface WebSocketClient<In = unknown, Out = unknown> {
150
- /** The URL (or URL function) the client was created with. */
151
- readonly url: UrlSource;
152
- /**
153
- * A promise that resolves once the socket has opened. Reading it starts an idle client.
154
- *
155
- * It stays resolved through automatic reconnects, so `use(client.ready)` shows a
156
- * Suspense fallback only for the first connection, never on a network blip; use
157
- * `status` to show reconnects. It rejects when the client gives up reconnecting, when
158
- * `close()` is called, and during a server render. After that, `connect()` or
159
- * `reconnect()` make it a new pending promise.
160
- *
161
- * It is safe to pass to React 19's `use()`: the same promise is returned until its state
162
- * changes, and it carries `status`/`value`/`reason` so `use()` doesn't suspend when it is
163
- * already settled.
164
- */
165
- readonly ready: Promise<void>;
166
- /** The current underlying `WebSocket`, if any. An escape hatch; prefer the client's methods. */
167
- readonly socket: WebSocket | null;
168
- /** Subscribe to snapshot changes. Compatible with `useSyncExternalStore`. Returns an unsubscribe function. */
169
- subscribe(listener: () => void): () => void;
170
- /** The current {@link Snapshot}. Returns the same object until something changes. */
171
- getSnapshot(): Snapshot<In>;
172
- /**
173
- * Listen to an event. Returns an unsubscribe function. Listener errors are re-thrown
174
- * asynchronously, so one failing listener doesn't break the others.
175
- */
176
- on<K extends keyof EventMap<In>>(type: K, listener: EventMap<In>[K]): () => void;
177
- /**
178
- * Send a message (encoded with `serialize`/`json` if configured). If the socket isn't
179
- * open, the message is queued and sent on open (see the `queue` option), unless
180
- * `options.volatile` is set.
181
- * @returns `true` if it was sent immediately, `false` if it was queued or dropped
182
- * (`volatile` while not open, or `maxBuffered` while open).
183
- *
184
- * @example
185
- * ```ts
186
- * game.send({ type: 'input', dx, dy }, { volatile: true }); // never replayed after a reconnect
187
- * game.send({ type: 'position', x, y }, { key: 'position' }); // only the newest is queued
188
- * game.send({ type: 'leave' }, { priority: true }); // ahead of everything already queued
189
- * ```
190
- */
191
- send(message: Out, options?: SendOptions): boolean;
192
- /**
193
- * Start connecting, and keep the connection open even when no hook is using the
194
- * client, until `close()` is called. Does nothing if already connecting or open.
195
- */
196
- connect(): void;
197
- /**
198
- * Close the connection and stop reconnecting. The status becomes `closed` and the
199
- * send queue is cleared. Mounted hooks stay mounted; call `connect()` or `reconnect()`
200
- * to start again.
201
- * @param code - Close code. @default 1000
202
- */
203
- close(code?: number, reason?: string): void;
204
- /**
205
- * Drop the current socket (if any) and connect again immediately, resetting the
206
- * backoff. Also restarts a `closed` client.
207
- */
208
- reconnect(): void;
209
- /**
210
- * Hold the connection open until the returned function is called. This is what the
211
- * hooks use; call it yourself to integrate with non-React code.
212
- * @returns A release function (safe to call more than once).
213
- */
214
- acquire(): () => void;
215
- }
216
- //#endregion
1
+ import { t as WebSocketClient } from "./types-BEecFqIB.cjs";
217
2
  //#region src/latency.d.ts
218
3
  /** Latest latency measurements. A new object is created on every change. */
219
4
  interface Latency {
@@ -0,0 +1,268 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * Where to connect: a URL, or a function that returns one (sync or async).
4
+ *
5
+ * A function is called before **every** connection attempt, including reconnects,
6
+ * so it can put a fresh auth token in the URL. If it throws or rejects, that counts
7
+ * as a failed attempt and is retried with backoff.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * createWebSocket(async () => `wss://api.example.com/live?token=${await getToken()}`);
12
+ * ```
13
+ */
14
+ type UrlSource = string | (() => string | Promise<string>);
15
+ /**
16
+ * Connection state.
17
+ *
18
+ * - `idle`: not connected and not trying to be. Nobody is using the client yet, or everyone stopped.
19
+ * - `connecting`: the first attempt is in progress.
20
+ * - `open`: connected. `send()` goes out immediately.
21
+ * - `reconnecting`: the connection dropped (or an attempt failed) and a retry is scheduled or in progress.
22
+ * - `closed`: stopped for good, by `close()` or after giving up on reconnecting.
23
+ * It stays closed until `connect()` or `reconnect()` is called, or every hook unmounts. If
24
+ * nothing held it when it stopped, the next hook to mount starts it again.
25
+ */
26
+ type Status = 'idle' | 'connecting' | 'open' | 'reconnecting' | 'closed';
27
+ /** The client's state as seen by React. A new object is created on every change. */
28
+ interface Snapshot<In> {
29
+ /** Connection state. */
30
+ readonly status: Status;
31
+ /** Most recent message (after `parse`/`json` and `schema`), kept across reconnects. */
32
+ readonly lastMessage: In | undefined;
33
+ /**
34
+ * Consecutive failed attempts since the last stable connection. A connection that closes
35
+ * within `reconnect.minUptime` of opening counts as failed. `0` while open.
36
+ */
37
+ readonly attempt: number;
38
+ }
39
+ /** Details of a closed connection, from the browser's `CloseEvent`. */
40
+ interface CloseInfo {
41
+ /** Close code: `1000` is a normal close, `1006` an abnormal one (e.g. network loss), `4000`–`4999` are yours. */
42
+ readonly code: number;
43
+ /** Close reason sent by the side that closed the connection. Often empty. */
44
+ readonly reason: string;
45
+ /** Whether the closing handshake completed. */
46
+ readonly wasClean: boolean;
47
+ }
48
+ /** Options for `client.migrate()`. */
49
+ interface MigrateOptions {
50
+ /**
51
+ * Where to connect instead: a URL, or a function called before the connection, like the
52
+ * client's own `url`. Later reconnects go there too, until the client is closed, gives up or
53
+ * is torn down.
54
+ * @default the client's current URL
55
+ */
56
+ url?: UrlSource;
57
+ /**
58
+ * Move at a random moment within this many ms, so that clients asked to move together don't
59
+ * all reconnect at once.
60
+ * @default 0
61
+ */
62
+ within?: number;
63
+ }
64
+ /** Per-message options for `send()`. */
65
+ interface SendOptions {
66
+ /**
67
+ * Drop the message instead of queueing it when the socket isn't open. For data that
68
+ * is stale by the time a reconnect finishes, such as player input or cursor positions.
69
+ * @default false
70
+ */
71
+ volatile?: boolean;
72
+ /**
73
+ * Keep only the newest queued message with this key. Sending again with the same key
74
+ * while disconnected replaces the earlier one, which moves to the back of the queue
75
+ * (or of the `priority` messages, for a priority one).
76
+ * For state where only the latest value matters, such as "my position is now (x, y)".
77
+ */
78
+ key?: string;
79
+ /**
80
+ * Queue this message ahead of every message queued without `priority`, after earlier
81
+ * priority messages. For control messages that must not wait behind a backlog, such as
82
+ * cancel, interrupt or a token refresh. Messages sent from `open` listeners still go first.
83
+ *
84
+ * It only matters while the socket isn't open: once a message is handed to the browser,
85
+ * nothing can overtake it. To keep that buffer short, send bulky streams with `maxBuffered`.
86
+ * @default false
87
+ */
88
+ priority?: boolean;
89
+ /**
90
+ * Drop the message instead of sending it while more than this many bytes are already
91
+ * waiting in the browser's send buffer (`socket.bufferedAmount`). For high-rate streams on
92
+ * a slow link, such as audio frames or per-tick input, where a late message is worse than
93
+ * none. `send()` returns `false`, and `onDrop` isn't called.
94
+ *
95
+ * Only checked while the socket is open: a message queued while disconnected is sent on
96
+ * open regardless. `bufferedAmount` includes what you sent earlier in the same task, so set
97
+ * it well above one burst of messages.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * voice.send(frame, { volatile: true, maxBuffered: 64 * 1024 });
102
+ * ```
103
+ */
104
+ maxBuffered?: number;
105
+ /**
106
+ * Drop the message instead of sending it if it has been queued for longer than this many
107
+ * ms, for messages that go stale during a long outage, such as "typing" or a price quote.
108
+ * Overrides `queue.maxAge`. Checked when the socket opens and whenever another message is
109
+ * queued; `onDrop` is called then.
110
+ */
111
+ maxAge?: number;
112
+ /**
113
+ * Called if the message is dropped from the queue without being sent: replaced by a
114
+ * newer message with the same `key`, evicted by `queue.limit`, or older than `maxAge`. Not
115
+ * called when the queue is cleared because the client closed or gave up, or when `send()`
116
+ * drops the message right away (`volatile` while not open, or `maxBuffered`) and returns
117
+ * `false`.
118
+ */
119
+ onDrop?: () => void;
120
+ }
121
+ /**
122
+ * Reported via the `error` event (and `onError`) when an incoming message can't be
123
+ * decoded by `parse`/`json` or fails `schema` validation. The message is not delivered.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * onError(error) {
128
+ * if (error instanceof MessageError) report(error.data, error.issues);
129
+ * }
130
+ * ```
131
+ */
132
+ declare class MessageError extends Error {
133
+ /** The raw `event.data` that failed. */
134
+ readonly data: unknown;
135
+ /** Schema validation issues, when the message failed `schema`. */
136
+ readonly issues: ReadonlyArray<{
137
+ readonly message: string;
138
+ }> | undefined;
139
+ constructor(message: string, data: unknown, options?: {
140
+ cause?: unknown;
141
+ issues?: ReadonlyArray<{
142
+ readonly message: string;
143
+ }>;
144
+ });
145
+ }
146
+ /** Events emitted by a client. Subscribe with `client.on(type, listener)` or `useWebSocketEvent`. */
147
+ interface EventMap<In> {
148
+ /**
149
+ * The socket opened (initially or after a reconnect). Listeners run before queued
150
+ * messages are sent, so a handshake sent from here goes out first.
151
+ */
152
+ open: (event: Event) => void;
153
+ /** A message arrived and passed `parse` and `schema`. */
154
+ message: (message: In, event: MessageEvent) => void;
155
+ /** A socket closed, whether it will be retried or not. */
156
+ close: (close: CloseInfo) => void;
157
+ /**
158
+ * A socket error `Event`, a {@link MessageError} for an undecodable or invalid message,
159
+ * or the `Error` thrown by the `WebSocket` constructor or a `url` function.
160
+ */
161
+ error: (error: Event | MessageError | Error) => void;
162
+ }
163
+ /**
164
+ * A WebSocket connection that reconnects, queues, decodes and can be shared.
165
+ * Create one with `createWebSocket()`.
166
+ *
167
+ * The connection is reference-counted: it opens when the first hook mounts (or
168
+ * `ready` is read) and closes one tick after the last hook unmounts. Calling
169
+ * `connect()` keeps it open regardless, until `close()`.
170
+ *
171
+ * @typeParam In - Type of incoming messages.
172
+ * @typeParam Out - Type accepted by `send()`.
173
+ */
174
+ interface WebSocketClient<In = unknown, Out = unknown> {
175
+ /** The URL (or URL function) the client was created with. */
176
+ readonly url: UrlSource;
177
+ /**
178
+ * A promise that resolves once the socket has opened. Reading it starts an idle client.
179
+ *
180
+ * It stays resolved through automatic reconnects, so `use(client.ready)` shows a
181
+ * Suspense fallback only for the first connection, never on a network blip; use
182
+ * `status` to show reconnects. It rejects when the client gives up reconnecting, when
183
+ * `close()` is called, and during a server render. After that, `connect()` or
184
+ * `reconnect()` make it a new pending promise.
185
+ *
186
+ * It is safe to pass to React 19's `use()`: the same promise is returned until its state
187
+ * changes, and it carries `status`/`value`/`reason` so `use()` doesn't suspend when it is
188
+ * already settled.
189
+ */
190
+ readonly ready: Promise<void>;
191
+ /** The current underlying `WebSocket`, if any. An escape hatch; prefer the client's methods. */
192
+ readonly socket: WebSocket | null;
193
+ /** Subscribe to snapshot changes. Compatible with `useSyncExternalStore`. Returns an unsubscribe function. */
194
+ subscribe(listener: () => void): () => void;
195
+ /** The current {@link Snapshot}. Returns the same object until something changes. */
196
+ getSnapshot(): Snapshot<In>;
197
+ /**
198
+ * Listen to an event. Returns an unsubscribe function. Listener errors are re-thrown
199
+ * asynchronously, so one failing listener doesn't break the others.
200
+ */
201
+ on<K extends keyof EventMap<In>>(type: K, listener: EventMap<In>[K]): () => void;
202
+ /**
203
+ * Send a message (encoded with `serialize`/`json` if configured). If the socket isn't
204
+ * open, the message is queued and sent on open (see the `queue` option), unless
205
+ * `options.volatile` is set.
206
+ * @returns `true` if it was sent immediately, `false` if it was queued or dropped
207
+ * (`volatile` while not open, or `maxBuffered` while open).
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * game.send({ type: 'input', dx, dy }, { volatile: true }); // never replayed after a reconnect
212
+ * game.send({ type: 'position', x, y }, { key: 'position' }); // only the newest is queued
213
+ * game.send({ type: 'leave' }, { priority: true }); // ahead of everything already queued
214
+ * ```
215
+ */
216
+ send(message: Out, options?: SendOptions): boolean;
217
+ /**
218
+ * Start connecting, and keep the connection open even when no hook is using the
219
+ * client, until `close()` is called. Does nothing if already connecting or open.
220
+ */
221
+ connect(): void;
222
+ /**
223
+ * Close the connection and stop reconnecting. The status becomes `closed` and the
224
+ * send queue is cleared. Mounted hooks stay mounted; call `connect()` or `reconnect()`
225
+ * to start again. Closed while no hook holds it, the next hook to mount starts it again.
226
+ *
227
+ * Like `WebSocket.close()`, it throws for a code or reason the socket rejects (browsers take
228
+ * `1000` or `3000`–`4999`, and a reason up to 123 bytes), and then nothing has changed.
229
+ * @param code - Close code. @default 1000
230
+ */
231
+ close(code?: number, reason?: string): void;
232
+ /**
233
+ * Drop the current socket (if any) and connect again immediately, resetting the
234
+ * backoff. Also restarts a `closed` client.
235
+ */
236
+ reconnect(): void;
237
+ /**
238
+ * Move to a new connection without a gap, for example when the server asks its clients to
239
+ * before a deploy. At a random moment within `options.within` ms, it opens a new connection
240
+ * (to `options.url`, if given) and, once that one is open, closes the current one with code
241
+ * `1000`. Until then the current connection keeps working, so the status stays `open` and
242
+ * `send()` doesn't queue.
243
+ *
244
+ * `open` listeners run for the new connection, as after any reconnect, so handshakes and
245
+ * topic subscriptions are sent again. Requests the old connection hadn't answered fail as on
246
+ * a lost connection. If the new connection fails before opening, the current one stays. If
247
+ * the client isn't open when the moment comes, only the URL changes, for the next attempt.
248
+ * A later call replaces one that hasn't moved yet.
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * // The server sends { type: 'reconnect', within: 30000 } before it shuts down.
253
+ * live.on('message', message => {
254
+ * if (message.type === 'reconnect') live.migrate({ within: message.within, url: message.url });
255
+ * });
256
+ * ```
257
+ */
258
+ migrate(options?: MigrateOptions): void;
259
+ /**
260
+ * Hold the connection open until the returned function is called. This is what the
261
+ * hooks use; call it yourself to integrate with non-React code.
262
+ * @returns A release function (safe to call more than once).
263
+ */
264
+ acquire(): () => void;
265
+ }
266
+ //#endregion
267
+ export { WebSocketClient as t };
268
+ //# sourceMappingURL=types-BEecFqIB.d.cts.map