@ts-pf/message 0.1.2 → 0.2.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/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/backpressure.d.ts +83 -0
- package/dist/backpressure.d.ts.map +1 -0
- package/dist/backpressure.js +117 -0
- package/dist/backpressure.js.map +1 -0
- package/dist/duplex.d.ts +25 -2
- package/dist/duplex.d.ts.map +1 -1
- package/dist/duplex.js +81 -25
- package/dist/duplex.js.map +1 -1
- package/dist/error.d.ts +6 -2
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +6 -2
- package/dist/error.js.map +1 -1
- package/dist/frame.d.ts +3 -2
- package/dist/frame.d.ts.map +1 -1
- package/dist/frame.js +7 -6
- package/dist/frame.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/port.d.ts +7 -0
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +7 -0
- package/dist/port.js.map +1 -1
- package/dist/push-queue.d.ts +28 -0
- package/dist/push-queue.d.ts.map +1 -0
- package/dist/push-queue.js +96 -0
- package/dist/push-queue.js.map +1 -0
- package/dist/session.d.ts +18 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +43 -7
- package/dist/session.js.map +1 -1
- package/dist/stdio.d.ts +7 -0
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +40 -2
- package/dist/stdio.js.map +1 -1
- package/dist/ws.d.ts +19 -1
- package/dist/ws.d.ts.map +1 -1
- package/dist/ws.js +66 -5
- package/dist/ws.js.map +1 -1
- package/package.json +8 -2
- package/skills/ts-pf-message/SKILL.md +17 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ts-pf contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -11,4 +11,45 @@ import { createPortDuplex, createWsDuplex, type WebSocketLike } from '@ts-pf/mes
|
|
|
11
11
|
import { createStdioDuplex } from '@ts-pf/message/stdio'
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
`createPushQueue()` is the primitive a transport adapter uses to turn frames into an `AsyncIterable`: `push(value)` from a frame callback, `end()` to complete, `fail(error)` to reject the next pull. Both closes are one-shot. `@ts-pf/message-server` (streamed input) and `@ts-pf/message-client` (streamed output) use it; so can a custom `Duplex` binding. A custom `Duplex` does not need it directly: `DuplexHandler` (`@ts-pf/message-server`) and `DuplexLink` (`@ts-pf/message-client`) own the queues and multiplexing.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { createPushQueue } from '@ts-pf/message'
|
|
18
|
+
|
|
19
|
+
const items = createPushQueue<number>()
|
|
20
|
+
items.push(1)
|
|
21
|
+
items.push(2)
|
|
22
|
+
items.end() // or items.fail(error)
|
|
23
|
+
for await (const item of items) console.log(item) // 1, 2
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Backpressure
|
|
27
|
+
|
|
28
|
+
Nothing changes on the wire; the pipe reports pressure and the sender slows down. `Duplex.send` may return a promise: the pipe is above its write high-water mark and the sender must not pull the next item of that stream until it resolves (it must settle when the duplex closes; a rejection closes the session). `createStdioDuplex` returns one when `output.write()` is refused and resolves it on `'drain'`; `createWsDuplex(socket, { highWaterMark })` (default 1 MiB) returns one while `socket.bufferedAmount` is over the mark (polled every 10 ms) or while frames queue during `CONNECTING`; `createPortDuplex` never does — a `MessagePort` has no buffer signal, so a port cannot report backpressure. A `Duplex` may also implement `pause()` / `resume()` so a receiver can stop reading while a per-call queue is over its mark (pausing is connection-wide): stdio pauses the `Readable`, ws forwards the socket's own `pause` / `resume` when it has them (npm `ws` does; browsers do not), a port cannot. `createMemoryDuplex({ highWaterMark })` simulates a slow peer for tests; without the option it stays synchronous.
|
|
29
|
+
|
|
30
|
+
`BackpressureOptions` is the one option object `@ts-pf/message-server` (`HandlerOptions.backpressure`) and `@ts-pf/message-client` (`LinkOptions.backpressure`) take; protection is on by default:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import type { BackpressureOptions, StallInfo } from '@ts-pf/message'
|
|
34
|
+
|
|
35
|
+
const backpressure: BackpressureOptions = {
|
|
36
|
+
highWaterMark: 1024 * 1024, // bytes buffered before a sender pauses; also the per-call receive-queue bound (frame text length). Infinity disables
|
|
37
|
+
drainTimeout: 30_000, // ms a paused sender waits before the call is aborted; 0 waits forever
|
|
38
|
+
onStall: (info: StallInfo) => console.warn(info.path.join('.'), info.action, info.waitedMs), // default warns on 'aborted' only; false silences
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`onStall` sees `action: 'paused'` once per call (normal flow control on a busy link, not logged by default) and `action: 'aborted'` when the drain timeout fires (logged by default); a throw from it is swallowed and never changes the call. A bad value is a `TypeError` naming the option from the binding's constructor. The validated form and the per-call drain wait (`resolveBackpressure`, `DrainWaiter`) are exported for the two bindings and marked `@internal`; a custom `Duplex` needs neither. `createPushQueue({ highWaterMark, onPause, onResume })` (`PushQueueOptions`) bounds the queue: `push(value, size)` counts `size` (default 1) against the mark, `onPause` fires once above it, `onResume` once the consumer drains it to half or on `end` / `fail`; nothing is dropped.
|
|
43
|
+
|
|
44
|
+
`localFailure` is still re-exported for compatibility but is deprecated — import it from `@ts-pf/protocol`.
|
|
45
|
+
|
|
14
46
|
Wire spec: [`packages/protocol/PROTOCOL.md`](../protocol/PROTOCOL.md) (Message transports).
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
- `MessageSession`, `Duplex`, `encodeFrame`, `decodeFrame`
|
|
51
|
+
- `createMemoryDuplex`, `createPortDuplex`, `createWsDuplex`, `WebSocketLike`
|
|
52
|
+
- `createPushQueue`, `PushQueue`, `PushQueueOptions`
|
|
53
|
+
- `BackpressureOptions`, `StallInfo` (`resolveBackpressure` / `DrainWaiter` are exported `@internal` for the bindings)
|
|
54
|
+
- `errorFromEnvelope`; `localFailure` (deprecated re-export — use `@ts-pf/protocol`)
|
|
55
|
+
- `createStdioDuplex` from `./stdio` only
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slow-peer protection shared by `@ts-pf/message-server` and
|
|
3
|
+
* `@ts-pf/message-client`: one option object (`BackpressureOptions`), its
|
|
4
|
+
* validated form (`resolveBackpressure`), and the per-call wait a sender
|
|
5
|
+
* performs while a duplex drains (`DrainWaiter`). No frame changes; see
|
|
6
|
+
* `PROTOCOL.md` "Backpressure".
|
|
7
|
+
*/
|
|
8
|
+
/** `onStall` payload: the call whose peer is not draining. */
|
|
9
|
+
export type StallInfo = {
|
|
10
|
+
path: string[];
|
|
11
|
+
id: string;
|
|
12
|
+
/** `0` when `paused`; the time spent waiting when `aborted`. */
|
|
13
|
+
waitedMs: number;
|
|
14
|
+
action: 'paused' | 'aborted';
|
|
15
|
+
};
|
|
16
|
+
export type BackpressureOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* The high-water mark: on the send side, bytes the duplex may buffer
|
|
19
|
+
* (WebSocket `bufferedAmount`, a refused stdio `write()`) before a
|
|
20
|
+
* producer pauses; on the receive side, the per-call queue bound measured
|
|
21
|
+
* in frame text length above which the receiver pauses reading the duplex.
|
|
22
|
+
* Default 1 MiB. `Infinity` disables both.
|
|
23
|
+
*/
|
|
24
|
+
highWaterMark?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Milliseconds a paused sender waits for the peer to drain before the call
|
|
27
|
+
* is aborted. Default 30_000. `0` disables the timeout (pause forever).
|
|
28
|
+
*/
|
|
29
|
+
drainTimeout?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Called on the first pause of a call (`action: 'paused'`) and when its
|
|
32
|
+
* drain timeout fires (`action: 'aborted'`). Default: one `console.warn`
|
|
33
|
+
* line for `aborted` only (a pause is normal flow control on a busy link).
|
|
34
|
+
* Pass your own to replace it, or `false` to silence. A throw from it is
|
|
35
|
+
* swallowed: a logging hook never changes the call's outcome.
|
|
36
|
+
*/
|
|
37
|
+
onStall?: ((info: StallInfo) => void) | false;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* `BackpressureOptions` with defaults applied; `resolveBackpressure` on it is the identity.
|
|
41
|
+
* @internal Shared by `@ts-pf/message-server` / `message-client`; not a consumer API.
|
|
42
|
+
*/
|
|
43
|
+
export type Backpressure = {
|
|
44
|
+
highWaterMark: number;
|
|
45
|
+
drainTimeout: number;
|
|
46
|
+
onStall: ((info: StallInfo) => void) | false;
|
|
47
|
+
};
|
|
48
|
+
/** @internal */
|
|
49
|
+
export type DrainOutcome = 'drained' | 'timeout' | 'cancelled';
|
|
50
|
+
export declare const DEFAULT_HIGH_WATER_MARK: number;
|
|
51
|
+
export declare const DEFAULT_DRAIN_TIMEOUT = 30000;
|
|
52
|
+
/**
|
|
53
|
+
* Apply defaults and validate; a bad value is a `TypeError` naming the option.
|
|
54
|
+
* @internal Shared by `@ts-pf/message-server` / `message-client`; not a consumer API.
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveBackpressure(options?: BackpressureOptions): Backpressure;
|
|
57
|
+
/**
|
|
58
|
+
* The wait a sender performs between two frames of one call while the duplex
|
|
59
|
+
* drains. `wait(drained)` resolves `'drained'` when the duplex's promise
|
|
60
|
+
* settles, `'timeout'` when `drainTimeout` elapses first (after
|
|
61
|
+
* `onStall('aborted')`), or `'cancelled'` after `cancel()`. The first wait of
|
|
62
|
+
* a call fires `onStall('paused')` once. One wait at a time: a second
|
|
63
|
+
* concurrent `wait` is an invariant violation and throws. `onStall` is
|
|
64
|
+
* invoked after the outcome is decided and its throws are swallowed, so a
|
|
65
|
+
* logging hook can neither hang nor change the call.
|
|
66
|
+
* @internal Shared by `@ts-pf/message-server` / `message-client`; not a consumer API.
|
|
67
|
+
*/
|
|
68
|
+
export declare class DrainWaiter {
|
|
69
|
+
private readonly backpressure;
|
|
70
|
+
private readonly call;
|
|
71
|
+
private stalled;
|
|
72
|
+
private pending;
|
|
73
|
+
constructor(backpressure: Backpressure, call: {
|
|
74
|
+
path: string[];
|
|
75
|
+
id: string;
|
|
76
|
+
});
|
|
77
|
+
wait(drained: Promise<void>): Promise<DrainOutcome>;
|
|
78
|
+
/** Settle a pending wait as `'cancelled'` (cancel frame, abort, close). */
|
|
79
|
+
cancel(): void;
|
|
80
|
+
/** A logging hook; a throw from it is swallowed so it cannot alter the call. */
|
|
81
|
+
private notify;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=backpressure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backpressure.d.ts","sourceRoot":"","sources":["../src/backpressure.ts"],"names":[],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vD,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IA0CnD,2EAA2E;IAC3E,MAAM,IAAI,IAAI;IAId,gFAAgF;IAChF,OAAO,CAAC,MAAM;CAef"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slow-peer protection shared by `@ts-pf/message-server` and
|
|
3
|
+
* `@ts-pf/message-client`: one option object (`BackpressureOptions`), its
|
|
4
|
+
* validated form (`resolveBackpressure`), and the per-call wait a sender
|
|
5
|
+
* performs while a duplex drains (`DrainWaiter`). No frame changes; see
|
|
6
|
+
* `PROTOCOL.md` "Backpressure".
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_HIGH_WATER_MARK = 1024 * 1024;
|
|
9
|
+
export const DEFAULT_DRAIN_TIMEOUT = 30_000;
|
|
10
|
+
function warnStall(info) {
|
|
11
|
+
if (info.action !== 'aborted') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
console.warn(`[ts-pf] ${info.path.join('.')} (id ${info.id}): peer did not drain within ${info.waitedMs} ms, call aborted`);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Apply defaults and validate; a bad value is a `TypeError` naming the option.
|
|
18
|
+
* @internal Shared by `@ts-pf/message-server` / `message-client`; not a consumer API.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveBackpressure(options = {}) {
|
|
21
|
+
const highWaterMark = options.highWaterMark ?? DEFAULT_HIGH_WATER_MARK;
|
|
22
|
+
if (typeof highWaterMark !== 'number' ||
|
|
23
|
+
Number.isNaN(highWaterMark) ||
|
|
24
|
+
highWaterMark < 0) {
|
|
25
|
+
throw new TypeError('backpressure.highWaterMark must be a number >= 0 (Infinity disables it)');
|
|
26
|
+
}
|
|
27
|
+
const drainTimeout = options.drainTimeout ?? DEFAULT_DRAIN_TIMEOUT;
|
|
28
|
+
if (!Number.isFinite(drainTimeout) || drainTimeout < 0) {
|
|
29
|
+
throw new TypeError('backpressure.drainTimeout must be a finite number >= 0 (0 disables it)');
|
|
30
|
+
}
|
|
31
|
+
const onStall = options.onStall ?? warnStall;
|
|
32
|
+
if (onStall !== false && typeof onStall !== 'function') {
|
|
33
|
+
throw new TypeError('backpressure.onStall must be a function or false');
|
|
34
|
+
}
|
|
35
|
+
return { highWaterMark, drainTimeout, onStall };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The wait a sender performs between two frames of one call while the duplex
|
|
39
|
+
* drains. `wait(drained)` resolves `'drained'` when the duplex's promise
|
|
40
|
+
* settles, `'timeout'` when `drainTimeout` elapses first (after
|
|
41
|
+
* `onStall('aborted')`), or `'cancelled'` after `cancel()`. The first wait of
|
|
42
|
+
* a call fires `onStall('paused')` once. One wait at a time: a second
|
|
43
|
+
* concurrent `wait` is an invariant violation and throws. `onStall` is
|
|
44
|
+
* invoked after the outcome is decided and its throws are swallowed, so a
|
|
45
|
+
* logging hook can neither hang nor change the call.
|
|
46
|
+
* @internal Shared by `@ts-pf/message-server` / `message-client`; not a consumer API.
|
|
47
|
+
*/
|
|
48
|
+
export class DrainWaiter {
|
|
49
|
+
backpressure;
|
|
50
|
+
call;
|
|
51
|
+
stalled = false;
|
|
52
|
+
pending;
|
|
53
|
+
constructor(backpressure, call) {
|
|
54
|
+
this.backpressure = backpressure;
|
|
55
|
+
this.call = call;
|
|
56
|
+
}
|
|
57
|
+
wait(drained) {
|
|
58
|
+
if (this.pending !== undefined) {
|
|
59
|
+
throw new Error('DrainWaiter: a wait is already pending for this call');
|
|
60
|
+
}
|
|
61
|
+
const started = Date.now();
|
|
62
|
+
const outcome = new Promise((resolve) => {
|
|
63
|
+
let timer;
|
|
64
|
+
const settle = (result) => {
|
|
65
|
+
if (this.pending !== settle) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.pending = undefined;
|
|
69
|
+
if (timer !== undefined) {
|
|
70
|
+
clearTimeout(timer);
|
|
71
|
+
}
|
|
72
|
+
resolve(result);
|
|
73
|
+
if (result === 'timeout') {
|
|
74
|
+
this.notify('aborted', Date.now() - started);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
this.pending = settle;
|
|
78
|
+
if (this.backpressure.drainTimeout > 0) {
|
|
79
|
+
timer = setTimeout(() => {
|
|
80
|
+
settle('timeout');
|
|
81
|
+
}, this.backpressure.drainTimeout);
|
|
82
|
+
}
|
|
83
|
+
drained.then(() => {
|
|
84
|
+
settle('drained');
|
|
85
|
+
}, () => {
|
|
86
|
+
settle('drained');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
if (!this.stalled) {
|
|
90
|
+
this.stalled = true;
|
|
91
|
+
this.notify('paused', 0);
|
|
92
|
+
}
|
|
93
|
+
return outcome;
|
|
94
|
+
}
|
|
95
|
+
/** Settle a pending wait as `'cancelled'` (cancel frame, abort, close). */
|
|
96
|
+
cancel() {
|
|
97
|
+
this.pending?.('cancelled');
|
|
98
|
+
}
|
|
99
|
+
/** A logging hook; a throw from it is swallowed so it cannot alter the call. */
|
|
100
|
+
notify(action, waitedMs) {
|
|
101
|
+
if (this.backpressure.onStall === false) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
this.backpressure.onStall({
|
|
106
|
+
path: this.call.path,
|
|
107
|
+
id: this.call.id,
|
|
108
|
+
waitedMs,
|
|
109
|
+
action,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// onStall is observability only; the call's outcome is already decided
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=backpressure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backpressure.js","sourceRoot":"","sources":["../src/backpressure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgDH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,GAAG,IAAI,CAAA;AAClD,MAAM,CA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AAA;YACnB,CAAC,CACF,CAAA;QACH,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACnB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;QAC1B,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,2EAA2E;IAC3E,MAAM;QACJ,IAAI,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,CAAA;IAC7B,CAAC;IAED,gFAAgF;IACxE,MAAM,CAAC,MAA2B,EAAE,QAAgB;QAC1D,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;YACxC,OAAM;QACR,CAAC;QACD,IAAI,CAAC;YACH,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;gBACxB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;gBACpB,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;gBAChB,QAAQ;gBACR,MAAM;aACP,CAAC,CAAA;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,uEAAuE;QACzE,CAAC;IACH,CAAC;CACF"}
|
package/dist/duplex.d.ts
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
export interface Duplex {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Hand one JSON text frame to the pipe. Return a promise only when the pipe
|
|
4
|
+
* is above its write high-water mark: the sender then pauses its producer
|
|
5
|
+
* until it resolves, so a slow peer slows the producer instead of growing a
|
|
6
|
+
* buffer. The promise must settle when the duplex closes; a rejection
|
|
7
|
+
* closes the session. A sync return means "no backpressure signal".
|
|
8
|
+
*/
|
|
9
|
+
send(text: string): void | Promise<void>;
|
|
3
10
|
onMessage(handler: (text: string) => void): () => void;
|
|
4
11
|
onClose(handler: (reason?: unknown) => void): () => void;
|
|
5
12
|
close(reason?: unknown): void;
|
|
13
|
+
/**
|
|
14
|
+
* Optional. Stop delivering `onMessage` until `resume()`; the receiving side
|
|
15
|
+
* calls them when a per-call queue crosses its high-water mark (pausing is
|
|
16
|
+
* connection-wide). Omit both when the pipe cannot pause.
|
|
17
|
+
*/
|
|
18
|
+
pause?(): void;
|
|
19
|
+
resume?(): void;
|
|
6
20
|
}
|
|
7
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Two in-memory `Duplex` ends. Delivery is deferred one microtask, so `send`
|
|
23
|
+
* never re-enters the current `onMessage`. With `highWaterMark`, a `send`
|
|
24
|
+
* returns a drain promise while the receiving end holds more than that many
|
|
25
|
+
* characters undelivered (because it is paused), which is how tests simulate
|
|
26
|
+
* a slow peer. Without it `send` is always synchronous.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createMemoryDuplex(options?: {
|
|
29
|
+
highWaterMark?: number;
|
|
30
|
+
}): {
|
|
8
31
|
a: Duplex;
|
|
9
32
|
b: Duplex;
|
|
10
33
|
};
|
package/dist/duplex.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplex.d.ts","sourceRoot":"","sources":["../src/duplex.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"duplex.d.ts","sourceRoot":"","sources":["../src/duplex.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;IACtD,OAAO,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;IACxD,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IAC7B;;;;OAIG;IACH,KAAK,CAAC,IAAI,IAAI,CAAA;IACd,MAAM,CAAC,IAAI,IAAI,CAAA;CAChB;AAmDD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG;IAC5E,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CA8FA"}
|
package/dist/duplex.js
CHANGED
|
@@ -21,23 +21,74 @@ function emitClose(handlers, reason) {
|
|
|
21
21
|
}
|
|
22
22
|
return firstError;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
function createInbox() {
|
|
25
|
+
return {
|
|
26
|
+
handlers: new Set(),
|
|
27
|
+
closes: new Set(),
|
|
28
|
+
queue: [],
|
|
29
|
+
bytes: 0,
|
|
30
|
+
paused: false,
|
|
31
|
+
flushScheduled: false,
|
|
32
|
+
drains: [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Two in-memory `Duplex` ends. Delivery is deferred one microtask, so `send`
|
|
37
|
+
* never re-enters the current `onMessage`. With `highWaterMark`, a `send`
|
|
38
|
+
* returns a drain promise while the receiving end holds more than that many
|
|
39
|
+
* characters undelivered (because it is paused), which is how tests simulate
|
|
40
|
+
* a slow peer. Without it `send` is always synchronous.
|
|
41
|
+
*/
|
|
42
|
+
export function createMemoryDuplex(options = {}) {
|
|
43
|
+
const toA = createInbox();
|
|
44
|
+
const toB = createInbox();
|
|
29
45
|
let closed = false;
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
const settleDrains = (inbox) => {
|
|
47
|
+
const waiters = inbox.drains;
|
|
48
|
+
inbox.drains = [];
|
|
49
|
+
for (const resolve of waiters) {
|
|
50
|
+
resolve();
|
|
33
51
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
};
|
|
53
|
+
const flush = (inbox) => {
|
|
54
|
+
inbox.flushScheduled = false;
|
|
55
|
+
// `closed` gates new sends and resumes, not frames queued before close.
|
|
56
|
+
while (!inbox.paused && inbox.queue.length > 0) {
|
|
57
|
+
const text = inbox.queue.shift();
|
|
58
|
+
inbox.bytes -= text.length;
|
|
59
|
+
for (const handler of [...inbox.handlers]) {
|
|
37
60
|
handler(text);
|
|
38
61
|
}
|
|
62
|
+
}
|
|
63
|
+
if (options.highWaterMark === undefined ||
|
|
64
|
+
inbox.bytes <= options.highWaterMark) {
|
|
65
|
+
settleDrains(inbox);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const scheduleFlush = (inbox) => {
|
|
69
|
+
if (inbox.flushScheduled || inbox.paused) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
inbox.flushScheduled = true;
|
|
73
|
+
queueMicrotask(() => {
|
|
74
|
+
flush(inbox);
|
|
39
75
|
});
|
|
40
76
|
};
|
|
77
|
+
const sendTo = (inbox, text) => {
|
|
78
|
+
if (closed) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
inbox.queue.push(text);
|
|
82
|
+
inbox.bytes += text.length;
|
|
83
|
+
scheduleFlush(inbox);
|
|
84
|
+
if (options.highWaterMark !== undefined &&
|
|
85
|
+
inbox.bytes > options.highWaterMark) {
|
|
86
|
+
return new Promise((resolve) => {
|
|
87
|
+
inbox.drains.push(resolve);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
};
|
|
41
92
|
const close = (reason) => {
|
|
42
93
|
if (closed) {
|
|
43
94
|
return;
|
|
@@ -45,26 +96,31 @@ export function createMemoryDuplex() {
|
|
|
45
96
|
closed = true;
|
|
46
97
|
// FIFO with send: already-queued messages deliver before onClose.
|
|
47
98
|
queueMicrotask(() => {
|
|
48
|
-
|
|
49
|
-
|
|
99
|
+
settleDrains(toA);
|
|
100
|
+
settleDrains(toB);
|
|
101
|
+
const aError = emitClose(toA.closes, reason);
|
|
102
|
+
const bError = emitClose(toB.closes, reason);
|
|
50
103
|
const error = aError ?? bError;
|
|
51
104
|
if (error !== undefined) {
|
|
52
105
|
throw error;
|
|
53
106
|
}
|
|
54
107
|
});
|
|
55
108
|
};
|
|
56
|
-
const
|
|
57
|
-
send: (text) => sendTo(
|
|
58
|
-
onMessage: (handler) => subscribe(
|
|
59
|
-
onClose: (handler) => subscribe(
|
|
60
|
-
close,
|
|
61
|
-
};
|
|
62
|
-
const b = {
|
|
63
|
-
send: (text) => sendTo(aMessages, text),
|
|
64
|
-
onMessage: (handler) => subscribe(bMessages, handler),
|
|
65
|
-
onClose: (handler) => subscribe(bCloses, handler),
|
|
109
|
+
const end = (inbox, peer) => ({
|
|
110
|
+
send: (text) => sendTo(peer, text),
|
|
111
|
+
onMessage: (handler) => subscribe(inbox.handlers, handler),
|
|
112
|
+
onClose: (handler) => subscribe(inbox.closes, handler),
|
|
66
113
|
close,
|
|
67
|
-
|
|
68
|
-
|
|
114
|
+
pause: () => {
|
|
115
|
+
inbox.paused = true;
|
|
116
|
+
},
|
|
117
|
+
resume: () => {
|
|
118
|
+
inbox.paused = false;
|
|
119
|
+
if (!closed) {
|
|
120
|
+
scheduleFlush(inbox);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
return { a: end(toA, toB), b: end(toB, toA) };
|
|
69
125
|
}
|
|
70
126
|
//# sourceMappingURL=duplex.js.map
|
package/dist/duplex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplex.js","sourceRoot":"","sources":["../src/duplex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"duplex.js","sourceRoot":"","sources":["../src/duplex.ts"],"names":[],"mappings":"AAwBA,SAAS,SAAS,CAAI,QAAgB,EAAE,OAAU;IAChD,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CA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ACD,MAAM,EAAE,GAAG,EAAE;YACX,KAAK,CAAC,MAAM,GAAG,KAAK,CAAA;YACpB,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,aAAa,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;QACH,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;AAC/C,CAAC"}
|
package/dist/error.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { PFError } from '@ts-pf/protocol';
|
|
2
|
-
|
|
1
|
+
import { PFError, localFailure as protocolLocalFailure } from '@ts-pf/protocol';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Import `localFailure` from `@ts-pf/protocol`. This re-export
|
|
4
|
+
* stays for compatibility; it is the same function.
|
|
5
|
+
*/
|
|
6
|
+
export declare const localFailure: typeof protocolLocalFailure;
|
|
3
7
|
export declare function errorFromEnvelope(error: {
|
|
4
8
|
code: string;
|
|
5
9
|
message: string;
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,YAAY,6BAAuB,CAAA;AAEhD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,GAAG,OAAO,CAMV"}
|
package/dist/error.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { PFError } from '@ts-pf/protocol';
|
|
2
|
-
|
|
1
|
+
import { PFError, localFailure as protocolLocalFailure } from '@ts-pf/protocol';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Import `localFailure` from `@ts-pf/protocol`. This re-export
|
|
4
|
+
* stays for compatibility; it is the same function.
|
|
5
|
+
*/
|
|
6
|
+
export const localFailure = protocolLocalFailure;
|
|
3
7
|
export function errorFromEnvelope(error) {
|
|
4
8
|
return new PFError({
|
|
5
9
|
code: error.code,
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAA;AAEhD,MAAM,UAAU,iBAAiB,CAAC,KAIjC;IACC,OAAO,IAAI,OAAO,CAAC;QACjB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/frame.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PROTOCOL_MAJOR } from '@ts-pf/protocol';
|
|
1
2
|
export type WireError = {
|
|
2
3
|
code: string;
|
|
3
4
|
message: string;
|
|
@@ -5,12 +6,12 @@ export type WireError = {
|
|
|
5
6
|
};
|
|
6
7
|
export type HelloFrame = {
|
|
7
8
|
type: 'hello';
|
|
8
|
-
v:
|
|
9
|
+
v: typeof PROTOCOL_MAJOR;
|
|
9
10
|
meta?: unknown;
|
|
10
11
|
};
|
|
11
12
|
export type HelloOkFrame = {
|
|
12
13
|
type: 'hello-ok';
|
|
13
|
-
v:
|
|
14
|
+
v: typeof PROTOCOL_MAJOR;
|
|
14
15
|
};
|
|
15
16
|
export type HelloErrorFrame = {
|
|
16
17
|
type: 'hello-error';
|
package/dist/frame.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../src/frame.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAEzE,MAAM,MAAM,UAAU,GAAG;
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../src/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAEzE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAA;IACb,CAAC,EAAE,OAAO,cAAc,CAAA;IACxB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AACD,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,CAAC,EAAE,OAAO,cAAc,CAAA;CAAE,CAAA;AACzE,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS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,YAAY,GACZ,eAAe,GACf,SAAS,GACT,WAAW,GACX,WAAW,GACX,SAAS,GACT,SAAS,GACT,WAAW,GACX,WAAW,CAAA;AAEf,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GACjC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAmE/C,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAuDvD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CA2BtD"}
|
package/dist/frame.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PROTOCOL_MAJOR } from '@ts-pf/protocol';
|
|
1
2
|
const KEYS = {
|
|
2
3
|
hello: ['type', 'v', 'meta'],
|
|
3
4
|
'hello-ok': ['type', 'v'],
|
|
@@ -55,13 +56,13 @@ export function encodeFrame(frame) {
|
|
|
55
56
|
const body = { type: frame.type };
|
|
56
57
|
switch (frame.type) {
|
|
57
58
|
case 'hello':
|
|
58
|
-
body.v =
|
|
59
|
+
body.v = PROTOCOL_MAJOR;
|
|
59
60
|
if (frame.meta !== undefined) {
|
|
60
61
|
body.meta = frame.meta;
|
|
61
62
|
}
|
|
62
63
|
break;
|
|
63
64
|
case 'hello-ok':
|
|
64
|
-
body.v =
|
|
65
|
+
body.v = PROTOCOL_MAJOR;
|
|
65
66
|
break;
|
|
66
67
|
case 'hello-error':
|
|
67
68
|
body.error = wireError(frame.error);
|
|
@@ -135,20 +136,20 @@ export function decodeFrame(text) {
|
|
|
135
136
|
function validateKnown(type, obj, fail) {
|
|
136
137
|
switch (type) {
|
|
137
138
|
case 'hello': {
|
|
138
|
-
if (obj.v !==
|
|
139
|
+
if (obj.v !== PROTOCOL_MAJOR) {
|
|
139
140
|
return fail('Invalid v');
|
|
140
141
|
}
|
|
141
|
-
const frame = { type: 'hello', v:
|
|
142
|
+
const frame = { type: 'hello', v: PROTOCOL_MAJOR };
|
|
142
143
|
if ('meta' in obj) {
|
|
143
144
|
frame.meta = obj.meta;
|
|
144
145
|
}
|
|
145
146
|
return { ok: true, frame };
|
|
146
147
|
}
|
|
147
148
|
case 'hello-ok':
|
|
148
|
-
if (obj.v !==
|
|
149
|
+
if (obj.v !== PROTOCOL_MAJOR) {
|
|
149
150
|
return fail('Invalid v');
|
|
150
151
|
}
|
|
151
|
-
return { ok: true, frame: { type: 'hello-ok', v:
|
|
152
|
+
return { ok: true, frame: { type: 'hello-ok', v: PROTOCOL_MAJOR } };
|
|
152
153
|
case 'hello-error': {
|
|
153
154
|
const error = decodeWireError(obj.error);
|
|
154
155
|
if (error === undefined) {
|
package/dist/frame.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../src/frame.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../src/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAwDhD,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC;IACzB,aAAa,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;IAChC,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;IAC/C,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC;IAC/C,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC;IAC9B,IAAI,EAAE,CAAC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