xstate 5.0.0-beta.34 → 5.0.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/actions/dist/xstate-actions.cjs.js +3 -3
- package/actions/dist/xstate-actions.development.cjs.js +3 -3
- package/actions/dist/xstate-actions.development.esm.js +3 -3
- package/actions/dist/xstate-actions.esm.js +3 -3
- 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 +1 -1
- package/actors/dist/xstate-actors.development.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.esm.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- 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 +0 -1
- package/dist/declarations/src/interpreter.d.ts +2 -0
- package/dist/declarations/src/stateUtils.d.ts +8 -7
- package/dist/declarations/src/types.d.ts +3 -6
- package/dist/{interpreter-dee56dc8.development.esm.js → interpreter-5c4e6634.development.esm.js} +59 -57
- package/dist/{interpreter-1301970f.cjs.js → interpreter-69605bf0.cjs.js} +59 -57
- package/dist/{interpreter-70ed62f2.development.cjs.js → interpreter-d3567419.development.cjs.js} +59 -57
- package/dist/{interpreter-83f7f2d4.esm.js → interpreter-de5217bc.esm.js} +59 -57
- package/dist/{raise-38b707c0.development.cjs.js → raise-106ea558.development.cjs.js} +160 -160
- package/dist/{raise-05f8b2a6.development.esm.js → raise-5b7ad3b7.development.esm.js} +160 -160
- package/dist/{raise-1dd65455.cjs.js → raise-c51b81a3.cjs.js} +157 -160
- package/dist/{raise-b5cfe1bb.esm.js → raise-ffe1014a.esm.js} +157 -160
- package/dist/{send-0b5eda0c.esm.js → send-0a7aa74e.esm.js} +5 -3
- package/dist/{send-3764c866.development.cjs.js → send-25e70bd4.development.cjs.js} +5 -3
- package/dist/{send-fe94de2b.cjs.js → send-778692de.cjs.js} +5 -3
- package/dist/{send-9526366e.development.esm.js → send-e93554d6.development.esm.js} +5 -3
- package/dist/xstate.cjs.js +32 -13
- package/dist/xstate.development.cjs.js +32 -13
- package/dist/xstate.development.esm.js +35 -16
- package/dist/xstate.esm.js +35 -16
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.esm.js +2 -2
- package/guards/dist/xstate-guards.esm.js +2 -2
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as cloneState, e as evaluateGuard } from './raise-
|
|
2
|
-
import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray,
|
|
1
|
+
import { j as cloneState, e as evaluateGuard } from './raise-5b7ad3b7.development.esm.js';
|
|
2
|
+
import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-5c4e6634.development.esm.js';
|
|
3
3
|
|
|
4
4
|
function createSpawner(actorContext, {
|
|
5
5
|
machine,
|
|
@@ -25,6 +25,7 @@ function createSpawner(actorContext, {
|
|
|
25
25
|
event,
|
|
26
26
|
self: actorContext.self
|
|
27
27
|
}) : input,
|
|
28
|
+
src,
|
|
28
29
|
systemId
|
|
29
30
|
});
|
|
30
31
|
spawnedChildren[actorRef.id] = actorRef;
|
|
@@ -50,6 +51,7 @@ function createSpawner(actorContext, {
|
|
|
50
51
|
id: options.id,
|
|
51
52
|
parent: actorContext.self,
|
|
52
53
|
input: options.input,
|
|
54
|
+
src: undefined,
|
|
53
55
|
systemId
|
|
54
56
|
});
|
|
55
57
|
if (options.syncSnapshot) {
|
|
@@ -293,7 +295,7 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
293
295
|
// #_invokeid. If the target is the special term '#_invokeid', where invokeid is the invokeid of an SCXML session that the sending session has created by <invoke>, the Processor must add the event to the external queue of that session.
|
|
294
296
|
targetActorRef = state.children[resolvedTarget.slice(2)];
|
|
295
297
|
} else {
|
|
296
|
-
targetActorRef = extra?.
|
|
298
|
+
targetActorRef = extra.deferredActorIds?.includes(resolvedTarget) ? resolvedTarget : state.children[resolvedTarget];
|
|
297
299
|
}
|
|
298
300
|
if (!targetActorRef) {
|
|
299
301
|
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${state.machine.id}'.`);
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
|
|
6
|
-
var interpreter = require('./interpreter-
|
|
7
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
8
|
-
var send = require('./send-
|
|
6
|
+
var interpreter = require('./interpreter-69605bf0.cjs.js');
|
|
7
|
+
var guards_dist_xstateGuards = require('./raise-c51b81a3.cjs.js');
|
|
8
|
+
var send = require('./send-778692de.cjs.js');
|
|
9
9
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
10
10
|
|
|
11
11
|
class SimulatedClock {
|
|
@@ -303,7 +303,7 @@ class StateNode {
|
|
|
303
303
|
return guards_dist_xstateGuards.memo(this, 'delayedTransitions', () => guards_dist_xstateGuards.getDelayedTransitions(this));
|
|
304
304
|
}
|
|
305
305
|
get initial() {
|
|
306
|
-
return guards_dist_xstateGuards.memo(this, 'initial', () => guards_dist_xstateGuards.formatInitialTransition(this, this.config.initial
|
|
306
|
+
return guards_dist_xstateGuards.memo(this, 'initial', () => guards_dist_xstateGuards.formatInitialTransition(this, this.config.initial));
|
|
307
307
|
}
|
|
308
308
|
next(state, event) {
|
|
309
309
|
const eventType = event.type;
|
|
@@ -471,7 +471,7 @@ class StateMachine {
|
|
|
471
471
|
...state,
|
|
472
472
|
value: guards_dist_xstateGuards.resolveStateValue(this.root, state.value),
|
|
473
473
|
configuration,
|
|
474
|
-
status: guards_dist_xstateGuards.isInFinalState(
|
|
474
|
+
status: guards_dist_xstateGuards.isInFinalState(configurationSet, this.root) ? 'done' : state.status
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
resolveStateValue(stateValue, ...[context]) {
|
|
@@ -518,7 +518,7 @@ class StateMachine {
|
|
|
518
518
|
* The initial state _before_ evaluating any microsteps.
|
|
519
519
|
* This "pre-initial" state is provided to initial actions executed in the initial state.
|
|
520
520
|
*/
|
|
521
|
-
getPreInitialState(actorCtx, initEvent) {
|
|
521
|
+
getPreInitialState(actorCtx, initEvent, internalQueue) {
|
|
522
522
|
const {
|
|
523
523
|
context
|
|
524
524
|
} = this.config;
|
|
@@ -539,7 +539,7 @@ class StateMachine {
|
|
|
539
539
|
spawn,
|
|
540
540
|
input: event.input
|
|
541
541
|
});
|
|
542
|
-
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorCtx, [send.assign(assignment)]);
|
|
542
|
+
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorCtx, [send.assign(assignment)], internalQueue);
|
|
543
543
|
}
|
|
544
544
|
return preInitial;
|
|
545
545
|
}
|
|
@@ -549,19 +549,19 @@ class StateMachine {
|
|
|
549
549
|
*/
|
|
550
550
|
getInitialState(actorCtx, input) {
|
|
551
551
|
const initEvent = interpreter.createInitEvent(input); // TODO: fix;
|
|
552
|
-
|
|
553
|
-
const preInitialState = this.getPreInitialState(actorCtx, initEvent);
|
|
552
|
+
const internalQueue = [];
|
|
553
|
+
const preInitialState = this.getPreInitialState(actorCtx, initEvent, internalQueue);
|
|
554
554
|
const nextState = guards_dist_xstateGuards.microstep([{
|
|
555
|
-
target: [...
|
|
555
|
+
target: [...guards_dist_xstateGuards.getInitialStateNodes(this.root)],
|
|
556
556
|
source: this.root,
|
|
557
557
|
reenter: true,
|
|
558
558
|
actions: [],
|
|
559
559
|
eventType: null,
|
|
560
560
|
toJSON: null // TODO: fix
|
|
561
|
-
}], preInitialState, actorCtx, initEvent, true);
|
|
561
|
+
}], preInitialState, actorCtx, initEvent, true, internalQueue);
|
|
562
562
|
const {
|
|
563
563
|
state: macroState
|
|
564
|
-
} = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorCtx);
|
|
564
|
+
} = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorCtx, internalQueue);
|
|
565
565
|
return macroState;
|
|
566
566
|
}
|
|
567
567
|
start(state) {
|
|
@@ -611,10 +611,29 @@ class StateMachine {
|
|
|
611
611
|
});
|
|
612
612
|
children[actorId] = actorRef;
|
|
613
613
|
});
|
|
614
|
-
|
|
614
|
+
const restoredSnapshot = this.createState(new guards_dist_xstateGuards.State({
|
|
615
615
|
...snapshot,
|
|
616
616
|
children
|
|
617
617
|
}, this));
|
|
618
|
+
let seen = new Set();
|
|
619
|
+
function reviveContext(contextPart, children) {
|
|
620
|
+
if (seen.has(contextPart)) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
seen.add(contextPart);
|
|
624
|
+
for (let key in contextPart) {
|
|
625
|
+
const value = contextPart[key];
|
|
626
|
+
if (value && typeof value === 'object') {
|
|
627
|
+
if ('xstate$$type' in value && value.xstate$$type === interpreter.$$ACTOR_TYPE) {
|
|
628
|
+
contextPart[key] = children[value.id];
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
reviveContext(value, children);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
reviveContext(restoredSnapshot.context, children);
|
|
636
|
+
return restoredSnapshot;
|
|
618
637
|
}
|
|
619
638
|
|
|
620
639
|
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
@@ -3,9 +3,9 @@
|
|
|
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 interpreter = require('./interpreter-
|
|
7
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
8
|
-
var send = require('./send-
|
|
6
|
+
var interpreter = require('./interpreter-d3567419.development.cjs.js');
|
|
7
|
+
var guards_dist_xstateGuards = require('./raise-106ea558.development.cjs.js');
|
|
8
|
+
var send = require('./send-25e70bd4.development.cjs.js');
|
|
9
9
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
10
10
|
|
|
11
11
|
class SimulatedClock {
|
|
@@ -303,7 +303,7 @@ class StateNode {
|
|
|
303
303
|
return guards_dist_xstateGuards.memo(this, 'delayedTransitions', () => guards_dist_xstateGuards.getDelayedTransitions(this));
|
|
304
304
|
}
|
|
305
305
|
get initial() {
|
|
306
|
-
return guards_dist_xstateGuards.memo(this, 'initial', () => guards_dist_xstateGuards.formatInitialTransition(this, this.config.initial
|
|
306
|
+
return guards_dist_xstateGuards.memo(this, 'initial', () => guards_dist_xstateGuards.formatInitialTransition(this, this.config.initial));
|
|
307
307
|
}
|
|
308
308
|
next(state, event) {
|
|
309
309
|
const eventType = event.type;
|
|
@@ -474,7 +474,7 @@ class StateMachine {
|
|
|
474
474
|
...state,
|
|
475
475
|
value: guards_dist_xstateGuards.resolveStateValue(this.root, state.value),
|
|
476
476
|
configuration,
|
|
477
|
-
status: guards_dist_xstateGuards.isInFinalState(
|
|
477
|
+
status: guards_dist_xstateGuards.isInFinalState(configurationSet, this.root) ? 'done' : state.status
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
480
|
resolveStateValue(stateValue, ...[context]) {
|
|
@@ -521,7 +521,7 @@ class StateMachine {
|
|
|
521
521
|
* The initial state _before_ evaluating any microsteps.
|
|
522
522
|
* This "pre-initial" state is provided to initial actions executed in the initial state.
|
|
523
523
|
*/
|
|
524
|
-
getPreInitialState(actorCtx, initEvent) {
|
|
524
|
+
getPreInitialState(actorCtx, initEvent, internalQueue) {
|
|
525
525
|
const {
|
|
526
526
|
context
|
|
527
527
|
} = this.config;
|
|
@@ -542,7 +542,7 @@ class StateMachine {
|
|
|
542
542
|
spawn,
|
|
543
543
|
input: event.input
|
|
544
544
|
});
|
|
545
|
-
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorCtx, [send.assign(assignment)]);
|
|
545
|
+
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorCtx, [send.assign(assignment)], internalQueue);
|
|
546
546
|
}
|
|
547
547
|
return preInitial;
|
|
548
548
|
}
|
|
@@ -552,19 +552,19 @@ class StateMachine {
|
|
|
552
552
|
*/
|
|
553
553
|
getInitialState(actorCtx, input) {
|
|
554
554
|
const initEvent = interpreter.createInitEvent(input); // TODO: fix;
|
|
555
|
-
|
|
556
|
-
const preInitialState = this.getPreInitialState(actorCtx, initEvent);
|
|
555
|
+
const internalQueue = [];
|
|
556
|
+
const preInitialState = this.getPreInitialState(actorCtx, initEvent, internalQueue);
|
|
557
557
|
const nextState = guards_dist_xstateGuards.microstep([{
|
|
558
|
-
target: [...
|
|
558
|
+
target: [...guards_dist_xstateGuards.getInitialStateNodes(this.root)],
|
|
559
559
|
source: this.root,
|
|
560
560
|
reenter: true,
|
|
561
561
|
actions: [],
|
|
562
562
|
eventType: null,
|
|
563
563
|
toJSON: null // TODO: fix
|
|
564
|
-
}], preInitialState, actorCtx, initEvent, true);
|
|
564
|
+
}], preInitialState, actorCtx, initEvent, true, internalQueue);
|
|
565
565
|
const {
|
|
566
566
|
state: macroState
|
|
567
|
-
} = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorCtx);
|
|
567
|
+
} = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorCtx, internalQueue);
|
|
568
568
|
return macroState;
|
|
569
569
|
}
|
|
570
570
|
start(state) {
|
|
@@ -614,10 +614,29 @@ class StateMachine {
|
|
|
614
614
|
});
|
|
615
615
|
children[actorId] = actorRef;
|
|
616
616
|
});
|
|
617
|
-
|
|
617
|
+
const restoredSnapshot = this.createState(new guards_dist_xstateGuards.State({
|
|
618
618
|
...snapshot,
|
|
619
619
|
children
|
|
620
620
|
}, this));
|
|
621
|
+
let seen = new Set();
|
|
622
|
+
function reviveContext(contextPart, children) {
|
|
623
|
+
if (seen.has(contextPart)) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
seen.add(contextPart);
|
|
627
|
+
for (let key in contextPart) {
|
|
628
|
+
const value = contextPart[key];
|
|
629
|
+
if (value && typeof value === 'object') {
|
|
630
|
+
if ('xstate$$type' in value && value.xstate$$type === interpreter.$$ACTOR_TYPE) {
|
|
631
|
+
contextPart[key] = children[value.id];
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
reviveContext(value, children);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
reviveContext(restoredSnapshot.context, children);
|
|
639
|
+
return restoredSnapshot;
|
|
621
640
|
}
|
|
622
641
|
|
|
623
642
|
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
|
@@ -1,10 +1,10 @@
|
|
|
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, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, e as matchesState } from './interpreter-
|
|
3
|
-
export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-
|
|
4
|
-
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as
|
|
5
|
-
export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-
|
|
6
|
-
import { a as assign } from './send-
|
|
7
|
-
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, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-5c4e6634.development.esm.js';
|
|
3
|
+
export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-5c4e6634.development.esm.js';
|
|
4
|
+
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-5b7ad3b7.development.esm.js';
|
|
5
|
+
export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-5b7ad3b7.development.esm.js';
|
|
6
|
+
import { a as assign } from './send-e93554d6.development.esm.js';
|
|
7
|
+
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-e93554d6.development.esm.js';
|
|
8
8
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -302,7 +302,7 @@ class StateNode {
|
|
|
302
302
|
return memo(this, 'delayedTransitions', () => getDelayedTransitions(this));
|
|
303
303
|
}
|
|
304
304
|
get initial() {
|
|
305
|
-
return memo(this, 'initial', () => formatInitialTransition(this, this.config.initial
|
|
305
|
+
return memo(this, 'initial', () => formatInitialTransition(this, this.config.initial));
|
|
306
306
|
}
|
|
307
307
|
next(state, event) {
|
|
308
308
|
const eventType = event.type;
|
|
@@ -473,7 +473,7 @@ class StateMachine {
|
|
|
473
473
|
...state,
|
|
474
474
|
value: resolveStateValue(this.root, state.value),
|
|
475
475
|
configuration,
|
|
476
|
-
status: isInFinalState(
|
|
476
|
+
status: isInFinalState(configurationSet, this.root) ? 'done' : state.status
|
|
477
477
|
});
|
|
478
478
|
}
|
|
479
479
|
resolveStateValue(stateValue, ...[context]) {
|
|
@@ -520,7 +520,7 @@ class StateMachine {
|
|
|
520
520
|
* The initial state _before_ evaluating any microsteps.
|
|
521
521
|
* This "pre-initial" state is provided to initial actions executed in the initial state.
|
|
522
522
|
*/
|
|
523
|
-
getPreInitialState(actorCtx, initEvent) {
|
|
523
|
+
getPreInitialState(actorCtx, initEvent, internalQueue) {
|
|
524
524
|
const {
|
|
525
525
|
context
|
|
526
526
|
} = this.config;
|
|
@@ -541,7 +541,7 @@ class StateMachine {
|
|
|
541
541
|
spawn,
|
|
542
542
|
input: event.input
|
|
543
543
|
});
|
|
544
|
-
return resolveActionsAndContext(preInitial, initEvent, actorCtx, [assign(assignment)]);
|
|
544
|
+
return resolveActionsAndContext(preInitial, initEvent, actorCtx, [assign(assignment)], internalQueue);
|
|
545
545
|
}
|
|
546
546
|
return preInitial;
|
|
547
547
|
}
|
|
@@ -551,19 +551,19 @@ class StateMachine {
|
|
|
551
551
|
*/
|
|
552
552
|
getInitialState(actorCtx, input) {
|
|
553
553
|
const initEvent = createInitEvent(input); // TODO: fix;
|
|
554
|
-
|
|
555
|
-
const preInitialState = this.getPreInitialState(actorCtx, initEvent);
|
|
554
|
+
const internalQueue = [];
|
|
555
|
+
const preInitialState = this.getPreInitialState(actorCtx, initEvent, internalQueue);
|
|
556
556
|
const nextState = microstep([{
|
|
557
|
-
target: [...
|
|
557
|
+
target: [...getInitialStateNodes(this.root)],
|
|
558
558
|
source: this.root,
|
|
559
559
|
reenter: true,
|
|
560
560
|
actions: [],
|
|
561
561
|
eventType: null,
|
|
562
562
|
toJSON: null // TODO: fix
|
|
563
|
-
}], preInitialState, actorCtx, initEvent, true);
|
|
563
|
+
}], preInitialState, actorCtx, initEvent, true, internalQueue);
|
|
564
564
|
const {
|
|
565
565
|
state: macroState
|
|
566
|
-
} = macrostep(nextState, initEvent, actorCtx);
|
|
566
|
+
} = macrostep(nextState, initEvent, actorCtx, internalQueue);
|
|
567
567
|
return macroState;
|
|
568
568
|
}
|
|
569
569
|
start(state) {
|
|
@@ -613,10 +613,29 @@ class StateMachine {
|
|
|
613
613
|
});
|
|
614
614
|
children[actorId] = actorRef;
|
|
615
615
|
});
|
|
616
|
-
|
|
616
|
+
const restoredSnapshot = this.createState(new State({
|
|
617
617
|
...snapshot,
|
|
618
618
|
children
|
|
619
619
|
}, this));
|
|
620
|
+
let seen = new Set();
|
|
621
|
+
function reviveContext(contextPart, children) {
|
|
622
|
+
if (seen.has(contextPart)) {
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
seen.add(contextPart);
|
|
626
|
+
for (let key in contextPart) {
|
|
627
|
+
const value = contextPart[key];
|
|
628
|
+
if (value && typeof value === 'object') {
|
|
629
|
+
if ('xstate$$type' in value && value.xstate$$type === $$ACTOR_TYPE) {
|
|
630
|
+
contextPart[key] = children[value.id];
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
reviveContext(value, children);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
reviveContext(restoredSnapshot.context, children);
|
|
638
|
+
return restoredSnapshot;
|
|
620
639
|
}
|
|
621
640
|
|
|
622
641
|
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, e as matchesState } from './interpreter-
|
|
3
|
-
export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-
|
|
4
|
-
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as
|
|
5
|
-
export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-
|
|
6
|
-
import { a as assign } from './send-
|
|
7
|
-
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, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-de5217bc.esm.js';
|
|
3
|
+
export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-de5217bc.esm.js';
|
|
4
|
+
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-ffe1014a.esm.js';
|
|
5
|
+
export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-ffe1014a.esm.js';
|
|
6
|
+
import { a as assign } from './send-0a7aa74e.esm.js';
|
|
7
|
+
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-0a7aa74e.esm.js';
|
|
8
8
|
import '../dev/dist/xstate-dev.esm.js';
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -302,7 +302,7 @@ class StateNode {
|
|
|
302
302
|
return memo(this, 'delayedTransitions', () => getDelayedTransitions(this));
|
|
303
303
|
}
|
|
304
304
|
get initial() {
|
|
305
|
-
return memo(this, 'initial', () => formatInitialTransition(this, this.config.initial
|
|
305
|
+
return memo(this, 'initial', () => formatInitialTransition(this, this.config.initial));
|
|
306
306
|
}
|
|
307
307
|
next(state, event) {
|
|
308
308
|
const eventType = event.type;
|
|
@@ -470,7 +470,7 @@ class StateMachine {
|
|
|
470
470
|
...state,
|
|
471
471
|
value: resolveStateValue(this.root, state.value),
|
|
472
472
|
configuration,
|
|
473
|
-
status: isInFinalState(
|
|
473
|
+
status: isInFinalState(configurationSet, this.root) ? 'done' : state.status
|
|
474
474
|
});
|
|
475
475
|
}
|
|
476
476
|
resolveStateValue(stateValue, ...[context]) {
|
|
@@ -517,7 +517,7 @@ class StateMachine {
|
|
|
517
517
|
* The initial state _before_ evaluating any microsteps.
|
|
518
518
|
* This "pre-initial" state is provided to initial actions executed in the initial state.
|
|
519
519
|
*/
|
|
520
|
-
getPreInitialState(actorCtx, initEvent) {
|
|
520
|
+
getPreInitialState(actorCtx, initEvent, internalQueue) {
|
|
521
521
|
const {
|
|
522
522
|
context
|
|
523
523
|
} = this.config;
|
|
@@ -538,7 +538,7 @@ class StateMachine {
|
|
|
538
538
|
spawn,
|
|
539
539
|
input: event.input
|
|
540
540
|
});
|
|
541
|
-
return resolveActionsAndContext(preInitial, initEvent, actorCtx, [assign(assignment)]);
|
|
541
|
+
return resolveActionsAndContext(preInitial, initEvent, actorCtx, [assign(assignment)], internalQueue);
|
|
542
542
|
}
|
|
543
543
|
return preInitial;
|
|
544
544
|
}
|
|
@@ -548,19 +548,19 @@ class StateMachine {
|
|
|
548
548
|
*/
|
|
549
549
|
getInitialState(actorCtx, input) {
|
|
550
550
|
const initEvent = createInitEvent(input); // TODO: fix;
|
|
551
|
-
|
|
552
|
-
const preInitialState = this.getPreInitialState(actorCtx, initEvent);
|
|
551
|
+
const internalQueue = [];
|
|
552
|
+
const preInitialState = this.getPreInitialState(actorCtx, initEvent, internalQueue);
|
|
553
553
|
const nextState = microstep([{
|
|
554
|
-
target: [...
|
|
554
|
+
target: [...getInitialStateNodes(this.root)],
|
|
555
555
|
source: this.root,
|
|
556
556
|
reenter: true,
|
|
557
557
|
actions: [],
|
|
558
558
|
eventType: null,
|
|
559
559
|
toJSON: null // TODO: fix
|
|
560
|
-
}], preInitialState, actorCtx, initEvent, true);
|
|
560
|
+
}], preInitialState, actorCtx, initEvent, true, internalQueue);
|
|
561
561
|
const {
|
|
562
562
|
state: macroState
|
|
563
|
-
} = macrostep(nextState, initEvent, actorCtx);
|
|
563
|
+
} = macrostep(nextState, initEvent, actorCtx, internalQueue);
|
|
564
564
|
return macroState;
|
|
565
565
|
}
|
|
566
566
|
start(state) {
|
|
@@ -610,10 +610,29 @@ class StateMachine {
|
|
|
610
610
|
});
|
|
611
611
|
children[actorId] = actorRef;
|
|
612
612
|
});
|
|
613
|
-
|
|
613
|
+
const restoredSnapshot = this.createState(new State({
|
|
614
614
|
...snapshot,
|
|
615
615
|
children
|
|
616
616
|
}, this));
|
|
617
|
+
let seen = new Set();
|
|
618
|
+
function reviveContext(contextPart, children) {
|
|
619
|
+
if (seen.has(contextPart)) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
seen.add(contextPart);
|
|
623
|
+
for (let key in contextPart) {
|
|
624
|
+
const value = contextPart[key];
|
|
625
|
+
if (value && typeof value === 'object') {
|
|
626
|
+
if ('xstate$$type' in value && value.xstate$$type === $$ACTOR_TYPE) {
|
|
627
|
+
contextPart[key] = children[value.id];
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
reviveContext(value, children);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
reviveContext(restoredSnapshot.context, children);
|
|
635
|
+
return restoredSnapshot;
|
|
617
636
|
}
|
|
618
637
|
|
|
619
638
|
/**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
|