xstate 5.0.0-beta.22 → 5.0.0-beta.23

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 (44) hide show
  1. package/actions/dist/xstate-actions.cjs.js +1 -1
  2. package/actions/dist/xstate-actions.development.cjs.js +1 -1
  3. package/actions/dist/xstate-actions.development.esm.js +1 -1
  4. package/actions/dist/xstate-actions.esm.js +1 -1
  5. package/actions/dist/xstate-actions.umd.min.js +1 -1
  6. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  7. package/actors/dist/xstate-actors.cjs.js +1 -1
  8. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  9. package/actors/dist/xstate-actors.development.esm.js +1 -1
  10. package/actors/dist/xstate-actors.esm.js +1 -1
  11. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  12. package/dist/{actions-4b70fc8d.development.cjs.js → actions-0fcd4d15.development.cjs.js} +9 -10
  13. package/dist/{actions-fb7384f8.esm.js → actions-bf7f6679.esm.js} +9 -10
  14. package/dist/{actions-8f2e997e.cjs.js → actions-e83129c5.cjs.js} +9 -10
  15. package/dist/{actions-d4305983.development.esm.js → actions-f6b5002d.development.esm.js} +9 -10
  16. package/dist/declarations/src/Machine.d.ts +2 -2
  17. package/dist/declarations/src/State.d.ts +5 -5
  18. package/dist/declarations/src/StateMachine.d.ts +24 -18
  19. package/dist/declarations/src/StateNode.d.ts +8 -8
  20. package/dist/declarations/src/actions/assign.d.ts +6 -6
  21. package/dist/declarations/src/actions/cancel.d.ts +7 -7
  22. package/dist/declarations/src/actions/choose.d.ts +4 -10
  23. package/dist/declarations/src/actions/log.d.ts +7 -7
  24. package/dist/declarations/src/actions/pure.d.ts +5 -17
  25. package/dist/declarations/src/actions/raise.d.ts +3 -3
  26. package/dist/declarations/src/actions/send.d.ts +22 -22
  27. package/dist/declarations/src/actions/stop.d.ts +7 -7
  28. package/dist/declarations/src/interpreter.d.ts +1 -1
  29. package/dist/declarations/src/stateUtils.d.ts +12 -12
  30. package/dist/declarations/src/typegenTypes.d.ts +1 -1
  31. package/dist/declarations/src/types.d.ts +106 -132
  32. package/dist/declarations/src/utils.d.ts +8 -8
  33. package/dist/xstate.cjs.js +6 -5
  34. package/dist/xstate.development.cjs.js +6 -5
  35. package/dist/xstate.development.esm.js +7 -6
  36. package/dist/xstate.esm.js +7 -6
  37. package/dist/xstate.umd.min.js +1 -1
  38. package/dist/xstate.umd.min.js.map +1 -1
  39. package/guards/dist/xstate-guards.cjs.js +1 -1
  40. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  41. package/guards/dist/xstate-guards.development.esm.js +1 -1
  42. package/guards/dist/xstate-guards.esm.js +1 -1
  43. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  44. package/package.json +1 -1
@@ -2441,7 +2441,12 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2441
2441
  _internalQueue: []
2442
2442
  });
2443
2443
  for (const action of actions) {
2444
- const resolved = typeof action === 'function' ? action : machine.implementations.actions[typeof action === 'string' ? action : action.type];
2444
+ const isInline = typeof action === 'function';
2445
+ const resolved = isInline ? action :
2446
+ // the existing type of `.actions` assumes non-nullable `TExpressionAction`
2447
+ // it's fine to cast this here to get a common type and lack of errors in the rest of the code
2448
+ // our logic below makes sure that we call those 2 "variants" correctly
2449
+ machine.implementations.actions[typeof action === 'string' ? action : action.type];
2445
2450
  if (!resolved) {
2446
2451
  continue;
2447
2452
  }
@@ -2450,12 +2455,7 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2450
2455
  event,
2451
2456
  self: actorCtx?.self,
2452
2457
  system: actorCtx?.system,
2453
- // TODO: figure out story for `action` and inline actions
2454
- // what those ones should receive?
2455
- //
2456
- // entry: ({ action }) => {}
2457
- // exit: assign(({ action }) => {})
2458
- action: typeof action === 'string' ? {
2458
+ action: isInline ? undefined : typeof action === 'string' ? {
2459
2459
  type: action
2460
2460
  } : action
2461
2461
  };
@@ -2595,9 +2595,8 @@ class State {
2595
2595
  */
2596
2596
 
2597
2597
  /**
2598
- * The done data of the top-level finite state.
2598
+ * The output data of the top-level finite state.
2599
2599
  */
2600
- // TODO: add an explicit type for `output`
2601
2600
 
2602
2601
  /**
2603
2602
  * The enabled state nodes representative of the state value.
@@ -3056,7 +3055,7 @@ function resolve(_, state, args, {
3056
3055
  get
3057
3056
  }) {
3058
3057
  return [state, undefined, toArray(get({
3059
- context: state.context,
3058
+ context: args.context,
3060
3059
  event: args.event
3061
3060
  }))];
3062
3061
  }
@@ -2398,7 +2398,12 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2398
2398
  _internalQueue: []
2399
2399
  });
2400
2400
  for (const action of actions) {
2401
- const resolved = typeof action === 'function' ? action : machine.implementations.actions[typeof action === 'string' ? action : action.type];
2401
+ const isInline = typeof action === 'function';
2402
+ const resolved = isInline ? action :
2403
+ // the existing type of `.actions` assumes non-nullable `TExpressionAction`
2404
+ // it's fine to cast this here to get a common type and lack of errors in the rest of the code
2405
+ // our logic below makes sure that we call those 2 "variants" correctly
2406
+ machine.implementations.actions[typeof action === 'string' ? action : action.type];
2402
2407
  if (!resolved) {
2403
2408
  continue;
2404
2409
  }
@@ -2407,12 +2412,7 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2407
2412
  event,
2408
2413
  self: actorCtx?.self,
2409
2414
  system: actorCtx?.system,
2410
- // TODO: figure out story for `action` and inline actions
2411
- // what those ones should receive?
2412
- //
2413
- // entry: ({ action }) => {}
2414
- // exit: assign(({ action }) => {})
2415
- action: typeof action === 'string' ? {
2415
+ action: isInline ? undefined : typeof action === 'string' ? {
2416
2416
  type: action
2417
2417
  } : action
2418
2418
  };
@@ -2549,9 +2549,8 @@ class State {
2549
2549
  */
2550
2550
 
2551
2551
  /**
2552
- * The done data of the top-level finite state.
2552
+ * The output data of the top-level finite state.
2553
2553
  */
2554
- // TODO: add an explicit type for `output`
2555
2554
 
2556
2555
  /**
2557
2556
  * The enabled state nodes representative of the state value.
@@ -2992,7 +2991,7 @@ function resolve(_, state, args, {
2992
2991
  get
2993
2992
  }) {
2994
2993
  return [state, undefined, toArray(get({
2995
- context: state.context,
2994
+ context: args.context,
2996
2995
  event: args.event
2997
2996
  }))];
2998
2997
  }
@@ -2400,7 +2400,12 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2400
2400
  _internalQueue: []
2401
2401
  });
2402
2402
  for (const action of actions) {
2403
- const resolved = typeof action === 'function' ? action : machine.implementations.actions[typeof action === 'string' ? action : action.type];
2403
+ const isInline = typeof action === 'function';
2404
+ const resolved = isInline ? action :
2405
+ // the existing type of `.actions` assumes non-nullable `TExpressionAction`
2406
+ // it's fine to cast this here to get a common type and lack of errors in the rest of the code
2407
+ // our logic below makes sure that we call those 2 "variants" correctly
2408
+ machine.implementations.actions[typeof action === 'string' ? action : action.type];
2404
2409
  if (!resolved) {
2405
2410
  continue;
2406
2411
  }
@@ -2409,12 +2414,7 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2409
2414
  event,
2410
2415
  self: actorCtx?.self,
2411
2416
  system: actorCtx?.system,
2412
- // TODO: figure out story for `action` and inline actions
2413
- // what those ones should receive?
2414
- //
2415
- // entry: ({ action }) => {}
2416
- // exit: assign(({ action }) => {})
2417
- action: typeof action === 'string' ? {
2417
+ action: isInline ? undefined : typeof action === 'string' ? {
2418
2418
  type: action
2419
2419
  } : action
2420
2420
  };
@@ -2551,9 +2551,8 @@ class State {
2551
2551
  */
2552
2552
 
2553
2553
  /**
2554
- * The done data of the top-level finite state.
2554
+ * The output data of the top-level finite state.
2555
2555
  */
2556
- // TODO: add an explicit type for `output`
2557
2556
 
2558
2557
  /**
2559
2558
  * The enabled state nodes representative of the state value.
@@ -2994,7 +2993,7 @@ function resolve(_, state, args, {
2994
2993
  get
2995
2994
  }) {
2996
2995
  return [state, undefined, toArray(get({
2997
- context: state.context,
2996
+ context: args.context,
2998
2997
  event: args.event
2999
2998
  }))];
3000
2999
  }
@@ -2439,7 +2439,12 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2439
2439
  _internalQueue: []
2440
2440
  });
2441
2441
  for (const action of actions) {
2442
- const resolved = typeof action === 'function' ? action : machine.implementations.actions[typeof action === 'string' ? action : action.type];
2442
+ const isInline = typeof action === 'function';
2443
+ const resolved = isInline ? action :
2444
+ // the existing type of `.actions` assumes non-nullable `TExpressionAction`
2445
+ // it's fine to cast this here to get a common type and lack of errors in the rest of the code
2446
+ // our logic below makes sure that we call those 2 "variants" correctly
2447
+ machine.implementations.actions[typeof action === 'string' ? action : action.type];
2443
2448
  if (!resolved) {
2444
2449
  continue;
2445
2450
  }
@@ -2448,12 +2453,7 @@ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
2448
2453
  event,
2449
2454
  self: actorCtx?.self,
2450
2455
  system: actorCtx?.system,
2451
- // TODO: figure out story for `action` and inline actions
2452
- // what those ones should receive?
2453
- //
2454
- // entry: ({ action }) => {}
2455
- // exit: assign(({ action }) => {})
2456
- action: typeof action === 'string' ? {
2456
+ action: isInline ? undefined : typeof action === 'string' ? {
2457
2457
  type: action
2458
2458
  } : action
2459
2459
  };
@@ -2593,9 +2593,8 @@ class State {
2593
2593
  */
2594
2594
 
2595
2595
  /**
2596
- * The done data of the top-level finite state.
2596
+ * The output data of the top-level finite state.
2597
2597
  */
2598
- // TODO: add an explicit type for `output`
2599
2598
 
2600
2599
  /**
2601
2600
  * The enabled state nodes representative of the state value.
@@ -3054,7 +3053,7 @@ function resolve(_, state, args, {
3054
3053
  get
3055
3054
  }) {
3056
3055
  return [state, undefined, toArray(get({
3057
- context: state.context,
3056
+ context: args.context,
3058
3057
  event: args.event
3059
3058
  }))];
3060
3059
  }
@@ -1,4 +1,4 @@
1
- import { MachineConfig, EventObject, MachineContext, InternalMachineImplementations, ParameterizedObject, ProvidedActor, AnyEventObject } from "./types.js";
1
+ import { MachineConfig, EventObject, MachineContext, InternalMachineImplementations, ParameterizedObject, ProvidedActor, AnyEventObject, NonReducibleUnknown } from "./types.js";
2
2
  import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from "./typegenTypes.js";
3
3
  import { StateMachine } from "./StateMachine.js";
4
- export declare function createMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TActor extends ProvidedActor = ProvidedActor, TInput = any, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, ParameterizedObject, TActor, TInput, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, ParameterizedObject, TActor, ResolveTypegenMeta<TTypesMeta, TEvent, ParameterizedObject, TActor>>): StateMachine<TContext, TEvent, ParameterizedObject, TActor, TInput, ResolveTypegenMeta<TTypesMeta, TEvent, ParameterizedObject, TActor>>;
4
+ export declare function createMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TActor extends ProvidedActor = ProvidedActor, TInput = any, TOutput = NonReducibleUnknown, TAction extends ParameterizedObject = ParameterizedObject, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, TAction, TActor, TInput, TOutput, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, TAction, TActor, ResolveTypegenMeta<TTypesMeta, TEvent, TAction, TActor>>): StateMachine<TContext, TEvent, TAction, TActor, TInput, TOutput, ResolveTypegenMeta<TTypesMeta, TEvent, TAction, TActor>>;
@@ -12,7 +12,7 @@ export declare function isStateConfig<TContext extends MachineContext, TEvent ex
12
12
  * @deprecated Use `isStateConfig(object)` or `state instanceof State` instead.
13
13
  */
14
14
  export declare const isState: typeof isStateConfig;
15
- export declare class State<TContext extends MachineContext, TEvent extends EventObject, TActor extends ProvidedActor, TResolvedTypesMeta = TypegenDisabled> {
15
+ export declare class State<TContext extends MachineContext, TEvent extends EventObject, TActor extends ProvidedActor, TOutput, TResolvedTypesMeta = TypegenDisabled> {
16
16
  machine: AnyStateMachine;
17
17
  tags: Set<string>;
18
18
  value: StateValue;
@@ -21,9 +21,9 @@ export declare class State<TContext extends MachineContext, TEvent extends Event
21
21
  */
22
22
  done: boolean;
23
23
  /**
24
- * The done data of the top-level finite state.
24
+ * The output data of the top-level finite state.
25
25
  */
26
- output: any;
26
+ output: TOutput | undefined;
27
27
  error: unknown;
28
28
  context: TContext;
29
29
  historyValue: Readonly<HistoryValue<TContext, TEvent>>;
@@ -41,7 +41,7 @@ export declare class State<TContext extends MachineContext, TEvent extends Event
41
41
  * @param stateValue
42
42
  * @param context
43
43
  */
44
- static from<TContext extends MachineContext, TEvent extends EventObject = EventObject>(stateValue: State<TContext, TEvent, TODO, any> | StateValue, context: TContext | undefined, machine: AnyStateMachine): State<TContext, TEvent, TODO, any>;
44
+ static from<TContext extends MachineContext, TEvent extends EventObject = EventObject>(stateValue: State<TContext, TEvent, TODO, any, any> | StateValue, context: TContext | undefined, machine: AnyStateMachine): State<TContext, TEvent, TODO, any, any>;
45
45
  /**
46
46
  * Creates a new `State` instance that represents the current state of a running machine.
47
47
  *
@@ -80,7 +80,7 @@ export declare class State<TContext extends MachineContext, TEvent extends Event
80
80
  /**
81
81
  * The next events that will cause a transition from the current state.
82
82
  */
83
- get nextEvents(): Array<TEvent['type']>;
83
+ get nextEvents(): Array<string>;
84
84
  get meta(): Record<string, any>;
85
85
  }
86
86
  export declare function cloneState<TState extends AnyState>(state: TState, config?: Partial<StateConfig<any, any>>): TState;
@@ -4,17 +4,17 @@ import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAs
4
4
  import type { ActorContext, ActorLogic, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineTypes, NoInfer, StateConfig, StateMachineDefinition, StateValue, TransitionDefinition, PersistedMachineState, ParameterizedObject, AnyActorContext, ProvidedActor, Equals, TODO } from "./types.js";
5
5
  export declare const STATE_IDENTIFIER = "#";
6
6
  export declare const WILDCARD = "*";
7
- export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TAction extends ParameterizedObject, TActor extends ProvidedActor, TInput, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TAction, TActor>> implements ActorLogic<TEvent, State<TContext, TEvent, TActor, TResolvedTypesMeta>, State<TContext, TEvent, TActor, TResolvedTypesMeta>, PersistedMachineState<State<TContext, TEvent, TActor, TResolvedTypesMeta>>, TODO, TInput, TODO> {
7
+ export declare class StateMachine<TContext extends MachineContext, TEvent extends EventObject, TAction extends ParameterizedObject, TActor extends ProvidedActor, TInput, TOutput, TResolvedTypesMeta = ResolveTypegenMeta<TypegenDisabled, NoInfer<TEvent>, TAction, TActor>> implements ActorLogic<TEvent, State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, PersistedMachineState<State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>>, TODO, TInput, TOutput> {
8
8
  /**
9
9
  * The raw config used to create the machine.
10
10
  */
11
- config: MachineConfig<TContext, TEvent, any, any, any>;
11
+ config: MachineConfig<TContext, TEvent, any, any, any, TOutput, any>;
12
12
  /**
13
13
  * The machine's own version.
14
14
  */
15
15
  version?: string;
16
16
  implementations: MachineImplementationsSimplified<TContext, TEvent>;
17
- types: MachineTypes<TContext, TEvent, TActor, TInput>;
17
+ types: MachineTypes<TContext, TEvent, TAction, TActor, TInput, TOutput>;
18
18
  __xstatenode: true;
19
19
  idMap: Map<string, StateNode<TContext, TEvent>>;
20
20
  root: StateNode<TContext, TEvent>;
@@ -25,7 +25,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
25
25
  /**
26
26
  * The raw config used to create the machine.
27
27
  */
28
- config: MachineConfig<TContext, TEvent, any, any, any>, implementations?: MachineImplementationsSimplified<TContext, TEvent>);
28
+ config: MachineConfig<TContext, TEvent, any, any, any, TOutput, any>, implementations?: MachineImplementationsSimplified<TContext, TEvent>);
29
29
  /**
30
30
  * Clones this state machine with the provided implementations
31
31
  * and merges the `context` (if provided).
@@ -35,7 +35,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
35
35
  *
36
36
  * @returns A new `StateMachine` instance with the provided implementations.
37
37
  */
38
- provide(implementations: InternalMachineImplementations<TContext, TEvent, TAction, TActor, TResolvedTypesMeta, true>): StateMachine<TContext, TEvent, TAction, TActor, TInput, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>;
38
+ provide(implementations: InternalMachineImplementations<TContext, TEvent, TAction, TActor, TResolvedTypesMeta, true>): StateMachine<TContext, TEvent, TAction, TActor, TInput, TOutput, AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends false ? MarkAllImplementationsAsProvided<TResolvedTypesMeta> : TResolvedTypesMeta>;
39
39
  /**
40
40
  * Resolves the given `state` to a new `State` instance relative to this machine.
41
41
  *
@@ -43,8 +43,8 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
43
43
  *
44
44
  * @param state The state to resolve
45
45
  */
46
- resolveState(state: State<TContext, TEvent, TActor, TResolvedTypesMeta>): typeof state;
47
- resolveStateValue(stateValue: StateValue, ...[context]: Equals<TContext, MachineContext> extends true ? [] : [TContext]): State<TContext, TEvent, TActor, TResolvedTypesMeta>;
46
+ resolveState(state: State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>): typeof state;
47
+ resolveStateValue(stateValue: StateValue, ...[context]: Equals<TContext, MachineContext> extends true ? [] : [TContext]): State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>;
48
48
  /**
49
49
  * Determines the next state given the current `state` and received `event`.
50
50
  * Calculates a full macrostep from all microsteps.
@@ -52,7 +52,7 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
52
52
  * @param state The current State instance or state value
53
53
  * @param event The received event
54
54
  */
55
- transition(state: State<TContext, TEvent, TActor, TResolvedTypesMeta>, event: TEvent, actorCtx: ActorContext<TEvent, State<TContext, TEvent, TActor, any>>): State<TContext, TEvent, TActor, TResolvedTypesMeta>;
55
+ transition(state: State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, event: TEvent, actorCtx: ActorContext<TEvent, typeof state>): State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>;
56
56
  /**
57
57
  * Determines the next state given the current `state` and `event`.
58
58
  * Calculates a microstep.
@@ -60,8 +60,8 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
60
60
  * @param state The current state
61
61
  * @param event The received event
62
62
  */
63
- microstep(state: State<TContext, TEvent, TActor, TResolvedTypesMeta>, event: TEvent, actorCtx: AnyActorContext): Array<State<TContext, TEvent, TActor, TResolvedTypesMeta>>;
64
- getTransitionData(state: State<TContext, TEvent, TActor, TResolvedTypesMeta>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>>;
63
+ microstep(state: State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, event: TEvent, actorCtx: AnyActorContext): Array<State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>>;
64
+ getTransitionData(state: State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>, event: TEvent): Array<TransitionDefinition<TContext, TEvent>>;
65
65
  /**
66
66
  * The initial state _before_ evaluating any microsteps.
67
67
  * This "pre-initial" state is provided to initial actions executed in the initial state.
@@ -70,21 +70,24 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
70
70
  /**
71
71
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
72
72
  */
73
- getInitialState(actorCtx: ActorContext<TEvent, State<TContext, TEvent, TActor, TResolvedTypesMeta>>, input?: TInput): State<TContext, TEvent, TActor, TResolvedTypesMeta>;
74
- start(state: State<TContext, TEvent, TActor, TResolvedTypesMeta>): void;
73
+ getInitialState(actorCtx: ActorContext<TEvent, State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>>, input?: TInput): State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>;
74
+ start(state: State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>): void;
75
75
  getStateNodeById(stateId: string): StateNode<TContext, TEvent>;
76
76
  get definition(): StateMachineDefinition<TContext, TEvent>;
77
77
  toJSON(): StateMachineDefinition<TContext, TEvent>;
78
- getPersistedState(state: State<TContext, TEvent, TActor, TResolvedTypesMeta>): PersistedMachineState<State<TContext, TEvent, TActor, TResolvedTypesMeta>>;
79
- createState(stateConfig: State<TContext, TEvent, TActor, TResolvedTypesMeta> | StateConfig<TContext, TEvent>): State<TContext, TEvent, TActor, TResolvedTypesMeta>;
80
- getStatus(state: State<TContext, TEvent, TActor, TResolvedTypesMeta>): {
78
+ getPersistedState(state: State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>): PersistedMachineState<State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>>;
79
+ createState(stateConfig: State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta> | StateConfig<TContext, TEvent>): State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>;
80
+ getStatus(state: State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>): {
81
81
  status: string;
82
- data: any;
82
+ data: {};
83
+ } | {
84
+ status: string;
85
+ data: TOutput | undefined;
83
86
  } | {
84
87
  status: string;
85
88
  data?: undefined;
86
89
  };
87
- restoreState(state: PersistedMachineState<State<TContext, TEvent, TActor, TResolvedTypesMeta>>, _actorCtx: ActorContext<TEvent, State<TContext, TEvent, TActor, TResolvedTypesMeta>>): State<TContext, TEvent, TActor, TResolvedTypesMeta>;
90
+ restoreState(state: PersistedMachineState<State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>>, _actorCtx: ActorContext<TEvent, State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>>): State<TContext, TEvent, TActor, TOutput, TResolvedTypesMeta>;
88
91
  /**@deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
89
92
  __TContext: TContext;
90
93
  /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
@@ -94,6 +97,9 @@ export declare class StateMachine<TContext extends MachineContext, TEvent extend
94
97
  /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
95
98
  __TActor: TActor;
96
99
  /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
97
- __TResolvedTypesMeta: TResolvedTypesMeta;
98
100
  __TInput: TInput;
101
+ /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
102
+ __TOutput: TOutput;
103
+ /** @deprecated an internal property acting as a "phantom" type, not meant to be used at runtime */
104
+ __TResolvedTypesMeta: TResolvedTypesMeta;
99
105
  }
@@ -1,16 +1,16 @@
1
1
  import type { State } from "./State.js";
2
2
  import type { StateMachine } from "./StateMachine.js";
3
- import type { Action, DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, InvokeDefinition, MachineContext, Mapper, StateNodeConfig, StateNodeDefinition, StateNodesConfig, TransitionDefinition, TransitionDefinitionMap, TODO } from "./types.js";
3
+ import type { DelayedTransitionDefinition, EventObject, InitialTransitionDefinition, InvokeDefinition, MachineContext, Mapper, StateNodeConfig, StateNodeDefinition, StateNodesConfig, TransitionDefinition, TransitionDefinitionMap, TODO, UnknownAction, ParameterizedObject } from "./types.js";
4
4
  interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
5
5
  _key: string;
6
6
  _parent?: StateNode<TContext, TEvent>;
7
- _machine: StateMachine<TContext, TEvent, any, any, any>;
7
+ _machine: StateMachine<TContext, TEvent, any, any, any, any>;
8
8
  }
9
9
  export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject> {
10
10
  /**
11
11
  * The raw config used to create the machine.
12
12
  */
13
- config: StateNodeConfig<TContext, TEvent, TODO, TODO>;
13
+ config: StateNodeConfig<TContext, TEvent, TODO, TODO, TODO>;
14
14
  /**
15
15
  * The relative key of the state node, which represents its location in the overall state value.
16
16
  */
@@ -47,11 +47,11 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
47
47
  /**
48
48
  * The action(s) to be executed upon entering the state node.
49
49
  */
50
- entry: Action<any, any, any>[];
50
+ entry: UnknownAction[];
51
51
  /**
52
52
  * The action(s) to be executed upon exiting the state node.
53
53
  */
54
- exit: Action<any, any, any>[];
54
+ exit: UnknownAction[];
55
55
  /**
56
56
  * The parent state node.
57
57
  */
@@ -80,7 +80,7 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
80
80
  /**
81
81
  * The raw config used to create the machine.
82
82
  */
83
- config: StateNodeConfig<TContext, TEvent, TODO, TODO>, options: StateNodeOptions<TContext, TEvent>);
83
+ config: StateNodeConfig<TContext, TEvent, TODO, TODO, TODO>, options: StateNodeOptions<TContext, TEvent>);
84
84
  _initialize(): void;
85
85
  /**
86
86
  * The well-structured state node definition.
@@ -90,14 +90,14 @@ export declare class StateNode<TContext extends MachineContext = MachineContext,
90
90
  /**
91
91
  * The logic invoked as actors by this state node.
92
92
  */
93
- get invoke(): Array<InvokeDefinition<TContext, TEvent>>;
93
+ get invoke(): Array<InvokeDefinition<TContext, TEvent, ParameterizedObject>>;
94
94
  /**
95
95
  * The mapping of events to transitions.
96
96
  */
97
97
  get on(): TransitionDefinitionMap<TContext, TEvent>;
98
98
  get after(): Array<DelayedTransitionDefinition<TContext, TEvent>>;
99
99
  get initial(): InitialTransitionDefinition<TContext, TEvent>;
100
- next(state: State<TContext, TEvent, TODO>, event: TEvent): TransitionDefinition<TContext, TEvent>[] | undefined;
100
+ next(state: State<TContext, TEvent, TODO, TODO>, event: TEvent): TransitionDefinition<TContext, TEvent>[] | undefined;
101
101
  /**
102
102
  * The target state value of the history state node, if it exists. This represents the
103
103
  * default state value to transition to if no history value exists yet.
@@ -1,16 +1,16 @@
1
- import type { ActionArgs, AnyActorContext, AnyState, Assigner, EventObject, LowInfer, MachineContext, PropertyAssigner } from "../types.js";
2
- declare function resolve(actorContext: AnyActorContext, state: AnyState, actionArgs: ActionArgs<any, any>, { assignment }: {
3
- assignment: Assigner<any, any> | PropertyAssigner<any, any>;
1
+ import type { ActionArgs, AnyActorContext, AnyState, Assigner, EventObject, LowInfer, MachineContext, ParameterizedObject, PropertyAssigner } from "../types.js";
2
+ declare function resolve(actorContext: AnyActorContext, state: AnyState, actionArgs: ActionArgs<any, any, any>, { assignment }: {
3
+ assignment: Assigner<any, any, any> | PropertyAssigner<any, any, any>;
4
4
  }): AnyState[];
5
5
  /**
6
6
  * Updates the current context of the machine.
7
7
  *
8
8
  * @param assignment An object that represents the partial context to update.
9
9
  */
10
- export declare function assign<TContext extends MachineContext, TExpressionEvent extends EventObject = EventObject, TEvent extends EventObject = TExpressionEvent>(assignment: Assigner<LowInfer<TContext>, TExpressionEvent> | PropertyAssigner<LowInfer<TContext>, TExpressionEvent>): {
11
- (_: ActionArgs<TContext, TExpressionEvent>): void;
10
+ export declare function assign<TContext extends MachineContext, TExpressionEvent extends EventObject = EventObject, TExpressionAction extends ParameterizedObject | undefined = ParameterizedObject | undefined>(assignment: Assigner<LowInfer<TContext>, TExpressionEvent, TExpressionAction> | PropertyAssigner<LowInfer<TContext>, TExpressionEvent, TExpressionAction>): {
11
+ (_: ActionArgs<TContext, TExpressionEvent, TExpressionAction>): void;
12
12
  type: string;
13
- assignment: Assigner<LowInfer<TContext>, TExpressionEvent> | PropertyAssigner<LowInfer<TContext>, TExpressionEvent>;
13
+ assignment: Assigner<LowInfer<TContext>, TExpressionEvent, TExpressionAction> | PropertyAssigner<LowInfer<TContext>, TExpressionEvent, TExpressionAction>;
14
14
  resolve: typeof resolve;
15
15
  };
16
16
  export {};
@@ -1,7 +1,7 @@
1
- import { AnyActorContext, AnyState, EventObject, MachineContext, ActionArgs } from "../types.js";
2
- type ResolvableSendId<TContext extends MachineContext, TExpressionEvent extends EventObject> = string | ((args: ActionArgs<TContext, TExpressionEvent>) => string);
3
- declare function resolve(_: AnyActorContext, state: AnyState, actionArgs: ActionArgs<any, any>, { sendId }: {
4
- sendId: ResolvableSendId<any, any>;
1
+ import { AnyActorContext, AnyState, EventObject, MachineContext, ActionArgs, ParameterizedObject } from "../types.js";
2
+ type ResolvableSendId<TContext extends MachineContext, TExpressionEvent extends EventObject, TExpressionAction extends ParameterizedObject | undefined> = string | ((args: ActionArgs<TContext, TExpressionEvent, TExpressionAction>) => string);
3
+ declare function resolve(_: AnyActorContext, state: AnyState, actionArgs: ActionArgs<any, any, any>, { sendId }: {
4
+ sendId: ResolvableSendId<any, any, any>;
5
5
  }): (string | AnyState)[];
6
6
  declare function execute(actorContext: AnyActorContext, resolvedSendId: string): void;
7
7
  /**
@@ -11,10 +11,10 @@ declare function execute(actorContext: AnyActorContext, resolvedSendId: string):
11
11
  *
12
12
  * @param sendId The `id` of the `send(...)` action to cancel.
13
13
  */
14
- export declare function cancel<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(sendId: ResolvableSendId<TContext, TExpressionEvent>): {
15
- (_: ActionArgs<TContext, TExpressionEvent>): void;
14
+ export declare function cancel<TContext extends MachineContext, TExpressionEvent extends EventObject, TExpressionAction extends ParameterizedObject | undefined>(sendId: ResolvableSendId<TContext, TExpressionEvent, TExpressionAction>): {
15
+ (_: ActionArgs<TContext, TExpressionEvent, TExpressionAction>): void;
16
16
  type: string;
17
- sendId: ResolvableSendId<TContext, TExpressionEvent>;
17
+ sendId: ResolvableSendId<TContext, TExpressionEvent, TExpressionAction>;
18
18
  resolve: typeof resolve;
19
19
  execute: typeof execute;
20
20
  };
@@ -1,11 +1,5 @@
1
- import { EventObject, ChooseBranch, MachineContext, AnyActorContext, AnyState, ActionArgs } from "../types.js";
2
- declare function resolve(_: AnyActorContext, state: AnyState, actionArgs: ActionArgs<any, any>, { branches }: {
3
- branches: Array<ChooseBranch<MachineContext, EventObject>>;
4
- }): (AnyState | (string | import("../types.js").ParameterizedObject | import("../types.js").ActionFunction<MachineContext, EventObject, EventObject, import("../types.js").ParameterizedObject>)[] | undefined)[];
5
- export declare function choose<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(branches: Array<ChooseBranch<TContext, TExpressionEvent>>): {
6
- (_: ActionArgs<TContext, TExpressionEvent>): void;
7
- type: string;
8
- branches: ChooseBranch<TContext, TExpressionEvent, TExpressionEvent>[];
9
- resolve: typeof resolve;
1
+ import { EventObject, ChooseBranch, MachineContext, ActionArgs, ParameterizedObject } from "../types.js";
2
+ export declare function choose<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TExpressionAction extends ParameterizedObject | undefined, TAction extends ParameterizedObject>(branches: ReadonlyArray<ChooseBranch<TContext, TExpressionEvent, TEvent, TAction>>): {
3
+ (args: ActionArgs<TContext, TExpressionEvent, TExpressionAction>): void;
4
+ _out_TAction?: TAction | undefined;
10
5
  };
11
- export {};
@@ -1,7 +1,7 @@
1
- import { ActionArgs, AnyActorContext, AnyState, EventObject, LogExpr, MachineContext } from "../types.js";
2
- type ResolvableLogValue<TContext extends MachineContext, TExpressionEvent extends EventObject> = string | LogExpr<TContext, TExpressionEvent>;
3
- declare function resolve(_: AnyActorContext, state: AnyState, actionArgs: ActionArgs<any, any>, { value, label }: {
4
- value: ResolvableLogValue<any, any>;
1
+ import { ActionArgs, AnyActorContext, AnyState, EventObject, LogExpr, MachineContext, ParameterizedObject } from "../types.js";
2
+ type ResolvableLogValue<TContext extends MachineContext, TExpressionEvent extends EventObject, TExpressionAction extends ParameterizedObject | undefined> = string | LogExpr<TContext, TExpressionEvent, TExpressionAction>;
3
+ declare function resolve(_: AnyActorContext, state: AnyState, actionArgs: ActionArgs<any, any, any>, { value, label }: {
4
+ value: ResolvableLogValue<any, any, any>;
5
5
  label: string | undefined;
6
6
  }): (AnyState | {
7
7
  value: unknown;
@@ -19,10 +19,10 @@ declare function execute({ logger }: AnyActorContext, { value, label }: {
19
19
  * - `event` - the event that caused this action to be executed.
20
20
  * @param label The label to give to the logged expression.
21
21
  */
22
- export declare function log<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(value?: ResolvableLogValue<TContext, TExpressionEvent>, label?: string): {
23
- (_: ActionArgs<TContext, TExpressionEvent>): void;
22
+ export declare function log<TContext extends MachineContext, TExpressionEvent extends EventObject, TExpressionAction extends ParameterizedObject | undefined>(value?: ResolvableLogValue<TContext, TExpressionEvent, TExpressionAction>, label?: string): {
23
+ (_: ActionArgs<TContext, TExpressionEvent, TExpressionAction>): void;
24
24
  type: string;
25
- value: ResolvableLogValue<TContext, TExpressionEvent>;
25
+ value: ResolvableLogValue<TContext, TExpressionEvent, TExpressionAction>;
26
26
  label: string | undefined;
27
27
  resolve: typeof resolve;
28
28
  execute: typeof execute;
@@ -1,20 +1,8 @@
1
- import { Action, ActionArgs, AnyActorContext, AnyState, EventObject, MachineContext, SingleOrArray } from "../types.js";
2
- declare function resolve(_: AnyActorContext, state: AnyState, args: ActionArgs<any, any>, { get }: {
3
- get: ({ context, event }: {
4
- context: MachineContext;
5
- event: EventObject;
6
- }) => SingleOrArray<Action<any, any, any>> | undefined;
7
- }): (AnyState | (string | import("../types.js").ParameterizedObject | import("../types.js").ActionFunction<any, any, any, import("../types.js").ParameterizedObject>)[] | undefined)[];
8
- export declare function pure<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(getActions: ({ context, event }: {
1
+ import { Actions, ActionArgs, EventObject, MachineContext, ParameterizedObject } from "../types.js";
2
+ export declare function pure<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent, TExpressionAction extends ParameterizedObject | undefined = ParameterizedObject | undefined, TAction extends ParameterizedObject = ParameterizedObject>(getActions: ({ context, event }: {
9
3
  context: TContext;
10
4
  event: TExpressionEvent;
11
- }) => SingleOrArray<Action<TContext, TExpressionEvent> | string> | undefined): {
12
- (_: ActionArgs<TContext, TExpressionEvent>): void;
13
- type: string;
14
- get: ({ context, event }: {
15
- context: TContext;
16
- event: TExpressionEvent;
17
- }) => SingleOrArray<Action<TContext, TExpressionEvent> | string> | undefined;
18
- resolve: typeof resolve;
5
+ }) => Actions<TContext, TExpressionEvent, TEvent, undefined, TAction> | undefined): {
6
+ (args: ActionArgs<TContext, TExpressionEvent, TExpressionAction>): void;
7
+ _out_TAction?: TAction | undefined;
19
8
  };
20
- export {};
@@ -1,11 +1,11 @@
1
- import { ActionArgs, EventObject, MachineContext, NoInfer, RaiseActionOptions, SendExpr } from "../types.js";
1
+ import { ActionArgs, EventObject, MachineContext, NoInfer, RaiseActionOptions, SendExpr, ParameterizedObject } from "../types.js";
2
2
  /**
3
3
  * Raises an event. This places the event in the internal event queue, so that
4
4
  * the event is immediately consumed by the machine in the current step.
5
5
  *
6
6
  * @param eventType The event to raise.
7
7
  */
8
- export declare function raise<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(eventOrExpr: NoInfer<TEvent> | SendExpr<TContext, TExpressionEvent, NoInfer<TEvent>>, options?: RaiseActionOptions<TContext, TExpressionEvent>): {
9
- (args: ActionArgs<TContext, TExpressionEvent>): void;
8
+ export declare function raise<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent, TExpressionAction extends ParameterizedObject | undefined = ParameterizedObject | undefined>(eventOrExpr: NoInfer<TEvent> | SendExpr<TContext, TExpressionEvent, TExpressionAction, NoInfer<TEvent>>, options?: RaiseActionOptions<TContext, TExpressionEvent, TExpressionAction>): {
9
+ (args: ActionArgs<TContext, TExpressionEvent, TExpressionAction>): void;
10
10
  _out_TEvent?: TEvent | undefined;
11
11
  };