xstate 5.0.0-beta.45 → 5.0.0-beta.46
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/actions/dist/xstate-actions.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -2
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +42 -5
- package/actors/dist/xstate-actors.development.cjs.js +42 -5
- package/actors/dist/xstate-actors.development.esm.js +42 -5
- package/actors/dist/xstate-actors.esm.js +42 -5
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +16 -26
- package/dist/declarations/src/StateMachine.d.ts +11 -29
- package/dist/declarations/src/StateNode.d.ts +8 -6
- package/dist/declarations/src/actors/observable.d.ts +41 -4
- package/dist/declarations/src/createMachine.d.ts +3 -3
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/setup.d.ts +11 -8
- package/dist/declarations/src/types.d.ts +41 -15
- package/dist/declarations/src/utils.d.ts +2 -1
- package/dist/{raise-2b5a4e4c.esm.js → raise-1682abb7.esm.js} +23 -36
- package/dist/{raise-fabffc3d.cjs.js → raise-a1d3d7e9.cjs.js} +23 -35
- package/dist/{raise-b3fb3c65.development.cjs.js → raise-a9e7e31c.development.cjs.js} +23 -35
- package/dist/{raise-90139fbc.development.esm.js → raise-fa23c2b9.development.esm.js} +23 -36
- package/dist/{send-c124176f.cjs.js → send-2fa3a204.cjs.js} +22 -1
- package/dist/{send-d0bc7eed.development.cjs.js → send-5b256a89.development.cjs.js} +22 -1
- package/dist/{send-24cc8018.development.esm.js → send-9acdf858.development.esm.js} +22 -1
- package/dist/{send-8e7e41e7.esm.js → send-a237e4e8.esm.js} +22 -1
- package/dist/xstate.cjs.js +59 -81
- package/dist/xstate.cjs.mjs +1 -0
- package/dist/xstate.development.cjs.js +59 -81
- package/dist/xstate.development.cjs.mjs +1 -0
- package/dist/xstate.development.esm.js +60 -83
- package/dist/xstate.esm.js +60 -83
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.development.cjs.js');
|
|
6
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var send = require('./send-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-a9e7e31c.development.cjs.js');
|
|
7
|
+
var send = require('./send-5b256a89.development.cjs.js');
|
|
8
8
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -90,85 +90,72 @@ const toSerializableAction = action => {
|
|
|
90
90
|
return action;
|
|
91
91
|
};
|
|
92
92
|
class StateNode {
|
|
93
|
-
/**
|
|
94
|
-
* The relative key of the state node, which represents its location in the overall state value.
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The unique ID of the state node.
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The type of this state node:
|
|
103
|
-
*
|
|
104
|
-
* - `'atomic'` - no child state nodes
|
|
105
|
-
* - `'compound'` - nested child state nodes (XOR)
|
|
106
|
-
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
107
|
-
* - `'history'` - history state node
|
|
108
|
-
* - `'final'` - final state node
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* The string path from the root machine node to this node.
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The child state nodes.
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* The type of history on this state node. Can be:
|
|
121
|
-
*
|
|
122
|
-
* - `'shallow'` - recalls only top-level historical state value
|
|
123
|
-
* - `'deep'` - recalls historical state value at all levels
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The action(s) to be executed upon entering the state node.
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* The action(s) to be executed upon exiting the state node.
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* The parent state node.
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* The root machine node.
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* The meta data associated with this state node, which will be returned in State instances.
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* The order this state node appears. Corresponds to the implicit document order.
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
93
|
constructor(
|
|
155
94
|
/**
|
|
156
95
|
* The raw config used to create the machine.
|
|
157
96
|
*/
|
|
158
97
|
config, options) {
|
|
159
98
|
this.config = config;
|
|
99
|
+
/**
|
|
100
|
+
* The relative key of the state node, which represents its location in the overall state value.
|
|
101
|
+
*/
|
|
160
102
|
this.key = void 0;
|
|
103
|
+
/**
|
|
104
|
+
* The unique ID of the state node.
|
|
105
|
+
*/
|
|
161
106
|
this.id = void 0;
|
|
107
|
+
/**
|
|
108
|
+
* The type of this state node:
|
|
109
|
+
*
|
|
110
|
+
* - `'atomic'` - no child state nodes
|
|
111
|
+
* - `'compound'` - nested child state nodes (XOR)
|
|
112
|
+
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
113
|
+
* - `'history'` - history state node
|
|
114
|
+
* - `'final'` - final state node
|
|
115
|
+
*/
|
|
162
116
|
this.type = void 0;
|
|
117
|
+
/**
|
|
118
|
+
* The string path from the root machine node to this node.
|
|
119
|
+
*/
|
|
163
120
|
this.path = void 0;
|
|
121
|
+
/**
|
|
122
|
+
* The child state nodes.
|
|
123
|
+
*/
|
|
164
124
|
this.states = void 0;
|
|
125
|
+
/**
|
|
126
|
+
* The type of history on this state node. Can be:
|
|
127
|
+
*
|
|
128
|
+
* - `'shallow'` - recalls only top-level historical state value
|
|
129
|
+
* - `'deep'` - recalls historical state value at all levels
|
|
130
|
+
*/
|
|
165
131
|
this.history = void 0;
|
|
132
|
+
/**
|
|
133
|
+
* The action(s) to be executed upon entering the state node.
|
|
134
|
+
*/
|
|
166
135
|
this.entry = void 0;
|
|
136
|
+
/**
|
|
137
|
+
* The action(s) to be executed upon exiting the state node.
|
|
138
|
+
*/
|
|
167
139
|
this.exit = void 0;
|
|
140
|
+
/**
|
|
141
|
+
* The parent state node.
|
|
142
|
+
*/
|
|
168
143
|
this.parent = void 0;
|
|
144
|
+
/**
|
|
145
|
+
* The root machine node.
|
|
146
|
+
*/
|
|
169
147
|
this.machine = void 0;
|
|
148
|
+
/**
|
|
149
|
+
* The meta data associated with this state node, which will be returned in State instances.
|
|
150
|
+
*/
|
|
170
151
|
this.meta = void 0;
|
|
152
|
+
/**
|
|
153
|
+
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
154
|
+
*/
|
|
171
155
|
this.output = void 0;
|
|
156
|
+
/**
|
|
157
|
+
* The order this state node appears. Corresponds to the implicit document order.
|
|
158
|
+
*/
|
|
172
159
|
this.order = -1;
|
|
173
160
|
this.description = void 0;
|
|
174
161
|
this.tags = [];
|
|
@@ -374,16 +361,15 @@ class StateNode {
|
|
|
374
361
|
|
|
375
362
|
const STATE_IDENTIFIER = '#';
|
|
376
363
|
class StateMachine {
|
|
377
|
-
/**
|
|
378
|
-
* The machine's own version.
|
|
379
|
-
*/
|
|
380
|
-
|
|
381
364
|
constructor(
|
|
382
365
|
/**
|
|
383
366
|
* The raw config used to create the machine.
|
|
384
367
|
*/
|
|
385
368
|
config, implementations) {
|
|
386
369
|
this.config = config;
|
|
370
|
+
/**
|
|
371
|
+
* The machine's own version.
|
|
372
|
+
*/
|
|
387
373
|
this.version = void 0;
|
|
388
374
|
this.implementations = void 0;
|
|
389
375
|
this.types = void 0;
|
|
@@ -393,15 +379,7 @@ class StateMachine {
|
|
|
393
379
|
this.id = void 0;
|
|
394
380
|
this.states = void 0;
|
|
395
381
|
this.events = void 0;
|
|
396
|
-
|
|
397
|
-
this.__TEvent = void 0;
|
|
398
|
-
this.__TActor = void 0;
|
|
399
|
-
this.__TAction = void 0;
|
|
400
|
-
this.__TGuard = void 0;
|
|
401
|
-
this.__TDelay = void 0;
|
|
402
|
-
this.__TTag = void 0;
|
|
403
|
-
this.__TInput = void 0;
|
|
404
|
-
this.__TOutput = void 0;
|
|
382
|
+
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
405
383
|
this.__TResolvedTypesMeta = void 0;
|
|
406
384
|
this.id = config.id || '(machine)';
|
|
407
385
|
this.implementations = {
|
|
@@ -486,7 +464,7 @@ class StateMachine {
|
|
|
486
464
|
*/
|
|
487
465
|
transition(state, event, actorScope) {
|
|
488
466
|
// TODO: handle error events in a better way
|
|
489
|
-
if (guards_dist_xstateGuards.isErrorActorEvent(event) && !
|
|
467
|
+
if (guards_dist_xstateGuards.isErrorActorEvent(event) && !guards_dist_xstateGuards.getAllOwnEventDescriptors(state).some(nextEvent => nextEvent === event.type)) {
|
|
490
468
|
return guards_dist_xstateGuards.cloneMachineSnapshot(state, {
|
|
491
469
|
status: 'error',
|
|
492
470
|
error: event.data
|
|
@@ -596,12 +574,11 @@ class StateMachine {
|
|
|
596
574
|
if (!logic) {
|
|
597
575
|
return;
|
|
598
576
|
}
|
|
599
|
-
const actorState = logic.restoreState?.(childState, _actorScope);
|
|
600
577
|
const actorRef = guards_dist_xstateGuards.createActor(logic, {
|
|
601
578
|
id: actorId,
|
|
602
579
|
parent: _actorScope?.self,
|
|
603
580
|
syncSnapshot: actorData.syncSnapshot,
|
|
604
|
-
state:
|
|
581
|
+
state: childState,
|
|
605
582
|
src,
|
|
606
583
|
systemId: actorData.systemId
|
|
607
584
|
});
|
|
@@ -632,8 +609,6 @@ class StateMachine {
|
|
|
632
609
|
reviveContext(restoredSnapshot.context, children);
|
|
633
610
|
return restoredSnapshot;
|
|
634
611
|
}
|
|
635
|
-
|
|
636
|
-
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
637
612
|
}
|
|
638
613
|
|
|
639
614
|
const defaultWaitForOptions = {
|
|
@@ -714,6 +689,8 @@ function createMachine(config, implementations) {
|
|
|
714
689
|
return new StateMachine(config, implementations);
|
|
715
690
|
}
|
|
716
691
|
|
|
692
|
+
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
693
|
+
// this could be reconsidered in the future
|
|
717
694
|
function setup({
|
|
718
695
|
actors,
|
|
719
696
|
actions,
|
|
@@ -737,6 +714,7 @@ exports.fromObservable = actors_dist_xstateActors.fromObservable;
|
|
|
737
714
|
exports.fromPromise = actors_dist_xstateActors.fromPromise;
|
|
738
715
|
exports.fromTransition = actors_dist_xstateActors.fromTransition;
|
|
739
716
|
exports.Actor = guards_dist_xstateGuards.Actor;
|
|
717
|
+
exports.__unsafe_getAllOwnEventDescriptors = guards_dist_xstateGuards.getAllOwnEventDescriptors;
|
|
740
718
|
exports.and = guards_dist_xstateGuards.and;
|
|
741
719
|
exports.cancel = guards_dist_xstateGuards.cancel;
|
|
742
720
|
exports.createActor = guards_dist_xstateGuards.createActor;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as isErrorActorEvent, o as
|
|
3
|
-
export {
|
|
4
|
-
import { a as assign } from './send-
|
|
5
|
-
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as isErrorActorEvent, o as getAllOwnEventDescriptors, p as cloneMachineSnapshot, q as macrostep, s as transitionNode, u as resolveActionsAndContext, v as createInitEvent, w as microstep, x as getInitialStateNodes, y as isStateId, z as getStateNodeByPath, A as getPersistedState, B as resolveReferencedActor, C as createActor, $ as $$ACTOR_TYPE } from './raise-fa23c2b9.development.esm.js';
|
|
3
|
+
export { D as Actor, o as __unsafe_getAllOwnEventDescriptors, J as and, O as cancel, C as createActor, j as getStateNodes, E as interpret, F as isMachineSnapshot, G as matchesState, K as not, L as or, H as pathToStateValue, P as raise, R as spawn, M as stateIn, Q as stop, I as toObserver } from './raise-fa23c2b9.development.esm.js';
|
|
4
|
+
import { a as assign } from './send-9acdf858.development.esm.js';
|
|
5
|
+
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-9acdf858.development.esm.js';
|
|
6
6
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
7
7
|
|
|
8
8
|
class SimulatedClock {
|
|
@@ -88,85 +88,72 @@ const toSerializableAction = action => {
|
|
|
88
88
|
return action;
|
|
89
89
|
};
|
|
90
90
|
class StateNode {
|
|
91
|
-
/**
|
|
92
|
-
* The relative key of the state node, which represents its location in the overall state value.
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The unique ID of the state node.
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The type of this state node:
|
|
101
|
-
*
|
|
102
|
-
* - `'atomic'` - no child state nodes
|
|
103
|
-
* - `'compound'` - nested child state nodes (XOR)
|
|
104
|
-
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
105
|
-
* - `'history'` - history state node
|
|
106
|
-
* - `'final'` - final state node
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The string path from the root machine node to this node.
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The child state nodes.
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* The type of history on this state node. Can be:
|
|
119
|
-
*
|
|
120
|
-
* - `'shallow'` - recalls only top-level historical state value
|
|
121
|
-
* - `'deep'` - recalls historical state value at all levels
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* The action(s) to be executed upon entering the state node.
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The action(s) to be executed upon exiting the state node.
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* The parent state node.
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* The root machine node.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* The meta data associated with this state node, which will be returned in State instances.
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* The order this state node appears. Corresponds to the implicit document order.
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
91
|
constructor(
|
|
153
92
|
/**
|
|
154
93
|
* The raw config used to create the machine.
|
|
155
94
|
*/
|
|
156
95
|
config, options) {
|
|
157
96
|
this.config = config;
|
|
97
|
+
/**
|
|
98
|
+
* The relative key of the state node, which represents its location in the overall state value.
|
|
99
|
+
*/
|
|
158
100
|
this.key = void 0;
|
|
101
|
+
/**
|
|
102
|
+
* The unique ID of the state node.
|
|
103
|
+
*/
|
|
159
104
|
this.id = void 0;
|
|
105
|
+
/**
|
|
106
|
+
* The type of this state node:
|
|
107
|
+
*
|
|
108
|
+
* - `'atomic'` - no child state nodes
|
|
109
|
+
* - `'compound'` - nested child state nodes (XOR)
|
|
110
|
+
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
111
|
+
* - `'history'` - history state node
|
|
112
|
+
* - `'final'` - final state node
|
|
113
|
+
*/
|
|
160
114
|
this.type = void 0;
|
|
115
|
+
/**
|
|
116
|
+
* The string path from the root machine node to this node.
|
|
117
|
+
*/
|
|
161
118
|
this.path = void 0;
|
|
119
|
+
/**
|
|
120
|
+
* The child state nodes.
|
|
121
|
+
*/
|
|
162
122
|
this.states = void 0;
|
|
123
|
+
/**
|
|
124
|
+
* The type of history on this state node. Can be:
|
|
125
|
+
*
|
|
126
|
+
* - `'shallow'` - recalls only top-level historical state value
|
|
127
|
+
* - `'deep'` - recalls historical state value at all levels
|
|
128
|
+
*/
|
|
163
129
|
this.history = void 0;
|
|
130
|
+
/**
|
|
131
|
+
* The action(s) to be executed upon entering the state node.
|
|
132
|
+
*/
|
|
164
133
|
this.entry = void 0;
|
|
134
|
+
/**
|
|
135
|
+
* The action(s) to be executed upon exiting the state node.
|
|
136
|
+
*/
|
|
165
137
|
this.exit = void 0;
|
|
138
|
+
/**
|
|
139
|
+
* The parent state node.
|
|
140
|
+
*/
|
|
166
141
|
this.parent = void 0;
|
|
142
|
+
/**
|
|
143
|
+
* The root machine node.
|
|
144
|
+
*/
|
|
167
145
|
this.machine = void 0;
|
|
146
|
+
/**
|
|
147
|
+
* The meta data associated with this state node, which will be returned in State instances.
|
|
148
|
+
*/
|
|
168
149
|
this.meta = void 0;
|
|
150
|
+
/**
|
|
151
|
+
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
152
|
+
*/
|
|
169
153
|
this.output = void 0;
|
|
154
|
+
/**
|
|
155
|
+
* The order this state node appears. Corresponds to the implicit document order.
|
|
156
|
+
*/
|
|
170
157
|
this.order = -1;
|
|
171
158
|
this.description = void 0;
|
|
172
159
|
this.tags = [];
|
|
@@ -372,16 +359,15 @@ class StateNode {
|
|
|
372
359
|
|
|
373
360
|
const STATE_IDENTIFIER = '#';
|
|
374
361
|
class StateMachine {
|
|
375
|
-
/**
|
|
376
|
-
* The machine's own version.
|
|
377
|
-
*/
|
|
378
|
-
|
|
379
362
|
constructor(
|
|
380
363
|
/**
|
|
381
364
|
* The raw config used to create the machine.
|
|
382
365
|
*/
|
|
383
366
|
config, implementations) {
|
|
384
367
|
this.config = config;
|
|
368
|
+
/**
|
|
369
|
+
* The machine's own version.
|
|
370
|
+
*/
|
|
385
371
|
this.version = void 0;
|
|
386
372
|
this.implementations = void 0;
|
|
387
373
|
this.types = void 0;
|
|
@@ -391,15 +377,7 @@ class StateMachine {
|
|
|
391
377
|
this.id = void 0;
|
|
392
378
|
this.states = void 0;
|
|
393
379
|
this.events = void 0;
|
|
394
|
-
|
|
395
|
-
this.__TEvent = void 0;
|
|
396
|
-
this.__TActor = void 0;
|
|
397
|
-
this.__TAction = void 0;
|
|
398
|
-
this.__TGuard = void 0;
|
|
399
|
-
this.__TDelay = void 0;
|
|
400
|
-
this.__TTag = void 0;
|
|
401
|
-
this.__TInput = void 0;
|
|
402
|
-
this.__TOutput = void 0;
|
|
380
|
+
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
403
381
|
this.__TResolvedTypesMeta = void 0;
|
|
404
382
|
this.id = config.id || '(machine)';
|
|
405
383
|
this.implementations = {
|
|
@@ -484,7 +462,7 @@ class StateMachine {
|
|
|
484
462
|
*/
|
|
485
463
|
transition(state, event, actorScope) {
|
|
486
464
|
// TODO: handle error events in a better way
|
|
487
|
-
if (isErrorActorEvent(event) && !state
|
|
465
|
+
if (isErrorActorEvent(event) && !getAllOwnEventDescriptors(state).some(nextEvent => nextEvent === event.type)) {
|
|
488
466
|
return cloneMachineSnapshot(state, {
|
|
489
467
|
status: 'error',
|
|
490
468
|
error: event.data
|
|
@@ -594,12 +572,11 @@ class StateMachine {
|
|
|
594
572
|
if (!logic) {
|
|
595
573
|
return;
|
|
596
574
|
}
|
|
597
|
-
const actorState = logic.restoreState?.(childState, _actorScope);
|
|
598
575
|
const actorRef = createActor(logic, {
|
|
599
576
|
id: actorId,
|
|
600
577
|
parent: _actorScope?.self,
|
|
601
578
|
syncSnapshot: actorData.syncSnapshot,
|
|
602
|
-
state:
|
|
579
|
+
state: childState,
|
|
603
580
|
src,
|
|
604
581
|
systemId: actorData.systemId
|
|
605
582
|
});
|
|
@@ -630,8 +607,6 @@ class StateMachine {
|
|
|
630
607
|
reviveContext(restoredSnapshot.context, children);
|
|
631
608
|
return restoredSnapshot;
|
|
632
609
|
}
|
|
633
|
-
|
|
634
|
-
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
635
610
|
}
|
|
636
611
|
|
|
637
612
|
const defaultWaitForOptions = {
|
|
@@ -712,6 +687,8 @@ function createMachine(config, implementations) {
|
|
|
712
687
|
return new StateMachine(config, implementations);
|
|
713
688
|
}
|
|
714
689
|
|
|
690
|
+
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
691
|
+
// this could be reconsidered in the future
|
|
715
692
|
function setup({
|
|
716
693
|
actors,
|
|
717
694
|
actions,
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as isErrorActorEvent, o as
|
|
3
|
-
export {
|
|
4
|
-
import { a as assign } from './send-
|
|
5
|
-
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as isErrorActorEvent, o as getAllOwnEventDescriptors, p as cloneMachineSnapshot, q as macrostep, s as transitionNode, u as resolveActionsAndContext, v as createInitEvent, w as microstep, x as getInitialStateNodes, y as isStateId, z as getStateNodeByPath, A as getPersistedState, B as resolveReferencedActor, C as createActor, $ as $$ACTOR_TYPE } from './raise-1682abb7.esm.js';
|
|
3
|
+
export { D as Actor, o as __unsafe_getAllOwnEventDescriptors, J as and, O as cancel, C as createActor, j as getStateNodes, E as interpret, F as isMachineSnapshot, G as matchesState, K as not, L as or, H as pathToStateValue, P as raise, R as spawn, M as stateIn, Q as stop, I as toObserver } from './raise-1682abb7.esm.js';
|
|
4
|
+
import { a as assign } from './send-a237e4e8.esm.js';
|
|
5
|
+
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-a237e4e8.esm.js';
|
|
6
6
|
import '../dev/dist/xstate-dev.esm.js';
|
|
7
7
|
|
|
8
8
|
class SimulatedClock {
|
|
@@ -88,85 +88,72 @@ const toSerializableAction = action => {
|
|
|
88
88
|
return action;
|
|
89
89
|
};
|
|
90
90
|
class StateNode {
|
|
91
|
-
/**
|
|
92
|
-
* The relative key of the state node, which represents its location in the overall state value.
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The unique ID of the state node.
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The type of this state node:
|
|
101
|
-
*
|
|
102
|
-
* - `'atomic'` - no child state nodes
|
|
103
|
-
* - `'compound'` - nested child state nodes (XOR)
|
|
104
|
-
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
105
|
-
* - `'history'` - history state node
|
|
106
|
-
* - `'final'` - final state node
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The string path from the root machine node to this node.
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The child state nodes.
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* The type of history on this state node. Can be:
|
|
119
|
-
*
|
|
120
|
-
* - `'shallow'` - recalls only top-level historical state value
|
|
121
|
-
* - `'deep'` - recalls historical state value at all levels
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* The action(s) to be executed upon entering the state node.
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The action(s) to be executed upon exiting the state node.
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* The parent state node.
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* The root machine node.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* The meta data associated with this state node, which will be returned in State instances.
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* The order this state node appears. Corresponds to the implicit document order.
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
91
|
constructor(
|
|
153
92
|
/**
|
|
154
93
|
* The raw config used to create the machine.
|
|
155
94
|
*/
|
|
156
95
|
config, options) {
|
|
157
96
|
this.config = config;
|
|
97
|
+
/**
|
|
98
|
+
* The relative key of the state node, which represents its location in the overall state value.
|
|
99
|
+
*/
|
|
158
100
|
this.key = void 0;
|
|
101
|
+
/**
|
|
102
|
+
* The unique ID of the state node.
|
|
103
|
+
*/
|
|
159
104
|
this.id = void 0;
|
|
105
|
+
/**
|
|
106
|
+
* The type of this state node:
|
|
107
|
+
*
|
|
108
|
+
* - `'atomic'` - no child state nodes
|
|
109
|
+
* - `'compound'` - nested child state nodes (XOR)
|
|
110
|
+
* - `'parallel'` - orthogonal nested child state nodes (AND)
|
|
111
|
+
* - `'history'` - history state node
|
|
112
|
+
* - `'final'` - final state node
|
|
113
|
+
*/
|
|
160
114
|
this.type = void 0;
|
|
115
|
+
/**
|
|
116
|
+
* The string path from the root machine node to this node.
|
|
117
|
+
*/
|
|
161
118
|
this.path = void 0;
|
|
119
|
+
/**
|
|
120
|
+
* The child state nodes.
|
|
121
|
+
*/
|
|
162
122
|
this.states = void 0;
|
|
123
|
+
/**
|
|
124
|
+
* The type of history on this state node. Can be:
|
|
125
|
+
*
|
|
126
|
+
* - `'shallow'` - recalls only top-level historical state value
|
|
127
|
+
* - `'deep'` - recalls historical state value at all levels
|
|
128
|
+
*/
|
|
163
129
|
this.history = void 0;
|
|
130
|
+
/**
|
|
131
|
+
* The action(s) to be executed upon entering the state node.
|
|
132
|
+
*/
|
|
164
133
|
this.entry = void 0;
|
|
134
|
+
/**
|
|
135
|
+
* The action(s) to be executed upon exiting the state node.
|
|
136
|
+
*/
|
|
165
137
|
this.exit = void 0;
|
|
138
|
+
/**
|
|
139
|
+
* The parent state node.
|
|
140
|
+
*/
|
|
166
141
|
this.parent = void 0;
|
|
142
|
+
/**
|
|
143
|
+
* The root machine node.
|
|
144
|
+
*/
|
|
167
145
|
this.machine = void 0;
|
|
146
|
+
/**
|
|
147
|
+
* The meta data associated with this state node, which will be returned in State instances.
|
|
148
|
+
*/
|
|
168
149
|
this.meta = void 0;
|
|
150
|
+
/**
|
|
151
|
+
* The output data sent with the "xstate.done.state._id_" event if this is a final state node.
|
|
152
|
+
*/
|
|
169
153
|
this.output = void 0;
|
|
154
|
+
/**
|
|
155
|
+
* The order this state node appears. Corresponds to the implicit document order.
|
|
156
|
+
*/
|
|
170
157
|
this.order = -1;
|
|
171
158
|
this.description = void 0;
|
|
172
159
|
this.tags = [];
|
|
@@ -372,16 +359,15 @@ class StateNode {
|
|
|
372
359
|
|
|
373
360
|
const STATE_IDENTIFIER = '#';
|
|
374
361
|
class StateMachine {
|
|
375
|
-
/**
|
|
376
|
-
* The machine's own version.
|
|
377
|
-
*/
|
|
378
|
-
|
|
379
362
|
constructor(
|
|
380
363
|
/**
|
|
381
364
|
* The raw config used to create the machine.
|
|
382
365
|
*/
|
|
383
366
|
config, implementations) {
|
|
384
367
|
this.config = config;
|
|
368
|
+
/**
|
|
369
|
+
* The machine's own version.
|
|
370
|
+
*/
|
|
385
371
|
this.version = void 0;
|
|
386
372
|
this.implementations = void 0;
|
|
387
373
|
this.types = void 0;
|
|
@@ -391,15 +377,7 @@ class StateMachine {
|
|
|
391
377
|
this.id = void 0;
|
|
392
378
|
this.states = void 0;
|
|
393
379
|
this.events = void 0;
|
|
394
|
-
|
|
395
|
-
this.__TEvent = void 0;
|
|
396
|
-
this.__TActor = void 0;
|
|
397
|
-
this.__TAction = void 0;
|
|
398
|
-
this.__TGuard = void 0;
|
|
399
|
-
this.__TDelay = void 0;
|
|
400
|
-
this.__TTag = void 0;
|
|
401
|
-
this.__TInput = void 0;
|
|
402
|
-
this.__TOutput = void 0;
|
|
380
|
+
/** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
403
381
|
this.__TResolvedTypesMeta = void 0;
|
|
404
382
|
this.id = config.id || '(machine)';
|
|
405
383
|
this.implementations = {
|
|
@@ -481,7 +459,7 @@ class StateMachine {
|
|
|
481
459
|
*/
|
|
482
460
|
transition(state, event, actorScope) {
|
|
483
461
|
// TODO: handle error events in a better way
|
|
484
|
-
if (isErrorActorEvent(event) && !state
|
|
462
|
+
if (isErrorActorEvent(event) && !getAllOwnEventDescriptors(state).some(nextEvent => nextEvent === event.type)) {
|
|
485
463
|
return cloneMachineSnapshot(state, {
|
|
486
464
|
status: 'error',
|
|
487
465
|
error: event.data
|
|
@@ -591,12 +569,11 @@ class StateMachine {
|
|
|
591
569
|
if (!logic) {
|
|
592
570
|
return;
|
|
593
571
|
}
|
|
594
|
-
const actorState = logic.restoreState?.(childState, _actorScope);
|
|
595
572
|
const actorRef = createActor(logic, {
|
|
596
573
|
id: actorId,
|
|
597
574
|
parent: _actorScope?.self,
|
|
598
575
|
syncSnapshot: actorData.syncSnapshot,
|
|
599
|
-
state:
|
|
576
|
+
state: childState,
|
|
600
577
|
src,
|
|
601
578
|
systemId: actorData.systemId
|
|
602
579
|
});
|
|
@@ -627,8 +604,6 @@ class StateMachine {
|
|
|
627
604
|
reviveContext(restoredSnapshot.context, children);
|
|
628
605
|
return restoredSnapshot;
|
|
629
606
|
}
|
|
630
|
-
|
|
631
|
-
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
632
607
|
}
|
|
633
608
|
|
|
634
609
|
const defaultWaitForOptions = {
|
|
@@ -706,6 +681,8 @@ function createMachine(config, implementations) {
|
|
|
706
681
|
return new StateMachine(config, implementations);
|
|
707
682
|
}
|
|
708
683
|
|
|
684
|
+
// at the moment we allow extra actors - ones that are not specified by `children`
|
|
685
|
+
// this could be reconsidered in the future
|
|
709
686
|
function setup({
|
|
710
687
|
actors,
|
|
711
688
|
actions,
|