@statewalker/webrun-streams-conformance 0.5.0 → 0.7.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 CHANGED
@@ -41,6 +41,7 @@ peer dependencies. One entry point, `.`.
41
41
  | `measureRunAhead(makePair, direction)` | function | L6's run-ahead measurement, for one direction: resolves `{ bound, ahead, complete, intact }`. |
42
42
  | `RunAheadMeasurement` | type | What `measureRunAhead` resolves. |
43
43
  | `DescribeDuplexAdapterOptions` | type | `{ concurrency?: number; skipHugeBody?: boolean }`. |
44
+ | `describePortWindow(name, make)` | function | The per-port window of native ports (`window` on a native port mux, statewalker/webrun-wire#153): agreement, a stalled consumer holding the sender to the window, credit coming back, a message larger than the window, a close sending what the window held, and both mixed cases against a mux without a window. `make(codec, { opener?, server? })` builds two connected ends with those windows (`PortWindowHarness`). |
44
45
 
45
46
  | Option | Default | Effect |
46
47
  | --- | --- | --- |
@@ -0,0 +1,35 @@
1
+ import type { MessagePipe } from "@statewalker/webrun-streams";
2
+ /**
3
+ * One adapter's pipe over a fake (or real) transport, with handles to drive
4
+ * the transport from the outside.
5
+ */
6
+ export interface MessagePipeHarness {
7
+ /** What the adapter returned: `{ target, signal, maxMessageSize }`. */
8
+ pipe: MessagePipe;
9
+ /** The transport delivers one inbound message, as the adapter's transport would. */
10
+ inject(data: unknown): void | Promise<void>;
11
+ /** What the adapter has put on the transport so far, one entry per message. */
12
+ sent(): Uint8Array[] | Promise<Uint8Array[]>;
13
+ /** The transport ends on its own (the peer went away). */
14
+ endRemotely(): void | Promise<void>;
15
+ /** Makes the transport report `bytes` buffered. Absent: the drain cases are skipped. */
16
+ setBuffered?(bytes: number): void;
17
+ /** Lets the adapter see buffered bytes go down, where it needs an event for it. */
18
+ settle?(): void | Promise<void>;
19
+ /** Releases anything the harness holds. */
20
+ dispose?(): void | Promise<void>;
21
+ }
22
+ export interface DescribeMessagePipeOptions {
23
+ /** Build a pipe with this frame ceiling. Absent: the ceiling cases are skipped. */
24
+ withMaxFrameBytes?: (maxFrameBytes: number) => MessagePipeHarness | Promise<MessagePipeHarness>;
25
+ /** The adapter's drain low-water mark. Default 256 KiB. */
26
+ drainLowWater?: number;
27
+ }
28
+ /**
29
+ * The contract every pipe of byte messages keeps (statewalker/webrun-wire#151),
30
+ * run against an adapter through its harness. The pipe module
31
+ * (`newMessagePipe` in `@statewalker/webrun-streams`) implements it once; each
32
+ * `webrun-streams-*` adapter runs this suite to show it still does.
33
+ */
34
+ export declare function describeMessagePipe(name: string, make: () => MessagePipeHarness | Promise<MessagePipeHarness>, options?: DescribeMessagePipeOptions): void;
35
+ //# sourceMappingURL=describe-message-pipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-message-pipe.d.ts","sourceRoot":"","sources":["../src/describe-message-pipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,IAAI,EAAE,WAAW,CAAC;IAClB,oFAAoF;IACpF,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,+EAA+E;IAC/E,IAAI,IAAI,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC7C,0DAA0D;IAC1D,WAAW,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,wFAAwF;IACxF,WAAW,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,mFAAmF;IACnF,MAAM,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,2CAA2C;IAC3C,OAAO,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,mFAAmF;IACnF,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAChG,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,EAC5D,OAAO,GAAE,0BAA+B,GACvC,IAAI,CAyIN"}
@@ -0,0 +1,19 @@
1
+ import type { NativePort, NativePortMux, ValueCodec } from "@statewalker/webrun-streams";
2
+ /** Two ends of one connection, from an adapter that opens a channel per port. */
3
+ export interface PortMuxHarness {
4
+ /** A mux that opens ports and accepts none. */
5
+ opener: NativePortMux;
6
+ /** A mux on the other end, handing each port the opener opens to `onPort`. */
7
+ serve(onPort: (port: NativePort) => boolean | undefined): Promise<NativePortMux>;
8
+ /** Releases the connection. */
9
+ dispose(): void | Promise<void>;
10
+ }
11
+ /** Builds two connected ends whose muxes use `codec`. */
12
+ export type MakePortMuxHarness = (codec: ValueCodec) => Promise<PortMuxHarness>;
13
+ /**
14
+ * The lifecycle every native port mux keeps (statewalker/webrun-wire#152): the
15
+ * module (`newNativePortMux` in `@statewalker/webrun-streams`) implements it
16
+ * once, and each transport (an in-memory one, WebRTC, libp2p) runs this suite.
17
+ */
18
+ export declare function describePortMux(name: string, make: MakePortMuxHarness): void;
19
+ //# sourceMappingURL=describe-port-mux.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-port-mux.d.ts","sourceRoot":"","sources":["../src/describe-port-mux.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGzF,iFAAiF;AACjF,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,MAAM,EAAE,aAAa,CAAC;IACtB,8EAA8E;IAC9E,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACjF,+BAA+B;IAC/B,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;AAiChF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAkJ5E"}
@@ -0,0 +1,34 @@
1
+ import { type NativePort, type NativePortMux, type ValueCodec } from "@statewalker/webrun-streams";
2
+ /** The windows each end of a {@link PortWindowHarness} grants; unset is none (an older peer). */
3
+ export interface PortWindows {
4
+ opener?: number;
5
+ server?: number;
6
+ }
7
+ /** Two ends of one connection whose muxes may have a window (`window` on the transport's mux). */
8
+ export interface PortWindowHarness {
9
+ /** A mux that opens ports and accepts none, with `windows.opener`. */
10
+ opener: NativePortMux;
11
+ /** A mux on the other end, with `windows.server`, handing each port to `onPort`. */
12
+ serve(onPort: (port: NativePort) => boolean | undefined): Promise<NativePortMux>;
13
+ /** Releases the connection. */
14
+ dispose(): void | Promise<void>;
15
+ }
16
+ export interface DescribePortWindowOptions {
17
+ /**
18
+ * The largest encoded message the transport carries (WebRTC: 16 KiB). The
19
+ * case of a message larger than the window is skipped below 64 KiB.
20
+ */
21
+ maxFrameBytes?: number;
22
+ }
23
+ /** Builds two connected ends whose muxes use `codec` and the given windows. */
24
+ export type MakePortWindowHarness = (codec: ValueCodec, windows: PortWindows) => Promise<PortWindowHarness>;
25
+ /**
26
+ * Per-port flow control on native ports (statewalker/webrun-wire#153): a mux
27
+ * given `window` grants its peer at most that many bytes of a port's messages
28
+ * delivered and not yet consumed, where both ends speak it, and runs as before
29
+ * against one that does not. The module (`newNativePortMux` in
30
+ * `@statewalker/webrun-streams`) implements it once; each transport runs this
31
+ * suite with its own negotiation.
32
+ */
33
+ export declare function describePortWindow(name: string, make: MakePortWindowHarness, options?: DescribePortWindowOptions): void;
34
+ //# sourceMappingURL=describe-port-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-port-window.d.ts","sourceRoot":"","sources":["../src/describe-port-window.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,aAAa,EAElB,KAAK,UAAU,EAChB,MAAM,6BAA6B,CAAC;AAGrC,iGAAiG;AACjG,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,kGAAkG;AAClG,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,MAAM,EAAE,aAAa,CAAC;IACtB,oFAAoF;IACpF,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACjF,+BAA+B;IAC/B,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,+EAA+E;AAC/E,MAAM,MAAM,qBAAqB,GAAG,CAClC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,iBAAiB,CAAC,CAAC;AA6DhC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,EAC3B,OAAO,GAAE,yBAA8B,GACtC,IAAI,CAwLN"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export { type DescribeDuplexAdapterOptions, describeDuplexAdapter, } from "./describe-duplex-adapter.js";
2
+ export { type DescribeMessagePipeOptions, describeMessagePipe, type MessagePipeHarness, } from "./describe-message-pipe.js";
3
+ export { describePortMux, type MakePortMuxHarness, type PortMuxHarness, } from "./describe-port-mux.js";
4
+ export { type DescribePortWindowOptions, describePortWindow, type MakePortWindowHarness, type PortWindowHarness, type PortWindows, } from "./describe-port-window.js";
2
5
  export { type ConnectServePair, type MakePair, makeLoopbackPair, type PairTuning, } from "./loopback.js";
3
6
  export { measureRunAhead, type RunAheadMeasurement } from "./run-ahead.js";
4
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,4BAA4B,EACjC,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,gBAAgB,EAChB,KAAK,UAAU,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,4BAA4B,EACjC,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,0BAA0B,EAC/B,mBAAmB,EACnB,KAAK,kBAAkB,GACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,yBAAyB,EAC9B,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,WAAW,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,gBAAgB,EAChB,KAAK,UAAU,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}