1 | import type { StateNode } from "./StateNode.js";
|
2 | import type { StateMachine } from "./StateMachine.js";
|
3 | import type { ProvidedActor, AnyMachineSnapshot, AnyStateMachine, EventObject, HistoryValue, MachineContext, StateConfig, StateValue, AnyActorRef, Snapshot, ParameterizedObject, IsNever } from "./types.js";
|
4 | type ToTestStateValue<TStateValue extends StateValue> = TStateValue extends string ? TStateValue : IsNever<keyof TStateValue> extends true ? never : keyof TStateValue | {
|
5 | [K in keyof TStateValue]?: ToTestStateValue<NonNullable<TStateValue[K]>>;
|
6 | };
|
7 | export declare function isMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject>(value: unknown): value is AnyMachineSnapshot;
|
8 | interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, _TUnusedButLeftForCompatReasons = never> {
|
9 | |
10 |
|
11 |
|
12 | machine: StateMachine<TContext, TEvent, TChildren, ProvidedActor, ParameterizedObject, ParameterizedObject, string, TStateValue, TTag, unknown, TOutput, EventObject>;
|
13 | |
14 |
|
15 |
|
16 | tags: Set<string>;
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | value: TStateValue;
|
36 | |
37 |
|
38 |
|
39 | status: 'active' | 'done' | 'error' | 'stopped';
|
40 | error: unknown;
|
41 | context: TContext;
|
42 | historyValue: Readonly<HistoryValue<TContext, TEvent>>;
|
43 | |
44 |
|
45 |
|
46 | _nodes: Array<StateNode<TContext, TEvent>>;
|
47 | |
48 |
|
49 |
|
50 | children: TChildren;
|
51 | |
52 |
|
53 |
|
54 |
|
55 | matches: (partialStateValue: ToTestStateValue<TStateValue>) => boolean;
|
56 | |
57 |
|
58 |
|
59 |
|
60 | hasTag: (tag: TTag) => boolean;
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | can: (event: TEvent) => boolean;
|
70 | getMeta: () => Record<string, any>;
|
71 | toJSON: () => unknown;
|
72 | }
|
73 | interface ActiveMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput> {
|
74 | status: 'active';
|
75 | output: undefined;
|
76 | error: undefined;
|
77 | }
|
78 | interface DoneMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput> {
|
79 | status: 'done';
|
80 | output: TOutput;
|
81 | error: undefined;
|
82 | }
|
83 | interface ErrorMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput> {
|
84 | status: 'error';
|
85 | output: undefined;
|
86 | error: unknown;
|
87 | }
|
88 | interface StoppedMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput> extends MachineSnapshotBase<TContext, TEvent, TChildren, TStateValue, TTag, TOutput> {
|
89 | status: 'stopped';
|
90 | output: undefined;
|
91 | error: undefined;
|
92 | }
|
93 | export type MachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, _TUnusedButLeftForCompatReasons = never> = ActiveMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput> | DoneMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput> | ErrorMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput> | StoppedMachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>;
|
94 | export declare function createMachineSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string>(config: StateConfig<TContext, TEvent>, machine: AnyStateMachine): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, undefined>;
|
95 | export declare function cloneMachineSnapshot<TState extends AnyMachineSnapshot>(snapshot: TState, config?: Partial<StateConfig<any, any>>): TState;
|
96 | export declare function getPersistedSnapshot<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput>(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput>, options?: unknown): Snapshot<unknown>;
|
97 | export {};
|