import { Event, StateValue, StateTransition, MachineOptions, EventObject, HistoryValue, StateNodeDefinition, TransitionDefinition, DelayedTransitionDefinition, ActivityDefinition, StateNodeConfig, StateSchema, StateNodesConfig, InvokeDefinition, ActionObject, Mapper, PropertyMapper, SCXML, Typestate, TransitionDefinitionMap, MachineSchema, InternalMachineOptions, ServiceMap, StateConfig, PredictableActionArgumentsExec } from './types'; import { State } from './State'; import { TypegenDisabled } from './typegenTypes'; declare class StateNode = { value: any; context: TContext; }, TServiceMap extends ServiceMap = ServiceMap, TResolvedTypesMeta = TypegenDisabled> { /** * The raw config used to create the machine. */ config: StateNodeConfig; /** * The initial extended state */ private _context; /** * 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: 'atomic' | 'compound' | 'parallel' | 'final' | 'history'; /** * 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 on this state node. 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>; 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. */ doneData?: 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; schema: MachineSchema; __xstatenode: true; description?: string; private __cache; private idMap; tags: string[]; constructor( /** * The raw config used to create the machine. */ config: StateNodeConfig, options?: MachineOptions, /** * The initial extended state */ _context?: Readonly | (() => Readonly), // TODO: this is unsafe, but we're removing it in v5 anyway _stateInfo?: { parent: StateNode; key: string; }); private _init; /** * 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: InternalMachineOptions, context?: TContext | (() => TContext)): StateNode; /** * Clones this state machine with custom context. * * @param context Custom context (will override predefined context, not recursive) */ withContext(context: TContext | (() => TContext)): StateNode; get context(): TContext; /** * The well-structured state node definition. */ get definition(): StateNodeDefinition; toJSON(): StateNodeDefinition; /** * The mapping of events to transitions. */ get on(): TransitionDefinitionMap; get after(): Array>; /** * All the transitions that can be taken from this state node. */ get transitions(): Array>; private getCandidates; /** * 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 | StateConfig): State; private transitionLeafNode; private transitionCompoundNode; private transitionParallelNode; private _transition; getTransitionData(state: State, event: Event | SCXML.Event): StateTransition | undefined; private next; private getPotentiallyReenteringNodes; 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 | undefined, event: Event | SCXML.Event, context?: TContext, exec?: PredictableActionArgumentsExec): State; private resolveRaisedTransition; private resolveTransition; /** * 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 getResolvedPath; private get initialStateValue(); getInitialState(stateValue: StateValue, context?: TContext): State; /** * The initial State instance, which includes all actions to be executed from * entering the initial state. */ get 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. */ get target(): StateValue | undefined; /** * 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: StateNode, historyValue?: HistoryValue, resolve?: boolean): Array>; get 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[]): 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. */ get stateIds(): string[]; /** * All the event types accepted by this state node and its descendants. */ get events(): Array; /** * All the events that have transitions directly from this state node. * * Excludes any inert events. */ get ownEvents(): Array; private resolveTarget; private formatTransition; private formatTransitions; } export { StateNode }; //# sourceMappingURL=StateNode.d.ts.map