posipaki 0.46.1 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/remote/node.js +1 -1
- package/dist/{version-BYC8xwip.js → version-DRbb_jh2.js} +2 -2
- package/dist/{version-BYC8xwip.js.map → version-DRbb_jh2.js.map} +1 -1
- package/dist/xfetch.d.ts +35 -24
- package/dist/xfetch.d.ts.map +1 -1
- package/dist/xfetch.js +30 -39
- package/dist/xfetch.js.map +1 -1
- package/package.json +1 -1
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.47.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-
|
|
5
|
+
import { t as LIB_VERSION } from "./version-DRbb_jh2.js";
|
|
6
6
|
//#region src/process.ts
|
|
7
7
|
/** @deprecated Use {@link spawnAsync} instead. */
|
|
8
8
|
function spawn(fn, pname, tp) {
|
package/dist/remote/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as LIB_VERSION } from "../version-
|
|
1
|
+
import { t as LIB_VERSION } from "../version-DRbb_jh2.js";
|
|
2
2
|
import { D as channelThrough, L as isProto, O as errorFrame$1, S as json1Channel, W as lowBand, a as remoteClient, k as errorReason$1, n as WebSocketTransport, o as pumpOutput, p as StreamStore, r as readParts, s as stderrSink, u as serveRemoteActor, y as VERSION } from "../websocket-Dnorztuc.js";
|
|
3
3
|
import { chmod, mkdir, mkdtemp, open, readFile, rm, stat, unlink } from "node:fs/promises";
|
|
4
4
|
import { execFile, spawn } from "node:child_process";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/version.ts
|
|
2
2
|
/** posipaki's release version. Must equal package.json's `version`. */
|
|
3
|
-
const LIB_VERSION = "0.
|
|
3
|
+
const LIB_VERSION = "0.47.0";
|
|
4
4
|
//#endregion
|
|
5
5
|
export { LIB_VERSION as t };
|
|
6
6
|
|
|
7
|
-
//# sourceMappingURL=version-
|
|
7
|
+
//# sourceMappingURL=version-DRbb_jh2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-
|
|
1
|
+
{"version":3,"file":"version-DRbb_jh2.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["// ── Library identity ───────────────────────────────────────────────────────\n//\n// posipaki's own release version, as a plain inlined string. A consumer that\n// stages artifacts onto a host it knows nothing about has to name those\n// artifacts after which posipaki they speak, and the bundle that runs there has\n// no node_modules and no posipaki on disk — it can never read a file to find out.\n//\n// It is not the protocol version: that is `VERSION` in ./remote (`json.v1`), and\n// it does not move between releases. The two answer different questions.\n//\n// version.test.ts pins this to package.json, so a release that forgets to bump it\n// fails the suite rather than shipping a lie.\n\n/** posipaki's release version. Must equal package.json's `version`. */\nexport const LIB_VERSION = \"0.47.0\";\n"],"mappings":";;AAcA,MAAa,cAAc"}
|
package/dist/xfetch.d.ts
CHANGED
|
@@ -1,44 +1,55 @@
|
|
|
1
1
|
import { d as WithSender, n as ExitMessage, o as ProcessCtx } from "./types-U3NvKgpg.js";
|
|
2
2
|
import { t as Process } from "./process-eCAv2tIS.js";
|
|
3
3
|
//#region src/xfetch.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A fetch init, plus the deadline that is not in the standard.
|
|
6
|
+
*
|
|
7
|
+
* `timeout` is Bun's socket idle deadline: the request fails if the connection stays idle that long.
|
|
8
|
+
* Bun's default is five minutes, which a slow generation outlives; this is the only place a caller can
|
|
9
|
+
* say otherwise. On a runtime that does not know the field, `fetch` ignores it.
|
|
10
|
+
*/
|
|
11
|
+
type FetchInit = RequestInit & {
|
|
12
|
+
timeout?: number | boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Arguments for a fetch process: a URL, and the init the caller wants sent with it. */
|
|
15
|
+
type FetchArgs = {
|
|
16
|
+
url: URL;
|
|
17
|
+
init?: FetchInit;
|
|
18
|
+
};
|
|
4
19
|
/** State of an in-flight or completed fetch. */
|
|
5
|
-
type FetchState
|
|
20
|
+
type FetchState = {
|
|
6
21
|
code: "pending" | "loading" | "aborted" | "failed" | "ok";
|
|
7
|
-
|
|
22
|
+
/** The answer's body as text, whatever its content-type said. */
|
|
8
23
|
text: string | null;
|
|
9
24
|
status: number;
|
|
10
25
|
responseHeaders: Record<string, string>;
|
|
11
26
|
};
|
|
12
|
-
/** Arguments for a fetch process. */
|
|
13
|
-
type FetchArgs<T> = {
|
|
14
|
-
url: URL;
|
|
15
|
-
method?: "GET";
|
|
16
|
-
body?: undefined;
|
|
17
|
-
headers?: Record<string, string>;
|
|
18
|
-
} | {
|
|
19
|
-
url: URL;
|
|
20
|
-
method?: "POST" | "PUT" | "PATCH";
|
|
21
|
-
body: T;
|
|
22
|
-
headers?: Record<string, string>;
|
|
23
|
-
};
|
|
24
27
|
/** Messages emitted by a fetch process during its lifecycle. */
|
|
25
|
-
type FetchMessage
|
|
28
|
+
type FetchMessage = {
|
|
26
29
|
type: "OK";
|
|
27
|
-
|
|
28
|
-
text?: string | null;
|
|
30
|
+
text: string;
|
|
29
31
|
status: number;
|
|
30
32
|
responseHeaders: Record<string, string>;
|
|
31
33
|
} | {
|
|
32
|
-
type: "ERROR"
|
|
34
|
+
type: "ERROR";
|
|
35
|
+
/** What went wrong, in the words of whatever threw: `socket hang up`, `The operation timed out.` */
|
|
36
|
+
reason: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: "LOADING" | "ABORTED" | "STOP";
|
|
33
39
|
} | ExitMessage;
|
|
34
40
|
/** A process that performs an HTTP fetch. */
|
|
35
|
-
type FetchProcess
|
|
41
|
+
type FetchProcess = Process<FetchArgs, FetchState, FetchMessage, FetchMessage>;
|
|
36
42
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
43
|
+
* Fetch, as a process.
|
|
44
|
+
*
|
|
45
|
+
* A pipe and nothing more: the init is handed to `fetch` untouched, the answer's body comes back as
|
|
46
|
+
* text with its status and headers, and a failure carries its cause. It parses nothing, shapes no
|
|
47
|
+
* request, and imposes no deadline of its own.
|
|
48
|
+
*
|
|
49
|
+
* It is a process because a request may run for minutes: the caller's loop must stay able to hear
|
|
50
|
+
* HEARTBEAT and STOP while it waits, and `STOP` aborts the request through the signal below.
|
|
40
51
|
*/
|
|
41
|
-
declare function xfetch
|
|
52
|
+
declare function xfetch({ pname, toParent, sendSelf }: ProcessCtx<FetchArgs, FetchState, FetchMessage, FetchMessage>, { url, init }: FetchArgs): Generator<FetchState | null, void, WithSender<FetchMessage>>;
|
|
42
53
|
//#endregion
|
|
43
|
-
export { FetchArgs, FetchMessage, FetchProcess, FetchState, xfetch };
|
|
54
|
+
export { FetchArgs, FetchInit, FetchMessage, FetchProcess, FetchState, xfetch };
|
|
44
55
|
//# sourceMappingURL=xfetch.d.ts.map
|
package/dist/xfetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xfetch.d.ts","names":[],"sources":["../src/xfetch.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"xfetch.d.ts","names":[],"sources":["../src/xfetch.ts"],"mappings":";;;;;;;;;;KAaY,YAAY;EACtB;;;KAIU;EACV,KAAK;EACL,OAAO;;;KAIG;EACV;;EAEA;EACA;EACA,iBAAiB;;;KAIP;EAEN;EACA;EACA;EACA,iBAAiB;;EAGjB;;EAEA;;EAEA;IACF;;KAGQ,eAAe,QAAQ,WAAW,YAAY,cAAc;;;;;;;;;;;iBA+B9D,SAEN,OACA,UACA,YACC,WAAW,WAAW,YAAY,cAAc,iBACjD,KAAK,QAAQ,YACd,UAAU,yBAAyB,WAAW"}
|
package/dist/xfetch.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { i as runDispatch } from "./util-Brtfgv68.js";
|
|
2
2
|
//#region src/xfetch.ts
|
|
3
|
-
function isJsonHelper(res) {
|
|
4
|
-
return res.headers.get("content-type") === "application/json";
|
|
5
|
-
}
|
|
6
3
|
/** Convert a Headers object to a plain Record. */
|
|
7
4
|
function headersToRecord(h) {
|
|
8
5
|
const out = {};
|
|
@@ -11,57 +8,52 @@ function headersToRecord(h) {
|
|
|
11
8
|
});
|
|
12
9
|
return out;
|
|
13
10
|
}
|
|
11
|
+
/** The cause of a failure, in words. A bare word is what made a 300 s deadline look like a network fault. */
|
|
12
|
+
function reasonOf(e) {
|
|
13
|
+
if (e instanceof Error) return e.message || e.name;
|
|
14
|
+
return String(e);
|
|
15
|
+
}
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
17
|
+
* Fetch, as a process.
|
|
18
|
+
*
|
|
19
|
+
* A pipe and nothing more: the init is handed to `fetch` untouched, the answer's body comes back as
|
|
20
|
+
* text with its status and headers, and a failure carries its cause. It parses nothing, shapes no
|
|
21
|
+
* request, and imposes no deadline of its own.
|
|
22
|
+
*
|
|
23
|
+
* It is a process because a request may run for minutes: the caller's loop must stay able to hear
|
|
24
|
+
* HEARTBEAT and STOP while it waits, and `STOP` aborts the request through the signal below.
|
|
18
25
|
*/
|
|
19
|
-
function* xfetch({ pname, toParent, sendSelf }, {
|
|
26
|
+
function* xfetch({ pname, toParent, sendSelf }, { url, init }) {
|
|
20
27
|
const state = {
|
|
21
28
|
code: "pending",
|
|
22
|
-
data: null,
|
|
23
29
|
text: null,
|
|
24
30
|
status: 0,
|
|
25
31
|
responseHeaders: {}
|
|
26
32
|
};
|
|
27
33
|
yield state;
|
|
28
34
|
const controller = new AbortController();
|
|
29
|
-
const signal = controller.signal;
|
|
30
35
|
const toSelf = sendSelf;
|
|
31
36
|
(async function doRequest() {
|
|
32
37
|
try {
|
|
33
38
|
toSelf({ type: "LOADING" });
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const requestInit = {
|
|
40
|
+
...init,
|
|
41
|
+
signal: controller.signal
|
|
42
|
+
};
|
|
43
|
+
const res = await fetch(url.href, requestInit);
|
|
44
|
+
const text = await res.text();
|
|
45
|
+
toSelf({
|
|
46
|
+
type: "OK",
|
|
47
|
+
text,
|
|
48
|
+
status: res.status,
|
|
49
|
+
responseHeaders: headersToRecord(res.headers)
|
|
42
50
|
});
|
|
43
|
-
const status = res.status;
|
|
44
|
-
const responseHeaders = headersToRecord(res.headers);
|
|
45
|
-
if (isJsonHelper(res)) {
|
|
46
|
-
const data = await res.json();
|
|
47
|
-
toSelf({
|
|
48
|
-
type: "OK",
|
|
49
|
-
data,
|
|
50
|
-
status,
|
|
51
|
-
responseHeaders
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
const text = await res.text();
|
|
55
|
-
toSelf({
|
|
56
|
-
type: "OK",
|
|
57
|
-
text,
|
|
58
|
-
status,
|
|
59
|
-
responseHeaders
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
51
|
} catch (e) {
|
|
63
52
|
if (e instanceof DOMException && e.name === "AbortError") toSelf({ type: "ABORTED" });
|
|
64
|
-
else toSelf({
|
|
53
|
+
else toSelf({
|
|
54
|
+
type: "ERROR",
|
|
55
|
+
reason: reasonOf(e)
|
|
56
|
+
});
|
|
65
57
|
}
|
|
66
58
|
})();
|
|
67
59
|
const isDone = () => !(state.code === "pending" || state.code === "loading");
|
|
@@ -80,8 +72,7 @@ function* xfetch({ pname, toParent, sendSelf }, { method = "GET", url, body, hea
|
|
|
80
72
|
if (msg.type === "OK") {
|
|
81
73
|
toParent(msg);
|
|
82
74
|
state.code = "ok";
|
|
83
|
-
state.
|
|
84
|
-
state.text = msg.text || null;
|
|
75
|
+
state.text = msg.text;
|
|
85
76
|
state.status = msg.status;
|
|
86
77
|
state.responseHeaders = msg.responseHeaders;
|
|
87
78
|
}
|
package/dist/xfetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xfetch.js","names":[],"sources":["../src/xfetch.ts"],"sourcesContent":["import { runDispatch } from \"./util.js\";\nimport type { ExitMessage, WithSender, ProcessCtx } from \"./types.js\";\nimport type { Process } from \"./process.js\";\n\n// ---- types ------------------------------------------------------------------\n\n
|
|
1
|
+
{"version":3,"file":"xfetch.js","names":[],"sources":["../src/xfetch.ts"],"sourcesContent":["import { runDispatch } from \"./util.js\";\nimport type { ExitMessage, WithSender, ProcessCtx } from \"./types.js\";\nimport type { Process } from \"./process.js\";\n\n// ---- types ------------------------------------------------------------------\n\n/**\n * A fetch init, plus the deadline that is not in the standard.\n *\n * `timeout` is Bun's socket idle deadline: the request fails if the connection stays idle that long.\n * Bun's default is five minutes, which a slow generation outlives; this is the only place a caller can\n * say otherwise. On a runtime that does not know the field, `fetch` ignores it.\n */\nexport type FetchInit = RequestInit & {\n timeout?: number | boolean;\n};\n\n/** Arguments for a fetch process: a URL, and the init the caller wants sent with it. */\nexport type FetchArgs = {\n url: URL;\n init?: FetchInit;\n};\n\n/** State of an in-flight or completed fetch. */\nexport type FetchState = {\n code: \"pending\" | \"loading\" | \"aborted\" | \"failed\" | \"ok\";\n /** The answer's body as text, whatever its content-type said. */\n text: string | null;\n status: number;\n responseHeaders: Record<string, string>;\n};\n\n/** Messages emitted by a fetch process during its lifecycle. */\nexport type FetchMessage =\n | {\n type: \"OK\";\n text: string;\n status: number;\n responseHeaders: Record<string, string>;\n }\n | {\n type: \"ERROR\";\n /** What went wrong, in the words of whatever threw: `socket hang up`, `The operation timed out.` */\n reason: string;\n }\n | { type: \"LOADING\" | \"ABORTED\" | \"STOP\" }\n | ExitMessage;\n\n/** A process that performs an HTTP fetch. */\nexport type FetchProcess = Process<FetchArgs, FetchState, FetchMessage, FetchMessage>;\n\n// ---- helpers ----------------------------------------------------------------\n\n/** Convert a Headers object to a plain Record. */\nfunction headersToRecord(h: Headers): Record<string, string> {\n const out: Record<string, string> = {};\n h.forEach((v, k) => {\n out[k] = v;\n });\n return out;\n}\n\n/** The cause of a failure, in words. A bare word is what made a 300 s deadline look like a network fault. */\nfunction reasonOf(e: unknown): string {\n if (e instanceof Error) return e.message || e.name;\n return String(e);\n}\n\n// ---- xfetch -----------------------------------------------------------------\n\n/**\n * Fetch, as a process.\n *\n * A pipe and nothing more: the init is handed to `fetch` untouched, the answer's body comes back as\n * text with its status and headers, and a failure carries its cause. It parses nothing, shapes no\n * request, and imposes no deadline of its own.\n *\n * It is a process because a request may run for minutes: the caller's loop must stay able to hear\n * HEARTBEAT and STOP while it waits, and `STOP` aborts the request through the signal below.\n */\nfunction* xfetch(\n {\n pname,\n toParent,\n sendSelf,\n }: ProcessCtx<FetchArgs, FetchState, FetchMessage, FetchMessage>,\n { url, init }: FetchArgs,\n): Generator<FetchState | null, void, WithSender<FetchMessage>> {\n const state: FetchState = {\n code: \"pending\",\n text: null,\n status: 0,\n responseHeaders: {},\n };\n yield state;\n\n const controller = new AbortController();\n const toSelf = sendSelf;\n\n (async function doRequest() {\n try {\n toSelf({ type: \"LOADING\" });\n // Our signal wins: the caller's STOP has to be able to abort whatever was sent.\n const requestInit: FetchInit = { ...init, signal: controller.signal };\n const res: Response = await fetch(url.href, requestInit);\n const text = await res.text();\n toSelf({\n type: \"OK\",\n text,\n status: res.status,\n responseHeaders: headersToRecord(res.headers),\n });\n } catch (e) {\n if (e instanceof DOMException && e.name === \"AbortError\") {\n toSelf({ type: \"ABORTED\" });\n } else {\n toSelf({ type: \"ERROR\", reason: reasonOf(e) });\n }\n }\n })();\n\n const isDone = (): boolean => !(state.code === \"pending\" || state.code === \"loading\");\n\n yield* runDispatch<WithSender<FetchMessage>>(\n pname,\n (maybe: WithSender<FetchMessage>) => {\n const [msg, _sender] = maybe;\n if (msg.type === \"STOP\") {\n controller.abort();\n }\n if (msg.type === \"ABORTED\") {\n toParent(msg);\n state.code = \"aborted\";\n }\n if (msg.type === \"ERROR\") {\n toParent(msg);\n state.code = \"failed\";\n }\n if (msg.type === \"LOADING\") {\n state.code = \"loading\";\n }\n if (msg.type === \"OK\") {\n toParent(msg);\n state.code = \"ok\";\n state.text = msg.text;\n state.status = msg.status;\n state.responseHeaders = msg.responseHeaders;\n }\n },\n isDone,\n false,\n );\n}\n\nexport { xfetch };\n"],"mappings":";;;AAsDA,SAAS,gBAAgB,GAAoC;CAC3D,MAAM,MAA8B,CAAC;CACrC,EAAE,SAAS,GAAG,MAAM;EAClB,IAAI,KAAK;CACX,CAAC;CACD,OAAO;AACT;;AAGA,SAAS,SAAS,GAAoB;CACpC,IAAI,aAAa,OAAO,OAAO,EAAE,WAAW,EAAE;CAC9C,OAAO,OAAO,CAAC;AACjB;;;;;;;;;;;AAcA,UAAU,OACR,EACE,OACA,UACA,YAEF,EAAE,KAAK,QACuD;CAC9D,MAAM,QAAoB;EACxB,MAAM;EACN,MAAM;EACN,QAAQ;EACR,iBAAiB,CAAC;CACpB;CACA,MAAM;CAEN,MAAM,aAAa,IAAI,gBAAgB;CACvC,MAAM,SAAS;CAEf,CAAC,eAAe,YAAY;EAC1B,IAAI;GACF,OAAO,EAAE,MAAM,UAAU,CAAC;GAE1B,MAAM,cAAyB;IAAE,GAAG;IAAM,QAAQ,WAAW;GAAO;GACpE,MAAM,MAAgB,MAAM,MAAM,IAAI,MAAM,WAAW;GACvD,MAAM,OAAO,MAAM,IAAI,KAAK;GAC5B,OAAO;IACL,MAAM;IACN;IACA,QAAQ,IAAI;IACZ,iBAAiB,gBAAgB,IAAI,OAAO;GAC9C,CAAC;EACH,SAAS,GAAG;GACV,IAAI,aAAa,gBAAgB,EAAE,SAAS,cAC1C,OAAO,EAAE,MAAM,UAAU,CAAC;QAE1B,OAAO;IAAE,MAAM;IAAS,QAAQ,SAAS,CAAC;GAAE,CAAC;EAEjD;CACF,EAAA,CAAG;CAEH,MAAM,eAAwB,EAAE,MAAM,SAAS,aAAa,MAAM,SAAS;CAE3E,OAAO,YACL,QACC,UAAoC;EACnC,MAAM,CAAC,KAAK,WAAW;EACvB,IAAI,IAAI,SAAS,QACf,WAAW,MAAM;EAEnB,IAAI,IAAI,SAAS,WAAW;GAC1B,SAAS,GAAG;GACZ,MAAM,OAAO;EACf;EACA,IAAI,IAAI,SAAS,SAAS;GACxB,SAAS,GAAG;GACZ,MAAM,OAAO;EACf;EACA,IAAI,IAAI,SAAS,WACf,MAAM,OAAO;EAEf,IAAI,IAAI,SAAS,MAAM;GACrB,SAAS,GAAG;GACZ,MAAM,OAAO;GACb,MAAM,OAAO,IAAI;GACjB,MAAM,SAAS,IAAI;GACnB,MAAM,kBAAkB,IAAI;EAC9B;CACF,GACA,QACA,KACF;AACF"}
|