Mutable context object associated with this FSM instance.
This is the same object passed at instantiation time.
Dispatches an event to the machine.
A top-level call to dispatch() synchronously processes the given
event and any subsequently dispatched events (e.g. from actions) in a
single tick, before returning.
A re-entrant call to dispatch() adds the new event to a FIFO queue
and returns immediately.
Throws FsmEngineUnknownEventError if an event is not used anywhere in the machine definition.
Throws FsmEngineUnhandledEventError if an event is known, but the current state provides no handler for it and no fallback handles it.
If a guard or action throws during the processing, any remaining queued events are discarded, and the error is rethrown here.
K extends EventName<Events> - Event name type. (The auto-generated doc incorrectly shows as K extends string)
Enables or disables trace logging.
When tracing is enabled, the engine logs event dispatch, guard evaluation,
transition selection, and action execution. The default logger is
console.log.
Pass true or false, or an options object.
enabled defaults to true when it's not explicitly specified.
If logger is specified, it updates the logger function, otherwise the
logger remains unchanged.
Returns this for chaining.
Optionalarg: boolean | { enabled?: boolean; logger?: (line: string) => void }StaticdefineDefines an FSM and returns a typed factory for creating instances.
The definition is validated eagerly. Invalid definitions throw one of the
FsmEngineDefinitionError subclasses during this call.
Finite-state machine instance created from a definition built with FsmEngine.define.
Each instance has its own current state, event queue, timers, and optional mutable context object.