@zukhruf/rpc 0.8.226 → 0.8.227

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 (34) hide show
  1. package/README.md +9 -10
  2. package/dist/channel/child-process-connection.d.ts +1 -2
  3. package/dist/channel/child-process-connection.d.ts.map +1 -1
  4. package/dist/channel/child-process-connection.js +2 -5
  5. package/dist/channel/child-process-connection.js.map +1 -1
  6. package/dist/channel/parent-port-connection.d.ts +1 -2
  7. package/dist/channel/parent-port-connection.d.ts.map +1 -1
  8. package/dist/channel/parent-port-connection.js +2 -5
  9. package/dist/channel/parent-port-connection.js.map +1 -1
  10. package/dist/channel/process-channel-connection.d.ts +1 -2
  11. package/dist/channel/process-channel-connection.d.ts.map +1 -1
  12. package/dist/channel/process-channel-connection.js +2 -5
  13. package/dist/channel/process-channel-connection.js.map +1 -1
  14. package/dist/channel/shared-channel-connection.d.ts +13 -5
  15. package/dist/channel/shared-channel-connection.d.ts.map +1 -1
  16. package/dist/channel/shared-channel-connection.js +66 -7
  17. package/dist/channel/shared-channel-connection.js.map +1 -1
  18. package/dist/channel/worker-connection.d.ts +1 -2
  19. package/dist/channel/worker-connection.d.ts.map +1 -1
  20. package/dist/channel/worker-connection.js +2 -5
  21. package/dist/channel/worker-connection.js.map +1 -1
  22. package/dist/connection/connection-closed-error.d.ts +1 -1
  23. package/dist/connection/connection-closed-error.d.ts.map +1 -1
  24. package/dist/connection/connection-closed-error.js +1 -1
  25. package/dist/connection/connection-closed-error.js.map +1 -1
  26. package/dist/connection/connection-supervisor.d.ts +7 -1
  27. package/dist/connection/connection-supervisor.d.ts.map +1 -1
  28. package/dist/connection/connection-supervisor.js +33 -2
  29. package/dist/connection/connection-supervisor.js.map +1 -1
  30. package/dist/connection/connection.d.ts +9 -1
  31. package/dist/connection/connection.d.ts.map +1 -1
  32. package/dist/connection/connector.d.ts +8 -3
  33. package/dist/connection/connector.d.ts.map +1 -1
  34. package/package.json +5 -5
package/README.md CHANGED
@@ -63,12 +63,9 @@ import {
63
63
  Server,
64
64
  } from '@zukhruf/rpc';
65
65
 
66
- const connection = new ParentPortConnection<RpcMessage>(parentPort!, {
67
- tag: '@greeter',
68
- });
69
- const link = new ConnectionSupervisor<RpcMessage>({
70
- connect: async () => connection,
71
- });
66
+ const link = new ConnectionSupervisor(
67
+ new ParentPortConnection<RpcMessage>(parentPort!, { tag: '@greeter' }),
68
+ );
72
69
  new Server(
73
70
  { greet: (name: string) => `Hello, ${name}` },
74
71
  {
@@ -106,6 +103,8 @@ Each end can run a `Client` and a `Server` on one link, as StreamJsonRpc's `Json
106
103
 
107
104
  `ConnectionSupervisor` keeps one connection open at a time. It connects on `open`, replaces a connection that is lost, and stops for good when its `Connector` gives `undefined`. It emits `connected`, `message`, `disconnected`, `unavailable` and `failed`.
108
105
 
106
+ A connection is one-shot: it lasts until it is lost or closed, and nothing opens it again. So each `connect` of a `Connector` gives a new one, as grpc-js's subchannel connector gives a new transport. A connector that gives a connection the supervisor had before gets `failed` with a `TypeError`. A link that has only one connection, such as a worker's port to its parent, takes that connection in place of a connector, as StreamJsonRpc's `JsonRpc(stream)` takes its one stream: `new ConnectionSupervisor(connection)` connects to it once, and is `unavailable` after its loss (ADR 0006).
107
+
109
108
  `link.hold()` keeps the process alive through the open connection, and each one that replaces it, until the token it gives is disposed. The supervisor counts the holds of everyone who works on the link, so the release of one does not unref the work of another. A supervisor that nobody holds lets the process exit, as an unref'd socket does (ADR 0004).
110
109
 
111
110
  ## Decide what happens to a call that was in flight
@@ -126,7 +125,7 @@ A call holds the link from its add until it is taken, so the process exits only
126
125
 
127
126
  ## Share a channel with the application
128
127
 
129
- `WorkerConnection`, `ParentPortConnection`, `ChildProcessConnection` and `ProcessChannelConnection` carry each message in the envelope of their `tag`: `{ [tag]: message }`. The application's own messages, and those of another tag, are not read, so they share the channel. The mutex's tag is `'@lock'`.
128
+ `WorkerConnection`, `ParentPortConnection`, `ChildProcessConnection` and `ProcessChannelConnection` carry each message in the envelope of their `tag`: `{ [tag]: message }`. The application's own messages, and those of another tag, are not read, so they share the channel. The mutex's tag is `'@lock'`. An adapter's `close()` is final: its `send` then rejects with `ConnectionClosedError` and sends nothing, and it emits no message, even after `ref()`.
130
129
 
131
130
  | Adapter | End | Tells of a lost peer by | Keeps the process alive |
132
131
  | -------------------------- | -------------------------------- | -------------------------------------- | ----------------------- |
@@ -141,10 +140,10 @@ A call holds the link from its add until it is taken, so the process exits only
141
140
  | ----------------------- | ------------------------------------------------------------------------------------------------------- |
142
141
  | `ConnectionLostError` | A call was in flight on a connection that was lost, the client was disposed, or no peer can come again. |
143
142
  | `ServerError` | The peer threw an error of a class that this end's codec does not list. |
144
- | `ConnectionClosedError` | A send of an adapter cannot reach the peer, because the connection is closed. |
143
+ | `ConnectionClosedError` | A send of an adapter cannot reach the peer, because the peer is gone or this end closed the connection. |
145
144
  | `RemoteSerializationError` | The peer ran the method, and its channel could not carry the answer. The `cause` is the channel's error. |
146
145
  | The channel's own error | A call or a notification has a value that the channel cannot carry. Nothing is sent, and the link goes on. |
147
- | `TypeError` | The server has no such method, the parameters fail its check, or the answer fails the client's check. |
146
+ | `TypeError` | The server has no such method, the parameters fail its check, or the answer fails the client's check. As `failed` of a supervisor: its connector gave a connection that it had before. |
148
147
  | `RangeError` | Two classes of an `ErrorCodec` have one name, or `PendingCalls.add` gets an id that waits already. |
149
148
 
150
149
  ## What the package does not do
@@ -180,7 +179,7 @@ comlink 4.4.2, birpc 4.2.0 and vscode-jsonrpc 10.0.2 were probed on Node 26.13.1
180
179
  export class ConnectionSupervisor<
181
180
  Outgoing,
182
181
  > extends EventEmitter<SupervisorEvents> {
183
- constructor(connector: Connector<Outgoing>);
182
+ constructor(source: Connector<Outgoing> | Connection<Outgoing>);
184
183
  readonly status: SupervisorStatus;
185
184
  open(): void;
186
185
  send(message: Outgoing): boolean;
@@ -14,10 +14,9 @@ export declare class ChildProcessConnection<Outgoing> extends SharedChannelConne
14
14
  * died (EPIPE) or after the channel closed (ERR_IPC_CHANNEL_CLOSED),
15
15
  * reports its error through the callback.
16
16
  */
17
- send(message: Outgoing): Promise<void>;
17
+ protected deliver(envelope: Record<string, unknown>): Promise<void>;
18
18
  /** The running child already keeps the parent alive. */
19
19
  ref(): void;
20
20
  unref(): void;
21
- close(): Promise<void>;
22
21
  }
23
22
  //# sourceMappingURL=child-process-connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"child-process-connection.d.ts","sourceRoot":"","sources":["../../src/channel/child-process-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;GAGG;AACH,qBAAa,sBAAsB,CACjC,QAAQ,CACR,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;;IAGzC,YAAY,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAIvD;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAOrC;IAED,wDAAwD;IACxD,GAAG,SAAK;IAER,KAAK,SAAK;IAEJ,KAAK,kBAEV;CACF"}
1
+ {"version":3,"file":"child-process-connection.d.ts","sourceRoot":"","sources":["../../src/channel/child-process-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;GAGG;AACH,qBAAa,sBAAsB,CACjC,QAAQ,CACR,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;;IAGzC,YAAY,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAIvD;IAED;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAOlE;IAED,wDAAwD;IACxD,GAAG,SAAK;IAER,KAAK,SAAK;CACX"}
@@ -17,9 +17,9 @@ export class ChildProcessConnection extends SharedChannelConnection {
17
17
  * died (EPIPE) or after the channel closed (ERR_IPC_CHANNEL_CLOSED),
18
18
  * reports its error through the callback.
19
19
  */
20
- send(message) {
20
+ deliver(envelope) {
21
21
  const { promise, resolve, reject } = Promise.withResolvers();
22
- this.#child.send(this.envelope.wrap(message), (error) => {
22
+ this.#child.send(envelope, (error) => {
23
23
  if (error)
24
24
  reject(new ConnectionClosedError({ cause: error }));
25
25
  else
@@ -30,8 +30,5 @@ export class ChildProcessConnection extends SharedChannelConnection {
30
30
  /** The running child already keeps the parent alive. */
31
31
  ref() { }
32
32
  unref() { }
33
- async close() {
34
- this.stopListening();
35
- }
36
33
  }
37
34
  //# sourceMappingURL=child-process-connection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"child-process-connection.js","sourceRoot":"","sources":["../../src/channel/child-process-connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;GAGG;AACH,MAAM,OAAO,sBAEX,SAAQ,uBAAiC;IAChC,MAAM,CAAe;IAE9B,YAAY,KAAmB,EAAE,OAAuB;QACtD,KAAK,CAAC,KAAK,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAiB;QACpB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAQ,CAAC;QACnE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;YACtD,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;;gBAC1D,OAAO,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,wDAAwD;IACxD,GAAG,KAAI,CAAC;IAER,KAAK,KAAI,CAAC;IAEV,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;CACF"}
1
+ {"version":3,"file":"child-process-connection.js","sourceRoot":"","sources":["../../src/channel/child-process-connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;GAGG;AACH,MAAM,OAAO,sBAEX,SAAQ,uBAAiC;IAChC,MAAM,CAAe;IAE9B,YAAY,KAAmB,EAAE,OAAuB;QACtD,KAAK,CAAC,KAAK,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACO,OAAO,CAAC,QAAiC;QACjD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAQ,CAAC;QACnE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YACnC,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;;gBAC1D,OAAO,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,wDAAwD;IACxD,GAAG,KAAI,CAAC;IAER,KAAK,KAAI,CAAC;CACX"}
@@ -12,10 +12,9 @@ export declare class ParentPortConnection<Outgoing> extends SharedChannelConnect
12
12
  #private;
13
13
  constructor(port: MessagePort, options: ChannelOptions);
14
14
  /** `postMessage` throws a `DataCloneError` for a value that it cannot clone, and sends nothing. */
15
- send(message: Outgoing): Promise<void>;
15
+ protected deliver(envelope: Record<string, unknown>): Promise<void>;
16
16
  /** Removes the listener before it adds it, so a second `ref` does not listen twice. */
17
17
  ref(): void;
18
18
  unref(): void;
19
- close(): Promise<void>;
20
19
  }
21
20
  //# sourceMappingURL=parent-port-connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parent-port-connection.d.ts","sourceRoot":"","sources":["../../src/channel/parent-port-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,qBAAa,oBAAoB,CAC/B,QAAQ,CACR,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;;IAGzC,YAAY,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAGrD;IAED,mGAAmG;IACnG,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrC;IAED,uFAAuF;IACvF,GAAG,SAGF;IAED,KAAK,SAEJ;IAEK,KAAK,kBAEV;CACF"}
1
+ {"version":3,"file":"parent-port-connection.d.ts","sourceRoot":"","sources":["../../src/channel/parent-port-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,qBAAa,oBAAoB,CAC/B,QAAQ,CACR,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;;IAGzC,YAAY,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAGrD;IAED,mGAAmG;IACnG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlE;IAED,uFAAuF;IACvF,GAAG,SAGF;IAED,KAAK,SAEJ;CACF"}
@@ -13,8 +13,8 @@ export class ParentPortConnection extends SharedChannelConnection {
13
13
  this.#port = port;
14
14
  }
15
15
  /** `postMessage` throws a `DataCloneError` for a value that it cannot clone, and sends nothing. */
16
- send(message) {
17
- this.#port.postMessage(this.envelope.wrap(message));
16
+ deliver(envelope) {
17
+ this.#port.postMessage(envelope);
18
18
  return Promise.resolve();
19
19
  }
20
20
  /** Removes the listener before it adds it, so a second `ref` does not listen twice. */
@@ -25,8 +25,5 @@ export class ParentPortConnection extends SharedChannelConnection {
25
25
  unref() {
26
26
  this.stopListening();
27
27
  }
28
- async close() {
29
- this.unref();
30
- }
31
28
  }
32
29
  //# sourceMappingURL=parent-port-connection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parent-port-connection.js","sourceRoot":"","sources":["../../src/channel/parent-port-connection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,OAAO,oBAEX,SAAQ,uBAAiC;IAChC,KAAK,CAAc;IAE5B,YAAY,IAAiB,EAAE,OAAuB;QACpD,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,mGAAmG;IACnG,IAAI,CAAC,OAAiB;QACpB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACpD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,uFAAuF;IACvF,GAAG;QACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF"}
1
+ {"version":3,"file":"parent-port-connection.js","sourceRoot":"","sources":["../../src/channel/parent-port-connection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,OAAO,oBAEX,SAAQ,uBAAiC;IAChC,KAAK,CAAc;IAE5B,YAAY,IAAiB,EAAE,OAAuB;QACpD,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,mGAAmG;IACzF,OAAO,CAAC,QAAiC;QACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,uFAAuF;IACvF,GAAG;QACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;CACF"}
@@ -17,11 +17,10 @@ export declare class ProcessChannelConnection<Outgoing> extends SharedChannelCon
17
17
  * throws here, and nothing is sent. A write after the channel closed
18
18
  * reports its error through the callback.
19
19
  */
20
- send(message: Outgoing): Promise<void>;
20
+ protected deliver(envelope: Record<string, unknown>): Promise<void>;
21
21
  /** Removes the listeners before it adds them, so a second `ref` does not listen twice. */
22
22
  ref(): void;
23
23
  unref(): void;
24
- close(): Promise<void>;
25
24
  }
26
25
  export {};
27
26
  //# sourceMappingURL=process-channel-connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-channel-connection.d.ts","sourceRoot":"","sources":["../../src/channel/process-channel-connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,iGAAiG;AACjG,KAAK,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,qBAAa,wBAAwB,CACnC,QAAQ,CACR,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;;IAGzC,YAAY,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAGrD;IAED;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAOrC;IAED,0FAA0F;IAC1F,GAAG,SAGF;IAED,KAAK,SAEJ;IAEK,KAAK,kBAEV;CACF"}
1
+ {"version":3,"file":"process-channel-connection.d.ts","sourceRoot":"","sources":["../../src/channel/process-channel-connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,iGAAiG;AACjG,KAAK,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,qBAAa,wBAAwB,CACnC,QAAQ,CACR,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;;IAGzC,YAAY,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAGrD;IAED;;;;OAIG;IACH,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAOlE;IAED,0FAA0F;IAC1F,GAAG,SAGF;IAED,KAAK,SAEJ;CACF"}
@@ -18,9 +18,9 @@ export class ProcessChannelConnection extends SharedChannelConnection {
18
18
  * throws here, and nothing is sent. A write after the channel closed
19
19
  * reports its error through the callback.
20
20
  */
21
- send(message) {
21
+ deliver(envelope) {
22
22
  const { promise, resolve, reject } = Promise.withResolvers();
23
- this.#send(this.envelope.wrap(message), undefined, undefined, (error) => {
23
+ this.#send(envelope, undefined, undefined, (error) => {
24
24
  if (error)
25
25
  reject(new ConnectionClosedError({ cause: error }));
26
26
  else
@@ -36,8 +36,5 @@ export class ProcessChannelConnection extends SharedChannelConnection {
36
36
  unref() {
37
37
  this.stopListening();
38
38
  }
39
- async close() {
40
- this.unref();
41
- }
42
39
  }
43
40
  //# sourceMappingURL=process-channel-connection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-channel-connection.js","sourceRoot":"","sources":["../../src/channel/process-channel-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAKzE;;;;;;GAMG;AACH,MAAM,OAAO,wBAEX,SAAQ,uBAAiC;IAChC,KAAK,CAAc;IAE5B,YAAY,IAAiB,EAAE,OAAuB;QACpD,KAAK,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,OAAiB;QACpB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAQ,CAAC;QACnE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACtE,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;;gBAC1D,OAAO,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,0FAA0F;IAC1F,GAAG;QACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF"}
1
+ {"version":3,"file":"process-channel-connection.js","sourceRoot":"","sources":["../../src/channel/process-channel-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAKzE;;;;;;GAMG;AACH,MAAM,OAAO,wBAEX,SAAQ,uBAAiC;IAChC,KAAK,CAAc;IAE5B,YAAY,IAAiB,EAAE,OAAuB;QACpD,KAAK,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACO,OAAO,CAAC,QAAiC;QACjD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAQ,CAAC;QACnE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACnD,IAAI,KAAK;gBAAE,MAAM,CAAC,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;;gBAC1D,OAAO,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,0FAA0F;IAC1F,GAAG;QACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;CACF"}
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import type { Connection, ConnectionEvents } from '../connection/connection.ts';
3
- import { type ChannelOptions, Envelope } from './envelope.ts';
3
+ import { type ChannelOptions } from './envelope.ts';
4
4
  /** The end of a message channel in Node: a worker, a child process, the process itself, or a worker port. */
5
5
  interface ChannelEnd {
6
6
  on(event: string, listener: (envelope: unknown) => void): unknown;
@@ -16,13 +16,21 @@ interface ChannelEnd {
16
16
  */
17
17
  export declare abstract class SharedChannelConnection<Outgoing> extends EventEmitter<ConnectionEvents> implements Connection<Outgoing> {
18
18
  #private;
19
- protected readonly envelope: Envelope;
20
19
  protected constructor(channel: ChannelEnd, goneEvents: readonly string[], { tag }: ChannelOptions);
21
- /** Throws the channel's refusal before anything is sent; rejects only with `ConnectionClosedError`. */
22
- abstract send(message: Outgoing): Promise<void>;
20
+ /**
21
+ * Rejects with `ConnectionClosedError` once this end closed the
22
+ * connection, and sends nothing. Otherwise the channel throws its refusal
23
+ * here, before anything is sent, and rejects only with
24
+ * `ConnectionClosedError` (rpc ADR 0005).
25
+ */
26
+ send(message: Outgoing): Promise<void>;
23
27
  abstract ref(): void;
24
28
  abstract unref(): void;
25
- abstract close(): Promise<void>;
29
+ /** Final: the connection stops listening, and neither `send` nor `ref` opens it again. */
30
+ close(): Promise<void>;
31
+ /** Writes `envelope` to the channel. */
32
+ protected abstract deliver(envelope: Record<string, unknown>): Promise<void>;
33
+ /** Listens to the channel while the connection is open; does nothing after its loss or its close. */
26
34
  protected listen(): void;
27
35
  protected stopListening(): void;
28
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shared-channel-connection.d.ts","sourceRoot":"","sources":["../../src/channel/shared-channel-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,KAAK,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9D,6GAA6G;AAC7G,UAAU,UAAU;IAClB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC;IAClE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC;IACnD,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC;CACpE;AAED;;;;;;GAMG;AACH,8BAAsB,uBAAuB,CAAC,QAAQ,CACpD,SAAQ,YAAY,CAAC,gBAAgB,CACrC,YAAW,UAAU,CAAC,QAAQ,CAAC;;IAE/B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAetC,SAAS,aACP,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,EAAE,GAAG,EAAE,EAAE,cAAc,EAMxB;IAED,uGAAuG;IACvG,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD,QAAQ,CAAC,GAAG,IAAI,IAAI,CAA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BAGV;IAED,wCAAwC;IACxC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7E,qGAAqG;IACrG,SAAS,CAAC,MAAM,SAEf;IAED,SAAS,CAAC,aAAa,SAKtB;CAQF"}
@@ -1,5 +1,43 @@
1
1
  import { EventEmitter } from 'node:events';
2
+ import { ConnectionClosedError } from '../connection/connection-closed-error.js';
2
3
  import { Envelope } from './envelope.js';
4
+ /** Sends, and listens when the adapter asks: in its constructor or at a `ref`. */
5
+ class Open {
6
+ #deliver;
7
+ #addListeners;
8
+ constructor(deliver, addListeners) {
9
+ this.#deliver = deliver;
10
+ this.#addListeners = addListeners;
11
+ }
12
+ send(envelope) {
13
+ return this.#deliver(envelope);
14
+ }
15
+ listen() {
16
+ this.#addListeners();
17
+ }
18
+ }
19
+ /**
20
+ * The peer is gone. A send still goes to the channel, which rejects it with
21
+ * the channel's own error as the cause (rpc ADR 0005). It never listens again,
22
+ * so a `ref` leaves nothing that keeps the process alive.
23
+ */
24
+ class Lost {
25
+ #deliver;
26
+ constructor(deliver) {
27
+ this.#deliver = deliver;
28
+ }
29
+ send(envelope) {
30
+ return this.#deliver(envelope);
31
+ }
32
+ listen() { }
33
+ }
34
+ /** This end closed the connection: a send rejects and sends nothing, and it never listens again. */
35
+ class Closed {
36
+ send() {
37
+ return Promise.reject(new ConnectionClosedError());
38
+ }
39
+ listen() { }
40
+ }
3
41
  /**
4
42
  * A connection over a message channel that the application uses too: an IPC
5
43
  * channel or a worker port. The messages of the connection travel in the
@@ -8,16 +46,19 @@ import { Envelope } from './envelope.js';
8
46
  * because the listeners can keep the process alive.
9
47
  */
10
48
  export class SharedChannelConnection extends EventEmitter {
11
- envelope;
49
+ #envelope;
12
50
  #channel;
13
51
  /** The events of the channel that tell that the peer is gone. */
14
52
  #goneEvents;
53
+ #deliver = (envelope) => this.deliver(envelope);
54
+ #state = new Open(this.#deliver, () => this.#addListeners());
15
55
  #onMessage = (envelope) => {
16
- const message = this.envelope.unwrap(envelope);
56
+ const message = this.#envelope.unwrap(envelope);
17
57
  if (message !== undefined)
18
58
  this.emit('message', message);
19
59
  };
20
60
  #onGone = () => {
61
+ this.#state = new Lost(this.#deliver);
21
62
  this.stopListening();
22
63
  this.emit('close');
23
64
  };
@@ -25,13 +66,25 @@ export class SharedChannelConnection extends EventEmitter {
25
66
  super();
26
67
  this.#channel = channel;
27
68
  this.#goneEvents = goneEvents;
28
- this.envelope = new Envelope(tag);
69
+ this.#envelope = new Envelope(tag);
29
70
  }
71
+ /**
72
+ * Rejects with `ConnectionClosedError` once this end closed the
73
+ * connection, and sends nothing. Otherwise the channel throws its refusal
74
+ * here, before anything is sent, and rejects only with
75
+ * `ConnectionClosedError` (rpc ADR 0005).
76
+ */
77
+ send(message) {
78
+ return this.#state.send(this.#envelope.wrap(message));
79
+ }
80
+ /** Final: the connection stops listening, and neither `send` nor `ref` opens it again. */
81
+ async close() {
82
+ this.#state = new Closed();
83
+ this.stopListening();
84
+ }
85
+ /** Listens to the channel while the connection is open; does nothing after its loss or its close. */
30
86
  listen() {
31
- this.#channel.on('message', this.#onMessage);
32
- for (const event of this.#goneEvents) {
33
- this.#channel.once(event, this.#onGone);
34
- }
87
+ this.#state.listen();
35
88
  }
36
89
  stopListening() {
37
90
  this.#channel.off('message', this.#onMessage);
@@ -39,5 +92,11 @@ export class SharedChannelConnection extends EventEmitter {
39
92
  this.#channel.off(event, this.#onGone);
40
93
  }
41
94
  }
95
+ #addListeners() {
96
+ this.#channel.on('message', this.#onMessage);
97
+ for (const event of this.#goneEvents) {
98
+ this.#channel.once(event, this.#onGone);
99
+ }
100
+ }
42
101
  }
43
102
  //# sourceMappingURL=shared-channel-connection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-channel-connection.js","sourceRoot":"","sources":["../../src/channel/shared-channel-connection.ts"],"names":[],"mappings":"AAAA,OAAO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AAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"shared-channel-connection.js","sourceRoot":"","sources":["../../src/channel/shared-channel-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAuB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAsB9D,kFAAkF;AAClF,MAAM,IAAI;IACC,QAAQ,CAAU;IAClB,aAAa,CAAa;IAEnC,YAAY,OAAgB,EAAE,YAAwB;QACpD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,QAAiC;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,IAAI;IACC,QAAQ,CAAU;IAE3B,YAAY,OAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,QAAiC;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,KAAI,CAAC;CACZ;AAED,oGAAoG;AACpG,MAAM,MAAM;IACV,IAAI;QACF,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,KAAI,CAAC;CACZ;AAED;;;;;;GAMG;AACH,MAAM,OAAgB,uBACpB,SAAQ,YAA8B;IAG7B,SAAS,CAAW;IACpB,QAAQ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CAAC;IACvB,CAAC;IAKD,qGAAqG;IAC3F,MAAM;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAES,aAAa;QACrB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9C,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,aAAa;QACX,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7C,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF"}
@@ -10,10 +10,9 @@ export declare class WorkerConnection<Outgoing> extends SharedChannelConnection<
10
10
  #private;
11
11
  constructor(worker: Worker, options: ChannelOptions);
12
12
  /** `postMessage` throws a `DataCloneError` for a value that it cannot clone, and sends nothing. */
13
- send(message: Outgoing): Promise<void>;
13
+ protected deliver(envelope: Record<string, unknown>): Promise<void>;
14
14
  /** The running worker already keeps its starting thread alive. */
15
15
  ref(): void;
16
16
  unref(): void;
17
- close(): Promise<void>;
18
17
  }
19
18
  //# sourceMappingURL=worker-connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-connection.d.ts","sourceRoot":"","sources":["../../src/channel/worker-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;GAIG;AACH,qBAAa,gBAAgB,CAC3B,QAAQ,CACR,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;;IAGzC,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAIlD;IAED,mGAAmG;IACnG,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAWrC;IAED,kEAAkE;IAClE,GAAG,SAAK;IAER,KAAK,SAAK;IAEJ,KAAK,kBAEV;CACF"}
1
+ {"version":3,"file":"worker-connection.d.ts","sourceRoot":"","sources":["../../src/channel/worker-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;GAIG;AACH,qBAAa,gBAAgB,CAC3B,QAAQ,CACR,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;;IAGzC,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAIlD;IAED,mGAAmG;IACnG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAWlE;IAED,kEAAkE;IAClE,GAAG,SAAK;IAER,KAAK,SAAK;CACX"}
@@ -13,21 +13,18 @@ export class WorkerConnection extends SharedChannelConnection {
13
13
  this.listen();
14
14
  }
15
15
  /** `postMessage` throws a `DataCloneError` for a value that it cannot clone, and sends nothing. */
16
- send(message) {
16
+ deliver(envelope) {
17
17
  // A stopped worker drops messages without an error; its thread id is -1 from then on.
18
18
  if (this.#worker.threadId === -1) {
19
19
  return Promise.reject(new ConnectionClosedError({
20
20
  cause: new Error('The worker thread has exited.'),
21
21
  }));
22
22
  }
23
- this.#worker.postMessage(this.envelope.wrap(message));
23
+ this.#worker.postMessage(envelope);
24
24
  return Promise.resolve();
25
25
  }
26
26
  /** The running worker already keeps its starting thread alive. */
27
27
  ref() { }
28
28
  unref() { }
29
- async close() {
30
- this.stopListening();
31
- }
32
29
  }
33
30
  //# sourceMappingURL=worker-connection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-connection.js","sourceRoot":"","sources":["../../src/channel/worker-connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;GAIG;AACH,MAAM,OAAO,gBAEX,SAAQ,uBAAiC;IAChC,OAAO,CAAS;IAEzB,YAAY,MAAc,EAAE,OAAuB;QACjD,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,mGAAmG;IACnG,IAAI,CAAC,OAAiB;QACpB,sFAAsF;QACtF,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;YACjC,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,qBAAqB,CAAC;gBACxB,KAAK,EAAE,IAAI,KAAK,CAAC,+BAA+B,CAAC;aAClD,CAAC,CACH,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,kEAAkE;IAClE,GAAG,KAAI,CAAC;IAER,KAAK,KAAI,CAAC;IAEV,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;CACF"}
1
+ {"version":3,"file":"worker-connection.js","sourceRoot":"","sources":["../../src/channel/worker-connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;GAIG;AACH,MAAM,OAAO,gBAEX,SAAQ,uBAAiC;IAChC,OAAO,CAAS;IAEzB,YAAY,MAAc,EAAE,OAAuB;QACjD,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,mGAAmG;IACzF,OAAO,CAAC,QAAiC;QACjD,sFAAsF;QACtF,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;YACjC,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,qBAAqB,CAAC;gBACxB,KAAK,EAAE,IAAI,KAAK,CAAC,+BAA+B,CAAC;aAClD,CAAC,CACH,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,kEAAkE;IAClE,GAAG,KAAI,CAAC;IAER,KAAK,KAAI,CAAC;CACX"}
@@ -1,4 +1,4 @@
1
- /** A send that cannot reach the peer, because the connection is closed. The `cause` is the error of the transport. */
1
+ /** A send that cannot reach the peer, because the connection is closed. The `cause` is the error of the transport; a connection that this end closed has none. */
2
2
  export declare class ConnectionClosedError extends Error {
3
3
  constructor(options?: ErrorOptions);
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"connection-closed-error.d.ts","sourceRoot":"","sources":["../../src/connection/connection-closed-error.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAO,CAAC,EAAE,YAAY,EAGjC;CACF"}
1
+ {"version":3,"file":"connection-closed-error.d.ts","sourceRoot":"","sources":["../../src/connection/connection-closed-error.ts"],"names":[],"mappings":"AAAA,kKAAkK;AAClK,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAO,CAAC,EAAE,YAAY,EAGjC;CACF"}
@@ -1,4 +1,4 @@
1
- /** A send that cannot reach the peer, because the connection is closed. The `cause` is the error of the transport. */
1
+ /** A send that cannot reach the peer, because the connection is closed. The `cause` is the error of the transport; a connection that this end closed has none. */
2
2
  export class ConnectionClosedError extends Error {
3
3
  constructor(options) {
4
4
  super('The connection is closed.', options);
@@ -1 +1 @@
1
- {"version":3,"file":"connection-closed-error.js","sourceRoot":"","sources":["../../src/connection/connection-closed-error.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAsB;QAChC,KAAK,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
1
+ {"version":3,"file":"connection-closed-error.js","sourceRoot":"","sources":["../../src/connection/connection-closed-error.ts"],"names":[],"mappings":"AAAA,kKAAkK;AAClK,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAsB;QAChC,KAAK,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter } from 'node:events';
2
+ import type { Connection } from './connection.ts';
2
3
  import type { Connector } from './connector.ts';
3
4
  export type SupervisorStatus = 'idle' | 'connecting' | 'connected' | 'unavailable' | 'closed';
4
5
  export interface SupervisorEvents {
@@ -17,10 +18,15 @@ export interface SupervisorEvents {
17
18
  * connection that is lost, and stops for good when its connector has no peer
18
19
  * left. It never reads the messages it carries: what a replacement must be
19
20
  * told again is for its listener to decide.
21
+ *
22
+ * It takes a `Connector`, which makes its connections, or one
23
+ * `Connection`, as StreamJsonRpc's `JsonRpc(stream)` takes its one stream:
24
+ * then it connects to that connection once, and is unavailable after its
25
+ * loss (rpc ADR 0006).
20
26
  */
21
27
  export declare class ConnectionSupervisor<Outgoing> extends EventEmitter<SupervisorEvents> {
22
28
  #private;
23
- constructor(connector: Connector<Outgoing>);
29
+ constructor(source: Connector<Outgoing> | Connection<Outgoing>);
24
30
  get status(): SupervisorStatus;
25
31
  /** Starts connecting, unless a connection is open, on its way, or never coming. */
26
32
  open(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"connection-supervisor.d.ts","sourceRoot":"","sources":["../../src/connection/connection-supervisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAC1B,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,8EAA8E;IAC9E,SAAS,EAAE,EAAE,CAAC;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,wGAAwG;IACxG,YAAY,EAAE,EAAE,CAAC;IACjB,6CAA6C;IAC7C,WAAW,EAAE,EAAE,CAAC;IAChB,kEAAkE;IAClE,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;CAC1B;AAED;;;;;GAKG;AACH,qBAAa,oBAAoB,CAC/B,QAAQ,CACR,SAAQ,YAAY,CAAC,gBAAgB,CAAC;;IAGtC,YAAY,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,EAGzC;IAED,IAAI,MAAM,IAAI,gBAAgB,CAE7B;IAED,mFAAmF;IACnF,IAAI,SAEH;IAED;;;;;OAKG;IACH,IAAI,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CACF"}
@@ -5,12 +5,17 @@ import { Latch, RefCount } from '@zukhruf/async';
5
5
  * connection that is lost, and stops for good when its connector has no peer
6
6
  * left. It never reads the messages it carries: what a replacement must be
7
7
  * told again is for its listener to decide.
8
+ *
9
+ * It takes a `Connector`, which makes its connections, or one
10
+ * `Connection`, as StreamJsonRpc's `JsonRpc(stream)` takes its one stream:
11
+ * then it connects to that connection once, and is unavailable after its
12
+ * loss (rpc ADR 0006).
8
13
  */
9
14
  export class ConnectionSupervisor extends EventEmitter {
10
15
  #supervision;
11
- constructor(connector) {
16
+ constructor(source) {
12
17
  super();
13
- this.#supervision = new Supervision(connector, this);
18
+ this.#supervision = new Supervision(connectorOf(source), this);
14
19
  }
15
20
  get status() {
16
21
  return this.#supervision.state.status;
@@ -43,6 +48,17 @@ export class ConnectionSupervisor extends EventEmitter {
43
48
  return this.#supervision.state.close();
44
49
  }
45
50
  }
51
+ /**
52
+ * The connector of `source`: itself, or, for one connection, a connector that
53
+ * gives it once and then no peer. Only a connector has `connect`, as
54
+ * vscode-jsonrpc tells a reader from a stream by what the value has.
55
+ */
56
+ function connectorOf(source) {
57
+ if ('connect' in source)
58
+ return source;
59
+ const connections = [source].values();
60
+ return { connect: async () => connections.next().value };
61
+ }
46
62
  const keepAlive = (connection) => connection.ref();
47
63
  const letExit = (connection) => connection.unref();
48
64
  /** What the states share: the current state, the holds on the link, and how to move to the next state. */
@@ -52,6 +68,8 @@ class Supervision {
52
68
  state;
53
69
  /** Whether a hold is out. Each new connection takes it on, whatever its adapter starts with. */
54
70
  reference = letExit;
71
+ /** Every connection that the connector gave, so it cannot give one again. */
72
+ #had = new WeakSet();
55
73
  /** The one count of the link: its first hold refs the link, and the release of its last unrefs it. */
56
74
  holds = new RefCount({
57
75
  ref: () => this.refer(keepAlive),
@@ -62,6 +80,13 @@ class Supervision {
62
80
  this.events = events;
63
81
  this.state = new Idle(this);
64
82
  }
83
+ /** Whether the connector gave `connection` before; records it if not. */
84
+ hadBefore(connection) {
85
+ if (this.#had.has(connection))
86
+ return true;
87
+ this.#had.add(connection);
88
+ return false;
89
+ }
65
90
  /** A state that stopped being current must not act on what it started. */
66
91
  isCurrent(state) {
67
92
  return this.state === state;
@@ -122,6 +147,12 @@ class Connecting {
122
147
  void connection?.close();
123
148
  return;
124
149
  }
150
+ // A connection is one-shot, as JsonRpc refuses a second StartListening.
151
+ if (connection && supervision.hadBefore(connection)) {
152
+ supervision.become(new Idle(supervision));
153
+ supervision.events.emit('failed', new TypeError('The connector gave a connection that the supervisor had before; a connection is one-shot, so each connect must give a new one (rpc ADR 0006).'));
154
+ return;
155
+ }
125
156
  supervision.become(connection
126
157
  ? new Connected(supervision, connection)
127
158
  : new Unavailable(supervision));
@@ -1 +1 @@
1
- {"version":3,"file":"connection-supervisor.js","sourceRoot":"","sources":["../../src/connection/connection-supervisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAkB,MAAM,gBAAgB,CAAC;AAoBjE;;;;;GAKG;AACH,MAAM,OAAO,oBAEX,SAAQ,YAA8B;IAC7B,YAAY,CAAwB;IAE7C,YAAY,SAA8B;QACxC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC;IACxC,CAAC;IAED,mFAAmF;IACnF,IAAI;QACF,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAiB;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;OAMG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,Y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GAAG,WAAW,CAAC;IAClC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,KAAI,CAAC;IAET,IAAI;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,KAAI,CAAC;IAEd,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAED,MAAM,MAAM;IACD,MAAM,GAAG,QAAQ,CAAC;IAE3B,KAAK,KAAI,CAAC;IAEV,IAAI,KAAI,CAAC;IAET,IAAI;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,KAAI,CAAC;IAEd,KAAK,CAAC,KAAK,KAAI,CAAC;CACjB"}
1
+ {"version":3,"file":"connection-supervisor.js","sourceRoot":"","sources":["../../src/connection/connection-supervisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAkB,MAAM,gBAAgB,CAAC;AAoBjE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,oBAEX,SAAQ,YAA8B;IAC7B,YAAY,CAAwB;IAE7C,YAAY,MAAkD;QAC5D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC;IACxC,CAAC;IAED,mFAAmF;IACnF,IAAI;QACF,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAiB;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK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AAE,CAAC,CAAC;IACzC,CAAC;CACF;AAED,MAAM,MAAM;IACD,MAAM,GAAG,QAAQ,CAAC;IAE3B,KAAK,KAAI,CAAC;IAEV,IAAI,KAAI,CAAC;IAET,IAAI;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,KAAI,CAAC;IAEd,KAAK,CAAC,KAAK,KAAI,CAAC;CACjB"}
@@ -9,6 +9,10 @@ export interface ConnectionEvents {
9
9
  * A message channel to one peer. Adapters wrap IPC channels and sockets.
10
10
  * Subscribe in the task that receives the connection: a message that arrives
11
11
  * while nobody listens is not kept.
12
+ *
13
+ * A connection is one-shot: it lasts from its making to its loss or to its
14
+ * `close()`, and nothing opens it again. A replacement is another connection,
15
+ * which a `Connector` makes (rpc ADR 0006).
12
16
  */
13
17
  export interface Connection<Outgoing> extends EventEmitter<ConnectionEvents> {
14
18
  /**
@@ -24,7 +28,11 @@ export interface Connection<Outgoing> extends EventEmitter<ConnectionEvents> {
24
28
  ref(): void;
25
29
  /** Lets the process exit; messages and closure are still reported while it runs. */
26
30
  unref(): void;
27
- /** Resolves once this end let the connection go. */
31
+ /**
32
+ * Resolves once this end let the connection go, for good: from then on,
33
+ * `send` rejects with `ConnectionClosedError` and sends nothing, no message
34
+ * is emitted, and `ref` does nothing.
35
+ */
28
36
  close(): Promise<void>;
29
37
  }
30
38
  //# sourceMappingURL=connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/connection/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,yFAAyF;IACzF,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,2CAA2C;IAC3C,KAAK,EAAE,EAAE,CAAC;CACX;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,QAAQ,CAAE,SAAQ,YAAY,CAAC,gBAAgB,CAAC;IAC1E;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,mEAAmE;IACnE,GAAG,IAAI,IAAI,CAAC;IACZ,oFAAoF;IACpF,KAAK,IAAI,IAAI,CAAC;IACd,oDAAoD;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/connection/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,yFAAyF;IACzF,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,2CAA2C;IAC3C,KAAK,EAAE,EAAE,CAAC;CACX;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU,CAAC,QAAQ,CAAE,SAAQ,YAAY,CAAC,gBAAgB,CAAC;IAC1E;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,mEAAmE;IACnE,GAAG,IAAI,IAAI,CAAC;IACZ,oFAAoF;IACpF,KAAK,IAAI,IAAI,CAAC;IACd;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
@@ -1,9 +1,14 @@
1
1
  import type { Connection } from './connection.ts';
2
- /** Decides how a client reaches its peer, and whether it can again after losing it. */
2
+ /**
3
+ * Decides how a client reaches its peer, and whether it can again after
4
+ * losing it. A connection is one-shot, so each `connect` gives a new one
5
+ * (rpc ADR 0006).
6
+ */
3
7
  export interface Connector<Outgoing> {
4
8
  /**
5
- * Resolves to `undefined` when the peer is gone for good and nothing can
6
- * replace it. Rejects when this attempt failed and a later one may succeed.
9
+ * Resolves to a new connection: `ConnectionSupervisor` refuses one that it
10
+ * had before. Resolves to `undefined` when the peer is gone for good and
11
+ * nothing can replace it. Rejects when this attempt failed and a later one may succeed.
7
12
  * Once `signal` aborts, rejects with its reason and leaves nothing started.
8
13
  */
9
14
  connect(signal: AbortSignal): Promise<Connection<Outgoing> | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/connection/connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,uFAAuF;AACvF,MAAM,WAAW,SAAS,CAAC,QAAQ;IACjC;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC;CACzE"}
1
+ {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/connection/connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,QAAQ;IACjC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC;CACzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/rpc",
3
- "version": "0.8.226",
3
+ "version": "0.8.227",
4
4
  "description": "Calls between threads and processes over a worker, a port or an IPC channel: a supervised connection, calls that reject at once when the peer goes or go again, and errors that keep their class and fields. After Go's net/rpc and .NET's StreamJsonRpc.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -42,11 +42,11 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@zukhruf/async": "^0.8.226"
45
+ "@zukhruf/async": "^0.8.227"
46
46
  },
47
47
  "devDependencies": {
48
- "@zukhruf/parameterized-test": "^0.8.226",
49
- "@zukhruf/process": "^0.8.226",
50
- "@zukhruf/testing": "^0.8.226"
48
+ "@zukhruf/parameterized-test": "^0.8.227",
49
+ "@zukhruf/process": "^0.8.227",
50
+ "@zukhruf/testing": "^0.8.227"
51
51
  }
52
52
  }