posipaki 0.41.0 → 0.42.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/index.d.ts +17 -41
- package/dist/remote/index.d.ts.map +1 -1
- package/dist/remote/index.js +24 -55
- package/dist/remote/index.js.map +1 -1
- package/dist/remote/node.d.ts +134 -3
- package/dist/remote/node.d.ts.map +1 -1
- package/dist/remote/node.js +374 -27
- package/dist/remote/node.js.map +1 -1
- package/dist/{version-CYQgj_GV.js → version-DnLiQ9Q-.js} +2 -2
- package/dist/{version-CYQgj_GV.js.map → version-DnLiQ9Q-.js.map} +1 -1
- package/dist/websocket-BYNYSi7b.d.ts +226 -0
- package/dist/websocket-BYNYSi7b.d.ts.map +1 -0
- package/dist/{json1-BWi4HzI4.js → websocket-DttBoCRL.js} +277 -59
- package/dist/websocket-DttBoCRL.js.map +1 -0
- package/package.json +1 -1
- package/dist/client-GrwWOUBV.d.ts +0 -93
- package/dist/client-GrwWOUBV.d.ts.map +0 -1
- package/dist/json1-BWi4HzI4.js.map +0 -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.42.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-C_-NpMFX.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-D7c9vn6S.js";
|
|
5
|
-
import { t as LIB_VERSION } from "./version-
|
|
5
|
+
import { t as LIB_VERSION } from "./version-DnLiQ9Q-.js";
|
|
6
6
|
//#region src/process.ts
|
|
7
7
|
/** @deprecated Use {@link spawnAsync} instead. */
|
|
8
8
|
function spawn(fn, pname, tp) {
|
package/dist/remote/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { i as Message, s as SenderInfo } from "../types-DYd-DDFB.js";
|
|
2
|
-
import { l as
|
|
3
|
-
import { S as isStop, _ as isPause, a as Channel, b as isResume, c as badFrame, d as errorReason, f as isBad, g as isMsg, h as isInit, i as BAD_PREFIX_LIMIT, l as badReason, m as isExit, n as ClientSpawner, o as StreamKind, p as isError, r as remoteClient, s as StringTransport, t as CHANNEL_LOST, u as errorFrame, v as isProto, x as isState, y as isRelease } from "../client-GrwWOUBV.js";
|
|
2
|
+
import { A as isError, C as StreamKind, D as errorFrame, E as badReason, F as isProto, I as isRelease, L as isResume, M as isInit, N as isMsg, O as errorReason, P as isPause, R as isState, S as Channel, T as badFrame, _ as Init, a as ClientSpawner, b as Spawner, c as Connection, d as ReactorOptions, f as Session, g as serveRemoteActor, h as reactor, i as CHANNEL_LOST, j as isExit, k as isBad, l as Listener, m as oneConnection, n as WebSocketLike, o as remoteClient, p as SessionFactory, r as WebSocketTransport, s as AnyActorDefinition, t as WS_OPEN, u as Reactor, v as Served, w as StringTransport, x as BAD_PREFIX_LIMIT, y as ServedProcess, z as isStop } from "../websocket-BYNYSi7b.js";
|
|
4
3
|
//#region src/remote/remote-process.d.ts
|
|
5
4
|
interface RemoteExit {
|
|
6
5
|
code: number;
|
|
@@ -229,10 +228,6 @@ type IdParity = "odd" | "even";
|
|
|
229
228
|
* build can hold two copies of the class. */
|
|
230
229
|
declare function isRemoteProcess(value: unknown): value is RemoteProcess;
|
|
231
230
|
//#endregion
|
|
232
|
-
//#region src/remote/server.d.ts
|
|
233
|
-
type Spawner = () => Promise<Channel>;
|
|
234
|
-
declare function serveRemoteActor<Args, State, InMsg extends Message, OutMsg extends Message, R extends ReflectionOptions>(actor: ActorDefinition<Args, State, InMsg, OutMsg, R>, spawner: Spawner): Promise<void>;
|
|
235
|
-
//#endregion
|
|
236
231
|
//#region src/remote/sender.d.ts
|
|
237
232
|
declare function makeSender(fromName: string, parentName: string | null, parentId: symbol | null): SenderInfo;
|
|
238
233
|
//#endregion
|
|
@@ -247,38 +242,6 @@ declare function decode(str: string): Record<string, unknown>;
|
|
|
247
242
|
declare function readFrame(str: string): Record<string, unknown>;
|
|
248
243
|
declare function json1Channel(transport: StringTransport): Channel;
|
|
249
244
|
//#endregion
|
|
250
|
-
//#region src/remote/transports/websocket.d.ts
|
|
251
|
-
/**
|
|
252
|
-
* The subset of a WebSocket the transport needs. The WHATWG client WebSocket
|
|
253
|
-
* (Node, Bun, browsers) satisfies this directly; a Bun server socket is adapted
|
|
254
|
-
* by the consumer (see spawners/ws-server.ts).
|
|
255
|
-
*/
|
|
256
|
-
interface WebSocketLike {
|
|
257
|
-
send(data: string): void;
|
|
258
|
-
close(code?: number, reason?: string): void;
|
|
259
|
-
readonly readyState: number;
|
|
260
|
-
onmessage: ((event: {
|
|
261
|
-
data: unknown;
|
|
262
|
-
}) => void) | null;
|
|
263
|
-
onclose: (() => void) | null;
|
|
264
|
-
}
|
|
265
|
-
/** WHATWG WebSocket readyState: OPEN. */
|
|
266
|
-
declare const WS_OPEN = 1;
|
|
267
|
-
declare class WebSocketTransport implements StringTransport {
|
|
268
|
-
private ws;
|
|
269
|
-
private pvtOnMessage;
|
|
270
|
-
private pvtOnClose;
|
|
271
|
-
private closed;
|
|
272
|
-
constructor(ws: WebSocketLike);
|
|
273
|
-
get canSend(): boolean;
|
|
274
|
-
onMessage(handler: (frame: string) => void): void;
|
|
275
|
-
removeHandler(): ((frame: string) => void) | null;
|
|
276
|
-
onClose(handler: () => void): void;
|
|
277
|
-
get hasHandler(): boolean;
|
|
278
|
-
send(frame: string): Promise<void>;
|
|
279
|
-
close(): Promise<void>;
|
|
280
|
-
}
|
|
281
|
-
//#endregion
|
|
282
245
|
//#region src/remote/transports/worker.d.ts
|
|
283
246
|
/** The worker encoding: native structured clone (no JSON). */
|
|
284
247
|
declare const WORKER_VERSION = "clone.v1";
|
|
@@ -311,7 +274,8 @@ declare class WorkerTransport implements Channel {
|
|
|
311
274
|
}
|
|
312
275
|
//#endregion
|
|
313
276
|
//#region src/remote/spawners/ws-client.d.ts
|
|
314
|
-
|
|
277
|
+
/** The socket the spawner needs: what the transport reads and writes, and the open/error slots. */
|
|
278
|
+
type OpenedWebSocket = {
|
|
315
279
|
readonly readyState: number;
|
|
316
280
|
send(data: string): void;
|
|
317
281
|
close(code?: number, reason?: string): void;
|
|
@@ -322,7 +286,19 @@ type WebSocketCtor = new (url: string) => {
|
|
|
322
286
|
}) => void) | null;
|
|
323
287
|
onclose: (() => void) | null;
|
|
324
288
|
};
|
|
325
|
-
|
|
289
|
+
type WebSocketCtor = new (url: string) => OpenedWebSocket;
|
|
290
|
+
/**
|
|
291
|
+
* How a socket is opened when a constructor is not enough: the URL to open, and the arguments this
|
|
292
|
+
* spawn was called with. A per-tenant header, a bearer token, an authority the machine does not
|
|
293
|
+
* already know — each of them is a fact about the connection, and each of them is the caller's to
|
|
294
|
+
* express in its own runtime's shape rather than in one posipaki was taught.
|
|
295
|
+
*/
|
|
296
|
+
type WebSocketOpener<Args = unknown> = (url: string, args: Args) => OpenedWebSocket;
|
|
297
|
+
interface WebSocketClientOptions<Args = unknown> {
|
|
298
|
+
/** Opens the socket. Given, it replaces the constructor. */
|
|
299
|
+
open?: WebSocketOpener<Args>;
|
|
300
|
+
}
|
|
301
|
+
declare function wsClientSpawner<Args = unknown>(url: string | ((args: Args) => string), WebSocketImpl?: WebSocketCtor, opts?: WebSocketClientOptions<Args>): ClientSpawner<Args>;
|
|
326
302
|
//#endregion
|
|
327
303
|
//#region src/remote/spawners/ws-server.d.ts
|
|
328
304
|
declare function wsServerSpawner(ws: WebSocketLike): Spawner;
|
|
@@ -366,5 +342,5 @@ declare function workerClientSpawner<Args = unknown>(url: string | ((args: Args)
|
|
|
366
342
|
//#region src/remote/spawners/worker-self.d.ts
|
|
367
343
|
declare function workerSelfSpawner(selfScope?: WorkerLike): Spawner;
|
|
368
344
|
//#endregion
|
|
369
|
-
export { BAD_PREFIX_LIMIT, type BunServerWebSocketLike, CHANNEL_LOST, type Channel, type ClientSpawner, type FrameSink, PROCESS_REF, type ProcessRef, type RemoteMessage, RemoteProcess, type Spawner, type StringTransport, VERSION, WORKER_VERSION, WS_OPEN, type WebSocketCtor, type WebSocketLike, WebSocketTransport, type WorkerCtor, type WorkerLike, WorkerTransport, badFrame, badReason, bunServerWebSocket, decode, encode, errorFrame, errorReason, isBad, isError, isExit, isInit, isMsg, isPause, isProto, isRelease, isRemoteProcess, isResume, isState, isStop, json1Channel, makeSender, readFrame, remoteClient, rootIdFor, serveRemoteActor, workerClientSpawner, workerSelfSpawner, wsClientSpawner, wsServerSpawner };
|
|
345
|
+
export { type AnyActorDefinition, BAD_PREFIX_LIMIT, type BunServerWebSocketLike, CHANNEL_LOST, type Channel, type ClientSpawner, type Connection, type FrameSink, type Init, type Listener, type OpenedWebSocket, PROCESS_REF, type ProcessRef, type Reactor, type ReactorOptions, type RemoteMessage, RemoteProcess, type Served, type ServedProcess, type Session, type SessionFactory, type Spawner, type StringTransport, VERSION, WORKER_VERSION, WS_OPEN, type WebSocketClientOptions, type WebSocketCtor, type WebSocketLike, type WebSocketOpener, WebSocketTransport, type WorkerCtor, type WorkerLike, WorkerTransport, badFrame, badReason, bunServerWebSocket, decode, encode, errorFrame, errorReason, isBad, isError, isExit, isInit, isMsg, isPause, isProto, isRelease, isRemoteProcess, isResume, isState, isStop, json1Channel, makeSender, oneConnection, reactor, readFrame, remoteClient, rootIdFor, serveRemoteActor, workerClientSpawner, workerSelfSpawner, wsClientSpawner, wsServerSpawner };
|
|
370
346
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/remote/remote-process.ts","../../src/remote/process-ref.ts","../../src/remote/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/remote/remote-process.ts","../../src/remote/process-ref.ts","../../src/remote/sender.ts","../../src/remote/protocols/json1.ts","../../src/remote/transports/worker.ts","../../src/remote/spawners/ws-client.ts","../../src/remote/spawners/ws-server.ts","../../src/remote/spawners/worker-client.ts","../../src/remote/spawners/worker-self.ts"],"mappings":";;;UAyDiB;EACf;EACA;;;;;KAMU,aAAa,OAAO,yBAAyB,sBAAsB;;;KAInE,eAAe;;KAGf,cAAc,eAAe,UAAU,YAAY,KAAK,QAAQ;cAE/D,cAAc,cAAc,UAAU,SAAS,eAAe,UAAU;;WAE1E;;;WAGA,KAAK;;;WAGL;;EAET,OAAO;;WAEE,aAAa,mBAAmB,oBAAoB;UAErD;UACA;UACA;;;;UAIA;UACA;;UAEA;UACA;UACA;UACA;;UAEA;;;UAGA;;;UAGA;;;;UAIA;;;;;UAKA;EAER,YAAY,KAAK,YAAY,MAAM,WAAW,kBAAkB,QAAQ;;;;;;;;;;;EAmBxE;;;;;;EASA;;EAUA;;;;UAOQ;UAOA;;;;;;EAUR;;;;;;;EAWA;;;UAgBQ;;EAQR;;;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cnC;EACf,KAAK;EACL,MAAM,eAAe;WACZ;EACT;;;;;;;;;;;;;;;;;;;;;iBAsBc,mBAAmB,IAAI,yBAAyB;;;KCxCpD,kBAAkB,gBAAgB;iBAI9B,oBAAoB,gBAClC,gBAAgB,MAAM,kBACtB,aAAY,aACX,cAAc;;;iBCRD,kBAAkB,YAAW,aAAmD"}
|
package/dist/remote/index.js
CHANGED
|
@@ -1,54 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
//#region src/remote/transports/websocket.ts
|
|
3
|
-
/** WHATWG WebSocket readyState: OPEN. */
|
|
4
|
-
const WS_OPEN = 1;
|
|
5
|
-
var WebSocketTransport = class {
|
|
6
|
-
constructor(ws) {
|
|
7
|
-
this.pvtOnMessage = null;
|
|
8
|
-
this.pvtOnClose = null;
|
|
9
|
-
this.closed = false;
|
|
10
|
-
this.ws = ws;
|
|
11
|
-
ws.onmessage = (event) => {
|
|
12
|
-
if (this.pvtOnMessage && !this.closed) this.pvtOnMessage(String(event.data));
|
|
13
|
-
};
|
|
14
|
-
ws.onclose = () => {
|
|
15
|
-
this.closed = true;
|
|
16
|
-
this.pvtOnClose?.();
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
get canSend() {
|
|
20
|
-
return !this.closed && this.ws.readyState === 1;
|
|
21
|
-
}
|
|
22
|
-
onMessage(handler) {
|
|
23
|
-
if (this.closed) throw new Error("WebSocketTransport: closed");
|
|
24
|
-
if (this.pvtOnMessage !== null) throw new Error("WebSocketTransport: handler already set — call removeHandler() first");
|
|
25
|
-
this.pvtOnMessage = handler;
|
|
26
|
-
}
|
|
27
|
-
removeHandler() {
|
|
28
|
-
const prev = this.pvtOnMessage;
|
|
29
|
-
this.pvtOnMessage = null;
|
|
30
|
-
return prev;
|
|
31
|
-
}
|
|
32
|
-
onClose(handler) {
|
|
33
|
-
this.pvtOnClose = handler;
|
|
34
|
-
}
|
|
35
|
-
get hasHandler() {
|
|
36
|
-
return this.pvtOnMessage !== null;
|
|
37
|
-
}
|
|
38
|
-
async send(frame) {
|
|
39
|
-
if (this.closed) throw new Error("WebSocketTransport: closed");
|
|
40
|
-
if (this.ws.readyState !== 1) throw new Error("WebSocketTransport: not open");
|
|
41
|
-
this.ws.send(frame);
|
|
42
|
-
}
|
|
43
|
-
async close() {
|
|
44
|
-
if (this.closed) return;
|
|
45
|
-
this.closed = true;
|
|
46
|
-
try {
|
|
47
|
-
this.ws.close();
|
|
48
|
-
} catch {}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
//#endregion
|
|
1
|
+
import { A as isStop, C as isInit, D as isRelease, E as isProto, M as isRemoteProcess, N as rootIdFor, O as isResume, S as isExit, T as isPause, _ as badReason, a as oneConnection, b as isBad, c as makeSender, d as decode, f as encode, g as badFrame, h as BAD_PREFIX_LIMIT, i as remoteClient, j as PROCESS_REF, k as isState, l as RemoteProcess, m as readFrame, n as WebSocketTransport, o as reactor, p as json1Channel, r as CHANNEL_LOST, s as serveRemoteActor, t as WS_OPEN, u as VERSION, v as errorFrame, w as isMsg, x as isError, y as errorReason } from "../websocket-DttBoCRL.js";
|
|
52
2
|
//#region src/remote/transports/worker.ts
|
|
53
3
|
/** The worker encoding: native structured clone (no JSON). */
|
|
54
4
|
const WORKER_VERSION = "clone.v1";
|
|
@@ -98,16 +48,35 @@ var WorkerTransport = class {
|
|
|
98
48
|
//#endregion
|
|
99
49
|
//#region src/remote/spawners/ws-client.ts
|
|
100
50
|
const defaultWebSocket = globalThis.WebSocket;
|
|
51
|
+
/** What a socket failure says about itself.
|
|
52
|
+
*
|
|
53
|
+
* A WHATWG WebSocket reports an open failure as an ErrorEvent, and `String(event)` is
|
|
54
|
+
* `[object ErrorEvent]`: its type, its message and the underlying error are all in its
|
|
55
|
+
* own fields, so read those rather than stringify the event that carries them.
|
|
56
|
+
*/
|
|
57
|
+
function describeSocketError(err) {
|
|
58
|
+
if (typeof err !== "object" || err === null) return String(err);
|
|
59
|
+
const event = err;
|
|
60
|
+
const cause = event.error instanceof Error ? event.error.message : event.error;
|
|
61
|
+
const parts = [
|
|
62
|
+
event.type,
|
|
63
|
+
event.message,
|
|
64
|
+
cause
|
|
65
|
+
].filter((part) => typeof part === "string" && part.length > 0);
|
|
66
|
+
return parts.length > 0 ? parts.join(": ") : String(err);
|
|
67
|
+
}
|
|
101
68
|
function openWebSocket(ws) {
|
|
102
69
|
return new Promise((resolve, reject) => {
|
|
103
70
|
if (ws.readyState === 1) return resolve();
|
|
104
71
|
ws.onopen = () => resolve();
|
|
105
|
-
ws.onerror = (err) => reject(/* @__PURE__ */ new Error(`websocket failed to open: ${
|
|
72
|
+
ws.onerror = (err) => reject(/* @__PURE__ */ new Error(`websocket failed to open: ${describeSocketError(err)}`));
|
|
106
73
|
});
|
|
107
74
|
}
|
|
108
|
-
function wsClientSpawner(url, WebSocketImpl = defaultWebSocket) {
|
|
75
|
+
function wsClientSpawner(url, WebSocketImpl = defaultWebSocket, opts = {}) {
|
|
76
|
+
const open = opts.open ?? ((target) => new WebSocketImpl(target));
|
|
109
77
|
return async (args) => {
|
|
110
|
-
const
|
|
78
|
+
const target = typeof url === "function" ? url(args) : url;
|
|
79
|
+
const ws = open(target, args);
|
|
111
80
|
const transport = new WebSocketTransport(ws);
|
|
112
81
|
const channel = json1Channel(transport);
|
|
113
82
|
const protoPromise = new Promise((resolve) => {
|
|
@@ -181,6 +150,6 @@ function workerSelfSpawner(selfScope = globalThis) {
|
|
|
181
150
|
};
|
|
182
151
|
}
|
|
183
152
|
//#endregion
|
|
184
|
-
export { BAD_PREFIX_LIMIT, CHANNEL_LOST, PROCESS_REF, RemoteProcess, VERSION, WORKER_VERSION, WS_OPEN, WebSocketTransport, WorkerTransport, badFrame, badReason, bunServerWebSocket, decode, encode, errorFrame, errorReason, isBad, isError, isExit, isInit, isMsg, isPause, isProto, isRelease, isRemoteProcess, isResume, isState, isStop, json1Channel, makeSender, readFrame, remoteClient, rootIdFor, serveRemoteActor, workerClientSpawner, workerSelfSpawner, wsClientSpawner, wsServerSpawner };
|
|
153
|
+
export { BAD_PREFIX_LIMIT, CHANNEL_LOST, PROCESS_REF, RemoteProcess, VERSION, WORKER_VERSION, WS_OPEN, WebSocketTransport, WorkerTransport, badFrame, badReason, bunServerWebSocket, decode, encode, errorFrame, errorReason, isBad, isError, isExit, isInit, isMsg, isPause, isProto, isRelease, isRemoteProcess, isResume, isState, isStop, json1Channel, makeSender, oneConnection, reactor, readFrame, remoteClient, rootIdFor, serveRemoteActor, workerClientSpawner, workerSelfSpawner, wsClientSpawner, wsServerSpawner };
|
|
185
154
|
|
|
186
155
|
//# sourceMappingURL=index.js.map
|
package/dist/remote/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/remote/transports/websocket.ts","../../src/remote/transports/worker.ts","../../src/remote/spawners/ws-client.ts","../../src/remote/spawners/ws-server.ts","../../src/remote/spawners/worker-client.ts","../../src/remote/spawners/worker-self.ts"],"sourcesContent":["/* eslint-disable unicorn/prefer-add-event-listener */\n// ── WebSocket transport ─────────────────────────────────────────────────────────\n//\n// Message-boundary transport over a WebSocket. The socket's native framing means\n// one `send` is one frame — there is no delimiter to add or strip. It moves\n// encoded frames (strings); json1Channel sits above it and handles JSON.\n\nimport type { StringTransport } from \"../channel.js\";\n\n/**\n * The subset of a WebSocket the transport needs. The WHATWG client WebSocket\n * (Node, Bun, browsers) satisfies this directly; a Bun server socket is adapted\n * by the consumer (see spawners/ws-server.ts).\n */\nexport interface WebSocketLike {\n send(data: string): void;\n close(code?: number, reason?: string): void;\n readonly readyState: number;\n onmessage: ((event: { data: unknown }) => void) | null;\n onclose: (() => void) | null;\n}\n\n/** WHATWG WebSocket readyState: OPEN. */\nexport const WS_OPEN = 1;\n\nexport class WebSocketTransport implements StringTransport {\n private ws: WebSocketLike;\n private pvtOnMessage: ((frame: string) => void) | null = null;\n private pvtOnClose: (() => void) | null = null;\n private closed = false;\n\n constructor(ws: WebSocketLike) {\n this.ws = ws;\n ws.onmessage = (event) => {\n if (this.pvtOnMessage && !this.closed) this.pvtOnMessage(String(event.data));\n };\n ws.onclose = () => {\n this.closed = true;\n this.pvtOnClose?.();\n };\n }\n\n get canSend(): boolean {\n return !this.closed && this.ws.readyState === WS_OPEN;\n }\n\n onMessage(handler: (frame: string) => void): void {\n if (this.closed) throw new Error(\"WebSocketTransport: closed\");\n if (this.pvtOnMessage !== null) {\n throw new Error(\"WebSocketTransport: handler already set — call removeHandler() first\");\n }\n this.pvtOnMessage = handler;\n }\n\n removeHandler(): ((frame: string) => void) | null {\n const prev = this.pvtOnMessage;\n this.pvtOnMessage = null;\n return prev;\n }\n\n onClose(handler: () => void): void {\n this.pvtOnClose = handler;\n }\n\n get hasHandler(): boolean {\n return this.pvtOnMessage !== null;\n }\n\n async send(frame: string): Promise<void> {\n if (this.closed) throw new Error(\"WebSocketTransport: closed\");\n if (this.ws.readyState !== WS_OPEN) throw new Error(\"WebSocketTransport: not open\");\n this.ws.send(frame);\n }\n\n async close(): Promise<void> {\n if (this.closed) return;\n this.closed = true;\n try {\n this.ws.close();\n } catch {\n // already closing / closed — ignore\n }\n }\n}\n","/* eslint-disable unicorn/prefer-add-event-listener, unicorn/require-post-message-target-origin */\n// ── Worker transport ────────────────────────────────────────────────────────────\n//\n// Moves frame objects directly over postMessage. postMessage structured-clones\n// the frame object, so there is no JSON encode/decode — this transport implements\n// Channel directly (not StringTransport). Structured clone is the worker's\n// native encoding, named by WORKER_VERSION.\n\nimport type { Channel } from \"../channel.js\";\n\n/** The worker encoding: native structured clone (no JSON). */\nexport const WORKER_VERSION = \"clone.v1\";\n\n/**\n * The subset of a worker the transport needs. The main-thread `Worker` and the\n * worker-global `self` both satisfy it; `terminate` is present only on the\n * main-thread side.\n */\nexport interface WorkerLike {\n postMessage(data: unknown): void;\n onmessage: ((event: { data: unknown }) => void) | null;\n onerror?: ((event: unknown) => void) | null;\n terminate?(): void;\n}\n\nexport class WorkerTransport implements Channel {\n private worker: WorkerLike;\n private pvtOnMessage: ((frame: Record<string, unknown>) => void) | null = null;\n private pvtOnClose: (() => void) | null = null;\n private closed = false;\n\n constructor(worker: WorkerLike) {\n this.worker = worker;\n worker.onmessage = (event) => {\n if (this.pvtOnMessage && !this.closed) {\n this.pvtOnMessage(event.data as Record<string, unknown>);\n }\n };\n // An uncaught error in the worker is the closest thing to an abrupt drop.\n if (\"onerror\" in worker) {\n worker.onerror = () => {\n this.closed = true;\n this.pvtOnClose?.();\n };\n }\n }\n\n get canSend(): boolean {\n return !this.closed;\n }\n\n onMessage(handler: (frame: Record<string, unknown>) => void): void {\n if (this.closed) throw new Error(\"WorkerTransport: closed\");\n if (this.pvtOnMessage !== null) {\n throw new Error(\"WorkerTransport: handler already set — call removeHandler() first\");\n }\n this.pvtOnMessage = handler;\n }\n\n removeHandler(): ((frame: Record<string, unknown>) => void) | null {\n const prev = this.pvtOnMessage;\n this.pvtOnMessage = null;\n return prev;\n }\n\n onClose(handler: () => void): void {\n this.pvtOnClose = handler;\n }\n\n get hasHandler(): boolean {\n return this.pvtOnMessage !== null;\n }\n\n async send(frame: Record<string, unknown>): Promise<void> {\n if (this.closed) throw new Error(\"WorkerTransport: closed\");\n this.worker.postMessage(frame);\n }\n\n async close(): Promise<void> {\n if (this.closed) return;\n this.closed = true;\n this.worker.terminate?.();\n }\n}\n","/* eslint-disable unicorn/prefer-add-event-listener */\n// ── WebSocket client spawner ────────────────────────────────────────────────────\n//\n// Environment-specific: connects to a `ws://` URL with the WHATWG WebSocket,\n// wraps it in a WebSocketTransport, and returns a frame Channel with the $proto\n// handshake already validated.\n\nimport { WebSocketTransport } from \"../transports/websocket.js\";\nimport { json1Channel, VERSION } from \"../protocols/json1.js\";\nimport { isProto } from \"../channel.js\";\nimport type { ClientSpawner } from \"../client.js\";\n\nexport type WebSocketCtor = new (url: string) => {\n readonly readyState: number;\n send(data: string): void;\n close(code?: number, reason?: string): void;\n onopen: (() => void) | null;\n onerror: ((err: unknown) => void) | null;\n onmessage: ((event: { data: unknown }) => void) | null;\n onclose: (() => void) | null;\n};\n\nconst defaultWebSocket = (globalThis as { WebSocket?: WebSocketCtor }).WebSocket;\n\nfunction openWebSocket(ws: { readonly readyState: number; onopen: (() => void) | null; onerror: ((err: unknown) => void) | null }): Promise<void> {\n return new Promise((resolve, reject) => {\n if (ws.readyState === 1 /* OPEN */) return resolve();\n ws.onopen = () => resolve();\n ws.onerror = (err) => reject(new Error(`websocket failed to open: ${String(err)}`));\n });\n}\n\nexport function wsClientSpawner<Args = unknown>(\n url: string | ((args: Args) => string),\n WebSocketImpl: WebSocketCtor = defaultWebSocket as WebSocketCtor,\n): ClientSpawner<Args> {\n return async (args) => {\n const target = typeof url === \"function\" ? url(args) : url;\n const ws = new WebSocketImpl(target);\n const transport = new WebSocketTransport(ws);\n const channel = json1Channel(transport);\n\n // Set the $proto waiter before awaiting open so a fast server's handshake\n // frame is not dropped.\n const protoPromise = new Promise<Record<string, unknown>>((resolve) => {\n channel.onMessage((frame) => resolve(frame));\n });\n await openWebSocket(ws);\n const protoFrame = await protoPromise;\n channel.removeHandler();\n\n if (!isProto(protoFrame) || protoFrame.$proto !== VERSION) {\n throw new Error(`unsupported protocol: ${JSON.stringify(protoFrame).slice(0, 50)}`);\n }\n return channel;\n };\n}\n","// ── WebSocket server spawner ────────────────────────────────────────────────────\n//\n// Environment-specific: serves an already-upgraded WebSocket connection. The\n// consumer's HTTP server does the upgrade and hands us the socket; we wrap it in\n// a WebSocketTransport, send $proto, and return the frame Channel.\n\nimport { WebSocketTransport, type WebSocketLike } from \"../transports/websocket.js\";\nimport { json1Channel, VERSION } from \"../protocols/json1.js\";\nimport type { Spawner } from \"../server.js\";\n\nexport function wsServerSpawner(ws: WebSocketLike): Spawner {\n return async () => {\n const channel = json1Channel(new WebSocketTransport(ws));\n await channel.send({ $proto: VERSION });\n return channel;\n };\n}\n\n/**\n * A minimal Bun `ServerWebSocket` — `send`/`close`/`readyState` plus the data\n * slot the server uses to stash per-connection state. Bun delivers message and\n * close events through the `Bun.serve` websocket config callbacks, not through\n * properties on the socket, so the consumer routes them onto the adapter.\n */\nexport interface BunServerWebSocketLike {\n send(data: string): void;\n close(code?: number, reason?: string): void;\n readonly readyState: number;\n data?: unknown;\n}\n\n/**\n * Adapt a Bun server socket to the `WebSocketLike` the transport consumes. The\n * returned adapter owns settable `onmessage`/`onclose` slots; the consumer\n * routes Bun's `message`/`close` config callbacks into them, e.g.:\n *\n * ```ts\n * Bun.serve({\n * websocket: {\n * open(ws) {\n * const adapter = bunServerWebSocket(ws);\n * ws.data = adapter;\n * serveRemoteActor(actor, wsServerSpawner(adapter));\n * },\n * message(ws, msg) { (ws.data as WebSocketLike).onmessage?.({ data: msg }); },\n * close(ws) { (ws.data as WebSocketLike).onclose?.(); },\n * },\n * });\n * ```\n */\nexport function bunServerWebSocket(ws: BunServerWebSocketLike): WebSocketLike {\n return {\n send: (data) => ws.send(data),\n close: (code, reason) => ws.close(code, reason),\n readyState: ws.readyState,\n onmessage: null,\n onclose: null,\n };\n}\n","// ── Worker client spawner (command) ─────────────────────────────────────────────\n//\n// Environment-specific: spawns a Worker with the WHATWG `new Worker(url)` API,\n// wraps it in a WorkerTransport, and returns a frame Channel with the $proto\n// handshake already validated.\n\nimport { WorkerTransport, WORKER_VERSION, type WorkerLike } from \"../transports/worker.js\";\nimport { isProto } from \"../channel.js\";\nimport type { ClientSpawner } from \"../client.js\";\n\nexport type WorkerCtor = new (url: string) => WorkerLike;\n\nconst defaultWorker = (globalThis as { Worker?: WorkerCtor }).Worker;\n\nexport function workerClientSpawner<Args = unknown>(\n url: string | ((args: Args) => string),\n WorkerImpl: WorkerCtor = defaultWorker as WorkerCtor,\n): ClientSpawner<Args> {\n return async (args) => {\n const target = typeof url === \"function\" ? url(args) : url;\n const channel = new WorkerTransport(new WorkerImpl(target));\n\n const protoFrame = await new Promise<Record<string, unknown>>((resolve) => {\n channel.onMessage((frame) => resolve(frame));\n });\n channel.removeHandler();\n\n if (!isProto(protoFrame) || protoFrame.$proto !== WORKER_VERSION) {\n throw new Error(`unsupported protocol: ${JSON.stringify(protoFrame).slice(0, 50)}`);\n }\n return channel;\n };\n}\n","// ── Worker server spawner (self) ────────────────────────────────────────────────\n//\n// Environment-specific: serves the worker-global scope (`self`) as a frame\n// Channel with the $proto handshake already sent. The worker entry script calls\n// `serveRemoteActor(actor, workerSelfSpawner())`.\n\nimport { WorkerTransport, WORKER_VERSION, type WorkerLike } from \"../transports/worker.js\";\nimport type { Spawner } from \"../server.js\";\n\nexport function workerSelfSpawner(selfScope: WorkerLike = globalThis as unknown as WorkerLike): Spawner {\n return async () => {\n const channel = new WorkerTransport(selfScope);\n await channel.send({ $proto: WORKER_VERSION });\n return channel;\n };\n}\n"],"mappings":";;;AAuBA,MAAa,UAAU;AAEvB,IAAa,qBAAb,MAA2D;CAMzD,YAAY,IAAmB;EAJ0B,KAAA,eAAA;EACf,KAAA,aAAA;EACzB,KAAA,SAAA;EAGf,KAAK,KAAK;EACV,GAAG,aAAa,UAAU;GACxB,IAAI,KAAK,gBAAgB,CAAC,KAAK,QAAQ,KAAK,aAAa,OAAO,MAAM,IAAI,CAAC;EAC7E;EACA,GAAG,gBAAgB;GACjB,KAAK,SAAS;GACd,KAAK,aAAa;EACpB;CACF;CAEA,IAAI,UAAmB;EACrB,OAAO,CAAC,KAAK,UAAU,KAAK,GAAG,eAAA;CACjC;CAEA,UAAU,SAAwC;EAChD,IAAI,KAAK,QAAQ,MAAM,IAAI,MAAM,4BAA4B;EAC7D,IAAI,KAAK,iBAAiB,MACxB,MAAM,IAAI,MAAM,sEAAsE;EAExF,KAAK,eAAe;CACtB;CAEA,gBAAkD;EAChD,MAAM,OAAO,KAAK;EAClB,KAAK,eAAe;EACpB,OAAO;CACT;CAEA,QAAQ,SAA2B;EACjC,KAAK,aAAa;CACpB;CAEA,IAAI,aAAsB;EACxB,OAAO,KAAK,iBAAiB;CAC/B;CAEA,MAAM,KAAK,OAA8B;EACvC,IAAI,KAAK,QAAQ,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,IAAI,WADzB,OAAO,QAAQ,aAAa,IAAI,IAAI,IAAI,GACE,CAAC;EAE1D,MAAM,aAAa,MAAM,IAAI,SAAkC,YAAY;GACzE,QAAQ,WAAW,UAAU,QAAQ,KAAK,CAAC;EAC7C,CAAC;EACD,QAAQ,cAAc;EAEtB,IAAI,CAAC,QAAQ,UAAU,KAAK,WAAW,WAAA,YACrC,MAAM,IAAI,MAAM,yBAAyB,KAAK,UAAU,UAAU,CAAC,CAAC,MAAM,GAAG,EAAE,GAAG;EAEpF,OAAO;CACT;AACF;;;ACvBA,SAAgB,kBAAkB,YAAwB,YAA8C;CACtG,OAAO,YAAY;EACjB,MAAM,UAAU,IAAI,gBAAgB,SAAS;EAC7C,MAAM,QAAQ,KAAK,EAAE,QAAQ,eAAe,CAAC;EAC7C,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/remote/transports/worker.ts","../../src/remote/spawners/ws-client.ts","../../src/remote/spawners/ws-server.ts","../../src/remote/spawners/worker-client.ts","../../src/remote/spawners/worker-self.ts"],"sourcesContent":["/* eslint-disable unicorn/prefer-add-event-listener, unicorn/require-post-message-target-origin */\n// ── Worker transport ────────────────────────────────────────────────────────────\n//\n// Moves frame objects directly over postMessage. postMessage structured-clones\n// the frame object, so there is no JSON encode/decode — this transport implements\n// Channel directly (not StringTransport). Structured clone is the worker's\n// native encoding, named by WORKER_VERSION.\n\nimport type { Channel } from \"../channel.js\";\n\n/** The worker encoding: native structured clone (no JSON). */\nexport const WORKER_VERSION = \"clone.v1\";\n\n/**\n * The subset of a worker the transport needs. The main-thread `Worker` and the\n * worker-global `self` both satisfy it; `terminate` is present only on the\n * main-thread side.\n */\nexport interface WorkerLike {\n postMessage(data: unknown): void;\n onmessage: ((event: { data: unknown }) => void) | null;\n onerror?: ((event: unknown) => void) | null;\n terminate?(): void;\n}\n\nexport class WorkerTransport implements Channel {\n private worker: WorkerLike;\n private pvtOnMessage: ((frame: Record<string, unknown>) => void) | null = null;\n private pvtOnClose: (() => void) | null = null;\n private closed = false;\n\n constructor(worker: WorkerLike) {\n this.worker = worker;\n worker.onmessage = (event) => {\n if (this.pvtOnMessage && !this.closed) {\n this.pvtOnMessage(event.data as Record<string, unknown>);\n }\n };\n // An uncaught error in the worker is the closest thing to an abrupt drop.\n if (\"onerror\" in worker) {\n worker.onerror = () => {\n this.closed = true;\n this.pvtOnClose?.();\n };\n }\n }\n\n get canSend(): boolean {\n return !this.closed;\n }\n\n onMessage(handler: (frame: Record<string, unknown>) => void): void {\n if (this.closed) throw new Error(\"WorkerTransport: closed\");\n if (this.pvtOnMessage !== null) {\n throw new Error(\"WorkerTransport: handler already set — call removeHandler() first\");\n }\n this.pvtOnMessage = handler;\n }\n\n removeHandler(): ((frame: Record<string, unknown>) => void) | null {\n const prev = this.pvtOnMessage;\n this.pvtOnMessage = null;\n return prev;\n }\n\n onClose(handler: () => void): void {\n this.pvtOnClose = handler;\n }\n\n get hasHandler(): boolean {\n return this.pvtOnMessage !== null;\n }\n\n async send(frame: Record<string, unknown>): Promise<void> {\n if (this.closed) throw new Error(\"WorkerTransport: closed\");\n this.worker.postMessage(frame);\n }\n\n async close(): Promise<void> {\n if (this.closed) return;\n this.closed = true;\n this.worker.terminate?.();\n }\n}\n","/* eslint-disable unicorn/prefer-add-event-listener */\n// ── WebSocket client spawner ────────────────────────────────────────────────────\n//\n// Environment-specific: connects to a `ws://` URL with the WHATWG WebSocket,\n// wraps it in a WebSocketTransport, and returns a frame Channel with the $proto\n// handshake already validated.\n//\n// How the socket is opened is the caller's. The second parameter constructs one from a URL, which is\n// what a runtime's own client takes; an opener replaces it with a function of the connection, which is\n// where a header belongs — a token in a URL is a token in every log the URL passes through — and the\n// only place a value that varies per spawn can be attached at all.\n\nimport { WebSocketTransport } from \"../transports/websocket.js\";\nimport { json1Channel, VERSION } from \"../protocols/json1.js\";\nimport { isProto } from \"../channel.js\";\nimport type { ClientSpawner } from \"../client.js\";\n\n/** The socket the spawner needs: what the transport reads and writes, and the open/error slots. */\nexport type OpenedWebSocket = {\n readonly readyState: number;\n send(data: string): void;\n close(code?: number, reason?: string): void;\n onopen: (() => void) | null;\n onerror: ((err: unknown) => void) | null;\n onmessage: ((event: { data: unknown }) => void) | null;\n onclose: (() => void) | null;\n};\n\nexport type WebSocketCtor = new (url: string) => OpenedWebSocket;\n\n/**\n * How a socket is opened when a constructor is not enough: the URL to open, and the arguments this\n * spawn was called with. A per-tenant header, a bearer token, an authority the machine does not\n * already know — each of them is a fact about the connection, and each of them is the caller's to\n * express in its own runtime's shape rather than in one posipaki was taught.\n */\nexport type WebSocketOpener<Args = unknown> = (url: string, args: Args) => OpenedWebSocket;\n\nexport interface WebSocketClientOptions<Args = unknown> {\n /** Opens the socket. Given, it replaces the constructor. */\n open?: WebSocketOpener<Args>;\n}\n\nconst defaultWebSocket = (globalThis as { WebSocket?: WebSocketCtor }).WebSocket;\n\n/** What a socket failure says about itself.\n *\n * A WHATWG WebSocket reports an open failure as an ErrorEvent, and `String(event)` is\n * `[object ErrorEvent]`: its type, its message and the underlying error are all in its\n * own fields, so read those rather than stringify the event that carries them.\n */\nfunction describeSocketError(err: unknown): string {\n if (typeof err !== \"object\" || err === null) return String(err);\n const event = err as { type?: unknown; message?: unknown; error?: unknown };\n const cause = event.error instanceof Error ? event.error.message : event.error;\n const parts = [event.type, event.message, cause].filter(\n (part): part is string => typeof part === \"string\" && part.length > 0,\n );\n return parts.length > 0 ? parts.join(\": \") : String(err);\n}\n\nfunction openWebSocket(ws: { readonly readyState: number; onopen: (() => void) | null; onerror: ((err: unknown) => void) | null }): Promise<void> {\n return new Promise((resolve, reject) => {\n if (ws.readyState === 1 /* OPEN */) return resolve();\n ws.onopen = () => resolve();\n ws.onerror = (err) => reject(new Error(`websocket failed to open: ${describeSocketError(err)}`));\n });\n}\n\nexport function wsClientSpawner<Args = unknown>(\n url: string | ((args: Args) => string),\n WebSocketImpl: WebSocketCtor = defaultWebSocket as WebSocketCtor,\n opts: WebSocketClientOptions<Args> = {},\n): ClientSpawner<Args> {\n // The constructor is the default opener, so the socket is opened one way either way.\n const open: WebSocketOpener<Args> = opts.open ?? ((target) => new WebSocketImpl(target));\n return async (args) => {\n const target = typeof url === \"function\" ? url(args) : url;\n const ws = open(target, args);\n const transport = new WebSocketTransport(ws);\n const channel = json1Channel(transport);\n\n // Set the $proto waiter before awaiting open so a fast server's handshake\n // frame is not dropped.\n const protoPromise = new Promise<Record<string, unknown>>((resolve) => {\n channel.onMessage((frame) => resolve(frame));\n });\n await openWebSocket(ws);\n const protoFrame = await protoPromise;\n channel.removeHandler();\n\n if (!isProto(protoFrame) || protoFrame.$proto !== VERSION) {\n throw new Error(`unsupported protocol: ${JSON.stringify(protoFrame).slice(0, 50)}`);\n }\n return channel;\n };\n}\n","// ── WebSocket server spawner ────────────────────────────────────────────────────\n//\n// Environment-specific: serves an already-upgraded WebSocket connection. The\n// consumer's HTTP server does the upgrade and hands us the socket; we wrap it in\n// a WebSocketTransport, send $proto, and return the frame Channel.\n\nimport { WebSocketTransport, type WebSocketLike } from \"../transports/websocket.js\";\nimport { json1Channel, VERSION } from \"../protocols/json1.js\";\nimport type { Spawner } from \"../server.js\";\n\nexport function wsServerSpawner(ws: WebSocketLike): Spawner {\n return async () => {\n const channel = json1Channel(new WebSocketTransport(ws));\n await channel.send({ $proto: VERSION });\n return channel;\n };\n}\n\n/**\n * A minimal Bun `ServerWebSocket` — `send`/`close`/`readyState` plus the data\n * slot the server uses to stash per-connection state. Bun delivers message and\n * close events through the `Bun.serve` websocket config callbacks, not through\n * properties on the socket, so the consumer routes them onto the adapter.\n */\nexport interface BunServerWebSocketLike {\n send(data: string): void;\n close(code?: number, reason?: string): void;\n readonly readyState: number;\n data?: unknown;\n}\n\n/**\n * Adapt a Bun server socket to the `WebSocketLike` the transport consumes. The\n * returned adapter owns settable `onmessage`/`onclose` slots; the consumer\n * routes Bun's `message`/`close` config callbacks into them, e.g.:\n *\n * ```ts\n * Bun.serve({\n * websocket: {\n * open(ws) {\n * const adapter = bunServerWebSocket(ws);\n * ws.data = adapter;\n * serveRemoteActor(actor, wsServerSpawner(adapter));\n * },\n * message(ws, msg) { (ws.data as WebSocketLike).onmessage?.({ data: msg }); },\n * close(ws) { (ws.data as WebSocketLike).onclose?.(); },\n * },\n * });\n * ```\n */\nexport function bunServerWebSocket(ws: BunServerWebSocketLike): WebSocketLike {\n return {\n send: (data) => ws.send(data),\n close: (code, reason) => ws.close(code, reason),\n readyState: ws.readyState,\n onmessage: null,\n onclose: null,\n };\n}\n","// ── Worker client spawner (command) ─────────────────────────────────────────────\n//\n// Environment-specific: spawns a Worker with the WHATWG `new Worker(url)` API,\n// wraps it in a WorkerTransport, and returns a frame Channel with the $proto\n// handshake already validated.\n\nimport { WorkerTransport, WORKER_VERSION, type WorkerLike } from \"../transports/worker.js\";\nimport { isProto } from \"../channel.js\";\nimport type { ClientSpawner } from \"../client.js\";\n\nexport type WorkerCtor = new (url: string) => WorkerLike;\n\nconst defaultWorker = (globalThis as { Worker?: WorkerCtor }).Worker;\n\nexport function workerClientSpawner<Args = unknown>(\n url: string | ((args: Args) => string),\n WorkerImpl: WorkerCtor = defaultWorker as WorkerCtor,\n): ClientSpawner<Args> {\n return async (args) => {\n const target = typeof url === \"function\" ? url(args) : url;\n const channel = new WorkerTransport(new WorkerImpl(target));\n\n const protoFrame = await new Promise<Record<string, unknown>>((resolve) => {\n channel.onMessage((frame) => resolve(frame));\n });\n channel.removeHandler();\n\n if (!isProto(protoFrame) || protoFrame.$proto !== WORKER_VERSION) {\n throw new Error(`unsupported protocol: ${JSON.stringify(protoFrame).slice(0, 50)}`);\n }\n return channel;\n };\n}\n","// ── Worker server spawner (self) ────────────────────────────────────────────────\n//\n// Environment-specific: serves the worker-global scope (`self`) as a frame\n// Channel with the $proto handshake already sent. The worker entry script calls\n// `serveRemoteActor(actor, workerSelfSpawner())`.\n\nimport { WorkerTransport, WORKER_VERSION, type WorkerLike } from \"../transports/worker.js\";\nimport type { Spawner } from \"../server.js\";\n\nexport function workerSelfSpawner(selfScope: WorkerLike = globalThis as unknown as WorkerLike): Spawner {\n return async () => {\n const channel = new WorkerTransport(selfScope);\n await channel.send({ $proto: WORKER_VERSION });\n return channel;\n };\n}\n"],"mappings":";;;AAWA,MAAa,iBAAiB;AAc9B,IAAa,kBAAb,MAAgD;CAM9C,YAAY,QAAoB;EAJ0C,KAAA,eAAA;EAChC,KAAA,aAAA;EACzB,KAAA,SAAA;EAGf,KAAK,SAAS;EACd,OAAO,aAAa,UAAU;GAC5B,IAAI,KAAK,gBAAgB,CAAC,KAAK,QAC7B,KAAK,aAAa,MAAM,IAA+B;EAE3D;EAEA,IAAI,aAAa,QACf,OAAO,gBAAgB;GACrB,KAAK,SAAS;GACd,KAAK,aAAa;EACpB;CAEJ;CAEA,IAAI,UAAmB;EACrB,OAAO,CAAC,KAAK;CACf;CAEA,UAAU,SAAyD;EACjE,IAAI,KAAK,QAAQ,MAAM,IAAI,MAAM,yBAAyB;EAC1D,IAAI,KAAK,iBAAiB,MACxB,MAAM,IAAI,MAAM,mEAAmE;EAErF,KAAK,eAAe;CACtB;CAEA,gBAAmE;EACjE,MAAM,OAAO,KAAK;EAClB,KAAK,eAAe;EACpB,OAAO;CACT;CAEA,QAAQ,SAA2B;EACjC,KAAK,aAAa;CACpB;CAEA,IAAI,aAAsB;EACxB,OAAO,KAAK,iBAAiB;CAC/B;CAEA,MAAM,KAAK,OAA+C;EACxD,IAAI,KAAK,QAAQ,MAAM,IAAI,MAAM,yBAAyB;EAC1D,KAAK,OAAO,YAAY,KAAK;CAC/B;CAEA,MAAM,QAAuB;EAC3B,IAAI,KAAK,QAAQ;EACjB,KAAK,SAAS;EACd,KAAK,OAAO,YAAY;CAC1B;AACF;;;ACxCA,MAAM,mBAAoB,WAA6C;;;;;;;AAQvE,SAAS,oBAAoB,KAAsB;CACjD,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM,OAAO,OAAO,GAAG;CAC9D,MAAM,QAAQ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K,EAAE,QAAQ,QAAQ,CAAC;EACtC,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,mBAAmB,IAA2C;CAC5E,OAAO;EACL,OAAO,SAAS,GAAG,KAAK,IAAI;EAC5B,QAAQ,MAAM,WAAW,GAAG,MAAM,MAAM,MAAM;EAC9C,YAAY,GAAG;EACf,WAAW;EACX,SAAS;CACX;AACF;;;AC9CA,MAAM,gBAAiB,WAAuC;AAE9D,SAAgB,oBACd,KACA,aAAyB,eACJ;CACrB,OAAO,OAAO,SAAS;EAErB,MAAM,UAAU,IAAI,gBAAgB,IAAI,WADzB,OAAO,QAAQ,aAAa,IAAI,IAAI,IAAI,GACE,CAAC;EAE1D,MAAM,aAAa,MAAM,IAAI,SAAkC,YAAY;GACzE,QAAQ,WAAW,UAAU,QAAQ,KAAK,CAAC;EAC7C,CAAC;EACD,QAAQ,cAAc;EAEtB,IAAI,CAAC,QAAQ,UAAU,KAAK,WAAW,WAAA,YACrC,MAAM,IAAI,MAAM,yBAAyB,KAAK,UAAU,UAAU,CAAC,CAAC,MAAM,GAAG,EAAE,GAAG;EAEpF,OAAO;CACT;AACF;;;ACvBA,SAAgB,kBAAkB,YAAwB,YAA8C;CACtG,OAAO,YAAY;EACjB,MAAM,UAAU,IAAI,gBAAgB,SAAS;EAC7C,MAAM,QAAQ,KAAK,EAAE,QAAQ,eAAe,CAAC;EAC7C,OAAO;CACT;AACF"}
|
package/dist/remote/node.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { i as Message } from "../types-DYd-DDFB.js";
|
|
2
2
|
import { h as MethodOptions, l as ActorDefinition, p as HandlerOptions, v as ReflectionOptions } from "../hooks-D1QaP6Vv.js";
|
|
3
|
-
import {
|
|
3
|
+
import { S as Channel, a as ClientSpawner, l as Listener, n as WebSocketLike, w as StringTransport } from "../websocket-BYNYSi7b.js";
|
|
4
4
|
import { FileHandle } from "node:fs/promises";
|
|
5
5
|
import { ChildProcess, StdioOptions } from "node:child_process";
|
|
6
|
-
import { Readable, Writable } from "node:stream";
|
|
6
|
+
import { Duplex, Readable, Writable } from "node:stream";
|
|
7
|
+
import { IncomingMessage } from "node:http";
|
|
7
8
|
//#region src/remote/transports/fifo.d.ts
|
|
8
9
|
declare class FifoUtf8NlineTransport implements StringTransport {
|
|
9
10
|
private readFd;
|
|
@@ -418,5 +419,135 @@ declare function hostRemote<Args>(spec: Omit<RemoteSpec<Args>, "name" | "entry">
|
|
|
418
419
|
name?: string;
|
|
419
420
|
}): ClientSpawner<Args>;
|
|
420
421
|
//#endregion
|
|
421
|
-
|
|
422
|
+
//#region src/remote/socket.d.ts
|
|
423
|
+
/** What a listener knows about an accepted connection before an actor exists for it. */
|
|
424
|
+
interface UnixSocketPeer {
|
|
425
|
+
/** The path this side is bound to. */
|
|
426
|
+
readonly path: string;
|
|
427
|
+
/**
|
|
428
|
+
* The peer's credentials, where the runtime gives them (Linux `SO_PEERCRED`). Node exposes none on a
|
|
429
|
+
* unix socket today, so this is undefined under node; the field is here for a runtime that can.
|
|
430
|
+
*/
|
|
431
|
+
readonly peer?: {
|
|
432
|
+
readonly uid: number;
|
|
433
|
+
readonly gid: number;
|
|
434
|
+
readonly pid?: number;
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
interface UnixSocketListenerOptions<Meta = unknown> {
|
|
438
|
+
/** The socket file. Made when the listener starts, and removed when it stops. */
|
|
439
|
+
path: string;
|
|
440
|
+
/** The mode of the socket file, set before the first connection is taken. Default 0o600. */
|
|
441
|
+
mode?: number;
|
|
442
|
+
/**
|
|
443
|
+
* Whether a path that exists and refuses a connection may be replaced: a socket nobody listens on is a
|
|
444
|
+
* crash's leftover. A path that is not a socket at all is refused rather than removed.
|
|
445
|
+
*/
|
|
446
|
+
replaceStale?: boolean;
|
|
447
|
+
/** The listen backlog, passed through to the runtime. */
|
|
448
|
+
backlog?: number;
|
|
449
|
+
/**
|
|
450
|
+
* Admission and identity. What it returns is the connection's meta; throwing refuses the connection
|
|
451
|
+
* before any actor exists.
|
|
452
|
+
*/
|
|
453
|
+
identify?(peer: UnixSocketPeer): Meta | Promise<Meta>;
|
|
454
|
+
}
|
|
455
|
+
interface UnixSocketClientOptions {
|
|
456
|
+
/** How long to wait for the connection, in milliseconds. Default 5000. */
|
|
457
|
+
timeoutMs?: number;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Bind a path and answer connections from it, as the reactor's Listener: the socket file is made before
|
|
461
|
+
* the first accept, its mode is set before the first connection is taken, and `close()` removes it if it
|
|
462
|
+
* is still the inode this listener bound.
|
|
463
|
+
*/
|
|
464
|
+
declare function unixSocketListener<Meta = unknown>(options: UnixSocketListenerOptions<Meta>): Promise<Listener<Meta>>;
|
|
465
|
+
/** Connect to a listener: one call, and no open order, since a socket is connected or it is not. */
|
|
466
|
+
declare function connectUnixSocket(path: string, options?: UnixSocketClientOptions): Promise<LineTransport>;
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/remote/spawners/socket-client.d.ts
|
|
469
|
+
declare function socketClientSpawner<Args = unknown>(path: string | ((args: Args) => string), options?: UnixSocketClientOptions): ClientSpawner<Args>;
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/remote/fifo.d.ts
|
|
472
|
+
/**
|
|
473
|
+
* The pair, named as the serving side sees it: `read` is where it reads, and `write` where it writes. The
|
|
474
|
+
* client side passes the same pair and swaps them, which is what makes it a pair rather than two paths.
|
|
475
|
+
*/
|
|
476
|
+
interface FifoPair {
|
|
477
|
+
readonly read: string;
|
|
478
|
+
readonly write: string;
|
|
479
|
+
}
|
|
480
|
+
interface FifoListenerOptions<Meta = unknown> {
|
|
481
|
+
/** Make the pair when it is missing, and refuse a path that exists and is not a fifo. Default true. */
|
|
482
|
+
make?: boolean;
|
|
483
|
+
/** Admission and identity: what this returns is the connection's meta. */
|
|
484
|
+
identify?(pair: FifoPair): Meta | Promise<Meta>;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Make the pair unless it is already there. A fifo is a file and one pair serves every connection, so
|
|
488
|
+
* nothing is recreated; something that is not a fifo where the pair goes is refused rather than worked
|
|
489
|
+
* around, because a regular file read as input is a silence nobody can explain.
|
|
490
|
+
*/
|
|
491
|
+
declare function makeFifoPair(pair: FifoPair): Promise<void>;
|
|
492
|
+
/**
|
|
493
|
+
* Listen on a pair, as the served side: it reads `pair.read` and writes `pair.write`, and it opens the
|
|
494
|
+
* write end first. That order is the handshake: a stream opened for reading on a fifo nobody writes to is
|
|
495
|
+
* handed an immediate end-of-stream by some runtimes, which closes a connection that never carried a byte.
|
|
496
|
+
*/
|
|
497
|
+
declare function fifoListener<Meta = unknown>(pair: FifoPair, options?: FifoListenerOptions<Meta>): Promise<Listener<Meta>>;
|
|
498
|
+
/**
|
|
499
|
+
* Connect to a pair, as the client side: it reads what the listener writes and writes what it reads,
|
|
500
|
+
* and it awaits the `$proto` frame, which is the side of the handshake a served actor speaks.
|
|
501
|
+
*/
|
|
502
|
+
declare function fifoClientSpawner<Args = unknown>(pair: FifoPair | ((args: Args) => FifoPair)): ClientSpawner<Args>;
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/remote/websocket.d.ts
|
|
505
|
+
/** A server that reports an upgrade before answering it: node's `http`/`https` server. */
|
|
506
|
+
interface UpgradeSource {
|
|
507
|
+
on(event: "upgrade", listener: (request: IncomingMessage, socket: Duplex, head: Buffer) => void): unknown;
|
|
508
|
+
off(event: "upgrade", listener: (request: IncomingMessage, socket: Duplex, head: Buffer) => void): unknown;
|
|
509
|
+
}
|
|
510
|
+
/** What arrived: the request that asked to upgrade, and the URL it asked for. */
|
|
511
|
+
interface WebSocketUpgrade {
|
|
512
|
+
readonly request: IncomingMessage;
|
|
513
|
+
readonly url: URL;
|
|
514
|
+
}
|
|
515
|
+
interface WebSocketListenerOptions<Meta = unknown> {
|
|
516
|
+
/** The server whose upgrades become connections. */
|
|
517
|
+
server: UpgradeSource;
|
|
518
|
+
/**
|
|
519
|
+
* Which path upgrades. An upgrade on any other path is not this listener's and is left as it
|
|
520
|
+
* arrived, so one server can route its paths between listeners. Every path upgrades when it is
|
|
521
|
+
* not given.
|
|
522
|
+
*/
|
|
523
|
+
path?: string;
|
|
524
|
+
/**
|
|
525
|
+
* Admission and identity. What it returns is the connection's meta; throwing refuses the upgrade
|
|
526
|
+
* before any actor exists — a refused connection costs no actor and no channel — and the far side
|
|
527
|
+
* is told by `refuse`.
|
|
528
|
+
*/
|
|
529
|
+
identify?(upgrade: WebSocketUpgrade): Meta | Promise<Meta>;
|
|
530
|
+
/**
|
|
531
|
+
* Complete the handshake and answer with the socket: the WebSocket implementation's own step,
|
|
532
|
+
* which is the one thing the library does not carry. With `ws`:
|
|
533
|
+
*
|
|
534
|
+
* ```ts
|
|
535
|
+
* upgrade: (request, socket, head) =>
|
|
536
|
+
* new Promise((resolve) => wss.handleUpgrade(request, socket, head, (ws) => resolve(socketOf(ws))))
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
upgrade(request: IncomingMessage, socket: Duplex, head: Buffer): Promise<WebSocketLike>;
|
|
540
|
+
/** What a refused upgrade is told. Default: `401`, and the socket is closed. */
|
|
541
|
+
refuse?(socket: Duplex, error: unknown, upgrade: WebSocketUpgrade): void;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Take connections from an HTTP server's upgrades, as the reactor's `Listener`.
|
|
545
|
+
*
|
|
546
|
+
* Admission happens when the upgrade arrives, so a refusal is the far side's before any handshake,
|
|
547
|
+
* and the handshake happens when a connection is accepted: what the reactor is handed is an open
|
|
548
|
+
* websocket and the meta it was admitted with.
|
|
549
|
+
*/
|
|
550
|
+
declare function webSocketListener<Meta = unknown>(options: WebSocketListenerOptions<Meta>): Listener<Meta>;
|
|
551
|
+
//#endregion
|
|
552
|
+
export { type BootstrapReport, type ClientChannelOptions, DEFAULT_KIT_PARENT, DEFAULT_RUNTIMES, type FifoListenerOptions, type FifoPair, FifoUtf8NlineTransport, GATEWAY_ARTIFACT, GATEWAY_ENTRY, GATEWAY_FAILED, type GatewayBoot, HANDSHAKE_TIMEOUT_MS, type HostProgram, type HostResult, type HostRun, type HostVersion, HostVersionError, type HostVersionVerdict, KIT_LAYOUT, type Kit, type KitApp, type KitFile, type LineStreams, LineTransport, type MakeKitOptions, type OutputFd, OutputFilter, type OutputFrame, type OutputSink, PAYLOAD_ARTIFACT, PAYLOAD_REFUSED, type RemoteSpec, RemoteSpecError, type RemoteWayIn, type SpawnChild, StdioWireError, type SubprocessActorBundle, type SubprocessActorOptions, type UnixSocketClientOptions, type UnixSocketListenerOptions, type UnixSocketPeer, type UpgradeSource, type WebSocketListenerOptions, type WebSocketUpgrade, bootstrapScript, clientChannel, commandSpawner, connectUnixSocket, defineSubprocessActor, errorFrame, errorReason, fdStreams, fifoArgvSpawner, fifoClientSpawner, fifoListener, gatewayArgs, gatewayBoot, gatewayClient, hostRemote, hostVersion, hostVersionAccepts, kitVersion, makeFifoPair, makeKit, outputFrame, parseBootstrapReport, parseHostVersion, parseOutputFrame, runGateway, runHost, sameHostVersion, serverChannel, sha256Hex, socketClientSpawner, spawnChild, stderrSink, unixSocketListener, webSocketListener };
|
|
422
553
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","names":[],"sources":["../../src/remote/transports/fifo.ts","../../src/remote/spawners/fifo-command.ts","../../src/remote/spawners/fifo-argv.ts","../../src/remote/kit.ts","../../src/remote/define-subprocess.ts","../../src/remote/stdio.ts","../../src/remote/gateway.ts","../../src/remote/host.ts","../../src/remote/gateway-client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","names":[],"sources":["../../src/remote/transports/fifo.ts","../../src/remote/spawners/fifo-command.ts","../../src/remote/spawners/fifo-argv.ts","../../src/remote/kit.ts","../../src/remote/define-subprocess.ts","../../src/remote/stdio.ts","../../src/remote/gateway.ts","../../src/remote/host.ts","../../src/remote/gateway-client.ts","../../src/rem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