export declare type Dict = Record; export declare type MaybeArray = T | T[]; export declare namespace StateMachine { type EventObject = { type: string; }; type Event = string | EventObject; type EventWithSrc = EventObject & { src?: any; }; type Expression = (context: TContext, event: TEvent) => TReturn; interface AnyEventObject extends EventObject { [key: string]: any; } type Action = string | Expression; type Actions = MaybeArray>; type TransitionDefinition = { target?: TState; actions?: Actions; cond?: Condition; }; type TransitionDefinitionWithDelay = TransitionDefinition & { delay?: Delay; }; type Delay = string | number | Expression; type Transition = TState | TransitionDefinition; type Activity = Expression; type Activities = MaybeArray>; type Transitions = Transition | MaybeArray>; type AfterTransitions = Record>> | Array & { delay: number | string | Expression; }>; type ExtractEvent = K extends TEvent["type"] ? Extract : EventObject; type TransitionDefinitionMap = { [K in TEvent["type"]]?: TState | MaybeArray>>; }; interface StateNode { type?: "final"; /** * The tags for the state node. */ tags?: string[]; /** * The activities to be started upon entering the state node, * and stopped upon exiting the state node. */ activities?: Activities; /** * The mapping of event types to their potential transition(s). */ on?: TransitionDefinitionMap; /** * The action(s) to be executed upon entering the state node. */ entry?: Actions; /** * The action(s) to be executed upon exiting the state node. */ exit?: Actions; /** * The mapping (or array) of delays (in `ms`) to their potential transition(s) to run after * the specified delay. Uses `setTimeout` under the hood. */ after?: AfterTransitions; /** * An eventless transition that is always taken when this state is active. */ always?: MaybeArray>; /** * The mapping (or array) of intervals (in `ms`) to their potential actions(s) to run at interval. * Uses `setInterval` under the hood. */ every?: Record> | Array<{ interval?: number | string | Expression; actions: Actions; cond?: string | Expression; }>; } type ConditionHelper = { exec: (guards: Dict) => Expression; }; type Condition = string | Expression | ConditionHelper; interface MachineConfig { /** * The unique identifier for the invoked machine. */ id?: string; /** * The extended state used to store `data` for your machine */ context?: TContext; /** * The initial state to start with */ initial?: TState; /** * The mapping of state node keys to their state node configurations (recursive). */ states?: Partial>>; /** * The `id` of the parent machine for this */ parent?: string; on?: TransitionDefinitionMap; } type SubscribeFunction = (state: State) => void; interface State { current: string; prev: string; event: string | string[]; context: TContext; done: boolean; matches(value: string | string[]): boolean; hasTag(value: string): boolean; nextEvents: string[]; changed: boolean; tags: Set; [key: string]: any; } interface StateInfo { transition: TransitionDefinition | undefined; stateNode: StateNode | undefined; hasTarget: boolean; isTransient: boolean; target: string | undefined; } type ActionsMap = Record, string>>; type GuardsMap = Record>; type TimersMap = { [delay: string]: number | Expression; }; interface MachineOptions { /** * The computed value to derive from the current context */ computed?: Dict<(context: TContext) => any>; guards?: GuardsMap; actions?: ActionsMap; delays?: TimersMap; } } //# sourceMappingURL=types.d.ts.map