xstate 4.26.0-pr2674-202191175724 → 4.27.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.
- package/CHANGELOG.md +60 -10
- package/dist/xstate.interpreter.js +1 -1
- package/dist/xstate.js +1 -1
- package/dist/xstate.web.js +2 -2
- package/es/Actor.d.ts +2 -1
- package/es/Machine.d.ts +4 -5
- package/es/State.d.ts +14 -13
- package/es/State.js +10 -3
- package/es/StateNode.d.ts +15 -15
- package/es/StateNode.js +50 -56
- package/es/_virtual/_tslib.js +8 -4
- package/es/actions.d.ts +21 -4
- package/es/actions.js +7 -7
- package/es/behaviors.d.ts +1 -1
- package/es/devTools.d.ts +2 -3
- package/es/devTools.js +4 -0
- package/es/each.d.ts +1 -1
- package/es/index.d.ts +0 -1
- package/es/interpreter.d.ts +25 -35
- package/es/interpreter.js +23 -17
- package/es/model.d.ts +2 -2
- package/es/model.types.d.ts +9 -8
- package/es/registry.js +1 -1
- package/es/scxml.d.ts +2 -2
- package/es/stateUtils.d.ts +6 -6
- package/es/stateUtils.js +8 -3
- package/es/types.d.ts +55 -69
- package/es/utils.d.ts +1 -1
- package/es/utils.js +10 -10
- package/lib/Actor.d.ts +2 -1
- package/lib/Machine.d.ts +4 -5
- package/lib/SimulatedClock.js +9 -5
- package/lib/State.d.ts +14 -13
- package/lib/State.js +10 -3
- package/lib/StateNode.d.ts +15 -15
- package/lib/StateNode.js +47 -53
- package/lib/_virtual/_tslib.js +8 -4
- package/lib/actions.d.ts +21 -4
- package/lib/actions.js +7 -7
- package/lib/behaviors.d.ts +1 -1
- package/lib/devTools.d.ts +2 -3
- package/lib/devTools.js +4 -0
- package/lib/each.d.ts +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/interpreter.d.ts +25 -35
- package/lib/interpreter.js +23 -17
- package/lib/json.js +7 -7
- package/lib/model.d.ts +2 -2
- package/lib/model.js +14 -10
- package/lib/model.types.d.ts +9 -8
- package/lib/patterns.js +2 -2
- package/lib/registry.js +1 -1
- package/lib/scxml.d.ts +2 -2
- package/lib/scxml.js +29 -25
- package/lib/stateUtils.d.ts +6 -6
- package/lib/stateUtils.js +7 -1
- package/lib/types.d.ts +55 -69
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +10 -10
- package/package.json +4 -8
- package/dist/xstate.cjs.d.ts +0 -11
- package/dist/xstate.cjs.js +0 -16
- package/es/typegenTypes.d.ts +0 -78
- package/lib/typegenTypes.d.ts +0 -78
- package/lib/typegenTypes.js +0 -2
package/lib/scxml.js
CHANGED
|
@@ -26,10 +26,14 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
26
26
|
}
|
|
27
27
|
return ar;
|
|
28
28
|
};
|
|
29
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
30
|
-
for (var i = 0,
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
+
if (ar || !(i in from)) {
|
|
32
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
+
ar[i] = from[i];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
37
|
};
|
|
34
38
|
var __values = (this && this.__values) || function(o) {
|
|
35
39
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
@@ -53,7 +57,7 @@ function getAttribute(element, attribute) {
|
|
|
53
57
|
}
|
|
54
58
|
function indexedRecord(items, identifier) {
|
|
55
59
|
var record = {};
|
|
56
|
-
var identifierFn = utils_1.isString(identifier)
|
|
60
|
+
var identifierFn = (0, utils_1.isString)(identifier)
|
|
57
61
|
? function (item) { return item[identifier]; }
|
|
58
62
|
: identifier;
|
|
59
63
|
items.forEach(function (item) {
|
|
@@ -71,7 +75,7 @@ function executableContent(elements) {
|
|
|
71
75
|
function getTargets(targetAttr) {
|
|
72
76
|
// return targetAttr ? [`#${targetAttr}`] : undefined;
|
|
73
77
|
return targetAttr
|
|
74
|
-
?
|
|
78
|
+
? "".concat(targetAttr).split(/\s+/).map(function (target) { return "#".concat(target); })
|
|
75
79
|
: undefined;
|
|
76
80
|
}
|
|
77
81
|
function delayToMs(delay) {
|
|
@@ -96,29 +100,29 @@ function delayToMs(delay) {
|
|
|
96
100
|
: 0;
|
|
97
101
|
var millisecondsPart = parseInt(secondsMatch[3].padEnd(3, '0'), 10);
|
|
98
102
|
if (millisecondsPart >= 1000) {
|
|
99
|
-
throw new Error("Can't parse \""
|
|
103
|
+
throw new Error("Can't parse \"".concat(delay, " delay.\""));
|
|
100
104
|
}
|
|
101
105
|
return secondsPart + millisecondsPart;
|
|
102
106
|
}
|
|
103
|
-
throw new Error("Can't parse \""
|
|
107
|
+
throw new Error("Can't parse \"".concat(delay, " delay.\""));
|
|
104
108
|
}
|
|
105
109
|
var evaluateExecutableContent = function (context, _ev, meta, body) {
|
|
106
110
|
var datamodel = context
|
|
107
|
-
? utils_1.keys(context)
|
|
108
|
-
.map(function (key) { return "const "
|
|
111
|
+
? (0, utils_1.keys)(context)
|
|
112
|
+
.map(function (key) { return "const ".concat(key, " = context['").concat(key, "'];"); })
|
|
109
113
|
.join('\n')
|
|
110
114
|
: '';
|
|
111
115
|
var scope = ['const _sessionid = "NOT_IMPLEMENTED";', datamodel]
|
|
112
116
|
.filter(Boolean)
|
|
113
117
|
.join('\n');
|
|
114
118
|
var args = ['context', '_event'];
|
|
115
|
-
var fnBody = "\n "
|
|
116
|
-
var fn = new (Function.bind.apply(Function, __spreadArray(__spreadArray([void 0], __read(args)), [fnBody])))();
|
|
119
|
+
var fnBody = "\n ".concat(scope, "\n ").concat(body, "\n ");
|
|
120
|
+
var fn = new (Function.bind.apply(Function, __spreadArray(__spreadArray([void 0], __read(args), false), [fnBody], false)))();
|
|
117
121
|
return fn(context, meta._event);
|
|
118
122
|
};
|
|
119
123
|
function createCond(cond) {
|
|
120
124
|
return function (context, _event, meta) {
|
|
121
|
-
return evaluateExecutableContent(context, _event, meta, "return "
|
|
125
|
+
return evaluateExecutableContent(context, _event, meta, "return ".concat(cond, ";"));
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
128
|
function mapAction(element) {
|
|
@@ -129,7 +133,7 @@ function mapAction(element) {
|
|
|
129
133
|
}
|
|
130
134
|
case 'assign': {
|
|
131
135
|
return actions.assign(function (context, e, meta) {
|
|
132
|
-
var fnBody = "\n return {'"
|
|
136
|
+
var fnBody = "\n return {'".concat(element.attributes.location, "': ").concat(element.attributes.expr, "};\n ");
|
|
133
137
|
return evaluateExecutableContent(context, e, meta, fnBody);
|
|
134
138
|
});
|
|
135
139
|
}
|
|
@@ -142,14 +146,14 @@ function mapAction(element) {
|
|
|
142
146
|
if (child.name === 'content') {
|
|
143
147
|
throw new Error('Conversion of <content/> inside <send/> not implemented.');
|
|
144
148
|
}
|
|
145
|
-
return ""
|
|
149
|
+
return "".concat(acc).concat(child.attributes.name, ":").concat(child.attributes.expr, ",\n");
|
|
146
150
|
}, '');
|
|
147
151
|
if (event_1 && !params_1) {
|
|
148
152
|
convertedEvent = event_1;
|
|
149
153
|
}
|
|
150
154
|
else {
|
|
151
155
|
convertedEvent = function (context, _ev, meta) {
|
|
152
|
-
var fnBody = "\n return { type: "
|
|
156
|
+
var fnBody = "\n return { type: ".concat(event_1 ? "\"".concat(event_1, "\"") : eventexpr_1, ", ").concat(params_1 ? params_1 : '', " }\n ");
|
|
153
157
|
return evaluateExecutableContent(context, _ev, meta, fnBody);
|
|
154
158
|
};
|
|
155
159
|
}
|
|
@@ -158,7 +162,7 @@ function mapAction(element) {
|
|
|
158
162
|
}
|
|
159
163
|
else if (element.attributes.delayexpr) {
|
|
160
164
|
convertedDelay = function (context, _ev, meta) {
|
|
161
|
-
var fnBody = "\n return ("
|
|
165
|
+
var fnBody = "\n return (".concat(delayToMs, ")(").concat(element.attributes.delayexpr, ");\n ");
|
|
162
166
|
return evaluateExecutableContent(context, _ev, meta, fnBody);
|
|
163
167
|
};
|
|
164
168
|
}
|
|
@@ -170,7 +174,7 @@ function mapAction(element) {
|
|
|
170
174
|
case 'log': {
|
|
171
175
|
var label = element.attributes.label;
|
|
172
176
|
return actions.log(function (context, e, meta) {
|
|
173
|
-
var fnBody = "\n return "
|
|
177
|
+
var fnBody = "\n return ".concat(element.attributes.expr, ";\n ");
|
|
174
178
|
return evaluateExecutableContent(context, e, meta, fnBody);
|
|
175
179
|
}, label !== undefined ? String(label) : undefined);
|
|
176
180
|
}
|
|
@@ -215,7 +219,7 @@ function mapAction(element) {
|
|
|
215
219
|
return actions.choose(conds);
|
|
216
220
|
}
|
|
217
221
|
default:
|
|
218
|
-
throw new Error("Conversion of \""
|
|
222
|
+
throw new Error("Conversion of \"".concat(element.name, "\" elements is not implemented yet."));
|
|
219
223
|
}
|
|
220
224
|
}
|
|
221
225
|
function mapActions(elements) {
|
|
@@ -257,7 +261,7 @@ function toConfig(nodeJson, id, options) {
|
|
|
257
261
|
return {
|
|
258
262
|
id: id,
|
|
259
263
|
history: history_1,
|
|
260
|
-
target: target ? "#"
|
|
264
|
+
target: target ? "#".concat(target) : undefined
|
|
261
265
|
};
|
|
262
266
|
}
|
|
263
267
|
case 'final': {
|
|
@@ -277,7 +281,7 @@ function toConfig(nodeJson, id, options) {
|
|
|
277
281
|
var invokeElements = nodeJson.elements.filter(function (element) { return element.name === 'invoke'; });
|
|
278
282
|
var onEntryElement = nodeJson.elements.find(function (element) { return element.name === 'onentry'; });
|
|
279
283
|
var onExitElement = nodeJson.elements.find(function (element) { return element.name === 'onexit'; });
|
|
280
|
-
var states = indexedRecord(stateElements, function (item) { return ""
|
|
284
|
+
var states = indexedRecord(stateElements, function (item) { return "".concat(item.attributes.id); });
|
|
281
285
|
var initialElement = !initial
|
|
282
286
|
? nodeJson.elements.find(function (element) { return element.name === 'initial'; })
|
|
283
287
|
: undefined;
|
|
@@ -312,7 +316,7 @@ function toConfig(nodeJson, id, options) {
|
|
|
312
316
|
});
|
|
313
317
|
return __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: id }, (initial ? { initial: initial } : undefined)), (parallel ? { type: 'parallel' } : undefined)), (stateElements.length
|
|
314
318
|
? {
|
|
315
|
-
states: utils_1.mapValues(states, function (state, key) {
|
|
319
|
+
states: (0, utils_1.mapValues)(states, function (state, key) {
|
|
316
320
|
return toConfig(state, key, options);
|
|
317
321
|
})
|
|
318
322
|
}
|
|
@@ -332,15 +336,15 @@ function scxmlToMachine(scxmlJson, options) {
|
|
|
332
336
|
}
|
|
333
337
|
acc[element.attributes.id] = element.attributes.expr
|
|
334
338
|
? // tslint:disable-next-line:no-eval
|
|
335
|
-
eval("("
|
|
339
|
+
eval("(".concat(element.attributes.expr, ")"))
|
|
336
340
|
: undefined;
|
|
337
341
|
return acc;
|
|
338
342
|
}, {})
|
|
339
343
|
: undefined;
|
|
340
|
-
return index_1.Machine(__assign(__assign({}, toConfig(machineElement, '(machine)', options)), { context: extState, delimiter: options.delimiter }));
|
|
344
|
+
return (0, index_1.Machine)(__assign(__assign({}, toConfig(machineElement, '(machine)', options)), { context: extState, delimiter: options.delimiter }));
|
|
341
345
|
}
|
|
342
346
|
function toMachine(xml, options) {
|
|
343
|
-
var json = xml_js_1.xml2js(xml);
|
|
347
|
+
var json = (0, xml_js_1.xml2js)(xml);
|
|
344
348
|
return scxmlToMachine(json, options);
|
|
345
349
|
}
|
|
346
350
|
exports.toMachine = toMachine;
|
package/lib/stateUtils.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { EventObject, StateValue } from '
|
|
2
|
-
import { StateNode } from './StateNode';
|
|
1
|
+
import { EventObject, StateNode, StateValue } from '.';
|
|
3
2
|
declare type Configuration<TC, TE extends EventObject> = Iterable<StateNode<TC, any, TE>>;
|
|
4
3
|
declare type AdjList<TC, TE extends EventObject> = Map<StateNode<TC, any, TE>, Array<StateNode<TC, any, TE>>>;
|
|
5
|
-
export declare const isLeafNode: (stateNode: StateNode<any, any, any, any
|
|
4
|
+
export declare const isLeafNode: (stateNode: StateNode<any, any, any, any>) => boolean;
|
|
6
5
|
export declare function getChildren<TC, TE extends EventObject>(stateNode: StateNode<TC, any, TE>): Array<StateNode<TC, any, TE>>;
|
|
7
|
-
export declare function getAllStateNodes<TC, TE extends EventObject>(stateNode: StateNode<TC, any, TE, any
|
|
8
|
-
export declare function getConfiguration<TC, TE extends EventObject>(prevStateNodes: Iterable<StateNode<TC, any, TE, any
|
|
6
|
+
export declare function getAllStateNodes<TC, TE extends EventObject>(stateNode: StateNode<TC, any, TE, any>): Array<StateNode<TC, any, TE, any>>;
|
|
7
|
+
export declare function getConfiguration<TC, TE extends EventObject>(prevStateNodes: Iterable<StateNode<TC, any, TE, any>>, stateNodes: Iterable<StateNode<TC, any, TE, any>>): Set<StateNode<TC, any, TE, any>>;
|
|
9
8
|
export declare function getAdjList<TC, TE extends EventObject>(configuration: Configuration<TC, TE>): AdjList<TC, TE>;
|
|
10
9
|
export declare function getValue<TC, TE extends EventObject>(rootNode: StateNode<TC, any, TE, any>, configuration: Configuration<TC, TE>): StateValue;
|
|
11
10
|
export declare function has<T>(iterable: Iterable<T>, item: T): boolean;
|
|
12
11
|
export declare function nextEvents<TC, TE extends EventObject>(configuration: Array<StateNode<TC, any, TE>>): Array<TE['type']>;
|
|
13
|
-
export declare function isInFinalState<TC, TE extends EventObject>(configuration: Array<StateNode<TC, any, TE, any
|
|
12
|
+
export declare function isInFinalState<TC, TE extends EventObject>(configuration: Array<StateNode<TC, any, TE, any>>, stateNode: StateNode<TC, any, TE, any>): boolean;
|
|
14
13
|
export declare function getMeta(configuration?: StateNode[]): Record<string, any>;
|
|
14
|
+
export declare function getTagsFromConfiguration(configuration: StateNode<any, any, any, any>[]): Set<string>;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=stateUtils.d.ts.map
|
package/lib/stateUtils.js
CHANGED
|
@@ -226,7 +226,7 @@ function has(iterable, item) {
|
|
|
226
226
|
function nextEvents(configuration) {
|
|
227
227
|
return _tslib.__spreadArray([], _tslib.__read(new Set(utils.flatten(_tslib.__spreadArray([], _tslib.__read(configuration.map(function (sn) {
|
|
228
228
|
return sn.ownEvents;
|
|
229
|
-
})))))));
|
|
229
|
+
})), false)))), false);
|
|
230
230
|
}
|
|
231
231
|
function isInFinalState(configuration, stateNode) {
|
|
232
232
|
if (stateNode.type === 'compound') {
|
|
@@ -256,12 +256,18 @@ function getMeta(configuration) {
|
|
|
256
256
|
return acc;
|
|
257
257
|
}, {});
|
|
258
258
|
}
|
|
259
|
+
function getTagsFromConfiguration(configuration) {
|
|
260
|
+
return new Set(utils.flatten(configuration.map(function (sn) {
|
|
261
|
+
return sn.tags;
|
|
262
|
+
})));
|
|
263
|
+
}
|
|
259
264
|
|
|
260
265
|
exports.getAdjList = getAdjList;
|
|
261
266
|
exports.getAllStateNodes = getAllStateNodes;
|
|
262
267
|
exports.getChildren = getChildren;
|
|
263
268
|
exports.getConfiguration = getConfiguration;
|
|
264
269
|
exports.getMeta = getMeta;
|
|
270
|
+
exports.getTagsFromConfiguration = getTagsFromConfiguration;
|
|
265
271
|
exports.getValue = getValue;
|
|
266
272
|
exports.has = has;
|
|
267
273
|
exports.isInFinalState = isInFinalState;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import { Clock, Interpreter } from './interpreter';
|
|
2
|
-
import { Model } from './model.types';
|
|
3
|
-
import { State } from './State';
|
|
4
1
|
import { StateNode } from './StateNode';
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { State } from './State';
|
|
3
|
+
import { Interpreter, Clock } from './interpreter';
|
|
4
|
+
import { IsNever, Model, Prop } from './model.types';
|
|
5
|
+
declare type AnyFunction = (...args: any[]) => any;
|
|
7
6
|
declare type ReturnTypeOrValue<T> = T extends AnyFunction ? ReturnType<T> : T;
|
|
8
|
-
export declare type
|
|
9
|
-
export declare type Cast<T extends any, TCastType extends any> = T extends TCastType ? T : TCastType;
|
|
10
|
-
export declare type Compute<A extends any> = {
|
|
11
|
-
[K in keyof A]: A[K];
|
|
12
|
-
} & unknown;
|
|
13
|
-
export declare type Prop<T, K> = K extends keyof T ? T[K] : never;
|
|
14
|
-
export declare type Values<T> = T[keyof T];
|
|
15
|
-
export declare type Merge<M, N> = Omit<M, keyof N> & N;
|
|
16
|
-
export declare type IndexByType<T extends {
|
|
17
|
-
type: string;
|
|
18
|
-
}> = {
|
|
19
|
-
[K in T['type']]: Extract<T, {
|
|
20
|
-
type: K;
|
|
21
|
-
}>;
|
|
22
|
-
};
|
|
7
|
+
export declare type Cast<A, B> = A extends B ? A : B;
|
|
23
8
|
export declare type EventType = string;
|
|
24
9
|
export declare type ActionType = string;
|
|
25
10
|
export declare type MetaObject = Record<string, any>;
|
|
@@ -50,7 +35,7 @@ export interface ActionObject<TContext, TEvent extends EventObject> extends Base
|
|
|
50
35
|
/**
|
|
51
36
|
* The implementation for executing the action.
|
|
52
37
|
*/
|
|
53
|
-
exec?: ActionFunction<TContext, TEvent
|
|
38
|
+
exec?: ActionFunction<TContext, TEvent> | undefined;
|
|
54
39
|
}
|
|
55
40
|
export declare type DefaultContext = Record<string, any> | undefined;
|
|
56
41
|
export declare type EventData = Record<string, any> & {
|
|
@@ -60,7 +45,7 @@ export declare type EventData = Record<string, any> & {
|
|
|
60
45
|
* The specified string event types or the specified event objects.
|
|
61
46
|
*/
|
|
62
47
|
export declare type Event<TEvent extends EventObject> = TEvent['type'] | TEvent;
|
|
63
|
-
export interface ActionMeta<TContext, TEvent extends EventObject, TAction extends
|
|
48
|
+
export interface ActionMeta<TContext, TEvent extends EventObject, TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> extends StateMeta<TContext, TEvent> {
|
|
64
49
|
action: TAction;
|
|
65
50
|
_event: SCXML.Event<TEvent>;
|
|
66
51
|
}
|
|
@@ -69,8 +54,8 @@ export interface AssignMeta<TContext, TEvent extends EventObject> {
|
|
|
69
54
|
action: AssignAction<TContext, TEvent>;
|
|
70
55
|
_event: SCXML.Event<TEvent>;
|
|
71
56
|
}
|
|
72
|
-
export declare type ActionFunction<TContext, TEvent extends EventObject, TAction extends
|
|
73
|
-
export interface
|
|
57
|
+
export declare type ActionFunction<TContext, TEvent extends EventObject, TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> = (context: TContext, event: TEvent, meta: ActionMeta<TContext, TEvent, TAction>) => void;
|
|
58
|
+
export interface ChooseCondition<TContext, TEvent extends EventObject> {
|
|
74
59
|
cond?: Condition<TContext, TEvent>;
|
|
75
60
|
actions: Actions<TContext, TEvent>;
|
|
76
61
|
}
|
|
@@ -97,14 +82,6 @@ export interface StateValueMap {
|
|
|
97
82
|
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
98
83
|
*/
|
|
99
84
|
export declare type StateValue = string | StateValueMap;
|
|
100
|
-
declare type KeysWithStates<TStates extends Record<string, StateSchema> | undefined> = TStates extends object ? {
|
|
101
|
-
[K in keyof TStates]-?: TStates[K] extends {
|
|
102
|
-
states: object;
|
|
103
|
-
} ? K : never;
|
|
104
|
-
}[keyof TStates] : never;
|
|
105
|
-
export declare type ExtractStateValue<TSchema extends Required<Pick<StateSchema<any>, 'states'>>> = keyof TSchema['states'] | (KeysWithStates<TSchema['states']> extends never ? never : {
|
|
106
|
-
[K in KeysWithStates<TSchema['states']>]?: ExtractStateValue<TSchema['states'][K]>;
|
|
107
|
-
});
|
|
108
85
|
export interface HistoryValue {
|
|
109
86
|
states: Record<string, HistoryValue | undefined>;
|
|
110
87
|
current: StateValue | undefined;
|
|
@@ -130,7 +107,7 @@ export interface TransitionConfig<TContext, TEvent extends EventObject> {
|
|
|
130
107
|
actions?: Actions<TContext, TEvent>;
|
|
131
108
|
in?: StateValue;
|
|
132
109
|
internal?: boolean;
|
|
133
|
-
target?: TransitionTarget<TContext, TEvent
|
|
110
|
+
target?: TransitionTarget<TContext, TEvent> | undefined;
|
|
134
111
|
meta?: Record<string, any>;
|
|
135
112
|
description?: string;
|
|
136
113
|
}
|
|
@@ -174,6 +151,7 @@ export declare type InvokeCallback<TEvent extends EventObject = AnyEventObject,
|
|
|
174
151
|
export interface InvokeMeta {
|
|
175
152
|
data: any;
|
|
176
153
|
src: InvokeSourceDefinition;
|
|
154
|
+
meta?: MetaObject;
|
|
177
155
|
}
|
|
178
156
|
/**
|
|
179
157
|
* Returns either a Promises or a callback handler (for streams of events) given the
|
|
@@ -213,6 +191,7 @@ export interface InvokeDefinition<TContext, TEvent extends EventObject> extends
|
|
|
213
191
|
* Data should be mapped to match the child machine's context shape.
|
|
214
192
|
*/
|
|
215
193
|
data?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
|
|
194
|
+
meta?: MetaObject;
|
|
216
195
|
}
|
|
217
196
|
export interface Delay {
|
|
218
197
|
id: string;
|
|
@@ -295,6 +274,10 @@ export interface InvokeConfig<TContext, TEvent extends EventObject> {
|
|
|
295
274
|
* The transition to take upon the invoked child machine sending an error event.
|
|
296
275
|
*/
|
|
297
276
|
onError?: string | SingleOrArray<TransitionConfig<TContext, DoneInvokeEvent<any>>>;
|
|
277
|
+
/**
|
|
278
|
+
* Meta data related to this invocation
|
|
279
|
+
*/
|
|
280
|
+
meta?: MetaObject;
|
|
298
281
|
}
|
|
299
282
|
export interface StateNodeConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TAction extends BaseActionObject = BaseActionObject> {
|
|
300
283
|
/**
|
|
@@ -363,7 +346,7 @@ export interface StateNodeConfig<TContext, TStateSchema extends StateSchema, TEv
|
|
|
363
346
|
*
|
|
364
347
|
* This is equivalent to defining a `[done(id)]` transition on this state node's `on` property.
|
|
365
348
|
*/
|
|
366
|
-
onDone?: string | SingleOrArray<TransitionConfig<TContext, DoneEventObject
|
|
349
|
+
onDone?: string | SingleOrArray<TransitionConfig<TContext, DoneEventObject>> | undefined;
|
|
367
350
|
/**
|
|
368
351
|
* The mapping (or array) of delays (in milliseconds) to their potential transition(s).
|
|
369
352
|
* The delayed transitions are taken after the specified delay in an interpreter.
|
|
@@ -450,6 +433,7 @@ export interface StateNodeDefinition<TContext, TStateSchema extends StateSchema,
|
|
|
450
433
|
data?: FinalStateNodeConfig<TContext, TEvent>['data'];
|
|
451
434
|
invoke: Array<InvokeDefinition<TContext, TEvent>>;
|
|
452
435
|
description?: string;
|
|
436
|
+
tags: string[];
|
|
453
437
|
}
|
|
454
438
|
export declare type AnyStateNodeDefinition = StateNodeDefinition<any, any, any>;
|
|
455
439
|
export interface AtomicStateNodeConfig<TContext, TEvent extends EventObject> extends StateNodeConfig<TContext, StateSchema, TEvent> {
|
|
@@ -471,7 +455,7 @@ export interface FinalStateNodeConfig<TContext, TEvent extends EventObject> exte
|
|
|
471
455
|
data?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
|
|
472
456
|
}
|
|
473
457
|
export declare type SimpleOrStateNodeConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject> = AtomicStateNodeConfig<TContext, TEvent> | StateNodeConfig<TContext, TStateSchema, TEvent>;
|
|
474
|
-
export declare type ActionFunctionMap<TContext, TEvent extends EventObject, TAction extends
|
|
458
|
+
export declare type ActionFunctionMap<TContext, TEvent extends EventObject, TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> = {
|
|
475
459
|
[K in TAction['type']]?: ActionObject<TContext, TEvent> | ActionFunction<TContext, TEvent, TAction extends {
|
|
476
460
|
type: K;
|
|
477
461
|
} ? TAction : never>;
|
|
@@ -479,25 +463,25 @@ export declare type ActionFunctionMap<TContext, TEvent extends EventObject, TAct
|
|
|
479
463
|
export declare type DelayFunctionMap<TContext, TEvent extends EventObject> = Record<string, DelayConfig<TContext, TEvent>>;
|
|
480
464
|
export declare type ServiceConfig<TContext, TEvent extends EventObject = AnyEventObject> = string | StateMachine<any, any, any> | InvokeCreator<TContext, TEvent>;
|
|
481
465
|
export declare type DelayConfig<TContext, TEvent extends EventObject> = number | DelayExpr<TContext, TEvent>;
|
|
482
|
-
export interface MachineOptions<TContext, TEvent extends EventObject, TAction extends
|
|
483
|
-
guards
|
|
484
|
-
actions
|
|
466
|
+
export interface MachineOptions<TContext, TEvent extends EventObject, TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> {
|
|
467
|
+
guards: Record<string, ConditionPredicate<TContext, TEvent>>;
|
|
468
|
+
actions: ActionFunctionMap<TContext, TEvent, TAction>;
|
|
485
469
|
/**
|
|
486
470
|
* @deprecated Use `services` instead.
|
|
487
471
|
*/
|
|
488
|
-
activities
|
|
489
|
-
services
|
|
490
|
-
delays
|
|
472
|
+
activities: Record<string, ActivityConfig<TContext, TEvent>>;
|
|
473
|
+
services: Record<string, ServiceConfig<TContext, TEvent>>;
|
|
474
|
+
delays: DelayFunctionMap<TContext, TEvent>;
|
|
491
475
|
/**
|
|
492
476
|
* @private
|
|
493
477
|
*/
|
|
494
|
-
_parent?: StateNode<TContext, any, TEvent, any
|
|
478
|
+
_parent?: StateNode<TContext, any, TEvent, any>;
|
|
495
479
|
/**
|
|
496
480
|
* @private
|
|
497
481
|
*/
|
|
498
482
|
_key?: string;
|
|
499
483
|
}
|
|
500
|
-
export interface MachineConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TAction extends BaseActionObject =
|
|
484
|
+
export interface MachineConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TAction extends BaseActionObject = ActionObject<TContext, TEvent>> extends StateNodeConfig<TContext, TStateSchema, TEvent, TAction> {
|
|
501
485
|
/**
|
|
502
486
|
* The initial context (extended state)
|
|
503
487
|
*/
|
|
@@ -507,7 +491,6 @@ export interface MachineConfig<TContext, TStateSchema extends StateSchema, TEven
|
|
|
507
491
|
*/
|
|
508
492
|
version?: string;
|
|
509
493
|
schema?: MachineSchema<TContext, TEvent>;
|
|
510
|
-
tsTypes?: TTypesMeta | true;
|
|
511
494
|
}
|
|
512
495
|
export interface MachineSchema<TContext, TEvent extends EventObject> {
|
|
513
496
|
context?: TContext;
|
|
@@ -542,13 +525,13 @@ export interface HistoryStateNode<TContext> extends StateNode<TContext> {
|
|
|
542
525
|
export interface StateMachine<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TTypestate extends Typestate<TContext> = {
|
|
543
526
|
value: any;
|
|
544
527
|
context: TContext;
|
|
545
|
-
},
|
|
528
|
+
}, _TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> extends StateNode<TContext, TStateSchema, TEvent, TTypestate> {
|
|
546
529
|
id: string;
|
|
547
|
-
states: StateNode<TContext, TStateSchema, TEvent
|
|
548
|
-
withConfig(options:
|
|
549
|
-
withContext(context: TContext | (() => TContext)): StateMachine<TContext, TStateSchema, TEvent, TTypestate
|
|
530
|
+
states: StateNode<TContext, TStateSchema, TEvent>['states'];
|
|
531
|
+
withConfig(options: Partial<MachineOptions<TContext, TEvent>>, context?: TContext | (() => TContext)): StateMachine<TContext, TStateSchema, TEvent, TTypestate>;
|
|
532
|
+
withContext(context: TContext | (() => TContext)): StateMachine<TContext, TStateSchema, TEvent, TTypestate>;
|
|
550
533
|
}
|
|
551
|
-
export declare type StateFrom<T extends StateMachine<any, any, any, any
|
|
534
|
+
export declare type StateFrom<T extends StateMachine<any, any, any, any> | ((...args: any[]) => StateMachine<any, any, any, any>)> = T extends StateMachine<any, any, any> ? ReturnType<T['transition']> : T extends (...args: any[]) => StateMachine<any, any, any> ? ReturnType<ReturnType<T>['transition']> : never;
|
|
552
535
|
export interface ActionMap<TContext, TEvent extends EventObject> {
|
|
553
536
|
onEntry: Array<Action<TContext, TEvent>>;
|
|
554
537
|
actions: Array<Action<TContext, TEvent>>;
|
|
@@ -567,13 +550,13 @@ export interface ActivityMap {
|
|
|
567
550
|
}
|
|
568
551
|
export interface StateTransition<TContext, TEvent extends EventObject> {
|
|
569
552
|
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
570
|
-
configuration: Array<StateNode<TContext, any, TEvent, any
|
|
571
|
-
entrySet: Array<StateNode<TContext, any, TEvent, any
|
|
572
|
-
exitSet: Array<StateNode<TContext, any, TEvent, any
|
|
553
|
+
configuration: Array<StateNode<TContext, any, TEvent, any>>;
|
|
554
|
+
entrySet: Array<StateNode<TContext, any, TEvent, any>>;
|
|
555
|
+
exitSet: Array<StateNode<TContext, any, TEvent, any>>;
|
|
573
556
|
/**
|
|
574
557
|
* The source state that preceded the transition.
|
|
575
558
|
*/
|
|
576
|
-
source: State<TContext, any, any, any
|
|
559
|
+
source: State<TContext, any, any, any> | undefined;
|
|
577
560
|
actions: Array<ActionObject<TContext, TEvent>>;
|
|
578
561
|
}
|
|
579
562
|
export interface TransitionData<TContext, TEvent extends EventObject> {
|
|
@@ -716,7 +699,7 @@ export interface PureAction<TContext, TEvent extends EventObject> extends Action
|
|
|
716
699
|
}
|
|
717
700
|
export interface ChooseAction<TContext, TEvent extends EventObject> extends ActionObject<TContext, TEvent> {
|
|
718
701
|
type: ActionTypes.Choose;
|
|
719
|
-
conds: Array<
|
|
702
|
+
conds: Array<ChooseCondition<TContext, TEvent>>;
|
|
720
703
|
}
|
|
721
704
|
export interface TransitionDefinition<TContext, TEvent extends EventObject> extends TransitionConfig<TContext, TEvent> {
|
|
722
705
|
target: Array<StateNode<TContext, any, TEvent>> | undefined;
|
|
@@ -794,7 +777,7 @@ export interface SCXMLEventMeta<TEvent extends EventObject> {
|
|
|
794
777
|
_event: SCXML.Event<TEvent>;
|
|
795
778
|
}
|
|
796
779
|
export interface StateMeta<TContext, TEvent extends EventObject> {
|
|
797
|
-
state: State<TContext, TEvent, any, any
|
|
780
|
+
state: State<TContext, TEvent, any, any>;
|
|
798
781
|
_event: SCXML.Event<TEvent>;
|
|
799
782
|
}
|
|
800
783
|
export interface Typestate<TContext> {
|
|
@@ -813,7 +796,7 @@ export interface StateConfig<TContext, TEvent extends EventObject> {
|
|
|
813
796
|
_event: SCXML.Event<TEvent>;
|
|
814
797
|
_sessionid: string | null;
|
|
815
798
|
historyValue?: HistoryValue | undefined;
|
|
816
|
-
history?: State<TContext, TEvent
|
|
799
|
+
history?: State<TContext, TEvent>;
|
|
817
800
|
actions?: Array<ActionObject<TContext, TEvent>>;
|
|
818
801
|
/**
|
|
819
802
|
* @deprecated
|
|
@@ -826,7 +809,7 @@ export interface StateConfig<TContext, TEvent extends EventObject> {
|
|
|
826
809
|
children: Record<string, ActorRef<any>>;
|
|
827
810
|
done?: boolean;
|
|
828
811
|
tags?: Set<string>;
|
|
829
|
-
machine?: StateMachine<TContext, any, TEvent, any
|
|
812
|
+
machine?: StateMachine<TContext, any, TEvent, any>;
|
|
830
813
|
}
|
|
831
814
|
export interface StateSchema<TC = any> {
|
|
832
815
|
meta?: any;
|
|
@@ -839,9 +822,9 @@ export interface InterpreterOptions {
|
|
|
839
822
|
/**
|
|
840
823
|
* Whether state actions should be executed immediately upon transition. Defaults to `true`.
|
|
841
824
|
*/
|
|
842
|
-
execute
|
|
843
|
-
clock
|
|
844
|
-
logger
|
|
825
|
+
execute: boolean;
|
|
826
|
+
clock: Clock;
|
|
827
|
+
logger: (...args: any[]) => void;
|
|
845
828
|
parent?: AnyInterpreter;
|
|
846
829
|
/**
|
|
847
830
|
* If `true`, defers processing of sent events until the service
|
|
@@ -850,7 +833,7 @@ export interface InterpreterOptions {
|
|
|
850
833
|
*
|
|
851
834
|
* Default: `true`
|
|
852
835
|
*/
|
|
853
|
-
deferEvents
|
|
836
|
+
deferEvents: boolean;
|
|
854
837
|
/**
|
|
855
838
|
* The custom `id` for referencing this service.
|
|
856
839
|
*/
|
|
@@ -860,7 +843,8 @@ export interface InterpreterOptions {
|
|
|
860
843
|
*
|
|
861
844
|
* Default: `false`
|
|
862
845
|
*/
|
|
863
|
-
devTools
|
|
846
|
+
devTools: boolean | object;
|
|
847
|
+
[option: string]: any;
|
|
864
848
|
}
|
|
865
849
|
export declare namespace SCXML {
|
|
866
850
|
interface Event<TEvent extends EventObject> {
|
|
@@ -954,16 +938,15 @@ export interface ActorRef<TEvent extends EventObject, TEmitted = any> extends Su
|
|
|
954
938
|
* @deprecated Use `ActorRef` instead.
|
|
955
939
|
*/
|
|
956
940
|
export declare type SpawnedActorRef<TEvent extends EventObject, TEmitted = any> = ActorRef<TEvent, TEmitted>;
|
|
957
|
-
export declare type ActorRefWithDeprecatedState<TContext, TEvent extends EventObject, TTypestate extends Typestate<TContext
|
|
941
|
+
export declare type ActorRefWithDeprecatedState<TContext, TEvent extends EventObject, TTypestate extends Typestate<TContext>> = ActorRef<TEvent, State<TContext, TEvent, any, TTypestate>> & {
|
|
958
942
|
/**
|
|
959
943
|
* @deprecated Use `.getSnapshot()` instead.
|
|
960
944
|
*/
|
|
961
|
-
state: State<TContext, TEvent, any, TTypestate
|
|
945
|
+
state: State<TContext, TEvent, any, TTypestate>;
|
|
962
946
|
};
|
|
963
|
-
export declare type ActorRefFrom<T> = T extends StateMachine<infer TContext, any, infer TEvent, infer TTypestate> ? ActorRefWithDeprecatedState<TContext, TEvent, TTypestate> : T extends (...args: any[]) => StateMachine<infer TContext, any, infer TEvent, infer TTypestate
|
|
964
|
-
export declare type AnyInterpreter = Interpreter<any, any, any, any
|
|
965
|
-
export declare type InterpreterFrom<T extends StateMachine<any, any, any, any> | ((...args: any[]) => StateMachine<any, any, any, any>)> = T extends StateMachine<infer TContext, infer TStateSchema, infer TEvent, infer TTypestate
|
|
966
|
-
export declare type MachineOptionsFrom<T extends StateMachine<any, any, any, any> | ((...args: any[]) => StateMachine<any, any, any, any>), TRequireMissingImplementations extends boolean = false> = T extends StateMachine<infer TContext, any, infer TEvent, any, any, infer TResolvedTypesMeta> ? MaybeTypegenMachineOptions<TContext, TEvent, any, TResolvedTypesMeta, TRequireMissingImplementations> : T extends (...args: any[]) => StateMachine<infer TContext, any, infer TEvent, any, any, infer TResolvedTypesMeta> ? MaybeTypegenMachineOptions<TContext, TEvent, any, TResolvedTypesMeta, TRequireMissingImplementations> : never;
|
|
947
|
+
export declare type ActorRefFrom<T> = T extends StateMachine<infer TContext, any, infer TEvent, infer TTypestate> ? ActorRefWithDeprecatedState<TContext, TEvent, TTypestate> : T extends (...args: any[]) => StateMachine<infer TContext, any, infer TEvent, infer TTypestate> ? ActorRefWithDeprecatedState<TContext, TEvent, TTypestate> : T extends Promise<infer U> ? ActorRef<never, U> : T extends Behavior<infer TEvent1, infer TEmitted> ? ActorRef<TEvent1, TEmitted> : T extends (...args: any[]) => Behavior<infer TEvent1, infer TEmitted> ? ActorRef<TEvent1, TEmitted> : never;
|
|
948
|
+
export declare type AnyInterpreter = Interpreter<any, any, any, any>;
|
|
949
|
+
export declare type InterpreterFrom<T extends StateMachine<any, any, any, any> | ((...args: any[]) => StateMachine<any, any, any, any>)> = T extends StateMachine<infer TContext, infer TStateSchema, infer TEvent, infer TTypestate> ? Interpreter<TContext, TStateSchema, TEvent, TTypestate> : T extends (...args: any[]) => StateMachine<infer TContext, infer TStateSchema, infer TEvent, infer TTypestate> ? Interpreter<TContext, TStateSchema, TEvent, TTypestate> : never;
|
|
967
950
|
export interface ActorContext<TEvent extends EventObject, TEmitted> {
|
|
968
951
|
parent?: ActorRef<any, any>;
|
|
969
952
|
self: ActorRef<TEvent, TEmitted>;
|
|
@@ -976,7 +959,10 @@ export interface Behavior<TEvent extends EventObject, TEmitted = any> {
|
|
|
976
959
|
start?: (actorCtx: ActorContext<TEvent, TEmitted>) => TEmitted;
|
|
977
960
|
}
|
|
978
961
|
export declare type EmittedFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends ActorRef<infer _, infer TEmitted> ? TEmitted : R extends Behavior<infer _, infer TEmitted> ? TEmitted : R extends ActorContext<infer _, infer TEmitted> ? TEmitted : never : never;
|
|
979
|
-
|
|
962
|
+
declare type ResolveEventType<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer _, infer __, infer TEvent, infer ____> ? TEvent : R extends Model<infer _, infer TEvent, infer ___, infer ____> ? TEvent : R extends State<infer _, infer TEvent, infer ___, infer ____> ? TEvent : R extends Interpreter<infer _, infer __, infer TEvent, infer ____> ? TEvent : R extends ActorRef<infer TEvent, infer _> ? TEvent : never : never;
|
|
963
|
+
export declare type EventFrom<T, K extends Prop<TEvent, 'type'> = never, TEvent = ResolveEventType<T>> = IsNever<K> extends true ? TEvent : Extract<TEvent, {
|
|
964
|
+
type: K;
|
|
965
|
+
}>;
|
|
980
966
|
export declare type ContextFrom<T> = ReturnTypeOrValue<T> extends infer R ? R extends StateMachine<infer TContext, infer _, infer __, infer ___> ? TContext : R extends Model<infer TContext, infer _, infer __, infer ___> ? TContext : R extends State<infer TContext, infer _, infer __, infer ___> ? TContext : R extends Interpreter<infer TContext, infer _, infer __, infer ___> ? TContext : never : never;
|
|
981
967
|
export {};
|
|
982
968
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/utils.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare function toTransitionConfigArray<TContext, TEvent extends EventOb
|
|
|
63
63
|
}>;
|
|
64
64
|
export declare function normalizeTarget<TContext, TEvent extends EventObject>(target: SingleOrArray<string | StateNode<TContext, any, TEvent>> | undefined): Array<string | StateNode<TContext, any, TEvent>> | undefined;
|
|
65
65
|
export declare function reportUnhandledExceptionOnInvocation(originalError: any, currentError: any, id: string): void;
|
|
66
|
-
export declare function evaluateGuard<TContext, TEvent extends EventObject>(machine: StateNode<TContext, any, TEvent, any
|
|
66
|
+
export declare function evaluateGuard<TContext, TEvent extends EventObject>(machine: StateNode<TContext, any, TEvent, any>, guard: Guard<TContext, TEvent>, context: TContext, _event: SCXML.Event<TEvent>, state: State<TContext, TEvent>): boolean;
|
|
67
67
|
export declare function toInvokeSource(src: string | InvokeSourceDefinition): InvokeSourceDefinition;
|
|
68
68
|
export declare function toObserver<T>(nextHandler: Observer<T> | ((value: T) => void), errorHandler?: (error: any) => void, completionHandler?: () => void): Observer<T>;
|
|
69
69
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib/utils.js
CHANGED
|
@@ -40,7 +40,7 @@ function matchesState(parentStateId, childStateId, delimiter) {
|
|
|
40
40
|
}
|
|
41
41
|
function getEventType(event) {
|
|
42
42
|
try {
|
|
43
|
-
return isString(event) || typeof event === 'number' ? ""
|
|
43
|
+
return isString(event) || typeof event === 'number' ? "".concat(event) : event.type;
|
|
44
44
|
} catch (e) {
|
|
45
45
|
throw new Error('Events must be strings or objects with a string event.type property.');
|
|
46
46
|
}
|
|
@@ -53,7 +53,7 @@ function toStatePath(stateId, delimiter) {
|
|
|
53
53
|
|
|
54
54
|
return stateId.toString().split(delimiter);
|
|
55
55
|
} catch (e) {
|
|
56
|
-
throw new Error("'"
|
|
56
|
+
throw new Error("'".concat(stateId, "' is not a valid state path."));
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
function isStateLike(state) {
|
|
@@ -222,7 +222,7 @@ function toStatePaths(stateValue) {
|
|
|
222
222
|
function flatten(array) {
|
|
223
223
|
var _a;
|
|
224
224
|
|
|
225
|
-
return (_a = []).concat.apply(_a, _tslib.__spreadArray([], _tslib.__read(array)));
|
|
225
|
+
return (_a = []).concat.apply(_a, _tslib.__spreadArray([], _tslib.__read(array), false));
|
|
226
226
|
}
|
|
227
227
|
function toArrayStrict(value) {
|
|
228
228
|
if (isArray(value)) {
|
|
@@ -399,7 +399,7 @@ if (!environment.IS_PRODUCTION) {
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
if (console !== undefined) {
|
|
402
|
-
var args = ["Warning: "
|
|
402
|
+
var args = ["Warning: ".concat(message)];
|
|
403
403
|
|
|
404
404
|
if (error) {
|
|
405
405
|
args.push(error);
|
|
@@ -528,15 +528,15 @@ function normalizeTarget(target) {
|
|
|
528
528
|
}
|
|
529
529
|
function reportUnhandledExceptionOnInvocation(originalError, currentError, id) {
|
|
530
530
|
if (!environment.IS_PRODUCTION) {
|
|
531
|
-
var originalStackTrace = originalError.stack ? " Stacktrace was '"
|
|
531
|
+
var originalStackTrace = originalError.stack ? " Stacktrace was '".concat(originalError.stack, "'") : '';
|
|
532
532
|
|
|
533
533
|
if (originalError === currentError) {
|
|
534
534
|
// tslint:disable-next-line:no-console
|
|
535
|
-
console.error("Missing onError handler for invocation '"
|
|
535
|
+
console.error("Missing onError handler for invocation '".concat(id, "', error was '").concat(originalError, "'.").concat(originalStackTrace));
|
|
536
536
|
} else {
|
|
537
|
-
var stackTrace = currentError.stack ? " Stacktrace was '"
|
|
537
|
+
var stackTrace = currentError.stack ? " Stacktrace was '".concat(currentError.stack, "'") : ''; // tslint:disable-next-line:no-console
|
|
538
538
|
|
|
539
|
-
console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '"
|
|
539
|
+
console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(id, "'. ") + "Original error: '".concat(originalError, "'. ").concat(originalStackTrace, " Current error is '").concat(currentError, "'.").concat(stackTrace));
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
}
|
|
@@ -552,10 +552,10 @@ function evaluateGuard(machine, guard, context, _event, state) {
|
|
|
552
552
|
return ((guards === null || guards === void 0 ? void 0 : guards[guard.name]) || guard.predicate)(context, _event.data, guardMeta);
|
|
553
553
|
}
|
|
554
554
|
|
|
555
|
-
var condFn = guards
|
|
555
|
+
var condFn = guards[guard.type];
|
|
556
556
|
|
|
557
557
|
if (!condFn) {
|
|
558
|
-
throw new Error("Guard '"
|
|
558
|
+
throw new Error("Guard '".concat(guard.type, "' is not implemented on machine '").concat(machine.id, "'."));
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
return condFn(context, _event.data, guardMeta);
|