@kyneta/machine 1.5.2 → 1.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/dispatcher.ts","../src/machine.ts","../src/observable.ts"],"mappings":";;AAcA;;;;;;KAAY,KAAA;EACV,KAAA;EACA,UAAA;EAAA,SACS,MAAA;EACT,OAAA;IAAW,KAAA;IAAe,IAAA;EAAA;EAAA,SACjB,eAAA;AAAA;AAAA,KAGC,YAAA;EACV,MAAA;EACA,eAAA;AAAA;AAAA,iBAGc,WAAA,CAAY,OAAA,GAAU,YAAA,GAAe,KAAA;AAAA,cAUxC,oBAAA,SAA6B,KAAA;EAAA,SAC/B,KAAA,EAAO,KAAA;EAAA,SACP,KAAA;cACG,KAAA,UAAe,KAAA,EAAO,KAAA;AAAA;AAAA,KAaxB,iBAAA;EACV,KAAA,GAAQ,KAAA;EACR,KAAA;AAAA;AAAA,UAGe,gBAAA;EACf,QAAA,CAAS,GAAA,EAAK,GAAA;EAAA,SACL,UAAA;AAAA;;;;;;;;;;iBAYK,gBAAA,KAAA,CACd,OAAA,GAAU,GAAA,EAAK,GAAA,EAAK,QAAA,GAAW,GAAA,EAAK,GAAA,oBACpC,OAAA,GAAU,iBAAA,GACT,gBAAA,CAAiB,GAAA;;;;KC1ER,QAAA,SAAiB,GAAA,EAAK,GAAA;;KAGtB,MAAA,SAAe,QAAA,EAAU,QAAA,CAAS,GAAA;;;;;;;;;;;ADkB9C;;KCJY,OAAA,kBAAyB,MAAA,CAAO,GAAA;EAC1C,IAAA,GAAO,KAAA,KAAU,EAAA;EACjB,MAAA,CAAO,GAAA,EAAK,GAAA,EAAK,KAAA,EAAO,KAAA,IAAS,KAAA,KAAU,EAAA;EAC3C,IAAA,EAAM,KAAA,EAAO,KAAA;AAAA;;KAIH,QAAA;;;;;;ADYZ;;;;;;;;;;iBCKgB,OAAA,YAAA,CACd,OA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AAC,CAAA;;AFjBhD;AAGjB;;;;;UE2BiB,gBAAA;EF3BoC;EE6BnD,QAAA,EAAU,QAAA,CAAS,GAAA;EF7BqC;EEgCxD,QAAA,IAAY,KAAA;EFtBoB;;;;;;EE8BhC,sBAAA,CAAuB,QAAA,EAAU,kBAAA,CAAmB,KAAA;EF9BZ;;;;;;EEsCxC,YAAA,CACE,SAAA,GAAY,KAAA,EAAO,KAAA,cACnB,OAAA;IAAY,SAAA;EAAA,IACX,OAAA,CAAQ,KAAA;EFtC4B;AAazC;;;;EEgCE,aAAA;IAA0B,MAAA;EAAA,GACxB,IAAA,EAAM,gBAAA,CAAiB,GAAA,EAAK,CAAA,GAC5B,MAAA,EAAQ,CAAA,YACR,OAAA;IAAY,SAAA;EAAA,IACX,OAAA,CAAQ,CAAA;EF/BI;;;EEoCf,OAAA;AAAA;;;;;;AFlCmB;AAYrB;;;;;;;;;;;;;;iBEiDgB,uBAAA,gBAAA,CACd,OAAA,EAAS,OAAA,CAAQ,GAAA,EAAK,KAAA,EAAO,EAAA,GAC7B,QAAA,GAAW,MAAA,EAAQ,EAAA,EAAI,QAAA,EAAU,QAAA,CAAS,GAAA,YAC1C,OAAA;EAAY,KAAA,GAAQ,KAAA;EAAO,KAAA;AAAA,IAC1B,gBAAA,CAAiB,GAAA,EAAK,KAAA"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/dispatcher.ts","../src/machine.ts","../src/observable.ts"],"sourcesContent":["// dispatcher — drain-to-quiescence primitive shared by reactive frontiers.\n//\n// createDispatcher() is the underlying primitive that the input-processing\n// loop in createObservableProgram is built on. Factoring it out as a named\n// export lets cooperating dispatchers share a Lease — a single iteration\n// budget and re-entry depth tracker that bounds runaway cascades.\n\n/**\n * Shared iteration budget for cooperating dispatchers.\n *\n * A Lease is a plain mutable record. Dispatchers mutate its fields\n * directly; no methods. When `depth` goes 0→1 a dispatcher becomes the\n * owner and resets `iterations`/`history` on its eventual 1→0 exit.\n */\nexport type Lease = {\n depth: number\n iterations: number\n readonly budget: number\n history: { label: string; type: string }[]\n readonly historyCapacity: number\n}\n\nexport type LeaseOptions = {\n budget?: number\n historyCapacity?: number\n}\n\nexport function createLease(options?: LeaseOptions): Lease {\n return {\n depth: 0,\n iterations: 0,\n budget: options?.budget ?? 100_000,\n history: [],\n historyCapacity: options?.historyCapacity ?? 32,\n }\n}\n\nexport class BudgetExhaustedError extends Error {\n readonly lease: Lease\n readonly label: string\n constructor(label: string, lease: Lease) {\n super(\n `[dispatcher:${label}] iteration budget exhausted (${lease.iterations} > ${lease.budget}); ` +\n `recent: ${lease.history.map(h => `${h.label}:${h.type}`).join(\", \")}`,\n )\n this.name = \"BudgetExhaustedError\"\n // Snapshot the lease so the history survives the owning dispatcher's\n // finally-block reset that runs as the exception unwinds.\n this.lease = { ...lease, history: [...lease.history] }\n this.label = label\n }\n}\n\nexport type DispatcherOptions = {\n lease?: Lease\n label?: string\n}\n\nexport interface DispatcherHandle<Msg> {\n dispatch(msg: Msg): void\n readonly queueDepth: number\n}\n\n/**\n * Drain-to-quiescence dispatcher with optional shared budget.\n *\n * Re-entrant `dispatch(msg)` from inside the handler — including from\n * another `DispatcherHandle.dispatch(...)` sharing the same Lease —\n * joins the current drain rather than recursing. This is the property\n * that lets cooperating dispatchers compose: an A→B→A oscillation is\n * one cascade in one lease, not a stack overflow.\n */\nexport function createDispatcher<Msg>(\n handler: (msg: Msg, dispatch: (msg: Msg) => void) => void,\n options?: DispatcherOptions,\n): DispatcherHandle<Msg> {\n const lease = options?.lease ?? createLease()\n const label = options?.label ?? \"dispatcher\"\n const pending: Msg[] = []\n let isDispatching = false\n\n function dispatch(msg: Msg): void {\n pending.push(msg)\n if (isDispatching) return\n\n isDispatching = true\n const owns = lease.depth === 0\n lease.depth += 1\n try {\n while (pending.length > 0) {\n const next = pending.shift()!\n lease.iterations += 1\n const type =\n typeof next === \"object\" && next !== null && \"type\" in next\n ? String((next as { type: unknown }).type)\n : \"<untyped>\"\n if (lease.history.length >= lease.historyCapacity) {\n lease.history.shift()\n }\n lease.history.push({ label, type })\n if (lease.iterations > lease.budget) {\n throw new BudgetExhaustedError(label, lease)\n }\n handler(next, dispatch)\n }\n } finally {\n lease.depth -= 1\n if (owns) {\n lease.iterations = 0\n lease.history.length = 0\n }\n isDispatching = false\n }\n }\n\n return {\n dispatch,\n get queueDepth(): number {\n return pending.length\n },\n }\n}\n","/** Dispatch a message into a running program. */\nexport type Dispatch<Msg> = (msg: Msg) => void\n\n/** An effect is a continuation that may dispatch messages. */\nexport type Effect<Msg> = (dispatch: Dispatch<Msg>) => void\n\n/**\n * A Mealy machine — pure state transitions with effect outputs.\n *\n * `Fx` defaults to `Effect<Msg>` (closure effects) but can be any\n * data type for programs with custom effect executors.\n *\n * - `init`: initial state and zero or more effects to execute at startup.\n * - `update`: pure transition — given a message and the current state,\n * return the new state and zero or more effects.\n * - `done`: optional teardown hook, called with the final state when\n * the runtime is disposed.\n */\nexport type Program<Msg, Model, Fx = Effect<Msg>> = {\n init: [Model, ...Fx[]]\n update(msg: Msg, model: Model): [Model, ...Fx[]]\n done?(model: Model): void\n}\n\n/** Dispose a running program — stops message processing and calls `done`. */\nexport type Disposer = () => void\n\n/**\n * Run a program whose effects are `Effect<Msg>` closures.\n *\n * The runtime:\n * 1. Extracts `[model, ...effects]` from `program.init`.\n * 2. Executes each initial effect with `dispatch`.\n * 3. Calls `view(model, dispatch)` if provided.\n * 4. On `dispatch(msg)`: calls `update(msg, state)`, updates state,\n * executes effects, calls `view`.\n * 5. Returns a `Disposer` that stops dispatch and calls `program.done`.\n *\n * Effects are executed synchronously in order. An effect may call\n * `dispatch` re-entrantly — the runtime processes re-entrant messages\n * after the current dispatch cycle completes (queue-based).\n */\nexport function runtime<Msg, Model>(\n program: Program<Msg, Model>,\n view?: (model: Model, dispatch: Dispatch<Msg>) => void,\n): Disposer {\n let state: Model\n let isRunning = true\n const pending: Msg[] = []\n let isDispatching = false\n\n function dispatch(msg: Msg): void {\n if (!isRunning) return\n\n pending.push(msg)\n if (isDispatching) return\n\n isDispatching = true\n try {\n while (pending.length > 0) {\n const next = pending.shift()!\n const [newModel, ...effects] = program.update(next, state)\n state = newModel\n for (const effect of effects) {\n effect(dispatch)\n }\n if (view) view(state, dispatch)\n }\n } finally {\n isDispatching = false\n }\n }\n\n // Initialize\n const [initialModel, ...initialEffects] = program.init\n state = initialModel\n for (const effect of initialEffects) {\n effect(dispatch)\n }\n if (view) view(state, dispatch)\n\n // Return disposer\n return () => {\n if (!isRunning) return\n isRunning = false\n program.done?.(state)\n }\n}\n","// observable — data-effect runtime with state observation.\n//\n// createObservableProgram() is the data-effect counterpart to runtime().\n// Where runtime() executes closure effects (Effect<Msg>), this function\n// accepts a custom executor for data effects (Fx). It also provides\n// state observation: subscribeToTransitions, waitForState, waitForStatus.\n//\n// This subsumes ClientStateMachine's observation API and the peer program's\n// hand-rolled dispatch loop. Transition delivery is synchronous — the\n// listener fires after each update. The microtask-batched delivery from\n// ClientStateMachine is unnecessary complexity that no consumer depends on.\n\nimport { createDispatcher, type Lease } from \"./dispatcher.js\"\nimport type { Dispatch, Program } from \"./machine.js\"\n\n// ---------------------------------------------------------------------------\n// Ambient declarations for timer APIs (not in lib: [\"ESNext\"])\n// ---------------------------------------------------------------------------\n\ndeclare function setTimeout(callback: () => void, ms: number): unknown\ndeclare function clearTimeout(id: unknown): void\n\n// ---------------------------------------------------------------------------\n// Observation types\n// ---------------------------------------------------------------------------\n\n/**\n * A state transition event — from one model to another.\n *\n * Generic over the model type. This is the machine-level primitive;\n * transport packages re-export or alias it for their specific state types.\n */\nexport type StateTransition<S> = {\n from: S\n to: S\n timestamp: number\n}\n\n/**\n * Listener for state transitions.\n */\nexport type TransitionListener<S> = (transition: StateTransition<S>) => void\n\n// ---------------------------------------------------------------------------\n// ObservableHandle\n// ---------------------------------------------------------------------------\n\n/**\n * Handle for a running observable program.\n *\n * Provides dispatch, state access, transition observation, and disposal.\n * The observation API (`subscribeToTransitions`, `waitForState`, `waitForStatus`)\n * matches the surface of the former `ClientStateMachine<S>`.\n */\nexport interface ObservableHandle<Msg, Model> {\n /** Dispatch a message into the program. */\n dispatch: Dispatch<Msg>\n\n /** Get the current model synchronously. */\n getState(): Model\n\n /**\n * Subscribe to state transitions.\n *\n * Transitions are delivered synchronously after each update.\n * Returns an unsubscribe function.\n */\n subscribeToTransitions(listener: TransitionListener<Model>): () => void\n\n /**\n * Wait for a specific state.\n *\n * Resolves immediately if the current state matches the predicate.\n * Otherwise waits for a transition that matches.\n */\n waitForState(\n predicate: (state: Model) => boolean,\n options?: { timeoutMs?: number },\n ): Promise<Model>\n\n /**\n * Wait for a specific status string on a model with a `status` discriminant.\n *\n * Convenience wrapper around `waitForState()`.\n */\n waitForStatus<S extends { status: string }>(\n this: ObservableHandle<Msg, S>,\n status: S[\"status\"],\n options?: { timeoutMs?: number },\n ): Promise<S>\n\n /**\n * Dispose the program — stops dispatch and calls `program.done`.\n */\n dispose(): void\n}\n\n// ---------------------------------------------------------------------------\n// createObservableProgram\n// ---------------------------------------------------------------------------\n\n/**\n * Run a program with data effects and state observation.\n *\n * Like `runtime()`, but instead of executing closure effects directly,\n * it delegates to a custom `executor` for each data effect. This enables\n * programs whose effects are inspectable data types (not opaque closures).\n *\n * The runtime:\n * 1. Extracts `[model, ...effects]` from `program.init`.\n * 2. Executes each initial effect via `executor(effect, dispatch)`.\n * 3. On `dispatch(msg)`: calls `update(msg, state)`, updates state,\n * notifies transition listeners, executes effects.\n * 4. Re-entrant dispatch (effect calls dispatch) is queued and processed\n * after the current dispatch cycle completes.\n * 5. `dispose()` stops dispatch and calls `program.done`.\n *\n * @param program - The program algebra: init, update, done.\n * @param executor - Interprets data effects as I/O.\n * @returns An observable handle for the running program.\n */\nexport function createObservableProgram<Msg, Model, Fx>(\n program: Program<Msg, Model, Fx>,\n executor: (effect: Fx, dispatch: Dispatch<Msg>) => void,\n options?: { lease?: Lease; label?: string },\n): ObservableHandle<Msg, Model> {\n let state: Model\n let isRunning = true\n const listeners = new Set<TransitionListener<Model>>()\n\n // --------------------------------------------------------------------------\n // Transition notification\n // --------------------------------------------------------------------------\n\n function notifyTransition(from: Model, to: Model): void {\n if (from === to) return\n\n const transition: StateTransition<Model> = {\n from,\n to,\n timestamp: Date.now(),\n }\n\n for (const listener of listeners) {\n try {\n listener(transition)\n } catch {\n // Swallow listener errors — observers must not break dispatch.\n }\n }\n }\n\n // --------------------------------------------------------------------------\n // Dispatch\n // --------------------------------------------------------------------------\n\n const handle = createDispatcher<Msg>(\n (msg, redispatch) => {\n if (!isRunning) return\n const prev = state\n const [newModel, ...effects] = program.update(msg, state)\n state = newModel\n notifyTransition(prev, state)\n for (const effect of effects) {\n executor(effect, redispatch)\n }\n },\n { lease: options?.lease, label: options?.label ?? \"observable\" },\n )\n\n function dispatch(msg: Msg): void {\n if (!isRunning) return\n handle.dispatch(msg)\n }\n\n // --------------------------------------------------------------------------\n // Observation\n // --------------------------------------------------------------------------\n\n function getState(): Model {\n return state\n }\n\n function subscribeToTransitions(\n listener: TransitionListener<Model>,\n ): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n }\n\n function waitForState(\n predicate: (state: Model) => boolean,\n options?: { timeoutMs?: number },\n ): Promise<Model> {\n // Resolve immediately if already matching\n if (predicate(state)) {\n return Promise.resolve(state)\n }\n\n return new Promise((resolve, reject) => {\n let timeoutId: unknown\n\n const unsubscribe = subscribeToTransitions(transition => {\n if (predicate(transition.to)) {\n cleanup()\n resolve(transition.to)\n }\n })\n\n const cleanup = () => {\n unsubscribe()\n if (timeoutId !== undefined) {\n clearTimeout(timeoutId)\n }\n }\n\n if (options?.timeoutMs !== undefined) {\n timeoutId = setTimeout(() => {\n cleanup()\n reject(\n new Error(`Timeout waiting for state after ${options.timeoutMs}ms`),\n )\n }, options.timeoutMs)\n }\n })\n }\n\n function waitForStatus<S extends { status: string }>(\n this: ObservableHandle<Msg, S>,\n status: S[\"status\"],\n options?: { timeoutMs?: number },\n ): Promise<S> {\n return this.waitForState((s: S) => s.status === status, options)\n }\n\n function dispose(): void {\n if (!isRunning) return\n isRunning = false\n program.done?.(state)\n }\n\n // --------------------------------------------------------------------------\n // Initialize\n // --------------------------------------------------------------------------\n\n const [initialModel, ...initialEffects] = program.init\n state = initialModel\n for (const effect of initialEffects) {\n executor(effect, dispatch)\n }\n\n // --------------------------------------------------------------------------\n // Return handle\n // --------------------------------------------------------------------------\n\n return {\n dispatch,\n getState,\n subscribeToTransitions,\n waitForState,\n waitForStatus,\n dispose,\n }\n}\n"],"mappings":";AA2BA,SAAgB,YAAY,SAA+B;AACzD,QAAO;EACL,OAAO;EACP,YAAY;EACZ,QAAQ,SAAS,UAAU;EAC3B,SAAS,EAAE;EACX,iBAAiB,SAAS,mBAAmB;EAC9C;;AAGH,IAAa,uBAAb,cAA0C,MAAM;CAC9C;CACA;CACA,YAAY,OAAe,OAAc;AACvC,QACE,eAAe,MAAM,gCAAgC,MAAM,WAAW,KAAK,MAAM,OAAO,aAC3E,MAAM,QAAQ,KAAI,MAAK,GAAG,EAAE,MAAM,GAAG,EAAE,OAAO,CAAC,KAAK,KAAK,GACvE;AACD,OAAK,OAAO;AAGZ,OAAK,QAAQ;GAAE,GAAG;GAAO,SAAS,CAAC,GAAG,MAAM,QAAQ;GAAE;AACtD,OAAK,QAAQ;;;;;;;;;;;;AAuBjB,SAAgB,iBACd,SACA,SACuB;CACvB,MAAM,QAAQ,SAAS,SAAS,aAAa;CAC7C,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,UAAiB,EAAE;CACzB,IAAI,gBAAgB;CAEpB,SAAS,SAAS,KAAgB;AAChC,UAAQ,KAAK,IAAI;AACjB,MAAI,cAAe;AAEnB,kBAAgB;EAChB,MAAM,OAAO,MAAM,UAAU;AAC7B,QAAM,SAAS;AACf,MAAI;AACF,UAAO,QAAQ,SAAS,GAAG;IACzB,MAAM,OAAO,QAAQ,OAAO;AAC5B,UAAM,cAAc;IACpB,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K,cAAc,MAAS,EAAE,WAAW,QAAQ,QAAQ;;CAGlE,SAAS,UAAgB;AACvB,MAAI,CAAC,UAAW;AAChB,cAAY;AACZ,UAAQ,OAAO,MAAM;;CAOvB,MAAM,CAAC,cAAc,GAAG,kBAAkB,QAAQ;AAClD,SAAQ;AACR,MAAK,MAAM,UAAU,eACnB,UAAS,QAAQ,SAAS;AAO5B,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/dispatcher.ts","../src/machine.ts","../src/observable.ts"],"sourcesContent":["// dispatcher — drain-to-quiescence primitive shared by reactive frontiers.\n//\n// createDispatcher() is the underlying primitive that the input-processing\n// loop in createObservableProgram is built on. Factoring it out as a named\n// export lets cooperating dispatchers share a Lease — a single iteration\n// budget and re-entry depth tracker that bounds runaway cascades.\n\n/**\n * Shared iteration budget for cooperating dispatchers.\n *\n * A Lease is a plain mutable record. Dispatchers mutate its fields\n * directly; no methods. When `depth` goes 0→1 a dispatcher becomes the\n * owner and resets `iterations`/`history` on its eventual 1→0 exit.\n */\nexport type Lease = {\n depth: number\n iterations: number\n readonly budget: number\n history: { label: string; type: string }[]\n readonly historyCapacity: number\n}\n\nexport type LeaseOptions = {\n budget?: number\n historyCapacity?: number\n}\n\nexport function createLease(options?: LeaseOptions): Lease {\n return {\n depth: 0,\n iterations: 0,\n budget: options?.budget ?? 100_000,\n history: [],\n historyCapacity: options?.historyCapacity ?? 32,\n }\n}\n\nexport class BudgetExhaustedError extends Error {\n readonly lease: Lease\n readonly label: string\n constructor(label: string, lease: Lease) {\n super(\n `[dispatcher:${label}] iteration budget exhausted (${lease.iterations} > ${lease.budget}); ` +\n `recent: ${lease.history.map(h => `${h.label}:${h.type}`).join(\", \")}`,\n )\n this.name = \"BudgetExhaustedError\"\n // Snapshot the lease so the history survives the owning dispatcher's\n // finally-block reset that runs as the exception unwinds.\n this.lease = { ...lease, history: [...lease.history] }\n this.label = label\n }\n}\n\nexport type DispatcherOptions = {\n lease?: Lease\n label?: string\n}\n\nexport interface DispatcherHandle<Msg> {\n dispatch(msg: Msg): void\n readonly queueDepth: number\n}\n\n/**\n * Drain-to-quiescence dispatcher with optional shared budget.\n *\n * Re-entrant `dispatch(msg)` from inside the handler — including from\n * another `DispatcherHandle.dispatch(...)` sharing the same Lease —\n * joins the current drain rather than recursing. This is the property\n * that lets cooperating dispatchers compose: an A→B→A oscillation is\n * one cascade in one lease, not a stack overflow.\n */\nexport function createDispatcher<Msg>(\n handler: (msg: Msg, dispatch: (msg: Msg) => void) => void,\n options?: DispatcherOptions,\n): DispatcherHandle<Msg> {\n const lease = options?.lease ?? createLease()\n const label = options?.label ?? \"dispatcher\"\n const pending: Msg[] = []\n let isDispatching = false\n\n function dispatch(msg: Msg): void {\n pending.push(msg)\n if (isDispatching) return\n\n isDispatching = true\n const owns = lease.depth === 0\n lease.depth += 1\n try {\n while (pending.length > 0) {\n const next = pending.shift()!\n lease.iterations += 1\n const type =\n typeof next === \"object\" && next !== null && \"type\" in next\n ? String((next as { type: unknown }).type)\n : \"<untyped>\"\n if (lease.history.length >= lease.historyCapacity) {\n lease.history.shift()\n }\n lease.history.push({ label, type })\n if (lease.iterations > lease.budget) {\n throw new BudgetExhaustedError(label, lease)\n }\n handler(next, dispatch)\n }\n } finally {\n lease.depth -= 1\n if (owns) {\n lease.iterations = 0\n lease.history.length = 0\n }\n isDispatching = false\n }\n }\n\n return {\n dispatch,\n get queueDepth(): number {\n return pending.length\n },\n }\n}\n","/** Dispatch a message into a running program. */\nexport type Dispatch<Msg> = (msg: Msg) => void\n\n/** An effect is a continuation that may dispatch messages. */\nexport type Effect<Msg> = (dispatch: Dispatch<Msg>) => void\n\n/**\n * A Mealy machine — pure state transitions with effect outputs.\n *\n * `Fx` defaults to `Effect<Msg>` (closure effects) but can be any\n * data type for programs with custom effect executors.\n *\n * - `init`: initial state and zero or more effects to execute at startup.\n * - `update`: pure transition — given a message and the current state,\n * return the new state and zero or more effects.\n * - `done`: optional teardown hook, called with the final state when\n * the runtime is disposed.\n */\nexport type Program<Msg, Model, Fx = Effect<Msg>> = {\n init: [Model, ...Fx[]]\n update(msg: Msg, model: Model): [Model, ...Fx[]]\n done?(model: Model): void\n}\n\n/** Dispose a running program — stops message processing and calls `done`. */\nexport type Disposer = () => void\n\n/**\n * Run a program whose effects are `Effect<Msg>` closures.\n *\n * The runtime:\n * 1. Extracts `[model, ...effects]` from `program.init`.\n * 2. Executes each initial effect with `dispatch`.\n * 3. Calls `view(model, dispatch)` if provided.\n * 4. On `dispatch(msg)`: calls `update(msg, state)`, updates state,\n * executes effects, calls `view`.\n * 5. Returns a `Disposer` that stops dispatch and calls `program.done`.\n *\n * Effects are executed synchronously in order. An effect may call\n * `dispatch` re-entrantly — the runtime processes re-entrant messages\n * after the current dispatch cycle completes (queue-based).\n */\nexport function runtime<Msg, Model>(\n program: Program<Msg, Model>,\n view?: (model: Model, dispatch: Dispatch<Msg>) => void,\n): Disposer {\n let state: Model\n let isRunning = true\n const pending: Msg[] = []\n let isDispatching = false\n\n function dispatch(msg: Msg): void {\n if (!isRunning) return\n\n pending.push(msg)\n if (isDispatching) return\n\n isDispatching = true\n try {\n while (pending.length > 0) {\n const next = pending.shift()!\n const [newModel, ...effects] = program.update(next, state)\n state = newModel\n for (const effect of effects) {\n effect(dispatch)\n }\n if (view) view(state, dispatch)\n }\n } finally {\n isDispatching = false\n }\n }\n\n // Initialize\n const [initialModel, ...initialEffects] = program.init\n state = initialModel\n for (const effect of initialEffects) {\n effect(dispatch)\n }\n if (view) view(state, dispatch)\n\n // Return disposer\n return () => {\n if (!isRunning) return\n isRunning = false\n program.done?.(state)\n }\n}\n","// observable — data-effect runtime with state observation.\n//\n// createObservableProgram() is the data-effect counterpart to runtime().\n// Where runtime() executes closure effects (Effect<Msg>), this function\n// accepts a custom executor for data effects (Fx). It also provides\n// state observation: subscribeToTransitions, waitForState, waitForStatus.\n//\n// This subsumes ClientStateMachine's observation API and the peer program's\n// hand-rolled dispatch loop. Transition delivery is synchronous — the\n// listener fires after each update. The microtask-batched delivery from\n// ClientStateMachine is unnecessary complexity that no consumer depends on.\n\nimport { createDispatcher, type Lease } from \"./dispatcher.js\"\nimport type { Dispatch, Program } from \"./machine.js\"\n\n// ---------------------------------------------------------------------------\n// Ambient declarations for timer APIs (not in lib: [\"ESNext\"])\n// ---------------------------------------------------------------------------\n\ndeclare function setTimeout(callback: () => void, ms: number): unknown\ndeclare function clearTimeout(id: unknown): void\n\n// ---------------------------------------------------------------------------\n// Observation types\n// ---------------------------------------------------------------------------\n\n/**\n * A state transition event — from one model to another.\n *\n * Generic over the model type. This is the machine-level primitive;\n * transport packages re-export or alias it for their specific state types.\n */\nexport type StateTransition<S> = {\n from: S\n to: S\n timestamp: number\n}\n\n/**\n * Listener for state transitions.\n */\nexport type TransitionListener<S> = (transition: StateTransition<S>) => void\n\n// ---------------------------------------------------------------------------\n// ObservableHandle\n// ---------------------------------------------------------------------------\n\n/**\n * Handle for a running observable program.\n *\n * Provides dispatch, state access, transition observation, and disposal.\n * The observation API (`subscribeToTransitions`, `waitForState`, `waitForStatus`)\n * matches the surface of the former `ClientStateMachine<S>`.\n */\nexport interface ObservableHandle<Msg, Model> {\n /** Dispatch a message into the program. */\n dispatch: Dispatch<Msg>\n\n /** Get the current model synchronously. */\n getState(): Model\n\n /**\n * Subscribe to state transitions.\n *\n * Transitions are delivered synchronously after each update.\n * Returns an unsubscribe function.\n */\n subscribeToTransitions(listener: TransitionListener<Model>): () => void\n\n /**\n * Wait for a specific state.\n *\n * Resolves immediately if the current state matches the predicate.\n * Otherwise waits for a transition that matches.\n */\n waitForState(\n predicate: (state: Model) => boolean,\n options?: { timeoutMs?: number },\n ): Promise<Model>\n\n /**\n * Wait for a specific status string on a model with a `status` discriminant.\n *\n * Convenience wrapper around `waitForState()`.\n */\n waitForStatus<S extends { status: string }>(\n this: ObservableHandle<Msg, S>,\n status: S[\"status\"],\n options?: { timeoutMs?: number },\n ): Promise<S>\n\n /**\n * Dispose the program — stops dispatch and calls `program.done`.\n */\n dispose(): void\n}\n\n// ---------------------------------------------------------------------------\n// createObservableProgram\n// ---------------------------------------------------------------------------\n\n/**\n * Run a program with data effects and state observation.\n *\n * Like `runtime()`, but instead of executing closure effects directly,\n * it delegates to a custom `executor` for each data effect. This enables\n * programs whose effects are inspectable data types (not opaque closures).\n *\n * The runtime:\n * 1. Extracts `[model, ...effects]` from `program.init`.\n * 2. Executes each initial effect via `executor(effect, dispatch)`.\n * 3. On `dispatch(msg)`: calls `update(msg, state)`, updates state,\n * notifies transition listeners, executes effects.\n * 4. Re-entrant dispatch (effect calls dispatch) is queued and processed\n * after the current dispatch cycle completes.\n * 5. `dispose()` stops dispatch and calls `program.done`.\n *\n * @param program - The program algebra: init, update, done.\n * @param executor - Interprets data effects as I/O.\n * @returns An observable handle for the running program.\n */\nexport function createObservableProgram<Msg, Model, Fx>(\n program: Program<Msg, Model, Fx>,\n executor: (effect: Fx, dispatch: Dispatch<Msg>) => void,\n options?: { lease?: Lease; label?: string },\n): ObservableHandle<Msg, Model> {\n let state: Model\n let isRunning = true\n const listeners = new Set<TransitionListener<Model>>()\n\n // --------------------------------------------------------------------------\n // Transition notification\n // --------------------------------------------------------------------------\n\n function notifyTransition(from: Model, to: Model): void {\n if (from === to) return\n\n const transition: StateTransition<Model> = {\n from,\n to,\n timestamp: Date.now(),\n }\n\n for (const listener of listeners) {\n try {\n listener(transition)\n } catch {\n // Swallow listener errors — observers must not break dispatch.\n }\n }\n }\n\n // --------------------------------------------------------------------------\n // Dispatch\n // --------------------------------------------------------------------------\n\n const handle = createDispatcher<Msg>(\n (msg, redispatch) => {\n if (!isRunning) return\n const prev = state\n const [newModel, ...effects] = program.update(msg, state)\n state = newModel\n notifyTransition(prev, state)\n for (const effect of effects) {\n executor(effect, redispatch)\n }\n },\n { lease: options?.lease, label: options?.label ?? \"observable\" },\n )\n\n function dispatch(msg: Msg): void {\n if (!isRunning) return\n handle.dispatch(msg)\n }\n\n // --------------------------------------------------------------------------\n // Observation\n // --------------------------------------------------------------------------\n\n function getState(): Model {\n return state\n }\n\n function subscribeToTransitions(\n listener: TransitionListener<Model>,\n ): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n }\n\n function waitForState(\n predicate: (state: Model) => boolean,\n options?: { timeoutMs?: number },\n ): Promise<Model> {\n // Resolve immediately if already matching\n if (predicate(state)) {\n return Promise.resolve(state)\n }\n\n return new Promise((resolve, reject) => {\n let timeoutId: unknown\n\n const unsubscribe = subscribeToTransitions(transition => {\n if (predicate(transition.to)) {\n cleanup()\n resolve(transition.to)\n }\n })\n\n const cleanup = () => {\n unsubscribe()\n if (timeoutId !== undefined) {\n clearTimeout(timeoutId)\n }\n }\n\n if (options?.timeoutMs !== undefined) {\n timeoutId = setTimeout(() => {\n cleanup()\n reject(\n new Error(`Timeout waiting for state after ${options.timeoutMs}ms`),\n )\n }, options.timeoutMs)\n }\n })\n }\n\n function waitForStatus<S extends { status: string }>(\n this: ObservableHandle<Msg, S>,\n status: S[\"status\"],\n options?: { timeoutMs?: number },\n ): Promise<S> {\n return this.waitForState((s: S) => s.status === status, options)\n }\n\n function dispose(): void {\n if (!isRunning) return\n isRunning = false\n program.done?.(state)\n }\n\n // --------------------------------------------------------------------------\n // Initialize\n // --------------------------------------------------------------------------\n\n const [initialModel, ...initialEffects] = program.init\n state = initialModel\n for (const effect of initialEffects) {\n executor(effect, dispatch)\n }\n\n // --------------------------------------------------------------------------\n // Return handle\n // --------------------------------------------------------------------------\n\n return {\n dispatch,\n getState,\n subscribeToTransitions,\n waitForState,\n waitForStatus,\n dispose,\n }\n}\n"],"mappings":";AA2BA,SAAgB,YAAY,SAA+B;CACzD,OAAO;EACL,OAAO;EACP,YAAY;EACZ,QAAQ,SAAS,UAAU;EAC3B,SAAS,CAAC;EACV,iBAAiB,SAAS,mBAAmB;CAC/C;AACF;AAEA,IAAa,uBAAb,cAA0C,MAAM;CAC9C;CACA;CACA,YAAY,OAAe,O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AS;EAAO,OAAO,SAAS,SAAS;CAAa,CACjE;CAEA,SAAS,SAAS,KAAgB;EAChC,IAAI,CAAC,WAAW;EAChB,OAAO,SAAS,GAAG;CACrB;CAMA,SAAS,WAAkB;EACzB,OAAO;CACT;CAEA,SAAS,uBACP,UACY;EACZ,UAAU,IAAI,QAAQ;EACtB,aAAa;GACX,UAAU,OAAO,QAAQ;EAC3B;CACF;CAEA,SAAS,aACP,WACA,SACgB;EAEhB,IAAI,UAAU,KAAK,GACjB,OAAO,QAAQ,QAAQ,KAAK;EAG9B,OAAO,IAAI,SAAS,SAAS,WAAW;GACtC,IAAI;GAEJ,MAAM,cAAc,wBAAuB,eAAc;IACvD,IAAI,UAAU,WAAW,EAAE,GAAG;KAC5B,QAAQ;KACR,QAAQ,WAAW,EAAE;IACvB;GACF,CAAC;GAED,MAAM,gBAAgB;IACpB,YAAY;IACZ,IAAI,cAAc,KAAA,GAChB,aAAa,SAAS;GAE1B;GAEA,IAAI,SAAS,cAAc,KAAA,GACzB,YAAY,iBAAiB;IAC3B,QAAQ;IACR,uBACE,IAAI,MAAM,mCAAmC,QAAQ,UAAU,GAAG,CACpE;GACF,GAAG,QAAQ,SAAS;EAExB,CAAC;CACH;CAEA,SAAS,cAEP,QACA,SACY;EACZ,OAAO,KAAK,cAAc,MAAS,EAAE,WAAW,QAAQ,OAAO;CACjE;CAEA,SAAS,UAAgB;EACvB,IAAI,CAAC,WAAW;EAChB,YAAY;EACZ,QAAQ,OAAO,KAAK;CACtB;CAMA,MAAM,CAAC,cAAc,GAAG,kBAAkB,QAAQ;CAClD,QAAQ;CACR,KAAK,MAAM,UAAU,gBACnB,SAAS,QAAQ,QAAQ;CAO3B,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyneta/machine",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "description": "Universal Mealy machine algebra — Program, Effect, Dispatch, runtime",
5
5
  "author": "Duane Johnson",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "./src/*": "./src/*"
31
31
  },
32
32
  "devDependencies": {
33
- "tsdown": "^0.21.9",
33
+ "tsdown": "^0.22.0",
34
34
  "typescript": "^5.9.2",
35
35
  "vitest": "^4.0.17"
36
36
  },