xstate 4.26.0 → 4.28.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 +78 -1
- package/dist/xstate.interpreter.js +1 -1
- package/dist/xstate.js +1 -1
- package/dist/xstate.web.js +2 -2
- package/es/Actor.js +5 -5
- package/es/State.d.ts +5 -2
- package/es/State.js +10 -3
- package/es/StateNode.d.ts +2 -1
- package/es/StateNode.js +54 -59
- package/es/_virtual/_tslib.js +8 -4
- package/es/actions.d.ts +18 -2
- package/es/actions.js +22 -8
- package/es/devTools.d.ts +1 -2
- package/es/devTools.js +4 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/interpreter.d.ts +0 -5
- package/es/interpreter.js +35 -25
- package/es/registry.js +1 -1
- package/es/stateUtils.d.ts +1 -1
- package/es/stateUtils.js +1 -1
- package/es/types.d.ts +10 -14
- package/es/utils.d.ts +7 -1
- package/es/utils.js +17 -10
- package/lib/Actor.js +4 -4
- package/lib/SimulatedClock.js +9 -5
- package/lib/State.d.ts +5 -2
- package/lib/State.js +10 -3
- package/lib/StateNode.d.ts +2 -1
- package/lib/StateNode.js +52 -57
- package/lib/_virtual/_tslib.js +8 -4
- package/lib/actions.d.ts +18 -2
- package/lib/actions.js +22 -7
- package/lib/devTools.d.ts +1 -2
- package/lib/devTools.js +4 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/interpreter.d.ts +0 -5
- package/lib/interpreter.js +34 -24
- package/lib/json.js +7 -7
- package/lib/model.js +14 -10
- package/lib/patterns.js +2 -2
- package/lib/registry.js +1 -1
- package/lib/scxml.js +29 -25
- package/lib/stateUtils.d.ts +1 -1
- package/lib/stateUtils.js +1 -1
- package/lib/types.d.ts +10 -14
- package/lib/utils.d.ts +7 -1
- package/lib/utils.js +18 -9
- package/package.json +3 -3
package/lib/utils.js
CHANGED
|
@@ -6,6 +6,7 @@ var _tslib = require('./_virtual/_tslib.js');
|
|
|
6
6
|
var constants = require('./constants.js');
|
|
7
7
|
var environment = require('./environment.js');
|
|
8
8
|
|
|
9
|
+
var _a;
|
|
9
10
|
function keys(value) {
|
|
10
11
|
return Object.keys(value);
|
|
11
12
|
}
|
|
@@ -40,7 +41,7 @@ function matchesState(parentStateId, childStateId, delimiter) {
|
|
|
40
41
|
}
|
|
41
42
|
function getEventType(event) {
|
|
42
43
|
try {
|
|
43
|
-
return isString(event) || typeof event === 'number' ? ""
|
|
44
|
+
return isString(event) || typeof event === 'number' ? "".concat(event) : event.type;
|
|
44
45
|
} catch (e) {
|
|
45
46
|
throw new Error('Events must be strings or objects with a string event.type property.');
|
|
46
47
|
}
|
|
@@ -53,7 +54,7 @@ function toStatePath(stateId, delimiter) {
|
|
|
53
54
|
|
|
54
55
|
return stateId.toString().split(delimiter);
|
|
55
56
|
} catch (e) {
|
|
56
|
-
throw new Error("'"
|
|
57
|
+
throw new Error("'".concat(stateId, "' is not a valid state path."));
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
function isStateLike(state) {
|
|
@@ -222,7 +223,7 @@ function toStatePaths(stateValue) {
|
|
|
222
223
|
function flatten(array) {
|
|
223
224
|
var _a;
|
|
224
225
|
|
|
225
|
-
return (_a = []).concat.apply(_a, _tslib.__spreadArray([], _tslib.__read(array)));
|
|
226
|
+
return (_a = []).concat.apply(_a, _tslib.__spreadArray([], _tslib.__read(array), false));
|
|
226
227
|
}
|
|
227
228
|
function toArrayStrict(value) {
|
|
228
229
|
if (isArray(value)) {
|
|
@@ -399,7 +400,7 @@ if (!environment.IS_PRODUCTION) {
|
|
|
399
400
|
}
|
|
400
401
|
|
|
401
402
|
if (console !== undefined) {
|
|
402
|
-
var args = ["Warning: "
|
|
403
|
+
var args = ["Warning: ".concat(message)];
|
|
403
404
|
|
|
404
405
|
if (error) {
|
|
405
406
|
args.push(error);
|
|
@@ -464,6 +465,9 @@ function isObservable(value) {
|
|
|
464
465
|
var symbolObservable = /*#__PURE__*/function () {
|
|
465
466
|
return typeof Symbol === 'function' && Symbol.observable || '@@observable';
|
|
466
467
|
}();
|
|
468
|
+
var interopSymbols = (_a = {}, _a[symbolObservable] = function () {
|
|
469
|
+
return this;
|
|
470
|
+
}, _a);
|
|
467
471
|
function isMachine(value) {
|
|
468
472
|
try {
|
|
469
473
|
return '__xstatenode' in value;
|
|
@@ -528,15 +532,15 @@ function normalizeTarget(target) {
|
|
|
528
532
|
}
|
|
529
533
|
function reportUnhandledExceptionOnInvocation(originalError, currentError, id) {
|
|
530
534
|
if (!environment.IS_PRODUCTION) {
|
|
531
|
-
var originalStackTrace = originalError.stack ? " Stacktrace was '"
|
|
535
|
+
var originalStackTrace = originalError.stack ? " Stacktrace was '".concat(originalError.stack, "'") : '';
|
|
532
536
|
|
|
533
537
|
if (originalError === currentError) {
|
|
534
538
|
// tslint:disable-next-line:no-console
|
|
535
|
-
console.error("Missing onError handler for invocation '"
|
|
539
|
+
console.error("Missing onError handler for invocation '".concat(id, "', error was '").concat(originalError, "'.").concat(originalStackTrace));
|
|
536
540
|
} else {
|
|
537
|
-
var stackTrace = currentError.stack ? " Stacktrace was '"
|
|
541
|
+
var stackTrace = currentError.stack ? " Stacktrace was '".concat(currentError.stack, "'") : ''; // tslint:disable-next-line:no-console
|
|
538
542
|
|
|
539
|
-
console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '"
|
|
543
|
+
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
544
|
}
|
|
541
545
|
}
|
|
542
546
|
}
|
|
@@ -555,7 +559,7 @@ function evaluateGuard(machine, guard, context, _event, state) {
|
|
|
555
559
|
var condFn = guards[guard.type];
|
|
556
560
|
|
|
557
561
|
if (!condFn) {
|
|
558
|
-
throw new Error("Guard '"
|
|
562
|
+
throw new Error("Guard '".concat(guard.type, "' is not implemented on machine '").concat(machine.id, "'."));
|
|
559
563
|
}
|
|
560
564
|
|
|
561
565
|
return condFn(context, _event.data, guardMeta);
|
|
@@ -584,10 +588,15 @@ function toObserver(nextHandler, errorHandler, completionHandler) {
|
|
|
584
588
|
complete: completionHandler || noop
|
|
585
589
|
};
|
|
586
590
|
}
|
|
591
|
+
function createInvokeId(stateNodeId, index) {
|
|
592
|
+
return "".concat(stateNodeId, ":invocation[").concat(index, "]");
|
|
593
|
+
}
|
|
587
594
|
|
|
595
|
+
exports.createInvokeId = createInvokeId;
|
|
588
596
|
exports.evaluateGuard = evaluateGuard;
|
|
589
597
|
exports.flatten = flatten;
|
|
590
598
|
exports.getEventType = getEventType;
|
|
599
|
+
exports.interopSymbols = interopSymbols;
|
|
591
600
|
exports.isActor = isActor;
|
|
592
601
|
exports.isArray = isArray;
|
|
593
602
|
exports.isBehavior = isBehavior;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xstate",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.28.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",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"rollup-plugin-uglify": "^6.0.2",
|
|
62
62
|
"rxjs": "^7.1.0",
|
|
63
63
|
"ts-jest": "^26.5.6",
|
|
64
|
-
"tslib": "^2.
|
|
65
|
-
"typescript": "^4.
|
|
64
|
+
"tslib": "^2.3.1",
|
|
65
|
+
"typescript": "^4.5.2",
|
|
66
66
|
"xml-js": "^1.6.11"
|
|
67
67
|
}
|
|
68
68
|
}
|