import type { ActionFunction, BuiltinAction, DelayExpr } from "./actions.js"; import type { MachineContext } from "./common.js"; import type { EventObject } from "./events.js"; import type { BuiltinGuard, GuardPredicate } from "./guards.js"; /** * Params of a referenced implementation are untyped at this level (they come * from `{ type, params }` objects in the config). Declare the parameter * explicitly when you need it: `(args, params: { level: number }) => ...`. * `never` accepts any declared parameter type without an `any` leak. */ export type ImplementationParams = never; /** * Function slots of the tables are bivariant in their arguments (method * syntax): an implementation may type `event` narrower than the machine's * event union. Generated code relies on it — the converter narrows the event * of a guard / action / delay to the events whose transitions reference it. * TypeScript does not check that the narrowing fits the config. */ type Bivariant = { bivarianceHack(...args: TArgs): TResult; }["bivarianceHack"]; export type ActionImplementation = Bivariant>, void> | BuiltinAction; export type GuardImplementation = Bivariant>, boolean> | BuiltinGuard; export type DelayImplementation = number | Bivariant>, number>; /** Second argument of `createMachine` and argument of `definition.provide()`. */ export interface MachineImplementations { actions?: Record>; guards?: Record>; delays?: Record>; } /** `definition.implementations`: every table present (possibly empty) and frozen. */ export interface ResolvedMachineImplementations { readonly actions: Readonly>>; readonly guards: Readonly>>; readonly delays: Readonly>>; } export {};