xstate 6.0.0-alpha.47 → 6.0.0-alpha.48
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 +7 -1
- package/dist/{StateMachine-74929087.esm.js → StateMachine-8329769a.esm.js} +10 -7
- package/dist/{StateMachine-ee10f67e.development.esm.js → StateMachine-88b3c26a.development.esm.js} +10 -7
- package/dist/{StateMachine-7046f677.cjs.js → StateMachine-b09d2b00.cjs.js} +15 -12
- package/dist/{StateMachine-70c06bdd.development.cjs.js → StateMachine-b3a890bf.development.cjs.js} +15 -12
- package/dist/{createActor-915ea40c.esm.js → createActor-27287c65.esm.js} +78 -22
- package/dist/{createActor-ff132afa.development.esm.js → createActor-309d77eb.development.esm.js} +78 -22
- package/dist/{createActor-bfe8b6bd.cjs.js → createActor-9b41ade9.cjs.js} +78 -22
- package/dist/{createActor-6736cbbe.development.cjs.js → createActor-cc3d6dde.development.cjs.js} +78 -22
- package/dist/declarations/src/createMachineFromConfig.d.ts +5 -77
- package/dist/declarations/src/scxml/index.d.ts +1 -0
- package/dist/declarations/src/scxml/runtime.d.ts +251 -0
- package/dist/declarations/src/scxml/scxml.d.ts +19 -0
- package/dist/declarations/src/types.d.ts +1 -0
- package/dist/{effectDescriptor-fbe67d5a.development.esm.js → effectDescriptor-7707794b.development.esm.js} +1 -1
- package/dist/{effectDescriptor-3c699328.development.cjs.js → effectDescriptor-a1678d06.development.cjs.js} +1 -1
- package/dist/{effectDescriptor-8be60443.esm.js → effectDescriptor-b1f5deb6.esm.js} +1 -1
- package/dist/{effectDescriptor-a7e2d4d1.cjs.js → effectDescriptor-bd36a33e.cjs.js} +1 -1
- package/dist/types-1793b8b6.development.esm.js +185 -0
- package/dist/types-7e468202.development.cjs.js +189 -0
- package/dist/types-81d03bef.esm.js +185 -0
- package/dist/types-9c1bc85f.cjs.js +189 -0
- package/dist/validation-05f1d517.esm.js +8 -0
- package/dist/validation-4561b43c.cjs.js +10 -0
- package/dist/validation-e69470ad.development.esm.js +8 -0
- package/dist/validation-f2714a35.development.cjs.js +10 -0
- package/dist/xstate-actors.cjs.js +934 -9
- package/dist/xstate-actors.development.cjs.js +934 -9
- package/dist/xstate-actors.development.esm.js +932 -2
- package/dist/xstate-actors.esm.js +932 -2
- package/dist/xstate-durable.cjs.js +2 -2
- package/dist/xstate-durable.development.cjs.js +2 -2
- package/dist/xstate-durable.development.esm.js +2 -2
- package/dist/xstate-durable.esm.js +2 -2
- package/dist/xstate-graph.cjs.js +4 -3
- package/dist/xstate-graph.development.cjs.js +4 -3
- package/dist/xstate-graph.development.esm.js +4 -3
- package/dist/xstate-graph.esm.js +4 -3
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate-scxml.cjs.d.mts +2 -0
- package/dist/xstate-scxml.cjs.d.ts +2 -0
- package/dist/xstate-scxml.cjs.js +2387 -0
- package/dist/xstate-scxml.cjs.mjs +3 -0
- package/dist/xstate-scxml.development.cjs.js +2387 -0
- package/dist/xstate-scxml.development.cjs.mjs +3 -0
- package/dist/xstate-scxml.development.esm.js +2383 -0
- package/dist/xstate-scxml.esm.js +2383 -0
- package/dist/xstate-scxml.umd.min.js +26 -0
- package/dist/xstate-scxml.umd.min.js.map +1 -0
- package/dist/xstate-validation.cjs.js +1 -1
- package/dist/xstate-validation.development.cjs.js +1 -1
- package/dist/xstate-validation.development.esm.js +1 -1
- package/dist/xstate-validation.esm.js +1 -1
- package/dist/xstate.cjs.js +141 -1036
- package/dist/xstate.development.cjs.js +141 -1036
- package/dist/xstate.development.esm.js +141 -1035
- package/dist/xstate.esm.js +141 -1035
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +20 -2
- package/scxml/package.json +8 -0
- package/dist/index-0f498ef2.development.cjs.js +0 -946
- package/dist/index-70d56425.development.esm.js +0 -937
- package/dist/index-b051c924.esm.js +0 -937
- package/dist/index-b3fe59bc.cjs.js +0 -946
|
@@ -2282,7 +2282,8 @@ function resolveHistoryDefaultTransition(stateNode) {
|
|
|
2282
2282
|
target,
|
|
2283
2283
|
source: stateNode,
|
|
2284
2284
|
reenter: false,
|
|
2285
|
-
eventType: ''
|
|
2285
|
+
eventType: '',
|
|
2286
|
+
to: stateNode.config._historyDefaultTransition
|
|
2286
2287
|
};
|
|
2287
2288
|
}
|
|
2288
2289
|
function isHistoryNode(stateNode) {
|
|
@@ -2296,7 +2297,9 @@ function getInitialStateNodes(stateNode) {
|
|
|
2296
2297
|
}
|
|
2297
2298
|
set.add(descStateNode);
|
|
2298
2299
|
if (descStateNode.type === 'compound') {
|
|
2299
|
-
|
|
2300
|
+
for (const target of descStateNode.initial.target ?? []) {
|
|
2301
|
+
iter(target);
|
|
2302
|
+
}
|
|
2300
2303
|
} else if (descStateNode.type === 'parallel') {
|
|
2301
2304
|
for (const child of getChildren(descStateNode)) {
|
|
2302
2305
|
iter(child);
|
|
@@ -2549,6 +2552,18 @@ function getTransitionDomain(transition, snapshot, resolveTransition) {
|
|
|
2549
2552
|
targets,
|
|
2550
2553
|
reenter
|
|
2551
2554
|
} = resolveTransition(transition);
|
|
2555
|
+
if (transition._transitionDomain) {
|
|
2556
|
+
if (transition._transitionDomain === 'internal' && transition.source.type === 'compound' && targetStates.every(target => isDescendant(target, transition.source))) {
|
|
2557
|
+
return transition.source;
|
|
2558
|
+
}
|
|
2559
|
+
const [head, ...tail] = targetStates.concat(transition.source);
|
|
2560
|
+
for (const ancestor of getProperAncestors(head, undefined)) {
|
|
2561
|
+
if (ancestor.type === 'compound' && tail.every(stateNode => isDescendant(stateNode, ancestor))) {
|
|
2562
|
+
return ancestor;
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
return;
|
|
2566
|
+
}
|
|
2552
2567
|
|
|
2553
2568
|
// A history target that restores the source itself must exit and reenter
|
|
2554
2569
|
// the source (SCXML domain = the source's ancestor), unlike a plain
|
|
@@ -2601,12 +2616,28 @@ function computeExitSet(transitions, stateNodeSet, snapshot, resolveTransition)
|
|
|
2601
2616
|
return [...statesToExit];
|
|
2602
2617
|
}
|
|
2603
2618
|
function initialMicrostep(root, preInitialState, actorScope, initEvent, internalQueue) {
|
|
2619
|
+
const initialStateNodes = [...getInitialStateNodes(root)];
|
|
2620
|
+
const statesForDefaultEntry = new Set();
|
|
2621
|
+
const collectDefaultEntryStates = stateNode => {
|
|
2622
|
+
if (stateNode.type === 'compound') {
|
|
2623
|
+
statesForDefaultEntry.add(stateNode);
|
|
2624
|
+
for (const target of stateNode.initial.target ?? []) {
|
|
2625
|
+
collectDefaultEntryStates(target);
|
|
2626
|
+
}
|
|
2627
|
+
} else if (stateNode.type === 'parallel') {
|
|
2628
|
+
for (const child of getChildren(stateNode)) {
|
|
2629
|
+
collectDefaultEntryStates(child);
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
};
|
|
2633
|
+
collectDefaultEntryStates(root);
|
|
2604
2634
|
return microstep([{
|
|
2605
|
-
target:
|
|
2635
|
+
target: initialStateNodes.filter(stateNode => !initialStateNodes.some(other => other !== stateNode && isDescendant(other, stateNode))),
|
|
2606
2636
|
source: root,
|
|
2607
2637
|
reenter: true,
|
|
2608
2638
|
eventType: null,
|
|
2609
|
-
toJSON: null
|
|
2639
|
+
toJSON: null,
|
|
2640
|
+
_statesForDefaultEntry: [...statesForDefaultEntry]
|
|
2610
2641
|
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
2611
2642
|
}
|
|
2612
2643
|
|
|
@@ -2785,6 +2816,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2785
2816
|
// in other words, those are states for which initial actions should be executed
|
|
2786
2817
|
// when we target `#deep_child` initial actions of its ancestors shouldn't be executed
|
|
2787
2818
|
const statesForDefaultEntry = new Set();
|
|
2819
|
+
const historyDefaultsByParent = new Map();
|
|
2788
2820
|
const addAncestorStatesToEnter = (ancestors, reentrancyDomain) => {
|
|
2789
2821
|
for (const anc of ancestors) {
|
|
2790
2822
|
if (!reentrancyDomain || isDescendant(anc, reentrancyDomain)) {
|
|
@@ -2813,6 +2845,11 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2813
2845
|
}
|
|
2814
2846
|
} else {
|
|
2815
2847
|
const historyDefaultTransition = resolveHistoryDefaultTransition(stateNode);
|
|
2848
|
+
const historyParent = stateNode.parent;
|
|
2849
|
+
statesForDefaultEntry.add(historyParent);
|
|
2850
|
+
const defaults = historyDefaultsByParent.get(historyParent) ?? [];
|
|
2851
|
+
defaults.push(historyDefaultTransition);
|
|
2852
|
+
historyDefaultsByParent.set(historyParent, defaults);
|
|
2816
2853
|
const {
|
|
2817
2854
|
targets
|
|
2818
2855
|
} = getCurrentTransitionResult(historyDefaultTransition);
|
|
@@ -2830,13 +2867,19 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2830
2867
|
return;
|
|
2831
2868
|
}
|
|
2832
2869
|
if (stateNode.type === 'compound') {
|
|
2833
|
-
const
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2870
|
+
const initialStates = getCurrentTransitionResult(stateNode.initial).targets ?? [];
|
|
2871
|
+
for (const initialState of initialStates) {
|
|
2872
|
+
if (!isHistoryNode(initialState)) {
|
|
2873
|
+
statesToEnter.add(initialState);
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
statesForDefaultEntry.add(stateNode);
|
|
2877
|
+
for (const initialState of initialStates) {
|
|
2878
|
+
addDescendantStatesToEnter(initialState);
|
|
2879
|
+
}
|
|
2880
|
+
for (const initialState of initialStates) {
|
|
2881
|
+
addAncestorStatesToEnter(getProperAncestors(initialState, stateNode), undefined);
|
|
2837
2882
|
}
|
|
2838
|
-
addDescendantStatesToEnter(initialState);
|
|
2839
|
-
addAncestorStatesToEnter(getProperAncestors(initialState, stateNode), undefined);
|
|
2840
2883
|
return;
|
|
2841
2884
|
}
|
|
2842
2885
|
if (stateNode.type === 'parallel') {
|
|
@@ -2878,7 +2921,9 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2878
2921
|
}
|
|
2879
2922
|
}
|
|
2880
2923
|
if (isInitial) {
|
|
2881
|
-
|
|
2924
|
+
for (const stateNode of filteredTransitions[0]._statesForDefaultEntry ?? [currentSnapshot.machine.root]) {
|
|
2925
|
+
statesForDefaultEntry.add(stateNode);
|
|
2926
|
+
}
|
|
2882
2927
|
}
|
|
2883
2928
|
const stateInputMap = {
|
|
2884
2929
|
...currentSnapshot._stateInputs
|
|
@@ -2963,17 +3008,28 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2963
3008
|
nextState.context = context;
|
|
2964
3009
|
}
|
|
2965
3010
|
if (statesForDefaultEntry.has(stateNodeToEnter)) {
|
|
2966
|
-
const
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
3011
|
+
const defaultTransitions = [stateNodeToEnter.initial, ...(historyDefaultsByParent.get(stateNodeToEnter) ?? [])].filter(Boolean);
|
|
3012
|
+
for (const defaultTransition of defaultTransitions) {
|
|
3013
|
+
const {
|
|
3014
|
+
actions: initialActions,
|
|
3015
|
+
context: initialContext,
|
|
3016
|
+
input: initialInput,
|
|
3017
|
+
internalEvents: initialInternalEvents
|
|
3018
|
+
} = getTransitionResult(defaultTransition, nextState, event, actorScope);
|
|
3019
|
+
if (initialActions) {
|
|
3020
|
+
actions.push(...initialActions);
|
|
3021
|
+
}
|
|
3022
|
+
if (initialInternalEvents?.length) {
|
|
3023
|
+
internalQueue.push(...initialInternalEvents);
|
|
3024
|
+
}
|
|
3025
|
+
if (initialContext !== undefined) {
|
|
3026
|
+
nextState.context = mergeContextPatch(nextState.context, initialContext);
|
|
3027
|
+
}
|
|
3028
|
+
if (initialInput && defaultTransition.target) {
|
|
3029
|
+
for (const targetNode of defaultTransition.target) {
|
|
3030
|
+
stateInputMap[targetNode.id] = initialInput;
|
|
3031
|
+
stateInputsChanged = true;
|
|
3032
|
+
}
|
|
2977
3033
|
}
|
|
2978
3034
|
}
|
|
2979
3035
|
}
|
package/dist/{createActor-6736cbbe.development.cjs.js → createActor-cc3d6dde.development.cjs.js}
RENAMED
|
@@ -2300,7 +2300,8 @@ function resolveHistoryDefaultTransition(stateNode) {
|
|
|
2300
2300
|
target,
|
|
2301
2301
|
source: stateNode,
|
|
2302
2302
|
reenter: false,
|
|
2303
|
-
eventType: ''
|
|
2303
|
+
eventType: '',
|
|
2304
|
+
to: stateNode.config._historyDefaultTransition
|
|
2304
2305
|
};
|
|
2305
2306
|
}
|
|
2306
2307
|
function isHistoryNode(stateNode) {
|
|
@@ -2314,7 +2315,9 @@ function getInitialStateNodes(stateNode) {
|
|
|
2314
2315
|
}
|
|
2315
2316
|
set.add(descStateNode);
|
|
2316
2317
|
if (descStateNode.type === 'compound') {
|
|
2317
|
-
|
|
2318
|
+
for (const target of descStateNode.initial.target ?? []) {
|
|
2319
|
+
iter(target);
|
|
2320
|
+
}
|
|
2318
2321
|
} else if (descStateNode.type === 'parallel') {
|
|
2319
2322
|
for (const child of getChildren(descStateNode)) {
|
|
2320
2323
|
iter(child);
|
|
@@ -2567,6 +2570,18 @@ function getTransitionDomain(transition, snapshot, resolveTransition) {
|
|
|
2567
2570
|
targets,
|
|
2568
2571
|
reenter
|
|
2569
2572
|
} = resolveTransition(transition);
|
|
2573
|
+
if (transition._transitionDomain) {
|
|
2574
|
+
if (transition._transitionDomain === 'internal' && transition.source.type === 'compound' && targetStates.every(target => isDescendant(target, transition.source))) {
|
|
2575
|
+
return transition.source;
|
|
2576
|
+
}
|
|
2577
|
+
const [head, ...tail] = targetStates.concat(transition.source);
|
|
2578
|
+
for (const ancestor of getProperAncestors(head, undefined)) {
|
|
2579
|
+
if (ancestor.type === 'compound' && tail.every(stateNode => isDescendant(stateNode, ancestor))) {
|
|
2580
|
+
return ancestor;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2570
2585
|
|
|
2571
2586
|
// A history target that restores the source itself must exit and reenter
|
|
2572
2587
|
// the source (SCXML domain = the source's ancestor), unlike a plain
|
|
@@ -2619,12 +2634,28 @@ function computeExitSet(transitions, stateNodeSet, snapshot, resolveTransition)
|
|
|
2619
2634
|
return [...statesToExit];
|
|
2620
2635
|
}
|
|
2621
2636
|
function initialMicrostep(root, preInitialState, actorScope, initEvent, internalQueue) {
|
|
2637
|
+
const initialStateNodes = [...getInitialStateNodes(root)];
|
|
2638
|
+
const statesForDefaultEntry = new Set();
|
|
2639
|
+
const collectDefaultEntryStates = stateNode => {
|
|
2640
|
+
if (stateNode.type === 'compound') {
|
|
2641
|
+
statesForDefaultEntry.add(stateNode);
|
|
2642
|
+
for (const target of stateNode.initial.target ?? []) {
|
|
2643
|
+
collectDefaultEntryStates(target);
|
|
2644
|
+
}
|
|
2645
|
+
} else if (stateNode.type === 'parallel') {
|
|
2646
|
+
for (const child of getChildren(stateNode)) {
|
|
2647
|
+
collectDefaultEntryStates(child);
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
};
|
|
2651
|
+
collectDefaultEntryStates(root);
|
|
2622
2652
|
return microstep([{
|
|
2623
|
-
target:
|
|
2653
|
+
target: initialStateNodes.filter(stateNode => !initialStateNodes.some(other => other !== stateNode && isDescendant(other, stateNode))),
|
|
2624
2654
|
source: root,
|
|
2625
2655
|
reenter: true,
|
|
2626
2656
|
eventType: null,
|
|
2627
|
-
toJSON: null
|
|
2657
|
+
toJSON: null,
|
|
2658
|
+
_statesForDefaultEntry: [...statesForDefaultEntry]
|
|
2628
2659
|
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
2629
2660
|
}
|
|
2630
2661
|
|
|
@@ -2803,6 +2834,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2803
2834
|
// in other words, those are states for which initial actions should be executed
|
|
2804
2835
|
// when we target `#deep_child` initial actions of its ancestors shouldn't be executed
|
|
2805
2836
|
const statesForDefaultEntry = new Set();
|
|
2837
|
+
const historyDefaultsByParent = new Map();
|
|
2806
2838
|
const addAncestorStatesToEnter = (ancestors, reentrancyDomain) => {
|
|
2807
2839
|
for (const anc of ancestors) {
|
|
2808
2840
|
if (!reentrancyDomain || isDescendant(anc, reentrancyDomain)) {
|
|
@@ -2831,6 +2863,11 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2831
2863
|
}
|
|
2832
2864
|
} else {
|
|
2833
2865
|
const historyDefaultTransition = resolveHistoryDefaultTransition(stateNode);
|
|
2866
|
+
const historyParent = stateNode.parent;
|
|
2867
|
+
statesForDefaultEntry.add(historyParent);
|
|
2868
|
+
const defaults = historyDefaultsByParent.get(historyParent) ?? [];
|
|
2869
|
+
defaults.push(historyDefaultTransition);
|
|
2870
|
+
historyDefaultsByParent.set(historyParent, defaults);
|
|
2834
2871
|
const {
|
|
2835
2872
|
targets
|
|
2836
2873
|
} = getCurrentTransitionResult(historyDefaultTransition);
|
|
@@ -2848,13 +2885,19 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2848
2885
|
return;
|
|
2849
2886
|
}
|
|
2850
2887
|
if (stateNode.type === 'compound') {
|
|
2851
|
-
const
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2888
|
+
const initialStates = getCurrentTransitionResult(stateNode.initial).targets ?? [];
|
|
2889
|
+
for (const initialState of initialStates) {
|
|
2890
|
+
if (!isHistoryNode(initialState)) {
|
|
2891
|
+
statesToEnter.add(initialState);
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
statesForDefaultEntry.add(stateNode);
|
|
2895
|
+
for (const initialState of initialStates) {
|
|
2896
|
+
addDescendantStatesToEnter(initialState);
|
|
2897
|
+
}
|
|
2898
|
+
for (const initialState of initialStates) {
|
|
2899
|
+
addAncestorStatesToEnter(getProperAncestors(initialState, stateNode), undefined);
|
|
2855
2900
|
}
|
|
2856
|
-
addDescendantStatesToEnter(initialState);
|
|
2857
|
-
addAncestorStatesToEnter(getProperAncestors(initialState, stateNode), undefined);
|
|
2858
2901
|
return;
|
|
2859
2902
|
}
|
|
2860
2903
|
if (stateNode.type === 'parallel') {
|
|
@@ -2896,7 +2939,9 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2896
2939
|
}
|
|
2897
2940
|
}
|
|
2898
2941
|
if (isInitial) {
|
|
2899
|
-
|
|
2942
|
+
for (const stateNode of filteredTransitions[0]._statesForDefaultEntry ?? [currentSnapshot.machine.root]) {
|
|
2943
|
+
statesForDefaultEntry.add(stateNode);
|
|
2944
|
+
}
|
|
2900
2945
|
}
|
|
2901
2946
|
const stateInputMap = {
|
|
2902
2947
|
...currentSnapshot._stateInputs
|
|
@@ -2981,17 +3026,28 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2981
3026
|
nextState.context = context;
|
|
2982
3027
|
}
|
|
2983
3028
|
if (statesForDefaultEntry.has(stateNodeToEnter)) {
|
|
2984
|
-
const
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
3029
|
+
const defaultTransitions = [stateNodeToEnter.initial, ...(historyDefaultsByParent.get(stateNodeToEnter) ?? [])].filter(Boolean);
|
|
3030
|
+
for (const defaultTransition of defaultTransitions) {
|
|
3031
|
+
const {
|
|
3032
|
+
actions: initialActions,
|
|
3033
|
+
context: initialContext,
|
|
3034
|
+
input: initialInput,
|
|
3035
|
+
internalEvents: initialInternalEvents
|
|
3036
|
+
} = getTransitionResult(defaultTransition, nextState, event, actorScope);
|
|
3037
|
+
if (initialActions) {
|
|
3038
|
+
actions.push(...initialActions);
|
|
3039
|
+
}
|
|
3040
|
+
if (initialInternalEvents?.length) {
|
|
3041
|
+
internalQueue.push(...initialInternalEvents);
|
|
3042
|
+
}
|
|
3043
|
+
if (initialContext !== undefined) {
|
|
3044
|
+
nextState.context = mergeContextPatch(nextState.context, initialContext);
|
|
3045
|
+
}
|
|
3046
|
+
if (initialInput && defaultTransition.target) {
|
|
3047
|
+
for (const targetNode of defaultTransition.target) {
|
|
3048
|
+
stateInputMap[targetNode.id] = initialInput;
|
|
3049
|
+
stateInputsChanged = true;
|
|
3050
|
+
}
|
|
2995
3051
|
}
|
|
2996
3052
|
}
|
|
2997
3053
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { AnyActorLogic, AnyEventObject, AnyStateMachine, EventObject, MachineContext, MetaObject } from "./types.js";
|
|
2
|
-
|
|
2
|
+
interface RaiseJSON {
|
|
3
3
|
type: '@xstate.raise';
|
|
4
4
|
event: EventObject;
|
|
5
5
|
id?: string;
|
|
6
6
|
delay?: number;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface CancelJSON {
|
|
9
9
|
type: '@xstate.cancel';
|
|
10
10
|
id: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
interface LogJSON {
|
|
13
13
|
type: '@xstate.log';
|
|
14
14
|
args: any[];
|
|
15
15
|
}
|
|
@@ -21,78 +21,12 @@ interface AssignJSON {
|
|
|
21
21
|
type: '@xstate.assign';
|
|
22
22
|
context: MachineContext;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
type: 'scxml.assign';
|
|
26
|
-
/** SCXML location attribute - the context property to assign to */
|
|
27
|
-
location: string;
|
|
28
|
-
/** SCXML expr attribute - expression to evaluate */
|
|
29
|
-
expr: string;
|
|
30
|
-
}
|
|
31
|
-
export interface ScxmlRaiseJSON {
|
|
32
|
-
type: 'scxml.raise';
|
|
33
|
-
/** Event type, or undefined if using eventexpr */
|
|
34
|
-
event?: string;
|
|
35
|
-
/** Expression to evaluate for event type */
|
|
36
|
-
eventexpr?: string;
|
|
37
|
-
/** Params with expressions to evaluate */
|
|
38
|
-
params?: Array<{
|
|
39
|
-
name: string;
|
|
40
|
-
expr: string;
|
|
41
|
-
}>;
|
|
42
|
-
id?: string;
|
|
43
|
-
delay?: number;
|
|
44
|
-
/** Expression for delay */
|
|
45
|
-
delayexpr?: string;
|
|
46
|
-
/** Static target (e.g. '#_parent') */
|
|
47
|
-
target?: string;
|
|
48
|
-
/** Expression for target */
|
|
49
|
-
targetexpr?: string;
|
|
50
|
-
}
|
|
51
|
-
interface ScxmlScriptJSON {
|
|
52
|
-
type: 'scxml.script';
|
|
53
|
-
/** The script code to execute */
|
|
54
|
-
code: string;
|
|
55
|
-
}
|
|
56
|
-
export interface ScxmlForeachJSON {
|
|
57
|
-
type: 'scxml.foreach';
|
|
58
|
-
array: string;
|
|
59
|
-
item: string;
|
|
60
|
-
index?: string;
|
|
61
|
-
actions: ActionJSON[];
|
|
62
|
-
}
|
|
63
|
-
export interface ScxmlCancelJSON {
|
|
64
|
-
type: 'scxml.cancel';
|
|
65
|
-
sendidexpr: string;
|
|
66
|
-
}
|
|
67
|
-
export interface ScxmlDonedataJSON {
|
|
68
|
-
params?: Array<{
|
|
69
|
-
name: string;
|
|
70
|
-
expr: string;
|
|
71
|
-
}>;
|
|
72
|
-
contentExpr?: string;
|
|
73
|
-
contentText?: string;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Isolated executable-content block. Errors in nested actions stop this block
|
|
77
|
-
* but do not propagate to the surrounding action list. Used to model SCXML's
|
|
78
|
-
* separate <onentry>/<onexit> blocks: each is its own block per spec.
|
|
79
|
-
*/
|
|
80
|
-
interface ScxmlBlockJSON {
|
|
81
|
-
type: 'scxml.block';
|
|
82
|
-
actions: ActionJSON[];
|
|
83
|
-
}
|
|
84
|
-
interface ScxmlIfJSON {
|
|
85
|
-
type: 'scxml.if';
|
|
86
|
-
branches: Array<{
|
|
87
|
-
cond?: string;
|
|
88
|
-
actions: ActionJSON[];
|
|
89
|
-
}>;
|
|
90
|
-
}
|
|
24
|
+
type BuiltInActionJSON = RaiseJSON | CancelJSON | LogJSON | EmitJSON | AssignJSON;
|
|
91
25
|
interface CustomActionJSON {
|
|
92
26
|
type: string;
|
|
93
27
|
params?: unknown;
|
|
94
28
|
}
|
|
95
|
-
export type ActionJSON = CustomActionJSON |
|
|
29
|
+
export type ActionJSON = CustomActionJSON | BuiltInActionJSON | ExpressionJSON | CodeJSON;
|
|
96
30
|
export interface GuardJSON {
|
|
97
31
|
type: string;
|
|
98
32
|
params?: unknown;
|
|
@@ -150,11 +84,6 @@ export interface StateNodeJSON {
|
|
|
150
84
|
after?: Record<string, TransitionConfigJSON | TransitionConfigJSON[]>;
|
|
151
85
|
always?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
152
86
|
choice?: ChoiceBranchJSON[] | ResolvableJSON;
|
|
153
|
-
/**
|
|
154
|
-
* JSON route config. Unlike the authoring API (a function), the JSON layer
|
|
155
|
-
* allows an object form whose `guard` may be a named guard reference (string)
|
|
156
|
-
* resolved against the machine's `guards` sources.
|
|
157
|
-
*/
|
|
158
87
|
route?: {
|
|
159
88
|
description?: string;
|
|
160
89
|
reenter?: boolean;
|
|
@@ -175,7 +104,6 @@ export interface StateNodeJSON {
|
|
|
175
104
|
target?: string | [string, ...string[]];
|
|
176
105
|
output?: unknown;
|
|
177
106
|
context?: Record<string, unknown>;
|
|
178
|
-
_scxmlDonedata?: ScxmlDonedataJSON;
|
|
179
107
|
}
|
|
180
108
|
export interface MachineJSON extends StateNodeJSON {
|
|
181
109
|
'@exprLang'?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMachineFromSCXML, type SCXMLConversionOptions } from "./scxml.js";
|