xstate 5.25.1 → 5.27.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 +1 -1
- package/actors/dist/xstate-actors.development.cjs.js +1 -1
- package/actors/dist/xstate-actors.development.esm.js +1 -1
- package/actors/dist/xstate-actors.esm.js +1 -1
- package/dist/{StateMachine-d0e98d09.development.esm.js → StateMachine-93271b59.development.esm.js} +8 -13
- package/dist/{StateMachine-6c48f805.esm.js → StateMachine-a4db5a91.esm.js} +8 -13
- package/dist/{StateMachine-6d24a98f.development.cjs.js → StateMachine-c3376229.development.cjs.js} +8 -13
- package/dist/{StateMachine-fee05db8.cjs.js → StateMachine-e93afc18.cjs.js} +8 -13
- package/dist/{assign-37a2fc1e.esm.js → assign-227b928a.esm.js} +1 -1
- package/dist/{assign-577bb842.development.cjs.js → assign-8ef0e332.development.cjs.js} +1 -1
- package/dist/{assign-541a432d.development.esm.js → assign-d5291869.development.esm.js} +1 -1
- package/dist/{assign-592716a8.cjs.js → assign-e36553db.cjs.js} +1 -1
- package/dist/declarations/src/StateMachine.d.ts +0 -5
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/stateUtils.d.ts +6 -5
- package/dist/declarations/src/transition.d.ts +41 -1
- package/dist/{log-3827c227.development.cjs.js → log-72d5ee02.development.cjs.js} +2 -2
- package/dist/{log-b8ca474e.development.esm.js → log-7dbbb7c2.development.esm.js} +2 -2
- package/dist/{log-9c9f917d.cjs.js → log-e54c2eff.cjs.js} +2 -2
- package/dist/{log-ce14fc9a.esm.js → log-fa76d888.esm.js} +2 -2
- package/dist/{raise-577e4163.cjs.js → raise-3a84be1f.cjs.js} +70 -45
- package/dist/{raise-13a60c49.development.esm.js → raise-a7794093.development.esm.js} +68 -44
- package/dist/{raise-f5c7cb5b.esm.js → raise-e5d81555.esm.js} +68 -44
- package/dist/{raise-ed7c6f3d.development.cjs.js → raise-ecea0c53.development.cjs.js} +70 -45
- package/dist/xstate.cjs.js +96 -4
- package/dist/xstate.cjs.mjs +3 -0
- package/dist/xstate.development.cjs.js +96 -4
- package/dist/xstate.development.cjs.mjs +3 -0
- package/dist/xstate.development.esm.js +98 -9
- package/dist/xstate.esm.js +98 -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
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-3a84be1f.cjs.js');
|
|
7
|
+
var StateMachine = require('./StateMachine-e93afc18.cjs.js');
|
|
8
|
+
var assign = require('./assign-e36553db.cjs.js');
|
|
9
|
+
var log = require('./log-e54c2eff.cjs.js');
|
|
10
10
|
require('../dev/dist/xstate-dev.cjs.js');
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -338,6 +338,95 @@ function initialTransition(logic, ...[input]) {
|
|
|
338
338
|
return [nextSnapshot, executableActions];
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Given a state `machine`, a `snapshot`, and an `event`, returns an array of
|
|
343
|
+
* microsteps, where each microstep is a tuple of `[snapshot, actions]`.
|
|
344
|
+
*
|
|
345
|
+
* This is a pure function that does not execute `actions`.
|
|
346
|
+
*/
|
|
347
|
+
function getMicrosteps(machine, snapshot, event) {
|
|
348
|
+
const actorScope = createInertActorScope(machine);
|
|
349
|
+
const {
|
|
350
|
+
microsteps
|
|
351
|
+
} = guards_dist_xstateGuards.macrostep(snapshot, event, actorScope, []);
|
|
352
|
+
return microsteps;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Given a state `machine` and optional `input`, returns an array of microsteps
|
|
357
|
+
* from the initial transition, where each microstep is a tuple of `[snapshot,
|
|
358
|
+
* actions]`.
|
|
359
|
+
*
|
|
360
|
+
* This is a pure function that does not execute `actions`.
|
|
361
|
+
*/
|
|
362
|
+
function getInitialMicrosteps(machine, ...[input]) {
|
|
363
|
+
const actorScope = createInertActorScope(machine);
|
|
364
|
+
const initEvent = guards_dist_xstateGuards.createInitEvent(input);
|
|
365
|
+
const internalQueue = [];
|
|
366
|
+
const preInitialSnapshot = machine._getPreInitialState(actorScope, initEvent, internalQueue);
|
|
367
|
+
const first = guards_dist_xstateGuards.initialMicrostep(machine.root, preInitialSnapshot, actorScope, initEvent, internalQueue);
|
|
368
|
+
const {
|
|
369
|
+
microsteps
|
|
370
|
+
} = guards_dist_xstateGuards.macrostep(first[0], initEvent, actorScope, internalQueue);
|
|
371
|
+
return [first, ...microsteps];
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Gets all potential next transitions from the current state.
|
|
376
|
+
*
|
|
377
|
+
* Returns all transitions that are available from the current state, including:
|
|
378
|
+
*
|
|
379
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
380
|
+
* configuration)
|
|
381
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
382
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
383
|
+
* - Always (eventless) transitions
|
|
384
|
+
* - After (delayed) transitions
|
|
385
|
+
*
|
|
386
|
+
* The order of transitions is deterministic:
|
|
387
|
+
*
|
|
388
|
+
* 1. Atomic states are processed in document order
|
|
389
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
390
|
+
* then its ancestors
|
|
391
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
392
|
+
* definition
|
|
393
|
+
*
|
|
394
|
+
* @param state - The current machine snapshot
|
|
395
|
+
* @returns Array of transition definitions from the current state, in
|
|
396
|
+
* deterministic order
|
|
397
|
+
*/
|
|
398
|
+
function getNextTransitions(state) {
|
|
399
|
+
const potentialTransitions = [];
|
|
400
|
+
const atomicStates = state._nodes.filter(guards_dist_xstateGuards.isAtomicStateNode);
|
|
401
|
+
const visited = new Set();
|
|
402
|
+
|
|
403
|
+
// Collect all transitions from atomic states and their ancestors
|
|
404
|
+
// Process atomic states in document order (as they appear in state._nodes)
|
|
405
|
+
for (const stateNode of atomicStates) {
|
|
406
|
+
// For each atomic state, process the state itself first, then its ancestors
|
|
407
|
+
// This ensures child state transitions come before parent state transitions
|
|
408
|
+
for (const s of [stateNode].concat(guards_dist_xstateGuards.getProperAncestors(stateNode, undefined))) {
|
|
409
|
+
if (visited.has(s.id)) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
visited.add(s.id);
|
|
413
|
+
|
|
414
|
+
// Get all transitions for each event type
|
|
415
|
+
// Include ALL transitions, even if the same event type appears in multiple state nodes
|
|
416
|
+
// This is important for guarded transitions - all are "potential" regardless of guard evaluation
|
|
417
|
+
for (const [, transitions] of s.transitions) {
|
|
418
|
+
potentialTransitions.push(...transitions);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Also include always (eventless) transitions
|
|
422
|
+
if (s.always) {
|
|
423
|
+
potentialTransitions.push(...s.always);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return potentialTransitions;
|
|
428
|
+
}
|
|
429
|
+
|
|
341
430
|
const defaultWaitForOptions = {
|
|
342
431
|
timeout: Infinity // much more than 10 seconds
|
|
343
432
|
};
|
|
@@ -476,8 +565,11 @@ exports.sendTo = log.sendTo;
|
|
|
476
565
|
exports.SimulatedClock = SimulatedClock;
|
|
477
566
|
exports.assertEvent = assertEvent;
|
|
478
567
|
exports.createMachine = createMachine;
|
|
568
|
+
exports.getInitialMicrosteps = getInitialMicrosteps;
|
|
479
569
|
exports.getInitialSnapshot = getInitialSnapshot;
|
|
570
|
+
exports.getMicrosteps = getMicrosteps;
|
|
480
571
|
exports.getNextSnapshot = getNextSnapshot;
|
|
572
|
+
exports.getNextTransitions = getNextTransitions;
|
|
481
573
|
exports.initialTransition = initialTransition;
|
|
482
574
|
exports.setup = setup;
|
|
483
575
|
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-ecea0c53.development.cjs.js');
|
|
7
|
+
var StateMachine = require('./StateMachine-c3376229.development.cjs.js');
|
|
8
|
+
var assign = require('./assign-8ef0e332.development.cjs.js');
|
|
9
|
+
var log = require('./log-72d5ee02.development.cjs.js');
|
|
10
10
|
require('../dev/dist/xstate-dev.development.cjs.js');
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -338,6 +338,95 @@ function initialTransition(logic, ...[input]) {
|
|
|
338
338
|
return [nextSnapshot, executableActions];
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Given a state `machine`, a `snapshot`, and an `event`, returns an array of
|
|
343
|
+
* microsteps, where each microstep is a tuple of `[snapshot, actions]`.
|
|
344
|
+
*
|
|
345
|
+
* This is a pure function that does not execute `actions`.
|
|
346
|
+
*/
|
|
347
|
+
function getMicrosteps(machine, snapshot, event) {
|
|
348
|
+
const actorScope = createInertActorScope(machine);
|
|
349
|
+
const {
|
|
350
|
+
microsteps
|
|
351
|
+
} = guards_dist_xstateGuards.macrostep(snapshot, event, actorScope, []);
|
|
352
|
+
return microsteps;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Given a state `machine` and optional `input`, returns an array of microsteps
|
|
357
|
+
* from the initial transition, where each microstep is a tuple of `[snapshot,
|
|
358
|
+
* actions]`.
|
|
359
|
+
*
|
|
360
|
+
* This is a pure function that does not execute `actions`.
|
|
361
|
+
*/
|
|
362
|
+
function getInitialMicrosteps(machine, ...[input]) {
|
|
363
|
+
const actorScope = createInertActorScope(machine);
|
|
364
|
+
const initEvent = guards_dist_xstateGuards.createInitEvent(input);
|
|
365
|
+
const internalQueue = [];
|
|
366
|
+
const preInitialSnapshot = machine._getPreInitialState(actorScope, initEvent, internalQueue);
|
|
367
|
+
const first = guards_dist_xstateGuards.initialMicrostep(machine.root, preInitialSnapshot, actorScope, initEvent, internalQueue);
|
|
368
|
+
const {
|
|
369
|
+
microsteps
|
|
370
|
+
} = guards_dist_xstateGuards.macrostep(first[0], initEvent, actorScope, internalQueue);
|
|
371
|
+
return [first, ...microsteps];
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Gets all potential next transitions from the current state.
|
|
376
|
+
*
|
|
377
|
+
* Returns all transitions that are available from the current state, including:
|
|
378
|
+
*
|
|
379
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
380
|
+
* configuration)
|
|
381
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
382
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
383
|
+
* - Always (eventless) transitions
|
|
384
|
+
* - After (delayed) transitions
|
|
385
|
+
*
|
|
386
|
+
* The order of transitions is deterministic:
|
|
387
|
+
*
|
|
388
|
+
* 1. Atomic states are processed in document order
|
|
389
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
390
|
+
* then its ancestors
|
|
391
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
392
|
+
* definition
|
|
393
|
+
*
|
|
394
|
+
* @param state - The current machine snapshot
|
|
395
|
+
* @returns Array of transition definitions from the current state, in
|
|
396
|
+
* deterministic order
|
|
397
|
+
*/
|
|
398
|
+
function getNextTransitions(state) {
|
|
399
|
+
const potentialTransitions = [];
|
|
400
|
+
const atomicStates = state._nodes.filter(guards_dist_xstateGuards.isAtomicStateNode);
|
|
401
|
+
const visited = new Set();
|
|
402
|
+
|
|
403
|
+
// Collect all transitions from atomic states and their ancestors
|
|
404
|
+
// Process atomic states in document order (as they appear in state._nodes)
|
|
405
|
+
for (const stateNode of atomicStates) {
|
|
406
|
+
// For each atomic state, process the state itself first, then its ancestors
|
|
407
|
+
// This ensures child state transitions come before parent state transitions
|
|
408
|
+
for (const s of [stateNode].concat(guards_dist_xstateGuards.getProperAncestors(stateNode, undefined))) {
|
|
409
|
+
if (visited.has(s.id)) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
visited.add(s.id);
|
|
413
|
+
|
|
414
|
+
// Get all transitions for each event type
|
|
415
|
+
// Include ALL transitions, even if the same event type appears in multiple state nodes
|
|
416
|
+
// This is important for guarded transitions - all are "potential" regardless of guard evaluation
|
|
417
|
+
for (const [, transitions] of s.transitions) {
|
|
418
|
+
potentialTransitions.push(...transitions);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Also include always (eventless) transitions
|
|
422
|
+
if (s.always) {
|
|
423
|
+
potentialTransitions.push(...s.always);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return potentialTransitions;
|
|
428
|
+
}
|
|
429
|
+
|
|
341
430
|
const defaultWaitForOptions = {
|
|
342
431
|
timeout: Infinity // much more than 10 seconds
|
|
343
432
|
};
|
|
@@ -479,8 +568,11 @@ exports.sendTo = log.sendTo;
|
|
|
479
568
|
exports.SimulatedClock = SimulatedClock;
|
|
480
569
|
exports.assertEvent = assertEvent;
|
|
481
570
|
exports.createMachine = createMachine;
|
|
571
|
+
exports.getInitialMicrosteps = getInitialMicrosteps;
|
|
482
572
|
exports.getInitialSnapshot = getInitialSnapshot;
|
|
573
|
+
exports.getMicrosteps = getMicrosteps;
|
|
483
574
|
exports.getNextSnapshot = getNextSnapshot;
|
|
575
|
+
exports.getNextTransitions = getNextTransitions;
|
|
484
576
|
exports.initialTransition = initialTransition;
|
|
485
577
|
exports.setup = setup;
|
|
486
578
|
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, d as macrostep, e as createInitEvent, i as initialMicrostep, f as isAtomicStateNode, g as getProperAncestors } from './raise-a7794093.development.esm.js';
|
|
3
|
+
export { A as Actor, q as __unsafe_getAllOwnEventDescriptors, j as and, a as cancel, c as createActor, p as getStateNodes, h as interpret, l as isMachineSnapshot, u as matchesState, n as not, o as or, v as pathToStateValue, r as raise, b as spawnChild, k as stateIn, x as stop, s as stopChild, w as toObserver } from './raise-a7794093.development.esm.js';
|
|
4
|
+
import { S as StateMachine } from './StateMachine-93271b59.development.esm.js';
|
|
5
|
+
export { S as StateMachine, a as StateNode } from './StateMachine-93271b59.development.esm.js';
|
|
6
|
+
import { a as assign } from './assign-d5291869.development.esm.js';
|
|
7
|
+
export { a as assign } from './assign-d5291869.development.esm.js';
|
|
8
|
+
import { s as sendTo, l as log, e as enqueueActions, a as emit } from './log-7dbbb7c2.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-7dbbb7c2.development.esm.js';
|
|
10
10
|
import '../dev/dist/xstate-dev.development.esm.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -338,6 +338,95 @@ function initialTransition(logic, ...[input]) {
|
|
|
338
338
|
return [nextSnapshot, executableActions];
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Given a state `machine`, a `snapshot`, and an `event`, returns an array of
|
|
343
|
+
* microsteps, where each microstep is a tuple of `[snapshot, actions]`.
|
|
344
|
+
*
|
|
345
|
+
* This is a pure function that does not execute `actions`.
|
|
346
|
+
*/
|
|
347
|
+
function getMicrosteps(machine, snapshot, event) {
|
|
348
|
+
const actorScope = createInertActorScope(machine);
|
|
349
|
+
const {
|
|
350
|
+
microsteps
|
|
351
|
+
} = macrostep(snapshot, event, actorScope, []);
|
|
352
|
+
return microsteps;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Given a state `machine` and optional `input`, returns an array of microsteps
|
|
357
|
+
* from the initial transition, where each microstep is a tuple of `[snapshot,
|
|
358
|
+
* actions]`.
|
|
359
|
+
*
|
|
360
|
+
* This is a pure function that does not execute `actions`.
|
|
361
|
+
*/
|
|
362
|
+
function getInitialMicrosteps(machine, ...[input]) {
|
|
363
|
+
const actorScope = createInertActorScope(machine);
|
|
364
|
+
const initEvent = createInitEvent(input);
|
|
365
|
+
const internalQueue = [];
|
|
366
|
+
const preInitialSnapshot = machine._getPreInitialState(actorScope, initEvent, internalQueue);
|
|
367
|
+
const first = initialMicrostep(machine.root, preInitialSnapshot, actorScope, initEvent, internalQueue);
|
|
368
|
+
const {
|
|
369
|
+
microsteps
|
|
370
|
+
} = macrostep(first[0], initEvent, actorScope, internalQueue);
|
|
371
|
+
return [first, ...microsteps];
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Gets all potential next transitions from the current state.
|
|
376
|
+
*
|
|
377
|
+
* Returns all transitions that are available from the current state, including:
|
|
378
|
+
*
|
|
379
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
380
|
+
* configuration)
|
|
381
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
382
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
383
|
+
* - Always (eventless) transitions
|
|
384
|
+
* - After (delayed) transitions
|
|
385
|
+
*
|
|
386
|
+
* The order of transitions is deterministic:
|
|
387
|
+
*
|
|
388
|
+
* 1. Atomic states are processed in document order
|
|
389
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
390
|
+
* then its ancestors
|
|
391
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
392
|
+
* definition
|
|
393
|
+
*
|
|
394
|
+
* @param state - The current machine snapshot
|
|
395
|
+
* @returns Array of transition definitions from the current state, in
|
|
396
|
+
* deterministic order
|
|
397
|
+
*/
|
|
398
|
+
function getNextTransitions(state) {
|
|
399
|
+
const potentialTransitions = [];
|
|
400
|
+
const atomicStates = state._nodes.filter(isAtomicStateNode);
|
|
401
|
+
const visited = new Set();
|
|
402
|
+
|
|
403
|
+
// Collect all transitions from atomic states and their ancestors
|
|
404
|
+
// Process atomic states in document order (as they appear in state._nodes)
|
|
405
|
+
for (const stateNode of atomicStates) {
|
|
406
|
+
// For each atomic state, process the state itself first, then its ancestors
|
|
407
|
+
// This ensures child state transitions come before parent state transitions
|
|
408
|
+
for (const s of [stateNode].concat(getProperAncestors(stateNode, undefined))) {
|
|
409
|
+
if (visited.has(s.id)) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
visited.add(s.id);
|
|
413
|
+
|
|
414
|
+
// Get all transitions for each event type
|
|
415
|
+
// Include ALL transitions, even if the same event type appears in multiple state nodes
|
|
416
|
+
// This is important for guarded transitions - all are "potential" regardless of guard evaluation
|
|
417
|
+
for (const [, transitions] of s.transitions) {
|
|
418
|
+
potentialTransitions.push(...transitions);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Also include always (eventless) transitions
|
|
422
|
+
if (s.always) {
|
|
423
|
+
potentialTransitions.push(...s.always);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return potentialTransitions;
|
|
428
|
+
}
|
|
429
|
+
|
|
341
430
|
const defaultWaitForOptions = {
|
|
342
431
|
timeout: Infinity // much more than 10 seconds
|
|
343
432
|
};
|
|
@@ -442,4 +531,4 @@ function waitFor(actorRef, predicate, options) {
|
|
|
442
531
|
});
|
|
443
532
|
}
|
|
444
533
|
|
|
445
|
-
export { SimulatedClock, assertEvent, createMachine, getInitialSnapshot, getNextSnapshot, initialTransition, setup, toPromise, transition, waitFor };
|
|
534
|
+
export { SimulatedClock, assertEvent, createMachine, getInitialMicrosteps, getInitialSnapshot, getMicrosteps, getNextSnapshot, getNextTransitions, initialTransition, setup, toPromise, transition, waitFor };
|
package/dist/xstate.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.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, d as macrostep, e as createInitEvent, i as initialMicrostep, f as isAtomicStateNode, g as getProperAncestors } from './raise-e5d81555.esm.js';
|
|
3
|
+
export { A as Actor, q as __unsafe_getAllOwnEventDescriptors, j as and, a as cancel, c as createActor, p as getStateNodes, h as interpret, l as isMachineSnapshot, u as matchesState, n as not, o as or, v as pathToStateValue, r as raise, b as spawnChild, k as stateIn, x as stop, s as stopChild, w as toObserver } from './raise-e5d81555.esm.js';
|
|
4
|
+
import { S as StateMachine } from './StateMachine-a4db5a91.esm.js';
|
|
5
|
+
export { S as StateMachine, a as StateNode } from './StateMachine-a4db5a91.esm.js';
|
|
6
|
+
import { a as assign } from './assign-227b928a.esm.js';
|
|
7
|
+
export { a as assign } from './assign-227b928a.esm.js';
|
|
8
|
+
import { s as sendTo, l as log, e as enqueueActions, a as emit } from './log-fa76d888.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-fa76d888.esm.js';
|
|
10
10
|
import '../dev/dist/xstate-dev.esm.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -338,6 +338,95 @@ function initialTransition(logic, ...[input]) {
|
|
|
338
338
|
return [nextSnapshot, executableActions];
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Given a state `machine`, a `snapshot`, and an `event`, returns an array of
|
|
343
|
+
* microsteps, where each microstep is a tuple of `[snapshot, actions]`.
|
|
344
|
+
*
|
|
345
|
+
* This is a pure function that does not execute `actions`.
|
|
346
|
+
*/
|
|
347
|
+
function getMicrosteps(machine, snapshot, event) {
|
|
348
|
+
const actorScope = createInertActorScope(machine);
|
|
349
|
+
const {
|
|
350
|
+
microsteps
|
|
351
|
+
} = macrostep(snapshot, event, actorScope, []);
|
|
352
|
+
return microsteps;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Given a state `machine` and optional `input`, returns an array of microsteps
|
|
357
|
+
* from the initial transition, where each microstep is a tuple of `[snapshot,
|
|
358
|
+
* actions]`.
|
|
359
|
+
*
|
|
360
|
+
* This is a pure function that does not execute `actions`.
|
|
361
|
+
*/
|
|
362
|
+
function getInitialMicrosteps(machine, ...[input]) {
|
|
363
|
+
const actorScope = createInertActorScope(machine);
|
|
364
|
+
const initEvent = createInitEvent(input);
|
|
365
|
+
const internalQueue = [];
|
|
366
|
+
const preInitialSnapshot = machine._getPreInitialState(actorScope, initEvent, internalQueue);
|
|
367
|
+
const first = initialMicrostep(machine.root, preInitialSnapshot, actorScope, initEvent, internalQueue);
|
|
368
|
+
const {
|
|
369
|
+
microsteps
|
|
370
|
+
} = macrostep(first[0], initEvent, actorScope, internalQueue);
|
|
371
|
+
return [first, ...microsteps];
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Gets all potential next transitions from the current state.
|
|
376
|
+
*
|
|
377
|
+
* Returns all transitions that are available from the current state, including:
|
|
378
|
+
*
|
|
379
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
380
|
+
* configuration)
|
|
381
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
382
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
383
|
+
* - Always (eventless) transitions
|
|
384
|
+
* - After (delayed) transitions
|
|
385
|
+
*
|
|
386
|
+
* The order of transitions is deterministic:
|
|
387
|
+
*
|
|
388
|
+
* 1. Atomic states are processed in document order
|
|
389
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
390
|
+
* then its ancestors
|
|
391
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
392
|
+
* definition
|
|
393
|
+
*
|
|
394
|
+
* @param state - The current machine snapshot
|
|
395
|
+
* @returns Array of transition definitions from the current state, in
|
|
396
|
+
* deterministic order
|
|
397
|
+
*/
|
|
398
|
+
function getNextTransitions(state) {
|
|
399
|
+
const potentialTransitions = [];
|
|
400
|
+
const atomicStates = state._nodes.filter(isAtomicStateNode);
|
|
401
|
+
const visited = new Set();
|
|
402
|
+
|
|
403
|
+
// Collect all transitions from atomic states and their ancestors
|
|
404
|
+
// Process atomic states in document order (as they appear in state._nodes)
|
|
405
|
+
for (const stateNode of atomicStates) {
|
|
406
|
+
// For each atomic state, process the state itself first, then its ancestors
|
|
407
|
+
// This ensures child state transitions come before parent state transitions
|
|
408
|
+
for (const s of [stateNode].concat(getProperAncestors(stateNode, undefined))) {
|
|
409
|
+
if (visited.has(s.id)) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
visited.add(s.id);
|
|
413
|
+
|
|
414
|
+
// Get all transitions for each event type
|
|
415
|
+
// Include ALL transitions, even if the same event type appears in multiple state nodes
|
|
416
|
+
// This is important for guarded transitions - all are "potential" regardless of guard evaluation
|
|
417
|
+
for (const [, transitions] of s.transitions) {
|
|
418
|
+
potentialTransitions.push(...transitions);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Also include always (eventless) transitions
|
|
422
|
+
if (s.always) {
|
|
423
|
+
potentialTransitions.push(...s.always);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return potentialTransitions;
|
|
428
|
+
}
|
|
429
|
+
|
|
341
430
|
const defaultWaitForOptions = {
|
|
342
431
|
timeout: Infinity // much more than 10 seconds
|
|
343
432
|
};
|
|
@@ -439,4 +528,4 @@ function waitFor(actorRef, predicate, options) {
|
|
|
439
528
|
});
|
|
440
529
|
}
|
|
441
530
|
|
|
442
|
-
export { SimulatedClock, assertEvent, createMachine, getInitialSnapshot, getNextSnapshot, initialTransition, setup, toPromise, transition, waitFor };
|
|
531
|
+
export { SimulatedClock, assertEvent, createMachine, getInitialMicrosteps, getInitialSnapshot, getMicrosteps, getNextSnapshot, getNextTransitions, initialTransition, setup, toPromise, transition, waitFor };
|