xstate 4.27.0-pr2674-2021926101023 → 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 +24 -12
- 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 +16 -20
- package/es/StateNode.js +51 -57
- package/es/_virtual/_tslib.js +8 -4
- package/es/actions.d.ts +20 -3
- 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 +21 -16
- 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 +5 -6
- package/es/stateUtils.js +1 -1
- package/es/types.d.ts +52 -104
- 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 +16 -20
- package/lib/StateNode.js +49 -55
- package/lib/_virtual/_tslib.js +8 -4
- package/lib/actions.d.ts +20 -3
- 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 +21 -16
- 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 +5 -6
- package/lib/stateUtils.js +1 -1
- package/lib/types.d.ts +52 -104
- 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 -92
- package/lib/typegenTypes.d.ts +0 -92
- 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,15 @@
|
|
|
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>;
|
|
15
14
|
export declare function getTagsFromConfiguration(configuration: StateNode<any, any, any, any>[]): Set<string>;
|
|
16
15
|
export {};
|
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') {
|
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,9 +54,7 @@ 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
|
-
bivarianceHack(context: TContext, event: TEvent, meta: ActionMeta<TContext, TEvent, TAction>): void;
|
|
74
|
-
}['bivarianceHack'];
|
|
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;
|
|
75
58
|
export interface ChooseCondition<TContext, TEvent extends EventObject> {
|
|
76
59
|
cond?: Condition<TContext, TEvent>;
|
|
77
60
|
actions: Actions<TContext, TEvent>;
|
|
@@ -99,14 +82,6 @@ export interface StateValueMap {
|
|
|
99
82
|
* - For complex state nodes, this is an object, e.g., `{ success: "someChildState" }`.
|
|
100
83
|
*/
|
|
101
84
|
export declare type StateValue = string | StateValueMap;
|
|
102
|
-
declare type KeysWithStates<TStates extends Record<string, StateSchema> | undefined> = TStates extends object ? {
|
|
103
|
-
[K in keyof TStates]-?: TStates[K] extends {
|
|
104
|
-
states: object;
|
|
105
|
-
} ? K : never;
|
|
106
|
-
}[keyof TStates] : never;
|
|
107
|
-
export declare type ExtractStateValue<TSchema extends Required<Pick<StateSchema<any>, 'states'>>> = keyof TSchema['states'] | (KeysWithStates<TSchema['states']> extends never ? never : {
|
|
108
|
-
[K in KeysWithStates<TSchema['states']>]?: ExtractStateValue<TSchema['states'][K]>;
|
|
109
|
-
});
|
|
110
85
|
export interface HistoryValue {
|
|
111
86
|
states: Record<string, HistoryValue | undefined>;
|
|
112
87
|
current: StateValue | undefined;
|
|
@@ -132,7 +107,7 @@ export interface TransitionConfig<TContext, TEvent extends EventObject> {
|
|
|
132
107
|
actions?: Actions<TContext, TEvent>;
|
|
133
108
|
in?: StateValue;
|
|
134
109
|
internal?: boolean;
|
|
135
|
-
target?: TransitionTarget<TContext, TEvent
|
|
110
|
+
target?: TransitionTarget<TContext, TEvent> | undefined;
|
|
136
111
|
meta?: Record<string, any>;
|
|
137
112
|
description?: string;
|
|
138
113
|
}
|
|
@@ -371,7 +346,7 @@ export interface StateNodeConfig<TContext, TStateSchema extends StateSchema, TEv
|
|
|
371
346
|
*
|
|
372
347
|
* This is equivalent to defining a `[done(id)]` transition on this state node's `on` property.
|
|
373
348
|
*/
|
|
374
|
-
onDone?: string | SingleOrArray<TransitionConfig<TContext, DoneEventObject
|
|
349
|
+
onDone?: string | SingleOrArray<TransitionConfig<TContext, DoneEventObject>> | undefined;
|
|
375
350
|
/**
|
|
376
351
|
* The mapping (or array) of delays (in milliseconds) to their potential transition(s).
|
|
377
352
|
* The delayed transitions are taken after the specified delay in an interpreter.
|
|
@@ -480,7 +455,7 @@ export interface FinalStateNodeConfig<TContext, TEvent extends EventObject> exte
|
|
|
480
455
|
data?: Mapper<TContext, TEvent, any> | PropertyMapper<TContext, TEvent, any>;
|
|
481
456
|
}
|
|
482
457
|
export declare type SimpleOrStateNodeConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject> = AtomicStateNodeConfig<TContext, TEvent> | StateNodeConfig<TContext, TStateSchema, TEvent>;
|
|
483
|
-
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>> = {
|
|
484
459
|
[K in TAction['type']]?: ActionObject<TContext, TEvent> | ActionFunction<TContext, TEvent, TAction extends {
|
|
485
460
|
type: K;
|
|
486
461
|
} ? TAction : never>;
|
|
@@ -488,44 +463,25 @@ export declare type ActionFunctionMap<TContext, TEvent extends EventObject, TAct
|
|
|
488
463
|
export declare type DelayFunctionMap<TContext, TEvent extends EventObject> = Record<string, DelayConfig<TContext, TEvent>>;
|
|
489
464
|
export declare type ServiceConfig<TContext, TEvent extends EventObject = AnyEventObject> = string | StateMachine<any, any, any> | InvokeCreator<TContext, TEvent>;
|
|
490
465
|
export declare type DelayConfig<TContext, TEvent extends EventObject> = number | DelayExpr<TContext, TEvent>;
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
declare type MachineOptionsDelays<TContext, TResolvedTypesMeta, TEventsCausingDelays = Prop<TResolvedTypesMeta, 'eventsCausingDelays'>, TIndexedEvents = Prop<TResolvedTypesMeta, 'indexedEvents'>> = {
|
|
495
|
-
[K in keyof TEventsCausingDelays]?: DelayConfig<TContext, Cast<Prop<TIndexedEvents, TEventsCausingDelays[K]>, EventObject>>;
|
|
496
|
-
};
|
|
497
|
-
declare type MachineOptionsGuards<TContext, TResolvedTypesMeta, TEventsCausingGuards = Prop<TResolvedTypesMeta, 'eventsCausingGuards'>, TIndexedEvents = Prop<TResolvedTypesMeta, 'indexedEvents'>> = {
|
|
498
|
-
[K in keyof TEventsCausingGuards]?: ConditionPredicate<TContext, Cast<Prop<TIndexedEvents, TEventsCausingGuards[K]>, EventObject>>;
|
|
499
|
-
};
|
|
500
|
-
declare type MachineOptionsServices<TContext, TResolvedTypesMeta, TEventsCausingServices = Prop<TResolvedTypesMeta, 'eventsCausingServices'>, TIndexedEvents = Prop<TResolvedTypesMeta, 'indexedEvents'>, TInvokeSrcNameMap = Prop<TResolvedTypesMeta, 'invokeSrcNameMap'>> = {
|
|
501
|
-
[K in keyof TEventsCausingServices]?: StateMachine<any, any, any> | InvokeCreator<TContext, Cast<Prop<TIndexedEvents, TEventsCausingServices[K]>, EventObject>, Prop<Prop<TIndexedEvents, Prop<TInvokeSrcNameMap, K>>, 'data'>>;
|
|
502
|
-
};
|
|
503
|
-
declare type MakeKeysRequired<T extends string> = {
|
|
504
|
-
[K in T]: unknown;
|
|
505
|
-
};
|
|
506
|
-
declare type MaybeMakeMissingImplementationsRequired<TImplementationType, TMissingImplementationsForType, TRequireMissingImplementations> = TRequireMissingImplementations extends true ? IsNever<TMissingImplementationsForType> extends true ? {} : {
|
|
507
|
-
[K in Cast<TImplementationType, string>]: MakeKeysRequired<Cast<TMissingImplementationsForType, string>>;
|
|
508
|
-
} : {};
|
|
509
|
-
declare type GenerateActionsConfigPart<TContext, TResolvedTypesMeta, TRequireMissingImplementations, TMissingImplementations> = MaybeMakeMissingImplementationsRequired<'actions', Prop<TMissingImplementations, 'actions'>, TRequireMissingImplementations> & {
|
|
510
|
-
actions?: MachineOptionsActions<TContext, TResolvedTypesMeta>;
|
|
511
|
-
};
|
|
512
|
-
declare type GenerateDelaysConfigPart<TContext, TResolvedTypesMeta, TRequireMissingImplementations, TMissingImplementations> = MaybeMakeMissingImplementationsRequired<'delays', Prop<TMissingImplementations, 'delays'>, TRequireMissingImplementations> & {
|
|
513
|
-
delays?: MachineOptionsDelays<TContext, TResolvedTypesMeta>;
|
|
514
|
-
};
|
|
515
|
-
declare type GenerateGuardsConfigPart<TContext, TResolvedTypesMeta, TRequireMissingImplementations, TMissingImplementations> = MaybeMakeMissingImplementationsRequired<'guards', Prop<TMissingImplementations, 'guards'>, TRequireMissingImplementations> & {
|
|
516
|
-
guards?: MachineOptionsGuards<TContext, TResolvedTypesMeta>;
|
|
517
|
-
};
|
|
518
|
-
declare type GenerateServicesConfigPart<TContext, TResolvedTypesMeta, TRequireMissingImplementations, TMissingImplementations> = MaybeMakeMissingImplementationsRequired<'services', Prop<TMissingImplementations, 'services'>, TRequireMissingImplementations> & {
|
|
519
|
-
services?: MachineOptionsServices<TContext, TResolvedTypesMeta>;
|
|
520
|
-
};
|
|
521
|
-
export declare type InternalMachineOptions<TContext, TEvent extends EventObject, TResolvedTypesMeta, TRequireMissingImplementations extends boolean = false, TMissingImplementations = Prop<TResolvedTypesMeta, 'missingImplementations'>> = GenerateActionsConfigPart<TContext, TResolvedTypesMeta, TRequireMissingImplementations, TMissingImplementations> & GenerateDelaysConfigPart<TContext, TResolvedTypesMeta, TRequireMissingImplementations, TMissingImplementations> & GenerateGuardsConfigPart<TContext, TResolvedTypesMeta, TRequireMissingImplementations, TMissingImplementations> & GenerateServicesConfigPart<TContext, TResolvedTypesMeta, TRequireMissingImplementations, TMissingImplementations> & {
|
|
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>;
|
|
522
469
|
/**
|
|
523
470
|
* @deprecated Use `services` instead.
|
|
524
471
|
*/
|
|
525
|
-
activities
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
472
|
+
activities: Record<string, ActivityConfig<TContext, TEvent>>;
|
|
473
|
+
services: Record<string, ServiceConfig<TContext, TEvent>>;
|
|
474
|
+
delays: DelayFunctionMap<TContext, TEvent>;
|
|
475
|
+
/**
|
|
476
|
+
* @private
|
|
477
|
+
*/
|
|
478
|
+
_parent?: StateNode<TContext, any, TEvent, any>;
|
|
479
|
+
/**
|
|
480
|
+
* @private
|
|
481
|
+
*/
|
|
482
|
+
_key?: string;
|
|
483
|
+
}
|
|
484
|
+
export interface MachineConfig<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TAction extends BaseActionObject = ActionObject<TContext, TEvent>> extends StateNodeConfig<TContext, TStateSchema, TEvent, TAction> {
|
|
529
485
|
/**
|
|
530
486
|
* The initial context (extended state)
|
|
531
487
|
*/
|
|
@@ -535,7 +491,6 @@ export interface MachineConfig<TContext, TStateSchema extends StateSchema, TEven
|
|
|
535
491
|
*/
|
|
536
492
|
version?: string;
|
|
537
493
|
schema?: MachineSchema<TContext, TEvent>;
|
|
538
|
-
tsTypes?: TTypesMeta | true;
|
|
539
494
|
}
|
|
540
495
|
export interface MachineSchema<TContext, TEvent extends EventObject> {
|
|
541
496
|
context?: TContext;
|
|
@@ -570,19 +525,13 @@ export interface HistoryStateNode<TContext> extends StateNode<TContext> {
|
|
|
570
525
|
export interface StateMachine<TContext, TStateSchema extends StateSchema, TEvent extends EventObject, TTypestate extends Typestate<TContext> = {
|
|
571
526
|
value: any;
|
|
572
527
|
context: TContext;
|
|
573
|
-
},
|
|
528
|
+
}, _TAction extends ActionObject<TContext, TEvent> = ActionObject<TContext, TEvent>> extends StateNode<TContext, TStateSchema, TEvent, TTypestate> {
|
|
574
529
|
id: string;
|
|
575
|
-
states: StateNode<TContext, TStateSchema, TEvent
|
|
576
|
-
withConfig(options:
|
|
577
|
-
withContext(context: TContext | (() => TContext)): StateMachine<TContext, TStateSchema, TEvent, TTypestate
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
__TEvent: TEvent;
|
|
581
|
-
__TTypestate: TTypestate;
|
|
582
|
-
__TAction: TAction;
|
|
583
|
-
__TResolvedTypesMeta: TResolvedTypesMeta;
|
|
584
|
-
}
|
|
585
|
-
export declare type StateFrom<T extends StateMachine<any, any, any, any, any, any> | ((...args: any[]) => StateMachine<any, any, any, any, any, any>)> = T extends StateMachine<any, any, any, any, any, any> ? ReturnType<T['transition']> : T extends (...args: any[]) => StateMachine<any, any, any, any, any, any> ? ReturnType<ReturnType<T>['transition']> : never;
|
|
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>;
|
|
533
|
+
}
|
|
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;
|
|
586
535
|
export interface ActionMap<TContext, TEvent extends EventObject> {
|
|
587
536
|
onEntry: Array<Action<TContext, TEvent>>;
|
|
588
537
|
actions: Array<Action<TContext, TEvent>>;
|
|
@@ -601,13 +550,13 @@ export interface ActivityMap {
|
|
|
601
550
|
}
|
|
602
551
|
export interface StateTransition<TContext, TEvent extends EventObject> {
|
|
603
552
|
transitions: Array<TransitionDefinition<TContext, TEvent>>;
|
|
604
|
-
configuration: Array<StateNode<TContext, any, TEvent, any
|
|
605
|
-
entrySet: Array<StateNode<TContext, any, TEvent, any
|
|
606
|
-
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>>;
|
|
607
556
|
/**
|
|
608
557
|
* The source state that preceded the transition.
|
|
609
558
|
*/
|
|
610
|
-
source: State<TContext, any, any, any
|
|
559
|
+
source: State<TContext, any, any, any> | undefined;
|
|
611
560
|
actions: Array<ActionObject<TContext, TEvent>>;
|
|
612
561
|
}
|
|
613
562
|
export interface TransitionData<TContext, TEvent extends EventObject> {
|
|
@@ -828,7 +777,7 @@ export interface SCXMLEventMeta<TEvent extends EventObject> {
|
|
|
828
777
|
_event: SCXML.Event<TEvent>;
|
|
829
778
|
}
|
|
830
779
|
export interface StateMeta<TContext, TEvent extends EventObject> {
|
|
831
|
-
state: State<TContext, TEvent, any, any
|
|
780
|
+
state: State<TContext, TEvent, any, any>;
|
|
832
781
|
_event: SCXML.Event<TEvent>;
|
|
833
782
|
}
|
|
834
783
|
export interface Typestate<TContext> {
|
|
@@ -847,7 +796,7 @@ export interface StateConfig<TContext, TEvent extends EventObject> {
|
|
|
847
796
|
_event: SCXML.Event<TEvent>;
|
|
848
797
|
_sessionid: string | null;
|
|
849
798
|
historyValue?: HistoryValue | undefined;
|
|
850
|
-
history?: State<TContext, TEvent
|
|
799
|
+
history?: State<TContext, TEvent>;
|
|
851
800
|
actions?: Array<ActionObject<TContext, TEvent>>;
|
|
852
801
|
/**
|
|
853
802
|
* @deprecated
|
|
@@ -860,7 +809,7 @@ export interface StateConfig<TContext, TEvent extends EventObject> {
|
|
|
860
809
|
children: Record<string, ActorRef<any>>;
|
|
861
810
|
done?: boolean;
|
|
862
811
|
tags?: Set<string>;
|
|
863
|
-
machine?: StateMachine<TContext, any, TEvent, any
|
|
812
|
+
machine?: StateMachine<TContext, any, TEvent, any>;
|
|
864
813
|
}
|
|
865
814
|
export interface StateSchema<TC = any> {
|
|
866
815
|
meta?: any;
|
|
@@ -873,9 +822,9 @@ export interface InterpreterOptions {
|
|
|
873
822
|
/**
|
|
874
823
|
* Whether state actions should be executed immediately upon transition. Defaults to `true`.
|
|
875
824
|
*/
|
|
876
|
-
execute
|
|
877
|
-
clock
|
|
878
|
-
logger
|
|
825
|
+
execute: boolean;
|
|
826
|
+
clock: Clock;
|
|
827
|
+
logger: (...args: any[]) => void;
|
|
879
828
|
parent?: AnyInterpreter;
|
|
880
829
|
/**
|
|
881
830
|
* If `true`, defers processing of sent events until the service
|
|
@@ -884,7 +833,7 @@ export interface InterpreterOptions {
|
|
|
884
833
|
*
|
|
885
834
|
* Default: `true`
|
|
886
835
|
*/
|
|
887
|
-
deferEvents
|
|
836
|
+
deferEvents: boolean;
|
|
888
837
|
/**
|
|
889
838
|
* The custom `id` for referencing this service.
|
|
890
839
|
*/
|
|
@@ -894,7 +843,8 @@ export interface InterpreterOptions {
|
|
|
894
843
|
*
|
|
895
844
|
* Default: `false`
|
|
896
845
|
*/
|
|
897
|
-
devTools
|
|
846
|
+
devTools: boolean | object;
|
|
847
|
+
[option: string]: any;
|
|
898
848
|
}
|
|
899
849
|
export declare namespace SCXML {
|
|
900
850
|
interface Event<TEvent extends EventObject> {
|
|
@@ -988,17 +938,15 @@ export interface ActorRef<TEvent extends EventObject, TEmitted = any> extends Su
|
|
|
988
938
|
* @deprecated Use `ActorRef` instead.
|
|
989
939
|
*/
|
|
990
940
|
export declare type SpawnedActorRef<TEvent extends EventObject, TEmitted = any> = ActorRef<TEvent, TEmitted>;
|
|
991
|
-
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>> & {
|
|
992
942
|
/**
|
|
993
943
|
* @deprecated Use `.getSnapshot()` instead.
|
|
994
944
|
*/
|
|
995
|
-
state: State<TContext, TEvent, any, TTypestate
|
|
945
|
+
state: State<TContext, TEvent, any, TTypestate>;
|
|
996
946
|
};
|
|
997
|
-
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
|
|
998
|
-
export declare type AnyInterpreter = Interpreter<any, any, any, any
|
|
999
|
-
export declare type InterpreterFrom<T extends StateMachine<any, any, any, any
|
|
1000
|
-
export declare type MachineOptionsFrom<T extends StateMachine<any, any, any, any> | ((...args: any[]) => StateMachine<any, any, any, any>), TRequireMissingImplementations extends boolean = false> = ReturnTypeOrValue<T> extends StateMachine<infer TContext, any, infer TEvent, any, any, infer TResolvedTypesMeta> ? InternalMachineOptions<TContext, TEvent, TResolvedTypesMeta, TRequireMissingImplementations> : never;
|
|
1001
|
-
export declare type __ResolvedTypesMetaFrom<T> = T extends StateMachine<any, any, any, any, any, infer TResolvedTypesMeta> ? TResolvedTypesMeta : 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;
|
|
1002
950
|
export interface ActorContext<TEvent extends EventObject, TEmitted> {
|
|
1003
951
|
parent?: ActorRef<any, any>;
|
|
1004
952
|
self: ActorRef<TEvent, TEmitted>;
|
|
@@ -1011,7 +959,7 @@ export interface Behavior<TEvent extends EventObject, TEmitted = any> {
|
|
|
1011
959
|
start?: (actorCtx: ActorContext<TEvent, TEmitted>) => TEmitted;
|
|
1012
960
|
}
|
|
1013
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;
|
|
1014
|
-
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 : never : never;
|
|
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;
|
|
1015
963
|
export declare type EventFrom<T, K extends Prop<TEvent, 'type'> = never, TEvent = ResolveEventType<T>> = IsNever<K> extends true ? TEvent : Extract<TEvent, {
|
|
1016
964
|
type: K;
|
|
1017
965
|
}>;
|
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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xstate",
|
|
3
|
-
"version": "4.27.0
|
|
3
|
+
"version": "4.27.0",
|
|
4
4
|
"description": "Finite State Machines and Statecharts for the Modern Web.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -30,11 +30,7 @@
|
|
|
30
30
|
"clean": "rm -rf lib es dist tsconfig.tsbuildinfo",
|
|
31
31
|
"test": "jest",
|
|
32
32
|
"build": "rollup -c",
|
|
33
|
-
"
|
|
34
|
-
"version": "npm run build",
|
|
35
|
-
"postversion": "git push --follow-tags",
|
|
36
|
-
"prepublishOnly": "npm run build",
|
|
37
|
-
"publish:next": "npm version prerelease && npm publish --tag next"
|
|
33
|
+
"prepublishOnly": "npm run build"
|
|
38
34
|
},
|
|
39
35
|
"repository": {
|
|
40
36
|
"type": "git",
|
|
@@ -65,8 +61,8 @@
|
|
|
65
61
|
"rollup-plugin-uglify": "^6.0.2",
|
|
66
62
|
"rxjs": "^7.1.0",
|
|
67
63
|
"ts-jest": "^26.5.6",
|
|
68
|
-
"tslib": "^2.
|
|
69
|
-
"typescript": "^4.
|
|
64
|
+
"tslib": "^2.3.1",
|
|
65
|
+
"typescript": "^4.5.2",
|
|
70
66
|
"xml-js": "^1.6.11"
|
|
71
67
|
}
|
|
72
68
|
}
|