xstate 4.32.1 → 5.0.0-alpha.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 +483 -0
- package/actions/ExecutableAction.ts +58 -0
- package/actions/dist/xstate-actions.cjs.d.ts +1 -0
- package/actions/dist/xstate-actions.cjs.dev.js +32 -0
- package/actions/dist/xstate-actions.cjs.js +7 -0
- package/actions/dist/xstate-actions.cjs.prod.js +32 -0
- package/actions/dist/xstate-actions.esm.js +2 -0
- package/actions/dynamicAction.ts +34 -0
- package/actions/package.json +4 -0
- package/actors/dist/xstate-actors.cjs.d.ts +1 -0
- package/actors/dist/xstate-actors.cjs.dev.js +21 -0
- package/actors/dist/xstate-actors.cjs.js +7 -0
- package/actors/dist/xstate-actors.cjs.prod.js +21 -0
- package/actors/dist/xstate-actors.esm.js +2 -0
- package/actors/package.json +4 -0
- package/dev/dist/xstate-dev.cjs.d.ts +1 -0
- package/dev/dist/xstate-dev.cjs.dev.js +11 -0
- package/dev/dist/xstate-dev.cjs.js +7 -0
- package/{lib/devTools.js → dev/dist/xstate-dev.cjs.prod.js} +17 -10
- package/dev/dist/xstate-dev.esm.js +1 -0
- package/dev/package.json +4 -0
- package/dist/Machine-9ce74c11.cjs.dev.js +755 -0
- package/dist/Machine-dca041dc.cjs.prod.js +749 -0
- package/dist/Machine-fb2f47f5.esm.js +751 -0
- package/dist/actions-6b86876d.cjs.dev.js +4815 -0
- package/dist/actions-70094c93.cjs.prod.js +4765 -0
- package/dist/actions-ff512f16.esm.js +4757 -0
- package/dist/declarations/actions/ExecutableAction.d.ts +23 -0
- package/dist/declarations/actions/dynamicAction.d.ts +3 -0
- package/dist/declarations/src/Machine.d.ts +4 -0
- package/dist/declarations/src/Mailbox.d.ts +12 -0
- package/dist/declarations/src/ObservableActorRef.d.ts +25 -0
- package/{lib → dist/declarations/src}/SimulatedClock.d.ts +0 -1
- package/dist/declarations/src/State.d.ts +104 -0
- package/dist/declarations/src/StateMachine.d.ts +112 -0
- package/dist/declarations/src/StateNode.d.ts +127 -0
- package/{es → dist/declarations/src}/actionTypes.d.ts +0 -3
- package/dist/declarations/src/actions/assign.d.ts +7 -0
- package/dist/declarations/src/actions/cancel.d.ts +10 -0
- package/dist/declarations/src/actions/choose.d.ts +3 -0
- package/dist/declarations/src/actions/invoke.d.ts +3 -0
- package/dist/declarations/src/actions/log.d.ts +11 -0
- package/dist/declarations/src/actions/pure.d.ts +3 -0
- package/dist/declarations/src/actions/raise.d.ts +9 -0
- package/dist/declarations/src/actions/send.d.ts +55 -0
- package/dist/declarations/src/actions/stop.d.ts +8 -0
- package/dist/declarations/src/actions.d.ts +44 -0
- package/dist/declarations/src/actors.d.ts +38 -0
- package/dist/declarations/src/constants.d.ts +5 -0
- package/{lib/devTools.d.ts → dist/declarations/src/dev/index.d.ts} +2 -2
- package/{es → dist/declarations/src}/environment.d.ts +0 -1
- package/dist/declarations/src/guards.d.ts +9 -0
- package/dist/declarations/src/index.d.ts +47 -0
- package/dist/declarations/src/interpreter.d.ts +147 -0
- package/{es → dist/declarations/src}/mapState.d.ts +0 -1
- package/dist/declarations/src/match.d.ts +5 -0
- package/dist/declarations/src/memo.d.ts +1 -0
- package/dist/declarations/src/model.d.ts +5 -0
- package/{lib → dist/declarations/src}/model.types.d.ts +6 -9
- package/dist/declarations/src/registry.d.ts +8 -0
- package/{es → dist/declarations/src}/schema.d.ts +0 -1
- package/dist/declarations/src/spawn.d.ts +2 -0
- package/dist/declarations/src/stateUtils.d.ts +85 -0
- package/{lib → dist/declarations/src}/typegenTypes.d.ts +16 -17
- package/dist/declarations/src/types.d.ts +1026 -0
- package/dist/declarations/src/utils.d.ts +56 -0
- package/{es/devTools.js → dist/index-20b364c4.esm.js} +18 -6
- package/dist/index-2a564d03.cjs.dev.js +64 -0
- package/dist/xstate.cjs.d.ts +1 -0
- package/dist/xstate.cjs.dev.js +217 -0
- package/dist/xstate.cjs.js +7 -0
- package/dist/xstate.cjs.prod.js +217 -0
- package/dist/xstate.esm.js +172 -0
- package/guards/dist/xstate-guards.cjs.d.ts +1 -0
- package/guards/dist/xstate-guards.cjs.dev.js +15 -0
- package/guards/dist/xstate-guards.cjs.js +7 -0
- package/guards/dist/xstate-guards.cjs.prod.js +15 -0
- package/guards/dist/xstate-guards.esm.js +2 -0
- package/guards/package.json +4 -0
- package/invoke/package.json +4 -0
- package/model/dist/xstate-model.cjs.d.ts +1 -0
- package/model/dist/xstate-model.cjs.dev.js +41 -0
- package/model/dist/xstate-model.cjs.js +7 -0
- package/model/dist/xstate-model.cjs.prod.js +41 -0
- package/model/dist/xstate-model.esm.js +37 -0
- package/model/package.json +4 -0
- package/package.json +21 -30
- package/dist/xstate.interpreter.js +0 -15
- package/dist/xstate.js +0 -15
- package/dist/xstate.web.js +0 -15
- package/es/Actor.d.ts +0 -25
- package/es/Actor.js +0 -99
- package/es/Machine.d.ts +0 -12
- package/es/Machine.js +0 -14
- package/es/SimulatedClock.d.ts +0 -17
- package/es/SimulatedClock.js +0 -81
- package/es/State.d.ts +0 -123
- package/es/State.js +0 -274
- package/es/StateNode.d.ts +0 -287
- package/es/StateNode.js +0 -1566
- package/es/_virtual/_tslib.js +0 -78
- package/es/actionTypes.js +0 -22
- package/es/actions.d.ts +0 -154
- package/es/actions.js +0 -520
- package/es/behaviors.d.ts +0 -37
- package/es/behaviors.js +0 -131
- package/es/constants.d.ts +0 -6
- package/es/constants.js +0 -6
- package/es/devTools.d.ts +0 -14
- package/es/each.d.ts +0 -4
- package/es/each.js +0 -13
- package/es/environment.js +0 -3
- package/es/index.d.ts +0 -22
- package/es/index.js +0 -23
- package/es/interpreter.d.ts +0 -209
- package/es/interpreter.js +0 -1402
- package/es/invoke.d.ts +0 -11
- package/es/invokeUtils.d.ts +0 -7
- package/es/invokeUtils.js +0 -40
- package/es/json.d.ts +0 -31
- package/es/json.js +0 -86
- package/es/mapState.js +0 -32
- package/es/match.d.ts +0 -9
- package/es/match.js +0 -34
- package/es/model.d.ts +0 -5
- package/es/model.js +0 -50
- package/es/model.types.d.ts +0 -56
- package/es/patterns.d.ts +0 -14
- package/es/patterns.js +0 -48
- package/es/registry.d.ts +0 -9
- package/es/registry.js +0 -19
- package/es/scheduler.d.ts +0 -17
- package/es/scheduler.js +0 -79
- package/es/schema.js +0 -6
- package/es/scxml.d.ts +0 -6
- package/es/serviceScope.d.ts +0 -4
- package/es/serviceScope.js +0 -16
- package/es/stateUtils.d.ts +0 -17
- package/es/stateUtils.js +0 -259
- package/es/typegenTypes.d.ts +0 -133
- package/es/types.d.ts +0 -1031
- package/es/types.js +0 -33
- package/es/utils.d.ts +0 -72
- package/es/utils.js +0 -626
- package/es/waitFor.d.ts +0 -32
- package/es/waitFor.js +0 -71
- package/lib/Actor.d.ts +0 -25
- package/lib/Actor.js +0 -108
- package/lib/Machine.d.ts +0 -12
- package/lib/Machine.js +0 -19
- package/lib/SimulatedClock.js +0 -85
- package/lib/State.d.ts +0 -123
- package/lib/State.js +0 -282
- package/lib/StateNode.d.ts +0 -287
- package/lib/StateNode.js +0 -1570
- package/lib/_virtual/_tslib.js +0 -85
- package/lib/actionTypes.d.ts +0 -20
- package/lib/actionTypes.js +0 -43
- package/lib/actions.d.ts +0 -154
- package/lib/actions.js +0 -552
- package/lib/behaviors.d.ts +0 -37
- package/lib/behaviors.js +0 -137
- package/lib/constants.d.ts +0 -6
- package/lib/constants.js +0 -13
- package/lib/each.d.ts +0 -4
- package/lib/each.js +0 -17
- package/lib/environment.d.ts +0 -2
- package/lib/environment.js +0 -7
- package/lib/index.d.ts +0 -22
- package/lib/index.js +0 -60
- package/lib/interpreter.d.ts +0 -209
- package/lib/interpreter.js +0 -1408
- package/lib/invoke.d.ts +0 -11
- package/lib/invoke.js +0 -20
- package/lib/invokeUtils.d.ts +0 -7
- package/lib/invokeUtils.js +0 -45
- package/lib/json.d.ts +0 -31
- package/lib/json.js +0 -94
- package/lib/mapState.d.ts +0 -4
- package/lib/mapState.js +0 -36
- package/lib/match.d.ts +0 -9
- package/lib/match.js +0 -38
- package/lib/model.d.ts +0 -5
- package/lib/model.js +0 -54
- package/lib/model.types.js +0 -2
- package/lib/patterns.d.ts +0 -14
- package/lib/patterns.js +0 -53
- package/lib/registry.d.ts +0 -9
- package/lib/registry.js +0 -23
- package/lib/scheduler.d.ts +0 -17
- package/lib/scheduler.js +0 -83
- package/lib/schema.d.ts +0 -3
- package/lib/schema.js +0 -11
- package/lib/scxml.d.ts +0 -6
- package/lib/scxml.js +0 -350
- package/lib/serviceScope.d.ts +0 -4
- package/lib/serviceScope.js +0 -21
- package/lib/stateUtils.d.ts +0 -17
- package/lib/stateUtils.js +0 -273
- package/lib/typegenTypes.js +0 -2
- package/lib/types.d.ts +0 -1031
- package/lib/types.js +0 -35
- package/lib/utils.d.ts +0 -72
- package/lib/utils.js +0 -673
- package/lib/waitFor.d.ts +0 -32
- package/lib/waitFor.js +0 -75
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var guards_dist_xstateGuards = require('./actions-70094c93.cjs.prod.js');
|
|
4
|
+
|
|
5
|
+
var _excluded = ["onDone", "onError"];
|
|
6
|
+
var EMPTY_OBJECT = {};
|
|
7
|
+
var StateNode = /*#__PURE__*/function () {
|
|
8
|
+
/**
|
|
9
|
+
* The relative key of the state node, which represents its location in the overall state value.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The unique ID of the state node.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The type of this state node:
|
|
18
|
+
*
|
|
19
|
+
* - `'atomic'` - no child state nodes
|
|
20
|
+
* - `'compound'` - nested child state nodes (XOR)
|
|
21
|
+
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
22
|
+
* - `'history'` - history state node
|
|
23
|
+
* - `'final'` - final state node
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The string path from the root machine node to this node.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The child state nodes.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The type of history on this state node. Can be:
|
|
36
|
+
*
|
|
37
|
+
* - `'shallow'` - recalls only top-level historical state value
|
|
38
|
+
* - `'deep'` - recalls historical state value at all levels
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The action(s) to be executed upon entering the state node.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The action(s) to be executed upon exiting the state node.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The parent state node.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The root machine node.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The meta data associated with this state node, which will be returned in State instances.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The data sent with the "done.state._id_" event if this is a final state node.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The order this state node appears. Corresponds to the implicit SCXML document order.
|
|
67
|
+
*/
|
|
68
|
+
function StateNode(
|
|
69
|
+
/**
|
|
70
|
+
* The raw config used to create the machine.
|
|
71
|
+
*/
|
|
72
|
+
config, options) {
|
|
73
|
+
var _this = this;
|
|
74
|
+
|
|
75
|
+
guards_dist_xstateGuards._classCallCheck(this, StateNode);
|
|
76
|
+
|
|
77
|
+
this.config = config;
|
|
78
|
+
|
|
79
|
+
guards_dist_xstateGuards._defineProperty(this, "key", void 0);
|
|
80
|
+
|
|
81
|
+
guards_dist_xstateGuards._defineProperty(this, "id", void 0);
|
|
82
|
+
|
|
83
|
+
guards_dist_xstateGuards._defineProperty(this, "type", void 0);
|
|
84
|
+
|
|
85
|
+
guards_dist_xstateGuards._defineProperty(this, "path", void 0);
|
|
86
|
+
|
|
87
|
+
guards_dist_xstateGuards._defineProperty(this, "states", void 0);
|
|
88
|
+
|
|
89
|
+
guards_dist_xstateGuards._defineProperty(this, "history", void 0);
|
|
90
|
+
|
|
91
|
+
guards_dist_xstateGuards._defineProperty(this, "entry", void 0);
|
|
92
|
+
|
|
93
|
+
guards_dist_xstateGuards._defineProperty(this, "exit", void 0);
|
|
94
|
+
|
|
95
|
+
guards_dist_xstateGuards._defineProperty(this, "parent", void 0);
|
|
96
|
+
|
|
97
|
+
guards_dist_xstateGuards._defineProperty(this, "machine", void 0);
|
|
98
|
+
|
|
99
|
+
guards_dist_xstateGuards._defineProperty(this, "meta", void 0);
|
|
100
|
+
|
|
101
|
+
guards_dist_xstateGuards._defineProperty(this, "doneData", void 0);
|
|
102
|
+
|
|
103
|
+
guards_dist_xstateGuards._defineProperty(this, "order", -1);
|
|
104
|
+
|
|
105
|
+
guards_dist_xstateGuards._defineProperty(this, "description", void 0);
|
|
106
|
+
|
|
107
|
+
guards_dist_xstateGuards._defineProperty(this, "tags", []);
|
|
108
|
+
|
|
109
|
+
guards_dist_xstateGuards._defineProperty(this, "transitions", void 0);
|
|
110
|
+
|
|
111
|
+
guards_dist_xstateGuards._defineProperty(this, "always", void 0);
|
|
112
|
+
|
|
113
|
+
this.parent = options._parent;
|
|
114
|
+
this.key = this.config.key || options._key;
|
|
115
|
+
this.machine = options._machine;
|
|
116
|
+
this.path = this.parent ? this.parent.path.concat(this.key) : [];
|
|
117
|
+
this.id = this.config.id || [this.machine.key].concat(guards_dist_xstateGuards._toConsumableArray(this.path)).join(this.machine.delimiter);
|
|
118
|
+
this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? 'compound' : this.config.history ? 'history' : 'atomic');
|
|
119
|
+
this.description = this.config.description;
|
|
120
|
+
this.order = this.machine.idMap.size;
|
|
121
|
+
this.machine.idMap.set(this.id, this);
|
|
122
|
+
this.states = this.config.states ? guards_dist_xstateGuards.mapValues(this.config.states, function (stateConfig, key) {
|
|
123
|
+
var stateNode = new StateNode(stateConfig, {
|
|
124
|
+
_parent: _this,
|
|
125
|
+
_key: key,
|
|
126
|
+
_machine: _this.machine
|
|
127
|
+
});
|
|
128
|
+
return stateNode;
|
|
129
|
+
}) : EMPTY_OBJECT;
|
|
130
|
+
|
|
131
|
+
if (this.type === 'compound' && !this.config.initial) {
|
|
132
|
+
throw new Error("No initial state specified for compound state node \"#".concat(this.id, "\". Try adding { initial: \"").concat(Object.keys(this.states)[0], "\" } to the state config."));
|
|
133
|
+
} // History config
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
this.history = this.config.history === true ? 'shallow' : this.config.history || false;
|
|
137
|
+
this.entry = guards_dist_xstateGuards.toArray(this.config.entry).map(function (action) {
|
|
138
|
+
return guards_dist_xstateGuards.toActionObject(action, _this.machine.options.actions);
|
|
139
|
+
});
|
|
140
|
+
this.exit = guards_dist_xstateGuards.toArray(this.config.exit).map(function (action) {
|
|
141
|
+
return guards_dist_xstateGuards.toActionObject(action, _this.machine.options.actions);
|
|
142
|
+
});
|
|
143
|
+
this.meta = this.config.meta;
|
|
144
|
+
this.doneData = this.type === 'final' ? this.config.data : undefined;
|
|
145
|
+
this.tags = guards_dist_xstateGuards.toArray(config.tags);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
guards_dist_xstateGuards._createClass(StateNode, [{
|
|
149
|
+
key: "_initialize",
|
|
150
|
+
value: function _initialize() {
|
|
151
|
+
var _this2 = this;
|
|
152
|
+
|
|
153
|
+
this.transitions = guards_dist_xstateGuards.formatTransitions(this);
|
|
154
|
+
|
|
155
|
+
if (this.config.always) {
|
|
156
|
+
this.always = guards_dist_xstateGuards.toTransitionConfigArray(guards_dist_xstateGuards.NULL_EVENT, this.config.always).map(function (t) {
|
|
157
|
+
return guards_dist_xstateGuards.formatTransition(_this2, t);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
Object.keys(this.states).forEach(function (key) {
|
|
162
|
+
_this2.states[key]._initialize();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The well-structured state node definition.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
}, {
|
|
170
|
+
key: "definition",
|
|
171
|
+
get: function get() {
|
|
172
|
+
var _this3 = this;
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
id: this.id,
|
|
176
|
+
key: this.key,
|
|
177
|
+
version: this.machine.version,
|
|
178
|
+
context: this.machine.context,
|
|
179
|
+
type: this.type,
|
|
180
|
+
initial: this.initial ? {
|
|
181
|
+
target: this.initial.target,
|
|
182
|
+
source: this,
|
|
183
|
+
actions: this.initial.actions,
|
|
184
|
+
eventType: null,
|
|
185
|
+
toJSON: function toJSON() {
|
|
186
|
+
return {
|
|
187
|
+
target: _this3.initial.target.map(function (t) {
|
|
188
|
+
return "#".concat(t.id);
|
|
189
|
+
}),
|
|
190
|
+
source: "#".concat(_this3.id),
|
|
191
|
+
actions: _this3.initial.actions,
|
|
192
|
+
eventType: null
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
} : undefined,
|
|
196
|
+
history: this.history,
|
|
197
|
+
states: guards_dist_xstateGuards.mapValues(this.states, function (state) {
|
|
198
|
+
return state.definition;
|
|
199
|
+
}),
|
|
200
|
+
on: this.on,
|
|
201
|
+
transitions: this.transitions,
|
|
202
|
+
entry: this.entry,
|
|
203
|
+
exit: this.exit,
|
|
204
|
+
meta: this.meta,
|
|
205
|
+
order: this.order || -1,
|
|
206
|
+
data: this.doneData,
|
|
207
|
+
invoke: this.invoke,
|
|
208
|
+
description: this.description,
|
|
209
|
+
tags: this.tags
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
key: "toJSON",
|
|
214
|
+
value: function toJSON() {
|
|
215
|
+
return this.definition;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* The behaviors invoked as actors by this state node.
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
}, {
|
|
222
|
+
key: "invoke",
|
|
223
|
+
get: function get() {
|
|
224
|
+
var _this4 = this;
|
|
225
|
+
|
|
226
|
+
return guards_dist_xstateGuards.memo(this, 'invoke', function () {
|
|
227
|
+
return guards_dist_xstateGuards.toArray(_this4.config.invoke).map(function (invocable, i) {
|
|
228
|
+
var generatedId = guards_dist_xstateGuards.createInvokeId(_this4.id, i);
|
|
229
|
+
var invokeConfig = guards_dist_xstateGuards.toInvokeConfig(invocable, generatedId);
|
|
230
|
+
var resolvedId = invokeConfig.id || generatedId;
|
|
231
|
+
var src = invokeConfig.src;
|
|
232
|
+
var resolvedSrc = guards_dist_xstateGuards.toInvokeSource(guards_dist_xstateGuards.isString(src) ? src : !('type' in src) ? resolvedId : src);
|
|
233
|
+
|
|
234
|
+
if (!_this4.machine.options.actors[resolvedId] && typeof src !== 'string' && !('type' in src)) {
|
|
235
|
+
_this4.machine.options.actors = guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, _this4.machine.options.actors), {}, guards_dist_xstateGuards._defineProperty({}, resolvedId, typeof src === 'function' ? src : function () {
|
|
236
|
+
return src;
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({
|
|
241
|
+
type: guards_dist_xstateGuards.invoke
|
|
242
|
+
}, invokeConfig), {}, {
|
|
243
|
+
src: resolvedSrc,
|
|
244
|
+
id: resolvedId,
|
|
245
|
+
toJSON: function toJSON() {
|
|
246
|
+
var onDone = invokeConfig.onDone,
|
|
247
|
+
onError = invokeConfig.onError,
|
|
248
|
+
invokeDefValues = guards_dist_xstateGuards._objectWithoutProperties(invokeConfig, _excluded);
|
|
249
|
+
|
|
250
|
+
return guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, invokeDefValues), {}, {
|
|
251
|
+
type: guards_dist_xstateGuards.invoke,
|
|
252
|
+
src: resolvedSrc,
|
|
253
|
+
id: resolvedId
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* The mapping of events to transitions.
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
}, {
|
|
265
|
+
key: "on",
|
|
266
|
+
get: function get() {
|
|
267
|
+
var _this5 = this;
|
|
268
|
+
|
|
269
|
+
return guards_dist_xstateGuards.memo(this, 'on', function () {
|
|
270
|
+
var transitions = _this5.transitions;
|
|
271
|
+
return transitions.reduce(function (map, transition) {
|
|
272
|
+
map[transition.eventType] = map[transition.eventType] || [];
|
|
273
|
+
map[transition.eventType].push(transition);
|
|
274
|
+
return map;
|
|
275
|
+
}, {});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "after",
|
|
280
|
+
get: function get() {
|
|
281
|
+
var _this6 = this;
|
|
282
|
+
|
|
283
|
+
return guards_dist_xstateGuards.memo(this, 'delayedTransitions', function () {
|
|
284
|
+
return guards_dist_xstateGuards.getDelayedTransitions(_this6);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}, {
|
|
288
|
+
key: "initial",
|
|
289
|
+
get: function get() {
|
|
290
|
+
var _this7 = this;
|
|
291
|
+
|
|
292
|
+
return guards_dist_xstateGuards.memo(this, 'initial', function () {
|
|
293
|
+
return guards_dist_xstateGuards.formatInitialTransition(_this7, _this7.config.initial || []);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Returns `true` if this state node explicitly handles the given event.
|
|
298
|
+
*
|
|
299
|
+
* @param event The event in question
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
}, {
|
|
303
|
+
key: "handles",
|
|
304
|
+
value: function handles(event) {
|
|
305
|
+
var eventType = guards_dist_xstateGuards.getEventType(event);
|
|
306
|
+
return this.events.includes(eventType);
|
|
307
|
+
}
|
|
308
|
+
}, {
|
|
309
|
+
key: "next",
|
|
310
|
+
value: function next(state, _event) {
|
|
311
|
+
var _this8 = this;
|
|
312
|
+
|
|
313
|
+
var eventName = _event.name;
|
|
314
|
+
var actions = [];
|
|
315
|
+
var selectedTransition;
|
|
316
|
+
var candidates = guards_dist_xstateGuards.memo(this, "candidates-".concat(eventName.toString()), function () {
|
|
317
|
+
return guards_dist_xstateGuards.getCandidates(_this8, eventName, _this8.machine.config.scxml // Whether token matching should be used
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
var _iterator = guards_dist_xstateGuards._createForOfIteratorHelper(candidates),
|
|
322
|
+
_step;
|
|
323
|
+
|
|
324
|
+
try {
|
|
325
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
326
|
+
var candidate = _step.value;
|
|
327
|
+
var guard = candidate.guard;
|
|
328
|
+
var resolvedContext = state.context;
|
|
329
|
+
var guardPassed = false;
|
|
330
|
+
|
|
331
|
+
try {
|
|
332
|
+
guardPassed = !guard || guards_dist_xstateGuards.evaluateGuard(guard, resolvedContext, _event, state, this.machine);
|
|
333
|
+
} catch (err) {
|
|
334
|
+
throw new Error("Unable to evaluate guard '".concat(guard.type, "' in transition for event '").concat(eventName, "' in state node '").concat(this.id, "':\n").concat(err.message));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (guardPassed) {
|
|
338
|
+
actions.push.apply(actions, guards_dist_xstateGuards._toConsumableArray(candidate.actions));
|
|
339
|
+
selectedTransition = candidate;
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
} catch (err) {
|
|
344
|
+
_iterator.e(err);
|
|
345
|
+
} finally {
|
|
346
|
+
_iterator.f();
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return selectedTransition ? [selectedTransition] : undefined;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* The target state value of the history state node, if it exists. This represents the
|
|
353
|
+
* default state value to transition to if no history value exists yet.
|
|
354
|
+
*/
|
|
355
|
+
|
|
356
|
+
}, {
|
|
357
|
+
key: "target",
|
|
358
|
+
get: function get() {
|
|
359
|
+
if (this.type === 'history') {
|
|
360
|
+
var historyConfig = this.config;
|
|
361
|
+
return historyConfig.target;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return undefined;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* All the state node IDs of this state node and its descendant state nodes.
|
|
368
|
+
*/
|
|
369
|
+
|
|
370
|
+
}, {
|
|
371
|
+
key: "stateIds",
|
|
372
|
+
get: function get() {
|
|
373
|
+
var _this9 = this;
|
|
374
|
+
|
|
375
|
+
var childStateIds = guards_dist_xstateGuards.flatten(Object.keys(this.states).map(function (stateKey) {
|
|
376
|
+
return _this9.states[stateKey].stateIds;
|
|
377
|
+
}));
|
|
378
|
+
return [this.id].concat(childStateIds);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* All the event types accepted by this state node and its descendants.
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
}, {
|
|
385
|
+
key: "events",
|
|
386
|
+
get: function get() {
|
|
387
|
+
var _this10 = this;
|
|
388
|
+
|
|
389
|
+
return guards_dist_xstateGuards.memo(this, 'events', function () {
|
|
390
|
+
var states = _this10.states;
|
|
391
|
+
var events = new Set(_this10.ownEvents);
|
|
392
|
+
|
|
393
|
+
if (states) {
|
|
394
|
+
for (var _i = 0, _Object$keys = Object.keys(states); _i < _Object$keys.length; _i++) {
|
|
395
|
+
var stateId = _Object$keys[_i];
|
|
396
|
+
var state = states[stateId];
|
|
397
|
+
|
|
398
|
+
if (state.states) {
|
|
399
|
+
var _iterator2 = guards_dist_xstateGuards._createForOfIteratorHelper(state.events),
|
|
400
|
+
_step2;
|
|
401
|
+
|
|
402
|
+
try {
|
|
403
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
404
|
+
var event = _step2.value;
|
|
405
|
+
events.add("".concat(event));
|
|
406
|
+
}
|
|
407
|
+
} catch (err) {
|
|
408
|
+
_iterator2.e(err);
|
|
409
|
+
} finally {
|
|
410
|
+
_iterator2.f();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return Array.from(events);
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* All the events that have transitions directly from this state node.
|
|
421
|
+
*
|
|
422
|
+
* Excludes any inert events.
|
|
423
|
+
*/
|
|
424
|
+
|
|
425
|
+
}, {
|
|
426
|
+
key: "ownEvents",
|
|
427
|
+
get: function get() {
|
|
428
|
+
var events = new Set(this.transitions.filter(function (transition) {
|
|
429
|
+
return !(!transition.target && !transition.actions.length && transition.internal);
|
|
430
|
+
}).map(function (transition) {
|
|
431
|
+
return transition.eventType;
|
|
432
|
+
}));
|
|
433
|
+
return Array.from(events);
|
|
434
|
+
}
|
|
435
|
+
}]);
|
|
436
|
+
|
|
437
|
+
return StateNode;
|
|
438
|
+
}();
|
|
439
|
+
|
|
440
|
+
var STATE_IDENTIFIER = '#';
|
|
441
|
+
|
|
442
|
+
function createDefaultOptions() {
|
|
443
|
+
return {
|
|
444
|
+
actions: {},
|
|
445
|
+
actors: {},
|
|
446
|
+
delays: {},
|
|
447
|
+
guards: {},
|
|
448
|
+
context: {}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function resolveContext(context, partialContext) {
|
|
453
|
+
if (guards_dist_xstateGuards.isFunction(partialContext)) {
|
|
454
|
+
return guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, context), partialContext);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, context), partialContext);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
var StateMachine = /*#__PURE__*/function () {
|
|
461
|
+
function StateMachine(
|
|
462
|
+
/**
|
|
463
|
+
* The raw config used to create the machine.
|
|
464
|
+
*/
|
|
465
|
+
config, options) {
|
|
466
|
+
var _this$config$schema;
|
|
467
|
+
|
|
468
|
+
guards_dist_xstateGuards._classCallCheck(this, StateMachine);
|
|
469
|
+
|
|
470
|
+
this.config = config;
|
|
471
|
+
|
|
472
|
+
guards_dist_xstateGuards._defineProperty(this, "_contextFactory", void 0);
|
|
473
|
+
|
|
474
|
+
guards_dist_xstateGuards._defineProperty(this, "version", void 0);
|
|
475
|
+
|
|
476
|
+
guards_dist_xstateGuards._defineProperty(this, "strict", void 0);
|
|
477
|
+
|
|
478
|
+
guards_dist_xstateGuards._defineProperty(this, "delimiter", void 0);
|
|
479
|
+
|
|
480
|
+
guards_dist_xstateGuards._defineProperty(this, "options", void 0);
|
|
481
|
+
|
|
482
|
+
guards_dist_xstateGuards._defineProperty(this, "schema", void 0);
|
|
483
|
+
|
|
484
|
+
guards_dist_xstateGuards._defineProperty(this, "__xstatenode", true);
|
|
485
|
+
|
|
486
|
+
guards_dist_xstateGuards._defineProperty(this, "idMap", new Map());
|
|
487
|
+
|
|
488
|
+
guards_dist_xstateGuards._defineProperty(this, "root", void 0);
|
|
489
|
+
|
|
490
|
+
guards_dist_xstateGuards._defineProperty(this, "key", void 0);
|
|
491
|
+
|
|
492
|
+
guards_dist_xstateGuards._defineProperty(this, "states", void 0);
|
|
493
|
+
|
|
494
|
+
guards_dist_xstateGuards._defineProperty(this, "events", void 0);
|
|
495
|
+
|
|
496
|
+
guards_dist_xstateGuards._defineProperty(this, "__TContext", void 0);
|
|
497
|
+
|
|
498
|
+
guards_dist_xstateGuards._defineProperty(this, "__TEvent", void 0);
|
|
499
|
+
|
|
500
|
+
guards_dist_xstateGuards._defineProperty(this, "__TAction", void 0);
|
|
501
|
+
|
|
502
|
+
guards_dist_xstateGuards._defineProperty(this, "__TActorMap", void 0);
|
|
503
|
+
|
|
504
|
+
guards_dist_xstateGuards._defineProperty(this, "__TResolvedTypesMeta", void 0);
|
|
505
|
+
|
|
506
|
+
this.key = config.key || config.id || '(machine)';
|
|
507
|
+
this.options = Object.assign(createDefaultOptions(), options);
|
|
508
|
+
this._contextFactory = guards_dist_xstateGuards.isFunction(config.context) ? config.context : function (stuff) {
|
|
509
|
+
var partialContext = typeof (options === null || options === void 0 ? void 0 : options.context) === 'function' ? options.context(stuff) : options === null || options === void 0 ? void 0 : options.context;
|
|
510
|
+
return resolveContext(config.context, partialContext);
|
|
511
|
+
}; // TODO: fix types
|
|
512
|
+
// this.context = resolveContext(config.context, options?.context);
|
|
513
|
+
|
|
514
|
+
this.delimiter = this.config.delimiter || guards_dist_xstateGuards.STATE_DELIMITER;
|
|
515
|
+
this.version = this.config.version;
|
|
516
|
+
this.schema = (_this$config$schema = this.config.schema) !== null && _this$config$schema !== void 0 ? _this$config$schema : {};
|
|
517
|
+
this.strict = !!this.config.strict;
|
|
518
|
+
this.transition = this.transition.bind(this);
|
|
519
|
+
this.root = new StateNode(config, {
|
|
520
|
+
_key: this.key,
|
|
521
|
+
_machine: this
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
this.root._initialize();
|
|
525
|
+
|
|
526
|
+
this.states = this.root.states; // TODO: remove!
|
|
527
|
+
|
|
528
|
+
this.events = this.root.events;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Clones this state machine with the provided implementations
|
|
532
|
+
* and merges the `context` (if provided).
|
|
533
|
+
*
|
|
534
|
+
* @param implementations Options (`actions`, `guards`, `actors`, `delays`, `context`)
|
|
535
|
+
* to recursively merge with the existing options.
|
|
536
|
+
*
|
|
537
|
+
* @returns A new `StateMachine` instance with the provided implementations.
|
|
538
|
+
*/
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
guards_dist_xstateGuards._createClass(StateMachine, [{
|
|
542
|
+
key: "context",
|
|
543
|
+
get: function get() {
|
|
544
|
+
return this.getContextAndActions()[0];
|
|
545
|
+
}
|
|
546
|
+
}, {
|
|
547
|
+
key: "getContextAndActions",
|
|
548
|
+
value: function getContextAndActions() {
|
|
549
|
+
var actions = []; // TODO: merge with this.options.context
|
|
550
|
+
|
|
551
|
+
var context = this._contextFactory({
|
|
552
|
+
spawn: guards_dist_xstateGuards.createSpawner(this, null, null, actions) // TODO: fix types
|
|
553
|
+
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
return [context, actions];
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* The machine's own version.
|
|
560
|
+
*/
|
|
561
|
+
|
|
562
|
+
}, {
|
|
563
|
+
key: "provide",
|
|
564
|
+
value: function provide(implementations) {
|
|
565
|
+
var _this$options = this.options,
|
|
566
|
+
actions = _this$options.actions,
|
|
567
|
+
guards = _this$options.guards,
|
|
568
|
+
actors = _this$options.actors,
|
|
569
|
+
delays = _this$options.delays;
|
|
570
|
+
return new StateMachine(this.config, {
|
|
571
|
+
actions: guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, actions), implementations.actions),
|
|
572
|
+
guards: guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, guards), implementations.guards),
|
|
573
|
+
actors: guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, actors), implementations.actors),
|
|
574
|
+
delays: guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, delays), implementations.delays),
|
|
575
|
+
context: implementations.context
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Clones this state machine with custom `context`.
|
|
580
|
+
*
|
|
581
|
+
* The `context` provided can be partial `context`, which will be combined with the original `context`.
|
|
582
|
+
*
|
|
583
|
+
* @param context Custom context (will override predefined context, not recursive)
|
|
584
|
+
*/
|
|
585
|
+
|
|
586
|
+
}, {
|
|
587
|
+
key: "withContext",
|
|
588
|
+
value: function withContext(context) {
|
|
589
|
+
return this.provide({
|
|
590
|
+
context: context
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Resolves the given `state` to a new `State` instance relative to this machine.
|
|
595
|
+
*
|
|
596
|
+
* This ensures that `.nextEvents` represent the correct values.
|
|
597
|
+
*
|
|
598
|
+
* @param state The state to resolve
|
|
599
|
+
*/
|
|
600
|
+
|
|
601
|
+
}, {
|
|
602
|
+
key: "resolveState",
|
|
603
|
+
value: function resolveState(state) {
|
|
604
|
+
var configuration = Array.from(guards_dist_xstateGuards.getConfiguration(guards_dist_xstateGuards.getStateNodes(this.root, state.value)));
|
|
605
|
+
return this.createState(guards_dist_xstateGuards._objectSpread2(guards_dist_xstateGuards._objectSpread2({}, state), {}, {
|
|
606
|
+
value: guards_dist_xstateGuards.resolveStateValue(this.root, state.value),
|
|
607
|
+
configuration: configuration
|
|
608
|
+
}));
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Determines the next state given the current `state` and received `event`.
|
|
612
|
+
* Calculates a full macrostep from all microsteps.
|
|
613
|
+
*
|
|
614
|
+
* @param state The current State instance or state value
|
|
615
|
+
* @param event The received event
|
|
616
|
+
*/
|
|
617
|
+
|
|
618
|
+
}, {
|
|
619
|
+
key: "transition",
|
|
620
|
+
value: function transition() {
|
|
621
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.initialState;
|
|
622
|
+
var event = arguments.length > 1 ? arguments[1] : undefined;
|
|
623
|
+
var currentState = guards_dist_xstateGuards.toState(state, this);
|
|
624
|
+
return guards_dist_xstateGuards.macrostep(currentState, event, this);
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Determines the next state given the current `state` and `event`.
|
|
628
|
+
* Calculates a microstep.
|
|
629
|
+
*
|
|
630
|
+
* @param state The current state
|
|
631
|
+
* @param event The received event
|
|
632
|
+
*/
|
|
633
|
+
|
|
634
|
+
}, {
|
|
635
|
+
key: "microstep",
|
|
636
|
+
value: function microstep() {
|
|
637
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.initialState;
|
|
638
|
+
var event = arguments.length > 1 ? arguments[1] : undefined;
|
|
639
|
+
var resolvedState = guards_dist_xstateGuards.toState(state, this);
|
|
640
|
+
|
|
641
|
+
var _event = guards_dist_xstateGuards.toSCXMLEvent(event);
|
|
642
|
+
|
|
643
|
+
if (this.strict) {
|
|
644
|
+
if (!this.root.events.includes(_event.name) && !guards_dist_xstateGuards.isBuiltInEvent(_event.name)) {
|
|
645
|
+
throw new Error("Machine '".concat(this.key, "' does not accept event '").concat(_event.name, "'"));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
var transitions = this.getTransitionData(resolvedState, _event);
|
|
650
|
+
return guards_dist_xstateGuards.resolveMicroTransition(this, transitions, resolvedState, _event);
|
|
651
|
+
}
|
|
652
|
+
}, {
|
|
653
|
+
key: "getTransitionData",
|
|
654
|
+
value: function getTransitionData(state, _event) {
|
|
655
|
+
return guards_dist_xstateGuards.transitionNode(this.root, state.value, state, _event) || [];
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* The initial state _before_ evaluating any microsteps.
|
|
659
|
+
* This "pre-initial" state is provided to initial actions executed in the initial state.
|
|
660
|
+
*/
|
|
661
|
+
|
|
662
|
+
}, {
|
|
663
|
+
key: "preInitialState",
|
|
664
|
+
get: function get() {
|
|
665
|
+
var _preInitial$actions;
|
|
666
|
+
|
|
667
|
+
var _this$getContextAndAc = this.getContextAndActions(),
|
|
668
|
+
_this$getContextAndAc2 = guards_dist_xstateGuards._slicedToArray(_this$getContextAndAc, 2),
|
|
669
|
+
context = _this$getContextAndAc2[0],
|
|
670
|
+
actions = _this$getContextAndAc2[1];
|
|
671
|
+
|
|
672
|
+
var preInitial = this.resolveState(guards_dist_xstateGuards.State.from(guards_dist_xstateGuards.getStateValue(this.root, guards_dist_xstateGuards.getConfiguration([this.root])), context));
|
|
673
|
+
preInitial._initial = true;
|
|
674
|
+
|
|
675
|
+
(_preInitial$actions = preInitial.actions).unshift.apply(_preInitial$actions, guards_dist_xstateGuards._toConsumableArray(actions));
|
|
676
|
+
|
|
677
|
+
return preInitial;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* The initial State instance, which includes all actions to be executed from
|
|
681
|
+
* entering the initial state.
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
}, {
|
|
685
|
+
key: "initialState",
|
|
686
|
+
get: function get() {
|
|
687
|
+
return this.getInitialState();
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
|
|
691
|
+
*/
|
|
692
|
+
|
|
693
|
+
}, {
|
|
694
|
+
key: "getInitialState",
|
|
695
|
+
value: function getInitialState() {
|
|
696
|
+
var _nextState$actions;
|
|
697
|
+
|
|
698
|
+
var preInitialState = this.preInitialState;
|
|
699
|
+
var nextState = guards_dist_xstateGuards.resolveMicroTransition(this, [], preInitialState, undefined);
|
|
700
|
+
|
|
701
|
+
(_nextState$actions = nextState.actions).unshift.apply(_nextState$actions, guards_dist_xstateGuards._toConsumableArray(preInitialState.actions));
|
|
702
|
+
|
|
703
|
+
var macroState = guards_dist_xstateGuards.macrostep(nextState, null, this);
|
|
704
|
+
macroState.changed = undefined;
|
|
705
|
+
return macroState;
|
|
706
|
+
}
|
|
707
|
+
}, {
|
|
708
|
+
key: "getStateNodeById",
|
|
709
|
+
value: function getStateNodeById(stateId) {
|
|
710
|
+
var resolvedStateId = guards_dist_xstateGuards.isStateId(stateId) ? stateId.slice(STATE_IDENTIFIER.length) : stateId;
|
|
711
|
+
var stateNode = this.idMap.get(resolvedStateId);
|
|
712
|
+
|
|
713
|
+
if (!stateNode) {
|
|
714
|
+
throw new Error("Child state node '#".concat(resolvedStateId, "' does not exist on machine '").concat(this.key, "'"));
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
return stateNode;
|
|
718
|
+
}
|
|
719
|
+
}, {
|
|
720
|
+
key: "definition",
|
|
721
|
+
get: function get() {
|
|
722
|
+
return this.root.definition;
|
|
723
|
+
}
|
|
724
|
+
}, {
|
|
725
|
+
key: "toJSON",
|
|
726
|
+
value: function toJSON() {
|
|
727
|
+
return this.definition;
|
|
728
|
+
}
|
|
729
|
+
}, {
|
|
730
|
+
key: "createState",
|
|
731
|
+
value: function createState(stateConfig) {
|
|
732
|
+
var state = stateConfig instanceof guards_dist_xstateGuards.State ? stateConfig : new guards_dist_xstateGuards.State(stateConfig);
|
|
733
|
+
state.machine = this;
|
|
734
|
+
return state;
|
|
735
|
+
}
|
|
736
|
+
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
737
|
+
|
|
738
|
+
}]);
|
|
739
|
+
|
|
740
|
+
return StateMachine;
|
|
741
|
+
}();
|
|
742
|
+
|
|
743
|
+
function createMachine(config, implementations) {
|
|
744
|
+
return new StateMachine(config, implementations);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
exports.StateMachine = StateMachine;
|
|
748
|
+
exports.StateNode = StateNode;
|
|
749
|
+
exports.createMachine = createMachine;
|