xstate 5.0.0-beta.41 → 5.0.0-beta.43
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 +3 -3
- package/actions/dist/xstate-actions.development.cjs.js +3 -3
- package/actions/dist/xstate-actions.development.esm.js +3 -3
- package/actions/dist/xstate-actions.esm.js +3 -3
- package/actions/dist/xstate-actions.umd.min.js +1 -1
- package/actions/dist/xstate-actions.umd.min.js.map +1 -1
- package/actors/dist/xstate-actors.cjs.js +45 -1
- package/actors/dist/xstate-actors.development.cjs.js +45 -1
- package/actors/dist/xstate-actors.development.esm.js +45 -1
- package/actors/dist/xstate-actors.esm.js +45 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +36 -43
- package/dist/declarations/src/StateMachine.d.ts +12 -29
- package/dist/declarations/src/StateNode.d.ts +2 -2
- package/dist/declarations/src/actions/spawn.d.ts +3 -3
- package/dist/declarations/src/actors/promise.d.ts +53 -0
- package/dist/declarations/src/index.d.ts +3 -4
- package/dist/declarations/src/interpreter.d.ts +12 -0
- package/dist/declarations/src/stateUtils.d.ts +7 -8
- package/dist/declarations/src/types.d.ts +153 -21
- package/dist/declarations/src/utils.d.ts +2 -8
- package/dist/{interpreter-fb2829f1.cjs.js → interpreter-36d5556e.cjs.js} +25 -19
- package/dist/{interpreter-70ed981b.development.cjs.js → interpreter-4e8e2a0d.development.cjs.js} +25 -19
- package/dist/{interpreter-480db258.esm.js → interpreter-63c80754.esm.js} +26 -19
- package/dist/{interpreter-936da690.development.esm.js → interpreter-80eb3bec.development.esm.js} +26 -19
- package/dist/{raise-5ab465ed.development.cjs.js → raise-23dea0d7.development.cjs.js} +101 -188
- package/dist/{raise-9d6921da.esm.js → raise-8dc8e1aa.esm.js} +95 -181
- package/dist/{raise-beae3fd3.cjs.js → raise-e0fe5c2d.cjs.js} +96 -183
- package/dist/{raise-f757be00.development.esm.js → raise-f4ad5a87.development.esm.js} +100 -186
- package/dist/{send-fb87a01a.development.cjs.js → send-0174c155.development.cjs.js} +10 -10
- package/dist/{send-b26e3812.development.esm.js → send-5d129d95.development.esm.js} +10 -10
- package/dist/{send-a931d1b8.esm.js → send-84e2e742.esm.js} +10 -10
- package/dist/{send-ca5f706c.cjs.js → send-87bbaaab.cjs.js} +10 -10
- package/dist/xstate.cjs.js +24 -50
- package/dist/xstate.cjs.mjs +0 -2
- package/dist/xstate.development.cjs.js +24 -50
- package/dist/xstate.development.cjs.mjs +0 -2
- package/dist/xstate.development.esm.js +28 -52
- package/dist/xstate.esm.js +28 -52
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/guards/dist/xstate-guards.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.cjs.js +2 -2
- package/guards/dist/xstate-guards.development.esm.js +2 -2
- package/guards/dist/xstate-guards.esm.js +2 -2
- package/guards/dist/xstate-guards.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/declarations/src/mapState.d.ts +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveReferencedActor, d as createActor, P as ProcessingStatus, h as createErrorActorEvent, j as
|
|
1
|
+
import { r as resolveReferencedActor, d as createActor, P as ProcessingStatus, h as createErrorActorEvent, j as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, k as toStatePath, l as createDoneStateEvent, o as resolveOutput, W as WILDCARD, X as XSTATE_STOP, q as XSTATE_INIT, s as createAfterEvent, u as flatten, $ as $$ACTOR_TYPE, f as matchesState } from './interpreter-80eb3bec.development.esm.js';
|
|
2
2
|
|
|
3
3
|
const cache = new WeakMap();
|
|
4
4
|
function memo(object, key, fn) {
|
|
@@ -50,25 +50,20 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
|
|
|
50
50
|
input,
|
|
51
51
|
syncSnapshot
|
|
52
52
|
}) {
|
|
53
|
-
const
|
|
54
|
-
src,
|
|
55
|
-
input: undefined
|
|
56
|
-
};
|
|
53
|
+
const logic = typeof src === 'string' ? resolveReferencedActor(state.machine, src) : src;
|
|
57
54
|
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
58
55
|
let actorRef;
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
const configuredInput = input || referenced.input;
|
|
62
|
-
actorRef = createActor(referenced.src, {
|
|
56
|
+
if (logic) {
|
|
57
|
+
actorRef = createActor(logic, {
|
|
63
58
|
id: resolvedId,
|
|
64
59
|
src,
|
|
65
60
|
parent: actorScope?.self,
|
|
66
61
|
systemId,
|
|
67
|
-
input: typeof
|
|
62
|
+
input: typeof input === 'function' ? input({
|
|
68
63
|
context: state.context,
|
|
69
64
|
event: actionArgs.event,
|
|
70
65
|
self: actorScope?.self
|
|
71
|
-
}) :
|
|
66
|
+
}) : input
|
|
72
67
|
});
|
|
73
68
|
if (syncSnapshot) {
|
|
74
69
|
actorRef.subscribe({
|
|
@@ -87,7 +82,7 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
|
|
|
87
82
|
if (!actorRef) {
|
|
88
83
|
console.warn(`Actor type '${src}' not found in machine '${actorScope.id}'.`);
|
|
89
84
|
}
|
|
90
|
-
return [
|
|
85
|
+
return [cloneMachineSnapshot(state, {
|
|
91
86
|
children: {
|
|
92
87
|
...state.children,
|
|
93
88
|
[resolvedId]: actorRef
|
|
@@ -150,7 +145,7 @@ function resolveStop(_, state, args, actionParams, {
|
|
|
150
145
|
};
|
|
151
146
|
delete children[resolvedActorRef.id];
|
|
152
147
|
}
|
|
153
|
-
return [
|
|
148
|
+
return [cloneMachineSnapshot(state, {
|
|
154
149
|
children
|
|
155
150
|
}), resolvedActorRef];
|
|
156
151
|
}
|
|
@@ -683,10 +678,9 @@ function getStateNodeByPath(stateNode, statePath) {
|
|
|
683
678
|
/**
|
|
684
679
|
* Returns the state nodes represented by the current state value.
|
|
685
680
|
*
|
|
686
|
-
* @param
|
|
681
|
+
* @param stateValue The state value or State instance
|
|
687
682
|
*/
|
|
688
|
-
function getStateNodes(stateNode,
|
|
689
|
-
const stateValue = state instanceof State ? state.value : toStateValue(state);
|
|
683
|
+
function getStateNodes(stateNode, stateValue) {
|
|
690
684
|
if (typeof stateValue === 'string') {
|
|
691
685
|
return [stateNode, stateNode.states[stateValue]];
|
|
692
686
|
}
|
|
@@ -907,7 +901,7 @@ function microstep(transitions, currentState, actorScope, event, isInitial, inte
|
|
|
907
901
|
if (historyValue === currentState.historyValue && areConfigurationsEqual(currentState.configuration, mutConfiguration)) {
|
|
908
902
|
return nextState;
|
|
909
903
|
}
|
|
910
|
-
return
|
|
904
|
+
return cloneMachineSnapshot(nextState, {
|
|
911
905
|
configuration: nextConfiguration,
|
|
912
906
|
historyValue
|
|
913
907
|
});
|
|
@@ -971,9 +965,9 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutCo
|
|
|
971
965
|
if (ancestorMarker) {
|
|
972
966
|
continue;
|
|
973
967
|
}
|
|
974
|
-
nextState =
|
|
968
|
+
nextState = cloneMachineSnapshot(nextState, {
|
|
975
969
|
status: 'done',
|
|
976
|
-
output: getMachineOutput(nextState, event, actorScope,
|
|
970
|
+
output: getMachineOutput(nextState, event, actorScope, nextState.machine.root, rootCompletionNode)
|
|
977
971
|
});
|
|
978
972
|
}
|
|
979
973
|
}
|
|
@@ -1177,7 +1171,7 @@ function macrostep(state, event, actorScope, internalQueue = []) {
|
|
|
1177
1171
|
|
|
1178
1172
|
// Handle stop event
|
|
1179
1173
|
if (event.type === XSTATE_STOP) {
|
|
1180
|
-
nextState =
|
|
1174
|
+
nextState = cloneMachineSnapshot(stopChildren(nextState, event, actorScope), {
|
|
1181
1175
|
status: 'stopped'
|
|
1182
1176
|
});
|
|
1183
1177
|
states.push(nextState);
|
|
@@ -1255,173 +1249,88 @@ function resolveStateValue(rootNode, stateValue) {
|
|
|
1255
1249
|
const configuration = getConfiguration(getStateNodes(rootNode, stateValue));
|
|
1256
1250
|
return getStateValue(rootNode, [...configuration]);
|
|
1257
1251
|
}
|
|
1258
|
-
function getInitialConfiguration(rootNode) {
|
|
1259
|
-
const configuration = [];
|
|
1260
|
-
const initialTransition = rootNode.initial;
|
|
1261
|
-
const statesToEnter = new Set();
|
|
1262
|
-
const statesForDefaultEntry = new Set([rootNode]);
|
|
1263
|
-
computeEntrySet([initialTransition], {}, statesForDefaultEntry, statesToEnter);
|
|
1264
|
-
for (const stateNodeToEnter of [...statesToEnter].sort((a, b) => a.order - b.order)) {
|
|
1265
|
-
configuration.push(stateNodeToEnter);
|
|
1266
|
-
}
|
|
1267
|
-
return configuration;
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
class State {
|
|
1271
|
-
/**
|
|
1272
|
-
* Indicates whether the state is a final state.
|
|
1273
|
-
*/
|
|
1274
|
-
|
|
1275
|
-
/**
|
|
1276
|
-
* The output data of the top-level finite state.
|
|
1277
|
-
*/
|
|
1278
|
-
|
|
1279
|
-
/**
|
|
1280
|
-
* The enabled state nodes representative of the state value.
|
|
1281
|
-
*/
|
|
1282
|
-
|
|
1283
|
-
/**
|
|
1284
|
-
* An object mapping actor names to spawned/invoked actors.
|
|
1285
|
-
*/
|
|
1286
|
-
|
|
1287
|
-
/**
|
|
1288
|
-
* Creates a new State instance for the given `stateValue` and `context`.
|
|
1289
|
-
* @param stateValue
|
|
1290
|
-
* @param context
|
|
1291
|
-
*/
|
|
1292
|
-
static from(stateValue, context = {}, machine) {
|
|
1293
|
-
if (stateValue instanceof State) {
|
|
1294
|
-
if (stateValue.context !== context) {
|
|
1295
|
-
return new State({
|
|
1296
|
-
value: stateValue.value,
|
|
1297
|
-
context,
|
|
1298
|
-
meta: {},
|
|
1299
|
-
configuration: [],
|
|
1300
|
-
// TODO: fix,
|
|
1301
|
-
children: {},
|
|
1302
|
-
status: 'active'
|
|
1303
|
-
}, machine);
|
|
1304
|
-
}
|
|
1305
|
-
return stateValue;
|
|
1306
|
-
}
|
|
1307
|
-
const configuration = getConfiguration(getStateNodes(machine.root, stateValue));
|
|
1308
|
-
return new State({
|
|
1309
|
-
value: stateValue,
|
|
1310
|
-
context,
|
|
1311
|
-
meta: undefined,
|
|
1312
|
-
configuration: Array.from(configuration),
|
|
1313
|
-
children: {},
|
|
1314
|
-
status: 'active'
|
|
1315
|
-
}, machine);
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
/**
|
|
1319
|
-
* Creates a new `State` instance that represents the current state of a running machine.
|
|
1320
|
-
*
|
|
1321
|
-
* @param config
|
|
1322
|
-
*/
|
|
1323
|
-
constructor(config, machine) {
|
|
1324
|
-
this.machine = machine;
|
|
1325
|
-
this.tags = void 0;
|
|
1326
|
-
this.value = void 0;
|
|
1327
|
-
this.status = void 0;
|
|
1328
|
-
this.error = void 0;
|
|
1329
|
-
this.context = void 0;
|
|
1330
|
-
this.historyValue = {};
|
|
1331
|
-
this.configuration = void 0;
|
|
1332
|
-
this.children = void 0;
|
|
1333
|
-
this.context = config.context;
|
|
1334
|
-
this.historyValue = config.historyValue || {};
|
|
1335
|
-
this.matches = this.matches.bind(this);
|
|
1336
|
-
this.toStrings = this.toStrings.bind(this);
|
|
1337
|
-
this.configuration = config.configuration ?? Array.from(getConfiguration(getStateNodes(machine.root, config.value)));
|
|
1338
|
-
this.children = config.children;
|
|
1339
|
-
this.value = getStateValue(machine.root, this.configuration);
|
|
1340
|
-
this.tags = new Set(flatten(this.configuration.map(sn => sn.tags)));
|
|
1341
|
-
this.status = config.status;
|
|
1342
|
-
this.output = config.output;
|
|
1343
|
-
this.error = config.error;
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
/**
|
|
1347
|
-
* Returns an array of all the string leaf state node paths.
|
|
1348
|
-
* @param stateValue
|
|
1349
|
-
* @param delimiter The character(s) that separate each subpath in the string state node path.
|
|
1350
|
-
*/
|
|
1351
|
-
toStrings(stateValue = this.value) {
|
|
1352
|
-
if (typeof stateValue === 'string') {
|
|
1353
|
-
return [stateValue];
|
|
1354
|
-
}
|
|
1355
|
-
const valueKeys = Object.keys(stateValue);
|
|
1356
|
-
return valueKeys.concat(...valueKeys.map(key => this.toStrings(stateValue[key]).map(s => key + STATE_DELIMITER + s)));
|
|
1357
|
-
}
|
|
1358
|
-
toJSON() {
|
|
1359
|
-
const {
|
|
1360
|
-
configuration,
|
|
1361
|
-
tags,
|
|
1362
|
-
machine,
|
|
1363
|
-
...jsonValues
|
|
1364
|
-
} = this;
|
|
1365
|
-
return {
|
|
1366
|
-
...jsonValues,
|
|
1367
|
-
tags: Array.from(tags),
|
|
1368
|
-
meta: this.meta
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* Whether the current state value is a subset of the given parent state value.
|
|
1374
|
-
* @param parentStateValue
|
|
1375
|
-
*/
|
|
1376
|
-
matches(parentStateValue) {
|
|
1377
|
-
return matchesState(parentStateValue, this.value);
|
|
1378
|
-
}
|
|
1379
1252
|
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1253
|
+
const machineSnapshotMatches = function matches(testValue) {
|
|
1254
|
+
return matchesState(testValue, this.value);
|
|
1255
|
+
};
|
|
1256
|
+
const machineSnapshotHasTag = function hasTag(tag) {
|
|
1257
|
+
return this.tags.has(tag);
|
|
1258
|
+
};
|
|
1259
|
+
const machineSnapshotCan = function can(event) {
|
|
1260
|
+
if (!this.machine) {
|
|
1261
|
+
console.warn(`state.can(...) used outside of a machine-created State object; this will always return false.`);
|
|
1262
|
+
}
|
|
1263
|
+
const transitionData = this.machine.getTransitionData(this, event);
|
|
1264
|
+
return !!transitionData?.length &&
|
|
1265
|
+
// Check that at least one transition is not forbidden
|
|
1266
|
+
transitionData.some(t => t.target !== undefined || t.actions.length);
|
|
1267
|
+
};
|
|
1268
|
+
const machineSnapshotToJSON = function toJSON() {
|
|
1269
|
+
const {
|
|
1270
|
+
configuration,
|
|
1271
|
+
tags,
|
|
1272
|
+
machine,
|
|
1273
|
+
nextEvents,
|
|
1274
|
+
toJSON,
|
|
1275
|
+
can,
|
|
1276
|
+
hasTag,
|
|
1277
|
+
matches,
|
|
1278
|
+
...jsonValues
|
|
1279
|
+
} = this;
|
|
1280
|
+
return {
|
|
1281
|
+
...jsonValues,
|
|
1282
|
+
tags: Array.from(tags)
|
|
1283
|
+
};
|
|
1284
|
+
};
|
|
1285
|
+
const machineSnapshotNextEvents = function nextEvents() {
|
|
1286
|
+
return memo(this, 'nextEvents', () => {
|
|
1287
|
+
return [...new Set(flatten([...this.configuration.map(sn => sn.ownEvents)]))];
|
|
1288
|
+
});
|
|
1289
|
+
};
|
|
1290
|
+
const machineSnapshotMeta = function nextEvents() {
|
|
1291
|
+
return this.configuration.reduce((acc, stateNode) => {
|
|
1292
|
+
if (stateNode.meta !== undefined) {
|
|
1293
|
+
acc[stateNode.id] = stateNode.meta;
|
|
1294
|
+
}
|
|
1295
|
+
return acc;
|
|
1296
|
+
}, {});
|
|
1297
|
+
};
|
|
1298
|
+
function createMachineSnapshot(config, machine) {
|
|
1299
|
+
const snapshot = {
|
|
1300
|
+
status: config.status,
|
|
1301
|
+
output: config.output,
|
|
1302
|
+
error: config.error,
|
|
1303
|
+
machine,
|
|
1304
|
+
context: config.context,
|
|
1305
|
+
configuration: config.configuration,
|
|
1306
|
+
value: getStateValue(machine.root, config.configuration),
|
|
1307
|
+
tags: new Set(flatten(config.configuration.map(sn => sn.tags))),
|
|
1308
|
+
children: config.children,
|
|
1309
|
+
historyValue: config.historyValue || {},
|
|
1310
|
+
// this one is generic in the target and it's hard to create a matching non-generic source signature
|
|
1311
|
+
matches: machineSnapshotMatches,
|
|
1312
|
+
hasTag: machineSnapshotHasTag,
|
|
1313
|
+
can: machineSnapshotCan,
|
|
1314
|
+
toJSON: machineSnapshotToJSON
|
|
1315
|
+
};
|
|
1316
|
+
Object.defineProperties(snapshot, {
|
|
1317
|
+
nextEvents: {
|
|
1318
|
+
get: machineSnapshotNextEvents,
|
|
1319
|
+
configurable: true,
|
|
1320
|
+
enumerable: true
|
|
1321
|
+
},
|
|
1322
|
+
meta: {
|
|
1323
|
+
get: machineSnapshotMeta,
|
|
1324
|
+
configurable: true,
|
|
1325
|
+
enumerable: true
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
return snapshot;
|
|
1422
1329
|
}
|
|
1423
|
-
function
|
|
1424
|
-
return
|
|
1330
|
+
function cloneMachineSnapshot(state, config = {}) {
|
|
1331
|
+
return createMachineSnapshot(
|
|
1332
|
+
// TODO: it's wasteful that this spread triggers getters
|
|
1333
|
+
{
|
|
1425
1334
|
...state,
|
|
1426
1335
|
...config
|
|
1427
1336
|
}, state.machine);
|
|
@@ -1433,6 +1342,11 @@ function getPersistedState(state, options) {
|
|
|
1433
1342
|
machine,
|
|
1434
1343
|
children,
|
|
1435
1344
|
context,
|
|
1345
|
+
can,
|
|
1346
|
+
hasTag,
|
|
1347
|
+
matches,
|
|
1348
|
+
toJSON,
|
|
1349
|
+
nextEvents,
|
|
1436
1350
|
...jsonValues
|
|
1437
1351
|
} = state;
|
|
1438
1352
|
const childrenJson = {};
|
|
@@ -1536,4 +1450,4 @@ function raise(eventOrExpr, options) {
|
|
|
1536
1450
|
return raise;
|
|
1537
1451
|
}
|
|
1538
1452
|
|
|
1539
|
-
export { raise as A, stop as B, spawn as C,
|
|
1453
|
+
export { raise as A, stop as B, spawn as C, formatTransition as a, formatInitialTransition as b, getCandidates as c, getConfiguration as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getStateNodes as h, createMachineSnapshot as i, isInFinalState as j, cloneMachineSnapshot as k, macrostep as l, memo as m, resolveActionsAndContext as n, microstep as o, getInitialStateNodes as p, isStateId as q, resolveStateValue as r, getStateNodeByPath as s, transitionNode as t, getPersistedState as u, and as v, not as w, or as x, stateIn as y, cancel as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-23dea0d7.development.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-4e8e2a0d.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorScope, {
|
|
7
7
|
machine,
|
|
@@ -9,17 +9,15 @@ function createSpawner(actorScope, {
|
|
|
9
9
|
}, event, spawnedChildren) {
|
|
10
10
|
const spawn = (src, options = {}) => {
|
|
11
11
|
const {
|
|
12
|
-
systemId
|
|
12
|
+
systemId,
|
|
13
|
+
input
|
|
13
14
|
} = options;
|
|
14
15
|
if (typeof src === 'string') {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
16
|
+
const logic = interpreter.resolveReferencedActor(machine, src);
|
|
17
|
+
if (!logic) {
|
|
17
18
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
// TODO: this should also receive `src`
|
|
22
|
-
const actorRef = interpreter.createActor(referenced.src, {
|
|
20
|
+
const actorRef = interpreter.createActor(logic, {
|
|
23
21
|
id: options.id,
|
|
24
22
|
parent: actorScope.self,
|
|
25
23
|
input: typeof input === 'function' ? input({
|
|
@@ -112,7 +110,7 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
115
|
-
return [guards_dist_xstateGuards.
|
|
113
|
+
return [guards_dist_xstateGuards.cloneMachineSnapshot(state, {
|
|
116
114
|
context: updatedContext,
|
|
117
115
|
children: Object.keys(spawnedChildren).length ? {
|
|
118
116
|
...state.children,
|
|
@@ -259,6 +257,8 @@ function pure(getActions) {
|
|
|
259
257
|
|
|
260
258
|
// TODO: remove once TS fixes this type-widening issue
|
|
261
259
|
|
|
260
|
+
// TODO: replace with AnyMachineSnapshot
|
|
261
|
+
|
|
262
262
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
263
263
|
|
|
264
264
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray,
|
|
1
|
+
import { k as cloneMachineSnapshot, e as evaluateGuard } from './raise-f4ad5a87.development.esm.js';
|
|
2
|
+
import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, v as XSTATE_ERROR } from './interpreter-80eb3bec.development.esm.js';
|
|
3
3
|
|
|
4
4
|
function createSpawner(actorScope, {
|
|
5
5
|
machine,
|
|
@@ -7,17 +7,15 @@ function createSpawner(actorScope, {
|
|
|
7
7
|
}, event, spawnedChildren) {
|
|
8
8
|
const spawn = (src, options = {}) => {
|
|
9
9
|
const {
|
|
10
|
-
systemId
|
|
10
|
+
systemId,
|
|
11
|
+
input
|
|
11
12
|
} = options;
|
|
12
13
|
if (typeof src === 'string') {
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
14
|
+
const logic = resolveReferencedActor(machine, src);
|
|
15
|
+
if (!logic) {
|
|
15
16
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
// TODO: this should also receive `src`
|
|
20
|
-
const actorRef = createActor(referenced.src, {
|
|
18
|
+
const actorRef = createActor(logic, {
|
|
21
19
|
id: options.id,
|
|
22
20
|
parent: actorScope.self,
|
|
23
21
|
input: typeof input === 'function' ? input({
|
|
@@ -110,7 +108,7 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
110
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
113
|
-
return [
|
|
111
|
+
return [cloneMachineSnapshot(state, {
|
|
114
112
|
context: updatedContext,
|
|
115
113
|
children: Object.keys(spawnedChildren).length ? {
|
|
116
114
|
...state.children,
|
|
@@ -257,6 +255,8 @@ function pure(getActions) {
|
|
|
257
255
|
|
|
258
256
|
// TODO: remove once TS fixes this type-widening issue
|
|
259
257
|
|
|
258
|
+
// TODO: replace with AnyMachineSnapshot
|
|
259
|
+
|
|
260
260
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
261
261
|
|
|
262
262
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray,
|
|
1
|
+
import { k as cloneMachineSnapshot, e as evaluateGuard } from './raise-8dc8e1aa.esm.js';
|
|
2
|
+
import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, v as XSTATE_ERROR } from './interpreter-63c80754.esm.js';
|
|
3
3
|
|
|
4
4
|
function createSpawner(actorScope, {
|
|
5
5
|
machine,
|
|
@@ -7,17 +7,15 @@ function createSpawner(actorScope, {
|
|
|
7
7
|
}, event, spawnedChildren) {
|
|
8
8
|
const spawn = (src, options = {}) => {
|
|
9
9
|
const {
|
|
10
|
-
systemId
|
|
10
|
+
systemId,
|
|
11
|
+
input
|
|
11
12
|
} = options;
|
|
12
13
|
if (typeof src === 'string') {
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
14
|
+
const logic = resolveReferencedActor(machine, src);
|
|
15
|
+
if (!logic) {
|
|
15
16
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
// TODO: this should also receive `src`
|
|
20
|
-
const actorRef = createActor(referenced.src, {
|
|
18
|
+
const actorRef = createActor(logic, {
|
|
21
19
|
id: options.id,
|
|
22
20
|
parent: actorScope.self,
|
|
23
21
|
input: typeof input === 'function' ? input({
|
|
@@ -110,7 +108,7 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
110
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
113
|
-
return [
|
|
111
|
+
return [cloneMachineSnapshot(state, {
|
|
114
112
|
context: updatedContext,
|
|
115
113
|
children: Object.keys(spawnedChildren).length ? {
|
|
116
114
|
...state.children,
|
|
@@ -245,6 +243,8 @@ function pure(getActions) {
|
|
|
245
243
|
|
|
246
244
|
// TODO: remove once TS fixes this type-widening issue
|
|
247
245
|
|
|
246
|
+
// TODO: replace with AnyMachineSnapshot
|
|
247
|
+
|
|
248
248
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
249
249
|
|
|
250
250
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-e0fe5c2d.cjs.js');
|
|
4
|
+
var interpreter = require('./interpreter-36d5556e.cjs.js');
|
|
5
5
|
|
|
6
6
|
function createSpawner(actorScope, {
|
|
7
7
|
machine,
|
|
@@ -9,17 +9,15 @@ function createSpawner(actorScope, {
|
|
|
9
9
|
}, event, spawnedChildren) {
|
|
10
10
|
const spawn = (src, options = {}) => {
|
|
11
11
|
const {
|
|
12
|
-
systemId
|
|
12
|
+
systemId,
|
|
13
|
+
input
|
|
13
14
|
} = options;
|
|
14
15
|
if (typeof src === 'string') {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
16
|
+
const logic = interpreter.resolveReferencedActor(machine, src);
|
|
17
|
+
if (!logic) {
|
|
17
18
|
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
// TODO: this should also receive `src`
|
|
22
|
-
const actorRef = interpreter.createActor(referenced.src, {
|
|
20
|
+
const actorRef = interpreter.createActor(logic, {
|
|
23
21
|
id: options.id,
|
|
24
22
|
parent: actorScope.self,
|
|
25
23
|
input: typeof input === 'function' ? input({
|
|
@@ -112,7 +110,7 @@ function resolveAssign(actorScope, state, actionArgs, actionParams, {
|
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
const updatedContext = Object.assign({}, state.context, partialUpdate);
|
|
115
|
-
return [guards_dist_xstateGuards.
|
|
113
|
+
return [guards_dist_xstateGuards.cloneMachineSnapshot(state, {
|
|
116
114
|
context: updatedContext,
|
|
117
115
|
children: Object.keys(spawnedChildren).length ? {
|
|
118
116
|
...state.children,
|
|
@@ -247,6 +245,8 @@ function pure(getActions) {
|
|
|
247
245
|
|
|
248
246
|
// TODO: remove once TS fixes this type-widening issue
|
|
249
247
|
|
|
248
|
+
// TODO: replace with AnyMachineSnapshot
|
|
249
|
+
|
|
250
250
|
// TODO: possibly refactor this somehow, use even a simpler type, and maybe even make `machine.options` private or something
|
|
251
251
|
|
|
252
252
|
let SpecialTargets = /*#__PURE__*/function (SpecialTargets) {
|