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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var guards_dist_xstateGuards = require('../../dist/raise-
|
|
5
|
+
var guards_dist_xstateGuards = require('../../dist/raise-3a84be1f.cjs.js');
|
|
6
6
|
require('../../dev/dist/xstate-dev.cjs.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var guards_dist_xstateGuards = require('../../dist/raise-
|
|
5
|
+
var guards_dist_xstateGuards = require('../../dist/raise-ecea0c53.development.cjs.js');
|
|
6
6
|
require('../../dev/dist/xstate-dev.development.cjs.js');
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/{StateMachine-d0e98d09.development.esm.js → StateMachine-93271b59.development.esm.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as STATE_DELIMITER,
|
|
2
|
-
import { a as assign } from './assign-
|
|
1
|
+
import { S as STATE_DELIMITER, y as mapValues, t as toArray, z as formatTransitions, B as toTransitionConfigArray, C as formatTransition, N as NULL_EVENT, D as evaluateGuard, E as createInvokeId, F as getDelayedTransitions, G as formatInitialTransition, H as getCandidates, I as resolveStateValue, J as getAllStateNodes, p as getStateNodes, K as createMachineSnapshot, L as isInFinalState, d as macrostep, M as transitionNode, O as resolveActionsAndContext, e as createInitEvent, i as initialMicrostep, P as toStatePath, Q as isStateId, R as getStateNodeByPath, T as getPersistedSnapshot, U as resolveReferencedActor, c as createActor, $ as $$ACTOR_TYPE } from './raise-a7794093.development.esm.js';
|
|
2
|
+
import { a as assign } from './assign-d5291869.development.esm.js';
|
|
3
3
|
|
|
4
4
|
const cache = new WeakMap();
|
|
5
5
|
function memo(object, key, fn) {
|
|
@@ -399,7 +399,7 @@ class StateMachine {
|
|
|
399
399
|
* @param event The received event
|
|
400
400
|
*/
|
|
401
401
|
microstep(snapshot, event, actorScope) {
|
|
402
|
-
return macrostep(snapshot, event, actorScope, []).
|
|
402
|
+
return macrostep(snapshot, event, actorScope, []).microsteps.map(([s]) => s);
|
|
403
403
|
}
|
|
404
404
|
getTransitionData(snapshot, event) {
|
|
405
405
|
return transitionNode(this.root, snapshot.value, snapshot, event) || [];
|
|
@@ -408,8 +408,10 @@ class StateMachine {
|
|
|
408
408
|
/**
|
|
409
409
|
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
410
410
|
* state is provided to initial actions executed in the initial state.
|
|
411
|
+
*
|
|
412
|
+
* @internal
|
|
411
413
|
*/
|
|
412
|
-
|
|
414
|
+
_getPreInitialState(actorScope, initEvent, internalQueue) {
|
|
413
415
|
const {
|
|
414
416
|
context
|
|
415
417
|
} = this.config;
|
|
@@ -441,15 +443,8 @@ class StateMachine {
|
|
|
441
443
|
getInitialSnapshot(actorScope, input) {
|
|
442
444
|
const initEvent = createInitEvent(input); // TODO: fix;
|
|
443
445
|
const internalQueue = [];
|
|
444
|
-
const preInitialState = this.
|
|
445
|
-
const nextState =
|
|
446
|
-
target: [...getInitialStateNodes(this.root)],
|
|
447
|
-
source: this.root,
|
|
448
|
-
reenter: true,
|
|
449
|
-
actions: [],
|
|
450
|
-
eventType: null,
|
|
451
|
-
toJSON: null // TODO: fix
|
|
452
|
-
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
446
|
+
const preInitialState = this._getPreInitialState(actorScope, initEvent, internalQueue);
|
|
447
|
+
const [nextState] = initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
453
448
|
const {
|
|
454
449
|
snapshot: macroState
|
|
455
450
|
} = macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as STATE_DELIMITER,
|
|
2
|
-
import { a as assign } from './assign-
|
|
1
|
+
import { S as STATE_DELIMITER, y as mapValues, t as toArray, z as formatTransitions, B as toTransitionConfigArray, C as formatTransition, N as NULL_EVENT, D as evaluateGuard, E as createInvokeId, F as getDelayedTransitions, G as formatInitialTransition, H as getCandidates, I as resolveStateValue, J as getAllStateNodes, p as getStateNodes, K as createMachineSnapshot, L as isInFinalState, d as macrostep, M as transitionNode, O as resolveActionsAndContext, e as createInitEvent, i as initialMicrostep, P as toStatePath, Q as isStateId, R as getStateNodeByPath, T as getPersistedSnapshot, U as resolveReferencedActor, c as createActor, $ as $$ACTOR_TYPE } from './raise-e5d81555.esm.js';
|
|
2
|
+
import { a as assign } from './assign-227b928a.esm.js';
|
|
3
3
|
|
|
4
4
|
const cache = new WeakMap();
|
|
5
5
|
function memo(object, key, fn) {
|
|
@@ -396,7 +396,7 @@ class StateMachine {
|
|
|
396
396
|
* @param event The received event
|
|
397
397
|
*/
|
|
398
398
|
microstep(snapshot, event, actorScope) {
|
|
399
|
-
return macrostep(snapshot, event, actorScope, []).
|
|
399
|
+
return macrostep(snapshot, event, actorScope, []).microsteps.map(([s]) => s);
|
|
400
400
|
}
|
|
401
401
|
getTransitionData(snapshot, event) {
|
|
402
402
|
return transitionNode(this.root, snapshot.value, snapshot, event) || [];
|
|
@@ -405,8 +405,10 @@ class StateMachine {
|
|
|
405
405
|
/**
|
|
406
406
|
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
407
407
|
* state is provided to initial actions executed in the initial state.
|
|
408
|
+
*
|
|
409
|
+
* @internal
|
|
408
410
|
*/
|
|
409
|
-
|
|
411
|
+
_getPreInitialState(actorScope, initEvent, internalQueue) {
|
|
410
412
|
const {
|
|
411
413
|
context
|
|
412
414
|
} = this.config;
|
|
@@ -438,15 +440,8 @@ class StateMachine {
|
|
|
438
440
|
getInitialSnapshot(actorScope, input) {
|
|
439
441
|
const initEvent = createInitEvent(input); // TODO: fix;
|
|
440
442
|
const internalQueue = [];
|
|
441
|
-
const preInitialState = this.
|
|
442
|
-
const nextState =
|
|
443
|
-
target: [...getInitialStateNodes(this.root)],
|
|
444
|
-
source: this.root,
|
|
445
|
-
reenter: true,
|
|
446
|
-
actions: [],
|
|
447
|
-
eventType: null,
|
|
448
|
-
toJSON: null // TODO: fix
|
|
449
|
-
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
443
|
+
const preInitialState = this._getPreInitialState(actorScope, initEvent, internalQueue);
|
|
444
|
+
const [nextState] = initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
450
445
|
const {
|
|
451
446
|
snapshot: macroState
|
|
452
447
|
} = macrostep(nextState, initEvent, actorScope, internalQueue);
|
package/dist/{StateMachine-6d24a98f.development.cjs.js → StateMachine-c3376229.development.cjs.js}
RENAMED
|
@@ -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-ecea0c53.development.cjs.js');
|
|
4
|
+
var assign = require('./assign-8ef0e332.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
const cache = new WeakMap();
|
|
7
7
|
function memo(object, key, fn) {
|
|
@@ -401,7 +401,7 @@ class StateMachine {
|
|
|
401
401
|
* @param event The received event
|
|
402
402
|
*/
|
|
403
403
|
microstep(snapshot, event, actorScope) {
|
|
404
|
-
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope, []).
|
|
404
|
+
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope, []).microsteps.map(([s]) => s);
|
|
405
405
|
}
|
|
406
406
|
getTransitionData(snapshot, event) {
|
|
407
407
|
return guards_dist_xstateGuards.transitionNode(this.root, snapshot.value, snapshot, event) || [];
|
|
@@ -410,8 +410,10 @@ class StateMachine {
|
|
|
410
410
|
/**
|
|
411
411
|
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
412
412
|
* state is provided to initial actions executed in the initial state.
|
|
413
|
+
*
|
|
414
|
+
* @internal
|
|
413
415
|
*/
|
|
414
|
-
|
|
416
|
+
_getPreInitialState(actorScope, initEvent, internalQueue) {
|
|
415
417
|
const {
|
|
416
418
|
context
|
|
417
419
|
} = this.config;
|
|
@@ -443,15 +445,8 @@ class StateMachine {
|
|
|
443
445
|
getInitialSnapshot(actorScope, input) {
|
|
444
446
|
const initEvent = guards_dist_xstateGuards.createInitEvent(input); // TODO: fix;
|
|
445
447
|
const internalQueue = [];
|
|
446
|
-
const preInitialState = this.
|
|
447
|
-
const nextState = guards_dist_xstateGuards.
|
|
448
|
-
target: [...guards_dist_xstateGuards.getInitialStateNodes(this.root)],
|
|
449
|
-
source: this.root,
|
|
450
|
-
reenter: true,
|
|
451
|
-
actions: [],
|
|
452
|
-
eventType: null,
|
|
453
|
-
toJSON: null // TODO: fix
|
|
454
|
-
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
448
|
+
const preInitialState = this._getPreInitialState(actorScope, initEvent, internalQueue);
|
|
449
|
+
const [nextState] = guards_dist_xstateGuards.initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
455
450
|
const {
|
|
456
451
|
snapshot: macroState
|
|
457
452
|
} = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
@@ -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-3a84be1f.cjs.js');
|
|
4
|
+
var assign = require('./assign-e36553db.cjs.js');
|
|
5
5
|
|
|
6
6
|
const cache = new WeakMap();
|
|
7
7
|
function memo(object, key, fn) {
|
|
@@ -398,7 +398,7 @@ class StateMachine {
|
|
|
398
398
|
* @param event The received event
|
|
399
399
|
*/
|
|
400
400
|
microstep(snapshot, event, actorScope) {
|
|
401
|
-
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope, []).
|
|
401
|
+
return guards_dist_xstateGuards.macrostep(snapshot, event, actorScope, []).microsteps.map(([s]) => s);
|
|
402
402
|
}
|
|
403
403
|
getTransitionData(snapshot, event) {
|
|
404
404
|
return guards_dist_xstateGuards.transitionNode(this.root, snapshot.value, snapshot, event) || [];
|
|
@@ -407,8 +407,10 @@ class StateMachine {
|
|
|
407
407
|
/**
|
|
408
408
|
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
409
409
|
* state is provided to initial actions executed in the initial state.
|
|
410
|
+
*
|
|
411
|
+
* @internal
|
|
410
412
|
*/
|
|
411
|
-
|
|
413
|
+
_getPreInitialState(actorScope, initEvent, internalQueue) {
|
|
412
414
|
const {
|
|
413
415
|
context
|
|
414
416
|
} = this.config;
|
|
@@ -440,15 +442,8 @@ class StateMachine {
|
|
|
440
442
|
getInitialSnapshot(actorScope, input) {
|
|
441
443
|
const initEvent = guards_dist_xstateGuards.createInitEvent(input); // TODO: fix;
|
|
442
444
|
const internalQueue = [];
|
|
443
|
-
const preInitialState = this.
|
|
444
|
-
const nextState = guards_dist_xstateGuards.
|
|
445
|
-
target: [...guards_dist_xstateGuards.getInitialStateNodes(this.root)],
|
|
446
|
-
source: this.root,
|
|
447
|
-
reenter: true,
|
|
448
|
-
actions: [],
|
|
449
|
-
eventType: null,
|
|
450
|
-
toJSON: null // TODO: fix
|
|
451
|
-
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
445
|
+
const preInitialState = this._getPreInitialState(actorScope, initEvent, internalQueue);
|
|
446
|
+
const [nextState] = guards_dist_xstateGuards.initialMicrostep(this.root, preInitialState, actorScope, initEvent, internalQueue);
|
|
452
447
|
const {
|
|
453
448
|
snapshot: macroState
|
|
454
449
|
} = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorScope, internalQueue);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Y as ProcessingStatus, U as resolveReferencedActor, c as createActor, Z as cloneMachineSnapshot } from './raise-e5d81555.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Z as ProcessingStatus, U as resolveReferencedActor, c as createActor, _ as cloneMachineSnapshot, V as executingCustomAction } from './raise-a7794093.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -57,11 +57,6 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
57
57
|
*/
|
|
58
58
|
microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TStateSchema>, event: TEvent, actorScope: AnyActorScope): Array<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TStateSchema>>;
|
|
59
59
|
getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TStateSchema>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>>;
|
|
60
|
-
/**
|
|
61
|
-
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
62
|
-
* state is provided to initial actions executed in the initial state.
|
|
63
|
-
*/
|
|
64
|
-
private getPreInitialState;
|
|
65
60
|
/**
|
|
66
61
|
* Returns the initial `State` instance, with reference to `self` as an
|
|
67
62
|
* `ActorRef`.
|
|
@@ -17,7 +17,7 @@ export type { ActorSystem } from "./system.js";
|
|
|
17
17
|
export { toPromise } from "./toPromise.js";
|
|
18
18
|
export * from "./types.js";
|
|
19
19
|
export { getAllOwnEventDescriptors as __unsafe_getAllOwnEventDescriptors, matchesState, pathToStateValue, toObserver } from "./utils.js";
|
|
20
|
-
export { transition, initialTransition } from "./transition.js";
|
|
20
|
+
export { transition, initialTransition, getMicrosteps, getInitialMicrosteps, getNextTransitions } from "./transition.js";
|
|
21
21
|
export { waitFor } from "./waitFor.js";
|
|
22
22
|
declare global {
|
|
23
23
|
interface SymbolConstructor {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { MachineSnapshot } from "./State.js";
|
|
2
2
|
import type { StateNode } from "./StateNode.js";
|
|
3
|
-
import { ActionArgs, AnyEventObject, AnyMachineSnapshot, AnyStateNode, AnyTransitionDefinition, DelayedTransitionDefinition, EventObject, InitialTransitionConfig, InitialTransitionDefinition, MachineContext, StateValue, TransitionDefinition, TODO, UnknownAction, ParameterizedObject, AnyTransitionConfig, AnyActorScope } from "./types.js";
|
|
3
|
+
import { ActionArgs, AnyEventObject, AnyMachineSnapshot, AnyStateNode, AnyTransitionDefinition, DelayedTransitionDefinition, EventObject, ExecutableActionObject, InitialTransitionConfig, InitialTransitionDefinition, MachineContext, StateValue, TransitionDefinition, TODO, UnknownAction, ParameterizedObject, AnyTransitionConfig, AnyActorScope } from "./types.js";
|
|
4
4
|
type StateNodeIterable<TContext extends MachineContext, TE extends EventObject> = Iterable<StateNode<TContext, TE>>;
|
|
5
5
|
type AnyStateNodeIterable = StateNodeIterable<any, any>;
|
|
6
|
+
export declare function isAtomicStateNode(stateNode: StateNode<any, any>): boolean;
|
|
7
|
+
export declare function getProperAncestors(stateNode: AnyStateNode, toStateNode: AnyStateNode | undefined): Array<typeof stateNode>;
|
|
6
8
|
export declare function getAllStateNodes(stateNodes: Iterable<AnyStateNode>): Set<AnyStateNode>;
|
|
7
9
|
export declare function getStateValue(rootNode: AnyStateNode, stateNodes: AnyStateNodeIterable): StateValue;
|
|
8
10
|
export declare function isInFinalState(stateNodeSet: Set<AnyStateNode>, stateNode: AnyStateNode): boolean;
|
|
@@ -13,7 +15,6 @@ export declare function getDelayedTransitions(stateNode: AnyStateNode): Array<De
|
|
|
13
15
|
export declare function formatTransition(stateNode: AnyStateNode, descriptor: string, transitionConfig: AnyTransitionConfig): AnyTransitionDefinition;
|
|
14
16
|
export declare function formatTransitions<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode): Map<string, TransitionDefinition<TContext, TEvent>[]>;
|
|
15
17
|
export declare function formatInitialTransition<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, _target: string | undefined | InitialTransitionConfig<TContext, TEvent, TODO, TODO, TODO, TODO>): InitialTransitionDefinition<TContext, TEvent>;
|
|
16
|
-
export declare function getInitialStateNodes(stateNode: AnyStateNode): Set<AnyStateNode>;
|
|
17
18
|
/**
|
|
18
19
|
* Returns the relative state node from the given `statePath`, or throws.
|
|
19
20
|
*
|
|
@@ -27,8 +28,8 @@ export declare function getStateNodeByPath(stateNode: AnyStateNode, statePath: s
|
|
|
27
28
|
*/
|
|
28
29
|
export declare function getStateNodes(stateNode: AnyStateNode, stateValue: StateValue): Array<AnyStateNode>;
|
|
29
30
|
export declare function transitionNode<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode, stateValue: StateValue, snapshot: MachineSnapshot<TContext, TEvent, any, any, any, any, any, any>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>> | undefined;
|
|
30
|
-
|
|
31
|
-
export declare function
|
|
31
|
+
type Microstep = readonly [AnyMachineSnapshot, ExecutableActionObject[]];
|
|
32
|
+
export declare function initialMicrostep(root: AnyStateNode, preInitialState: AnyMachineSnapshot, actorScope: AnyActorScope, initEvent: AnyEventObject, internalQueue: AnyEventObject[]): Microstep;
|
|
32
33
|
export interface BuiltinAction {
|
|
33
34
|
(): void;
|
|
34
35
|
type: `xstate.${string}`;
|
|
@@ -43,7 +44,7 @@ export interface BuiltinAction {
|
|
|
43
44
|
export declare function resolveActionsAndContext(currentSnapshot: AnyMachineSnapshot, event: AnyEventObject, actorScope: AnyActorScope, actions: UnknownAction[], internalQueue: AnyEventObject[], deferredActorIds: string[] | undefined): AnyMachineSnapshot;
|
|
44
45
|
export declare function macrostep(snapshot: AnyMachineSnapshot, event: EventObject, actorScope: AnyActorScope, internalQueue: AnyEventObject[]): {
|
|
45
46
|
snapshot: typeof snapshot;
|
|
46
|
-
|
|
47
|
+
microsteps: Microstep[];
|
|
47
48
|
};
|
|
48
49
|
/**
|
|
49
50
|
* Resolves a partial state value with its full representation in the state
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyActorLogic, EventFromLogic, InputFrom, SnapshotFrom, ExecutableActionsFrom } from "./types.js";
|
|
1
|
+
import { AnyActorLogic, AnyStateMachine, 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,43 @@ 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
|
+
* Given a state `machine`, a `snapshot`, and an `event`, returns an array of
|
|
19
|
+
* microsteps, where each microstep is a tuple of `[snapshot, actions]`.
|
|
20
|
+
*
|
|
21
|
+
* This is a pure function that does not execute `actions`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getMicrosteps<T extends AnyStateMachine>(machine: T, snapshot: SnapshotFrom<T>, event: EventFromLogic<T>): Array<[SnapshotFrom<T>, ExecutableActionsFrom<T>[]]>;
|
|
24
|
+
/**
|
|
25
|
+
* Given a state `machine` and optional `input`, returns an array of microsteps
|
|
26
|
+
* from the initial transition, where each microstep is a tuple of `[snapshot,
|
|
27
|
+
* actions]`.
|
|
28
|
+
*
|
|
29
|
+
* This is a pure function that does not execute `actions`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getInitialMicrosteps<T extends AnyStateMachine>(machine: T, ...[input]: undefined extends InputFrom<T> ? [input?: InputFrom<T>] : [input: InputFrom<T>]): Array<[SnapshotFrom<T>, ExecutableActionsFrom<T>[]]>;
|
|
32
|
+
/**
|
|
33
|
+
* Gets all potential next transitions from the current state.
|
|
34
|
+
*
|
|
35
|
+
* Returns all transitions that are available from the current state, including:
|
|
36
|
+
*
|
|
37
|
+
* - All transitions from atomic states (leaf states in the current state
|
|
38
|
+
* configuration)
|
|
39
|
+
* - All transitions from ancestor states (parent states that may handle events)
|
|
40
|
+
* - All guarded transitions (regardless of whether their guards would pass)
|
|
41
|
+
* - Always (eventless) transitions
|
|
42
|
+
* - After (delayed) transitions
|
|
43
|
+
*
|
|
44
|
+
* The order of transitions is deterministic:
|
|
45
|
+
*
|
|
46
|
+
* 1. Atomic states are processed in document order
|
|
47
|
+
* 2. For each atomic state, transitions are collected from the state itself first,
|
|
48
|
+
* then its ancestors
|
|
49
|
+
* 3. Within each state node, transitions are in the order they appear in the state
|
|
50
|
+
* definition
|
|
51
|
+
*
|
|
52
|
+
* @param state - The current machine snapshot
|
|
53
|
+
* @returns Array of transition definitions from the current state, in
|
|
54
|
+
* deterministic order
|
|
55
|
+
*/
|
|
56
|
+
export declare function getNextTransitions(state: AnyMachineSnapshot): AnyTransitionDefinition[];
|
|
@@ -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-ecea0c53.development.cjs.js');
|
|
4
|
+
var assign = require('./assign-8ef0e332.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 { V as executingCustomAction, W as XSTATE_ERROR, Y as createErrorActorEvent, D as evaluateGuard, a as cancel, r as raise, b as spawnChild, s as stopChild } from './raise-a7794093.development.esm.js';
|
|
2
|
+
import { a as assign } from './assign-d5291869.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-3a84be1f.cjs.js');
|
|
4
|
+
var assign = require('./assign-e36553db.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 { V as XSTATE_ERROR, W as createErrorActorEvent, D as evaluateGuard, a as cancel, r as raise, b as spawnChild, s as stopChild } from './raise-e5d81555.esm.js';
|
|
2
|
+
import { a as assign } from './assign-227b928a.esm.js';
|
|
3
3
|
|
|
4
4
|
function resolveEmit(_, snapshot, args, actionParams, {
|
|
5
5
|
event: eventOrExpr
|
|
@@ -1535,7 +1535,9 @@ function evaluateGuard(guard, context, event, snapshot) {
|
|
|
1535
1535
|
);
|
|
1536
1536
|
}
|
|
1537
1537
|
|
|
1538
|
-
|
|
1538
|
+
function isAtomicStateNode(stateNode) {
|
|
1539
|
+
return stateNode.type === 'atomic' || stateNode.type === 'final';
|
|
1540
|
+
}
|
|
1539
1541
|
function getChildren(stateNode) {
|
|
1540
1542
|
return Object.values(stateNode.states).filter(sn => sn.type !== 'history');
|
|
1541
1543
|
}
|
|
@@ -2073,45 +2075,65 @@ function areStateNodeCollectionsEqual(prevStateNodes, nextStateNodeSet) {
|
|
|
2073
2075
|
}
|
|
2074
2076
|
return true;
|
|
2075
2077
|
}
|
|
2078
|
+
function initialMicrostep(root, preInitialState, actorScope, initEvent, internalQueue) {
|
|
2079
|
+
return microstep([{
|
|
2080
|
+
target: [...getInitialStateNodes(root)],
|
|
2081
|
+
source: root,
|
|
2082
|
+
reenter: true,
|
|
2083
|
+
actions: [],
|
|
2084
|
+
eventType: null,
|
|
2085
|
+
toJSON: null
|
|
2086
|
+
}], preInitialState, actorScope, initEvent, true, internalQueue);
|
|
2087
|
+
}
|
|
2076
2088
|
|
|
2077
2089
|
/** https://www.w3.org/TR/scxml/#microstepProcedure */
|
|
2078
2090
|
function microstep(transitions, currentSnapshot, actorScope, event, isInitial, internalQueue) {
|
|
2091
|
+
const actions = [];
|
|
2079
2092
|
if (!transitions.length) {
|
|
2080
|
-
return currentSnapshot;
|
|
2093
|
+
return [currentSnapshot, actions];
|
|
2081
2094
|
}
|
|
2082
|
-
const
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2095
|
+
const originalExecutor = actorScope.actionExecutor;
|
|
2096
|
+
actorScope.actionExecutor = action => {
|
|
2097
|
+
actions.push(action);
|
|
2098
|
+
originalExecutor(action);
|
|
2099
|
+
};
|
|
2100
|
+
try {
|
|
2101
|
+
const mutStateNodeSet = new Set(currentSnapshot._nodes);
|
|
2102
|
+
let historyValue = currentSnapshot.historyValue;
|
|
2103
|
+
const filteredTransitions = removeConflictingTransitions(transitions, mutStateNodeSet, historyValue);
|
|
2104
|
+
let nextState = currentSnapshot;
|
|
2086
2105
|
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2106
|
+
// Exit states
|
|
2107
|
+
if (!isInitial) {
|
|
2108
|
+
[nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, historyValue, internalQueue, actorScope.actionExecutor);
|
|
2109
|
+
}
|
|
2091
2110
|
|
|
2092
|
-
|
|
2093
|
-
|
|
2111
|
+
// Execute transition content
|
|
2112
|
+
nextState = resolveActionsAndContext(nextState, event, actorScope, filteredTransitions.flatMap(t => t.actions), internalQueue, undefined);
|
|
2094
2113
|
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2114
|
+
// Enter states
|
|
2115
|
+
nextState = enterStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial);
|
|
2116
|
+
const nextStateNodes = [...mutStateNodeSet];
|
|
2117
|
+
if (nextState.status === 'done') {
|
|
2118
|
+
nextState = resolveActionsAndContext(nextState, event, actorScope, nextStateNodes.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue, undefined);
|
|
2119
|
+
}
|
|
2101
2120
|
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2121
|
+
// eslint-disable-next-line no-useless-catch
|
|
2122
|
+
try {
|
|
2123
|
+
if (historyValue === currentSnapshot.historyValue && areStateNodeCollectionsEqual(currentSnapshot._nodes, mutStateNodeSet)) {
|
|
2124
|
+
return [nextState, actions];
|
|
2125
|
+
}
|
|
2126
|
+
return [cloneMachineSnapshot(nextState, {
|
|
2127
|
+
_nodes: nextStateNodes,
|
|
2128
|
+
historyValue
|
|
2129
|
+
}), actions];
|
|
2130
|
+
} catch (e) {
|
|
2131
|
+
// TODO: Refactor this once proper error handling is implemented.
|
|
2132
|
+
// See https://github.com/statelyai/rfcs/pull/4
|
|
2133
|
+
throw e;
|
|
2106
2134
|
}
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
historyValue
|
|
2110
|
-
});
|
|
2111
|
-
} catch (e) {
|
|
2112
|
-
// TODO: Refactor this once proper error handling is implemented.
|
|
2113
|
-
// See https://github.com/statelyai/rfcs/pull/4
|
|
2114
|
-
throw e;
|
|
2135
|
+
} finally {
|
|
2136
|
+
actorScope.actionExecutor = originalExecutor;
|
|
2115
2137
|
}
|
|
2116
2138
|
}
|
|
2117
2139
|
function getMachineOutput(snapshot, event, actorScope, rootNode, rootCompletionNode) {
|
|
@@ -2368,16 +2390,16 @@ function resolveActionsAndContext(currentSnapshot, event, actorScope, actions, i
|
|
|
2368
2390
|
}
|
|
2369
2391
|
function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
2370
2392
|
let nextSnapshot = snapshot;
|
|
2371
|
-
const
|
|
2372
|
-
function
|
|
2393
|
+
const microsteps = [];
|
|
2394
|
+
function addMicrostep(step, event, transitions) {
|
|
2373
2395
|
actorScope.system._sendInspectionEvent({
|
|
2374
2396
|
type: '@xstate.microstep',
|
|
2375
2397
|
actorRef: actorScope.self,
|
|
2376
2398
|
event,
|
|
2377
|
-
snapshot:
|
|
2399
|
+
snapshot: step[0],
|
|
2378
2400
|
_transitions: transitions
|
|
2379
2401
|
});
|
|
2380
|
-
|
|
2402
|
+
microsteps.push(step);
|
|
2381
2403
|
}
|
|
2382
2404
|
|
|
2383
2405
|
// Handle stop event
|
|
@@ -2385,10 +2407,10 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2385
2407
|
nextSnapshot = cloneMachineSnapshot(stopChildren(nextSnapshot, event, actorScope), {
|
|
2386
2408
|
status: 'stopped'
|
|
2387
2409
|
});
|
|
2388
|
-
|
|
2410
|
+
addMicrostep([nextSnapshot, []], event, []);
|
|
2389
2411
|
return {
|
|
2390
2412
|
snapshot: nextSnapshot,
|
|
2391
|
-
|
|
2413
|
+
microsteps
|
|
2392
2414
|
};
|
|
2393
2415
|
}
|
|
2394
2416
|
let nextEvent = event;
|
|
@@ -2407,16 +2429,17 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2407
2429
|
status: 'error',
|
|
2408
2430
|
error: currentEvent.error
|
|
2409
2431
|
});
|
|
2410
|
-
|
|
2432
|
+
addMicrostep([nextSnapshot, []], currentEvent, []);
|
|
2411
2433
|
return {
|
|
2412
2434
|
snapshot: nextSnapshot,
|
|
2413
|
-
|
|
2435
|
+
microsteps
|
|
2414
2436
|
};
|
|
2415
2437
|
}
|
|
2416
|
-
|
|
2438
|
+
const step = microstep(transitions, snapshot, actorScope, nextEvent, false,
|
|
2417
2439
|
// isInitial
|
|
2418
2440
|
internalQueue);
|
|
2419
|
-
|
|
2441
|
+
nextSnapshot = step[0];
|
|
2442
|
+
addMicrostep(step, currentEvent, transitions);
|
|
2420
2443
|
}
|
|
2421
2444
|
let shouldSelectEventlessTransitions = true;
|
|
2422
2445
|
while (nextSnapshot.status === 'active') {
|
|
@@ -2432,16 +2455,17 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2432
2455
|
nextEvent = internalQueue.shift();
|
|
2433
2456
|
enabledTransitions = selectTransitions(nextEvent, nextSnapshot);
|
|
2434
2457
|
}
|
|
2435
|
-
|
|
2458
|
+
const step = microstep(enabledTransitions, nextSnapshot, actorScope, nextEvent, false, internalQueue);
|
|
2459
|
+
nextSnapshot = step[0];
|
|
2436
2460
|
shouldSelectEventlessTransitions = nextSnapshot !== previousState;
|
|
2437
|
-
|
|
2461
|
+
addMicrostep(step, nextEvent, enabledTransitions);
|
|
2438
2462
|
}
|
|
2439
2463
|
if (nextSnapshot.status !== 'active') {
|
|
2440
2464
|
stopChildren(nextSnapshot, nextEvent, actorScope);
|
|
2441
2465
|
}
|
|
2442
2466
|
return {
|
|
2443
2467
|
snapshot: nextSnapshot,
|
|
2444
|
-
|
|
2468
|
+
microsteps
|
|
2445
2469
|
};
|
|
2446
2470
|
}
|
|
2447
2471
|
function stopChildren(nextState, event, actorScope) {
|
|
@@ -2704,11 +2728,13 @@ exports.getAllOwnEventDescriptors = getAllOwnEventDescriptors;
|
|
|
2704
2728
|
exports.getAllStateNodes = getAllStateNodes;
|
|
2705
2729
|
exports.getCandidates = getCandidates;
|
|
2706
2730
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
2707
|
-
exports.getInitialStateNodes = getInitialStateNodes;
|
|
2708
2731
|
exports.getPersistedSnapshot = getPersistedSnapshot;
|
|
2732
|
+
exports.getProperAncestors = getProperAncestors;
|
|
2709
2733
|
exports.getStateNodeByPath = getStateNodeByPath;
|
|
2710
2734
|
exports.getStateNodes = getStateNodes;
|
|
2735
|
+
exports.initialMicrostep = initialMicrostep;
|
|
2711
2736
|
exports.interpret = interpret;
|
|
2737
|
+
exports.isAtomicStateNode = isAtomicStateNode;
|
|
2712
2738
|
exports.isInFinalState = isInFinalState;
|
|
2713
2739
|
exports.isMachineSnapshot = isMachineSnapshot;
|
|
2714
2740
|
exports.isStateId = isStateId;
|
|
@@ -2716,7 +2742,6 @@ exports.macrostep = macrostep;
|
|
|
2716
2742
|
exports.mapValues = mapValues;
|
|
2717
2743
|
exports.matchesEventDescriptor = matchesEventDescriptor;
|
|
2718
2744
|
exports.matchesState = matchesState;
|
|
2719
|
-
exports.microstep = microstep;
|
|
2720
2745
|
exports.not = not;
|
|
2721
2746
|
exports.or = or;
|
|
2722
2747
|
exports.pathToStateValue = pathToStateValue;
|