xstate 6.0.0-alpha.3 → 6.0.0-alpha.4

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.
Files changed (42) hide show
  1. package/dist/{StateMachine-e1048cd6.cjs.js → StateMachine-445a8480.cjs.js} +15 -6
  2. package/dist/{StateMachine-e6ad61d0.development.esm.js → StateMachine-4deb4090.development.esm.js} +15 -6
  3. package/dist/{StateMachine-8249d511.esm.js → StateMachine-f310bc72.esm.js} +15 -6
  4. package/dist/{StateMachine-0770ac71.development.cjs.js → StateMachine-f83f01f9.development.cjs.js} +15 -6
  5. package/dist/declarations/src/StateMachine.d.ts +5 -4
  6. package/dist/declarations/src/actions.d.ts +1 -1
  7. package/dist/declarations/src/createActor.d.ts +3 -0
  8. package/dist/declarations/src/createMachine.d.ts +10 -7
  9. package/dist/declarations/src/graph/graph.d.ts +3 -3
  10. package/dist/declarations/src/graph/shortestPaths.d.ts +2 -2
  11. package/dist/declarations/src/graph/simplePaths.d.ts +2 -2
  12. package/dist/declarations/src/index.d.ts +1 -0
  13. package/dist/declarations/src/setup.d.ts +79 -33
  14. package/dist/declarations/src/transition.d.ts +8 -5
  15. package/dist/declarations/src/transitionActions.d.ts +4 -0
  16. package/dist/declarations/src/types.d.ts +69 -17
  17. package/dist/declarations/src/types.v6.d.ts +39 -21
  18. package/dist/{index-dda021d5.cjs.js → index-918ab496.cjs.js} +235 -127
  19. package/dist/{index-a7e3d8b3.esm.js → index-9cce3480.esm.js} +234 -127
  20. package/dist/{index-66ff64a6.development.esm.js → index-ccbe7c0b.development.esm.js} +234 -127
  21. package/dist/{index-269d256d.development.cjs.js → index-ebaf6fd8.development.cjs.js} +235 -127
  22. package/dist/xstate-actors.cjs.js +1 -1
  23. package/dist/xstate-actors.development.cjs.js +1 -1
  24. package/dist/xstate-actors.development.esm.js +1 -1
  25. package/dist/xstate-actors.esm.js +1 -1
  26. package/dist/xstate-actors.umd.min.js +1 -1
  27. package/dist/xstate-actors.umd.min.js.map +1 -1
  28. package/dist/xstate-graph.cjs.js +2 -2
  29. package/dist/xstate-graph.development.cjs.js +2 -2
  30. package/dist/xstate-graph.development.esm.js +2 -2
  31. package/dist/xstate-graph.esm.js +2 -2
  32. package/dist/xstate-graph.umd.min.js +1 -1
  33. package/dist/xstate-graph.umd.min.js.map +1 -1
  34. package/dist/xstate.cjs.js +67 -23
  35. package/dist/xstate.cjs.mjs +1 -0
  36. package/dist/xstate.development.cjs.js +67 -23
  37. package/dist/xstate.development.cjs.mjs +1 -0
  38. package/dist/xstate.development.esm.js +68 -25
  39. package/dist/xstate.esm.js +68 -25
  40. package/dist/xstate.umd.min.js +1 -1
  41. package/dist/xstate.umd.min.js.map +1 -1
  42. package/package.json +1 -1
@@ -1,7 +1,15 @@
1
1
  import { StandardSchemaV1 } from "./schema.types.js";
2
2
  import { StateMachine } from "./StateMachine.js";
3
- import { AnyActorRef, EventObject, AnyEventObject, EventDescriptor, ExtractEvent, MachineContext, ProvidedActor, RoutableStateId, StateSchema, StateValue, ToChildren, MetaObject, Cast } from "./types.js";
4
- import { DelayMapFromNames, Implementations, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, ValidateDelayReferences, WithDefault } from "./types.v6.js";
3
+ import { AnyActorRef, AnyStateNode, EventObject, AnyEventObject, EventDescriptor, ExtractEvent, MachineContext, ProvidedActor, RoutableStateId, StateSchema, StateValue, ToChildren, MetaObject, Cast, Compute } from "./types.js";
4
+ import { DelayMapFromNames, InferChildren, Implementations, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, WithDefault } from "./types.v6.js";
5
+ type SetupConfig<TSchemas extends SetupSchemas, TStates extends Record<string, SetupStateSchema>, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
6
+ schemas?: TSchemas;
7
+ states?: TStates;
8
+ actions?: TActionMap;
9
+ actors?: TActorMap;
10
+ guards?: TGuardMap;
11
+ delays?: TDelayMap;
12
+ };
5
13
  type SetupStateSchemas = {
6
14
  context?: StandardSchemaV1;
7
15
  input?: StandardSchemaV1;
@@ -14,6 +22,7 @@ type SetupSchemas = {
14
22
  output?: StandardSchemaV1;
15
23
  meta?: StandardSchemaV1;
16
24
  tags?: StandardSchemaV1;
25
+ children?: Record<string, StandardSchemaV1>;
17
26
  };
18
27
  /** State schema with optional schemas.input and nested states */
19
28
  interface SetupStateSchema {
@@ -21,9 +30,9 @@ interface SetupStateSchema {
21
30
  states?: Record<string, SetupStateSchema>;
22
31
  }
23
32
  type SetupSchema<TSchemas, TKey extends keyof SetupSchemas> = TKey extends keyof TSchemas ? TSchemas[TKey] extends StandardSchemaV1 ? TSchemas[TKey] : never : never;
24
- type SetupSchemaMap<TSchemas, TKey extends 'events' | 'emitted'> = TKey extends keyof TSchemas ? TSchemas[TKey] extends Record<string, StandardSchemaV1> ? TSchemas[TKey] : never : never;
33
+ type SetupSchemaMap<TSchemas, TKey extends 'events' | 'emitted' | 'children'> = TKey extends keyof TSchemas ? TSchemas[TKey] extends Record<string, StandardSchemaV1> ? TSchemas[TKey] : never : never;
25
34
  type SetupOrConfigSchema<TSchemas, TKey extends Exclude<keyof SetupSchemas, 'events' | 'emitted'>, TConfigSchema extends StandardSchemaV1> = [SetupSchema<TSchemas, TKey>] extends [never] ? TConfigSchema : SetupSchema<TSchemas, TKey>;
26
- type SetupOrConfigSchemaMap<TSchemas, TKey extends 'events' | 'emitted', TConfigSchemaMap extends Record<string, StandardSchemaV1>> = [SetupSchemaMap<TSchemas, TKey>] extends [never] ? TConfigSchemaMap : SetupSchemaMap<TSchemas, TKey>;
35
+ type SetupOrConfigSchemaMap<TSchemas, TKey extends 'events' | 'emitted' | 'children', TConfigSchemaMap extends Record<string, StandardSchemaV1>> = [SetupSchemaMap<TSchemas, TKey>] extends [never] ? TConfigSchemaMap : SetupSchemaMap<TSchemas, TKey>;
27
36
  type SetupStateKeys<TStateSchemas extends Record<string, SetupStateSchema>> = keyof TStateSchemas & string;
28
37
  type SetupStateKey<TStateSchemas extends Record<string, SetupStateSchema>> = string extends SetupStateKeys<TStateSchemas> ? string : [SetupStateKeys<TStateSchemas>] extends [never] ? string : SetupStateKeys<TStateSchemas>;
29
38
  type SetupStateTarget<TStateSchemas extends Record<string, SetupStateSchema>> = string extends SetupStateKeys<TStateSchemas> ? string : [SetupStateKeys<TStateSchemas>] extends [never] ? string : SetupStateKeys<TStateSchemas> | `.${string}` | `#${string}`;
@@ -64,6 +73,29 @@ type SetupEmitted<TSchemas, TEmittedSchemaMap extends Record<string, StandardSch
64
73
  type SetupMeta<TSchemas, TMetaSchema extends StandardSchemaV1> = [
65
74
  SetupSchema<TSchemas, 'meta'>
66
75
  ] extends [never] ? InferOutput<TMetaSchema, MetaObject> : InferOutput<SetupSchema<TSchemas, 'meta'>, MetaObject>;
76
+ type SetupChildren<TSchemas, TChildrenSchemaMap extends Record<string, StandardSchemaV1>> = [SetupSchemaMap<TSchemas, 'children'>] extends [never] ? InferChildren<TChildrenSchemaMap> : InferChildren<SetupSchemaMap<TSchemas, 'children'>>;
77
+ type MergeChildren<TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor> = [keyof TChildren] extends [never] ? Compute<ToChildren<TActor>> : Compute<TChildren>;
78
+ type MergeImplementationMaps<TBase extends Record<string, unknown>, TExtension extends Record<string, unknown>> = Compute<TBase & TExtension>;
79
+ type DelayNamesFromConfigOrString<TConfig> = TConfig extends {
80
+ delays: infer TDelays;
81
+ } ? Extract<keyof TDelays, string> : string;
82
+ type DelayNamesFromConfig<TConfig> = TConfig extends {
83
+ delays: infer TDelays;
84
+ } ? Extract<keyof TDelays, string> : never;
85
+ type InvalidDelayReferences<TConfig, TDelays extends string> = (TConfig extends {
86
+ after: infer TAfter;
87
+ } ? Exclude<Extract<keyof TAfter, string>, TDelays> : never) | (TConfig extends {
88
+ timeout: infer TTimeout;
89
+ } ? TTimeout extends string ? TTimeout extends TDelays ? never : TTimeout : never : never) | (TConfig extends {
90
+ states: infer TStates;
91
+ } ? TStates extends Record<string, unknown> ? {
92
+ [K in keyof TStates]: InvalidDelayReferences<TStates[K], TDelays>;
93
+ }[keyof TStates] : never : never);
94
+ type ValidateSetupDelayReferences<TConfig, TSetupDelays extends string> = string extends ([
95
+ TSetupDelays
96
+ ] extends [never] ? DelayNamesFromConfigOrString<TConfig> : TSetupDelays | DelayNamesFromConfig<TConfig>) ? unknown : InvalidDelayReferences<TConfig, [
97
+ TSetupDelays
98
+ ] extends [never] ? DelayNamesFromConfigOrString<TConfig> : TSetupDelays | DelayNamesFromConfig<TConfig>> extends never ? unknown : never;
67
99
  /** Extracts input type from a state schema */
68
100
  type StateInput<TStateSchema extends SetupStateSchema> = TStateSchema['schemas'] extends {
69
101
  input: infer TInputSchema;
@@ -122,29 +154,39 @@ type MergeStateSchema<TConfig extends StateSchema, TSetup extends StateSchema> =
122
154
  } : undefined : undefined;
123
155
  };
124
156
  /** Machine config with typed state input */
125
- 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, TContext extends MachineContext, TEvent extends EventObject, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TContextRequired extends boolean> = 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>, TContext, TEvent, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, TContextRequired>, 'states' | 'initial'> & {
157
+ 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['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TContextRequired extends boolean, TRootDelays extends string = TDelays, TRootActionMap extends Implementations['actions'] = TActionMap, TRootActorMap extends Implementations['actors'] = 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>, 'states' | 'initial' | 'actions' | 'actors' | 'guards' | 'delays'> & {
158
+ actions?: TRootActionMap;
159
+ actors?: TRootActorMap;
160
+ guards?: TRootGuardMap;
161
+ delays?: {
162
+ [K in TRootDelays | number]?: number | (({ context, event, stateNode }: {
163
+ context: TContext;
164
+ event: TEvent;
165
+ stateNode: AnyStateNode;
166
+ }) => number);
167
+ };
126
168
  initial?: SetupStateKey<TStateSchemas> | InitialTransitionWithInput<TStateSchemas, TContext, TEvent> | undefined;
127
- states?: StatesWithInput<TStateSchemas, TStateSchemas, TContext, TEvent, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
169
+ states?: StatesWithInput<TStateSchemas, TStateSchemas, TContext, TEvent, TChildren, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
128
170
  };
129
171
  /** States config type that provides typed input for known states */
130
- type StatesWithInput<TRootStateSchemas extends Record<string, SetupStateSchema>, TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TEvent extends EventObject, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
131
- [K in keyof TStateSchemas & string]?: StateNodeConfigWithNestedInput<TRootStateSchemas, TStateSchemas[K], TContext, TEvent, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
172
+ type StatesWithInput<TRootStateSchemas extends Record<string, SetupStateSchema>, TStateSchemas extends Record<string, SetupStateSchema>, 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['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
173
+ [K in keyof TStateSchemas & string]?: StateNodeConfigWithNestedInput<TRootStateSchemas, TStateSchemas[K], TContext, TEvent, TChildren, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
132
174
  };
133
175
  /** State node config that recursively applies typed input for nested states */
134
- type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, TContext extends MachineContext, TEvent extends EventObject, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = WithNestedStates<Omit<Next_StateNodeConfig<StateContext<TStateSchema, TContext>, TEvent, TDelays, TTag, any, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, StateInput<TStateSchema>>, 'on' | 'always' | 'initial'> & {
176
+ type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, 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['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = WithNestedStates<Omit<Next_StateNodeConfig<StateContext<TStateSchema, TContext>, TEvent, TDelays, TTag, any, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, StateInput<TStateSchema>>, 'on' | 'always' | 'initial'> & {
135
177
  initial?: TStateSchema['states'] extends Record<string, SetupStateSchema> ? SetupStateKey<TStateSchema['states']> | InitialTransitionWithInput<TStateSchema['states'], StateContext<TStateSchema, TContext>, TEvent> : string | {
136
178
  target: string;
137
179
  input?: Record<string, unknown>;
138
180
  } | undefined;
139
- on?: StateTransitions<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, TEvent, TEmitted, TMeta>;
140
- always?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, TEvent, TEvent, TEmitted, TMeta>;
141
- }, TStateSchema['states'] extends Record<string, SetupStateSchema> ? StatesWithInput<TStateSchema['states'], TStateSchema['states'], TContext, TEvent, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap> : {
142
- [K in string]?: Next_StateNodeConfig<TContext, TEvent, TDelays, TTag, any, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, undefined>;
181
+ on?: StateTransitions<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
182
+ always?: StateTransitionConfigOrTarget<TSiblingStateSchemas, StateContext<TStateSchema, TContext>, TEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
183
+ }, TStateSchema['states'] extends Record<string, SetupStateSchema> ? StatesWithInput<TStateSchema['states'], TStateSchema['states'], TContext, TEvent, TChildren, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap> : {
184
+ [K in string]?: Next_StateNodeConfig<TContext, TEvent, TDelays, TTag, any, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, undefined>;
143
185
  }>;
144
- type StateTransitions<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TMeta extends MetaObject> = {
145
- [K in EventDescriptor<TEvent>]?: StateTransitionConfigOrTarget<TStateSchemas, TContext, ExtractEvent<TEvent, K>, TEvent, TEmitted, TMeta>;
186
+ type StateTransitions<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
187
+ [K in EventDescriptor<TEvent>]?: StateTransitionConfigOrTarget<TStateSchemas, TContext, ExtractEvent<TEvent, K>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
146
188
  };
147
- type StateTransitionConfigOrTarget<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TMeta extends MetaObject> = SetupStateTarget<TStateSchemas> | undefined | {
189
+ type StateTransitionConfigOrTarget<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, 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['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = SetupStateTarget<TStateSchemas> | undefined | {
148
190
  target?: SetupStateTarget<TStateSchemas> | SetupStateTarget<TStateSchemas>[];
149
191
  description?: string;
150
192
  reenter?: boolean;
@@ -153,18 +195,18 @@ type StateTransitionConfigOrTarget<TStateSchemas extends Record<string, SetupSta
153
195
  context: TContext;
154
196
  event: TExpressionEvent;
155
197
  }) => Record<string, unknown>);
156
- } | StateTransitionFunction<TStateSchemas, TContext, TExpressionEvent, TEvent, TEmitted, TMeta>;
157
- type StateTransitionFunction<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TExpressionEvent extends EventObject, _TEvent extends EventObject, _TEmitted extends EventObject, TMeta extends MetaObject> = (args: {
198
+ } | StateTransitionFunction<TStateSchemas, TContext, TExpressionEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
199
+ type StateTransitionFunction<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, 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['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = (args: {
158
200
  context: TContext;
159
201
  event: TExpressionEvent;
160
202
  self: AnyActorRef;
161
203
  parent: AnyActorRef | undefined;
162
204
  value: StateValue;
163
- children: Record<string, AnyActorRef>;
164
- actions: Implementations['actions'];
165
- actors: Implementations['actors'];
166
- guards: Implementations['guards'];
167
- delays: Implementations['delays'];
205
+ children: TChildren;
206
+ actions: TActionMap;
207
+ actors: TActorMap;
208
+ guards: TGuardMap;
209
+ delays: TDelayMap;
168
210
  }, enq: any) => StateTransitionResult<TStateSchemas, TContext, TMeta> | void;
169
211
  type StateTransitionResult<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TMeta extends MetaObject> = {
170
212
  target?: never;
@@ -194,9 +236,11 @@ type InitialTransitionWithInput<TStateSchemas extends Record<string, SetupStateS
194
236
  };
195
237
  }[keyof TStateSchemas & string];
196
238
  /** Return type of setup() */
197
- interface SetupReturn<TStates extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>, TSchemas extends SetupSchemas = {}> {
239
+ interface SetupReturn<TStates extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>, TSchemas extends SetupSchemas = {}, TSetupActionMap extends Implementations['actions'] = {}, TSetupActorMap extends Implementations['actors'] = {}, TSetupGuardMap extends Implementations['guards'] = {}, TSetupDelayMap extends Implementations['delays'] = {}, TSetupDelays extends string = Extract<keyof TSetupDelayMap, string>> {
240
+ /** Extends the setup configuration */
241
+ extend<const TExtendSchemas extends SetupSchemas = {}, const TExtendStates extends Record<string, SetupStateSchema> = {}, TExtendActionMap extends Implementations['actions'] = {}, TExtendActorMap extends Implementations['actors'] = {}, TExtendGuardMap extends Implementations['guards'] = {}, TExtendDelayMap extends Implementations['delays'] = {}>(config: SetupConfig<TExtendSchemas, TExtendStates, TExtendActionMap, TExtendActorMap, TExtendGuardMap, TExtendDelayMap>): SetupReturn<MergeImplementationMaps<TStates, TExtendStates>, MergeImplementationMaps<TSchemas, TExtendSchemas>, MergeImplementationMaps<TSetupActionMap, TExtendActionMap>, MergeImplementationMaps<TSetupActorMap, TExtendActorMap>, MergeImplementationMaps<TSetupGuardMap, TExtendGuardMap>, MergeImplementationMaps<TSetupDelayMap, TExtendDelayMap>, TSetupDelays | Extract<keyof TExtendDelayMap, string>>;
198
242
  /** Creates a state machine with the setup configuration */
199
- createMachine<TContextSchema extends StandardSchemaV1, const TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, _TEvent extends EventObject, TActor extends ProvidedActor, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TDelays extends string, TTag extends SetupTags<TSchemas, TTagSchema>, TInput, TConfig extends SetupMachineConfig<TStates, TSchemas, TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, SetupContext<TSchemas, TContextSchema>, SetupEvents<TSchemas, TEventSchemaMap>, TDelays, TTag, SetupEmitted<TSchemas, TEmittedSchemaMap>, SetupMeta<TSchemas, TMetaSchema>, TActionMap, TActorMap, TGuardMap, TDelayMap, SetupContextRequired<TSchemas, TContextSchema>>>(config: TConfig & ValidateSetupStateKeys<TConfig, TStates> & ValidateNestedSetupStateKeys<TConfig, TStates> & ValidateDelayReferences<TConfig> & {
243
+ createMachine<TContextSchema extends StandardSchemaV1 = StandardSchemaV1, const TEventSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1 = StandardSchemaV1, 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 Implementations['actions'] = {}, TActorMap extends Implementations['actors'] = {}, TGuardMap extends Implementations['guards'] = {}, TDelayMap extends Implementations['delays'] = {}, TDelays extends string = Extract<keyof TDelayMap, string>, TTag extends SetupTags<TSchemas, TTagSchema> = SetupTags<TSchemas, TTagSchema>, TInput = unknown, TConfig extends SetupMachineConfig<TStates, TSchemas, TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, SetupContext<TSchemas, TContextSchema>, SetupEvents<TSchemas, TEventSchemaMap>, Cast<MergeChildren<SetupChildren<TSchemas, TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TSetupDelays | TDelays, TTag, SetupEmitted<TSchemas, TEmittedSchemaMap>, SetupMeta<TSchemas, TMetaSchema>, MergeImplementationMaps<TSetupActionMap, TActionMap>, MergeImplementationMaps<TSetupActorMap, TActorMap>, MergeImplementationMaps<TSetupGuardMap, TGuardMap>, MergeImplementationMaps<TSetupDelayMap, TDelayMap>, SetupContextRequired<TSchemas, TContextSchema>, TDelays, TActionMap, TActorMap, TGuardMap> = SetupMachineConfig<TStates, TSchemas, TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, SetupContext<TSchemas, TContextSchema>, SetupEvents<TSchemas, TEventSchemaMap>, Cast<MergeChildren<SetupChildren<TSchemas, TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TSetupDelays | TDelays, TTag, SetupEmitted<TSchemas, TEmittedSchemaMap>, SetupMeta<TSchemas, TMetaSchema>, MergeImplementationMaps<TSetupActionMap, TActionMap>, MergeImplementationMaps<TSetupActorMap, TActorMap>, MergeImplementationMaps<TSetupGuardMap, TGuardMap>, MergeImplementationMaps<TSetupDelayMap, TDelayMap>, SetupContextRequired<TSchemas, TContextSchema>, TDelays, TActionMap, TActorMap, TGuardMap>>(config: {
200
244
  schemas?: {
201
245
  events?: TEventSchemaMap;
202
246
  context?: TContextSchema;
@@ -205,15 +249,20 @@ interface SetupReturn<TStates extends Record<string, SetupStateSchema> = Record<
205
249
  output?: TOutputSchema;
206
250
  meta?: TMetaSchema;
207
251
  tags?: TTagSchema;
252
+ children?: TChildrenSchemaMap;
208
253
  };
209
- }): StateMachine<SetupContext<TSchemas, TContextSchema>, SetupEvents<TSchemas, TEventSchemaMap> | ([RoutableStateId<Cast<TConfig, StateSchema>>] extends [never] ? never : {
254
+ actions?: TActionMap;
255
+ actors?: TActorMap;
256
+ guards?: TGuardMap;
257
+ delays?: TDelayMap;
258
+ } & TConfig & ValidateSetupStateKeys<TConfig, TStates> & ValidateNestedSetupStateKeys<TConfig, TStates> & ValidateSetupDelayReferences<TConfig, TSetupDelays>): StateMachine<SetupContext<TSchemas, TContextSchema>, SetupEvents<TSchemas, TEventSchemaMap> | ([RoutableStateId<Cast<TConfig, StateSchema>>] extends [never] ? never : {
210
259
  type: 'xstate.route';
211
260
  to: RoutableStateId<Cast<TConfig, StateSchema>>;
212
- }), Cast<ToChildren<TActor>, Record<string, AnyActorRef | undefined>>, StateValue, TTag & string, [
261
+ }), Cast<MergeChildren<SetupChildren<TSchemas, TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, StateValue, TTag & string, [
213
262
  SetupSchema<TSchemas, 'input'>
214
- ] extends [never] ? TInput : SetupInput<TSchemas, TInputSchema>, SetupOutput<TSchemas, TOutputSchema>, SetupEmitted<TSchemas, TEmittedSchemaMap>, SetupMeta<TSchemas, TMetaSchema>, MergeStateSchema<Cast<TConfig, StateSchema>, SetupStatesToStateSchema<TStates>>, TActionMap, TActorMap, TGuardMap, DelayMapFromNames<TDelays, TDelayMap>>;
263
+ ] extends [never] ? TInput : SetupInput<TSchemas, TInputSchema>, SetupOutput<TSchemas, TOutputSchema>, SetupEmitted<TSchemas, TEmittedSchemaMap>, SetupMeta<TSchemas, TMetaSchema>, MergeStateSchema<Cast<TConfig, StateSchema>, SetupStatesToStateSchema<TStates>>, MergeImplementationMaps<TSetupActionMap, TActionMap>, MergeImplementationMaps<TSetupActorMap, TActorMap>, MergeImplementationMaps<TSetupGuardMap, TGuardMap>, DelayMapFromNames<TSetupDelays | TDelays, MergeImplementationMaps<TSetupDelayMap, TDelayMap>>>;
215
264
  /** Creates a state node config with the setup configuration */
216
- createStateConfig<const TConfig extends StateNodeConfigWithNestedInput<TStates, SetupStateSchema, SetupContext<TSchemas, StandardSchemaV1>, SetupEvents<TSchemas, Record<string, StandardSchemaV1>>, string, SetupTags<TSchemas, StandardSchemaV1>, SetupEmitted<TSchemas, Record<string, StandardSchemaV1>>, SetupMeta<TSchemas, StandardSchemaV1>, Implementations['actions'], Implementations['actors'], Implementations['guards'], Implementations['delays']>>(config: TConfig): TConfig;
265
+ createStateConfig<const TConfig extends StateNodeConfigWithNestedInput<TStates, SetupStateSchema, SetupContext<TSchemas, StandardSchemaV1>, SetupEvents<TSchemas, Record<string, StandardSchemaV1>>, Cast<SetupChildren<TSchemas, Record<string, StandardSchemaV1>>, Record<string, AnyActorRef | undefined>>, string, SetupTags<TSchemas, StandardSchemaV1>, SetupEmitted<TSchemas, Record<string, StandardSchemaV1>>, SetupMeta<TSchemas, StandardSchemaV1>, TSetupActionMap, TSetupActorMap, TSetupGuardMap, TSetupDelayMap>>(config: TConfig): TConfig;
217
266
  /** State input schemas from setup config */
218
267
  states: TStates;
219
268
  }
@@ -253,8 +302,5 @@ interface SetupReturn<TStates extends Record<string, SetupStateSchema> = Record<
253
302
  * });
254
303
  * ```
255
304
  */
256
- export declare function setup<const TSchemas extends SetupSchemas = {}, const TStates extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>>(config?: {
257
- schemas?: TSchemas;
258
- states?: TStates;
259
- }): SetupReturn<TStates, TSchemas>;
305
+ export declare function setup<const TSchemas extends SetupSchemas = {}, const TStates extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>, TActionMap extends Implementations['actions'] = {}, TActorMap extends Implementations['actors'] = {}, TGuardMap extends Implementations['guards'] = {}, TDelayMap extends Implementations['delays'] = {}>(config?: SetupConfig<TSchemas, TStates, TActionMap, TActorMap, TGuardMap, TDelayMap>): SetupReturn<TStates, TSchemas, TActionMap, TActorMap, TGuardMap, TDelayMap>;
260
306
  export {};
@@ -1,11 +1,14 @@
1
- import { AnyActorLogic, AnyStateMachine, EventFromLogic, InputFrom, SnapshotFrom, ExecutableActionObject, AnyTransitionDefinition, AnyMachineSnapshot } from "./types.js";
1
+ import { AnyActorLogic, AnyStateMachine, EventFromLogic, InputFrom, SnapshotFrom, ExecutableActionObjectFromLogic, AnyTransitionDefinition, AnyMachineSnapshot } from "./types.js";
2
2
  /**
3
3
  * Given actor `logic`, a `snapshot`, and an `event`, returns a tuple of the
4
4
  * `nextSnapshot` and `actions` to execute.
5
5
  *
6
6
  * This is a pure function that does not execute `actions`.
7
7
  */
8
- export declare function transition<T extends AnyActorLogic>(logic: T, snapshot: SnapshotFrom<T>, event: EventFromLogic<T>): [nextSnapshot: SnapshotFrom<T>, actions: ExecutableActionObject[]];
8
+ export declare function transition<T extends AnyActorLogic>(logic: T, snapshot: SnapshotFrom<T>, event: EventFromLogic<T>): [
9
+ nextSnapshot: SnapshotFrom<T>,
10
+ actions: ExecutableActionObjectFromLogic<T>[]
11
+ ];
9
12
  /**
10
13
  * Given actor `logic` and optional `input`, returns a tuple of the
11
14
  * `nextSnapshot` and `actions` to execute from the initial transition (no
@@ -13,14 +16,14 @@ export declare function transition<T extends AnyActorLogic>(logic: T, snapshot:
13
16
  *
14
17
  * This is a pure function that does not execute `actions`.
15
18
  */
16
- export declare function initialTransition<T extends AnyActorLogic>(logic: T, ...[input]: undefined extends InputFrom<T> ? [input?: InputFrom<T>] : [input: InputFrom<T>]): [SnapshotFrom<T>, ExecutableActionObject[]];
19
+ export declare function initialTransition<T extends AnyActorLogic>(logic: T, ...[input]: undefined extends InputFrom<T> ? [input?: InputFrom<T>] : [input: InputFrom<T>]): [SnapshotFrom<T>, ExecutableActionObjectFromLogic<T>[]];
17
20
  /**
18
21
  * Given a state `machine`, a `snapshot`, and an `event`, returns an array of
19
22
  * microsteps, where each microstep is a tuple of `[snapshot, actions]`.
20
23
  *
21
24
  * This is a pure function that does not execute `actions`.
22
25
  */
23
- export declare function getMicrosteps<T extends AnyStateMachine>(machine: T, snapshot: SnapshotFrom<T>, event: EventFromLogic<T>): Array<[SnapshotFrom<T>, ExecutableActionObject[]]>;
26
+ export declare function getMicrosteps<T extends AnyStateMachine>(machine: T, snapshot: SnapshotFrom<T>, event: EventFromLogic<T>): Array<[SnapshotFrom<T>, ExecutableActionObjectFromLogic<T>[]]>;
24
27
  /**
25
28
  * Given a state `machine` and optional `input`, returns an array of microsteps
26
29
  * from the initial transition, where each microstep is a tuple of `[snapshot,
@@ -28,7 +31,7 @@ export declare function getMicrosteps<T extends AnyStateMachine>(machine: T, sna
28
31
  *
29
32
  * This is a pure function that does not execute `actions`.
30
33
  */
31
- export declare function getInitialMicrosteps<T extends AnyStateMachine>(machine: T, ...[input]: undefined extends InputFrom<T> ? [input?: InputFrom<T>] : [input: InputFrom<T>]): Array<[SnapshotFrom<T>, ExecutableActionObject[]]>;
34
+ export declare function getInitialMicrosteps<T extends AnyStateMachine>(machine: T, ...[input]: undefined extends InputFrom<T> ? [input?: InputFrom<T>] : [input: InputFrom<T>]): Array<[SnapshotFrom<T>, ExecutableActionObjectFromLogic<T>[]]>;
32
35
  /**
33
36
  * Gets all potential next transitions from the current state.
34
37
  *
@@ -0,0 +1,4 @@
1
+ import type { AnyAction, AnyActorScope, AnyEventObject, AnyMachineSnapshot, EnqueueObject, EventObject, ExecutableActionObject, SpecialExecutableAction } from "./types.js";
2
+ export declare function createTransitionEnqueue(actorScope: AnyActorScope, actions: any[], internalEvents: EventObject[], actorSubscriptions?: boolean): EnqueueObject<any, any>;
3
+ export declare function isBuiltInExecutableAction(action: ExecutableActionObject): action is SpecialExecutableAction;
4
+ export declare function resolveActionsWithContext(currentSnapshot: AnyMachineSnapshot, event: AnyEventObject, actorScope: AnyActorScope, actions: AnyAction[]): [AnyMachineSnapshot, ExecutableActionObject[]];
@@ -205,7 +205,7 @@ export type TransitionConfigFunction<TContext extends MachineContext, TCurrentEv
205
205
  reenter?: boolean;
206
206
  meta?: TMeta;
207
207
  } | void;
208
- export type AnyTransitionConfigFunction = TransitionConfigFunction<any, any, any, any, any, any, any, any, any>;
208
+ export type AnyTransitionConfigFunction = TransitionConfigFunction<any, any, any, any, any, any, any, any, any, any>;
209
209
  export type TransitionsConfig<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
210
210
  [K in EventDescriptor<TEvent>]?: TransitionConfigOrTarget<TContext, ExtractEvent<TEvent, K>, TEvent, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
211
211
  };
@@ -306,7 +306,7 @@ export type InvokeConfig<TContext extends MachineContext, TEvent extends EventOb
306
306
  onTimeout?: string | SingleOrArray<TransitionConfigOrTarget<TContext, TEvent, TEvent, TEmitted, TMeta, any, any, any, any>>;
307
307
  };
308
308
  export type AnyInvokeConfig = InvokeConfig<any, any, any, any, any, any, any, any>;
309
- export type AnyStateNodeConfig = Next_StateNodeConfig<any, any, any, any, any, any, any, any, any, any, any>;
309
+ export type AnyStateNodeConfig = Next_StateNodeConfig<any, any, any, any, any, any, any, any, any, any, any, any>;
310
310
  export type AnyStateNode = StateNode<any, any> | StateNode<never, EventObject> | StateNode<any, EventObject> | StateNode<never, any>;
311
311
  export type AnyMachineSnapshot = MachineSnapshot<any, any, any, any, any, any, any, any>;
312
312
  export type AnyStateMachine = StateMachine<any, // context
@@ -367,7 +367,7 @@ export type PersistedHistoryValue = Record<string, Array<{
367
367
  id: string;
368
368
  }>>;
369
369
  export type AnyHistoryValue = HistoryValue;
370
- export type StateFrom<T extends AnyStateMachine | ((...args: any[]) => AnyStateMachine)> = T extends AnyStateMachine ? ReturnType<T['transition']> : T extends (...args: any[]) => AnyStateMachine ? ReturnType<ReturnType<T>['transition']> : never;
370
+ export type StateFrom<T extends AnyStateMachine | ((...args: any[]) => AnyStateMachine)> = T extends AnyStateMachine ? SnapshotFrom<T> : T extends (...args: any[]) => AnyStateMachine ? SnapshotFrom<ReturnType<T>> : never;
371
371
  export interface DoneActorEvent<TOutput = unknown, TId extends string = string> extends EventObject {
372
372
  type: `xstate.done.actor.${TId}`;
373
373
  output: TOutput;
@@ -717,7 +717,8 @@ export type ActorRefFrom<T> = T extends StateMachine<infer TContext, infer TEven
717
717
  export type SendableEventFromLogic<TLogic extends AnyActorLogic> = TLogic extends StateMachine<infer _TContext, infer TEvent, infer _TChildren, infer _TStateValue, infer _TTag, infer _TInput, infer _TOutput, infer _TEmitted, infer _TMeta, infer TConfig, infer _TActionMap, infer _TActorMap, infer _TGuardMap, infer _TDelayMap> ? TConfig extends {
718
718
  internalEvents?: readonly EventDescriptor<TEvent>[];
719
719
  } ? ExcludeInternalEvents<TEvent, TConfig['internalEvents'] extends readonly EventDescriptor<TEvent>[] ? TConfig['internalEvents'] extends readonly (infer TDesc)[] ? Extract<TDesc, string> : never : never> : TEvent : EventFromLogic<TLogic>;
720
- export type ActorRefFromLogic<T extends AnyActorLogic> = ActorRef<SnapshotFrom<T>, EventFromLogic<T>, EmittedFrom<T>, SendableEventFromLogic<T>>;
720
+ type OpaqueMachineSnapshot<TSnapshot extends Snapshot<unknown>> = TSnapshot extends MachineSnapshot<infer TContext, infer TEvent, infer TChildren, infer TStateValue, infer TTag, infer TOutput, infer TMeta, infer _TStateSchema> ? MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, any> : TSnapshot;
721
+ export type ActorRefFromLogic<T extends AnyActorLogic> = ActorRef<OpaqueMachineSnapshot<SnapshotFrom<T>>, EventFromLogic<T>, EmittedFrom<T>, SendableEventFromLogic<T>>;
721
722
  export type AnyActorRef = ActorRef<any, any, any, any>;
722
723
  /** The concrete actor instance type produced from actor logic. */
723
724
  export type ActorFromLogic<T extends AnyActorLogic> = ActorInstance<SnapshotFrom<T>, EventFromLogic<T>, EmittedFrom<T>, SendableEventFromLogic<T>>;
@@ -766,6 +767,7 @@ export type Snapshot<TOutput> = {
766
767
  output: undefined;
767
768
  error: undefined;
768
769
  };
770
+ export type ActorLogicTransitionResult<TSnapshot extends Snapshot<unknown>, TEffect = unknown> = [nextSnapshot: TSnapshot, effects: TEffect[]];
769
771
  /**
770
772
  * Represents logic which can be used by an actor.
771
773
  *
@@ -781,14 +783,22 @@ in TInput = NonReducibleUnknown, TSystem extends AnyActorSystem = AnyActorSystem
781
783
  config?: unknown;
782
784
  /**
783
785
  * Transition function that processes the current state and an incoming event
784
- * to produce a new state.
786
+ * to produce a new state and effects.
785
787
  *
786
788
  * @param snapshot - The current state.
787
789
  * @param event - The incoming event.
788
790
  * @param actorScope - The actor scope.
789
- * @returns The new state.
791
+ * @returns A tuple of the next state and effects.
790
792
  */
791
- transition: (snapshot: TSnapshot, event: TEvent, actorScope: ActorScope<TSnapshot, TEvent, TSystem, TEmitted>) => TSnapshot;
793
+ transition: (snapshot: TSnapshot, event: TEvent, actorScope: ActorScope<TSnapshot, TEvent, TSystem, TEmitted>) => ActorLogicTransitionResult<TSnapshot>;
794
+ /**
795
+ * Transition function that produces the initial state and effects.
796
+ *
797
+ * @param actorScope - The actor scope.
798
+ * @param input - The input for the initial state.
799
+ * @returns A tuple of the initial state and effects.
800
+ */
801
+ initialTransition: (input: TInput, actorScope: ActorScope<TSnapshot, TEvent, TSystem, TEmitted>) => ActorLogicTransitionResult<TSnapshot>;
792
802
  /**
793
803
  * Called to provide the initial state of the actor.
794
804
  *
@@ -832,8 +842,8 @@ export type UnknownActorLogic = ActorLogic<any, // snapshot
832
842
  any, // event
833
843
  any, // input
834
844
  AnyActorSystem, any>;
835
- export type SnapshotFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer TSnapshot, infer _, infer __> ? TSnapshot : R extends Actor<infer TLogic> ? SnapshotFrom<TLogic> : R extends ActorLogic<infer _TSnapshot, infer _TEvent, infer _TInput, infer _TEmitted, infer _TSystem> ? ReturnType<R['transition']> : R extends ActorScope<infer TSnapshot, infer _TEvent, infer _TEmitted, infer _TSystem> ? TSnapshot : never : never;
836
- export type EventFromLogic<TLogic extends AnyActorLogic> = TLogic extends ActorLogic<infer _TSnapshot, infer TEvent, infer _TInput, infer _TEmitted, infer _TSystem> ? TEvent : never;
845
+ export type SnapshotFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer TSnapshot, infer _, infer __> ? TSnapshot : R extends Actor<infer TLogic> ? SnapshotFrom<TLogic> : R extends ActorLogic<infer TSnapshot, infer _TEvent, infer _TInput, infer _TSystem, infer _TEmitted> ? TSnapshot : R extends ActorScope<infer TSnapshot, infer _TEvent, infer _TEmitted, infer _TSystem> ? TSnapshot : never : never;
846
+ export type EventFromLogic<TLogic extends AnyActorLogic> = TLogic extends ActorLogic<infer _TSnapshot, infer TEvent, infer _TInput, infer _TSystem, infer _TEmitted> ? TEvent : never;
837
847
  export type EmittedFrom<TLogic extends AnyActorLogic> = TLogic extends ActorLogic<infer _TSnapshot, infer _TEvent, infer _TInput, infer _TSystem, infer TEmitted> ? TEmitted : never;
838
848
  type ResolveEventType<T> = T extends infer R ? R extends StateMachine<infer _TContext, infer TEvent, infer _TChildren, infer _TStateValue, infer _TTag, infer _TInput, infer _TOutput, infer _TEmitted, infer _TMeta, infer _TConfig, infer _TActionMap, infer _TActorMap, infer _TGuardMap, infer _TDelayMap> ? TEvent : R extends MachineSnapshot<infer _TContext, infer TEvent, infer _TChildren, infer _TStateValue, infer _TTag, infer _TOutput, infer _TMeta, infer _TStateSchema> ? TEvent : R extends ActorRef<infer _TSnapshot, infer TEvent, infer _TEmitted> ? TEvent : never : never;
839
849
  export type EventFrom<T, K extends Prop<TEvent, 'type'> = never, TEvent extends EventObject = ResolveEventType<T>> = IsNever<K> extends true ? TEvent : ExtractEvent<TEvent, K>;
@@ -952,19 +962,61 @@ export type ToStateValue<T extends StateSchema> = T extends {
952
962
  [StateKey in K]: ToStateValue<T['states'][K]>;
953
963
  };
954
964
  }>> : never) : {};
955
- export interface ExecutableActionObject {
956
- type: string & {};
965
+ export interface BaseExecutableActionObject {
957
966
  params: NonReducibleUnknown;
958
967
  args: unknown[];
959
968
  exec: (() => void) | undefined;
960
969
  }
961
- export type SpecialExecutableAction = Values<{
962
- [K in keyof typeof builtInActions]: {
963
- type: K;
964
- args: Parameters<(typeof builtInActions)[K]>;
965
- };
970
+ export interface CustomExecutableActionObject<TType extends string = string & {}> extends BaseExecutableActionObject {
971
+ type: TType;
972
+ }
973
+ export interface StartExecutableActionObject extends BaseExecutableActionObject {
974
+ type: '@xstate.start';
975
+ actor: AnyActor;
976
+ id: string;
977
+ logic: AnyActorLogic;
978
+ src: string | AnyActorLogic;
979
+ input: unknown;
980
+ args: Parameters<(typeof builtInActions)['@xstate.start']>;
981
+ }
982
+ export interface RaiseExecutableActionObject extends BaseExecutableActionObject {
983
+ type: '@xstate.raise';
984
+ event: EventObject;
985
+ id: string | undefined;
986
+ delay: number | undefined;
987
+ args: Parameters<(typeof builtInActions)['@xstate.raise']>;
988
+ }
989
+ export interface SendToExecutableActionObject extends BaseExecutableActionObject {
990
+ type: '@xstate.sendTo';
991
+ target: AnyActor;
992
+ event: EventObject;
993
+ id: string | undefined;
994
+ delay: number | undefined;
995
+ args: Parameters<(typeof builtInActions)['@xstate.sendTo']>;
996
+ }
997
+ export interface CancelExecutableActionObject extends BaseExecutableActionObject {
998
+ type: '@xstate.cancel';
999
+ id: string;
1000
+ args: Parameters<(typeof builtInActions)['@xstate.cancel']>;
1001
+ }
1002
+ export interface StopExecutableActionObject extends BaseExecutableActionObject {
1003
+ type: '@xstate.stop';
1004
+ actor: AnyActor;
1005
+ args: Parameters<(typeof builtInActions)['@xstate.stop']>;
1006
+ }
1007
+ export type BuiltInExecutableActionObject = Values<{
1008
+ '@xstate.start': StartExecutableActionObject;
1009
+ '@xstate.raise': RaiseExecutableActionObject;
1010
+ '@xstate.sendTo': SendToExecutableActionObject;
1011
+ '@xstate.cancel': CancelExecutableActionObject;
1012
+ '@xstate.stop': StopExecutableActionObject;
966
1013
  }>;
967
- export interface ToExecutableAction<T extends ParameterizedObject> extends ExecutableActionObject {
1014
+ export type SpecialExecutableAction = BuiltInExecutableActionObject;
1015
+ type TransitionExecutableActionObject<TType extends string = never> = BuiltInExecutableActionObject | CustomExecutableActionObject<TType | (string & {})>;
1016
+ type KnownImplementationKeys<TImplementationMap> = string extends keyof TImplementationMap ? never : Extract<keyof TImplementationMap, string>;
1017
+ export type ExecutableActionObjectFromLogic<T extends AnyActorLogic> = T extends StateMachine<any, any, any, any, any, any, any, any, any, any, infer TActionMap, any, any, any> ? TransitionExecutableActionObject<KnownImplementationKeys<TActionMap>> : ExecutableActionObject;
1018
+ export type ExecutableActionObject<TType extends string = string & {}> = BuiltInExecutableActionObject | CustomExecutableActionObject<TType>;
1019
+ export interface ToExecutableAction<T extends ParameterizedObject> extends CustomExecutableActionObject<T['type']> {
968
1020
  type: T['type'];
969
1021
  params: T['params'];
970
1022
  exec: undefined;
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from "./schema.types.js";
2
2
  import { MachineSnapshot } from "./State.js";
3
- import { Action, ActorSelf, AnyActorLogic, AnyActorRef, Compute, DoneActorEvent, DoNotInfer, EventDescriptor, EventObject, ExtractEvent, InitialContext, InputFrom, IsNever, MetaObject, NonReducibleUnknown, SingleOrArray, SnapshotEvent, StateValue, TODO, TransitionConfigFunction, Values, AnyStateNode } from "./types.js";
3
+ import { Action, ActorLogic, ActorRef, ActorRefFromLogic, ActorSelf, AnyActorLogic, AnyActorRef, Compute, DoneActorEvent, DoNotInfer, EventDescriptor, EventObject, ExtractEvent, InitialContext, InputFrom, IsNever, MetaObject, NonReducibleUnknown, SingleOrArray, SnapshotEvent, StateValue, TODO, TransitionConfigFunction, Values, AnyStateNode } 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";
@@ -17,6 +17,10 @@ export type InferEvents<TEventSchemaMap extends Record<string, StandardSchemaV1>
17
17
  type: K;
18
18
  } : never;
19
19
  }>;
20
+ export type InferChildren<TChildrenSchemaMap extends Record<string, StandardSchemaV1>> = string extends keyof TChildrenSchemaMap ? {} : {
21
+ [K in keyof TChildrenSchemaMap & string]?: StandardSchemaV1.InferOutput<TChildrenSchemaMap[K]> extends AnyActorRef ? NormalizeActorRef<StandardSchemaV1.InferOutput<TChildrenSchemaMap[K]>> : never;
22
+ };
23
+ type NormalizeActorRef<TActorRef> = TActorRef extends ActorRef<infer TSnapshot, infer TEvent, infer TEmitted, infer TSendEvent> ? ActorRef<TSnapshot, TEvent, TEmitted, TSendEvent> : never;
20
24
  type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
21
25
  type InternalEventDescriptorFor<TEvent extends EventObject> = [TEvent] extends [
22
26
  never
@@ -46,7 +50,7 @@ export interface MachineOptions {
46
50
  */
47
51
  maxIterations?: number;
48
52
  }
49
- type MachineSchemas<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> = {
53
+ type MachineSchemas<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>> = {
50
54
  events?: TEventSchemaMap;
51
55
  context?: TContextSchema;
52
56
  emitted?: TEmittedSchemaMap;
@@ -54,11 +58,12 @@ type MachineSchemas<TContextSchema extends StandardSchemaV1, TEventSchemaMap ext
54
58
  output?: TOutputSchema;
55
59
  meta?: TMetaSchema;
56
60
  tags?: TTagSchema;
61
+ children?: TChildrenSchemaMap;
57
62
  };
58
- export type AnyMachineSchemas = MachineSchemas<StandardSchemaV1, Record<string, StandardSchemaV1>, Record<string, StandardSchemaV1>, StandardSchemaV1, StandardSchemaV1, StandardSchemaV1, StandardSchemaV1>;
59
- 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, TContext extends MachineContext = InferOutput<TContextSchema, MachineContext>, TEvent extends EventObject = InferEvents<TEventSchemaMap>, TDelays extends string = string, _TTag extends string = string, TActionMap extends Implementations['actions'] = Implementations['actions'], TActorMap extends Implementations['actors'] = Implementations['actors'], TGuardMap extends Implementations['guards'] = Implementations['guards'], TDelayMap extends Implementations['delays'] = Implementations['delays'], TContextRequired extends boolean = IsNever<TContext> extends true ? false : true> = (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<TActionMap>, DoNotInfer<TActorMap>, DoNotInfer<TGuardMap>, DoNotInfer<TDelayMap>>, 'output'> & {
63
+ export type AnyMachineSchemas = MachineSchemas<StandardSchemaV1, Record<string, StandardSchemaV1>, Record<string, StandardSchemaV1>, StandardSchemaV1, StandardSchemaV1, StandardSchemaV1, StandardSchemaV1, Record<string, StandardSchemaV1>>;
64
+ 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 Implementations['actions'] = Implementations['actions'], TActorMap extends Implementations['actors'] = Implementations['actors'], TGuardMap extends Implementations['guards'] = Implementations['guards'], TDelayMap extends Implementations['delays'] = Implementations['delays'], TContextRequired extends boolean = IsNever<TContext> extends true ? false : true> = (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>>, 'output'> & {
60
65
  internalEvents?: readonly InternalEventDescriptorFor<InferEvents<TEventSchemaMap>>[];
61
- schemas?: MachineSchemas<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema>;
66
+ schemas?: MachineSchemas<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap>;
62
67
  actions?: TActionMap;
63
68
  guards?: TGuardMap;
64
69
  actors?: TActorMap;
@@ -102,10 +107,26 @@ type InvokeSrcArgs<TContext extends MachineContext, TEvent extends EventObject,
102
107
  event: TEvent;
103
108
  self: AnyActorRef;
104
109
  };
105
- type InvokeInputArgs<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject> = {
110
+ type InvokeInputArgs<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>> = {
106
111
  context: TContext;
107
112
  event: TEvent;
108
- self: ActorSelf<MachineSnapshot<TContext, TEvent, Record<string, AnyActorRef | undefined>, StateValue, string, unknown, TODO, TODO>, TEvent, TEmitted>;
113
+ self: ActorSelf<MachineSnapshot<TContext, TEvent, TChildren, StateValue, string, unknown, TODO, TODO>, TEvent, TEmitted>;
114
+ };
115
+ type HasExplicitChildren<TChildren extends Record<string, AnyActorRef | undefined>> = string extends keyof TChildren ? false : [keyof TChildren] extends [never] ? false : true;
116
+ type ChildIdForLogic<TLogic extends AnyActorLogic, TChildren extends Record<string, AnyActorRef | undefined>> = HasExplicitChildren<TChildren> extends true ? Values<{
117
+ [K in keyof TChildren & string]: ActorRefFromLogic<TLogic> extends NonNullable<TChildren[K]> ? K : never;
118
+ }> : string;
119
+ type LogicForChildRef<TActorRef> = NonNullable<TActorRef> extends ActorRef<infer TSnapshot, infer TEvent, infer TEmitted, any> ? ActorLogic<TSnapshot, TEvent, any, any, TEmitted> : never;
120
+ type InlineChildInvokeConfig<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TMeta extends MetaObject> = Values<{
121
+ [K in keyof TChildren & string]: Next_InvokeConfigBase<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> & {
122
+ id: K;
123
+ src: LogicForChildRef<TChildren[K]>;
124
+ input?: ((args: InvokeInputArgs<TContext, TEvent, TEmitted, TChildren>) => unknown) | NonReducibleUnknown;
125
+ };
126
+ }>;
127
+ type InlineInvokeConfig<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TMeta extends MetaObject> = HasExplicitChildren<TChildren> extends true ? InlineChildInvokeConfig<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> : Next_InvokeConfigBase<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> & {
128
+ src: AnyActorLogic;
129
+ input?: ((args: InvokeInputArgs<TContext, TEvent, TEmitted, TChildren>) => unknown) | NonReducibleUnknown;
109
130
  };
110
131
  /**
111
132
  * Invoke config. A union of:
@@ -117,20 +138,17 @@ type InvokeInputArgs<TContext extends MachineContext, TEvent extends EventObject
117
138
  * - A branch for inline (unregistered) actor logic values, whose `input` cannot
118
139
  * be correlated (the config is not generic over inline logic).
119
140
  */
120
- export type Next_InvokeConfig<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TMeta extends MetaObject> = string extends keyof TActorMap ? // No registered actors (permissive map): `src`/`input` cannot be
121
- Next_InvokeConfigBase<TContext, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> & {
141
+ export type Next_InvokeConfig<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TMeta extends MetaObject> = string extends keyof TActorMap ? HasExplicitChildren<TChildren> extends true ? InlineInvokeConfig<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> : Next_InvokeConfigBase<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> & {
122
142
  src: string | AnyActorLogic | ((args: InvokeSrcArgs<TContext, TEvent, TActorMap>) => string | AnyActorLogic);
123
- input?: ((args: InvokeInputArgs<TContext, TEvent, TEmitted>) => unknown) | NonReducibleUnknown;
143
+ input?: ((args: InvokeInputArgs<TContext, TEvent, TEmitted, TChildren>) => unknown) | NonReducibleUnknown;
124
144
  } : {
125
- [K in keyof TActorMap & string]: Next_InvokeConfigBase<TContext, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> & {
145
+ [K in keyof TActorMap & string]: Next_InvokeConfigBase<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> & {
126
146
  src: K | TActorMap[K] | ((args: InvokeSrcArgs<TContext, TEvent, TActorMap>) => K | TActorMap[K]);
127
- input?: ((args: InvokeInputArgs<TContext, TEvent, TEmitted>) => InputFrom<TActorMap[K]>) | InputFrom<TActorMap[K]>;
147
+ id?: ChildIdForLogic<TActorMap[K], TChildren>;
148
+ input?: ((args: InvokeInputArgs<TContext, TEvent, TEmitted, TChildren>) => InputFrom<TActorMap[K]>) | InputFrom<TActorMap[K]>;
128
149
  };
129
- }[keyof TActorMap & string] | (Next_InvokeConfigBase<TContext, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta> & {
130
- src: AnyActorLogic;
131
- input?: ((args: InvokeInputArgs<TContext, TEvent, TEmitted>) => unknown) | NonReducibleUnknown;
132
- });
133
- interface Next_InvokeConfigBase<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TMeta extends MetaObject> {
150
+ }[keyof TActorMap & string] | InlineInvokeConfig<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>;
151
+ interface Next_InvokeConfigBase<TContext extends MachineContext, TEvent extends EventObject, TEmitted extends EventObject, _TChildren extends Record<string, AnyActorRef | undefined>, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TMeta extends MetaObject> {
134
152
  id?: string;
135
153
  systemId?: string;
136
154
  onDone?: Next_TransitionConfigOrTarget<TContext, DoneActorEvent<any>, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>;
@@ -196,7 +214,7 @@ type Next_RouteConfig<TContext extends MachineContext, TEvent extends EventObjec
196
214
  }) => Record<string, unknown>);
197
215
  });
198
216
  type Next_ChoiceConfigFunction<TContext extends MachineContext, TCurrentEvent extends EventObject, TEvent extends EventObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TMeta extends MetaObject, _TCtx = [TContext] extends [never] ? any : TContext> = (args: Next_ChoiceArgs<TContext, TCurrentEvent, TEvent, TActionMap, TActorMap, TGuardMap, TDelayMap, _TCtx>) => Next_ChoiceTarget<TMeta>;
199
- export type Next_StateNodeConfig<TContext extends MachineContext, TEvent extends EventObject, TDelays extends string, TTag extends string, _TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TInput = Record<string, unknown> | undefined, TInputMap extends Record<string, unknown> = Record<string, unknown>> = Next_RegularStateNodeConfig<TContext, TEvent, TDelays, TTag, _TOutput, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TInput, TInputMap> | Next_ChoiceStateNodeConfig<TContext, TEvent, TTag, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
217
+ 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 Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TInput = Record<string, unknown> | undefined, TInputMap extends Record<string, unknown> = Record<string, unknown>> = Next_RegularStateNodeConfig<TContext, TEvent, TDelays, TTag, _TOutput, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TInput, TInputMap> | Next_ChoiceStateNodeConfig<TContext, TEvent, TTag, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap>;
200
218
  interface Next_ChoiceStateNodeConfig<TContext extends MachineContext, TEvent extends EventObject, TTag extends string, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> {
201
219
  contextSchema?: StandardSchemaV1;
202
220
  type: 'choice';
@@ -223,7 +241,7 @@ interface Next_ChoiceStateNodeConfig<TContext extends MachineContext, TEvent ext
223
241
  output?: never;
224
242
  target?: never;
225
243
  }
226
- interface Next_RegularStateNodeConfig<TContext extends MachineContext, TEvent extends EventObject, TDelays extends string, TTag extends string, _TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TInput = Record<string, unknown> | undefined, TInputMap extends Record<string, unknown> = Record<string, unknown>> {
244
+ 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 Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TInput = Record<string, unknown> | undefined, TInputMap extends Record<string, unknown> = Record<string, unknown>> {
227
245
  contextSchema?: StandardSchemaV1;
228
246
  /** The initial state transition. */
229
247
  initial?: string | {
@@ -254,13 +272,13 @@ interface Next_RegularStateNodeConfig<TContext extends MachineContext, TEvent ex
254
272
  */
255
273
  states?: {
256
274
  [K in string]: Next_StateNodeConfig<TContext, TEvent, TDelays, TTag, any, // TOutput,
257
- TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, LookupInput<TInputMap, K>, TInputMap>;
275
+ TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, LookupInput<TInputMap, K>, TInputMap>;
258
276
  };
259
277
  /**
260
278
  * The services to invoke upon entering this state node. These services will
261
279
  * be stopped upon exiting this state node.
262
280
  */
263
- invoke?: SingleOrArray<Next_InvokeConfig<TContext, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>>;
281
+ invoke?: SingleOrArray<Next_InvokeConfig<TContext, TEvent, TEmitted, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>>;
264
282
  /** The mapping of event types to their potential transition(s). */
265
283
  on?: {
266
284
  [K in EventDescriptor<TEvent>]?: Next_TransitionConfigOrTarget<TContext, ExtractEvent<TEvent, K>, TEvent, TEmitted, TActionMap, TActorMap, TGuardMap, TDelayMap, TMeta>;