xstate 5.18.2 → 5.19.1
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/actions/dist/xstate-actions.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.cjs.js +2 -2
- package/actions/dist/xstate-actions.development.esm.js +2 -2
- package/actions/dist/xstate-actions.esm.js +2 -2
- 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/dev/dist/xstate-dev.cjs.js +1 -1
- package/dev/dist/xstate-dev.development.cjs.js +1 -1
- package/dev/dist/xstate-dev.development.esm.js +1 -1
- package/dev/dist/xstate-dev.esm.js +1 -1
- package/dev/dist/xstate-dev.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +1 -1
- package/dist/declarations/src/actions/raise.d.ts +9 -1
- package/dist/declarations/src/actions/send.d.ts +10 -1
- package/dist/declarations/src/createActor.d.ts +2 -1
- package/dist/declarations/src/getNextSnapshot.d.ts +2 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/inspection.d.ts +1 -1
- package/dist/declarations/src/spawn.d.ts +19 -11
- package/dist/declarations/src/stateUtils.d.ts +17 -7
- package/dist/declarations/src/transition.d.ts +16 -0
- package/dist/declarations/src/types.d.ts +48 -14
- package/dist/declarations/src/utils.d.ts +1 -1
- package/dist/{log-38475d87.development.esm.js → log-0acd9069.development.esm.js} +32 -33
- package/dist/{log-15d0f775.esm.js → log-3d9d72a9.esm.js} +31 -29
- package/dist/{log-b7ed1b61.development.cjs.js → log-8aa651a0.development.cjs.js} +32 -33
- package/dist/{log-98fcce74.cjs.js → log-a019fbd0.cjs.js} +31 -29
- package/dist/{raise-5ea71f04.development.esm.js → raise-1db27a82.development.esm.js} +98 -72
- package/dist/{raise-e919c5d4.development.cjs.js → raise-4acdb210.development.cjs.js} +98 -72
- package/dist/{raise-b1e0b9a9.cjs.js → raise-60cebf03.cjs.js} +94 -70
- package/dist/{raise-0f7cf128.esm.js → raise-c17ec2bc.esm.js} +94 -70
- package/dist/xstate.cjs.js +57 -15
- package/dist/xstate.cjs.mjs +2 -0
- package/dist/xstate.development.cjs.js +57 -15
- package/dist/xstate.development.cjs.mjs +2 -0
- package/dist/xstate.development.esm.js +58 -18
- package/dist/xstate.esm.js +58 -18
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.cjs.js +1 -1
- package/guards/dist/xstate-guards.development.esm.js +1 -1
- package/guards/dist/xstate-guards.esm.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js +1 -1
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -154,7 +154,7 @@ function toStatePath(stateId) {
|
|
|
154
154
|
if (isArray(stateId)) {
|
|
155
155
|
return stateId;
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
const result = [];
|
|
158
158
|
let segment = '';
|
|
159
159
|
for (let i = 0; i < stateId.length; i++) {
|
|
160
160
|
const char = stateId.charCodeAt(i);
|
|
@@ -234,7 +234,7 @@ function resolveOutput(mapper, context, event, self) {
|
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
236
|
if (!!mapper && typeof mapper === 'object' && Object.values(mapper).some(val => typeof val === 'function')) {
|
|
237
|
-
console.warn(`Dynamically mapping values to individual properties is deprecated. Use a single function that returns the mapped object instead.\nFound object containing properties whose values are possibly mapping functions: ${Object.entries(mapper).filter(([
|
|
237
|
+
console.warn(`Dynamically mapping values to individual properties is deprecated. Use a single function that returns the mapped object instead.\nFound object containing properties whose values are possibly mapping functions: ${Object.entries(mapper).filter(([, value]) => typeof value === 'function').map(([key, value]) => `\n - ${key}: ${value.toString().replace(/\n\s*/g, '')}`).join('')}`);
|
|
238
238
|
}
|
|
239
239
|
return mapper;
|
|
240
240
|
}
|
|
@@ -422,6 +422,7 @@ function createSystem(rootActor, options) {
|
|
|
422
422
|
return system;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
+
let executingCustomAction = false;
|
|
425
426
|
const $$ACTOR_TYPE = 1;
|
|
426
427
|
|
|
427
428
|
// those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
|
|
@@ -542,10 +543,37 @@ class Actor {
|
|
|
542
543
|
if (!listeners && !wildcardListener) {
|
|
543
544
|
return;
|
|
544
545
|
}
|
|
545
|
-
const allListeners =
|
|
546
|
-
for (const handler of
|
|
546
|
+
const allListeners = [...(listeners ? listeners.values() : []), ...(wildcardListener ? wildcardListener.values() : [])];
|
|
547
|
+
for (const handler of allListeners) {
|
|
547
548
|
handler(emittedEvent);
|
|
548
549
|
}
|
|
550
|
+
},
|
|
551
|
+
actionExecutor: action => {
|
|
552
|
+
const exec = () => {
|
|
553
|
+
this._actorScope.system._sendInspectionEvent({
|
|
554
|
+
type: '@xstate.action',
|
|
555
|
+
actorRef: this,
|
|
556
|
+
action: {
|
|
557
|
+
type: action.type,
|
|
558
|
+
params: action.params
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
if (!action.exec) {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
const saveExecutingCustomAction = executingCustomAction;
|
|
565
|
+
try {
|
|
566
|
+
executingCustomAction = true;
|
|
567
|
+
action.exec(action.info, action.params);
|
|
568
|
+
} finally {
|
|
569
|
+
executingCustomAction = saveExecutingCustomAction;
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
if (this._processingStatus === ProcessingStatus.Running) {
|
|
573
|
+
exec();
|
|
574
|
+
} else {
|
|
575
|
+
this._deferred.push(exec);
|
|
576
|
+
}
|
|
549
577
|
}
|
|
550
578
|
};
|
|
551
579
|
|
|
@@ -1085,11 +1113,13 @@ function resolveCancel(_, snapshot, actionArgs, actionParams, {
|
|
|
1085
1113
|
sendId
|
|
1086
1114
|
}) {
|
|
1087
1115
|
const resolvedSendId = typeof sendId === 'function' ? sendId(actionArgs, actionParams) : sendId;
|
|
1088
|
-
return [snapshot,
|
|
1116
|
+
return [snapshot, {
|
|
1117
|
+
sendId: resolvedSendId
|
|
1118
|
+
}, undefined];
|
|
1089
1119
|
}
|
|
1090
|
-
function executeCancel(actorScope,
|
|
1120
|
+
function executeCancel(actorScope, params) {
|
|
1091
1121
|
actorScope.defer(() => {
|
|
1092
|
-
actorScope.system.scheduler.cancel(actorScope.self,
|
|
1122
|
+
actorScope.system.scheduler.cancel(actorScope.self, params.sendId);
|
|
1093
1123
|
});
|
|
1094
1124
|
}
|
|
1095
1125
|
/**
|
|
@@ -1125,7 +1155,7 @@ function executeCancel(actorScope, resolvedSendId) {
|
|
|
1125
1155
|
* @param sendId The `id` of the `sendTo(...)` action to cancel.
|
|
1126
1156
|
*/
|
|
1127
1157
|
function cancel(sendId) {
|
|
1128
|
-
function cancel(
|
|
1158
|
+
function cancel(_args, _params) {
|
|
1129
1159
|
{
|
|
1130
1160
|
throw new Error(`This isn't supposed to be called`);
|
|
1131
1161
|
}
|
|
@@ -1147,22 +1177,26 @@ function resolveSpawn(actorScope, snapshot, actionArgs, _actionParams, {
|
|
|
1147
1177
|
const logic = typeof src === 'string' ? resolveReferencedActor(snapshot.machine, src) : src;
|
|
1148
1178
|
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
1149
1179
|
let actorRef;
|
|
1180
|
+
let resolvedInput = undefined;
|
|
1150
1181
|
if (logic) {
|
|
1182
|
+
resolvedInput = typeof input === 'function' ? input({
|
|
1183
|
+
context: snapshot.context,
|
|
1184
|
+
event: actionArgs.event,
|
|
1185
|
+
self: actorScope.self
|
|
1186
|
+
}) : input;
|
|
1151
1187
|
actorRef = createActor(logic, {
|
|
1152
1188
|
id: resolvedId,
|
|
1153
1189
|
src,
|
|
1154
1190
|
parent: actorScope.self,
|
|
1155
1191
|
syncSnapshot,
|
|
1156
1192
|
systemId,
|
|
1157
|
-
input:
|
|
1158
|
-
context: snapshot.context,
|
|
1159
|
-
event: actionArgs.event,
|
|
1160
|
-
self: actorScope.self
|
|
1161
|
-
}) : input
|
|
1193
|
+
input: resolvedInput
|
|
1162
1194
|
});
|
|
1163
1195
|
}
|
|
1164
1196
|
if (!actorRef) {
|
|
1165
|
-
console.warn(
|
|
1197
|
+
console.warn(
|
|
1198
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions,@typescript-eslint/no-base-to-string
|
|
1199
|
+
`Actor type '${src}' not found in machine '${actorScope.id}'.`);
|
|
1166
1200
|
}
|
|
1167
1201
|
return [cloneMachineSnapshot(snapshot, {
|
|
1168
1202
|
children: {
|
|
@@ -1171,11 +1205,13 @@ function resolveSpawn(actorScope, snapshot, actionArgs, _actionParams, {
|
|
|
1171
1205
|
}
|
|
1172
1206
|
}), {
|
|
1173
1207
|
id,
|
|
1174
|
-
|
|
1175
|
-
|
|
1208
|
+
systemId,
|
|
1209
|
+
actorRef,
|
|
1210
|
+
src,
|
|
1211
|
+
input: resolvedInput
|
|
1212
|
+
}, undefined];
|
|
1176
1213
|
}
|
|
1177
1214
|
function executeSpawn(actorScope, {
|
|
1178
|
-
id,
|
|
1179
1215
|
actorRef
|
|
1180
1216
|
}) {
|
|
1181
1217
|
if (!actorRef) {
|
|
@@ -1194,12 +1230,12 @@ function spawnChild(...[src, {
|
|
|
1194
1230
|
input,
|
|
1195
1231
|
syncSnapshot = false
|
|
1196
1232
|
} = {}]) {
|
|
1197
|
-
function spawnChild(
|
|
1233
|
+
function spawnChild(_args, _params) {
|
|
1198
1234
|
{
|
|
1199
1235
|
throw new Error(`This isn't supposed to be called`);
|
|
1200
1236
|
}
|
|
1201
1237
|
}
|
|
1202
|
-
spawnChild.type = '
|
|
1238
|
+
spawnChild.type = 'xstate.spawnChild';
|
|
1203
1239
|
spawnChild.id = id;
|
|
1204
1240
|
spawnChild.systemId = systemId;
|
|
1205
1241
|
spawnChild.src = src;
|
|
@@ -1224,7 +1260,7 @@ function resolveStop(_, snapshot, args, actionParams, {
|
|
|
1224
1260
|
}
|
|
1225
1261
|
return [cloneMachineSnapshot(snapshot, {
|
|
1226
1262
|
children
|
|
1227
|
-
}), resolvedActorRef];
|
|
1263
|
+
}), resolvedActorRef, undefined];
|
|
1228
1264
|
}
|
|
1229
1265
|
function executeStop(actorScope, actorRef) {
|
|
1230
1266
|
if (!actorRef) {
|
|
@@ -1256,7 +1292,7 @@ function executeStop(actorScope, actorRef) {
|
|
|
1256
1292
|
* @param actorRef The actor to stop.
|
|
1257
1293
|
*/
|
|
1258
1294
|
function stopChild(actorRef) {
|
|
1259
|
-
function stop(
|
|
1295
|
+
function stop(_args, _params) {
|
|
1260
1296
|
{
|
|
1261
1297
|
throw new Error(`This isn't supposed to be called`);
|
|
1262
1298
|
}
|
|
@@ -1286,7 +1322,7 @@ function checkStateIn(snapshot, _, {
|
|
|
1286
1322
|
return snapshot.matches(stateValue);
|
|
1287
1323
|
}
|
|
1288
1324
|
function stateIn(stateValue) {
|
|
1289
|
-
function stateIn(
|
|
1325
|
+
function stateIn() {
|
|
1290
1326
|
{
|
|
1291
1327
|
throw new Error(`This isn't supposed to be called`);
|
|
1292
1328
|
}
|
|
@@ -1334,7 +1370,7 @@ function checkNot(snapshot, {
|
|
|
1334
1370
|
* @returns A guard
|
|
1335
1371
|
*/
|
|
1336
1372
|
function not(guard) {
|
|
1337
|
-
function not(
|
|
1373
|
+
function not(_args, _params) {
|
|
1338
1374
|
{
|
|
1339
1375
|
throw new Error(`This isn't supposed to be called`);
|
|
1340
1376
|
}
|
|
@@ -1382,7 +1418,7 @@ function checkAnd(snapshot, {
|
|
|
1382
1418
|
* @returns A guard action object
|
|
1383
1419
|
*/
|
|
1384
1420
|
function and(guards) {
|
|
1385
|
-
function and(
|
|
1421
|
+
function and(_args, _params) {
|
|
1386
1422
|
{
|
|
1387
1423
|
throw new Error(`This isn't supposed to be called`);
|
|
1388
1424
|
}
|
|
@@ -1430,7 +1466,7 @@ function checkOr(snapshot, {
|
|
|
1430
1466
|
* @returns A guard action object
|
|
1431
1467
|
*/
|
|
1432
1468
|
function or(guards) {
|
|
1433
|
-
function or(
|
|
1469
|
+
function or(_args, _params) {
|
|
1434
1470
|
{
|
|
1435
1471
|
throw new Error(`This isn't supposed to be called`);
|
|
1436
1472
|
}
|
|
@@ -1616,7 +1652,7 @@ function getDelayedTransitions(stateNode) {
|
|
|
1616
1652
|
if (!afterConfig) {
|
|
1617
1653
|
return [];
|
|
1618
1654
|
}
|
|
1619
|
-
const mutateEntryExit =
|
|
1655
|
+
const mutateEntryExit = delay => {
|
|
1620
1656
|
const afterEvent = createAfterEvent(delay, stateNode.id);
|
|
1621
1657
|
const eventType = afterEvent.type;
|
|
1622
1658
|
stateNode.entry.push(raise(afterEvent, {
|
|
@@ -1626,7 +1662,7 @@ function getDelayedTransitions(stateNode) {
|
|
|
1626
1662
|
stateNode.exit.push(cancel(eventType));
|
|
1627
1663
|
return eventType;
|
|
1628
1664
|
};
|
|
1629
|
-
const delayedTransitions = Object.keys(afterConfig).flatMap(
|
|
1665
|
+
const delayedTransitions = Object.keys(afterConfig).flatMap(delay => {
|
|
1630
1666
|
const configTransition = afterConfig[delay];
|
|
1631
1667
|
const resolvedTransition = typeof configTransition === 'string' ? {
|
|
1632
1668
|
target: configTransition
|
|
@@ -1716,7 +1752,9 @@ function formatTransitions(stateNode) {
|
|
|
1716
1752
|
function formatInitialTransition(stateNode, _target) {
|
|
1717
1753
|
const resolvedTarget = typeof _target === 'string' ? stateNode.states[_target] : _target ? stateNode.states[_target.target] : undefined;
|
|
1718
1754
|
if (!resolvedTarget && _target) {
|
|
1719
|
-
throw new Error(
|
|
1755
|
+
throw new Error(
|
|
1756
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-base-to-string
|
|
1757
|
+
`Initial state node "${_target}" not found on parent state node #${stateNode.id}`);
|
|
1720
1758
|
}
|
|
1721
1759
|
const transition = {
|
|
1722
1760
|
source: stateNode,
|
|
@@ -1826,7 +1864,7 @@ function getStateNodeByPath(stateNode, statePath) {
|
|
|
1826
1864
|
if (typeof statePath === 'string' && isStateId(statePath)) {
|
|
1827
1865
|
try {
|
|
1828
1866
|
return stateNode.machine.getStateNodeById(statePath);
|
|
1829
|
-
} catch
|
|
1867
|
+
} catch {
|
|
1830
1868
|
// try individual paths
|
|
1831
1869
|
// throw e;
|
|
1832
1870
|
}
|
|
@@ -2055,18 +2093,20 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
|
|
|
2055
2093
|
|
|
2056
2094
|
// Exit states
|
|
2057
2095
|
if (!isInitial) {
|
|
2058
|
-
[nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, historyValue, internalQueue);
|
|
2096
|
+
[nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, historyValue, internalQueue, actorScope.actionExecutor);
|
|
2059
2097
|
}
|
|
2060
2098
|
|
|
2061
2099
|
// Execute transition content
|
|
2062
|
-
nextState = resolveActionsAndContext(nextState, event, actorScope, filteredTransitions.flatMap(t => t.actions), internalQueue);
|
|
2100
|
+
nextState = resolveActionsAndContext(nextState, event, actorScope, filteredTransitions.flatMap(t => t.actions), internalQueue, undefined);
|
|
2063
2101
|
|
|
2064
2102
|
// Enter states
|
|
2065
2103
|
nextState = enterStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial);
|
|
2066
2104
|
const nextStateNodes = [...mutStateNodeSet];
|
|
2067
2105
|
if (nextState.status === 'done') {
|
|
2068
|
-
nextState = resolveActionsAndContext(nextState, event, actorScope, nextStateNodes.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue);
|
|
2106
|
+
nextState = resolveActionsAndContext(nextState, event, actorScope, nextStateNodes.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue, undefined);
|
|
2069
2107
|
}
|
|
2108
|
+
|
|
2109
|
+
// eslint-disable-next-line no-useless-catch
|
|
2070
2110
|
try {
|
|
2071
2111
|
if (historyValue === currentSnapshot.historyValue && areStateNodeCollectionsEqual(currentSnapshot._nodes, mutStateNodeSet)) {
|
|
2072
2112
|
return nextState;
|
|
@@ -2236,7 +2276,7 @@ function addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultE
|
|
|
2236
2276
|
function addProperAncestorStatesToEnter(stateNode, toStateNode, statesToEnter, historyValue, statesForDefaultEntry) {
|
|
2237
2277
|
addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultEntry, getProperAncestors(stateNode, toStateNode));
|
|
2238
2278
|
}
|
|
2239
|
-
function exitStates(currentSnapshot, event, actorScope, transitions, mutStateNodeSet, historyValue, internalQueue) {
|
|
2279
|
+
function exitStates(currentSnapshot, event, actorScope, transitions, mutStateNodeSet, historyValue, internalQueue, _actionExecutor) {
|
|
2240
2280
|
let nextSnapshot = currentSnapshot;
|
|
2241
2281
|
const statesToExit = computeExitSet(transitions, mutStateNodeSet, historyValue);
|
|
2242
2282
|
statesToExit.sort((a, b) => b.order - a.order);
|
|
@@ -2260,12 +2300,14 @@ function exitStates(currentSnapshot, event, actorScope, transitions, mutStateNod
|
|
|
2260
2300
|
}
|
|
2261
2301
|
}
|
|
2262
2302
|
for (const s of statesToExit) {
|
|
2263
|
-
nextSnapshot = resolveActionsAndContext(nextSnapshot, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
|
|
2303
|
+
nextSnapshot = resolveActionsAndContext(nextSnapshot, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue, undefined);
|
|
2264
2304
|
mutStateNodeSet.delete(s);
|
|
2265
2305
|
}
|
|
2266
2306
|
return [nextSnapshot, changedHistory || historyValue];
|
|
2267
2307
|
}
|
|
2268
|
-
|
|
2308
|
+
function getAction(machine, actionType) {
|
|
2309
|
+
return machine.implementations.actions[actionType];
|
|
2310
|
+
}
|
|
2269
2311
|
function resolveAndExecuteActionsWithContext(currentSnapshot, event, actorScope, actions, extra, retries) {
|
|
2270
2312
|
const {
|
|
2271
2313
|
machine
|
|
@@ -2277,10 +2319,8 @@ function resolveAndExecuteActionsWithContext(currentSnapshot, event, actorScope,
|
|
|
2277
2319
|
// the existing type of `.actions` assumes non-nullable `TExpressionAction`
|
|
2278
2320
|
// it's fine to cast this here to get a common type and lack of errors in the rest of the code
|
|
2279
2321
|
// our logic below makes sure that we call those 2 "variants" correctly
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
continue;
|
|
2283
|
-
}
|
|
2322
|
+
|
|
2323
|
+
getAction(machine, typeof action === 'string' ? action : action.type);
|
|
2284
2324
|
const actionArgs = {
|
|
2285
2325
|
context: intermediateSnapshot.context,
|
|
2286
2326
|
event,
|
|
@@ -2291,30 +2331,13 @@ function resolveAndExecuteActionsWithContext(currentSnapshot, event, actorScope,
|
|
|
2291
2331
|
context: intermediateSnapshot.context,
|
|
2292
2332
|
event
|
|
2293
2333
|
}) : action.params : undefined;
|
|
2294
|
-
|
|
2295
|
-
actorScope.
|
|
2296
|
-
type: '
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
params: actionParams
|
|
2301
|
-
}
|
|
2334
|
+
if (!resolvedAction || !('resolve' in resolvedAction)) {
|
|
2335
|
+
actorScope.actionExecutor({
|
|
2336
|
+
type: typeof action === 'string' ? action : typeof action === 'object' ? action.type : action.name || '(anonymous)',
|
|
2337
|
+
info: actionArgs,
|
|
2338
|
+
params: actionParams,
|
|
2339
|
+
exec: resolvedAction
|
|
2302
2340
|
});
|
|
2303
|
-
try {
|
|
2304
|
-
executingCustomAction = resolvedAction;
|
|
2305
|
-
resolvedAction(actionArgs, actionParams);
|
|
2306
|
-
} finally {
|
|
2307
|
-
executingCustomAction = false;
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
if (!('resolve' in resolvedAction)) {
|
|
2311
|
-
if (actorScope.self._processingStatus === ProcessingStatus.Running) {
|
|
2312
|
-
executeAction();
|
|
2313
|
-
} else {
|
|
2314
|
-
actorScope.defer(() => {
|
|
2315
|
-
executeAction();
|
|
2316
|
-
});
|
|
2317
|
-
}
|
|
2318
2341
|
continue;
|
|
2319
2342
|
}
|
|
2320
2343
|
const builtinAction = resolvedAction;
|
|
@@ -2326,11 +2349,12 @@ function resolveAndExecuteActionsWithContext(currentSnapshot, event, actorScope,
|
|
|
2326
2349
|
retries?.push([builtinAction, params]);
|
|
2327
2350
|
}
|
|
2328
2351
|
if ('execute' in builtinAction) {
|
|
2329
|
-
|
|
2330
|
-
builtinAction.
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2352
|
+
actorScope.actionExecutor({
|
|
2353
|
+
type: builtinAction.type,
|
|
2354
|
+
info: actionArgs,
|
|
2355
|
+
params,
|
|
2356
|
+
exec: builtinAction.execute.bind(null, actorScope, params)
|
|
2357
|
+
});
|
|
2334
2358
|
}
|
|
2335
2359
|
if (actions) {
|
|
2336
2360
|
intermediateSnapshot = resolveAndExecuteActionsWithContext(intermediateSnapshot, event, actorScope, actions, extra, retries);
|
|
@@ -2349,7 +2373,7 @@ function resolveActionsAndContext(currentSnapshot, event, actorScope, actions, i
|
|
|
2349
2373
|
});
|
|
2350
2374
|
return nextState;
|
|
2351
2375
|
}
|
|
2352
|
-
function macrostep(snapshot, event, actorScope, internalQueue
|
|
2376
|
+
function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
2353
2377
|
if (event.type === WILDCARD) {
|
|
2354
2378
|
throw new Error(`An event cannot have the wildcard type ('${WILDCARD}')`);
|
|
2355
2379
|
}
|
|
@@ -2431,7 +2455,7 @@ function macrostep(snapshot, event, actorScope, internalQueue = []) {
|
|
|
2431
2455
|
};
|
|
2432
2456
|
}
|
|
2433
2457
|
function stopChildren(nextState, event, actorScope) {
|
|
2434
|
-
return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);
|
|
2458
|
+
return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), [], undefined);
|
|
2435
2459
|
}
|
|
2436
2460
|
function selectTransitions(event, nextState) {
|
|
2437
2461
|
return nextState.machine.getTransitionData(nextState, event);
|
|
@@ -2604,7 +2628,9 @@ function resolveRaise(_, snapshot, args, actionParams, {
|
|
|
2604
2628
|
}) {
|
|
2605
2629
|
const delaysMap = snapshot.machine.implementations.delays;
|
|
2606
2630
|
if (typeof eventOrExpr === 'string') {
|
|
2607
|
-
throw new Error(
|
|
2631
|
+
throw new Error(
|
|
2632
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
2633
|
+
`Only event objects may be used with raise; use raise({ type: "${eventOrExpr}" }) instead`);
|
|
2608
2634
|
}
|
|
2609
2635
|
const resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args, actionParams) : eventOrExpr;
|
|
2610
2636
|
let resolvedDelay;
|
|
@@ -2621,7 +2647,7 @@ function resolveRaise(_, snapshot, args, actionParams, {
|
|
|
2621
2647
|
event: resolvedEvent,
|
|
2622
2648
|
id,
|
|
2623
2649
|
delay: resolvedDelay
|
|
2624
|
-
}];
|
|
2650
|
+
}, undefined];
|
|
2625
2651
|
}
|
|
2626
2652
|
function executeRaise(actorScope, params) {
|
|
2627
2653
|
const {
|
|
@@ -2647,7 +2673,7 @@ function raise(eventOrExpr, options) {
|
|
|
2647
2673
|
if (executingCustomAction) {
|
|
2648
2674
|
console.warn('Custom actions should not call `raise()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
2649
2675
|
}
|
|
2650
|
-
function raise(
|
|
2676
|
+
function raise(_args, _params) {
|
|
2651
2677
|
{
|
|
2652
2678
|
throw new Error(`This isn't supposed to be called`);
|
|
2653
2679
|
}
|