xstate 5.0.0-beta.8 → 5.0.0-beta.9

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 (54) hide show
  1. package/actions/dist/xstate-actions.cjs.d.mts +2 -0
  2. package/actions/dist/xstate-actions.cjs.d.mts.map +1 -0
  3. package/actions/dist/xstate-actions.cjs.d.ts +1 -0
  4. package/actions/dist/xstate-actions.cjs.d.ts.map +1 -0
  5. package/actions/dist/xstate-actions.cjs.dev.js +1 -1
  6. package/actions/dist/xstate-actions.cjs.mjs +25 -0
  7. package/actions/dist/xstate-actions.cjs.prod.js +2 -2
  8. package/actions/dist/xstate-actions.esm.js +1 -1
  9. package/actions/dist/xstate-actions.umd.min.js +1 -1
  10. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  11. package/actors/dist/xstate-actors.cjs.d.mts +2 -0
  12. package/actors/dist/xstate-actors.cjs.d.mts.map +1 -0
  13. package/actors/dist/xstate-actors.cjs.d.ts +1 -0
  14. package/actors/dist/xstate-actors.cjs.d.ts.map +1 -0
  15. package/actors/dist/xstate-actors.cjs.dev.js +1 -1
  16. package/actors/dist/xstate-actors.cjs.mjs +15 -0
  17. package/actors/dist/xstate-actors.cjs.prod.js +2 -2
  18. package/actors/dist/xstate-actors.esm.js +1 -1
  19. package/actors/dist/xstate-actors.umd.min.js +1 -1
  20. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  21. package/dev/dist/xstate-dev.cjs.d.mts +2 -0
  22. package/dev/dist/xstate-dev.cjs.d.mts.map +1 -0
  23. package/dev/dist/xstate-dev.cjs.d.ts +1 -0
  24. package/dev/dist/xstate-dev.cjs.d.ts.map +1 -0
  25. package/dev/dist/xstate-dev.cjs.mjs +5 -0
  26. package/dev/dist/xstate-dev.cjs.prod.js +6 -43
  27. package/dev/dist/xstate-dev.umd.min.js.map +1 -1
  28. package/dist/{actions-d06ca158.cjs.dev.js → actions-b6357569.cjs.dev.js} +164 -114
  29. package/dist/{actions-900f9761.cjs.prod.js → actions-bd4a184d.cjs.prod.js} +191 -117
  30. package/dist/{actions-c8d7df32.esm.js → actions-de434a04.esm.js} +120 -104
  31. package/dist/declarations/src/interpreter.d.ts +3 -2
  32. package/dist/declarations/src/typegenTypes.d.ts +7 -1
  33. package/dist/declarations/src/types.d.ts +2 -1
  34. package/dist/index-0f3fdf0c.cjs.prod.js +52 -0
  35. package/dist/xstate.cjs.d.mts +2 -0
  36. package/dist/xstate.cjs.d.mts.map +1 -0
  37. package/dist/xstate.cjs.d.ts +1 -0
  38. package/dist/xstate.cjs.d.ts.map +1 -0
  39. package/dist/xstate.cjs.dev.js +13 -19
  40. package/dist/xstate.cjs.mjs +39 -0
  41. package/dist/xstate.cjs.prod.js +14 -20
  42. package/dist/xstate.esm.js +11 -11
  43. package/dist/xstate.umd.min.js +1 -1
  44. package/dist/xstate.umd.min.js.map +1 -1
  45. package/guards/dist/xstate-guards.cjs.d.mts +2 -0
  46. package/guards/dist/xstate-guards.cjs.d.mts.map +1 -0
  47. package/guards/dist/xstate-guards.cjs.d.ts +1 -0
  48. package/guards/dist/xstate-guards.cjs.d.ts.map +1 -0
  49. package/guards/dist/xstate-guards.cjs.dev.js +1 -1
  50. package/guards/dist/xstate-guards.cjs.mjs +8 -0
  51. package/guards/dist/xstate-guards.cjs.prod.js +2 -2
  52. package/guards/dist/xstate-guards.esm.js +1 -1
  53. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  54. package/package.json +7 -1
@@ -59,39 +59,39 @@ var SpecialTargets;
59
59
  })(SpecialTargets || (SpecialTargets = {}));
60
60
 
61
61
  // xstate-specific action types
62
- var stop = ActionTypes.Stop;
63
- var raise = ActionTypes.Raise;
64
- var send = ActionTypes.Send;
65
- var cancel = ActionTypes.Cancel;
66
- var assign = ActionTypes.Assign;
67
- var after = ActionTypes.After;
62
+ var stop$1 = ActionTypes.Stop;
63
+ var raise$1 = ActionTypes.Raise;
64
+ var send$1 = ActionTypes.Send;
65
+ var cancel$1 = ActionTypes.Cancel;
66
+ var assign$1 = ActionTypes.Assign;
67
+ var after$1 = ActionTypes.After;
68
68
  var doneState = ActionTypes.DoneState;
69
- var log = ActionTypes.Log;
69
+ var log$1 = ActionTypes.Log;
70
70
  var init = ActionTypes.Init;
71
- var invoke = ActionTypes.Invoke;
71
+ var invoke$1 = ActionTypes.Invoke;
72
72
  var errorExecution = ActionTypes.ErrorExecution;
73
73
  var errorPlatform = ActionTypes.ErrorPlatform;
74
- var error = ActionTypes.ErrorCustom;
75
- var choose = ActionTypes.Choose;
76
- var pure = ActionTypes.Pure;
74
+ var error$1 = ActionTypes.ErrorCustom;
75
+ var choose$1 = ActionTypes.Choose;
76
+ var pure$1 = ActionTypes.Pure;
77
77
 
78
78
  var actionTypes = /*#__PURE__*/Object.freeze({
79
79
  __proto__: null,
80
- stop: stop,
81
- raise: raise,
82
- send: send,
83
- cancel: cancel,
84
- assign: assign,
85
- after: after,
80
+ stop: stop$1,
81
+ raise: raise$1,
82
+ send: send$1,
83
+ cancel: cancel$1,
84
+ assign: assign$1,
85
+ after: after$1,
86
86
  doneState: doneState,
87
- log: log,
87
+ log: log$1,
88
88
  init: init,
89
- invoke: invoke,
89
+ invoke: invoke$1,
90
90
  errorExecution: errorExecution,
91
91
  errorPlatform: errorPlatform,
92
- error: error,
93
- choose: choose,
94
- pure: pure
92
+ error: error$1,
93
+ choose: choose$1,
94
+ pure: pure$1
95
95
  });
96
96
 
97
97
  function _toPrimitive(input, hint) {
@@ -535,9 +535,9 @@ function isDynamicAction(action) {
535
535
  * - `delay` - The number of milliseconds to delay the sending of the event.
536
536
  * - `to` - The target of this event (by default, the machine the event was sent from).
537
537
  */
538
- function send$1(eventOrExpr, options) {
538
+ function send(eventOrExpr, options) {
539
539
  return createDynamicAction({
540
- type: send,
540
+ type: send$1,
541
541
  params: {
542
542
  to: options ? options.to : undefined,
543
543
  delay: options ? options.delay : undefined,
@@ -598,7 +598,7 @@ function send$1(eventOrExpr, options) {
598
598
  targetActorRef = resolvedTarget || (actorContext === null || actorContext === void 0 ? void 0 : actorContext.self);
599
599
  }
600
600
  var resolvedAction = {
601
- type: send,
601
+ type: send$1,
602
602
  params: _objectSpread2(_objectSpread2({}, params), {}, {
603
603
  to: targetActorRef,
604
604
  _event: resolvedEvent,
@@ -617,7 +617,7 @@ function send$1(eventOrExpr, options) {
617
617
  actorCtx.defer(function () {
618
618
  var origin = actorCtx.self;
619
619
  var resolvedEvent = _objectSpread2(_objectSpread2({}, _event2), {}, {
620
- name: _event2.name === error ? "".concat(error$1(origin.id)) : _event2.name,
620
+ name: _event2.name === error$1 ? "".concat(error(origin.id)) : _event2.name,
621
621
  origin: origin
622
622
  });
623
623
  target.send(resolvedEvent);
@@ -636,7 +636,7 @@ function send$1(eventOrExpr, options) {
636
636
  * @param options Options to pass into the send event.
637
637
  */
638
638
  function sendParent(event, options) {
639
- return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
639
+ return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
640
640
  to: SpecialTargets.Parent
641
641
  }));
642
642
  }
@@ -648,7 +648,7 @@ function sendParent(event, options) {
648
648
  * @param options Options to pass into the send event
649
649
  */
650
650
  function respond(event, options) {
651
- return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
651
+ return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
652
652
  to: function to(_ref2) {
653
653
  var _event = _ref2._event;
654
654
  return _event.origin; // TODO: handle when _event.origin is undefined
@@ -673,7 +673,7 @@ function forwardTo(target, options) {
673
673
  return resolvedTarget;
674
674
  };
675
675
  }
676
- return send$1(function (_ref3) {
676
+ return send(function (_ref3) {
677
677
  var event = _ref3.event;
678
678
  return event;
679
679
  }, _objectSpread2(_objectSpread2({}, options), {}, {
@@ -691,7 +691,7 @@ function forwardTo(target, options) {
691
691
  function escalate(errorData, options) {
692
692
  return sendParent(function (arg) {
693
693
  return {
694
- type: error,
694
+ type: error$1,
695
695
  data: isFunction(errorData) ? errorData(arg) : errorData
696
696
  };
697
697
  }, _objectSpread2(_objectSpread2({}, options), {}, {
@@ -708,7 +708,7 @@ function escalate(errorData, options) {
708
708
  * @returns An XState send action object
709
709
  */
710
710
  function sendTo(actor, event, options) {
711
- return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
711
+ return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
712
712
  to: actor
713
713
  }));
714
714
  }
@@ -903,11 +903,19 @@ promiseCreator) {
903
903
  input: state.input
904
904
  }));
905
905
  resolvedPromise.then(function (response) {
906
+ // TODO: remove this condition once dead letter queue lands
907
+ if (self._state.status !== 'active') {
908
+ return;
909
+ }
906
910
  self.send({
907
911
  type: resolveEventType,
908
912
  data: response
909
913
  });
910
914
  }, function (errorData) {
915
+ // TODO: remove this condition once dead letter queue lands
916
+ if (self._state.status !== 'active') {
917
+ return;
918
+ }
911
919
  self.send({
912
920
  type: rejectEventType,
913
921
  data: errorData
@@ -1196,7 +1204,7 @@ function fromCallback(invokeCallback) {
1196
1204
  state.canceled = true;
1197
1205
  }, function (errorData) {
1198
1206
  var _self$_parent3;
1199
- var errorEvent = error$1(id, errorData);
1207
+ var errorEvent = error(id, errorData);
1200
1208
  (_self$_parent3 = self._parent) === null || _self$_parent3 === void 0 ? void 0 : _self$_parent3.send(toSCXMLEvent(errorEvent, {
1201
1209
  origin: self
1202
1210
  }));
@@ -1489,9 +1497,9 @@ var Interpreter = /*#__PURE__*/function () {
1489
1497
  _step;
1490
1498
  try {
1491
1499
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1492
- var _observer2$next;
1493
- var _observer2 = _step.value;
1494
- (_observer2$next = _observer2.next) === null || _observer2$next === void 0 ? void 0 : _observer2$next.call(_observer2, snapshot);
1500
+ var _observer$next;
1501
+ var _observer = _step.value;
1502
+ (_observer$next = _observer.next) === null || _observer$next === void 0 ? void 0 : _observer$next.call(_observer, snapshot);
1495
1503
  }
1496
1504
  } catch (err) {
1497
1505
  _iterator.e(err);
@@ -1501,30 +1509,20 @@ var Interpreter = /*#__PURE__*/function () {
1501
1509
  var status = (_this$behavior$getSta = (_this$behavior = this.behavior).getStatus) === null || _this$behavior$getSta === void 0 ? void 0 : _this$behavior$getSta.call(_this$behavior, state);
1502
1510
  switch (status === null || status === void 0 ? void 0 : status.status) {
1503
1511
  case 'done':
1512
+ this._stopProcedure();
1504
1513
  this._doneEvent = doneInvoke(this.id, status.data);
1505
1514
  (_this$_parent = this._parent) === null || _this$_parent === void 0 ? void 0 : _this$_parent.send(toSCXMLEvent(this._doneEvent, {
1506
1515
  origin: this,
1507
1516
  invokeid: this.id
1508
1517
  }));
1509
- this._stopProcedure();
1518
+ this._complete();
1510
1519
  break;
1511
1520
  case 'error':
1512
- (_this$_parent2 = this._parent) === null || _this$_parent2 === void 0 ? void 0 : _this$_parent2.send(toSCXMLEvent(error$1(this.id, status.data), {
1521
+ this._stopProcedure();
1522
+ (_this$_parent2 = this._parent) === null || _this$_parent2 === void 0 ? void 0 : _this$_parent2.send(toSCXMLEvent(error(this.id, status.data), {
1513
1523
  origin: this
1514
1524
  }));
1515
- var _iterator2 = _createForOfIteratorHelper(this.observers),
1516
- _step2;
1517
- try {
1518
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1519
- var _observer$error;
1520
- var _observer = _step2.value;
1521
- (_observer$error = _observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(_observer, status.data);
1522
- }
1523
- } catch (err) {
1524
- _iterator2.e(err);
1525
- } finally {
1526
- _iterator2.f();
1527
- }
1525
+ this._error(status.data);
1528
1526
  break;
1529
1527
  }
1530
1528
  }
@@ -1605,13 +1603,14 @@ var Interpreter = /*#__PURE__*/function () {
1605
1603
  this.update(nextState);
1606
1604
  if (event.name === stopSignalType) {
1607
1605
  this._stopProcedure();
1606
+ this._complete();
1608
1607
  }
1609
1608
  } catch (err) {
1610
1609
  // TODO: properly handle errors
1611
1610
  if (this.observers.size > 0) {
1612
1611
  this.observers.forEach(function (observer) {
1613
- var _observer$error2;
1614
- (_observer$error2 = observer.error) === null || _observer$error2 === void 0 ? void 0 : _observer$error2.call(observer, err);
1612
+ var _observer$error;
1613
+ (_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, err);
1615
1614
  });
1616
1615
  this.stop();
1617
1616
  } else {
@@ -1650,13 +1649,31 @@ var Interpreter = /*#__PURE__*/function () {
1650
1649
  }, {
1651
1650
  key: "_complete",
1652
1651
  value: function _complete() {
1652
+ var _iterator2 = _createForOfIteratorHelper(this.observers),
1653
+ _step2;
1654
+ try {
1655
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1656
+ var _observer2$complete;
1657
+ var _observer2 = _step2.value;
1658
+ (_observer2$complete = _observer2.complete) === null || _observer2$complete === void 0 ? void 0 : _observer2$complete.call(_observer2);
1659
+ }
1660
+ } catch (err) {
1661
+ _iterator2.e(err);
1662
+ } finally {
1663
+ _iterator2.f();
1664
+ }
1665
+ this.observers.clear();
1666
+ }
1667
+ }, {
1668
+ key: "_error",
1669
+ value: function _error(data) {
1653
1670
  var _iterator3 = _createForOfIteratorHelper(this.observers),
1654
1671
  _step3;
1655
1672
  try {
1656
1673
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1657
- var _observer3$complete;
1674
+ var _observer3$error;
1658
1675
  var _observer3 = _step3.value;
1659
- (_observer3$complete = _observer3.complete) === null || _observer3$complete === void 0 ? void 0 : _observer3$complete.call(_observer3);
1676
+ (_observer3$error = _observer3.error) === null || _observer3$error === void 0 ? void 0 : _observer3$error.call(_observer3, data);
1660
1677
  }
1661
1678
  } catch (err) {
1662
1679
  _iterator3.e(err);
@@ -1668,7 +1685,6 @@ var Interpreter = /*#__PURE__*/function () {
1668
1685
  }, {
1669
1686
  key: "_stopProcedure",
1670
1687
  value: function _stopProcedure() {
1671
- this._complete();
1672
1688
  if (this.status !== ActorStatus.Running) {
1673
1689
  // Interpreter already stopped; do nothing
1674
1690
  return this;
@@ -1795,10 +1811,10 @@ function interpret(behavior, options) {
1795
1811
  * @param actorRef The actor to stop.
1796
1812
  */
1797
1813
 
1798
- function stop$1(actorRef) {
1814
+ function stop(actorRef) {
1799
1815
  var actor = actorRef;
1800
1816
  return createDynamicAction({
1801
- type: stop,
1817
+ type: stop$1,
1802
1818
  params: {
1803
1819
  actor: actor
1804
1820
  }
@@ -1848,11 +1864,11 @@ var defaultLogExpr = function defaultLogExpr(_ref) {
1848
1864
  * @param label The label to give to the logged expression.
1849
1865
  */
1850
1866
 
1851
- function log$1() {
1867
+ function log() {
1852
1868
  var expr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultLogExpr;
1853
1869
  var label = arguments.length > 1 ? arguments[1] : undefined;
1854
1870
  return createDynamicAction({
1855
- type: log,
1871
+ type: log$1,
1856
1872
  params: {
1857
1873
  label: label,
1858
1874
  expr: expr
@@ -1895,9 +1911,9 @@ function log$1() {
1895
1911
  * @param sendId The `id` of the `send(...)` action to cancel.
1896
1912
  */
1897
1913
 
1898
- function cancel$1(sendId) {
1914
+ function cancel(sendId) {
1899
1915
  return createDynamicAction({
1900
- type: cancel,
1916
+ type: cancel$1,
1901
1917
  params: {
1902
1918
  sendId: sendId
1903
1919
  }
@@ -2308,13 +2324,13 @@ function getDelayedTransitions(stateNode) {
2308
2324
  }
2309
2325
  var mutateEntryExit = function mutateEntryExit(delay, i) {
2310
2326
  var delayRef = isFunction(delay) ? "".concat(stateNode.id, ":delay[").concat(i, "]") : delay;
2311
- var eventType = after$1(delayRef, stateNode.id);
2312
- stateNode.entry.push(raise$1({
2327
+ var eventType = after(delayRef, stateNode.id);
2328
+ stateNode.entry.push(raise({
2313
2329
  type: eventType
2314
2330
  }, {
2315
2331
  delay: delay
2316
2332
  }));
2317
- stateNode.exit.push(cancel$1(eventType));
2333
+ stateNode.exit.push(cancel(eventType));
2318
2334
  return eventType;
2319
2335
  };
2320
2336
  var delayedTransitions = isArray(afterConfig) ? afterConfig.map(function (transition, i) {
@@ -2965,12 +2981,12 @@ function setChildren(currentState, nonRaisedActions) {
2965
2981
  try {
2966
2982
  for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
2967
2983
  var action = _step21.value;
2968
- if (action.type === invoke && action.params.ref) {
2984
+ if (action.type === invoke$1 && action.params.ref) {
2969
2985
  var ref = action.params.ref;
2970
2986
  if (ref) {
2971
2987
  children[ref.id] = ref;
2972
2988
  }
2973
- } else if (action.type === stop) {
2989
+ } else if (action.type === stop$1) {
2974
2990
  var _ref = action.params.actor;
2975
2991
  if (_ref) {
2976
2992
  delete children[_ref.id];
@@ -3069,7 +3085,7 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
3069
3085
  try {
3070
3086
  for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
3071
3087
  var invokeDef = _step23.value;
3072
- actions.push(invoke$1(invokeDef));
3088
+ actions.push(invoke(invokeDef));
3073
3089
  }
3074
3090
 
3075
3091
  // Add entry actions
@@ -3379,7 +3395,7 @@ function exitStates(transitions, mutConfiguration, historyValue, actions) {
3379
3395
  for (_iterator40.s(); !(_step40 = _iterator40.n()).done;) {
3380
3396
  var s = _step40.value;
3381
3397
  actions.push.apply(actions, _toConsumableArray(s.exit.flat()).concat(_toConsumableArray(s.invoke.map(function (def) {
3382
- return stop$1(def.id);
3398
+ return stop(def.id);
3383
3399
  }))));
3384
3400
  mutConfiguration["delete"](s);
3385
3401
  }
@@ -3417,12 +3433,12 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3417
3433
  resolvedAction = _executableActionObje2[1];
3418
3434
  var matchedActions = (_resolvedAction$param = resolvedAction.params) === null || _resolvedAction$param === void 0 ? void 0 : _resolvedAction$param.actions;
3419
3435
  intermediateState = nextState;
3420
- if ((resolvedAction.type === raise || resolvedAction.type === send && resolvedAction.params.internal) && typeof resolvedAction.params.delay !== 'number') {
3436
+ if ((resolvedAction.type === raise$1 || resolvedAction.type === send$1 && resolvedAction.params.internal) && typeof resolvedAction.params.delay !== 'number') {
3421
3437
  raiseActions.push(resolvedAction);
3422
3438
  }
3423
3439
 
3424
3440
  // TODO: remove the check; just handleAction
3425
- if (resolvedAction.type !== pure) {
3441
+ if (resolvedAction.type !== pure$1) {
3426
3442
  handleAction(resolvedAction);
3427
3443
  }
3428
3444
  toActionObjects(matchedActions).forEach(resolveAction);
@@ -3536,7 +3552,7 @@ function stopStep(scxmlEvent, nextState, actorCtx) {
3536
3552
  }
3537
3553
  for (var _i4 = 0, _Object$values = Object.values(nextState.children); _i4 < _Object$values.length; _i4++) {
3538
3554
  var child = _Object$values[_i4];
3539
- actions.push(stop$1(child));
3555
+ actions.push(stop(child));
3540
3556
  }
3541
3557
  var _resolveActionsAndCon2 = resolveActionsAndContext(actions, scxmlEvent, nextState, actorCtx),
3542
3558
  stoppedState = _resolveActionsAndCon2.nextState;
@@ -3709,11 +3725,11 @@ var State = /*#__PURE__*/function () {
3709
3725
  }, {
3710
3726
  key: "toJSON",
3711
3727
  value: function toJSON() {
3712
- var configuration = this.configuration,
3713
- transitions = this.transitions,
3714
- tags = this.tags,
3715
- machine = this.machine,
3716
- jsonValues = _objectWithoutProperties(this, _excluded);
3728
+ this.configuration;
3729
+ this.transitions;
3730
+ var tags = this.tags;
3731
+ this.machine;
3732
+ var jsonValues = _objectWithoutProperties(this, _excluded);
3717
3733
  return _objectSpread2(_objectSpread2({}, jsonValues), {}, {
3718
3734
  tags: Array.from(tags),
3719
3735
  meta: this.meta
@@ -3864,11 +3880,11 @@ function cloneState(state) {
3864
3880
  return new State(_objectSpread2(_objectSpread2({}, state), config), state.machine);
3865
3881
  }
3866
3882
  function getPersistedState(state) {
3867
- var configuration = state.configuration,
3868
- transitions = state.transitions,
3869
- tags = state.tags,
3870
- machine = state.machine,
3871
- children = state.children,
3883
+ state.configuration;
3884
+ state.transitions;
3885
+ state.tags;
3886
+ state.machine;
3887
+ var children = state.children,
3872
3888
  jsonValues = _objectWithoutProperties(state, _excluded2);
3873
3889
  var childrenJson = {};
3874
3890
  for (var id in children) {
@@ -3883,14 +3899,14 @@ function getPersistedState(state) {
3883
3899
  });
3884
3900
  }
3885
3901
 
3886
- function invoke$1(invokeDef) {
3902
+ function invoke(invokeDef) {
3887
3903
  return createDynamicAction({
3888
- type: invoke,
3904
+ type: invoke$1,
3889
3905
  params: invokeDef
3890
3906
  }, function (_event, _ref) {
3891
3907
  var state = _ref.state,
3892
3908
  actorContext = _ref.actorContext;
3893
- var type = invoke;
3909
+ var type = invoke$1;
3894
3910
  var id = invokeDef.id,
3895
3911
  src = invokeDef.src;
3896
3912
  var resolvedInvokeAction;
@@ -3952,7 +3968,7 @@ function invoke$1(invokeDef) {
3952
3968
  var _actorRef$start;
3953
3969
  (_actorRef$start = actorRef.start) === null || _actorRef$start === void 0 ? void 0 : _actorRef$start.call(actorRef);
3954
3970
  } catch (err) {
3955
- parent.send(error$1(id, err));
3971
+ parent.send(error(id, err));
3956
3972
  return;
3957
3973
  }
3958
3974
  });
@@ -3981,7 +3997,7 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3981
3997
  self: self
3982
3998
  }) : input
3983
3999
  });
3984
- mutCapturedActions.push(invoke$1({
4000
+ mutCapturedActions.push(invoke({
3985
4001
  id: actorRef.id,
3986
4002
  // @ts-ignore TODO: fix types
3987
4003
  src: actorRef,
@@ -4002,7 +4018,7 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
4002
4018
  parent: self,
4003
4019
  input: options.input
4004
4020
  });
4005
- mutCapturedActions.push(invoke$1({
4021
+ mutCapturedActions.push(invoke({
4006
4022
  // @ts-ignore TODO: fix types
4007
4023
  src: _actorRef,
4008
4024
  ref: _actorRef,
@@ -4020,9 +4036,9 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
4020
4036
  *
4021
4037
  * @param assignment An object that represents the partial context to update.
4022
4038
  */
4023
- function assign$1(assignment) {
4039
+ function assign(assignment) {
4024
4040
  return createDynamicAction({
4025
- type: assign,
4041
+ type: assign$1,
4026
4042
  params: {
4027
4043
  assignment: assignment
4028
4044
  }
@@ -4058,7 +4074,7 @@ function assign$1(assignment) {
4058
4074
  return [cloneState(state, {
4059
4075
  context: updatedContext
4060
4076
  }), {
4061
- type: assign,
4077
+ type: assign$1,
4062
4078
  params: {
4063
4079
  context: updatedContext,
4064
4080
  actions: capturedActions
@@ -4074,9 +4090,9 @@ function assign$1(assignment) {
4074
4090
  * @param eventType The event to raise.
4075
4091
  */
4076
4092
 
4077
- function raise$1(eventOrExpr, options) {
4093
+ function raise(eventOrExpr, options) {
4078
4094
  return createDynamicAction({
4079
- type: raise,
4095
+ type: raise$1,
4080
4096
  params: {
4081
4097
  delay: options ? options.delay : undefined,
4082
4098
  event: eventOrExpr,
@@ -4113,7 +4129,7 @@ function raise$1(eventOrExpr, options) {
4113
4129
  resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
4114
4130
  }
4115
4131
  var resolvedAction = {
4116
- type: raise,
4132
+ type: raise$1,
4117
4133
  params: _objectSpread2(_objectSpread2({}, params), {}, {
4118
4134
  _event: resolvedEvent,
4119
4135
  event: resolvedEvent.data,
@@ -4130,9 +4146,9 @@ function raise$1(eventOrExpr, options) {
4130
4146
  });
4131
4147
  }
4132
4148
 
4133
- function choose$1(guards) {
4149
+ function choose(guards) {
4134
4150
  return createDynamicAction({
4135
- type: choose,
4151
+ type: choose$1,
4136
4152
  params: {
4137
4153
  guards: guards
4138
4154
  }
@@ -4146,7 +4162,7 @@ function choose$1(guards) {
4146
4162
  return !guard || evaluateGuard(guard, state.context, _event, state);
4147
4163
  })) === null || _guards$find === void 0 ? void 0 : _guards$find.actions;
4148
4164
  return [state, {
4149
- type: choose,
4165
+ type: choose$1,
4150
4166
  params: {
4151
4167
  actions: toActionObjects(matchedActions)
4152
4168
  }
@@ -4154,9 +4170,9 @@ function choose$1(guards) {
4154
4170
  });
4155
4171
  }
4156
4172
 
4157
- function pure$1(getActions) {
4173
+ function pure(getActions) {
4158
4174
  return createDynamicAction({
4159
- type: pure,
4175
+ type: pure$1,
4160
4176
  params: {
4161
4177
  get: getActions
4162
4178
  }
@@ -4164,7 +4180,7 @@ function pure$1(getActions) {
4164
4180
  var _toArray;
4165
4181
  var state = _ref.state;
4166
4182
  return [state, {
4167
- type: pure,
4183
+ type: pure$1,
4168
4184
  params: {
4169
4185
  actions: (_toArray = toArray(toActionObjects(getActions({
4170
4186
  context: state.context,
@@ -4196,9 +4212,9 @@ function resolveActionObject(actionObject, actionFunctionMap) {
4196
4212
  execute: function execute(actorCtx) {
4197
4213
  return dereferencedAction({
4198
4214
  context: state.context,
4199
- event: state.event,
4215
+ event: _event.data,
4200
4216
  action: a,
4201
- _event: state._event,
4217
+ _event: _event,
4202
4218
  system: actorCtx.system,
4203
4219
  self: actorCtx.self
4204
4220
  });
@@ -4267,7 +4283,7 @@ var toActionObjects = function toActionObjects(action) {
4267
4283
  * @param delayRef The delay in milliseconds
4268
4284
  * @param id The state node ID where this event is handled
4269
4285
  */
4270
- function after$1(delayRef, id) {
4286
+ function after(delayRef, id) {
4271
4287
  var idSuffix = id ? "#".concat(id) : '';
4272
4288
  return "".concat(ActionTypes.After, "(").concat(delayRef, ")").concat(idSuffix);
4273
4289
  }
@@ -4311,7 +4327,7 @@ function doneInvoke(invokeId, output) {
4311
4327
  };
4312
4328
  return eventObject;
4313
4329
  }
4314
- function error$1(id, data) {
4330
+ function error(id, data) {
4315
4331
  var type = "".concat(ActionTypes.ErrorPlatform, ".").concat(id);
4316
4332
  var eventObject = {
4317
4333
  type: type,
@@ -4329,4 +4345,4 @@ function createInitEvent(input) {
4329
4345
  });
4330
4346
  }
4331
4347
 
4332
- export { doneInvoke as $, resolveStateValue as A, isInFinalState as B, toSCXMLEvent as C, isSCXMLErrorEvent as D, macrostep as E, transitionNode as F, _slicedToArray as G, getInitialConfiguration as H, resolveActionsAndContext as I, microstep as J, error$1 as K, isStateId as L, getStateNodeByPath as M, NULL_EVENT as N, getPersistedState as O, resolveReferencedActor as P, interpret as Q, STATE_DELIMITER as R, State as S, initEvent as T, matchesState as U, sendTo as V, sendParent as W, forwardTo as X, Interpreter as Y, ActorStatus as Z, _createClass as _, formatTransition as a, assign$1 as a0, cancel$1 as a1, choose$1 as a2, log$1 as a3, pure$1 as a4, raise$1 as a5, stop$1 as a6, pathToStateValue as a7, toObserver as a8, fromPromise as a9, escalate as aA, fromObservable as aa, fromCallback as ab, fromEventObservable as ac, fromTransition as ad, stateIn as ae, not as af, and as ag, or as ah, ActionTypes as ai, SpecialTargets as aj, startSignalType as ak, stopSignalType as al, startSignal as am, stopSignal as an, isSignal as ao, isActorRef as ap, toActorRef as aq, createEmptyActor as ar, toGuardDefinition as as, actionTypes as at, resolveActionObject as au, toActionObject as av, after$1 as aw, done as ax, send$1 as ay, respond as az, memo as b, _createForOfIteratorHelper as c, _toConsumableArray as d, evaluateGuard as e, formatTransitions as f, flatten as g, _classCallCheck as h, _defineProperty as i, toActionObjects as j, toArray as k, createInvokeId as l, mapValues as m, toInvokeConfig as n, _objectSpread2 as o, invoke as p, _objectWithoutProperties as q, getDelayedTransitions as r, formatInitialTransition as s, toTransitionConfigArray as t, getCandidates as u, isString as v, createSpawner as w, createInitEvent as x, getConfiguration as y, getStateNodes as z };
4348
+ export { doneInvoke as $, resolveStateValue as A, isInFinalState as B, toSCXMLEvent as C, isSCXMLErrorEvent as D, macrostep as E, transitionNode as F, _slicedToArray as G, getInitialConfiguration as H, resolveActionsAndContext as I, microstep as J, error as K, isStateId as L, getStateNodeByPath as M, NULL_EVENT as N, getPersistedState as O, resolveReferencedActor as P, interpret as Q, STATE_DELIMITER as R, State as S, initEvent as T, matchesState as U, sendTo as V, sendParent as W, forwardTo as X, Interpreter as Y, ActorStatus as Z, _createClass as _, formatTransition as a, assign as a0, cancel as a1, choose as a2, log as a3, pure as a4, raise as a5, stop as a6, pathToStateValue as a7, toObserver as a8, fromPromise as a9, escalate as aA, fromObservable as aa, fromCallback as ab, fromEventObservable as ac, fromTransition as ad, stateIn as ae, not as af, and as ag, or as ah, ActionTypes as ai, SpecialTargets as aj, startSignalType as ak, stopSignalType as al, startSignal as am, stopSignal as an, isSignal as ao, isActorRef as ap, toActorRef as aq, createEmptyActor as ar, toGuardDefinition as as, actionTypes as at, resolveActionObject as au, toActionObject as av, after as aw, done as ax, send as ay, respond as az, memo as b, _createForOfIteratorHelper as c, _toConsumableArray as d, evaluateGuard as e, formatTransitions as f, flatten as g, _classCallCheck as h, _defineProperty as i, toActionObjects as j, toArray as k, createInvokeId as l, mapValues as m, toInvokeConfig as n, _objectSpread2 as o, invoke$1 as p, _objectWithoutProperties as q, getDelayedTransitions as r, formatInitialTransition as s, toTransitionConfigArray as t, getCandidates as u, isString as v, createSpawner as w, createInitEvent as x, getConfiguration as y, getStateNodes as z };
@@ -1,5 +1,5 @@
1
1
  import { symbolObservable } from './symbolObservable.ts';
2
- import { AreAllImplementationsAssumedToBeProvided } from './typegenTypes.ts';
2
+ import { AreAllImplementationsAssumedToBeProvided, MissingImplementationsError } from './typegenTypes.ts';
3
3
  import type { ActorSystem, AnyActorBehavior, AnyStateMachine, EventFromBehavior, InterpreterFrom, PersistedStateFrom, RaiseActionObject, SnapshotFrom } from './types.ts';
4
4
  import { ActorRef, DoneEvent, EventObject, InteropSubscribable, InterpreterOptions, Observer, SCXML, SendActionObject, Subscription } from './types.ts';
5
5
  export type SnapshotListener<TBehavior extends AnyActorBehavior> = (state: SnapshotFrom<TBehavior>) => void;
@@ -77,6 +77,7 @@ export declare class Interpreter<TBehavior extends AnyActorBehavior, TEvent exte
77
77
  */
78
78
  stop(): this;
79
79
  private _complete;
80
+ private _error;
80
81
  private _stopProcedure;
81
82
  /**
82
83
  * Sends an event to the running interpreter to trigger a transition.
@@ -100,5 +101,5 @@ export declare class Interpreter<TBehavior extends AnyActorBehavior, TEvent exte
100
101
  * @param machine The machine to interpret
101
102
  * @param options Interpreter options
102
103
  */
103
- export declare function interpret<TMachine extends AnyStateMachine>(machine: AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? TMachine : 'Some implementations missing', options?: InterpreterOptions<TMachine>): InterpreterFrom<TMachine>;
104
+ export declare function interpret<TMachine extends AnyStateMachine>(machine: AreAllImplementationsAssumedToBeProvided<TMachine['__TResolvedTypesMeta']> extends true ? TMachine : MissingImplementationsError<TMachine['__TResolvedTypesMeta']>, options?: InterpreterOptions<TMachine>): InterpreterFrom<TMachine>;
104
105
  export declare function interpret<TBehavior extends AnyActorBehavior>(behavior: TBehavior, options?: InterpreterOptions<TBehavior>): Interpreter<TBehavior>;
@@ -1,4 +1,4 @@
1
- import { EventObject, IndexByType, IsNever, Prop, Values, IsAny, ActorMap, Cast, ParameterizedObject } from './types.ts';
1
+ import { Compute, EventObject, IndexByType, IsNever, Prop, Values, IsAny, ActorMap, Cast, ParameterizedObject } from './types.ts';
2
2
  export interface TypegenDisabled {
3
3
  '@@xstate/typegen': false;
4
4
  }
@@ -86,6 +86,12 @@ export type TypegenConstraint = TypegenEnabled | TypegenDisabled;
86
86
  export type AreAllImplementationsAssumedToBeProvided<TResolvedTypesMeta, TMissingImplementations = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'missingImplementations'>> = IsAny<TResolvedTypesMeta> extends true ? true : TResolvedTypesMeta extends TypegenEnabled ? IsNever<Values<{
87
87
  [K in keyof TMissingImplementations]: TMissingImplementations[K];
88
88
  }>> extends true ? true : false : true;
89
+ export type MissingImplementationsError<TResolvedTypesMeta, TMissingImplementations = Prop<Prop<TResolvedTypesMeta, 'resolved'>, 'missingImplementations'>> = Compute<[
90
+ 'Some implementations missing',
91
+ Values<{
92
+ [K in keyof TMissingImplementations]: TMissingImplementations[K];
93
+ }>
94
+ ]>;
89
95
  interface AllImplementationsProvided {
90
96
  missingImplementations: {
91
97
  actions: never;
@@ -92,7 +92,7 @@ export type ActionFunction<TContext extends MachineContext, TExpressionEvent ext
92
92
  event: TExpressionEvent;
93
93
  } & ActionMeta<TEvent, TAction>) => void;
94
94
  export interface ChooseCondition<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent> {
95
- guard?: GuardConfig<TContext, TEvent>;
95
+ guard?: GuardConfig<TContext, TExpressionEvent>;
96
96
  actions: Actions<TContext, TExpressionEvent, TEvent>;
97
97
  }
98
98
  export type Action<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent> = ActionType | ParameterizedObject | ActionFunction<TContext, TExpressionEvent, ParameterizedObject, TEvent> | BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, any, any>;
@@ -1010,6 +1010,7 @@ export type InferEvent<E extends EventObject> = {
1010
1010
  }[E['type']];
1011
1011
  export type TODO = any;
1012
1012
  export type StateValueFrom<TMachine extends AnyStateMachine> = Parameters<StateFrom<TMachine>['matches']>[0];
1013
+ export type TagsFrom<TMachine extends AnyStateMachine> = Parameters<StateFrom<TMachine>['hasTag']>[0];
1013
1014
  export type StateFromMachine<TMachine extends AnyStateMachine> = TMachine['initialState'];
1014
1015
  export interface ActorSystemInfo {
1015
1016
  actors: Record<string, AnyActorRef>;