xstate 5.0.0-alpha.0 → 5.0.0-alpha.1

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 (83) hide show
  1. package/README.md +23 -13
  2. package/actions/dist/xstate-actions.cjs.dev.js +22 -24
  3. package/actions/dist/xstate-actions.cjs.prod.js +22 -24
  4. package/actions/dist/xstate-actions.esm.js +1 -1
  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 +4 -4
  8. package/actions/package.json +5 -1
  9. package/actors/dist/xstate-actors.cjs.dev.js +12 -13
  10. package/actors/dist/xstate-actors.cjs.prod.js +12 -13
  11. package/actors/dist/xstate-actors.esm.js +1 -1
  12. package/actors/dist/xstate-actors.umd.min.js +2 -0
  13. package/actors/dist/xstate-actors.umd.min.js.map +1 -0
  14. package/actors/package.json +5 -1
  15. package/dev/dist/xstate-dev.umd.min.js +2 -0
  16. package/dev/dist/xstate-dev.umd.min.js.map +1 -0
  17. package/dev/package.json +5 -1
  18. package/dist/{actions-70094c93.cjs.prod.js → actions-7ea9280f.cjs.prod.js} +3118 -3209
  19. package/dist/{actions-6b86876d.cjs.dev.js → actions-b08d0da8.cjs.dev.js} +3105 -3202
  20. package/dist/{actions-ff512f16.esm.js → actions-b673cb13.esm.js} +3092 -3189
  21. package/dist/declarations/actions/dynamicAction.d.ts +5 -3
  22. package/dist/declarations/src/Machine.d.ts +4 -4
  23. package/dist/declarations/src/Mailbox.d.ts +12 -12
  24. package/dist/declarations/src/SimulatedClock.d.ts +16 -16
  25. package/dist/declarations/src/State.d.ts +97 -104
  26. package/dist/declarations/src/StateMachine.d.ts +120 -112
  27. package/dist/declarations/src/StateNode.d.ts +127 -127
  28. package/dist/declarations/src/actionTypes.d.ts +16 -17
  29. package/dist/declarations/src/actions/assign.d.ts +7 -7
  30. package/dist/declarations/src/actions/cancel.d.ts +10 -10
  31. package/dist/declarations/src/actions/choose.d.ts +3 -3
  32. package/dist/declarations/src/actions/invoke.d.ts +3 -3
  33. package/dist/declarations/src/actions/log.d.ts +11 -11
  34. package/dist/declarations/src/actions/pure.d.ts +3 -3
  35. package/dist/declarations/src/actions/raise.d.ts +9 -9
  36. package/dist/declarations/src/actions/send.d.ts +51 -55
  37. package/dist/declarations/src/actions/stop.d.ts +7 -8
  38. package/dist/declarations/src/actions.d.ts +43 -44
  39. package/dist/declarations/src/actors.d.ts +37 -38
  40. package/dist/declarations/src/constants.d.ts +5 -5
  41. package/dist/declarations/src/dev/index.d.ts +14 -14
  42. package/dist/declarations/src/environment.d.ts +1 -1
  43. package/dist/declarations/src/guards.d.ts +8 -9
  44. package/dist/declarations/src/index.d.ts +44 -47
  45. package/dist/declarations/src/interpreter.d.ts +108 -147
  46. package/dist/declarations/src/mapState.d.ts +3 -3
  47. package/dist/declarations/src/memo.d.ts +2 -1
  48. package/dist/declarations/src/registry.d.ts +8 -8
  49. package/dist/declarations/src/schema.d.ts +2 -2
  50. package/dist/declarations/src/spawn.d.ts +2 -2
  51. package/dist/declarations/src/stateUtils.d.ts +70 -85
  52. package/dist/declarations/src/symbolObservable.d.ts +1 -0
  53. package/dist/declarations/src/typegenTypes.d.ts +132 -132
  54. package/dist/declarations/src/types.d.ts +1001 -1026
  55. package/dist/declarations/src/utils.d.ts +54 -56
  56. package/dist/xstate.cjs.dev.js +856 -80
  57. package/dist/xstate.cjs.prod.js +856 -80
  58. package/dist/xstate.esm.js +815 -35
  59. package/dist/xstate.umd.min.js +2 -0
  60. package/dist/xstate.umd.min.js.map +1 -0
  61. package/guards/dist/xstate-guards.cjs.dev.js +7 -7
  62. package/guards/dist/xstate-guards.cjs.prod.js +7 -7
  63. package/guards/dist/xstate-guards.esm.js +1 -1
  64. package/guards/dist/xstate-guards.umd.min.js +2 -0
  65. package/guards/dist/xstate-guards.umd.min.js.map +1 -0
  66. package/guards/package.json +5 -1
  67. package/package.json +25 -2
  68. package/CHANGELOG.md +0 -1986
  69. package/actions/ExecutableAction.ts +0 -58
  70. package/dist/Machine-9ce74c11.cjs.dev.js +0 -755
  71. package/dist/Machine-dca041dc.cjs.prod.js +0 -749
  72. package/dist/Machine-fb2f47f5.esm.js +0 -751
  73. package/dist/declarations/actions/ExecutableAction.d.ts +0 -23
  74. package/dist/declarations/src/ObservableActorRef.d.ts +0 -25
  75. package/dist/declarations/src/match.d.ts +0 -5
  76. package/dist/declarations/src/model.d.ts +0 -5
  77. package/dist/declarations/src/model.types.d.ts +0 -53
  78. package/model/dist/xstate-model.cjs.d.ts +0 -1
  79. package/model/dist/xstate-model.cjs.dev.js +0 -41
  80. package/model/dist/xstate-model.cjs.js +0 -7
  81. package/model/dist/xstate-model.cjs.prod.js +0 -41
  82. package/model/dist/xstate-model.esm.js +0 -37
  83. 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';
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: 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';
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 } 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,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';
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,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';
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,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';
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,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';
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,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';
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,9 +1,9 @@
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, 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: TEvent): BaseDynamicActionObject<any, TEvent, RaiseActionObject<TEvent>, RaiseActionObject<TEvent>['params']>;
@@ -1,55 +1,51 @@
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';
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: TSentEvent | SendExpr<TContext, TEvent, TSentEvent>, options?: SendActionOptions<TContext, TEvent>): BaseDynamicActionObject<TContext, TEvent, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent>>;
14
+ /**
15
+ * Sends an event to this machine's parent.
16
+ *
17
+ * @param event The event to send to the parent machine.
18
+ * @param options Options to pass into the send event.
19
+ */
20
+ 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, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
21
+ /**
22
+ * Sends an event back to the sender of the original event.
23
+ *
24
+ * @param event The event to send back to the sender
25
+ * @param options Options to pass into the send event
26
+ */
27
+ 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, SendActionObject<AnyEventObject>, SendActionParams<TContext, TEvent, EventObject>>;
28
+ /**
29
+ * Forwards (sends) an event to a specified service.
30
+ *
31
+ * @param target The target service to forward the event to.
32
+ * @param options Options to pass into the send action creator.
33
+ */
34
+ 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>>;
35
+ /**
36
+ * Escalates an error by sending it as an event to this machine's parent.
37
+ *
38
+ * @param errorData The error data to send, or the expression function that
39
+ * takes in the `context`, `event`, and `meta`, and returns the error data to send.
40
+ * @param options Options to pass into the send action creator.
41
+ */
42
+ 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>>;
43
+ /**
44
+ * Sends an event to an actor.
45
+ *
46
+ * @param actor The `ActorRef` to send the event to.
47
+ * @param event The event to send, or an expression that evaluates to the event to send
48
+ * @param options Send action options
49
+ * @returns An XState send action object
50
+ */
51
+ 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,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';
2
+ /**
3
+ * Stops an actor.
4
+ *
5
+ * @param actorRef The actor to stop.
6
+ */
7
+ export declare function stop<TContext extends MachineContext, TEvent extends EventObject>(actorRef: string | ActorRef<any> | Expr<TContext, TEvent, ActorRef<any> | string>): BaseDynamicActionObject<TContext, TEvent, StopActionObject, DynamicStopActionObject<TContext, TEvent>['params']>;
@@ -1,44 +1,43 @@
1
- import { Action, EventObject, SingleOrArray, ActionType, ActionFunction, ActionFunctionMap, ActionTypes, DoneEvent, ErrorPlatformEvent, DoneEventObject, MachineContext, BaseActionObject } from './types';
2
- import * as actionTypes from './actionTypes';
3
- export { send, sendTo, sendUpdate, sendParent, respond, forwardTo, escalate } from './actions/send';
4
- export { stop } from './actions/stop';
5
- export { log } from './actions/log';
6
- export { cancel } from './actions/cancel';
7
- export { assign } from './actions/assign';
8
- export { raise } from './actions/raise';
9
- export { choose } from './actions/choose';
10
- export { actionTypes };
11
- export declare const initEvent: import("./types").SCXML.Event<{
12
- type: ActionTypes;
13
- }>;
14
- export declare function getActionFunction<TContext extends MachineContext, TEvent extends EventObject>(actionType: ActionType, actionFunctionMap?: ActionFunctionMap<TContext, TEvent>): BaseActionObject | ActionFunction<TContext, TEvent> | undefined;
15
- export declare function resolveActionObject(actionObject: BaseActionObject, actionFunctionMap?: ActionFunctionMap<any, any>): BaseActionObject;
16
- export declare function toActionObject<TContext extends MachineContext, TEvent extends EventObject>(action: BaseActionObject | ActionFunction<TContext, TEvent> | string, actionFunctionMap?: ActionFunctionMap<TContext, TEvent>): BaseActionObject;
17
- export declare const toActionObjects: <TContext extends MachineContext, TEvent extends EventObject>(action?: SingleOrArray<Action<TContext, TEvent>> | undefined, actionFunctionMap?: ActionFunctionMap<TContext, TEvent, BaseActionObject> | undefined) => BaseActionObject[];
18
- /**
19
- * Returns an event type that represents an implicit event that
20
- * is sent after the specified `delay`.
21
- *
22
- * @param delayRef The delay in milliseconds
23
- * @param id The state node ID where this event is handled
24
- */
25
- export declare function after(delayRef: number | string, id?: string): string;
26
- /**
27
- * Returns an event that represents that a final state node
28
- * has been reached in the parent state node.
29
- *
30
- * @param id The final state node's parent state node `id`
31
- * @param data The data to pass into the event
32
- */
33
- export declare function done(id: string, data?: any): DoneEventObject;
34
- /**
35
- * Returns an event that represents that an invoked service has terminated.
36
- *
37
- * An invoked service is terminated when it has reached a top-level final state node,
38
- * but not when it is canceled.
39
- *
40
- * @param invokeId The invoked service ID
41
- * @param data The data to pass into the event
42
- */
43
- export declare function doneInvoke(invokeId: string, data?: any): DoneEvent;
44
- export declare function error(id: string, data?: any): ErrorPlatformEvent & string;
1
+ import { Action, EventObject, SingleOrArray, ActionFunction, ActionFunctionMap, ActionTypes, DoneEvent, ErrorPlatformEvent, DoneEventObject, MachineContext, BaseActionObject, SCXML } from './types';
2
+ import * as actionTypes from './actionTypes';
3
+ export { send, sendTo, sendParent, respond, forwardTo, escalate } from './actions/send';
4
+ export { stop } from './actions/stop';
5
+ export { log } from './actions/log';
6
+ export { cancel } from './actions/cancel';
7
+ export { assign } from './actions/assign';
8
+ export { raise } from './actions/raise';
9
+ export { choose } from './actions/choose';
10
+ export { actionTypes };
11
+ export declare const initEvent: SCXML.Event<{
12
+ type: ActionTypes;
13
+ }>;
14
+ export declare function resolveActionObject(actionObject: BaseActionObject, actionFunctionMap: ActionFunctionMap<any, any>): BaseActionObject;
15
+ export declare function toActionObject<TContext extends MachineContext, TEvent extends EventObject>(action: BaseActionObject | ActionFunction<TContext, TEvent> | string): BaseActionObject;
16
+ export declare const toActionObjects: <TContext extends MachineContext, TEvent extends EventObject>(action?: SingleOrArray<Action<TContext, TEvent>> | undefined) => BaseActionObject[];
17
+ /**
18
+ * Returns an event type that represents an implicit event that
19
+ * is sent after the specified `delay`.
20
+ *
21
+ * @param delayRef The delay in milliseconds
22
+ * @param id The state node ID where this event is handled
23
+ */
24
+ export declare function after(delayRef: number | string, id?: string): string;
25
+ /**
26
+ * Returns an event that represents that a final state node
27
+ * has been reached in the parent state node.
28
+ *
29
+ * @param id The final state node's parent state node `id`
30
+ * @param data The data to pass into the event
31
+ */
32
+ export declare function done(id: string, data?: any): DoneEventObject;
33
+ /**
34
+ * Returns an event that represents that an invoked service has terminated.
35
+ *
36
+ * An invoked service is terminated when it has reached a top-level final state node,
37
+ * but not when it is canceled.
38
+ *
39
+ * @param invokeId The invoked service ID
40
+ * @param data The data to pass into the event
41
+ */
42
+ export declare function doneInvoke(invokeId: string, data?: any): DoneEvent;
43
+ export declare function error(id: string, data?: any): ErrorPlatformEvent & string;