xstate 5.25.0 → 5.26.0
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 +4 -1
- package/actors/dist/xstate-actors.development.cjs.js +4 -1
- package/actors/dist/xstate-actors.development.esm.js +4 -1
- package/actors/dist/xstate-actors.esm.js +4 -1
- package/actors/dist/xstate-actors.umd.min.js +1 -1
- package/actors/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/{StateMachine-f73271f9.cjs.js → StateMachine-29d33e13.cjs.js} +2 -2
- package/dist/{StateMachine-e3bf357b.development.cjs.js → StateMachine-3a7b3253.development.cjs.js} +2 -2
- package/dist/{StateMachine-53479528.development.esm.js → StateMachine-ceed8de1.development.esm.js} +2 -2
- package/dist/{StateMachine-a6d25621.esm.js → StateMachine-d08f7a0b.esm.js} +2 -2
- package/dist/{assign-ef1b62f6.development.esm.js → assign-382e15e2.development.esm.js} +1 -1
- package/dist/{assign-fd69c737.esm.js → assign-5d7df46f.esm.js} +1 -1
- package/dist/{assign-97062f30.development.cjs.js → assign-6a45790f.development.cjs.js} +1 -1
- package/dist/{assign-ae103a72.cjs.js → assign-9271e302.cjs.js} +1 -1
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/stateUtils.d.ts +2 -0
- package/dist/declarations/src/transition.d.ts +26 -1
- package/dist/{log-fbb00743.esm.js → log-46a8697a.esm.js} +2 -2
- package/dist/{log-bf2198dc.development.cjs.js → log-661c5df8.development.cjs.js} +2 -2
- package/dist/{log-3eec9346.development.esm.js → log-d09f274f.development.esm.js} +2 -2
- package/dist/{log-ec818628.cjs.js → log-fe39762e.cjs.js} +2 -2
- package/dist/{raise-235fa0c7.development.esm.js → raise-13e2f823.development.esm.js} +19 -3
- package/dist/{raise-ad4f12ad.cjs.js → raise-df325116.cjs.js} +20 -2
- package/dist/{raise-723edf2d.development.cjs.js → raise-e47e3273.development.cjs.js} +20 -2
- package/dist/{raise-da2ff7ca.esm.js → raise-f11495d1.esm.js} +19 -3
- package/dist/xstate.cjs.js +61 -4
- package/dist/xstate.cjs.mjs +1 -0
- package/dist/xstate.development.cjs.js +61 -4
- package/dist/xstate.development.cjs.mjs +1 -0
- package/dist/xstate.development.esm.js +65 -9
- package/dist/xstate.esm.js +65 -9
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/graph/dist/xstate-graph.cjs.js +3 -3
- package/graph/dist/xstate-graph.development.cjs.js +3 -3
- package/graph/dist/xstate-graph.development.esm.js +3 -3
- package/graph/dist/xstate-graph.esm.js +3 -3
- package/graph/dist/xstate-graph.umd.min.js +1 -1
- package/graph/dist/xstate-graph.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyActorLogic, EventFromLogic, InputFrom, SnapshotFrom, ExecutableActionsFrom } from "./types.js";
|
|
1
|
+
import { AnyActorLogic, EventFromLogic, InputFrom, SnapshotFrom, ExecutableActionsFrom, AnyTransitionDefinition, AnyMachineSnapshot } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Given actor `logic`, a `snapshot`, and an `event`, returns a tuple of the
|
|
4
4
|
* `nextSnapshot` and `actions` to execute.
|
|
@@ -14,3 +14,28 @@ export declare function transition<T extends AnyActorLogic>(logic: T, snapshot:
|
|
|
14
14
|
* This is a pure function that does not execute `actions`.
|
|
15
15
|
*/
|
|
16
16
|
export declare function initialTransition<T extends AnyActorLogic>(logic: T, ...[input]: undefined extends InputFrom<T> ? [input?: InputFrom<T>] : [input: InputFrom<T>]): [SnapshotFrom<T>, ExecutableActionsFrom<T>[]];
|
|
17
|
+
/**
|
|
18
|
+
* Gets all potential next transitions from the current state.
|
|
19
|
+
*
|
|
20
|
+
* Returns all transitions that are available from the current state, including:
|
|
21
|
+
*
|
|
22
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
23
|
+
* configuration)
|
|
24
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
25
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
26
|
+
* - Always (eventless) transitions
|
|
27
|
+
* - After (delayed) transitions
|
|
28
|
+
*
|
|
29
|
+
* The order of transitions is deterministic:
|
|
30
|
+
*
|
|
31
|
+
* 1. Atomic states are processed in document order
|
|
32
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
33
|
+
* then its ancestors
|
|
34
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
35
|
+
* definition
|
|
36
|
+
*
|
|
37
|
+
* @param state - The current machine snapshot
|
|
38
|
+
* @returns Array of transition definitions from the current state, in
|
|
39
|
+
* deterministic order
|
|
40
|
+
*/
|
|
41
|
+
export declare function getNextTransitions(state: AnyMachineSnapshot): AnyTransitionDefinition[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as assign } from './assign-
|
|
1
|
+
import { W as XSTATE_ERROR, Y as createErrorActorEvent, z as evaluateGuard, a as cancel, r as raise, b as spawnChild, s as stopChild } from './raise-f11495d1.esm.js';
|
|
2
|
+
import { a as assign } from './assign-5d7df46f.esm.js';
|
|
3
3
|
|
|
4
4
|
function resolveEmit(_, snapshot, args, actionParams, {
|
|
5
5
|
event: eventOrExpr
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var assign = require('./assign-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-e47e3273.development.cjs.js');
|
|
4
|
+
var assign = require('./assign-6a45790f.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
function resolveEmit(_, snapshot, args, actionParams, {
|
|
7
7
|
event: eventOrExpr
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as assign } from './assign-
|
|
1
|
+
import { W as executingCustomAction, Y as XSTATE_ERROR, Z as createErrorActorEvent, z as evaluateGuard, a as cancel, r as raise, b as spawnChild, s as stopChild } from './raise-13e2f823.development.esm.js';
|
|
2
|
+
import { a as assign } from './assign-382e15e2.development.esm.js';
|
|
3
3
|
|
|
4
4
|
function resolveEmit(_, snapshot, args, actionParams, {
|
|
5
5
|
event: eventOrExpr
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var guards_dist_xstateGuards = require('./raise-
|
|
4
|
-
var assign = require('./assign-
|
|
3
|
+
var guards_dist_xstateGuards = require('./raise-df325116.cjs.js');
|
|
4
|
+
var assign = require('./assign-9271e302.cjs.js');
|
|
5
5
|
|
|
6
6
|
function resolveEmit(_, snapshot, args, actionParams, {
|
|
7
7
|
event: eventOrExpr
|
|
@@ -968,12 +968,14 @@ class Actor {
|
|
|
968
968
|
}
|
|
969
969
|
}
|
|
970
970
|
this.observers.clear();
|
|
971
|
+
this.eventListeners.clear();
|
|
971
972
|
}
|
|
972
973
|
_reportError(err) {
|
|
973
974
|
if (!this.observers.size) {
|
|
974
975
|
if (!this._parent) {
|
|
975
976
|
reportUnhandledError(err);
|
|
976
977
|
}
|
|
978
|
+
this.eventListeners.clear();
|
|
977
979
|
return;
|
|
978
980
|
}
|
|
979
981
|
let reportError = false;
|
|
@@ -987,6 +989,7 @@ class Actor {
|
|
|
987
989
|
}
|
|
988
990
|
}
|
|
989
991
|
this.observers.clear();
|
|
992
|
+
this.eventListeners.clear();
|
|
990
993
|
if (reportError) {
|
|
991
994
|
reportUnhandledError(err);
|
|
992
995
|
}
|
|
@@ -1315,6 +1318,16 @@ function resolveStop(_, snapshot, args, actionParams, {
|
|
|
1315
1318
|
children
|
|
1316
1319
|
}), resolvedActorRef, undefined];
|
|
1317
1320
|
}
|
|
1321
|
+
function unregisterRecursively(actorScope, actorRef) {
|
|
1322
|
+
// unregister children first (depth-first)
|
|
1323
|
+
const snapshot = actorRef.getSnapshot();
|
|
1324
|
+
if (snapshot && 'children' in snapshot) {
|
|
1325
|
+
for (const child of Object.values(snapshot.children)) {
|
|
1326
|
+
unregisterRecursively(actorScope, child);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
actorScope.system._unregister(actorRef);
|
|
1330
|
+
}
|
|
1318
1331
|
function executeStop(actorScope, actorRef) {
|
|
1319
1332
|
if (!actorRef) {
|
|
1320
1333
|
return;
|
|
@@ -1323,7 +1336,8 @@ function executeStop(actorScope, actorRef) {
|
|
|
1323
1336
|
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1324
1337
|
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1325
1338
|
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1326
|
-
|
|
1339
|
+
// we also need to recursively unregister all nested children's systemIds
|
|
1340
|
+
unregisterRecursively(actorScope, actorRef);
|
|
1327
1341
|
|
|
1328
1342
|
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1329
1343
|
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
@@ -1561,7 +1575,9 @@ function evaluateGuard(guard, context, event, snapshot) {
|
|
|
1561
1575
|
);
|
|
1562
1576
|
}
|
|
1563
1577
|
|
|
1564
|
-
|
|
1578
|
+
function isAtomicStateNode(stateNode) {
|
|
1579
|
+
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
1580
|
+
}
|
|
1565
1581
|
function getChildren(stateNode) {
|
|
1566
1582
|
return Object.values(stateNode.states).filter(sn => sn.type !== 'history');
|
|
1567
1583
|
}
|
|
@@ -2727,4 +2743,4 @@ function raise(eventOrExpr, options) {
|
|
|
2727
2743
|
return raise;
|
|
2728
2744
|
}
|
|
2729
2745
|
|
|
2730
|
-
export { $$ACTOR_TYPE as $, Actor as A,
|
|
2746
|
+
export { $$ACTOR_TYPE as $, Actor as A, createInvokeId as B, getDelayedTransitions as C, formatInitialTransition as D, getCandidates as E, resolveStateValue as F, getAllStateNodes as G, createMachineSnapshot as H, isInFinalState as I, macrostep as J, transitionNode as K, resolveActionsAndContext as L, createInitEvent as M, NULL_EVENT as N, microstep as O, getInitialStateNodes as P, toStatePath as Q, isStateId as R, STATE_DELIMITER as S, getStateNodeByPath as T, getPersistedSnapshot as U, resolveReferencedActor as V, executingCustomAction as W, XSTATE_STOP as X, XSTATE_ERROR as Y, createErrorActorEvent as Z, ProcessingStatus as _, cancel as a, cloneMachineSnapshot as a0, spawnChild as b, createActor as c, interpret as d, and as e, stateIn as f, getProperAncestors as g, isMachineSnapshot as h, isAtomicStateNode as i, getStateNodes as j, getAllOwnEventDescriptors as k, matchesState as l, matchesEventDescriptor as m, not as n, or as o, pathToStateValue as p, toObserver as q, raise as r, stopChild as s, toArray as t, stop as u, mapValues as v, formatTransitions as w, toTransitionConfigArray as x, formatTransition as y, evaluateGuard as z };
|
|
@@ -961,12 +961,14 @@ class Actor {
|
|
|
961
961
|
}
|
|
962
962
|
}
|
|
963
963
|
this.observers.clear();
|
|
964
|
+
this.eventListeners.clear();
|
|
964
965
|
}
|
|
965
966
|
_reportError(err) {
|
|
966
967
|
if (!this.observers.size) {
|
|
967
968
|
if (!this._parent) {
|
|
968
969
|
reportUnhandledError(err);
|
|
969
970
|
}
|
|
971
|
+
this.eventListeners.clear();
|
|
970
972
|
return;
|
|
971
973
|
}
|
|
972
974
|
let reportError = false;
|
|
@@ -980,6 +982,7 @@ class Actor {
|
|
|
980
982
|
}
|
|
981
983
|
}
|
|
982
984
|
this.observers.clear();
|
|
985
|
+
this.eventListeners.clear();
|
|
983
986
|
if (reportError) {
|
|
984
987
|
reportUnhandledError(err);
|
|
985
988
|
}
|
|
@@ -1286,6 +1289,16 @@ function resolveStop(_, snapshot, args, actionParams, {
|
|
|
1286
1289
|
children
|
|
1287
1290
|
}), resolvedActorRef, undefined];
|
|
1288
1291
|
}
|
|
1292
|
+
function unregisterRecursively(actorScope, actorRef) {
|
|
1293
|
+
// unregister children first (depth-first)
|
|
1294
|
+
const snapshot = actorRef.getSnapshot();
|
|
1295
|
+
if (snapshot && 'children' in snapshot) {
|
|
1296
|
+
for (const child of Object.values(snapshot.children)) {
|
|
1297
|
+
unregisterRecursively(actorScope, child);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
actorScope.system._unregister(actorRef);
|
|
1301
|
+
}
|
|
1289
1302
|
function executeStop(actorScope, actorRef) {
|
|
1290
1303
|
if (!actorRef) {
|
|
1291
1304
|
return;
|
|
@@ -1294,7 +1307,8 @@ function executeStop(actorScope, actorRef) {
|
|
|
1294
1307
|
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1295
1308
|
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1296
1309
|
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1297
|
-
|
|
1310
|
+
// we also need to recursively unregister all nested children's systemIds
|
|
1311
|
+
unregisterRecursively(actorScope, actorRef);
|
|
1298
1312
|
|
|
1299
1313
|
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1300
1314
|
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
@@ -1521,7 +1535,9 @@ function evaluateGuard(guard, context, event, snapshot) {
|
|
|
1521
1535
|
);
|
|
1522
1536
|
}
|
|
1523
1537
|
|
|
1524
|
-
|
|
1538
|
+
function isAtomicStateNode(stateNode) {
|
|
1539
|
+
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
1540
|
+
}
|
|
1525
1541
|
function getChildren(stateNode) {
|
|
1526
1542
|
return Object.values(stateNode.states).filter(sn => sn.type !== 'history');
|
|
1527
1543
|
}
|
|
@@ -2692,9 +2708,11 @@ exports.getCandidates = getCandidates;
|
|
|
2692
2708
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
2693
2709
|
exports.getInitialStateNodes = getInitialStateNodes;
|
|
2694
2710
|
exports.getPersistedSnapshot = getPersistedSnapshot;
|
|
2711
|
+
exports.getProperAncestors = getProperAncestors;
|
|
2695
2712
|
exports.getStateNodeByPath = getStateNodeByPath;
|
|
2696
2713
|
exports.getStateNodes = getStateNodes;
|
|
2697
2714
|
exports.interpret = interpret;
|
|
2715
|
+
exports.isAtomicStateNode = isAtomicStateNode;
|
|
2698
2716
|
exports.isInFinalState = isInFinalState;
|
|
2699
2717
|
exports.isMachineSnapshot = isMachineSnapshot;
|
|
2700
2718
|
exports.isStateId = isStateId;
|
|
@@ -970,12 +970,14 @@ class Actor {
|
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
972
|
this.observers.clear();
|
|
973
|
+
this.eventListeners.clear();
|
|
973
974
|
}
|
|
974
975
|
_reportError(err) {
|
|
975
976
|
if (!this.observers.size) {
|
|
976
977
|
if (!this._parent) {
|
|
977
978
|
reportUnhandledError(err);
|
|
978
979
|
}
|
|
980
|
+
this.eventListeners.clear();
|
|
979
981
|
return;
|
|
980
982
|
}
|
|
981
983
|
let reportError = false;
|
|
@@ -989,6 +991,7 @@ class Actor {
|
|
|
989
991
|
}
|
|
990
992
|
}
|
|
991
993
|
this.observers.clear();
|
|
994
|
+
this.eventListeners.clear();
|
|
992
995
|
if (reportError) {
|
|
993
996
|
reportUnhandledError(err);
|
|
994
997
|
}
|
|
@@ -1317,6 +1320,16 @@ function resolveStop(_, snapshot, args, actionParams, {
|
|
|
1317
1320
|
children
|
|
1318
1321
|
}), resolvedActorRef, undefined];
|
|
1319
1322
|
}
|
|
1323
|
+
function unregisterRecursively(actorScope, actorRef) {
|
|
1324
|
+
// unregister children first (depth-first)
|
|
1325
|
+
const snapshot = actorRef.getSnapshot();
|
|
1326
|
+
if (snapshot && 'children' in snapshot) {
|
|
1327
|
+
for (const child of Object.values(snapshot.children)) {
|
|
1328
|
+
unregisterRecursively(actorScope, child);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
actorScope.system._unregister(actorRef);
|
|
1332
|
+
}
|
|
1320
1333
|
function executeStop(actorScope, actorRef) {
|
|
1321
1334
|
if (!actorRef) {
|
|
1322
1335
|
return;
|
|
@@ -1325,7 +1338,8 @@ function executeStop(actorScope, actorRef) {
|
|
|
1325
1338
|
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1326
1339
|
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1327
1340
|
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1328
|
-
|
|
1341
|
+
// we also need to recursively unregister all nested children's systemIds
|
|
1342
|
+
unregisterRecursively(actorScope, actorRef);
|
|
1329
1343
|
|
|
1330
1344
|
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1331
1345
|
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
@@ -1563,7 +1577,9 @@ function evaluateGuard(guard, context, event, snapshot) {
|
|
|
1563
1577
|
);
|
|
1564
1578
|
}
|
|
1565
1579
|
|
|
1566
|
-
|
|
1580
|
+
function isAtomicStateNode(stateNode) {
|
|
1581
|
+
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
1582
|
+
}
|
|
1567
1583
|
function getChildren(stateNode) {
|
|
1568
1584
|
return Object.values(stateNode.states).filter(sn => sn.type !== 'history');
|
|
1569
1585
|
}
|
|
@@ -2754,9 +2770,11 @@ exports.getCandidates = getCandidates;
|
|
|
2754
2770
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
2755
2771
|
exports.getInitialStateNodes = getInitialStateNodes;
|
|
2756
2772
|
exports.getPersistedSnapshot = getPersistedSnapshot;
|
|
2773
|
+
exports.getProperAncestors = getProperAncestors;
|
|
2757
2774
|
exports.getStateNodeByPath = getStateNodeByPath;
|
|
2758
2775
|
exports.getStateNodes = getStateNodes;
|
|
2759
2776
|
exports.interpret = interpret;
|
|
2777
|
+
exports.isAtomicStateNode = isAtomicStateNode;
|
|
2760
2778
|
exports.isInFinalState = isInFinalState;
|
|
2761
2779
|
exports.isMachineSnapshot = isMachineSnapshot;
|
|
2762
2780
|
exports.isStateId = isStateId;
|
|
@@ -959,12 +959,14 @@ class Actor {
|
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
961
|
this.observers.clear();
|
|
962
|
+
this.eventListeners.clear();
|
|
962
963
|
}
|
|
963
964
|
_reportError(err) {
|
|
964
965
|
if (!this.observers.size) {
|
|
965
966
|
if (!this._parent) {
|
|
966
967
|
reportUnhandledError(err);
|
|
967
968
|
}
|
|
969
|
+
this.eventListeners.clear();
|
|
968
970
|
return;
|
|
969
971
|
}
|
|
970
972
|
let reportError = false;
|
|
@@ -978,6 +980,7 @@ class Actor {
|
|
|
978
980
|
}
|
|
979
981
|
}
|
|
980
982
|
this.observers.clear();
|
|
983
|
+
this.eventListeners.clear();
|
|
981
984
|
if (reportError) {
|
|
982
985
|
reportUnhandledError(err);
|
|
983
986
|
}
|
|
@@ -1284,6 +1287,16 @@ function resolveStop(_, snapshot, args, actionParams, {
|
|
|
1284
1287
|
children
|
|
1285
1288
|
}), resolvedActorRef, undefined];
|
|
1286
1289
|
}
|
|
1290
|
+
function unregisterRecursively(actorScope, actorRef) {
|
|
1291
|
+
// unregister children first (depth-first)
|
|
1292
|
+
const snapshot = actorRef.getSnapshot();
|
|
1293
|
+
if (snapshot && 'children' in snapshot) {
|
|
1294
|
+
for (const child of Object.values(snapshot.children)) {
|
|
1295
|
+
unregisterRecursively(actorScope, child);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
actorScope.system._unregister(actorRef);
|
|
1299
|
+
}
|
|
1287
1300
|
function executeStop(actorScope, actorRef) {
|
|
1288
1301
|
if (!actorRef) {
|
|
1289
1302
|
return;
|
|
@@ -1292,7 +1305,8 @@ function executeStop(actorScope, actorRef) {
|
|
|
1292
1305
|
// we need to eagerly unregister it here so a new actor with the same systemId can be registered immediately
|
|
1293
1306
|
// since we defer actual stopping of the actor but we don't defer actor creations (and we can't do that)
|
|
1294
1307
|
// this could throw on `systemId` collision, for example, when dealing with reentering transitions
|
|
1295
|
-
|
|
1308
|
+
// we also need to recursively unregister all nested children's systemIds
|
|
1309
|
+
unregisterRecursively(actorScope, actorRef);
|
|
1296
1310
|
|
|
1297
1311
|
// this allows us to prevent an actor from being started if it gets stopped within the same macrostep
|
|
1298
1312
|
// this can happen, for example, when the invoking state is being exited immediately by an always transition
|
|
@@ -1519,7 +1533,9 @@ function evaluateGuard(guard, context, event, snapshot) {
|
|
|
1519
1533
|
);
|
|
1520
1534
|
}
|
|
1521
1535
|
|
|
1522
|
-
|
|
1536
|
+
function isAtomicStateNode(stateNode) {
|
|
1537
|
+
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
1538
|
+
}
|
|
1523
1539
|
function getChildren(stateNode) {
|
|
1524
1540
|
return Object.values(stateNode.states).filter(sn => sn.type !== 'history');
|
|
1525
1541
|
}
|
|
@@ -2665,4 +2681,4 @@ function raise(eventOrExpr, options) {
|
|
|
2665
2681
|
return raise;
|
|
2666
2682
|
}
|
|
2667
2683
|
|
|
2668
|
-
export { $$ACTOR_TYPE as $, Actor as A,
|
|
2684
|
+
export { $$ACTOR_TYPE as $, Actor as A, createInvokeId as B, getDelayedTransitions as C, formatInitialTransition as D, getCandidates as E, resolveStateValue as F, getAllStateNodes as G, createMachineSnapshot as H, isInFinalState as I, macrostep as J, transitionNode as K, resolveActionsAndContext as L, createInitEvent as M, NULL_EVENT as N, microstep as O, getInitialStateNodes as P, toStatePath as Q, isStateId as R, STATE_DELIMITER as S, getStateNodeByPath as T, getPersistedSnapshot as U, resolveReferencedActor as V, XSTATE_ERROR as W, XSTATE_STOP as X, createErrorActorEvent as Y, ProcessingStatus as Z, cloneMachineSnapshot as _, cancel as a, spawnChild as b, createActor as c, interpret as d, and as e, stateIn as f, getProperAncestors as g, isMachineSnapshot as h, isAtomicStateNode as i, getStateNodes as j, getAllOwnEventDescriptors as k, matchesState as l, matchesEventDescriptor as m, not as n, or as o, pathToStateValue as p, toObserver as q, raise as r, stopChild as s, toArray as t, stop as u, mapValues as v, formatTransitions as w, toTransitionConfigArray as x, formatTransition as y, evaluateGuard as z };
|
package/dist/xstate.cjs.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
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 guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var StateMachine = require('./StateMachine-
|
|
8
|
-
var assign = require('./assign-
|
|
9
|
-
var log = require('./log-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-df325116.cjs.js');
|
|
7
|
+
var StateMachine = require('./StateMachine-29d33e13.cjs.js');
|
|
8
|
+
var assign = require('./assign-9271e302.cjs.js');
|
|
9
|
+
var log = require('./log-fe39762e.cjs.js');
|
|
10
10
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -338,6 +338,62 @@ function initialTransition(logic, ...[input]) {
|
|
|
338
338
|
return [nextSnapshot, executableActions];
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Gets all potential next transitions from the current state.
|
|
343
|
+
*
|
|
344
|
+
* Returns all transitions that are available from the current state, including:
|
|
345
|
+
*
|
|
346
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
347
|
+
* configuration)
|
|
348
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
349
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
350
|
+
* - Always (eventless) transitions
|
|
351
|
+
* - After (delayed) transitions
|
|
352
|
+
*
|
|
353
|
+
* The order of transitions is deterministic:
|
|
354
|
+
*
|
|
355
|
+
* 1. Atomic states are processed in document order
|
|
356
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
357
|
+
* then its ancestors
|
|
358
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
359
|
+
* definition
|
|
360
|
+
*
|
|
361
|
+
* @param state - The current machine snapshot
|
|
362
|
+
* @returns Array of transition definitions from the current state, in
|
|
363
|
+
* deterministic order
|
|
364
|
+
*/
|
|
365
|
+
function getNextTransitions(state) {
|
|
366
|
+
const potentialTransitions = [];
|
|
367
|
+
const atomicStates = state._nodes.filter(guards_dist_xstateGuards.isAtomicStateNode);
|
|
368
|
+
const visited = new Set();
|
|
369
|
+
|
|
370
|
+
// Collect all transitions from atomic states and their ancestors
|
|
371
|
+
// Process atomic states in document order (as they appear in state._nodes)
|
|
372
|
+
for (const stateNode of atomicStates) {
|
|
373
|
+
// For each atomic state, process the state itself first, then its ancestors
|
|
374
|
+
// This ensures child state transitions come before parent state transitions
|
|
375
|
+
for (const s of [stateNode].concat(guards_dist_xstateGuards.getProperAncestors(stateNode, undefined))) {
|
|
376
|
+
if (visited.has(s.id)) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
visited.add(s.id);
|
|
380
|
+
|
|
381
|
+
// Get all transitions for each event type
|
|
382
|
+
// Include ALL transitions, even if the same event type appears in multiple state nodes
|
|
383
|
+
// This is important for guarded transitions - all are "potential" regardless of guard evaluation
|
|
384
|
+
for (const [, transitions] of s.transitions) {
|
|
385
|
+
potentialTransitions.push(...transitions);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Also include always (eventless) transitions
|
|
389
|
+
if (s.always) {
|
|
390
|
+
potentialTransitions.push(...s.always);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return potentialTransitions;
|
|
395
|
+
}
|
|
396
|
+
|
|
341
397
|
const defaultWaitForOptions = {
|
|
342
398
|
timeout: Infinity // much more than 10 seconds
|
|
343
399
|
};
|
|
@@ -478,6 +534,7 @@ exports.assertEvent = assertEvent;
|
|
|
478
534
|
exports.createMachine = createMachine;
|
|
479
535
|
exports.getInitialSnapshot = getInitialSnapshot;
|
|
480
536
|
exports.getNextSnapshot = getNextSnapshot;
|
|
537
|
+
exports.getNextTransitions = getNextTransitions;
|
|
481
538
|
exports.initialTransition = initialTransition;
|
|
482
539
|
exports.setup = setup;
|
|
483
540
|
exports.toPromise = toPromise;
|
package/dist/xstate.cjs.mjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
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 guards_dist_xstateGuards = require('./raise-
|
|
7
|
-
var StateMachine = require('./StateMachine-
|
|
8
|
-
var assign = require('./assign-
|
|
9
|
-
var log = require('./log-
|
|
6
|
+
var guards_dist_xstateGuards = require('./raise-e47e3273.development.cjs.js');
|
|
7
|
+
var StateMachine = require('./StateMachine-3a7b3253.development.cjs.js');
|
|
8
|
+
var assign = require('./assign-6a45790f.development.cjs.js');
|
|
9
|
+
var log = require('./log-661c5df8.development.cjs.js');
|
|
10
10
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -338,6 +338,62 @@ function initialTransition(logic, ...[input]) {
|
|
|
338
338
|
return [nextSnapshot, executableActions];
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Gets all potential next transitions from the current state.
|
|
343
|
+
*
|
|
344
|
+
* Returns all transitions that are available from the current state, including:
|
|
345
|
+
*
|
|
346
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
347
|
+
* configuration)
|
|
348
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
349
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
350
|
+
* - Always (eventless) transitions
|
|
351
|
+
* - After (delayed) transitions
|
|
352
|
+
*
|
|
353
|
+
* The order of transitions is deterministic:
|
|
354
|
+
*
|
|
355
|
+
* 1. Atomic states are processed in document order
|
|
356
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
357
|
+
* then its ancestors
|
|
358
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
359
|
+
* definition
|
|
360
|
+
*
|
|
361
|
+
* @param state - The current machine snapshot
|
|
362
|
+
* @returns Array of transition definitions from the current state, in
|
|
363
|
+
* deterministic order
|
|
364
|
+
*/
|
|
365
|
+
function getNextTransitions(state) {
|
|
366
|
+
const potentialTransitions = [];
|
|
367
|
+
const atomicStates = state._nodes.filter(guards_dist_xstateGuards.isAtomicStateNode);
|
|
368
|
+
const visited = new Set();
|
|
369
|
+
|
|
370
|
+
// Collect all transitions from atomic states and their ancestors
|
|
371
|
+
// Process atomic states in document order (as they appear in state._nodes)
|
|
372
|
+
for (const stateNode of atomicStates) {
|
|
373
|
+
// For each atomic state, process the state itself first, then its ancestors
|
|
374
|
+
// This ensures child state transitions come before parent state transitions
|
|
375
|
+
for (const s of [stateNode].concat(guards_dist_xstateGuards.getProperAncestors(stateNode, undefined))) {
|
|
376
|
+
if (visited.has(s.id)) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
visited.add(s.id);
|
|
380
|
+
|
|
381
|
+
// Get all transitions for each event type
|
|
382
|
+
// Include ALL transitions, even if the same event type appears in multiple state nodes
|
|
383
|
+
// This is important for guarded transitions - all are "potential" regardless of guard evaluation
|
|
384
|
+
for (const [, transitions] of s.transitions) {
|
|
385
|
+
potentialTransitions.push(...transitions);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Also include always (eventless) transitions
|
|
389
|
+
if (s.always) {
|
|
390
|
+
potentialTransitions.push(...s.always);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return potentialTransitions;
|
|
395
|
+
}
|
|
396
|
+
|
|
341
397
|
const defaultWaitForOptions = {
|
|
342
398
|
timeout: Infinity // much more than 10 seconds
|
|
343
399
|
};
|
|
@@ -481,6 +537,7 @@ exports.assertEvent = assertEvent;
|
|
|
481
537
|
exports.createMachine = createMachine;
|
|
482
538
|
exports.getInitialSnapshot = getInitialSnapshot;
|
|
483
539
|
exports.getNextSnapshot = getNextSnapshot;
|
|
540
|
+
exports.getNextTransitions = getNextTransitions;
|
|
484
541
|
exports.initialTransition = initialTransition;
|
|
485
542
|
exports.setup = setup;
|
|
486
543
|
exports.toPromise = toPromise;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
|
|
2
|
-
import { m as matchesEventDescriptor, t as toArray, c as createActor, r as raise, a as cancel, s as stopChild, b as spawnChild } from './raise-
|
|
3
|
-
export { A as Actor,
|
|
4
|
-
import { S as StateMachine } from './StateMachine-
|
|
5
|
-
export { S as StateMachine, a as StateNode } from './StateMachine-
|
|
6
|
-
import { a as assign } from './assign-
|
|
7
|
-
export { a as assign } from './assign-
|
|
8
|
-
import { s as sendTo, l as log, e as enqueueActions, a as emit } from './log-
|
|
9
|
-
export { S as SpecialTargets, a as emit, e as enqueueActions, f as forwardTo, l as log, b as sendParent, s as sendTo } from './log-
|
|
2
|
+
import { m as matchesEventDescriptor, t as toArray, c as createActor, r as raise, a as cancel, s as stopChild, b as spawnChild, i as isAtomicStateNode, g as getProperAncestors } from './raise-13e2f823.development.esm.js';
|
|
3
|
+
export { A as Actor, k as __unsafe_getAllOwnEventDescriptors, e as and, a as cancel, c as createActor, j as getStateNodes, d as interpret, h as isMachineSnapshot, l as matchesState, n as not, o as or, p as pathToStateValue, r as raise, b as spawnChild, f as stateIn, u as stop, s as stopChild, q as toObserver } from './raise-13e2f823.development.esm.js';
|
|
4
|
+
import { S as StateMachine } from './StateMachine-ceed8de1.development.esm.js';
|
|
5
|
+
export { S as StateMachine, a as StateNode } from './StateMachine-ceed8de1.development.esm.js';
|
|
6
|
+
import { a as assign } from './assign-382e15e2.development.esm.js';
|
|
7
|
+
export { a as assign } from './assign-382e15e2.development.esm.js';
|
|
8
|
+
import { s as sendTo, l as log, e as enqueueActions, a as emit } from './log-d09f274f.development.esm.js';
|
|
9
|
+
export { S as SpecialTargets, a as emit, e as enqueueActions, f as forwardTo, l as log, b as sendParent, s as sendTo } from './log-d09f274f.development.esm.js';
|
|
10
10
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -338,6 +338,62 @@ function initialTransition(logic, ...[input]) {
|
|
|
338
338
|
return [nextSnapshot, executableActions];
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Gets all potential next transitions from the current state.
|
|
343
|
+
*
|
|
344
|
+
* Returns all transitions that are available from the current state, including:
|
|
345
|
+
*
|
|
346
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
347
|
+
* configuration)
|
|
348
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
349
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
350
|
+
* - Always (eventless) transitions
|
|
351
|
+
* - After (delayed) transitions
|
|
352
|
+
*
|
|
353
|
+
* The order of transitions is deterministic:
|
|
354
|
+
*
|
|
355
|
+
* 1. Atomic states are processed in document order
|
|
356
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
357
|
+
* then its ancestors
|
|
358
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
359
|
+
* definition
|
|
360
|
+
*
|
|
361
|
+
* @param state - The current machine snapshot
|
|
362
|
+
* @returns Array of transition definitions from the current state, in
|
|
363
|
+
* deterministic order
|
|
364
|
+
*/
|
|
365
|
+
function getNextTransitions(state) {
|
|
366
|
+
const potentialTransitions = [];
|
|
367
|
+
const atomicStates = state._nodes.filter(isAtomicStateNode);
|
|
368
|
+
const visited = new Set();
|
|
369
|
+
|
|
370
|
+
// Collect all transitions from atomic states and their ancestors
|
|
371
|
+
// Process atomic states in document order (as they appear in state._nodes)
|
|
372
|
+
for (const stateNode of atomicStates) {
|
|
373
|
+
// For each atomic state, process the state itself first, then its ancestors
|
|
374
|
+
// This ensures child state transitions come before parent state transitions
|
|
375
|
+
for (const s of [stateNode].concat(getProperAncestors(stateNode, undefined))) {
|
|
376
|
+
if (visited.has(s.id)) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
visited.add(s.id);
|
|
380
|
+
|
|
381
|
+
// Get all transitions for each event type
|
|
382
|
+
// Include ALL transitions, even if the same event type appears in multiple state nodes
|
|
383
|
+
// This is important for guarded transitions - all are "potential" regardless of guard evaluation
|
|
384
|
+
for (const [, transitions] of s.transitions) {
|
|
385
|
+
potentialTransitions.push(...transitions);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Also include always (eventless) transitions
|
|
389
|
+
if (s.always) {
|
|
390
|
+
potentialTransitions.push(...s.always);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return potentialTransitions;
|
|
395
|
+
}
|
|
396
|
+
|
|
341
397
|
const defaultWaitForOptions = {
|
|
342
398
|
timeout: Infinity // much more than 10 seconds
|
|
343
399
|
};
|
|
@@ -442,4 +498,4 @@ function waitFor(actorRef, predicate, options) {
|
|
|
442
498
|
});
|
|
443
499
|
}
|
|
444
500
|
|
|
445
|
-
export { SimulatedClock, assertEvent, createMachine, getInitialSnapshot, getNextSnapshot, initialTransition, setup, toPromise, transition, waitFor };
|
|
501
|
+
export { SimulatedClock, assertEvent, createMachine, getInitialSnapshot, getNextSnapshot, getNextTransitions, initialTransition, setup, toPromise, transition, waitFor };
|