xstate 5.0.0-alpha.0 → 5.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -13
- package/actions/dist/xstate-actions.cjs.dev.js +22 -24
- package/actions/dist/xstate-actions.cjs.prod.js +22 -24
- package/actions/dist/xstate-actions.esm.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js +2 -0
- package/actions/dist/xstate-actions.umd.min.js.map +1 -0
- package/actions/dynamicAction.ts +4 -4
- package/actions/package.json +5 -1
- package/actors/dist/xstate-actors.cjs.dev.js +12 -13
- package/actors/dist/xstate-actors.cjs.prod.js +12 -13
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js +2 -0
- package/actors/dist/xstate-actors.umd.min.js.map +1 -0
- package/actors/package.json +5 -1
- package/dev/dist/xstate-dev.umd.min.js +2 -0
- package/dev/dist/xstate-dev.umd.min.js.map +1 -0
- package/dev/package.json +5 -1
- package/dist/{actions-70094c93.cjs.prod.js → actions-7ea9280f.cjs.prod.js} +3118 -3209
- package/dist/{actions-6b86876d.cjs.dev.js → actions-b08d0da8.cjs.dev.js} +3105 -3202
- package/dist/{actions-ff512f16.esm.js → actions-b673cb13.esm.js} +3092 -3189
- package/dist/declarations/actions/dynamicAction.d.ts +5 -3
- package/dist/declarations/src/Machine.d.ts +4 -4
- package/dist/declarations/src/Mailbox.d.ts +12 -12
- package/dist/declarations/src/SimulatedClock.d.ts +16 -16
- package/dist/declarations/src/State.d.ts +97 -104
- package/dist/declarations/src/StateMachine.d.ts +120 -112
- package/dist/declarations/src/StateNode.d.ts +127 -127
- package/dist/declarations/src/actionTypes.d.ts +16 -17
- package/dist/declarations/src/actions/assign.d.ts +7 -7
- package/dist/declarations/src/actions/cancel.d.ts +10 -10
- package/dist/declarations/src/actions/choose.d.ts +3 -3
- package/dist/declarations/src/actions/invoke.d.ts +3 -3
- package/dist/declarations/src/actions/log.d.ts +11 -11
- package/dist/declarations/src/actions/pure.d.ts +3 -3
- package/dist/declarations/src/actions/raise.d.ts +9 -9
- package/dist/declarations/src/actions/send.d.ts +51 -55
- package/dist/declarations/src/actions/stop.d.ts +7 -8
- package/dist/declarations/src/actions.d.ts +43 -44
- package/dist/declarations/src/actors.d.ts +37 -38
- package/dist/declarations/src/constants.d.ts +5 -5
- package/dist/declarations/src/dev/index.d.ts +14 -14
- package/dist/declarations/src/environment.d.ts +1 -1
- package/dist/declarations/src/guards.d.ts +8 -9
- package/dist/declarations/src/index.d.ts +44 -47
- package/dist/declarations/src/interpreter.d.ts +108 -147
- package/dist/declarations/src/mapState.d.ts +3 -3
- package/dist/declarations/src/memo.d.ts +2 -1
- package/dist/declarations/src/registry.d.ts +8 -8
- package/dist/declarations/src/schema.d.ts +2 -2
- package/dist/declarations/src/spawn.d.ts +2 -2
- package/dist/declarations/src/stateUtils.d.ts +70 -85
- package/dist/declarations/src/symbolObservable.d.ts +1 -0
- package/dist/declarations/src/typegenTypes.d.ts +132 -132
- package/dist/declarations/src/types.d.ts +1001 -1026
- package/dist/declarations/src/utils.d.ts +54 -56
- package/dist/xstate.cjs.dev.js +856 -80
- package/dist/xstate.cjs.prod.js +856 -80
- package/dist/xstate.esm.js +815 -35
- package/dist/xstate.umd.min.js +2 -0
- package/dist/xstate.umd.min.js.map +1 -0
- package/guards/dist/xstate-guards.cjs.dev.js +7 -7
- package/guards/dist/xstate-guards.cjs.prod.js +7 -7
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js +2 -0
- package/guards/dist/xstate-guards.umd.min.js.map +1 -0
- package/guards/package.json +5 -1
- package/package.json +25 -2
- package/CHANGELOG.md +0 -1986
- package/actions/ExecutableAction.ts +0 -58
- package/dist/Machine-9ce74c11.cjs.dev.js +0 -755
- package/dist/Machine-dca041dc.cjs.prod.js +0 -749
- package/dist/Machine-fb2f47f5.esm.js +0 -751
- package/dist/declarations/actions/ExecutableAction.d.ts +0 -23
- package/dist/declarations/src/ObservableActorRef.d.ts +0 -25
- package/dist/declarations/src/match.d.ts +0 -5
- package/dist/declarations/src/model.d.ts +0 -5
- package/dist/declarations/src/model.types.d.ts +0 -53
- package/model/dist/xstate-model.cjs.d.ts +0 -1
- package/model/dist/xstate-model.cjs.dev.js +0 -41
- package/model/dist/xstate-model.cjs.js +0 -7
- package/model/dist/xstate-model.cjs.prod.js +0 -41
- package/model/dist/xstate-model.esm.js +0 -37
- package/model/package.json +0 -4
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { BaseActionObject, BaseDynamicActionObject, EventObject, MachineContext } from '../src/types';
|
|
2
|
-
export declare function createDynamicAction<TContext extends MachineContext, TEvent extends EventObject, TAction extends BaseActionObject, TDynamicParams extends Record<string, any>>(
|
|
3
|
-
|
|
1
|
+
import type { BaseActionObject, BaseDynamicActionObject, BuiltInActionObject, EventObject, MachineContext } from '../src/types';
|
|
2
|
+
export declare function createDynamicAction<TContext extends MachineContext, TEvent extends EventObject, TAction extends BaseActionObject, TDynamicParams extends Record<string, any>>(action: BuiltInActionObject & {
|
|
3
|
+
params: TDynamicParams;
|
|
4
|
+
}, resolve: BaseDynamicActionObject<TContext, TEvent, TAction, TDynamicParams>['resolve']): BaseDynamicActionObject<TContext, TEvent, TAction, TDynamicParams>;
|
|
5
|
+
export declare function isDynamicAction(action: any): action is BaseDynamicActionObject<any, any, any, any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MachineConfig, EventObject, AnyEventObject, MachineContext, ActorMap, InternalMachineImplementations, BaseActionObject } from './types';
|
|
2
|
-
import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from './typegenTypes';
|
|
3
|
-
import { StateMachine } from './StateMachine';
|
|
4
|
-
export declare function createMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TActorMap extends ActorMap = ActorMap, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, BaseActionObject, TActorMap, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, ResolveTypegenMeta<TTypesMeta, TEvent, BaseActionObject, TActorMap>>): StateMachine<TContext, TEvent, BaseActionObject, TActorMap, ResolveTypegenMeta<TTypesMeta, TEvent, BaseActionObject, TActorMap>>;
|
|
1
|
+
import { MachineConfig, EventObject, AnyEventObject, MachineContext, ActorMap, InternalMachineImplementations, BaseActionObject } from './types';
|
|
2
|
+
import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from './typegenTypes';
|
|
3
|
+
import { StateMachine } from './StateMachine';
|
|
4
|
+
export declare function createMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TActorMap extends ActorMap = ActorMap, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, BaseActionObject, TActorMap, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, ResolveTypegenMeta<TTypesMeta, TEvent, BaseActionObject, TActorMap>>): StateMachine<TContext, TEvent, BaseActionObject, TActorMap, ResolveTypegenMeta<TTypesMeta, TEvent, BaseActionObject, TActorMap>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export declare class Mailbox<T> {
|
|
2
|
-
private _process;
|
|
3
|
-
private _active;
|
|
4
|
-
private _current;
|
|
5
|
-
private _last;
|
|
6
|
-
constructor(_process: (ev: T) => void);
|
|
7
|
-
start(): void;
|
|
8
|
-
clear(): void;
|
|
9
|
-
prepend(event: T): void;
|
|
10
|
-
enqueue(event: T): void;
|
|
11
|
-
private flush;
|
|
12
|
-
}
|
|
1
|
+
export declare class Mailbox<T> {
|
|
2
|
+
private _process;
|
|
3
|
+
private _active;
|
|
4
|
+
private _current;
|
|
5
|
+
private _last;
|
|
6
|
+
constructor(_process: (ev: T) => void);
|
|
7
|
+
start(): void;
|
|
8
|
+
clear(): void;
|
|
9
|
+
prepend(event: T): void;
|
|
10
|
+
enqueue(event: T): void;
|
|
11
|
+
private flush;
|
|
12
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Clock } from './interpreter';
|
|
2
|
-
export interface SimulatedClock extends Clock {
|
|
3
|
-
start(speed: number): void;
|
|
4
|
-
increment(ms: number): void;
|
|
5
|
-
set(ms: number): void;
|
|
6
|
-
}
|
|
7
|
-
export declare class SimulatedClock implements SimulatedClock {
|
|
8
|
-
private timeouts;
|
|
9
|
-
private _now;
|
|
10
|
-
private _id;
|
|
11
|
-
now(): number;
|
|
12
|
-
private getId;
|
|
13
|
-
setTimeout(fn: (...args: any[]) => void, timeout: number): number;
|
|
14
|
-
clearTimeout(id: number): void;
|
|
15
|
-
private flushTimeouts;
|
|
16
|
-
}
|
|
1
|
+
import { Clock } from './interpreter';
|
|
2
|
+
export interface SimulatedClock extends Clock {
|
|
3
|
+
start(speed: number): void;
|
|
4
|
+
increment(ms: number): void;
|
|
5
|
+
set(ms: number): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class SimulatedClock implements SimulatedClock {
|
|
8
|
+
private timeouts;
|
|
9
|
+
private _now;
|
|
10
|
+
private _id;
|
|
11
|
+
now(): number;
|
|
12
|
+
private getId;
|
|
13
|
+
setTimeout(fn: (...args: any[]) => void, timeout: number): number;
|
|
14
|
+
clearTimeout(id: number): void;
|
|
15
|
+
private flushTimeouts;
|
|
16
|
+
}
|
|
@@ -1,104 +1,97 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare
|
|
10
|
-
|
|
11
|
-
value: StateValue;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
* @param
|
|
53
|
-
*/
|
|
54
|
-
static
|
|
55
|
-
/**
|
|
56
|
-
* Creates a new `State` instance
|
|
57
|
-
*
|
|
58
|
-
* @param
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* Whether the
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*/
|
|
99
|
-
can(event: TEvent | SimpleEventsOf<TEvent>['type']): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* The next events that will cause a transition from the current state.
|
|
102
|
-
*/
|
|
103
|
-
get nextEvents(): Array<TEvent['type']>;
|
|
104
|
-
}
|
|
1
|
+
import type { StateNode } from './StateNode';
|
|
2
|
+
import { TypegenDisabled, TypegenEnabled } from './typegenTypes';
|
|
3
|
+
import type { ActorRef, AnyState, AnyStateMachine, BaseActionObject, EventObject, HistoryValue, MachineContext, Prop, SCXML, StateConfig, StateValue, TransitionDefinition } from './types';
|
|
4
|
+
export declare function isStateConfig<TContext extends MachineContext, TEvent extends EventObject>(state: any): state is StateConfig<TContext, TEvent>;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `isStateConfig(object)` or `state instanceof State` instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isState: typeof isStateConfig;
|
|
9
|
+
export declare class State<TContext extends MachineContext, TEvent extends EventObject = EventObject, TResolvedTypesMeta = TypegenDisabled> {
|
|
10
|
+
machine: AnyStateMachine;
|
|
11
|
+
value: StateValue;
|
|
12
|
+
/**
|
|
13
|
+
* Indicates whether the state is a final state.
|
|
14
|
+
*/
|
|
15
|
+
done: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The done data of the top-level finite state.
|
|
18
|
+
*/
|
|
19
|
+
output: any;
|
|
20
|
+
context: TContext;
|
|
21
|
+
historyValue: Readonly<HistoryValue<TContext, TEvent>>;
|
|
22
|
+
actions: BaseActionObject[];
|
|
23
|
+
event: TEvent;
|
|
24
|
+
_internalQueue: Array<SCXML.Event<TEvent>>;
|
|
25
|
+
_event: SCXML.Event<TEvent>;
|
|
26
|
+
_sessionid: string | undefined;
|
|
27
|
+
_initial: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Indicates whether the state has changed from the previous state. A state is considered "changed" if:
|
|
30
|
+
*
|
|
31
|
+
* - Its value is not equal to its previous value, or:
|
|
32
|
+
* - It has any new actions (side-effects) to execute.
|
|
33
|
+
*
|
|
34
|
+
* An initial state (with no history) will return `undefined`.
|
|
35
|
+
*/
|
|
36
|
+
changed: boolean | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The enabled state nodes representative of the state value.
|
|
39
|
+
*/
|
|
40
|
+
configuration: Array<StateNode<TContext, TEvent>>;
|
|
41
|
+
/**
|
|
42
|
+
* The transition definitions that resulted in this state.
|
|
43
|
+
*/
|
|
44
|
+
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
45
|
+
/**
|
|
46
|
+
* An object mapping actor names to spawned/invoked actors.
|
|
47
|
+
*/
|
|
48
|
+
children: Record<string, ActorRef<any>>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new State instance for the given `stateValue` and `context`.
|
|
51
|
+
* @param stateValue
|
|
52
|
+
* @param context
|
|
53
|
+
*/
|
|
54
|
+
static from<TContext extends MachineContext, TEvent extends EventObject = EventObject>(stateValue: State<TContext, TEvent, any> | StateValue, context: TContext | undefined, machine: AnyStateMachine): State<TContext, TEvent, any>;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new `State` instance that represents the current state of a running machine.
|
|
57
|
+
*
|
|
58
|
+
* @param config
|
|
59
|
+
*/
|
|
60
|
+
constructor(config: StateConfig<TContext, TEvent>, machine: AnyStateMachine);
|
|
61
|
+
/**
|
|
62
|
+
* Returns an array of all the string leaf state node paths.
|
|
63
|
+
* @param stateValue
|
|
64
|
+
* @param delimiter The character(s) that separate each subpath in the string state node path.
|
|
65
|
+
*/
|
|
66
|
+
toStrings(stateValue?: StateValue, delimiter?: string): string[];
|
|
67
|
+
toJSON(): Omit<this, "nextEvents" | "meta" | "toJSON" | "configuration" | "transitions" | "tags" | "machine" | "toStrings" | "matches" | "hasTag" | "can"> & {
|
|
68
|
+
tags: string[];
|
|
69
|
+
meta: Record<string, any>;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Whether the current state value is a subset of the given parent state value.
|
|
73
|
+
* @param parentStateValue
|
|
74
|
+
*/
|
|
75
|
+
matches<TSV extends TResolvedTypesMeta extends TypegenEnabled ? Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'matchesStates'> : StateValue>(parentStateValue: TSV): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the current state configuration has a state node with the specified `tag`.
|
|
78
|
+
* @param tag
|
|
79
|
+
*/
|
|
80
|
+
hasTag(tag: TResolvedTypesMeta extends TypegenEnabled ? Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'tags'> : string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Determines whether sending the `event` will cause a non-forbidden transition
|
|
83
|
+
* to be selected, even if the transitions have no actions nor
|
|
84
|
+
* change the state value.
|
|
85
|
+
*
|
|
86
|
+
* @param event The event to test
|
|
87
|
+
* @returns Whether the event will cause a transition
|
|
88
|
+
*/
|
|
89
|
+
can(event: TEvent): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The next events that will cause a transition from the current state.
|
|
92
|
+
*/
|
|
93
|
+
get nextEvents(): Array<TEvent['type']>;
|
|
94
|
+
get meta(): Record<string, any>;
|
|
95
|
+
get tags(): Set<string>;
|
|
96
|
+
}
|
|
97
|
+
export declare function cloneState<TState extends AnyState>(state: TState, config?: Partial<StateConfig<any, any>>): TState;
|
|
@@ -1,112 +1,120 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @param
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @param
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
|
99
|
-
get definition():
|
|
100
|
-
toJSON():
|
|
101
|
-
createState(stateConfig: State<TContext, TEvent, TResolvedTypesMeta> | StateConfig<TContext, TEvent>): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
import { State } from './State';
|
|
2
|
+
import { StateNode } from './StateNode';
|
|
3
|
+
import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, ResolveTypegenMeta, TypegenDisabled } from './typegenTypes';
|
|
4
|
+
import type { ActorContext, ActorMap, BaseActionObject, Behavior, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineSchema, MaybeLazy, NoInfer, SCXML, StateConfig, StateMachineDefinition, StateValue, TransitionDefinition } from './types';
|
|
5
|
+
export declare const NULL_EVENT = "";
|
|
6
|
+
export declare const STATE_IDENTIFIER = "#";
|
|
7
|
+
export declare const WILDCARD = "*";
|
|
8
|
+
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject = EventObject, TAction extends BaseActionObject = BaseActionObject, TActorMap extends ActorMap = ActorMap, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TAction, TActorMap>> implements Behavior<TEvent | SCXML.Event<TEvent>, State<TContext, TEvent, TResolvedTypesMeta>, State<TContext, TEvent, TResolvedTypesMeta>> {
|
|
9
|
+
/**
|
|
10
|
+
* The raw config used to create the machine.
|
|
11
|
+
*/
|
|
12
|
+
config: MachineConfig<TContext, TEvent, any, any, any>;
|
|
13
|
+
private _contextFactory;
|
|
14
|
+
get context(): TContext;
|
|
15
|
+
private getContextAndActions;
|
|
16
|
+
/**
|
|
17
|
+
* The machine's own version.
|
|
18
|
+
*/
|
|
19
|
+
version?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The string delimiter for serializing the path to a string. The default is "."
|
|
22
|
+
*/
|
|
23
|
+
delimiter: string;
|
|
24
|
+
options: MachineImplementationsSimplified<TContext, TEvent>;
|
|
25
|
+
schema: MachineSchema<TContext, TEvent>;
|
|
26
|
+
__xstatenode: true;
|
|
27
|
+
idMap: Map<string, StateNode<TContext, TEvent>>;
|
|
28
|
+
root: StateNode<TContext, TEvent>;
|
|
29
|
+
id: string;
|
|
30
|
+
states: StateNode<TContext, TEvent>['states'];
|
|
31
|
+
events: Array<TEvent['type']>;
|
|
32
|
+
constructor(
|
|
33
|
+
/**
|
|
34
|
+
* The raw config used to create the machine.
|
|
35
|
+
*/
|
|
36
|
+
config: MachineConfig<TContext, TEvent, any, any, any>, options?: MachineImplementationsSimplified<TContext, TEvent>);
|
|
37
|
+
/**
|
|
38
|
+
* Clones this state machine with the provided implementations
|
|
39
|
+
* and merges the `context` (if provided).
|
|
40
|
+
*
|
|
41
|
+
* @param implementations Options (`actions`, `guards`, `actors`, `delays`, `context`)
|
|
42
|
+
* to recursively merge with the existing options.
|
|
43
|
+
*
|
|
44
|
+
* @returns A new `StateMachine` instance with the provided implementations.
|
|
45
|
+
*/
|
|
46
|
+
provide(implementations: InternalMachineImplementations<TContext, TEvent, TResolvedTypesMeta, true> & {
|
|
47
|
+
context?: MaybeLazy<Partial<TContext>>;
|
|
48
|
+
}): StateMachine<TContext, TEvent, TAction, TActorMap, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>;
|
|
49
|
+
/**
|
|
50
|
+
* Clones this state machine with custom `context`.
|
|
51
|
+
*
|
|
52
|
+
* The `context` provided can be partial `context`, which will be combined with the original `context`.
|
|
53
|
+
*
|
|
54
|
+
* @param context Custom context (will override predefined context, not recursive)
|
|
55
|
+
*/
|
|
56
|
+
withContext(context: Partial<TContext>): this;
|
|
57
|
+
/**
|
|
58
|
+
* Resolves the given `state` to a new `State` instance relative to this machine.
|
|
59
|
+
*
|
|
60
|
+
* This ensures that `.nextEvents` represent the correct values.
|
|
61
|
+
*
|
|
62
|
+
* @param state The state to resolve
|
|
63
|
+
*/
|
|
64
|
+
resolveState(state: State<TContext, TEvent, TResolvedTypesMeta>): typeof state;
|
|
65
|
+
resolveStateValue(stateValue: StateValue): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
66
|
+
/**
|
|
67
|
+
* Determines the next state given the current `state` and received `event`.
|
|
68
|
+
* Calculates a full macrostep from all microsteps.
|
|
69
|
+
*
|
|
70
|
+
* @param state The current State instance or state value
|
|
71
|
+
* @param event The received event
|
|
72
|
+
*/
|
|
73
|
+
transition(state: StateValue | State<TContext, TEvent, TResolvedTypesMeta> | undefined, event: TEvent | SCXML.Event<TEvent>, actorCtx?: ActorContext<TEvent, State<TContext, TEvent, any>>): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
74
|
+
/**
|
|
75
|
+
* Determines the next state given the current `state` and `event`.
|
|
76
|
+
* Calculates a microstep.
|
|
77
|
+
*
|
|
78
|
+
* @param state The current state
|
|
79
|
+
* @param event The received event
|
|
80
|
+
*/
|
|
81
|
+
microstep(state: State<TContext, TEvent, TResolvedTypesMeta> | undefined, event: TEvent | SCXML.Event<TEvent>, actorCtx?: ActorContext<any, any> | undefined): Array<State<TContext, TEvent, TResolvedTypesMeta>>;
|
|
82
|
+
getTransitionData(state: State<TContext, TEvent, TResolvedTypesMeta>, _event: SCXML.Event<TEvent>): Array<TransitionDefinition<TContext, TEvent>>;
|
|
83
|
+
/**
|
|
84
|
+
* The initial state _before_ evaluating any microsteps.
|
|
85
|
+
* This "pre-initial" state is provided to initial actions executed in the initial state.
|
|
86
|
+
*/
|
|
87
|
+
private getPreInitialState;
|
|
88
|
+
/**
|
|
89
|
+
* The initial State instance, which includes all actions to be executed from
|
|
90
|
+
* entering the initial state.
|
|
91
|
+
*/
|
|
92
|
+
get initialState(): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
|
|
95
|
+
*/
|
|
96
|
+
getInitialState(actorCtx?: ActorContext<TEvent, State<TContext, TEvent, TResolvedTypesMeta>>): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
97
|
+
start(state: State<TContext, TEvent, TResolvedTypesMeta>, actorCtx: ActorContext<TEvent, State<TContext, TEvent, TResolvedTypesMeta>>): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
98
|
+
getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
|
99
|
+
get definition(): StateMachineDefinition<TContext, TEvent>;
|
|
100
|
+
toJSON(): StateMachineDefinition<TContext, TEvent>;
|
|
101
|
+
createState(stateConfig: State<TContext, TEvent, TResolvedTypesMeta> | StateConfig<TContext, TEvent>): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
102
|
+
getStatus(state: State<TContext, TEvent, TResolvedTypesMeta>): {
|
|
103
|
+
status: string;
|
|
104
|
+
data: any;
|
|
105
|
+
} | {
|
|
106
|
+
status: string;
|
|
107
|
+
data?: undefined;
|
|
108
|
+
};
|
|
109
|
+
restoreState(state: State<TContext, TEvent, TResolvedTypesMeta>, _actorCtx?: ActorContext<TEvent, State<TContext, TEvent, TResolvedTypesMeta>>): State<TContext, TEvent, TResolvedTypesMeta>;
|
|
110
|
+
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
111
|
+
__TContext: TContext;
|
|
112
|
+
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
113
|
+
__TEvent: TEvent;
|
|
114
|
+
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
115
|
+
__TAction: TAction;
|
|
116
|
+
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
117
|
+
__TActorMap: TActorMap;
|
|
118
|
+
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
119
|
+
__TResolvedTypesMeta: TResolvedTypesMeta;
|
|
120
|
+
}
|