posipaki 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{hooks-Dpbe39oa.d.ts → hooks-DO-efRM_.d.ts} +2 -2
  2. package/dist/{hooks-Dpbe39oa.d.ts.map → hooks-DO-efRM_.d.ts.map} +1 -1
  3. package/dist/hooks.d.ts +1 -1
  4. package/dist/index.d.ts +4 -4
  5. package/dist/index.js +1 -1
  6. package/dist/plugins/debug-logger.d.ts +2 -2
  7. package/dist/plugins/tree-introspection.d.ts +2 -2
  8. package/dist/{process-CoEKoY5f.d.ts → process-eCAv2tIS.d.ts} +2 -2
  9. package/dist/{process-CoEKoY5f.d.ts.map → process-eCAv2tIS.d.ts.map} +1 -1
  10. package/dist/remote/gateway-cli.js +1157 -50
  11. package/dist/remote/gateway-cli.js.map +1 -1
  12. package/dist/remote/index.d.ts +4 -232
  13. package/dist/remote/index.d.ts.map +1 -1
  14. package/dist/remote/index.js +2 -2
  15. package/dist/remote/index.js.map +1 -1
  16. package/dist/remote/node.d.ts +29 -54
  17. package/dist/remote/node.d.ts.map +1 -1
  18. package/dist/remote/node.js +128 -128
  19. package/dist/remote/node.js.map +1 -1
  20. package/dist/testing/index.d.ts +4 -4
  21. package/dist/testing/index.d.ts.map +1 -1
  22. package/dist/testing/index.js.map +1 -1
  23. package/dist/{types-CuabnerI.d.ts → types-U3NvKgpg.d.ts} +10 -1
  24. package/dist/{types-CuabnerI.d.ts.map → types-U3NvKgpg.d.ts.map} +1 -1
  25. package/dist/{version-B6eNJRZD.js → version-yonmO5bG.js} +2 -2
  26. package/dist/{version-B6eNJRZD.js.map → version-yonmO5bG.js.map} +1 -1
  27. package/dist/websocket-DT8zKD34.d.ts +836 -0
  28. package/dist/websocket-DT8zKD34.d.ts.map +1 -0
  29. package/dist/{websocket-DecgMfb3.js → websocket-DkDAHMFm.js} +1102 -85
  30. package/dist/websocket-DkDAHMFm.js.map +1 -0
  31. package/dist/xfetch.d.ts +2 -2
  32. package/package.json +1 -1
  33. package/dist/websocket-DecgMfb3.js.map +0 -1
  34. package/dist/websocket-sGQcEDbm.d.ts +0 -310
  35. package/dist/websocket-sGQcEDbm.d.ts.map +0 -1
@@ -1,233 +1,5 @@
1
- import { a as Message, c as SenderInfo } from "../types-CuabnerI.js";
2
- import { A as OutputFd, B as isInit, C as Init, D as BAD_PREFIX_LIMIT, E as Spawner, F as errorFrame, G as isResume, H as isPause, I as errorReason, J as outputFrame, K as isState, L as isBad, M as StringTransport, N as badFrame, O as Channel, P as badReason, R as isError, S as serveRemoteActor, T as ServedProcess, U as isProto, V as isMsg, W as isRelease, Y as outputOf, _ as ServedConnection, b as oneConnection, c as ClientContext, d as remoteClient, f as AnyActorDefinition, g as ReactorOptions, h as Reactor, i as OutputSink, j as StreamKind, k as Frame, l as ClientSpawner, m as Listener, n as WebSocketLike, o as withOutput, p as Connection, q as isStop, r as WebSocketTransport, s as CHANNEL_LOST, t as WS_OPEN, u as RemoteClientOptions, v as Session, w as Served, x as reactor, y as SessionFactory, z as isExit } from "../websocket-sGQcEDbm.js";
3
- //#region src/remote/remote-process.d.ts
4
- interface RemoteExit {
5
- code: number;
6
- state: unknown;
7
- }
8
- /** How a handle gets a frame onto the connection it belongs to, addressed to a
9
- * process the far side holds. The answer is handed back when a caller has to know
10
- * the frame is out — the root's end is said that way, just before the wire closes. */
11
- type FrameSink = (frame: Record<string, unknown>, to: number) => void | Promise<void>;
12
- /** What a side does when it lets go of a handle: stop knowing the id, so nothing
13
- * arriving for it can land here again. */
14
- type ReleaseHook = (id: number) => void;
15
- /** An out-message of the far process, and the name it came with. */
16
- type RemoteMessage<OutMsg extends Message = Message> = (msg: OutMsg, fromName: string) => void;
17
- declare class RemoteProcess<InMsg extends Message = Message, OutMsg extends Message = Message> {
18
- /** The name the far side knows it by. */
19
- readonly pname: string;
20
- /** The id this connection knows it by — the far side's own, since it is the
21
- * side that holds the process. */
22
- readonly ref: ProcessRef;
23
- /** A symbol of this side's own, so a handle can be told apart from any other
24
- * the way a process is: by holding one. */
25
- readonly id: symbol;
26
- /** What the far side has said about its state so far. */
27
- state: Record<string, unknown> | null;
28
- /** The methods the far side announced it can answer. */
29
- readonly $reflection: Record<string, (...args: unknown[]) => Promise<unknown>>;
30
- private pvtSend;
31
- private pvtFromName;
32
- private pvtConnected;
33
- /** This side let it go: nothing more is asked of it, and nothing arriving for it
34
- * is news any more. Not the same as ending, and not the same as the connection
35
- * going: in all three the handle is dead, and only the reason differs. */
36
- private pvtReleased;
37
- private pvtLetGo;
38
- /** What the far side said when it ended, or null while it is running. */
39
- private pvtExit;
40
- private pvtExitWaiter;
41
- private pvtMessageSubs;
42
- private pvtStateSubs;
43
- /** Whoever is waiting to hear what it holds, settled by the first word of it. */
44
- private pvtReadyWaiters;
45
- /** How many times this reference has been kept. Nothing is heard about a process
46
- * nothing here keeps, so the count is what makes a handle usable rather than a name. */
47
- private pvtRefCount;
48
- /** The handles this one keeps because they sit in what it holds. Counted, and given
49
- * back when this one is let go of: the thing holding them is here. */
50
- private pvtOwnedRefs;
51
- /** The handles that arrived here on their way somewhere else, in a message or an answer.
52
- * Not counted — nobody here asked for them, and whoever receives them is the one to deal
53
- * with them — but remembered, so that one nobody ever keeps is let go of after all. */
54
- private pvtTransientRefs;
55
- /** What this side has asked to be told about it. A process that crosses is
56
- * silent, so a handle starts out having asked for nothing and hears nothing
57
- * until something here wants it — which is the same rule the far side holds,
58
- * written from the other end. */
59
- private pvtWanted;
60
- constructor(ref: ProcessRef, send: FrameSink, fromName: string, letGo?: ReleaseHook);
61
- /**
62
- * Whether the process this handle names can still be reached: the wire is there, and
63
- * this side has not let the handle go.
64
- *
65
- * Reaching it is not the same as it being alive. A process that has ended is still
66
- * one this side has a handle on — it is what the handle points at, and what it left
67
- * behind is here — so an end does not put it out of reach; `hasEnded()` is that
68
- * answer, and the two are asked separately. From the two ways out there is no coming
69
- * back: no reconnect, and no way to un-release.
70
- */
71
- isConnected(): boolean;
72
- /**
73
- * The connection is gone. Every handle this side holds goes out of reach with it,
74
- * and says so: there is no reconnect to wait for, so a send fails here and now
75
- * rather than disappearing into nothing.
76
- */
77
- disconnect(): void;
78
- /** Whether the process it names has ended, as far as this side has been told. */
79
- hasEnded(): boolean;
80
- /** Why nothing can be asked *of the process* — let go, ended, or out of reach — or
81
- * nothing when something can. Those are not one thing said three ways: an ended
82
- * process is still reached, it simply has nothing left to receive. */
83
- private pvtWhyNotAskable;
84
- private pvtRequireAskable;
85
- /**
86
- * Keep this reference: from here it is counted, which is what lets anything be asked of
87
- * it. It returns the handle, so what is kept is written in one line —
88
- * `this.pvtRemoteRefsHeld.push(ref.holdRef())` — and a table of them reads as what it is.
89
- */
90
- holdRef(): this;
91
- /**
92
- * Give the count back. Whoever gives the last one back lets the reference go, which is
93
- * what tells the far side that nothing here wants to hear about the process again. A
94
- * reference nobody ever kept is let go of by this too, which is how whoever receives one
95
- * they do not want is rid of it.
96
- */
97
- releaseRef(): void;
98
- /** Let go of the binding here without asking the far side for anything: what the process
99
- * was is over, or the wire that carried it is. */
100
- private pvtDropBinding;
101
- /** How many times this reference has been kept. */
102
- refCount(): number;
103
- /**
104
- * What this is, in JSON: the same reference the wire would carry, or the unstable thing
105
- * it is when nothing keeps it. Written so that an unheld reference cannot be mistaken
106
- * for a process that merely looks odd in a state, and so that one that is kept reads as
107
- * the reference it is rather than as whatever fields it happens to have.
108
- */
109
- toJSON(): unknown;
110
- /**
111
- * Remember the references inside a value that arrived here to be passed on. They are not
112
- * counted — the receiver is the one to deal with them — and this is what keeps one from
113
- * being nobody's for ever: when this handle is let go of, they are dropped with it.
114
- */
115
- markTransient(value: unknown): void;
116
- /** Stop treating a reference as one that was only passing through. */
117
- private pvtDropTransient;
118
- /**
119
- * Keep the references sitting in what this process holds. What it holds is here, so the
120
- * thing keeping those references alive is this handle, and it holds them until it is let
121
- * go of itself.
122
- */
123
- private pvtHoldOwned;
124
- /** Nothing is heard about a process nothing here keeps. A subscription, a tuning and a
125
- * wait for the state are all ways of hearing, so they are where a reference has to have
126
- * been kept first — and where the mistake says what to do about it. */
127
- private pvtRequireHeld;
128
- /**
129
- * Wait until what it holds is here.
130
- *
131
- * A handle starts out knowing nothing about the process: the far side says what a
132
- * process holds when something over here asks to hear it, so the asking and the waiting
133
- * are one act, and this is both. It settles with whatever has arrived when nothing more
134
- * can: a process that has ended has said its last, and a connection that has gone has
135
- * nothing left to say. Asking twice is asking about what is already here.
136
- */
137
- ready(): Promise<void>;
138
- /** Everyone waiting for what it holds has heard it, or never will. */
139
- private pvtSettleReady;
140
- /**
141
- * Wait for the process to end. Its exit crosses back like everything else it
142
- * does, and what it left behind is the answer.
143
- *
144
- * A handle whose connection is gone rejects instead: what is left to wait for
145
- * after that is nothing, and a process that keeps running is not something this
146
- * side can tell from one that died with the wire.
147
- */
148
- wait(): Promise<RemoteExit>;
149
- /**
150
- * Ask the far side to stop it. Stops the way it always does there, and this
151
- * resolves when its exit has crossed back — which is all this side can know.
152
- * There is no deadline, so a process that refuses to stop leaves this pending.
153
- */
154
- stop(): Promise<void>;
155
- /**
156
- * Let it go: the far side forgets this id and stops telling this side anything
157
- * about the process behind it. The process itself is untouched — it runs on, it
158
- * is simply nobody's here any more — and this handle is done: nothing reaches it,
159
- * nothing is waited for, and what arrives for it later is not news.
160
- */
161
- release(): void;
162
- /** Stop feeding it messages. It is still there: `send` still reaches it. */
163
- pause(): void;
164
- /** Feed it messages again. */
165
- resume(): void;
166
- /**
167
- * What to be told about it from now on: any of `message`, `state` and `exit`,
168
- * or `"silent"` for none of it.
169
- *
170
- * A process that crossed is silent to begin with, so this is how a handle asks
171
- * to hear anything at all — and what is heard is only ever what was asked for.
172
- * An exit nobody asked for is not sent: silence is silence, which makes this the
173
- * one way to leave a handle that will not answer a `wait()`, and the far side's
174
- * books the one place an end can go unrecorded.
175
- */
176
- tune(kinds: StreamKind[] | "silent"): void;
177
- /** Ask the far side to say exactly this much, and nothing when it is already
178
- * saying it. The list goes in the order the three are named in, so asking for
179
- * the same thing twice sends the same frame twice. */
180
- private pvtTune;
181
- /** Ask for one more category, because something here now wants it. A handle
182
- * that is gone asks nothing: there is no far side left to hear it, and nothing
183
- * was asked for, so what was wanted stays what it was. */
184
- private pvtWant;
185
- /** Hand the far process a message. */
186
- send(msg: InMsg): void;
187
- /** Subscribe to what it says, or to what it holds. Asking here is asking the far
188
- * side: a subscription is the first thing that wants the category, so it is what
189
- * turns it on, and unsubscribing leaves it on — the far side is not told to stop
190
- * saying something that another subscriber may still want. */
191
- subscribe(channel: "message", cb: RemoteMessage<OutMsg>): () => void;
192
- subscribe(channel: "state", cb: () => void): () => void;
193
- private pvtUnsubscribe;
194
- /** Its state, as the far side just published it. */
195
- receiveState(state: Record<string, unknown>): void;
196
- /** A message it emitted. */
197
- receiveMessage(msg: OutMsg, fromName: string): void;
198
- /** It has ended, and this is what it left behind. The last thing said about a
199
- * process: nothing crosses about it after its exit, though the handle still
200
- * reaches it for what it left. */
201
- receiveExit(exit: RemoteExit): void;
202
- /** The methods it can answer, as functions that ask it for an answer. `call`
203
- * is the connection's own: a handle knows what to ask for, not how a call is
204
- * made or paired with its answer. */
205
- receiveMethods(names: string[], call: (name: string, args: unknown[]) => Promise<unknown>): void;
206
- }
207
- //#endregion
208
- //#region src/remote/process-ref.d.ts
209
- /** The key that marks a process reference inside an otherwise JSON value. */
210
- declare const PROCESS_REF = "$p";
211
- /**
212
- * The id a side gives its own root: the first id of its parity. The two ends of a
213
- * connection therefore number their roots differently, and an id says whose root it is
214
- * as it says who holds every other process. A side hands out its next id from two
215
- * steps further on, the one in between belonging to the root of the side it talks to.
216
- */
217
- declare function rootIdFor(parity: IdParity): number;
218
- /** What crosses the wire in place of a process. */
219
- interface ProcessRef {
220
- id: number;
221
- pname: string;
222
- }
223
- /** Which ids a side hands out: the client takes the odd ones, the server the
224
- * even ones, so one number can never name a process on both sides at once. */
225
- type IdParity = "odd" | "even";
226
- /** Whether `value` has the shape of a handle on a far-side process. Judged by
227
- * what it holds rather than by `instanceof`, for the reason a process is: one
228
- * build can hold two copies of the class. */
229
- declare function isRemoteProcess(value: unknown): value is RemoteProcess;
230
- //#endregion
1
+ import { c as SenderInfo } from "../types-U3NvKgpg.js";
2
+ import { $ as isInit, A as BlobSource, B as isBytesRef, C as Init, D as Blob, E as Spawner, F as Stream, G as StringTransport, H as BAD_PREFIX_LIMIT, I as StreamRef, J as errorFrame, K as badFrame, L as StreamStore, M as RemoteBlob, N as RemoteBytes, O as BlobFacts, P as RemoteStream, Q as isExit, R as StreamStoreOptions, S as serveRemoteActor, T as ServedProcess, U as Channel, V as isStreamRef, W as Frame, X as isBad, Y as errorReason, Z as isError, _ as ServedConnection, a as ClientContext, at as isState, b as oneConnection, c as remoteClient, ct as ProcessRef, d as stderrSink, dt as FrameSink, et as isMsg, f as AnyActorDefinition, ft as RemoteMessage, g as ReactorOptions, h as Reactor, i as CHANNEL_LOST, it as isResume, j as BytesRef, k as BlobRef, l as OutputSink, lt as isRemoteProcess, m as Listener, n as WebSocketLike, nt as isProto, o as ClientSpawner, ot as isStop, p as Connection, pt as RemoteProcess, q as badReason, r as WebSocketTransport, rt as isRelease, s as RemoteClientOptions, st as PROCESS_REF, t as WS_OPEN, tt as isPause, u as pumpOutput, ut as rootIdFor, v as Session, w as Served, x as reactor, y as SessionFactory, z as isBlobRef } from "../websocket-DT8zKD34.js";
231
3
  //#region src/remote/sender.d.ts
232
4
  declare function makeSender(fromName: string, parentName: string | null, parentId: symbol | null): SenderInfo;
233
5
  //#endregion
@@ -309,7 +81,7 @@ declare function wsServerSpawner(ws: WebSocketLike): Spawner;
309
81
  * properties on the socket, so the consumer routes them onto the adapter.
310
82
  */
311
83
  interface BunServerWebSocketLike {
312
- send(data: string): void;
84
+ send(data: string | Uint8Array): void;
313
85
  close(code?: number, reason?: string): void;
314
86
  readonly readyState: number;
315
87
  data?: unknown;
@@ -342,5 +114,5 @@ declare function workerClientSpawner<Args = unknown>(url: string | ((args: Args)
342
114
  //#region src/remote/spawners/worker-self.d.ts
343
115
  declare function workerSelfSpawner(selfScope?: WorkerLike): Spawner;
344
116
  //#endregion
345
- export { type AnyActorDefinition, BAD_PREFIX_LIMIT, type BunServerWebSocketLike, CHANNEL_LOST, type Channel, type ClientContext, type ClientSpawner, type Connection, type Frame, type FrameSink, type Init, type Listener, type OpenedWebSocket, type OutputFd, type OutputSink, PROCESS_REF, type ProcessRef, type Reactor, type ReactorOptions, type RemoteClientOptions, type RemoteMessage, RemoteProcess, type Served, type ServedConnection, 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, outputFrame, outputOf, reactor, readFrame, remoteClient, rootIdFor, serveRemoteActor, withOutput, workerClientSpawner, workerSelfSpawner, wsClientSpawner, wsServerSpawner };
117
+ export { type AnyActorDefinition, BAD_PREFIX_LIMIT, type Blob, type BlobFacts, type BlobRef, type BlobSource, type BunServerWebSocketLike, type BytesRef, CHANNEL_LOST, type Channel, type ClientContext, type ClientSpawner, type Connection, type Frame, type FrameSink, type Init, type Listener, type OpenedWebSocket, type OutputSink, PROCESS_REF, type ProcessRef, type Reactor, type ReactorOptions, RemoteBlob, RemoteBytes, type RemoteClientOptions, type RemoteMessage, RemoteProcess, RemoteStream, type Served, type ServedConnection, type ServedProcess, type Session, type SessionFactory, type Spawner, type Stream, type StreamRef, StreamStore, type StreamStoreOptions, 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, isBlobRef, isBytesRef, isError, isExit, isInit, isMsg, isPause, isProto, isRelease, isRemoteProcess, isResume, isState, isStop, isStreamRef, json1Channel, makeSender, oneConnection, pumpOutput, reactor, readFrame, remoteClient, rootIdFor, serveRemoteActor, stderrSink, workerClientSpawner, workerSelfSpawner, wsClientSpawner, wsServerSpawner };
346
118
  //# 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/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;;;;;;;EAkBA;;;;;;EAUA,cAAc;;UAUN;;;;;;UAUA;;;;UAYA;;;;;;;;;;EAiBR,SAAS;;UAQD;;;;;;;;;EAcR,QAAQ,QAAQ;;;;;;EAgBhB,QAAQ;;;;;;;EAgBR;;EAqBA;;EAMA;;;;;;;;;;;EAeA,KAAK,OAAO;;;;UASJ;;;;UAYA;;EAOR,KAAK,K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sources":["../../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":";;;iBAUgB,WACd,kBACA,2BACA,0BACC;;;cCMU;iBAMG,OAAO,OAAO;;;iBAMd,OAAO,cAAc;;;iBAMrB,UAAU,cAAc;iBAiCxB,aAAa,WAAW,kBAAkB;;;;cC5D7C;;;;;;UAOI;EACf,YAAY;EACZ,aAAa;IAAS;;EACtB,YAAY;EACZ;;cAGW,2BAA2B;UAC9B;UACA;UACA;UACA;UACA;EAER,YAAY,QAAQ;MAgBhB;EAIJ,UAAU,UAAU,OAAO;EAU3B,QAAQ;MAIJ;EAIE,KAAK,OAAO,0BAA0B;EAKtC,SAAS;;;;;KCzDL;WACD;EACT,KAAK;EACL,MAAM,eAAe;EACrB;EACA,WAAW;EACX,aAAa;IAAS;;EACtB;;KAGU,qBAAqB,gBAAgB;;;;;;;KAQrC,gBAAgB,mBAAmB,aAAa,MAAM,SAAS;UAE1D,uBAAuB;;EAEtC,OAAO,gBAAgB;;iBA6BT,gBAAgB,gBAC9B,gBAAgB,MAAM,kBACtB,gBAAe,eACf,OAAM,uBAAuB,QAC5B,cAAc;;;iBC/DD,gBAAgB,IAAI,gBAAgB;;;;;;;UAcnC;EACf,KAAK,eAAe;EACpB,MAAM,eAAe;WACZ;EACT;;;;;;;;;;;;;;;;;;;;;iBAsBc,mBAAmB,IAAI,yBAAyB;;;KCxCpD,kBAAkB,gBAAgB;iBAI9B,oBAAoB,gBAClC,gBAAgB,MAAM,kBACtB,aAAY,aACX,cAAc;;;iBCRD,kBAAkB,YAAW,aAAmD"}
@@ -1,4 +1,4 @@
1
- import { A as isRelease, C as isBad, D as isMsg, E as isInit, F as outputOf, I as PROCESS_REF, L as isRemoteProcess, M as isState, N as isStop, O as isPause, P as outputFrame, R as rootIdFor, S as frameReaders, T as isExit, _ as BAD_PREFIX_LIMIT, a as CHANNEL_LOST, b as errorFrame, c as reactor, d as RemoteProcess, f as VERSION, g as readFrame, h as json1Channel, i as withOutput, j as isResume, k as isProto, l as serveRemoteActor, m as encode, n as WebSocketTransport, o as remoteClient, p as decode, s as oneConnection, t as WS_OPEN, u as makeSender, v as badFrame, w as isError, x as errorReason, y as badReason } from "../websocket-DecgMfb3.js";
1
+ import { A as errorReason, B as isResume, C as json1Channel, D as badReason, E as badFrame, F as isInit, H as isStop, I as isMsg, K as rootIdFor, L as isPause, M as isBad, N as isError, P as isExit, R as isProto, S as encode, T as BAD_PREFIX_LIMIT, U as PROCESS_REF, V as isState, W as isRemoteProcess, _ as isStreamRef, a as remoteClient, b as VERSION, c as oneConnection, d as RemoteBlob, f as RemoteBytes, g as isBytesRef, h as isBlobRef, i as CHANNEL_LOST, j as frameReaders, k as errorFrame, l as reactor, m as StreamStore, n as WebSocketTransport, o as pumpOutput, p as RemoteStream, s as stderrSink, t as WS_OPEN, u as serveRemoteActor, v as makeSender, w as readFrame, x as decode, y as RemoteProcess, z as isRelease } from "../websocket-DkDAHMFm.js";
2
2
  //#region src/remote/transports/worker.ts
3
3
  /** The worker encoding: native structured clone (no JSON). */
4
4
  const WORKER_VERSION = "clone.v1";
@@ -152,6 +152,6 @@ function workerSelfSpawner(selfScope = globalThis) {
152
152
  };
153
153
  }
154
154
  //#endregion
155
- 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, outputFrame, outputOf, reactor, readFrame, remoteClient, rootIdFor, serveRemoteActor, withOutput, workerClientSpawner, workerSelfSpawner, wsClientSpawner, wsServerSpawner };
155
+ export { BAD_PREFIX_LIMIT, CHANNEL_LOST, PROCESS_REF, RemoteBlob, RemoteBytes, RemoteProcess, RemoteStream, StreamStore, VERSION, WORKER_VERSION, WS_OPEN, WebSocketTransport, WorkerTransport, badFrame, badReason, bunServerWebSocket, decode, encode, errorFrame, errorReason, isBad, isBlobRef, isBytesRef, isError, isExit, isInit, isMsg, isPause, isProto, isRelease, isRemoteProcess, isResume, isState, isStop, isStreamRef, json1Channel, makeSender, oneConnection, pumpOutput, reactor, readFrame, remoteClient, rootIdFor, serveRemoteActor, stderrSink, workerClientSpawner, workerSelfSpawner, wsClientSpawner, wsServerSpawner };
156
156
 
157
157
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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 { frameReaders, 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 pvtSubscribe: ((handler: (frame: Record<string, unknown>) => void) => () => 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 // This transport moves frame objects itself, so it is a channel and not a transport: readers are kept\n // the way any channel keeps them, over the one handler the worker's own event needs.\n this.pvtSubscribe ??= frameReaders((deliver) => {\n this.pvtOnMessage = deliver;\n });\n return this.pvtSubscribe(handler);\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 const off = channel.onMessage((frame) => {\n off();\n resolve(frame);\n });\n });\n await openWebSocket(ws);\n const protoFrame = await protoPromise;\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 const off = channel.onMessage((frame) => {\n off();\n resolve(frame);\n });\n });\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;CAO9C,YAAY,QAAoB;EAL0C,KAAA,eAAA;EACyB,KAAA,eAAA;EACzD,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,SAA+D;EACvE,IAAI,KAAK,QAAQ,MAAM,IAAI,MAAM,yBAAyB;EAG1D,KAAK,iBAAiB,cAAc,YAAY;GAC9C,KAAK,eAAe;EACtB,CAAC;EACD,OAAO,KAAK,aAAa,OAAO;CAClC;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;;;ACrCA,MAAM,mBAAoB,WAA6C;;;;;;;AAQvE,SAAS,oBAAoB,KAAsB;CACjD,IAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM,OAAO,OAAO,GAAG;CAC9D,MAAM,QAAQ;CACd,MAAM,QAAQ,MAAM,iBAAiB,QAAQ,MAAM,MAAM,UAAU,MAAM;CACzE,MAAM,QAAQ;EAAC,MAAM;EAAM,MAAM;EAAS;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C;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,MAAM,MAAM,QAAQ,WAAW,UAAU;IACvC,IAAI;IACJ,QAAQ,KAAK;GACf,CAAC;EACH,CAAC;EAED,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;;;ACzBA,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 { frameReaders, 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 pvtSubscribe: ((handler: (frame: Record<string, unknown>) => void) => () => 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 // This transport moves frame objects itself, so it is a channel and not a transport: readers are kept\n // the way any channel keeps them, over the one handler the worker's own event needs.\n this.pvtSubscribe ??= frameReaders((deliver) => {\n this.pvtOnMessage = deliver;\n });\n return this.pvtSubscribe(handler);\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 const off = channel.onMessage((frame) => {\n off();\n resolve(frame);\n });\n });\n await openWebSocket(ws);\n const protoFrame = await protoPromise;\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 | Uint8Array): 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 const off = channel.onMessage((frame) => {\n off();\n resolve(frame);\n });\n });\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;CAO9C,YAAY,QAAoB;EAL0C,KAAA,eAAA;EACyB,KAAA,eAAA;EACzD,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,SAA+D;EACvE,IAAI,KAAK,QAAQ,MAAM,IAAI,MAAM,yBAAyB;EAG1D,KAAK,iBAAiB,cAAc,YAAY;GAC9C,KAAK,eAAe;EACtB,CAAC;EACD,OAAO,KAAK,aAAa,OAAO;CAClC;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,yBA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import { a as Message } from "../types-CuabnerI.js";
2
- import { h as MethodOptions, l as ActorDefinition, p as HandlerOptions, v as ReflectionOptions } from "../hooks-Dpbe39oa.js";
3
- import { A as OutputFd, M as StringTransport, O as Channel, a as stderrSink, i as OutputSink, l as ClientSpawner, m as Listener, n as WebSocketLike, o as withOutput } from "../websocket-sGQcEDbm.js";
1
+ import { a as Message } from "../types-U3NvKgpg.js";
2
+ import { h as MethodOptions, l as ActorDefinition, p as HandlerOptions, v as ReflectionOptions } from "../hooks-DO-efRM_.js";
3
+ import { G as StringTransport, U as Channel, d as stderrSink, l as OutputSink, m as Listener, n as WebSocketLike, o as ClientSpawner, u as pumpOutput } from "../websocket-DT8zKD34.js";
4
4
  import { FileHandle } from "node:fs/promises";
5
5
  import { ChildProcess, StdioOptions } from "node:child_process";
6
6
  import { Duplex, Readable, Writable } from "node:stream";
@@ -9,10 +9,11 @@ import { IncomingMessage } from "node:http";
9
9
  declare class FifoUtf8NlineTransport implements StringTransport {
10
10
  private readFd;
11
11
  private writeFd;
12
- private rl;
12
+ private reader;
13
13
  private rs;
14
14
  private ws;
15
15
  private pvtOnMessage;
16
+ private pvtOnBytes;
16
17
  private pvtOnClose;
17
18
  private closed;
18
19
  private closingPromise;
@@ -47,12 +48,14 @@ declare class FifoUtf8NlineTransport implements StringTransport {
47
48
  */
48
49
  static connect(readPath: string, writePath: string): Promise<FifoUtf8NlineTransport>;
49
50
  get canSend(): boolean;
50
- onMessage(handler: (line: string) => void): void;
51
- removeHandler(): ((line: string) => void) | null;
51
+ onBytes(handler: (bytes: Uint8Array) => void): void;
52
+ onMessage(handler: (line: string) => number | void): void;
53
+ removeHandler(): ((line: string) => number | void) | null;
52
54
  onClose(handler: () => void): void;
53
55
  get hasHandler(): boolean;
54
56
  get lastError(): Error | null;
55
57
  send(line: string): Promise<void>;
58
+ sendBytes(bytes: Uint8Array): Promise<void>;
56
59
  close(): Promise<void>;
57
60
  private pvtClose;
58
61
  }
@@ -237,31 +240,35 @@ declare function errorReason(frame: Record<string, unknown>): string | null;
237
240
  declare class LineTransport implements StringTransport {
238
241
  private readonly streams;
239
242
  private pvtOnMessage;
243
+ private pvtOnBytes;
240
244
  private pvtOnClose;
241
245
  private pvtClosed;
242
246
  private pvtClosing;
243
247
  constructor(streams: LineStreams);
244
248
  get closed(): boolean;
245
249
  get hasHandler(): boolean;
246
- onMessage(handler: (line: string) => void): void;
247
- removeHandler(): ((line: string) => void) | null;
250
+ onMessage(handler: (line: string) => number | void): void;
251
+ onBytes(handler: (bytes: Uint8Array) => void): void;
252
+ removeHandler(): ((line: string) => number | void) | null;
248
253
  onClose(handler: () => void): void;
249
254
  send(frame: string): Promise<void>;
255
+ sendBytes(bytes: Uint8Array): Promise<void>;
256
+ private pvtWrite;
250
257
  close(): Promise<void>;
251
258
  private pvtClose;
252
259
  }
253
260
  /** Streams over two fds of *our own* process — the child side of an fd wire. */
254
261
  declare function fdStreams(readFd: number, writeFd: number): LineStreams;
255
262
  interface ClientChannelOptions {
256
- /** Where the far end's own output goes. Defaults to our stderr. */
257
- onOutput?: OutputSink;
258
263
  /** How long to wait for the peer's protocol frame. Defaults to {@link HANDSHAKE_TIMEOUT_MS}. */
259
264
  timeoutMs?: number;
260
265
  }
261
266
  /**
262
- * The client end of the connection: hand the streams to the seam and wait for the peer's `$proto`,
263
- * with the far end's own output going to `onOutput` (our stderr by default) as it arrives. A
264
- * first stage reports a failed start as an `$error` frame instead.
267
+ * The client end of the connection: hand the streams to the seam and wait for the peer's `$proto`.
268
+ * A first stage reports a failed start as an `$error` frame instead.
269
+ *
270
+ * What the far end prints is not here: it arrives as a stream the far end announces under a name,
271
+ * and whoever wants it reads it by that name.
265
272
  */
266
273
  declare function clientChannel(streams: LineStreams, opts?: ClientChannelOptions): Promise<Channel>;
267
274
  /** The server end of the wire — a payload speaking stdio itself. */
@@ -277,44 +284,13 @@ interface LineLog {
277
284
  info(message: string, ...args: unknown[]): void;
278
285
  warn(message: string, ...args: unknown[]): void;
279
286
  }
280
- /** One stream of a connection: what the other end's root says on it, and what this end's root says. */
281
- interface FdStream {
282
- /** The other end's root, printing on this stream of its own. */
283
- readonly read: Readable;
284
- /** This end's root, printing on this stream; the other end reads it. */
285
- readonly write: Writable;
286
- }
287
- /** The three streams of a connection, and the one way to let them go. */
288
- interface FdSet {
289
- readonly stdin: FdStream;
290
- readonly stdout: FdStream;
291
- readonly stderr: FdStream;
292
- /** Stop reading the connection, and end every stream of it. */
293
- close(): void;
294
- }
295
- /** Where a frame goes: a connection's own `send`, or a transport's, encoded. */
296
- type OutputSender = (frame: Record<string, unknown>) => void | Promise<void>;
297
287
  /**
298
- * A writable that writes what is written to it as output frames of one fd: one chunk is one frame.
299
- *
300
- * The shape of an output frame lives here rather than at each caller — the gateway relays a payload's
301
- * own output and holds no channel — and a send that fails is the stream's error, not a lost line.
302
- */
303
- declare function fdWriter(send: OutputSender, fd: OutputFd): Writable;
304
- /**
305
- * The byte streams of a connection: what each end's root prints, and what it reads.
306
- *
307
- * The frames are the connection's, so anyone may also read them directly (`Channel.onMessage`); what
308
- * this adds is the shape a program outside the seam already speaks.
309
- */
310
- declare function connectionFds(channel: Channel): FdSet;
311
- /**
312
- * A writable that turns what is written to it into log lines: fd 1 arrives as `info` and fd 2 as
313
- * `warn`, and the tail is held until a newline (or the end) so a chunk boundary is not a line
314
- * boundary.
288
+ * A writable that turns what is written to it into log lines: `stderr` arrives as `warn` and every
289
+ * other name as `info`, and the tail is held until a newline (or the end) so a chunk boundary is not
290
+ * a line boundary.
315
291
  */
316
292
  declare function logStream(log: LineLog, opts?: {
317
- fd?: OutputFd;
293
+ name?: string;
318
294
  }): Writable;
319
295
  //#endregion
320
296
  //#region src/remote/gateway.d.ts
@@ -346,6 +322,8 @@ interface GatewayBoot {
346
322
  declare function gatewayArgs(boot: GatewayBoot): string[];
347
323
  /** The boot a gateway was started with, or the reason it cannot start. */
348
324
  declare function gatewayBoot(argv: string[]): GatewayBoot;
325
+ /** Everything a payload printed into its pipes, up to the point they end: what a start that dies
326
+ * before its channel says about itself. A stream cannot carry it — there is no connection yet. */
349
327
  /**
350
328
  * Serve one environment over stdin/stdout. Returns the exit code; the caller
351
329
  * turns it into `process.exitCode`.
@@ -488,11 +466,8 @@ declare function unixSocketListener<Meta = unknown>(options: UnixSocketListenerO
488
466
  declare function connectUnixSocket(path: string, options?: UnixSocketClientOptions): Promise<LineTransport>;
489
467
  //#endregion
490
468
  //#region src/remote/spawners/socket-client.d.ts
491
- /** What a socket client needs: how to reach it, and where the far end's own output goes. */
492
- interface SocketClientSpawnerOptions extends UnixSocketClientOptions {
493
- /** Where the far end's own output goes. Defaults to our stderr. */
494
- onOutput?: OutputSink;
495
- }
469
+ /** What a socket client needs: how to reach it. */
470
+ interface SocketClientSpawnerOptions extends UnixSocketClientOptions {}
496
471
  declare function socketClientSpawner<Args = unknown>(path: string | ((args: Args) => string), options?: SocketClientSpawnerOptions): ClientSpawner<Args>;
497
472
  //#endregion
498
473
  //#region src/remote/fifo.d.ts
@@ -576,5 +551,5 @@ interface WebSocketListenerOptions<Meta = unknown> {
576
551
  */
577
552
  declare function webSocketListener<Meta = unknown>(options: WebSocketListenerOptions<Meta>): Listener<Meta>;
578
553
  //#endregion
579
- export { type BootstrapReport, type ClientChannelOptions, DEFAULT_KIT_PARENT, DEFAULT_RUNTIMES, type FdSet, type FdStream, 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 LineLog, type LineStreams, LineTransport, type MakeKitOptions, type OutputFd, type OutputSender, type OutputSink, PAYLOAD_ARTIFACT, PAYLOAD_REFUSED, type RemoteSpec, RemoteSpecError, type RemoteWayIn, type SocketClientSpawnerOptions, type SpawnChild, StdioWireError, type SubprocessActorBundle, type SubprocessActorOptions, type UnixSocketClientOptions, type UnixSocketListenerOptions, type UnixSocketPeer, type UpgradeSource, type WebSocketListenerOptions, type WebSocketUpgrade, bootstrapScript, clientChannel, commandSpawner, connectUnixSocket, connectionFds, defineSubprocessActor, errorFrame, errorReason, fdStreams, fdWriter, fifoArgvSpawner, fifoClientSpawner, fifoListener, gatewayArgs, gatewayBoot, gatewayClient, hostRemote, hostVersion, hostVersionAccepts, kitVersion, logStream, makeFifoPair, makeKit, parseBootstrapReport, parseHostVersion, runGateway, runHost, sameHostVersion, serverChannel, sha256Hex, socketClientSpawner, spawnChild, stderrSink, unixSocketListener, webSocketListener, withOutput };
554
+ 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 LineLog, type LineStreams, LineTransport, type MakeKitOptions, type OutputSink, PAYLOAD_ARTIFACT, PAYLOAD_REFUSED, type RemoteSpec, RemoteSpecError, type RemoteWayIn, type SocketClientSpawnerOptions, 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, logStream, makeFifoPair, makeKit, parseBootstrapReport, parseHostVersion, pumpOutput, runGateway, runHost, sameHostVersion, serverChannel, sha256Hex, socketClientSpawner, spawnChild, stderrSink, unixSocketListener, webSocketListener };
580
555
  //# 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/streams.ts","../../src/remote/gateway.ts","../../src/remote/host.ts","../../src/remote/gateway-client.ts","../../src/remote/socket.ts","../../src/remote/spawners/socket-client.ts","../../src/remote/fifo.ts","../../src/remote/websocket.ts"],"mappings":";;;;;;;;cAUa,kCAAkC;UACrC;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UAED;SAuCA,aAAa,QAAQ,aAAa;SAIlC,aAAa,SAAS,aAAa;SAInC,QAAQ,QAAQ,YAAY,SAAS,aAAa;;;;;;;;;;;;SAiBlD,aACL,kBACA;IACG,WAAW,QAAQ;;;;;;;;;;;;SAqBX,QAAQ,kBAAkB,oBAAoB,QAAQ;MAS/D;EAIJ,UAAU,UAAU;EASpB,mBAAmB;EAMnB,QAAQ;MAIJ;MAIA,aAAa;EAIX,KAAK,eAAe;EAOpB,SAAS;UAMD;;;;iBCrJA,eAAe,0BAA0B,QAAQ;;;;;;;;;;;iBCe3C,gBAAgB,eAAe,QAAQ;;;;cCLhD;;cAGA;;cAGA;;cAGA;cACA;UAEI;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;EACf;EACA;;UAGe;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA,KAAK;;UAGU;;EAEf,KAAK;;EAEL;;EAEA;;KAGU;EACN;EAAe;EAAgB;EAAiB;;EAChD;EAAe;;;iBAGL,UAAU,kBAAkB;;UAW3B,oBAAoB;EACnC;;;cAIW,yBAAyB;;;;;;;;;;;iBAYtB,YAAY,KAAK;;iBAgBjB,iBAAiB,eAAe;;cAYnC;KAED;EAAuB;;EAAe;EAAW;;;;;;;;;;;iBAW7C,mBACd,yBACA,4BACC;;;;;;iBA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,MAAM,aAAa,MAAM,SAAS,YACjC,cAAc;;;;UCnHA;EACf,GAAG,kBAAkB,WAAW,SAAS,iBAAiB,QAAQ,QAAQ,MAAM;EAChF,IAAI,kBAAkB,WAAW,SAAS,iBAAiB,QAAQ,QAAQ,MAAM;;;UAIlE;WACN,SAAS;WACT,KAAK;;UAGC,yBAAyB;;EAExC,QAAQ;;;;;;EAMR;;;;;;EAMA,UAAU,SAAS,mBAAmB,OAAO,QAAQ;;;;;;;;;;EAUrD,QAAQ,SAAS,iBAAiB,QAAQ,QAAQ,MAAM,SAAS,QAAQ;;EAEzE,QAAQ,QAAQ,QAAQ,gBAAgB,SAAS;;;;;;;;;iBAkBnC,kBAAkB,gBAAgB,SAAS,yBAAyB,QAAQ,SAAS"}
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/streams.ts","../../src/remote/gateway.ts","../../src/remote/host.ts","../../src/remote/gateway-client.ts","../../src/remote/socket.ts","../../src/remote/spawners/socket-client.ts","../../src/remote/fifo.ts","../../src/remote/websocket.ts"],"mappings":";;;;;;;;cAUa,kCAAkC;UACrC;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UAED;SAwCA,aAAa,QAAQ,aAAa;SAIlC,aAAa,SAAS,aAAa;SAInC,QAAQ,QAAQ,YAAY,SAAS,aAAa;;;;;;;;;;;;SAiBlD,aACL,kBACA;IACG,WAAW,QAAQ;;;;;;;;;;;;SAqBX,QAAQ,kBAAkB,oBAAoB,QAAQ;MAS/D;EAIJ,QAAQ,UAAU,OAAO;EAMzB,UAAU,UAAU;EASpB,mBAAmB;EAMnB,QAAQ;MAIJ;MAIA,aAAa;EAIX,KAAK,eAAe;EAOpB,UAAU,OAAO,aAAa;EAM9B,SAAS;UAMD;;;;iBCnKA,eAA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