xstate 5.0.0-beta.34 → 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 +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/interpreter.d.ts +2 -0
- package/dist/declarations/src/stateUtils.d.ts +5 -4
- package/dist/declarations/src/types.d.ts +3 -5
- 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-1dd65455.cjs.js → raise-0ff57677.cjs.js} +100 -99
- package/dist/{raise-38b707c0.development.cjs.js → raise-26e4d83c.development.cjs.js} +103 -99
- package/dist/{raise-b5cfe1bb.esm.js → raise-511399cc.esm.js} +100 -99
- package/dist/{raise-05f8b2a6.development.esm.js → raise-cdcdf834.development.esm.js} +103 -99
- package/dist/{send-fe94de2b.cjs.js → send-19ffc568.cjs.js} +4 -2
- package/dist/{send-9526366e.development.esm.js → send-1de74f4d.development.esm.js} +4 -2
- package/dist/{send-0b5eda0c.esm.js → send-211a2a94.esm.js} +4 -2
- package/dist/{send-3764c866.development.cjs.js → send-894c4b18.development.cjs.js} +4 -2
- package/dist/xstate.cjs.js +26 -7
- package/dist/xstate.development.cjs.js +26 -7
- package/dist/xstate.development.esm.js +29 -10
- package/dist/xstate.esm.js +29 -10
- 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,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveReferencedActor, d as createActor, f as ActorStatus, j as createErrorActorEvent, k as toStateValue, l as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, o as toStatePath, q as createDoneStateEvent, s as resolveOutput, W as WILDCARD, X as XSTATE_STOP, u as XSTATE_INIT, v as
|
|
1
|
+
import { r as resolveReferencedActor, d as createActor, f as ActorStatus, j as createErrorActorEvent, k as toStateValue, l as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, o as toStatePath, q as createDoneStateEvent, s as resolveOutput, W as WILDCARD, X as XSTATE_STOP, u as XSTATE_INIT, v as createAfterEvent, w as flatten, e as matchesState, $ as $$ACTOR_TYPE } from './interpreter-5c4e6634.development.esm.js';
|
|
2
2
|
|
|
3
3
|
const cache = new WeakMap();
|
|
4
4
|
function memo(object, key, fn) {
|
|
@@ -297,20 +297,6 @@ function evaluateGuard(guard, context, event, state) {
|
|
|
297
297
|
);
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
function getOutput(configuration, context, event, self) {
|
|
301
|
-
const {
|
|
302
|
-
machine
|
|
303
|
-
} = configuration[0];
|
|
304
|
-
const {
|
|
305
|
-
root
|
|
306
|
-
} = machine;
|
|
307
|
-
if (!root.output) {
|
|
308
|
-
return undefined;
|
|
309
|
-
}
|
|
310
|
-
const finalChildStateNode = configuration.find(stateNode => stateNode.type === 'final' && stateNode.parent === machine.root);
|
|
311
|
-
const doneStateEvent = createDoneStateEvent(finalChildStateNode.id, finalChildStateNode.output ? resolveOutput(finalChildStateNode.output, context, event, self) : undefined);
|
|
312
|
-
return resolveOutput(root.output, context, doneStateEvent, self);
|
|
313
|
-
}
|
|
314
300
|
const isAtomicStateNode = stateNode => stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
315
301
|
function getChildren(stateNode) {
|
|
316
302
|
return Object.values(stateNode.states).filter(sn => sn.type !== 'history');
|
|
@@ -335,7 +321,7 @@ function getConfiguration(stateNodes) {
|
|
|
335
321
|
for (const s of configuration) {
|
|
336
322
|
// if previously active, add existing child nodes
|
|
337
323
|
if (s.type === 'compound' && (!adjList.get(s) || !adjList.get(s).length)) {
|
|
338
|
-
|
|
324
|
+
getInitialStateNodesWithTheirAncestors(s).forEach(sn => configurationSet.add(sn));
|
|
339
325
|
} else {
|
|
340
326
|
if (s.type === 'parallel') {
|
|
341
327
|
for (const child of getChildren(s)) {
|
|
@@ -343,7 +329,8 @@ function getConfiguration(stateNodes) {
|
|
|
343
329
|
continue;
|
|
344
330
|
}
|
|
345
331
|
if (!configurationSet.has(child)) {
|
|
346
|
-
|
|
332
|
+
const initialStates = getInitialStateNodesWithTheirAncestors(child);
|
|
333
|
+
for (const initialStateNode of initialStates) {
|
|
347
334
|
configurationSet.add(initialStateNode);
|
|
348
335
|
}
|
|
349
336
|
}
|
|
@@ -403,14 +390,14 @@ function getStateValue(rootNode, configuration) {
|
|
|
403
390
|
const config = getConfiguration(configuration);
|
|
404
391
|
return getValueFromAdj(rootNode, getAdjList(config));
|
|
405
392
|
}
|
|
406
|
-
function isInFinalState(configuration, stateNode
|
|
393
|
+
function isInFinalState(configuration, stateNode) {
|
|
407
394
|
if (stateNode.type === 'compound') {
|
|
408
|
-
return getChildren(stateNode).some(s => s.type === 'final' && configuration.
|
|
395
|
+
return getChildren(stateNode).some(s => s.type === 'final' && configuration.has(s));
|
|
409
396
|
}
|
|
410
397
|
if (stateNode.type === 'parallel') {
|
|
411
398
|
return getChildren(stateNode).every(sn => isInFinalState(configuration, sn));
|
|
412
399
|
}
|
|
413
|
-
return
|
|
400
|
+
return stateNode.type === 'final';
|
|
414
401
|
}
|
|
415
402
|
const isStateId = str => str[0] === STATE_IDENTIFIER;
|
|
416
403
|
function getCandidates(stateNode, receivedEventType) {
|
|
@@ -466,13 +453,7 @@ function getDelayedTransitions(stateNode) {
|
|
|
466
453
|
stateNode.exit.push(cancel(eventType));
|
|
467
454
|
return eventType;
|
|
468
455
|
};
|
|
469
|
-
const delayedTransitions =
|
|
470
|
-
const eventType = mutateEntryExit(transition.delay, i);
|
|
471
|
-
return {
|
|
472
|
-
...transition,
|
|
473
|
-
event: eventType
|
|
474
|
-
};
|
|
475
|
-
}) : Object.keys(afterConfig).flatMap((delay, i) => {
|
|
456
|
+
const delayedTransitions = Object.keys(afterConfig).flatMap((delay, i) => {
|
|
476
457
|
const configTransition = afterConfig[delay];
|
|
477
458
|
const resolvedTransition = typeof configTransition === 'string' ? {
|
|
478
459
|
target: configTransition
|
|
@@ -560,43 +541,23 @@ function formatTransitions(stateNode) {
|
|
|
560
541
|
return transitions;
|
|
561
542
|
}
|
|
562
543
|
function formatInitialTransition(stateNode, _target) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
// to their state node
|
|
567
|
-
const descStateNode = typeof t === 'string' ? isStateId(t) ? stateNode.machine.getStateNodeById(t) : stateNode.states[t] : t;
|
|
568
|
-
if (!descStateNode) {
|
|
569
|
-
throw new Error(`Initial state node "${t}" not found on parent state node #${stateNode.id}`);
|
|
570
|
-
}
|
|
571
|
-
if (!isDescendant(descStateNode, stateNode)) {
|
|
572
|
-
throw new Error(`Invalid initial target: state node #${descStateNode.id} is not a descendant of #${stateNode.id}`);
|
|
573
|
-
}
|
|
574
|
-
return descStateNode;
|
|
575
|
-
});
|
|
576
|
-
const resolvedTarget = resolveTarget(stateNode, targets);
|
|
577
|
-
const transition = {
|
|
578
|
-
source: stateNode,
|
|
579
|
-
actions: [],
|
|
580
|
-
eventType: null,
|
|
581
|
-
reenter: false,
|
|
582
|
-
target: resolvedTarget,
|
|
583
|
-
toJSON: () => ({
|
|
584
|
-
...transition,
|
|
585
|
-
source: `#${stateNode.id}`,
|
|
586
|
-
target: resolvedTarget ? resolvedTarget.map(t => `#${t.id}`) : undefined
|
|
587
|
-
})
|
|
588
|
-
};
|
|
589
|
-
return transition;
|
|
544
|
+
const resolvedTarget = typeof _target === 'string' ? stateNode.states[_target] : _target ? stateNode.states[_target.target] : undefined;
|
|
545
|
+
if (!resolvedTarget && _target) {
|
|
546
|
+
throw new Error(`Initial state node "${_target}" not found on parent state node #${stateNode.id}`);
|
|
590
547
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
548
|
+
const transition = {
|
|
549
|
+
source: stateNode,
|
|
550
|
+
actions: !_target || typeof _target === 'string' ? [] : toArray(_target.actions),
|
|
551
|
+
eventType: null,
|
|
552
|
+
reenter: false,
|
|
553
|
+
target: resolvedTarget ? [resolvedTarget] : [],
|
|
554
|
+
toJSON: () => ({
|
|
555
|
+
...transition,
|
|
556
|
+
source: `#${stateNode.id}`,
|
|
557
|
+
target: resolvedTarget ? [`#${resolvedTarget.id}`] : []
|
|
558
|
+
})
|
|
559
|
+
};
|
|
560
|
+
return transition;
|
|
600
561
|
}
|
|
601
562
|
function resolveTarget(stateNode, targets) {
|
|
602
563
|
if (targets === undefined) {
|
|
@@ -639,6 +600,15 @@ function resolveHistoryTarget(stateNode) {
|
|
|
639
600
|
function isHistoryNode(stateNode) {
|
|
640
601
|
return stateNode.type === 'history';
|
|
641
602
|
}
|
|
603
|
+
function getInitialStateNodesWithTheirAncestors(stateNode) {
|
|
604
|
+
const states = getInitialStateNodes(stateNode);
|
|
605
|
+
for (const initialState of states) {
|
|
606
|
+
for (const ancestor of getProperAncestors(initialState, stateNode)) {
|
|
607
|
+
states.add(ancestor);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return states;
|
|
611
|
+
}
|
|
642
612
|
function getInitialStateNodes(stateNode) {
|
|
643
613
|
const set = new Set();
|
|
644
614
|
function iter(descStateNode) {
|
|
@@ -647,12 +617,7 @@ function getInitialStateNodes(stateNode) {
|
|
|
647
617
|
}
|
|
648
618
|
set.add(descStateNode);
|
|
649
619
|
if (descStateNode.type === 'compound') {
|
|
650
|
-
|
|
651
|
-
for (const a of getProperAncestors(targetStateNode, stateNode)) {
|
|
652
|
-
set.add(a);
|
|
653
|
-
}
|
|
654
|
-
iter(targetStateNode);
|
|
655
|
-
}
|
|
620
|
+
iter(descStateNode.initial.target[0]);
|
|
656
621
|
} else if (descStateNode.type === 'parallel') {
|
|
657
622
|
for (const child of getChildren(descStateNode)) {
|
|
658
623
|
iter(child);
|
|
@@ -660,7 +625,7 @@ function getInitialStateNodes(stateNode) {
|
|
|
660
625
|
}
|
|
661
626
|
}
|
|
662
627
|
iter(stateNode);
|
|
663
|
-
return
|
|
628
|
+
return set;
|
|
664
629
|
}
|
|
665
630
|
/**
|
|
666
631
|
* Returns the child state node from its relative `stateKey`, or throws.
|
|
@@ -938,21 +903,15 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
|
|
|
938
903
|
// Enter states
|
|
939
904
|
nextState = enterStates(nextState, event, actorCtx, filteredTransitions, mutConfiguration, internalQueue, historyValue, isInitial);
|
|
940
905
|
const nextConfiguration = [...mutConfiguration];
|
|
941
|
-
|
|
942
|
-
if (done) {
|
|
906
|
+
if (nextState.status === 'done') {
|
|
943
907
|
nextState = resolveActionsAndContext(nextState, event, actorCtx, nextConfiguration.sort((a, b) => b.order - a.order).flatMap(state => state.exit));
|
|
944
908
|
}
|
|
945
909
|
try {
|
|
946
|
-
const output = done ? getOutput(nextConfiguration, nextState.context, event, actorCtx.self) : undefined;
|
|
947
910
|
internalQueue.push(...nextState._internalQueue);
|
|
948
|
-
return cloneState(
|
|
911
|
+
return cloneState(nextState, {
|
|
949
912
|
configuration: nextConfiguration,
|
|
950
913
|
historyValue,
|
|
951
|
-
_internalQueue: internalQueue
|
|
952
|
-
context: nextState.context,
|
|
953
|
-
status: done ? 'done' : currentState.status,
|
|
954
|
-
output,
|
|
955
|
-
children: nextState.children
|
|
914
|
+
_internalQueue: internalQueue
|
|
956
915
|
});
|
|
957
916
|
} catch (e) {
|
|
958
917
|
// TODO: Refactor this once proper error handling is implemented.
|
|
@@ -960,6 +919,13 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
|
|
|
960
919
|
throw e;
|
|
961
920
|
}
|
|
962
921
|
}
|
|
922
|
+
function getMachineOutput(state, event, actorCtx, rootNode, rootCompletionNode) {
|
|
923
|
+
if (!rootNode.output) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
const doneStateEvent = createDoneStateEvent(rootCompletionNode.id, rootCompletionNode.output && rootCompletionNode.parent ? resolveOutput(rootCompletionNode.output, state.context, event, actorCtx.self) : undefined);
|
|
927
|
+
return resolveOutput(rootNode.output, state.context, doneStateEvent, actorCtx.self);
|
|
928
|
+
}
|
|
963
929
|
function enterStates(currentState, event, actorCtx, filteredTransitions, mutConfiguration, internalQueue, historyValue, isInitial) {
|
|
964
930
|
let nextState = currentState;
|
|
965
931
|
const statesToEnter = new Set();
|
|
@@ -970,6 +936,7 @@ function enterStates(currentState, event, actorCtx, filteredTransitions, mutConf
|
|
|
970
936
|
if (isInitial) {
|
|
971
937
|
statesForDefaultEntry.add(currentState.machine.root);
|
|
972
938
|
}
|
|
939
|
+
const completedNodes = new Set();
|
|
973
940
|
for (const stateNodeToEnter of [...statesToEnter].sort((a, b) => a.order - b.order)) {
|
|
974
941
|
mutConfiguration.add(stateNodeToEnter);
|
|
975
942
|
const actions = [];
|
|
@@ -980,26 +947,34 @@ function enterStates(currentState, event, actorCtx, filteredTransitions, mutConf
|
|
|
980
947
|
actions.push(invoke(invokeDef));
|
|
981
948
|
}
|
|
982
949
|
if (statesForDefaultEntry.has(stateNodeToEnter)) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
actions.push(...initialActions);
|
|
986
|
-
}
|
|
950
|
+
const initialActions = stateNodeToEnter.initial.actions;
|
|
951
|
+
actions.push(...initialActions);
|
|
987
952
|
}
|
|
988
953
|
nextState = resolveActionsAndContext(nextState, event, actorCtx, actions, stateNodeToEnter.invoke.map(invokeDef => invokeDef.id));
|
|
989
954
|
if (stateNodeToEnter.type === 'final') {
|
|
990
955
|
const parent = stateNodeToEnter.parent;
|
|
991
|
-
if (
|
|
956
|
+
if (completedNodes.has(parent)) {
|
|
992
957
|
continue;
|
|
993
958
|
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
959
|
+
completedNodes.add(parent);
|
|
960
|
+
let rootCompletionNode = parent?.type === 'parallel' ? parent : stateNodeToEnter;
|
|
961
|
+
let ancestorMarker = parent?.parent;
|
|
962
|
+
if (ancestorMarker) {
|
|
963
|
+
internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output ? resolveOutput(stateNodeToEnter.output, nextState.context, event, actorCtx.self) : undefined));
|
|
964
|
+
while (ancestorMarker?.type === 'parallel' && !completedNodes.has(ancestorMarker) && isInFinalState(mutConfiguration, ancestorMarker)) {
|
|
965
|
+
completedNodes.add(ancestorMarker);
|
|
966
|
+
internalQueue.push(createDoneStateEvent(ancestorMarker.id));
|
|
967
|
+
rootCompletionNode = ancestorMarker;
|
|
968
|
+
ancestorMarker = ancestorMarker.parent;
|
|
1001
969
|
}
|
|
1002
970
|
}
|
|
971
|
+
if (ancestorMarker) {
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
nextState = cloneState(nextState, {
|
|
975
|
+
status: 'done',
|
|
976
|
+
output: getMachineOutput(nextState, event, actorCtx, currentState.configuration[0].machine.root, rootCompletionNode)
|
|
977
|
+
});
|
|
1003
978
|
}
|
|
1004
979
|
}
|
|
1005
980
|
return nextState;
|
|
@@ -1045,13 +1020,9 @@ function addDescendantStatesToEnter(stateNode, historyValue, statesForDefaultEnt
|
|
|
1045
1020
|
statesToEnter.add(stateNode);
|
|
1046
1021
|
if (stateNode.type === 'compound') {
|
|
1047
1022
|
statesForDefaultEntry.add(stateNode);
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
for (const initialState of initialStates) {
|
|
1053
|
-
addAncestorStatesToEnter(initialState, stateNode, statesToEnter, historyValue, statesForDefaultEntry);
|
|
1054
|
-
}
|
|
1023
|
+
const [initialState] = stateNode.initial.target;
|
|
1024
|
+
addDescendantStatesToEnter(initialState, historyValue, statesForDefaultEntry, statesToEnter);
|
|
1025
|
+
addAncestorStatesToEnter(initialState, stateNode, statesToEnter, historyValue, statesForDefaultEntry);
|
|
1055
1026
|
} else {
|
|
1056
1027
|
if (stateNode.type === 'parallel') {
|
|
1057
1028
|
for (const child of getChildren(stateNode).filter(sn => !isHistoryNode(sn))) {
|
|
@@ -1445,11 +1416,15 @@ function getPersistedState(state) {
|
|
|
1445
1416
|
tags,
|
|
1446
1417
|
machine,
|
|
1447
1418
|
children,
|
|
1419
|
+
context,
|
|
1448
1420
|
...jsonValues
|
|
1449
1421
|
} = state;
|
|
1450
1422
|
const childrenJson = {};
|
|
1451
1423
|
for (const id in children) {
|
|
1452
1424
|
const child = children[id];
|
|
1425
|
+
if (typeof child.src !== 'string') {
|
|
1426
|
+
throw new Error('An inline child actor cannot be persisted.');
|
|
1427
|
+
}
|
|
1453
1428
|
childrenJson[id] = {
|
|
1454
1429
|
state: child.getPersistedState?.(),
|
|
1455
1430
|
src: child.src
|
|
@@ -1457,9 +1432,38 @@ function getPersistedState(state) {
|
|
|
1457
1432
|
}
|
|
1458
1433
|
return {
|
|
1459
1434
|
...jsonValues,
|
|
1435
|
+
// TODO: this makes `PersistedMachineState`'s type kind of a lie
|
|
1436
|
+
// it doesn't truly use `TContext` but rather some kind of a derived form of it
|
|
1437
|
+
context: persistContext(context),
|
|
1460
1438
|
children: childrenJson
|
|
1461
1439
|
};
|
|
1462
1440
|
}
|
|
1441
|
+
function persistContext(contextPart) {
|
|
1442
|
+
let copy;
|
|
1443
|
+
for (const key in contextPart) {
|
|
1444
|
+
const value = contextPart[key];
|
|
1445
|
+
if (value && typeof value === 'object') {
|
|
1446
|
+
if ('sessionId' in value && 'send' in value && 'ref' in value) {
|
|
1447
|
+
copy ??= Array.isArray(contextPart) ? contextPart.slice() : {
|
|
1448
|
+
...contextPart
|
|
1449
|
+
};
|
|
1450
|
+
copy[key] = {
|
|
1451
|
+
xstate$$type: $$ACTOR_TYPE,
|
|
1452
|
+
id: value.id
|
|
1453
|
+
};
|
|
1454
|
+
} else {
|
|
1455
|
+
const result = persistContext(value);
|
|
1456
|
+
if (result !== value) {
|
|
1457
|
+
copy ??= Array.isArray(contextPart) ? contextPart.slice() : {
|
|
1458
|
+
...contextPart
|
|
1459
|
+
};
|
|
1460
|
+
copy[key] = result;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
return copy ?? contextPart;
|
|
1466
|
+
}
|
|
1463
1467
|
|
|
1464
1468
|
function resolveRaise(_, state, args, {
|
|
1465
1469
|
event: eventOrExpr,
|
|
@@ -1513,4 +1517,4 @@ function raise(eventOrExpr, options) {
|
|
|
1513
1517
|
return raise;
|
|
1514
1518
|
}
|
|
1515
1519
|
|
|
1516
|
-
export { raise as A, stop as B, State as S, formatTransition as a, formatInitialTransition as b, getCandidates as c, getConfiguration as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getStateNodes as h, isInFinalState as i, cloneState as j, macrostep as k, getInitialConfiguration as l, memo as m, resolveActionsAndContext as n, microstep as o,
|
|
1520
|
+
export { raise as A, stop as B, State as S, formatTransition as a, formatInitialTransition as b, getCandidates as c, getConfiguration as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getStateNodes as h, isInFinalState as i, cloneState as j, macrostep as k, getInitialConfiguration as l, memo as m, resolveActionsAndContext as n, microstep as o, getInitialStateNodes as p, isStateId as q, resolveStateValue as r, getStateNodeByPath as s, transitionNode as t, getPersistedState as u, and as v, not as w, or as x, stateIn as y, cancel as z };
|
|
@@ -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-0ff57677.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-69605bf0.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) {
|
|
@@ -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-cdcdf834.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) {
|
|
@@ -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-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) {
|
|
@@ -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) {
|
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]) {
|
|
@@ -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: [],
|
|
@@ -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]) {
|
|
@@ -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: [],
|
|
@@ -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]) {
|
|
@@ -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: [],
|
|
@@ -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 */
|