posipaki 0.48.1 → 0.49.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.
Files changed (34) hide show
  1. package/dist/{actor-C8DzeQeT.js → actor-Df5v2zuv.js} +38 -34
  2. package/dist/actor-Df5v2zuv.js.map +1 -0
  3. package/dist/hooks-DO-efRM_.d.ts.map +1 -1
  4. package/dist/{index-B3FcBNz7.d.ts → index-DFqA3rI6.d.ts} +2 -2
  5. package/dist/{index-B3FcBNz7.d.ts.map → index-DFqA3rI6.d.ts.map} +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/port/index.d.ts +2 -2
  9. package/dist/port/index.js +2 -2
  10. package/dist/port/node.d.ts +23 -23
  11. package/dist/port/node.d.ts.map +1 -1
  12. package/dist/port/node.js +94 -61
  13. package/dist/port/node.js.map +1 -1
  14. package/dist/{port-DowG9tgl.js → port-BR7f7BDY.js} +22 -7
  15. package/dist/port-BR7f7BDY.js.map +1 -0
  16. package/dist/process-eCAv2tIS.d.ts.map +1 -1
  17. package/dist/{reactor-CWPBP7qN.d.ts → reactor-4MaIKVnw.d.ts} +21 -10
  18. package/dist/reactor-4MaIKVnw.d.ts.map +1 -0
  19. package/dist/remote/gateway-cli.js.map +1 -1
  20. package/dist/remote/index.d.ts +2 -2
  21. package/dist/remote/index.js +1 -1
  22. package/dist/remote/node.d.ts +1 -1
  23. package/dist/remote/node.js +3 -3
  24. package/dist/{version-CjO8pCPA.js → version-DyYl4K-F.js} +2 -2
  25. package/dist/{version-CjO8pCPA.js.map → version-DyYl4K-F.js.map} +1 -1
  26. package/dist/{websocket-Ddmd6p1n.js → websocket-Ce4oq-7O.js} +14 -7
  27. package/dist/websocket-Ce4oq-7O.js.map +1 -0
  28. package/dist/{websocket-AU2aygxx.d.ts → websocket-DNSNv77Y.d.ts} +2 -2
  29. package/dist/{websocket-AU2aygxx.d.ts.map → websocket-DNSNv77Y.d.ts.map} +1 -1
  30. package/package.json +1 -1
  31. package/dist/actor-C8DzeQeT.js.map +0 -1
  32. package/dist/port-DowG9tgl.js.map +0 -1
  33. package/dist/reactor-CWPBP7qN.d.ts.map +0 -1
  34. package/dist/websocket-Ddmd6p1n.js.map +0 -1
@@ -132,7 +132,9 @@ function splitChannel(inner, announced = NOTHING) {
132
132
  close: async (why = "closed here") => {
133
133
  shut();
134
134
  await inner.close(why);
135
- }
135
+ },
136
+ info: inner.info,
137
+ control: (command) => inner.control(command)
136
138
  };
137
139
  }
138
140
  //#endregion
@@ -192,7 +194,9 @@ function held(inner) {
192
194
  failers.delete(handler);
193
195
  };
194
196
  },
195
- close: (reason) => inner.close(reason)
197
+ close: (reason) => inner.close(reason),
198
+ info: inner.info,
199
+ control: (command) => inner.control(command)
196
200
  };
197
201
  }
198
202
  //#endregion
@@ -200,54 +204,54 @@ function held(inner) {
200
204
  /**
201
205
  * An actor over one channel.
202
206
  *
203
- * In `SEND {data}` writes to it and `SIGNAL {signal}` asks the medium to act on what is behind it; posipaki's
204
- * `STOP` ends the actor, which closes the channel. Out `DATA {data}` for every frame. The channel's ending is
205
- * left in `state.end` and the actor stops.
207
+ * In `SEND {data}` writes to it and `SIGNAL {signal}` asks the medium to act on what is behind it, through
208
+ * the channel's own `control`; posipaki's `STOP` ends the actor, which closes the channel. Out `DATA {data}`
209
+ * for every frame. The channel's ending is left in `state.end`, what the medium knows about itself in
210
+ * `state.info`, and then the actor stops.
206
211
  */
207
212
  function portActor(spec) {
208
213
  return defineActor({
209
214
  name: spec.name,
210
215
  inMessages: /* @__PURE__ */ defineMessages(),
211
216
  outMessages: /* @__PURE__ */ defineMessages(),
212
- setup: (args) => ({
213
- public: {
214
- alive: false,
215
- end: null
216
- },
217
- private: {
218
- channel: null,
219
- args
220
- }
221
- }),
217
+ setup: async (args) => {
218
+ const channel = await spec.open(args);
219
+ return {
220
+ public: {
221
+ alive: true,
222
+ end: null,
223
+ info: channel.info
224
+ },
225
+ private: {
226
+ channel,
227
+ args
228
+ }
229
+ };
230
+ },
222
231
  afterStart() {
223
- const { args } = this.state.private;
224
- spec.open(args).then((channel) => {
225
- this.state.private.channel = channel;
226
- this.state.public.alive = true;
227
- channel.onFrame((data) => {
228
- this.emit({
229
- type: "DATA",
230
- data
231
- });
232
- });
233
- channel.onClose((reason) => {
234
- this.state.public.alive = false;
235
- this.state.public.end = reason;
236
- this.exit();
232
+ const { channel } = this.state.private;
233
+ channel.onFrame((data) => {
234
+ this.emit({
235
+ type: "DATA",
236
+ data
237
237
  });
238
238
  });
239
+ channel.onClose((reason) => {
240
+ this.state.public.alive = false;
241
+ this.state.public.end = reason;
242
+ this.exit();
243
+ });
239
244
  },
240
245
  async beforeEnd() {
241
246
  this.state.public.alive = false;
242
- await this.state.private.channel?.close();
247
+ await this.state.private.channel.close();
243
248
  },
244
249
  handlers: {
245
250
  async SEND(msg) {
246
- await this.state.private.channel?.send(msg.data);
251
+ await this.state.private.channel.send(msg.data);
247
252
  },
248
253
  SIGNAL(msg) {
249
- const channel = this.state.private.channel;
250
- if (channel !== null) spec.signal?.(channel, msg.signal);
254
+ this.state.private.channel.control({ signal: msg.signal });
251
255
  }
252
256
  }
253
257
  });
@@ -255,4 +259,4 @@ function portActor(spec) {
255
259
  //#endregion
256
260
  export { held as n, splitChannel as r, portActor as t };
257
261
 
258
- //# sourceMappingURL=actor-C8DzeQeT.js.map
262
+ //# sourceMappingURL=actor-Df5v2zuv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor-Df5v2zuv.js","names":[],"sources":["../src/port/split.ts","../src/port/held.ts","../src/port/actor.ts"],"sourcesContent":["// ── bytes into parts: the splitter ──────────────────────────────────────────\n//\n// Cuts a stream of bytes on 0x0a; what lies between two cuts is a line. Every byte medium does this: a stdio pair,\n// a socket, an HTTP body.\n\n// Splitting on the byte is safe for UTF-8: a continuation byte is never 0x0a, so a character cannot be cut in\n// half. A character that straddles two chunks waits in the buffer until the rest arrives.\n//\n// Text is decoded by a StringDecoder for the same reason: half a character waits rather than becoming two\n// replacement marks.\n//\n// A line may announce octets after it. The splitter does not know that rule, so it is passed in: given a line,\n// how many raw octets follow it? The seam answers with `$chunk`; a medium with no such thing answers none.\n\nimport { StringDecoder } from \"node:string_decoder\";\n\nimport type { Channel, Part } from \"./channel.js\";\n\nconst NL = 0x0a;\nconst CR = 0x0d;\n\n/** Given a line, how many raw octets follow it. Default: none, this is a plain line. */\nexport type Announcement = (line: string) => number | null;\n\nconst NOTHING: Announcement = () => null;\n\n/**\n * One byte channel in, one channel of parts out.\n *\n * The returned channel's `send` is the same rule backwards: a part becomes its line, a terminator, and the\n * octets it carried.\n */\nexport function splitChannel<C = string>(\n inner: Channel<Uint8Array, C>,\n announced: Announcement = NOTHING,\n): Channel<Part, C> {\n const readers = new Set<(part: Part) => void>();\n const closers = new Set<(reason: C) => void>();\n const failers = new Set<(error: unknown) => void>();\n const decoder = new StringDecoder(\"utf8\");\n /** Bytes that are not yet a frame: a line, or the octets a line announced. */\n let buffered = Buffer.alloc(0);\n /** The line whose announced octets are still arriving. */\n let pending: { line: string; bytes: number } | null = null;\n let ended = false;\n let reason: C | null = null;\n\n const emit = (part: Part): void => {\n for (const reader of [...readers]) reader(part);\n };\n\n /** The far end is gone: our own readers hear it. */\n const close = (why: C): void => {\n if (ended) return;\n ended = true;\n reason = why;\n for (const closer of [...closers]) closer(why);\n };\n\n /**\n * End it here: the far end hears a close, our own readers do not, because we are the one who asked. The\n * reason stays null: a sentence from this side is not `C`, which is what the other end had to say.\n */\n const shut = (): void => {\n if (ended) return;\n ended = true;\n };\n\n /** Hand over what the buffer holds, as far as the framing allows. */\n const drain = (): void => {\n while (!ended) {\n if (pending !== null) {\n if (buffered.length < pending.bytes) return;\n const bytes = buffered.subarray(0, pending.bytes);\n buffered = buffered.subarray(pending.bytes);\n const line = pending.line;\n pending = null;\n emit({ line, bytes: new Uint8Array(bytes) });\n continue;\n }\n const cut = buffered.indexOf(NL);\n if (cut === -1) return;\n const raw = buffered.subarray(0, cut);\n buffered = buffered.subarray(cut + 1);\n const line = raw.length > 0 && raw[raw.length - 1] === CR ? raw.subarray(0, raw.length - 1) : raw;\n const text = decoder.write(line);\n const count = announced(text);\n if (count === null) {\n emit({ line: text, bytes: null });\n continue;\n }\n pending = { line: text, bytes: count };\n if (count === 0) {\n pending = null;\n emit({ line: text, bytes: new Uint8Array(0) });\n }\n }\n };\n\n inner.onFrame((chunk) => {\n if (ended) return;\n buffered = buffered.length === 0 ? Buffer.from(chunk) : Buffer.concat([buffered, Buffer.from(chunk)]);\n drain();\n });\n inner.onError((error) => {\n for (const failer of [...failers]) failer(error);\n });\n inner.onClose((why) => {\n if (ended) return;\n // Whatever is left without a terminator is still a line: a peer that hangs up after writing has said\n // something, and dropping it would be the framing deciding to lose the last word.\n if (pending === null && buffered.length > 0) {\n const rest = buffered;\n buffered = Buffer.alloc(0);\n emit({ line: decoder.write(rest) + decoder.end(), bytes: null });\n } else {\n decoder.end();\n }\n close(why);\n });\n\n return {\n send: async (part: Part) => {\n const head = Buffer.from(`${part.line}\\n`, \"utf8\");\n const body = part.bytes === null ? head : Buffer.concat([head, Buffer.from(part.bytes)]);\n await inner.send(new Uint8Array(body));\n },\n onFrame: (handler) => {\n readers.add(handler);\n return () => {\n readers.delete(handler);\n };\n },\n onClose: (handler) => {\n if (ended && reason !== null) {\n handler(reason);\n return () => {};\n }\n closers.add(handler);\n return () => {\n closers.delete(handler);\n };\n },\n onError: (handler) => {\n failers.add(handler);\n return () => {\n failers.delete(handler);\n };\n },\n close: async (why = \"closed here\") => {\n shut();\n await inner.close(why);\n },\n info: inner.info,\n control: (command) => inner.control(command),\n };\n}\n","// ── a channel that keeps what nobody was reading yet ────────────────────────\n//\n// A medium can deliver a frame in the same turn a reader is being installed, and a channel with no subscriber\n// drops it. This wraps a channel so nothing is dropped for want of a listener: what arrives while nobody is\n// subscribed is kept, and every subscriber that arrives before the first frame is delivered is given it.\n//\n// The window ends at the first delivery. After that the channel is live, and a subscriber that comes later has\n// missed what went before it — which is what any live channel means, and the alternative would be an unbounded\n// copy of everything ever said.\n\nimport type { Channel } from \"./channel.js\";\n\n/**\n * `inner`, with the frames that arrive before anyone is subscribed kept for the readers that follow.\n *\n * The kept frames are not bounded, because a bound depends on what the far end may say before anyone listens,\n * and that is not something this adapter can know.\n */\nexport function held<F, C>(inner: Channel<F, C>): Channel<F, C> {\n const readers = new Set<(frame: F) => void>();\n const closers = new Set<(reason: C) => void>();\n const failers = new Set<(error: unknown) => void>();\n const kept: F[] = [];\n let live = false;\n\n const emit = (frame: F): void => {\n for (const reader of [...readers]) reader(frame);\n };\n\n inner.onFrame((frame) => {\n if (live) {\n emit(frame);\n return;\n }\n if (readers.size === 0) {\n kept.push(frame);\n return;\n }\n // Somebody is reading: from here the channel is live, and what was kept has been taken.\n live = true;\n kept.length = 0;\n emit(frame);\n });\n inner.onClose((reason) => {\n for (const closer of [...closers]) closer(reason);\n });\n inner.onError((error) => {\n for (const failer of [...failers]) failer(error);\n });\n\n return {\n send: (frame) => inner.send(frame),\n onFrame(handler) {\n readers.add(handler);\n // Handed to every subscriber that arrives before the first delivery, not only to the first.\n for (const frame of kept) handler(frame);\n return () => {\n readers.delete(handler);\n };\n },\n onClose(handler) {\n closers.add(handler);\n return () => {\n closers.delete(handler);\n };\n },\n onError(handler) {\n failers.add(handler);\n return () => {\n failers.delete(handler);\n };\n },\n close: (reason) => inner.close(reason),\n info: inner.info,\n control: (command) => inner.control(command),\n };\n}\n","// ── a port as an actor ──────────────────────────────────────────────────────\n//\n// One actor that owns one channel and speaks for it: what it is told to send goes in, what the channel delivers\n// comes out as DATA, and the way the channel ended is left in the actor's state, where a parent reads anyway.\n//\n// The channel is opened in `setup`, which the runtime awaits, so an actor that is ready has a channel: a send is\n// never asked to wait for one, and a port that cannot open fails its start rather than looking alive. What a\n// channel is — a process, a socket, a pair in memory — is `open`'s business; the actor knows only that it has one.\n\nimport type { ActorDefinition } from \"../actor-types.js\";\nimport { defineActor, defineMessages } from \"../define-actor.js\";\nimport type { Message } from \"../types.js\";\nimport type { Channel } from \"./channel.js\";\n\n/** Write this to the channel. */\nexport interface SendMessage<F> extends Message {\n type: \"SEND\";\n data: F;\n}\n\n/** Ask the channel's own world to act on what is behind it; a medium without one ignores it. */\nexport interface SignalMessage extends Message {\n type: \"SIGNAL\";\n signal: string;\n}\n\n/** A frame the channel delivered. */\nexport interface DataMessage<F> extends Message {\n type: \"DATA\";\n data: F;\n}\n\nexport type PortIn<F> = SendMessage<F> | SignalMessage;\nexport type PortOut<F> = DataMessage<F>;\n\n/** What a parent may read of a port. The ending is here because it is state, not news. */\nexport interface PortPublic<C> {\n /** The channel is open. False before it opens and after it has ended. */\n alive: boolean;\n /** How it ended, or null while it has not. */\n end: C | null;\n /** What the medium knows about itself — a process its pid — as the channel reported it. */\n info: Record<string, unknown>;\n}\n\n/** What a medium's actor is handed: a name, and a way to open the channel it will own. */\nexport interface PortActorSpec<Args, F, C = string> {\n name: string;\n /** Opens the channel this actor owns. Called once, when the actor starts. */\n open(args: Args): Promise<Channel<F, C>>;\n}\n\ntype PortState<F, C> = {\n public: PortPublic<C>;\n private: { channel: Channel<F, C>; args: unknown };\n};\n\n/**\n * An actor over one channel.\n *\n * In `SEND {data}` writes to it and `SIGNAL {signal}` asks the medium to act on what is behind it, through\n * the channel's own `control`; posipaki's `STOP` ends the actor, which closes the channel. Out `DATA {data}`\n * for every frame. The channel's ending is left in `state.end`, what the medium knows about itself in\n * `state.info`, and then the actor stops.\n */\nexport function portActor<Args, F, C = string>(\n spec: PortActorSpec<Args, F, C>,\n): ActorDefinition<Args, PortState<F, C>, PortIn<F>, PortOut<F>, {}> {\n return defineActor({\n name: spec.name,\n inMessages: defineMessages<PortIn<F>>(),\n outMessages: defineMessages<PortOut<F>>(),\n setup: async (args: Args): Promise<PortState<F, C>> => {\n const channel = await spec.open(args);\n return {\n public: { alive: true, end: null, info: channel.info },\n private: { channel, args },\n };\n },\n afterStart() {\n const { channel } = this.state.private;\n channel.onFrame((data) => {\n this.emit({ type: \"DATA\", data });\n });\n channel.onClose((reason) => {\n this.state.public.alive = false;\n this.state.public.end = reason;\n this.exit();\n });\n },\n async beforeEnd() {\n this.state.public.alive = false;\n await this.state.private.channel.close();\n },\n handlers: {\n async SEND(msg: SendMessage<F>) {\n await this.state.private.channel.send(msg.data);\n },\n SIGNAL(msg: SignalMessage) {\n this.state.private.channel.control({ signal: msg.signal });\n },\n },\n });\n}\n"],"mappings":";;;AAkBA,MAAM,KAAK;AACX,MAAM,KAAK;AAKX,MAAM,gBAA8B;;;;;;;AAQpC,SAAgB,aACd,OACA,YAA0B,SACR;CAClB,MAAM,0BAAU,IAAI,IAA0B;CAC9C,MAAM,0BAAU,IAAI,IAAyB;CAC7C,MAAM,0BAAU,IAAI,IAA8B;CAClD,MAAM,UAAU,IAAI,cAAc,MAAM;;CAExC,IAAI,WAAW,OAAO,MAAM,CAAC;;CAE7B,IAAI,UAAkD;CACtD,IAAI,QAAQ;CACZ,IAAI,SAAmB;CAEvB,MAAM,QAAQ,SAAqB;EACjC,KAAK,MAAM,UAAU,CAAC,GAAG,OAAO,GAAG,OAAO,IAAI;CAChD;;CAGA,MAAM,SAAS,QAAiB;EAC9B,IAAI,OAAO;EACX,QAAQ;EACR,SAAS;EACT,KAAK,MAAM,UAAU,CAAC,GAAG,OAAO,GAAG,OAAO,GAAG;CAC/C;;;;;CAMA,MAAM,aAAmB;EACvB,IAAI,OAAO;EACX,QAAQ;CACV;;CAGA,MAAM,cAAoB;EACxB,OAAO,CAAC,OAAO;GACb,IAAI,YAAY,MAAM;IACpB,IAAI,SAAS,SAAS,QAAQ,OAAO;IACrC,MAAM,QAAQ,SAAS,SAAS,GAAG,QAAQ,KAAK;IAChD,WAAW,SAAS,SAAS,QAAQ,KAAK;IAC1C,MAAM,OAAO,QAAQ;IACrB,UAAU;IACV,KAAK;KAAE;KAAM,OAAO,IAAI,WAAW,KAAK;IAAE,CAAC;IAC3C;GACF;GACA,MAAM,MAAM,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AS,UAAU,sBAAsB;EAC/G,OAAO;EACP,QAAQ,eAAe;EACvB,KAAK,GAAG,GAAG,WAAW,SAAS,WAAW,OAAO,UAAU,mBAAmB,OAAO,gBAAgB,GAAG,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG;IAC7H;IACA,aAAa;MACb,QAAQ,aAAa,GAAG,YAAY,IAAI,IAAI,IAAI,IAAI;EACxD,KAAK,WAAW,MAAM,YAAY,gBAAgB,OAAO;;;;;;KAMjD,eAAe,KAAK,UAAU,kBAAkB,YAAY,qBAAqB,cAAc,eAAe,eAAe,eAAe,gBAAgB,qBAAqB,gBAAgB,0BAA0B,qBAAqB,aAAa,MAAM,eAAe,OAAO,QAAQ,SAAS,iBAAiB,eAAe,SAAS,WAAW,eAAe,QAAQ,oBAAoB;;;;;;;;;;;;;;;UCjIpY;;;UAGA,wBAAwB;;;;;;;;;;;;;;;iBAkBzB,UAAU,OAAO,yBAC/B,YAAY,MAAM,UAAU,MAAM,UAAU,aAAa,QAAQ,0BACjE,SAAS,MAAM,UAAU,MAAM,UAAU,aAAa,QAAQ,eAC5D,MAAM,UAAU,MAAM,UAAU,aAAa,QAAQ;;;;;;;;;;;;;;;;;;;iBA6BzC,aAAa,UAAU,WACrC,MAAM,GACN,SAAS,QAAQ,KAAK,SAAS,eAAe,MAC7C;KA0BS,KAAK,GAAG,qBAAqB,MAAM,MAAM,MAAM,MAAM,MAAM;iBAEjD,SAAS,GAAG,qBAAqB,GACrD,IAAI,KAAK,GAAG,GAAG,gBACf,MAAM,qCACN,SAAS,MACN,MAAM,IACR,QAAQ"}
@@ -1,4 +1,4 @@
1
- import { g as Part, m as Channel } from "./reactor-CWPBP7qN.js";
1
+ import { g as Part, m as Channel } from "./reactor-4MaIKVnw.js";
2
2
  import { Readable, Writable } from "node:stream";
3
3
  //#region src/port/memory.d.ts
4
4
  /** One end of a pair. `fail` is the hook this double adds: it breaks the wire the way a socket would. */
@@ -102,4 +102,4 @@ declare function duplexChannel<F, C = void>(pair: {
102
102
  }): Channel<F, C>;
103
103
  //#endregion
104
104
  export { held as a, all as c, streamChannel as d, Announcement as f, memoryChannelPair as g, MemoryEnd as h, fetchPort as i, settled as l, ChannelPair as m, FetchPortOptions as n, Ended as o, splitChannel as p, HttpEnd as r, Sourced as s, duplexChannel as t, StreamPair as u };
105
- //# sourceMappingURL=index-B3FcBNz7.d.ts.map
105
+ //# sourceMappingURL=index-DFqA3rI6.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-B3FcBNz7.d.ts","names":[],"sources":["../src/port/memory.ts","../src/port/split.ts","../src/port/stream.ts","../src/port/combine.ts","../src/port/held.ts","../src/port/fetch.ts","../src/port/duplex.ts"],"mappings":";;;;UAUiB,UAAU,WAAW,QAAQ;;EAE5C,KAAK;;UAGU,YAAY;EAC3B,MAAM,UAAU;EAChB,KAAK,UAAU;;;iBAgBD,kBAAkB,MAAM,YAAY;;;;KCXxC,gBAAgB;;;;;;;iBAUZ,aAAa,YAC3B,OAAO,QAAQ,YAAY,IAC3B,YAAW,eACV,QAAQ,MAAM;;;;UCnBA;EACf,MAAM;EACN,OAAO;;;;;;;;;iBAyBO,cAAc,MAAM,aAAa,QAAQ;;;;UC5BxC,QAAQ,GAAG;WACjB,QAAQ;WACR,OAAO;;;UAID,MAAM,GAAG;WACf,QAAQ;WACR,QAAQ;;;;;;;;iBAaH,IAAI,kBAAkB,GAAG,GAAG,SAAS,OAAO,GAAG,QAAQ,GAAG,MAAM,QAAQ,QAAQ,GAAG,IAAI;;;;;;;iBAgEvF,QAAQ,kBAAkB,GAAG,GAC3C,SAAS,OAAO,GAAG,QAAQ,GAAG,MAC7B,QAAQ,QAAQ,GAAG,KAAK,MAAM,GAAG;;;;;;;;;iBCpFpB,KAAK,GAAG,GAAG,OAAO,QAAQ,GAAG,KAAK,QAAQ,GAAG;;;;UCR5C;;WAEN;;UAGM;;EAEf,OAAO;;EAEP;;;;;;;;iBASoB,UAAU,aAAa,UAAS,mBAAwB,QAAQ,QAAQ,YAAY;;;;iBChB1F,cAAc,GAAG,UAAU;WAChC,SAAS,QAAQ,GAAG;WACpB,UAAU,QAAQ,GAAG;IAC5B,QAAQ,GAAG"}
1
+ {"version":3,"file":"index-DFqA3rI6.d.ts","names":[],"sources":["../src/port/memory.ts","../src/port/split.ts","../src/port/stream.ts","../src/port/combine.ts","../src/port/held.ts","../src/port/fetch.ts","../src/port/duplex.ts"],"mappings":";;;;UAUiB,UAAU,WAAW,QAAQ;;EAE5C,KAAK;;UAGU,YAAY;EAC3B,MAAM,UAAU;EAChB,KAAK,UAAU;;;iBAgBD,kBAAkB,MAAM,YAAY;;;;KCXxC,gBAAgB;;;;;;;iBAUZ,aAAa,YAC3B,OAAO,QAAQ,YAAY,IAC3B,YAAW,eACV,QAAQ,MAAM;;;;UCnBA;EACf,MAAM;EACN,OAAO;;;;;;;;;iBAyBO,cAAc,MAAM,aAAa,QAAQ;;;;UC5BxC,QAAQ,GAAG;WACjB,QAAQ;WACR,OAAO;;;UAID,MAAM,GAAG;WACf,QAAQ;WACR,QAAQ;;;;;;;;iBAaH,IAAI,kBAAkB,GAAG,GAAG,SAAS,OAAO,GAAG,QAAQ,GAAG,MAAM,QAAQ,QAAQ,GAAG,IAAI;;;;;;;iBAkEvF,QAAQ,kBAAkB,GAAG,GAC3C,SAAS,OAAO,GAAG,QAAQ,GAAG,MAC7B,QAAQ,QAAQ,GAAG,KAAK,MAAM,GAAG;;;;;;;;;iBCtFpB,KAAK,GAAG,GAAG,OAAO,QAAQ,GAAG,KAAK,QAAQ,GAAG;;;;UCR5C;;WAEN;;UAGM;;EAEf,OAAO;;EAEP;;;;;;;;iBASoB,UAAU,aAAa,UAAS,mBAAwB,QAAQ,QAAQ,YAAY;;;;iBChB1F,cAAc,GAAG,UAAU;WAChC,SAAS,QAAQ,GAAG;WACpB,UAAU,QAAQ,GAAG;IAC5B,QAAQ,GAAG"}
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ declare function defineActor<Args, InternalState, InMsg extends Message, OutMsg
20
20
  //#endregion
21
21
  //#region src/version.d.ts
22
22
  /** posipaki's release version. Must equal package.json's `version`. */
23
- declare const LIB_VERSION = "0.48.1";
23
+ declare const LIB_VERSION = "0.49.0";
24
24
  //#endregion
25
25
  export { type ActorConfig, type ActorContext, type ActorDecorated, type ActorDefinition, type ActorPlugin, type ActorReflection, type AnyProcess, AsyncProcess, type AsyncProcessFn, type ExitMessage, type HandlerFn, type HandlerOptions, type HookResult, LIB_VERSION, type Message, type MethodOptions, type PluginTransform, Process, type ProcessCtx, type ProcessFn, type SenderInfo, type SenderOrigin, type SpawnedFrom, type StopMessage, type WithSender, type WithoutSender, asyncify, callHook, chainHook, defineActor, defineMessages, mergeConfigs, propagateError, runDispatch, runDispatchAsync, spawn, spawnAsync, stopPropagation };
26
26
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { i as runDispatch } from "./util-Brtfgv68.js";
2
2
  import { a as spawnAsync, i as runDispatchAsync, o as asyncify, t as AsyncProcess } from "./process.async-B1FqZyD1.js";
3
3
  import { n as chainHook, o as propagateError, r as mergeConfigs, s as stopPropagation, t as callHook } from "./hooks-CgXhmY4r.js";
4
4
  import { n as defineMessages, t as defineActor } from "./define-actor-DR1P1PA5.js";
5
- import { t as LIB_VERSION } from "./version-CjO8pCPA.js";
5
+ import { t as LIB_VERSION } from "./version-DyYl4K-F.js";
6
6
  //#region src/process.ts
7
7
  /** @deprecated Use {@link spawnAsync} instead. */
8
8
  function spawn(fn, pname, tp) {
@@ -1,3 +1,3 @@
1
- import { a as portReactor, c as PortIn, d as SendMessage, f as SignalMessage, g as Part, h as ChannelClosed, i as PortReactorOptions, l as PortOut, m as Channel, n as PortPair, o as DataMessage, p as portActor, r as PortReactor, s as PortActorSpec, t as PortListener, u as PortPublic } from "../reactor-CWPBP7qN.js";
2
- import { a as held, c as all, d as streamChannel, f as Announcement, g as memoryChannelPair, h as MemoryEnd, i as fetchPort, l as settled, m as ChannelPair, n as FetchPortOptions, o as Ended, p as splitChannel, r as HttpEnd, s as Sourced, t as duplexChannel, u as StreamPair } from "../index-B3FcBNz7.js";
1
+ import { a as portReactor, c as PortIn, d as SendMessage, f as SignalMessage, g as Part, h as ChannelClosed, i as PortReactorOptions, l as PortOut, m as Channel, n as PortPair, o as DataMessage, p as portActor, r as PortReactor, s as PortActorSpec, t as PortListener, u as PortPublic } from "../reactor-4MaIKVnw.js";
2
+ import { a as held, c as all, d as streamChannel, f as Announcement, g as memoryChannelPair, h as MemoryEnd, i as fetchPort, l as settled, m as ChannelPair, n as FetchPortOptions, o as Ended, p as splitChannel, r as HttpEnd, s as Sourced, t as duplexChannel, u as StreamPair } from "../index-DFqA3rI6.js";
3
3
  export { type Announcement, type Channel, ChannelClosed, type ChannelPair, type DataMessage, type Ended, type FetchPortOptions, type HttpEnd, type MemoryEnd, type Part, type PortActorSpec, type PortIn, type PortListener, type PortOut, type PortPair, type PortPublic, type PortReactor, type PortReactorOptions, type SendMessage, type SignalMessage, type Sourced, type StreamPair, all, duplexChannel, fetchPort, held, memoryChannelPair, portActor, portReactor, settled, splitChannel, streamChannel };
@@ -1,3 +1,3 @@
1
- import { a as settled, c as ChannelClosed, i as all, n as portReactor, o as streamChannel, r as fetchPort, s as memoryChannelPair, t as duplexChannel } from "../port-DowG9tgl.js";
2
- import { n as held, r as splitChannel, t as portActor } from "../actor-C8DzeQeT.js";
1
+ import { a as settled, c as ChannelClosed, i as all, n as portReactor, o as streamChannel, r as fetchPort, s as memoryChannelPair, t as duplexChannel } from "../port-BR7f7BDY.js";
2
+ import { n as held, r as splitChannel, t as portActor } from "../actor-Df5v2zuv.js";
3
3
  export { ChannelClosed, all, duplexChannel, fetchPort, held, memoryChannelPair, portActor, portReactor, settled, splitChannel, streamChannel };
@@ -1,5 +1,5 @@
1
1
  import { l as ActorDefinition } from "../hooks-DO-efRM_.js";
2
- import { c as PortIn, l as PortOut, m as Channel, t as PortListener, u as PortPublic } from "../reactor-CWPBP7qN.js";
2
+ import { c as PortIn, l as PortOut, m as Channel, t as PortListener, u as PortPublic } from "../reactor-4MaIKVnw.js";
3
3
  //#region src/port/node/spawn.d.ts
4
4
  /** How a process ended: it exited with a code, or a signal terminated it. */
5
5
  type ProcessEnd = {
@@ -24,6 +24,25 @@ declare function spawnPort(command: string[], options?: SpawnPortOptions): Promi
24
24
  /** One process, its stdout and its stderr, each a channel that ends with the same exit. */
25
25
  declare function spawnPorts(command: string[], options?: SpawnPortOptions): Promise<ProcessPorts>;
26
26
  //#endregion
27
+ //#region src/port/node/listener.d.ts
28
+ interface HttpListenerOptions<Meta> {
29
+ port?: number;
30
+ hostname?: string;
31
+ /** Admission before a body is made: what it returns is the pair's meta; throwing refuses the request. */
32
+ identify?(request: Request): Meta | Promise<Meta>;
33
+ }
34
+ /** A port listener that is also an HTTP server: the port it bound, and the pairs it hands out. */
35
+ interface HttpListener<Meta> extends PortListener<Uint8Array, Uint8Array, Meta> {
36
+ readonly port: number;
37
+ }
38
+ /**
39
+ * A server whose requests arrive as pairs of ports.
40
+ *
41
+ * `identify` runs before a pair exists, so a refused request costs no stream and the caller reads a status with
42
+ * the reason in it. The request body is the inbound port; the response body is the outbound one.
43
+ */
44
+ declare function httpListener<Meta = unknown>(options?: HttpListenerOptions<Meta>): HttpListener<Meta>;
45
+ //#endregion
27
46
  //#region src/port/node/process.d.ts
28
47
  /** How a process port is started. */
29
48
  interface ProcessPortArgs {
@@ -37,37 +56,18 @@ interface ProcessPortArgs {
37
56
  declare const BinaryPort: ActorDefinition<ProcessPortArgs, {
38
57
  public: PortPublic<ProcessEnd>;
39
58
  private: {
40
- channel: Channel<unknown, ProcessEnd> | null;
59
+ channel: Channel<Uint8Array<ArrayBufferLike>, ProcessEnd>;
41
60
  args: unknown;
42
61
  };
43
62
  }, PortIn<Uint8Array<ArrayBufferLike>>, PortOut<Uint8Array<ArrayBufferLike>>, {}>;
44
- /** The same child, cut into lines. */
63
+ /** The same child cut into lines: the facts come with it, because the medium is the same one. */
45
64
  declare const Utf8Port: ActorDefinition<ProcessPortArgs, {
46
65
  public: PortPublic<ProcessEnd>;
47
66
  private: {
48
- channel: Channel<unknown, ProcessEnd> | null;
67
+ channel: Channel<string, ProcessEnd>;
49
68
  args: unknown;
50
69
  };
51
70
  }, PortIn<string>, PortOut<string>, {}>;
52
71
  //#endregion
53
- //#region src/port/node/listener.d.ts
54
- interface HttpListenerOptions<Meta> {
55
- port?: number;
56
- hostname?: string;
57
- /** Admission before a body is made: what it returns is the pair's meta; throwing refuses the request. */
58
- identify?(request: Request): Meta | Promise<Meta>;
59
- }
60
- /** A port listener that is also an HTTP server: the port it bound, and the pairs it hands out. */
61
- interface HttpListener<Meta> extends PortListener<Uint8Array, Uint8Array, Meta> {
62
- readonly port: number;
63
- }
64
- /**
65
- * A server whose requests arrive as pairs of ports.
66
- *
67
- * `identify` runs before a pair exists, so a refused request costs no stream and the caller reads a status with
68
- * the reason in it. The request body is the inbound port; the response body is the outbound one.
69
- */
70
- declare function httpListener<Meta = unknown>(options?: HttpListenerOptions<Meta>): HttpListener<Meta>;
71
- //#endregion
72
72
  export { BinaryPort, type HttpListener, type HttpListenerOptions, type ProcessEnd, type ProcessPortArgs, type ProcessPorts, type SpawnPortOptions, Utf8Port, httpListener, spawnPort, spawnPorts };
73
73
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","names":[],"sources":["../../src/port/node/spawn.ts","../../src/port/node/process.ts","../../src/port/node/listener.ts"],"mappings":";;;;KAcY;WACG;WAAuB;;WACvB;WAAyB;;UACvB;EACf;EACA,MAAM,OAAO;;EAEb;;UAEe;WACN,QAAQ,QAAQ,YAAY;WAC5B,QAAQ,QAAQ,YAAY;;;iBAIvB,UACd,mBACA,UAAS,mBACR,QAAQ,QAAQ,YAAY;;iBAIT,WACpB,mBACA,UAAS,mBACR,QAAQ;;;;UC3BM;EACf;EACA;EACA,MAAM,OAAO;;EAEb;;;cA8CW,YAGX,gBAHqB;;;;;;GAGrB,OAAA,WAAA,mBAAA,QAAA,WAAA;;cAGW,UAGX,gBAHmB;;;;;;mBAGnB;;;UC3De,oBAAoB;EACnC;EACA;;EAEA,UAAU,SAAS,UAAU,OAAO,QAAQ;;;UAI7B,aAAa,cAAc,aAAa,YAAY,YAAY;WACtE;;;;;;;;iBAuBK,aAAa,gBAAgB,UAAS,oBAAoB,QAAa,aAAa"}
1
+ {"version":3,"file":"node.d.ts","names":[],"sources":["../../src/port/node/spawn.ts","../../src/port/node/listener.ts","../../src/port/node/process.ts"],"mappings":";;;;KAcY;WACG;WAAuB;;WACvB;WAAyB;;UACvB;EACf;EACA,MAAM,OAAO;;EAEb;;UAEe;WACN,QAAQ,QAAQ,YAAY;WAC5B,QAAQ,QAAQ,YAAY;;;iBAIvB,UACd,mBACA,UAAS,mBACR,QAAQ,QAAQ,YAAY;;iBAIT,WACpB,mBACA,UAAS,mBACR,QAAQ;;;UC1BM,oBAAoB;EACnC;EACA;;EAEA,UAAU,SAAS,UAAU,OAAO,QAAQ;;;UAI7B,aAAa,cAAc,aAAa,YAAY,YAAY;WACtE;;;;;;;;iBAuBK,aAAa,gBAAgB,UAAS,oBAAoB,QAAa,aAAa;;;;UCjCnF;EACf;EACA;EACA,MAAM,OAAO;;EAEb;;;cAiDW,YAGX,gBAHqB;;;;;;GAGrB,OAAA,WAAA,mBAAA,QAAA,WAAA;;cAGW,UAGX,gBAHmB;;;;;;mBAGnB"}
package/dist/port/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as held, r as splitChannel, t as portActor } from "../actor-C8DzeQeT.js";
1
+ import { n as held, r as splitChannel, t as portActor } from "../actor-Df5v2zuv.js";
2
2
  import { spawn } from "node:child_process";
3
3
  //#region src/port/node/spawn.ts
4
4
  const DEFAULT_KILL_AFTER_MS = 5e3;
@@ -12,7 +12,8 @@ async function spawnPorts(command, options = {}) {
12
12
  if (file === void 0) throw new Error("spawnPort: there is no command to run");
13
13
  const child = spawn(file, args, {
14
14
  cwd: options.cwd,
15
- env: options.env
15
+ env: options.env,
16
+ detached: true
16
17
  });
17
18
  await started(child, file);
18
19
  const out = bytesOf(child.stdout, "stdout");
@@ -56,12 +57,20 @@ async function spawnPorts(command, options = {}) {
56
57
  failers.delete(handler);
57
58
  };
58
59
  };
60
+ const facts = {
61
+ info: { pid: child.pid },
62
+ control: (command) => {
63
+ const signal = command.signal;
64
+ if (typeof signal === "string") signalGroup(child, signal);
65
+ }
66
+ };
59
67
  const stderr = {
60
68
  send: () => Promise.reject(/* @__PURE__ */ new Error("stderr carries the process's output; it has no input")),
61
69
  onFrame: err.onFrame,
62
70
  onClose,
63
71
  onError,
64
- close
72
+ close,
73
+ ...facts
65
74
  };
66
75
  return {
67
76
  stdout: {
@@ -69,7 +78,8 @@ async function spawnPorts(command, options = {}) {
69
78
  onFrame: out.onFrame,
70
79
  onClose,
71
80
  onError,
72
- close
81
+ close,
82
+ ...facts
73
83
  },
74
84
  stderr
75
85
  };
@@ -94,7 +104,9 @@ function bytesOf(stream, label) {
94
104
  },
95
105
  onClose: () => () => {},
96
106
  onError: () => () => {},
97
- close: () => Promise.resolve()
107
+ close: () => Promise.resolve(),
108
+ info: {},
109
+ control: () => {}
98
110
  };
99
111
  stream?.on("data", (chunk) => {
100
112
  const bytes = new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
@@ -110,7 +122,19 @@ function write(child, frame) {
110
122
  stdin.write(frame, (error) => error === null || error === void 0 ? resolve() : reject(error));
111
123
  });
112
124
  }
113
- /** Ends stdin, and kills what is still there after the grace. */
125
+ /** Signal the child's process group, or the child alone when it has none. */
126
+ function signalGroup(child, signal) {
127
+ const pid = child.pid;
128
+ if (pid === void 0) return;
129
+ try {
130
+ process.kill(-pid, signal);
131
+ return;
132
+ } catch {}
133
+ try {
134
+ child.kill(signal);
135
+ } catch {}
136
+ }
137
+ /** Ends stdin, and kills what is still there after the grace. A caller in a hurry sends `signal` first. */
114
138
  async function shutdown(child, killAfterMs) {
115
139
  if (child.exitCode !== null || child.signalCode !== null) return;
116
140
  const closed = new Promise((resolve) => {
@@ -118,65 +142,13 @@ async function shutdown(child, killAfterMs) {
118
142
  });
119
143
  child.stdin?.end();
120
144
  const timer = setTimeout(() => {
121
- if (child.exitCode === null && child.signalCode === null) child.kill("SIGKILL");
145
+ if (child.exitCode === null && child.signalCode === null) signalGroup(child, "SIGKILL");
122
146
  }, killAfterMs);
123
147
  timer.unref?.();
124
148
  await closed;
125
149
  clearTimeout(timer);
126
150
  }
127
151
  //#endregion
128
- //#region src/port/node/process.ts
129
- /** Parts as their text: what a line port carries. Octets that came with a line are not text and are dropped. */
130
- function lines(parts) {
131
- const readers = /* @__PURE__ */ new Set();
132
- const closers = /* @__PURE__ */ new Set();
133
- const failers = /* @__PURE__ */ new Set();
134
- parts.onFrame(({ line }) => {
135
- for (const reader of [...readers]) reader(line);
136
- });
137
- parts.onClose((reason) => {
138
- for (const closer of [...closers]) closer(reason);
139
- });
140
- parts.onError((error) => {
141
- for (const failer of [...failers]) failer(error);
142
- });
143
- return {
144
- send: (line) => parts.send({
145
- line,
146
- bytes: null
147
- }),
148
- onFrame(handler) {
149
- readers.add(handler);
150
- return () => {
151
- readers.delete(handler);
152
- };
153
- },
154
- onClose(handler) {
155
- closers.add(handler);
156
- return () => {
157
- closers.delete(handler);
158
- };
159
- },
160
- onError(handler) {
161
- failers.add(handler);
162
- return () => {
163
- failers.delete(handler);
164
- };
165
- },
166
- close: (reason) => parts.close(reason)
167
- };
168
- }
169
- /** The child's octets, frame for frame. */
170
- const BinaryPort = portActor({
171
- name: "binary-port",
172
- open: (args) => spawnPort(args.command, args)
173
- });
174
- /** The same child, cut into lines. */
175
- const Utf8Port = portActor({
176
- name: "utf8-port",
177
- open: async (args) => lines(splitChannel(await spawnPort(args.command, args)))
178
- });
179
- //#endregion
180
152
  //#region src/port/node/listener.ts
181
153
  /**
182
154
  * A server whose requests arrive as pairs of ports.
@@ -276,7 +248,12 @@ function requestPort(request) {
276
248
  close: async () => {
277
249
  await request.body?.cancel().catch(() => void 0);
278
250
  end();
279
- }
251
+ },
252
+ info: {
253
+ method: request.method,
254
+ url: request.url
255
+ },
256
+ control: () => {}
280
257
  };
281
258
  const reader = request.body?.getReader();
282
259
  const port = held(inbound);
@@ -330,7 +307,9 @@ function responsePort() {
330
307
  },
331
308
  async close() {
332
309
  end();
333
- }
310
+ },
311
+ info: {},
312
+ control: () => {}
334
313
  },
335
314
  body: new ReadableStream({
336
315
  start(controller) {
@@ -348,6 +327,60 @@ function responsePort() {
348
327
  };
349
328
  }
350
329
  //#endregion
330
+ //#region src/port/node/process.ts
331
+ /** Parts as their text: what a line port carries. Octets that came with a line are not text and are dropped. */
332
+ function lines(parts) {
333
+ const readers = /* @__PURE__ */ new Set();
334
+ const closers = /* @__PURE__ */ new Set();
335
+ const failers = /* @__PURE__ */ new Set();
336
+ parts.onFrame(({ line }) => {
337
+ for (const reader of [...readers]) reader(line);
338
+ });
339
+ parts.onClose((reason) => {
340
+ for (const closer of [...closers]) closer(reason);
341
+ });
342
+ parts.onError((error) => {
343
+ for (const failer of [...failers]) failer(error);
344
+ });
345
+ return {
346
+ send: (line) => parts.send({
347
+ line,
348
+ bytes: null
349
+ }),
350
+ onFrame(handler) {
351
+ readers.add(handler);
352
+ return () => {
353
+ readers.delete(handler);
354
+ };
355
+ },
356
+ onClose(handler) {
357
+ closers.add(handler);
358
+ return () => {
359
+ closers.delete(handler);
360
+ };
361
+ },
362
+ onError(handler) {
363
+ failers.add(handler);
364
+ return () => {
365
+ failers.delete(handler);
366
+ };
367
+ },
368
+ close: (reason) => parts.close(reason),
369
+ info: parts.info,
370
+ control: (command) => parts.control(command)
371
+ };
372
+ }
373
+ /** The child's octets, frame for frame. */
374
+ const BinaryPort = portActor({
375
+ name: "binary-port",
376
+ open: (args) => spawnPort(args.command, args)
377
+ });
378
+ /** The same child cut into lines: the facts come with it, because the medium is the same one. */
379
+ const Utf8Port = portActor({
380
+ name: "utf8-port",
381
+ open: async (args) => lines(splitChannel(await spawnPort(args.command, args)))
382
+ });
383
+ //#endregion
351
384
  export { BinaryPort, Utf8Port, httpListener, spawnPort, spawnPorts };
352
385
 
353
386
  //# sourceMappingURL=node.js.map