xstate 5.0.0-beta.42 → 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 +5 -5
- package/dist/declarations/src/actions/spawn.d.ts +3 -3
- package/dist/declarations/src/actors/promise.d.ts +53 -0
- package/dist/declarations/src/types.d.ts +41 -6
- package/dist/declarations/src/utils.d.ts +2 -8
- package/dist/{interpreter-b6bdd134.cjs.js → interpreter-36d5556e.cjs.js} +2 -9
- package/dist/{interpreter-23e4041c.development.cjs.js → interpreter-4e8e2a0d.development.cjs.js} +2 -9
- package/dist/{interpreter-3d0c0ff2.esm.js → interpreter-63c80754.esm.js} +2 -9
- package/dist/{interpreter-f2620ea7.development.esm.js → interpreter-80eb3bec.development.esm.js} +2 -9
- package/dist/{raise-8f482ce9.development.cjs.js → raise-23dea0d7.development.cjs.js} +69 -56
- package/dist/{raise-d2084327.esm.js → raise-8dc8e1aa.esm.js} +66 -53
- package/dist/{raise-6b64c553.cjs.js → raise-e0fe5c2d.cjs.js} +66 -53
- package/dist/{raise-51ae36e5.development.esm.js → raise-f4ad5a87.development.esm.js} +69 -56
- package/dist/{send-cc8f864e.development.cjs.js → send-0174c155.development.cjs.js} +7 -9
- package/dist/{send-7a350091.development.esm.js → send-5d129d95.development.esm.js} +7 -9
- package/dist/{send-4e732fa5.esm.js → send-84e2e742.esm.js} +7 -9
- package/dist/{send-85b562d8.cjs.js → send-87bbaaab.cjs.js} +7 -9
- package/dist/xstate.cjs.js +4 -4
- package/dist/xstate.development.cjs.js +4 -4
- package/dist/xstate.development.esm.js +7 -7
- package/dist/xstate.esm.js +7 -7
- 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/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var interpreter = require('./interpreter-
|
|
3
|
+
var interpreter = require('./interpreter-36d5556e.cjs.js');
|
|
4
4
|
|
|
5
5
|
const cache = new WeakMap();
|
|
6
6
|
function memo(object, key, fn) {
|
|
@@ -49,25 +49,20 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
|
|
|
49
49
|
input,
|
|
50
50
|
syncSnapshot
|
|
51
51
|
}) {
|
|
52
|
-
const
|
|
53
|
-
src,
|
|
54
|
-
input: undefined
|
|
55
|
-
};
|
|
52
|
+
const logic = typeof src === 'string' ? interpreter.resolveReferencedActor(state.machine, src) : src;
|
|
56
53
|
const resolvedId = typeof id === 'function' ? id(actionArgs) : id;
|
|
57
54
|
let actorRef;
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
const configuredInput = input || referenced.input;
|
|
61
|
-
actorRef = interpreter.createActor(referenced.src, {
|
|
55
|
+
if (logic) {
|
|
56
|
+
actorRef = interpreter.createActor(logic, {
|
|
62
57
|
id: resolvedId,
|
|
63
58
|
src,
|
|
64
59
|
parent: actorScope?.self,
|
|
65
60
|
systemId,
|
|
66
|
-
input: typeof
|
|
61
|
+
input: typeof input === 'function' ? input({
|
|
67
62
|
context: state.context,
|
|
68
63
|
event: actionArgs.event,
|
|
69
64
|
self: actorScope?.self
|
|
70
|
-
}) :
|
|
65
|
+
}) : input
|
|
71
66
|
});
|
|
72
67
|
if (syncSnapshot) {
|
|
73
68
|
actorRef.subscribe({
|
|
@@ -1223,8 +1218,50 @@ function resolveStateValue(rootNode, stateValue) {
|
|
|
1223
1218
|
return getStateValue(rootNode, [...configuration]);
|
|
1224
1219
|
}
|
|
1225
1220
|
|
|
1226
|
-
function
|
|
1221
|
+
const machineSnapshotMatches = function matches(testValue) {
|
|
1222
|
+
return interpreter.matchesState(testValue, this.value);
|
|
1223
|
+
};
|
|
1224
|
+
const machineSnapshotHasTag = function hasTag(tag) {
|
|
1225
|
+
return this.tags.has(tag);
|
|
1226
|
+
};
|
|
1227
|
+
const machineSnapshotCan = function can(event) {
|
|
1228
|
+
const transitionData = this.machine.getTransitionData(this, event);
|
|
1229
|
+
return !!transitionData?.length &&
|
|
1230
|
+
// Check that at least one transition is not forbidden
|
|
1231
|
+
transitionData.some(t => t.target !== undefined || t.actions.length);
|
|
1232
|
+
};
|
|
1233
|
+
const machineSnapshotToJSON = function toJSON() {
|
|
1234
|
+
const {
|
|
1235
|
+
configuration,
|
|
1236
|
+
tags,
|
|
1237
|
+
machine,
|
|
1238
|
+
nextEvents,
|
|
1239
|
+
toJSON,
|
|
1240
|
+
can,
|
|
1241
|
+
hasTag,
|
|
1242
|
+
matches,
|
|
1243
|
+
...jsonValues
|
|
1244
|
+
} = this;
|
|
1227
1245
|
return {
|
|
1246
|
+
...jsonValues,
|
|
1247
|
+
tags: Array.from(tags)
|
|
1248
|
+
};
|
|
1249
|
+
};
|
|
1250
|
+
const machineSnapshotNextEvents = function nextEvents() {
|
|
1251
|
+
return memo(this, 'nextEvents', () => {
|
|
1252
|
+
return [...new Set(interpreter.flatten([...this.configuration.map(sn => sn.ownEvents)]))];
|
|
1253
|
+
});
|
|
1254
|
+
};
|
|
1255
|
+
const machineSnapshotMeta = function nextEvents() {
|
|
1256
|
+
return this.configuration.reduce((acc, stateNode) => {
|
|
1257
|
+
if (stateNode.meta !== undefined) {
|
|
1258
|
+
acc[stateNode.id] = stateNode.meta;
|
|
1259
|
+
}
|
|
1260
|
+
return acc;
|
|
1261
|
+
}, {});
|
|
1262
|
+
};
|
|
1263
|
+
function createMachineSnapshot(config, machine) {
|
|
1264
|
+
const snapshot = {
|
|
1228
1265
|
status: config.status,
|
|
1229
1266
|
output: config.output,
|
|
1230
1267
|
error: config.error,
|
|
@@ -1235,49 +1272,25 @@ function createMachineSnapshot(config, machine) {
|
|
|
1235
1272
|
tags: new Set(interpreter.flatten(config.configuration.map(sn => sn.tags))),
|
|
1236
1273
|
children: config.children,
|
|
1237
1274
|
historyValue: config.historyValue || {},
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
},
|
|
1250
|
-
get nextEvents() {
|
|
1251
|
-
return memo(this, 'nextEvents', () => {
|
|
1252
|
-
return [...new Set(interpreter.flatten([...this.configuration.map(sn => sn.ownEvents)]))];
|
|
1253
|
-
});
|
|
1254
|
-
},
|
|
1255
|
-
get meta() {
|
|
1256
|
-
return this.configuration.reduce((acc, stateNode) => {
|
|
1257
|
-
if (stateNode.meta !== undefined) {
|
|
1258
|
-
acc[stateNode.id] = stateNode.meta;
|
|
1259
|
-
}
|
|
1260
|
-
return acc;
|
|
1261
|
-
}, {});
|
|
1275
|
+
// this one is generic in the target and it's hard to create a matching non-generic source signature
|
|
1276
|
+
matches: machineSnapshotMatches,
|
|
1277
|
+
hasTag: machineSnapshotHasTag,
|
|
1278
|
+
can: machineSnapshotCan,
|
|
1279
|
+
toJSON: machineSnapshotToJSON
|
|
1280
|
+
};
|
|
1281
|
+
Object.defineProperties(snapshot, {
|
|
1282
|
+
nextEvents: {
|
|
1283
|
+
get: machineSnapshotNextEvents,
|
|
1284
|
+
configurable: true,
|
|
1285
|
+
enumerable: true
|
|
1262
1286
|
},
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
machine,
|
|
1268
|
-
nextEvents,
|
|
1269
|
-
toJSON,
|
|
1270
|
-
can,
|
|
1271
|
-
hasTag,
|
|
1272
|
-
matches,
|
|
1273
|
-
...jsonValues
|
|
1274
|
-
} = this;
|
|
1275
|
-
return {
|
|
1276
|
-
...jsonValues,
|
|
1277
|
-
tags: Array.from(tags)
|
|
1278
|
-
};
|
|
1287
|
+
meta: {
|
|
1288
|
+
get: machineSnapshotMeta,
|
|
1289
|
+
configurable: true,
|
|
1290
|
+
enumerable: true
|
|
1279
1291
|
}
|
|
1280
|
-
};
|
|
1292
|
+
});
|
|
1293
|
+
return snapshot;
|
|
1281
1294
|
}
|
|
1282
1295
|
function cloneMachineSnapshot(state, config = {}) {
|
|
1283
1296
|
return createMachineSnapshot(
|
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
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({
|
|
@@ -1255,8 +1250,53 @@ function resolveStateValue(rootNode, stateValue) {
|
|
|
1255
1250
|
return getStateValue(rootNode, [...configuration]);
|
|
1256
1251
|
}
|
|
1257
1252
|
|
|
1258
|
-
function
|
|
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;
|
|
1259
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 = {
|
|
1260
1300
|
status: config.status,
|
|
1261
1301
|
output: config.output,
|
|
1262
1302
|
error: config.error,
|
|
@@ -1267,52 +1307,25 @@ function createMachineSnapshot(config, machine) {
|
|
|
1267
1307
|
tags: new Set(flatten(config.configuration.map(sn => sn.tags))),
|
|
1268
1308
|
children: config.children,
|
|
1269
1309
|
historyValue: config.historyValue || {},
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
return !!transitionData?.length &&
|
|
1282
|
-
// Check that at least one transition is not forbidden
|
|
1283
|
-
transitionData.some(t => t.target !== undefined || t.actions.length);
|
|
1284
|
-
},
|
|
1285
|
-
get nextEvents() {
|
|
1286
|
-
return memo(this, 'nextEvents', () => {
|
|
1287
|
-
return [...new Set(flatten([...this.configuration.map(sn => sn.ownEvents)]))];
|
|
1288
|
-
});
|
|
1289
|
-
},
|
|
1290
|
-
get meta() {
|
|
1291
|
-
return this.configuration.reduce((acc, stateNode) => {
|
|
1292
|
-
if (stateNode.meta !== undefined) {
|
|
1293
|
-
acc[stateNode.id] = stateNode.meta;
|
|
1294
|
-
}
|
|
1295
|
-
return acc;
|
|
1296
|
-
}, {});
|
|
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
|
|
1297
1321
|
},
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
machine,
|
|
1303
|
-
nextEvents,
|
|
1304
|
-
toJSON,
|
|
1305
|
-
can,
|
|
1306
|
-
hasTag,
|
|
1307
|
-
matches,
|
|
1308
|
-
...jsonValues
|
|
1309
|
-
} = this;
|
|
1310
|
-
return {
|
|
1311
|
-
...jsonValues,
|
|
1312
|
-
tags: Array.from(tags)
|
|
1313
|
-
};
|
|
1322
|
+
meta: {
|
|
1323
|
+
get: machineSnapshotMeta,
|
|
1324
|
+
configurable: true,
|
|
1325
|
+
enumerable: true
|
|
1314
1326
|
}
|
|
1315
|
-
};
|
|
1327
|
+
});
|
|
1328
|
+
return snapshot;
|
|
1316
1329
|
}
|
|
1317
1330
|
function cloneMachineSnapshot(state, config = {}) {
|
|
1318
1331
|
return createMachineSnapshot(
|
|
@@ -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({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as cloneMachineSnapshot, e as evaluateGuard } from './raise-
|
|
2
|
-
import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, v as XSTATE_ERROR } from './interpreter-
|
|
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({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as cloneMachineSnapshot, e as evaluateGuard } from './raise-
|
|
2
|
-
import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, v as XSTATE_ERROR } from './interpreter-
|
|
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({
|
|
@@ -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({
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
|
|
6
|
-
var interpreter = require('./interpreter-
|
|
7
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
8
|
-
var send = require('./send-
|
|
6
|
+
var interpreter = require('./interpreter-36d5556e.cjs.js');
|
|
7
|
+
var guards_dist_xstateGuards = require('./raise-e0fe5c2d.cjs.js');
|
|
8
|
+
var send = require('./send-87bbaaab.cjs.js');
|
|
9
9
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
10
10
|
|
|
11
11
|
class SimulatedClock {
|
|
@@ -576,7 +576,7 @@ class StateMachine {
|
|
|
576
576
|
const actorData = snapshotChildren[actorId];
|
|
577
577
|
const childState = actorData.state;
|
|
578
578
|
const src = actorData.src;
|
|
579
|
-
const logic = typeof src === 'string' ? interpreter.resolveReferencedActor(this, src)
|
|
579
|
+
const logic = typeof src === 'string' ? interpreter.resolveReferencedActor(this, src) : src;
|
|
580
580
|
if (!logic) {
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var actors_dist_xstateActors = require('../actors/dist/xstate-actors.development.cjs.js');
|
|
6
|
-
var interpreter = require('./interpreter-
|
|
7
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
8
|
-
var send = require('./send-
|
|
6
|
+
var interpreter = require('./interpreter-4e8e2a0d.development.cjs.js');
|
|
7
|
+
var guards_dist_xstateGuards = require('./raise-23dea0d7.development.cjs.js');
|
|
8
|
+
var send = require('./send-0174c155.development.cjs.js');
|
|
9
9
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
10
10
|
|
|
11
11
|
class SimulatedClock {
|
|
@@ -579,7 +579,7 @@ class StateMachine {
|
|
|
579
579
|
const actorData = snapshotChildren[actorId];
|
|
580
580
|
const childState = actorData.state;
|
|
581
581
|
const src = actorData.src;
|
|
582
|
-
const logic = typeof src === 'string' ? interpreter.resolveReferencedActor(this, src)
|
|
582
|
+
const logic = typeof src === 'string' ? interpreter.resolveReferencedActor(this, src) : src;
|
|
583
583
|
if (!logic) {
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE } from './interpreter-
|
|
3
|
-
export { A as Actor, d as createActor, e as interpret, f as matchesState, p as pathToStateValue, g as toObserver } from './interpreter-
|
|
4
|
-
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, r as resolveStateValue, d as getConfiguration, h as getStateNodes, i as createMachineSnapshot, j as isInFinalState, k as cloneMachineSnapshot, l as macrostep, t as transitionNode, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-
|
|
5
|
-
export { v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-
|
|
6
|
-
import { a as assign } from './send-
|
|
7
|
-
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE } from './interpreter-80eb3bec.development.esm.js';
|
|
3
|
+
export { A as Actor, d as createActor, e as interpret, f as matchesState, p as pathToStateValue, g as toObserver } from './interpreter-80eb3bec.development.esm.js';
|
|
4
|
+
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, r as resolveStateValue, d as getConfiguration, h as getStateNodes, i as createMachineSnapshot, j as isInFinalState, k as cloneMachineSnapshot, l as macrostep, t as transitionNode, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-f4ad5a87.development.esm.js';
|
|
5
|
+
export { v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-f4ad5a87.development.esm.js';
|
|
6
|
+
import { a as assign } from './send-5d129d95.development.esm.js';
|
|
7
|
+
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-5d129d95.development.esm.js';
|
|
8
8
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -578,7 +578,7 @@ class StateMachine {
|
|
|
578
578
|
const actorData = snapshotChildren[actorId];
|
|
579
579
|
const childState = actorData.state;
|
|
580
580
|
const src = actorData.src;
|
|
581
|
-
const logic = typeof src === 'string' ? resolveReferencedActor(this, src)
|
|
581
|
+
const logic = typeof src === 'string' ? resolveReferencedActor(this, src) : src;
|
|
582
582
|
if (!logic) {
|
|
583
583
|
return;
|
|
584
584
|
}
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
|
|
2
|
-
import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE } from './interpreter-
|
|
3
|
-
export { A as Actor, d as createActor, e as interpret, f as matchesState, p as pathToStateValue, g as toObserver } from './interpreter-
|
|
4
|
-
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, r as resolveStateValue, d as getConfiguration, h as getStateNodes, i as createMachineSnapshot, j as isInFinalState, k as cloneMachineSnapshot, l as macrostep, t as transitionNode, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-
|
|
5
|
-
export { v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-
|
|
6
|
-
import { a as assign } from './send-
|
|
7
|
-
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-
|
|
2
|
+
import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE } from './interpreter-63c80754.esm.js';
|
|
3
|
+
export { A as Actor, d as createActor, e as interpret, f as matchesState, p as pathToStateValue, g as toObserver } from './interpreter-63c80754.esm.js';
|
|
4
|
+
import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, r as resolveStateValue, d as getConfiguration, h as getStateNodes, i as createMachineSnapshot, j as isInFinalState, k as cloneMachineSnapshot, l as macrostep, t as transitionNode, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-8dc8e1aa.esm.js';
|
|
5
|
+
export { v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-8dc8e1aa.esm.js';
|
|
6
|
+
import { a as assign } from './send-84e2e742.esm.js';
|
|
7
|
+
export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-84e2e742.esm.js';
|
|
8
8
|
import '../dev/dist/xstate-dev.esm.js';
|
|
9
9
|
|
|
10
10
|
class SimulatedClock {
|
|
@@ -575,7 +575,7 @@ class StateMachine {
|
|
|
575
575
|
const actorData = snapshotChildren[actorId];
|
|
576
576
|
const childState = actorData.state;
|
|
577
577
|
const src = actorData.src;
|
|
578
|
-
const logic = typeof src === 'string' ? resolveReferencedActor(this, src)
|
|
578
|
+
const logic = typeof src === 'string' ? resolveReferencedActor(this, src) : src;
|
|
579
579
|
if (!logic) {
|
|
580
580
|
return;
|
|
581
581
|
}
|