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.
Files changed (50) hide show
  1. package/CHANGELOG.md +78 -1
  2. package/dist/xstate.interpreter.js +1 -1
  3. package/dist/xstate.js +1 -1
  4. package/dist/xstate.web.js +2 -2
  5. package/es/Actor.js +5 -5
  6. package/es/State.d.ts +5 -2
  7. package/es/State.js +10 -3
  8. package/es/StateNode.d.ts +2 -1
  9. package/es/StateNode.js +54 -59
  10. package/es/_virtual/_tslib.js +8 -4
  11. package/es/actions.d.ts +18 -2
  12. package/es/actions.js +22 -8
  13. package/es/devTools.d.ts +1 -2
  14. package/es/devTools.js +4 -0
  15. package/es/index.d.ts +2 -1
  16. package/es/index.js +2 -1
  17. package/es/interpreter.d.ts +0 -5
  18. package/es/interpreter.js +35 -25
  19. package/es/registry.js +1 -1
  20. package/es/stateUtils.d.ts +1 -1
  21. package/es/stateUtils.js +1 -1
  22. package/es/types.d.ts +10 -14
  23. package/es/utils.d.ts +7 -1
  24. package/es/utils.js +17 -10
  25. package/lib/Actor.js +4 -4
  26. package/lib/SimulatedClock.js +9 -5
  27. package/lib/State.d.ts +5 -2
  28. package/lib/State.js +10 -3
  29. package/lib/StateNode.d.ts +2 -1
  30. package/lib/StateNode.js +52 -57
  31. package/lib/_virtual/_tslib.js +8 -4
  32. package/lib/actions.d.ts +18 -2
  33. package/lib/actions.js +22 -7
  34. package/lib/devTools.d.ts +1 -2
  35. package/lib/devTools.js +4 -0
  36. package/lib/index.d.ts +2 -1
  37. package/lib/index.js +1 -0
  38. package/lib/interpreter.d.ts +0 -5
  39. package/lib/interpreter.js +34 -24
  40. package/lib/json.js +7 -7
  41. package/lib/model.js +14 -10
  42. package/lib/patterns.js +2 -2
  43. package/lib/registry.js +1 -1
  44. package/lib/scxml.js +29 -25
  45. package/lib/stateUtils.d.ts +1 -1
  46. package/lib/stateUtils.js +1 -1
  47. package/lib/types.d.ts +10 -14
  48. package/lib/utils.d.ts +7 -1
  49. package/lib/utils.js +18 -9
  50. 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' ? "" + event : event.type;
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("'" + stateId + "' is not a valid state path.");
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: " + message];
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 '" + originalError.stack + "'" : '';
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 '" + id + "', error was '" + originalError + "'." + originalStackTrace);
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 '" + currentError.stack + "'" : ''; // tslint:disable-next-line:no-console
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 '" + id + "'. " + ("Original error: '" + originalError + "'. " + originalStackTrace + " Current error is '" + currentError + "'." + stackTrace));
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 '" + guard.type + "' is not implemented on machine '" + machine.id + "'.");
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.26.0",
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.2.0",
65
- "typescript": "^4.3.5",
64
+ "tslib": "^2.3.1",
65
+ "typescript": "^4.5.2",
66
66
  "xml-js": "^1.6.11"
67
67
  }
68
68
  }