xstate 5.0.0-beta.45 → 5.0.0-beta.47
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 +4 -3
- package/actions/dist/xstate-actions.cjs.mjs +3 -2
- package/actions/dist/xstate-actions.development.cjs.js +4 -3
- package/actions/dist/xstate-actions.development.cjs.mjs +3 -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 +42 -5
- package/actors/dist/xstate-actors.development.cjs.js +42 -5
- package/actors/dist/xstate-actors.development.esm.js +42 -5
- package/actors/dist/xstate-actors.esm.js +42 -5
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/declarations/src/State.d.ts +16 -26
- package/dist/declarations/src/StateMachine.d.ts +11 -29
- package/dist/declarations/src/StateNode.d.ts +8 -6
- package/dist/declarations/src/actions/{spawn.d.ts → spawnChild.d.ts} +1 -1
- package/dist/declarations/src/actions/{stop.d.ts → stopChild.d.ts} +8 -2
- package/dist/declarations/src/actions.d.ts +2 -2
- package/dist/declarations/src/actors/observable.d.ts +41 -4
- package/dist/declarations/src/createMachine.d.ts +3 -3
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/setup.d.ts +11 -8
- package/dist/declarations/src/types.d.ts +41 -15
- package/dist/declarations/src/utils.d.ts +2 -1
- package/dist/{raise-90139fbc.development.esm.js → raise-156f5f68.development.esm.js} +47 -53
- package/dist/{raise-fabffc3d.cjs.js → raise-7af24c22.cjs.js} +49 -53
- package/dist/{raise-b3fb3c65.development.cjs.js → raise-7dc97582.development.cjs.js} +49 -53
- package/dist/{raise-2b5a4e4c.esm.js → raise-91ec8b4f.esm.js} +47 -53
- package/dist/{send-c124176f.cjs.js → send-401f5c30.cjs.js} +22 -1
- package/dist/{send-24cc8018.development.esm.js → send-7489590c.development.esm.js} +22 -1
- package/dist/{send-d0bc7eed.development.cjs.js → send-bc0d3e22.development.cjs.js} +22 -1
- package/dist/{send-8e7e41e7.esm.js → send-ed326064.esm.js} +22 -1
- package/dist/xstate.cjs.js +61 -82
- package/dist/xstate.cjs.mjs +3 -1
- package/dist/xstate.development.cjs.js +61 -82
- package/dist/xstate.development.cjs.mjs +3 -1
- package/dist/xstate.development.esm.js +60 -83
- package/dist/xstate.esm.js +60 -83
- 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.map +1 -1
- package/package.json +1 -1
|
@@ -318,6 +318,9 @@ function resolveReferencedActor(machine, src) {
|
|
|
318
318
|
}
|
|
319
319
|
return machine.implementations.actors[src];
|
|
320
320
|
}
|
|
321
|
+
function getAllOwnEventDescriptors(snapshot) {
|
|
322
|
+
return [...new Set(flatten([...snapshot._nodes.map(sn => sn.ownEvents)]))];
|
|
323
|
+
}
|
|
321
324
|
|
|
322
325
|
const $$ACTOR_TYPE = 1;
|
|
323
326
|
// those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
|
|
@@ -344,32 +347,6 @@ const defaultOptions = {
|
|
|
344
347
|
* An Actor is a running process that can receive events, send events and change its behavior based on the events it receives, which can cause effects outside of the actor. When you run a state machine, it becomes an actor.
|
|
345
348
|
*/
|
|
346
349
|
class Actor {
|
|
347
|
-
/**
|
|
348
|
-
* The current internal state of the actor.
|
|
349
|
-
*/
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
353
|
-
*/
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* The unique identifier for this actor relative to its parent.
|
|
357
|
-
*/
|
|
358
|
-
|
|
359
|
-
/** @internal */
|
|
360
|
-
|
|
361
|
-
// Actor Ref
|
|
362
|
-
|
|
363
|
-
// TODO: add typings for system
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* The globally unique process ID for this invocation.
|
|
367
|
-
*/
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* The system to which this actor belongs.
|
|
371
|
-
*/
|
|
372
|
-
|
|
373
350
|
/**
|
|
374
351
|
* Creates a new actor instance for the given logic with the provided options, if any.
|
|
375
352
|
*
|
|
@@ -378,24 +355,43 @@ class Actor {
|
|
|
378
355
|
*/
|
|
379
356
|
constructor(logic, options) {
|
|
380
357
|
this.logic = logic;
|
|
358
|
+
/**
|
|
359
|
+
* The current internal state of the actor.
|
|
360
|
+
*/
|
|
381
361
|
this._state = void 0;
|
|
362
|
+
/**
|
|
363
|
+
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
364
|
+
*/
|
|
382
365
|
this.clock = void 0;
|
|
383
366
|
this.options = void 0;
|
|
367
|
+
/**
|
|
368
|
+
* The unique identifier for this actor relative to its parent.
|
|
369
|
+
*/
|
|
384
370
|
this.id = void 0;
|
|
385
371
|
this.mailbox = new Mailbox(this._process.bind(this));
|
|
386
372
|
this.delayedEventsMap = {};
|
|
387
373
|
this.observers = new Set();
|
|
388
374
|
this.logger = void 0;
|
|
375
|
+
/** @internal */
|
|
389
376
|
this._processingStatus = ProcessingStatus.NotStarted;
|
|
377
|
+
// Actor Ref
|
|
390
378
|
this._parent = void 0;
|
|
391
379
|
this._syncSnapshot = void 0;
|
|
392
380
|
this.ref = void 0;
|
|
381
|
+
// TODO: add typings for system
|
|
393
382
|
this._actorScope = void 0;
|
|
394
383
|
this._systemId = void 0;
|
|
384
|
+
/**
|
|
385
|
+
* The globally unique process ID for this invocation.
|
|
386
|
+
*/
|
|
395
387
|
this.sessionId = void 0;
|
|
388
|
+
/**
|
|
389
|
+
* The system to which this actor belongs.
|
|
390
|
+
*/
|
|
396
391
|
this.system = void 0;
|
|
397
392
|
this._doneEvent = void 0;
|
|
398
393
|
this.src = void 0;
|
|
394
|
+
// array of functions to defer
|
|
399
395
|
this._deferred = [];
|
|
400
396
|
const resolvedOptions = {
|
|
401
397
|
...defaultOptions,
|
|
@@ -460,9 +456,6 @@ class Actor {
|
|
|
460
456
|
_initState(persistedState) {
|
|
461
457
|
this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
|
|
462
458
|
}
|
|
463
|
-
|
|
464
|
-
// array of functions to defer
|
|
465
|
-
|
|
466
459
|
update(snapshot, event) {
|
|
467
460
|
// Update state
|
|
468
461
|
this._state = snapshot;
|
|
@@ -948,23 +941,23 @@ function executeSpawn(actorScope, {
|
|
|
948
941
|
}
|
|
949
942
|
});
|
|
950
943
|
}
|
|
951
|
-
function
|
|
944
|
+
function spawnChild(...[src, {
|
|
952
945
|
id,
|
|
953
946
|
systemId,
|
|
954
947
|
input,
|
|
955
948
|
syncSnapshot = false
|
|
956
949
|
} = {}]) {
|
|
957
|
-
function
|
|
950
|
+
function spawnChild(args, params) {
|
|
958
951
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
return
|
|
952
|
+
spawnChild.type = 'xstate.spawnChild';
|
|
953
|
+
spawnChild.id = id;
|
|
954
|
+
spawnChild.systemId = systemId;
|
|
955
|
+
spawnChild.src = src;
|
|
956
|
+
spawnChild.input = input;
|
|
957
|
+
spawnChild.syncSnapshot = syncSnapshot;
|
|
958
|
+
spawnChild.resolve = resolveSpawn;
|
|
959
|
+
spawnChild.execute = executeSpawn;
|
|
960
|
+
return spawnChild;
|
|
968
961
|
}
|
|
969
962
|
|
|
970
963
|
function resolveStop(_, state, args, actionParams, {
|
|
@@ -1008,20 +1001,27 @@ function executeStop(actorScope, actorRef) {
|
|
|
1008
1001
|
});
|
|
1009
1002
|
}
|
|
1010
1003
|
/**
|
|
1011
|
-
* Stops
|
|
1004
|
+
* Stops a child actor.
|
|
1012
1005
|
*
|
|
1013
1006
|
* @param actorRef The actor to stop.
|
|
1014
1007
|
*/
|
|
1015
|
-
function
|
|
1008
|
+
function stopChild(actorRef) {
|
|
1016
1009
|
function stop(args, params) {
|
|
1017
1010
|
}
|
|
1018
|
-
stop.type = 'xstate.
|
|
1011
|
+
stop.type = 'xstate.stopChild';
|
|
1019
1012
|
stop.actorRef = actorRef;
|
|
1020
1013
|
stop.resolve = resolveStop;
|
|
1021
1014
|
stop.execute = executeStop;
|
|
1022
1015
|
return stop;
|
|
1023
1016
|
}
|
|
1024
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* Stops a child actor.
|
|
1020
|
+
*
|
|
1021
|
+
* @deprecated Use `stopChild(...)` instead
|
|
1022
|
+
*/
|
|
1023
|
+
const stop = stopChild;
|
|
1024
|
+
|
|
1025
1025
|
function checkStateIn(state, _, {
|
|
1026
1026
|
stateValue
|
|
1027
1027
|
}) {
|
|
@@ -1750,7 +1750,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
|
|
|
1750
1750
|
// Add entry actions
|
|
1751
1751
|
actions.push(...stateNodeToEnter.entry);
|
|
1752
1752
|
for (const invokeDef of stateNodeToEnter.invoke) {
|
|
1753
|
-
actions.push(
|
|
1753
|
+
actions.push(spawnChild(invokeDef.src, {
|
|
1754
1754
|
...invokeDef,
|
|
1755
1755
|
syncSnapshot: !!invokeDef.onSnapshot
|
|
1756
1756
|
}));
|
|
@@ -1901,7 +1901,7 @@ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSe
|
|
|
1901
1901
|
}
|
|
1902
1902
|
}
|
|
1903
1903
|
for (const s of statesToExit) {
|
|
1904
|
-
nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def =>
|
|
1904
|
+
nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
|
|
1905
1905
|
mutStateNodeSet.delete(s);
|
|
1906
1906
|
}
|
|
1907
1907
|
return [nextState, changedHistory || historyValue];
|
|
@@ -2024,7 +2024,7 @@ function macrostep(state, event, actorScope, internalQueue = []) {
|
|
|
2024
2024
|
};
|
|
2025
2025
|
}
|
|
2026
2026
|
function stopChildren(nextState, event, actorScope) {
|
|
2027
|
-
return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child =>
|
|
2027
|
+
return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);
|
|
2028
2028
|
}
|
|
2029
2029
|
function selectTransitions(event, nextState) {
|
|
2030
2030
|
return nextState.machine.getTransitionData(nextState, event);
|
|
@@ -2078,7 +2078,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2078
2078
|
_nodes: nodes,
|
|
2079
2079
|
tags,
|
|
2080
2080
|
machine,
|
|
2081
|
-
getNextEvents,
|
|
2082
2081
|
getMeta,
|
|
2083
2082
|
toJSON,
|
|
2084
2083
|
can,
|
|
@@ -2091,9 +2090,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2091
2090
|
tags: Array.from(tags)
|
|
2092
2091
|
};
|
|
2093
2092
|
};
|
|
2094
|
-
const machineSnapshotGetNextEvents = function getNextEvents() {
|
|
2095
|
-
return [...new Set(flatten([...this._nodes.map(sn => sn.ownEvents)]))];
|
|
2096
|
-
};
|
|
2097
2093
|
const machineSnapshotGetMeta = function getMeta() {
|
|
2098
2094
|
return this._nodes.reduce((acc, stateNode) => {
|
|
2099
2095
|
if (stateNode.meta !== undefined) {
|
|
@@ -2118,7 +2114,6 @@ function createMachineSnapshot(config, machine) {
|
|
|
2118
2114
|
matches: machineSnapshotMatches,
|
|
2119
2115
|
hasTag: machineSnapshotHasTag,
|
|
2120
2116
|
can: machineSnapshotCan,
|
|
2121
|
-
getNextEvents: machineSnapshotGetNextEvents,
|
|
2122
2117
|
getMeta: machineSnapshotGetMeta,
|
|
2123
2118
|
toJSON: machineSnapshotToJSON
|
|
2124
2119
|
};
|
|
@@ -2139,7 +2134,6 @@ function getPersistedState(state, options) {
|
|
|
2139
2134
|
can,
|
|
2140
2135
|
hasTag,
|
|
2141
2136
|
matches,
|
|
2142
|
-
getNextEvents,
|
|
2143
2137
|
getMeta,
|
|
2144
2138
|
toJSON,
|
|
2145
2139
|
...jsonValues
|
|
@@ -2259,6 +2253,7 @@ exports.evaluateGuard = evaluateGuard;
|
|
|
2259
2253
|
exports.formatInitialTransition = formatInitialTransition;
|
|
2260
2254
|
exports.formatTransition = formatTransition;
|
|
2261
2255
|
exports.formatTransitions = formatTransitions;
|
|
2256
|
+
exports.getAllOwnEventDescriptors = getAllOwnEventDescriptors;
|
|
2262
2257
|
exports.getAllStateNodes = getAllStateNodes;
|
|
2263
2258
|
exports.getCandidates = getCandidates;
|
|
2264
2259
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
@@ -2282,9 +2277,10 @@ exports.raise = raise;
|
|
|
2282
2277
|
exports.resolveActionsAndContext = resolveActionsAndContext;
|
|
2283
2278
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
2284
2279
|
exports.resolveStateValue = resolveStateValue;
|
|
2285
|
-
exports.
|
|
2280
|
+
exports.spawnChild = spawnChild;
|
|
2286
2281
|
exports.stateIn = stateIn;
|
|
2287
2282
|
exports.stop = stop;
|
|
2283
|
+
exports.stopChild = stopChild;
|
|
2288
2284
|
exports.toArray = toArray;
|
|
2289
2285
|
exports.toObserver = toObserver;
|
|
2290
2286
|
exports.toTransitionConfigArray = toTransitionConfigArray;
|
|
@@ -321,6 +321,9 @@ function resolveReferencedActor(machine, src) {
|
|
|
321
321
|
}
|
|
322
322
|
return machine.implementations.actors[src];
|
|
323
323
|
}
|
|
324
|
+
function getAllOwnEventDescriptors(snapshot) {
|
|
325
|
+
return [...new Set(flatten([...snapshot._nodes.map(sn => sn.ownEvents)]))];
|
|
326
|
+
}
|
|
324
327
|
|
|
325
328
|
const $$ACTOR_TYPE = 1;
|
|
326
329
|
// those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
|
|
@@ -347,32 +350,6 @@ const defaultOptions = {
|
|
|
347
350
|
* An Actor is a running process that can receive events, send events and change its behavior based on the events it receives, which can cause effects outside of the actor. When you run a state machine, it becomes an actor.
|
|
348
351
|
*/
|
|
349
352
|
class Actor {
|
|
350
|
-
/**
|
|
351
|
-
* The current internal state of the actor.
|
|
352
|
-
*/
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* The unique identifier for this actor relative to its parent.
|
|
360
|
-
*/
|
|
361
|
-
|
|
362
|
-
/** @internal */
|
|
363
|
-
|
|
364
|
-
// Actor Ref
|
|
365
|
-
|
|
366
|
-
// TODO: add typings for system
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* The globally unique process ID for this invocation.
|
|
370
|
-
*/
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* The system to which this actor belongs.
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
353
|
/**
|
|
377
354
|
* Creates a new actor instance for the given logic with the provided options, if any.
|
|
378
355
|
*
|
|
@@ -381,24 +358,43 @@ class Actor {
|
|
|
381
358
|
*/
|
|
382
359
|
constructor(logic, options) {
|
|
383
360
|
this.logic = logic;
|
|
361
|
+
/**
|
|
362
|
+
* The current internal state of the actor.
|
|
363
|
+
*/
|
|
384
364
|
this._state = void 0;
|
|
365
|
+
/**
|
|
366
|
+
* The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
|
|
367
|
+
*/
|
|
385
368
|
this.clock = void 0;
|
|
386
369
|
this.options = void 0;
|
|
370
|
+
/**
|
|
371
|
+
* The unique identifier for this actor relative to its parent.
|
|
372
|
+
*/
|
|
387
373
|
this.id = void 0;
|
|
388
374
|
this.mailbox = new Mailbox(this._process.bind(this));
|
|
389
375
|
this.delayedEventsMap = {};
|
|
390
376
|
this.observers = new Set();
|
|
391
377
|
this.logger = void 0;
|
|
378
|
+
/** @internal */
|
|
392
379
|
this._processingStatus = ProcessingStatus.NotStarted;
|
|
380
|
+
// Actor Ref
|
|
393
381
|
this._parent = void 0;
|
|
394
382
|
this._syncSnapshot = void 0;
|
|
395
383
|
this.ref = void 0;
|
|
384
|
+
// TODO: add typings for system
|
|
396
385
|
this._actorScope = void 0;
|
|
397
386
|
this._systemId = void 0;
|
|
387
|
+
/**
|
|
388
|
+
* The globally unique process ID for this invocation.
|
|
389
|
+
*/
|
|
398
390
|
this.sessionId = void 0;
|
|
391
|
+
/**
|
|
392
|
+
* The system to which this actor belongs.
|
|
393
|
+
*/
|
|
399
394
|
this.system = void 0;
|
|
400
395
|
this._doneEvent = void 0;
|
|
401
396
|
this.src = void 0;
|
|
397
|
+
// array of functions to defer
|
|
402
398
|
this._deferred = [];
|
|
403
399
|
const resolvedOptions = {
|
|
404
400
|
...defaultOptions,
|
|
@@ -463,9 +459,6 @@ class Actor {
|
|
|
463
459
|
_initState(persistedState) {
|
|
464
460
|
this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
|
|
465
461
|
}
|
|
466
|
-
|
|
467
|
-
// array of functions to defer
|
|
468
|
-
|
|
469
462
|
update(snapshot, event) {
|
|
470
463
|
// Update state
|
|
471
464
|
this._state = snapshot;
|
|
@@ -965,26 +958,26 @@ function executeSpawn(actorScope, {
|
|
|
965
958
|
}
|
|
966
959
|
});
|
|
967
960
|
}
|
|
968
|
-
function
|
|
961
|
+
function spawnChild(...[src, {
|
|
969
962
|
id,
|
|
970
963
|
systemId,
|
|
971
964
|
input,
|
|
972
965
|
syncSnapshot = false
|
|
973
966
|
} = {}]) {
|
|
974
|
-
function
|
|
967
|
+
function spawnChild(args, params) {
|
|
975
968
|
{
|
|
976
969
|
throw new Error(`This isn't supposed to be called`);
|
|
977
970
|
}
|
|
978
971
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
return
|
|
972
|
+
spawnChild.type = 'xstate.spawnChild';
|
|
973
|
+
spawnChild.id = id;
|
|
974
|
+
spawnChild.systemId = systemId;
|
|
975
|
+
spawnChild.src = src;
|
|
976
|
+
spawnChild.input = input;
|
|
977
|
+
spawnChild.syncSnapshot = syncSnapshot;
|
|
978
|
+
spawnChild.resolve = resolveSpawn;
|
|
979
|
+
spawnChild.execute = executeSpawn;
|
|
980
|
+
return spawnChild;
|
|
988
981
|
}
|
|
989
982
|
|
|
990
983
|
function resolveStop(_, state, args, actionParams, {
|
|
@@ -1028,23 +1021,30 @@ function executeStop(actorScope, actorRef) {
|
|
|
1028
1021
|
});
|
|
1029
1022
|
}
|
|
1030
1023
|
/**
|
|
1031
|
-
* Stops
|
|
1024
|
+
* Stops a child actor.
|
|
1032
1025
|
*
|
|
1033
1026
|
* @param actorRef The actor to stop.
|
|
1034
1027
|
*/
|
|
1035
|
-
function
|
|
1028
|
+
function stopChild(actorRef) {
|
|
1036
1029
|
function stop(args, params) {
|
|
1037
1030
|
{
|
|
1038
1031
|
throw new Error(`This isn't supposed to be called`);
|
|
1039
1032
|
}
|
|
1040
1033
|
}
|
|
1041
|
-
stop.type = 'xstate.
|
|
1034
|
+
stop.type = 'xstate.stopChild';
|
|
1042
1035
|
stop.actorRef = actorRef;
|
|
1043
1036
|
stop.resolve = resolveStop;
|
|
1044
1037
|
stop.execute = executeStop;
|
|
1045
1038
|
return stop;
|
|
1046
1039
|
}
|
|
1047
1040
|
|
|
1041
|
+
/**
|
|
1042
|
+
* Stops a child actor.
|
|
1043
|
+
*
|
|
1044
|
+
* @deprecated Use `stopChild(...)` instead
|
|
1045
|
+
*/
|
|
1046
|
+
const stop = stopChild;
|
|
1047
|
+
|
|
1048
1048
|
function checkStateIn(state, _, {
|
|
1049
1049
|
stateValue
|
|
1050
1050
|
}) {
|
|
@@ -1792,7 +1792,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
|
|
|
1792
1792
|
// Add entry actions
|
|
1793
1793
|
actions.push(...stateNodeToEnter.entry);
|
|
1794
1794
|
for (const invokeDef of stateNodeToEnter.invoke) {
|
|
1795
|
-
actions.push(
|
|
1795
|
+
actions.push(spawnChild(invokeDef.src, {
|
|
1796
1796
|
...invokeDef,
|
|
1797
1797
|
syncSnapshot: !!invokeDef.onSnapshot
|
|
1798
1798
|
}));
|
|
@@ -1943,7 +1943,7 @@ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSe
|
|
|
1943
1943
|
}
|
|
1944
1944
|
}
|
|
1945
1945
|
for (const s of statesToExit) {
|
|
1946
|
-
nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def =>
|
|
1946
|
+
nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
|
|
1947
1947
|
mutStateNodeSet.delete(s);
|
|
1948
1948
|
}
|
|
1949
1949
|
return [nextState, changedHistory || historyValue];
|
|
@@ -2069,7 +2069,7 @@ function macrostep(state, event, actorScope, internalQueue = []) {
|
|
|
2069
2069
|
};
|
|
2070
2070
|
}
|
|
2071
2071
|
function stopChildren(nextState, event, actorScope) {
|
|
2072
|
-
return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child =>
|
|
2072
|
+
return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);
|
|
2073
2073
|
}
|
|
2074
2074
|
function selectTransitions(event, nextState) {
|
|
2075
2075
|
return nextState.machine.getTransitionData(nextState, event);
|
|
@@ -2126,7 +2126,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2126
2126
|
_nodes: nodes,
|
|
2127
2127
|
tags,
|
|
2128
2128
|
machine,
|
|
2129
|
-
getNextEvents,
|
|
2130
2129
|
getMeta,
|
|
2131
2130
|
toJSON,
|
|
2132
2131
|
can,
|
|
@@ -2139,9 +2138,6 @@ const machineSnapshotToJSON = function toJSON() {
|
|
|
2139
2138
|
tags: Array.from(tags)
|
|
2140
2139
|
};
|
|
2141
2140
|
};
|
|
2142
|
-
const machineSnapshotGetNextEvents = function getNextEvents() {
|
|
2143
|
-
return [...new Set(flatten([...this._nodes.map(sn => sn.ownEvents)]))];
|
|
2144
|
-
};
|
|
2145
2141
|
const machineSnapshotGetMeta = function getMeta() {
|
|
2146
2142
|
return this._nodes.reduce((acc, stateNode) => {
|
|
2147
2143
|
if (stateNode.meta !== undefined) {
|
|
@@ -2166,7 +2162,6 @@ function createMachineSnapshot(config, machine) {
|
|
|
2166
2162
|
matches: machineSnapshotMatches,
|
|
2167
2163
|
hasTag: machineSnapshotHasTag,
|
|
2168
2164
|
can: machineSnapshotCan,
|
|
2169
|
-
getNextEvents: machineSnapshotGetNextEvents,
|
|
2170
2165
|
getMeta: machineSnapshotGetMeta,
|
|
2171
2166
|
toJSON: machineSnapshotToJSON
|
|
2172
2167
|
};
|
|
@@ -2187,7 +2182,6 @@ function getPersistedState(state, options) {
|
|
|
2187
2182
|
can,
|
|
2188
2183
|
hasTag,
|
|
2189
2184
|
matches,
|
|
2190
|
-
getNextEvents,
|
|
2191
2185
|
getMeta,
|
|
2192
2186
|
toJSON,
|
|
2193
2187
|
...jsonValues
|
|
@@ -2313,6 +2307,7 @@ exports.evaluateGuard = evaluateGuard;
|
|
|
2313
2307
|
exports.formatInitialTransition = formatInitialTransition;
|
|
2314
2308
|
exports.formatTransition = formatTransition;
|
|
2315
2309
|
exports.formatTransitions = formatTransitions;
|
|
2310
|
+
exports.getAllOwnEventDescriptors = getAllOwnEventDescriptors;
|
|
2316
2311
|
exports.getAllStateNodes = getAllStateNodes;
|
|
2317
2312
|
exports.getCandidates = getCandidates;
|
|
2318
2313
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
@@ -2336,9 +2331,10 @@ exports.raise = raise;
|
|
|
2336
2331
|
exports.resolveActionsAndContext = resolveActionsAndContext;
|
|
2337
2332
|
exports.resolveReferencedActor = resolveReferencedActor;
|
|
2338
2333
|
exports.resolveStateValue = resolveStateValue;
|
|
2339
|
-
exports.
|
|
2334
|
+
exports.spawnChild = spawnChild;
|
|
2340
2335
|
exports.stateIn = stateIn;
|
|
2341
2336
|
exports.stop = stop;
|
|
2337
|
+
exports.stopChild = stopChild;
|
|
2342
2338
|
exports.toArray = toArray;
|
|
2343
2339
|
exports.toObserver = toObserver;
|
|
2344
2340
|
exports.toTransitionConfigArray = toTransitionConfigArray;
|