xstate 5.0.0-beta.33 → 5.0.0-beta.35
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 +3 -3
- package/actors/dist/xstate-actors.development.cjs.js +3 -3
- package/actors/dist/xstate-actors.development.esm.js +3 -3
- package/actors/dist/xstate-actors.esm.js +3 -3
- 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/index.d.ts +1 -0
- package/dist/declarations/src/interpreter.d.ts +3 -1
- package/dist/declarations/src/stateUtils.d.ts +6 -5
- package/dist/declarations/src/types.d.ts +3 -5
- package/dist/{interpreter-825f3d6e.development.esm.js → interpreter-5c4e6634.development.esm.js} +67 -65
- package/dist/{interpreter-054e9fb7.cjs.js → interpreter-69605bf0.cjs.js} +67 -65
- package/dist/{interpreter-0c630f66.development.cjs.js → interpreter-d3567419.development.cjs.js} +67 -65
- package/dist/{interpreter-03737810.esm.js → interpreter-de5217bc.esm.js} +67 -65
- package/dist/{raise-987c242e.cjs.js → raise-0ff57677.cjs.js} +142 -124
- package/dist/{raise-4c6a5a96.development.cjs.js → raise-26e4d83c.development.cjs.js} +145 -124
- package/dist/{raise-2d92eae8.esm.js → raise-511399cc.esm.js} +142 -124
- package/dist/{raise-46f122aa.development.esm.js → raise-cdcdf834.development.esm.js} +145 -124
- package/dist/{send-bd1bd0e3.cjs.js → send-19ffc568.cjs.js} +16 -8
- package/dist/{send-4d5b92dc.development.esm.js → send-1de74f4d.development.esm.js} +16 -8
- package/dist/{send-0edee2b4.esm.js → send-211a2a94.esm.js} +16 -8
- package/dist/{send-0e8675c8.development.cjs.js → send-894c4b18.development.cjs.js} +16 -8
- package/dist/xstate.cjs.js +28 -9
- package/dist/xstate.development.cjs.js +28 -9
- package/dist/xstate.development.esm.js +31 -12
- package/dist/xstate.esm.js +31 -12
- 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,
|
|
1
|
+
import { j as cloneState, e as evaluateGuard } from './raise-511399cc.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-de5217bc.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) {
|
|
@@ -256,7 +258,7 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
256
258
|
event: eventOrExpr,
|
|
257
259
|
id,
|
|
258
260
|
delay
|
|
259
|
-
}) {
|
|
261
|
+
}, extra) {
|
|
260
262
|
const delaysMap = state.machine.implementations.delays;
|
|
261
263
|
if (typeof eventOrExpr === 'string') {
|
|
262
264
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
@@ -281,7 +283,7 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
281
283
|
// #_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.
|
|
282
284
|
targetActorRef = state.children[resolvedTarget.slice(2)];
|
|
283
285
|
} else {
|
|
284
|
-
targetActorRef = state.children[resolvedTarget];
|
|
286
|
+
targetActorRef = extra?.deferredActorIds.includes(resolvedTarget) ? resolvedTarget : state.children[resolvedTarget];
|
|
285
287
|
}
|
|
286
288
|
if (!targetActorRef) {
|
|
287
289
|
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${state.machine.id}'.`);
|
|
@@ -296,16 +298,21 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
296
298
|
delay: resolvedDelay
|
|
297
299
|
}];
|
|
298
300
|
}
|
|
301
|
+
function retryResolveSendTo(_, state, params) {
|
|
302
|
+
if (typeof params.to === 'string') {
|
|
303
|
+
params.to = state.children[params.to];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
299
306
|
function executeSendTo(actorContext, params) {
|
|
300
307
|
if (typeof params.delay === 'number') {
|
|
301
308
|
actorContext.self.delaySend(params);
|
|
302
309
|
return;
|
|
303
310
|
}
|
|
304
|
-
const {
|
|
305
|
-
to,
|
|
306
|
-
event
|
|
307
|
-
} = params;
|
|
308
311
|
actorContext.defer(() => {
|
|
312
|
+
const {
|
|
313
|
+
to,
|
|
314
|
+
event
|
|
315
|
+
} = params;
|
|
309
316
|
actorContext?.system._relay(actorContext.self, to, event.type === XSTATE_ERROR ? createErrorActorEvent(actorContext.self.id, event.data) : event);
|
|
310
317
|
});
|
|
311
318
|
}
|
|
@@ -327,6 +334,7 @@ function sendTo(to, eventOrExpr, options) {
|
|
|
327
334
|
sendTo.id = options?.id;
|
|
328
335
|
sendTo.delay = options?.delay;
|
|
329
336
|
sendTo.resolve = resolveSendTo;
|
|
337
|
+
sendTo.retryResolve = retryResolveSendTo;
|
|
330
338
|
sendTo.execute = executeSendTo;
|
|
331
339
|
return sendTo;
|
|
332
340
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-26e4d83c.development.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-d3567419.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorContext, {
|
|
7
7
|
machine,
|
|
@@ -27,6 +27,7 @@ function createSpawner(actorContext, {
|
|
|
27
27
|
event,
|
|
28
28
|
self: actorContext.self
|
|
29
29
|
}) : input,
|
|
30
|
+
src,
|
|
30
31
|
systemId
|
|
31
32
|
});
|
|
32
33
|
spawnedChildren[actorRef.id] = actorRef;
|
|
@@ -52,6 +53,7 @@ function createSpawner(actorContext, {
|
|
|
52
53
|
id: options.id,
|
|
53
54
|
parent: actorContext.self,
|
|
54
55
|
input: options.input,
|
|
56
|
+
src: undefined,
|
|
55
57
|
systemId
|
|
56
58
|
});
|
|
57
59
|
if (options.syncSnapshot) {
|
|
@@ -270,7 +272,7 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
270
272
|
event: eventOrExpr,
|
|
271
273
|
id,
|
|
272
274
|
delay
|
|
273
|
-
}) {
|
|
275
|
+
}, extra) {
|
|
274
276
|
const delaysMap = state.machine.implementations.delays;
|
|
275
277
|
if (typeof eventOrExpr === 'string') {
|
|
276
278
|
throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`);
|
|
@@ -295,7 +297,7 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
295
297
|
// #_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.
|
|
296
298
|
targetActorRef = state.children[resolvedTarget.slice(2)];
|
|
297
299
|
} else {
|
|
298
|
-
targetActorRef = state.children[resolvedTarget];
|
|
300
|
+
targetActorRef = extra?.deferredActorIds.includes(resolvedTarget) ? resolvedTarget : state.children[resolvedTarget];
|
|
299
301
|
}
|
|
300
302
|
if (!targetActorRef) {
|
|
301
303
|
throw new Error(`Unable to send event to actor '${resolvedTarget}' from machine '${state.machine.id}'.`);
|
|
@@ -310,16 +312,21 @@ function resolveSendTo(actorContext, state, args, {
|
|
|
310
312
|
delay: resolvedDelay
|
|
311
313
|
}];
|
|
312
314
|
}
|
|
315
|
+
function retryResolveSendTo(_, state, params) {
|
|
316
|
+
if (typeof params.to === 'string') {
|
|
317
|
+
params.to = state.children[params.to];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
313
320
|
function executeSendTo(actorContext, params) {
|
|
314
321
|
if (typeof params.delay === 'number') {
|
|
315
322
|
actorContext.self.delaySend(params);
|
|
316
323
|
return;
|
|
317
324
|
}
|
|
318
|
-
const {
|
|
319
|
-
to,
|
|
320
|
-
event
|
|
321
|
-
} = params;
|
|
322
325
|
actorContext.defer(() => {
|
|
326
|
+
const {
|
|
327
|
+
to,
|
|
328
|
+
event
|
|
329
|
+
} = params;
|
|
323
330
|
actorContext?.system._relay(actorContext.self, to, event.type === interpreter.XSTATE_ERROR ? interpreter.createErrorActorEvent(actorContext.self.id, event.data) : event);
|
|
324
331
|
});
|
|
325
332
|
}
|
|
@@ -344,6 +351,7 @@ function sendTo(to, eventOrExpr, options) {
|
|
|
344
351
|
sendTo.id = options?.id;
|
|
345
352
|
sendTo.delay = options?.delay;
|
|
346
353
|
sendTo.resolve = resolveSendTo;
|
|
354
|
+
sendTo.retryResolve = retryResolveSendTo;
|
|
347
355
|
sendTo.execute = executeSendTo;
|
|
348
356
|
return sendTo;
|
|
349
357
|
}
|
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-0ff57677.cjs.js');
|
|
8
|
+
var send = require('./send-19ffc568.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]) {
|
|
@@ -539,7 +539,7 @@ class StateMachine {
|
|
|
539
539
|
spawn,
|
|
540
540
|
input: event.input
|
|
541
541
|
});
|
|
542
|
-
return guards_dist_xstateGuards.resolveActionsAndContext([send.assign(assignment)]
|
|
542
|
+
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorCtx, [send.assign(assignment)]);
|
|
543
543
|
}
|
|
544
544
|
return preInitial;
|
|
545
545
|
}
|
|
@@ -552,7 +552,7 @@ class StateMachine {
|
|
|
552
552
|
|
|
553
553
|
const preInitialState = this.getPreInitialState(actorCtx, initEvent);
|
|
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: [],
|
|
@@ -567,7 +567,7 @@ class StateMachine {
|
|
|
567
567
|
start(state) {
|
|
568
568
|
Object.values(state.children).forEach(child => {
|
|
569
569
|
if (child.status === 0) {
|
|
570
|
-
child.start
|
|
570
|
+
child.start();
|
|
571
571
|
}
|
|
572
572
|
});
|
|
573
573
|
}
|
|
@@ -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-26e4d83c.development.cjs.js');
|
|
8
|
+
var send = require('./send-894c4b18.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]) {
|
|
@@ -542,7 +542,7 @@ class StateMachine {
|
|
|
542
542
|
spawn,
|
|
543
543
|
input: event.input
|
|
544
544
|
});
|
|
545
|
-
return guards_dist_xstateGuards.resolveActionsAndContext([send.assign(assignment)]
|
|
545
|
+
return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorCtx, [send.assign(assignment)]);
|
|
546
546
|
}
|
|
547
547
|
return preInitial;
|
|
548
548
|
}
|
|
@@ -555,7 +555,7 @@ class StateMachine {
|
|
|
555
555
|
|
|
556
556
|
const preInitialState = this.getPreInitialState(actorCtx, initEvent);
|
|
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: [],
|
|
@@ -570,7 +570,7 @@ class StateMachine {
|
|
|
570
570
|
start(state) {
|
|
571
571
|
Object.values(state.children).forEach(child => {
|
|
572
572
|
if (child.status === 0) {
|
|
573
|
-
child.start
|
|
573
|
+
child.start();
|
|
574
574
|
}
|
|
575
575
|
});
|
|
576
576
|
}
|
|
@@ -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-cdcdf834.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-cdcdf834.development.esm.js';
|
|
6
|
+
import { a as assign } from './send-1de74f4d.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-1de74f4d.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]) {
|
|
@@ -541,7 +541,7 @@ class StateMachine {
|
|
|
541
541
|
spawn,
|
|
542
542
|
input: event.input
|
|
543
543
|
});
|
|
544
|
-
return resolveActionsAndContext(
|
|
544
|
+
return resolveActionsAndContext(preInitial, initEvent, actorCtx, [assign(assignment)]);
|
|
545
545
|
}
|
|
546
546
|
return preInitial;
|
|
547
547
|
}
|
|
@@ -554,7 +554,7 @@ class StateMachine {
|
|
|
554
554
|
|
|
555
555
|
const preInitialState = this.getPreInitialState(actorCtx, initEvent);
|
|
556
556
|
const nextState = microstep([{
|
|
557
|
-
target: [...
|
|
557
|
+
target: [...getInitialStateNodes(this.root)],
|
|
558
558
|
source: this.root,
|
|
559
559
|
reenter: true,
|
|
560
560
|
actions: [],
|
|
@@ -569,7 +569,7 @@ class StateMachine {
|
|
|
569
569
|
start(state) {
|
|
570
570
|
Object.values(state.children).forEach(child => {
|
|
571
571
|
if (child.status === 0) {
|
|
572
|
-
child.start
|
|
572
|
+
child.start();
|
|
573
573
|
}
|
|
574
574
|
});
|
|
575
575
|
}
|
|
@@ -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-511399cc.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-511399cc.esm.js';
|
|
6
|
+
import { a as assign } from './send-211a2a94.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-211a2a94.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]) {
|
|
@@ -538,7 +538,7 @@ class StateMachine {
|
|
|
538
538
|
spawn,
|
|
539
539
|
input: event.input
|
|
540
540
|
});
|
|
541
|
-
return resolveActionsAndContext(
|
|
541
|
+
return resolveActionsAndContext(preInitial, initEvent, actorCtx, [assign(assignment)]);
|
|
542
542
|
}
|
|
543
543
|
return preInitial;
|
|
544
544
|
}
|
|
@@ -551,7 +551,7 @@ class StateMachine {
|
|
|
551
551
|
|
|
552
552
|
const preInitialState = this.getPreInitialState(actorCtx, initEvent);
|
|
553
553
|
const nextState = microstep([{
|
|
554
|
-
target: [...
|
|
554
|
+
target: [...getInitialStateNodes(this.root)],
|
|
555
555
|
source: this.root,
|
|
556
556
|
reenter: true,
|
|
557
557
|
actions: [],
|
|
@@ -566,7 +566,7 @@ class StateMachine {
|
|
|
566
566
|
start(state) {
|
|
567
567
|
Object.values(state.children).forEach(child => {
|
|
568
568
|
if (child.status === 0) {
|
|
569
|
-
child.start
|
|
569
|
+
child.start();
|
|
570
570
|
}
|
|
571
571
|
});
|
|
572
572
|
}
|
|
@@ -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 */
|