@statewalker/webrun-streams-ws 0.2.3 → 0.3.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 +152 -120
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -134
- package/dist/message-target.d.ts +68 -0
- package/dist/message-target.d.ts.map +1 -0
- package/dist/websocket-like.d.ts +4 -0
- package/dist/websocket-like.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +7 -3
- package/src/message-target.ts +224 -0
- package/src/websocket-like.ts +4 -0
- package/dist/byte-channel.d.ts +0 -12
- package/dist/byte-channel.d.ts.map +0 -1
- package/dist/connect.d.ts +0 -28
- package/dist/connect.d.ts.map +0 -1
- package/dist/serve.d.ts +0 -29
- package/dist/serve.d.ts.map +0 -1
- package/src/byte-channel.ts +0 -122
- package/src/connect.ts +0 -76
- package/src/serve.ts +0 -44
package/README.md
CHANGED
|
@@ -2,91 +2,101 @@
|
|
|
2
2
|
|
|
3
3
|
## What it is
|
|
4
4
|
|
|
5
|
-
A WebSocket
|
|
6
|
-
`
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
A WebSocket as a pipe of bytes for `@statewalker/webrun-rpc`'s port stack.
|
|
6
|
+
`messageTargetOverWebSocket(ws)` turns one open socket into `{ target, signal }`:
|
|
7
|
+
`target` is a `MessageTarget` whose messages are `Uint8Array`s, one WebSocket
|
|
8
|
+
message each, and `signal` aborts when the socket closes. Hand both to
|
|
9
|
+
`webrun-rpc`'s `overPipe` with `msgpackCodec`, and `webrun-rpc`'s `connect` /
|
|
10
|
+
`serve` run many concurrent calls over the socket, one port per call. The
|
|
11
|
+
handler is an ordinary `Duplex` (`(input) => AsyncGenerator<Uint8Array>`) and
|
|
12
|
+
never sees the socket.
|
|
11
13
|
|
|
12
14
|
## Why it exists
|
|
13
15
|
|
|
14
16
|
A raw WebSocket is one message pipe. It has no notion of a request, no
|
|
15
17
|
concurrency, no half-close, and no way to deliver the far end's exception as
|
|
16
|
-
an `Error`.
|
|
17
|
-
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
the
|
|
18
|
+
an `Error`. `webrun-rpc`'s port stack supplies all of that over any pipe of
|
|
19
|
+
messages: `overPipe` invents a port per call on the pipe, and `connect` /
|
|
20
|
+
`serve` run one stream per port, with a producer never more than one chunk
|
|
21
|
+
ahead of its consumer. What it needs from a transport is the pipe, plus a
|
|
22
|
+
way to learn that the pipe died. A WebSocket says so only through its `close`
|
|
23
|
+
event, delivers binary messages in a form that depends on the runtime and on
|
|
24
|
+
`binaryType`, and has no drain event. This package handles those three things
|
|
25
|
+
and nothing else. Because the handler is a plain `Duplex`, the same function
|
|
26
|
+
runs over any other transport that implements the seam.
|
|
21
27
|
|
|
22
28
|
## How to use
|
|
23
29
|
|
|
24
30
|
```sh
|
|
25
|
-
pnpm add @statewalker/webrun-streams-ws
|
|
31
|
+
pnpm add @statewalker/webrun-streams-ws @statewalker/webrun-rpc @statewalker/webrun-msgpack
|
|
26
32
|
```
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
The pipe imports nothing from this repository; `@statewalker/webrun-rpc` and
|
|
35
|
+
`@statewalker/webrun-msgpack` are what you run over it. No peer dependencies.
|
|
36
|
+
One entry point, `.`.
|
|
30
37
|
|
|
31
|
-
- **Browser and worker**: `
|
|
38
|
+
- **Browser and worker**: `openWebSocket` uses the global `WebSocket`.
|
|
32
39
|
- **Node**: pass a constructor as `WebSocketCtor`. The `ws` package works
|
|
33
|
-
(`pnpm add ws`). On the server side
|
|
34
|
-
|
|
35
|
-
`
|
|
40
|
+
(`pnpm add ws`). On the server side there is no server object to hand over:
|
|
41
|
+
call `messageTargetOverWebSocket` on each socket your server accepts, so it
|
|
42
|
+
works with `ws`'s `WebSocketServer`, a runtime's built-in upgrade, or any
|
|
43
|
+
other source of open sockets.
|
|
36
44
|
|
|
37
45
|
| Export | What it gives |
|
|
38
46
|
| --- | --- |
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `WebSocketLike` | Structural socket type accepted everywhere: `readyState`, `send`, `close`, `addEventListener` / `removeEventListener` for `message`, `open`, `close`, `error`. Node's `ws` satisfies it as is; the DOM `WebSocket` satisfies it at runtime but needs a cast at the type level (see Internals). |
|
|
47
|
+
| `messageTargetOverWebSocket(ws)` | One open socket as a `WebSocketMessageTarget`, `{ target, signal }`: `target` is a `MessageTarget` of bytes (one WebSocket message each) with `bufferedAmount` and `whenDrained()`; `signal` aborts when the socket closes. Hand both to `overPipe` with `msgpackCodec`; see below. |
|
|
48
|
+
| `openWebSocket(params)` | Opens a socket and resolves once it is `OPEN`; rejects if it fails or closes first. `params` is `OpenWebSocketParams`. |
|
|
49
|
+
| `DRAIN_LOW_WATER` | `256 * 1024`. `whenDrained()` resolves once `bufferedAmount` is at most this. |
|
|
50
|
+
| `WebSocketLike` | Structural socket type accepted everywhere: `readyState`, optional `bufferedAmount` and `binaryType`, `send`, `close`, `addEventListener` / `removeEventListener` for `message`, `open`, `close`, `error`. Node's `ws` satisfies it as is; the DOM `WebSocket` satisfies it at runtime but needs a cast at the type level (see Internals). |
|
|
43
51
|
| `WS_READY_STATE` | `{ CONNECTING: 0, OPEN: 1, CLOSING: 2, CLOSED: 3 }`. |
|
|
44
|
-
| `
|
|
52
|
+
| `WebSocketMessageTarget`, `OpenWebSocketParams` | Types for the two functions above. |
|
|
45
53
|
|
|
46
|
-
`
|
|
54
|
+
`OpenWebSocketParams`:
|
|
47
55
|
|
|
48
56
|
| Field | Type | Default | Meaning |
|
|
49
57
|
| --- | --- | --- | --- |
|
|
50
58
|
| `url` | `string` | required | `ws://` or `wss://` URL. |
|
|
51
59
|
| `protocols` | `string \| string[]` | none | Subprotocols passed to the constructor. |
|
|
52
60
|
| `WebSocketCtor` | `new (url, protocols?) => WebSocketLike` | `globalThis.WebSocket` | Required where there is no global `WebSocket`. |
|
|
53
|
-
| `mux` | `EmulateMuxOptions` | `emulateMux` defaults | `mtu`, `maxStreams`, `maxStreamBuffer`. `side` is always `"initiator"`. |
|
|
54
61
|
|
|
55
|
-
`
|
|
56
|
-
|
|
57
|
-
| Field | Type | Meaning |
|
|
58
|
-
| --- | --- | --- |
|
|
59
|
-
| `onConnection` | `(cb: (ws: WebSocketLike) => void) => () => void` | Subscribes to inbound open sockets; returns an unsubscribe function. |
|
|
60
|
-
| `mux` | `EmulateMuxOptions` | As above. `side` is always `"responder"`. |
|
|
61
|
-
|
|
62
|
-
Both sides of a connection must run this package's `emulateMux` wire format;
|
|
63
|
-
a plain WebSocket peer cannot talk to it.
|
|
62
|
+
Both ends of a connection must run the port stack (`overPipe` with the same
|
|
63
|
+
codec); a plain WebSocket peer cannot talk to it.
|
|
64
64
|
|
|
65
65
|
## Examples
|
|
66
66
|
|
|
67
67
|
### Serve and call in Node
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
|
-
import {
|
|
70
|
+
import { msgpackCodec } from "@statewalker/webrun-msgpack";
|
|
71
|
+
import { connect, overPipe, serve } from "@statewalker/webrun-rpc";
|
|
72
|
+
import {
|
|
73
|
+
messageTargetOverWebSocket,
|
|
74
|
+
openWebSocket,
|
|
75
|
+
type WebSocketLike,
|
|
76
|
+
} from "@statewalker/webrun-streams-ws";
|
|
71
77
|
import { WebSocket as NodeWebSocket, WebSocketServer } from "ws";
|
|
72
78
|
|
|
73
79
|
const wss = new WebSocketServer({ port: 8080 });
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
// server, per accepted socket
|
|
82
|
+
wss.on("connection", (socket) => {
|
|
83
|
+
const { target, signal } = messageTargetOverWebSocket(socket as unknown as WebSocketLike);
|
|
84
|
+
void serve(
|
|
85
|
+
{ mux: overPipe(target, { codec: msgpackCodec, side: "responder", signal }) },
|
|
86
|
+
async function* echo(input) {
|
|
87
|
+
for await (const chunk of input) yield chunk;
|
|
80
88
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
for await (const chunk of input) yield chunk;
|
|
84
|
-
},
|
|
85
|
-
);
|
|
89
|
+
);
|
|
90
|
+
});
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
// client
|
|
93
|
+
const ws = await openWebSocket({
|
|
88
94
|
url: "ws://127.0.0.1:8080",
|
|
89
|
-
WebSocketCtor: NodeWebSocket,
|
|
95
|
+
WebSocketCtor: NodeWebSocket as unknown as new (url: string) => WebSocketLike,
|
|
96
|
+
});
|
|
97
|
+
const pipe = messageTargetOverWebSocket(ws);
|
|
98
|
+
const { call, close } = await connect({
|
|
99
|
+
mux: overPipe(pipe.target, { codec: msgpackCodec, side: "initiator", signal: pipe.signal }),
|
|
90
100
|
});
|
|
91
101
|
|
|
92
102
|
for await (const chunk of call([new TextEncoder().encode("hello")])) {
|
|
@@ -94,20 +104,34 @@ for await (const chunk of call([new TextEncoder().encode("hello")])) {
|
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
await close();
|
|
97
|
-
await stop();
|
|
98
107
|
wss.close();
|
|
99
108
|
```
|
|
100
109
|
|
|
110
|
+
Pass `signal`: a WebSocket that dies says so only through its `close` event,
|
|
111
|
+
and without it the multiplexer's ports stay open forever. No `maxMessageSize`
|
|
112
|
+
is reported, because WebSocket limits are deployment settings: the `ws` server
|
|
113
|
+
closes with 1009 past its `maxPayload` (100 MiB by default), and browsers and
|
|
114
|
+
proxies have their own. Without one, a chunk crosses as one message; set
|
|
115
|
+
`overPipe`'s `maxMessageSize` (256 bytes under the real limit) or `frameSize`
|
|
116
|
+
if your path has a smaller ceiling.
|
|
117
|
+
|
|
101
118
|
### Browser client, concurrent calls
|
|
102
119
|
|
|
103
120
|
```ts
|
|
121
|
+
import { msgpackCodec } from "@statewalker/webrun-msgpack";
|
|
122
|
+
import { connect, overPipe } from "@statewalker/webrun-rpc";
|
|
104
123
|
import { collectBytes } from "@statewalker/webrun-streams";
|
|
105
|
-
import {
|
|
124
|
+
import { messageTargetOverWebSocket, openWebSocket } from "@statewalker/webrun-streams-ws";
|
|
106
125
|
|
|
107
|
-
const {
|
|
126
|
+
const { target, signal } = messageTargetOverWebSocket(
|
|
127
|
+
await openWebSocket({ url: "wss://example.com/socket" }),
|
|
128
|
+
);
|
|
129
|
+
const { call, close } = await connect({
|
|
130
|
+
mux: overPipe(target, { codec: msgpackCodec, side: "initiator", signal }),
|
|
131
|
+
});
|
|
108
132
|
const enc = new TextEncoder();
|
|
109
133
|
|
|
110
|
-
// Each call is an independent
|
|
134
|
+
// Each call is an independent port on the same socket.
|
|
111
135
|
const [a, b] = await Promise.all([
|
|
112
136
|
collectBytes(call([enc.encode("first")])),
|
|
113
137
|
collectBytes(call([enc.encode("second")])),
|
|
@@ -118,67 +142,71 @@ await close();
|
|
|
118
142
|
### HTTP over the socket
|
|
119
143
|
|
|
120
144
|
`@statewalker/webrun-http-streams` carries `Request` / `Response` over any
|
|
121
|
-
`Duplex
|
|
145
|
+
`Duplex`, so it runs on the `call` from the previous example:
|
|
122
146
|
|
|
123
147
|
```ts
|
|
124
148
|
import { fetchOverDuplex } from "@statewalker/webrun-http-streams";
|
|
125
|
-
import { connect } from "@statewalker/webrun-streams-ws";
|
|
126
149
|
|
|
127
|
-
const { call } = await connect({ url: "wss://example.com/socket" });
|
|
128
150
|
const response = await fetchOverDuplex(call, new Request("http://peer/api/todo"));
|
|
129
151
|
```
|
|
130
152
|
|
|
131
|
-
### Driving `emulateMux` on a socket you own
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
import { emulateMux } from "@statewalker/webrun-streams";
|
|
135
|
-
import { byteChannelFromWebSocket, type WebSocketLike } from "@statewalker/webrun-streams-ws";
|
|
136
|
-
|
|
137
|
-
declare const socket: WebSocket; // already open
|
|
138
|
-
// The cast is needed with current DOM typings; see "WebSocketLike and the DOM type" below.
|
|
139
|
-
const mux = emulateMux(byteChannelFromWebSocket(socket as unknown as WebSocketLike), {
|
|
140
|
-
side: "initiator",
|
|
141
|
-
});
|
|
142
|
-
const response = mux.call([new TextEncoder().encode("ping")]);
|
|
143
|
-
```
|
|
144
|
-
|
|
145
153
|
## Internals
|
|
146
154
|
|
|
147
|
-
### One socket, one
|
|
155
|
+
### One socket, one pipe, many ports
|
|
148
156
|
|
|
149
157
|
```
|
|
150
|
-
client
|
|
151
|
-
call(a) ──┐
|
|
152
|
-
call(b) ──┼─
|
|
153
|
-
call(c) ──┘ (initiator)
|
|
154
|
-
|
|
158
|
+
client server
|
|
159
|
+
call(a) ──┐ ┌──> handler(a)
|
|
160
|
+
call(b) ──┼─ overPipe ══ WebSocket ══ overPipe ─┼──> handler(b)
|
|
161
|
+
call(c) ──┘ (initiator) (responder) └──> handler(c)
|
|
162
|
+
messageTargetOverWebSocket messageTargetOverWebSocket
|
|
155
163
|
```
|
|
156
164
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
### Why
|
|
165
|
-
|
|
166
|
-
`
|
|
167
|
-
dependency on a server library. It can be wired to `ws`, to a
|
|
168
|
-
built-in WebSocket upgrade, or to a custom accept loop.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
-
|
|
181
|
-
|
|
165
|
+
Each socket is one pipe. `overPipe` (`webrun-rpc`'s `multiplexPort` with a
|
|
166
|
+
codec) opens a port per call on it, and `webrun-rpc`'s `connect` / `serve`
|
|
167
|
+
run one stream per port. The two ends must pass opposite `side`s so they
|
|
168
|
+
allocate port ids from different sets. Framing, flow control, port lifetimes
|
|
169
|
+
and error propagation are `webrun-rpc`'s; see its README. This package only
|
|
170
|
+
maps the socket onto a `MessageTarget` and reports its death.
|
|
171
|
+
|
|
172
|
+
### Why there is no server object
|
|
173
|
+
|
|
174
|
+
`messageTargetOverWebSocket` takes one socket, whoever accepted it, so this
|
|
175
|
+
package has no dependency on a server library. It can be wired to `ws`, to a
|
|
176
|
+
runtime's built-in WebSocket upgrade, or to a custom accept loop. Tearing a
|
|
177
|
+
server down is two steps: the teardown `webrun-rpc`'s `serve` resolves to
|
|
178
|
+
closes that connection's multiplexer, failing its calls in flight; stop
|
|
179
|
+
accepting and close the sockets yourself (for example `wss.close()` plus
|
|
180
|
+
`terminate()` on each client with `ws`).
|
|
181
|
+
|
|
182
|
+
### How `messageTargetOverWebSocket` maps the socket
|
|
183
|
+
|
|
184
|
+
- The socket must be `OPEN`. Messages must arrive as bytes at once: a socket
|
|
185
|
+
on `binaryType` "blob" (read asynchronously, so a later message could
|
|
186
|
+
overtake it) or `ws`'s "fragments" is switched to "arraybuffer";
|
|
187
|
+
"arraybuffer" and `ws`'s "nodebuffer" are left alone.
|
|
188
|
+
- Each WebSocket message is one `message` event whose `data` is a
|
|
189
|
+
`Uint8Array`. `Uint8Array` (including Node `Buffer`), `ArrayBuffer` and
|
|
190
|
+
other `ArrayBufferView`s are passed through without copying. A text message
|
|
191
|
+
is delivered as its UTF-8 bytes. A message of any other kind ends the pipe
|
|
192
|
+
with a `TypeError` and closes the socket instead of being dropped, since a
|
|
193
|
+
lost envelope would hang its call. Messages that reach no listener are
|
|
194
|
+
dropped, as on a `MessagePort`; one listener throwing does not stop
|
|
195
|
+
delivery to the others.
|
|
196
|
+
- `postMessage` sends one binary message. It throws `TypeError` for anything
|
|
197
|
+
but bytes, so a codec breaking its contract is not papered over. After the
|
|
198
|
+
socket has closed it is a no-op: `signal` already says so.
|
|
199
|
+
- The socket's `close` event (a failing socket fires `error` and then always
|
|
200
|
+
`close`) aborts `signal` with `webrun-streams-ws: the WebSocket closed (code
|
|
201
|
+
<n>)`. `overPipe` closes the multiplexer on it, which fails every call in
|
|
202
|
+
flight. `target.close()` closes the socket and aborts `signal` with
|
|
203
|
+
`webrun-streams-ws: closed locally`.
|
|
204
|
+
- `bufferedAmount` is the socket's own. A WebSocket has no drain event, so
|
|
205
|
+
`whenDrained()` polls it every 5 ms (with an unref'd timer, so a peer that
|
|
206
|
+
stops reading never keeps Node alive) and resolves once it is at most
|
|
207
|
+
`DRAIN_LOW_WATER`, or the socket has closed. Waiting for zero would make a
|
|
208
|
+
sender that waits before every frame (`overPipe`'s `frameSize`) pause a poll
|
|
209
|
+
interval per frame.
|
|
182
210
|
|
|
183
211
|
### WebSocketLike and the DOM type
|
|
184
212
|
|
|
@@ -187,34 +215,36 @@ both fit without this package depending on either. `ws`'s `WebSocket` type
|
|
|
187
215
|
checks as is. The DOM type does not: `WebSocketLike.send` accepts
|
|
188
216
|
`Uint8Array<ArrayBufferLike>`, which the current DOM `WebSocket.send` typing
|
|
189
217
|
(`BufferSource`) rejects, so passing a DOM socket to
|
|
190
|
-
`
|
|
191
|
-
`as unknown as WebSocketLike`. `
|
|
192
|
-
global `WebSocket` and does the cast itself.
|
|
218
|
+
`messageTargetOverWebSocket` or a DOM constructor as `WebSocketCtor` needs
|
|
219
|
+
`as unknown as WebSocketLike`. `openWebSocket` without `WebSocketCtor` uses
|
|
220
|
+
the global `WebSocket` and does the cast itself.
|
|
193
221
|
|
|
194
222
|
### Failure modes
|
|
195
223
|
|
|
196
224
|
| Situation | Error |
|
|
197
225
|
| --- | --- |
|
|
198
|
-
| No `WebSocketCtor` and no global `WebSocket` | `webrun-streams-ws
|
|
226
|
+
| No `WebSocketCtor` and no global `WebSocket` | `webrun-streams-ws: no WebSocket constructor available. Pass \`WebSocketCtor\` (e.g. the \`ws\` package's WebSocket in Node).` |
|
|
199
227
|
| Socket errors before opening | `WebSocket error before open` |
|
|
200
228
|
| Socket closes before opening | `WebSocket closed before it opened` |
|
|
201
|
-
| `
|
|
202
|
-
|
|
|
203
|
-
|
|
204
|
-
`
|
|
205
|
-
the promise pending.
|
|
206
|
-
|
|
207
|
-
### Teardown is listener-only on the server
|
|
229
|
+
| `messageTargetOverWebSocket` on a socket that is not open | `messageTargetOverWebSocket: WebSocket is in readyState <n>, expected OPEN (1)` |
|
|
230
|
+
| `postMessage` with something other than bytes | `TypeError: webrun-streams-ws: a byte pipe carries Uint8Array, ArrayBuffer or a view, got <type>` |
|
|
231
|
+
| A message arrives as something other than bytes or text | `signal` aborts with `TypeError: webrun-streams-ws: a message arrived as <type>; set binaryType to "arraybuffer" or "nodebuffer"` |
|
|
232
|
+
| Socket closes | `signal` aborts with `webrun-streams-ws: the WebSocket closed (code <n>)`; calls in flight fail through `webrun-rpc`. |
|
|
208
233
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
socket closes. To drop live connections, close the sockets (for example
|
|
212
|
-
`wss.close()` plus `terminate()` on each client with `ws`).
|
|
234
|
+
`openWebSocket` has no timeout of its own; a socket that never opens or fails
|
|
235
|
+
leaves the promise pending.
|
|
213
236
|
|
|
214
237
|
### Tests and measurements
|
|
215
238
|
|
|
216
|
-
`pnpm test` runs the shared conformance suite (L0 to L6) against an
|
|
217
|
-
`ws` server
|
|
239
|
+
`pnpm test` runs the shared conformance suite (L0 to L6) against an
|
|
240
|
+
in-process `ws` server over the port stack (`overPipe` + `msgpackCodec`).
|
|
241
|
+
L6 asserts the port stack's bound in both directions: a consumer that stops
|
|
242
|
+
reading lets the producer get at most one 4 KiB chunk ahead (measured 0). `message-target.test.ts`
|
|
243
|
+
pins the pipe's contract: bytes only (anything else is a `TypeError`), text
|
|
244
|
+
frames as UTF-8 bytes, `signal` aborted by a dead peer, `whenDrained`
|
|
245
|
+
resolving at the low-water mark, sockets on "fragments" or "blob" delivering
|
|
246
|
+
bytes in order, a dead peer failing the calls in flight over the multiplexer,
|
|
247
|
+
and `serve`'s teardown failing a call in flight on each connection.
|
|
218
248
|
`pnpm run test:bench` runs a separate measurement that compares a direct
|
|
219
249
|
WebSocket round trip with one bridged through a `MessageChannel`. It reports
|
|
220
250
|
numbers and does not gate on a threshold, because a timing threshold on
|
|
@@ -222,10 +252,12 @@ shared CI hardware is unreliable, and it is excluded from `pnpm test`.
|
|
|
222
252
|
|
|
223
253
|
### Dependencies
|
|
224
254
|
|
|
225
|
-
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
255
|
+
- None at runtime from this repository: `src/` imports nothing outside the
|
|
256
|
+
package, and `messageTargetOverWebSocket` returns a `MessageTarget` by
|
|
257
|
+
shape.
|
|
258
|
+
- `ws`, `@statewalker/webrun-rpc`, `@statewalker/webrun-msgpack` and
|
|
259
|
+
`@statewalker/webrun-streams-conformance` are dev dependencies used only by
|
|
260
|
+
the tests; consumers supply their own `webrun-rpc` and codec.
|
|
229
261
|
|
|
230
262
|
## License
|
|
231
263
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { type ConnectWsParams, connect } from "./connect.js";
|
|
3
|
-
export { type ServeWsParams, serve } from "./serve.js";
|
|
1
|
+
export { DRAIN_LOW_WATER, messageTargetOverWebSocket, type OpenWebSocketParams, openWebSocket, type WebSocketMessageTarget, } from "./message-target.js";
|
|
4
2
|
export { type WebSocketLike, WS_READY_STATE } from "./websocket-like.js";
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,KAAK,mBAAmB,EACxB,aAAa,EACb,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|