export type Event_T = [name: string, payload: any]; export interface Machine_T { states: Array; } export interface State_T { name: string; eventReactionCouplings: Array; } export interface EventReactionCouplings_T { eventName: string; reactions: Array; } export type Reaction_T = SideEffect_T | ContextMutation_T | Goto_T; export interface SideEffect_T { type: 'SideEffect'; fn: SideEffectFunction_T; } export type SideEffectFunction_T = (ctx: any, e: Event_T, self: Interpreter_T) => void; export interface ContextMutation_T { type: 'ContextMutation'; fn: ContextMutationFunction_T; } export type ContextMutationFunction_T = (ctx: any, e: Event_T, self: Interpreter_T) => any; export interface Goto_T { type: 'Goto'; targetStateName: string; } export declare const Machine: (...states: Array) => Machine_T; export declare const State: (name: string, ...eventReactionCouplings: Array) => State_T; export declare const On: (eventName: string, ...reactions: Array) => EventReactionCouplings_T; export declare const SideEffect: (fn: SideEffectFunction_T) => SideEffect_T; export declare const Goto: (targetStateName: string) => Goto_T; export declare const Context: (fn: ContextMutationFunction_T) => ContextMutation_T; export interface Interpreter_T { machine: Machine_T; state: string; context: any; eventQueue: Array; isTransitioning: boolean; subscriptions: Record; } export declare function interpret(machine: Machine_T, options: { state?: string; context: any; }): Interpreter_T; /** Inject an Event into the Interpreter's "tick queue". * * An event can be signify something "new" happening, such that its reactions should run on the next Tick; * or it can signify a milestone "within" the current Tick, such that a Tick can be thought of as having * "sub-Ticks". * * This distinction is significant for proper ordering of reaction execution, and also for determining * whether to run a reaction at all. If an Event is received, and is specified to be applied on a past * Tick, it is discarded. */ export declare function send(interpreter: Interpreter_T, event: Event_T): void; export declare const enqueue: typeof send; export type SubscriptionCallbackFunction_T = (self: Interpreter_T) => void; export declare function subscribe(interpreter: Interpreter_T, callback: SubscriptionCallbackFunction_T): number; export declare function unsubscribe(interpreter: Interpreter_T, subscriptionId: string): void; export declare const Spawn: () => void; export declare const Unspawn: () => void;