import type { NOmit, PrimitiveObject } from '../libs/bemedev/globals/types'; import { type EventsMap, type ToEvents } from '../events/index.js'; import { type DefinedValue } from '../guards/index.js'; import type { State, StateExtended, StateP, StatePextended } from '../states/index.js'; import { type FlatMapN, type NodeConfig, type StateValue } from '../states/index.js'; import { type Decompose } from '@bemedev/decompose'; import type { Action } from '../actions/index.js'; import type { DelayFunction } from '../delays/index.js'; import { EventsR, ActorsConfigMap, ToEventObject } from '../events/index.js'; import type { PredicateS } from '../guards/index.js'; import type { AddOptions_F, AddOptionsParam_F, AnyMachine } from './machine.types'; import type { Config, ConfigDef, ExtractTagsFromConfig, GetActorKeysFromConfig, GetActorKeysFromConfig2, GetEventsFromConfig, MachineOptions, NoExtraKeysConfig, NoExtraKeysConfigDef, TransformConfigDef } from './types'; /** * A class representing a state machine. * It provides methods to manage states, actions, predicates, delays, promises, and machines. * * @template : {@linkcode Config} [C] - The configuration type of the machine. * @template Pc : The private context type of the machine. * @template : {@linkcode PrimitiveObject} [Pc] - The context type of the machine. * @template : {@linkcode GetEventsFromConfig}<{@linkcode C}> [E] - The events map type derived from the configuration. * @template : {@linkcode PromiseeMap} [P] - The promisees map type derived from the configuration. * @template : {@linkcode SimpleMachineOptions2} [Mo] - The options type for the machine, which includes actions, predicates, delays, promises, and machines. Defaults to {@linkcode MachineOptions}<[{@linkcode C} , {@linkcode E} , {@linkcode A} , {@linkcode Pc} , {@linkcode Tc} ]>. * * @implements {@linkcode AnyMachine}<{@linkcode E} , {@linkcode A} , {@linkcode Pc} , {@linkcode Tc} > */ declare class Machine = GetEventsFromConfig, A extends ActorsConfigMap = GetActorKeysFromConfig, Ta extends ExtractTagsFromConfig = ExtractTagsFromConfig, Eo extends ToEventObject> = ToEventObject>, Mo extends MachineOptions = MachineOptions> implements AnyMachine { #private; get __config(): C; get decomposed(): Decompose; /** * Public accessor for the events map for this {@linkcode Machine}. * * @see {@linkcode EventsMap} * @see {@linkcode E} */ get eventsMap(): E; /** * Public accessor for the promisees map for this {@linkcode Machine}. * * @see {@linkcode PromiseeMap} * @see {@linkcode A} */ get actorsMap(): A; /** * @deprecated * * This property provides the events map for this {@linkcode Machine} as a type. * * @see {@linkcode ToEvents} * @see {@linkcode E} * @see {@linkcode A} * * @remarks Used for typing purposes only. */ get __events(): EventsR; /** * @deprecated * * This property provides the events map for this {@linkcode Machine} as a type. * * @see {@linkcode ToEvents} * @see {@linkcode E} * @see {@linkcode A} * * @remarks Used for typing purposes only. */ get __eventsO(): Eo; /** * @deprecated * This property provides the action function for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode E} * @see {@linkcode PromiseeMap} * @see {@linkcode A} * @see {@linkcode Pc} * @see {@linkcode PrimitiveObject} * @see {@linkcode Tc} */ get __actionFn(): Action; /** * @deprecated * * This property provides any action key for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. */ get __actionKey(): keyof Extract; /** * @deprecated * * This property provides the action parameters of action function for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode E} * @see {@linkcode Pc} * @see {@linkcode PrimitiveObject} * @see {@linkcode Tc} */ get __actionParams(): { pContext: Pc; context: Tc; map: E; }; /** * @deprecated * * This property provides the state extended for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode StateExtended} * @see {@linkcode ToEvents} * @see {@linkcode PrimitiveObject} * @see {@linkcode ActorsConfigMap} * @see {@linkcode E} * @see {@linkcode A} * @see {@linkcode Pc} * @see {@linkcode Tc} */ get __stateExtended(): StateExtended; /** * @deprecated * * This property provides the state for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode State} * @see {@linkcode ToEventsR2} * @see {@linkcode PrimitiveObject} * @see {@linkcode ActorsConfigMap} * @see {@linkcode E} * @see {@linkcode A} * @see {@linkcode Pc} * @see {@linkcode Tc} */ get __state(): State; /** * @deprecated * * This property provides the decomposed state for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode State} * @see {@linkcode Decompose} * @see {@linkcode Eo} * @see {@linkcode Tc} * @see {@linkcode Ta} */ get __decomposedState(): Decompose, { sep: "."; start: false; object: "both"; }>; /** * @deprecated * * This property provides the state payload for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode StateP} * @see {@linkcode ToEventsR2} * @see {@linkcode PrimitiveObject} * @see {@linkcode ActorsConfigMap} * @see {@linkcode E} * @see {@linkcode A} * @see {@linkcode Pc} * @see {@linkcode Tc} */ get __stateP(): StateP; /** * @deprecated * * This property provides the extended state payload for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode StatePextended} * @see {@linkcode ToEventsR2} * @see {@linkcode PrimitiveObject} * @see {@linkcode ActorsConfigMap} * @see {@linkcode E} * @see {@linkcode A} * @see {@linkcode Pc} * @see {@linkcode Tc} */ get __statePextended(): StatePextended; /** * @deprecated * * This property provides any guard key for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. */ get __guardKey(): keyof Extract; /** * @deprecated * * This property provides the predicate function for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode PredicateS} * @see {@linkcode ActorsConfigMap} * @see {@linkcode PrimitiveObject} * @see {@linkcode E} * @see {@linkcode A} * @see {@linkcode Pc} * @see {@linkcode Tc} */ get __predicate(): PredicateS; /** * @deprecated * * This property provides any delay key for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. */ get __delayKey(): keyof Extract; /** * @deprecated * * This property provides the delay function for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode DelayFunction} * @see {@linkcode ActorsConfigMap} * @see {@linkcode PrimitiveObject} * @see {@linkcode E} * @see {@linkcode A} * @see {@linkcode Pc} * @see {@linkcode Tc} */ get __delay(): DelayFunction; /** * @deprecated * * This property provides any {@linkcode DefinedValue} for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. * * @see {@linkcode DefinedValue} * @see {@linkcode PrimitiveObject} * @see {@linkcode Pc} * @see {@linkcode Tc} */ get __definedValue(): DefinedValue; /** * @deprecated * * This property provides any child key for this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. */ get __childKey(): keyof Extract; /** * @deprecated * * Return this {@linkcode Machine} as a type. * * @remarks Used for typing purposes only. */ get __machine(): this; get __tag(): Ta; /** * Creates an instance of Machine. * * @param config : of type {@linkcode Config} [C] - The configuration for the machine. * * @remarks * This constructor initializes the machine with the provided configuration. * It flattens the configuration and prepares it for further operations ({@linkcode flat}). */ constructor(config: C); readonly longRuns: boolean; /** * The accessor configuration of the machine for this {@linkcode Machine}. * * @see {@linkcode Config} * @see {@linkcode C} */ get config(): C; /** * The public accessor of the flat map of the configuration for this {@linkcode Machine}. * * @see {@linkcode FlatMapN} * @see {@linkcode Config} * @see {@linkcode C} */ get flat(): FlatMapN; /** * The accessor of context for this {@linkcode Machine}. * * @see {@linkcode PrimitiveObject} * @see {@linkcode Tc} */ get context(): Tc; /** * The accessor of private context for this {@linkcode Machine}. * * @see {@linkcode Pc} */ get pContext(): Pc; get actions(): Mo["actions"] | undefined; get predicates(): Mo["predicates"] | undefined; get delays(): Mo["delays"] | undefined; get children(): Partial, Eo, A, Pc, Tc, Ta, (FlatMapN extends infer T extends FlatMapN ? { [key in keyof T]: import("../transitions").ExtractChildKeysFromTransitions>; } : never)["/" | import("../libs/bemedev/globals/types").UnionKeys; } & { [key_2 in keyof C[keyof C & "states"]]: C[keyof C & "states"][key_2] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_4 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_4 & string}`]: Omit; } & { [key_5 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_5] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_6 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_6 & string}`]: Omit; } & { [key_7 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_7] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_8 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_7 & string}/${key_8 & string}`]: Omit; } & { [key_9 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_9] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_10 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_7 & string}/${key_9 & string}/${key_10 & string}`]: Omit; } & { [key_11 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_11] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_12 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_7 & string}/${key_9 & string}/${key_11 & string}/${key_12 & string}`]: Omit; } & { [key_13 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_13] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_14 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_7 & string}/${key_9 & string}/${key_11 & string}/${key_13 & string}/${key_14 & string}`]: Omit; } & { [key_15 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_15] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_16 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_7 & string}/${key_9 & string}/${key_11 & string}/${key_13 & string}/${key_15 & string}/${key_16 & string}`]: Omit; } & { [key_17 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_17] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_18 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_7 & string}/${key_9 & string}/${key_11 & string}/${key_13 & string}/${key_15 & string}/${key_17 & string}/${key_18 & string}`]: Omit; } & { [key_19 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_19] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_20 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_7 & string}/${key_9 & string}/${key_11 & string}/${key_13 & string}/${key_15 & string}/${key_17 & string}/${key_19 & string}/${key_20 & string}`]: Omit; } & { [key_21 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_21] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? "states" extends keyof S ? { readonly [key_22 in keyof S[keyof S & "states"] as `/${key_2 & string}/${key_5 & string}/${key_7 & string}/${key_9 & string}/${key_11 & string}/${key_13 & string}/${key_15 & string}/${key_17 & string}/${key_19 & string}/${key_21 & string}/${key_22 & string}`]: Omit; } & { [key_23 in keyof S[keyof S & "states"]]: S[keyof S & "states"][key_23] extends infer S extends (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type: "parallel"; readonly initial?: never; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) | (import("../states/index.js").BaseConfig & import("../transitions").TransitionsConfig & { readonly type?: "compound"; readonly initial: string; readonly states: import("../types").RecordS; } & { states: import("../types").RecordS; }) ? /*elided*/ any : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof S[keyof S & "states"]] : {} : {}; }[keyof C[keyof C & "states"]] : {}>>]>> | undefined; get emitters(): Partial, Eo, A, Pc, Tc, Ta>> | undefined; isInitial: (target: string) => boolean; retrieveParentFromInitial: (target: string) => NodeConfig; /** * Create options for the machine. * * @param option a function that provides options for the machine. * Options can include actions, predicates, delays, promises, and child machines. * * Remark: Used for typings, when you're outside the Machine class. */ createOptions: AddOptions_F; /** * Provides options for the machine. * * @param option a function that provides options for the machine. * Options can include actions, predicates, delays, promises, and child machines. */ addOptions: AddOptions_F; /** * Provides options for the machine. * * @param helper a function that provides options for the machine. * Options can include actions, predicates, delays, promises, and child machines. * @returns a new instance of the machine with the provided options applied. */ provideOptions: (helper: AddOptionsParam_F) => this; /** * Returns a new instance from this {@linkcode Machine} with all its {@linkcode Elements}. */ get renew(): this; addPrivateContext: (pContext: Pc) => void; addContext: (context: Tc) => void; /** * @deprecated * @remarks used internally */ _provideEvents: (map: T) => Machine>, ToEventObject>, Partial<{ actions: Partial, ToEventObject>, Pc, Tc, import("../states/index.js").ExtractTagsFromFlat>>>; predicates: Partial, ToEventObject>, Pc, Tc, import("../states/index.js").ExtractTagsFromFlat>>>; delays: Partial, ToEventObject>, Pc, Tc, import("../states/index.js").ExtractTagsFromFlat>>>; actors: Partial, ToEventObject>, A, Pc, Tc, import("../states/index.js").ExtractTagsFromFlat>>>; }>>; /** * @deprecated * @remarks used internally */ _provideActors: (map: T) => Machine>, ToEventObject>, Partial<{ actions: Partial, ToEventObject>, Pc, Tc, import("../states/index.js").ExtractTagsFromFlat>>>; predicates: Partial, ToEventObject>, Pc, Tc, import("../states/index.js").ExtractTagsFromFlat>>>; delays: Partial, ToEventObject>, Pc, Tc, import("../states/index.js").ExtractTagsFromFlat>>>; actors: Partial, ToEventObject>, T, Pc, Tc, import("../states/index.js").ExtractTagsFromFlat>>>; }>>; /** * Converts a {@linkcode StateValue} to a {@linkcode NodeConfigWithInitials} with the {@linkcode NodeConfigWithInitials} postConfig of this {@linkcode Machine}. * * @param from the {@linkcode StateValue} to convert. * @returns the converted {@linkcode NodeConfigWithInitials}. * * @see {@linkcode valueToNodeConfig} */ valueToConfig: (from: StateValue) => NodeConfig; /** * The accessor of the initial node config of this {@linkcode Machine}. */ get initialConfig(): NodeConfig; /** * The accessor of the initial {@linkcode StateValue} of this {@linkcode Machine}. * * @see {@linkcode nodeToValue} */ get initialValue(): StateValue; /** * Alias of {@linkcode valueToConfig} method. */ toNode: (from: StateValue) => NodeConfig; get options(): Mo; } /** * Retrieves all entry actions from a node. */ export declare const getEntries: (node?: NodeConfig | undefined) => import("../actions/index.js").ActionConfig[]; /** * Retrieves all exit actions from a node. */ export declare const getExits: (node?: NodeConfig | undefined) => import("../actions/index.js").ActionConfig[]; export type { Machine }; export type CreateMachine_F = = NoExtraKeysConfigDef, const C extends Config & TransformConfigDef = Config & TransformConfigDef, Tc extends PrimitiveObject = PrimitiveObject, EventM extends GetEventsFromConfig = GetEventsFromConfig, A0 extends GetActorKeysFromConfig2 = GetActorKeysFromConfig2, A extends NOmit = NOmit, Pc extends A0['pContext'] = A0['pContext']>(config: NoExtraKeysConfig; }>, types: { pContext: Pc; context: Tc; eventsMap: EventM; actorsMap: A; }) => Machine; /** * Creates a new instance of {@linkcode Machine} with the provided configuration and * * @param config The configuration for the machine. * @param types An object containing the types for the machine: * - `pContext`: The private context type. * - `context`: The context type. * - `eventsMap`: The events map type derived from the configuration. * - `promiseesMap`: The promisees map type derived from the configuration. * * @param initials The initials {@linkcode StateValue} for all compound node configs for the {@linkcode Machine}, derived from the configuration. * @returns A new instance of {@linkcode Machine} with the provided configuration and * * @see {@linkcode CreateMachine_F} */ export declare const createMachine: CreateMachine_F; //# sourceMappingURL=machine.d.ts.map