xstate 6.0.0-alpha.24 → 6.0.0-alpha.26

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 (39) hide show
  1. package/dist/{StateMachine-0d7aa36b.cjs.js → StateMachine-1a51a14a.cjs.js} +37 -26
  2. package/dist/{StateMachine-f3d5f2d8.development.esm.js → StateMachine-70bbb88f.development.esm.js} +40 -29
  3. package/dist/{StateMachine-27ce068a.development.cjs.js → StateMachine-89f725ff.development.cjs.js} +40 -29
  4. package/dist/{StateMachine-4f3ebd99.esm.js → StateMachine-bfbf8d6e.esm.js} +37 -26
  5. package/dist/declarations/src/StateMachine.d.ts +11 -11
  6. package/dist/declarations/src/StateNode.d.ts +2 -0
  7. package/dist/declarations/src/createMachine.d.ts +6 -6
  8. package/dist/declarations/src/createMachineFromConfig.d.ts +5 -5
  9. package/dist/declarations/src/fsm.d.ts +2 -2
  10. package/dist/declarations/src/index.d.ts +1 -1
  11. package/dist/declarations/src/schema.types.d.ts +5 -0
  12. package/dist/declarations/src/serialize.d.ts +3 -3
  13. package/dist/declarations/src/setup.d.ts +51 -50
  14. package/dist/declarations/src/spawn.d.ts +1 -1
  15. package/dist/declarations/src/types.d.ts +39 -39
  16. package/dist/declarations/src/types.v6.d.ts +28 -26
  17. package/dist/{index-cf2e8954.esm.js → index-036a773f.esm.js} +85 -39
  18. package/dist/{index-46c96e83.development.cjs.js → index-1ad8a761.development.cjs.js} +85 -38
  19. package/dist/{index-1a180503.development.esm.js → index-b90ebcd4.development.esm.js} +85 -39
  20. package/dist/{index-0ef8d20d.cjs.js → index-f58cc498.cjs.js} +85 -38
  21. package/dist/xstate-actors.cjs.js +1 -1
  22. package/dist/xstate-actors.development.cjs.js +1 -1
  23. package/dist/xstate-actors.development.esm.js +1 -1
  24. package/dist/xstate-actors.esm.js +1 -1
  25. package/dist/xstate-actors.umd.min.js +1 -1
  26. package/dist/xstate-actors.umd.min.js.map +1 -1
  27. package/dist/xstate-graph.cjs.js +2 -2
  28. package/dist/xstate-graph.development.cjs.js +2 -2
  29. package/dist/xstate-graph.development.esm.js +2 -2
  30. package/dist/xstate-graph.esm.js +2 -2
  31. package/dist/xstate-graph.umd.min.js +1 -1
  32. package/dist/xstate-graph.umd.min.js.map +1 -1
  33. package/dist/xstate.cjs.js +85 -52
  34. package/dist/xstate.development.cjs.js +85 -52
  35. package/dist/xstate.development.esm.js +87 -54
  36. package/dist/xstate.esm.js +87 -54
  37. package/dist/xstate.umd.min.js +1 -1
  38. package/dist/xstate.umd.min.js.map +1 -1
  39. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- import { M as setSnapshotActorRef, N as getSnapshotActorRef, O as createSnapshotSystem, q as isMachineSnapshot, h as createActor, S as STATE_DELIMITER, P as mapValues, t as toArray, Q as createInvokeId, R as getDelayedTransitions, U as getEventDescriptorKey, V as evaluateCandidate, W as formatTransition, Y as NULL_EVENT, Z as toTransitionConfigArray, _ as createInvokeTimeoutEventId, $ as getCandidates, a0 as matchesActorSession, a1 as formatRouteTransitions, a2 as resolveStateValue, a3 as getAllStateNodes, s as getStateNodes, a4 as createMachineSnapshot, a5 as isInFinalState, j as macrostep, a6 as cloneMachineSnapshot, a7 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a8 as getTransitionResult, a9 as hasEffect, aa as createErrorPlatformEvent, r as resolveActionsWithContext, k as createInitEvent, l as createSpawnEffect, n as initialMicrostep, ab as toStatePath, ac as isStateId, ad as getStateNodeByPath, ae as getPersistedSnapshot, af as resolveReferencedActor, ag as $$ACTOR_TYPE } from './index-cf2e8954.esm.js';
1
+ import { M as setSnapshotActorRef, N as getSnapshotActorRef, O as createSnapshotSystem, q as isMachineSnapshot, h as createActor, S as STATE_DELIMITER, P as mapValues, t as toArray, Q as createInvokeId, R as getDelayedTransitions, U as getEventDescriptorKey, V as evaluateCandidate, W as formatTransition, Y as NULL_EVENT, Z as toTransitionConfigArray, _ as createInvokeTimeoutEventId, $ as getCandidates, a0 as matchesActorSession, a1 as formatRouteTransitions, a2 as resolveStateValue, a3 as getAllStateNodes, s as getStateNodes, a4 as createMachineSnapshot, a5 as isInFinalState, j as macrostep, a6 as cloneMachineSnapshot, a7 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a8 as getTransitionResult, a9 as hasEffect, aa as createErrorPlatformEvent, r as resolveActionsWithContext, k as createInitEvent, l as createSpawnEffect, n as initialMicrostep, ab as toStatePath, ac as isStateId, ad as getStateNodeByPath, ae as getPersistedSnapshot, af as resolveReferencedActor, ag as createInvokeTimeoutEvent, ah as $$ACTOR_TYPE } from './index-036a773f.esm.js';
2
2
 
3
- function createSpawner(actorScope, actorSources, spawnedChildren) {
3
+ function createSpawner(actorScope, actors, spawnedChildren) {
4
4
  return (src, options) => {
5
- const referencedSrc = Object.entries(actorSources).find(([, logic]) => logic === src)?.[0];
5
+ const referencedSrc = Object.entries(actors).find(([, logic]) => logic === src)?.[0];
6
6
  const actor = actorScope.system.createActorRef(src, {
7
7
  id: options?.id,
8
8
  parent: actorScope.self,
@@ -45,7 +45,8 @@ function createInertActorScope(actorLogic, snapshot, sourceSelf) {
45
45
  const self = createActor(actorLogic, {
46
46
  _inert: true,
47
47
  ...(previousSelf ? {
48
- id: previousSelf.id
48
+ id: previousSelf.id,
49
+ _sessionId: previousSelf.sessionId
49
50
  } : {}),
50
51
  ...(system ? {
51
52
  _systemRef: {
@@ -192,6 +193,7 @@ class StateNode {
192
193
  */
193
194
  this.order = -1;
194
195
  this.description = void 0;
196
+ this.schemas = void 0;
195
197
  this.tags = [];
196
198
  this.transitions = void 0;
197
199
  this.always = void 0;
@@ -208,6 +210,7 @@ class StateNode {
208
210
  this.id = this.config.id || [this.machine.id, ...this.path].join(STATE_DELIMITER);
209
211
  this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
210
212
  this.description = this.config.description;
213
+ this.schemas = this.config.schemas;
211
214
  validateStateNodeConfig(this);
212
215
  this.order = this.machine.idMap.size;
213
216
  this.machine.idMap.set(this.id, this);
@@ -523,12 +526,12 @@ function getEmptyCanActorScope() {
523
526
  }
524
527
  class StateMachine {
525
528
  constructor(/** The raw config used to create the machine. */
526
- config, implementations) {
529
+ config, sources) {
527
530
  this.config = config;
528
531
  /** The machine's own version. */
529
532
  this.version = void 0;
530
533
  this.schemas = void 0;
531
- this.implementations = void 0;
534
+ this.sources = void 0;
532
535
  /** Runtime options for machine execution. */
533
536
  this.options = void 0;
534
537
  /** @internal */
@@ -547,12 +550,12 @@ class StateMachine {
547
550
  */
548
551
  this._json = void 0;
549
552
  this.id = config.id || '(machine)';
550
- this.implementations = {
551
- actorSources: config.actorSources ?? {},
553
+ this.sources = {
554
+ actors: config.actors ?? {},
552
555
  actions: config.actions ?? {},
553
556
  delays: config.delays ?? {},
554
557
  guards: config.guards ?? {},
555
- ...implementations
558
+ ...sources
556
559
  };
557
560
  this.version = this.config.version;
558
561
  this.schemas = this.config.schemas;
@@ -579,38 +582,38 @@ class StateMachine {
579
582
  }
580
583
 
581
584
  /**
582
- * Clones this state machine with the provided implementations.
585
+ * Clones this state machine with the provided sources.
583
586
  *
584
- * @param implementations Options (`actions`, `guards`, `actorSources`,
585
- * `delays`) to recursively merge with the existing options.
586
- * @returns A new `StateMachine` instance with the provided implementations.
587
+ * @param sources Options (`actions`, `guards`, `actors`, `delays`) to
588
+ * recursively merge with the existing options.
589
+ * @returns A new `StateMachine` instance with the provided sources.
587
590
  */
588
- provide(implementations) {
591
+ provide(sources) {
589
592
  const {
590
593
  actions,
591
594
  guards,
592
- actorSources,
595
+ actors,
593
596
  delays
594
- } = this.implementations;
597
+ } = this.sources;
595
598
  const provided = new StateMachine(this.config, {
596
599
  actions: {
597
600
  ...actions,
598
- ...implementations.actions
601
+ ...sources.actions
599
602
  },
600
603
  guards: {
601
604
  ...guards,
602
- ...implementations.guards
605
+ ...sources.guards
603
606
  },
604
- actorSources: {
605
- ...actorSources,
606
- ...implementations.actorSources
607
+ actors: {
608
+ ...actors,
609
+ ...sources.actors
607
610
  },
608
611
  delays: {
609
612
  ...delays,
610
- ...implementations.delays
613
+ ...sources.delays
611
614
  }
612
615
  });
613
- // Providing implementations does not change the serializable definition.
616
+ // Providing sources does not change the serializable definition.
614
617
  provided._json = this._json;
615
618
  return provided;
616
619
  }
@@ -801,12 +804,12 @@ class StateMachine {
801
804
  }, this, actorScope.self);
802
805
  if (typeof context === 'function') {
803
806
  const children = {};
804
- const spawn = createSpawner(actorScope, this.implementations.actorSources, children);
807
+ const spawn = createSpawner(actorScope, this.sources.actors, children);
805
808
  const resolvedContext = context({
806
809
  spawn,
807
810
  input: initEvent.input,
808
811
  self: actorScope.self,
809
- actorSources: this.implementations.actorSources
812
+ actors: this.sources.actors
810
813
  });
811
814
  const [nextState] = resolveActionsWithContext(preInitial, initEvent, actorScope, []);
812
815
  if (resolvedContext) {
@@ -918,7 +921,6 @@ class StateMachine {
918
921
  syncSnapshot: actorData.syncSnapshot,
919
922
  snapshot: childState,
920
923
  src,
921
- _sessionId: actorData.sessionId,
922
924
  registryKey: actorData.registryKey
923
925
  });
924
926
  // Mark so `start()` knows to start this child (freshly invoked/spawned
@@ -929,6 +931,14 @@ class StateMachine {
929
931
  const timers = {};
930
932
  const persistedTimers = snapshotData.timers ?? {};
931
933
  for (const [id, timer] of Object.entries(persistedTimers)) {
934
+ let event = timer.event;
935
+ if (event.type === 'xstate.timeout.actor') {
936
+ const actorId = event.actorId;
937
+ const child = children[actorId];
938
+ if (child) {
939
+ event = createInvokeTimeoutEvent(actorId, child.sessionId);
940
+ }
941
+ }
932
942
  const target = typeof timer.target === 'string' ? timer.target === 'self' ? 'self' : children[timer.target] : resolvedActorScope.self._parent;
933
943
  if (!target) {
934
944
  const targetDescription = typeof timer.target === 'string' ? timer.target : timer.target.type;
@@ -936,6 +946,7 @@ class StateMachine {
936
946
  }
937
947
  timers[id] = {
938
948
  ...timer,
949
+ event,
939
950
  target
940
951
  };
941
952
  }
@@ -2,14 +2,14 @@ import { MachineSnapshot } from "./State.js";
2
2
  import { StateNode } from "./StateNode.js";
3
3
  import { AnyActorSystem } from "./system.js";
4
4
  import type { ActorLogic, ActorLogicTransitionResult, ActorScope, AnyActor, AnyActorLogic, AnyActorRef, AnyActorScope, AnyTransitionDefinition, Equals, EventDescriptor, EmittedFrom, EventObject, EventFromLogic, ExecutableActionObjectFromLogic, HistoryValue, InputFrom, IsAny, MachineContext, MetaObject, OutputFrom, Snapshot, SnapshotFrom, StateValue, StateSchema, SnapshotStatus } from "./types.js";
5
- import { AnyMachineSchemas, Implementations, Next_MachineConfig, MachineOptions } from "./types.v6.js";
5
+ import { AnyMachineSchemas, Sources, Next_MachineConfig, MachineOptions } from "./types.v6.js";
6
6
  type CompatibleProvidedActorSource<TExpected extends AnyActorLogic, TActual extends AnyActorLogic> = IsAny<TActual> extends true ? TActual : [OutputFrom<TActual>] extends [OutputFrom<TExpected>] ? [Omit<SnapshotFrom<TActual>, 'input'>] extends [
7
7
  Omit<SnapshotFrom<TExpected>, 'input'>
8
8
  ] ? [InputFrom<TExpected>] extends [InputFrom<TActual>] ? [EventFromLogic<TExpected>] extends [EventFromLogic<TActual>] ? [EmittedFrom<TActual>] extends [EmittedFrom<TExpected>] ? TActual : never : never : never : never : never;
9
- type ProvidedActorSources<TExpectedActorMap extends Implementations['actorSources'], TProvidedActorMap extends Partial<Record<keyof TExpectedActorMap & string, AnyActorLogic>>> = {
9
+ type ProvidedActors<TExpectedActorMap extends Sources['actors'], TProvidedActorMap extends Partial<Record<keyof TExpectedActorMap & string, AnyActorLogic>>> = {
10
10
  [K in keyof TProvidedActorMap]: K extends keyof TExpectedActorMap ? TProvidedActorMap[K] extends AnyActorLogic ? CompatibleProvidedActorSource<TExpectedActorMap[K], TProvidedActorMap[K]> : never : never;
11
11
  };
12
- export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TConfig extends StateSchema, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
12
+ export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TStateValue extends StateValue, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TMeta extends MetaObject, TConfig extends StateSchema, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays']> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
13
13
  /** The raw config used to create the machine. */
14
14
  config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any> & {
15
15
  schemas?: AnyMachineSchemas;
@@ -18,7 +18,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
18
18
  /** The machine's own version. */
19
19
  version?: string;
20
20
  schemas: AnyMachineSchemas | undefined;
21
- implementations: Implementations;
21
+ sources: Sources;
22
22
  /** Runtime options for machine execution. */
23
23
  options: MachineOptions;
24
24
  root: StateNode<TContext, TEvent>;
@@ -31,17 +31,17 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
31
31
  config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any> & {
32
32
  schemas?: AnyMachineSchemas;
33
33
  internalEvents?: readonly string[];
34
- }, implementations?: Implementations);
34
+ }, sources?: Sources);
35
35
  /**
36
- * Clones this state machine with the provided implementations.
36
+ * Clones this state machine with the provided sources.
37
37
  *
38
- * @param implementations Options (`actions`, `guards`, `actorSources`,
39
- * `delays`) to recursively merge with the existing options.
40
- * @returns A new `StateMachine` instance with the provided implementations.
38
+ * @param sources Options (`actions`, `guards`, `actors`, `delays`) to
39
+ * recursively merge with the existing options.
40
+ * @returns A new `StateMachine` instance with the provided sources.
41
41
  */
42
- provide<const TProvidedActorMap extends Partial<Record<keyof TActorMap & string, AnyActorLogic>> = {}>(implementations: {
42
+ provide<const TProvidedActorMap extends Partial<Record<keyof TActorMap & string, AnyActorLogic>> = {}>(sources: {
43
43
  actions?: Partial<TActionMap>;
44
- actorSources?: TProvidedActorMap & ProvidedActorSources<TActorMap, TProvidedActorMap>;
44
+ actors?: TProvidedActorMap & ProvidedActors<TActorMap, TProvidedActorMap>;
45
45
  guards?: Partial<TGuardMap>;
46
46
  delays?: Partial<TDelayMap>;
47
47
  }): StateMachine<TContext, TEvent, TChildren, TStateValue, TTag, TInput, TOutput, TEmitted, TMeta, TConfig, TActionMap, TActorMap, TGuardMap, TDelayMap>;
@@ -1,3 +1,4 @@
1
+ import type { SetupStateSchemas } from "./schema.types.js";
1
2
  import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, MachineContext, Mapper, StateNodesConfig, TransitionDefinitionMap, AnyStateMachine, AnyStateNodeConfig, NonReducibleUnknown, EventDescriptor, AnyAction, AnyTransitionDefinition, AnyInvokeDefinition } from "./types.js";
2
3
  interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
3
4
  _key: string;
@@ -60,6 +61,7 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
60
61
  */
61
62
  order: number;
62
63
  description?: string;
64
+ schemas: SetupStateSchemas | undefined;
63
65
  tags: string[];
64
66
  transitions: Map<string, AnyTransitionDefinition[]>;
65
67
  always?: Array<AnyTransitionDefinition>;
@@ -1,7 +1,7 @@
1
1
  import { StandardSchemaV1 } from "./schema.types.js";
2
2
  import { StateMachine } from "./StateMachine.js";
3
3
  import { AnyActorRef, EventObject, AnyEventObject, Cast, MachineContext, ProvidedActor, StateValue, ToChildren, MetaObject, StateSchema, DoNotInfer, RoutableStateId, Compute } from "./types.js";
4
- import { Implementations, DelayMapFromNames, InferChildren, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, ValidateDelayReferences, ValidateTopLevelFinalOutputs, WidenLiterals, WithDefault } from "./types.v6.js";
4
+ import { Sources, DelayMapFromNames, InferChildren, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, ValidateDelayReferences, ValidateTopLevelFinalOutputs, WidenLiterals, WithDefault } from "./types.v6.js";
5
5
  type MergeChildren<TChildren extends Record<string, AnyActorRef | undefined>, TActor extends ProvidedActor> = [keyof TChildren] extends [never] ? Compute<ToChildren<TActor>> : Compute<TChildren>;
6
6
  /**
7
7
  * Creates a state machine (statechart) with the given configuration.
@@ -43,9 +43,9 @@ type MergeChildren<TChildren extends Record<string, AnyActorRef | undefined>, TA
43
43
  *
44
44
  * @param config The state machine configuration.
45
45
  * @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })`
46
- * to provide machine implementations instead.
46
+ * to provide machine sources instead.
47
47
  */
48
- export declare function createMachine<TContextSchema extends StandardSchemaV1, const TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, const TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1>, _TEvent extends EventObject, TActor extends ProvidedActor, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TDelays extends string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, TInput, const TSS extends StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, InferOutput<TContextSchema, MachineContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap> & {
48
+ export declare function createMachine<TContextSchema extends StandardSchemaV1, const TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, const TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1>, _TEvent extends EventObject, TActor extends ProvidedActor, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TDelays extends string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, TInput, const TSS extends StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<TContextSchema, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, InferOutput<TContextSchema, MachineContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap> & {
49
49
  schemas: {
50
50
  context: TContextSchema;
51
51
  children?: TChildrenSchemaMap;
@@ -58,13 +58,13 @@ TSS, // TStateSchema
58
58
  TActionMap, TActorMap, TGuardMap, DelayMapFromNames<TDelays, TDelayMap>> & {
59
59
  states: TSS;
60
60
  };
61
- export declare function createMachine<TContext extends MachineContext = never, const TEventSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1 = StandardSchemaV1, const TOutputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetaSchema extends StandardSchemaV1 = StandardSchemaV1, TTagSchema extends StandardSchemaV1 = StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, _TEvent extends EventObject = EventObject, TActor extends ProvidedActor = ProvidedActor, TActionMap extends Implementations['actions'] = Implementations['actions'], TActorMap extends Implementations['actorSources'] = Implementations['actorSources'], TGuardMap extends Implementations['guards'] = Implementations['guards'], TDelayMap extends Implementations['delays'] = Implementations['delays'], TDelays extends string = string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string = StandardSchemaV1.InferOutput<TTagSchema> & string, TInput = unknown, const TSS extends StateSchema = StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<StandardSchemaV1, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, WidenLiterals<TContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, false> & {
61
+ export declare function createMachine<TContext extends MachineContext = never, const TEventSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1 = StandardSchemaV1, const TOutputSchema extends StandardSchemaV1 = StandardSchemaV1, TMetaSchema extends StandardSchemaV1 = StandardSchemaV1, TTagSchema extends StandardSchemaV1 = StandardSchemaV1, const TChildrenSchemaMap extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, _TEvent extends EventObject = EventObject, TActor extends ProvidedActor = ProvidedActor, TActionMap extends Sources['actions'] = Sources['actions'], TActorMap extends Sources['actors'] = Sources['actors'], TGuardMap extends Sources['guards'] = Sources['guards'], TDelayMap extends Sources['delays'] = Sources['delays'], TDelays extends string = string, TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string = StandardSchemaV1.InferOutput<TTagSchema> & string, TInput = unknown, const TSS extends StateSchema = StateSchema>(config: TSS & ValidateDelayReferences<TSS> & Next_MachineConfig<StandardSchemaV1, TEventSchemaMap, TEmittedSchemaMap, TInputSchema, TOutputSchema, TMetaSchema, TTagSchema, TChildrenSchemaMap, WidenLiterals<TContext>, InferEvents<TEventSchemaMap>, Cast<MergeChildren<InferChildren<TChildrenSchemaMap>, TActor>, Record<string, AnyActorRef | undefined>>, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, false> & {
62
62
  schemas?: {
63
63
  context?: never;
64
64
  };
65
65
  context?: TContext | ((_: {
66
66
  spawn: any;
67
- actorSources: TActorMap;
67
+ actors: TActorMap;
68
68
  input: InferOutput<TInputSchema, unknown>;
69
69
  self: any;
70
70
  }) => TContext);
@@ -77,5 +77,5 @@ TActionMap, TActorMap, TGuardMap, DelayMapFromNames<TDelays, TDelayMap>> & {
77
77
  states: TSS;
78
78
  };
79
79
  export declare function createStateConfig<TContextSchema extends StandardSchemaV1, TEventSchema extends StandardSchemaV1, TEmittedSchema extends StandardSchemaV1, _TInputSchema extends StandardSchemaV1, const TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, _TEvent extends StandardSchemaV1.InferOutput<TEventSchema> & EventObject, // TODO: consider using a stricter `EventObject` here
80
- _TActor extends ProvidedActor, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TDelays extends string, _TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, _TInput, const TSS extends StateSchema>(config: TSS & Next_StateNodeConfig<InferOutput<TContextSchema, MachineContext>, DoNotInfer<StandardSchemaV1.InferOutput<TEventSchema> & EventObject>, DoNotInfer<TDelays>, DoNotInfer<StandardSchemaV1.InferOutput<TTagSchema> & string>, DoNotInfer<StandardSchemaV1.InferOutput<TOutputSchema>>, DoNotInfer<StandardSchemaV1.InferOutput<TEmittedSchema> & EventObject>, DoNotInfer<InferOutput<TMetaSchema, MetaObject>>, DoNotInfer<Record<string, AnyActorRef | undefined>>, DoNotInfer<TActionMap>, DoNotInfer<TActorMap>, DoNotInfer<TGuardMap>, DoNotInfer<TDelayMap>>): typeof config;
80
+ _TActor extends ProvidedActor, TActionMap extends Sources['actions'], TActorMap extends Sources['actors'], TGuardMap extends Sources['guards'], TDelayMap extends Sources['delays'], TDelays extends string, _TTag extends StandardSchemaV1.InferOutput<TTagSchema> & string, _TInput, const TSS extends StateSchema>(config: TSS & Next_StateNodeConfig<InferOutput<TContextSchema, MachineContext>, DoNotInfer<StandardSchemaV1.InferOutput<TEventSchema> & EventObject>, DoNotInfer<TDelays>, DoNotInfer<StandardSchemaV1.InferOutput<TTagSchema> & string>, DoNotInfer<StandardSchemaV1.InferOutput<TOutputSchema>>, DoNotInfer<StandardSchemaV1.InferOutput<TEmittedSchema> & EventObject>, DoNotInfer<InferOutput<TMetaSchema, MetaObject>>, DoNotInfer<Record<string, AnyActorRef | undefined>>, DoNotInfer<TActionMap>, DoNotInfer<TActorMap>, DoNotInfer<TGuardMap>, DoNotInfer<TDelayMap>>): typeof config;
81
81
  export {};
@@ -153,7 +153,7 @@ export interface StateNodeJSON {
153
153
  /**
154
154
  * JSON route config. Unlike the authoring API (a function), the JSON layer
155
155
  * allows an object form whose `guard` may be a named guard reference (string)
156
- * resolved against the machine's `guards` implementations.
156
+ * resolved against the machine's `guards` sources.
157
157
  */
158
158
  route?: {
159
159
  description?: string;
@@ -184,7 +184,7 @@ export interface MachineJSON extends StateNodeJSON {
184
184
  guards?: Record<string, {
185
185
  when: ConditionJSON;
186
186
  }>;
187
- actorSources?: Record<string, unknown>;
187
+ actors?: Record<string, unknown>;
188
188
  delays?: Record<string, number | string | {
189
189
  duration: number | string | ResolvableJSON;
190
190
  }>;
@@ -199,12 +199,12 @@ interface EvaluatorArgs {
199
199
  scope: Record<string, unknown>;
200
200
  path: string;
201
201
  }
202
- interface MachineImplementations {
202
+ interface MachineSources {
203
203
  actions?: Record<string, (...args: any[]) => unknown>;
204
204
  guards?: Record<string, (...args: any[]) => boolean>;
205
- actorSources?: Record<string, AnyActorLogic>;
205
+ actors?: Record<string, AnyActorLogic>;
206
206
  delays?: Record<string, number | ((...args: any[]) => number)>;
207
207
  evaluators?: Record<string, (args: EvaluatorArgs) => unknown>;
208
208
  }
209
- export declare function createMachineFromConfig(json: MachineJSON, implementations?: MachineImplementations): AnyStateMachine;
209
+ export declare function createMachineFromConfig(json: MachineJSON, sources?: MachineSources): AnyStateMachine;
210
210
  export {};
@@ -10,9 +10,9 @@ export type FSMSnapshot<TContext extends MachineContext, TState extends string,
10
10
  _stateInput: Record<string, unknown> | undefined;
11
11
  machine: {
12
12
  id: string;
13
- implementations: {
13
+ sources: {
14
14
  actions: {};
15
- actorSources: {};
15
+ actors: {};
16
16
  guards: {};
17
17
  delays: {};
18
18
  };
@@ -21,7 +21,7 @@ export { getStateNodes } from "./stateUtils.js";
21
21
  export type { ActorSystem, ActorSystemRuntime, AnyActorSystem } from "./system.js";
22
22
  export { toPromise } from "./toPromise.js";
23
23
  export * from "./types.js";
24
- export type { Next_MachineConfig as MachineConfig, Next_StateNodeConfig as StateNodeConfig, Next_InvokeConfig as InvokeConfig, Next_TransitionConfigOrTarget as TransitionConfigOrTarget, Implementations, InferEvents, WidenLiterals } from "./types.v6.js";
24
+ export type { Next_MachineConfig as MachineConfig, Next_StateNodeConfig as StateNodeConfig, Next_InvokeConfig as InvokeConfig, Next_TransitionConfigOrTarget as TransitionConfigOrTarget, Sources, InferEvents, WidenLiterals } from "./types.v6.js";
25
25
  export { getAllOwnEventDescriptors as __unsafe_getAllOwnEventDescriptors, matchesState, checkStateIn, pathToStateValue, toObserver } from "./utils.js";
26
26
  export { transition, initialTransition, getMicrosteps, getInitialMicrosteps, getNextTransitions } from "./transition.js";
27
27
  export { executeEffects, isBuiltInExecutableAction } from "./transitionActions.js";
@@ -3,6 +3,11 @@ export interface StandardSchemaV1<Input = unknown, Output = Input> {
3
3
  /** The Standard Schema properties. */
4
4
  readonly '~standard': StandardSchemaV1.Props<Input, Output>;
5
5
  }
6
+ /** Schemas that can be declared for an individual state node. */
7
+ export type SetupStateSchemas = {
8
+ context?: StandardSchemaV1;
9
+ input?: StandardSchemaV1;
10
+ };
6
11
  /** A type-only Standard Schema produced by {@link types}. */
7
12
  export interface TypeSchema<T> extends StandardSchemaV1<T, T> {
8
13
  readonly '~standard': StandardSchemaV1.Props<T, T> & {
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * `machineConfigToJSON` converts a machine config into a JSON-safe structure
5
5
  * (the `MachineJSON` shape accepted by `createMachineFromConfig`). The boundary
6
- * between serializable structure and runtime implementations is explicit:
7
- * functions are represented as `@code` source objects, while actor logic,
8
- * runtime schemas, and other non-data runtime values are omitted.
6
+ * between serializable structure and runtime sources is explicit: functions are
7
+ * represented as `@code` source objects, while actor logic, runtime schemas,
8
+ * and other non-data runtime values are omitted.
9
9
  */
10
10
  import type { AnyStateMachine } from "./types.js";
11
11
  export interface CodeExpression {