xstate 6.0.0-alpha.25 → 6.0.0-alpha.27
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-bf4ec0f1.development.esm.js → StateMachine-24c5e3f9.development.esm.js} +6 -1
- package/dist/{StateMachine-ac1167f3.development.cjs.js → StateMachine-673e9a91.development.cjs.js} +6 -1
- package/dist/{StateMachine-69278d2c.esm.js → StateMachine-7daabf24.esm.js} +6 -1
- package/dist/{StateMachine-b20d5a53.cjs.js → StateMachine-bcb27183.cjs.js} +6 -1
- package/dist/declarations/src/StateNode.d.ts +2 -0
- package/dist/declarations/src/createMachine.d.ts +3 -3
- package/dist/declarations/src/createMachineFromConfig.d.ts +1 -1
- package/dist/declarations/src/schema.types.d.ts +5 -0
- package/dist/declarations/src/setup.d.ts +11 -10
- package/dist/declarations/src/types.d.ts +2 -0
- package/dist/declarations/src/types.v6.d.ts +167 -5
- package/dist/{index-b90ebcd4.development.esm.js → index-41508d62.development.esm.js} +39 -1
- package/dist/{index-f58cc498.cjs.js → index-b228b8b6.cjs.js} +39 -1
- package/dist/{index-1ad8a761.development.cjs.js → index-c55fff73.development.cjs.js} +39 -1
- package/dist/{index-036a773f.esm.js → index-d33c7b85.esm.js} +39 -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 +2 -2
- package/dist/xstate-graph.development.cjs.js +2 -2
- package/dist/xstate-graph.development.esm.js +2 -2
- package/dist/xstate-graph.esm.js +2 -2
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate.cjs.js +38 -2
- package/dist/xstate.development.cjs.js +38 -2
- package/dist/xstate.development.esm.js +40 -4
- package/dist/xstate.esm.js +40 -4
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/{StateMachine-bf4ec0f1.development.esm.js → StateMachine-24c5e3f9.development.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as setSnapshotActorRef, N as getSnapshotActorRef, O as createSnapshotSystem, q as isMachineSnapshot, h as createActor, S as STATE_DELIMITER, P as mapValues, t as toArray, Q as createInvokeId, R as getDelayedTransitions, U as getEventDescriptorKey, V as evaluateCandidate, W as formatTransition, Y as NULL_EVENT, Z as toTransitionConfigArray, _ as createInvokeTimeoutEventId, $ as getCandidates, a0 as matchesActorSession, a1 as formatRouteTransitions, a2 as resolveStateValue, a3 as getAllStateNodes, s as getStateNodes, a4 as createMachineSnapshot, a5 as isInFinalState, j as macrostep, a6 as cloneMachineSnapshot, a7 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a8 as getTransitionResult, a9 as hasEffect, aa as createErrorPlatformEvent, r as resolveActionsWithContext, k as createInitEvent, l as createSpawnEffect, n as initialMicrostep, ab as toStatePath, ac as isStateId, ad as getStateNodeByPath, ae as getPersistedSnapshot, af as resolveReferencedActor, ag as createInvokeTimeoutEvent, ah as $$ACTOR_TYPE } from './index-
|
|
1
|
+
import { M as setSnapshotActorRef, N as getSnapshotActorRef, O as createSnapshotSystem, q as isMachineSnapshot, h as createActor, S as STATE_DELIMITER, P as mapValues, t as toArray, Q as createInvokeId, R as getDelayedTransitions, U as getEventDescriptorKey, V as evaluateCandidate, W as formatTransition, Y as NULL_EVENT, Z as toTransitionConfigArray, _ as createInvokeTimeoutEventId, $ as getCandidates, a0 as matchesActorSession, a1 as formatRouteTransitions, a2 as resolveStateValue, a3 as getAllStateNodes, s as getStateNodes, a4 as createMachineSnapshot, a5 as isInFinalState, j as macrostep, a6 as cloneMachineSnapshot, a7 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a8 as getTransitionResult, a9 as hasEffect, aa as createErrorPlatformEvent, r as resolveActionsWithContext, k as createInitEvent, l as createSpawnEffect, n as initialMicrostep, ab as toStatePath, ac as isStateId, ad as getStateNodeByPath, ae as getPersistedSnapshot, af as resolveReferencedActor, ag as createInvokeTimeoutEvent, ah as $$ACTOR_TYPE } from './index-41508d62.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
4
4
|
return (src, options) => {
|
|
@@ -194,6 +194,7 @@ class StateNode {
|
|
|
194
194
|
*/
|
|
195
195
|
this.order = -1;
|
|
196
196
|
this.description = void 0;
|
|
197
|
+
this.schemas = void 0;
|
|
197
198
|
this.tags = [];
|
|
198
199
|
this.transitions = void 0;
|
|
199
200
|
this.always = void 0;
|
|
@@ -210,6 +211,7 @@ class StateNode {
|
|
|
210
211
|
this.id = this.config.id || [this.machine.id, ...this.path].join(STATE_DELIMITER);
|
|
211
212
|
this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
|
|
212
213
|
this.description = this.config.description;
|
|
214
|
+
this.schemas = this.config.schemas;
|
|
213
215
|
validateStateNodeConfig(this);
|
|
214
216
|
this.order = this.machine.idMap.size;
|
|
215
217
|
this.machine.idMap.set(this.id, this);
|
|
@@ -314,6 +316,9 @@ class StateNode {
|
|
|
314
316
|
}
|
|
315
317
|
function validateStateNodeConfig(stateNode) {
|
|
316
318
|
const config = stateNode.config;
|
|
319
|
+
if (stateNode.type === 'history' && !(typeof config.target === 'string' && config.target.trim().length > 0 || Array.isArray(config.target) && config.target.length > 0 && config.target.every(target => typeof target === 'string' && target.trim().length > 0))) {
|
|
320
|
+
throw new Error(`History state "${stateNode.id}" must declare a non-empty \`target\`.` );
|
|
321
|
+
}
|
|
317
322
|
if (stateNode.type !== 'choice') {
|
|
318
323
|
if (config.choice !== undefined) {
|
|
319
324
|
throw new Error(`State "${stateNode.id}" has \`choice\`, but \`choice\` can only be used with \`type: 'choice'\`.`);
|
package/dist/{StateMachine-ac1167f3.development.cjs.js → StateMachine-673e9a91.development.cjs.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dist_xstateActors = require('./index-
|
|
3
|
+
var dist_xstateActors = require('./index-c55fff73.development.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
6
6
|
return (src, options) => {
|
|
@@ -196,6 +196,7 @@ class StateNode {
|
|
|
196
196
|
*/
|
|
197
197
|
this.order = -1;
|
|
198
198
|
this.description = void 0;
|
|
199
|
+
this.schemas = void 0;
|
|
199
200
|
this.tags = [];
|
|
200
201
|
this.transitions = void 0;
|
|
201
202
|
this.always = void 0;
|
|
@@ -212,6 +213,7 @@ class StateNode {
|
|
|
212
213
|
this.id = this.config.id || [this.machine.id, ...this.path].join(dist_xstateActors.STATE_DELIMITER);
|
|
213
214
|
this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
|
|
214
215
|
this.description = this.config.description;
|
|
216
|
+
this.schemas = this.config.schemas;
|
|
215
217
|
validateStateNodeConfig(this);
|
|
216
218
|
this.order = this.machine.idMap.size;
|
|
217
219
|
this.machine.idMap.set(this.id, this);
|
|
@@ -316,6 +318,9 @@ class StateNode {
|
|
|
316
318
|
}
|
|
317
319
|
function validateStateNodeConfig(stateNode) {
|
|
318
320
|
const config = stateNode.config;
|
|
321
|
+
if (stateNode.type === 'history' && !(typeof config.target === 'string' && config.target.trim().length > 0 || Array.isArray(config.target) && config.target.length > 0 && config.target.every(target => typeof target === 'string' && target.trim().length > 0))) {
|
|
322
|
+
throw new Error(`History state "${stateNode.id}" must declare a non-empty \`target\`.` );
|
|
323
|
+
}
|
|
319
324
|
if (stateNode.type !== 'choice') {
|
|
320
325
|
if (config.choice !== undefined) {
|
|
321
326
|
throw new Error(`State "${stateNode.id}" has \`choice\`, but \`choice\` can only be used with \`type: 'choice'\`.`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as setSnapshotActorRef, N as getSnapshotActorRef, O as createSnapshotSystem, q as isMachineSnapshot, h as createActor, S as STATE_DELIMITER, P as mapValues, t as toArray, Q as createInvokeId, R as getDelayedTransitions, U as getEventDescriptorKey, V as evaluateCandidate, W as formatTransition, Y as NULL_EVENT, Z as toTransitionConfigArray, _ as createInvokeTimeoutEventId, $ as getCandidates, a0 as matchesActorSession, a1 as formatRouteTransitions, a2 as resolveStateValue, a3 as getAllStateNodes, s as getStateNodes, a4 as createMachineSnapshot, a5 as isInFinalState, j as macrostep, a6 as cloneMachineSnapshot, a7 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a8 as getTransitionResult, a9 as hasEffect, aa as createErrorPlatformEvent, r as resolveActionsWithContext, k as createInitEvent, l as createSpawnEffect, n as initialMicrostep, ab as toStatePath, ac as isStateId, ad as getStateNodeByPath, ae as getPersistedSnapshot, af as resolveReferencedActor, ag as createInvokeTimeoutEvent, ah as $$ACTOR_TYPE } from './index-
|
|
1
|
+
import { M as setSnapshotActorRef, N as getSnapshotActorRef, O as createSnapshotSystem, q as isMachineSnapshot, h as createActor, S as STATE_DELIMITER, P as mapValues, t as toArray, Q as createInvokeId, R as getDelayedTransitions, U as getEventDescriptorKey, V as evaluateCandidate, W as formatTransition, Y as NULL_EVENT, Z as toTransitionConfigArray, _ as createInvokeTimeoutEventId, $ as getCandidates, a0 as matchesActorSession, a1 as formatRouteTransitions, a2 as resolveStateValue, a3 as getAllStateNodes, s as getStateNodes, a4 as createMachineSnapshot, a5 as isInFinalState, j as macrostep, a6 as cloneMachineSnapshot, a7 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a8 as getTransitionResult, a9 as hasEffect, aa as createErrorPlatformEvent, r as resolveActionsWithContext, k as createInitEvent, l as createSpawnEffect, n as initialMicrostep, ab as toStatePath, ac as isStateId, ad as getStateNodeByPath, ae as getPersistedSnapshot, af as resolveReferencedActor, ag as createInvokeTimeoutEvent, ah as $$ACTOR_TYPE } from './index-d33c7b85.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
4
4
|
return (src, options) => {
|
|
@@ -193,6 +193,7 @@ class StateNode {
|
|
|
193
193
|
*/
|
|
194
194
|
this.order = -1;
|
|
195
195
|
this.description = void 0;
|
|
196
|
+
this.schemas = void 0;
|
|
196
197
|
this.tags = [];
|
|
197
198
|
this.transitions = void 0;
|
|
198
199
|
this.always = void 0;
|
|
@@ -209,6 +210,7 @@ class StateNode {
|
|
|
209
210
|
this.id = this.config.id || [this.machine.id, ...this.path].join(STATE_DELIMITER);
|
|
210
211
|
this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
|
|
211
212
|
this.description = this.config.description;
|
|
213
|
+
this.schemas = this.config.schemas;
|
|
212
214
|
validateStateNodeConfig(this);
|
|
213
215
|
this.order = this.machine.idMap.size;
|
|
214
216
|
this.machine.idMap.set(this.id, this);
|
|
@@ -313,6 +315,9 @@ class StateNode {
|
|
|
313
315
|
}
|
|
314
316
|
function validateStateNodeConfig(stateNode) {
|
|
315
317
|
const config = stateNode.config;
|
|
318
|
+
if (stateNode.type === 'history' && !(typeof config.target === 'string' && config.target.trim().length > 0 || Array.isArray(config.target) && config.target.length > 0 && config.target.every(target => typeof target === 'string' && target.trim().length > 0))) {
|
|
319
|
+
throw new Error(`Missing history target on "${stateNode.id}"`);
|
|
320
|
+
}
|
|
316
321
|
if (stateNode.type !== 'choice') {
|
|
317
322
|
return;
|
|
318
323
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dist_xstateActors = require('./index-
|
|
3
|
+
var dist_xstateActors = require('./index-b228b8b6.cjs.js');
|
|
4
4
|
|
|
5
5
|
function createSpawner(actorScope, actors, spawnedChildren) {
|
|
6
6
|
return (src, options) => {
|
|
@@ -195,6 +195,7 @@ class StateNode {
|
|
|
195
195
|
*/
|
|
196
196
|
this.order = -1;
|
|
197
197
|
this.description = void 0;
|
|
198
|
+
this.schemas = void 0;
|
|
198
199
|
this.tags = [];
|
|
199
200
|
this.transitions = void 0;
|
|
200
201
|
this.always = void 0;
|
|
@@ -211,6 +212,7 @@ class StateNode {
|
|
|
211
212
|
this.id = this.config.id || [this.machine.id, ...this.path].join(dist_xstateActors.STATE_DELIMITER);
|
|
212
213
|
this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
|
|
213
214
|
this.description = this.config.description;
|
|
215
|
+
this.schemas = this.config.schemas;
|
|
214
216
|
validateStateNodeConfig(this);
|
|
215
217
|
this.order = this.machine.idMap.size;
|
|
216
218
|
this.machine.idMap.set(this.id, this);
|
|
@@ -315,6 +317,9 @@ class StateNode {
|
|
|
315
317
|
}
|
|
316
318
|
function validateStateNodeConfig(stateNode) {
|
|
317
319
|
const config = stateNode.config;
|
|
320
|
+
if (stateNode.type === 'history' && !(typeof config.target === 'string' && config.target.trim().length > 0 || Array.isArray(config.target) && config.target.length > 0 && config.target.every(target => typeof target === 'string' && target.trim().length > 0))) {
|
|
321
|
+
throw new Error(`Missing history target on "${stateNode.id}"`);
|
|
322
|
+
}
|
|
318
323
|
if (stateNode.type !== 'choice') {
|
|
319
324
|
return;
|
|
320
325
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SetupStateSchemas } from "./schema.types.js";
|
|
1
2
|
import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, MachineContext, Mapper, StateNodesConfig, TransitionDefinitionMap, AnyStateMachine, AnyStateNodeConfig, NonReducibleUnknown, EventDescriptor, AnyAction, AnyTransitionDefinition, AnyInvokeDefinition } from "./types.js";
|
|
2
3
|
interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
|
|
3
4
|
_key: string;
|
|
@@ -60,6 +61,7 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
|
|
|
60
61
|
*/
|
|
61
62
|
order: number;
|
|
62
63
|
description?: string;
|
|
64
|
+
schemas: SetupStateSchemas | undefined;
|
|
63
65
|
tags: string[];
|
|
64
66
|
transitions: Map<string, AnyTransitionDefinition[]>;
|
|
65
67
|
always?: Array<AnyTransitionDefinition>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./schema.types.js";
|
|
2
2
|
import { StateMachine } from "./StateMachine.js";
|
|
3
3
|
import { AnyActorRef, EventObject, AnyEventObject, Cast, MachineContext, ProvidedActor, StateValue, ToChildren, MetaObject, StateSchema, DoNotInfer, RoutableStateId, Compute } from "./types.js";
|
|
4
|
-
import { Sources, DelayMapFromNames, InferChildren, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, ValidateDelayReferences, ValidateTopLevelFinalOutputs, WidenLiterals, WithDefault } from "./types.v6.js";
|
|
4
|
+
import { Sources, DelayMapFromNames, InferChildren, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, ValidateDelayReferences, ValidateHistoryDefaults, ValidateStateTargets, ValidateTopLevelFinalOutputs, WidenLiterals, WithDefault } from "./types.v6.js";
|
|
5
5
|
type MergeChildren<TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor> = [keyof TChildren] extends [never] ? Compute<ToChildren<TActor>> : Compute<TChildren>;
|
|
6
6
|
/**
|
|
7
7
|
* Creates a state machine (statechart) with the given configuration.
|
|
@@ -45,7 +45,7 @@ type MergeChildren<TChildren extends Record<string, AnyActorRef | undefined>, TA
|
|
|
45
45
|
* @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })`
|
|
46
46
|
* to provide machine sources instead.
|
|
47
47
|
*/
|
|
48
|
-
export declare function createMachine<TContextSchema extends StandardSchemaV1, const TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, const TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1>, _TEvent extends EventObject, TActor extends ProvidedActor, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TDelays extends string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, TInput, const TSS extends StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, InferOutput<TContextSchema, MachineContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap> & {
|
|
48
|
+
export declare function createMachine<TContextSchema extends StandardSchemaV1, const TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, const TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1>, _TEvent extends EventObject, TActor extends ProvidedActor, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TDelays extends string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, TInput, const TSS extends StateSchema>(config: TSS & ValidateDelayReferences<TSS> & ValidateHistoryDefaults<TSS> & ValidateStateTargets<TSS> & Next_MachineConfig<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, InferOutput<TContextSchema, MachineContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap> & {
|
|
49
49
|
schemas: {
|
|
50
50
|
context: TContextSchema;
|
|
51
51
|
children?: TChildrenSchemaMap;
|
|
@@ -58,7 +58,7 @@ TSS, // TStateSchema
|
|
|
58
58
|
TActionMap, TActorMap, TGuardMap, DelayMapFromNames<TDelays, TDelayMap>> & {
|
|
59
59
|
states: TSS;
|
|
60
60
|
};
|
|
61
|
-
export declare function createMachine<TContext extends MachineContext = never, const TEventSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1 = StandardSchemaV1, const TOutputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetaSchema extends StandardSchemaV1 = StandardSchemaV1, TTagSchema extends StandardSchemaV1 = StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, _TEvent extends EventObject = EventObject, TActor extends ProvidedActor = ProvidedActor, TActionMap extends Sources['actions'] = Sources['actions'], TActorMap extends Sources['actors'] = Sources['actors'], TGuardMap extends Sources['guards'] = Sources['guards'], TDelayMap extends Sources['delays'] = Sources['delays'], TDelays extends string = string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string = StandardSchemaV1.InferOutput<TTagSchema> & string, TInput = unknown, const TSS extends StateSchema = StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<StandardSchemaV1, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, WidenLiterals<TContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, false> & {
|
|
61
|
+
export declare function createMachine<TContext extends MachineContext = never, const TEventSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1 = StandardSchemaV1, const TOutputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetaSchema extends StandardSchemaV1 = StandardSchemaV1, TTagSchema extends StandardSchemaV1 = StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, _TEvent extends EventObject = EventObject, TActor extends ProvidedActor = ProvidedActor, TActionMap extends Sources['actions'] = Sources['actions'], TActorMap extends Sources['actors'] = Sources['actors'], TGuardMap extends Sources['guards'] = Sources['guards'], TDelayMap extends Sources['delays'] = Sources['delays'], TDelays extends string = string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string = StandardSchemaV1.InferOutput<TTagSchema> & string, TInput = unknown, const TSS extends StateSchema = StateSchema>(config: TSS & ValidateDelayReferences<TSS> & ValidateHistoryDefaults<TSS> & ValidateStateTargets<TSS> & Next_MachineConfig<StandardSchemaV1, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, WidenLiterals<TContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, false> & {
|
|
62
62
|
schemas?: {
|
|
63
63
|
context?: never;
|
|
64
64
|
};
|
|
@@ -172,7 +172,7 @@ export interface StateNodeJSON {
|
|
|
172
172
|
timeout?: number | string | ResolvableJSON;
|
|
173
173
|
onTimeout?: TransitionConfigJSON | TransitionConfigJSON[];
|
|
174
174
|
history?: 'shallow' | 'deep';
|
|
175
|
-
target?: string;
|
|
175
|
+
target?: string | [string, ...string[]];
|
|
176
176
|
output?: unknown;
|
|
177
177
|
context?: Record<string, unknown>;
|
|
178
178
|
_scxmlDonedata?: ScxmlDonedataJSON;
|
|
@@ -3,6 +3,11 @@ export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
|
3
3
|
/** The Standard Schema properties. */
|
|
4
4
|
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
5
5
|
}
|
|
6
|
+
/** Schemas that can be declared for an individual state node. */
|
|
7
|
+
export type SetupStateSchemas = {
|
|
8
|
+
context?: StandardSchemaV1;
|
|
9
|
+
input?: StandardSchemaV1;
|
|
10
|
+
};
|
|
6
11
|
/** A type-only Standard Schema produced by {@link types}. */
|
|
7
12
|
export interface TypeSchema<T> extends StandardSchemaV1<T, T> {
|
|
8
13
|
readonly '~standard': StandardSchemaV1.Props<T, T> & {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "./schema.types.js";
|
|
1
|
+
import { SetupStateSchemas, StandardSchemaV1 } from "./schema.types.js";
|
|
2
2
|
import { StateMachine } from "./StateMachine.js";
|
|
3
3
|
import { type Actor, type RequiredActorOptionsKeys } from "./createActor.js";
|
|
4
|
-
import { AnyActorRef, AnyActorLogic, ActorRefFromLogic, AnyStateNode, EventObject, AnyEventObject, EventDescriptor, ExtractEvent, MachineContext, ProvidedActor, RoutableStateId, StateSchema, StateValue, ToChildren, MetaObject, Cast, Compute, EnqueueObject, DoneActorEvent, DoneStateEvent, ErrorActorEvent, SystemRegistry, RegistryKeyForLogic, ActorOptions, Observer, Subscription, OutputArg, SnapshotEvent, SingleOrArray } from "./types.js";
|
|
4
|
+
import { AnyActorRef, AnyActorLogic, ActorRefFromLogic, AnyStateNode, EventObject, AnyEventObject, EventDescriptor, ExtractEvent, MachineContext, ProvidedActor, RoutableStateId, StateSchema, StateValue, ToChildren, MetaObject, Cast, Compute, EnqueueObject, DoneActorEvent, DoneStateEvent, ErrorActorEvent, SystemRegistry, RegistryKeyForLogic, ActorOptions, Observer, Subscription, OutputArg, SnapshotEvent, SingleOrArray, AfterEvent, TimeoutEvent, ErrorEvent } from "./types.js";
|
|
5
5
|
import { AnyActorSystem } from "./system.js";
|
|
6
6
|
import { InspectionEvent } from "./inspection.js";
|
|
7
|
-
import { ActionSchemas, DelayMapFromNames, GuardSchemas, InferChildren, InferActions, InferGuards, Sources, InferOutput, InferEvents, Next_MachineConfig, Next_InvokeConfig, Next_StateNodeConfig, Next_TransitionConfigOrTarget, WithDefault } from "./types.v6.js";
|
|
7
|
+
import { ActionSchemas, DelayMapFromNames, GuardSchemas, InferChildren, InferActions, InferGuards, Sources, InferOutput, InferEvents, Next_MachineConfig, Next_InvokeConfig, Next_StateNodeConfig, Next_TransitionConfigOrTarget, ValidateHistoryDefaults, ValidateStateTargets, WithDefault } from "./types.v6.js";
|
|
8
8
|
export type SetupConfig<TSchemas extends SetupSchemas, TStates extends Record<string, SetupStateSchema>, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays']> = {
|
|
9
9
|
schemas?: TSchemas & SetupSchemas;
|
|
10
10
|
states?: TStates;
|
|
@@ -50,10 +50,7 @@ type ValidateRegistryKeys<TConfig, TSystemRegistry extends SystemRegistry, TActo
|
|
|
50
50
|
[K in keyof TStates]: TStates[K] & ValidateRegistryKeys<TStates[K], TSystemRegistry, TActorMap>;
|
|
51
51
|
};
|
|
52
52
|
} : unknown);
|
|
53
|
-
export type SetupStateSchemas
|
|
54
|
-
context?: StandardSchemaV1;
|
|
55
|
-
input?: StandardSchemaV1;
|
|
56
|
-
};
|
|
53
|
+
export type { SetupStateSchemas };
|
|
57
54
|
export type SetupSchemas = {
|
|
58
55
|
context?: StandardSchemaV1;
|
|
59
56
|
events?: Record<string, StandardSchemaV1>;
|
|
@@ -245,7 +242,7 @@ type StatesWithInput<TRootStateSchemas extends Record<string, SetupStateSchema>,
|
|
|
245
242
|
[K in TStateKeys]?: StateNodeConfigWithNestedInput<StateSchemasWithKeys<TRootStateSchemas, TStateKeys>, K extends keyof TStateSchemas ? TStateSchemas[K] : {}, TContext, TContextShape, TEvent, TChildren, TDelays, TTag, TOutput, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
246
243
|
};
|
|
247
244
|
/** State node config that recursively applies typed input for nested states */
|
|
248
|
-
type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TSystemRegistry extends SystemRegistry> = WithNestedStates<Omit<Next_StateNodeConfig<StateContext<TStateSchema, TContext>, TEvent, TDelays, TTag, TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, StateInput<TStateSchema>, Record<string, unknown>, TSystemRegistry>, 'on' | 'always' | 'initial' | 'invoke' | 'onDone'> & {
|
|
245
|
+
type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TSystemRegistry extends SystemRegistry> = WithNestedStates<Omit<Next_StateNodeConfig<StateContext<TStateSchema, TContext>, TEvent, TDelays, TTag, TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, StateInput<TStateSchema>, Record<string, unknown>, TSystemRegistry>, 'on' | 'always' | 'initial' | 'invoke' | 'onDone' | 'onError' | 'onTimeout' | 'after'> & {
|
|
249
246
|
initial?: TStateSchema['states'] extends Record<string, SetupStateSchema> ? SetupStateKey<TStateSchema['states']> | (string & {}) | InitialTransitionWithInput<TStateSchema['states'], StateContext<TStateSchema, TContext>, TEvent> : string | {
|
|
250
247
|
target: string;
|
|
251
248
|
input?: Record<string, unknown>;
|
|
@@ -254,6 +251,11 @@ type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string,
|
|
|
254
251
|
always?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, StateInput<TStateSchema>>;
|
|
255
252
|
invoke?: SingleOrArray<SetupInvokeConfig<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>>;
|
|
256
253
|
onDone?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, DoneStateEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, StateInput<TStateSchema>>;
|
|
254
|
+
onError?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, ErrorEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, StateInput<TStateSchema>>;
|
|
255
|
+
onTimeout?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TimeoutEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, StateInput<TStateSchema>>;
|
|
256
|
+
after?: {
|
|
257
|
+
[K in NoInfer<TDelays> | number]?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, AfterEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, StateInput<TStateSchema>>;
|
|
258
|
+
};
|
|
257
259
|
}, TStateSchema['states'] extends Record<string, SetupStateSchema> ? StatesWithInput<TStateSchema['states'], TStateSchema['states'], TContext, StateContextShape<TStateSchema, TContextShape>, TEvent, TChildren, TDelays, TTag, TOutput, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry> : {
|
|
258
260
|
[K in string]?: Next_StateNodeConfig<TContext, TEvent, TDelays, TTag, TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, undefined, Record<string, unknown>, TSystemRegistry>;
|
|
259
261
|
}>;
|
|
@@ -380,7 +382,7 @@ export interface SetupReturn<TStates extends Record<string, SetupStateSchema> =
|
|
|
380
382
|
guards?: TGuardMap;
|
|
381
383
|
delays?: TDelayMap;
|
|
382
384
|
states?: Record<TStateKeys, unknown>;
|
|
383
|
-
} & TConfig & ValidateSetupDelayReferences<TConfig, TSetupDelays> & ValidateRegistryKeys<TConfig, TSystemRegistry, MergeSourceMaps<TSetupActorMap, TActorMap>>): StateMachine<SetupContext<TSchemas, TContextSchema>, SetupEvents<TSchemas, TEventSchemaMap> | ([RoutableStateId<Cast<TConfig, StateSchema>>] extends [never] ? never : {
|
|
385
|
+
} & TConfig & ValidateSetupDelayReferences<TConfig, TSetupDelays> & ValidateHistoryDefaults<TConfig> & ValidateStateTargets<TConfig> & ValidateRegistryKeys<TConfig, TSystemRegistry, MergeSourceMaps<TSetupActorMap, TActorMap>>): StateMachine<SetupContext<TSchemas, TContextSchema>, SetupEvents<TSchemas, TEventSchemaMap> | ([RoutableStateId<Cast<TConfig, StateSchema>>] extends [never] ? never : {
|
|
384
386
|
type: 'xstate.route';
|
|
385
387
|
to: RoutableStateId<Cast<TConfig, StateSchema>>;
|
|
386
388
|
}), Cast<MergeChildren<SetupChildren<TSchemas, TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, StateValue, TTag & string, [
|
|
@@ -469,4 +471,3 @@ type SystemBuilder<TSystemRegistry extends SystemRegistry> = {
|
|
|
469
471
|
setup<const TSchemas extends SetupSchemas = {}, const TStates extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>, TActionMap extends Sources['actions'] = {}, TActorMap extends Sources['actors'] = {}, TGuardMap extends Sources['guards'] = {}, TDelayMap extends Sources['delays'] = {}>(config?: SetupConfig<TSchemas, TStates, TActionMap, TActorMap, TGuardMap, TDelayMap>): SetupReturn<TStates, TSchemas, TActionMap, TActorMap, TGuardMap, TDelayMap, Extract<keyof TDelayMap, string>, TSystemRegistry>;
|
|
470
472
|
};
|
|
471
473
|
export declare function createSystem<const TSystemRegistry extends SystemRegistry = {}>(_config?: SystemConfig<TSystemRegistry>): SystemBuilder<TSystemRegistry>;
|
|
472
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "./schema.types.js";
|
|
1
|
+
import { SetupStateSchemas, StandardSchemaV1 } from "./schema.types.js";
|
|
2
2
|
import { MachineSnapshot } from "./State.js";
|
|
3
3
|
import { Action, ActorTimeoutEvent, AfterEvent, ActorLogic, ActorRef, ActorRefFromLogic, ActorSelf, AnyActorLogic, AnyActorRef, Compute, DoneActorEvent, DoNotInfer, ErrorActorEvent, EventDescriptor, ErrorEvent, EventObject, EventPayloadPattern, ExtractEvent, InitialContext, InputFrom, IsNever, MetaObject, NonReducibleUnknown, OutputFrom, SingleOrArray, SnapshotEvent, StateValue, TODO, TransitionContextMapper, TransitionContextPatch, TransitionConfigFunction, Values, AnyStateNode, SystemRegistry, TimeoutEvent } from "./types.js";
|
|
4
4
|
import { MachineContext, Mapper } from "./types.js";
|
|
@@ -102,7 +102,7 @@ type MachineSchemas<TContextSchema extends StandardSchemaV1, TEventSchemaMap ext
|
|
|
102
102
|
children?: TChildrenSchemaMap;
|
|
103
103
|
};
|
|
104
104
|
export type AnyMachineSchemas = MachineSchemas<StandardSchemaV1, Record<string, StandardSchemaV1>, Record<string, StandardSchemaV1>, StandardSchemaV1, StandardSchemaV1, StandardSchemaV1, StandardSchemaV1, Record<string, StandardSchemaV1>>;
|
|
105
|
-
export type Next_MachineConfig<TContextSchema extends StandardSchemaV1, TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, TChildrenSchemaMap extends Record<string, StandardSchemaV1>, TContext extends MachineContext = InferOutput<TContextSchema, MachineContext>, TEvent extends EventObject = InferEvents<TEventSchemaMap>, TChildren extends Record<string, AnyActorRef | undefined> = InferChildren<TChildrenSchemaMap>, TDelays extends string = string, _TTag extends string = string, TActionMap extends Sources['actions'] = Sources['actions'], TActorMap extends Sources['actors'] = Sources['actors'], TGuardMap extends Sources['guards'] = Sources['guards'], TDelayMap extends Sources['delays'] = Sources['delays'], TContextRequired extends boolean = IsNever<TContext> extends true ? false : true, TSystemRegistry extends SystemRegistry = SystemRegistry> = (DistributiveOmit<Next_StateNodeConfig<TContext, DoNotInfer<InferEvents<TEventSchemaMap>>, DoNotInfer<TDelays>, DoNotInfer<StandardSchemaV1.InferOutput<TTagSchema> & string>, DoNotInfer<StandardSchemaV1.InferOutput<TOutputSchema>>, DoNotInfer<InferEvents<TEmittedSchemaMap>>, DoNotInfer<InferOutput<TMetaSchema, MetaObject>>, DoNotInfer<TChildren>, DoNotInfer<TActionMap>, DoNotInfer<TActorMap>, DoNotInfer<TGuardMap>, DoNotInfer<TDelayMap>, Record<string, unknown> | undefined, Record<string, unknown>, DoNotInfer<TSystemRegistry>, DoNotInfer<InferOutput<TOutputSchema, unknown>>>, 'output'> & {
|
|
105
|
+
export type Next_MachineConfig<TContextSchema extends StandardSchemaV1, TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, TChildrenSchemaMap extends Record<string, StandardSchemaV1>, TContext extends MachineContext = InferOutput<TContextSchema, MachineContext>, TEvent extends EventObject = InferEvents<TEventSchemaMap>, TChildren extends Record<string, AnyActorRef | undefined> = InferChildren<TChildrenSchemaMap>, TDelays extends string = string, _TTag extends string = string, TActionMap extends Sources['actions'] = Sources['actions'], TActorMap extends Sources['actors'] = Sources['actors'], TGuardMap extends Sources['guards'] = Sources['guards'], TDelayMap extends Sources['delays'] = Sources['delays'], TContextRequired extends boolean = IsNever<TContext> extends true ? false : true, TSystemRegistry extends SystemRegistry = SystemRegistry> = (DistributiveOmit<Next_StateNodeConfig<TContext, DoNotInfer<InferEvents<TEventSchemaMap>>, DoNotInfer<TDelays>, DoNotInfer<StandardSchemaV1.InferOutput<TTagSchema> & string>, DoNotInfer<StandardSchemaV1.InferOutput<TOutputSchema>>, DoNotInfer<InferEvents<TEmittedSchemaMap>>, DoNotInfer<InferOutput<TMetaSchema, MetaObject>>, DoNotInfer<TChildren>, DoNotInfer<TActionMap>, DoNotInfer<TActorMap>, DoNotInfer<TGuardMap>, DoNotInfer<TDelayMap>, Record<string, unknown> | undefined, Record<string, unknown>, DoNotInfer<TSystemRegistry>, DoNotInfer<InferOutput<TOutputSchema, unknown>>>, 'output' | 'schemas'> & {
|
|
106
106
|
internalEvents?: readonly InternalEventDescriptorFor<InferEvents<TEventSchemaMap>>[];
|
|
107
107
|
schemas?: MachineSchemas<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap>;
|
|
108
108
|
actions?: TActionMap;
|
|
@@ -264,6 +264,7 @@ type Next_ChoiceConfigFunction<TContext extends MachineContext, TCurrentEvent ex
|
|
|
264
264
|
export type Next_StateNodeConfig<TContext extends MachineContext, TEvent extends EventObject, TDelays extends string, TTag extends string, _TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TChildren extends Record<string, AnyActorRef | undefined>, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TInput = Record<string, unknown> | undefined, TInputMap extends Record<string, unknown> = Record<string, unknown>, TSystemRegistry extends SystemRegistry = SystemRegistry, TChildOutput = unknown> = Next_RegularStateNodeConfig<TContext, TEvent, TDelays, TTag, _TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TInput, TInputMap, TSystemRegistry, TChildOutput> | Next_ChoiceStateNodeConfig<TContext, TEvent, TTag, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
|
|
265
265
|
interface Next_ChoiceStateNodeConfig<TContext extends MachineContext, TEvent extends EventObject, TTag extends string, TMeta extends MetaObject, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays']> {
|
|
266
266
|
contextSchema?: StandardSchemaV1;
|
|
267
|
+
schemas?: SetupStateSchemas;
|
|
267
268
|
type: 'choice';
|
|
268
269
|
/** Function that resolves this choice state to a target. */
|
|
269
270
|
choice: Next_ChoiceConfigFunction<TContext, TEvent, TEvent, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>;
|
|
@@ -291,6 +292,7 @@ interface Next_ChoiceStateNodeConfig<TContext extends MachineContext, TEvent ext
|
|
|
291
292
|
}
|
|
292
293
|
interface Next_RegularStateNodeConfig<TContext extends MachineContext, TEvent extends EventObject, TDelays extends string, TTag extends string, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TChildren extends Record<string, AnyActorRef | undefined>, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TInput = Record<string, unknown> | undefined, TInputMap extends Record<string, unknown> = Record<string, unknown>, TSystemRegistry extends SystemRegistry = SystemRegistry, TChildOutput = unknown> {
|
|
293
294
|
contextSchema?: StandardSchemaV1;
|
|
295
|
+
schemas?: SetupStateSchemas;
|
|
294
296
|
/** The initial state transition. */
|
|
295
297
|
initial?: string | {
|
|
296
298
|
target: string;
|
|
@@ -416,9 +418,9 @@ interface Next_RegularStateNodeConfig<TContext extends MachineContext, TEvent ex
|
|
|
416
418
|
/** A text description of the state node */
|
|
417
419
|
description?: string;
|
|
418
420
|
/** A default target for a history state */
|
|
419
|
-
target?: string | undefined;
|
|
421
|
+
target?: string | string[] | undefined;
|
|
420
422
|
}
|
|
421
|
-
export type Next_TransitionConfigOrTarget<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TMeta extends MetaObject, TInput = undefined> =
|
|
423
|
+
export type Next_TransitionConfigOrTarget<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TMeta extends MetaObject, TInput = undefined> = undefined | {
|
|
422
424
|
matches?: EventPayloadPattern<TExpressionEvent>;
|
|
423
425
|
target?: string | string[];
|
|
424
426
|
context?: TransitionContextPatch<TContext> | TransitionContextMapper<TContext, TExpressionEvent, TEvent, TActionMap, TActorMap, TGuardMap, TDelayMap>;
|
|
@@ -440,7 +442,7 @@ export type Next_TransitionConfigOrTarget<TContext extends MachineContext, TExpr
|
|
|
440
442
|
context: any;
|
|
441
443
|
event: any;
|
|
442
444
|
}) => Record<string, unknown>);
|
|
443
|
-
} | TransitionConfigFunction<TContext, TExpressionEvent, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta, TInput
|
|
445
|
+
} | TransitionConfigFunction<TContext, TExpressionEvent, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta, TInput>;
|
|
444
446
|
export type WithDefault<T, Default> = IsNever<T> extends true ? Default : T;
|
|
445
447
|
export interface Sources {
|
|
446
448
|
actions: Record<string, (...args: any[]) => void | {
|
|
@@ -465,4 +467,164 @@ type InvalidDelayReferences<TConfig, TDelays extends string> = (TConfig extends
|
|
|
465
467
|
[K in keyof TStates]: InvalidDelayReferences<TStates[K], TDelays>;
|
|
466
468
|
}[keyof TStates] : never : never);
|
|
467
469
|
export type ValidateDelayReferences<TConfig> = string extends DelayNamesFromConfig<TConfig> ? unknown : InvalidDelayReferences<TConfig, DelayNamesFromConfig<TConfig>> extends never ? unknown : never;
|
|
470
|
+
type IsHistoryStateConfig<TConfig> = TConfig extends {
|
|
471
|
+
type: 'history';
|
|
472
|
+
} ? true : TConfig extends {
|
|
473
|
+
history: false | undefined;
|
|
474
|
+
} ? false : TConfig extends {
|
|
475
|
+
history: unknown;
|
|
476
|
+
} ? true : false;
|
|
477
|
+
type MissingHistoryDefault<TConfig> = 0 extends 1 & TConfig ? never : IsHistoryStateConfig<TConfig> extends true ? TConfig extends {
|
|
478
|
+
target: string | readonly [string, ...string[]];
|
|
479
|
+
} ? never : true : TConfig extends {
|
|
480
|
+
states: infer TStates;
|
|
481
|
+
} ? TStates extends Record<string, unknown> ? {
|
|
482
|
+
[K in keyof TStates]: MissingHistoryDefault<TStates[K]>;
|
|
483
|
+
}[keyof TStates] : never : never;
|
|
484
|
+
/**
|
|
485
|
+
* Rejects authored machines containing a history state without its SCXML
|
|
486
|
+
* default target.
|
|
487
|
+
*/
|
|
488
|
+
export type ValidateHistoryDefaults<TConfig> = MissingHistoryDefault<TConfig> extends never ? unknown : never;
|
|
489
|
+
type StatePath = readonly string[];
|
|
490
|
+
type AppendStatePath<TPrefix extends StatePath, TKey extends string> = [
|
|
491
|
+
...TPrefix,
|
|
492
|
+
TKey
|
|
493
|
+
];
|
|
494
|
+
type EscapeStatePathDots<TValue extends string> = TValue extends `${infer THead}.${infer TTail}` ? `${THead}\\.${EscapeStatePathDots<TTail>}` : TValue;
|
|
495
|
+
type ProtectEscapedStatePathDots<TValue extends string> = TValue extends `${infer THead}\\.${infer TTail}` ? `${THead}__XSTATE_ESCAPED_DOT__${ProtectEscapedStatePathDots<TTail>}` : TValue;
|
|
496
|
+
type RestoreEscapedStatePathDots<TValue extends string> = TValue extends `${infer THead}__XSTATE_ESCAPED_DOT__${infer TTail}` ? `${THead}.${RestoreEscapedStatePathDots<TTail>}` : TValue;
|
|
497
|
+
type SplitStatePath<TPath extends string> = ProtectEscapedStatePathDots<TPath> extends infer TProtected extends string ? TProtected extends '' ? [] : TProtected extends `${infer THead}.${infer TTail}` ? [RestoreEscapedStatePathDots<THead>, ...SplitStatePath<TTail>] : [RestoreEscapedStatePathDots<TProtected>] : never;
|
|
498
|
+
type ParentStatePath<TPath extends StatePath> = TPath extends readonly [
|
|
499
|
+
...infer TParent extends string[],
|
|
500
|
+
string
|
|
501
|
+
] ? TParent : [];
|
|
502
|
+
type StatePathsFromStates<TStates, TPrefix extends StatePath = []> = TStates extends Record<string, unknown> ? {
|
|
503
|
+
[K in keyof TStates & string]: AppendStatePath<TPrefix, K> | (0 extends 1 & TStates[K] ? never : TStates[K] extends {
|
|
504
|
+
states: infer TChildren;
|
|
505
|
+
} ? StatePathsFromStates<TChildren, AppendStatePath<TPrefix, K>> : never);
|
|
506
|
+
}[keyof TStates & string] : never;
|
|
507
|
+
type AuthoredStatePaths<TConfig> = TConfig extends {
|
|
508
|
+
states: infer TStates;
|
|
509
|
+
} ? StatePathsFromStates<TStates> : never;
|
|
510
|
+
type OpaqueStatePathsFromStates<TStates, TPrefix extends StatePath = []> = TStates extends Record<string, unknown> ? {
|
|
511
|
+
[K in keyof TStates & string]: 0 extends 1 & TStates[K] ? AppendStatePath<TPrefix, K> : TStates[K] extends {
|
|
512
|
+
states: infer TChildren;
|
|
513
|
+
} ? OpaqueStatePathsFromStates<TChildren, AppendStatePath<TPrefix, K>> : never;
|
|
514
|
+
}[keyof TStates & string] : never;
|
|
515
|
+
type OpaqueStatePaths<TConfig> = TConfig extends {
|
|
516
|
+
states: infer TStates;
|
|
517
|
+
} ? OpaqueStatePathsFromStates<TStates> : never;
|
|
518
|
+
type IsWithinStatePath<TPath extends StatePath, TAncestor> = TAncestor extends StatePath ? TPath extends readonly [...TAncestor, ...string[]] ? true : false : false;
|
|
519
|
+
type JoinStateTargetString<TPrefix extends string, TKey extends string> = TPrefix extends '' ? TKey : `${TPrefix}.${TKey}`;
|
|
520
|
+
type StateTargetStringsFromStates<TStates, TPrefix extends string = ''> = TStates extends Record<string, unknown> ? {
|
|
521
|
+
[K in keyof TStates & string]: JoinStateTargetString<TPrefix, EscapeStatePathDots<K>> | (0 extends 1 & TStates[K] ? never : TStates[K] extends {
|
|
522
|
+
states: infer TChildren;
|
|
523
|
+
} ? StateTargetStringsFromStates<TChildren, JoinStateTargetString<TPrefix, EscapeStatePathDots<K>>> : never);
|
|
524
|
+
}[keyof TStates & string] : never;
|
|
525
|
+
type IdTargetsForNode<TNode> = TNode extends {
|
|
526
|
+
id: infer TId extends string;
|
|
527
|
+
} ? string extends TId ? never : TNode extends {
|
|
528
|
+
states: infer TStates;
|
|
529
|
+
} ? `#${EscapeStatePathDots<TId>}` | `#${EscapeStatePathDots<TId>}.${StateTargetStringsFromStates<TStates>}` : `#${EscapeStatePathDots<TId>}` : never;
|
|
530
|
+
type IdTargetsFromStates<TStates> = TStates extends Record<string, unknown> ? {
|
|
531
|
+
[K in keyof TStates & string]: IdTargetsForNode<TStates[K]> | (0 extends 1 & TStates[K] ? never : TStates[K] extends {
|
|
532
|
+
states: infer TChildren;
|
|
533
|
+
} ? IdTargetsFromStates<TChildren> : never);
|
|
534
|
+
}[keyof TStates & string] : never;
|
|
535
|
+
type AuthoredIdTargets<TConfig> = IdTargetsForNode<TConfig> | (TConfig extends {
|
|
536
|
+
states: infer TStates;
|
|
537
|
+
} ? IdTargetsFromStates<TStates> : never);
|
|
538
|
+
type ResolveIdTargetAtNode<TNode, TNodePath extends StatePath, TTarget extends string> = TNode extends {
|
|
539
|
+
id: infer TId extends string;
|
|
540
|
+
} ? string extends TId ? never : TTarget extends `#${EscapeStatePathDots<TId>}` ? TNodePath : TTarget extends `#${EscapeStatePathDots<TId>}.${infer TDescendant}` ? [...TNodePath, ...SplitStatePath<TDescendant>] : never : never;
|
|
541
|
+
type ResolveIdTargetInStates<TStates, TTarget extends string, TPrefix extends StatePath = []> = TStates extends Record<string, unknown> ? {
|
|
542
|
+
[K in keyof TStates & string]: ResolveIdTargetAtNode<TStates[K], AppendStatePath<TPrefix, K>, TTarget> | (0 extends 1 & TStates[K] ? never : TStates[K] extends {
|
|
543
|
+
states: infer TChildren;
|
|
544
|
+
} ? ResolveIdTargetInStates<TChildren, TTarget, AppendStatePath<TPrefix, K>> : never);
|
|
545
|
+
}[keyof TStates & string] : never;
|
|
546
|
+
type ResolveIdTargetPath<TConfig, TTarget extends string> = ResolveIdTargetAtNode<TConfig, [], TTarget> | (TConfig extends {
|
|
547
|
+
states: infer TStates;
|
|
548
|
+
} ? ResolveIdTargetInStates<TStates, TTarget> : never);
|
|
549
|
+
type ResolveAuthoredTarget<TSourcePath extends StatePath, TTarget extends string> = TTarget extends `#${string}` ? never : TTarget extends '.' ? TSourcePath : TTarget extends `.${infer TDescendant}` ? [...TSourcePath, ...SplitStatePath<TDescendant>] : [...ParentStatePath<TSourcePath>, ...SplitStatePath<TTarget>];
|
|
550
|
+
type StateNodeAtPath<TConfig, TPath extends StatePath> = TConfig extends {
|
|
551
|
+
states: infer TStates;
|
|
552
|
+
} ? TPath extends readonly [
|
|
553
|
+
infer THead extends string,
|
|
554
|
+
...infer TTail extends string[]
|
|
555
|
+
] ? THead extends keyof TStates ? TTail extends [] ? TStates[THead] : StateNodeAtPath<TStates[THead], TTail> : never : TConfig : never;
|
|
556
|
+
type CommonStatePathSegments<TLeft extends readonly string[], TRight extends readonly string[], TCommon extends readonly string[] = []> = TLeft extends readonly [
|
|
557
|
+
infer TLeftHead extends string,
|
|
558
|
+
...infer TLeftTail extends string[]
|
|
559
|
+
] ? TRight extends readonly [
|
|
560
|
+
infer TRightHead extends string,
|
|
561
|
+
...infer TRightTail extends string[]
|
|
562
|
+
] ? TLeftHead extends TRightHead ? CommonStatePathSegments<TLeftTail, TRightTail, [...TCommon, TLeftHead]> : TCommon : TCommon : TCommon;
|
|
563
|
+
type NearestCommonStatePath<TLeft extends StatePath, TRight extends StatePath> = CommonStatePathSegments<TLeft, TRight>;
|
|
564
|
+
type IsAncestorStatePath<TAncestor extends StatePath, TDescendant extends StatePath> = TDescendant extends readonly [...TAncestor, ...infer TRest] ? TRest extends [] ? false : true : false;
|
|
565
|
+
type IsParallelStatePath<TConfig, TPath extends StatePath> = TPath extends readonly [] ? TConfig extends {
|
|
566
|
+
type: 'parallel';
|
|
567
|
+
} ? true : false : StateNodeAtPath<TConfig, TPath> extends {
|
|
568
|
+
type: 'parallel';
|
|
569
|
+
} ? true : false;
|
|
570
|
+
type ResolvedAuthoredTargetPath<TRootConfig, TSourcePath extends StatePath, TTarget> = TTarget extends string ? TTarget extends `#${string}` ? ResolveIdTargetPath<TRootConfig, TTarget> : ResolveAuthoredTarget<TSourcePath, TTarget> : never;
|
|
571
|
+
type InvalidTargetPair<TRootConfig, TLeftPath extends StatePath, TRightPath extends StatePath> = TLeftPath extends TRightPath ? TRightPath extends TLeftPath ? true : never : IsAncestorStatePath<TLeftPath, TRightPath> extends true ? true : IsAncestorStatePath<TRightPath, TLeftPath> extends true ? true : IsParallelStatePath<TRootConfig, NearestCommonStatePath<TLeftPath, TRightPath>> extends true ? never : true;
|
|
572
|
+
type InvalidTargetPairsWithHead<TRootConfig, TSourcePath extends StatePath, THead, TRest extends readonly unknown[]> = TRest extends readonly [infer TNext, ...infer TTail] ? (ResolvedAuthoredTargetPath<TRootConfig, TSourcePath, THead> extends infer THeadPath extends StatePath ? ResolvedAuthoredTargetPath<TRootConfig, TSourcePath, TNext> extends infer TNextPath extends StatePath ? InvalidTargetPair<TRootConfig, THeadPath, TNextPath> : never : never) | InvalidTargetPairsWithHead<TRootConfig, TSourcePath, THead, TTail> : never;
|
|
573
|
+
type InvalidTargetSet<TRootConfig, TSourcePath extends StatePath, TTargets> = TTargets extends readonly [infer THead, ...infer TRest] ? InvalidTargetPairsWithHead<TRootConfig, TSourcePath, THead, TRest> | InvalidTargetSet<TRootConfig, TSourcePath, TRest> : never;
|
|
574
|
+
type InvalidTargetValue<TRootConfig, TSourcePath extends StatePath, TTarget> = TTarget extends string ? string extends TTarget ? never : TTarget extends `#${string}` ? TTarget extends AuthoredIdTargets<TRootConfig> ? never : TTarget : ResolveAuthoredTarget<TSourcePath, TTarget> extends infer TResolvedTarget extends StatePath ? TResolvedTarget extends AuthoredStatePaths<TRootConfig> ? never : true extends IsWithinStatePath<TResolvedTarget, OpaqueStatePaths<TRootConfig>> ? never : TTarget : TTarget : TTarget extends readonly unknown[] ? InvalidTargetValue<TRootConfig, TSourcePath, TTarget[number]> : never;
|
|
575
|
+
type InvalidTransitionTarget<TRootConfig, TSourcePath extends StatePath, TTransition> = 0 extends 1 & TTransition ? never : TTransition extends (...args: any[]) => any ? InvalidTransitionTarget<TRootConfig, TSourcePath, ReturnType<TTransition>> : TTransition extends readonly unknown[] ? InvalidTransitionTarget<TRootConfig, TSourcePath, TTransition[number]> : TTransition extends {
|
|
576
|
+
target: infer TTarget;
|
|
577
|
+
} ? InvalidTargetValue<TRootConfig, TSourcePath, TTarget> | InvalidTargetSet<TRootConfig, TSourcePath, TTarget> : never;
|
|
578
|
+
type InvalidTransitionMapTargets<TRootConfig, TSourcePath extends StatePath, TTransitionMap> = 0 extends 1 & TTransitionMap ? never : TTransitionMap extends Record<string, unknown> ? {
|
|
579
|
+
[K in keyof TTransitionMap]: InvalidTransitionTarget<TRootConfig, TSourcePath, TTransitionMap[K]>;
|
|
580
|
+
}[keyof TTransitionMap] : never;
|
|
581
|
+
type InvalidInvokeTargets<TRootConfig, TSourcePath extends StatePath, TInvoke> = 0 extends 1 & TInvoke ? never : TInvoke extends readonly unknown[] ? InvalidInvokeTargets<TRootConfig, TSourcePath, TInvoke[number]> : TInvoke extends Record<string, unknown> ? (TInvoke extends {
|
|
582
|
+
onDone: infer TOnDone;
|
|
583
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TOnDone> : never) | (TInvoke extends {
|
|
584
|
+
onError: infer TOnError;
|
|
585
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TOnError> : never) | (TInvoke extends {
|
|
586
|
+
onSnapshot: infer TOnSnapshot;
|
|
587
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TOnSnapshot> : never) | (TInvoke extends {
|
|
588
|
+
onTimeout: infer TOnTimeout;
|
|
589
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TOnTimeout> : never) : never;
|
|
590
|
+
type InvalidNodeTargets<TRootConfig, TNode, TSourcePath extends StatePath> = 0 extends 1 & TNode ? never : (TNode extends {
|
|
591
|
+
initial: infer TInitial;
|
|
592
|
+
states: infer TChildStates;
|
|
593
|
+
} ? (TInitial extends {
|
|
594
|
+
target: infer TInitialTarget;
|
|
595
|
+
} ? TInitialTarget : TInitial) extends infer TInitialTarget ? TInitialTarget extends string ? string extends TInitialTarget ? never : TInitialTarget extends keyof TChildStates ? never : TInitialTarget : never : never : never) | (TNode extends {
|
|
596
|
+
on: infer TOn;
|
|
597
|
+
} ? InvalidTransitionMapTargets<TRootConfig, TSourcePath, TOn> : never) | (TNode extends {
|
|
598
|
+
always: infer TAlways;
|
|
599
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TAlways> : never) | (TNode extends {
|
|
600
|
+
choice: infer TChoice;
|
|
601
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TChoice> : never) | (TNode extends {
|
|
602
|
+
after: infer TAfter;
|
|
603
|
+
} ? InvalidTransitionMapTargets<TRootConfig, TSourcePath, TAfter> : never) | (TNode extends {
|
|
604
|
+
onDone: infer TOnDone;
|
|
605
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TOnDone> : never) | (TNode extends {
|
|
606
|
+
onError: infer TOnError;
|
|
607
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TOnError> : never) | (TNode extends {
|
|
608
|
+
onTimeout: infer TOnTimeout;
|
|
609
|
+
} ? InvalidTransitionTarget<TRootConfig, TSourcePath, TOnTimeout> : never) | (TNode extends {
|
|
610
|
+
invoke: infer TInvoke;
|
|
611
|
+
} ? InvalidInvokeTargets<TRootConfig, TSourcePath, TInvoke> : never) | (TNode extends {
|
|
612
|
+
target: infer THistoryTarget;
|
|
613
|
+
} ? InvalidTargetValue<TRootConfig, TSourcePath, THistoryTarget> : never);
|
|
614
|
+
type InvalidTargetsInStates<TRootConfig, TStates, TPrefix extends StatePath = []> = TStates extends Record<string, unknown> ? {
|
|
615
|
+
[K in keyof TStates & string]: 0 extends 1 & TStates[K] ? never : InvalidNodeTargets<TRootConfig, TStates[K], AppendStatePath<TPrefix, K>> | (TStates[K] extends {
|
|
616
|
+
states: infer TChildren;
|
|
617
|
+
} ? InvalidTargetsInStates<TRootConfig, TChildren, AppendStatePath<TPrefix, K>> : never);
|
|
618
|
+
}[keyof TStates & string] : never;
|
|
619
|
+
/**
|
|
620
|
+
* Rejects authored literal transition targets that do not resolve in the
|
|
621
|
+
* machine topology.
|
|
622
|
+
*/
|
|
623
|
+
export type ValidateStateTargets<TConfig> = 0 extends 1 & TConfig ? unknown : TConfig extends {
|
|
624
|
+
states: infer TStates;
|
|
625
|
+
} ? (TConfig extends {
|
|
626
|
+
initial: infer TInitial;
|
|
627
|
+
} ? (TInitial extends {
|
|
628
|
+
target: infer TInitialTarget;
|
|
629
|
+
} ? TInitialTarget : TInitial) extends infer TInitialTarget ? TInitialTarget extends string ? string extends TInitialTarget ? never : TInitialTarget extends keyof TStates ? never : TInitialTarget : never : never : never) | InvalidNodeTargets<TConfig, TConfig, []> | InvalidTargetsInStates<TConfig, TStates> extends never ? unknown : never : unknown;
|
|
468
630
|
export {};
|
|
@@ -1285,6 +1285,7 @@ function formatTransition(stateNode, descriptor, transitionConfig) {
|
|
|
1285
1285
|
const normalizedTarget = normalizeTarget(transitionConfig.target);
|
|
1286
1286
|
const reenter = transitionConfig.reenter ?? false;
|
|
1287
1287
|
const target = resolveTarget(stateNode, normalizedTarget);
|
|
1288
|
+
assertLegalTargetSet(stateNode, target);
|
|
1288
1289
|
const transition = {
|
|
1289
1290
|
...transitionConfig,
|
|
1290
1291
|
target,
|
|
@@ -1299,6 +1300,41 @@ function formatTransition(stateNode, descriptor, transitionConfig) {
|
|
|
1299
1300
|
};
|
|
1300
1301
|
return transition;
|
|
1301
1302
|
}
|
|
1303
|
+
function isStateNodeDescendantOf(stateNode, ancestor) {
|
|
1304
|
+
for (let current = stateNode.parent; current; current = current.parent) {
|
|
1305
|
+
if (current === ancestor) {
|
|
1306
|
+
return true;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
return false;
|
|
1310
|
+
}
|
|
1311
|
+
function getLeastCommonStateNodeAncestor(left, right) {
|
|
1312
|
+
const leftAncestors = new Set();
|
|
1313
|
+
for (let current = left; current; current = current.parent) {
|
|
1314
|
+
leftAncestors.add(current);
|
|
1315
|
+
}
|
|
1316
|
+
for (let current = right; current; current = current.parent) {
|
|
1317
|
+
if (leftAncestors.has(current)) {
|
|
1318
|
+
return current;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
return undefined;
|
|
1322
|
+
}
|
|
1323
|
+
function assertLegalTargetSet(source, targets) {
|
|
1324
|
+
if (!targets || targets.length < 2) {
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
for (let leftIndex = 0; leftIndex < targets.length; leftIndex++) {
|
|
1328
|
+
for (let rightIndex = leftIndex + 1; rightIndex < targets.length; rightIndex++) {
|
|
1329
|
+
const left = targets[leftIndex];
|
|
1330
|
+
const right = targets[rightIndex];
|
|
1331
|
+
const commonAncestor = getLeastCommonStateNodeAncestor(left, right);
|
|
1332
|
+
if (left === right || isStateNodeDescendantOf(left, right) || isStateNodeDescendantOf(right, left) || commonAncestor?.type !== 'parallel') {
|
|
1333
|
+
throw new Error(`Invalid transition definition for state node '${source.id}': target set is not a legal SCXML configuration.` );
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1302
1338
|
|
|
1303
1339
|
/**
|
|
1304
1340
|
* Collects route transitions from all descendants with explicit IDs. Called
|
|
@@ -1401,8 +1437,10 @@ function resolveHistoryDefaultTransition(stateNode) {
|
|
|
1401
1437
|
}
|
|
1402
1438
|
return stateNode.parent.initial;
|
|
1403
1439
|
}
|
|
1440
|
+
const target = normalizedTarget.map(t => typeof t === 'string' ? getStateNodeByPath(stateNode.parent, t) : t);
|
|
1441
|
+
assertLegalTargetSet(stateNode, target);
|
|
1404
1442
|
return {
|
|
1405
|
-
target
|
|
1443
|
+
target,
|
|
1406
1444
|
source: stateNode,
|
|
1407
1445
|
reenter: false,
|
|
1408
1446
|
eventType: ''
|