xstate 4.35.2 → 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 (203) hide show
  1. package/README.md +25 -16
  2. package/actions/dist/xstate-actions.cjs.d.ts +1 -0
  3. package/actions/dist/xstate-actions.cjs.dev.js +30 -0
  4. package/actions/dist/xstate-actions.cjs.js +7 -0
  5. package/actions/dist/xstate-actions.cjs.prod.js +30 -0
  6. package/actions/dist/xstate-actions.esm.js +2 -0
  7. package/actions/dist/xstate-actions.umd.min.js +2 -0
  8. package/actions/dist/xstate-actions.umd.min.js.map +1 -0
  9. package/actions/dynamicAction.ts +34 -0
  10. package/actions/package.json +8 -0
  11. package/actors/dist/xstate-actors.cjs.d.ts +1 -0
  12. package/actors/dist/xstate-actors.cjs.dev.js +20 -0
  13. package/actors/dist/xstate-actors.cjs.js +7 -0
  14. package/actors/dist/xstate-actors.cjs.prod.js +20 -0
  15. package/actors/dist/xstate-actors.esm.js +2 -0
  16. package/actors/dist/xstate-actors.umd.min.js +2 -0
  17. package/actors/dist/xstate-actors.umd.min.js.map +1 -0
  18. package/actors/package.json +8 -0
  19. package/dev/dist/xstate-dev.cjs.d.ts +1 -0
  20. package/dev/dist/xstate-dev.cjs.dev.js +11 -0
  21. package/dev/dist/xstate-dev.cjs.js +7 -0
  22. package/{lib/devTools.js → dev/dist/xstate-dev.cjs.prod.js} +17 -10
  23. package/dev/dist/xstate-dev.esm.js +1 -0
  24. package/dev/dist/xstate-dev.umd.min.js +2 -0
  25. package/dev/dist/xstate-dev.umd.min.js.map +1 -0
  26. package/dev/package.json +8 -0
  27. package/dist/actions-7ea9280f.cjs.prod.js +4674 -0
  28. package/dist/actions-b08d0da8.cjs.dev.js +4718 -0
  29. package/dist/actions-b673cb13.esm.js +4660 -0
  30. package/dist/declarations/actions/dynamicAction.d.ts +5 -0
  31. package/dist/declarations/src/Machine.d.ts +4 -0
  32. package/dist/declarations/src/Mailbox.d.ts +12 -0
  33. package/{es → dist/declarations/src}/SimulatedClock.d.ts +16 -17
  34. package/dist/declarations/src/State.d.ts +97 -0
  35. package/dist/declarations/src/StateMachine.d.ts +120 -0
  36. package/dist/declarations/src/StateNode.d.ts +127 -0
  37. package/{es → dist/declarations/src}/actionTypes.d.ts +16 -20
  38. package/dist/declarations/src/actions/assign.d.ts +7 -0
  39. package/dist/declarations/src/actions/cancel.d.ts +10 -0
  40. package/dist/declarations/src/actions/choose.d.ts +3 -0
  41. package/dist/declarations/src/actions/invoke.d.ts +3 -0
  42. package/dist/declarations/src/actions/log.d.ts +11 -0
  43. package/dist/declarations/src/actions/pure.d.ts +3 -0
  44. package/dist/declarations/src/actions/raise.d.ts +9 -0
  45. package/dist/declarations/src/actions/send.d.ts +51 -0
  46. package/dist/declarations/src/actions/stop.d.ts +7 -0
  47. package/dist/declarations/src/actions.d.ts +43 -0
  48. package/dist/declarations/src/actors.d.ts +37 -0
  49. package/dist/declarations/src/constants.d.ts +5 -0
  50. package/{lib/devTools.d.ts → dist/declarations/src/dev/index.d.ts} +14 -14
  51. package/{es → dist/declarations/src}/environment.d.ts +1 -2
  52. package/dist/declarations/src/guards.d.ts +8 -0
  53. package/dist/declarations/src/index.d.ts +44 -0
  54. package/dist/declarations/src/interpreter.d.ts +108 -0
  55. package/{es → dist/declarations/src}/mapState.d.ts +3 -4
  56. package/dist/declarations/src/memo.d.ts +2 -0
  57. package/dist/declarations/src/registry.d.ts +8 -0
  58. package/{es → dist/declarations/src}/schema.d.ts +2 -3
  59. package/dist/declarations/src/spawn.d.ts +2 -0
  60. package/dist/declarations/src/stateUtils.d.ts +70 -0
  61. package/dist/declarations/src/symbolObservable.d.ts +1 -0
  62. package/{lib → dist/declarations/src}/typegenTypes.d.ts +132 -133
  63. package/dist/declarations/src/types.d.ts +1001 -0
  64. package/dist/declarations/src/utils.d.ts +54 -0
  65. package/{es/devTools.js → dist/index-20b364c4.esm.js} +18 -6
  66. package/dist/index-2a564d03.cjs.dev.js +64 -0
  67. package/dist/xstate.cjs.d.ts +1 -0
  68. package/dist/xstate.cjs.dev.js +993 -0
  69. package/dist/xstate.cjs.js +7 -0
  70. package/dist/xstate.cjs.prod.js +993 -0
  71. package/dist/xstate.esm.js +952 -0
  72. package/dist/xstate.umd.min.js +2 -0
  73. package/dist/xstate.umd.min.js.map +1 -0
  74. package/guards/dist/xstate-guards.cjs.d.ts +1 -0
  75. package/guards/dist/xstate-guards.cjs.dev.js +15 -0
  76. package/guards/dist/xstate-guards.cjs.js +7 -0
  77. package/guards/dist/xstate-guards.cjs.prod.js +15 -0
  78. package/guards/dist/xstate-guards.esm.js +2 -0
  79. package/guards/dist/xstate-guards.umd.min.js +2 -0
  80. package/guards/dist/xstate-guards.umd.min.js.map +1 -0
  81. package/guards/package.json +8 -0
  82. package/invoke/package.json +4 -0
  83. package/package.json +44 -30
  84. package/dist/xstate.interpreter.js +0 -15
  85. package/dist/xstate.js +0 -15
  86. package/dist/xstate.web.js +0 -15
  87. package/es/Actor.d.ts +0 -25
  88. package/es/Actor.js +0 -99
  89. package/es/Machine.d.ts +0 -12
  90. package/es/Machine.js +0 -21
  91. package/es/SimulatedClock.js +0 -81
  92. package/es/State.d.ts +0 -123
  93. package/es/State.js +0 -274
  94. package/es/StateNode.d.ts +0 -282
  95. package/es/StateNode.js +0 -1587
  96. package/es/_virtual/_tslib.js +0 -78
  97. package/es/actionTypes.js +0 -22
  98. package/es/actions.d.ts +0 -157
  99. package/es/actions.js +0 -630
  100. package/es/behaviors.d.ts +0 -37
  101. package/es/behaviors.js +0 -131
  102. package/es/constants.d.ts +0 -6
  103. package/es/constants.js +0 -6
  104. package/es/devTools.d.ts +0 -14
  105. package/es/each.d.ts +0 -4
  106. package/es/each.js +0 -13
  107. package/es/environment.js +0 -3
  108. package/es/index.d.ts +0 -22
  109. package/es/index.js +0 -25
  110. package/es/interpreter.d.ts +0 -217
  111. package/es/interpreter.js +0 -1488
  112. package/es/invoke.d.ts +0 -11
  113. package/es/invokeUtils.d.ts +0 -7
  114. package/es/invokeUtils.js +0 -40
  115. package/es/json.d.ts +0 -31
  116. package/es/json.js +0 -86
  117. package/es/mapState.js +0 -32
  118. package/es/match.d.ts +0 -9
  119. package/es/match.js +0 -34
  120. package/es/model.d.ts +0 -8
  121. package/es/model.js +0 -50
  122. package/es/model.types.d.ts +0 -56
  123. package/es/patterns.d.ts +0 -14
  124. package/es/patterns.js +0 -48
  125. package/es/registry.d.ts +0 -9
  126. package/es/registry.js +0 -19
  127. package/es/scheduler.d.ts +0 -17
  128. package/es/scheduler.js +0 -79
  129. package/es/schema.js +0 -6
  130. package/es/scxml.d.ts +0 -6
  131. package/es/serviceScope.d.ts +0 -4
  132. package/es/serviceScope.js +0 -16
  133. package/es/stateUtils.d.ts +0 -18
  134. package/es/stateUtils.js +0 -262
  135. package/es/typegenTypes.d.ts +0 -133
  136. package/es/types.d.ts +0 -1040
  137. package/es/types.js +0 -33
  138. package/es/utils.d.ts +0 -72
  139. package/es/utils.js +0 -622
  140. package/es/waitFor.d.ts +0 -34
  141. package/es/waitFor.js +0 -73
  142. package/lib/Actor.d.ts +0 -25
  143. package/lib/Actor.js +0 -108
  144. package/lib/Machine.d.ts +0 -12
  145. package/lib/Machine.js +0 -26
  146. package/lib/SimulatedClock.d.ts +0 -17
  147. package/lib/SimulatedClock.js +0 -85
  148. package/lib/State.d.ts +0 -123
  149. package/lib/State.js +0 -282
  150. package/lib/StateNode.d.ts +0 -282
  151. package/lib/StateNode.js +0 -1591
  152. package/lib/_virtual/_tslib.js +0 -85
  153. package/lib/actionTypes.d.ts +0 -20
  154. package/lib/actionTypes.js +0 -43
  155. package/lib/actions.d.ts +0 -157
  156. package/lib/actions.js +0 -662
  157. package/lib/behaviors.d.ts +0 -37
  158. package/lib/behaviors.js +0 -137
  159. package/lib/constants.d.ts +0 -6
  160. package/lib/constants.js +0 -13
  161. package/lib/each.d.ts +0 -4
  162. package/lib/each.js +0 -17
  163. package/lib/environment.d.ts +0 -2
  164. package/lib/environment.js +0 -7
  165. package/lib/index.d.ts +0 -22
  166. package/lib/index.js +0 -64
  167. package/lib/interpreter.d.ts +0 -217
  168. package/lib/interpreter.js +0 -1494
  169. package/lib/invoke.d.ts +0 -11
  170. package/lib/invoke.js +0 -20
  171. package/lib/invokeUtils.d.ts +0 -7
  172. package/lib/invokeUtils.js +0 -45
  173. package/lib/json.d.ts +0 -31
  174. package/lib/json.js +0 -94
  175. package/lib/mapState.d.ts +0 -4
  176. package/lib/mapState.js +0 -36
  177. package/lib/match.d.ts +0 -9
  178. package/lib/match.js +0 -38
  179. package/lib/model.d.ts +0 -8
  180. package/lib/model.js +0 -54
  181. package/lib/model.types.d.ts +0 -56
  182. package/lib/model.types.js +0 -2
  183. package/lib/patterns.d.ts +0 -14
  184. package/lib/patterns.js +0 -53
  185. package/lib/registry.d.ts +0 -9
  186. package/lib/registry.js +0 -23
  187. package/lib/scheduler.d.ts +0 -17
  188. package/lib/scheduler.js +0 -83
  189. package/lib/schema.d.ts +0 -3
  190. package/lib/schema.js +0 -11
  191. package/lib/scxml.d.ts +0 -6
  192. package/lib/scxml.js +0 -350
  193. package/lib/serviceScope.d.ts +0 -4
  194. package/lib/serviceScope.js +0 -21
  195. package/lib/stateUtils.d.ts +0 -18
  196. package/lib/stateUtils.js +0 -277
  197. package/lib/typegenTypes.js +0 -2
  198. package/lib/types.d.ts +0 -1040
  199. package/lib/types.js +0 -35
  200. package/lib/utils.d.ts +0 -72
  201. package/lib/utils.js +0 -669
  202. package/lib/waitFor.d.ts +0 -34
  203. package/lib/waitFor.js +0 -77
package/es/behaviors.js DELETED
@@ -1,131 +0,0 @@
1
- import { error, doneInvoke } from './actions.js';
2
- import { toActorRef } from './Actor.js';
3
- import { toObserver } from './utils.js';
4
-
5
- /**
6
- * Returns an actor behavior from a reducer and its initial state.
7
- *
8
- * @param transition The pure reducer that returns the next state given the current state and event.
9
- * @param initialState The initial state of the reducer.
10
- * @returns An actor behavior
11
- */
12
-
13
- function fromReducer(transition, initialState) {
14
- return {
15
- transition: transition,
16
- initialState: initialState
17
- };
18
- }
19
- function fromPromise(promiseFn) {
20
- var initialState = {
21
- error: undefined,
22
- data: undefined,
23
- status: 'pending'
24
- };
25
- return {
26
- transition: function (state, event, _a) {
27
- var parent = _a.parent,
28
- id = _a.id,
29
- observers = _a.observers;
30
-
31
- switch (event.type) {
32
- case 'fulfill':
33
- parent === null || parent === void 0 ? void 0 : parent.send(doneInvoke(id, event.data));
34
- return {
35
- error: undefined,
36
- data: event.data,
37
- status: 'fulfilled'
38
- };
39
-
40
- case 'reject':
41
- parent === null || parent === void 0 ? void 0 : parent.send(error(id, event.error));
42
- observers.forEach(function (observer) {
43
- observer.error(event.error);
44
- });
45
- return {
46
- error: event.error,
47
- data: undefined,
48
- status: 'rejected'
49
- };
50
-
51
- default:
52
- return state;
53
- }
54
- },
55
- initialState: initialState,
56
- start: function (_a) {
57
- var self = _a.self;
58
- promiseFn().then(function (data) {
59
- self.send({
60
- type: 'fulfill',
61
- data: data
62
- });
63
- }, function (reason) {
64
- self.send({
65
- type: 'reject',
66
- error: reason
67
- });
68
- });
69
- return initialState;
70
- }
71
- };
72
- }
73
- function spawnBehavior(behavior, options) {
74
- if (options === void 0) {
75
- options = {};
76
- }
77
-
78
- var state = behavior.initialState;
79
- var observers = new Set();
80
- var mailbox = [];
81
- var flushing = false;
82
-
83
- var flush = function () {
84
- if (flushing) {
85
- return;
86
- }
87
-
88
- flushing = true;
89
-
90
- while (mailbox.length > 0) {
91
- var event_1 = mailbox.shift();
92
- state = behavior.transition(state, event_1, actorCtx);
93
- observers.forEach(function (observer) {
94
- return observer.next(state);
95
- });
96
- }
97
-
98
- flushing = false;
99
- };
100
-
101
- var actor = toActorRef({
102
- id: options.id,
103
- send: function (event) {
104
- mailbox.push(event);
105
- flush();
106
- },
107
- getSnapshot: function () {
108
- return state;
109
- },
110
- subscribe: function (next, handleError, complete) {
111
- var observer = toObserver(next, handleError, complete);
112
- observers.add(observer);
113
- observer.next(state);
114
- return {
115
- unsubscribe: function () {
116
- observers.delete(observer);
117
- }
118
- };
119
- }
120
- });
121
- var actorCtx = {
122
- parent: options.parent,
123
- self: actor,
124
- id: options.id || 'anonymous',
125
- observers: observers
126
- };
127
- state = behavior.start ? behavior.start(actorCtx) : state;
128
- return actor;
129
- }
130
-
131
- export { fromPromise, fromReducer, spawnBehavior };
package/es/constants.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { ActivityMap, DefaultGuardType } from './types';
2
- export declare const STATE_DELIMITER = ".";
3
- export declare const EMPTY_ACTIVITY_MAP: ActivityMap;
4
- export declare const DEFAULT_GUARD_TYPE: DefaultGuardType;
5
- export declare const TARGETLESS_KEY = "";
6
- //# sourceMappingURL=constants.d.ts.map
package/es/constants.js DELETED
@@ -1,6 +0,0 @@
1
- var STATE_DELIMITER = '.';
2
- var EMPTY_ACTIVITY_MAP = {};
3
- var DEFAULT_GUARD_TYPE = 'xstate.guard';
4
- var TARGETLESS_KEY = '';
5
-
6
- export { DEFAULT_GUARD_TYPE, EMPTY_ACTIVITY_MAP, STATE_DELIMITER, TARGETLESS_KEY };
package/es/devTools.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { AnyInterpreter } from './types';
2
- declare type ServiceListener = (service: AnyInterpreter) => void;
3
- export interface XStateDevInterface {
4
- register: (service: AnyInterpreter) => void;
5
- unregister: (service: AnyInterpreter) => void;
6
- onRegister: (listener: ServiceListener) => {
7
- unsubscribe: () => void;
8
- };
9
- services: Set<AnyInterpreter>;
10
- }
11
- export declare function getGlobal(): typeof globalThis | undefined;
12
- export declare function registerService(service: AnyInterpreter): void;
13
- export {};
14
- //# sourceMappingURL=devTools.d.ts.map
package/es/each.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { EventObject, SingleOrArray, ActionObject } from './types';
2
- export declare function each<TContext, TEvent extends EventObject>(collection: keyof TContext, item: keyof TContext, actions: SingleOrArray<ActionObject<TContext, TEvent>>): ActionObject<TContext, TEvent>;
3
- export declare function each<TContext, TEvent extends EventObject>(collection: keyof TContext, item: keyof TContext, index: keyof TContext, actions: SingleOrArray<ActionObject<TContext, TEvent>>): ActionObject<TContext, TEvent>;
4
- //# sourceMappingURL=each.d.ts.map
package/es/each.js DELETED
@@ -1,13 +0,0 @@
1
- function each(collection, item, indexOrActions, maybeActions) {
2
- var actions = maybeActions || indexOrActions;
3
- var index = maybeActions ? indexOrActions : undefined;
4
- return {
5
- type: 'xstate.foreach',
6
- collection: collection,
7
- item: item,
8
- index: index,
9
- actions: actions
10
- };
11
- }
12
-
13
- export { each };
package/es/environment.js DELETED
@@ -1,3 +0,0 @@
1
- var IS_PRODUCTION = process.env.NODE_ENV === 'production';
2
-
3
- export { IS_PRODUCTION };
package/es/index.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import * as actions from './actions';
2
- import { Actor, toActorRef } from './Actor';
3
- import { interpret, Interpreter, InterpreterStatus, spawn } from './interpreter';
4
- import { createMachine, Machine } from './Machine';
5
- import { mapState } from './mapState';
6
- import { matchState } from './match';
7
- import { createSchema, t } from './schema';
8
- import { State } from './State';
9
- import { StateNode } from './StateNode';
10
- export { spawnBehavior } from './behaviors';
11
- export { XStateDevInterface } from './devTools';
12
- export * from './typegenTypes';
13
- export * from './types';
14
- export { matchesState, toEventObject, toObserver, toSCXMLEvent } from './utils';
15
- export { Actor, toActorRef, Machine, StateNode, State, mapState, actions, assign, send, sendTo, sendParent, sendUpdate, raise, forwardTo, interpret, Interpreter, InterpreterStatus, matchState, spawn, doneInvoke, createMachine, createSchema, t };
16
- declare const assign: <TContext, TEvent extends import("./types").EventObject = import("./types").EventObject>(assignment: import("./types").Assigner<TContext, TEvent> | import("./types").PropertyAssigner<TContext, TEvent>) => import("./types").AssignAction<TContext, TEvent>, send: typeof actions.send, sendTo: typeof actions.sendTo, sendParent: typeof actions.sendParent, sendUpdate: typeof actions.sendUpdate, forwardTo: typeof actions.forwardTo, doneInvoke: typeof actions.doneInvoke, raise: typeof actions.raise;
17
- declare global {
18
- interface SymbolConstructor {
19
- readonly observable: symbol;
20
- }
21
- }
22
- //# sourceMappingURL=index.d.ts.map
package/es/index.js DELETED
@@ -1,25 +0,0 @@
1
- import { assign as assign$1, send as send$1, sendTo as sendTo$1, sendParent as sendParent$1, sendUpdate as sendUpdate$1, forwardTo as forwardTo$1, doneInvoke as doneInvoke$1, raise as raise$1 } from './actions.js';
2
- import * as actions from './actions.js';
3
- export { actions };
4
- export { toActorRef } from './Actor.js';
5
- export { Interpreter, InterpreterStatus, interpret, spawn } from './interpreter.js';
6
- export { Machine, createMachine } from './Machine.js';
7
- export { mapState } from './mapState.js';
8
- export { matchState } from './match.js';
9
- export { createSchema, t } from './schema.js';
10
- export { State } from './State.js';
11
- export { StateNode } from './StateNode.js';
12
- export { spawnBehavior } from './behaviors.js';
13
- export { ActionTypes, SpecialTargets } from './types.js';
14
- export { matchesState, toEventObject, toObserver, toSCXMLEvent } from './utils.js';
15
-
16
- var assign = assign$1,
17
- send = send$1,
18
- sendTo = sendTo$1,
19
- sendParent = sendParent$1,
20
- sendUpdate = sendUpdate$1,
21
- forwardTo = forwardTo$1,
22
- doneInvoke = doneInvoke$1,
23
- raise = raise$1;
24
-
25
- export { assign, doneInvoke, forwardTo, raise, send, sendParent, sendTo, sendUpdate };
@@ -1,217 +0,0 @@
1
- import { StateMachine, Event, EventObject, DefaultContext, StateSchema, StateValue, InterpreterOptions, SingleOrArray, DoneEvent, MachineOptions, SCXML, EventData, Observer, Spawnable, Typestate, ActorRef, ActorRefFrom, Behavior, Subscription, StateConfig, InteropSubscribable } from './types';
2
- import { State } from './State';
3
- import { symbolObservable } from './utils';
4
- import { AreAllImplementationsAssumedToBeProvided, TypegenDisabled } from './typegenTypes';
5
- export declare type StateListener<TContext, TEvent extends EventObject, TStateSchema extends StateSchema<TContext> = any, TTypestate extends Typestate<TContext> = {
6
- value: any;
7
- context: TContext;
8
- }, TResolvedTypesMeta = TypegenDisabled> = (state: State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>, event: TEvent) => void;
9
- export declare type ContextListener<TContext = DefaultContext> = (context: TContext, prevContext: TContext | undefined) => void;
10
- export declare type EventListener<TEvent extends EventObject = EventObject> = (event: TEvent) => void;
11
- export declare type Listener = () => void;
12
- export interface Clock {
13
- setTimeout(fn: (...args: any[]) => void, timeout: number): any;
14
- clearTimeout(id: any): void;
15
- }
16
- interface SpawnOptions {
17
- name?: string;
18
- autoForward?: boolean;
19
- sync?: boolean;
20
- }
21
- export declare enum InterpreterStatus {
22
- NotStarted = 0,
23
- Running = 1,
24
- Stopped = 2
25
- }
26
- export declare class Interpreter<TContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
27
- value: any;
28
- context: TContext;
29
- }, TResolvedTypesMeta = TypegenDisabled> implements ActorRef<TEvent, State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>> {
30
- machine: StateMachine<TContext, TStateSchema, TEvent, TTypestate, any, any, TResolvedTypesMeta>;
31
- /**
32
- * The default interpreter options:
33
- *
34
- * - `clock` uses the global `setTimeout` and `clearTimeout` functions
35
- * - `logger` uses the global `console.log()` method
36
- */
37
- static defaultOptions: {
38
- execute: boolean;
39
- deferEvents: boolean;
40
- clock: Clock;
41
- logger: any;
42
- devTools: boolean;
43
- };
44
- /**
45
- * The current state of the interpreted machine.
46
- */
47
- private _state?;
48
- private _initialState?;
49
- /**
50
- * The clock that is responsible for setting and clearing timeouts, such as delayed events and transitions.
51
- */
52
- clock: Clock;
53
- options: Readonly<InterpreterOptions>;
54
- private scheduler;
55
- private delayedEventsMap;
56
- private listeners;
57
- private contextListeners;
58
- private stopListeners;
59
- private doneListeners;
60
- private eventListeners;
61
- private sendListeners;
62
- private logger;
63
- /**
64
- * Whether the service is started.
65
- */
66
- initialized: boolean;
67
- status: InterpreterStatus;
68
- parent?: Interpreter<any>;
69
- id: string;
70
- /**
71
- * The globally unique process ID for this invocation.
72
- */
73
- sessionId: string;
74
- children: Map<string | number, ActorRef<any>>;
75
- private forwardTo;
76
- private _outgoingQueue;
77
- private devTools?;
78
- /**
79
- * Creates a new Interpreter instance (i.e., service) for the given machine with the provided options, if any.
80
- *
81
- * @param machine The machine to be interpreted
82
- * @param options Interpreter options
83
- */
84
- constructor(machine: StateMachine<TContext, TStateSchema, TEvent, TTypestate, any, any, TResolvedTypesMeta>, options?: InterpreterOptions);
85
- get initialState(): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
86
- /**
87
- * @deprecated Use `.getSnapshot()` instead.
88
- */
89
- get state(): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
90
- static interpret: typeof interpret;
91
- /**
92
- * Executes the actions of the given state, with that state's `context` and `event`.
93
- *
94
- * @param state The state whose actions will be executed
95
- * @param actionsConfig The action implementations to use
96
- */
97
- execute(state: State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>, actionsConfig?: MachineOptions<TContext, TEvent>['actions']): void;
98
- private update;
99
- onTransition(listener: StateListener<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>): this;
100
- subscribe(observer: Partial<Observer<State<TContext, TEvent, any, TTypestate, TResolvedTypesMeta>>>): Subscription;
101
- subscribe(nextListener?: (state: State<TContext, TEvent, any, TTypestate, TResolvedTypesMeta>) => void, errorListener?: (error: any) => void, completeListener?: () => void): Subscription;
102
- /**
103
- * Adds an event listener that is notified whenever an event is sent to the running interpreter.
104
- * @param listener The event listener
105
- */
106
- onEvent(listener: EventListener): this;
107
- /**
108
- * Adds an event listener that is notified whenever a `send` event occurs.
109
- * @param listener The event listener
110
- */
111
- onSend(listener: EventListener): this;
112
- /**
113
- * Adds a context listener that is notified whenever the state context changes.
114
- * @param listener The context listener
115
- */
116
- onChange(listener: ContextListener<TContext>): this;
117
- /**
118
- * Adds a listener that is notified when the machine is stopped.
119
- * @param listener The listener
120
- */
121
- onStop(listener: Listener): this;
122
- /**
123
- * Adds a state listener that is notified when the statechart has reached its final state.
124
- * @param listener The state listener
125
- */
126
- onDone(listener: EventListener<DoneEvent>): this;
127
- /**
128
- * Removes a listener.
129
- * @param listener The listener to remove
130
- */
131
- off(listener: (...args: any[]) => void): this;
132
- /**
133
- * Alias for Interpreter.prototype.start
134
- */
135
- init: (initialState?: State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta> | StateConfig<TContext, TEvent> | StateValue) => this;
136
- /**
137
- * Starts the interpreter from the given state, or the initial state.
138
- * @param initialState The state to start the statechart from
139
- */
140
- start(initialState?: State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta> | StateConfig<TContext, TEvent> | StateValue): this;
141
- private _stopChildren;
142
- private _stop;
143
- /**
144
- * Stops the interpreter and unsubscribe all listeners.
145
- *
146
- * This will also notify the `onStop` listeners.
147
- */
148
- stop(): this;
149
- /**
150
- * Sends an event to the running interpreter to trigger a transition.
151
- *
152
- * An array of events (batched) can be sent as well, which will send all
153
- * batched events to the running interpreter. The listeners will be
154
- * notified only **once** when all events are processed.
155
- *
156
- * @param event The event(s) to send
157
- */
158
- send: (event: SingleOrArray<Event<TEvent>> | SCXML.Event<TEvent>, payload?: EventData) => State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
159
- private batch;
160
- /**
161
- * Returns a send function bound to this interpreter instance.
162
- *
163
- * @param event The event to be sent by the sender.
164
- */
165
- sender(event: Event<TEvent>): () => State<TContext, TEvent, TStateSchema, TTypestate>;
166
- private sendTo;
167
- private _nextState;
168
- /**
169
- * Returns the next state given the interpreter's current state and the event.
170
- *
171
- * This is a pure method that does _not_ update the interpreter's state.
172
- *
173
- * @param event The event to determine the next state
174
- */
175
- nextState(event: Event<TEvent> | SCXML.Event<TEvent>): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
176
- private forward;
177
- private defer;
178
- private cancel;
179
- private _exec;
180
- private exec;
181
- private removeChild;
182
- private stopChild;
183
- spawn(entity: Spawnable, name: string, options?: SpawnOptions): ActorRef<any>;
184
- spawnMachine<TChildContext, TChildStateSchema extends StateSchema, TChildEvent extends EventObject>(machine: StateMachine<TChildContext, TChildStateSchema, TChildEvent>, options?: {
185
- id?: string;
186
- autoForward?: boolean;
187
- sync?: boolean;
188
- }): ActorRef<TChildEvent, State<TChildContext, TChildEvent>>;
189
- private spawnBehavior;
190
- private spawnPromise;
191
- private spawnCallback;
192
- private spawnObservable;
193
- private spawnActor;
194
- private spawnActivity;
195
- private spawnEffect;
196
- private attachDev;
197
- toJSON(): {
198
- id: string;
199
- };
200
- [Symbol.observable](): InteropSubscribable<State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>>;
201
- getSnapshot(): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
202
- }
203
- export declare function spawn<T extends Behavior<any, any>>(entity: T, nameOrOptions?: string | SpawnOptions): ActorRefFrom<T>;
204
- export declare function spawn<TC, TE extends EventObject>(entity: StateMachine<TC, any, TE, any, any, any, any>, nameOrOptions?: string | SpawnOptions): ActorRefFrom<StateMachine<TC, any, TE, any, any, any, any>>;
205
- export declare function spawn(entity: Spawnable, nameOrOptions?: string | SpawnOptions): ActorRef<any>;
206
- /**
207
- * Creates a new Interpreter instance for the given machine with the provided options, if any.
208
- *
209
- * @param machine The machine to interpret
210
- * @param options Interpreter options
211
- */
212
- export declare function interpret<TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
213
- value: any;
214
- context: TContext;
215
- }, TResolvedTypesMeta = TypegenDisabled>(machine: AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta> extends true ? StateMachine<TContext, TStateSchema, TEvent, TTypestate, any, any, TResolvedTypesMeta> : 'Some implementations missing', options?: InterpreterOptions): Interpreter<TContext, TStateSchema, TEvent, TTypestate, TResolvedTypesMeta>;
216
- export {};
217
- //# sourceMappingURL=interpreter.d.ts.map