export type FSMLifecycleFn = (meta: LifecycleFnMeta) => void; export type LifecycleFnMeta = { from: StatesT | null; to: StatesT; event: EventsT | null; args: unknown; }; export declare function isLifecycleFnMeta(meta: unknown): meta is LifecycleFnMeta; export type FSMLifecycle = "_enter" | "_exit"; export type ActionFn = (...args: unknown[]) => StatesT | void; export type Action = StatesT | ActionFn; export type StateHandler = { [e in EventsT]?: Action; } & { [k in FSMLifecycle]?: FSMLifecycleFn; }; export type Transition = { [s in StatesT]: StateHandler; } & { "*"?: StateHandler; }; /** * Defines a strongly-typed finite state machine. * * @see {@link https://runed.dev/docs/utilities/finite-state-machine} */ export declare class FiniteStateMachine { #private; readonly states: Transition; constructor(initial: StatesT, states: Transition); /** Triggers a new event and returns the new state. */ send(event: EventsT, ...args: unknown[]): StatesT; /** Debounces the triggering of an event. */ debounce(wait: number | undefined, event: EventsT, ...args: unknown[]): Promise; /** The current state. */ get current(): StatesT; }