1 | import { MachineSnapshot } from "./State.js";
|
2 | import { StateNode } from "./StateNode.js";
|
3 | import { AnyActorSystem } from "./system.js";
|
4 | import { ResolveTypegenMeta, TypegenDisabled } from "./typegenTypes.js";
|
5 | import type { ActorLogic, ActorScope, AnyActorRef, AnyActorScope, DoNotInfer, Equals, EventDescriptor, EventObject, HistoryValue, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, ParameterizedObject, ProvidedActor, Snapshot, StateMachineDefinition, StateValue, TransitionDefinition } from "./types.js";
|
6 | export declare const STATE_IDENTIFIER = "#";
|
7 | export declare const WILDCARD = "*";
|
8 | export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject = EventObject,
|
9 | TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, DoNotInfer<TEvent>, TActor, TAction, TGuard, TDelay, TTag, TEmitted>> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
10 | |
11 |
|
12 |
|
13 | config: MachineConfig<TContext, TEvent, any, any, any, any, any, any, TOutput, any> & {
|
14 | schemas?: unknown;
|
15 | };
|
16 | |
17 |
|
18 |
|
19 | version?: string;
|
20 | schemas: unknown;
|
21 | implementations: MachineImplementationsSimplified<TContext, TEvent>;
|
22 | root: StateNode<TContext, TEvent>;
|
23 | id: string;
|
24 | states: StateNode<TContext, TEvent>['states'];
|
25 | events: Array<EventDescriptor<TEvent>>;
|
26 | constructor(
|
27 | |
28 |
|
29 |
|
30 | config: MachineConfig<TContext, TEvent, any, any, any, any, any, any, TOutput, any> & {
|
31 | schemas?: unknown;
|
32 | }, implementations?: MachineImplementationsSimplified<TContext, TEvent>);
|
33 | /**
|
34 | * Clones this state machine with the provided implementations
|
35 | * and merges the `context` (if provided).
|
36 | *
|
37 | * @param implementations Options (`actions`, `guards`, `actors`, `delays`, `context`)
|
38 | * to recursively merge with the existing options.
|
39 | *
|
40 | * @returns A new `StateMachine` instance with the provided implementations.
|
41 | */
|
42 | provide(implementations: InternalMachineImplementations<TContext, TResolvedTypesMeta, true>): StateMachine<TContext, TEvent, TChildren, TActor, TAction, TGuard, TDelay, TStateValue, TTag, TInput, TOutput, TEmitted, TResolvedTypesMeta>;
|
43 | resolveState(config: {
|
44 | value: StateValue;
|
45 | context?: TContext;
|
46 | historyValue?: HistoryValue<TContext, TEvent>;
|
47 | status?: 'active' | 'done' | 'error' | 'stopped';
|
48 | output?: TOutput;
|
49 | error?: unknown;
|
50 | } & (Equals<TContext, MachineContext> extends false ? {
|
51 | context: unknown;
|
52 | } : {})): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>;
|
53 | /**
|
54 | * Determines the next snapshot given the current `snapshot` and received `event`.
|
55 | * Calculates a full macrostep from all microsteps.
|
56 | *
|
57 | * @param snapshot The current snapshot
|
58 | * @param event The received event
|
59 | */
|
60 | transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>, event: TEvent, actorScope: ActorScope<typeof snapshot, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>;
|
61 | /**
|
62 | * Determines the next state given the current `state` and `event`.
|
63 | * Calculates a microstep.
|
64 | *
|
65 | * @param state The current state
|
66 | * @param event The received event
|
67 | */
|
68 | microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>, event: TEvent, actorScope: AnyActorScope): Array<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>>;
|
69 | getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>>;
|
70 | /**
|
71 | * The initial state _before_ evaluating any microsteps.
|
72 | * This "pre-initial" state is provided to initial actions executed in the initial state.
|
73 | */
|
74 | private getPreInitialState;
|
75 | /**
|
76 | * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
|
77 | */
|
78 | getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>, TEvent, AnyActorSystem, TEmitted>, input?: TInput): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>;
|
79 | start(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>): void;
|
80 | getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
81 | get definition(): StateMachineDefinition<TContext, TEvent>;
|
82 | toJSON(): StateMachineDefinition<TContext, TEvent>;
|
83 | getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>, options?: unknown): Snapshot<unknown>;
|
84 | restoreSnapshot(snapshot: Snapshot<unknown>, _actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>;
|
85 | /**
|
86 | * @deprecated an internal property that was acting as a "phantom" type, it's not used by anything right now but it's kept around for compatibility reasons
|
87 | **/
|
88 | __TResolvedTypesMeta: TResolvedTypesMeta;
|
89 | }
|