xstate 6.0.0-alpha.13 → 6.0.0-alpha.15
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-193c2d4d.development.esm.js → StateMachine-0fa9c094.development.esm.js} +1 -1
- package/dist/{StateMachine-614c0f36.esm.js → StateMachine-8dbd20ad.esm.js} +1 -1
- package/dist/{StateMachine-3120a7ff.development.cjs.js → StateMachine-98411dc5.development.cjs.js} +1 -1
- package/dist/{StateMachine-1b26c5de.cjs.js → StateMachine-e3b1aa2d.cjs.js} +1 -1
- package/dist/declarations/src/State.d.ts +13 -2
- package/dist/declarations/src/setup.d.ts +47 -5
- package/dist/declarations/src/types.d.ts +18 -2
- package/dist/declarations/src/types.v6.d.ts +2 -2
- package/dist/{index-08d86676.development.cjs.js → index-07b19ed0.development.cjs.js} +2 -3
- package/dist/{index-32631949.cjs.js → index-0d940f2c.cjs.js} +2 -3
- package/dist/{index-603c1cda.esm.js → index-2635a437.esm.js} +2 -3
- package/dist/{index-7081e0c9.development.esm.js → index-362125ce.development.esm.js} +2 -3
- 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 +26 -4
- package/dist/xstate.development.cjs.js +26 -4
- package/dist/xstate.development.esm.js +28 -6
- package/dist/xstate.esm.js +28 -6
- 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-193c2d4d.development.esm.js → StateMachine-0fa9c094.development.esm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProcessingStatus, G as resolveReferencedActor, d as createActor, S as STATE_DELIMITER, H as mapValues, t as toArray, I as createInvokeId, J as getDelayedTransitions, K as evaluateCandidate, L as formatTransition, N as NULL_EVENT, M as toTransitionConfigArray, O as createInvokeTimeoutEvent, Q as getCandidates, R as formatRouteTransitions, U as resolveStateValue, V as getAllStateNodes, k as getStateNodes, W as createMachineSnapshot, Y as isInFinalState, e as macrostep, Z as cloneMachineSnapshot, _ as transitionNode, m as matchesEventDescriptor, r as resolveActionsWithContext, f as createInitEvent, g as initialMicrostep, $ as toStatePath, a0 as isStateId, a1 as getStateNodeByPath, a2 as getPersistedSnapshot, a3 as $$ACTOR_TYPE } from './index-
|
|
1
|
+
import { P as ProcessingStatus, G as resolveReferencedActor, d as createActor, S as STATE_DELIMITER, H as mapValues, t as toArray, I as createInvokeId, J as getDelayedTransitions, K as evaluateCandidate, L as formatTransition, N as NULL_EVENT, M as toTransitionConfigArray, O as createInvokeTimeoutEvent, Q as getCandidates, R as formatRouteTransitions, U as resolveStateValue, V as getAllStateNodes, k as getStateNodes, W as createMachineSnapshot, Y as isInFinalState, e as macrostep, Z as cloneMachineSnapshot, _ as transitionNode, m as matchesEventDescriptor, r as resolveActionsWithContext, f as createInitEvent, g as initialMicrostep, $ as toStatePath, a0 as isStateId, a1 as getStateNodeByPath, a2 as getPersistedSnapshot, a3 as $$ACTOR_TYPE } from './index-362125ce.development.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProcessingStatus, G as resolveReferencedActor, d as createActor, S as STATE_DELIMITER, H as mapValues, t as toArray, I as createInvokeId, J as getDelayedTransitions, K as evaluateCandidate, L as formatTransition, N as NULL_EVENT, M as toTransitionConfigArray, O as createInvokeTimeoutEvent, Q as getCandidates, R as formatRouteTransitions, U as resolveStateValue, V as getAllStateNodes, k as getStateNodes, W as createMachineSnapshot, Y as isInFinalState, e as macrostep, Z as cloneMachineSnapshot, _ as transitionNode, m as matchesEventDescriptor, r as resolveActionsWithContext, f as createInitEvent, g as initialMicrostep, $ as toStatePath, a0 as isStateId, a1 as getStateNodeByPath, a2 as getPersistedSnapshot, a3 as $$ACTOR_TYPE } from './index-
|
|
1
|
+
import { P as ProcessingStatus, G as resolveReferencedActor, d as createActor, S as STATE_DELIMITER, H as mapValues, t as toArray, I as createInvokeId, J as getDelayedTransitions, K as evaluateCandidate, L as formatTransition, N as NULL_EVENT, M as toTransitionConfigArray, O as createInvokeTimeoutEvent, Q as getCandidates, R as formatRouteTransitions, U as resolveStateValue, V as getAllStateNodes, k as getStateNodes, W as createMachineSnapshot, Y as isInFinalState, e as macrostep, Z as cloneMachineSnapshot, _ as transitionNode, m as matchesEventDescriptor, r as resolveActionsWithContext, f as createInitEvent, g as initialMicrostep, $ as toStatePath, a0 as isStateId, a1 as getStateNodeByPath, a2 as getPersistedSnapshot, a3 as $$ACTOR_TYPE } from './index-2635a437.esm.js';
|
|
2
2
|
|
|
3
3
|
function createSpawner(actorScope, {
|
|
4
4
|
machine,
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import type { AnyMachineSnapshot, AnyStateMachine, EventObject, HistoryValue, MachineContext, StateConfig, StateValue, AnyActorRef, Snapshot, MetaObject, StateSchema, StateId, StateIdInputs, StateContextFromStateValue, SnapshotStatus, AnyStateNode } from "./types.js";
|
|
1
|
+
import type { AnyMachineSnapshot, AnyStateMachine, EventObject, HistoryValue, MachineContext, StateConfig, StateValue, StateValueMap, AnyActorRef, Snapshot, MetaObject, StateSchema, StateId, StateIdInputs, StateContextFromStateValue, SnapshotStatus, AnyStateNode } from "./types.js";
|
|
2
2
|
export declare function isMachineSnapshot(value: unknown): value is AnyMachineSnapshot;
|
|
3
|
+
type Values<T> = T[keyof T];
|
|
4
|
+
type MatchingObjectStateValue<TStateValue extends Record<string, unknown>, TTestStateValue extends Record<string, unknown>> = false extends Values<{
|
|
5
|
+
[K in keyof TTestStateValue]: K extends keyof TStateValue ? NonNullable<TStateValue[K]> extends StateValue ? NonNullable<TTestStateValue[K]> extends StateValue ? [
|
|
6
|
+
MatchingStateValue<NonNullable<TStateValue[K]>, NonNullable<TTestStateValue[K]>>
|
|
7
|
+
] extends [never] ? false : true : false : false : false;
|
|
8
|
+
}> ? never : {
|
|
9
|
+
[K in keyof TStateValue]: K extends keyof TTestStateValue ? MatchingStateValue<NonNullable<TStateValue[K]>, NonNullable<TTestStateValue[K]>> : TStateValue[K];
|
|
10
|
+
};
|
|
11
|
+
type MatchingStateValue<TStateValue extends StateValue, TTestStateValue extends StateValue> = StateValue extends TTestStateValue ? TStateValue : string extends TTestStateValue ? TStateValue : TStateValue extends unknown ? TTestStateValue extends string ? TStateValue extends string ? TTestStateValue extends TStateValue ? TTestStateValue : Extract<TStateValue, TTestStateValue> : TStateValue extends Record<string, unknown> ? TStateValue & Record<TTestStateValue, StateValue | undefined> : never : TTestStateValue extends Record<string, unknown> ? TStateValue extends Record<string, unknown> ? MatchingObjectStateValue<TStateValue, TTestStateValue> : never : never : never;
|
|
3
12
|
interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, _TOutput, TMeta extends MetaObject, TStateSchema extends StateSchema = StateSchema> {
|
|
4
13
|
/** The state machine that produced this state snapshot. */
|
|
5
14
|
machine: AnyStateMachine;
|
|
@@ -42,7 +51,9 @@ interface MachineSnapshotBase<TContext extends MachineContext, TEvent extends Ev
|
|
|
42
51
|
*
|
|
43
52
|
* @param partialStateValue
|
|
44
53
|
*/
|
|
45
|
-
matches<const TTestStateValue extends
|
|
54
|
+
matches<const TTestStateValue extends string>(partialStateValue: TTestStateValue, ...args: string extends TTestStateValue ? [never] : []): this is MachineSnapshot<StateContextFromStateValue<TStateSchema, TContext, TTestStateValue>, TEvent, TChildren, MatchingStateValue<TStateValue, TTestStateValue>, TTag, _TOutput, TMeta, TStateSchema>;
|
|
55
|
+
matches<const TTestStateValue extends StateValueMap>(partialStateValue: TTestStateValue, ...args: string extends keyof TTestStateValue ? [never] : []): this is MachineSnapshot<StateContextFromStateValue<TStateSchema, TContext, TTestStateValue>, TEvent, TChildren, MatchingStateValue<TStateValue, TTestStateValue>, TTag, _TOutput, TMeta, TStateSchema>;
|
|
56
|
+
matches(partialStateValue: StateValue): boolean;
|
|
46
57
|
/**
|
|
47
58
|
* Whether the current state nodes has a state node with the specified `tag`.
|
|
48
59
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { 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, SystemRegistry, RegistryKeyForLogic, ActorOptions, Observer, Subscription, OutputArg } 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 } 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, Implementations, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, WithDefault } from "./types.v6.js";
|
|
7
|
+
import { ActionSchemas, DelayMapFromNames, GuardSchemas, InferChildren, InferActions, InferGuards, Implementations, InferOutput, InferEvents, Next_MachineConfig, Next_InvokeConfig, Next_StateNodeConfig, Next_TransitionConfigOrTarget, WithDefault } from "./types.v6.js";
|
|
8
8
|
export type SetupConfig<TSchemas extends SetupSchemas, TStates extends Record<string, SetupStateSchema>, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
|
|
9
9
|
schemas?: TSchemas & SetupSchemas;
|
|
10
10
|
states?: TStates;
|
|
@@ -80,6 +80,29 @@ type SetupOrConfigSchemaMap<TSchemas, TKey extends 'events' | 'emitted' | 'child
|
|
|
80
80
|
type SetupStateKeys<TStateSchemas extends Record<string, SetupStateSchema>> = keyof TStateSchemas & string;
|
|
81
81
|
type SetupStateKey<TStateSchemas extends Record<string, SetupStateSchema>> = string extends SetupStateKeys<TStateSchemas> ? string : [SetupStateKeys<TStateSchemas>] extends [never] ? string : SetupStateKeys<TStateSchemas>;
|
|
82
82
|
type SetupStateTarget<TStateSchemas extends Record<string, SetupStateSchema>> = string extends SetupStateKeys<TStateSchemas> ? string : [SetupStateKeys<TStateSchemas>] extends [never] ? string : SetupStateKeys<TStateSchemas> | `.${string}` | `#${string}`;
|
|
83
|
+
/**
|
|
84
|
+
* The sibling state schemas of a dotted path: the children of the path's
|
|
85
|
+
* parent. A bare transition target resolves relative to the parent, so the
|
|
86
|
+
* valid targets for a path's config are its siblings. For a dotless (top-level)
|
|
87
|
+
* path the siblings are the root states.
|
|
88
|
+
*/
|
|
89
|
+
type ResolveStateSiblings<TStates extends Record<string, SetupStateSchema>, TPath extends string> = TPath extends `${infer Head}.${infer Rest}` ? Head extends keyof TStates ? TStates[Head]['states'] extends Record<string, SetupStateSchema> ? ResolveStateSiblings<TStates[Head]['states'], Rest> : never : never : TStates;
|
|
90
|
+
/**
|
|
91
|
+
* Resolves a dotted state path (e.g. `'parent.child'`) into the leaf
|
|
92
|
+
* `SetupStateSchema` it addresses, or `never` if any segment is missing.
|
|
93
|
+
*/
|
|
94
|
+
type ResolveStatePath<TStates extends Record<string, SetupStateSchema>, TPath extends string> = TPath extends `${infer Head}.${infer Rest}` ? Head extends keyof TStates ? TStates[Head]['states'] extends Record<string, SetupStateSchema> ? ResolveStatePath<TStates[Head]['states'], Rest> : never : never : TPath extends keyof TStates ? TStates[TPath] : never;
|
|
95
|
+
/** Union of every addressable dotted path into a setup states tree */
|
|
96
|
+
type StatePathsInner<TStates extends Record<string, SetupStateSchema>> = {
|
|
97
|
+
[K in SetupStateKeys<TStates>]: K | (TStates[K]['states'] extends Record<string, SetupStateSchema> ? `${K}.${StatePathsInner<TStates[K]['states']>}` : never);
|
|
98
|
+
}[SetupStateKeys<TStates>];
|
|
99
|
+
type StatePaths<TStates extends Record<string, SetupStateSchema>> = string extends SetupStateKeys<TStates> ? string : [SetupStateKeys<TStates>] extends [never] ? string : StatePathsInner<TStates>;
|
|
100
|
+
/**
|
|
101
|
+
* Shared body of both `createStateConfig` overloads: the
|
|
102
|
+
* `StateNodeConfigWithNestedInput` instantiation whose only varying parts are
|
|
103
|
+
* the leading sibling-schemas and state-schema arguments.
|
|
104
|
+
*/
|
|
105
|
+
type SetupStateNodeConfig<TStates extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, TSchemas extends SetupSchemas, TSetupActionMap extends Implementations['actions'], TSetupActorMap extends Implementations['actorSources'], TSetupGuardMap extends Implementations['guards'], TSetupDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = StateNodeConfigWithNestedInput<TStates, TStateSchema, SetupContext<TSchemas, StandardSchemaV1>, SetupContextShape<TSchemas, StandardSchemaV1, SetupContext<TSchemas, StandardSchemaV1>>, SetupEvents<TSchemas, Record<string, StandardSchemaV1>>, Cast<SetupChildren<TSchemas, Record<string, StandardSchemaV1>>, Record<string, AnyActorRef | undefined>>, string, SetupTags<TSchemas, StandardSchemaV1>, SetupOutput<TSchemas, StandardSchemaV1>, SetupEmitted<TSchemas, Record<string, StandardSchemaV1>>, SetupMeta<TSchemas, StandardSchemaV1>, SetupActions<TSchemas, TSetupActionMap>, TSetupActorMap, SetupGuards<TSchemas, TSetupGuardMap>, TSetupDelayMap, TSystemRegistry>;
|
|
83
106
|
type InvalidSetupStateKeys<TConfig, TStateSchemas extends Record<string, SetupStateSchema>> = string extends SetupStateKeys<TStateSchemas> ? never : [SetupStateKeys<TStateSchemas>] extends [never] ? never : TConfig extends {
|
|
84
107
|
states: infer TStates;
|
|
85
108
|
} ? Exclude<keyof TStates & string, SetupStateKeys<TStateSchemas>> : never;
|
|
@@ -162,6 +185,7 @@ type WithNestedStates<TConfig, TNestedStates> = TConfig extends {
|
|
|
162
185
|
} ? TConfig : Omit<TConfig, 'states'> & {
|
|
163
186
|
states?: TNestedStates;
|
|
164
187
|
};
|
|
188
|
+
type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
|
|
165
189
|
/**
|
|
166
190
|
* Converts SetupStateSchema to StateSchema with input types included. This
|
|
167
191
|
* allows getInputs() to be strongly typed.
|
|
@@ -208,7 +232,7 @@ type MergeStateSchema<TConfig extends StateSchema, TSetup extends StateSchema> =
|
|
|
208
232
|
} : undefined : undefined;
|
|
209
233
|
};
|
|
210
234
|
/** Machine config with typed state input */
|
|
211
|
-
type SetupMachineConfig<TStateSchemas extends Record<string, SetupStateSchema>, TSchemas extends SetupSchemas, 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, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry, TContextRequired extends boolean, TRootDelays extends string = TDelays, TRootActionMap extends Implementations['actions'] = TActionMap, TRootActorMap extends Implementations['actorSources'] = TActorMap, TRootGuardMap extends Implementations['guards'] = TGuardMap> = Omit<Next_MachineConfig<SetupOrConfigSchema<TSchemas, 'context', TContextSchema>, SetupOrConfigSchemaMap<TSchemas, 'events', TEventSchemaMap>, SetupOrConfigSchemaMap<TSchemas, 'emitted', TEmittedSchemaMap>, SetupOrConfigSchema<TSchemas, 'input', TInputSchema>, SetupOrConfigSchema<TSchemas, 'output', TOutputSchema>, SetupOrConfigSchema<TSchemas, 'meta', TMetaSchema>, SetupOrConfigSchema<TSchemas, 'tags', TTagSchema>, SetupOrConfigSchemaMap<TSchemas, 'children', TChildrenSchemaMap>, TContext, TEvent, TChildren, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, TContextRequired, TSystemRegistry>, 'states' | 'initial' | 'on' | 'always' | 'actions' | 'actorSources' | 'guards' | 'delays'> & {
|
|
235
|
+
type SetupMachineConfig<TStateSchemas extends Record<string, SetupStateSchema>, TSchemas extends SetupSchemas, 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, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry, TContextRequired extends boolean, TRootDelays extends string = TDelays, TRootActionMap extends Implementations['actions'] = TActionMap, TRootActorMap extends Implementations['actorSources'] = TActorMap, TRootGuardMap extends Implementations['guards'] = TGuardMap> = Omit<Next_MachineConfig<SetupOrConfigSchema<TSchemas, 'context', TContextSchema>, SetupOrConfigSchemaMap<TSchemas, 'events', TEventSchemaMap>, SetupOrConfigSchemaMap<TSchemas, 'emitted', TEmittedSchemaMap>, SetupOrConfigSchema<TSchemas, 'input', TInputSchema>, SetupOrConfigSchema<TSchemas, 'output', TOutputSchema>, SetupOrConfigSchema<TSchemas, 'meta', TMetaSchema>, SetupOrConfigSchema<TSchemas, 'tags', TTagSchema>, SetupOrConfigSchemaMap<TSchemas, 'children', TChildrenSchemaMap>, TContext, TEvent, TChildren, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, TContextRequired, TSystemRegistry>, 'states' | 'initial' | 'on' | 'always' | 'invoke' | 'actions' | 'actorSources' | 'guards' | 'delays'> & {
|
|
212
236
|
actions?: TRootActionMap;
|
|
213
237
|
actorSources?: TRootActorMap;
|
|
214
238
|
guards?: TRootGuardMap;
|
|
@@ -222,6 +246,7 @@ type SetupMachineConfig<TStateSchemas extends Record<string, SetupStateSchema>,
|
|
|
222
246
|
initial?: SetupStateKey<TStateSchemas> | InitialTransitionWithInput<TStateSchemas, TContext, TEvent> | undefined;
|
|
223
247
|
on?: StateTransitions<TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
224
248
|
always?: StateTransitionConfigOrTarget<TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
249
|
+
invoke?: SingleOrArray<SetupInvokeConfig<TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>>;
|
|
225
250
|
states?: StatesWithInput<TStateSchemas, TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TChildren, TDelays, TTag, SetupOutput<TSchemas, TOutputSchema>, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
226
251
|
};
|
|
227
252
|
/** States config type that provides typed input for known states */
|
|
@@ -229,19 +254,30 @@ type StatesWithInput<TRootStateSchemas extends Record<string, SetupStateSchema>,
|
|
|
229
254
|
[K in keyof TStateSchemas & string]?: StateNodeConfigWithNestedInput<TRootStateSchemas, TStateSchemas[K], TContext, TContextShape, TEvent, TChildren, TDelays, TTag, TOutput, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
230
255
|
};
|
|
231
256
|
/** State node config that recursively applies typed input for nested states */
|
|
232
|
-
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 Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['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'> & {
|
|
257
|
+
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 Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['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'> & {
|
|
233
258
|
initial?: TStateSchema['states'] extends Record<string, SetupStateSchema> ? SetupStateKey<TStateSchema['states']> | InitialTransitionWithInput<TStateSchema['states'], StateContext<TStateSchema, TContext>, TEvent> : string | {
|
|
234
259
|
target: string;
|
|
235
260
|
input?: Record<string, unknown>;
|
|
236
261
|
} | undefined;
|
|
237
262
|
on?: StateTransitions<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
238
263
|
always?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
264
|
+
invoke?: SingleOrArray<SetupInvokeConfig<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>>;
|
|
265
|
+
onDone?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, StateContextShape<TStateSchema, TContextShape>, DoneStateEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
239
266
|
}, 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> : {
|
|
240
267
|
[K in string]?: Next_StateNodeConfig<TContext, TEvent, TDelays, TTag, TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, undefined, Record<string, unknown>, TSystemRegistry>;
|
|
241
268
|
}>;
|
|
242
269
|
type StateTransitions<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = {
|
|
243
270
|
[K in EventDescriptor<TEvent>]?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, ExtractEvent<TEvent, K>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
244
271
|
};
|
|
272
|
+
type InvokeDoneEvent<TInvoke> = TInvoke extends {
|
|
273
|
+
onDone?: Next_TransitionConfigOrTarget<infer _TContext, infer TDoneEvent, infer _TEvent, infer _TEmitted, infer _TActionMap, infer _TActorMap, infer _TGuardMap, infer _TDelayMap, infer _TMeta>;
|
|
274
|
+
} ? Cast<TDoneEvent, EventObject> : DoneActorEvent;
|
|
275
|
+
type SetupInvokeConfig<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = Next_InvokeConfig<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta, TSystemRegistry> extends infer TInvoke ? TInvoke extends any ? DistributiveOmit<TInvoke, 'onDone' | 'onError' | 'onSnapshot' | 'onTimeout'> & {
|
|
276
|
+
onDone?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, InvokeDoneEvent<TInvoke>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
277
|
+
onError?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, ErrorActorEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
278
|
+
onSnapshot?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, SnapshotEvent<any>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
279
|
+
onTimeout?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, TEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
280
|
+
} : never : never;
|
|
245
281
|
type StateTransitionConfigOrTarget<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = undefined | StateTransitionObjectConfig<TStateSchemas, TContext, TContextShape, TExpressionEvent, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry> | StateTransitionFunction<TStateSchemas, TContext, TContextShape, TExpressionEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
|
|
246
282
|
type StateTransitionObjectConfig<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = (StateTransitionResult<TStateSchemas, TContext, TContextShape, TMeta, TExpressionEvent, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry, true> & {
|
|
247
283
|
description?: string;
|
|
@@ -357,8 +393,14 @@ export interface SetupReturn<TStates extends Record<string, SetupStateSchema> =
|
|
|
357
393
|
}), Cast<MergeChildren<SetupChildren<TSchemas, TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, StateValue, TTag & string, [
|
|
358
394
|
SetupSchema<TSchemas, 'input'>
|
|
359
395
|
] extends [never] ? TInput : SetupInput<TSchemas, TInputSchema>, SetupOutput<TSchemas, TOutputSchema>, SetupEmitted<TSchemas, TEmittedSchemaMap>, SetupMeta<TSchemas, TMetaSchema>, MergeStateSchema<Cast<TConfig, StateSchema>, SetupStatesToStateSchema<TStates>>, MergeImplementationMaps<SetupActions<TSchemas, TSetupActionMap>, MergeImplementationMaps<InferActions<TActionSchemaMap>, TActionMap>>, MergeImplementationMaps<TSetupActorMap, TActorMap>, MergeImplementationMaps<SetupGuards<TSchemas, TSetupGuardMap>, MergeImplementationMaps<InferGuards<TGuardSchemaMap>, TGuardMap>>, DelayMapFromNames<TSetupDelays | TDelays, MergeImplementationMaps<TSetupDelayMap, TDelayMap>>>;
|
|
396
|
+
/**
|
|
397
|
+
* Creates a state node config bound to a specific setup-declared state,
|
|
398
|
+
* addressed by a dotted path (e.g. `'loading'` or `'parent.child'`). The
|
|
399
|
+
* addressed state's own `input` schema is typed inside `entry`/`exit` args.
|
|
400
|
+
*/
|
|
401
|
+
createStateConfig<const TPath extends StatePaths<TStates>, const TConfig extends SetupStateNodeConfig<ResolveStateSiblings<TStates, TPath>, ResolveStatePath<TStates, TPath>, TSchemas, TSetupActionMap, TSetupActorMap, TSetupGuardMap, TSetupDelayMap, TSystemRegistry>>(path: TPath, config: TConfig): TConfig;
|
|
360
402
|
/** Creates a state node config with the setup configuration */
|
|
361
|
-
createStateConfig<const TConfig extends
|
|
403
|
+
createStateConfig<const TConfig extends SetupStateNodeConfig<TStates, SetupStateSchema, TSchemas, TSetupActionMap, TSetupActorMap, TSetupGuardMap, TSetupDelayMap, TSystemRegistry>>(config: TConfig): TConfig;
|
|
362
404
|
/** State input schemas from setup config */
|
|
363
405
|
states: TStates;
|
|
364
406
|
}
|
|
@@ -209,6 +209,7 @@ export type TransitionConfigFunction<TContext extends MachineContext, TCurrentEv
|
|
|
209
209
|
context?: TransitionContextPatch<_TCtx>;
|
|
210
210
|
reenter?: boolean;
|
|
211
211
|
meta?: TMeta;
|
|
212
|
+
input?: Record<string, unknown>;
|
|
212
213
|
} | void;
|
|
213
214
|
type TransitionFunctionArgs<TContext, TCurrentEvent extends EventObject, TEvent extends EventObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
|
|
214
215
|
context: TContext;
|
|
@@ -385,7 +386,20 @@ export type PersistedHistoryValue = Record<string, Array<{
|
|
|
385
386
|
id: string;
|
|
386
387
|
}>>;
|
|
387
388
|
export type AnyHistoryValue = HistoryValue;
|
|
388
|
-
export type StateFrom<T extends AnyStateMachine | ((...args: any[]) => AnyStateMachine)> = T extends AnyStateMachine ?
|
|
389
|
+
export type StateFrom<T extends AnyStateMachine | ((...args: any[]) => AnyStateMachine)> = T extends AnyStateMachine ? StateSnapshotFromMachine<T> : T extends (...args: any[]) => AnyStateMachine ? StateSnapshotFromMachine<ReturnType<T>> : never;
|
|
390
|
+
type StateValueFromStateSchema<T extends StateSchema> = StateSchema extends T ? StateValue : ToStateValue<T> extends infer TStateValue ? TStateValue extends StateValue ? TStateValue : StateValue : StateValue;
|
|
391
|
+
type MatchingStateValueForStateFrom<TStateValue extends StateValue, TTestStateValue extends StateValue> = TStateValue extends unknown ? TTestStateValue extends string ? TStateValue extends string ? TTestStateValue extends TStateValue ? TTestStateValue : Extract<TStateValue, TTestStateValue> : TStateValue extends StateValueMap ? TStateValue & Record<TTestStateValue, StateValue | undefined> : never : TTestStateValue extends StateValueMap ? TStateValue extends StateValueMap ? MatchingStateValueMapForStateFrom<TStateValue, TTestStateValue> : never : never : never;
|
|
392
|
+
type MatchingStateValueMapForStateFrom<TStateValue extends StateValueMap, TTestStateValue extends StateValueMap> = false extends {
|
|
393
|
+
[K in keyof TTestStateValue & string]: K extends keyof TStateValue ? IsNever<MatchingStateValueForStateFrom<NonNullable<TStateValue[K]>, NonNullable<TTestStateValue[K]>>> extends true ? false : true : false;
|
|
394
|
+
}[keyof TTestStateValue & string] ? never : {
|
|
395
|
+
[K in keyof TStateValue]: K extends keyof TTestStateValue ? MatchingStateValueForStateFrom<NonNullable<TStateValue[K]>, NonNullable<TTestStateValue[K]>> : TStateValue[K];
|
|
396
|
+
};
|
|
397
|
+
type StateSnapshotFromStateValue<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TOutput, TMeta extends MetaObject, TStateSchema extends StateSchema, TAllStateValue extends StateValue = TStateValue> = TStateValue extends unknown ? Omit<MachineSnapshot<StateContextFromStateValue<TStateSchema, TContext, TStateValue>, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TStateSchema>, 'matches'> & {
|
|
398
|
+
matches<const TTestStateValue extends string>(partialStateValue: TTestStateValue, ...args: string extends TTestStateValue ? [never] : []): this is StateSnapshotFromStateValue<StateContextFromStateValue<TStateSchema, TContext, TTestStateValue>, TEvent, TChildren, MatchingStateValueForStateFrom<TAllStateValue, TTestStateValue>, TTag, TOutput, TMeta, TStateSchema, TAllStateValue>;
|
|
399
|
+
matches<const TTestStateValue extends StateValueMap>(partialStateValue: TTestStateValue, ...args: string extends keyof TTestStateValue ? [never] : []): this is StateSnapshotFromStateValue<StateContextFromStateValue<TStateSchema, TContext, TTestStateValue>, TEvent, TChildren, MatchingStateValueForStateFrom<TAllStateValue, TTestStateValue>, TTag, TOutput, TMeta, TStateSchema, TAllStateValue>;
|
|
400
|
+
matches(partialStateValue: StateValue): boolean;
|
|
401
|
+
} : never;
|
|
402
|
+
type StateSnapshotFromMachine<T extends AnyStateMachine> = SnapshotFrom<T> extends MachineSnapshot<infer TContext, infer TEvent, infer TChildren, infer _TStateValue, infer TTag, infer TOutput, infer TMeta, infer TStateSchema> ? StateSnapshotFromStateValue<TContext, TEvent, TChildren, StateValueFromStateSchema<TStateSchema>, TTag, TOutput, TMeta, TStateSchema, StateValueFromStateSchema<TStateSchema>> : SnapshotFrom<T>;
|
|
389
403
|
export interface DoneActorEvent<TOutput = unknown, TId extends string = string> extends EventObject {
|
|
390
404
|
type: `xstate.done.actor.${TId}`;
|
|
391
405
|
output: TOutput;
|
|
@@ -973,7 +987,9 @@ type _GroupStateKeys<T extends StateSchema, S extends keyof T['states']> = S ext
|
|
|
973
987
|
type: 'history';
|
|
974
988
|
} ? [never, never] : T extends {
|
|
975
989
|
type: 'parallel';
|
|
976
|
-
} ? [S, never] :
|
|
990
|
+
} ? [S, never] : T['states'][S] extends {
|
|
991
|
+
states: Record<string, StateSchema>;
|
|
992
|
+
} ? [S, never] : [never, S] : never;
|
|
977
993
|
type GroupStateKeys<T extends StateSchema, S extends keyof T['states']> = {
|
|
978
994
|
nonLeaf: _GroupStateKeys<T, S & string>[0];
|
|
979
995
|
leaf: _GroupStateKeys<T, S & string>[1];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./schema.types.js";
|
|
2
2
|
import { MachineSnapshot } from "./State.js";
|
|
3
|
-
import { Action, ActorLogic, ActorRef, ActorRefFromLogic, ActorSelf, AnyActorLogic, AnyActorRef, Compute, DoneActorEvent, DoNotInfer, EventDescriptor, EventObject, ExtractEvent, InitialContext, InputFrom, IsNever, MetaObject, NonReducibleUnknown, OutputFrom, SingleOrArray, SnapshotEvent, StateValue, TODO, TransitionContextMapper, TransitionContextPatch, TransitionConfigFunction, Values, AnyStateNode, SystemRegistry } from "./types.js";
|
|
3
|
+
import { Action, ActorLogic, ActorRef, ActorRefFromLogic, ActorSelf, AnyActorLogic, AnyActorRef, Compute, DoneActorEvent, DoNotInfer, ErrorActorEvent, EventDescriptor, EventObject, ExtractEvent, InitialContext, InputFrom, IsNever, MetaObject, NonReducibleUnknown, OutputFrom, SingleOrArray, SnapshotEvent, StateValue, TODO, TransitionContextMapper, TransitionContextPatch, TransitionConfigFunction, Values, AnyStateNode, SystemRegistry } from "./types.js";
|
|
4
4
|
import { MachineContext, Mapper } from "./types.js";
|
|
5
5
|
import { LowInfer } from "./types.js";
|
|
6
6
|
import { DoneStateEvent } from "./types.js";
|
|
@@ -195,7 +195,7 @@ interface Next_InvokeConfigBase<TContext extends MachineContext, TEvent extends
|
|
|
195
195
|
id?: string;
|
|
196
196
|
registryKey?: keyof TSystemRegistry & string;
|
|
197
197
|
onDone?: Next_TransitionConfigOrTarget<TContext, TDoneEvent, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>;
|
|
198
|
-
onError?: Next_TransitionConfigOrTarget<TContext,
|
|
198
|
+
onError?: Next_TransitionConfigOrTarget<TContext, ErrorActorEvent, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>;
|
|
199
199
|
onSnapshot?: Next_TransitionConfigOrTarget<TContext, SnapshotEvent<any>, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>;
|
|
200
200
|
/**
|
|
201
201
|
* The duration (in ms) after which this invocation will time out if it has
|
|
@@ -1730,12 +1730,11 @@ function getTransitionResult(transition, snapshot, event, actorScope, options) {
|
|
|
1730
1730
|
const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents, false, options?.resolveActions ?? true);
|
|
1731
1731
|
const res = transition.to(transitionArgs, enqueue);
|
|
1732
1732
|
const targets = res?.target ? resolveTarget(transition.source, toArray(res.target)) : undefined;
|
|
1733
|
-
|
|
1734
|
-
const resolvedInput = typeof transition.input === 'function' ? transition.input({
|
|
1733
|
+
const resolvedInput = res?.input ?? (typeof transition.input === 'function' ? transition.input({
|
|
1735
1734
|
context: snapshot.context,
|
|
1736
1735
|
event,
|
|
1737
1736
|
output: getEventOutput(event)
|
|
1738
|
-
}) : transition.input;
|
|
1737
|
+
}) : transition.input);
|
|
1739
1738
|
return {
|
|
1740
1739
|
targets: targets,
|
|
1741
1740
|
context: res?.context,
|
|
@@ -1719,12 +1719,11 @@ function getTransitionResult(transition, snapshot, event, actorScope, options) {
|
|
|
1719
1719
|
const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents, false, options?.resolveActions ?? true);
|
|
1720
1720
|
const res = transition.to(transitionArgs, enqueue);
|
|
1721
1721
|
const targets = res?.target ? resolveTarget(transition.source, toArray(res.target)) : undefined;
|
|
1722
|
-
|
|
1723
|
-
const resolvedInput = typeof transition.input === 'function' ? transition.input({
|
|
1722
|
+
const resolvedInput = res?.input ?? (typeof transition.input === 'function' ? transition.input({
|
|
1724
1723
|
context: snapshot.context,
|
|
1725
1724
|
event,
|
|
1726
1725
|
output: getEventOutput(event)
|
|
1727
|
-
}) : transition.input;
|
|
1726
|
+
}) : transition.input);
|
|
1728
1727
|
return {
|
|
1729
1728
|
targets: targets,
|
|
1730
1729
|
context: res?.context,
|
|
@@ -1717,12 +1717,11 @@ function getTransitionResult(transition, snapshot, event, actorScope, options) {
|
|
|
1717
1717
|
const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents, false, options?.resolveActions ?? true);
|
|
1718
1718
|
const res = transition.to(transitionArgs, enqueue);
|
|
1719
1719
|
const targets = res?.target ? resolveTarget(transition.source, toArray(res.target)) : undefined;
|
|
1720
|
-
|
|
1721
|
-
const resolvedInput = typeof transition.input === 'function' ? transition.input({
|
|
1720
|
+
const resolvedInput = res?.input ?? (typeof transition.input === 'function' ? transition.input({
|
|
1722
1721
|
context: snapshot.context,
|
|
1723
1722
|
event,
|
|
1724
1723
|
output: getEventOutput(event)
|
|
1725
|
-
}) : transition.input;
|
|
1724
|
+
}) : transition.input);
|
|
1726
1725
|
return {
|
|
1727
1726
|
targets: targets,
|
|
1728
1727
|
context: res?.context,
|
|
@@ -1728,12 +1728,11 @@ function getTransitionResult(transition, snapshot, event, actorScope, options) {
|
|
|
1728
1728
|
const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents, false, options?.resolveActions ?? true);
|
|
1729
1729
|
const res = transition.to(transitionArgs, enqueue);
|
|
1730
1730
|
const targets = res?.target ? resolveTarget(transition.source, toArray(res.target)) : undefined;
|
|
1731
|
-
|
|
1732
|
-
const resolvedInput = typeof transition.input === 'function' ? transition.input({
|
|
1731
|
+
const resolvedInput = res?.input ?? (typeof transition.input === 'function' ? transition.input({
|
|
1733
1732
|
context: snapshot.context,
|
|
1734
1733
|
event,
|
|
1735
1734
|
output: getEventOutput(event)
|
|
1736
|
-
}) : transition.input;
|
|
1735
|
+
}) : transition.input);
|
|
1737
1736
|
return {
|
|
1738
1737
|
targets: targets,
|
|
1739
1738
|
context: res?.context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { T as TimeoutError, B as createAsyncLogic, w as createCallbackLogic, v as createEmptyActor, y as createEventObservableLogic, C as createListenerLogic, z as createLogic, x as createObservableLogic, E as createSubscriptionLogic, D as listenerLogic, F as subscriptionLogic } from './index-
|
|
1
|
+
export { T as TimeoutError, B as createAsyncLogic, w as createCallbackLogic, v as createEmptyActor, y as createEventObservableLogic, C as createListenerLogic, z as createLogic, x as createObservableLogic, E as createSubscriptionLogic, D as listenerLogic, F as subscriptionLogic } from './index-362125ce.development.esm.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { T as TimeoutError, B as createAsyncLogic, w as createCallbackLogic, v as createEmptyActor, y as createEventObservableLogic, C as createListenerLogic, z as createLogic, x as createObservableLogic, E as createSubscriptionLogic, D as listenerLogic, F as subscriptionLogic } from './index-
|
|
1
|
+
export { T as TimeoutError, B as createAsyncLogic, w as createCallbackLogic, v as createEmptyActor, y as createEventObservableLogic, C as createListenerLogic, z as createLogic, x as createObservableLogic, E as createSubscriptionLogic, D as listenerLogic, F as subscriptionLogic } from './index-2635a437.esm.js';
|
package/dist/xstate-graph.cjs.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_xstateActors = require('./index-
|
|
6
|
-
var StateMachine = require('./StateMachine-
|
|
5
|
+
var dist_xstateActors = require('./index-0d940f2c.cjs.js');
|
|
6
|
+
var StateMachine = require('./StateMachine-e3b1aa2d.cjs.js');
|
|
7
7
|
|
|
8
8
|
function simpleStringify(value) {
|
|
9
9
|
return JSON.stringify(value);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_xstateActors = require('./index-
|
|
6
|
-
var StateMachine = require('./StateMachine-
|
|
5
|
+
var dist_xstateActors = require('./index-07b19ed0.development.cjs.js');
|
|
6
|
+
var StateMachine = require('./StateMachine-98411dc5.development.cjs.js');
|
|
7
7
|
|
|
8
8
|
function simpleStringify(value) {
|
|
9
9
|
return JSON.stringify(value);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as isMachineSnapshot, l as getAllOwnEventDescriptors, v as createEmptyActor, X as XSTATE_INIT } from './index-
|
|
2
|
-
import { S as StateMachine } from './StateMachine-
|
|
1
|
+
import { j as isMachineSnapshot, l as getAllOwnEventDescriptors, v as createEmptyActor, X as XSTATE_INIT } from './index-362125ce.development.esm.js';
|
|
2
|
+
import { S as StateMachine } from './StateMachine-0fa9c094.development.esm.js';
|
|
3
3
|
|
|
4
4
|
function simpleStringify(value) {
|
|
5
5
|
return JSON.stringify(value);
|
package/dist/xstate-graph.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as isMachineSnapshot, l as getAllOwnEventDescriptors, v as createEmptyActor, X as XSTATE_INIT } from './index-
|
|
2
|
-
import { S as StateMachine } from './StateMachine-
|
|
1
|
+
import { j as isMachineSnapshot, l as getAllOwnEventDescriptors, v as createEmptyActor, X as XSTATE_INIT } from './index-2635a437.esm.js';
|
|
2
|
+
import { S as StateMachine } from './StateMachine-8dbd20ad.esm.js';
|
|
3
3
|
|
|
4
4
|
function simpleStringify(value) {
|
|
5
5
|
return JSON.stringify(value);
|