xstate 5.32.6 → 5.33.1
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/dist/{StateMachine-3f520def.cjs.js → StateMachine-385ea6e2.cjs.js} +8 -6
- package/dist/{StateMachine-28a9f50e.esm.js → StateMachine-521e1f66.esm.js} +8 -6
- package/dist/{StateMachine-3778f5e0.development.cjs.js → StateMachine-d4a4d688.development.cjs.js} +8 -6
- package/dist/{StateMachine-fffbf42d.development.esm.js → StateMachine-e5453556.development.esm.js} +8 -6
- package/dist/{assign-c349a5e8.development.esm.js → assign-08205f93.development.esm.js} +1 -1
- package/dist/{assign-f03a9bed.development.cjs.js → assign-22c2f2aa.development.cjs.js} +1 -1
- package/dist/{assign-54f9e2d3.esm.js → assign-b4b1f28f.esm.js} +1 -1
- package/dist/{assign-d3f33159.cjs.js → assign-b8c7b733.cjs.js} +1 -1
- package/dist/declarations/src/StateMachine.d.ts +17 -15
- package/dist/declarations/src/StateNode.d.ts +18 -18
- package/dist/declarations/src/createMachine.d.ts +4 -4
- package/dist/declarations/src/graph/types.d.ts +2 -3
- package/dist/declarations/src/setup.d.ts +8 -8
- package/dist/declarations/src/stateUtils.d.ts +2 -2
- package/dist/declarations/src/types.d.ts +87 -77
- package/dist/{log-66075555.esm.js → log-64b4a2b9.esm.js} +2 -2
- package/dist/{log-3beea04f.cjs.js → log-aca8da4c.cjs.js} +2 -2
- package/dist/{log-140dec60.development.esm.js → log-ccf9f9e1.development.esm.js} +2 -2
- package/dist/{log-0ed3e43f.development.cjs.js → log-dc444aec.development.cjs.js} +2 -2
- package/dist/{raise-c90786ef.development.esm.js → raise-4d6182c1.development.esm.js} +2 -0
- package/dist/{raise-53e20da7.development.cjs.js → raise-6dbf7d60.development.cjs.js} +2 -0
- package/dist/{raise-8dd8aaec.esm.js → raise-97446fd4.esm.js} +2 -0
- package/dist/{raise-a26997bd.cjs.js → raise-ad56cf14.cjs.js} +2 -0
- package/dist/xstate-actions.cjs.js +3 -3
- package/dist/xstate-actions.development.cjs.js +3 -3
- package/dist/xstate-actions.development.esm.js +3 -3
- package/dist/xstate-actions.esm.js +3 -3
- package/dist/xstate-actions.umd.min.js.map +1 -1
- package/dist/xstate-actors.cjs.js +1 -1
- package/dist/xstate-actors.development.cjs.js +1 -1
- package/dist/xstate-actors.development.esm.js +1 -1
- package/dist/xstate-actors.esm.js +1 -1
- package/dist/xstate-graph.cjs.js +3 -3
- package/dist/xstate-graph.development.cjs.js +3 -3
- package/dist/xstate-graph.development.esm.js +3 -3
- package/dist/xstate-graph.esm.js +3 -3
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate-guards.cjs.js +1 -1
- package/dist/xstate-guards.development.cjs.js +1 -1
- package/dist/xstate-guards.development.esm.js +1 -1
- package/dist/xstate-guards.esm.js +1 -1
- package/dist/xstate-guards.umd.min.js.map +1 -1
- package/dist/xstate.cjs.js +4 -4
- package/dist/xstate.development.cjs.js +4 -4
- package/dist/xstate.development.esm.js +8 -8
- package/dist/xstate.esm.js +8 -8
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dist_xstateGuards = require('./raise-
|
|
4
|
-
var assign = require('./assign-
|
|
3
|
+
var dist_xstateGuards = require('./raise-ad56cf14.cjs.js');
|
|
4
|
+
var assign = require('./assign-b8c7b733.cjs.js');
|
|
5
5
|
|
|
6
6
|
const cache = new WeakMap();
|
|
7
7
|
function memo(object, key, fn) {
|
|
@@ -149,17 +149,19 @@ class StateNode {
|
|
|
149
149
|
actions: this.initial.actions.map(toSerializableAction),
|
|
150
150
|
eventType: null,
|
|
151
151
|
reenter: false,
|
|
152
|
+
meta: this.initial.meta,
|
|
153
|
+
description: this.initial.description,
|
|
152
154
|
toJSON: () => ({
|
|
153
155
|
target: this.initial.target.map(t => `#${t.id}`),
|
|
154
156
|
source: `#${this.id}`,
|
|
155
157
|
actions: this.initial.actions.map(toSerializableAction),
|
|
156
|
-
eventType: null
|
|
158
|
+
eventType: null,
|
|
159
|
+
meta: this.initial.meta,
|
|
160
|
+
description: this.initial.description
|
|
157
161
|
})
|
|
158
162
|
} : undefined,
|
|
159
163
|
history: this.history,
|
|
160
|
-
states: dist_xstateGuards.mapValues(this.states, state =>
|
|
161
|
-
return state.definition;
|
|
162
|
-
}),
|
|
164
|
+
states: dist_xstateGuards.mapValues(this.states, state => state.definition),
|
|
163
165
|
on: this.on,
|
|
164
166
|
transitions: [...this.transitions.values()].flat().map(t => ({
|
|
165
167
|
...t,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as STATE_DELIMITER, z as mapValues, t as toArray, B as formatTransitions, C as toTransitionConfigArray, D as formatTransition, N as NULL_EVENT, E as evaluateGuard, F as createInvokeId, G as getDelayedTransitions, H as formatInitialTransition, I as getCandidates, J as formatRouteTransitions, K as resolveStateValue, L as getAllStateNodes, q as getStateNodes, M as createMachineSnapshot, O as isInFinalState, e as macrostep, P as transitionNode, Q as resolveActionsAndContext, f as createInitEvent, g as initialMicrostep, R as cloneMachineSnapshot, T as toStatePath, U as isStateId, V as getStateNodeByPath, W as getPersistedSnapshot, Y as resolveReferencedActor, c as createActor, $ as $$ACTOR_TYPE } from './raise-
|
|
2
|
-
import { a as assign } from './assign-
|
|
1
|
+
import { S as STATE_DELIMITER, z as mapValues, t as toArray, B as formatTransitions, C as toTransitionConfigArray, D as formatTransition, N as NULL_EVENT, E as evaluateGuard, F as createInvokeId, G as getDelayedTransitions, H as formatInitialTransition, I as getCandidates, J as formatRouteTransitions, K as resolveStateValue, L as getAllStateNodes, q as getStateNodes, M as createMachineSnapshot, O as isInFinalState, e as macrostep, P as transitionNode, Q as resolveActionsAndContext, f as createInitEvent, g as initialMicrostep, R as cloneMachineSnapshot, T as toStatePath, U as isStateId, V as getStateNodeByPath, W as getPersistedSnapshot, Y as resolveReferencedActor, c as createActor, $ as $$ACTOR_TYPE } from './raise-97446fd4.esm.js';
|
|
2
|
+
import { a as assign } from './assign-b4b1f28f.esm.js';
|
|
3
3
|
|
|
4
4
|
const cache = new WeakMap();
|
|
5
5
|
function memo(object, key, fn) {
|
|
@@ -147,17 +147,19 @@ class StateNode {
|
|
|
147
147
|
actions: this.initial.actions.map(toSerializableAction),
|
|
148
148
|
eventType: null,
|
|
149
149
|
reenter: false,
|
|
150
|
+
meta: this.initial.meta,
|
|
151
|
+
description: this.initial.description,
|
|
150
152
|
toJSON: () => ({
|
|
151
153
|
target: this.initial.target.map(t => `#${t.id}`),
|
|
152
154
|
source: `#${this.id}`,
|
|
153
155
|
actions: this.initial.actions.map(toSerializableAction),
|
|
154
|
-
eventType: null
|
|
156
|
+
eventType: null,
|
|
157
|
+
meta: this.initial.meta,
|
|
158
|
+
description: this.initial.description
|
|
155
159
|
})
|
|
156
160
|
} : undefined,
|
|
157
161
|
history: this.history,
|
|
158
|
-
states: mapValues(this.states, state =>
|
|
159
|
-
return state.definition;
|
|
160
|
-
}),
|
|
162
|
+
states: mapValues(this.states, state => state.definition),
|
|
161
163
|
on: this.on,
|
|
162
164
|
transitions: [...this.transitions.values()].flat().map(t => ({
|
|
163
165
|
...t,
|
package/dist/{StateMachine-3778f5e0.development.cjs.js → StateMachine-d4a4d688.development.cjs.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dist_xstateGuards = require('./raise-
|
|
4
|
-
var assign = require('./assign-
|
|
3
|
+
var dist_xstateGuards = require('./raise-6dbf7d60.development.cjs.js');
|
|
4
|
+
var assign = require('./assign-22c2f2aa.development.cjs.js');
|
|
5
5
|
|
|
6
6
|
const cache = new WeakMap();
|
|
7
7
|
function memo(object, key, fn) {
|
|
@@ -149,17 +149,19 @@ class StateNode {
|
|
|
149
149
|
actions: this.initial.actions.map(toSerializableAction),
|
|
150
150
|
eventType: null,
|
|
151
151
|
reenter: false,
|
|
152
|
+
meta: this.initial.meta,
|
|
153
|
+
description: this.initial.description,
|
|
152
154
|
toJSON: () => ({
|
|
153
155
|
target: this.initial.target.map(t => `#${t.id}`),
|
|
154
156
|
source: `#${this.id}`,
|
|
155
157
|
actions: this.initial.actions.map(toSerializableAction),
|
|
156
|
-
eventType: null
|
|
158
|
+
eventType: null,
|
|
159
|
+
meta: this.initial.meta,
|
|
160
|
+
description: this.initial.description
|
|
157
161
|
})
|
|
158
162
|
} : undefined,
|
|
159
163
|
history: this.history,
|
|
160
|
-
states: dist_xstateGuards.mapValues(this.states, state =>
|
|
161
|
-
return state.definition;
|
|
162
|
-
}),
|
|
164
|
+
states: dist_xstateGuards.mapValues(this.states, state => state.definition),
|
|
163
165
|
on: this.on,
|
|
164
166
|
transitions: [...this.transitions.values()].flat().map(t => ({
|
|
165
167
|
...t,
|
package/dist/{StateMachine-fffbf42d.development.esm.js → StateMachine-e5453556.development.esm.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as STATE_DELIMITER, z as mapValues, t as toArray, B as formatTransitions, C as toTransitionConfigArray, D as formatTransition, N as NULL_EVENT, E as evaluateGuard, F as createInvokeId, G as getDelayedTransitions, H as formatInitialTransition, I as getCandidates, J as formatRouteTransitions, K as resolveStateValue, L as getAllStateNodes, q as getStateNodes, M as createMachineSnapshot, O as isInFinalState, e as macrostep, P as transitionNode, Q as resolveActionsAndContext, f as createInitEvent, g as initialMicrostep, R as cloneMachineSnapshot, T as toStatePath, U as isStateId, V as getStateNodeByPath, W as getPersistedSnapshot, Y as resolveReferencedActor, c as createActor, $ as $$ACTOR_TYPE } from './raise-
|
|
2
|
-
import { a as assign } from './assign-
|
|
1
|
+
import { S as STATE_DELIMITER, z as mapValues, t as toArray, B as formatTransitions, C as toTransitionConfigArray, D as formatTransition, N as NULL_EVENT, E as evaluateGuard, F as createInvokeId, G as getDelayedTransitions, H as formatInitialTransition, I as getCandidates, J as formatRouteTransitions, K as resolveStateValue, L as getAllStateNodes, q as getStateNodes, M as createMachineSnapshot, O as isInFinalState, e as macrostep, P as transitionNode, Q as resolveActionsAndContext, f as createInitEvent, g as initialMicrostep, R as cloneMachineSnapshot, T as toStatePath, U as isStateId, V as getStateNodeByPath, W as getPersistedSnapshot, Y as resolveReferencedActor, c as createActor, $ as $$ACTOR_TYPE } from './raise-4d6182c1.development.esm.js';
|
|
2
|
+
import { a as assign } from './assign-08205f93.development.esm.js';
|
|
3
3
|
|
|
4
4
|
const cache = new WeakMap();
|
|
5
5
|
function memo(object, key, fn) {
|
|
@@ -147,17 +147,19 @@ class StateNode {
|
|
|
147
147
|
actions: this.initial.actions.map(toSerializableAction),
|
|
148
148
|
eventType: null,
|
|
149
149
|
reenter: false,
|
|
150
|
+
meta: this.initial.meta,
|
|
151
|
+
description: this.initial.description,
|
|
150
152
|
toJSON: () => ({
|
|
151
153
|
target: this.initial.target.map(t => `#${t.id}`),
|
|
152
154
|
source: `#${this.id}`,
|
|
153
155
|
actions: this.initial.actions.map(toSerializableAction),
|
|
154
|
-
eventType: null
|
|
156
|
+
eventType: null,
|
|
157
|
+
meta: this.initial.meta,
|
|
158
|
+
description: this.initial.description
|
|
155
159
|
})
|
|
156
160
|
} : undefined,
|
|
157
161
|
history: this.history,
|
|
158
|
-
states: mapValues(this.states, state =>
|
|
159
|
-
return state.definition;
|
|
160
|
-
}),
|
|
162
|
+
states: mapValues(this.states, state => state.definition),
|
|
161
163
|
on: this.on,
|
|
162
164
|
transitions: [...this.transitions.values()].flat().map(t => ({
|
|
163
165
|
...t,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a1 as ProcessingStatus, Y as resolveReferencedActor, c as createActor, R as cloneMachineSnapshot, Z as executingCustomAction } from './raise-
|
|
1
|
+
import { a1 as ProcessingStatus, Y as resolveReferencedActor, c as createActor, R as cloneMachineSnapshot, Z as executingCustomAction } from './raise-4d6182c1.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a0 as ProcessingStatus, Y as resolveReferencedActor, c as createActor, R as cloneMachineSnapshot } from './raise-
|
|
1
|
+
import { a0 as ProcessingStatus, Y as resolveReferencedActor, c as createActor, R as cloneMachineSnapshot } from './raise-97446fd4.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -2,9 +2,10 @@ import { MachineSnapshot } from "./State.js";
|
|
|
2
2
|
import { StateNode } from "./StateNode.js";
|
|
3
3
|
import { AnyActorSystem } from "./system.js";
|
|
4
4
|
import type { ActorLogic, ActorScope, AnyActorRef, AnyActorScope, DoNotInfer, Equals, EventDescriptor, EventObject, HistoryValue, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineOptions, MetaObject, ParameterizedObject, ProvidedActor, Snapshot, StateMachineDefinition, StateValue, TransitionDefinition, ResolvedStateMachineTypes, StateSchema, SnapshotStatus } from "./types.js";
|
|
5
|
-
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject,
|
|
5
|
+
export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TStateMeta extends MetaObject, TStateSchema extends StateSchema, TTransitionMeta extends MetaObject = TStateMeta> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>, TEvent, TInput, AnyActorSystem, TEmitted> {
|
|
6
6
|
/** The raw config used to create the machine. */
|
|
7
7
|
config: MachineConfig<TContext, TEvent, any, any, any, any, any, any, TOutput, any, // TEmitted
|
|
8
|
+
any, // TStateMeta
|
|
8
9
|
any> & {
|
|
9
10
|
schemas?: unknown;
|
|
10
11
|
};
|
|
@@ -14,13 +15,14 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
14
15
|
implementations: MachineImplementationsSimplified<TContext, TEvent>;
|
|
15
16
|
/** Runtime options for machine execution. */
|
|
16
17
|
options: MachineOptions;
|
|
17
|
-
root: StateNode<TContext, TEvent>;
|
|
18
|
+
root: StateNode<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
18
19
|
id: string;
|
|
19
|
-
states: StateNode<TContext, TEvent>['states'];
|
|
20
|
+
states: StateNode<TContext, TEvent, TStateMeta, TTransitionMeta>['states'];
|
|
20
21
|
events: Array<EventDescriptor<TEvent>>;
|
|
21
22
|
constructor(
|
|
22
23
|
/** The raw config used to create the machine. */
|
|
23
24
|
config: MachineConfig<TContext, TEvent, any, any, any, any, any, any, TOutput, any, // TEmitted
|
|
25
|
+
any, // TStateMeta
|
|
24
26
|
any> & {
|
|
25
27
|
schemas?: unknown;
|
|
26
28
|
}, implementations?: MachineImplementationsSimplified<TContext, TEvent>);
|
|
@@ -31,7 +33,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
31
33
|
* recursively merge with the existing options.
|
|
32
34
|
* @returns A new `StateMachine` instance with the provided implementations.
|
|
33
35
|
*/
|
|
34
|
-
provide(implementations: InternalMachineImplementations<ResolvedStateMachineTypes<TContext, DoNotInfer<TEvent>, TActor, TAction, TGuard, TDelay, TTag, TEmitted>>): StateMachine<TContext, TEvent, TChildren, TActor, TAction, TGuard, TDelay, TStateValue, TTag, TInput, TOutput, TEmitted,
|
|
36
|
+
provide(implementations: InternalMachineImplementations<ResolvedStateMachineTypes<TContext, DoNotInfer<TEvent>, TActor, TAction, TGuard, TDelay, TTag, TEmitted>>): StateMachine<TContext, TEvent, TChildren, TActor, TAction, TGuard, TDelay, TStateValue, TTag, TInput, TOutput, TEmitted, TStateMeta, TStateSchema, TTransitionMeta>;
|
|
35
37
|
resolveState(config: {
|
|
36
38
|
value: StateValue;
|
|
37
39
|
context?: TContext;
|
|
@@ -41,7 +43,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
41
43
|
error?: unknown;
|
|
42
44
|
} & (Equals<TContext, MachineContext> extends false ? {
|
|
43
45
|
context: unknown;
|
|
44
|
-
} : {})): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput,
|
|
46
|
+
} : {})): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>;
|
|
45
47
|
/**
|
|
46
48
|
* Determines the next snapshot given the current `snapshot` and received
|
|
47
49
|
* `event`. Calculates a full macrostep from all microsteps.
|
|
@@ -49,7 +51,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
49
51
|
* @param snapshot The current snapshot
|
|
50
52
|
* @param event The received event
|
|
51
53
|
*/
|
|
52
|
-
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput,
|
|
54
|
+
transition(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>, event: TEvent, actorScope: ActorScope<typeof snapshot, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>;
|
|
53
55
|
/**
|
|
54
56
|
* Determines the next state given the current `state` and `event`. Calculates
|
|
55
57
|
* a microstep.
|
|
@@ -57,17 +59,17 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
|
|
|
57
59
|
* @param state The current state
|
|
58
60
|
* @param event The received event
|
|
59
61
|
*/
|
|
60
|
-
microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput,
|
|
61
|
-
getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput,
|
|
62
|
+
microstep(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>, event: TEvent, actorScope: AnyActorScope): Array<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>>;
|
|
63
|
+
getTransitionData(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>, event: TEvent): Array<TransitionDefinition<TContext, TEvent, TTransitionMeta>>;
|
|
62
64
|
/**
|
|
63
65
|
* Returns the initial `State` instance, with reference to `self` as an
|
|
64
66
|
* `ActorRef`.
|
|
65
67
|
*/
|
|
66
|
-
getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput,
|
|
67
|
-
start(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput,
|
|
68
|
-
getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
|
|
69
|
-
get definition(): StateMachineDefinition<TContext, TEvent>;
|
|
70
|
-
toJSON(): StateMachineDefinition<TContext, TEvent>;
|
|
71
|
-
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput,
|
|
72
|
-
restoreSnapshot(snapshot: Snapshot<unknown>, _actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput,
|
|
68
|
+
getInitialSnapshot(actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>, TEvent, AnyActorSystem, TEmitted>, input?: TInput): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>;
|
|
69
|
+
start(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>): void;
|
|
70
|
+
getStateNodeById(stateId: string): StateNode<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
71
|
+
get definition(): StateMachineDefinition<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
72
|
+
toJSON(): StateMachineDefinition<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
73
|
+
getPersistedSnapshot(snapshot: MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>, options?: unknown): Snapshot<unknown>;
|
|
74
|
+
restoreSnapshot(snapshot: Snapshot<unknown>, _actorScope: ActorScope<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>, TEvent, AnyActorSystem, TEmitted>): MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TStateMeta, TStateSchema>;
|
|
73
75
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { StateMachine } from "./StateMachine.js";
|
|
2
|
-
import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, InvokeDefinition, MachineContext, Mapper, StateNodeConfig, StateNodeDefinition, StateNodesConfig, TransitionDefinition, TransitionDefinitionMap, TODO, UnknownAction, ParameterizedObject, AnyStateMachine, ProvidedActor, NonReducibleUnknown, EventDescriptor } from "./types.js";
|
|
3
|
-
interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
|
|
2
|
+
import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, InvokeDefinition, MachineContext, Mapper, StateNodeConfig, StateNodeDefinition, StateNodesConfig, TransitionDefinition, TransitionDefinitionMap, TODO, UnknownAction, ParameterizedObject, AnyStateMachine, ProvidedActor, NonReducibleUnknown, EventDescriptor, MetaObject } from "./types.js";
|
|
3
|
+
interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject, TStateMeta extends MetaObject, TTransitionMeta extends MetaObject> {
|
|
4
4
|
_key: string;
|
|
5
|
-
_parent?: StateNode<TContext, TEvent>;
|
|
5
|
+
_parent?: StateNode<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
6
6
|
_machine: AnyStateMachine;
|
|
7
7
|
}
|
|
8
|
-
export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject> {
|
|
8
|
+
export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject, TStateMeta extends MetaObject = MetaObject, TTransitionMeta extends MetaObject = TStateMeta> {
|
|
9
9
|
/** The raw config used to create the machine. */
|
|
10
10
|
config: StateNodeConfig<TContext, TEvent, TODO, // actors
|
|
11
11
|
TODO, // actions
|
|
@@ -14,7 +14,7 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
14
14
|
TODO, // tags
|
|
15
15
|
TODO, // output
|
|
16
16
|
TODO, // emitted
|
|
17
|
-
|
|
17
|
+
TStateMeta, TTransitionMeta>;
|
|
18
18
|
/**
|
|
19
19
|
* The relative key of the state node, which represents its location in the
|
|
20
20
|
* overall state value.
|
|
@@ -35,7 +35,7 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
35
35
|
/** The string path from the root machine node to this node. */
|
|
36
36
|
path: string[];
|
|
37
37
|
/** The child state nodes. */
|
|
38
|
-
states: StateNodesConfig<TContext, TEvent>;
|
|
38
|
+
states: StateNodesConfig<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
39
39
|
/**
|
|
40
40
|
* The type of history on this state node. Can be:
|
|
41
41
|
*
|
|
@@ -48,7 +48,7 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
48
48
|
/** The action(s) to be executed upon exiting the state node. */
|
|
49
49
|
exit: UnknownAction[];
|
|
50
50
|
/** The parent state node. */
|
|
51
|
-
parent?: StateNode<TContext, TEvent>;
|
|
51
|
+
parent?: StateNode<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
52
52
|
/** The root machine node. */
|
|
53
53
|
machine: StateMachine<TContext, TEvent, any, // children
|
|
54
54
|
any, // actor
|
|
@@ -60,13 +60,13 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
60
60
|
any, // input
|
|
61
61
|
any, // output
|
|
62
62
|
any, // emitted
|
|
63
|
-
any, //
|
|
64
|
-
|
|
63
|
+
TStateMeta, any, // state schema
|
|
64
|
+
TTransitionMeta>;
|
|
65
65
|
/**
|
|
66
66
|
* The meta data associated with this state node, which will be returned in
|
|
67
67
|
* State instances.
|
|
68
68
|
*/
|
|
69
|
-
meta?:
|
|
69
|
+
meta?: TStateMeta;
|
|
70
70
|
/**
|
|
71
71
|
* The output data sent with the "xstate.done.state._id_" event if this is a
|
|
72
72
|
* final state node.
|
|
@@ -79,8 +79,8 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
79
79
|
order: number;
|
|
80
80
|
description?: string;
|
|
81
81
|
tags: string[];
|
|
82
|
-
transitions: Map<string, TransitionDefinition<TContext, TEvent>[]>;
|
|
83
|
-
always?: Array<TransitionDefinition<TContext, TEvent>>;
|
|
82
|
+
transitions: Map<string, TransitionDefinition<TContext, TEvent, TTransitionMeta>[]>;
|
|
83
|
+
always?: Array<TransitionDefinition<TContext, TEvent, TTransitionMeta>>;
|
|
84
84
|
constructor(
|
|
85
85
|
/** The raw config used to create the machine. */
|
|
86
86
|
config: StateNodeConfig<TContext, TEvent, TODO, // actors
|
|
@@ -90,16 +90,16 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
90
90
|
TODO, // tags
|
|
91
91
|
TODO, // output
|
|
92
92
|
TODO, // emitted
|
|
93
|
-
|
|
93
|
+
TStateMeta, TTransitionMeta>, options: StateNodeOptions<TContext, TEvent, TStateMeta, TTransitionMeta>);
|
|
94
94
|
/** The well-structured state node definition. */
|
|
95
|
-
get definition(): StateNodeDefinition<TContext, TEvent>;
|
|
95
|
+
get definition(): StateNodeDefinition<TContext, TEvent, TStateMeta, TTransitionMeta>;
|
|
96
96
|
/** The logic invoked as actors by this state node. */
|
|
97
97
|
get invoke(): Array<InvokeDefinition<TContext, TEvent, ProvidedActor, ParameterizedObject, ParameterizedObject, string, TODO, // TEmitted
|
|
98
|
-
|
|
98
|
+
TTransitionMeta>>;
|
|
99
99
|
/** The mapping of events to transitions. */
|
|
100
|
-
get on(): TransitionDefinitionMap<TContext, TEvent>;
|
|
101
|
-
get after(): Array<DelayedTransitionDefinition<TContext, TEvent>>;
|
|
102
|
-
get initial(): InitialTransitionDefinition<TContext, TEvent>;
|
|
100
|
+
get on(): TransitionDefinitionMap<TContext, TEvent, TTransitionMeta>;
|
|
101
|
+
get after(): Array<DelayedTransitionDefinition<TContext, TEvent, TTransitionMeta>>;
|
|
102
|
+
get initial(): InitialTransitionDefinition<TContext, TEvent, TTransitionMeta>;
|
|
103
103
|
/** All the event types accepted by this state node and its descendants. */
|
|
104
104
|
get events(): Array<EventDescriptor<TEvent>>;
|
|
105
105
|
/**
|
|
@@ -43,8 +43,8 @@ import { ResolvedStateMachineTypes, TODO, AnyActorRef, EventObject, AnyEventObje
|
|
|
43
43
|
* to provide machine implementations instead.
|
|
44
44
|
*/
|
|
45
45
|
export declare function createMachine<TContext extends MachineContext, TEvent extends AnyEventObject, // TODO: consider using a stricter `EventObject` here
|
|
46
|
-
TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TEmitted extends EventObject,
|
|
47
|
-
types?: MachineTypes<TContext, TEvent, TActor, TAction, TGuard, TDelay, TTag, TInput, TOutput, TEmitted,
|
|
46
|
+
TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TEmitted extends EventObject, TStateMeta extends MetaObject = any, TTransitionMeta extends MetaObject = TStateMeta, _ = any>(config: {
|
|
47
|
+
types?: MachineTypes<TContext, TEvent, TActor, TAction, TGuard, TDelay, TTag, TInput, TOutput, TEmitted, TStateMeta, TTransitionMeta>;
|
|
48
48
|
schemas?: unknown;
|
|
49
|
-
} & MachineConfig<TContext, TEvent, TActor, TAction, TGuard, TDelay, TTag, TInput, TOutput, TEmitted,
|
|
50
|
-
|
|
49
|
+
} & MachineConfig<TContext, TEvent, TActor, TAction, TGuard, TDelay, TTag, TInput, TOutput, TEmitted, TStateMeta, TTransitionMeta>, implementations?: InternalMachineImplementations<ResolvedStateMachineTypes<TContext, TEvent, TActor, TAction, TGuard, TDelay, TTag, TEmitted>>): StateMachine<TContext, TEvent, Cast<ToChildren<TActor>, Record<string, AnyActorRef | undefined>>, TActor, TAction, TGuard, TDelay, StateValue, TTag & string, TInput, TOutput, TEmitted, TStateMeta, TODO, // TStateSchema
|
|
50
|
+
TTransitionMeta>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventObject, StateNode, TransitionDefinition, Snapshot, MachineContext, ActorLogic, MachineSnapshot } from "../index.js";
|
|
2
|
-
export type AnyStateNode
|
|
1
|
+
import { AnyStateNode, EventObject, StateNode, TransitionDefinition, Snapshot, MachineContext, ActorLogic, MachineSnapshot } from "../index.js";
|
|
2
|
+
export type { AnyStateNode };
|
|
3
3
|
type JSONSerializable<T extends object, U> = T & {
|
|
4
4
|
toJSON: () => U;
|
|
5
5
|
};
|
|
@@ -157,4 +157,3 @@ export interface AdjacencyValue<TState, TEvent> {
|
|
|
157
157
|
export interface AdjacencyMap<TState, TEvent> {
|
|
158
158
|
[key: SerializedSnapshot]: AdjacencyValue<TState, TEvent>;
|
|
159
159
|
}
|
|
160
|
-
export {};
|
|
@@ -41,7 +41,7 @@ type ExtractConfigChildren<TConfig> = TConfig extends {
|
|
|
41
41
|
invoke: infer TInvoke;
|
|
42
42
|
} ? ExtractInvokeChildren<TInvoke> : {};
|
|
43
43
|
type MergeChildrenMap<TExplicit extends Record<string, string>, TInferred extends Record<string, string>> = IsNever<keyof TExplicit> extends true ? TInferred : TExplicit;
|
|
44
|
-
export type SetupReturn<TContext extends MachineContext, TEvent extends AnyEventObject, TActors extends Record<string, UnknownActorLogic>, TChildrenMap extends Record<string, string>, TActions extends Record<string, ParameterizedObject['params'] | undefined>, TGuards extends Record<string, ParameterizedObject['params'] | undefined>, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TEmitted extends EventObject,
|
|
44
|
+
export type SetupReturn<TContext extends MachineContext, TEvent extends AnyEventObject, TActors extends Record<string, UnknownActorLogic>, TChildrenMap extends Record<string, string>, TActions extends Record<string, ParameterizedObject['params'] | undefined>, TGuards extends Record<string, ParameterizedObject['params'] | undefined>, TDelay extends string, TTag extends string, TInput, TOutput extends NonReducibleUnknown, TEmitted extends EventObject, TStateMeta extends MetaObject, TTransitionMeta extends MetaObject = TStateMeta> = {
|
|
45
45
|
extend: <TExtendActions extends Record<string, ParameterizedObject['params'] | undefined> = {}, TExtendGuards extends Record<string, ParameterizedObject['params'] | undefined> = {}, TExtendDelays extends string = never>({ actions, guards, delays }: {
|
|
46
46
|
actions?: {
|
|
47
47
|
[K in keyof TExtendActions]: ActionFunction<TContext, TEvent, TEvent, TExtendActions[K], ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions & TExtendActions>, ToParameterizedObject<TGuards & TExtendGuards>, TDelay | TExtendDelays, TEmitted>;
|
|
@@ -52,7 +52,7 @@ export type SetupReturn<TContext extends MachineContext, TEvent extends AnyEvent
|
|
|
52
52
|
delays?: {
|
|
53
53
|
[K in TExtendDelays]: DelayConfig<TContext, TEvent, ToParameterizedObject<TActions & TExtendActions>['params'], TEvent>;
|
|
54
54
|
};
|
|
55
|
-
}) => SetupReturn<TContext, TEvent, TActors, TChildrenMap, TActions & TExtendActions, TGuards & TExtendGuards, TDelay | TExtendDelays, TTag, TInput, TOutput, TEmitted,
|
|
55
|
+
}) => SetupReturn<TContext, TEvent, TActors, TChildrenMap, TActions & TExtendActions, TGuards & TExtendGuards, TDelay | TExtendDelays, TTag, TInput, TOutput, TEmitted, TStateMeta, TTransitionMeta>;
|
|
56
56
|
/**
|
|
57
57
|
* Creates a state config that is strongly typed. This state config can be
|
|
58
58
|
* used to create a machine.
|
|
@@ -82,7 +82,7 @@ export type SetupReturn<TContext extends MachineContext, TEvent extends AnyEvent
|
|
|
82
82
|
* });
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
createStateConfig: <TStateConfig extends StateNodeConfig<TContext, TEvent, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, TTag, unknown, TEmitted,
|
|
85
|
+
createStateConfig: <TStateConfig extends StateNodeConfig<TContext, TEvent, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, TTag, unknown, TEmitted, TStateMeta, TTransitionMeta>>(config: TStateConfig) => TStateConfig;
|
|
86
86
|
/**
|
|
87
87
|
* Creates a type-safe action.
|
|
88
88
|
*
|
|
@@ -108,10 +108,10 @@ export type SetupReturn<TContext extends MachineContext, TEvent extends AnyEvent
|
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
110
|
createAction: (action: ActionFunction<TContext, TEvent, TEvent, unknown, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, TEmitted>) => typeof action;
|
|
111
|
-
createMachine: <const TConfig extends MachineConfig<TContext, TEvent, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, TTag, TInput, TOutput, TEmitted,
|
|
111
|
+
createMachine: <const TConfig extends MachineConfig<TContext, TEvent, ToProvidedActor<TChildrenMap, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, TTag, TInput, TOutput, TEmitted, TStateMeta, TTransitionMeta>, TResolvedChildren extends Record<string, string> = MergeChildrenMap<TChildrenMap, Cast<ExtractConfigChildren<TConfig>, Record<string, string>>>>(config: TConfig) => StateMachine<TContext, TEvent | ([RoutableStateId<TConfig>] extends [never] ? never : {
|
|
112
112
|
type: 'xstate.route';
|
|
113
113
|
to: RoutableStateId<TConfig>;
|
|
114
|
-
}), Cast<ToChildren<ToProvidedActor<TResolvedChildren, TActors>>, Record<string, AnyActorRef | undefined>>, ToProvidedActor<TResolvedChildren, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, ToStateValue<TConfig>, TTag, TInput, TOutput, TEmitted,
|
|
114
|
+
}), Cast<ToChildren<ToProvidedActor<TResolvedChildren, TActors>>, Record<string, AnyActorRef | undefined>>, ToProvidedActor<TResolvedChildren, TActors>, ToParameterizedObject<TActions>, ToParameterizedObject<TGuards>, TDelay, ToStateValue<TConfig>, TTag, TInput, TOutput, TEmitted, TStateMeta, ToStateSchema<TConfig>, TTransitionMeta>;
|
|
115
115
|
assign: typeof assign<TContext, TEvent, undefined, TEvent, ToProvidedActor<TChildrenMap, TActors>>;
|
|
116
116
|
sendTo: <TTargetActor extends AnyActorRef>(...args: Parameters<typeof sendTo<TContext, TEvent, undefined, TTargetActor, TEvent, TDelay, TDelay>>) => ReturnType<typeof sendTo<TContext, TEvent, undefined, TTargetActor, TEvent, TDelay, TDelay>>;
|
|
117
117
|
raise: typeof raise<TContext, TEvent, TEvent, undefined, TDelay, TDelay>;
|
|
@@ -123,9 +123,9 @@ export type SetupReturn<TContext extends MachineContext, TEvent extends AnyEvent
|
|
|
123
123
|
spawnChild: typeof spawnChild<TContext, TEvent, undefined, TEvent, ToProvidedActor<TChildrenMap, TActors>>;
|
|
124
124
|
};
|
|
125
125
|
export declare function setup<TContext extends MachineContext, TEvent extends AnyEventObject, // TODO: consider using a stricter `EventObject` here
|
|
126
|
-
TActors extends Record<string, UnknownActorLogic> = {}, TChildrenMap extends Record<string, string> = {}, TActions extends Record<string, ParameterizedObject['params'] | undefined> = {}, TGuards extends Record<string, ParameterizedObject['params'] | undefined> = {}, TDelay extends string = never, TTag extends string = string, TInput = NonReducibleUnknown, TOutput extends NonReducibleUnknown = NonReducibleUnknown, TEmitted extends EventObject = EventObject,
|
|
126
|
+
TActors extends Record<string, UnknownActorLogic> = {}, TChildrenMap extends Record<string, string> = {}, TActions extends Record<string, ParameterizedObject['params'] | undefined> = {}, TGuards extends Record<string, ParameterizedObject['params'] | undefined> = {}, TDelay extends string = never, TTag extends string = string, TInput = NonReducibleUnknown, TOutput extends NonReducibleUnknown = NonReducibleUnknown, TEmitted extends EventObject = EventObject, TStateMeta extends MetaObject = MetaObject, TTransitionMeta extends MetaObject = TStateMeta>({ schemas, actors, actions, guards, delays }: {
|
|
127
127
|
schemas?: unknown;
|
|
128
|
-
types?: SetupTypes<TContext, TEvent, TChildrenMap, TTag, TInput, TOutput, TEmitted,
|
|
128
|
+
types?: SetupTypes<TContext, TEvent, TChildrenMap, TTag, TInput, TOutput, TEmitted, TStateMeta, TTransitionMeta>;
|
|
129
129
|
actors?: {
|
|
130
130
|
[K in keyof TActors | Values<TChildrenMap>]: K extends keyof TActors ? TActors[K] : never;
|
|
131
131
|
};
|
|
@@ -140,5 +140,5 @@ TActors extends Record<string, UnknownActorLogic> = {}, TChildrenMap extends Rec
|
|
|
140
140
|
};
|
|
141
141
|
} & {
|
|
142
142
|
[K in RequiredSetupKeys<TChildrenMap>]: unknown;
|
|
143
|
-
}): SetupReturn<TContext, TEvent, TActors, TChildrenMap, TActions, TGuards, TDelay, TTag, TInput, TOutput, TEmitted,
|
|
143
|
+
}): SetupReturn<TContext, TEvent, TActors, TChildrenMap, TActions, TGuards, TDelay, TTag, TInput, TOutput, TEmitted, TStateMeta, TTransitionMeta>;
|
|
144
144
|
export {};
|
|
@@ -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, ExecutableActionObject, 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, MetaObject } 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;
|
|
@@ -19,7 +19,7 @@ export declare function formatTransitions<TContext extends MachineContext, TEven
|
|
|
19
19
|
* once on the root node to avoid O(N²) repeated traversals.
|
|
20
20
|
*/
|
|
21
21
|
export declare function formatRouteTransitions(rootStateNode: AnyStateNode): void;
|
|
22
|
-
export declare function formatInitialTransition<TContext extends MachineContext, TEvent extends EventObject>(stateNode:
|
|
22
|
+
export declare function formatInitialTransition<TContext extends MachineContext, TEvent extends EventObject, TTransitionMeta extends MetaObject>(stateNode: StateNode<TContext, TEvent, any, TTransitionMeta>, _target: string | undefined | InitialTransitionConfig<TContext, TEvent, TODO, TODO, TODO, TODO, TODO, TTransitionMeta>): InitialTransitionDefinition<TContext, TEvent, TTransitionMeta>;
|
|
23
23
|
/**
|
|
24
24
|
* Returns the relative state node from the given `statePath`, or throws.
|
|
25
25
|
*
|