xstate 5.0.0-alpha.0 → 5.0.0-alpha.2

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 (97) hide show
  1. package/README.md +26 -15
  2. package/actions/dist/xstate-actions.cjs.dev.js +24 -25
  3. package/actions/dist/xstate-actions.cjs.prod.js +23 -24
  4. package/actions/dist/xstate-actions.esm.js +2 -2
  5. package/actions/dist/xstate-actions.umd.min.js +2 -0
  6. package/actions/dist/xstate-actions.umd.min.js.map +1 -0
  7. package/actions/dynamicAction.ts +15 -7
  8. package/actions/package.json +5 -1
  9. package/actors/dist/xstate-actors.cjs.d.ts +1 -1
  10. package/actors/dist/xstate-actors.cjs.dev.js +14 -14
  11. package/actors/dist/xstate-actors.cjs.prod.js +13 -13
  12. package/actors/dist/xstate-actors.esm.js +2 -2
  13. package/actors/dist/xstate-actors.umd.min.js +2 -0
  14. package/actors/dist/xstate-actors.umd.min.js.map +1 -0
  15. package/actors/package.json +5 -1
  16. package/dev/dist/xstate-dev.cjs.dev.js +1 -1
  17. package/dev/dist/xstate-dev.cjs.prod.js +0 -11
  18. package/dev/dist/xstate-dev.esm.js +1 -1
  19. package/dev/dist/xstate-dev.umd.min.js +2 -0
  20. package/dev/dist/xstate-dev.umd.min.js.map +1 -0
  21. package/dev/package.json +5 -1
  22. package/dist/{actions-6b86876d.cjs.dev.js → actions-1e9778c2.cjs.dev.js} +2819 -3334
  23. package/dist/actions-9778f6fb.esm.js +4246 -0
  24. package/dist/actions-acb29ffe.cjs.prod.js +4262 -0
  25. package/dist/declarations/actions/dynamicAction.d.ts +5 -3
  26. package/dist/declarations/src/Machine.d.ts +4 -4
  27. package/dist/declarations/src/Mailbox.d.ts +12 -12
  28. package/dist/declarations/src/SimulatedClock.d.ts +16 -16
  29. package/dist/declarations/src/State.d.ts +97 -104
  30. package/dist/declarations/src/StateMachine.d.ts +110 -112
  31. package/dist/declarations/src/StateNode.d.ts +127 -127
  32. package/dist/declarations/src/actionTypes.d.ts +16 -17
  33. package/dist/declarations/src/actions/assign.d.ts +7 -7
  34. package/dist/declarations/src/actions/cancel.d.ts +10 -10
  35. package/dist/declarations/src/actions/choose.d.ts +3 -3
  36. package/dist/declarations/src/actions/invoke.d.ts +3 -3
  37. package/dist/declarations/src/actions/log.d.ts +11 -11
  38. package/dist/declarations/src/actions/pure.d.ts +3 -3
  39. package/dist/declarations/src/actions/raise.d.ts +8 -9
  40. package/dist/declarations/src/actions/send.d.ts +53 -55
  41. package/dist/declarations/src/actions/stop.d.ts +7 -8
  42. package/dist/declarations/src/actions.d.ts +47 -44
  43. package/dist/declarations/src/actors/callback.d.ts +8 -0
  44. package/dist/declarations/src/actors/index.d.ts +27 -0
  45. package/dist/declarations/src/actors/observable.d.ts +23 -0
  46. package/dist/declarations/src/actors/promise.d.ts +12 -0
  47. package/dist/declarations/src/actors/transition.d.ts +13 -0
  48. package/dist/declarations/src/constants.d.ts +5 -5
  49. package/dist/declarations/src/dev/index.d.ts +14 -14
  50. package/dist/declarations/src/environment.d.ts +1 -1
  51. package/dist/declarations/src/guards.d.ts +8 -9
  52. package/dist/declarations/src/index.d.ts +44 -47
  53. package/dist/declarations/src/interpreter.d.ts +104 -147
  54. package/dist/declarations/src/mapState.d.ts +3 -3
  55. package/dist/declarations/src/memo.d.ts +2 -1
  56. package/dist/declarations/src/schema.d.ts +2 -2
  57. package/dist/declarations/src/spawn.d.ts +2 -2
  58. package/dist/declarations/src/stateUtils.d.ts +70 -85
  59. package/dist/declarations/src/symbolObservable.d.ts +1 -0
  60. package/dist/declarations/src/system.d.ts +2 -0
  61. package/dist/declarations/src/typegenTypes.d.ts +132 -132
  62. package/dist/declarations/src/types.d.ts +1008 -1026
  63. package/dist/declarations/src/utils.d.ts +58 -56
  64. package/dist/{index-20b364c4.esm.js → index-50bd0aff.esm.js} +0 -12
  65. package/dist/{index-2a564d03.cjs.dev.js → index-ebaab3c9.cjs.dev.js} +0 -12
  66. package/dist/xstate.cjs.dev.js +798 -100
  67. package/dist/xstate.cjs.prod.js +797 -99
  68. package/dist/xstate.esm.js +756 -55
  69. package/dist/xstate.umd.min.js +2 -0
  70. package/dist/xstate.umd.min.js.map +1 -0
  71. package/guards/dist/xstate-guards.cjs.dev.js +8 -8
  72. package/guards/dist/xstate-guards.cjs.prod.js +7 -7
  73. package/guards/dist/xstate-guards.esm.js +2 -2
  74. package/guards/dist/xstate-guards.umd.min.js +2 -0
  75. package/guards/dist/xstate-guards.umd.min.js.map +1 -0
  76. package/guards/package.json +5 -1
  77. package/package.json +28 -6
  78. package/CHANGELOG.md +0 -1986
  79. package/actions/ExecutableAction.ts +0 -58
  80. package/dist/Machine-9ce74c11.cjs.dev.js +0 -755
  81. package/dist/Machine-dca041dc.cjs.prod.js +0 -749
  82. package/dist/Machine-fb2f47f5.esm.js +0 -751
  83. package/dist/actions-70094c93.cjs.prod.js +0 -4765
  84. package/dist/actions-ff512f16.esm.js +0 -4757
  85. package/dist/declarations/actions/ExecutableAction.d.ts +0 -23
  86. package/dist/declarations/src/ObservableActorRef.d.ts +0 -25
  87. package/dist/declarations/src/actors.d.ts +0 -38
  88. package/dist/declarations/src/match.d.ts +0 -5
  89. package/dist/declarations/src/model.d.ts +0 -5
  90. package/dist/declarations/src/model.types.d.ts +0 -53
  91. package/dist/declarations/src/registry.d.ts +0 -8
  92. package/model/dist/xstate-model.cjs.d.ts +0 -1
  93. package/model/dist/xstate-model.cjs.dev.js +0 -41
  94. package/model/dist/xstate-model.cjs.js +0 -7
  95. package/model/dist/xstate-model.cjs.prod.js +0 -41
  96. package/model/dist/xstate-model.esm.js +0 -37
  97. package/model/package.json +0 -4
@@ -1,127 +1,127 @@
1
- import type { Event, EventObject, StateNodeDefinition, TransitionDefinition, DelayedTransitionDefinition, StateNodeConfig, StateNodesConfig, InvokeDefinition, Mapper, PropertyMapper, SCXML, TransitionDefinitionMap, InitialTransitionDefinition, MachineContext, BaseActionObject } from './types';
2
- import type { State } from './State';
3
- import type { StateMachine } from './StateMachine';
4
- interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
5
- _key: string;
6
- _parent?: StateNode<TContext, TEvent>;
7
- _machine: StateMachine<TContext, TEvent, any, any, any>;
8
- }
9
- export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject> {
10
- /**
11
- * The raw config used to create the machine.
12
- */
13
- config: StateNodeConfig<TContext, TEvent>;
14
- /**
15
- * The relative key of the state node, which represents its location in the overall state value.
16
- */
17
- key: string;
18
- /**
19
- * The unique ID of the state node.
20
- */
21
- id: string;
22
- /**
23
- * The type of this state node:
24
- *
25
- * - `'atomic'` - no child state nodes
26
- * - `'compound'` - nested child state nodes (XOR)
27
- * - `'parallel'` - orthogonal nested child state nodes (AND)
28
- * - `'history'` - history state node
29
- * - `'final'` - final state node
30
- */
31
- type: 'atomic' | 'compound' | 'parallel' | 'final' | 'history';
32
- /**
33
- * The string path from the root machine node to this node.
34
- */
35
- path: string[];
36
- /**
37
- * The child state nodes.
38
- */
39
- states: StateNodesConfig<TContext, TEvent>;
40
- /**
41
- * The type of history on this state node. Can be:
42
- *
43
- * - `'shallow'` - recalls only top-level historical state value
44
- * - `'deep'` - recalls historical state value at all levels
45
- */
46
- history: false | 'shallow' | 'deep';
47
- /**
48
- * The action(s) to be executed upon entering the state node.
49
- */
50
- entry: BaseActionObject[];
51
- /**
52
- * The action(s) to be executed upon exiting the state node.
53
- */
54
- exit: BaseActionObject[];
55
- /**
56
- * The parent state node.
57
- */
58
- parent?: StateNode<TContext, TEvent>;
59
- /**
60
- * The root machine node.
61
- */
62
- machine: StateMachine<TContext, TEvent, any, any>;
63
- /**
64
- * The meta data associated with this state node, which will be returned in State instances.
65
- */
66
- meta?: any;
67
- /**
68
- * The data sent with the "done.state._id_" event if this is a final state node.
69
- */
70
- doneData?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
71
- /**
72
- * The order this state node appears. Corresponds to the implicit SCXML document order.
73
- */
74
- order: number;
75
- description?: string;
76
- tags: string[];
77
- transitions: Array<TransitionDefinition<TContext, TEvent>>;
78
- always?: Array<TransitionDefinition<TContext, TEvent>>;
79
- constructor(
80
- /**
81
- * The raw config used to create the machine.
82
- */
83
- config: StateNodeConfig<TContext, TEvent>, options: StateNodeOptions<TContext, TEvent>);
84
- _initialize(): void;
85
- /**
86
- * The well-structured state node definition.
87
- */
88
- get definition(): StateNodeDefinition<TContext, TEvent>;
89
- toJSON(): StateNodeDefinition<TContext, TEvent>;
90
- /**
91
- * The behaviors invoked as actors by this state node.
92
- */
93
- get invoke(): Array<InvokeDefinition<TContext, TEvent>>;
94
- /**
95
- * The mapping of events to transitions.
96
- */
97
- get on(): TransitionDefinitionMap<TContext, TEvent>;
98
- get after(): Array<DelayedTransitionDefinition<TContext, TEvent>>;
99
- get initial(): InitialTransitionDefinition<TContext, TEvent>;
100
- /**
101
- * Returns `true` if this state node explicitly handles the given event.
102
- *
103
- * @param event The event in question
104
- */
105
- handles(event: Event<TEvent>): boolean;
106
- next(state: State<TContext, TEvent>, _event: SCXML.Event<TEvent>): TransitionDefinition<TContext, TEvent>[] | undefined;
107
- /**
108
- * The target state value of the history state node, if it exists. This represents the
109
- * default state value to transition to if no history value exists yet.
110
- */
111
- get target(): string | undefined;
112
- /**
113
- * All the state node IDs of this state node and its descendant state nodes.
114
- */
115
- get stateIds(): string[];
116
- /**
117
- * All the event types accepted by this state node and its descendants.
118
- */
119
- get events(): Array<TEvent['type']>;
120
- /**
121
- * All the events that have transitions directly from this state node.
122
- *
123
- * Excludes any inert events.
124
- */
125
- get ownEvents(): Array<TEvent['type']>;
126
- }
127
- export {};
1
+ import type { EventObject, StateNodeDefinition, TransitionDefinition, DelayedTransitionDefinition, StateNodeConfig, StateNodesConfig, InvokeDefinition, Mapper, PropertyMapper, SCXML, TransitionDefinitionMap, InitialTransitionDefinition, MachineContext, BaseActionObject } from './types.js';
2
+ import type { State } from './State.js';
3
+ import type { StateMachine } from './StateMachine.js';
4
+ interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
5
+ _key: string;
6
+ _parent?: StateNode<TContext, TEvent>;
7
+ _machine: StateMachine<TContext, TEvent, any, any, any>;
8
+ }
9
+ export declare class StateNode<TContext extends MachineContext = MachineContext, TEvent extends EventObject = EventObject> {
10
+ /**
11
+ * The raw config used to create the machine.
12
+ */
13
+ config: StateNodeConfig<TContext, TEvent>;
14
+ /**
15
+ * The relative key of the state node, which represents its location in the overall state value.
16
+ */
17
+ key: string;
18
+ /**
19
+ * The unique ID of the state node.
20
+ */
21
+ id: string;
22
+ /**
23
+ * The type of this state node:
24
+ *
25
+ * - `'atomic'` - no child state nodes
26
+ * - `'compound'` - nested child state nodes (XOR)
27
+ * - `'parallel'` - orthogonal nested child state nodes (AND)
28
+ * - `'history'` - history state node
29
+ * - `'final'` - final state node
30
+ */
31
+ type: 'atomic' | 'compound' | 'parallel' | 'final' | 'history';
32
+ /**
33
+ * The string path from the root machine node to this node.
34
+ */
35
+ path: string[];
36
+ /**
37
+ * The child state nodes.
38
+ */
39
+ states: StateNodesConfig<TContext, TEvent>;
40
+ /**
41
+ * The type of history on this state node. Can be:
42
+ *
43
+ * - `'shallow'` - recalls only top-level historical state value
44
+ * - `'deep'` - recalls historical state value at all levels
45
+ */
46
+ history: false | 'shallow' | 'deep';
47
+ /**
48
+ * The action(s) to be executed upon entering the state node.
49
+ */
50
+ entry: BaseActionObject[];
51
+ /**
52
+ * The action(s) to be executed upon exiting the state node.
53
+ */
54
+ exit: BaseActionObject[];
55
+ /**
56
+ * The parent state node.
57
+ */
58
+ parent?: StateNode<TContext, TEvent>;
59
+ /**
60
+ * The root machine node.
61
+ */
62
+ machine: StateMachine<TContext, TEvent, any, any>;
63
+ /**
64
+ * The meta data associated with this state node, which will be returned in State instances.
65
+ */
66
+ meta?: any;
67
+ /**
68
+ * The data sent with the "done.state._id_" event if this is a final state node.
69
+ */
70
+ doneData?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
71
+ /**
72
+ * The order this state node appears. Corresponds to the implicit SCXML document order.
73
+ */
74
+ order: number;
75
+ description?: string;
76
+ tags: string[];
77
+ transitions: Array<TransitionDefinition<TContext, TEvent>>;
78
+ always?: Array<TransitionDefinition<TContext, TEvent>>;
79
+ constructor(
80
+ /**
81
+ * The raw config used to create the machine.
82
+ */
83
+ config: StateNodeConfig<TContext, TEvent>, options: StateNodeOptions<TContext, TEvent>);
84
+ _initialize(): void;
85
+ /**
86
+ * The well-structured state node definition.
87
+ */
88
+ get definition(): StateNodeDefinition<TContext, TEvent>;
89
+ toJSON(): StateNodeDefinition<TContext, TEvent>;
90
+ /**
91
+ * The behaviors invoked as actors by this state node.
92
+ */
93
+ get invoke(): Array<InvokeDefinition<TContext, TEvent>>;
94
+ /**
95
+ * The mapping of events to transitions.
96
+ */
97
+ get on(): TransitionDefinitionMap<TContext, TEvent>;
98
+ get after(): Array<DelayedTransitionDefinition<TContext, TEvent>>;
99
+ get initial(): InitialTransitionDefinition<TContext, TEvent>;
100
+ /**
101
+ * Returns `true` if this state node explicitly handles the given event.
102
+ *
103
+ * @param event The event in question
104
+ */
105
+ handles(event: TEvent): boolean;
106
+ next(state: State<TContext, TEvent>, _event: SCXML.Event<TEvent>): TransitionDefinition<TContext, TEvent>[] | undefined;
107
+ /**
108
+ * The target state value of the history state node, if it exists. This represents the
109
+ * default state value to transition to if no history value exists yet.
110
+ */
111
+ get target(): string | undefined;
112
+ /**
113
+ * All the state node IDs of this state node and its descendant state nodes.
114
+ */
115
+ get stateIds(): string[];
116
+ /**
117
+ * All the event types accepted by this state node and its descendants.
118
+ */
119
+ get events(): Array<TEvent['type']>;
120
+ /**
121
+ * All the events that have transitions directly from this state node.
122
+ *
123
+ * Excludes any inert events.
124
+ */
125
+ get ownEvents(): Array<TEvent['type']>;
126
+ }
127
+ export {};
@@ -1,17 +1,16 @@
1
- import { ActionTypes } from './types';
2
- export declare const stop = ActionTypes.Stop;
3
- export declare const raise = ActionTypes.Raise;
4
- export declare const send = ActionTypes.Send;
5
- export declare const cancel = ActionTypes.Cancel;
6
- export declare const assign = ActionTypes.Assign;
7
- export declare const after = ActionTypes.After;
8
- export declare const doneState = ActionTypes.DoneState;
9
- export declare const log = ActionTypes.Log;
10
- export declare const init = ActionTypes.Init;
11
- export declare const invoke = ActionTypes.Invoke;
12
- export declare const errorExecution = ActionTypes.ErrorExecution;
13
- export declare const errorPlatform = ActionTypes.ErrorPlatform;
14
- export declare const error = ActionTypes.ErrorCustom;
15
- export declare const update = ActionTypes.Update;
16
- export declare const choose = ActionTypes.Choose;
17
- export declare const pure = ActionTypes.Pure;
1
+ import { ActionTypes } from './types.js';
2
+ export declare const stop = ActionTypes.Stop;
3
+ export declare const raise = ActionTypes.Raise;
4
+ export declare const send = ActionTypes.Send;
5
+ export declare const cancel = ActionTypes.Cancel;
6
+ export declare const assign = ActionTypes.Assign;
7
+ export declare const after = ActionTypes.After;
8
+ export declare const doneState = ActionTypes.DoneState;
9
+ export declare const log = ActionTypes.Log;
10
+ export declare const init = ActionTypes.Init;
11
+ export declare const invoke = ActionTypes.Invoke;
12
+ export declare const errorExecution = ActionTypes.ErrorExecution;
13
+ export declare const errorPlatform = ActionTypes.ErrorPlatform;
14
+ export declare const error = ActionTypes.ErrorCustom;
15
+ export declare const choose = ActionTypes.Choose;
16
+ export declare const pure = ActionTypes.Pure;
@@ -1,7 +1,7 @@
1
- import type { EventObject, Assigner, PropertyAssigner, MachineContext, DynamicAssignAction } from '../types';
2
- /**
3
- * Updates the current context of the machine.
4
- *
5
- * @param assignment An object that represents the partial context to update.
6
- */
7
- export declare function assign<TContext extends MachineContext, TEvent extends EventObject = EventObject, TAssignment extends Assigner<TContext, TEvent> | PropertyAssigner<TContext, TEvent> = Assigner<TContext, TEvent> | PropertyAssigner<TContext, TEvent>>(assignment: TAssignment): DynamicAssignAction<TContext, TEvent>;
1
+ import type { EventObject, Assigner, PropertyAssigner, MachineContext, DynamicAssignAction, LowInfer } from '../types.js';
2
+ /**
3
+ * Updates the current context of the machine.
4
+ *
5
+ * @param assignment An object that represents the partial context to update.
6
+ */
7
+ export declare function assign<TContext extends MachineContext, TExpressionEvent extends EventObject = EventObject, TEvent extends EventObject = TExpressionEvent>(assignment: Assigner<LowInfer<TContext>, TExpressionEvent, TEvent> | PropertyAssigner<LowInfer<TContext>, TExpressionEvent, TEvent>): DynamicAssignAction<TContext, TExpressionEvent, TEvent>;
@@ -1,10 +1,10 @@
1
- import { EventObject, ExprWithMeta, MachineContext } from '../types';
2
- import { BaseDynamicActionObject, CancelActionObject, DynamicCancelActionObject } from '..';
3
- /**
4
- * Cancels an in-flight `send(...)` action. A canceled sent action will not
5
- * be executed, nor will its event be sent, unless it has already been sent
6
- * (e.g., if `cancel(...)` is called after the `send(...)` action's `delay`).
7
- *
8
- * @param sendId The `id` of the `send(...)` action to cancel.
9
- */
10
- export declare function cancel<TContext extends MachineContext, TEvent extends EventObject>(sendId: string | ExprWithMeta<TContext, TEvent, string>): BaseDynamicActionObject<TContext, TEvent, CancelActionObject, DynamicCancelActionObject<TContext, TEvent>['params']>;
1
+ import { EventObject, ExprWithMeta, MachineContext } from '../types.js';
2
+ import { BaseDynamicActionObject, CancelActionObject, DynamicCancelActionObject } from '../index.js';
3
+ /**
4
+ * Cancels an in-flight `send(...)` action. A canceled sent action will not
5
+ * be executed, nor will its event be sent, unless it has already been sent
6
+ * (e.g., if `cancel(...)` is called after the `send(...)` action's `delay`).
7
+ *
8
+ * @param sendId The `id` of the `send(...)` action to cancel.
9
+ */
10
+ export declare function cancel<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(sendId: string | ExprWithMeta<TContext, TExpressionEvent, string>): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, CancelActionObject, DynamicCancelActionObject<TContext, TExpressionEvent>['params']>;
@@ -1,3 +1,3 @@
1
- import { EventObject, ChooseCondition, MachineContext } from '../types';
2
- import { BaseDynamicActionObject, ChooseAction, ResolvedChooseAction } from '..';
3
- export declare function choose<TContext extends MachineContext, TEvent extends EventObject>(guards: Array<ChooseCondition<TContext, TEvent>>): BaseDynamicActionObject<TContext, TEvent, ResolvedChooseAction, ChooseAction<TContext, TEvent>['params']>;
1
+ import { EventObject, ChooseCondition, MachineContext } from '../types.js';
2
+ import { BaseDynamicActionObject, ChooseAction, ResolvedChooseAction } from '../index.js';
3
+ export declare function choose<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(guards: Array<ChooseCondition<TContext, TExpressionEvent>>): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, ResolvedChooseAction, ChooseAction<TContext, TExpressionEvent>['params']>;
@@ -1,3 +1,3 @@
1
- import { EventObject, InvokeDefinition, MachineContext } from '../types';
2
- import { BaseDynamicActionObject, DynamicInvokeActionObject, InvokeActionObject } from '..';
3
- export declare function invoke<TContext extends MachineContext, TEvent extends EventObject>(invokeDef: InvokeDefinition<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, InvokeActionObject, DynamicInvokeActionObject<TContext, TEvent>['params']>;
1
+ import { EventObject, InvokeDefinition, MachineContext } from '../types.js';
2
+ import { BaseDynamicActionObject, DynamicInvokeActionObject, InvokeActionObject } from '../index.js';
3
+ export declare function invoke<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(invokeDef: InvokeDefinition<TContext, TEvent>): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, InvokeActionObject, DynamicInvokeActionObject<TContext, TEvent>['params']>;
@@ -1,11 +1,11 @@
1
- import { EventObject, LogExpr, MachineContext, LogActionObject } from '../types';
2
- import { BaseDynamicActionObject, DynamicLogAction } from '..';
3
- /**
4
- *
5
- * @param expr The expression function to evaluate which will be logged.
6
- * Takes in 2 arguments:
7
- * - `ctx` - the current state context
8
- * - `event` - the event that caused this action to be executed.
9
- * @param label The label to give to the logged expression.
10
- */
11
- export declare function log<TContext extends MachineContext, TEvent extends EventObject>(expr?: string | LogExpr<TContext, TEvent>, label?: string): BaseDynamicActionObject<TContext, TEvent, LogActionObject, DynamicLogAction<TContext, TEvent>['params']>;
1
+ import { EventObject, LogExpr, MachineContext, LogActionObject } from '../types.js';
2
+ import { BaseDynamicActionObject, DynamicLogAction } from '../index.js';
3
+ /**
4
+ *
5
+ * @param expr The expression function to evaluate which will be logged.
6
+ * Takes in 2 arguments:
7
+ * - `ctx` - the current state context
8
+ * - `event` - the event that caused this action to be executed.
9
+ * @param label The label to give to the logged expression.
10
+ */
11
+ export declare function log<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(expr?: string | LogExpr<TContext, TExpressionEvent>, label?: string): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, LogActionObject, DynamicLogAction<TContext, TExpressionEvent, TEvent>['params']>;
@@ -1,3 +1,3 @@
1
- import { EventObject, SingleOrArray, MachineContext } from '../types';
2
- import { BaseActionObject, BaseDynamicActionObject, DynamicPureActionObject, PureActionObject } from '..';
3
- export declare function pure<TContext extends MachineContext, TEvent extends EventObject>(getActions: (context: TContext, event: TEvent) => SingleOrArray<BaseActionObject> | undefined): BaseDynamicActionObject<TContext, TEvent, PureActionObject, DynamicPureActionObject<TContext, TEvent>['params']>;
1
+ import { EventObject, SingleOrArray, MachineContext } from '../types.js';
2
+ import { BaseActionObject, BaseDynamicActionObject, DynamicPureActionObject, PureActionObject } from '..';
3
+ export declare function pure<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(getActions: (context: TContext, event: TExpressionEvent) => SingleOrArray<BaseActionObject | string> | undefined): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, PureActionObject, DynamicPureActionObject<TContext, TExpressionEvent>['params']>;
@@ -1,9 +1,8 @@
1
- import { Event, EventObject, RaiseActionObject } from '../types';
2
- import { BaseDynamicActionObject } from '..';
3
- /**
4
- * Raises an event. This places the event in the internal event queue, so that
5
- * the event is immediately consumed by the machine in the current step.
6
- *
7
- * @param eventType The event to raise.
8
- */
9
- export declare function raise<TEvent extends EventObject>(event: Event<TEvent>): BaseDynamicActionObject<any, TEvent, RaiseActionObject<TEvent>, RaiseActionObject<TEvent>['params']>;
1
+ import { EventObject, MachineContext, RaiseActionObject, BaseDynamicActionObject, RaiseActionOptions, SendExpr, RaiseActionParams, NoInfer } from '../types.js';
2
+ /**
3
+ * Raises an event. This places the event in the internal event queue, so that
4
+ * the event is immediately consumed by the machine in the current step.
5
+ *
6
+ * @param eventType The event to raise.
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>): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, RaiseActionObject<TContext, TExpressionEvent, TEvent>, RaiseActionParams<TContext, TExpressionEvent, TEvent>>;
@@ -1,55 +1,53 @@
1
- import { Event, EventObject, SendActionParams, SendExpr, AnyEventObject, MachineContext } from '../types';
2
- import { AnyActorRef, BaseDynamicActionObject, Cast, EventFrom, ExprWithMeta, InferEvent, SendActionObject, SendActionOptions } from '..';
3
- /**
4
- * Sends an event. This returns an action that will be read by an interpreter to
5
- * send the event in the next step, after the current step is finished executing.
6
- *
7
- * @param event The event to send.
8
- * @param options Options to pass into the send event:
9
- * - `id` - The unique send event identifier (used with `cancel()`).
10
- * - `delay` - The number of milliseconds to delay the sending of the event.
11
- * - `to` - The target of this event (by default, the machine the event was sent from).
12
- */
13
- export declare function send<TContext extends MachineContext, TEvent extends EventObject, TSentEvent extends EventObject = AnyEventObject>(event: Event<TSentEvent> | SendExpr<TContext, TEvent, TSentEvent>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent>>;
14
- /**
15
- * Sends an update event to this machine's parent.
16
- */
17
- export declare function sendUpdate<TContext extends MachineContext, TEvent extends EventObject>(): BaseDynamicActionObject<TContext, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
18
- /**
19
- * Sends an event to this machine's parent.
20
- *
21
- * @param event The event to send to the parent machine.
22
- * @param options Options to pass into the send event.
23
- */
24
- export declare function sendParent<TContext extends MachineContext, TEvent extends EventObject, TSentEvent extends EventObject = AnyEventObject>(event: Event<TSentEvent> | SendExpr<TContext, TEvent, TSentEvent>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
25
- /**
26
- * Sends an event back to the sender of the original event.
27
- *
28
- * @param event The event to send back to the sender
29
- * @param options Options to pass into the send event
30
- */
31
- export declare function respond<TContext extends MachineContext, TEvent extends EventObject, TSentEvent extends EventObject = AnyEventObject>(event: Event<TEvent> | SendExpr<TContext, TEvent, TSentEvent>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
32
- /**
33
- * Forwards (sends) an event to a specified service.
34
- *
35
- * @param target The target service to forward the event to.
36
- * @param options Options to pass into the send action creator.
37
- */
38
- export declare function forwardTo<TContext extends MachineContext, TEvent extends EventObject>(target: Required<SendActionParams<TContext, TEvent>>['to'], options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
39
- /**
40
- * Escalates an error by sending it as an event to this machine's parent.
41
- *
42
- * @param errorData The error data to send, or the expression function that
43
- * takes in the `context`, `event`, and `meta`, and returns the error data to send.
44
- * @param options Options to pass into the send action creator.
45
- */
46
- export declare function escalate<TContext extends MachineContext, TEvent extends EventObject, TErrorData = any>(errorData: TErrorData | ExprWithMeta<TContext, TEvent, TErrorData>, options?: SendActionParams<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
47
- /**
48
- * Sends an event to an actor.
49
- *
50
- * @param actor The `ActorRef` to send the event to.
51
- * @param event The event to send, or an expression that evaluates to the event to send
52
- * @param options Send action options
53
- * @returns An XState send action object
54
- */
55
- export declare function sendTo<TContext extends MachineContext, TEvent extends EventObject, TActor extends AnyActorRef>(actor: (ctx: TContext) => TActor, event: EventFrom<TActor> | SendExpr<TContext, TEvent, InferEvent<Cast<EventFrom<TActor>, EventObject>>>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
1
+ import { EventObject, SendActionParams, SendExpr, AnyEventObject, MachineContext } from '../types.js';
2
+ import { AnyActorRef, BaseDynamicActionObject, Cast, EventFrom, ExprWithMeta, InferEvent, SendActionObject, SendActionOptions } from '../index.js';
3
+ /**
4
+ * Sends an event. This returns an action that will be read by an interpreter to
5
+ * send the event in the next step, after the current step is finished executing.
6
+ *
7
+ * @deprecated Use the `sendTo(...)` action creator instead.
8
+ *
9
+ * @param eventOrExpr The event to send.
10
+ * @param options Options to pass into the send event:
11
+ * - `id` - The unique send event identifier (used with `cancel()`).
12
+ * - `delay` - The number of milliseconds to delay the sending of the event.
13
+ * - `to` - The target of this event (by default, the machine the event was sent from).
14
+ */
15
+ export declare function send<TContext extends MachineContext, TEvent extends EventObject, TSentEvent extends EventObject = AnyEventObject>(eventOrExpr: TSentEvent | SendExpr<TContext, TEvent, AnyEventObject>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent>>;
16
+ /**
17
+ * Sends an event to this machine's parent.
18
+ *
19
+ * @param event The event to send to the parent machine.
20
+ * @param options Options to pass into the send event.
21
+ */
22
+ export declare function sendParent<TContext extends MachineContext, TEvent extends EventObject, TSentEvent extends EventObject = AnyEventObject>(event: TSentEvent | SendExpr<TContext, TEvent, TSentEvent>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
23
+ /**
24
+ * Sends an event back to the sender of the original event.
25
+ *
26
+ * @param event The event to send back to the sender
27
+ * @param options Options to pass into the send event
28
+ */
29
+ export declare function respond<TContext extends MachineContext, TEvent extends EventObject, TSentEvent extends EventObject = AnyEventObject>(event: TEvent | SendExpr<TContext, TEvent, TSentEvent>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
30
+ /**
31
+ * Forwards (sends) an event to a specified service.
32
+ *
33
+ * @param target The target service to forward the event to.
34
+ * @param options Options to pass into the send action creator.
35
+ */
36
+ export declare function forwardTo<TContext extends MachineContext, TEvent extends EventObject>(target: Required<SendActionParams<TContext, TEvent>>['to'], options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
37
+ /**
38
+ * Escalates an error by sending it as an event to this machine's parent.
39
+ *
40
+ * @param errorData The error data to send, or the expression function that
41
+ * takes in the `context`, `event`, and `meta`, and returns the error data to send.
42
+ * @param options Options to pass into the send action creator.
43
+ */
44
+ export declare function escalate<TContext extends MachineContext, TEvent extends EventObject, TErrorData = any>(errorData: TErrorData | ExprWithMeta<TContext, TEvent, TErrorData>, options?: SendActionParams<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
45
+ /**
46
+ * Sends an event to an actor.
47
+ *
48
+ * @param actor The `ActorRef` to send the event to.
49
+ * @param event The event to send, or an expression that evaluates to the event to send
50
+ * @param options Send action options
51
+ * @returns An XState send action object
52
+ */
53
+ export declare function sendTo<TContext extends MachineContext, TEvent extends EventObject, TActor extends AnyActorRef>(actor: TActor | string | ExprWithMeta<TContext, TEvent, TActor | string>, event: EventFrom<TActor> | SendExpr<TContext, TEvent, InferEvent<Cast<EventFrom<TActor>, EventObject>>>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
@@ -1,8 +1,7 @@
1
- import { EventObject, ActorRef, Expr, MachineContext } from '../types';
2
- import { BaseDynamicActionObject, DynamicStopActionObject, StopActionObject } from '..';
3
- /**
4
- * Stops an actor.
5
- *
6
- * @param actorRef The actor to stop.
7
- */
8
- export declare function stop<TContext extends MachineContext, TEvent extends EventObject>(actorRef: string | Expr<TContext, TEvent, ActorRef<any>>): BaseDynamicActionObject<TContext, TEvent, StopActionObject, DynamicStopActionObject<TContext, TEvent>['params']>;
1
+ import { ActorRef, BaseDynamicActionObject, DynamicStopActionObject, EventObject, Expr, MachineContext, StopActionObject } from '../types.js';
2
+ /**
3
+ * Stops an actor.
4
+ *
5
+ * @param actorRef The actor to stop.
6
+ */
7
+ export declare function stop<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(actorRef: string | ActorRef<any> | Expr<TContext, TExpressionEvent, ActorRef<any> | string>): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, StopActionObject, DynamicStopActionObject<TContext, TExpressionEvent>['params']>;