react-websocket 3.6.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.
- package/README.md +34 -5
- package/dist/ag-ui.cjs +421 -0
- package/dist/ag-ui.cjs.map +1 -0
- package/dist/ag-ui.d.cts +493 -0
- package/dist/ag-ui.d.ts +171 -0
- package/dist/ag-ui.js +418 -0
- package/dist/ag-ui.js.map +1 -0
- package/dist/core.cjs +727 -162
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +501 -62
- package/dist/core.d.ts +501 -62
- package/dist/core.js +723 -163
- package/dist/core.js.map +1 -1
- package/dist/devtools.cjs +186 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.cts +32 -0
- package/dist/devtools.d.ts +32 -0
- package/dist/devtools.js +185 -0
- package/dist/devtools.js.map +1 -0
- package/dist/index.cjs +214 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +705 -56
- package/dist/index.d.ts +421 -30
- package/dist/index.js +211 -21
- package/dist/index.js.map +1 -1
- package/dist/outbox.cjs +222 -0
- package/dist/outbox.cjs.map +1 -0
- package/dist/outbox.d.cts +127 -0
- package/dist/outbox.d.ts +127 -0
- package/dist/outbox.js +219 -0
- package/dist/outbox.js.map +1 -0
- package/dist/replay.cjs +324 -0
- package/dist/replay.cjs.map +1 -0
- package/dist/replay.d.cts +124 -0
- package/dist/replay.d.ts +124 -0
- package/dist/replay.js +322 -0
- package/dist/replay.js.map +1 -0
- package/dist/tabs.cjs +336 -0
- package/dist/tabs.cjs.map +1 -0
- package/dist/tabs.d.cts +81 -0
- package/dist/tabs.d.ts +81 -0
- package/dist/tabs.js +335 -0
- package/dist/tabs.js.map +1 -0
- package/dist/timeline.d.cts +1 -213
- package/dist/types-BEecFqIB.d.cts +268 -0
- package/dist/webtransport.cjs +243 -0
- package/dist/webtransport.cjs.map +1 -0
- package/dist/webtransport.d.cts +67 -0
- package/dist/webtransport.d.ts +67 -0
- package/dist/webtransport.js +242 -0
- package/dist/webtransport.js.map +1 -0
- package/package.json +139 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webtransport.js","names":[],"sources":["../src/webtransport.ts"],"sourcesContent":["// An entry with no imports: it only implements the `WebSocket` interface.\n\n/** Options for {@link createWebTransportSocket}. */\nexport interface WebTransportSocketOptions {\n /**\n * The WebTransport URL for the client's WebSocket URL.\n * @default `ws:` and `wss:` become `https:`\n */\n url?: (url: string) => string;\n /** Options for the `WebTransport` constructor, e.g. `serverCertificateHashes` in development. */\n transport?: WebTransportOptions;\n /**\n * The `WebSocket` to connect with where WebTransport isn't available, or when a session can't be\n * established, to the client's own URL. `false` fails the connection instead.\n * @default the global WebSocket\n */\n fallback?: typeof WebSocket | false;\n /**\n * How long to wait for a WebTransport session before falling back, in ms. UDP is blocked on\n * some networks, where the attempt only fails after a long time.\n * @default 5000\n */\n timeout?: number;\n /**\n * Send `volatile` messages as datagrams, which can be lost even while connected. `false` sends\n * every message on the stream.\n * @default true\n */\n datagrams?: boolean;\n}\n\n/** The class from {@link createWebTransportSocket}. */\nexport interface WebTransportWebSocket {\n new (url: string | URL, protocols?: string | string[]): WebSocket;\n readonly prototype: WebSocket;\n readonly CONNECTING: 0;\n readonly OPEN: 1;\n readonly CLOSING: 2;\n readonly CLOSED: 3;\n /** Whether connections go over WebSocket now, because WebTransport is missing or failed. */\n readonly fallingBack: boolean;\n}\n\nconst CONNECTING = 0;\nconst OPEN = 1;\nconst CLOSING = 2;\nconst CLOSED = 3;\nconst TEXT = 0;\nconst BINARY = 1;\n\n/** The method the client calls for `volatile` sends, where a socket has it. */\nconst DATAGRAM = Symbol.for('react-websocket.datagram');\n\ntype Data = Parameters<WebSocket['send']>[0];\n\nfunction closeEvent(code: number, reason: string, wasClean: boolean): Event {\n const init = { code, reason, wasClean };\n // Node 22 has no CloseEvent.\n return typeof CloseEvent === 'function'\n ? new CloseEvent('close', init)\n : Object.assign(new Event('close'), init);\n}\n\nfunction bytes(data: Exclude<Data, Blob>): [number, Uint8Array] {\n if (typeof data === 'string') return [TEXT, new TextEncoder().encode(data)];\n if (data instanceof ArrayBuffer) return [BINARY, new Uint8Array(data)];\n return [BINARY, new Uint8Array(data.buffer, data.byteOffset, data.byteLength)];\n}\n\n/**\n * Connect over [WebTransport](https://developer.mozilla.org/en-US/docs/Web/API/WebTransport_API)\n * behind the same client API. Pass the returned class as the `WebSocket` option: messages go on\n * one reliable, ordered stream, and `volatile` sends go as datagrams, which are never queued or\n * retransmitted, so stale input or cursor positions don't hold up what comes after them.\n *\n * Where WebTransport isn't available, or a session can't be established within `timeout`, it\n * connects with a WebSocket to the client's own URL instead, and keeps doing so for later\n * connections.\n *\n * The server speaks a small framing over WebTransport: see the guide.\n *\n * @example\n * ```ts\n * import { createWebTransportSocket } from 'react-websocket/webtransport';\n *\n * export const game = createWebSocket('wss://game.example.com/play', {\n * json: true,\n * WebSocket: createWebTransportSocket()\n * });\n *\n * game.send({ type: 'aim', angle }, { volatile: true }); // a datagram\n * ```\n */\nexport function createWebTransportSocket(\n options: WebTransportSocketOptions = {}\n): WebTransportWebSocket {\n const mapUrl = options.url ?? ((url: string) => url.replace(/^ws(s?):/, 'https:'));\n const timeout = options.timeout ?? 5000;\n let fallingBack = false;\n\n class WebTransportSocket extends EventTarget implements WebSocket {\n static readonly CONNECTING = CONNECTING;\n static readonly OPEN = OPEN;\n static readonly CLOSING = CLOSING;\n static readonly CLOSED = CLOSED;\n readonly CONNECTING = CONNECTING;\n readonly OPEN = OPEN;\n readonly CLOSING = CLOSING;\n readonly CLOSED = CLOSED;\n\n readonly url: string;\n readonly extensions = '';\n onopen: WebSocket['onopen'] = null;\n onmessage: WebSocket['onmessage'] = null;\n onerror: WebSocket['onerror'] = null;\n onclose: WebSocket['onclose'] = null;\n binaryType: BinaryType = 'blob';\n protocol = '';\n\n #state: WebSocket['readyState'] = CONNECTING;\n #transport: WebTransport | undefined;\n #writer: WritableStreamDefaultWriter<Uint8Array> | undefined;\n #datagrams: WritableStreamDefaultWriter<Uint8Array> | undefined;\n #inner: WebSocket | undefined;\n // Bytes handed to the stream and not yet written, like `bufferedAmount`.\n #buffered = 0;\n // Sends waiting for a Blob to be read, so they keep their order.\n #chain: Promise<void> | undefined;\n\n static get fallingBack() {\n return fallingBack || typeof WebTransport !== 'function';\n }\n\n constructor(url: string | URL, protocols?: string | string[]) {\n super();\n if (typeof window === 'undefined') {\n throw new Error('react-websocket/webtransport: no WebSocket here (server render?)');\n }\n for (const type of ['open', 'message', 'error', 'close'] as const) {\n this.addEventListener(type, event =>\n (this[`on${type}`] as ((event: Event) => void) | null)?.call(this, event)\n );\n }\n this.url = String(url);\n if (fallingBack || typeof WebTransport !== 'function') {\n this.#fallBack(protocols);\n return;\n }\n void this.#connect(protocols);\n }\n\n get readyState() {\n return this.#state;\n }\n\n get bufferedAmount() {\n return this.#inner?.bufferedAmount ?? this.#buffered;\n }\n\n send(data: Data) {\n if (this.#state === CONNECTING) {\n throw new DOMException('WebSocket is still in CONNECTING state', 'InvalidStateError');\n }\n if (this.#state !== OPEN) return;\n if (this.#inner) return this.#inner.send(data);\n if (data instanceof Blob || this.#chain) {\n const chain = (this.#chain ?? Promise.resolve()).then(async () => {\n this.#write(...bytes(data instanceof Blob ? await data.arrayBuffer() : data));\n if (this.#chain === chain) this.#chain = undefined;\n });\n this.#chain = chain;\n return;\n }\n this.#write(...bytes(data));\n }\n\n /** A `volatile` send from the client: a datagram, unless it's too big for one. */\n [DATAGRAM](data: Data) {\n const transport = this.#transport;\n if (\n options.datagrams === false ||\n this.#inner ||\n !transport ||\n data instanceof Blob ||\n this.#state !== OPEN\n ) {\n return this.send(data);\n }\n const [type, payload] = bytes(data);\n if (payload.byteLength + 1 > transport.datagrams.maxDatagramSize) return this.send(data);\n const datagram = new Uint8Array(payload.byteLength + 1);\n datagram[0] = type;\n datagram.set(payload, 1);\n this.#datagrams!.write(datagram).catch(() => {});\n }\n\n close(code = 1000, reason = '') {\n if (this.#state >= CLOSING) return;\n const connecting = this.#state === CONNECTING;\n // First, so that a code the socket rejects throws before anything has changed.\n if (this.#inner) this.#inner.close(code, reason);\n this.#state = CLOSING;\n if (this.#inner) return;\n if (!connecting) return this.#transport!.close({ closeCode: code, reason });\n // Not open yet: give up on the session, and report this close rather than its failure.\n this.#transport?.close();\n setTimeout(() => this.#end(code, reason, true), 0);\n }\n\n async #connect(protocols: string | string[] | undefined) {\n let transport: WebTransport;\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n transport = this.#transport = new WebTransport(mapUrl(this.url), options.transport);\n await Promise.race([\n transport.ready,\n new Promise((_, reject) => (timer = setTimeout(reject, timeout, new Error('timeout'))))\n ]);\n const stream = await transport.createBidirectionalStream();\n if (this.#state !== CONNECTING) return transport.close();\n this.#writer = stream.writable.getWriter();\n this.#datagrams = transport.datagrams.writable.getWriter();\n void this.#read(stream.readable.getReader());\n void this.#readDatagrams(transport.datagrams.readable.getReader());\n } catch {\n // No session: fall back to a WebSocket for this connection and the ones after it.\n this.#transport?.close();\n this.#transport = undefined;\n // Closed while connecting: `close()` reports its own code.\n if (this.#state !== CONNECTING) return;\n if (options.fallback === false) {\n this.dispatchEvent(new Event('error'));\n return this.#end(1006, '', false);\n }\n fallingBack = true;\n return this.#fallBack(protocols);\n } finally {\n clearTimeout(timer);\n }\n transport.closed.then(\n // A session ended without a code reports 0: like a WebSocket closed without a status.\n info => this.#end(info.closeCode || 1005, info.reason ?? '', true),\n () => {\n this.dispatchEvent(new Event('error'));\n this.#end(1006, '', false);\n }\n );\n this.#state = OPEN;\n this.dispatchEvent(new Event('open'));\n }\n\n #fallBack(protocols: string | string[] | undefined) {\n const Impl =\n options.fallback === false ? undefined : (options.fallback ?? globalThis.WebSocket);\n if (!Impl) {\n throw new Error('react-websocket/webtransport: no WebTransport, and no fallback');\n }\n const inner = (this.#inner = new Impl(this.url, protocols));\n inner.binaryType = 'arraybuffer';\n inner.onopen = () => {\n this.protocol = inner.protocol;\n this.#state = OPEN;\n this.dispatchEvent(new Event('open'));\n };\n inner.onmessage = event => this.#message(event.data);\n inner.onerror = () => this.dispatchEvent(new Event('error'));\n inner.onclose = event => this.#end(event.code, event.reason, event.wasClean);\n }\n\n #write(type: number, payload: Uint8Array) {\n const frame = new Uint8Array(payload.byteLength + 5);\n const view = new DataView(frame.buffer);\n view.setUint8(0, type);\n view.setUint32(1, payload.byteLength);\n frame.set(payload, 5);\n this.#buffered += frame.byteLength;\n this.#writer!.write(frame).then(\n () => (this.#buffered -= frame.byteLength),\n () => {}\n );\n }\n\n /** Reassemble frames from the stream, whatever its chunks. */\n async #read(reader: ReadableStreamDefaultReader<Uint8Array>) {\n let buffer = new Uint8Array(0);\n try {\n for (;;) {\n const { value, done } = await reader.read();\n if (done) return;\n const joined = new Uint8Array(buffer.byteLength + value.byteLength);\n joined.set(buffer);\n joined.set(value, buffer.byteLength);\n buffer = joined;\n while (buffer.byteLength >= 5) {\n const view = new DataView(buffer.buffer, buffer.byteOffset);\n const length = view.getUint32(1);\n if (buffer.byteLength < 5 + length) break;\n this.#frame(view.getUint8(0), buffer.slice(5, 5 + length));\n buffer = buffer.slice(5 + length);\n }\n }\n } catch {\n // The session closed; `closed` reports it.\n }\n }\n\n async #readDatagrams(reader: ReadableStreamDefaultReader<Uint8Array>) {\n try {\n for (;;) {\n const { value, done } = await reader.read();\n if (done) return;\n if (value.byteLength) this.#frame(value[0]!, value.slice(1));\n }\n } catch {\n // The session closed; `closed` reports it.\n }\n }\n\n #frame(type: number, payload: Uint8Array) {\n this.#message(type === TEXT ? new TextDecoder().decode(payload) : payload.buffer);\n }\n\n #message(data: unknown) {\n if (this.#state !== OPEN) return;\n if (data instanceof ArrayBuffer && this.binaryType === 'blob') data = new Blob([data]);\n this.dispatchEvent(new MessageEvent('message', { data }));\n }\n\n #end(code: number, reason: string, wasClean: boolean) {\n if (this.#state === CLOSED) return;\n this.#state = CLOSED;\n this.dispatchEvent(closeEvent(code, reason, wasClean));\n }\n }\n\n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AO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-websocket",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.18.0",
|
|
4
4
|
"description": "Hooks-first WebSocket client for React: shared connections, auto-reconnect, typed messages, Suspense-ready",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -37,6 +37,46 @@
|
|
|
37
37
|
"default": "./dist/chaos.cjs"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
+
"./webtransport": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/webtransport.d.ts",
|
|
43
|
+
"default": "./dist/webtransport.js"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/webtransport.d.cts",
|
|
47
|
+
"default": "./dist/webtransport.cjs"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"./devtools": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/devtools.d.ts",
|
|
53
|
+
"default": "./dist/devtools.js"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/devtools.d.cts",
|
|
57
|
+
"default": "./dist/devtools.cjs"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"./replay": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/replay.d.ts",
|
|
63
|
+
"default": "./dist/replay.js"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/replay.d.cts",
|
|
67
|
+
"default": "./dist/replay.cjs"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./tabs": {
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./dist/tabs.d.ts",
|
|
73
|
+
"default": "./dist/tabs.js"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./dist/tabs.d.cts",
|
|
77
|
+
"default": "./dist/tabs.cjs"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
40
80
|
"./timeline": {
|
|
41
81
|
"import": {
|
|
42
82
|
"types": "./dist/timeline.d.ts",
|
|
@@ -47,6 +87,26 @@
|
|
|
47
87
|
"default": "./dist/timeline.cjs"
|
|
48
88
|
}
|
|
49
89
|
},
|
|
90
|
+
"./ag-ui": {
|
|
91
|
+
"import": {
|
|
92
|
+
"types": "./dist/ag-ui.d.ts",
|
|
93
|
+
"default": "./dist/ag-ui.js"
|
|
94
|
+
},
|
|
95
|
+
"require": {
|
|
96
|
+
"types": "./dist/ag-ui.d.cts",
|
|
97
|
+
"default": "./dist/ag-ui.cjs"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"./outbox": {
|
|
101
|
+
"import": {
|
|
102
|
+
"types": "./dist/outbox.d.ts",
|
|
103
|
+
"default": "./dist/outbox.js"
|
|
104
|
+
},
|
|
105
|
+
"require": {
|
|
106
|
+
"types": "./dist/outbox.d.cts",
|
|
107
|
+
"default": "./dist/outbox.cjs"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
50
110
|
"./package.json": "./package.json"
|
|
51
111
|
},
|
|
52
112
|
"files": [
|
|
@@ -116,6 +176,7 @@
|
|
|
116
176
|
"@types/react-dom": "^19.3.0",
|
|
117
177
|
"@vitejs/plugin-react": "^6.1.2",
|
|
118
178
|
"@vitest/coverage-v8": "5.0.3",
|
|
179
|
+
"fake-indexeddb": "^6.2.5",
|
|
119
180
|
"jsdom": "^30.1.2",
|
|
120
181
|
"publint": "^0.3.25",
|
|
121
182
|
"react": "^19.3.0",
|
|
@@ -134,7 +195,7 @@
|
|
|
134
195
|
"ignore": [
|
|
135
196
|
"react"
|
|
136
197
|
],
|
|
137
|
-
"limit": "
|
|
198
|
+
"limit": "4.1 kB",
|
|
138
199
|
"gzip": true
|
|
139
200
|
},
|
|
140
201
|
{
|
|
@@ -144,7 +205,7 @@
|
|
|
144
205
|
"ignore": [
|
|
145
206
|
"react"
|
|
146
207
|
],
|
|
147
|
-
"limit": "
|
|
208
|
+
"limit": "3.4 kB",
|
|
148
209
|
"gzip": true
|
|
149
210
|
},
|
|
150
211
|
{
|
|
@@ -157,6 +218,16 @@
|
|
|
157
218
|
"limit": "1 kB",
|
|
158
219
|
"gzip": true
|
|
159
220
|
},
|
|
221
|
+
{
|
|
222
|
+
"name": "react-websocket (feeds + state hooks)",
|
|
223
|
+
"path": "dist/index.js",
|
|
224
|
+
"import": "{ createWebSocketFeeds, createWebSocketState, useWebSocketTopic, useWebSocketState }",
|
|
225
|
+
"ignore": [
|
|
226
|
+
"react"
|
|
227
|
+
],
|
|
228
|
+
"limit": "1.3 kB",
|
|
229
|
+
"gzip": true
|
|
230
|
+
},
|
|
160
231
|
{
|
|
161
232
|
"name": "react-websocket (requests + latency)",
|
|
162
233
|
"path": "dist/index.js",
|
|
@@ -187,6 +258,26 @@
|
|
|
187
258
|
"limit": "1.2 kB",
|
|
188
259
|
"gzip": true
|
|
189
260
|
},
|
|
261
|
+
{
|
|
262
|
+
"name": "react-websocket (runs + hook)",
|
|
263
|
+
"path": "dist/index.js",
|
|
264
|
+
"import": "{ createWebSocketRuns, useAgentRun }",
|
|
265
|
+
"ignore": [
|
|
266
|
+
"react"
|
|
267
|
+
],
|
|
268
|
+
"limit": "1.9 kB",
|
|
269
|
+
"gzip": true
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"name": "react-websocket (presence + hook)",
|
|
273
|
+
"path": "dist/index.js",
|
|
274
|
+
"import": "{ createWebSocketPresence, useWebSocketPresence }",
|
|
275
|
+
"ignore": [
|
|
276
|
+
"react"
|
|
277
|
+
],
|
|
278
|
+
"limit": "750 B",
|
|
279
|
+
"gzip": true
|
|
280
|
+
},
|
|
190
281
|
{
|
|
191
282
|
"name": "react-websocket (adaptive send rate)",
|
|
192
283
|
"path": "dist/index.js",
|
|
@@ -204,12 +295,57 @@
|
|
|
204
295
|
"limit": "2.1 kB",
|
|
205
296
|
"gzip": true
|
|
206
297
|
},
|
|
298
|
+
{
|
|
299
|
+
"name": "react-websocket/webtransport (createWebTransportSocket)",
|
|
300
|
+
"path": "dist/webtransport.js",
|
|
301
|
+
"import": "{ createWebTransportSocket }",
|
|
302
|
+
"limit": "1.7 kB",
|
|
303
|
+
"gzip": true
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"name": "react-websocket/devtools (WebSocketDevtools)",
|
|
307
|
+
"path": "dist/devtools.js",
|
|
308
|
+
"import": "{ WebSocketDevtools }",
|
|
309
|
+
"ignore": [
|
|
310
|
+
"react"
|
|
311
|
+
],
|
|
312
|
+
"limit": "1.8 kB",
|
|
313
|
+
"gzip": true
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"name": "react-websocket/replay (recording and replay)",
|
|
317
|
+
"path": "dist/replay.js",
|
|
318
|
+
"import": "{ createRecordingWebSocket, createReplayWebSocket }",
|
|
319
|
+
"limit": "1.8 kB",
|
|
320
|
+
"gzip": true
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"name": "react-websocket/tabs (createTabsWebSocket)",
|
|
324
|
+
"path": "dist/tabs.js",
|
|
325
|
+
"import": "{ createTabsWebSocket }",
|
|
326
|
+
"limit": "1.85 kB",
|
|
327
|
+
"gzip": true
|
|
328
|
+
},
|
|
207
329
|
{
|
|
208
330
|
"name": "react-websocket/timeline (createWebSocketTimeline)",
|
|
209
331
|
"path": "dist/timeline.js",
|
|
210
332
|
"import": "{ createWebSocketTimeline }",
|
|
211
333
|
"limit": "1 kB",
|
|
212
334
|
"gzip": true
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "react-websocket/ag-ui (createAgUiAgent)",
|
|
338
|
+
"path": "dist/ag-ui.js",
|
|
339
|
+
"import": "{ createAgUiAgent }",
|
|
340
|
+
"limit": "3.85 kB",
|
|
341
|
+
"gzip": true
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"name": "react-websocket/outbox (createWebSocketOutbox)",
|
|
345
|
+
"path": "dist/outbox.js",
|
|
346
|
+
"import": "{ createWebSocketOutbox }",
|
|
347
|
+
"limit": "1.35 kB",
|
|
348
|
+
"gzip": true
|
|
213
349
|
}
|
|
214
350
|
],
|
|
215
351
|
"overrides": {
|