xstate 6.0.0-alpha.7 → 6.0.0-alpha.8

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 (34) hide show
  1. package/dist/{StateMachine-2b259bff.development.esm.js → StateMachine-0aa98f54.development.esm.js} +10 -10
  2. package/dist/{StateMachine-6673bf76.cjs.js → StateMachine-aef700df.cjs.js} +9 -9
  3. package/dist/{StateMachine-1ff90553.esm.js → StateMachine-d4931336.esm.js} +9 -9
  4. package/dist/{StateMachine-68fe6077.development.cjs.js → StateMachine-da872dde.development.cjs.js} +10 -10
  5. package/dist/declarations/src/StateMachine.d.ts +4 -4
  6. package/dist/declarations/src/createMachine.d.ts +4 -4
  7. package/dist/declarations/src/createMachineFromConfig.d.ts +2 -2
  8. package/dist/declarations/src/serialize.d.ts +2 -1
  9. package/dist/declarations/src/setup.d.ts +31 -25
  10. package/dist/declarations/src/types.d.ts +54 -42
  11. package/dist/declarations/src/types.v6.d.ts +21 -21
  12. package/dist/declarations/src/utils.d.ts +2 -1
  13. package/dist/{index-b063a967.development.cjs.js → index-219cb621.development.cjs.js} +35 -13
  14. package/dist/{index-9594f050.development.esm.js → index-2f2fbd9b.development.esm.js} +35 -13
  15. package/dist/{index-87499be0.cjs.js → index-559ceab3.cjs.js} +35 -13
  16. package/dist/{index-aaf74d09.esm.js → index-8828376f.esm.js} +35 -13
  17. package/dist/xstate-actors.cjs.js +1 -1
  18. package/dist/xstate-actors.development.cjs.js +1 -1
  19. package/dist/xstate-actors.development.esm.js +1 -1
  20. package/dist/xstate-actors.esm.js +1 -1
  21. package/dist/xstate-actors.umd.min.js.map +1 -1
  22. package/dist/xstate-graph.cjs.js +2 -2
  23. package/dist/xstate-graph.development.cjs.js +2 -2
  24. package/dist/xstate-graph.development.esm.js +2 -2
  25. package/dist/xstate-graph.esm.js +2 -2
  26. package/dist/xstate-graph.umd.min.js +1 -1
  27. package/dist/xstate-graph.umd.min.js.map +1 -1
  28. package/dist/xstate.cjs.js +17 -16
  29. package/dist/xstate.development.cjs.js +17 -16
  30. package/dist/xstate.development.esm.js +19 -18
  31. package/dist/xstate.esm.js +19 -18
  32. package/dist/xstate.umd.min.js +1 -1
  33. package/dist/xstate.umd.min.js.map +1 -1
  34. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { P as ProcessingStatus, C as resolveReferencedActor, c as createActor, S as STATE_DELIMITER, D as mapValues, t as toArray, E as createInvokeId, F as getDelayedTransitions, G as evaluateCandidate, H as formatTransition, N as NULL_EVENT, I as toTransitionConfigArray, J as createInvokeTimeoutEvent, K as getCandidates, L as formatRouteTransitions, M as resolveStateValue, O as getAllStateNodes, f as getStateNodes, Q as createMachineSnapshot, R as isInFinalState, a as macrostep, U as transitionNode, m as matchesEventDescriptor, V as resolveActionsWithContext, b as createInitEvent, d as initialMicrostep, W as toStatePath, X as isStateId, Y as getStateNodeByPath, Z as getPersistedSnapshot, $ as $$ACTOR_TYPE } from './index-9594f050.development.esm.js';
1
+ import { P as ProcessingStatus, C as resolveReferencedActor, c as createActor, S as STATE_DELIMITER, D as mapValues, t as toArray, E as createInvokeId, F as getDelayedTransitions, G as evaluateCandidate, H as formatTransition, N as NULL_EVENT, I as toTransitionConfigArray, J as createInvokeTimeoutEvent, K as getCandidates, L as formatRouteTransitions, M as resolveStateValue, O as getAllStateNodes, f as getStateNodes, Q as createMachineSnapshot, R as isInFinalState, a as macrostep, U as transitionNode, m as matchesEventDescriptor, V as resolveActionsWithContext, b as createInitEvent, d as initialMicrostep, W as toStatePath, X as isStateId, Y as getStateNodeByPath, Z as getPersistedSnapshot, $ as $$ACTOR_TYPE } from './index-2f2fbd9b.development.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -422,7 +422,7 @@ class StateMachine {
422
422
  this._json = void 0;
423
423
  this.id = config.id || '(machine)';
424
424
  this.implementations = {
425
- actors: config.actors ?? {},
425
+ actorSources: config.actorSources ?? {},
426
426
  actions: config.actions ?? {},
427
427
  delays: config.delays ?? {},
428
428
  guards: config.guards ?? {},
@@ -431,7 +431,7 @@ class StateMachine {
431
431
  {
432
432
  // The `@xstate.` prefix is reserved for built-in serialized action and
433
433
  // guard descriptors — user implementation names must not collide.
434
- for (const kind of ['actions', 'guards', 'actors', 'delays']) {
434
+ for (const kind of ['actions', 'guards', 'actorSources', 'delays']) {
435
435
  for (const key of Object.keys(this.implementations[kind])) {
436
436
  if (key.startsWith('@xstate.')) {
437
437
  throw new Error(`Invalid ${kind} name '${key}': the '@xstate.' prefix is reserved for built-in descriptors.`);
@@ -469,15 +469,15 @@ class StateMachine {
469
469
  /**
470
470
  * Clones this state machine with the provided implementations.
471
471
  *
472
- * @param implementations Options (`actions`, `guards`, `actors`, `delays`) to
473
- * recursively merge with the existing options.
472
+ * @param implementations Options (`actions`, `guards`, `actorSources`,
473
+ * `delays`) to recursively merge with the existing options.
474
474
  * @returns A new `StateMachine` instance with the provided implementations.
475
475
  */
476
476
  provide(implementations) {
477
477
  const {
478
478
  actions,
479
479
  guards,
480
- actors,
480
+ actorSources,
481
481
  delays
482
482
  } = this.implementations;
483
483
  const provided = new StateMachine(this.config, {
@@ -489,9 +489,9 @@ class StateMachine {
489
489
  ...guards,
490
490
  ...implementations.guards
491
491
  },
492
- actors: {
493
- ...actors,
494
- ...implementations.actors
492
+ actorSources: {
493
+ ...actorSources,
494
+ ...implementations.actorSources
495
495
  },
496
496
  delays: {
497
497
  ...delays,
@@ -585,7 +585,7 @@ class StateMachine {
585
585
  spawn,
586
586
  input: initEvent.input,
587
587
  self: actorScope.self,
588
- actors: this.implementations.actors
588
+ actorSources: this.implementations.actorSources
589
589
  });
590
590
  const [nextState] = resolveActionsWithContext(preInitial, initEvent, actorScope, []);
591
591
  if (resolvedContext) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var dist_xstateActors = require('./index-87499be0.cjs.js');
3
+ var dist_xstateActors = require('./index-559ceab3.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -424,7 +424,7 @@ class StateMachine {
424
424
  this._json = void 0;
425
425
  this.id = config.id || '(machine)';
426
426
  this.implementations = {
427
- actors: config.actors ?? {},
427
+ actorSources: config.actorSources ?? {},
428
428
  actions: config.actions ?? {},
429
429
  delays: config.delays ?? {},
430
430
  guards: config.guards ?? {},
@@ -457,15 +457,15 @@ class StateMachine {
457
457
  /**
458
458
  * Clones this state machine with the provided implementations.
459
459
  *
460
- * @param implementations Options (`actions`, `guards`, `actors`, `delays`) to
461
- * recursively merge with the existing options.
460
+ * @param implementations Options (`actions`, `guards`, `actorSources`,
461
+ * `delays`) to recursively merge with the existing options.
462
462
  * @returns A new `StateMachine` instance with the provided implementations.
463
463
  */
464
464
  provide(implementations) {
465
465
  const {
466
466
  actions,
467
467
  guards,
468
- actors,
468
+ actorSources,
469
469
  delays
470
470
  } = this.implementations;
471
471
  const provided = new StateMachine(this.config, {
@@ -477,9 +477,9 @@ class StateMachine {
477
477
  ...guards,
478
478
  ...implementations.guards
479
479
  },
480
- actors: {
481
- ...actors,
482
- ...implementations.actors
480
+ actorSources: {
481
+ ...actorSources,
482
+ ...implementations.actorSources
483
483
  },
484
484
  delays: {
485
485
  ...delays,
@@ -573,7 +573,7 @@ class StateMachine {
573
573
  spawn,
574
574
  input: initEvent.input,
575
575
  self: actorScope.self,
576
- actors: this.implementations.actors
576
+ actorSources: this.implementations.actorSources
577
577
  });
578
578
  const [nextState] = dist_xstateActors.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
579
579
  if (resolvedContext) {
@@ -1,4 +1,4 @@
1
- import { P as ProcessingStatus, C as resolveReferencedActor, c as createActor, S as STATE_DELIMITER, D as mapValues, t as toArray, E as createInvokeId, F as getDelayedTransitions, G as evaluateCandidate, H as formatTransition, N as NULL_EVENT, I as toTransitionConfigArray, J as createInvokeTimeoutEvent, K as getCandidates, L as formatRouteTransitions, M as resolveStateValue, O as getAllStateNodes, f as getStateNodes, Q as createMachineSnapshot, R as isInFinalState, a as macrostep, U as transitionNode, m as matchesEventDescriptor, V as resolveActionsWithContext, b as createInitEvent, d as initialMicrostep, W as toStatePath, X as isStateId, Y as getStateNodeByPath, Z as getPersistedSnapshot, $ as $$ACTOR_TYPE } from './index-aaf74d09.esm.js';
1
+ import { P as ProcessingStatus, C as resolveReferencedActor, c as createActor, S as STATE_DELIMITER, D as mapValues, t as toArray, E as createInvokeId, F as getDelayedTransitions, G as evaluateCandidate, H as formatTransition, N as NULL_EVENT, I as toTransitionConfigArray, J as createInvokeTimeoutEvent, K as getCandidates, L as formatRouteTransitions, M as resolveStateValue, O as getAllStateNodes, f as getStateNodes, Q as createMachineSnapshot, R as isInFinalState, a as macrostep, U as transitionNode, m as matchesEventDescriptor, V as resolveActionsWithContext, b as createInitEvent, d as initialMicrostep, W as toStatePath, X as isStateId, Y as getStateNodeByPath, Z as getPersistedSnapshot, $ as $$ACTOR_TYPE } from './index-8828376f.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -422,7 +422,7 @@ class StateMachine {
422
422
  this._json = void 0;
423
423
  this.id = config.id || '(machine)';
424
424
  this.implementations = {
425
- actors: config.actors ?? {},
425
+ actorSources: config.actorSources ?? {},
426
426
  actions: config.actions ?? {},
427
427
  delays: config.delays ?? {},
428
428
  guards: config.guards ?? {},
@@ -455,15 +455,15 @@ class StateMachine {
455
455
  /**
456
456
  * Clones this state machine with the provided implementations.
457
457
  *
458
- * @param implementations Options (`actions`, `guards`, `actors`, `delays`) to
459
- * recursively merge with the existing options.
458
+ * @param implementations Options (`actions`, `guards`, `actorSources`,
459
+ * `delays`) to recursively merge with the existing options.
460
460
  * @returns A new `StateMachine` instance with the provided implementations.
461
461
  */
462
462
  provide(implementations) {
463
463
  const {
464
464
  actions,
465
465
  guards,
466
- actors,
466
+ actorSources,
467
467
  delays
468
468
  } = this.implementations;
469
469
  const provided = new StateMachine(this.config, {
@@ -475,9 +475,9 @@ class StateMachine {
475
475
  ...guards,
476
476
  ...implementations.guards
477
477
  },
478
- actors: {
479
- ...actors,
480
- ...implementations.actors
478
+ actorSources: {
479
+ ...actorSources,
480
+ ...implementations.actorSources
481
481
  },
482
482
  delays: {
483
483
  ...delays,
@@ -571,7 +571,7 @@ class StateMachine {
571
571
  spawn,
572
572
  input: initEvent.input,
573
573
  self: actorScope.self,
574
- actors: this.implementations.actors
574
+ actorSources: this.implementations.actorSources
575
575
  });
576
576
  const [nextState] = resolveActionsWithContext(preInitial, initEvent, actorScope, []);
577
577
  if (resolvedContext) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var dist_xstateActors = require('./index-b063a967.development.cjs.js');
3
+ var dist_xstateActors = require('./index-219cb621.development.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -424,7 +424,7 @@ class StateMachine {
424
424
  this._json = void 0;
425
425
  this.id = config.id || '(machine)';
426
426
  this.implementations = {
427
- actors: config.actors ?? {},
427
+ actorSources: config.actorSources ?? {},
428
428
  actions: config.actions ?? {},
429
429
  delays: config.delays ?? {},
430
430
  guards: config.guards ?? {},
@@ -433,7 +433,7 @@ class StateMachine {
433
433
  {
434
434
  // The `@xstate.` prefix is reserved for built-in serialized action and
435
435
  // guard descriptors — user implementation names must not collide.
436
- for (const kind of ['actions', 'guards', 'actors', 'delays']) {
436
+ for (const kind of ['actions', 'guards', 'actorSources', 'delays']) {
437
437
  for (const key of Object.keys(this.implementations[kind])) {
438
438
  if (key.startsWith('@xstate.')) {
439
439
  throw new Error(`Invalid ${kind} name '${key}': the '@xstate.' prefix is reserved for built-in descriptors.`);
@@ -471,15 +471,15 @@ class StateMachine {
471
471
  /**
472
472
  * Clones this state machine with the provided implementations.
473
473
  *
474
- * @param implementations Options (`actions`, `guards`, `actors`, `delays`) to
475
- * recursively merge with the existing options.
474
+ * @param implementations Options (`actions`, `guards`, `actorSources`,
475
+ * `delays`) to recursively merge with the existing options.
476
476
  * @returns A new `StateMachine` instance with the provided implementations.
477
477
  */
478
478
  provide(implementations) {
479
479
  const {
480
480
  actions,
481
481
  guards,
482
- actors,
482
+ actorSources,
483
483
  delays
484
484
  } = this.implementations;
485
485
  const provided = new StateMachine(this.config, {
@@ -491,9 +491,9 @@ class StateMachine {
491
491
  ...guards,
492
492
  ...implementations.guards
493
493
  },
494
- actors: {
495
- ...actors,
496
- ...implementations.actors
494
+ actorSources: {
495
+ ...actorSources,
496
+ ...implementations.actorSources
497
497
  },
498
498
  delays: {
499
499
  ...delays,
@@ -587,7 +587,7 @@ class StateMachine {
587
587
  spawn,
588
588
  input: initEvent.input,
589
589
  self: actorScope.self,
590
- actors: this.implementations.actors
590
+ actorSources: this.implementations.actorSources
591
591
  });
592
592
  const [nextState] = dist_xstateActors.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
593
593
  if (resolvedContext) {
@@ -3,7 +3,7 @@ import { StateNode } from "./StateNode.js";
3
3
  import { AnyActorSystem } from "./system.js";
4
4
  import type { ActorLogic, ActorLogicTransitionResult, ActorScope, AnyActor, AnyActorRef, AnyActorScope, AnyTransitionDefinition, Equals, EventDescriptor, EventObject, ExecutableActionObjectFromLogic, HistoryValue, MachineContext, MetaObject, Snapshot, StateValue, StateSchema, SnapshotStatus } from "./types.js";
5
5
  import { AnyMachineSchemas, Implementations, Next_MachineConfig, MachineOptions } from "./types.v6.js";
6
- 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['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> implements ActorLogic<MachineSnapshot<TContext, TEvent, TChildren, TStateValue, TTag, TOutput, TMeta, TConfig>, TEvent, TInput, AnyActorSystem, TEmitted> {
6
+ 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> {
7
7
  /** The raw config used to create the machine. */
8
8
  config: Next_MachineConfig<any, any, any, any, any, any, any, any, any, any, any> & {
9
9
  schemas?: AnyMachineSchemas;
@@ -29,13 +29,13 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
29
29
  /**
30
30
  * Clones this state machine with the provided implementations.
31
31
  *
32
- * @param implementations Options (`actions`, `guards`, `actors`, `delays`) to
33
- * recursively merge with the existing options.
32
+ * @param implementations Options (`actions`, `guards`, `actorSources`,
33
+ * `delays`) to recursively merge with the existing options.
34
34
  * @returns A new `StateMachine` instance with the provided implementations.
35
35
  */
36
36
  provide(implementations: {
37
37
  actions?: Partial<TActionMap>;
38
- actors?: Partial<TActorMap>;
38
+ actorSources?: Partial<TActorMap>;
39
39
  guards?: Partial<TGuardMap>;
40
40
  delays?: Partial<TDelayMap>;
41
41
  }): StateMachine<TContext, TEvent, TChildren, TStateValue, TTag, TInput, TOutput, TEmitted, TMeta, TConfig, TActionMap, TActorMap, TGuardMap, TDelayMap>;
@@ -45,7 +45,7 @@ type MergeChildren<TChildren extends Record<string, AnyActorRef | undefined>, TA
45
45
  * @param options DEPRECATED: use `setup({ ... })` or `machine.provide({ ... })`
46
46
  * to provide machine implementations 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, 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['actors'], 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, 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> & {
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, 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['actors'] = Implementations['actors'], 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, 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> & {
62
62
  schemas?: {
63
63
  context?: never;
64
64
  };
65
65
  context?: TContext | ((_: {
66
66
  spawn: any;
67
- actors: TActorMap;
67
+ actorSources: 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, 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['actors'], 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 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;
81
81
  export {};
@@ -159,7 +159,7 @@ export interface MachineJSON extends StateNodeJSON {
159
159
  version?: string;
160
160
  actions?: Record<string, unknown>;
161
161
  guards?: Record<string, unknown>;
162
- actors?: Record<string, unknown>;
162
+ actorSources?: Record<string, unknown>;
163
163
  delays?: Record<string, unknown>;
164
164
  schemas?: Record<string, unknown>;
165
165
  }
@@ -170,7 +170,7 @@ interface UnserializableMarker {
170
170
  interface MachineImplementations {
171
171
  actions?: Record<string, (...args: any[]) => unknown>;
172
172
  guards?: Record<string, (...args: any[]) => boolean>;
173
- actors?: Record<string, AnyActorLogic>;
173
+ actorSources?: Record<string, AnyActorLogic>;
174
174
  delays?: Record<string, number | ((...args: any[]) => number)>;
175
175
  }
176
176
  export declare function createMachineFromConfig(json: MachineJSON, implementations?: MachineImplementations): AnyStateMachine;
@@ -11,7 +11,8 @@
11
11
  * A machine definition is fully portable iff its JSON contains no
12
12
  * `$unserializable` markers; reviving a definition that has markers requires
13
13
  * re-providing those implementations (e.g. via `machine.provide(...)` or the
14
- * `actions`/`guards`/`actors` maps on `createMachineFromConfig` revival).
14
+ * `actions`/`guards`/`actorSources` maps on `createMachineFromConfig`
15
+ * revival).
15
16
  */
16
17
  import type { AnyStateMachine } from "./types.js";
17
18
  export interface UnserializableMarker {
@@ -1,14 +1,15 @@
1
1
  import { StandardSchemaV1 } from "./schema.types.js";
2
2
  import { StateMachine } from "./StateMachine.js";
3
3
  import { type Actor, type RequiredActorOptionsKeys } from "./createActor.js";
4
- import { AnyActorRef, AnyActorLogic, ActorRefFromLogic, AnyStateNode, EventObject, AnyEventObject, EventDescriptor, ExtractEvent, MachineContext, ProvidedActor, RoutableStateId, StateSchema, StateValue, ToChildren, MetaObject, Cast, Compute, EnqueueObject, SystemRegistry, RegistryKeyForLogic, ActorOptions, Observer, Subscription } from "./types.js";
4
+ import { AnyActorRef, AnyActorLogic, ActorRefFromLogic, AnyStateNode, EventObject, AnyEventObject, EventDescriptor, ExtractEvent, MachineContext, ProvidedActor, RoutableStateId, StateSchema, StateValue, ToChildren, MetaObject, Cast, Compute, EnqueueObject, SystemRegistry, RegistryKeyForLogic, ActorOptions, Observer, Subscription, OutputArg } from "./types.js";
5
+ import { AnyActorSystem } from "./system.js";
5
6
  import { InspectionEvent } from "./inspection.js";
6
7
  import { DelayMapFromNames, InferChildren, Implementations, InferOutput, InferEvents, Next_MachineConfig, Next_StateNodeConfig, WithDefault } from "./types.v6.js";
7
- 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']> = {
8
+ type SetupConfig<TSchemas extends SetupSchemas, TStates extends Record<string, SetupStateSchema>, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays']> = {
8
9
  schemas?: TSchemas;
9
10
  states?: TStates;
10
11
  actions?: TActionMap;
11
- actors?: TActorMap;
12
+ actorSources?: TActorMap;
12
13
  guards?: TGuardMap;
13
14
  delays?: TDelayMap;
14
15
  };
@@ -18,9 +19,13 @@ type SystemConfig<TSystemRegistry extends SystemRegistry> = {
18
19
  type SystemActorMap<TSystemRegistry extends SystemRegistry> = {
19
20
  [K in keyof TSystemRegistry & string]: ActorRefFromLogic<TSystemRegistry[K]>;
20
21
  };
22
+ type SystemRuntime<TSystemRegistry extends SystemRegistry> = Omit<AnyActorSystem, 'get' | 'getAll'> & {
23
+ get<K extends keyof SystemActorMap<TSystemRegistry> & string>(key: K): SystemActorMap<TSystemRegistry>[K] | undefined;
24
+ getAll(): Partial<SystemActorMap<TSystemRegistry>>;
25
+ };
21
26
  type LogicMatchesRegistryKey<TLogic, TSystemLogic> = TLogic extends AnyActorLogic ? TSystemLogic extends AnyActorLogic ? [TLogic] extends [TSystemLogic] ? true : [TSystemLogic] extends [TLogic] ? true : ActorRefFromLogic<TLogic> extends ActorRefFromLogic<TSystemLogic> ? true : false : false : false;
22
- type RegistryKeyMatchesSrc<TKey extends string, TSrc, TSystemRegistry extends SystemRegistry, TActorMap extends Implementations['actors']> = TKey extends keyof TSystemRegistry & string ? TSrc extends keyof TActorMap & string ? LogicMatchesRegistryKey<TActorMap[TSrc], TSystemRegistry[TKey]> : TSrc extends AnyActorLogic ? LogicMatchesRegistryKey<TSrc, TSystemRegistry[TKey]> : true : false;
23
- type ValidateSystemInvoke<TInvoke, TSystemRegistry extends SystemRegistry, TActorMap extends Implementations['actors']> = TInvoke extends readonly unknown[] ? {
27
+ type RegistryKeyMatchesSrc<TKey extends string, TSrc, TSystemRegistry extends SystemRegistry, TActorMap extends Implementations['actorSources']> = TKey extends keyof TSystemRegistry & string ? TSrc extends keyof TActorMap & string ? LogicMatchesRegistryKey<TActorMap[TSrc], TSystemRegistry[TKey]> : TSrc extends AnyActorLogic ? LogicMatchesRegistryKey<TSrc, TSystemRegistry[TKey]> : true : false;
28
+ type ValidateSystemInvoke<TInvoke, TSystemRegistry extends SystemRegistry, TActorMap extends Implementations['actorSources']> = TInvoke extends readonly unknown[] ? {
24
29
  [K in keyof TInvoke]: TInvoke[K] & ValidateSystemInvoke<TInvoke[K], TSystemRegistry, TActorMap>;
25
30
  } : TInvoke extends {
26
31
  registryKey: infer TKey;
@@ -33,7 +38,7 @@ type ValidateSystemInvoke<TInvoke, TSystemRegistry extends SystemRegistry, TActo
33
38
  } : {
34
39
  registryKey: never;
35
40
  } : unknown;
36
- type ValidateRegistryKeys<TConfig, TSystemRegistry extends SystemRegistry, TActorMap extends Implementations['actors']> = string extends keyof TSystemRegistry ? unknown : (TConfig extends {
41
+ type ValidateRegistryKeys<TConfig, TSystemRegistry extends SystemRegistry, TActorMap extends Implementations['actorSources']> = string extends keyof TSystemRegistry ? unknown : (TConfig extends {
37
42
  invoke: infer TInvoke;
38
43
  } ? {
39
44
  invoke: TInvoke & ValidateSystemInvoke<TInvoke, TSystemRegistry, TActorMap>;
@@ -192,9 +197,9 @@ type MergeStateSchema<TConfig extends StateSchema, TSetup extends StateSchema> =
192
197
  } : undefined : undefined;
193
198
  };
194
199
  /** Machine config with typed state input */
195
- 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'], TSystemRegistry extends SystemRegistry, 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, TSystemRegistry>, 'states' | 'initial' | 'on' | 'always' | 'actions' | 'actors' | 'guards' | 'delays'> & {
200
+ type SetupMachineConfig<TStateSchemas extends Record<string, SetupStateSchema>, TSchemas extends SetupSchemas, TContextSchema extends StandardSchemaV1, TEventSchemaMap extends Record<string, StandardSchemaV1>, TEmittedSchemaMap extends Record<string, StandardSchemaV1>, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TTagSchema extends StandardSchemaV1, TChildrenSchemaMap extends Record<string, StandardSchemaV1>, TContext extends MachineContext, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry, TContextRequired extends boolean, TRootDelays extends string = TDelays, TRootActionMap extends Implementations['actions'] = TActionMap, TRootActorMap extends Implementations['actorSources'] = TActorMap, TRootGuardMap extends Implementations['guards'] = TGuardMap> = Omit<Next_MachineConfig<SetupOrConfigSchema<TSchemas, 'context', TContextSchema>, SetupOrConfigSchemaMap<TSchemas, 'events', TEventSchemaMap>, SetupOrConfigSchemaMap<TSchemas, 'emitted', TEmittedSchemaMap>, SetupOrConfigSchema<TSchemas, 'input', TInputSchema>, SetupOrConfigSchema<TSchemas, 'output', TOutputSchema>, SetupOrConfigSchema<TSchemas, 'meta', TMetaSchema>, SetupOrConfigSchema<TSchemas, 'tags', TTagSchema>, SetupOrConfigSchemaMap<TSchemas, 'children', TChildrenSchemaMap>, TContext, TEvent, TChildren, TDelays, TTag, TActionMap, TActorMap, TGuardMap, TDelayMap, TContextRequired, TSystemRegistry>, 'states' | 'initial' | 'on' | 'always' | 'actions' | 'actorSources' | 'guards' | 'delays'> & {
196
201
  actions?: TRootActionMap;
197
- actors?: TRootActorMap;
202
+ actorSources?: TRootActorMap;
198
203
  guards?: TRootGuardMap;
199
204
  delays?: {
200
205
  [K in TRootDelays | number]?: number | (({ context, event, stateNode }: {
@@ -209,11 +214,11 @@ type SetupMachineConfig<TStateSchemas extends Record<string, SetupStateSchema>,
209
214
  states?: StatesWithInput<TStateSchemas, TStateSchemas, TContext, SetupContextShape<TSchemas, TContextSchema, TContext>, TEvent, TChildren, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
210
215
  };
211
216
  /** States config type that provides typed input for known states */
212
- type StatesWithInput<TRootStateSchemas extends Record<string, SetupStateSchema>, TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, 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'], TSystemRegistry extends SystemRegistry> = {
217
+ type StatesWithInput<TRootStateSchemas extends Record<string, SetupStateSchema>, TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = {
213
218
  [K in keyof TStateSchemas & string]?: StateNodeConfigWithNestedInput<TRootStateSchemas, TStateSchemas[K], TContext, TContextShape, TEvent, TChildren, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
214
219
  };
215
220
  /** State node config that recursively applies typed input for nested states */
216
- type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = WithNestedStates<Omit<Next_StateNodeConfig<StateContext<TStateSchema, TContext>, TEvent, TDelays, TTag, any, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, StateInput<TStateSchema>, Record<string, unknown>, TSystemRegistry>, 'on' | 'always' | 'initial'> & {
221
+ type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string, SetupStateSchema>, TStateSchema extends SetupStateSchema, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TDelays extends string, TTag extends string, TEmitted extends EventObject, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = WithNestedStates<Omit<Next_StateNodeConfig<StateContext<TStateSchema, TContext>, TEvent, TDelays, TTag, any, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, StateInput<TStateSchema>, Record<string, unknown>, TSystemRegistry>, 'on' | 'always' | 'initial'> & {
217
222
  initial?: TStateSchema['states'] extends Record<string, SetupStateSchema> ? SetupStateKey<TStateSchema['states']> | InitialTransitionWithInput<TStateSchema['states'], StateContext<TStateSchema, TContext>, TEvent> : string | {
218
223
  target: string;
219
224
  input?: Record<string, unknown>;
@@ -223,10 +228,10 @@ type StateNodeConfigWithNestedInput<TSiblingStateSchemas extends Record<string,
223
228
  }, TStateSchema['states'] extends Record<string, SetupStateSchema> ? StatesWithInput<TStateSchema['states'], TStateSchema['states'], TContext, StateContextShape<TStateSchema, TContextShape>, TEvent, TChildren, TDelays, TTag, TEmitted, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry> : {
224
229
  [K in string]?: Next_StateNodeConfig<TContext, TEvent, TDelays, TTag, any, TEmitted, TMeta, TChildren, TActionMap, TActorMap, TGuardMap, TDelayMap, undefined, Record<string, unknown>, TSystemRegistry>;
225
230
  }>;
226
- type StateTransitions<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = {
231
+ type StateTransitions<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = {
227
232
  [K in EventDescriptor<TEvent>]?: StateTransitionConfigOrTarget<TStateSchemas, TContext, TContextShape, ExtractEvent<TEvent, K>, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
228
233
  };
229
- type StateTransitionConfigOrTarget<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = undefined | StateTransitionObjectConfig<TStateSchemas, TContext, TContextShape, TExpressionEvent, TMeta> | StateTransitionFunction<TStateSchemas, TContext, TContextShape, TExpressionEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
234
+ type StateTransitionConfigOrTarget<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = undefined | StateTransitionObjectConfig<TStateSchemas, TContext, TContextShape, TExpressionEvent, TMeta> | StateTransitionFunction<TStateSchemas, TContext, TContextShape, TExpressionEvent, TEvent, TEmitted, TChildren, TMeta, TActionMap, TActorMap, TGuardMap, TDelayMap, TSystemRegistry>;
230
235
  type StateTransitionObjectConfig<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TMeta extends MetaObject> = (StateTransitionResult<TStateSchemas, TContext, TContextShape, TMeta> & {
231
236
  description?: string;
232
237
  }) | {
@@ -238,20 +243,21 @@ type StateTransitionObjectConfig<TStateSchemas extends Record<string, SetupState
238
243
  input?: Record<string, unknown> | ((args: {
239
244
  context: TContext;
240
245
  event: TExpressionEvent;
241
- }) => Record<string, unknown>);
246
+ } & OutputArg<TExpressionEvent>) => Record<string, unknown>);
242
247
  };
243
- type StateTransitionFunction<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actors'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = (args: {
248
+ type StateTransitionFunction<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TExpressionEvent extends EventObject, TEvent extends EventObject, TEmitted extends EventObject, TChildren extends Record<string, AnyActorRef | undefined>, TMeta extends MetaObject, TActionMap extends Implementations['actions'], TActorMap extends Implementations['actorSources'], TGuardMap extends Implementations['guards'], TDelayMap extends Implementations['delays'], TSystemRegistry extends SystemRegistry> = (args: {
244
249
  context: TContext;
245
250
  event: TExpressionEvent;
246
251
  self: AnyActorRef;
247
252
  parent: AnyActorRef | undefined;
248
253
  value: StateValue;
249
254
  children: TChildren;
255
+ system: SystemRuntime<TSystemRegistry>;
250
256
  actions: TActionMap;
251
- actors: TActorMap;
257
+ actorSources: TActorMap;
252
258
  guards: TGuardMap;
253
259
  delays: TDelayMap;
254
- }, enq: EnqueueObject<TEvent, TEmitted, TSystemRegistry>) => StateTransitionResult<TStateSchemas, TContext, TContextShape, TMeta> | void;
260
+ } & OutputArg<TExpressionEvent>, enq: EnqueueObject<TEvent, TEmitted, TSystemRegistry>) => StateTransitionResult<TStateSchemas, TContext, TContextShape, TMeta> | void;
255
261
  type StateTransitionResult<TStateSchemas extends Record<string, SetupStateSchema>, TContext extends MachineContext, TContextShape, TMeta extends MetaObject> = {
256
262
  target?: never;
257
263
  context?: ContextPatch<TContextShape, TContextShape, TContext>;
@@ -265,7 +271,7 @@ type StateTransitionResult<TStateSchemas extends Record<string, SetupStateSchema
265
271
  input?: StateInput<TStateSchemas[K]> | ((args: {
266
272
  context: TContext;
267
273
  event: EventObject;
268
- }) => StateInput<TStateSchemas[K]>);
274
+ } & OutputArg<EventObject>) => StateInput<TStateSchemas[K]>);
269
275
  } & ([TContextShape] extends [
270
276
  StateContextShape<TStateSchemas[K], TContextShape>
271
277
  ] ? {
@@ -294,11 +300,11 @@ type InitialTransitionWithInput<TStateSchemas extends Record<string, SetupStateS
294
300
  };
295
301
  }[keyof TStateSchemas & string];
296
302
  /** Return type of setup() */
297
- 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>, TSystemRegistry extends SystemRegistry = SystemRegistry> {
303
+ interface SetupReturn<TStates extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>, TSchemas extends SetupSchemas = {}, TSetupActionMap extends Implementations['actions'] = {}, TSetupActorMap extends Implementations['actorSources'] = {}, TSetupGuardMap extends Implementations['guards'] = {}, TSetupDelayMap extends Implementations['delays'] = {}, TSetupDelays extends string = Extract<keyof TSetupDelayMap, string>, TSystemRegistry extends SystemRegistry = SystemRegistry> {
298
304
  /** Extends the setup configuration */
299
- 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>, TSystemRegistry>;
305
+ extend<const TExtendSchemas extends SetupSchemas = {}, const TExtendStates extends Record<string, SetupStateSchema> = {}, TExtendActionMap extends Implementations['actions'] = {}, TExtendActorMap extends Implementations['actorSources'] = {}, 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>, TSystemRegistry>;
300
306
  /** Creates a state machine with the setup configuration */
301
- 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>, TSystemRegistry, 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>, TSystemRegistry, SetupContextRequired<TSchemas, TContextSchema>, TDelays, TActionMap, TActorMap, TGuardMap>>(config: {
307
+ 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['actorSources'] = {}, 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>, TSystemRegistry, 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>, TSystemRegistry, SetupContextRequired<TSchemas, TContextSchema>, TDelays, TActionMap, TActorMap, TGuardMap>>(config: {
302
308
  schemas?: {
303
309
  events?: TEventSchemaMap;
304
310
  context?: TContextSchema;
@@ -310,7 +316,7 @@ interface SetupReturn<TStates extends Record<string, SetupStateSchema> = Record<
310
316
  children?: TChildrenSchemaMap;
311
317
  };
312
318
  actions?: TActionMap;
313
- actors?: TActorMap;
319
+ actorSources?: TActorMap;
314
320
  guards?: TGuardMap;
315
321
  delays?: TDelayMap;
316
322
  } & TConfig & ValidateSetupStateKeys<TConfig, TStates> & ValidateNestedSetupStateKeys<TConfig, TStates> & ValidateSetupDelayReferences<TConfig, TSetupDelays> & ValidateRegistryKeys<TConfig, TSystemRegistry, MergeImplementationMaps<TSetupActorMap, TActorMap>>): StateMachine<SetupContext<TSchemas, TContextSchema>, SetupEvents<TSchemas, TEventSchemaMap> | ([RoutableStateId<Cast<TConfig, StateSchema>>] extends [never] ? never : {
@@ -360,17 +366,17 @@ interface SetupReturn<TStates extends Record<string, SetupStateSchema> = Record<
360
366
  * });
361
367
  * ```
362
368
  */
363
- 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>;
369
+ export declare function setup<const TSchemas extends SetupSchemas = {}, const TStates extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>, TActionMap extends Implementations['actions'] = {}, TActorMap extends Implementations['actorSources'] = {}, TGuardMap extends Implementations['guards'] = {}, TDelayMap extends Implementations['delays'] = {}>(config?: SetupConfig<TSchemas, TStates, TActionMap, TActorMap, TGuardMap, TDelayMap>): SetupReturn<TStates, TSchemas, TActionMap, TActorMap, TGuardMap, TDelayMap>;
364
370
  type SystemBuilder<TSystemRegistry extends SystemRegistry> = {
365
371
  createActor<TLogic extends AnyActorLogic>(logic: TLogic, options?: Omit<ActorOptions<TLogic>, 'registryKey'> & {
366
372
  registryKey?: RegistryKeyForLogic<TLogic, TSystemRegistry>;
367
373
  } & {
368
374
  [K in RequiredActorOptionsKeys<TLogic>]: unknown;
369
375
  }): Actor<TLogic>;
370
- get<K extends keyof SystemActorMap<TSystemRegistry> & string>(key: K): SystemActorMap<TSystemRegistry>[K] | undefined;
371
- getAll(): Partial<SystemActorMap<TSystemRegistry>>;
376
+ get: SystemRuntime<TSystemRegistry>['get'];
377
+ getAll: SystemRuntime<TSystemRegistry>['getAll'];
372
378
  inspect(observer: Observer<InspectionEvent> | ((inspectionEvent: InspectionEvent) => void)): Subscription;
373
- 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, Extract<keyof TDelayMap, string>, TSystemRegistry>;
379
+ setup<const TSchemas extends SetupSchemas = {}, const TStates extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>, TActionMap extends Implementations['actions'] = {}, TActorMap extends Implementations['actorSources'] = {}, TGuardMap extends Implementations['guards'] = {}, TDelayMap extends Implementations['delays'] = {}>(config?: SetupConfig<TSchemas, TStates, TActionMap, TActorMap, TGuardMap, TDelayMap>): SetupReturn<TStates, TSchemas, TActionMap, TActorMap, TGuardMap, TDelayMap, Extract<keyof TDelayMap, string>, TSystemRegistry>;
374
380
  };
375
381
  export declare function createSystem<const TSystemRegistry extends SystemRegistry = {}>(_config?: SystemConfig<TSystemRegistry>): SystemBuilder<TSystemRegistry>;
376
382
  export {};