xstate 5.26.0 → 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.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-ceed8de1.development.esm.js → StateMachine-93271b59.development.esm.js} +8 -13
- package/dist/{StateMachine-d08f7a0b.esm.js → StateMachine-a4db5a91.esm.js} +8 -13
- package/dist/{StateMachine-3a7b3253.development.cjs.js → StateMachine-c3376229.development.cjs.js} +8 -13
- package/dist/{StateMachine-29d33e13.cjs.js → StateMachine-e93afc18.cjs.js} +8 -13
- package/dist/{assign-5d7df46f.esm.js → assign-227b928a.esm.js} +1 -1
- package/dist/{assign-6a45790f.development.cjs.js → assign-8ef0e332.development.cjs.js} +1 -1
- package/dist/{assign-382e15e2.development.esm.js → assign-d5291869.development.esm.js} +1 -1
- package/dist/{assign-9271e302.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 +4 -5
- package/dist/declarations/src/transition.d.ts +16 -1
- package/dist/{log-661c5df8.development.cjs.js → log-72d5ee02.development.cjs.js} +2 -2
- package/dist/{log-d09f274f.development.esm.js → log-7dbbb7c2.development.esm.js} +2 -2
- package/dist/{log-fe39762e.cjs.js → log-e54c2eff.cjs.js} +2 -2
- package/dist/{log-46a8697a.esm.js → log-fa76d888.esm.js} +2 -2
- package/dist/{raise-df325116.cjs.js → raise-3a84be1f.cjs.js} +65 -44
- package/dist/{raise-13e2f823.development.esm.js → raise-a7794093.development.esm.js} +65 -43
- package/dist/{raise-f11495d1.esm.js → raise-e5d81555.esm.js} +65 -43
- package/dist/{raise-e47e3273.development.cjs.js → raise-ecea0c53.development.cjs.js} +65 -44
- package/dist/xstate.cjs.js +39 -4
- package/dist/xstate.cjs.mjs +2 -0
- package/dist/xstate.development.cjs.js +39 -4
- package/dist/xstate.development.cjs.mjs +2 -0
- package/dist/xstate.development.esm.js +42 -9
- package/dist/xstate.esm.js +42 -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-ceed8de1.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-3a7b3253.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, getNextTransitions } 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,6 +1,6 @@
|
|
|
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
6
|
export declare function isAtomicStateNode(stateNode: StateNode<any, any>): boolean;
|
|
@@ -15,7 +15,6 @@ export declare function getDelayedTransitions(stateNode: AnyStateNode): Array<De
|
|
|
15
15
|
export declare function formatTransition(stateNode: AnyStateNode, descriptor: string, transitionConfig: AnyTransitionConfig): AnyTransitionDefinition;
|
|
16
16
|
export declare function formatTransitions<TContext extends MachineContext, TEvent extends EventObject>(stateNode: AnyStateNode): Map<string, TransitionDefinition<TContext, TEvent>[]>;
|
|
17
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>;
|
|
18
|
-
export declare function getInitialStateNodes(stateNode: AnyStateNode): Set<AnyStateNode>;
|
|
19
18
|
/**
|
|
20
19
|
* Returns the relative state node from the given `statePath`, or throws.
|
|
21
20
|
*
|
|
@@ -29,8 +28,8 @@ export declare function getStateNodeByPath(stateNode: AnyStateNode, statePath: s
|
|
|
29
28
|
*/
|
|
30
29
|
export declare function getStateNodes(stateNode: AnyStateNode, stateValue: StateValue): Array<AnyStateNode>;
|
|
31
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;
|
|
32
|
-
|
|
33
|
-
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;
|
|
34
33
|
export interface BuiltinAction {
|
|
35
34
|
(): void;
|
|
36
35
|
type: `xstate.${string}`;
|
|
@@ -45,7 +44,7 @@ export interface BuiltinAction {
|
|
|
45
44
|
export declare function resolveActionsAndContext(currentSnapshot: AnyMachineSnapshot, event: AnyEventObject, actorScope: AnyActorScope, actions: UnknownAction[], internalQueue: AnyEventObject[], deferredActorIds: string[] | undefined): AnyMachineSnapshot;
|
|
46
45
|
export declare function macrostep(snapshot: AnyMachineSnapshot, event: EventObject, actorScope: AnyActorScope, internalQueue: AnyEventObject[]): {
|
|
47
46
|
snapshot: typeof snapshot;
|
|
48
|
-
|
|
47
|
+
microsteps: Microstep[];
|
|
49
48
|
};
|
|
50
49
|
/**
|
|
51
50
|
* Resolves a partial state value with its full representation in the state
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyActorLogic, EventFromLogic, InputFrom, SnapshotFrom, ExecutableActionsFrom, AnyTransitionDefinition, AnyMachineSnapshot } 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,6 +14,21 @@ 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>[]]>;
|
|
17
32
|
/**
|
|
18
33
|
* Gets all potential next transitions from the current state.
|
|
19
34
|
*
|
|
@@ -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
|
|
@@ -2075,45 +2075,65 @@ function areStateNodeCollectionsEqual(prevStateNodes, nextStateNodeSet) {
|
|
|
2075
2075
|
}
|
|
2076
2076
|
return true;
|
|
2077
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
|
+
}
|
|
2078
2088
|
|
|
2079
2089
|
/** https://www.w3.org/TR/scxml/#microstepProcedure */
|
|
2080
2090
|
function microstep(transitions, currentSnapshot, actorScope, event, isInitial, internalQueue) {
|
|
2091
|
+
const actions = [];
|
|
2081
2092
|
if (!transitions.length) {
|
|
2082
|
-
return currentSnapshot;
|
|
2093
|
+
return [currentSnapshot, actions];
|
|
2083
2094
|
}
|
|
2084
|
-
const
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
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;
|
|
2088
2105
|
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2106
|
+
// Exit states
|
|
2107
|
+
if (!isInitial) {
|
|
2108
|
+
[nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, historyValue, internalQueue, actorScope.actionExecutor);
|
|
2109
|
+
}
|
|
2093
2110
|
|
|
2094
|
-
|
|
2095
|
-
|
|
2111
|
+
// Execute transition content
|
|
2112
|
+
nextState = resolveActionsAndContext(nextState, event, actorScope, filteredTransitions.flatMap(t => t.actions), internalQueue, undefined);
|
|
2096
2113
|
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
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
|
+
}
|
|
2103
2120
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
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;
|
|
2108
2134
|
}
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
historyValue
|
|
2112
|
-
});
|
|
2113
|
-
} catch (e) {
|
|
2114
|
-
// TODO: Refactor this once proper error handling is implemented.
|
|
2115
|
-
// See https://github.com/statelyai/rfcs/pull/4
|
|
2116
|
-
throw e;
|
|
2135
|
+
} finally {
|
|
2136
|
+
actorScope.actionExecutor = originalExecutor;
|
|
2117
2137
|
}
|
|
2118
2138
|
}
|
|
2119
2139
|
function getMachineOutput(snapshot, event, actorScope, rootNode, rootCompletionNode) {
|
|
@@ -2370,16 +2390,16 @@ function resolveActionsAndContext(currentSnapshot, event, actorScope, actions, i
|
|
|
2370
2390
|
}
|
|
2371
2391
|
function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
2372
2392
|
let nextSnapshot = snapshot;
|
|
2373
|
-
const
|
|
2374
|
-
function
|
|
2393
|
+
const microsteps = [];
|
|
2394
|
+
function addMicrostep(step, event, transitions) {
|
|
2375
2395
|
actorScope.system._sendInspectionEvent({
|
|
2376
2396
|
type: '@xstate.microstep',
|
|
2377
2397
|
actorRef: actorScope.self,
|
|
2378
2398
|
event,
|
|
2379
|
-
snapshot:
|
|
2399
|
+
snapshot: step[0],
|
|
2380
2400
|
_transitions: transitions
|
|
2381
2401
|
});
|
|
2382
|
-
|
|
2402
|
+
microsteps.push(step);
|
|
2383
2403
|
}
|
|
2384
2404
|
|
|
2385
2405
|
// Handle stop event
|
|
@@ -2387,10 +2407,10 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2387
2407
|
nextSnapshot = cloneMachineSnapshot(stopChildren(nextSnapshot, event, actorScope), {
|
|
2388
2408
|
status: 'stopped'
|
|
2389
2409
|
});
|
|
2390
|
-
|
|
2410
|
+
addMicrostep([nextSnapshot, []], event, []);
|
|
2391
2411
|
return {
|
|
2392
2412
|
snapshot: nextSnapshot,
|
|
2393
|
-
|
|
2413
|
+
microsteps
|
|
2394
2414
|
};
|
|
2395
2415
|
}
|
|
2396
2416
|
let nextEvent = event;
|
|
@@ -2409,16 +2429,17 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2409
2429
|
status: 'error',
|
|
2410
2430
|
error: currentEvent.error
|
|
2411
2431
|
});
|
|
2412
|
-
|
|
2432
|
+
addMicrostep([nextSnapshot, []], currentEvent, []);
|
|
2413
2433
|
return {
|
|
2414
2434
|
snapshot: nextSnapshot,
|
|
2415
|
-
|
|
2435
|
+
microsteps
|
|
2416
2436
|
};
|
|
2417
2437
|
}
|
|
2418
|
-
|
|
2438
|
+
const step = microstep(transitions, snapshot, actorScope, nextEvent, false,
|
|
2419
2439
|
// isInitial
|
|
2420
2440
|
internalQueue);
|
|
2421
|
-
|
|
2441
|
+
nextSnapshot = step[0];
|
|
2442
|
+
addMicrostep(step, currentEvent, transitions);
|
|
2422
2443
|
}
|
|
2423
2444
|
let shouldSelectEventlessTransitions = true;
|
|
2424
2445
|
while (nextSnapshot.status === 'active') {
|
|
@@ -2434,16 +2455,17 @@ function macrostep(snapshot, event, actorScope, internalQueue) {
|
|
|
2434
2455
|
nextEvent = internalQueue.shift();
|
|
2435
2456
|
enabledTransitions = selectTransitions(nextEvent, nextSnapshot);
|
|
2436
2457
|
}
|
|
2437
|
-
|
|
2458
|
+
const step = microstep(enabledTransitions, nextSnapshot, actorScope, nextEvent, false, internalQueue);
|
|
2459
|
+
nextSnapshot = step[0];
|
|
2438
2460
|
shouldSelectEventlessTransitions = nextSnapshot !== previousState;
|
|
2439
|
-
|
|
2461
|
+
addMicrostep(step, nextEvent, enabledTransitions);
|
|
2440
2462
|
}
|
|
2441
2463
|
if (nextSnapshot.status !== 'active') {
|
|
2442
2464
|
stopChildren(nextSnapshot, nextEvent, actorScope);
|
|
2443
2465
|
}
|
|
2444
2466
|
return {
|
|
2445
2467
|
snapshot: nextSnapshot,
|
|
2446
|
-
|
|
2468
|
+
microsteps
|
|
2447
2469
|
};
|
|
2448
2470
|
}
|
|
2449
2471
|
function stopChildren(nextState, event, actorScope) {
|
|
@@ -2706,11 +2728,11 @@ exports.getAllOwnEventDescriptors = getAllOwnEventDescriptors;
|
|
|
2706
2728
|
exports.getAllStateNodes = getAllStateNodes;
|
|
2707
2729
|
exports.getCandidates = getCandidates;
|
|
2708
2730
|
exports.getDelayedTransitions = getDelayedTransitions;
|
|
2709
|
-
exports.getInitialStateNodes = getInitialStateNodes;
|
|
2710
2731
|
exports.getPersistedSnapshot = getPersistedSnapshot;
|
|
2711
2732
|
exports.getProperAncestors = getProperAncestors;
|
|
2712
2733
|
exports.getStateNodeByPath = getStateNodeByPath;
|
|
2713
2734
|
exports.getStateNodes = getStateNodes;
|
|
2735
|
+
exports.initialMicrostep = initialMicrostep;
|
|
2714
2736
|
exports.interpret = interpret;
|
|
2715
2737
|
exports.isAtomicStateNode = isAtomicStateNode;
|
|
2716
2738
|
exports.isInFinalState = isInFinalState;
|
|
@@ -2720,7 +2742,6 @@ exports.macrostep = macrostep;
|
|
|
2720
2742
|
exports.mapValues = mapValues;
|
|
2721
2743
|
exports.matchesEventDescriptor = matchesEventDescriptor;
|
|
2722
2744
|
exports.matchesState = matchesState;
|
|
2723
|
-
exports.microstep = microstep;
|
|
2724
2745
|
exports.not = not;
|
|
2725
2746
|
exports.or = or;
|
|
2726
2747
|
exports.pathToStateValue = pathToStateValue;
|