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.
- package/README.md +25 -16
- package/actions/dist/xstate-actions.cjs.d.ts +1 -0
- package/actions/dist/xstate-actions.cjs.dev.js +30 -0
- package/actions/dist/xstate-actions.cjs.js +7 -0
- package/actions/dist/xstate-actions.cjs.prod.js +30 -0
- package/actions/dist/xstate-actions.esm.js +2 -0
- package/actions/dist/xstate-actions.umd.min.js +2 -0
- package/actions/dist/xstate-actions.umd.min.js.map +1 -0
- package/actions/dynamicAction.ts +34 -0
- package/actions/package.json +8 -0
- package/actors/dist/xstate-actors.cjs.d.ts +1 -0
- package/actors/dist/xstate-actors.cjs.dev.js +20 -0
- package/actors/dist/xstate-actors.cjs.js +7 -0
- package/actors/dist/xstate-actors.cjs.prod.js +20 -0
- package/actors/dist/xstate-actors.esm.js +2 -0
- package/actors/dist/xstate-actors.umd.min.js +2 -0
- package/actors/dist/xstate-actors.umd.min.js.map +1 -0
- package/actors/package.json +8 -0
- package/dev/dist/xstate-dev.cjs.d.ts +1 -0
- package/dev/dist/xstate-dev.cjs.dev.js +11 -0
- package/dev/dist/xstate-dev.cjs.js +7 -0
- package/{lib/devTools.js → dev/dist/xstate-dev.cjs.prod.js} +17 -10
- package/dev/dist/xstate-dev.esm.js +1 -0
- package/dev/dist/xstate-dev.umd.min.js +2 -0
- package/dev/dist/xstate-dev.umd.min.js.map +1 -0
- package/dev/package.json +8 -0
- package/dist/actions-7ea9280f.cjs.prod.js +4674 -0
- package/dist/actions-b08d0da8.cjs.dev.js +4718 -0
- package/dist/actions-b673cb13.esm.js +4660 -0
- package/dist/declarations/actions/dynamicAction.d.ts +5 -0
- package/dist/declarations/src/Machine.d.ts +4 -0
- package/dist/declarations/src/Mailbox.d.ts +12 -0
- package/{es → dist/declarations/src}/SimulatedClock.d.ts +16 -17
- package/dist/declarations/src/State.d.ts +97 -0
- package/dist/declarations/src/StateMachine.d.ts +120 -0
- package/dist/declarations/src/StateNode.d.ts +127 -0
- package/{es → dist/declarations/src}/actionTypes.d.ts +16 -20
- package/dist/declarations/src/actions/assign.d.ts +7 -0
- package/dist/declarations/src/actions/cancel.d.ts +10 -0
- package/dist/declarations/src/actions/choose.d.ts +3 -0
- package/dist/declarations/src/actions/invoke.d.ts +3 -0
- package/dist/declarations/src/actions/log.d.ts +11 -0
- package/dist/declarations/src/actions/pure.d.ts +3 -0
- package/dist/declarations/src/actions/raise.d.ts +9 -0
- package/dist/declarations/src/actions/send.d.ts +51 -0
- package/dist/declarations/src/actions/stop.d.ts +7 -0
- package/dist/declarations/src/actions.d.ts +43 -0
- package/dist/declarations/src/actors.d.ts +37 -0
- package/dist/declarations/src/constants.d.ts +5 -0
- package/{lib/devTools.d.ts → dist/declarations/src/dev/index.d.ts} +14 -14
- package/{es → dist/declarations/src}/environment.d.ts +1 -2
- package/dist/declarations/src/guards.d.ts +8 -0
- package/dist/declarations/src/index.d.ts +44 -0
- package/dist/declarations/src/interpreter.d.ts +108 -0
- package/{es → dist/declarations/src}/mapState.d.ts +3 -4
- package/dist/declarations/src/memo.d.ts +2 -0
- package/dist/declarations/src/registry.d.ts +8 -0
- package/{es → dist/declarations/src}/schema.d.ts +2 -3
- package/dist/declarations/src/spawn.d.ts +2 -0
- package/dist/declarations/src/stateUtils.d.ts +70 -0
- package/dist/declarations/src/symbolObservable.d.ts +1 -0
- package/{lib → dist/declarations/src}/typegenTypes.d.ts +132 -133
- package/dist/declarations/src/types.d.ts +1001 -0
- package/dist/declarations/src/utils.d.ts +54 -0
- package/{es/devTools.js → dist/index-20b364c4.esm.js} +18 -6
- package/dist/index-2a564d03.cjs.dev.js +64 -0
- package/dist/xstate.cjs.d.ts +1 -0
- package/dist/xstate.cjs.dev.js +993 -0
- package/dist/xstate.cjs.js +7 -0
- package/dist/xstate.cjs.prod.js +993 -0
- package/dist/xstate.esm.js +952 -0
- package/dist/xstate.umd.min.js +2 -0
- package/dist/xstate.umd.min.js.map +1 -0
- package/guards/dist/xstate-guards.cjs.d.ts +1 -0
- package/guards/dist/xstate-guards.cjs.dev.js +15 -0
- package/guards/dist/xstate-guards.cjs.js +7 -0
- package/guards/dist/xstate-guards.cjs.prod.js +15 -0
- package/guards/dist/xstate-guards.esm.js +2 -0
- package/guards/dist/xstate-guards.umd.min.js +2 -0
- package/guards/dist/xstate-guards.umd.min.js.map +1 -0
- package/guards/package.json +8 -0
- package/invoke/package.json +4 -0
- package/package.json +44 -30
- package/dist/xstate.interpreter.js +0 -15
- package/dist/xstate.js +0 -15
- package/dist/xstate.web.js +0 -15
- package/es/Actor.d.ts +0 -25
- package/es/Actor.js +0 -99
- package/es/Machine.d.ts +0 -12
- package/es/Machine.js +0 -21
- package/es/SimulatedClock.js +0 -81
- package/es/State.d.ts +0 -123
- package/es/State.js +0 -274
- package/es/StateNode.d.ts +0 -282
- package/es/StateNode.js +0 -1587
- package/es/_virtual/_tslib.js +0 -78
- package/es/actionTypes.js +0 -22
- package/es/actions.d.ts +0 -157
- package/es/actions.js +0 -630
- package/es/behaviors.d.ts +0 -37
- package/es/behaviors.js +0 -131
- package/es/constants.d.ts +0 -6
- package/es/constants.js +0 -6
- package/es/devTools.d.ts +0 -14
- package/es/each.d.ts +0 -4
- package/es/each.js +0 -13
- package/es/environment.js +0 -3
- package/es/index.d.ts +0 -22
- package/es/index.js +0 -25
- package/es/interpreter.d.ts +0 -217
- package/es/interpreter.js +0 -1488
- package/es/invoke.d.ts +0 -11
- package/es/invokeUtils.d.ts +0 -7
- package/es/invokeUtils.js +0 -40
- package/es/json.d.ts +0 -31
- package/es/json.js +0 -86
- package/es/mapState.js +0 -32
- package/es/match.d.ts +0 -9
- package/es/match.js +0 -34
- package/es/model.d.ts +0 -8
- package/es/model.js +0 -50
- package/es/model.types.d.ts +0 -56
- package/es/patterns.d.ts +0 -14
- package/es/patterns.js +0 -48
- package/es/registry.d.ts +0 -9
- package/es/registry.js +0 -19
- package/es/scheduler.d.ts +0 -17
- package/es/scheduler.js +0 -79
- package/es/schema.js +0 -6
- package/es/scxml.d.ts +0 -6
- package/es/serviceScope.d.ts +0 -4
- package/es/serviceScope.js +0 -16
- package/es/stateUtils.d.ts +0 -18
- package/es/stateUtils.js +0 -262
- package/es/typegenTypes.d.ts +0 -133
- package/es/types.d.ts +0 -1040
- package/es/types.js +0 -33
- package/es/utils.d.ts +0 -72
- package/es/utils.js +0 -622
- package/es/waitFor.d.ts +0 -34
- package/es/waitFor.js +0 -73
- package/lib/Actor.d.ts +0 -25
- package/lib/Actor.js +0 -108
- package/lib/Machine.d.ts +0 -12
- package/lib/Machine.js +0 -26
- package/lib/SimulatedClock.d.ts +0 -17
- package/lib/SimulatedClock.js +0 -85
- package/lib/State.d.ts +0 -123
- package/lib/State.js +0 -282
- package/lib/StateNode.d.ts +0 -282
- package/lib/StateNode.js +0 -1591
- package/lib/_virtual/_tslib.js +0 -85
- package/lib/actionTypes.d.ts +0 -20
- package/lib/actionTypes.js +0 -43
- package/lib/actions.d.ts +0 -157
- package/lib/actions.js +0 -662
- package/lib/behaviors.d.ts +0 -37
- package/lib/behaviors.js +0 -137
- package/lib/constants.d.ts +0 -6
- package/lib/constants.js +0 -13
- package/lib/each.d.ts +0 -4
- package/lib/each.js +0 -17
- package/lib/environment.d.ts +0 -2
- package/lib/environment.js +0 -7
- package/lib/index.d.ts +0 -22
- package/lib/index.js +0 -64
- package/lib/interpreter.d.ts +0 -217
- package/lib/interpreter.js +0 -1494
- package/lib/invoke.d.ts +0 -11
- package/lib/invoke.js +0 -20
- package/lib/invokeUtils.d.ts +0 -7
- package/lib/invokeUtils.js +0 -45
- package/lib/json.d.ts +0 -31
- package/lib/json.js +0 -94
- package/lib/mapState.d.ts +0 -4
- package/lib/mapState.js +0 -36
- package/lib/match.d.ts +0 -9
- package/lib/match.js +0 -38
- package/lib/model.d.ts +0 -8
- package/lib/model.js +0 -54
- package/lib/model.types.d.ts +0 -56
- package/lib/model.types.js +0 -2
- package/lib/patterns.d.ts +0 -14
- package/lib/patterns.js +0 -53
- package/lib/registry.d.ts +0 -9
- package/lib/registry.js +0 -23
- package/lib/scheduler.d.ts +0 -17
- package/lib/scheduler.js +0 -83
- package/lib/schema.d.ts +0 -3
- package/lib/schema.js +0 -11
- package/lib/scxml.d.ts +0 -6
- package/lib/scxml.js +0 -350
- package/lib/serviceScope.d.ts +0 -4
- package/lib/serviceScope.js +0 -21
- package/lib/stateUtils.d.ts +0 -18
- package/lib/stateUtils.js +0 -277
- package/lib/typegenTypes.js +0 -2
- package/lib/types.d.ts +0 -1040
- package/lib/types.js +0 -35
- package/lib/utils.d.ts +0 -72
- package/lib/utils.js +0 -669
- package/lib/waitFor.d.ts +0 -34
- package/lib/waitFor.js +0 -77
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;
|
package/lib/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/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;
|
package/lib/environment.d.ts
DELETED
package/lib/environment.js
DELETED
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, 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/lib/index.js
DELETED
|
@@ -1,64 +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
|
-
sendTo = actions.sendTo,
|
|
21
|
-
sendParent = actions.sendParent,
|
|
22
|
-
sendUpdate = actions.sendUpdate,
|
|
23
|
-
forwardTo = actions.forwardTo,
|
|
24
|
-
doneInvoke = actions.doneInvoke,
|
|
25
|
-
raise = actions.raise;
|
|
26
|
-
|
|
27
|
-
exports.actions = actions;
|
|
28
|
-
exports.toActorRef = Actor.toActorRef;
|
|
29
|
-
exports.Interpreter = interpreter.Interpreter;
|
|
30
|
-
Object.defineProperty(exports, 'InterpreterStatus', {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () { return interpreter.InterpreterStatus; }
|
|
33
|
-
});
|
|
34
|
-
exports.interpret = interpreter.interpret;
|
|
35
|
-
exports.spawn = interpreter.spawn;
|
|
36
|
-
exports.Machine = Machine.Machine;
|
|
37
|
-
exports.createMachine = Machine.createMachine;
|
|
38
|
-
exports.mapState = mapState.mapState;
|
|
39
|
-
exports.matchState = match.matchState;
|
|
40
|
-
exports.createSchema = schema.createSchema;
|
|
41
|
-
exports.t = schema.t;
|
|
42
|
-
exports.State = State.State;
|
|
43
|
-
exports.StateNode = StateNode.StateNode;
|
|
44
|
-
exports.spawnBehavior = behaviors.spawnBehavior;
|
|
45
|
-
Object.defineProperty(exports, 'ActionTypes', {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () { return types.ActionTypes; }
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(exports, 'SpecialTargets', {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () { return types.SpecialTargets; }
|
|
52
|
-
});
|
|
53
|
-
exports.matchesState = utils.matchesState;
|
|
54
|
-
exports.toEventObject = utils.toEventObject;
|
|
55
|
-
exports.toObserver = utils.toObserver;
|
|
56
|
-
exports.toSCXMLEvent = utils.toSCXMLEvent;
|
|
57
|
-
exports.assign = assign;
|
|
58
|
-
exports.doneInvoke = doneInvoke;
|
|
59
|
-
exports.forwardTo = forwardTo;
|
|
60
|
-
exports.raise = raise;
|
|
61
|
-
exports.send = send;
|
|
62
|
-
exports.sendParent = sendParent;
|
|
63
|
-
exports.sendTo = sendTo;
|
|
64
|
-
exports.sendUpdate = sendUpdate;
|
package/lib/interpreter.d.ts
DELETED
|
@@ -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
|