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