import type { MachineModel } from "./core/model.js"; import { type ToMermaidOptions } from "./export/toMermaid.js"; import { type ToXStateSourceOptions } from "./export/toXStateSource.js"; import type { EventObject, MachineConfig, MachineContext, MachineImplementations, ResolvedMachineImplementations } from "./types/index.js"; import type { DeepReadonly } from "./types/common.js"; /** The config as `MachineDefinition` exposes it: the same object, typed as deep-frozen. */ type FrozenMachineConfig = DeepReadonly>; /** * The blueprint returned by `createMachine()`: validated config, implementation * table and (privately) the normalized model. Stateless; one definition drives * any number of `Statechart` instances. Constructed only through `createMachine`. */ export declare class MachineDefinition { /** * The raw config as passed to `createMachine` — the very same object, * deep-frozen (the initial `context` object excepted), which the type * reflects: plain objects and arrays are read-only all the way down. */ readonly config: FrozenMachineConfig; readonly implementations: ResolvedMachineImplementations; /** Normalized model; read through `getMachineModel()` inside the package only. */ private readonly model; private constructor(); /** Machine id: `config.id` or `"(machine)"`. */ get id(): string; /** * `config.source`: the verbatim `.mmd` text the machine was generated * from (the viz renders it instead of `toMermaid()`); `undefined` for * config-authored machines. Carried over by `provide()`. */ get source(): string | undefined; /** * Returns a new definition with the given implementations merged over the * existing ones (new wins). Shapes are validated immediately; names are * matched against the config by `new Statechart()`. */ provide(implementations: MachineImplementations): MachineDefinition; /** `createMachine({...})` source text for Stately Studio "import from code". */ toXStateSource(options?: ToXStateSourceOptions): string; /** Mermaid `stateDiagram-v2` of the machine. */ toMermaid(options?: ToMermaidOptions): string; } /** * Package-internal factory used by `createMachine` (not exported from the * barrel). `createMachine` deep-freezes `config` right after this call, which * is what the read-only view the definition exposes stands for: the same * object, never a copy. */ export declare function createMachineDefinition(config: MachineConfig, implementations: MachineImplementations | undefined, model: MachineModel): MachineDefinition; /** Package-internal accessor of the normalized model (engine, exporters, tests); not exported from the barrel. */ export declare function getMachineModel(definition: MachineDefinition): MachineModel; /** * Lazy implementation check (spec 6.3), run by `new Statechart()` so that * `definition.provide()` can fill the tables after `createMachine()`: * * 1. every action / guard / delay name referenced by the config must exist in * the corresponding table (order: actions, guards, delays; first missing * name throws); * 2. builtins stored in the tables must resolve too — `raise(..., { delay: * "" })` needs the delay, `and` / `or` / `not` need their string * members, `stateIn("#id")` needs the node — and named guards must not * reference each other in a cycle. * * Throws `MachineConfigError("implementations.", ...)`. A definition * that passed once is remembered (`WeakSet`) and not re-scanned. */ export declare function assertImplementations(definition: MachineDefinition): void; export {};