posipaki 0.43.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.
- package/dist/{define-actor-D7c9vn6S.js → define-actor-DR1P1PA5.js} +3 -3
- package/dist/define-actor-DR1P1PA5.js.map +1 -0
- package/dist/hooks-CgXhmY4r.js.map +1 -1
- package/dist/{hooks-D1QaP6Vv.d.ts → hooks-DO-efRM_.d.ts} +5 -2
- package/dist/hooks-DO-efRM_.d.ts.map +1 -0
- package/dist/hooks.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/plugins/debug-logger.d.ts +7 -5
- package/dist/plugins/debug-logger.d.ts.map +1 -1
- package/dist/plugins/debug-logger.js +71 -16
- package/dist/plugins/debug-logger.js.map +1 -1
- package/dist/plugins/tree-introspection.d.ts +2 -2
- package/dist/plugins/tree-introspection.js +1 -1
- package/dist/{process-BVwU7TQo.d.ts → process-eCAv2tIS.d.ts} +2 -2
- package/dist/{process-BVwU7TQo.d.ts.map → process-eCAv2tIS.d.ts.map} +1 -1
- package/dist/{process.async-C_-NpMFX.js → process.async-B1FqZyD1.js} +11 -2
- package/dist/process.async-B1FqZyD1.js.map +1 -0
- package/dist/remote/gateway-cli.js +1167 -41
- package/dist/remote/gateway-cli.js.map +1 -1
- package/dist/remote/index.d.ts +6 -234
- package/dist/remote/index.d.ts.map +1 -1
- package/dist/remote/index.js +15 -13
- package/dist/remote/index.js.map +1 -1
- package/dist/remote/node.d.ts +95 -13
- package/dist/remote/node.d.ts.map +1 -1
- package/dist/remote/node.js +165 -126
- package/dist/remote/node.js.map +1 -1
- package/dist/testing/index.d.ts +4 -4
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/{types-DYd-DDFB.d.ts → types-U3NvKgpg.d.ts} +44 -3
- package/dist/types-U3NvKgpg.d.ts.map +1 -0
- package/dist/{version-B97iGJJk.js → version-yonmO5bG.js} +2 -2
- package/dist/{version-B97iGJJk.js.map → version-yonmO5bG.js.map} +1 -1
- package/dist/websocket-DT8zKD34.d.ts +836 -0
- package/dist/websocket-DT8zKD34.d.ts.map +1 -0
- package/dist/{websocket-Dqd8Hu6G.js → websocket-DkDAHMFm.js} +1163 -67
- package/dist/websocket-DkDAHMFm.js.map +1 -0
- package/dist/xfetch.d.ts +2 -2
- package/package.json +1 -1
- package/dist/define-actor-D7c9vn6S.js.map +0 -1
- package/dist/hooks-D1QaP6Vv.d.ts.map +0 -1
- package/dist/process.async-C_-NpMFX.js.map +0 -1
- package/dist/types-DYd-DDFB.d.ts.map +0 -1
- package/dist/websocket-Dqd8Hu6G.js.map +0 -1
- package/dist/websocket-Dyfw3WDD.d.ts +0 -323
- package/dist/websocket-Dyfw3WDD.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.async-B1FqZyD1.js","names":[],"sources":["../src/adapters.ts","../src/process.async.ts"],"sourcesContent":["import type { ProcessFn, AsyncProcessFn, Message } from \"./types.js\";\n\nexport function asyncify<A, S, IM extends Message, OM extends Message>(\n fn: ProcessFn<A, S, IM, OM>,\n): AsyncProcessFn<A, S, IM, OM> {\n return async function* (ctx, args) {\n yield* fn(ctx, args) as any;\n };\n}\n","import { defer, makeWaiter, debugLog, withTimeout } from \"./util.js\";\nimport type { DeferredCall, Waiter } from \"./util.js\";\nimport type {\n Message,\n WithSender,\n SenderInfo,\n ExitMessage,\n StopMessage,\n FrameChannel,\n ProcessCtx,\n AsyncProcessFn,\n ProcessFn,\n} from \"./types.js\";\nimport { asyncify } from \"./adapters.js\";\n\n// ---- types ------------------------------------------------------------------\n\n/** An async iterator over process state. Receives `WithSender<InMessage | StopMessage>`. */\ntype AsyncProcessGenerator<ProcessState, InMessage extends Message> = AsyncGenerator<\n ProcessState | null,\n void,\n WithSender<InMessage | StopMessage>\n>;\n\ntype NotifyFn = () => void;\n\n/**\n * Framework-internal traffic: a message no actor ever sees. Used to resume the\n * generator without delivering anything — `start()` uses it to move past the\n * initial yield, and `wake()` to give a parked dispatch loop one chance to\n * notice that it is done. Actors skip it before any hook or handler runs.\n */\nexport const INTERNAL_ADVANCE = \"__ADVANCE__\";\n\n/** Sender stamp for the messages above. */\nconst internalSender = (): SenderInfo => ({\n fromName: \"__internal__\",\n fromId: Symbol(\"__internal__\"),\n});\n\n// ---- runDispatchAsync -------------------------------------------------------\n\ntype AsyncReducer<M> = (msg: M) => Promise<void>;\ntype ReadyFn = () => boolean;\n\n/**\n * Async equivalent of `runDispatch`. Loops, yielding `null` and feeding\n * each incoming message to an `async` reducer. Exits when `readyFn()`\n * returns true.\n */\nexport async function* runDispatchAsync<M>(\n name: string,\n fn: AsyncReducer<M>,\n readyFn: ReadyFn = () => false,\n debugLevel = false,\n): AsyncGenerator<null, void, M> {\n let msg: M;\n while (!readyFn()) {\n msg = yield null;\n debugLog(debugLevel, \"msg\", name, \" <- \", msg);\n await fn(msg);\n }\n}\n\n// ---- AsyncProcess -----------------------------------------------------------\n\n/** A subscriber to this process's message channel: receives the message and\n * its sender separately (not a `WithSender` tuple). */\ntype MessageCallback<M extends Message> = (msg: M, from: SenderInfo) => void;\n\n/** How long a parent waits for a child to stop before continuing shutdown. */\nconst CHILD_STOP_TIMEOUT_MS = 1_000;\n\n/**\n * A process driven by an async generator. Functionally identical to\n * {@link Process} but supports `await` inside reducers.\n *\n * Messages are processed **one at a time** — if a tick is already\n * in-flight, new messages are buffered and processed when the current\n * tick completes.\n */\nexport class AsyncProcess<\n Args,\n State,\n InMessage extends Message,\n OutMessage extends Message,\n ReflectionMethods extends object,\n> {\n /** Reflection methods. Empty by default — defineActor fills in configured\n * methods, each wrapped so calling one answers with a promise whatever the\n * method was written as. */\n $reflection: ReflectionMethods = {} as ReflectionMethods;\n pgenerator: AsyncProcessFn<Args, State, InMessage, OutMessage>;\n pname: string;\n /**\n * The connection this process holds, or null. Its own fact, like `pname`: read through\n * `ctx.connection` and set where the connection is made — at spawn (`{ connection }`),\n * or by the process itself when it opens one.\n */\n connection: FrameChannel | null = null;\n /** Subscribers to this process's message channel (`ctx.toParent`). */\n private messageSubscribers: Array<MessageCallback<OutMessage>> = [];\n id: symbol;\n state: State | null;\n\n private current: AsyncProcessGenerator<State, InMessage> | null = null;\n /** Every buffered message carries sender provenance. */\n private buffer: Array<WithSender<InMessage | StopMessage>> = [];\n private nextTick: DeferredCall | null = null;\n /** Child processes forked from this one (any fork method). */\n children: Array<AsyncProcess<unknown, unknown, Message, Message, {}>> = [];\n /** Children inherited from a child that exited (see ctx-orphans proposal). */\n orphans: Array<AsyncProcess<unknown, unknown, Message, Message, {}>> = [];\n private stateSubscribers: Array<NotifyFn> = [];\n /** Unsubscribe handles for outgoing message subscriptions (monitor only). */\n private pvtOutgoingSubscriptions: Array<() => void> = [];\n /** Unsubscribe handles for adopt (ownership) subscriptions, keyed by child id. */\n private pvtAdoptUnsubs: Map<symbol, () => void> = new Map();\n /** Live buffer while this process is an unowned orphan mid-handoff. */\n private pvtPending: Array<WithSender<Message>> | null = null;\n /** Unsubscribe for the collector currently buffering into pvtPending. */\n private pvtCollectorUnsub: (() => void) | null = null;\n private exitWaiter: Waiter;\n private pvtIsPaused: boolean = false;\n private pvtDead: boolean = false;\n /**\n * Set once the initial state exists. An actor whose start failed never got\n * one: it is dead on arrival, and its end-of-life hooks must not run against\n * a state that never arrived (see `pvtStartFailed`).\n */\n private pvtStarted: boolean = false;\n private pvtTickInProgress: boolean = false;\n /** True once the initial state has been delivered and `start()` has advanced\n * the generator into its dispatch loop. Until then no tick may run: the\n * generator is still suspended at the initial yield, which belongs to\n * `start()` and would swallow a message handed to it (see `start()`). */\n private pvtDispatchLive: boolean = false;\n private pvtExitReject: ((e: unknown) => void) | null = null;\n private pvtReady!: Waiter;\n private pvtResolveReady!: () => void;\n\n constructor(\n fn: AsyncProcessFn<Args, State, InMessage, OutMessage>,\n pname: string,\n toParent?: MessageCallback<OutMessage>,\n ) {\n this.pgenerator = fn;\n this.pname = pname;\n if (toParent) this.messageSubscribers.push(toParent);\n this.id = Symbol(pname);\n this.state = null;\n this.exitWaiter = makeWaiter();\n this.pvtReady = makeWaiter();\n this.pvtResolveReady = this.pvtReady.resolve;\n // `ready()` carries a failed start to whoever awaited it. A caller that\n // never awaited it must not turn that into an unhandled rejection.\n void this.pvtReady.promise.catch(() => {});\n }\n\n /** Compact handle for `util.inspect` — actor state often holds process\n * references, and dumping the internals would be unreadable. */\n [Symbol.for(\"nodejs.util.inspect.custom\")](): string {\n return `AsyncProcess<${this.pname}>`;\n }\n\n /** Promise that resolves once the initial state is available. */\n ready(): Promise<void> {\n return this.pvtReady.promise;\n }\n\n // ---- lifecycle ------------------------------------------------------------\n\n /**\n * Kick off the async generator. The first `yield` sets the initial\n * state; for async generators this happens in a microtask.\n */\n start(arg0: Args, parentName?: string | null, parentId?: symbol | null) {\n const selfCtx: SenderInfo = { fromName: this.pname, fromId: this.id };\n\n const proc = this;\n const ctx: ProcessCtx<Args, State, InMessage, OutMessage> = {\n pname: this.pname,\n id: this.id,\n self: this,\n parentName: parentName ?? null,\n parentId: parentId ?? null,\n get connection() {\n return proc.connection;\n },\n set connection(value: FrameChannel | null) {\n proc.connection = value;\n },\n fork: this.fork.bind(this),\n forkSync: this.forkSync.bind(this),\n children: this.children,\n orphans: this.orphans,\n adopt: this.adopt.bind(this),\n monitor: this.monitor.bind(this),\n sendSelf: (msg) => {\n this.send([msg, selfCtx]);\n },\n wake: () => {\n this.pvtWake();\n },\n toParent: (msg) => {\n this.messageSubscribers.forEach((cb) => cb(msg as OutMessage, selfCtx));\n },\n notify: () => {\n this.notify();\n },\n };\n\n this.current = this.pvtWatchExit(ctx, arg0);\n void this.current.next().then(\n (ret: IteratorResult<State | null, void>) => {\n this.state = ret.value ?? null;\n this.pvtStarted = true;\n this.pvtResolveReady();\n if (ret.done) {\n this.exitWaiter.resolve();\n return;\n }\n // Advance past the initial yield so the pvtWatchExit generator\n // runs its finally block (EXIT/STOP) and the inner generator\n // enters its dispatch loop.\n const advance: WithSender<InMessage | StopMessage> = [\n { type: INTERNAL_ADVANCE } as InMessage,\n internalSender(),\n ];\n // Only now may a tick feed the generator. Anything that arrived while\n // we were still setting up waited in the buffer: no tick is pending for\n // it (they were all held back), so schedule one.\n this.pvtDispatchLive = true;\n this.pvtEatResult(this.current!.next(advance));\n if (this.buffer.length > 0) this.pvtScheduleTick();\n },\n // The generator threw before its first yield: setup() — or a hook that\n // runs before it — failed, so there is no state and nothing to dispatch.\n (e: unknown) => this.pvtStartFailed(e),\n );\n return this;\n }\n\n /**\n * The process never started: its first `next()` rejected before any state\n * existed. The failure *is* the outcome, so `ready()` carries it — `spawn()`\n * waits on `ready()`, which is what turns a spawner that fails into a spawn\n * that fails, with its own error intact. Whoever is already parked in\n * `wait()` is told as well; a later `wait()` sees the process as ended.\n */\n private pvtStartFailed(e: unknown): void {\n this.pvtDead = true;\n // Abandon the generator: it is already finished (it threw), but nothing\n // may tick it again.\n this.current = null;\n this.buffer.length = 0;\n this.nextTick?.cancel();\n this.nextTick = null;\n this.pvtUnsubscribeAll();\n\n this.pvtReady.reject(e);\n this.pvtExitReject?.(e);\n this.pvtExitReject = null;\n this.exitWaiter.resolve();\n }\n\n /** Wrap the user's generator so EXIT/STOP logic fires on completion. */\n private async *pvtWatchExit(\n ctx: ProcessCtx<Args, State, InMessage, OutMessage>,\n arg0: Args,\n ): AsyncProcessGenerator<State, InMessage> {\n try {\n yield* this.pgenerator(ctx, arg0);\n } finally {\n // Cascade: stop every child (nice) and collect the refusers as orphans.\n const orphans: Array<AnyProcess> = [...this.orphans];\n const parentSender: SenderInfo = { fromName: this.pname, fromId: this.id };\n const stopPromises = this.children.map(async (child) => {\n const stopped = await child.stop({ from: parentSender });\n if (!stopped) {\n orphans.push(child);\n console.warn(\n `posipaki: child \"${child.pname}\" did not stop within ${CHILD_STOP_TIMEOUT_MS}ms; continuing shutdown`,\n );\n }\n });\n\n await Promise.all(stopPromises);\n // Hand surviving children and inherited orphans up to the parent for adoption (see ctx-orphans proposal).\n // In-process only.\n this.pvtPrepareHandoff(orphans);\n // Why it ended, when it said: a stop that was agreed to is not the news a wire that went\n // away is (`CHANNEL_LOST`), and neither is a child that finished what it was for.\n ctx.toParent({\n type: \"EXIT\",\n ...(ctx.exitReason === undefined ? {} : { reason: ctx.exitReason }),\n orphans,\n });\n // Unsubscribe from children/monitored processes so a dead parent\n // doesn't keep receiving their messages (handoff collectors stay on the orphans).\n this.pvtUnsubscribeAll();\n // An actor that never got a state never started, and `afterEnd` is handed\n // a context whose state is typed as present: running it there means every\n // implementation that reads `this.state` trips over an undefined one —\n // and swaps the caller's error for its own TypeError.\n if (ctx.afterExit && this.pvtStarted) await ctx.afterExit();\n }\n }\n\n // ---- fork -----------------------------------------------------------------\n\n fork<ChildArgs, ChildState, ChildIM extends Message, ChildOM extends Message>(\n fn: AsyncProcessFn<ChildArgs, ChildState, ChildIM, ChildOM>,\n pname: string,\n ): (args: ChildArgs) => AsyncProcess<ChildArgs, ChildState, ChildIM, ChildOM, {}> {\n return (args: ChildArgs) => {\n const child = new AsyncProcess<ChildArgs, ChildState, ChildIM, ChildOM, {}>(fn, pname);\n this.adopt(child);\n child.start(args, this.pname, this.id);\n return child;\n };\n }\n\n forkSync<ChildArgs, ChildState, ChildIM extends Message, ChildOM extends InMessage>(\n fn: ProcessFn<ChildArgs, ChildState, ChildIM, ChildOM>,\n pname: string,\n ): (args: ChildArgs) => AsyncProcess<ChildArgs, ChildState, ChildIM, ChildOM, {}> {\n return this.fork(asyncify(fn), pname);\n }\n\n // ---- message processing ---------------------------------------------------\n\n /**\n * Give a parked dispatch loop one chance to notice a flag that was set from\n * outside it. Clearing `done` is not enough on its own: an idle process is\n * suspended at its dispatch yield, and nothing re-reads the flag until\n * something resumes it. A stop that arrives as a message (STOP) resumes the\n * loop by itself; this is for the paths that do not.\n */\n pvtWake(): void {\n if (this.pvtDead || !this.pvtDispatchLive) return;\n // The loop is running right now: it re-checks the flag as soon as the\n // reducer returns, so a wake-up message would only sit in the buffer.\n if (this.pvtTickInProgress) return;\n this.send([{ type: INTERNAL_ADVANCE } as InMessage, internalSender()]);\n }\n\n protected async pvtTick(): Promise<void> {\n // A message that arrives before the initial state is delivered is kept in\n // the buffer, not fed to the generator: the generator is still suspended at\n // its initial yield, and the value sent to that yield is discarded — the\n // message would be lost and `start()`'s advance would take its place.\n if (!this.current || !this.pvtDispatchLive || this.pvtTickInProgress) return;\n\n this.pvtTickInProgress = true;\n try {\n let msgAndSender: WithSender<InMessage | StopMessage> | undefined;\n let ret: IteratorResult<State | null, void> | null = null;\n while ((msgAndSender = this.buffer.shift()) !== undefined) {\n ret = await this.pvtSafeNext(msgAndSender);\n if (!ret || ret.done) break;\n }\n this.notify();\n this.pvtEatResult(ret);\n } catch (e) {\n this.pvtExitReject?.(e);\n this.pvtExitReject = null;\n } finally {\n this.pvtTickInProgress = false;\n }\n }\n\n /** Call `.next()` and redirect unhandled rejections. */\n private async pvtSafeNext(\n msgAndSender: WithSender<InMessage | StopMessage>,\n ): Promise<IteratorResult<State | null, void> | null> {\n try {\n return await this.current!.next(msgAndSender);\n } catch (e) {\n this.pvtExitReject?.(e);\n this.pvtExitReject = null;\n return { done: true, value: undefined };\n }\n }\n\n private pvtEatResult(\n ret: IteratorResult<State | null, void> | Promise<IteratorResult<State | null, void>> | null,\n ): void {\n if (!ret) return;\n Promise.resolve(ret).then((r) => {\n if (r.done) {\n this.exitWaiter.resolve();\n }\n });\n }\n\n /** Broadcast a message to all children. */\n toAllChildren(msg: Message): void {\n const stamp: SenderInfo = { fromName: this.pname, fromId: this.id };\n this.children.forEach((p) => p.send([msg, stamp] as WithSender<Message>));\n }\n\n /** Stamp and enqueue a message from a named sender (external API). */\n send(msg: InMessage | StopMessage, from?: SenderInfo): void;\n /** Enqueue a pre-stamped message (internal: fromChild, toAllChildren). */\n send(msgAndSender: WithSender<InMessage | StopMessage>): void;\n send(\n msgOrTuple: InMessage | StopMessage | WithSender<InMessage | StopMessage>,\n from?: SenderInfo,\n ): void {\n if (this.pvtDead) return;\n if (\"type\" in msgOrTuple) {\n this.buffer.push([msgOrTuple as InMessage | StopMessage, from as SenderInfo]);\n } else {\n this.buffer.push(msgOrTuple as WithSender<InMessage | StopMessage>);\n }\n this.pvtScheduleTick();\n }\n\n /**\n * Synchronously flush the buffer. For sync processes use {@link Process.tick};\n * for async processes this is **not guaranteed** to process everything\n * immediately if reducers contain `await`. Prefer `send()` + `await proc.wait()`.\n */\n tick(): void {\n this.nextTick?.flush();\n this.nextTick = null;\n }\n\n private pvtScheduleTick(): void {\n if (this.pvtIsPaused || this.pvtDead) return;\n\n this.nextTick?.cancel();\n this.nextTick = defer(() => {\n this.nextTick = null;\n void this.pvtTick();\n });\n }\n\n // ---- subscribers ----------------------------------------------------------\n\n notify(): void {\n this.stateSubscribers.forEach((f) => f());\n }\n\n get isListenedTo(): boolean {\n return this.stateSubscribers.length > 0;\n }\n\n subscribe(channel: \"message\", cb: MessageCallback<OutMessage>): () => void;\n subscribe(channel: \"state\", cb: NotifyFn): () => void;\n /** @deprecated Use `subscribe(\"state\", cb)`. */\n subscribe(cb: NotifyFn): () => void;\n subscribe(\n channelOrCb: \"message\" | \"state\" | NotifyFn,\n cb?: MessageCallback<OutMessage> | NotifyFn,\n ): () => void {\n if (typeof channelOrCb === \"function\") {\n return this.subscribe(\"state\", channelOrCb);\n }\n if (channelOrCb === \"message\") {\n const fn = cb as MessageCallback<OutMessage>;\n this.messageSubscribers.push(fn);\n return () => this.pvtUnsubscribe(this.messageSubscribers, fn);\n }\n const fn = cb as NotifyFn;\n this.stateSubscribers.push(fn);\n return () => this.pvtUnsubscribe(this.stateSubscribers, fn);\n }\n\n private pvtUnsubscribe<T>(list: Array<T>, fn: T): void {\n const idx = list.indexOf(fn);\n if (idx >= 0) list.splice(idx, 1);\n }\n\n // ---- pause / resume -------------------------------------------------------\n\n /**\n * Freeze dispatch: no further ticks are scheduled, so the process stops\n * *processing* incoming messages. This is half-working as a \"quiesce\"\n * primitive — it does not stop the process from *emitting* via async\n * callbacks (timers, fetch) that bypass the dispatch loop.\n */\n pause(): void {\n this.nextTick?.cancel();\n this.nextTick = null;\n this.pvtIsPaused = true;\n }\n\n resume(): void {\n this.pvtIsPaused = false;\n this.pvtScheduleTick();\n }\n\n /**\n * Hard-kill this process: abandon the generator without running its\n * `finally` (no EXIT, no STOP cascade), drop the inbox and observers,\n * unsubscribe from children/monitors, and settle `wait()`/`ready()`.\n *\n * There is nothing to observe afterward — callers remove the process from\n * their `children`/`orphans` lists imperatively. Does not cascade to this\n * process's own children; they are abandoned (force-stop them separately if\n * owned).\n *\n * Best-effort: an idle generator (suspended at `yield`) is abandoned\n * cleanly; a generator mid-`await` completes its `finally` when that await\n * settles, because JS offers no way to cancel a pending promise.\n */\n forceStop(opts?: { cascade?: boolean }): void {\n if (this.pvtDead) return;\n this.pvtDead = true;\n\n // Abandon the generator so its finally block never runs.\n this.current = null;\n\n // Drop the inbox and stop scheduling.\n this.buffer.length = 0;\n this.nextTick?.cancel();\n this.nextTick = null;\n\n // Release incoming observers and outgoing subscriptions.\n this.messageSubscribers.length = 0;\n this.stateSubscribers.length = 0;\n this.pvtUnsubscribeAll();\n // Drop any handoff state this process carried as an unowned orphan.\n this.unparent();\n\n // Settle waiters.\n this.pvtResolveReady();\n this.exitWaiter.resolve();\n this.pvtExitReject = null;\n\n if (opts?.cascade) {\n // Stop the children too, starting with the nice stop (fire-and-forget:\n // the hard kill itself does not block on their graceful exit).\n const selfSender: SenderInfo = { fromName: this.pname, fromId: this.id };\n for (const child of this.children) {\n void child.stop({ force: true, from: selfSender }).catch(() => {});\n }\n }\n }\n\n /**\n * Stop this process. Sends STOP (the nice way — the generator cooperates\n * and its `finally` runs) and awaits on a best-effort basis.\n *\n * With `{ force: true }`, when the process refuses (does not exit within the\n * timeout) it escalates: fires `generator.return()` *without awaiting* (throw\n * the generator away for GC to find), cascades to children with the same\n * ladder, then hard-kills itself.\n *\n * Resolves `true` if the process stopped (gracefully or forced), `false` if\n * it refused and `force` was not requested.\n */\n async stop(opts?: { force?: boolean; from?: SenderInfo }): Promise<boolean> {\n if (this.pvtDead) return true;\n\n this.send({ type: \"STOP\" } as StopMessage, opts?.from);\n\n try {\n await withTimeout(this.wait(), CHILD_STOP_TIMEOUT_MS, \"stop\");\n return true;\n } catch (e) {\n if ((e as Error)?.message !== \"Timeout:stop\") throw e;\n // refused to stop within the timeout\n }\n\n if (!opts?.force) return false;\n\n // Escalate: give the finally a chance to run (fire-and-forget), but do not\n // block on it — the process may be stuck awaiting a dead promise.\n void this.current?.return(undefined);\n\n // Cascade to children with the same ladder, stamped from this process.\n const selfSender: SenderInfo = { fromName: this.pname, fromId: this.id };\n await Promise.all(\n [...this.children].map((child) => child.stop({ force: true, from: selfSender })),\n );\n\n this.forceStop();\n return true;\n }\n\n // ---- waiting --------------------------------------------------------------\n\n /**\n * Returns a promise that resolves when the generator completes, or\n * rejects if an unhandled error occurs during message processing.\n */\n wait(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n this.pvtExitReject = reject;\n\n this.exitWaiter.promise.then(\n () => {\n this.pvtExitReject = null;\n resolve();\n },\n (e) => {\n this.pvtExitReject = null;\n reject(e);\n },\n );\n });\n }\n\n // ---- child messages -------------------------------------------------------\n\n /**\n * Tap another process's message channel: every message it emits is fed\n * into this process's incoming queue. No ownership — the sender's EXIT\n * does not touch `children`/`orphans`.\n */\n monitor<ChildArgs, ChildState, ChildIM extends Message, ChildOM extends Message>(\n child: AsyncProcess<ChildArgs, ChildState, ChildIM, ChildOM, {}>,\n ): () => void {\n const unsub = child.subscribe(\"message\", (msg, from) => {\n this.send([msg, from] as WithSender<InMessage | StopMessage>);\n });\n this.pvtOutgoingSubscriptions.push(unsub);\n return unsub;\n }\n\n /**\n * Claim another process as a child: its messages are routed here and its\n * EXIT removes it from `children` (collecting its orphans). Generalizes\n * what `fork` does — used for both spawning and orphan adoption.\n */\n adopt<ChildArgs, ChildState, ChildIM extends Message, ChildOM extends Message>(\n child: AsyncProcess<ChildArgs, ChildState, ChildIM, ChildOM, {}>,\n ): () => void {\n this.children.push(child as unknown as AnyProcess);\n const unsub = child.subscribe(\"message\", (msg, from) => {\n this.pvtChildMessage(msg, from);\n });\n this.pvtAdoptUnsubs.set(child.id, unsub);\n // Lossless handoff: drain a pending buffer left by the previous parent.\n this.pvtDrainPending(child as unknown as AnyProcess);\n return unsub;\n }\n\n /** Handles a child's emitted message: EXIT cleanup + forward to the queue. */\n private pvtChildMessage(msg: Message, sender: SenderInfo): void {\n if (msg.type === \"EXIT\") {\n // sender.fromId === child's id (stamped by the child's ctx.toParent)\n // Mutate in place so ctx.children (a live reference) stays consistent.\n const idx = this.children.findIndex((p) => p.id === sender.fromId);\n if (idx >= 0) this.children.splice(idx, 1);\n const orphans = (msg as ExitMessage).orphans;\n if (orphans && orphans.length > 0) {\n this.orphans.push(...orphans);\n }\n }\n this.send([msg, sender] as WithSender<InMessage | StopMessage>);\n }\n\n // ---- orphan handoff -------------------------------------------------------\n\n /** Unsubscribe from all outgoing subscriptions (monitors + adopt). */\n private pvtUnsubscribeAll(): void {\n for (const unsub of this.pvtOutgoingSubscriptions) unsub();\n this.pvtOutgoingSubscriptions = [];\n for (const unsub of this.pvtAdoptUnsubs.values()) unsub();\n this.pvtAdoptUnsubs.clear();\n }\n\n /** Prepare surviving children and inherited orphans for a lossless handoff:\n * recover undrained messages and install a collector on each orphan. */\n private pvtPrepareHandoff(orphans: Array<AnyProcess>): void {\n for (const orphan of orphans) {\n this.pvtBackFeed(orphan);\n if (!orphan.pvtCollectorUnsub) {\n this.pvtSwapToCollector(orphan);\n }\n }\n }\n\n /** Recover messages the orphan emitted into my inbox that I never drained. */\n private pvtBackFeed(orphan: AnyProcess): void {\n const fromOrphan: Array<WithSender<Message>> = [];\n this.buffer = this.buffer.filter((entry) => {\n if (entry[1].fromId === orphan.id) {\n fromOrphan.push(entry);\n return false;\n }\n return true;\n });\n if (fromOrphan.length === 0) return;\n if (!orphan.pvtPending) orphan.pvtPending = [];\n orphan.pvtPending.unshift(...fromOrphan);\n }\n\n /** Replace my ownership subscription to `orphan` with a handoff collector. */\n private pvtSwapToCollector(orphan: AnyProcess): void {\n const mine = this.pvtAdoptUnsubs.get(orphan.id);\n if (mine) {\n mine();\n this.pvtAdoptUnsubs.delete(orphan.id);\n }\n if (!orphan.pvtPending) orphan.pvtPending = [];\n const pending = orphan.pvtPending;\n orphan.pvtCollectorUnsub = orphan.subscribe(\"message\", (msg, from) => {\n pending.push([msg, from]);\n });\n }\n\n /** Drain a handed-off orphan's pending buffer into my inbox (lossless adopt). */\n private pvtDrainPending(orphan: AnyProcess): void {\n if (orphan.pvtCollectorUnsub) {\n orphan.pvtCollectorUnsub();\n orphan.pvtCollectorUnsub = null;\n }\n const pending = orphan.pvtPending;\n if (!pending) return;\n orphan.pvtPending = null;\n for (const [msg, from] of pending) {\n this.pvtChildMessage(msg, from);\n }\n }\n\n /**\n * Drop this process's handoff state (collector + pending buffer) without\n * stopping it. Used by `onOrphan`'s \"unparent\" decision: the orphan keeps\n * running and stays in the orphans list, but its in-flight buffer is gone.\n */\n unparent(): void {\n if (this.pvtCollectorUnsub) {\n this.pvtCollectorUnsub();\n this.pvtCollectorUnsub = null;\n }\n this.pvtPending = null;\n }\n}\nexport type AnyProcess = AsyncProcess<unknown, unknown, Message, Message, {}>;\n\n/**\n * Whether a value is a process, judged by what it holds rather than by which\n * class built it. `instanceof` would answer about the bundle, not the value: a\n * build that inlines its own copy of this class per entry point (one dist file\n * importing the core, another doing the same) has two constructors for one kind\n * of thing, and a process from one is not an instance of the other.\n */\nexport function isProcess(value: unknown): value is AnyProcess {\n if (typeof value !== \"object\" || value === null) return false;\n const candidate = value as Partial<AnyProcess>;\n return (\n typeof candidate.pname === \"string\" &&\n typeof candidate.id === \"symbol\" &&\n typeof candidate.send === \"function\" &&\n typeof candidate.fork === \"function\"\n );\n}\n// ---- spawnAsync -------------------------------------------------------------\n\n/**\n * Spawn a new async process. Accepts both sync and async process\n * functions — sync ones are automatically wrapped with {@link asyncify}.\n */\nexport function spawnAsync<\n Args,\n State,\n InMessage extends Message = Message,\n OutMessage extends Message = ExitMessage,\n>(\n fn: AsyncProcessFn<Args, State, InMessage, OutMessage>,\n pname: string,\n toParent?: MessageCallback<OutMessage>,\n parentName?: string | null,\n parentId?: symbol | null,\n connection?: FrameChannel | null,\n): (args: Args) => AsyncProcess<Args, State, InMessage, OutMessage, {}> {\n return (args: Args) => {\n const proc = new AsyncProcess<Args, State, InMessage, OutMessage, {}>(fn, pname, toParent);\n proc.start(args, parentName, parentId);\n proc.connection = connection ?? null;\n return proc;\n };\n}\n"],"mappings":";;AAEA,SAAgB,SACd,IAC8B;CAC9B,OAAO,iBAAiB,KAAK,MAAM;EACjC,OAAO,GAAG,KAAK,IAAI;CACrB;AACF;;;;;;;;;ACwBA,MAAa,mBAAmB;;AAGhC,MAAM,wBAAoC;CACxC,UAAU;CACV,QAAQ,OAAO,cAAc;AAC/B;;;;;;AAYA,gBAAuB,iBACrB,MACA,IACA,gBAAyB,OACzB,aAAa,OACkB;CAC/B,IAAI;CACJ,OAAO,CAAC,QAAQ,GAAG;EACjB,MAAM,MAAM;EACZ,SAAS,YAAY,OAAO,MAAM,QAAQ,GAAG;EAC7C,MAAM,GAAG,GAAG;CACd;AACF;;AASA,MAAM,wBAAwB;;;;;;;;;AAU9B,IAAa,eAAb,MAAa,aAMX;CAsDA,YACE,IACA,OACA,UACA;EAtD+B,KAAA,cAAA,CAAC;EAQA,KAAA,aAAA;EAE+B,KAAA,qBAAA,CAAC;EAIA,KAAA,UAAA;EAEL,KAAA,SAAA,CAAC;EACtB,KAAA,WAAA;EAEgC,KAAA,WAAA,CAAC;EAEF,KAAA,UAAA,CAAC;EAC5B,KAAA,mBAAA,CAAC;EAES,KAAA,2BAAA,CAAC;EAEL,KAAA,iCAAA,IAAI,IAAI;EAEF,KAAA,aAAA;EAEP,KAAA,oBAAA;EAElB,K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