xstate 5.0.0-beta.51 → 5.0.0-beta.53
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 +9 -11
- package/actions/dist/xstate-actions.cjs.mjs +0 -2
- package/actions/dist/xstate-actions.development.cjs.js +9 -11
- package/actions/dist/xstate-actions.development.cjs.mjs +0 -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 +17 -17
- package/actors/dist/xstate-actors.development.cjs.js +17 -17
- package/actors/dist/xstate-actors.development.esm.js +17 -17
- package/actors/dist/xstate-actors.esm.js +17 -17
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +2 -2
- package/dist/declarations/src/StateMachine.d.ts +6 -6
- package/dist/declarations/src/StateNode.d.ts +4 -4
- package/dist/declarations/src/actions.d.ts +0 -2
- package/dist/declarations/src/actors/index.d.ts +1 -1
- package/dist/declarations/src/actors/transition.d.ts +1 -1
- package/dist/declarations/src/guards.d.ts +1 -1
- package/dist/declarations/src/interpreter.d.ts +7 -7
- package/dist/declarations/src/stateUtils.d.ts +9 -9
- package/dist/declarations/src/types.d.ts +23 -19
- package/dist/{pure-296f8ebd.development.esm.js → log-1fd7d00a.development.esm.js} +24 -61
- package/dist/{pure-aefddc19.esm.js → log-60ab9eaf.esm.js} +24 -58
- package/dist/{pure-c5f1b46c.cjs.js → log-717bb5a1.cjs.js} +23 -59
- package/dist/{pure-a0f16134.development.cjs.js → log-c8797128.development.cjs.js} +23 -62
- package/dist/{raise-acaa3884.development.esm.js → raise-953b1eb5.development.esm.js} +136 -136
- package/dist/{raise-d5633a02.cjs.js → raise-a8367773.cjs.js} +136 -136
- package/dist/{raise-4742bf04.esm.js → raise-be2f20bc.esm.js} +136 -136
- package/dist/{raise-528386de.development.cjs.js → raise-d9fd8932.development.cjs.js} +136 -136
- package/dist/xstate.cjs.js +28 -30
- package/dist/xstate.cjs.mjs +0 -2
- package/dist/xstate.development.cjs.js +28 -30
- package/dist/xstate.development.cjs.mjs +0 -2
- package/dist/xstate.development.esm.js +21 -21
- package/dist/xstate.esm.js +21 -21
- 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
- package/dist/declarations/src/actions/choose.d.ts +0 -9
- package/dist/declarations/src/actions/pure.d.ts +0 -10
|
@@ -66,9 +66,8 @@ const XSTATE_STOP = 'xstate.stop';
|
|
|
66
66
|
* @param id The state node ID where this event is handled
|
|
67
67
|
*/
|
|
68
68
|
function createAfterEvent(delayRef, id) {
|
|
69
|
-
const idSuffix = id ? `#${id}` : '';
|
|
70
69
|
return {
|
|
71
|
-
type: `xstate.after
|
|
70
|
+
type: `xstate.after.${delayRef}.${id}`
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -303,16 +302,17 @@ function toObserver(nextHandler, errorHandler, completionHandler) {
|
|
|
303
302
|
};
|
|
304
303
|
}
|
|
305
304
|
function createInvokeId(stateNodeId, index) {
|
|
306
|
-
return `${
|
|
305
|
+
return `${index}.${stateNodeId}`;
|
|
307
306
|
}
|
|
308
307
|
function resolveReferencedActor(machine, src) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const invokeConfig = node.config.invoke;
|
|
313
|
-
return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
|
|
308
|
+
const match = src.match(/^xstate\.invoke\.(\d+)\.(.*)/);
|
|
309
|
+
if (!match) {
|
|
310
|
+
return machine.implementations.actors[src];
|
|
314
311
|
}
|
|
315
|
-
|
|
312
|
+
const [, indexStr, nodeId] = match;
|
|
313
|
+
const node = machine.getStateNodeById(nodeId);
|
|
314
|
+
const invokeConfig = node.config.invoke;
|
|
315
|
+
return (Array.isArray(invokeConfig) ? invokeConfig[indexStr] : invokeConfig).src;
|
|
316
316
|
}
|
|
317
317
|
function getAllOwnEventDescriptors(snapshot) {
|
|
318
318
|
return [...new Set([...snapshot._nodes.flatMap(sn => sn.ownEvents)])];
|
|
@@ -354,7 +354,7 @@ class Actor {
|
|
|
354
354
|
/**
|
|
355
355
|
* The current internal state of the actor.
|
|
356
356
|
*/
|
|
357
|
-
this.
|
|
357
|
+
this._snapshot = void 0;
|
|
358
358
|
/**
|
|
359
359
|
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
360
360
|
*/
|
|
@@ -444,19 +444,19 @@ class Actor {
|
|
|
444
444
|
this._systemId = systemId;
|
|
445
445
|
this.system._set(systemId, this);
|
|
446
446
|
}
|
|
447
|
-
this._initState(options?.state);
|
|
448
|
-
if (systemId && this.
|
|
447
|
+
this._initState(options?.snapshot ?? options?.state);
|
|
448
|
+
if (systemId && this._snapshot.status !== 'active') {
|
|
449
449
|
this.system._unregister(this);
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
452
|
_initState(persistedState) {
|
|
453
453
|
try {
|
|
454
|
-
this.
|
|
454
|
+
this._snapshot = persistedState ? this.logic.restoreSnapshot ? this.logic.restoreSnapshot(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
|
|
455
455
|
} catch (err) {
|
|
456
|
-
// if we get here then it means that we assign a value to this.
|
|
456
|
+
// if we get here then it means that we assign a value to this._snapshot that is not of the correct type
|
|
457
457
|
// we can't get the true `TSnapshot & { status: 'error'; }`, it's impossible
|
|
458
458
|
// so right now this is a lie of sorts
|
|
459
|
-
this.
|
|
459
|
+
this._snapshot = {
|
|
460
460
|
status: 'error',
|
|
461
461
|
output: undefined,
|
|
462
462
|
error: err
|
|
@@ -465,7 +465,7 @@ class Actor {
|
|
|
465
465
|
}
|
|
466
466
|
update(snapshot, event) {
|
|
467
467
|
// Update state
|
|
468
|
-
this.
|
|
468
|
+
this._snapshot = snapshot;
|
|
469
469
|
|
|
470
470
|
// Execute deferred effects
|
|
471
471
|
let deferredFn;
|
|
@@ -479,14 +479,14 @@ class Actor {
|
|
|
479
479
|
// no "builtin deferred" should actually throw an error since they are either safe
|
|
480
480
|
// or the control flow is passed through the mailbox and errors should be caught by the `_process` used by the mailbox
|
|
481
481
|
this._deferred.length = 0;
|
|
482
|
-
this.
|
|
482
|
+
this._snapshot = {
|
|
483
483
|
...snapshot,
|
|
484
484
|
status: 'error',
|
|
485
485
|
error: err
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
switch (this.
|
|
489
|
+
switch (this._snapshot.status) {
|
|
490
490
|
case 'active':
|
|
491
491
|
for (const observer of this.observers) {
|
|
492
492
|
try {
|
|
@@ -512,13 +512,13 @@ class Actor {
|
|
|
512
512
|
}
|
|
513
513
|
this._stopProcedure();
|
|
514
514
|
this._complete();
|
|
515
|
-
this._doneEvent = createDoneActorEvent(this.id, this.
|
|
515
|
+
this._doneEvent = createDoneActorEvent(this.id, this._snapshot.output);
|
|
516
516
|
if (this._parent) {
|
|
517
517
|
this.system._relay(this, this._parent, this._doneEvent);
|
|
518
518
|
}
|
|
519
519
|
break;
|
|
520
520
|
case 'error':
|
|
521
|
-
this._error(this.
|
|
521
|
+
this._error(this._snapshot.error);
|
|
522
522
|
break;
|
|
523
523
|
}
|
|
524
524
|
this.system._sendInspectionEvent({
|
|
@@ -631,24 +631,24 @@ class Actor {
|
|
|
631
631
|
actorRef: this,
|
|
632
632
|
event: initEvent
|
|
633
633
|
});
|
|
634
|
-
const status = this.
|
|
634
|
+
const status = this._snapshot.status;
|
|
635
635
|
switch (status) {
|
|
636
636
|
case 'done':
|
|
637
637
|
// a state machine can be "done" upon initialization (it could reach a final state using initial microsteps)
|
|
638
638
|
// we still need to complete observers, flush deferreds etc
|
|
639
|
-
this.update(this.
|
|
639
|
+
this.update(this._snapshot, initEvent);
|
|
640
640
|
// TODO: rethink cleanup of observers, mailbox, etc
|
|
641
641
|
return this;
|
|
642
642
|
case 'error':
|
|
643
|
-
this._error(this.
|
|
643
|
+
this._error(this._snapshot.error);
|
|
644
644
|
return this;
|
|
645
645
|
}
|
|
646
646
|
if (this.logic.start) {
|
|
647
647
|
try {
|
|
648
|
-
this.logic.start(this.
|
|
648
|
+
this.logic.start(this._snapshot, this._actorScope);
|
|
649
649
|
} catch (err) {
|
|
650
|
-
this.
|
|
651
|
-
...this.
|
|
650
|
+
this._snapshot = {
|
|
651
|
+
...this._snapshot,
|
|
652
652
|
status: 'error',
|
|
653
653
|
error: err
|
|
654
654
|
};
|
|
@@ -660,7 +660,7 @@ class Actor {
|
|
|
660
660
|
// TODO: this notifies all subscribers but usually this is redundant
|
|
661
661
|
// there is no real change happening here
|
|
662
662
|
// we need to rethink if this needs to be refactored
|
|
663
|
-
this.update(this.
|
|
663
|
+
this.update(this._snapshot, initEvent);
|
|
664
664
|
if (this.options.devTools) {
|
|
665
665
|
this.attachDevTools();
|
|
666
666
|
}
|
|
@@ -671,7 +671,7 @@ class Actor {
|
|
|
671
671
|
let nextState;
|
|
672
672
|
let caughtError;
|
|
673
673
|
try {
|
|
674
|
-
nextState = this.logic.transition(this.
|
|
674
|
+
nextState = this.logic.transition(this._snapshot, event, this._actorScope);
|
|
675
675
|
} catch (err) {
|
|
676
676
|
// we wrap it in a box so we can rethrow it later even if falsy value gets caught here
|
|
677
677
|
caughtError = {
|
|
@@ -682,8 +682,8 @@ class Actor {
|
|
|
682
682
|
const {
|
|
683
683
|
err
|
|
684
684
|
} = caughtError;
|
|
685
|
-
this.
|
|
686
|
-
...this.
|
|
685
|
+
this._snapshot = {
|
|
686
|
+
...this._snapshot,
|
|
687
687
|
status: 'error',
|
|
688
688
|
error: err
|
|
689
689
|
};
|
|
@@ -871,8 +871,8 @@ class Actor {
|
|
|
871
871
|
* @see https://stately.ai/docs/persistence
|
|
872
872
|
*/
|
|
873
873
|
|
|
874
|
-
|
|
875
|
-
return this.logic.
|
|
874
|
+
getPersistedSnapshot(options) {
|
|
875
|
+
return this.logic.getPersistedSnapshot(this._snapshot, options);
|
|
876
876
|
}
|
|
877
877
|
[symbolObservable]() {
|
|
878
878
|
return this;
|
|
@@ -890,10 +890,10 @@ class Actor {
|
|
|
890
890
|
* Note that some actors, such as callback actors generated with `fromCallback`, will not emit snapshots.
|
|
891
891
|
*
|
|
892
892
|
* @see {@link Actor.subscribe} to subscribe to an actor’s snapshot values.
|
|
893
|
-
* @see {@link Actor.
|
|
893
|
+
* @see {@link Actor.getPersistedSnapshot} to persist the internal state of an actor (which is more than just a snapshot).
|
|
894
894
|
*/
|
|
895
895
|
getSnapshot() {
|
|
896
|
-
return this.
|
|
896
|
+
return this._snapshot;
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
|
|
@@ -946,11 +946,11 @@ const interpret = createActor;
|
|
|
946
946
|
* @deprecated Use `Actor` instead.
|
|
947
947
|
*/
|
|
948
948
|
|
|
949
|
-
function resolveCancel(_,
|
|
949
|
+
function resolveCancel(_, snapshot, actionArgs, actionParams, {
|
|
950
950
|
sendId
|
|
951
951
|
}) {
|
|
952
952
|
const resolvedSendId = typeof sendId === 'function' ? sendId(actionArgs, actionParams) : sendId;
|
|
953
|
-
return [
|
|
953
|
+
return [snapshot, resolvedSendId];
|
|
954
954
|
}
|
|
955
955
|
function executeCancel(actorScope, resolvedSendId) {
|
|
956
956
|
actorScope.self.cancel(resolvedSendId);
|
|
@@ -975,14 +975,14 @@ function cancel(sendId) {
|
|
|
975
975
|
return cancel;
|
|
976
976
|
}
|
|
977
977
|
|
|
978
|
-
function resolveSpawn(actorScope,
|
|
978
|
+
function resolveSpawn(actorScope, snapshot, actionArgs, _actionParams, {
|
|
979
979
|
id,
|
|
980
980
|
systemId,
|
|
981
981
|
src,
|
|
982
982
|
input,
|
|
983
983
|
syncSnapshot
|
|
984
984
|
}) {
|
|
985
|
-
const logic = typeof src === 'string' ? resolveReferencedActor(
|
|
985
|
+
const logic = typeof src === 'string' ? resolveReferencedActor(snapshot.machine, src) : src;
|
|
986
986
|
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
987
987
|
let actorRef;
|
|
988
988
|
if (logic) {
|
|
@@ -993,7 +993,7 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
|
|
|
993
993
|
syncSnapshot,
|
|
994
994
|
systemId,
|
|
995
995
|
input: typeof input === 'function' ? input({
|
|
996
|
-
context:
|
|
996
|
+
context: snapshot.context,
|
|
997
997
|
event: actionArgs.event,
|
|
998
998
|
self: actorScope?.self
|
|
999
999
|
}) : input
|
|
@@ -1002,9 +1002,9 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
|
|
|
1002
1002
|
if (!actorRef) {
|
|
1003
1003
|
console.warn(`Actor type '${src}' not found in machine '${actorScope.id}'.`);
|
|
1004
1004
|
}
|
|
1005
|
-
return [cloneMachineSnapshot(
|
|
1005
|
+
return [cloneMachineSnapshot(snapshot, {
|
|
1006
1006
|
children: {
|
|
1007
|
-
...
|
|
1007
|
+
...snapshot.children,
|
|
1008
1008
|
[resolvedId]: actorRef
|
|
1009
1009
|
}
|
|
1010
1010
|
}), {
|
|
@@ -1037,7 +1037,7 @@ function spawnChild(...[src, {
|
|
|
1037
1037
|
throw new Error(`This isn't supposed to be called`);
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
|
-
spawnChild.type = '
|
|
1040
|
+
spawnChild.type = 'snapshot.spawnChild';
|
|
1041
1041
|
spawnChild.id = id;
|
|
1042
1042
|
spawnChild.systemId = systemId;
|
|
1043
1043
|
spawnChild.src = src;
|
|
@@ -1048,19 +1048,19 @@ function spawnChild(...[src, {
|
|
|
1048
1048
|
return spawnChild;
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
|
-
function resolveStop(_,
|
|
1051
|
+
function resolveStop(_, snapshot, args, actionParams, {
|
|
1052
1052
|
actorRef
|
|
1053
1053
|
}) {
|
|
1054
1054
|
const actorRefOrString = typeof actorRef === 'function' ? actorRef(args, actionParams) : actorRef;
|
|
1055
|
-
const resolvedActorRef = typeof actorRefOrString === 'string' ?
|
|
1056
|
-
let children =
|
|
1055
|
+
const resolvedActorRef = typeof actorRefOrString === 'string' ? snapshot.children[actorRefOrString] : actorRefOrString;
|
|
1056
|
+
let children = snapshot.children;
|
|
1057
1057
|
if (resolvedActorRef) {
|
|
1058
1058
|
children = {
|
|
1059
1059
|
...children
|
|
1060
1060
|
};
|
|
1061
1061
|
delete children[resolvedActorRef.id];
|
|
1062
1062
|
}
|
|
1063
|
-
return [cloneMachineSnapshot(
|
|
1063
|
+
return [cloneMachineSnapshot(snapshot, {
|
|
1064
1064
|
children
|
|
1065
1065
|
}), resolvedActorRef];
|
|
1066
1066
|
}
|
|
@@ -1113,14 +1113,14 @@ function stopChild(actorRef) {
|
|
|
1113
1113
|
*/
|
|
1114
1114
|
const stop = stopChild;
|
|
1115
1115
|
|
|
1116
|
-
function checkStateIn(
|
|
1116
|
+
function checkStateIn(snapshot, _, {
|
|
1117
1117
|
stateValue
|
|
1118
1118
|
}) {
|
|
1119
1119
|
if (typeof stateValue === 'string' && isStateId(stateValue)) {
|
|
1120
|
-
const target =
|
|
1121
|
-
return
|
|
1120
|
+
const target = snapshot.machine.getStateNodeById(stateValue);
|
|
1121
|
+
return snapshot._nodes.some(sn => sn === target);
|
|
1122
1122
|
}
|
|
1123
|
-
return
|
|
1123
|
+
return snapshot.matches(stateValue);
|
|
1124
1124
|
}
|
|
1125
1125
|
function stateIn(stateValue) {
|
|
1126
1126
|
function stateIn(args, params) {
|
|
@@ -1132,13 +1132,13 @@ function stateIn(stateValue) {
|
|
|
1132
1132
|
stateIn.stateValue = stateValue;
|
|
1133
1133
|
return stateIn;
|
|
1134
1134
|
}
|
|
1135
|
-
function checkNot(
|
|
1135
|
+
function checkNot(snapshot, {
|
|
1136
1136
|
context,
|
|
1137
1137
|
event
|
|
1138
1138
|
}, {
|
|
1139
1139
|
guards
|
|
1140
1140
|
}) {
|
|
1141
|
-
return !evaluateGuard(guards[0], context, event,
|
|
1141
|
+
return !evaluateGuard(guards[0], context, event, snapshot);
|
|
1142
1142
|
}
|
|
1143
1143
|
function not(guard) {
|
|
1144
1144
|
function not(args, params) {
|
|
@@ -1150,13 +1150,13 @@ function not(guard) {
|
|
|
1150
1150
|
not.guards = [guard];
|
|
1151
1151
|
return not;
|
|
1152
1152
|
}
|
|
1153
|
-
function checkAnd(
|
|
1153
|
+
function checkAnd(snapshot, {
|
|
1154
1154
|
context,
|
|
1155
1155
|
event
|
|
1156
1156
|
}, {
|
|
1157
1157
|
guards
|
|
1158
1158
|
}) {
|
|
1159
|
-
return guards.every(guard => evaluateGuard(guard, context, event,
|
|
1159
|
+
return guards.every(guard => evaluateGuard(guard, context, event, snapshot));
|
|
1160
1160
|
}
|
|
1161
1161
|
function and(guards) {
|
|
1162
1162
|
function and(args, params) {
|
|
@@ -1168,13 +1168,13 @@ function and(guards) {
|
|
|
1168
1168
|
and.guards = guards;
|
|
1169
1169
|
return and;
|
|
1170
1170
|
}
|
|
1171
|
-
function checkOr(
|
|
1171
|
+
function checkOr(snapshot, {
|
|
1172
1172
|
context,
|
|
1173
1173
|
event
|
|
1174
1174
|
}, {
|
|
1175
1175
|
guards
|
|
1176
1176
|
}) {
|
|
1177
|
-
return guards.some(guard => evaluateGuard(guard, context, event,
|
|
1177
|
+
return guards.some(guard => evaluateGuard(guard, context, event, snapshot));
|
|
1178
1178
|
}
|
|
1179
1179
|
function or(guards) {
|
|
1180
1180
|
function or(args, params) {
|
|
@@ -1188,17 +1188,17 @@ function or(guards) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
|
|
1190
1190
|
// TODO: throw on cycles (depth check should be enough)
|
|
1191
|
-
function evaluateGuard(guard, context, event,
|
|
1191
|
+
function evaluateGuard(guard, context, event, snapshot) {
|
|
1192
1192
|
const {
|
|
1193
1193
|
machine
|
|
1194
|
-
} =
|
|
1194
|
+
} = snapshot;
|
|
1195
1195
|
const isInline = typeof guard === 'function';
|
|
1196
1196
|
const resolved = isInline ? guard : machine.implementations.guards[typeof guard === 'string' ? guard : guard.type];
|
|
1197
1197
|
if (!isInline && !resolved) {
|
|
1198
1198
|
throw new Error(`Guard '${typeof guard === 'string' ? guard : guard.type}' is not implemented.'.`);
|
|
1199
1199
|
}
|
|
1200
1200
|
if (typeof resolved !== 'function') {
|
|
1201
|
-
return evaluateGuard(resolved, context, event,
|
|
1201
|
+
return evaluateGuard(resolved, context, event, snapshot);
|
|
1202
1202
|
}
|
|
1203
1203
|
const guardArgs = {
|
|
1204
1204
|
context,
|
|
@@ -1215,7 +1215,7 @@ function evaluateGuard(guard, context, event, state) {
|
|
|
1215
1215
|
return resolved(guardArgs, guardParams);
|
|
1216
1216
|
}
|
|
1217
1217
|
const builtinGuard = resolved;
|
|
1218
|
-
return builtinGuard.check(
|
|
1218
|
+
return builtinGuard.check(snapshot, guardArgs, resolved // this holds all params
|
|
1219
1219
|
);
|
|
1220
1220
|
}
|
|
1221
1221
|
|
|
@@ -1615,24 +1615,24 @@ function getStateNodes(stateNode, stateValue) {
|
|
|
1615
1615
|
return allSubStateNodes.concat(subStateNodes);
|
|
1616
1616
|
}, []));
|
|
1617
1617
|
}
|
|
1618
|
-
function transitionAtomicNode(stateNode, stateValue,
|
|
1618
|
+
function transitionAtomicNode(stateNode, stateValue, snapshot, event) {
|
|
1619
1619
|
const childStateNode = getStateNode(stateNode, stateValue);
|
|
1620
|
-
const next = childStateNode.next(
|
|
1620
|
+
const next = childStateNode.next(snapshot, event);
|
|
1621
1621
|
if (!next || !next.length) {
|
|
1622
|
-
return stateNode.next(
|
|
1622
|
+
return stateNode.next(snapshot, event);
|
|
1623
1623
|
}
|
|
1624
1624
|
return next;
|
|
1625
1625
|
}
|
|
1626
|
-
function transitionCompoundNode(stateNode, stateValue,
|
|
1626
|
+
function transitionCompoundNode(stateNode, stateValue, snapshot, event) {
|
|
1627
1627
|
const subStateKeys = Object.keys(stateValue);
|
|
1628
1628
|
const childStateNode = getStateNode(stateNode, subStateKeys[0]);
|
|
1629
|
-
const next = transitionNode(childStateNode, stateValue[subStateKeys[0]],
|
|
1629
|
+
const next = transitionNode(childStateNode, stateValue[subStateKeys[0]], snapshot, event);
|
|
1630
1630
|
if (!next || !next.length) {
|
|
1631
|
-
return stateNode.next(
|
|
1631
|
+
return stateNode.next(snapshot, event);
|
|
1632
1632
|
}
|
|
1633
1633
|
return next;
|
|
1634
1634
|
}
|
|
1635
|
-
function transitionParallelNode(stateNode, stateValue,
|
|
1635
|
+
function transitionParallelNode(stateNode, stateValue, snapshot, event) {
|
|
1636
1636
|
const allInnerTransitions = [];
|
|
1637
1637
|
for (const subStateKey of Object.keys(stateValue)) {
|
|
1638
1638
|
const subStateValue = stateValue[subStateKey];
|
|
@@ -1640,29 +1640,29 @@ function transitionParallelNode(stateNode, stateValue, state, event) {
|
|
|
1640
1640
|
continue;
|
|
1641
1641
|
}
|
|
1642
1642
|
const subStateNode = getStateNode(stateNode, subStateKey);
|
|
1643
|
-
const innerTransitions = transitionNode(subStateNode, subStateValue,
|
|
1643
|
+
const innerTransitions = transitionNode(subStateNode, subStateValue, snapshot, event);
|
|
1644
1644
|
if (innerTransitions) {
|
|
1645
1645
|
allInnerTransitions.push(...innerTransitions);
|
|
1646
1646
|
}
|
|
1647
1647
|
}
|
|
1648
1648
|
if (!allInnerTransitions.length) {
|
|
1649
|
-
return stateNode.next(
|
|
1649
|
+
return stateNode.next(snapshot, event);
|
|
1650
1650
|
}
|
|
1651
1651
|
return allInnerTransitions;
|
|
1652
1652
|
}
|
|
1653
|
-
function transitionNode(stateNode, stateValue,
|
|
1653
|
+
function transitionNode(stateNode, stateValue, snapshot, event) {
|
|
1654
1654
|
// leaf node
|
|
1655
1655
|
if (typeof stateValue === 'string') {
|
|
1656
|
-
return transitionAtomicNode(stateNode, stateValue,
|
|
1656
|
+
return transitionAtomicNode(stateNode, stateValue, snapshot, event);
|
|
1657
1657
|
}
|
|
1658
1658
|
|
|
1659
1659
|
// compound node
|
|
1660
1660
|
if (Object.keys(stateValue).length === 1) {
|
|
1661
|
-
return transitionCompoundNode(stateNode, stateValue,
|
|
1661
|
+
return transitionCompoundNode(stateNode, stateValue, snapshot, event);
|
|
1662
1662
|
}
|
|
1663
1663
|
|
|
1664
1664
|
// parallel node
|
|
1665
|
-
return transitionParallelNode(stateNode, stateValue,
|
|
1665
|
+
return transitionParallelNode(stateNode, stateValue, snapshot, event);
|
|
1666
1666
|
}
|
|
1667
1667
|
function getHistoryNodes(stateNode) {
|
|
1668
1668
|
return Object.keys(stateNode.states).map(key => stateNode.states[key]).filter(sn => sn.type === 'history');
|
|
@@ -1794,14 +1794,14 @@ function areStateNodeCollectionsEqual(prevStateNodes, nextStateNodeSet) {
|
|
|
1794
1794
|
/**
|
|
1795
1795
|
* https://www.w3.org/TR/scxml/#microstepProcedure
|
|
1796
1796
|
*/
|
|
1797
|
-
function microstep(transitions,
|
|
1797
|
+
function microstep(transitions, currentSnapshot, actorScope, event, isInitial, internalQueue) {
|
|
1798
1798
|
if (!transitions.length) {
|
|
1799
|
-
return
|
|
1799
|
+
return currentSnapshot;
|
|
1800
1800
|
}
|
|
1801
|
-
const mutStateNodeSet = new Set(
|
|
1802
|
-
let historyValue =
|
|
1801
|
+
const mutStateNodeSet = new Set(currentSnapshot._nodes);
|
|
1802
|
+
let historyValue = currentSnapshot.historyValue;
|
|
1803
1803
|
const filteredTransitions = removeConflictingTransitions(transitions, mutStateNodeSet, historyValue);
|
|
1804
|
-
let nextState =
|
|
1804
|
+
let nextState = currentSnapshot;
|
|
1805
1805
|
|
|
1806
1806
|
// Exit states
|
|
1807
1807
|
if (!isInitial) {
|
|
@@ -1818,7 +1818,7 @@ function microstep(transitions, currentState, actorScope, event, isInitial, inte
|
|
|
1818
1818
|
nextState = resolveActionsAndContext(nextState, event, actorScope, nextStateNodes.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue);
|
|
1819
1819
|
}
|
|
1820
1820
|
try {
|
|
1821
|
-
if (historyValue ===
|
|
1821
|
+
if (historyValue === currentSnapshot.historyValue && areStateNodeCollectionsEqual(currentSnapshot._nodes, mutStateNodeSet)) {
|
|
1822
1822
|
return nextState;
|
|
1823
1823
|
}
|
|
1824
1824
|
return cloneMachineSnapshot(nextState, {
|
|
@@ -1831,15 +1831,15 @@ function microstep(transitions, currentState, actorScope, event, isInitial, inte
|
|
|
1831
1831
|
throw e;
|
|
1832
1832
|
}
|
|
1833
1833
|
}
|
|
1834
|
-
function getMachineOutput(
|
|
1834
|
+
function getMachineOutput(snapshot, event, actorScope, rootNode, rootCompletionNode) {
|
|
1835
1835
|
if (!rootNode.output) {
|
|
1836
1836
|
return;
|
|
1837
1837
|
}
|
|
1838
|
-
const doneStateEvent = createDoneStateEvent(rootCompletionNode.id, rootCompletionNode.output && rootCompletionNode.parent ? resolveOutput(rootCompletionNode.output,
|
|
1839
|
-
return resolveOutput(rootNode.output,
|
|
1838
|
+
const doneStateEvent = createDoneStateEvent(rootCompletionNode.id, rootCompletionNode.output && rootCompletionNode.parent ? resolveOutput(rootCompletionNode.output, snapshot.context, event, actorScope.self) : undefined);
|
|
1839
|
+
return resolveOutput(rootNode.output, snapshot.context, doneStateEvent, actorScope.self);
|
|
1840
1840
|
}
|
|
1841
|
-
function enterStates(
|
|
1842
|
-
let
|
|
1841
|
+
function enterStates(currentSnapshot, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial) {
|
|
1842
|
+
let nextSnapshot = currentSnapshot;
|
|
1843
1843
|
const statesToEnter = new Set();
|
|
1844
1844
|
// those are states that were directly targeted or indirectly targeted by the explicit target
|
|
1845
1845
|
// in other words, those are states for which initial actions should be executed
|
|
@@ -1849,7 +1849,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
|
|
|
1849
1849
|
|
|
1850
1850
|
// In the initial state, the root state node is "entered".
|
|
1851
1851
|
if (isInitial) {
|
|
1852
|
-
statesForDefaultEntry.add(
|
|
1852
|
+
statesForDefaultEntry.add(currentSnapshot.machine.root);
|
|
1853
1853
|
}
|
|
1854
1854
|
const completedNodes = new Set();
|
|
1855
1855
|
for (const stateNodeToEnter of [...statesToEnter].sort((a, b) => a.order - b.order)) {
|
|
@@ -1868,13 +1868,13 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
|
|
|
1868
1868
|
const initialActions = stateNodeToEnter.initial.actions;
|
|
1869
1869
|
actions.push(...initialActions);
|
|
1870
1870
|
}
|
|
1871
|
-
|
|
1871
|
+
nextSnapshot = resolveActionsAndContext(nextSnapshot, event, actorScope, actions, internalQueue, stateNodeToEnter.invoke.map(invokeDef => invokeDef.id));
|
|
1872
1872
|
if (stateNodeToEnter.type === 'final') {
|
|
1873
1873
|
const parent = stateNodeToEnter.parent;
|
|
1874
1874
|
let ancestorMarker = parent?.type === 'parallel' ? parent : parent?.parent;
|
|
1875
1875
|
let rootCompletionNode = ancestorMarker || stateNodeToEnter;
|
|
1876
1876
|
if (parent?.type === 'compound') {
|
|
1877
|
-
internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output ? resolveOutput(stateNodeToEnter.output,
|
|
1877
|
+
internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output ? resolveOutput(stateNodeToEnter.output, nextSnapshot.context, event, actorScope.self) : undefined));
|
|
1878
1878
|
}
|
|
1879
1879
|
while (ancestorMarker?.type === 'parallel' && !completedNodes.has(ancestorMarker) && isInFinalState(mutStateNodeSet, ancestorMarker)) {
|
|
1880
1880
|
completedNodes.add(ancestorMarker);
|
|
@@ -1885,13 +1885,13 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
|
|
|
1885
1885
|
if (ancestorMarker) {
|
|
1886
1886
|
continue;
|
|
1887
1887
|
}
|
|
1888
|
-
|
|
1888
|
+
nextSnapshot = cloneMachineSnapshot(nextSnapshot, {
|
|
1889
1889
|
status: 'done',
|
|
1890
|
-
output: getMachineOutput(
|
|
1890
|
+
output: getMachineOutput(nextSnapshot, event, actorScope, nextSnapshot.machine.root, rootCompletionNode)
|
|
1891
1891
|
});
|
|
1892
1892
|
}
|
|
1893
1893
|
}
|
|
1894
|
-
return
|
|
1894
|
+
return nextSnapshot;
|
|
1895
1895
|
}
|
|
1896
1896
|
function computeEntrySet(transitions, historyValue, statesForDefaultEntry, statesToEnter) {
|
|
1897
1897
|
for (const t of transitions) {
|
|
@@ -1986,8 +1986,8 @@ function addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultE
|
|
|
1986
1986
|
function addProperAncestorStatesToEnter(stateNode, toStateNode, statesToEnter, historyValue, statesForDefaultEntry) {
|
|
1987
1987
|
addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultEntry, getProperAncestors(stateNode, toStateNode));
|
|
1988
1988
|
}
|
|
1989
|
-
function exitStates(
|
|
1990
|
-
let
|
|
1989
|
+
function exitStates(currentSnapshot, event, actorScope, transitions, mutStateNodeSet, historyValue, internalQueue) {
|
|
1990
|
+
let nextSnapshot = currentSnapshot;
|
|
1991
1991
|
const statesToExit = computeExitSet(transitions, mutStateNodeSet, historyValue);
|
|
1992
1992
|
statesToExit.sort((a, b) => b.order - a.order);
|
|
1993
1993
|
let changedHistory;
|
|
@@ -2010,16 +2010,16 @@ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSe
|
|
|
2010
2010
|
}
|
|
2011
2011
|
}
|
|
2012
2012
|
for (const s of statesToExit) {
|
|
2013
|
-
|
|
2013
|
+
nextSnapshot = resolveActionsAndContext(nextSnapshot, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
|
|
2014
2014
|
mutStateNodeSet.delete(s);
|
|
2015
2015
|
}
|
|
2016
|
-
return [
|
|
2016
|
+
return [nextSnapshot, changedHistory || historyValue];
|
|
2017
2017
|
}
|
|
2018
|
-
function resolveActionsAndContextWorker(
|
|
2018
|
+
function resolveActionsAndContextWorker(currentSnapshot, event, actorScope, actions, extra, retries) {
|
|
2019
2019
|
const {
|
|
2020
2020
|
machine
|
|
2021
|
-
} =
|
|
2022
|
-
let
|
|
2021
|
+
} = currentSnapshot;
|
|
2022
|
+
let intermediateSnapshot = currentSnapshot;
|
|
2023
2023
|
for (const action of actions) {
|
|
2024
2024
|
const isInline = typeof action === 'function';
|
|
2025
2025
|
const resolvedAction = isInline ? action :
|
|
@@ -2031,13 +2031,13 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
|
|
|
2031
2031
|
continue;
|
|
2032
2032
|
}
|
|
2033
2033
|
const actionArgs = {
|
|
2034
|
-
context:
|
|
2034
|
+
context: intermediateSnapshot.context,
|
|
2035
2035
|
event,
|
|
2036
2036
|
self: actorScope?.self,
|
|
2037
2037
|
system: actorScope?.system
|
|
2038
2038
|
};
|
|
2039
2039
|
const actionParams = isInline || typeof action === 'string' ? undefined : 'params' in action ? typeof action.params === 'function' ? action.params({
|
|
2040
|
-
context:
|
|
2040
|
+
context: intermediateSnapshot.context,
|
|
2041
2041
|
event
|
|
2042
2042
|
}) : action.params : undefined;
|
|
2043
2043
|
if (!('resolve' in resolvedAction)) {
|
|
@@ -2051,10 +2051,10 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
|
|
|
2051
2051
|
continue;
|
|
2052
2052
|
}
|
|
2053
2053
|
const builtinAction = resolvedAction;
|
|
2054
|
-
const [nextState, params, actions] = builtinAction.resolve(actorScope,
|
|
2054
|
+
const [nextState, params, actions] = builtinAction.resolve(actorScope, intermediateSnapshot, actionArgs, actionParams, resolvedAction,
|
|
2055
2055
|
// this holds all params
|
|
2056
2056
|
extra);
|
|
2057
|
-
|
|
2057
|
+
intermediateSnapshot = nextState;
|
|
2058
2058
|
if ('retryResolve' in builtinAction) {
|
|
2059
2059
|
retries?.push([builtinAction, params]);
|
|
2060
2060
|
}
|
|
@@ -2066,14 +2066,14 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
|
|
|
2066
2066
|
}
|
|
2067
2067
|
}
|
|
2068
2068
|
if (actions) {
|
|
2069
|
-
|
|
2069
|
+
intermediateSnapshot = resolveActionsAndContextWorker(intermediateSnapshot, event, actorScope, actions, extra, retries);
|
|
2070
2070
|
}
|
|
2071
2071
|
}
|
|
2072
|
-
return
|
|
2072
|
+
return intermediateSnapshot;
|
|
2073
2073
|
}
|
|
2074
|
-
function resolveActionsAndContext(
|
|
2074
|
+
function resolveActionsAndContext(currentSnapshot, event, actorScope, actions, internalQueue, deferredActorIds) {
|
|
2075
2075
|
const retries = deferredActorIds ? [] : undefined;
|
|
2076
|
-
const nextState = resolveActionsAndContextWorker(
|
|
2076
|
+
const nextState = resolveActionsAndContextWorker(currentSnapshot, event, actorScope, actions, {
|
|
2077
2077
|
internalQueue,
|
|
2078
2078
|
deferredActorIds
|
|
2079
2079
|
}, retries);
|
|
@@ -2082,21 +2082,21 @@ function resolveActionsAndContext(currentState, event, actorScope, actions, inte
|
|
|
2082
2082
|
});
|
|
2083
2083
|
return nextState;
|
|
2084
2084
|
}
|
|
2085
|
-
function macrostep(
|
|
2085
|
+
function macrostep(snapshot, event, actorScope, internalQueue = []) {
|
|
2086
2086
|
if (event.type === WILDCARD) {
|
|
2087
2087
|
throw new Error(`An event cannot have the wildcard type ('${WILDCARD}')`);
|
|
2088
2088
|
}
|
|
2089
|
-
let
|
|
2089
|
+
let nextSnapshot = snapshot;
|
|
2090
2090
|
const states = [];
|
|
2091
2091
|
|
|
2092
2092
|
// Handle stop event
|
|
2093
2093
|
if (event.type === XSTATE_STOP) {
|
|
2094
|
-
|
|
2094
|
+
nextSnapshot = cloneMachineSnapshot(stopChildren(nextSnapshot, event, actorScope), {
|
|
2095
2095
|
status: 'stopped'
|
|
2096
2096
|
});
|
|
2097
|
-
states.push(
|
|
2097
|
+
states.push(nextSnapshot);
|
|
2098
2098
|
return {
|
|
2099
|
-
|
|
2099
|
+
snapshot: nextSnapshot,
|
|
2100
2100
|
microstates: states
|
|
2101
2101
|
};
|
|
2102
2102
|
}
|
|
@@ -2107,47 +2107,47 @@ function macrostep(state, event, actorScope, internalQueue = []) {
|
|
|
2107
2107
|
if (nextEvent.type !== XSTATE_INIT) {
|
|
2108
2108
|
const currentEvent = nextEvent;
|
|
2109
2109
|
const isErr = isErrorActorEvent(currentEvent);
|
|
2110
|
-
const transitions = selectTransitions(currentEvent,
|
|
2110
|
+
const transitions = selectTransitions(currentEvent, nextSnapshot);
|
|
2111
2111
|
if (isErr && !transitions.length) {
|
|
2112
2112
|
// TODO: we should likely only allow transitions selected by very explicit descriptors
|
|
2113
2113
|
// `*` shouldn't be matched, likely `xstate.error.*` shouldnt be either
|
|
2114
2114
|
// similarly `xstate.error.actor.*` and `xstate.error.actor.todo.*` have to be considered too
|
|
2115
|
-
|
|
2115
|
+
nextSnapshot = cloneMachineSnapshot(snapshot, {
|
|
2116
2116
|
status: 'error',
|
|
2117
2117
|
error: currentEvent.data
|
|
2118
2118
|
});
|
|
2119
|
-
states.push(
|
|
2119
|
+
states.push(nextSnapshot);
|
|
2120
2120
|
return {
|
|
2121
|
-
|
|
2121
|
+
snapshot: nextSnapshot,
|
|
2122
2122
|
microstates: states
|
|
2123
2123
|
};
|
|
2124
2124
|
}
|
|
2125
|
-
|
|
2126
|
-
states.push(
|
|
2125
|
+
nextSnapshot = microstep(transitions, snapshot, actorScope, nextEvent, false, internalQueue);
|
|
2126
|
+
states.push(nextSnapshot);
|
|
2127
2127
|
}
|
|
2128
2128
|
let shouldSelectEventlessTransitions = true;
|
|
2129
|
-
while (
|
|
2130
|
-
let enabledTransitions = shouldSelectEventlessTransitions ? selectEventlessTransitions(
|
|
2129
|
+
while (nextSnapshot.status === 'active') {
|
|
2130
|
+
let enabledTransitions = shouldSelectEventlessTransitions ? selectEventlessTransitions(nextSnapshot, nextEvent) : [];
|
|
2131
2131
|
|
|
2132
2132
|
// eventless transitions should always be selected after selecting *regular* transitions
|
|
2133
2133
|
// by assigning `undefined` to `previousState` we ensure that `shouldSelectEventlessTransitions` gets always computed to true in such a case
|
|
2134
|
-
const previousState = enabledTransitions.length ?
|
|
2134
|
+
const previousState = enabledTransitions.length ? nextSnapshot : undefined;
|
|
2135
2135
|
if (!enabledTransitions.length) {
|
|
2136
2136
|
if (!internalQueue.length) {
|
|
2137
2137
|
break;
|
|
2138
2138
|
}
|
|
2139
2139
|
nextEvent = internalQueue.shift();
|
|
2140
|
-
enabledTransitions = selectTransitions(nextEvent,
|
|
2140
|
+
enabledTransitions = selectTransitions(nextEvent, nextSnapshot);
|
|
2141
2141
|
}
|
|
2142
|
-
|
|
2143
|
-
shouldSelectEventlessTransitions =
|
|
2144
|
-
states.push(
|
|
2142
|
+
nextSnapshot = microstep(enabledTransitions, nextSnapshot, actorScope, nextEvent, false, internalQueue);
|
|
2143
|
+
shouldSelectEventlessTransitions = nextSnapshot !== previousState;
|
|
2144
|
+
states.push(nextSnapshot);
|
|
2145
2145
|
}
|
|
2146
|
-
if (
|
|
2147
|
-
stopChildren(
|
|
2146
|
+
if (nextSnapshot.status !== 'active') {
|
|
2147
|
+
stopChildren(nextSnapshot, nextEvent, actorScope);
|
|
2148
2148
|
}
|
|
2149
2149
|
return {
|
|
2150
|
-
|
|
2150
|
+
snapshot: nextSnapshot,
|
|
2151
2151
|
microstates: states
|
|
2152
2152
|
};
|
|
2153
2153
|
}
|
|
@@ -2248,13 +2248,13 @@ function createMachineSnapshot(config, machine) {
|
|
|
2248
2248
|
toJSON: machineSnapshotToJSON
|
|
2249
2249
|
};
|
|
2250
2250
|
}
|
|
2251
|
-
function cloneMachineSnapshot(
|
|
2251
|
+
function cloneMachineSnapshot(snapshot, config = {}) {
|
|
2252
2252
|
return createMachineSnapshot({
|
|
2253
|
-
...
|
|
2253
|
+
...snapshot,
|
|
2254
2254
|
...config
|
|
2255
|
-
},
|
|
2255
|
+
}, snapshot.machine);
|
|
2256
2256
|
}
|
|
2257
|
-
function
|
|
2257
|
+
function getPersistedSnapshot(snapshot, options) {
|
|
2258
2258
|
const {
|
|
2259
2259
|
_nodes: nodes,
|
|
2260
2260
|
tags,
|
|
@@ -2267,7 +2267,7 @@ function getPersistedState(state, options) {
|
|
|
2267
2267
|
getMeta,
|
|
2268
2268
|
toJSON,
|
|
2269
2269
|
...jsonValues
|
|
2270
|
-
} =
|
|
2270
|
+
} = snapshot;
|
|
2271
2271
|
const childrenJson = {};
|
|
2272
2272
|
for (const id in children) {
|
|
2273
2273
|
const child = children[id];
|
|
@@ -2275,7 +2275,7 @@ function getPersistedState(state, options) {
|
|
|
2275
2275
|
throw new Error('An inline child actor cannot be persisted.');
|
|
2276
2276
|
}
|
|
2277
2277
|
childrenJson[id] = {
|
|
2278
|
-
|
|
2278
|
+
snapshot: child.getPersistedSnapshot(options),
|
|
2279
2279
|
src: child.src,
|
|
2280
2280
|
systemId: child._systemId,
|
|
2281
2281
|
syncSnapshot: child._syncSnapshot
|
|
@@ -2315,14 +2315,14 @@ function persistContext(contextPart) {
|
|
|
2315
2315
|
return copy ?? contextPart;
|
|
2316
2316
|
}
|
|
2317
2317
|
|
|
2318
|
-
function resolveRaise(_,
|
|
2318
|
+
function resolveRaise(_, snapshot, args, actionParams, {
|
|
2319
2319
|
event: eventOrExpr,
|
|
2320
2320
|
id,
|
|
2321
2321
|
delay
|
|
2322
2322
|
}, {
|
|
2323
2323
|
internalQueue
|
|
2324
2324
|
}) {
|
|
2325
|
-
const delaysMap =
|
|
2325
|
+
const delaysMap = snapshot.machine.implementations.delays;
|
|
2326
2326
|
if (typeof eventOrExpr === 'string') {
|
|
2327
2327
|
throw new Error(`Only event objects may be used with raise; use raise({ type: "${eventOrExpr}" }) instead`);
|
|
2328
2328
|
}
|
|
@@ -2337,7 +2337,7 @@ function resolveRaise(_, state, args, actionParams, {
|
|
|
2337
2337
|
if (typeof resolvedDelay !== 'number') {
|
|
2338
2338
|
internalQueue.push(resolvedEvent);
|
|
2339
2339
|
}
|
|
2340
|
-
return [
|
|
2340
|
+
return [snapshot, {
|
|
2341
2341
|
event: resolvedEvent,
|
|
2342
2342
|
id,
|
|
2343
2343
|
delay: resolvedDelay
|
|
@@ -2394,7 +2394,7 @@ exports.getAllStateNodes = getAllStateNodes;
|
|
|
2394
2394
|
exports.getCandidates = getCandidates;
|
|
2395
2395
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
2396
2396
|
exports.getInitialStateNodes = getInitialStateNodes;
|
|
2397
|
-
exports.
|
|
2397
|
+
exports.getPersistedSnapshot = getPersistedSnapshot;
|
|
2398
2398
|
exports.getStateNodeByPath = getStateNodeByPath;
|
|
2399
2399
|
exports.getStateNodes = getStateNodes;
|
|
2400
2400
|
exports.interpret = interpret;
|