xstate 4.32.1 → 5.0.0-alpha.0

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 (206) hide show
  1. package/CHANGELOG.md +483 -0
  2. package/actions/ExecutableAction.ts +58 -0
  3. package/actions/dist/xstate-actions.cjs.d.ts +1 -0
  4. package/actions/dist/xstate-actions.cjs.dev.js +32 -0
  5. package/actions/dist/xstate-actions.cjs.js +7 -0
  6. package/actions/dist/xstate-actions.cjs.prod.js +32 -0
  7. package/actions/dist/xstate-actions.esm.js +2 -0
  8. package/actions/dynamicAction.ts +34 -0
  9. package/actions/package.json +4 -0
  10. package/actors/dist/xstate-actors.cjs.d.ts +1 -0
  11. package/actors/dist/xstate-actors.cjs.dev.js +21 -0
  12. package/actors/dist/xstate-actors.cjs.js +7 -0
  13. package/actors/dist/xstate-actors.cjs.prod.js +21 -0
  14. package/actors/dist/xstate-actors.esm.js +2 -0
  15. package/actors/package.json +4 -0
  16. package/dev/dist/xstate-dev.cjs.d.ts +1 -0
  17. package/dev/dist/xstate-dev.cjs.dev.js +11 -0
  18. package/dev/dist/xstate-dev.cjs.js +7 -0
  19. package/{lib/devTools.js → dev/dist/xstate-dev.cjs.prod.js} +17 -10
  20. package/dev/dist/xstate-dev.esm.js +1 -0
  21. package/dev/package.json +4 -0
  22. package/dist/Machine-9ce74c11.cjs.dev.js +755 -0
  23. package/dist/Machine-dca041dc.cjs.prod.js +749 -0
  24. package/dist/Machine-fb2f47f5.esm.js +751 -0
  25. package/dist/actions-6b86876d.cjs.dev.js +4815 -0
  26. package/dist/actions-70094c93.cjs.prod.js +4765 -0
  27. package/dist/actions-ff512f16.esm.js +4757 -0
  28. package/dist/declarations/actions/ExecutableAction.d.ts +23 -0
  29. package/dist/declarations/actions/dynamicAction.d.ts +3 -0
  30. package/dist/declarations/src/Machine.d.ts +4 -0
  31. package/dist/declarations/src/Mailbox.d.ts +12 -0
  32. package/dist/declarations/src/ObservableActorRef.d.ts +25 -0
  33. package/{lib → dist/declarations/src}/SimulatedClock.d.ts +0 -1
  34. package/dist/declarations/src/State.d.ts +104 -0
  35. package/dist/declarations/src/StateMachine.d.ts +112 -0
  36. package/dist/declarations/src/StateNode.d.ts +127 -0
  37. package/{es → dist/declarations/src}/actionTypes.d.ts +0 -3
  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 +55 -0
  46. package/dist/declarations/src/actions/stop.d.ts +8 -0
  47. package/dist/declarations/src/actions.d.ts +44 -0
  48. package/dist/declarations/src/actors.d.ts +38 -0
  49. package/dist/declarations/src/constants.d.ts +5 -0
  50. package/{lib/devTools.d.ts → dist/declarations/src/dev/index.d.ts} +2 -2
  51. package/{es → dist/declarations/src}/environment.d.ts +0 -1
  52. package/dist/declarations/src/guards.d.ts +9 -0
  53. package/dist/declarations/src/index.d.ts +47 -0
  54. package/dist/declarations/src/interpreter.d.ts +147 -0
  55. package/{es → dist/declarations/src}/mapState.d.ts +0 -1
  56. package/dist/declarations/src/match.d.ts +5 -0
  57. package/dist/declarations/src/memo.d.ts +1 -0
  58. package/dist/declarations/src/model.d.ts +5 -0
  59. package/{lib → dist/declarations/src}/model.types.d.ts +6 -9
  60. package/dist/declarations/src/registry.d.ts +8 -0
  61. package/{es → dist/declarations/src}/schema.d.ts +0 -1
  62. package/dist/declarations/src/spawn.d.ts +2 -0
  63. package/dist/declarations/src/stateUtils.d.ts +85 -0
  64. package/{lib → dist/declarations/src}/typegenTypes.d.ts +16 -17
  65. package/dist/declarations/src/types.d.ts +1026 -0
  66. package/dist/declarations/src/utils.d.ts +56 -0
  67. package/{es/devTools.js → dist/index-20b364c4.esm.js} +18 -6
  68. package/dist/index-2a564d03.cjs.dev.js +64 -0
  69. package/dist/xstate.cjs.d.ts +1 -0
  70. package/dist/xstate.cjs.dev.js +217 -0
  71. package/dist/xstate.cjs.js +7 -0
  72. package/dist/xstate.cjs.prod.js +217 -0
  73. package/dist/xstate.esm.js +172 -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/package.json +4 -0
  80. package/invoke/package.json +4 -0
  81. package/model/dist/xstate-model.cjs.d.ts +1 -0
  82. package/model/dist/xstate-model.cjs.dev.js +41 -0
  83. package/model/dist/xstate-model.cjs.js +7 -0
  84. package/model/dist/xstate-model.cjs.prod.js +41 -0
  85. package/model/dist/xstate-model.esm.js +37 -0
  86. package/model/package.json +4 -0
  87. package/package.json +21 -30
  88. package/dist/xstate.interpreter.js +0 -15
  89. package/dist/xstate.js +0 -15
  90. package/dist/xstate.web.js +0 -15
  91. package/es/Actor.d.ts +0 -25
  92. package/es/Actor.js +0 -99
  93. package/es/Machine.d.ts +0 -12
  94. package/es/Machine.js +0 -14
  95. package/es/SimulatedClock.d.ts +0 -17
  96. package/es/SimulatedClock.js +0 -81
  97. package/es/State.d.ts +0 -123
  98. package/es/State.js +0 -274
  99. package/es/StateNode.d.ts +0 -287
  100. package/es/StateNode.js +0 -1566
  101. package/es/_virtual/_tslib.js +0 -78
  102. package/es/actionTypes.js +0 -22
  103. package/es/actions.d.ts +0 -154
  104. package/es/actions.js +0 -520
  105. package/es/behaviors.d.ts +0 -37
  106. package/es/behaviors.js +0 -131
  107. package/es/constants.d.ts +0 -6
  108. package/es/constants.js +0 -6
  109. package/es/devTools.d.ts +0 -14
  110. package/es/each.d.ts +0 -4
  111. package/es/each.js +0 -13
  112. package/es/environment.js +0 -3
  113. package/es/index.d.ts +0 -22
  114. package/es/index.js +0 -23
  115. package/es/interpreter.d.ts +0 -209
  116. package/es/interpreter.js +0 -1402
  117. package/es/invoke.d.ts +0 -11
  118. package/es/invokeUtils.d.ts +0 -7
  119. package/es/invokeUtils.js +0 -40
  120. package/es/json.d.ts +0 -31
  121. package/es/json.js +0 -86
  122. package/es/mapState.js +0 -32
  123. package/es/match.d.ts +0 -9
  124. package/es/match.js +0 -34
  125. package/es/model.d.ts +0 -5
  126. package/es/model.js +0 -50
  127. package/es/model.types.d.ts +0 -56
  128. package/es/patterns.d.ts +0 -14
  129. package/es/patterns.js +0 -48
  130. package/es/registry.d.ts +0 -9
  131. package/es/registry.js +0 -19
  132. package/es/scheduler.d.ts +0 -17
  133. package/es/scheduler.js +0 -79
  134. package/es/schema.js +0 -6
  135. package/es/scxml.d.ts +0 -6
  136. package/es/serviceScope.d.ts +0 -4
  137. package/es/serviceScope.js +0 -16
  138. package/es/stateUtils.d.ts +0 -17
  139. package/es/stateUtils.js +0 -259
  140. package/es/typegenTypes.d.ts +0 -133
  141. package/es/types.d.ts +0 -1031
  142. package/es/types.js +0 -33
  143. package/es/utils.d.ts +0 -72
  144. package/es/utils.js +0 -626
  145. package/es/waitFor.d.ts +0 -32
  146. package/es/waitFor.js +0 -71
  147. package/lib/Actor.d.ts +0 -25
  148. package/lib/Actor.js +0 -108
  149. package/lib/Machine.d.ts +0 -12
  150. package/lib/Machine.js +0 -19
  151. package/lib/SimulatedClock.js +0 -85
  152. package/lib/State.d.ts +0 -123
  153. package/lib/State.js +0 -282
  154. package/lib/StateNode.d.ts +0 -287
  155. package/lib/StateNode.js +0 -1570
  156. package/lib/_virtual/_tslib.js +0 -85
  157. package/lib/actionTypes.d.ts +0 -20
  158. package/lib/actionTypes.js +0 -43
  159. package/lib/actions.d.ts +0 -154
  160. package/lib/actions.js +0 -552
  161. package/lib/behaviors.d.ts +0 -37
  162. package/lib/behaviors.js +0 -137
  163. package/lib/constants.d.ts +0 -6
  164. package/lib/constants.js +0 -13
  165. package/lib/each.d.ts +0 -4
  166. package/lib/each.js +0 -17
  167. package/lib/environment.d.ts +0 -2
  168. package/lib/environment.js +0 -7
  169. package/lib/index.d.ts +0 -22
  170. package/lib/index.js +0 -60
  171. package/lib/interpreter.d.ts +0 -209
  172. package/lib/interpreter.js +0 -1408
  173. package/lib/invoke.d.ts +0 -11
  174. package/lib/invoke.js +0 -20
  175. package/lib/invokeUtils.d.ts +0 -7
  176. package/lib/invokeUtils.js +0 -45
  177. package/lib/json.d.ts +0 -31
  178. package/lib/json.js +0 -94
  179. package/lib/mapState.d.ts +0 -4
  180. package/lib/mapState.js +0 -36
  181. package/lib/match.d.ts +0 -9
  182. package/lib/match.js +0 -38
  183. package/lib/model.d.ts +0 -5
  184. package/lib/model.js +0 -54
  185. package/lib/model.types.js +0 -2
  186. package/lib/patterns.d.ts +0 -14
  187. package/lib/patterns.js +0 -53
  188. package/lib/registry.d.ts +0 -9
  189. package/lib/registry.js +0 -23
  190. package/lib/scheduler.d.ts +0 -17
  191. package/lib/scheduler.js +0 -83
  192. package/lib/schema.d.ts +0 -3
  193. package/lib/schema.js +0 -11
  194. package/lib/scxml.d.ts +0 -6
  195. package/lib/scxml.js +0 -350
  196. package/lib/serviceScope.d.ts +0 -4
  197. package/lib/serviceScope.js +0 -21
  198. package/lib/stateUtils.d.ts +0 -17
  199. package/lib/stateUtils.js +0 -273
  200. package/lib/typegenTypes.js +0 -2
  201. package/lib/types.d.ts +0 -1031
  202. package/lib/types.js +0 -35
  203. package/lib/utils.d.ts +0 -72
  204. package/lib/utils.js +0 -673
  205. package/lib/waitFor.d.ts +0 -32
  206. package/lib/waitFor.js +0 -75
package/lib/behaviors.js DELETED
@@ -1,137 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var actions = require('./actions.js');
6
- var Actor = require('./Actor.js');
7
- var utils = require('./utils.js');
8
-
9
- /**
10
- * Returns an actor behavior from a reducer and its initial state.
11
- *
12
- * @param transition The pure reducer that returns the next state given the current state and event.
13
- * @param initialState The initial state of the reducer.
14
- * @returns An actor behavior
15
- */
16
-
17
- function fromReducer(transition, initialState) {
18
- return {
19
- transition: transition,
20
- initialState: initialState
21
- };
22
- }
23
- function fromPromise(promiseFn) {
24
- var initialState = {
25
- error: undefined,
26
- data: undefined,
27
- status: 'pending'
28
- };
29
- return {
30
- transition: function (state, event, _a) {
31
- var parent = _a.parent,
32
- id = _a.id,
33
- observers = _a.observers;
34
-
35
- switch (event.type) {
36
- case 'fulfill':
37
- parent === null || parent === void 0 ? void 0 : parent.send(actions.doneInvoke(id, event.data));
38
- return {
39
- error: undefined,
40
- data: event.data,
41
- status: 'fulfilled'
42
- };
43
-
44
- case 'reject':
45
- parent === null || parent === void 0 ? void 0 : parent.send(actions.error(id, event.error));
46
- observers.forEach(function (observer) {
47
- observer.error(event.error);
48
- });
49
- return {
50
- error: event.error,
51
- data: undefined,
52
- status: 'rejected'
53
- };
54
-
55
- default:
56
- return state;
57
- }
58
- },
59
- initialState: initialState,
60
- start: function (_a) {
61
- var self = _a.self;
62
- promiseFn().then(function (data) {
63
- self.send({
64
- type: 'fulfill',
65
- data: data
66
- });
67
- }, function (reason) {
68
- self.send({
69
- type: 'reject',
70
- error: reason
71
- });
72
- });
73
- return initialState;
74
- }
75
- };
76
- }
77
- function spawnBehavior(behavior, options) {
78
- if (options === void 0) {
79
- options = {};
80
- }
81
-
82
- var state = behavior.initialState;
83
- var observers = new Set();
84
- var mailbox = [];
85
- var flushing = false;
86
-
87
- var flush = function () {
88
- if (flushing) {
89
- return;
90
- }
91
-
92
- flushing = true;
93
-
94
- while (mailbox.length > 0) {
95
- var event_1 = mailbox.shift();
96
- state = behavior.transition(state, event_1, actorCtx);
97
- observers.forEach(function (observer) {
98
- return observer.next(state);
99
- });
100
- }
101
-
102
- flushing = false;
103
- };
104
-
105
- var actor = Actor.toActorRef({
106
- id: options.id,
107
- send: function (event) {
108
- mailbox.push(event);
109
- flush();
110
- },
111
- getSnapshot: function () {
112
- return state;
113
- },
114
- subscribe: function (next, handleError, complete) {
115
- var observer = utils.toObserver(next, handleError, complete);
116
- observers.add(observer);
117
- observer.next(state);
118
- return {
119
- unsubscribe: function () {
120
- observers.delete(observer);
121
- }
122
- };
123
- }
124
- });
125
- var actorCtx = {
126
- parent: options.parent,
127
- self: actor,
128
- id: options.id || 'anonymous',
129
- observers: observers
130
- };
131
- state = behavior.start ? behavior.start(actorCtx) : state;
132
- return actor;
133
- }
134
-
135
- exports.fromPromise = fromPromise;
136
- exports.fromReducer = fromReducer;
137
- exports.spawnBehavior = spawnBehavior;
@@ -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/lib/constants.js DELETED
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var STATE_DELIMITER = '.';
6
- var EMPTY_ACTIVITY_MAP = {};
7
- var DEFAULT_GUARD_TYPE = 'xstate.guard';
8
- var TARGETLESS_KEY = '';
9
-
10
- exports.DEFAULT_GUARD_TYPE = DEFAULT_GUARD_TYPE;
11
- exports.EMPTY_ACTIVITY_MAP = EMPTY_ACTIVITY_MAP;
12
- exports.STATE_DELIMITER = STATE_DELIMITER;
13
- exports.TARGETLESS_KEY = TARGETLESS_KEY;
package/lib/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/lib/each.js DELETED
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function each(collection, item, indexOrActions, maybeActions) {
6
- var actions = maybeActions || indexOrActions;
7
- var index = maybeActions ? indexOrActions : undefined;
8
- return {
9
- type: 'xstate.foreach',
10
- collection: collection,
11
- item: item,
12
- index: index,
13
- actions: actions
14
- };
15
- }
16
-
17
- exports.each = each;
@@ -1,2 +0,0 @@
1
- export declare const IS_PRODUCTION: boolean;
2
- //# sourceMappingURL=environment.d.ts.map
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var IS_PRODUCTION = process.env.NODE_ENV === 'production';
6
-
7
- exports.IS_PRODUCTION = IS_PRODUCTION;
package/lib/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, sendParent, sendUpdate, 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, sendParent: typeof actions.sendParent, sendUpdate: typeof actions.sendUpdate, forwardTo: typeof actions.forwardTo, doneInvoke: typeof actions.doneInvoke;
17
- declare global {
18
- interface SymbolConstructor {
19
- readonly observable: symbol;
20
- }
21
- }
22
- //# sourceMappingURL=index.d.ts.map
package/lib/index.js DELETED
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var actions = require('./actions.js');
6
- var Actor = require('./Actor.js');
7
- var interpreter = require('./interpreter.js');
8
- var Machine = require('./Machine.js');
9
- var mapState = require('./mapState.js');
10
- var match = require('./match.js');
11
- var schema = require('./schema.js');
12
- var State = require('./State.js');
13
- var StateNode = require('./StateNode.js');
14
- var behaviors = require('./behaviors.js');
15
- var types = require('./types.js');
16
- var utils = require('./utils.js');
17
-
18
- var assign = actions.assign,
19
- send = actions.send,
20
- sendParent = actions.sendParent,
21
- sendUpdate = actions.sendUpdate,
22
- forwardTo = actions.forwardTo,
23
- doneInvoke = actions.doneInvoke;
24
-
25
- exports.actions = actions;
26
- exports.toActorRef = Actor.toActorRef;
27
- exports.Interpreter = interpreter.Interpreter;
28
- Object.defineProperty(exports, 'InterpreterStatus', {
29
- enumerable: true,
30
- get: function () { return interpreter.InterpreterStatus; }
31
- });
32
- exports.interpret = interpreter.interpret;
33
- exports.spawn = interpreter.spawn;
34
- exports.Machine = Machine.Machine;
35
- exports.createMachine = Machine.createMachine;
36
- exports.mapState = mapState.mapState;
37
- exports.matchState = match.matchState;
38
- exports.createSchema = schema.createSchema;
39
- exports.t = schema.t;
40
- exports.State = State.State;
41
- exports.StateNode = StateNode.StateNode;
42
- exports.spawnBehavior = behaviors.spawnBehavior;
43
- Object.defineProperty(exports, 'ActionTypes', {
44
- enumerable: true,
45
- get: function () { return types.ActionTypes; }
46
- });
47
- Object.defineProperty(exports, 'SpecialTargets', {
48
- enumerable: true,
49
- get: function () { return types.SpecialTargets; }
50
- });
51
- exports.matchesState = utils.matchesState;
52
- exports.toEventObject = utils.toEventObject;
53
- exports.toObserver = utils.toObserver;
54
- exports.toSCXMLEvent = utils.toSCXMLEvent;
55
- exports.assign = assign;
56
- exports.doneInvoke = doneInvoke;
57
- exports.forwardTo = forwardTo;
58
- exports.send = send;
59
- exports.sendParent = sendParent;
60
- exports.sendUpdate = sendUpdate;
@@ -1,209 +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 devTools?;
77
- /**
78
- * Creates a new Interpreter instance (i.e., service) for the given machine with the provided options, if any.
79
- *
80
- * @param machine The machine to be interpreted
81
- * @param options Interpreter options
82
- */
83
- constructor(machine: StateMachine<TContext, TStateSchema, TEvent, TTypestate, any, any, TResolvedTypesMeta>, options?: InterpreterOptions);
84
- get initialState(): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
85
- get state(): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
86
- static interpret: typeof interpret;
87
- /**
88
- * Executes the actions of the given state, with that state's `context` and `event`.
89
- *
90
- * @param state The state whose actions will be executed
91
- * @param actionsConfig The action implementations to use
92
- */
93
- execute(state: State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>, actionsConfig?: MachineOptions<TContext, TEvent>['actions']): void;
94
- private update;
95
- onTransition(listener: StateListener<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>): this;
96
- subscribe(observer: Observer<State<TContext, TEvent, any, TTypestate, TResolvedTypesMeta>>): Subscription;
97
- subscribe(nextListener?: (state: State<TContext, TEvent, any, TTypestate, TResolvedTypesMeta>) => void, errorListener?: (error: any) => void, completeListener?: () => void): Subscription;
98
- /**
99
- * Adds an event listener that is notified whenever an event is sent to the running interpreter.
100
- * @param listener The event listener
101
- */
102
- onEvent(listener: EventListener): this;
103
- /**
104
- * Adds an event listener that is notified whenever a `send` event occurs.
105
- * @param listener The event listener
106
- */
107
- onSend(listener: EventListener): this;
108
- /**
109
- * Adds a context listener that is notified whenever the state context changes.
110
- * @param listener The context listener
111
- */
112
- onChange(listener: ContextListener<TContext>): this;
113
- /**
114
- * Adds a listener that is notified when the machine is stopped.
115
- * @param listener The listener
116
- */
117
- onStop(listener: Listener): this;
118
- /**
119
- * Adds a state listener that is notified when the statechart has reached its final state.
120
- * @param listener The state listener
121
- */
122
- onDone(listener: EventListener<DoneEvent>): this;
123
- /**
124
- * Removes a listener.
125
- * @param listener The listener to remove
126
- */
127
- off(listener: (...args: any[]) => void): this;
128
- /**
129
- * Alias for Interpreter.prototype.start
130
- */
131
- init: (initialState?: StateValue | State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta> | StateConfig<TContext, TEvent> | undefined) => this;
132
- /**
133
- * Starts the interpreter from the given state, or the initial state.
134
- * @param initialState The state to start the statechart from
135
- */
136
- start(initialState?: State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta> | StateConfig<TContext, TEvent> | StateValue): this;
137
- /**
138
- * Stops the interpreter and unsubscribe all listeners.
139
- *
140
- * This will also notify the `onStop` listeners.
141
- */
142
- stop(): this;
143
- /**
144
- * Sends an event to the running interpreter to trigger a transition.
145
- *
146
- * An array of events (batched) can be sent as well, which will send all
147
- * batched events to the running interpreter. The listeners will be
148
- * notified only **once** when all events are processed.
149
- *
150
- * @param event The event(s) to send
151
- */
152
- send: (event: SingleOrArray<Event<TEvent>> | SCXML.Event<TEvent>, payload?: EventData | undefined) => State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
153
- private batch;
154
- /**
155
- * Returns a send function bound to this interpreter instance.
156
- *
157
- * @param event The event to be sent by the sender.
158
- */
159
- sender(event: Event<TEvent>): () => State<TContext, TEvent, TStateSchema, TTypestate>;
160
- private sendTo;
161
- /**
162
- * Returns the next state given the interpreter's current state and the event.
163
- *
164
- * This is a pure method that does _not_ update the interpreter's state.
165
- *
166
- * @param event The event to determine the next state
167
- */
168
- nextState(event: Event<TEvent> | SCXML.Event<TEvent>): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
169
- private forward;
170
- private defer;
171
- private cancel;
172
- private exec;
173
- private removeChild;
174
- private stopChild;
175
- spawn(entity: Spawnable, name: string, options?: SpawnOptions): ActorRef<any>;
176
- spawnMachine<TChildContext, TChildStateSchema, TChildEvent extends EventObject>(machine: StateMachine<TChildContext, TChildStateSchema, TChildEvent>, options?: {
177
- id?: string;
178
- autoForward?: boolean;
179
- sync?: boolean;
180
- }): ActorRef<TChildEvent, State<TChildContext, TChildEvent>>;
181
- private spawnBehavior;
182
- private spawnPromise;
183
- private spawnCallback;
184
- private spawnObservable;
185
- private spawnActor;
186
- private spawnActivity;
187
- private spawnEffect;
188
- private attachDev;
189
- toJSON(): {
190
- id: string;
191
- };
192
- [Symbol.observable](): InteropSubscribable<State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>>;
193
- getSnapshot(): State<TContext, TEvent, TStateSchema, TTypestate, TResolvedTypesMeta>;
194
- }
195
- export declare function spawn<T extends Behavior<any, any>>(entity: T, nameOrOptions?: string | SpawnOptions): ActorRefFrom<T>;
196
- 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>>;
197
- export declare function spawn(entity: Spawnable, nameOrOptions?: string | SpawnOptions): ActorRef<any>;
198
- /**
199
- * Creates a new Interpreter instance for the given machine with the provided options, if any.
200
- *
201
- * @param machine The machine to interpret
202
- * @param options Interpreter options
203
- */
204
- export declare function interpret<TContext = DefaultContext, TStateSchema extends StateSchema = any, TEvent extends EventObject = EventObject, TTypestate extends Typestate<TContext> = {
205
- value: any;
206
- context: TContext;
207
- }, 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>;
208
- export {};
209
- //# sourceMappingURL=interpreter.d.ts.map