posipaki 0.48.1 → 0.49.1
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/dist/{actor-C8DzeQeT.js → actor-MIvmdVJD.js} +116 -111
- package/dist/actor-MIvmdVJD.js.map +1 -0
- package/dist/{index-B3FcBNz7.d.ts → index-ChSy_Vdu.d.ts} +14 -3
- package/dist/{index-B3FcBNz7.d.ts.map → index-ChSy_Vdu.d.ts.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/port/index.d.ts +3 -3
- package/dist/port/index.js +3 -3
- package/dist/port/node.d.ts +23 -23
- package/dist/port/node.d.ts.map +1 -1
- package/dist/port/node.js +94 -61
- package/dist/port/node.js.map +1 -1
- package/dist/{port-DowG9tgl.js → port-0vYKSxBM.js} +40 -9
- package/dist/port-0vYKSxBM.js.map +1 -0
- package/dist/process-eCAv2tIS.d.ts.map +1 -1
- package/dist/{reactor-CWPBP7qN.d.ts → reactor-4MaIKVnw.d.ts} +21 -10
- package/dist/reactor-4MaIKVnw.d.ts.map +1 -0
- package/dist/remote/gateway-cli.js.map +1 -1
- package/dist/remote/index.d.ts +2 -2
- package/dist/remote/index.js +1 -1
- package/dist/remote/node.d.ts +1 -1
- package/dist/remote/node.js +3 -3
- package/dist/{version-CjO8pCPA.js → version-DNJbW_di.js} +2 -2
- package/dist/{version-CjO8pCPA.js.map → version-DNJbW_di.js.map} +1 -1
- package/dist/{websocket-Ddmd6p1n.js → websocket-By6xlyLp.js} +14 -7
- package/dist/websocket-By6xlyLp.js.map +1 -0
- package/dist/{websocket-AU2aygxx.d.ts → websocket-DNSNv77Y.d.ts} +2 -2
- package/dist/{websocket-AU2aygxx.d.ts.map → websocket-DNSNv77Y.d.ts.map} +1 -1
- package/package.json +1 -1
- package/dist/actor-C8DzeQeT.js.map +0 -1
- package/dist/port-DowG9tgl.js.map +0 -1
- package/dist/reactor-CWPBP7qN.d.ts.map +0 -1
- package/dist/websocket-Ddmd6p1n.js.map +0 -1
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
import { n as defineMessages, t as defineActor } from "./define-actor-DR1P1PA5.js";
|
|
2
2
|
import { StringDecoder } from "node:string_decoder";
|
|
3
|
+
//#region src/port/held.ts
|
|
4
|
+
/**
|
|
5
|
+
* `inner`, with the frames that arrive before anyone is subscribed kept for the readers that follow.
|
|
6
|
+
*
|
|
7
|
+
* The kept frames are not bounded, because a bound depends on what the far end may say before anyone listens,
|
|
8
|
+
* and that is not something this adapter can know.
|
|
9
|
+
*/
|
|
10
|
+
function held(inner) {
|
|
11
|
+
const readers = /* @__PURE__ */ new Set();
|
|
12
|
+
const closers = /* @__PURE__ */ new Set();
|
|
13
|
+
const failers = /* @__PURE__ */ new Set();
|
|
14
|
+
const kept = [];
|
|
15
|
+
let live = false;
|
|
16
|
+
const emit = (frame) => {
|
|
17
|
+
for (const reader of [...readers]) reader(frame);
|
|
18
|
+
};
|
|
19
|
+
inner.onFrame((frame) => {
|
|
20
|
+
if (live) {
|
|
21
|
+
emit(frame);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (readers.size === 0) {
|
|
25
|
+
kept.push(frame);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
live = true;
|
|
29
|
+
kept.length = 0;
|
|
30
|
+
emit(frame);
|
|
31
|
+
});
|
|
32
|
+
inner.onClose((reason) => {
|
|
33
|
+
for (const closer of [...closers]) closer(reason);
|
|
34
|
+
});
|
|
35
|
+
inner.onError((error) => {
|
|
36
|
+
for (const failer of [...failers]) failer(error);
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
send: (frame) => inner.send(frame),
|
|
40
|
+
onFrame(handler) {
|
|
41
|
+
readers.add(handler);
|
|
42
|
+
for (const frame of kept) handler(frame);
|
|
43
|
+
return () => {
|
|
44
|
+
readers.delete(handler);
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
onClose(handler) {
|
|
48
|
+
closers.add(handler);
|
|
49
|
+
return () => {
|
|
50
|
+
closers.delete(handler);
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
onError(handler) {
|
|
54
|
+
failers.add(handler);
|
|
55
|
+
return () => {
|
|
56
|
+
failers.delete(handler);
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
close: (reason) => inner.close(reason),
|
|
60
|
+
info: inner.info,
|
|
61
|
+
control: (command) => inner.control(command)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
3
65
|
//#region src/port/split.ts
|
|
4
66
|
const NL = 10;
|
|
5
67
|
const CR = 13;
|
|
@@ -81,27 +143,7 @@ function splitChannel(inner, announced = NOTHING) {
|
|
|
81
143
|
}
|
|
82
144
|
}
|
|
83
145
|
};
|
|
84
|
-
|
|
85
|
-
if (ended) return;
|
|
86
|
-
buffered = buffered.length === 0 ? Buffer.from(chunk) : Buffer.concat([buffered, Buffer.from(chunk)]);
|
|
87
|
-
drain();
|
|
88
|
-
});
|
|
89
|
-
inner.onError((error) => {
|
|
90
|
-
for (const failer of [...failers]) failer(error);
|
|
91
|
-
});
|
|
92
|
-
inner.onClose((why) => {
|
|
93
|
-
if (ended) return;
|
|
94
|
-
if (pending === null && buffered.length > 0) {
|
|
95
|
-
const rest = buffered;
|
|
96
|
-
buffered = Buffer.alloc(0);
|
|
97
|
-
emit({
|
|
98
|
-
line: decoder.write(rest) + decoder.end(),
|
|
99
|
-
bytes: null
|
|
100
|
-
});
|
|
101
|
-
} else decoder.end();
|
|
102
|
-
close(why);
|
|
103
|
-
});
|
|
104
|
-
return {
|
|
146
|
+
const parts = held({
|
|
105
147
|
send: async (part) => {
|
|
106
148
|
const head = Buffer.from(`${part.line}\n`, "utf8");
|
|
107
149
|
const body = part.bytes === null ? head : Buffer.concat([head, Buffer.from(part.bytes)]);
|
|
@@ -132,127 +174,90 @@ function splitChannel(inner, announced = NOTHING) {
|
|
|
132
174
|
close: async (why = "closed here") => {
|
|
133
175
|
shut();
|
|
134
176
|
await inner.close(why);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/port/held.ts
|
|
140
|
-
/**
|
|
141
|
-
* `inner`, with the frames that arrive before anyone is subscribed kept for the readers that follow.
|
|
142
|
-
*
|
|
143
|
-
* The kept frames are not bounded, because a bound depends on what the far end may say before anyone listens,
|
|
144
|
-
* and that is not something this adapter can know.
|
|
145
|
-
*/
|
|
146
|
-
function held(inner) {
|
|
147
|
-
const readers = /* @__PURE__ */ new Set();
|
|
148
|
-
const closers = /* @__PURE__ */ new Set();
|
|
149
|
-
const failers = /* @__PURE__ */ new Set();
|
|
150
|
-
const kept = [];
|
|
151
|
-
let live = false;
|
|
152
|
-
const emit = (frame) => {
|
|
153
|
-
for (const reader of [...readers]) reader(frame);
|
|
154
|
-
};
|
|
155
|
-
inner.onFrame((frame) => {
|
|
156
|
-
if (live) {
|
|
157
|
-
emit(frame);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (readers.size === 0) {
|
|
161
|
-
kept.push(frame);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
live = true;
|
|
165
|
-
kept.length = 0;
|
|
166
|
-
emit(frame);
|
|
177
|
+
},
|
|
178
|
+
info: inner.info,
|
|
179
|
+
control: (command) => inner.control(command)
|
|
167
180
|
});
|
|
168
|
-
inner.
|
|
169
|
-
|
|
181
|
+
inner.onFrame((chunk) => {
|
|
182
|
+
if (ended) return;
|
|
183
|
+
buffered = buffered.length === 0 ? Buffer.from(chunk) : Buffer.concat([buffered, Buffer.from(chunk)]);
|
|
184
|
+
drain();
|
|
170
185
|
});
|
|
171
186
|
inner.onError((error) => {
|
|
172
187
|
for (const failer of [...failers]) failer(error);
|
|
173
188
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
};
|
|
188
|
-
},
|
|
189
|
-
onError(handler) {
|
|
190
|
-
failers.add(handler);
|
|
191
|
-
return () => {
|
|
192
|
-
failers.delete(handler);
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
close: (reason) => inner.close(reason)
|
|
196
|
-
};
|
|
189
|
+
inner.onClose((why) => {
|
|
190
|
+
if (ended) return;
|
|
191
|
+
if (pending === null && buffered.length > 0) {
|
|
192
|
+
const rest = buffered;
|
|
193
|
+
buffered = Buffer.alloc(0);
|
|
194
|
+
emit({
|
|
195
|
+
line: decoder.write(rest) + decoder.end(),
|
|
196
|
+
bytes: null
|
|
197
|
+
});
|
|
198
|
+
} else decoder.end();
|
|
199
|
+
close(why);
|
|
200
|
+
});
|
|
201
|
+
return parts;
|
|
197
202
|
}
|
|
198
203
|
//#endregion
|
|
199
204
|
//#region src/port/actor.ts
|
|
200
205
|
/**
|
|
201
206
|
* An actor over one channel.
|
|
202
207
|
*
|
|
203
|
-
* In `SEND {data}` writes to it and `SIGNAL {signal}` asks the medium to act on what is behind it
|
|
204
|
-
* `STOP` ends the actor, which closes the channel. Out `DATA {data}`
|
|
205
|
-
* left in `state.end
|
|
208
|
+
* In `SEND {data}` writes to it and `SIGNAL {signal}` asks the medium to act on what is behind it, through
|
|
209
|
+
* the channel's own `control`; posipaki's `STOP` ends the actor, which closes the channel. Out `DATA {data}`
|
|
210
|
+
* for every frame. The channel's ending is left in `state.end`, what the medium knows about itself in
|
|
211
|
+
* `state.info`, and then the actor stops.
|
|
206
212
|
*/
|
|
207
213
|
function portActor(spec) {
|
|
208
214
|
return defineActor({
|
|
209
215
|
name: spec.name,
|
|
210
216
|
inMessages: /* @__PURE__ */ defineMessages(),
|
|
211
217
|
outMessages: /* @__PURE__ */ defineMessages(),
|
|
212
|
-
setup: (args) =>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
218
|
+
setup: async (args) => {
|
|
219
|
+
const channel = await spec.open(args);
|
|
220
|
+
return {
|
|
221
|
+
public: {
|
|
222
|
+
alive: true,
|
|
223
|
+
end: null,
|
|
224
|
+
info: channel.info
|
|
225
|
+
},
|
|
226
|
+
private: {
|
|
227
|
+
channel,
|
|
228
|
+
args
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
},
|
|
222
232
|
afterStart() {
|
|
223
|
-
const {
|
|
224
|
-
|
|
225
|
-
this.
|
|
226
|
-
|
|
227
|
-
|
|
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();
|
|
233
|
+
const { channel } = this.state.private;
|
|
234
|
+
channel.onFrame((data) => {
|
|
235
|
+
this.emit({
|
|
236
|
+
type: "DATA",
|
|
237
|
+
data
|
|
237
238
|
});
|
|
238
239
|
});
|
|
240
|
+
channel.onClose((reason) => {
|
|
241
|
+
this.state.public.alive = false;
|
|
242
|
+
this.state.public.end = reason;
|
|
243
|
+
this.exit();
|
|
244
|
+
});
|
|
239
245
|
},
|
|
240
246
|
async beforeEnd() {
|
|
241
247
|
this.state.public.alive = false;
|
|
242
|
-
await this.state.private.channel
|
|
248
|
+
await this.state.private.channel.close();
|
|
243
249
|
},
|
|
244
250
|
handlers: {
|
|
245
251
|
async SEND(msg) {
|
|
246
|
-
await this.state.private.channel
|
|
252
|
+
await this.state.private.channel.send(msg.data);
|
|
247
253
|
},
|
|
248
254
|
SIGNAL(msg) {
|
|
249
|
-
|
|
250
|
-
if (channel !== null) spec.signal?.(channel, msg.signal);
|
|
255
|
+
this.state.private.channel.control({ signal: msg.signal });
|
|
251
256
|
}
|
|
252
257
|
}
|
|
253
258
|
});
|
|
254
259
|
}
|
|
255
260
|
//#endregion
|
|
256
|
-
export {
|
|
261
|
+
export { splitChannel as n, held as r, portActor as t };
|
|
257
262
|
|
|
258
|
-
//# sourceMappingURL=actor-
|
|
263
|
+
//# sourceMappingURL=actor-MIvmdVJD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor-MIvmdVJD.js","names":[],"sources":["../src/port/held.ts","../src/port/split.ts","../src/port/actor.ts"],"sourcesContent":["// ── 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","// ── 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\";\nimport { held } from \"./held.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 // Built and wrapped before the inner channel is read: the medium may have kept frames for its first\n // reader, and subscribing drains them at once — a part produced then must be a reader's to find, not the\n // wire's to lose.\n const parts: Channel<Part, C> = held<Part, C>({\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 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 parts;\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,SAAgB,KAAW,OAAqC;CAC9D,MAAM,0BAAU,IAAI,IAAwB;CAC5C,MAAM,0BAAU,IAAI,IAAyB;CAC7C,MAAM,0BAAU,IAAI,IAA8B;CAClD,MAAM,OAAY,CAAC;CACnB,IAAI,OAAO;CAEX,MAAM,QAAQ,UAAmB;EAC/B,KAAK,MAAM,UAAU,CAAC,GAAG,OAAO,GAAG,OAAO,KAAK;CACj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EACjB,MAAM,KAAK;EACX,YAAY,+BAA0B;EACtC,aAAa,+BAA2B;EACxC,OAAO,OAAO,SAAyC;GACrD,MAAM,UAAU,MAAM,KAAK,KAAK,IAAI;GACpC,OAAO;IACL,QAAQ;KAAE,OAAO;KAAM,KAAK;KAAM,MAAM,QAAQ;IAAK;IACrD,SAAS;KAAE;KAAS;IAAK;GAC3B;EACF;EACA,aAAa;GACX,MAAM,EAAE,YAAY,KAAK,MAAM;GAC/B,QAAQ,SAAS,SAAS;IACxB,KAAK,KAAK;KAAE,MAAM;KAAQ;IAAK,CAAC;GAClC,CAAC;GACD,QAAQ,SAAS,WAAW;IAC1B,KAAK,MAAM,OAAO,QAAQ;IAC1B,KAAK,MAAM,OAAO,MAAM;IACxB,KAAK,KAAK;GACZ,CAAC;EACH;EACA,MAAM,YAAY;GAChB,KAAK,MAAM,OAAO,QAAQ;GAC1B,MAAM,KAAK,MAAM,QAAQ,QAAQ,MAAM;EACzC;EACA,UAAU;GACR,MAAM,KAAK,KAAqB;IAC9B,MAAM,KAAK,MAAM,QAAQ,QAAQ,KAAK,IAAI,IAAI;GAChD;GACA,OAAO,KAAoB;IACzB,KAAK,MAAM,QAAQ,QAAQ,QAAQ,EAAE,QAAQ,IAAI,OAAO,CAAC;GAC3D;EACF;CACF,CAAC;AACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as Part, m as Channel } from "./reactor-
|
|
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. */
|
|
@@ -93,6 +93,17 @@ interface FetchPortOptions {
|
|
|
93
93
|
* response. `close()` aborts the request, and the far side hears it.
|
|
94
94
|
*/
|
|
95
95
|
declare function fetchPort(url: string, options?: FetchPortOptions): Promise<Channel<Uint8Array, HttpEnd>>;
|
|
96
|
+
/** The response head, or a rejection that says why there is none. */
|
|
97
|
+
/**
|
|
98
|
+
* A response that is not a stream: the far end answered, and the answer was a refusal.
|
|
99
|
+
*
|
|
100
|
+
* The status is here as a fact and in the sentence, because a caller that decides what to do next wants the
|
|
101
|
+
* number and a caller reading a log wants the words.
|
|
102
|
+
*/
|
|
103
|
+
declare class HttpRefusal extends Error {
|
|
104
|
+
readonly status: number;
|
|
105
|
+
constructor(status: number, message: string);
|
|
106
|
+
}
|
|
96
107
|
//#endregion
|
|
97
108
|
//#region src/port/duplex.d.ts
|
|
98
109
|
/** A pair whose two sides carry the same frame type, read as one channel. */
|
|
@@ -101,5 +112,5 @@ declare function duplexChannel<F, C = void>(pair: {
|
|
|
101
112
|
readonly outbound: Channel<F, C>;
|
|
102
113
|
}): Channel<F, C>;
|
|
103
114
|
//#endregion
|
|
104
|
-
export {
|
|
105
|
-
//# sourceMappingURL=index-
|
|
115
|
+
export { memoryChannelPair as _, fetchPort as a, Sourced as c, StreamPair as d, streamChannel as f, MemoryEnd as g, ChannelPair as h, HttpRefusal as i, all as l, splitChannel as m, FetchPortOptions as n, held as o, Announcement as p, HttpEnd as r, Ended as s, duplexChannel as t, settled as u };
|
|
116
|
+
//# sourceMappingURL=index-ChSy_Vdu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-ChSy_Vdu.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;;;;KCVxC,gBAAgB;;;;;;;iBAUZ,aAAa,YAC3B,OAAO,QAAQ,YAAY,IAC3B,YAAW,eACV,QAAQ,MAAM;;;;UCpBA;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;;;;;;;;cAmF7F,oBAAoB;WAEpB;EADX,YACW,gBACT;;;;;iBCtGY,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.
|
|
23
|
+
declare const LIB_VERSION = "0.49.1";
|
|
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-
|
|
5
|
+
import { t as LIB_VERSION } from "./version-DNJbW_di.js";
|
|
6
6
|
//#region src/process.ts
|
|
7
7
|
/** @deprecated Use {@link spawnAsync} instead. */
|
|
8
8
|
function spawn(fn, pname, tp) {
|
package/dist/port/index.d.ts
CHANGED
|
@@ -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-
|
|
2
|
-
import { a as
|
|
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
|
+
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 { _ as memoryChannelPair, a as fetchPort, c as Sourced, d as StreamPair, f as streamChannel, g as MemoryEnd, h as ChannelPair, i as HttpRefusal, l as all, m as splitChannel, n as FetchPortOptions, o as held, p as Announcement, r as HttpEnd, s as Ended, t as duplexChannel, u as settled } from "../index-ChSy_Vdu.js";
|
|
3
|
+
export { type Announcement, type Channel, ChannelClosed, type ChannelPair, type DataMessage, type Ended, type FetchPortOptions, type HttpEnd, HttpRefusal, 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 };
|
package/dist/port/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as
|
|
3
|
-
export { ChannelClosed, all, duplexChannel, fetchPort, held, memoryChannelPair, portActor, portReactor, settled, splitChannel, streamChannel };
|
|
1
|
+
import { a as all, c as memoryChannelPair, i as fetchPort, l as ChannelClosed, n as portReactor, o as settled, r as HttpRefusal, s as streamChannel, t as duplexChannel } from "../port-0vYKSxBM.js";
|
|
2
|
+
import { n as splitChannel, r as held, t as portActor } from "../actor-MIvmdVJD.js";
|
|
3
|
+
export { ChannelClosed, HttpRefusal, all, duplexChannel, fetchPort, held, memoryChannelPair, portActor, portReactor, settled, splitChannel, streamChannel };
|
package/dist/port/node.d.ts
CHANGED
|
@@ -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-
|
|
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<
|
|
59
|
+
channel: Channel<Uint8Array<ArrayBufferLike>, ProcessEnd>;
|
|
41
60
|
args: unknown;
|
|
42
61
|
};
|
|
43
62
|
}, PortIn<Uint8Array<ArrayBufferLike>>, PortOut<Uint8Array<ArrayBufferLike>>, {}>;
|
|
44
|
-
/** The same child
|
|
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<
|
|
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
|
package/dist/port/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","names":[],"sources":["../../src/port/node/spawn.ts","../../src/port/node/
|
|
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"}
|