import { Event, StateValue, MachineOptions, EventObject, HistoryValue, StateNodeDefinition, TransitionDefinition, DelayedTransitionDefinition, ActivityDefinition, StateTypes, StateNodeConfig, StateSchema, TransitionsDefinition, StateNodesConfig, OmniEventObject, InvokeDefinition, OmniEvent, ActionObject, Mapper, PropertyMapper } from './types'; import { State } from './State'; declare class StateNode = OmniEventObject> { /** * The initial extended state */ context?: Readonly | undefined; /** * The relative key of the state node, which represents its location in the overall state value. */ key: string; /** * The unique ID of the state node. */ id: string; /** * The machine's own version. */ version?: string; /** * The type of this state node: * * - `'atomic'` - no child state nodes * - `'compound'` - nested child state nodes (XOR) * - `'parallel'` - orthogonal nested child state nodes (AND) * - `'history'` - history state node * - `'final'` - final state node */ type: StateTypes; /** * The string path from the root machine node to this node. */ path: string[]; /** * The initial state node key. */ initial?: keyof TStateSchema['states']; /** * (DEPRECATED) Whether the state node is a parallel state node. * * Use `type: 'parallel'` instead. */ parallel?: boolean; /** * Whether the state node is "transient". A state node is considered transient if it has * an immediate transition from a "null event" (empty string), taken upon entering the state node. */ private _transient; /** * The child state nodes. */ states: StateNodesConfig; /** * The type of history exhibited. Can be: * * - `'shallow'` - recalls only top-level historical state value * - `'deep'` - recalls historical state value at all levels */ history: false | 'shallow' | 'deep'; /** * The action(s) to be executed upon entering the state node. */ onEntry: Array>; /** * The action(s) to be executed upon exiting the state node. */ onExit: Array>; /** * The activities to be started upon entering the state node, * and stopped upon exiting the state node. */ activities: Array>; /** * The delayed transitions. */ after: Array>; strict: boolean; /** * The parent state node. */ parent?: StateNode; /** * The root machine node. */ machine: StateNode; /** * The meta data associated with this state node, which will be returned in State instances. */ meta?: TStateSchema extends { meta: infer D; } ? D : any; /** * The data sent with the "done.state._id_" event if this is a final state node. */ data?: Mapper | PropertyMapper; /** * The string delimiter for serializing the path to a string. The default is "." */ delimiter: string; /** * The order this state node appears. Corresponds to the implicit SCXML document order. */ order: number; /** * The services invoked by this state node. */ invoke: Array>; options: MachineOptions; /** * The raw config used to create the machine. */ config: StateNodeConfig; __xstatenode: true; private __cache; private idMap; constructor(_config: StateNodeConfig, options?: Partial>, /** * The initial extended state */ context?: Readonly | undefined); /** * Clones this state machine with custom options and context. * * @param options Options (actions, guards, activities, services) to recursively merge with the existing options. * @param context Custom context (will override predefined context) */ withConfig(options: Partial>, context?: TContext | undefined): StateNode; /** * Clones this state machine with custom context. * * @param context Custom context (will override predefined context, not recursive) */ withContext(context: TContext): StateNode; /** * The well-structured state node definition. */ readonly definition: StateNodeDefinition; toJSON(): StateNodeDefinition; /** * The mapping of events to transitions. */ readonly on: TransitionsDefinition; /** * All the transitions that can be taken from this state node. */ readonly transitions: Array>; /** * All delayed transitions from the config. */ private getDelayedTransitions; /** * Returns the state nodes represented by the current state value. * * @param state The state value or State instance */ getStateNodes(state: StateValue | State): Array>; /** * Returns `true` if this state node explicitly handles the given event. * * @param event The event in question */ handles(event: Event): boolean; /** * Resolves the given `state` to a new `State` instance relative to this machine. * * This ensures that `.events` and `.nextEvents` represent the correct values. * * @param state The state to resolve */ resolveState(state: State): State; private transitionLeafNode; private transitionCompoundNode; private transitionParallelNode; private _transition; private next; /** * The state tree represented by this state node. */ private readonly tree; private nodesFromChild; private getStateTree; /** * Whether the given state node "escapes" this state node. If the `stateNode` is equal to or the parent of * this state node, it does not escape. */ private escapes; private evaluateGuard; private getActions; /** * Determines the next state given the current `state` and sent `event`. * * @param state The current State instance or state value * @param event The event that was sent at the current state * @param context The current context (extended state) of the current state */ transition(state: StateValue | State, event: OmniEvent, context?: TContext): State; private resolveTransition; private ensureValidPaths; /** * Returns the child state node from its relative `stateKey`, or throws. */ getStateNode(stateKey: string): StateNode; /** * Returns the state node with the given `stateId`, or throws. * * @param stateId The state ID. The prefix "#" is removed. */ getStateNodeById(stateId: string): StateNode; /** * Returns the relative state node from the given `statePath`, or throws. * * @param statePath The string or string array relative path to the state node. */ getStateNodeByPath(statePath: string | string[]): StateNode; /** * Resolves a partial state value with its full representation in this machine. * * @param stateValue The partial state value to resolve. */ resolve(stateValue: StateValue): StateValue; private readonly resolvedStateValue; private getResolvedPath; private readonly initialStateValue; getInitialState(stateValue: StateValue, context?: TContext): State; /** * The initial State instance, which includes all actions to be executed from * entering the initial state. */ readonly initialState: State; /** * The target state value of the history state node, if it exists. This represents the * default state value to transition to if no history value exists yet. */ readonly target: StateValue | undefined; getStates(stateValue: StateValue): Array>; /** * Returns the leaf nodes from a state path relative to this state node. * * @param relativeStateId The relative state path to retrieve the state nodes * @param history The previous state to retrieve history * @param resolve Whether state nodes should resolve to initial child state nodes */ getRelativeStateNodes(relativeStateId: string | string[], historyValue?: HistoryValue, resolve?: boolean): Array>; readonly initialStateNodes: Array>; /** * Retrieves state nodes from a relative path to this state node. * * @param relativePath The relative path from this state node * @param historyValue */ getFromRelativePath(relativePath: string[], historyValue?: HistoryValue): Array>; private historyValue; /** * Resolves to the historical value(s) of the parent state node, * represented by state nodes. * * @param historyValue */ private resolveHistory; /** * All the state node IDs of this state node and its descendant state nodes. */ readonly stateIds: string[]; /** * All the event types accepted by this state node and its descendants. */ readonly events: Array; /** * All the events that have transitions directly from this state node. * * Excludes any inert events. */ readonly ownEvents: Array; private formatTransition; private formatTransitions; } export { StateNode };