xstate 6.0.0-alpha.52 → 6.0.0-alpha.54
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/dist/{createActor-41e3bbc3.development.esm.js → createActor-04e2ee20.development.esm.js} +27 -10
- package/dist/{createActor-20277025.cjs.js → createActor-54b4caed.cjs.js} +27 -10
- package/dist/{createActor-4d94dd53.development.cjs.js → createActor-72c06d5c.development.cjs.js} +27 -10
- package/dist/{createActor-6fa87eea.esm.js → createActor-a7b9d1be.esm.js} +27 -10
- package/dist/declarations/src/StateMachine.d.ts +6 -6
- package/dist/declarations/src/StateNode.d.ts +14 -14
- package/dist/declarations/src/createActor.d.ts +2 -2
- package/dist/declarations/src/createMachine.d.ts +7 -6
- package/dist/declarations/src/graph/types.d.ts +1 -3
- package/dist/declarations/src/machineVersions.d.ts +2 -10
- package/dist/declarations/src/setup.d.ts +46 -34
- package/dist/declarations/src/transitionActions.d.ts +1 -1
- package/dist/declarations/src/types.d.ts +59 -18
- package/dist/declarations/src/types.v6.d.ts +52 -51
- package/dist/{effectDescriptor-fa21710c.cjs.js → effectDescriptor-66968b91.cjs.js} +1 -1
- package/dist/{effectDescriptor-e64efd18.development.esm.js → effectDescriptor-8ab6c005.development.esm.js} +1 -1
- package/dist/{effectDescriptor-c56bd9d5.esm.js → effectDescriptor-de20c07d.esm.js} +1 -1
- package/dist/{effectDescriptor-6991ab90.development.cjs.js → effectDescriptor-ff81f016.development.cjs.js} +1 -1
- package/dist/{types-84a9c6a1.development.cjs.js → types-2dc94fbf.development.cjs.js} +39 -3
- package/dist/{types-5d934c5c.cjs.js → types-744035f0.cjs.js} +39 -3
- package/dist/{types-ab7eb7a3.esm.js → types-a388ae30.esm.js} +39 -3
- package/dist/{types-63cc2400.development.esm.js → types-e1c553c1.development.esm.js} +39 -3
- package/dist/xstate-actors.cjs.js +1 -1
- package/dist/xstate-actors.development.cjs.js +1 -1
- package/dist/xstate-actors.development.esm.js +2 -2
- package/dist/xstate-actors.esm.js +2 -2
- package/dist/xstate-actors.umd.min.js.map +1 -1
- 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-durable.umd.min.js.map +1 -1
- package/dist/xstate-graph.cjs.js +1 -1
- package/dist/xstate-graph.development.cjs.js +1 -1
- package/dist/xstate-graph.development.esm.js +1 -1
- package/dist/xstate-graph.esm.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate-scxml.cjs.js +2 -2
- package/dist/xstate-scxml.development.cjs.js +2 -2
- package/dist/xstate-scxml.development.esm.js +2 -2
- package/dist/xstate-scxml.esm.js +2 -2
- package/dist/xstate-scxml.umd.min.js +1 -1
- package/dist/xstate-scxml.umd.min.js.map +1 -1
- 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 +3 -3
- package/dist/xstate.development.cjs.js +3 -3
- package/dist/xstate.development.esm.js +5 -5
- package/dist/xstate.esm.js +5 -5
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/{createActor-41e3bbc3.development.esm.js → createActor-04e2ee20.development.esm.js}
RENAMED
|
@@ -1177,7 +1177,7 @@ async function executeEffects(effects, runtime) {
|
|
|
1177
1177
|
await effect.exec(runtime);
|
|
1178
1178
|
}
|
|
1179
1179
|
}
|
|
1180
|
-
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions) {
|
|
1180
|
+
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions, internalEvents) {
|
|
1181
1181
|
let intermediateSnapshot = currentSnapshot;
|
|
1182
1182
|
const executableActions = [];
|
|
1183
1183
|
for (const action of actions) {
|
|
@@ -1201,7 +1201,20 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
1201
1201
|
};
|
|
1202
1202
|
const isInline = typeof action === 'function';
|
|
1203
1203
|
const actionRecord = getTransitionActionRecord(action);
|
|
1204
|
-
|
|
1204
|
+
let resolvedActionArgs = actionRecord?.args;
|
|
1205
|
+
if (actionRecord?.action === builtInActions['@xstate.sendTo'] && typeof actionRecord.args[1] === 'string') {
|
|
1206
|
+
const childId = actionRecord.args[1];
|
|
1207
|
+
const target = Object.hasOwn(intermediateSnapshot.children, childId) ? intermediateSnapshot.children[childId] : undefined;
|
|
1208
|
+
if (!target) {
|
|
1209
|
+
internalEvents?.push(createErrorPlatformEvent('communication', {
|
|
1210
|
+
message: `Unable to send event to unknown child '${childId}'`,
|
|
1211
|
+
event: actionRecord.args[2]
|
|
1212
|
+
}));
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
resolvedActionArgs = [actionRecord.args[0], target, ...actionRecord.args.slice(2)];
|
|
1216
|
+
}
|
|
1217
|
+
const resolvedAction = isInline ? action : actionRecord ? actionRecord.action.bind(null, ...resolvedActionArgs) : false;
|
|
1205
1218
|
let actionParams = undefined;
|
|
1206
1219
|
if (typeof action === 'object' && action !== null) {
|
|
1207
1220
|
const {
|
|
@@ -1242,13 +1255,13 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
1242
1255
|
continue;
|
|
1243
1256
|
}
|
|
1244
1257
|
if (!resolvedAction || !('resolve' in resolvedAction)) {
|
|
1245
|
-
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action,
|
|
1258
|
+
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action, resolvedActionArgs) : undefined;
|
|
1246
1259
|
const isEmittedEvent = typeof action === 'object' && action !== null && !actionRecord;
|
|
1247
1260
|
const executableAction = {
|
|
1248
1261
|
kind: builtInFields ? 'builtin' : isEmittedEvent ? 'emit' : 'action',
|
|
1249
1262
|
type: typeof action === 'object' ? 'action' in action && typeof action.action === 'function' ? action.action.name ?? '(anonymous)' : action.type : action.name || '(anonymous)',
|
|
1250
1263
|
params: builtInFields ? undefined : actionParams,
|
|
1251
|
-
args: typeof action === 'object' && 'action' in action ?
|
|
1264
|
+
args: typeof action === 'object' && 'action' in action ? resolvedActionArgs : [],
|
|
1252
1265
|
...(builtInFields ? {} : isEmittedEvent ? {
|
|
1253
1266
|
source: actorScope.self,
|
|
1254
1267
|
event: action
|
|
@@ -2796,12 +2809,12 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2796
2809
|
context: nextContext
|
|
2797
2810
|
});
|
|
2798
2811
|
}
|
|
2799
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, exitActions);
|
|
2812
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, exitActions, internalQueue);
|
|
2800
2813
|
nextState = resolvedState;
|
|
2801
2814
|
executableActions.push(...resolvedActions);
|
|
2802
2815
|
const invokeStopActions = getInvokeStopActions(exitStateNode, nextState.children);
|
|
2803
2816
|
if (invokeStopActions.length) {
|
|
2804
|
-
const [stoppedState, stopEffects] = resolveActionsWithContext(nextState, event, actorScope, invokeStopActions);
|
|
2817
|
+
const [stoppedState, stopEffects] = resolveActionsWithContext(nextState, event, actorScope, invokeStopActions, internalQueue);
|
|
2805
2818
|
nextState = stoppedState;
|
|
2806
2819
|
executableActions.push(...stopEffects);
|
|
2807
2820
|
}
|
|
@@ -2932,14 +2945,18 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2932
2945
|
}
|
|
2933
2946
|
}
|
|
2934
2947
|
};
|
|
2948
|
+
const enteredTargetsByTransition = new Map();
|
|
2935
2949
|
for (const transition of filteredTransitions) {
|
|
2936
2950
|
const domain = getTransitionDomain(transition, currentSnapshot, getCurrentTransitionResult);
|
|
2937
2951
|
const {
|
|
2938
2952
|
targets,
|
|
2939
2953
|
reenter
|
|
2940
2954
|
} = getCurrentTransitionResult(transition);
|
|
2955
|
+
const enteredTargets = new Set();
|
|
2956
|
+
enteredTargetsByTransition.set(transition, enteredTargets);
|
|
2941
2957
|
for (const targetNode of targets ?? []) {
|
|
2942
2958
|
if (!isHistoryNode(targetNode) && (transition.source !== targetNode || transition.source !== domain || reenter)) {
|
|
2959
|
+
enteredTargets.add(targetNode);
|
|
2943
2960
|
statesToEnter.add(targetNode);
|
|
2944
2961
|
statesForDefaultEntry.add(targetNode);
|
|
2945
2962
|
}
|
|
@@ -2975,7 +2992,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2975
2992
|
input
|
|
2976
2993
|
} = getCurrentTransitionResult(transition);
|
|
2977
2994
|
if (input && targets) {
|
|
2978
|
-
for (const targetNode of targets) {
|
|
2995
|
+
for (const targetNode of targets.filter(targetNode => enteredTargetsByTransition.get(transition)?.has(targetNode))) {
|
|
2979
2996
|
stateInputMap[targetNode.id] = input;
|
|
2980
2997
|
stateInputsChanged = true;
|
|
2981
2998
|
}
|
|
@@ -3074,7 +3091,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3074
3091
|
}
|
|
3075
3092
|
}
|
|
3076
3093
|
}
|
|
3077
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, actions);
|
|
3094
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, actions, internalQueue);
|
|
3078
3095
|
nextState = resolvedState;
|
|
3079
3096
|
actions.length = 0;
|
|
3080
3097
|
executableActions.push(...resolvedActions);
|
|
@@ -3123,7 +3140,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3123
3140
|
};
|
|
3124
3141
|
|
|
3125
3142
|
// Execute transition content
|
|
3126
|
-
const [resolvedTransitionState, transitionExecutableActions] = resolveActionsWithContext(nextState, event, actorScope, transitionActions);
|
|
3143
|
+
const [resolvedTransitionState, transitionExecutableActions] = resolveActionsWithContext(nextState, event, actorScope, transitionActions, internalQueue);
|
|
3127
3144
|
nextState = resolvedTransitionState;
|
|
3128
3145
|
executableActions.push(...transitionExecutableActions);
|
|
3129
3146
|
if (context && context !== currentSnapshot.context) {
|
|
@@ -3150,7 +3167,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3150
3167
|
}
|
|
3151
3168
|
}
|
|
3152
3169
|
});
|
|
3153
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, allExitActions);
|
|
3170
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, allExitActions, internalQueue);
|
|
3154
3171
|
nextState = resolvedState;
|
|
3155
3172
|
executableActions.push(...resolvedActions);
|
|
3156
3173
|
const [stoppedState, stopEffects] = stopChildren(nextState, event, actorScope);
|
|
@@ -1171,7 +1171,7 @@ async function executeEffects(effects, runtime) {
|
|
|
1171
1171
|
await effect.exec(runtime);
|
|
1172
1172
|
}
|
|
1173
1173
|
}
|
|
1174
|
-
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions) {
|
|
1174
|
+
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions, internalEvents) {
|
|
1175
1175
|
let intermediateSnapshot = currentSnapshot;
|
|
1176
1176
|
const executableActions = [];
|
|
1177
1177
|
for (const action of actions) {
|
|
@@ -1195,7 +1195,20 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
1195
1195
|
};
|
|
1196
1196
|
const isInline = typeof action === 'function';
|
|
1197
1197
|
const actionRecord = getTransitionActionRecord(action);
|
|
1198
|
-
|
|
1198
|
+
let resolvedActionArgs = actionRecord?.args;
|
|
1199
|
+
if (actionRecord?.action === builtInActions['@xstate.sendTo'] && typeof actionRecord.args[1] === 'string') {
|
|
1200
|
+
const childId = actionRecord.args[1];
|
|
1201
|
+
const target = Object.hasOwn(intermediateSnapshot.children, childId) ? intermediateSnapshot.children[childId] : undefined;
|
|
1202
|
+
if (!target) {
|
|
1203
|
+
internalEvents?.push(createErrorPlatformEvent('communication', {
|
|
1204
|
+
message: `Unable to send event to unknown child '${childId}'`,
|
|
1205
|
+
event: actionRecord.args[2]
|
|
1206
|
+
}));
|
|
1207
|
+
continue;
|
|
1208
|
+
}
|
|
1209
|
+
resolvedActionArgs = [actionRecord.args[0], target, ...actionRecord.args.slice(2)];
|
|
1210
|
+
}
|
|
1211
|
+
const resolvedAction = isInline ? action : actionRecord ? actionRecord.action.bind(null, ...resolvedActionArgs) : false;
|
|
1199
1212
|
let actionParams = undefined;
|
|
1200
1213
|
if (typeof action === 'object' && action !== null) {
|
|
1201
1214
|
const {
|
|
@@ -1236,13 +1249,13 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
1236
1249
|
continue;
|
|
1237
1250
|
}
|
|
1238
1251
|
if (!resolvedAction || !('resolve' in resolvedAction)) {
|
|
1239
|
-
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action,
|
|
1252
|
+
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action, resolvedActionArgs) : undefined;
|
|
1240
1253
|
const isEmittedEvent = typeof action === 'object' && action !== null && !actionRecord;
|
|
1241
1254
|
const executableAction = {
|
|
1242
1255
|
kind: builtInFields ? 'builtin' : isEmittedEvent ? 'emit' : 'action',
|
|
1243
1256
|
type: typeof action === 'object' ? 'action' in action && typeof action.action === 'function' ? action.action.name ?? '(anonymous)' : action.type : action.name || '(anonymous)',
|
|
1244
1257
|
params: builtInFields ? undefined : actionParams,
|
|
1245
|
-
args: typeof action === 'object' && 'action' in action ?
|
|
1258
|
+
args: typeof action === 'object' && 'action' in action ? resolvedActionArgs : [],
|
|
1246
1259
|
...(builtInFields ? {} : isEmittedEvent ? {
|
|
1247
1260
|
source: actorScope.self,
|
|
1248
1261
|
event: action
|
|
@@ -2780,12 +2793,12 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2780
2793
|
context: nextContext
|
|
2781
2794
|
});
|
|
2782
2795
|
}
|
|
2783
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, exitActions);
|
|
2796
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, exitActions, internalQueue);
|
|
2784
2797
|
nextState = resolvedState;
|
|
2785
2798
|
executableActions.push(...resolvedActions);
|
|
2786
2799
|
const invokeStopActions = getInvokeStopActions(exitStateNode, nextState.children);
|
|
2787
2800
|
if (invokeStopActions.length) {
|
|
2788
|
-
const [stoppedState, stopEffects] = resolveActionsWithContext(nextState, event, actorScope, invokeStopActions);
|
|
2801
|
+
const [stoppedState, stopEffects] = resolveActionsWithContext(nextState, event, actorScope, invokeStopActions, internalQueue);
|
|
2789
2802
|
nextState = stoppedState;
|
|
2790
2803
|
executableActions.push(...stopEffects);
|
|
2791
2804
|
}
|
|
@@ -2916,14 +2929,18 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2916
2929
|
}
|
|
2917
2930
|
}
|
|
2918
2931
|
};
|
|
2932
|
+
const enteredTargetsByTransition = new Map();
|
|
2919
2933
|
for (const transition of filteredTransitions) {
|
|
2920
2934
|
const domain = getTransitionDomain(transition, currentSnapshot, getCurrentTransitionResult);
|
|
2921
2935
|
const {
|
|
2922
2936
|
targets,
|
|
2923
2937
|
reenter
|
|
2924
2938
|
} = getCurrentTransitionResult(transition);
|
|
2939
|
+
const enteredTargets = new Set();
|
|
2940
|
+
enteredTargetsByTransition.set(transition, enteredTargets);
|
|
2925
2941
|
for (const targetNode of targets ?? []) {
|
|
2926
2942
|
if (!isHistoryNode(targetNode) && (transition.source !== targetNode || transition.source !== domain || reenter)) {
|
|
2943
|
+
enteredTargets.add(targetNode);
|
|
2927
2944
|
statesToEnter.add(targetNode);
|
|
2928
2945
|
statesForDefaultEntry.add(targetNode);
|
|
2929
2946
|
}
|
|
@@ -2959,7 +2976,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2959
2976
|
input
|
|
2960
2977
|
} = getCurrentTransitionResult(transition);
|
|
2961
2978
|
if (input && targets) {
|
|
2962
|
-
for (const targetNode of targets) {
|
|
2979
|
+
for (const targetNode of targets.filter(targetNode => enteredTargetsByTransition.get(transition)?.has(targetNode))) {
|
|
2963
2980
|
stateInputMap[targetNode.id] = input;
|
|
2964
2981
|
stateInputsChanged = true;
|
|
2965
2982
|
}
|
|
@@ -3058,7 +3075,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3058
3075
|
}
|
|
3059
3076
|
}
|
|
3060
3077
|
}
|
|
3061
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, actions);
|
|
3078
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, actions, internalQueue);
|
|
3062
3079
|
nextState = resolvedState;
|
|
3063
3080
|
actions.length = 0;
|
|
3064
3081
|
executableActions.push(...resolvedActions);
|
|
@@ -3107,7 +3124,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3107
3124
|
};
|
|
3108
3125
|
|
|
3109
3126
|
// Execute transition content
|
|
3110
|
-
const [resolvedTransitionState, transitionExecutableActions] = resolveActionsWithContext(nextState, event, actorScope, transitionActions);
|
|
3127
|
+
const [resolvedTransitionState, transitionExecutableActions] = resolveActionsWithContext(nextState, event, actorScope, transitionActions, internalQueue);
|
|
3111
3128
|
nextState = resolvedTransitionState;
|
|
3112
3129
|
executableActions.push(...transitionExecutableActions);
|
|
3113
3130
|
if (context && context !== currentSnapshot.context) {
|
|
@@ -3134,7 +3151,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3134
3151
|
}
|
|
3135
3152
|
}
|
|
3136
3153
|
});
|
|
3137
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, allExitActions);
|
|
3154
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, allExitActions, internalQueue);
|
|
3138
3155
|
nextState = resolvedState;
|
|
3139
3156
|
executableActions.push(...resolvedActions);
|
|
3140
3157
|
const [stoppedState, stopEffects] = stopChildren(nextState, event, actorScope);
|
package/dist/{createActor-4d94dd53.development.cjs.js → createActor-72c06d5c.development.cjs.js}
RENAMED
|
@@ -1179,7 +1179,7 @@ async function executeEffects(effects, runtime) {
|
|
|
1179
1179
|
await effect.exec(runtime);
|
|
1180
1180
|
}
|
|
1181
1181
|
}
|
|
1182
|
-
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions) {
|
|
1182
|
+
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions, internalEvents) {
|
|
1183
1183
|
let intermediateSnapshot = currentSnapshot;
|
|
1184
1184
|
const executableActions = [];
|
|
1185
1185
|
for (const action of actions) {
|
|
@@ -1203,7 +1203,20 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
1203
1203
|
};
|
|
1204
1204
|
const isInline = typeof action === 'function';
|
|
1205
1205
|
const actionRecord = getTransitionActionRecord(action);
|
|
1206
|
-
|
|
1206
|
+
let resolvedActionArgs = actionRecord?.args;
|
|
1207
|
+
if (actionRecord?.action === builtInActions['@xstate.sendTo'] && typeof actionRecord.args[1] === 'string') {
|
|
1208
|
+
const childId = actionRecord.args[1];
|
|
1209
|
+
const target = Object.hasOwn(intermediateSnapshot.children, childId) ? intermediateSnapshot.children[childId] : undefined;
|
|
1210
|
+
if (!target) {
|
|
1211
|
+
internalEvents?.push(createErrorPlatformEvent('communication', {
|
|
1212
|
+
message: `Unable to send event to unknown child '${childId}'`,
|
|
1213
|
+
event: actionRecord.args[2]
|
|
1214
|
+
}));
|
|
1215
|
+
continue;
|
|
1216
|
+
}
|
|
1217
|
+
resolvedActionArgs = [actionRecord.args[0], target, ...actionRecord.args.slice(2)];
|
|
1218
|
+
}
|
|
1219
|
+
const resolvedAction = isInline ? action : actionRecord ? actionRecord.action.bind(null, ...resolvedActionArgs) : false;
|
|
1207
1220
|
let actionParams = undefined;
|
|
1208
1221
|
if (typeof action === 'object' && action !== null) {
|
|
1209
1222
|
const {
|
|
@@ -1244,13 +1257,13 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
1244
1257
|
continue;
|
|
1245
1258
|
}
|
|
1246
1259
|
if (!resolvedAction || !('resolve' in resolvedAction)) {
|
|
1247
|
-
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action,
|
|
1260
|
+
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action, resolvedActionArgs) : undefined;
|
|
1248
1261
|
const isEmittedEvent = typeof action === 'object' && action !== null && !actionRecord;
|
|
1249
1262
|
const executableAction = {
|
|
1250
1263
|
kind: builtInFields ? 'builtin' : isEmittedEvent ? 'emit' : 'action',
|
|
1251
1264
|
type: typeof action === 'object' ? 'action' in action && typeof action.action === 'function' ? action.action.name ?? '(anonymous)' : action.type : action.name || '(anonymous)',
|
|
1252
1265
|
params: builtInFields ? undefined : actionParams,
|
|
1253
|
-
args: typeof action === 'object' && 'action' in action ?
|
|
1266
|
+
args: typeof action === 'object' && 'action' in action ? resolvedActionArgs : [],
|
|
1254
1267
|
...(builtInFields ? {} : isEmittedEvent ? {
|
|
1255
1268
|
source: actorScope.self,
|
|
1256
1269
|
event: action
|
|
@@ -2798,12 +2811,12 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2798
2811
|
context: nextContext
|
|
2799
2812
|
});
|
|
2800
2813
|
}
|
|
2801
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, exitActions);
|
|
2814
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, exitActions, internalQueue);
|
|
2802
2815
|
nextState = resolvedState;
|
|
2803
2816
|
executableActions.push(...resolvedActions);
|
|
2804
2817
|
const invokeStopActions = getInvokeStopActions(exitStateNode, nextState.children);
|
|
2805
2818
|
if (invokeStopActions.length) {
|
|
2806
|
-
const [stoppedState, stopEffects] = resolveActionsWithContext(nextState, event, actorScope, invokeStopActions);
|
|
2819
|
+
const [stoppedState, stopEffects] = resolveActionsWithContext(nextState, event, actorScope, invokeStopActions, internalQueue);
|
|
2807
2820
|
nextState = stoppedState;
|
|
2808
2821
|
executableActions.push(...stopEffects);
|
|
2809
2822
|
}
|
|
@@ -2934,14 +2947,18 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2934
2947
|
}
|
|
2935
2948
|
}
|
|
2936
2949
|
};
|
|
2950
|
+
const enteredTargetsByTransition = new Map();
|
|
2937
2951
|
for (const transition of filteredTransitions) {
|
|
2938
2952
|
const domain = getTransitionDomain(transition, currentSnapshot, getCurrentTransitionResult);
|
|
2939
2953
|
const {
|
|
2940
2954
|
targets,
|
|
2941
2955
|
reenter
|
|
2942
2956
|
} = getCurrentTransitionResult(transition);
|
|
2957
|
+
const enteredTargets = new Set();
|
|
2958
|
+
enteredTargetsByTransition.set(transition, enteredTargets);
|
|
2943
2959
|
for (const targetNode of targets ?? []) {
|
|
2944
2960
|
if (!isHistoryNode(targetNode) && (transition.source !== targetNode || transition.source !== domain || reenter)) {
|
|
2961
|
+
enteredTargets.add(targetNode);
|
|
2945
2962
|
statesToEnter.add(targetNode);
|
|
2946
2963
|
statesForDefaultEntry.add(targetNode);
|
|
2947
2964
|
}
|
|
@@ -2977,7 +2994,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2977
2994
|
input
|
|
2978
2995
|
} = getCurrentTransitionResult(transition);
|
|
2979
2996
|
if (input && targets) {
|
|
2980
|
-
for (const targetNode of targets) {
|
|
2997
|
+
for (const targetNode of targets.filter(targetNode => enteredTargetsByTransition.get(transition)?.has(targetNode))) {
|
|
2981
2998
|
stateInputMap[targetNode.id] = input;
|
|
2982
2999
|
stateInputsChanged = true;
|
|
2983
3000
|
}
|
|
@@ -3076,7 +3093,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3076
3093
|
}
|
|
3077
3094
|
}
|
|
3078
3095
|
}
|
|
3079
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, actions);
|
|
3096
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, actions, internalQueue);
|
|
3080
3097
|
nextState = resolvedState;
|
|
3081
3098
|
actions.length = 0;
|
|
3082
3099
|
executableActions.push(...resolvedActions);
|
|
@@ -3125,7 +3142,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3125
3142
|
};
|
|
3126
3143
|
|
|
3127
3144
|
// Execute transition content
|
|
3128
|
-
const [resolvedTransitionState, transitionExecutableActions] = resolveActionsWithContext(nextState, event, actorScope, transitionActions);
|
|
3145
|
+
const [resolvedTransitionState, transitionExecutableActions] = resolveActionsWithContext(nextState, event, actorScope, transitionActions, internalQueue);
|
|
3129
3146
|
nextState = resolvedTransitionState;
|
|
3130
3147
|
executableActions.push(...transitionExecutableActions);
|
|
3131
3148
|
if (context && context !== currentSnapshot.context) {
|
|
@@ -3152,7 +3169,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3152
3169
|
}
|
|
3153
3170
|
}
|
|
3154
3171
|
});
|
|
3155
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, allExitActions);
|
|
3172
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, allExitActions, internalQueue);
|
|
3156
3173
|
nextState = resolvedState;
|
|
3157
3174
|
executableActions.push(...resolvedActions);
|
|
3158
3175
|
const [stoppedState, stopEffects] = stopChildren(nextState, event, actorScope);
|
|
@@ -1169,7 +1169,7 @@ async function executeEffects(effects, runtime) {
|
|
|
1169
1169
|
await effect.exec(runtime);
|
|
1170
1170
|
}
|
|
1171
1171
|
}
|
|
1172
|
-
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions) {
|
|
1172
|
+
function resolveActionsWithContext(currentSnapshot, event, actorScope, actions, internalEvents) {
|
|
1173
1173
|
let intermediateSnapshot = currentSnapshot;
|
|
1174
1174
|
const executableActions = [];
|
|
1175
1175
|
for (const action of actions) {
|
|
@@ -1193,7 +1193,20 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
1193
1193
|
};
|
|
1194
1194
|
const isInline = typeof action === 'function';
|
|
1195
1195
|
const actionRecord = getTransitionActionRecord(action);
|
|
1196
|
-
|
|
1196
|
+
let resolvedActionArgs = actionRecord?.args;
|
|
1197
|
+
if (actionRecord?.action === builtInActions['@xstate.sendTo'] && typeof actionRecord.args[1] === 'string') {
|
|
1198
|
+
const childId = actionRecord.args[1];
|
|
1199
|
+
const target = Object.hasOwn(intermediateSnapshot.children, childId) ? intermediateSnapshot.children[childId] : undefined;
|
|
1200
|
+
if (!target) {
|
|
1201
|
+
internalEvents?.push(createErrorPlatformEvent('communication', {
|
|
1202
|
+
message: `Unable to send event to unknown child '${childId}'`,
|
|
1203
|
+
event: actionRecord.args[2]
|
|
1204
|
+
}));
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
resolvedActionArgs = [actionRecord.args[0], target, ...actionRecord.args.slice(2)];
|
|
1208
|
+
}
|
|
1209
|
+
const resolvedAction = isInline ? action : actionRecord ? actionRecord.action.bind(null, ...resolvedActionArgs) : false;
|
|
1197
1210
|
let actionParams = undefined;
|
|
1198
1211
|
if (typeof action === 'object' && action !== null) {
|
|
1199
1212
|
const {
|
|
@@ -1234,13 +1247,13 @@ function resolveActionsWithContext(currentSnapshot, event, actorScope, actions)
|
|
|
1234
1247
|
continue;
|
|
1235
1248
|
}
|
|
1236
1249
|
if (!resolvedAction || !('resolve' in resolvedAction)) {
|
|
1237
|
-
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action,
|
|
1250
|
+
const builtInFields = typeof action === 'object' && action !== null && 'action' in action && typeof action.action === 'function' ? getBuiltInActionFields(action.action, resolvedActionArgs) : undefined;
|
|
1238
1251
|
const isEmittedEvent = typeof action === 'object' && action !== null && !actionRecord;
|
|
1239
1252
|
const executableAction = {
|
|
1240
1253
|
kind: builtInFields ? 'builtin' : isEmittedEvent ? 'emit' : 'action',
|
|
1241
1254
|
type: typeof action === 'object' ? 'action' in action && typeof action.action === 'function' ? action.action.name ?? '(anonymous)' : action.type : action.name || '(anonymous)',
|
|
1242
1255
|
params: builtInFields ? undefined : actionParams,
|
|
1243
|
-
args: typeof action === 'object' && 'action' in action ?
|
|
1256
|
+
args: typeof action === 'object' && 'action' in action ? resolvedActionArgs : [],
|
|
1244
1257
|
...(builtInFields ? {} : isEmittedEvent ? {
|
|
1245
1258
|
source: actorScope.self,
|
|
1246
1259
|
event: action
|
|
@@ -2778,12 +2791,12 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2778
2791
|
context: nextContext
|
|
2779
2792
|
});
|
|
2780
2793
|
}
|
|
2781
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, exitActions);
|
|
2794
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, exitActions, internalQueue);
|
|
2782
2795
|
nextState = resolvedState;
|
|
2783
2796
|
executableActions.push(...resolvedActions);
|
|
2784
2797
|
const invokeStopActions = getInvokeStopActions(exitStateNode, nextState.children);
|
|
2785
2798
|
if (invokeStopActions.length) {
|
|
2786
|
-
const [stoppedState, stopEffects] = resolveActionsWithContext(nextState, event, actorScope, invokeStopActions);
|
|
2799
|
+
const [stoppedState, stopEffects] = resolveActionsWithContext(nextState, event, actorScope, invokeStopActions, internalQueue);
|
|
2787
2800
|
nextState = stoppedState;
|
|
2788
2801
|
executableActions.push(...stopEffects);
|
|
2789
2802
|
}
|
|
@@ -2914,14 +2927,18 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2914
2927
|
}
|
|
2915
2928
|
}
|
|
2916
2929
|
};
|
|
2930
|
+
const enteredTargetsByTransition = new Map();
|
|
2917
2931
|
for (const transition of filteredTransitions) {
|
|
2918
2932
|
const domain = getTransitionDomain(transition, currentSnapshot, getCurrentTransitionResult);
|
|
2919
2933
|
const {
|
|
2920
2934
|
targets,
|
|
2921
2935
|
reenter
|
|
2922
2936
|
} = getCurrentTransitionResult(transition);
|
|
2937
|
+
const enteredTargets = new Set();
|
|
2938
|
+
enteredTargetsByTransition.set(transition, enteredTargets);
|
|
2923
2939
|
for (const targetNode of targets ?? []) {
|
|
2924
2940
|
if (!isHistoryNode(targetNode) && (transition.source !== targetNode || transition.source !== domain || reenter)) {
|
|
2941
|
+
enteredTargets.add(targetNode);
|
|
2925
2942
|
statesToEnter.add(targetNode);
|
|
2926
2943
|
statesForDefaultEntry.add(targetNode);
|
|
2927
2944
|
}
|
|
@@ -2957,7 +2974,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2957
2974
|
input
|
|
2958
2975
|
} = getCurrentTransitionResult(transition);
|
|
2959
2976
|
if (input && targets) {
|
|
2960
|
-
for (const targetNode of targets) {
|
|
2977
|
+
for (const targetNode of targets.filter(targetNode => enteredTargetsByTransition.get(transition)?.has(targetNode))) {
|
|
2961
2978
|
stateInputMap[targetNode.id] = input;
|
|
2962
2979
|
stateInputsChanged = true;
|
|
2963
2980
|
}
|
|
@@ -3056,7 +3073,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3056
3073
|
}
|
|
3057
3074
|
}
|
|
3058
3075
|
}
|
|
3059
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, actions);
|
|
3076
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, actions, internalQueue);
|
|
3060
3077
|
nextState = resolvedState;
|
|
3061
3078
|
actions.length = 0;
|
|
3062
3079
|
executableActions.push(...resolvedActions);
|
|
@@ -3105,7 +3122,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3105
3122
|
};
|
|
3106
3123
|
|
|
3107
3124
|
// Execute transition content
|
|
3108
|
-
const [resolvedTransitionState, transitionExecutableActions] = resolveActionsWithContext(nextState, event, actorScope, transitionActions);
|
|
3125
|
+
const [resolvedTransitionState, transitionExecutableActions] = resolveActionsWithContext(nextState, event, actorScope, transitionActions, internalQueue);
|
|
3109
3126
|
nextState = resolvedTransitionState;
|
|
3110
3127
|
executableActions.push(...transitionExecutableActions);
|
|
3111
3128
|
if (context && context !== currentSnapshot.context) {
|
|
@@ -3132,7 +3149,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
3132
3149
|
}
|
|
3133
3150
|
}
|
|
3134
3151
|
});
|
|
3135
|
-
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, allExitActions);
|
|
3152
|
+
const [resolvedState, resolvedActions] = resolveActionsWithContext(nextState, event, actorScope, allExitActions, internalQueue);
|
|
3136
3153
|
nextState = resolvedState;
|
|
3137
3154
|
executableActions.push(...resolvedActions);
|
|
3138
3155
|
const [stoppedState, stopEffects] = stopChildren(nextState, event, actorScope);
|
|
@@ -13,9 +13,9 @@ type CompatibleProvidedActorSource<TExpected extends AnyActorLogic, TActual exte
|
|
|
13
13
|
type ProvidedActors<TExpectedActorMap extends Sources['actors'], TProvidedActorMap extends Partial<Record<keyof TExpectedActorMap & string, AnyActorLogic>>> = {
|
|
14
14
|
[K in keyof TProvidedActorMap]: K extends keyof TExpectedActorMap ? TProvidedActorMap[K] extends AnyActorLogic ? CompatibleProvidedActorSource<TExpectedActorMap[K], TProvidedActorMap[K]> : never : never;
|
|
15
15
|
};
|
|
16
|
-
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TConfig extends StateSchema, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TInternalEvent extends EventObject = never> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
|
16
|
+
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TConfig extends StateSchema, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TInternalEvent extends EventObject = never, TTransitionMeta extends MetaObject = TMeta> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
|
17
17
|
/** The raw config used to create the machine. */
|
|
18
|
-
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any, any> & {
|
|
18
|
+
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any, any, any> & {
|
|
19
19
|
schemas?: AnyMachineSchemas;
|
|
20
20
|
internalEvents?: readonly string[];
|
|
21
21
|
};
|
|
@@ -32,14 +32,14 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
32
32
|
sources: Sources;
|
|
33
33
|
/** Runtime options for machine execution. */
|
|
34
34
|
options: MachineOptions;
|
|
35
|
-
root: StateNode<TContext, TEvent>;
|
|
35
|
+
root: StateNode<TContext, TEvent, TMeta, TTransitionMeta>;
|
|
36
36
|
id: string;
|
|
37
|
-
states: StateNode<TContext, TEvent>['states'];
|
|
37
|
+
states: StateNode<TContext, TEvent, TMeta, TTransitionMeta>['states'];
|
|
38
38
|
events: Array<EventDescriptor<TEvent>>;
|
|
39
39
|
internalEventDescriptors: ReadonlyArray<string>;
|
|
40
40
|
constructor(
|
|
41
41
|
/** The raw config used to create the machine. */
|
|
42
|
-
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any, any> & {
|
|
42
|
+
config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any, any, any> & {
|
|
43
43
|
schemas?: AnyMachineSchemas;
|
|
44
44
|
internalEvents?: readonly string[];
|
|
45
45
|
}, sources?: Sources, validator?: ActorLogicValidator | undefined);
|
|
@@ -98,7 +98,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
98
98
|
getInitialSnapshot(actorScope?: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>, input?: TInput): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
99
99
|
initialTransition(input: TInput | undefined, actorScope?: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>): ActorLogicTransitionResult<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, ExecutableActionObjectFromLogic<this>>;
|
|
100
100
|
start(snapshot?: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>): void;
|
|
101
|
-
getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
|
101
|
+
getStateNodeById(stateId: string): StateNode<TContext, TEvent, TMeta, TTransitionMeta>;
|
|
102
102
|
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, options?: unknown): Snapshot<unknown>;
|
|
103
103
|
restoreSnapshot(snapshot: Snapshot<unknown>, actorScope?: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>;
|
|
104
104
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { SetupStateSchemas } from "./schema.types.js";
|
|
2
|
-
import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, MachineContext, Mapper,
|
|
3
|
-
interface StateNodeOptions<
|
|
2
|
+
import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, MachineContext, Mapper, TransitionDefinition, TransitionDefinitionMap, AnyStateMachine, AnyStateNodeConfig, NonReducibleUnknown, EventDescriptor, AnyAction, InvokeDefinition, MetaObject } from "./types.js";
|
|
3
|
+
interface StateNodeOptions<TStateMeta extends MetaObject, TTransitionMeta extends MetaObject> {
|
|
4
4
|
_key: string;
|
|
5
|
-
_parent?: StateNode<
|
|
5
|
+
_parent?: StateNode<any, any, TStateMeta, TTransitionMeta>;
|
|
6
6
|
_machine: AnyStateMachine;
|
|
7
7
|
}
|
|
8
|
-
export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject> {
|
|
8
|
+
export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject, TStateMeta extends MetaObject = any, TTransitionMeta extends MetaObject = TStateMeta> {
|
|
9
9
|
/** The raw config used to create the machine. */
|
|
10
10
|
config: AnyStateNodeConfig;
|
|
11
11
|
/**
|
|
@@ -29,7 +29,7 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
29
29
|
/** The string path from the root machine node to this node. */
|
|
30
30
|
path: string[];
|
|
31
31
|
/** The child state nodes. */
|
|
32
|
-
states:
|
|
32
|
+
states: Record<string, StateNode<TContext, TEvent, TStateMeta, TTransitionMeta>>;
|
|
33
33
|
/**
|
|
34
34
|
* The type of history on this state node. Can be:
|
|
35
35
|
*
|
|
@@ -42,14 +42,14 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
42
42
|
/** The action(s) to be executed upon exiting the state node. */
|
|
43
43
|
exit: AnyAction | undefined;
|
|
44
44
|
/** The parent state node. */
|
|
45
|
-
parent?: StateNode<
|
|
45
|
+
parent?: StateNode<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
46
46
|
/** The root machine node. */
|
|
47
47
|
machine: AnyStateMachine;
|
|
48
48
|
/**
|
|
49
49
|
* The meta data associated with this state node, which will be returned in
|
|
50
50
|
* State instances.
|
|
51
51
|
*/
|
|
52
|
-
meta?:
|
|
52
|
+
meta?: TStateMeta;
|
|
53
53
|
/**
|
|
54
54
|
* The output data sent with the `xstate.done.state` event if this is a final
|
|
55
55
|
* state node.
|
|
@@ -63,17 +63,17 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
63
63
|
description?: string;
|
|
64
64
|
schemas: SetupStateSchemas | undefined;
|
|
65
65
|
tags: string[];
|
|
66
|
-
transitions: Map<string,
|
|
67
|
-
always?: Array<
|
|
68
|
-
invoke: Array<
|
|
69
|
-
on: TransitionDefinitionMap<any, any>;
|
|
70
|
-
after: Array<DelayedTransitionDefinition<any, any>>;
|
|
66
|
+
transitions: Map<string, TransitionDefinition<any, any, TTransitionMeta>[]>;
|
|
67
|
+
always?: Array<TransitionDefinition<any, any, TTransitionMeta>>;
|
|
68
|
+
invoke: Array<InvokeDefinition<any, any, any, TTransitionMeta, any, any, any, any>>;
|
|
69
|
+
on: TransitionDefinitionMap<any, any, TTransitionMeta>;
|
|
70
|
+
after: Array<DelayedTransitionDefinition<any, any, TTransitionMeta>>;
|
|
71
71
|
events: Array<EventDescriptor<any>>;
|
|
72
72
|
ownEvents: Array<EventDescriptor<any>>;
|
|
73
73
|
private _candidateCache?;
|
|
74
74
|
constructor(
|
|
75
75
|
/** The raw config used to create the machine. */
|
|
76
|
-
config: AnyStateNodeConfig, options: StateNodeOptions<
|
|
77
|
-
get initial(): InitialTransitionDefinition
|
|
76
|
+
config: AnyStateNodeConfig, options: StateNodeOptions<TStateMeta, TTransitionMeta>);
|
|
77
|
+
get initial(): InitialTransitionDefinition<TTransitionMeta>;
|
|
78
78
|
}
|
|
79
79
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { symbolObservable } from "./symbolObservable.js";
|
|
2
2
|
import { AnyActorSystem, Clock } from "./system.js";
|
|
3
|
-
import type { ActorTrigger, AnyActor, AnyActorLogic, EmittedFrom, EventFromLogic, SendableEventFromLogic, InputFrom,
|
|
3
|
+
import type { ActorTrigger, AnyActor, AnyActorLogic, EmittedFrom, EventFromLogic, SendableEventFromLogic, InputFrom, PersistedSnapshotOf, SnapshotFrom, Readable } from "./types.js";
|
|
4
4
|
import { ActorOptions, ActorInstance, ActorRef, InteropSubscribable, Observer, Subscription } from "./types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Marks a serialized object as an actor reference (`xstate$type` in JSON
|
|
@@ -200,7 +200,7 @@ export declare class Actor<TLogic extends AnyActorLogic> implements ActorInstanc
|
|
|
200
200
|
* owns it. Defaults to `true`.
|
|
201
201
|
*/
|
|
202
202
|
embedChildren?: boolean;
|
|
203
|
-
}):
|
|
203
|
+
}): PersistedSnapshotOf<TLogic>;
|
|
204
204
|
[symbolObservable](): InteropSubscribable<SnapshotFrom<TLogic>>;
|
|
205
205
|
/**
|
|
206
206
|
* Read an actor’s snapshot synchronously.
|