xstate 4.22.0 → 4.23.0
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/CHANGELOG.md +58 -4
- package/dist/xstate.interpreter.js +1 -1
- package/dist/xstate.js +1 -1
- package/dist/xstate.web.js +2 -2
- package/es/Actor.js +1 -6
- package/es/Machine.d.ts +3 -3
- package/es/Machine.js +1 -2
- package/es/State.js +1 -3
- package/es/StateNode.js +3 -2
- package/es/_virtual/_tslib.js +59 -73
- package/es/actionTypes.js +3 -2
- package/es/actions.d.ts +1 -1
- package/es/actions.js +51 -37
- package/es/behaviors.js +4 -2
- package/es/constants.js +2 -1
- package/es/devTools.js +1 -1
- package/es/environment.js +2 -1
- package/es/index.js +3 -1
- package/es/interpreter.d.ts +8 -2
- package/es/interpreter.js +8 -6
- package/es/invokeUtils.js +4 -3
- package/es/mapState.js +1 -1
- package/es/match.js +1 -1
- package/es/model.d.ts +2 -37
- package/es/model.types.d.ts +37 -0
- package/es/registry.js +2 -1
- package/es/scheduler.js +2 -1
- package/es/schema.js +1 -1
- package/es/serviceScope.js +1 -3
- package/es/stateUtils.js +1 -9
- package/es/types.d.ts +12 -2
- package/es/types.js +1 -1
- package/es/utils.js +1 -41
- package/lib/Actor.d.ts +25 -25
- package/lib/Actor.js +85 -66
- package/lib/Machine.d.ts +17 -17
- package/lib/Machine.js +14 -8
- package/lib/SimulatedClock.d.ts +16 -16
- package/lib/State.d.ts +108 -108
- package/lib/State.js +246 -236
- package/lib/StateNode.d.ts +279 -279
- package/lib/StateNode.js +1535 -1357
- package/lib/_virtual/_tslib.js +81 -0
- package/lib/actionTypes.d.ts +19 -19
- package/lib/actionTypes.js +43 -23
- package/lib/actions.d.ts +138 -138
- package/lib/actions.js +465 -387
- package/lib/behaviors.d.ts +36 -36
- package/lib/behaviors.js +65 -106
- package/lib/constants.d.ts +5 -5
- package/lib/constants.js +13 -7
- package/lib/devTools.d.ts +15 -15
- package/lib/devTools.js +37 -26
- package/lib/each.d.ts +3 -3
- package/lib/environment.d.ts +1 -1
- package/lib/environment.js +7 -4
- package/lib/index.d.ts +30 -30
- package/lib/index.js +67 -57
- package/lib/interpreter.d.ts +205 -199
- package/lib/interpreter.js +1306 -1060
- package/lib/invoke.d.ts +10 -10
- package/lib/invokeUtils.d.ts +6 -6
- package/lib/invokeUtils.js +40 -37
- package/lib/json.d.ts +30 -30
- package/lib/mapState.d.ts +3 -3
- package/lib/mapState.js +31 -32
- package/lib/match.d.ts +8 -8
- package/lib/match.js +33 -47
- package/lib/model.d.ts +4 -39
- package/lib/model.types.d.ts +37 -0
- package/lib/model.types.js +2 -0
- package/lib/patterns.d.ts +13 -13
- package/lib/registry.d.ts +8 -8
- package/lib/registry.js +21 -18
- package/lib/scheduler.d.ts +16 -16
- package/lib/scheduler.js +79 -70
- package/lib/schema.d.ts +1 -1
- package/lib/schema.js +6 -4
- package/lib/scxml.d.ts +5 -5
- package/lib/serviceScope.d.ts +3 -3
- package/lib/serviceScope.js +16 -12
- package/lib/stateUtils.d.ts +14 -14
- package/lib/stateUtils.js +231 -199
- package/lib/types.d.ts +928 -918
- package/lib/types.js +29 -29
- package/lib/utils.d.ts +68 -68
- package/lib/utils.js +528 -534
- package/package.json +5 -5
package/lib/State.d.ts
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { StateValue, ActivityMap, EventObject, HistoryValue, ActionObject, EventType, StateConfig, SCXML, StateSchema, TransitionDefinition, Typestate, ActorRef } from './types';
|
|
2
|
-
import { StateNode } from './StateNode';
|
|
3
|
-
export declare function stateValuesEqual(a: StateValue | undefined, b: StateValue | undefined): boolean;
|
|
4
|
-
export declare function isState<TContext, TEvent extends EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
5
|
-
value: any;
|
|
6
|
-
context: TContext;
|
|
7
|
-
}>(state: object | string): state is State<TContext, TEvent, TStateSchema, TTypestate>;
|
|
8
|
-
export declare function bindActionToState<TC, TE extends EventObject>(action: ActionObject<TC, TE>, state: State<TC, TE, any, any>): ActionObject<TC, TE>;
|
|
9
|
-
export declare class State<TContext, TEvent extends EventObject = EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
10
|
-
value: any;
|
|
11
|
-
context: TContext;
|
|
12
|
-
}> {
|
|
13
|
-
value: StateValue;
|
|
14
|
-
context: TContext;
|
|
15
|
-
historyValue?: HistoryValue | undefined;
|
|
16
|
-
history?: State<TContext, TEvent, TStateSchema, TTypestate>;
|
|
17
|
-
actions: Array<ActionObject<TContext, TEvent>>;
|
|
18
|
-
activities: ActivityMap;
|
|
19
|
-
meta: any;
|
|
20
|
-
events: TEvent[];
|
|
21
|
-
event: TEvent;
|
|
22
|
-
_event: SCXML.Event<TEvent>;
|
|
23
|
-
_sessionid: string | null;
|
|
24
|
-
/**
|
|
25
|
-
* Indicates whether the state has changed from the previous state. A state is considered "changed" if:
|
|
26
|
-
*
|
|
27
|
-
* - Its value is not equal to its previous value, or:
|
|
28
|
-
* - It has any new actions (side-effects) to execute.
|
|
29
|
-
*
|
|
30
|
-
* An initial state (with no history) will return `undefined`.
|
|
31
|
-
*/
|
|
32
|
-
changed: boolean | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Indicates whether the state is a final state.
|
|
35
|
-
*/
|
|
36
|
-
done: boolean | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* The enabled state nodes representative of the state value.
|
|
39
|
-
*/
|
|
40
|
-
configuration: Array<StateNode<TContext, any, TEvent, any>>;
|
|
41
|
-
/**
|
|
42
|
-
* The next events that will cause a transition from the current state.
|
|
43
|
-
*/
|
|
44
|
-
nextEvents: EventType[];
|
|
45
|
-
/**
|
|
46
|
-
* The transition definitions that resulted in this state.
|
|
47
|
-
*/
|
|
48
|
-
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
49
|
-
/**
|
|
50
|
-
* An object mapping actor IDs to spawned actors/invoked services.
|
|
51
|
-
*/
|
|
52
|
-
children: Record<string, ActorRef<any>>;
|
|
53
|
-
tags: Set<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Creates a new State instance for the given `stateValue` and `context`.
|
|
56
|
-
* @param stateValue
|
|
57
|
-
* @param context
|
|
58
|
-
*/
|
|
59
|
-
static from<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE, any, any> | StateValue, context?: TC | undefined): State<TC, TE, any, any>;
|
|
60
|
-
/**
|
|
61
|
-
* Creates a new State instance for the given `config`.
|
|
62
|
-
* @param config The state config
|
|
63
|
-
*/
|
|
64
|
-
static create<TC, TE extends EventObject = EventObject>(config: StateConfig<TC, TE>): State<TC, TE>;
|
|
65
|
-
/**
|
|
66
|
-
* Creates a new `State` instance for the given `stateValue` and `context` with no actions (side-effects).
|
|
67
|
-
* @param stateValue
|
|
68
|
-
* @param context
|
|
69
|
-
*/
|
|
70
|
-
static inert<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE> | StateValue, context: TC): State<TC, TE>;
|
|
71
|
-
/**
|
|
72
|
-
* Creates a new State instance.
|
|
73
|
-
* @param value The state value
|
|
74
|
-
* @param context The extended state
|
|
75
|
-
* @param historyValue The tree representing historical values of the state nodes
|
|
76
|
-
* @param history The previous state
|
|
77
|
-
* @param actions An array of action objects to execute as side-effects
|
|
78
|
-
* @param activities A mapping of activities and whether they are started (`true`) or stopped (`false`).
|
|
79
|
-
* @param meta
|
|
80
|
-
* @param events Internal event queue. Should be empty with run-to-completion semantics.
|
|
81
|
-
* @param configuration
|
|
82
|
-
*/
|
|
83
|
-
constructor(config: StateConfig<TContext, TEvent>);
|
|
84
|
-
/**
|
|
85
|
-
* Returns an array of all the string leaf state node paths.
|
|
86
|
-
* @param stateValue
|
|
87
|
-
* @param delimiter The character(s) that separate each subpath in the string state node path.
|
|
88
|
-
*/
|
|
89
|
-
toStrings(stateValue?: StateValue, delimiter?: string): string[];
|
|
90
|
-
toJSON(): Omit<this, "configuration" | "transitions" | "tags"> & {
|
|
91
|
-
tags: string[];
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Whether the current state value is a subset of the given parent state value.
|
|
95
|
-
* @param parentStateValue
|
|
96
|
-
*/
|
|
97
|
-
matches<TSV extends TTypestate['value']>(parentStateValue: TSV): this is State<(TTypestate extends any ? {
|
|
98
|
-
value: TSV;
|
|
99
|
-
context: any;
|
|
100
|
-
} extends TTypestate ? TTypestate : never : never)['context'], TEvent, TStateSchema, TTypestate> & {
|
|
101
|
-
value: TSV;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Whether the current state configuration has a state node with the specified `tag`.
|
|
105
|
-
* @param tag
|
|
106
|
-
*/
|
|
107
|
-
hasTag(tag: string): boolean;
|
|
108
|
-
}
|
|
1
|
+
import { StateValue, ActivityMap, EventObject, HistoryValue, ActionObject, EventType, StateConfig, SCXML, StateSchema, TransitionDefinition, Typestate, ActorRef } from './types';
|
|
2
|
+
import { StateNode } from './StateNode';
|
|
3
|
+
export declare function stateValuesEqual(a: StateValue | undefined, b: StateValue | undefined): boolean;
|
|
4
|
+
export declare function isState<TContext, TEvent extends EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
5
|
+
value: any;
|
|
6
|
+
context: TContext;
|
|
7
|
+
}>(state: object | string): state is State<TContext, TEvent, TStateSchema, TTypestate>;
|
|
8
|
+
export declare function bindActionToState<TC, TE extends EventObject>(action: ActionObject<TC, TE>, state: State<TC, TE, any, any>): ActionObject<TC, TE>;
|
|
9
|
+
export declare class State<TContext, TEvent extends EventObject = EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
|
|
10
|
+
value: any;
|
|
11
|
+
context: TContext;
|
|
12
|
+
}> {
|
|
13
|
+
value: StateValue;
|
|
14
|
+
context: TContext;
|
|
15
|
+
historyValue?: HistoryValue | undefined;
|
|
16
|
+
history?: State<TContext, TEvent, TStateSchema, TTypestate>;
|
|
17
|
+
actions: Array<ActionObject<TContext, TEvent>>;
|
|
18
|
+
activities: ActivityMap;
|
|
19
|
+
meta: any;
|
|
20
|
+
events: TEvent[];
|
|
21
|
+
event: TEvent;
|
|
22
|
+
_event: SCXML.Event<TEvent>;
|
|
23
|
+
_sessionid: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Indicates whether the state has changed from the previous state. A state is considered "changed" if:
|
|
26
|
+
*
|
|
27
|
+
* - Its value is not equal to its previous value, or:
|
|
28
|
+
* - It has any new actions (side-effects) to execute.
|
|
29
|
+
*
|
|
30
|
+
* An initial state (with no history) will return `undefined`.
|
|
31
|
+
*/
|
|
32
|
+
changed: boolean | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Indicates whether the state is a final state.
|
|
35
|
+
*/
|
|
36
|
+
done: boolean | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The enabled state nodes representative of the state value.
|
|
39
|
+
*/
|
|
40
|
+
configuration: Array<StateNode<TContext, any, TEvent, any>>;
|
|
41
|
+
/**
|
|
42
|
+
* The next events that will cause a transition from the current state.
|
|
43
|
+
*/
|
|
44
|
+
nextEvents: EventType[];
|
|
45
|
+
/**
|
|
46
|
+
* The transition definitions that resulted in this state.
|
|
47
|
+
*/
|
|
48
|
+
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
49
|
+
/**
|
|
50
|
+
* An object mapping actor IDs to spawned actors/invoked services.
|
|
51
|
+
*/
|
|
52
|
+
children: Record<string, ActorRef<any>>;
|
|
53
|
+
tags: Set<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new State instance for the given `stateValue` and `context`.
|
|
56
|
+
* @param stateValue
|
|
57
|
+
* @param context
|
|
58
|
+
*/
|
|
59
|
+
static from<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE, any, any> | StateValue, context?: TC | undefined): State<TC, TE, any, any>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new State instance for the given `config`.
|
|
62
|
+
* @param config The state config
|
|
63
|
+
*/
|
|
64
|
+
static create<TC, TE extends EventObject = EventObject>(config: StateConfig<TC, TE>): State<TC, TE>;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new `State` instance for the given `stateValue` and `context` with no actions (side-effects).
|
|
67
|
+
* @param stateValue
|
|
68
|
+
* @param context
|
|
69
|
+
*/
|
|
70
|
+
static inert<TC, TE extends EventObject = EventObject>(stateValue: State<TC, TE> | StateValue, context: TC): State<TC, TE>;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new State instance.
|
|
73
|
+
* @param value The state value
|
|
74
|
+
* @param context The extended state
|
|
75
|
+
* @param historyValue The tree representing historical values of the state nodes
|
|
76
|
+
* @param history The previous state
|
|
77
|
+
* @param actions An array of action objects to execute as side-effects
|
|
78
|
+
* @param activities A mapping of activities and whether they are started (`true`) or stopped (`false`).
|
|
79
|
+
* @param meta
|
|
80
|
+
* @param events Internal event queue. Should be empty with run-to-completion semantics.
|
|
81
|
+
* @param configuration
|
|
82
|
+
*/
|
|
83
|
+
constructor(config: StateConfig<TContext, TEvent>);
|
|
84
|
+
/**
|
|
85
|
+
* Returns an array of all the string leaf state node paths.
|
|
86
|
+
* @param stateValue
|
|
87
|
+
* @param delimiter The character(s) that separate each subpath in the string state node path.
|
|
88
|
+
*/
|
|
89
|
+
toStrings(stateValue?: StateValue, delimiter?: string): string[];
|
|
90
|
+
toJSON(): Omit<this, "configuration" | "transitions" | "tags"> & {
|
|
91
|
+
tags: string[];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Whether the current state value is a subset of the given parent state value.
|
|
95
|
+
* @param parentStateValue
|
|
96
|
+
*/
|
|
97
|
+
matches<TSV extends TTypestate['value']>(parentStateValue: TSV): this is State<(TTypestate extends any ? {
|
|
98
|
+
value: TSV;
|
|
99
|
+
context: any;
|
|
100
|
+
} extends TTypestate ? TTypestate : never : never)['context'], TEvent, TStateSchema, TTypestate> & {
|
|
101
|
+
value: TSV;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Whether the current state configuration has a state node with the specified `tag`.
|
|
105
|
+
* @param tag
|
|
106
|
+
*/
|
|
107
|
+
hasTag(tag: string): boolean;
|
|
108
|
+
}
|
|
109
109
|
//# sourceMappingURL=State.d.ts.map
|