xstate 5.0.0-alpha.5 → 5.0.0-beta.10

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 (70) 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 +2 -2
  6. package/actions/dist/xstate-actions.cjs.mjs +24 -0
  7. package/actions/dist/xstate-actions.cjs.prod.js +3 -3
  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 +2 -1
  16. package/actors/dist/xstate-actors.cjs.mjs +15 -0
  17. package/actors/dist/xstate-actors.cjs.prod.js +3 -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-96f799fc.cjs.dev.js → actions-109712d3.cjs.dev.js} +397 -379
  29. package/dist/{actions-7678b87b.esm.js → actions-67f1d04e.esm.js} +351 -366
  30. package/dist/{actions-2479953d.cjs.prod.js → actions-d0262a43.cjs.prod.js} +420 -388
  31. package/dist/declarations/src/State.d.ts +2 -3
  32. package/dist/declarations/src/StateMachine.d.ts +6 -6
  33. package/dist/declarations/src/StateNode.d.ts +5 -11
  34. package/dist/declarations/src/actions/send.d.ts +0 -7
  35. package/dist/declarations/src/actions.d.ts +13 -12
  36. package/dist/declarations/src/actors/index.d.ts +2 -1
  37. package/dist/declarations/src/actors/observable.d.ts +1 -2
  38. package/dist/declarations/src/actors/promise.d.ts +1 -2
  39. package/dist/declarations/src/guards.d.ts +2 -2
  40. package/dist/declarations/src/index.d.ts +13 -29
  41. package/dist/declarations/src/interpreter.d.ts +5 -4
  42. package/dist/declarations/src/spawn.d.ts +2 -2
  43. package/dist/declarations/src/stateUtils.d.ts +15 -14
  44. package/dist/declarations/src/typegenTypes.d.ts +10 -4
  45. package/dist/declarations/src/types.d.ts +27 -101
  46. package/dist/declarations/src/utils.d.ts +3 -5
  47. package/dist/declarations/src/waitFor.d.ts +33 -0
  48. package/dist/index-0f3fdf0c.cjs.prod.js +52 -0
  49. package/dist/xstate.cjs.d.mts +2 -0
  50. package/dist/xstate.cjs.d.mts.map +1 -0
  51. package/dist/xstate.cjs.d.ts +1 -0
  52. package/dist/xstate.cjs.d.ts.map +1 -0
  53. package/dist/xstate.cjs.dev.js +125 -111
  54. package/dist/xstate.cjs.mjs +38 -0
  55. package/dist/xstate.cjs.prod.js +123 -112
  56. package/dist/xstate.esm.js +108 -99
  57. package/dist/xstate.umd.min.js +1 -1
  58. package/dist/xstate.umd.min.js.map +1 -1
  59. package/guards/dist/xstate-guards.cjs.d.mts +2 -0
  60. package/guards/dist/xstate-guards.cjs.d.mts.map +1 -0
  61. package/guards/dist/xstate-guards.cjs.d.ts +1 -0
  62. package/guards/dist/xstate-guards.cjs.d.ts.map +1 -0
  63. package/guards/dist/xstate-guards.cjs.dev.js +1 -1
  64. package/guards/dist/xstate-guards.cjs.mjs +8 -0
  65. package/guards/dist/xstate-guards.cjs.prod.js +2 -2
  66. package/guards/dist/xstate-guards.esm.js +1 -1
  67. package/guards/dist/xstate-guards.umd.min.js +1 -1
  68. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  69. package/package.json +7 -1
  70. package/dist/declarations/src/schema.d.ts +0 -2
@@ -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) {
@@ -319,7 +319,7 @@ function toStatePath(stateId, delimiter) {
319
319
  }
320
320
  }
321
321
  function isStateLike(state) {
322
- return _typeof(state) === 'object' && 'value' in state && 'context' in state && 'event' in state && '_event' in state;
322
+ return _typeof(state) === 'object' && 'value' in state && 'context' in state && 'event' in state;
323
323
  }
324
324
  function toStateValue(stateValue, delimiter) {
325
325
  if (isStateLike(stateValue)) {
@@ -375,17 +375,17 @@ function toArray(value) {
375
375
  }
376
376
  return toArrayStrict(value);
377
377
  }
378
- function mapContext(mapper, context, _event) {
378
+ function mapContext(mapper, context, event) {
379
379
  if (isFunction(mapper)) {
380
380
  return mapper({
381
381
  context: context,
382
- event: _event.data
382
+ event: event
383
383
  });
384
384
  }
385
385
  var result = {};
386
386
  var args = {
387
387
  context: context,
388
- event: _event.data
388
+ event: event
389
389
  };
390
390
  for (var _i4 = 0, _Object$keys2 = Object.keys(mapper); _i4 < _Object$keys2.length; _i4++) {
391
391
  var _key3 = _Object$keys2[_i4];
@@ -438,22 +438,8 @@ function isFunction(value) {
438
438
  function isString(value) {
439
439
  return typeof value === 'string';
440
440
  }
441
- function isSCXMLEvent(event) {
442
- return '$$type' in event && event.$$type === 'scxml';
443
- }
444
- function isSCXMLErrorEvent(event) {
445
- return typeof event.name === 'string' && (event.name === errorExecution || event.name.startsWith(errorPlatform));
446
- }
447
- function toSCXMLEvent(event, scxmlEvent) {
448
- if (isSCXMLEvent(event)) {
449
- return event;
450
- }
451
- return _objectSpread2({
452
- name: event.type,
453
- data: event,
454
- $$type: 'scxml',
455
- type: 'external'
456
- }, scxmlEvent);
441
+ function isErrorEvent(event) {
442
+ return typeof event.type === 'string' && (event.type === errorExecution || event.type.startsWith(errorPlatform));
457
443
  }
458
444
  function toTransitionConfigArray(event, configLike) {
459
445
  var transitions = toArrayStrict(configLike).map(function (transitionLike) {
@@ -535,16 +521,16 @@ function isDynamicAction(action) {
535
521
  * - `delay` - The number of milliseconds to delay the sending of the event.
536
522
  * - `to` - The target of this event (by default, the machine the event was sent from).
537
523
  */
538
- function send$1(eventOrExpr, options) {
524
+ function send(eventOrExpr, options) {
539
525
  return createDynamicAction({
540
- type: send,
526
+ type: send$1,
541
527
  params: {
542
528
  to: options ? options.to : undefined,
543
529
  delay: options ? options.delay : undefined,
544
530
  event: eventOrExpr,
545
531
  id: options && options.id !== undefined ? options.id : isFunction(eventOrExpr) ? eventOrExpr.name : eventOrExpr.type
546
532
  }
547
- }, function (_event, _ref) {
533
+ }, function (event, _ref) {
548
534
  var _actorContext$self;
549
535
  var actorContext = _ref.actorContext,
550
536
  state = _ref.state;
@@ -558,15 +544,17 @@ function send$1(eventOrExpr, options) {
558
544
  };
559
545
  var args = {
560
546
  context: state.context,
561
- event: _event.data,
562
- _event: _event,
547
+ event: event,
563
548
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : null,
564
549
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
565
550
  };
566
551
  var delaysMap = state.machine.options.delays;
567
552
 
568
553
  // TODO: helper function for resolving Expr
569
- var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(args) : eventOrExpr);
554
+ if (typeof eventOrExpr === 'string') {
555
+ throw new Error("Only event objects may be used with sendTo; use sendTo({ type: \"".concat(eventOrExpr, "\" }) instead"));
556
+ }
557
+ var resolvedEvent = isFunction(eventOrExpr) ? eventOrExpr(args) : eventOrExpr;
570
558
  var resolvedDelay;
571
559
  if (isString(params.delay)) {
572
560
  var configDelay = delaysMap && delaysMap[params.delay];
@@ -595,11 +583,10 @@ function send$1(eventOrExpr, options) {
595
583
  targetActorRef = resolvedTarget || (actorContext === null || actorContext === void 0 ? void 0 : actorContext.self);
596
584
  }
597
585
  var resolvedAction = {
598
- type: send,
586
+ type: send$1,
599
587
  params: _objectSpread2(_objectSpread2({}, params), {}, {
600
588
  to: targetActorRef,
601
- _event: resolvedEvent,
602
- event: resolvedEvent.data,
589
+ event: resolvedEvent,
603
590
  delay: resolvedDelay,
604
591
  internal: resolvedTarget === SpecialTargets.Internal
605
592
  }),
@@ -610,14 +597,12 @@ function send$1(eventOrExpr, options) {
610
597
  return;
611
598
  } else {
612
599
  var target = sendAction.params.to;
613
- var _event2 = sendAction.params._event;
600
+ var sentEvent = sendAction.params.event;
614
601
  actorCtx.defer(function () {
615
- var origin = actorCtx.self;
616
- var resolvedEvent = _objectSpread2(_objectSpread2({}, _event2), {}, {
617
- name: _event2.name === error ? "".concat(error$1(origin.id)) : _event2.name,
618
- origin: origin
619
- });
620
- target.send(resolvedEvent);
602
+ target.send(sentEvent.type === error$1 ? {
603
+ type: "".concat(error(actorCtx.self.id)),
604
+ data: sentEvent.data
605
+ } : sendAction.params.event);
621
606
  });
622
607
  }
623
608
  }
@@ -633,26 +618,11 @@ function send$1(eventOrExpr, options) {
633
618
  * @param options Options to pass into the send event.
634
619
  */
635
620
  function sendParent(event, options) {
636
- return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
621
+ return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
637
622
  to: SpecialTargets.Parent
638
623
  }));
639
624
  }
640
625
 
641
- /**
642
- * Sends an event back to the sender of the original event.
643
- *
644
- * @param event The event to send back to the sender
645
- * @param options Options to pass into the send event
646
- */
647
- function respond(event, options) {
648
- return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
649
- to: function to(_ref2) {
650
- var _event = _ref2._event;
651
- return _event.origin; // TODO: handle when _event.origin is undefined
652
- }
653
- }));
654
- }
655
-
656
626
  /**
657
627
  * Forwards (sends) an event to a specified service.
658
628
  *
@@ -660,7 +630,7 @@ function respond(event, options) {
660
630
  * @param options Options to pass into the send action creator.
661
631
  */
662
632
  function forwardTo(target, options) {
663
- if (process.env.NODE_END !== 'production' && (!target || typeof target === 'function')) {
633
+ if (process.env.NODE_ENV !== 'production' && (!target || typeof target === 'function')) {
664
634
  var originalTarget = target;
665
635
  target = function target() {
666
636
  var resolvedTarget = typeof originalTarget === 'function' ? originalTarget.apply(void 0, arguments) : originalTarget;
@@ -670,8 +640,8 @@ function forwardTo(target, options) {
670
640
  return resolvedTarget;
671
641
  };
672
642
  }
673
- return send$1(function (_ref3) {
674
- var event = _ref3.event;
643
+ return send(function (_ref2) {
644
+ var event = _ref2.event;
675
645
  return event;
676
646
  }, _objectSpread2(_objectSpread2({}, options), {}, {
677
647
  to: target
@@ -688,7 +658,7 @@ function forwardTo(target, options) {
688
658
  function escalate(errorData, options) {
689
659
  return sendParent(function (arg) {
690
660
  return {
691
- type: error,
661
+ type: error$1,
692
662
  data: isFunction(errorData) ? errorData(arg) : errorData
693
663
  };
694
664
  }, _objectSpread2(_objectSpread2({}, options), {}, {
@@ -705,7 +675,7 @@ function escalate(errorData, options) {
705
675
  * @returns An XState send action object
706
676
  */
707
677
  function sendTo(actor, event, options) {
708
- return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
678
+ return send(event, _objectSpread2(_objectSpread2({}, options), {}, {
709
679
  to: actor
710
680
  }));
711
681
  }
@@ -829,11 +799,9 @@ var symbolObservable = function () {
829
799
  */
830
800
  function fromTransition(_transition, initialState) {
831
801
  var behavior = {
802
+ config: _transition,
832
803
  transition: function transition(state, event, actorContext) {
833
- // @ts-ignore TODO
834
- var resolvedEvent = isSCXMLEvent(event) ? event.data : event;
835
- // @ts-ignore TODO
836
- return _transition(state, resolvedEvent, actorContext);
804
+ return _transition(state, event, actorContext);
837
805
  },
838
806
  getInitialState: function getInitialState(_, input) {
839
807
  return typeof initialState === 'function' ? initialState({
@@ -861,27 +829,29 @@ promiseCreator) {
861
829
 
862
830
  // TODO: add event types
863
831
  var behavior = {
832
+ config: promiseCreator,
864
833
  transition: function transition(state, event) {
865
- var _event = toSCXMLEvent(event);
866
- if (state.canceled) {
834
+ if (state.status !== 'active') {
867
835
  return state;
868
836
  }
869
- var eventObject = _event.data;
870
- switch (_event.name) {
837
+ switch (event.type) {
871
838
  case resolveEventType:
872
- state.status = 'done';
873
- state.data = eventObject.data;
874
- delete state.input;
875
- return state;
839
+ return _objectSpread2(_objectSpread2({}, state), {}, {
840
+ status: 'done',
841
+ data: event.data,
842
+ input: undefined
843
+ });
876
844
  case rejectEventType:
877
- state.status = 'error';
878
- state.data = eventObject.data;
879
- delete state.input;
880
- return state;
845
+ return _objectSpread2(_objectSpread2({}, state), {}, {
846
+ status: 'error',
847
+ data: event.data,
848
+ input: undefined
849
+ });
881
850
  case stopSignalType:
882
- state.canceled = true;
883
- delete state.input;
884
- return state;
851
+ return _objectSpread2(_objectSpread2({}, state), {}, {
852
+ status: 'canceled',
853
+ input: undefined
854
+ });
885
855
  default:
886
856
  return state;
887
857
  }
@@ -897,11 +867,19 @@ promiseCreator) {
897
867
  input: state.input
898
868
  }));
899
869
  resolvedPromise.then(function (response) {
870
+ // TODO: remove this condition once dead letter queue lands
871
+ if (self._state.status !== 'active') {
872
+ return;
873
+ }
900
874
  self.send({
901
875
  type: resolveEventType,
902
876
  data: response
903
877
  });
904
878
  }, function (errorData) {
879
+ // TODO: remove this condition once dead letter queue lands
880
+ if (self._state.status !== 'active') {
881
+ return;
882
+ }
905
883
  self.send({
906
884
  type: rejectEventType,
907
885
  data: errorData
@@ -910,7 +888,6 @@ promiseCreator) {
910
888
  },
911
889
  getInitialState: function getInitialState(_, input) {
912
890
  return {
913
- canceled: false,
914
891
  status: 'active',
915
892
  data: undefined,
916
893
  input: input
@@ -940,43 +917,48 @@ function fromObservable(observableCreator) {
940
917
 
941
918
  // TODO: add event types
942
919
  var behavior = {
920
+ config: observableCreator,
943
921
  transition: function transition(state, event, _ref) {
944
922
  var self = _ref.self,
945
923
  id = _ref.id,
946
924
  defer = _ref.defer;
947
- var _event = toSCXMLEvent(event);
948
- if (state.canceled) {
925
+ if (state.status !== 'active') {
949
926
  return state;
950
927
  }
951
- switch (_event.name) {
928
+ switch (event.type) {
952
929
  case nextEventType:
953
- state.data = event.data.data;
954
930
  // match the exact timing of events sent by machines
955
931
  // send actions are not executed immediately
956
932
  defer(function () {
957
933
  var _self$_parent;
958
- (_self$_parent = self._parent) === null || _self$_parent === void 0 ? void 0 : _self$_parent.send(toSCXMLEvent({
934
+ (_self$_parent = self._parent) === null || _self$_parent === void 0 ? void 0 : _self$_parent.send({
959
935
  type: "xstate.snapshot.".concat(id),
960
- data: _event.data.data
961
- }, {
962
- origin: self
963
- }));
936
+ data: event.data
937
+ });
938
+ });
939
+ return _objectSpread2(_objectSpread2({}, state), {}, {
940
+ data: event.data
964
941
  });
965
- return state;
966
942
  case errorEventType:
967
- state.status = 'error';
968
- delete state.input;
969
- state.data = _event.data.data;
970
- return state;
943
+ return _objectSpread2(_objectSpread2({}, state), {}, {
944
+ status: 'error',
945
+ input: undefined,
946
+ data: event.data,
947
+ subscription: undefined
948
+ });
971
949
  case completeEventType:
972
- state.status = 'done';
973
- delete state.input;
974
- return state;
950
+ return _objectSpread2(_objectSpread2({}, state), {}, {
951
+ status: 'done',
952
+ input: undefined,
953
+ subscription: undefined
954
+ });
975
955
  case stopSignalType:
976
- state.canceled = true;
977
- delete state.input;
978
956
  state.subscription.unsubscribe();
979
- return state;
957
+ return _objectSpread2(_objectSpread2({}, state), {}, {
958
+ status: 'canceled',
959
+ input: undefined,
960
+ subscription: undefined
961
+ });
980
962
  default:
981
963
  return state;
982
964
  }
@@ -984,7 +966,6 @@ function fromObservable(observableCreator) {
984
966
  getInitialState: function getInitialState(_, input) {
985
967
  return {
986
968
  subscription: undefined,
987
- canceled: false,
988
969
  status: 'active',
989
970
  data: undefined,
990
971
  input: input
@@ -1022,12 +1003,10 @@ function fromObservable(observableCreator) {
1022
1003
  return state.data;
1023
1004
  },
1024
1005
  getPersistedState: function getPersistedState(_ref3) {
1025
- var canceled = _ref3.canceled,
1026
- status = _ref3.status,
1006
+ var status = _ref3.status,
1027
1007
  data = _ref3.data,
1028
1008
  input = _ref3.input;
1029
1009
  return {
1030
- canceled: canceled,
1031
1010
  status: status,
1032
1011
  data: data,
1033
1012
  input: input
@@ -1060,26 +1039,32 @@ function fromEventObservable(lazyObservable) {
1060
1039
 
1061
1040
  // TODO: event types
1062
1041
  var behavior = {
1042
+ config: lazyObservable,
1063
1043
  transition: function transition(state, event) {
1064
- var _event = toSCXMLEvent(event);
1065
- if (state.canceled) {
1044
+ if (state.status !== 'active') {
1066
1045
  return state;
1067
1046
  }
1068
- switch (_event.name) {
1047
+ switch (event.type) {
1069
1048
  case errorEventType:
1070
- state.status = 'error';
1071
- delete state.input;
1072
- state.data = _event.data.data;
1073
- return state;
1049
+ return _objectSpread2(_objectSpread2({}, state), {}, {
1050
+ status: 'error',
1051
+ input: undefined,
1052
+ data: event.data,
1053
+ subscription: undefined
1054
+ });
1074
1055
  case completeEventType:
1075
- state.status = 'done';
1076
- delete state.input;
1077
- return state;
1056
+ return _objectSpread2(_objectSpread2({}, state), {}, {
1057
+ status: 'done',
1058
+ input: undefined,
1059
+ subscription: undefined
1060
+ });
1078
1061
  case stopSignalType:
1079
- state.canceled = true;
1080
- delete state.input;
1081
1062
  state.subscription.unsubscribe();
1082
- return state;
1063
+ return _objectSpread2(_objectSpread2({}, state), {}, {
1064
+ status: 'canceled',
1065
+ input: undefined,
1066
+ subscription: undefined
1067
+ });
1083
1068
  default:
1084
1069
  return state;
1085
1070
  }
@@ -1087,7 +1072,6 @@ function fromEventObservable(lazyObservable) {
1087
1072
  getInitialState: function getInitialState() {
1088
1073
  return {
1089
1074
  subscription: undefined,
1090
- canceled: false,
1091
1075
  status: 'active',
1092
1076
  data: undefined
1093
1077
  };
@@ -1103,9 +1087,7 @@ function fromEventObservable(lazyObservable) {
1103
1087
  }).subscribe({
1104
1088
  next: function next(value) {
1105
1089
  var _self$_parent2;
1106
- (_self$_parent2 = self._parent) === null || _self$_parent2 === void 0 ? void 0 : _self$_parent2.send(toSCXMLEvent(value, {
1107
- origin: self
1108
- }));
1090
+ (_self$_parent2 = self._parent) === null || _self$_parent2 === void 0 ? void 0 : _self$_parent2.send(value);
1109
1091
  },
1110
1092
  error: function error(err) {
1111
1093
  self.send({
@@ -1124,12 +1106,10 @@ function fromEventObservable(lazyObservable) {
1124
1106
  return undefined;
1125
1107
  },
1126
1108
  getPersistedState: function getPersistedState(_ref5) {
1127
- var canceled = _ref5.canceled,
1128
- status = _ref5.status,
1109
+ var status = _ref5.status,
1129
1110
  data = _ref5.data,
1130
1111
  input = _ref5.input;
1131
1112
  return {
1132
- canceled: canceled,
1133
1113
  status: status,
1134
1114
  data: data,
1135
1115
  input: input
@@ -1149,6 +1129,7 @@ function fromEventObservable(lazyObservable) {
1149
1129
 
1150
1130
  function fromCallback(invokeCallback) {
1151
1131
  var behavior = {
1132
+ config: invokeCallback,
1152
1133
  start: function start(_state, _ref) {
1153
1134
  var self = _ref.self;
1154
1135
  self.send({
@@ -1158,16 +1139,13 @@ function fromCallback(invokeCallback) {
1158
1139
  transition: function transition(state, event, _ref2) {
1159
1140
  var self = _ref2.self,
1160
1141
  id = _ref2.id;
1161
- var _event = toSCXMLEvent(event);
1162
- if (_event.name === startSignalType) {
1142
+ if (event.type === startSignalType) {
1163
1143
  var sender = function sender(eventForParent) {
1164
1144
  var _self$_parent;
1165
1145
  if (state.canceled) {
1166
- return state;
1146
+ return;
1167
1147
  }
1168
- (_self$_parent = self._parent) === null || _self$_parent === void 0 ? void 0 : _self$_parent.send(toSCXMLEvent(eventForParent, {
1169
- origin: self
1170
- }));
1148
+ (_self$_parent = self._parent) === null || _self$_parent === void 0 ? void 0 : _self$_parent.send(eventForParent);
1171
1149
  };
1172
1150
  var receiver = function receiver(newListener) {
1173
1151
  state.receivers.add(newListener);
@@ -1178,36 +1156,30 @@ function fromCallback(invokeCallback) {
1178
1156
  if (isPromiseLike(state.dispose)) {
1179
1157
  state.dispose.then(function (resolved) {
1180
1158
  var _self$_parent2;
1181
- (_self$_parent2 = self._parent) === null || _self$_parent2 === void 0 ? void 0 : _self$_parent2.send(toSCXMLEvent(doneInvoke(id, resolved), {
1182
- origin: self
1183
- }));
1159
+ (_self$_parent2 = self._parent) === null || _self$_parent2 === void 0 ? void 0 : _self$_parent2.send(doneInvoke(id, resolved));
1184
1160
  state.canceled = true;
1185
1161
  }, function (errorData) {
1186
1162
  var _self$_parent3;
1187
- var errorEvent = error$1(id, errorData);
1188
- (_self$_parent3 = self._parent) === null || _self$_parent3 === void 0 ? void 0 : _self$_parent3.send(toSCXMLEvent(errorEvent, {
1189
- origin: self
1190
- }));
1191
1163
  state.canceled = true;
1164
+ (_self$_parent3 = self._parent) === null || _self$_parent3 === void 0 ? void 0 : _self$_parent3.send(error(id, errorData));
1192
1165
  });
1193
1166
  }
1194
1167
  return state;
1195
1168
  }
1196
- if (_event.name === stopSignalType) {
1169
+ if (event.type === stopSignalType) {
1197
1170
  state.canceled = true;
1198
1171
  if (isFunction(state.dispose)) {
1199
1172
  state.dispose();
1200
1173
  }
1201
1174
  return state;
1202
1175
  }
1203
- if (isSignal(_event.name)) {
1176
+ if (isSignal(event.type)) {
1204
1177
  // TODO: unrecognized signal
1205
1178
  return state;
1206
1179
  }
1207
- var plainEvent = isSCXMLEvent(event) ? event.data : event;
1208
- if (!isSignal(plainEvent.type)) {
1180
+ if (!isSignal(event.type)) {
1209
1181
  state.receivers.forEach(function (receiver) {
1210
- return receiver(plainEvent);
1182
+ return receiver(event);
1211
1183
  });
1212
1184
  }
1213
1185
  return state;
@@ -1278,6 +1250,12 @@ function toActorRef(actorRefLike) {
1278
1250
  return void 0;
1279
1251
  }), _objectSpread2$1), actorRefLike);
1280
1252
  }
1253
+ var emptyBehavior = fromTransition(function (_) {
1254
+ return undefined;
1255
+ }, undefined);
1256
+ function createEmptyActor() {
1257
+ return interpret(emptyBehavior);
1258
+ }
1281
1259
 
1282
1260
  function createSystem() {
1283
1261
  var sessionIdCounter = 0;
@@ -1471,9 +1449,9 @@ var Interpreter = /*#__PURE__*/function () {
1471
1449
  _step;
1472
1450
  try {
1473
1451
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1474
- var _observer2$next;
1475
- var _observer2 = _step.value;
1476
- (_observer2$next = _observer2.next) === null || _observer2$next === void 0 ? void 0 : _observer2$next.call(_observer2, snapshot);
1452
+ var _observer$next;
1453
+ var _observer = _step.value;
1454
+ (_observer$next = _observer.next) === null || _observer$next === void 0 ? void 0 : _observer$next.call(_observer, snapshot);
1477
1455
  }
1478
1456
  } catch (err) {
1479
1457
  _iterator.e(err);
@@ -1483,30 +1461,15 @@ var Interpreter = /*#__PURE__*/function () {
1483
1461
  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);
1484
1462
  switch (status === null || status === void 0 ? void 0 : status.status) {
1485
1463
  case 'done':
1486
- this._doneEvent = doneInvoke(this.id, status.data);
1487
- (_this$_parent = this._parent) === null || _this$_parent === void 0 ? void 0 : _this$_parent.send(toSCXMLEvent(this._doneEvent, {
1488
- origin: this,
1489
- invokeid: this.id
1490
- }));
1491
1464
  this._stopProcedure();
1465
+ this._doneEvent = doneInvoke(this.id, status.data);
1466
+ (_this$_parent = this._parent) === null || _this$_parent === void 0 ? void 0 : _this$_parent.send(this._doneEvent);
1467
+ this._complete();
1492
1468
  break;
1493
1469
  case 'error':
1494
- (_this$_parent2 = this._parent) === null || _this$_parent2 === void 0 ? void 0 : _this$_parent2.send(toSCXMLEvent(error$1(this.id, status.data), {
1495
- origin: this
1496
- }));
1497
- var _iterator2 = _createForOfIteratorHelper(this.observers),
1498
- _step2;
1499
- try {
1500
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1501
- var _observer$error;
1502
- var _observer = _step2.value;
1503
- (_observer$error = _observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(_observer, status.data);
1504
- }
1505
- } catch (err) {
1506
- _iterator2.e(err);
1507
- } finally {
1508
- _iterator2.f();
1509
- }
1470
+ this._stopProcedure();
1471
+ (_this$_parent2 = this._parent) === null || _this$_parent2 === void 0 ? void 0 : _this$_parent2.send(error(this.id, status.data));
1472
+ this._error(status.data);
1510
1473
  break;
1511
1474
  }
1512
1475
  }
@@ -1585,15 +1548,16 @@ var Interpreter = /*#__PURE__*/function () {
1585
1548
  try {
1586
1549
  var nextState = this.behavior.transition(this._state, event, this._actorContext);
1587
1550
  this.update(nextState);
1588
- if (event.name === stopSignalType) {
1551
+ if (event.type === stopSignalType) {
1589
1552
  this._stopProcedure();
1553
+ this._complete();
1590
1554
  }
1591
1555
  } catch (err) {
1592
1556
  // TODO: properly handle errors
1593
1557
  if (this.observers.size > 0) {
1594
1558
  this.observers.forEach(function (observer) {
1595
- var _observer$error2;
1596
- (_observer$error2 = observer.error) === null || _observer$error2 === void 0 ? void 0 : _observer$error2.call(observer, err);
1559
+ var _observer$error;
1560
+ (_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, err);
1597
1561
  });
1598
1562
  this.stop();
1599
1563
  } else {
@@ -1612,9 +1576,9 @@ var Interpreter = /*#__PURE__*/function () {
1612
1576
  this.status = ActorStatus.Stopped;
1613
1577
  return this;
1614
1578
  }
1615
- this.mailbox.enqueue(toSCXMLEvent({
1579
+ this.mailbox.enqueue({
1616
1580
  type: stopSignalType
1617
- }));
1581
+ });
1618
1582
  return this;
1619
1583
  }
1620
1584
 
@@ -1632,13 +1596,31 @@ var Interpreter = /*#__PURE__*/function () {
1632
1596
  }, {
1633
1597
  key: "_complete",
1634
1598
  value: function _complete() {
1599
+ var _iterator2 = _createForOfIteratorHelper(this.observers),
1600
+ _step2;
1601
+ try {
1602
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1603
+ var _observer2$complete;
1604
+ var _observer2 = _step2.value;
1605
+ (_observer2$complete = _observer2.complete) === null || _observer2$complete === void 0 ? void 0 : _observer2$complete.call(_observer2);
1606
+ }
1607
+ } catch (err) {
1608
+ _iterator2.e(err);
1609
+ } finally {
1610
+ _iterator2.f();
1611
+ }
1612
+ this.observers.clear();
1613
+ }
1614
+ }, {
1615
+ key: "_error",
1616
+ value: function _error(data) {
1635
1617
  var _iterator3 = _createForOfIteratorHelper(this.observers),
1636
1618
  _step3;
1637
1619
  try {
1638
1620
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1639
- var _observer3$complete;
1621
+ var _observer3$error;
1640
1622
  var _observer3 = _step3.value;
1641
- (_observer3$complete = _observer3.complete) === null || _observer3$complete === void 0 ? void 0 : _observer3$complete.call(_observer3);
1623
+ (_observer3$error = _observer3.error) === null || _observer3$error === void 0 ? void 0 : _observer3$error.call(_observer3, data);
1642
1624
  }
1643
1625
  } catch (err) {
1644
1626
  _iterator3.e(err);
@@ -1650,7 +1632,6 @@ var Interpreter = /*#__PURE__*/function () {
1650
1632
  }, {
1651
1633
  key: "_stopProcedure",
1652
1634
  value: function _stopProcedure() {
1653
- this._complete();
1654
1635
  if (this.status !== ActorStatus.Running) {
1655
1636
  // Interpreter already stopped; do nothing
1656
1637
  return this;
@@ -1682,21 +1663,23 @@ var Interpreter = /*#__PURE__*/function () {
1682
1663
  }, {
1683
1664
  key: "send",
1684
1665
  value: function send(event) {
1685
- var _event = toSCXMLEvent(event);
1666
+ if (typeof event === 'string') {
1667
+ throw new Error("Only event objects may be sent to actors; use .send({ type: \"".concat(event, "\" }) instead"));
1668
+ }
1686
1669
  if (this.status === ActorStatus.Stopped) {
1687
1670
  // do nothing
1688
1671
  if (!IS_PRODUCTION) {
1689
- var eventString = JSON.stringify(_event.data);
1690
- warn(false, "Event \"".concat(_event.name.toString(), "\" was sent to stopped actor \"").concat(this.id, " (").concat(this.sessionId, ")\". This actor has already reached its final state, and will not transition.\nEvent: ").concat(eventString));
1672
+ var eventString = JSON.stringify(event);
1673
+ warn(false, "Event \"".concat(event.type.toString(), "\" was sent to stopped actor \"").concat(this.id, " (").concat(this.sessionId, ")\". This actor has already reached its final state, and will not transition.\nEvent: ").concat(eventString));
1691
1674
  }
1692
1675
  return;
1693
1676
  }
1694
1677
  if (this.status !== ActorStatus.Running && !this.options.deferEvents) {
1695
- throw new Error("Event \"".concat(_event.name, "\" was sent to uninitialized actor \"").concat(this.id
1678
+ throw new Error("Event \"".concat(event.type, "\" was sent to uninitialized actor \"").concat(this.id
1696
1679
  // tslint:disable-next-line:max-line-length
1697
- , "\". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ").concat(JSON.stringify(_event.data)));
1680
+ , "\". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ").concat(JSON.stringify(event)));
1698
1681
  }
1699
- this.mailbox.enqueue(_event);
1682
+ this.mailbox.enqueue(event);
1700
1683
  }
1701
1684
 
1702
1685
  // TODO: make private (and figure out a way to do this within the machine)
@@ -1706,9 +1689,9 @@ var Interpreter = /*#__PURE__*/function () {
1706
1689
  var _this4 = this;
1707
1690
  this.delayedEventsMap[sendAction.params.id] = this.clock.setTimeout(function () {
1708
1691
  if ('to' in sendAction.params && sendAction.params.to) {
1709
- sendAction.params.to.send(sendAction.params._event);
1692
+ sendAction.params.to.send(sendAction.params.event);
1710
1693
  } else {
1711
- _this4.send(sendAction.params._event);
1694
+ _this4.send(sendAction.params.event);
1712
1695
  }
1713
1696
  }, sendAction.params.delay);
1714
1697
  }
@@ -1774,18 +1757,18 @@ function interpret(behavior, options) {
1774
1757
  * @param actorRef The actor to stop.
1775
1758
  */
1776
1759
 
1777
- function stop$1(actorRef) {
1760
+ function stop(actorRef) {
1778
1761
  var actor = actorRef;
1779
1762
  return createDynamicAction({
1780
- type: stop,
1763
+ type: stop$1,
1781
1764
  params: {
1782
1765
  actor: actor
1783
1766
  }
1784
- }, function (_event, _ref) {
1767
+ }, function (event, _ref) {
1785
1768
  var state = _ref.state;
1786
1769
  var actorRefOrString = isFunction(actor) ? actor({
1787
1770
  context: state.context,
1788
- event: _event.data
1771
+ event: event
1789
1772
  }) : actor;
1790
1773
  var actorRef = typeof actorRefOrString === 'string' ? state.children[actorRefOrString] : actorRefOrString;
1791
1774
  return [state, {
@@ -1827,23 +1810,22 @@ var defaultLogExpr = function defaultLogExpr(_ref) {
1827
1810
  * @param label The label to give to the logged expression.
1828
1811
  */
1829
1812
 
1830
- function log$1() {
1813
+ function log() {
1831
1814
  var expr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultLogExpr;
1832
1815
  var label = arguments.length > 1 ? arguments[1] : undefined;
1833
1816
  return createDynamicAction({
1834
- type: log,
1817
+ type: log$1,
1835
1818
  params: {
1836
1819
  label: label,
1837
1820
  expr: expr
1838
1821
  }
1839
- }, function (_event, _ref2) {
1822
+ }, function (event, _ref2) {
1840
1823
  var _actorContext$self;
1841
1824
  var state = _ref2.state,
1842
1825
  actorContext = _ref2.actorContext;
1843
1826
  var resolvedValue = typeof expr === 'function' ? expr({
1844
1827
  context: state.context,
1845
- event: _event.data,
1846
- _event: _event,
1828
+ event: event,
1847
1829
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
1848
1830
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
1849
1831
  }) : expr;
@@ -1874,20 +1856,19 @@ function log$1() {
1874
1856
  * @param sendId The `id` of the `send(...)` action to cancel.
1875
1857
  */
1876
1858
 
1877
- function cancel$1(sendId) {
1859
+ function cancel(sendId) {
1878
1860
  return createDynamicAction({
1879
- type: cancel,
1861
+ type: cancel$1,
1880
1862
  params: {
1881
1863
  sendId: sendId
1882
1864
  }
1883
- }, function (_event, _ref) {
1865
+ }, function (event, _ref) {
1884
1866
  var _actorContext$self;
1885
1867
  var state = _ref.state,
1886
1868
  actorContext = _ref.actorContext;
1887
1869
  var resolvedSendId = isFunction(sendId) ? sendId({
1888
1870
  context: state.context,
1889
- event: _event.data,
1890
- _event: _event,
1871
+ event: event,
1891
1872
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
1892
1873
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
1893
1874
  }) : sendId;
@@ -1973,9 +1954,9 @@ function not(guard) {
1973
1954
  var evaluate = _ref2.evaluate,
1974
1955
  guard = _ref2.guard,
1975
1956
  context = _ref2.context,
1976
- _event = _ref2._event,
1957
+ event = _ref2.event,
1977
1958
  state = _ref2.state;
1978
- return !evaluate(guard.children[0], context, _event, state);
1959
+ return !evaluate(guard.children[0], context, event, state);
1979
1960
  }
1980
1961
  };
1981
1962
  }
@@ -1992,10 +1973,10 @@ function and(guards) {
1992
1973
  var evaluate = _ref3.evaluate,
1993
1974
  guard = _ref3.guard,
1994
1975
  context = _ref3.context,
1995
- _event = _ref3._event,
1976
+ event = _ref3.event,
1996
1977
  state = _ref3.state;
1997
1978
  return guard.children.every(function (childGuard) {
1998
- return evaluate(childGuard, context, _event, state);
1979
+ return evaluate(childGuard, context, event, state);
1999
1980
  });
2000
1981
  }
2001
1982
  };
@@ -2013,15 +1994,15 @@ function or(guards) {
2013
1994
  var evaluate = _ref4.evaluate,
2014
1995
  guard = _ref4.guard,
2015
1996
  context = _ref4.context,
2016
- _event = _ref4._event,
1997
+ event = _ref4.event,
2017
1998
  state = _ref4.state;
2018
1999
  return guard.children.some(function (childGuard) {
2019
- return evaluate(childGuard, context, _event, state);
2000
+ return evaluate(childGuard, context, event, state);
2020
2001
  });
2021
2002
  }
2022
2003
  };
2023
2004
  }
2024
- function evaluateGuard(guard, context, _event, state) {
2005
+ function evaluateGuard(guard, context, event, state) {
2025
2006
  var _machine$options$guar, _machine$options, _machine$options$guar2;
2026
2007
  var machine = state.machine;
2027
2008
  var predicate = (_machine$options$guar = machine === null || machine === void 0 ? void 0 : (_machine$options = machine.options) === null || _machine$options === void 0 ? void 0 : (_machine$options$guar2 = _machine$options.guards) === null || _machine$options$guar2 === void 0 ? void 0 : _machine$options$guar2[guard.type]) !== null && _machine$options$guar !== void 0 ? _machine$options$guar : guard.predicate;
@@ -2030,10 +2011,9 @@ function evaluateGuard(guard, context, _event, state) {
2030
2011
  }
2031
2012
  return predicate({
2032
2013
  context: context,
2033
- event: _event.data,
2014
+ event: event,
2034
2015
  state: state,
2035
2016
  guard: guard,
2036
- _event: _event,
2037
2017
  evaluate: evaluateGuard
2038
2018
  });
2039
2019
  }
@@ -2068,13 +2048,12 @@ function toGuardDefinition(guardConfig, getPredicate) {
2068
2048
  };
2069
2049
  }
2070
2050
 
2071
- function getOutput(configuration, context, _event) {
2051
+ function getOutput(configuration, context, event) {
2072
2052
  var machine = configuration[0].machine;
2073
2053
  var finalChildStateNode = configuration.find(function (stateNode) {
2074
2054
  return stateNode.type === 'final' && stateNode.parent === machine.root;
2075
2055
  });
2076
- var doneData = finalChildStateNode && finalChildStateNode.doneData ? mapContext(finalChildStateNode.doneData, context, _event) : undefined;
2077
- return doneData;
2056
+ return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, event) : undefined;
2078
2057
  }
2079
2058
  var isAtomicStateNode = function isAtomicStateNode(stateNode) {
2080
2059
  return stateNode.type === 'atomic' || stateNode.type === 'final';
@@ -2238,7 +2217,6 @@ var isStateId = function isStateId(str) {
2238
2217
  return str[0] === STATE_IDENTIFIER;
2239
2218
  };
2240
2219
  function getCandidates(stateNode, receivedEventType) {
2241
- var partialMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2242
2220
  var candidates = stateNode.transitions.filter(function (transition) {
2243
2221
  var eventType = transition.eventType;
2244
2222
  // First, check the trivial case: event names are exactly equal
@@ -2251,7 +2229,7 @@ function getCandidates(stateNode, receivedEventType) {
2251
2229
  if (eventType === WILDCARD) {
2252
2230
  return true;
2253
2231
  }
2254
- if (!partialMatch && !eventType.endsWith('.*')) {
2232
+ if (!eventType.endsWith('.*')) {
2255
2233
  return false;
2256
2234
  }
2257
2235
  if (!IS_PRODUCTION) {
@@ -2288,13 +2266,13 @@ function getDelayedTransitions(stateNode) {
2288
2266
  }
2289
2267
  var mutateEntryExit = function mutateEntryExit(delay, i) {
2290
2268
  var delayRef = isFunction(delay) ? "".concat(stateNode.id, ":delay[").concat(i, "]") : delay;
2291
- var eventType = after$1(delayRef, stateNode.id);
2292
- stateNode.entry.push(send$1({
2269
+ var eventType = after(delayRef, stateNode.id);
2270
+ stateNode.entry.push(raise({
2293
2271
  type: eventType
2294
2272
  }, {
2295
2273
  delay: delay
2296
2274
  }));
2297
- stateNode.exit.push(cancel$1(eventType));
2275
+ stateNode.exit.push(cancel(eventType));
2298
2276
  return eventType;
2299
2277
  };
2300
2278
  var delayedTransitions = isArray(afterConfig) ? afterConfig.map(function (transition, i) {
@@ -2324,9 +2302,9 @@ function getDelayedTransitions(stateNode) {
2324
2302
  });
2325
2303
  }
2326
2304
  function formatTransition(stateNode, transitionConfig) {
2327
- var _transitionConfig$ext;
2305
+ var _transitionConfig$ree;
2328
2306
  var normalizedTarget = normalizeTarget(transitionConfig.target);
2329
- var external = (_transitionConfig$ext = transitionConfig.external) !== null && _transitionConfig$ext !== void 0 ? _transitionConfig$ext : false;
2307
+ var reenter = (_transitionConfig$ree = transitionConfig.reenter) !== null && _transitionConfig$ree !== void 0 ? _transitionConfig$ree : false;
2330
2308
  var guards = stateNode.machine.options.guards;
2331
2309
  var target = resolveTarget(stateNode, normalizedTarget);
2332
2310
 
@@ -2341,7 +2319,7 @@ function formatTransition(stateNode, transitionConfig) {
2341
2319
  }) : undefined,
2342
2320
  target: target,
2343
2321
  source: stateNode,
2344
- external: external,
2322
+ reenter: reenter,
2345
2323
  eventType: transitionConfig.event,
2346
2324
  toJSON: function toJSON() {
2347
2325
  return _objectSpread2(_objectSpread2({}, transition), {}, {
@@ -2428,7 +2406,7 @@ function formatInitialTransition(stateNode, _target) {
2428
2406
  source: stateNode,
2429
2407
  actions: [],
2430
2408
  eventType: null,
2431
- external: false,
2409
+ reenter: false,
2432
2410
  target: resolvedTarget,
2433
2411
  toJSON: function toJSON() {
2434
2412
  return _objectSpread2(_objectSpread2({}, transition), {}, {
@@ -2461,6 +2439,9 @@ function resolveTarget(stateNode, targets) {
2461
2439
  if (!isString(target)) {
2462
2440
  return target;
2463
2441
  }
2442
+ if (isStateId(target)) {
2443
+ return stateNode.machine.getStateNodeById(target);
2444
+ }
2464
2445
  var isInternalTarget = target[0] === stateNode.machine.delimiter;
2465
2446
  // If internal target is defined on machine,
2466
2447
  // do not include machine key on target
@@ -2476,7 +2457,7 @@ function resolveTarget(stateNode, targets) {
2476
2457
  throw new Error("Invalid transition definition for state node '".concat(stateNode.id, "':\n").concat(err.message));
2477
2458
  }
2478
2459
  } else {
2479
- return getStateNodeByPath(stateNode, resolvedTarget);
2460
+ throw new Error("Invalid target: \"".concat(target, "\" is not a valid target from the root node. Did you mean \".").concat(target, "\"?"));
2480
2461
  }
2481
2462
  });
2482
2463
  }
@@ -2608,24 +2589,24 @@ function getStateNodes(stateNode, state) {
2608
2589
  return allSubStateNodes.concat(subStateNodes);
2609
2590
  }, []));
2610
2591
  }
2611
- function transitionAtomicNode(stateNode, stateValue, state, _event) {
2592
+ function transitionAtomicNode(stateNode, stateValue, state, event) {
2612
2593
  var childStateNode = getStateNode(stateNode, stateValue);
2613
- var next = childStateNode.next(state, _event);
2594
+ var next = childStateNode.next(state, event);
2614
2595
  if (!next || !next.length) {
2615
- return stateNode.next(state, _event);
2596
+ return stateNode.next(state, event);
2616
2597
  }
2617
2598
  return next;
2618
2599
  }
2619
- function transitionCompoundNode(stateNode, stateValue, state, _event) {
2600
+ function transitionCompoundNode(stateNode, stateValue, state, event) {
2620
2601
  var subStateKeys = Object.keys(stateValue);
2621
2602
  var childStateNode = getStateNode(stateNode, subStateKeys[0]);
2622
- var next = transitionNode(childStateNode, stateValue[subStateKeys[0]], state, _event);
2603
+ var next = transitionNode(childStateNode, stateValue[subStateKeys[0]], state, event);
2623
2604
  if (!next || !next.length) {
2624
- return stateNode.next(state, _event);
2605
+ return stateNode.next(state, event);
2625
2606
  }
2626
2607
  return next;
2627
2608
  }
2628
- function transitionParallelNode(stateNode, stateValue, state, _event) {
2609
+ function transitionParallelNode(stateNode, stateValue, state, event) {
2629
2610
  var allInnerTransitions = [];
2630
2611
  for (var _i3 = 0, _Object$keys2 = Object.keys(stateValue); _i3 < _Object$keys2.length; _i3++) {
2631
2612
  var subStateKey = _Object$keys2[_i3];
@@ -2634,29 +2615,29 @@ function transitionParallelNode(stateNode, stateValue, state, _event) {
2634
2615
  continue;
2635
2616
  }
2636
2617
  var subStateNode = getStateNode(stateNode, subStateKey);
2637
- var innerTransitions = transitionNode(subStateNode, subStateValue, state, _event);
2618
+ var innerTransitions = transitionNode(subStateNode, subStateValue, state, event);
2638
2619
  if (innerTransitions) {
2639
2620
  allInnerTransitions.push.apply(allInnerTransitions, _toConsumableArray(innerTransitions));
2640
2621
  }
2641
2622
  }
2642
2623
  if (!allInnerTransitions.length) {
2643
- return stateNode.next(state, _event);
2624
+ return stateNode.next(state, event);
2644
2625
  }
2645
2626
  return allInnerTransitions;
2646
2627
  }
2647
- function transitionNode(stateNode, stateValue, state, _event) {
2628
+ function transitionNode(stateNode, stateValue, state, event) {
2648
2629
  // leaf node
2649
2630
  if (isString(stateValue)) {
2650
- return transitionAtomicNode(stateNode, stateValue, state, _event);
2631
+ return transitionAtomicNode(stateNode, stateValue, state, event);
2651
2632
  }
2652
2633
 
2653
2634
  // compound node
2654
2635
  if (Object.keys(stateValue).length === 1) {
2655
- return transitionCompoundNode(stateNode, stateValue, state, _event);
2636
+ return transitionCompoundNode(stateNode, stateValue, state, event);
2656
2637
  }
2657
2638
 
2658
2639
  // parallel node
2659
- return transitionParallelNode(stateNode, stateValue, state, _event);
2640
+ return transitionParallelNode(stateNode, stateValue, state, event);
2660
2641
  }
2661
2642
  function getHistoryNodes(stateNode) {
2662
2643
  return Object.keys(stateNode.states).map(function (key) {
@@ -2848,7 +2829,7 @@ function getTransitionDomain(transition, historyValue) {
2848
2829
  if (!targetStates) {
2849
2830
  return null;
2850
2831
  }
2851
- if (!transition.external && transition.source.type === 'compound' && targetStates.every(function (targetStateNode) {
2832
+ if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
2852
2833
  return isDescendant(targetStateNode, transition.source);
2853
2834
  })) {
2854
2835
  return transition.source;
@@ -2899,7 +2880,7 @@ function computeExitSet(transitions, configuration, historyValue) {
2899
2880
  * @param mutConfiguration
2900
2881
  */
2901
2882
 
2902
- function microstep(transitions, currentState, actorCtx, scxmlEvent) {
2883
+ function microstep(transitions, currentState, actorCtx, event) {
2903
2884
  var machine = currentState.machine;
2904
2885
  // Transition will "apply" if:
2905
2886
  // - the state node is the initial state (there is no current state)
@@ -2908,7 +2889,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
2908
2889
  var mutConfiguration = new Set(currentState.configuration);
2909
2890
  if (!currentState._initial && !willTransition) {
2910
2891
  var inertState = cloneState(currentState, {
2911
- _event: scxmlEvent,
2892
+ event: event,
2912
2893
  actions: [],
2913
2894
  transitions: []
2914
2895
  });
@@ -2918,11 +2899,11 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
2918
2899
  var microstate = microstepProcedure(currentState._initial ? [{
2919
2900
  target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
2920
2901
  source: machine.root,
2921
- external: true,
2902
+ reenter: true,
2922
2903
  actions: [],
2923
2904
  eventType: null,
2924
2905
  toJSON: null // TODO: fix
2925
- }] : transitions, currentState, mutConfiguration, scxmlEvent, actorCtx);
2906
+ }] : transitions, currentState, mutConfiguration, event, actorCtx);
2926
2907
  var context = microstate.context,
2927
2908
  nonRaisedActions = microstate.actions;
2928
2909
  var children = setChildren(currentState, nonRaisedActions);
@@ -2942,12 +2923,12 @@ function setChildren(currentState, nonRaisedActions) {
2942
2923
  try {
2943
2924
  for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
2944
2925
  var action = _step21.value;
2945
- if (action.type === invoke && action.params.ref) {
2926
+ if (action.type === invoke$1 && action.params.ref) {
2946
2927
  var ref = action.params.ref;
2947
2928
  if (ref) {
2948
2929
  children[ref.id] = ref;
2949
2930
  }
2950
- } else if (action.type === stop) {
2931
+ } else if (action.type === stop$1) {
2951
2932
  var _ref = action.params.actor;
2952
2933
  if (_ref) {
2953
2934
  delete children[_ref.id];
@@ -2961,8 +2942,7 @@ function setChildren(currentState, nonRaisedActions) {
2961
2942
  }
2962
2943
  return children;
2963
2944
  }
2964
- function microstepProcedure(transitions, currentState, mutConfiguration, scxmlEvent, actorCtx) {
2965
- var machine = currentState.machine;
2945
+ function microstepProcedure(transitions, currentState, mutConfiguration, event, actorCtx) {
2966
2946
  var actions = [];
2967
2947
  var historyValue = _objectSpread2({}, currentState.historyValue);
2968
2948
  var filteredTransitions = removeConflictingTransitions(transitions, mutConfiguration, historyValue);
@@ -2991,9 +2971,9 @@ function microstepProcedure(transitions, currentState, mutConfiguration, scxmlEv
2991
2971
  actions.push.apply(actions, _toConsumableArray(finalActions));
2992
2972
  }
2993
2973
  try {
2994
- var _resolveActionsAndCon = resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx),
2974
+ var _resolveActionsAndCon = resolveActionsAndContext(actions, event, currentState, actorCtx),
2995
2975
  nextState = _resolveActionsAndCon.nextState;
2996
- var output = done ? getOutput(nextConfiguration, nextState.context, scxmlEvent) : undefined;
2976
+ var output = done ? getOutput(nextConfiguration, nextState.context, event) : undefined;
2997
2977
  internalQueue.push.apply(internalQueue, _toConsumableArray(nextState._internalQueue));
2998
2978
  return cloneState(currentState, {
2999
2979
  actions: nextState.actions,
@@ -3001,7 +2981,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, scxmlEv
3001
2981
  historyValue: historyValue,
3002
2982
  _internalQueue: internalQueue,
3003
2983
  context: nextState.context,
3004
- _event: scxmlEvent,
2984
+ event: event,
3005
2985
  done: done,
3006
2986
  output: output,
3007
2987
  children: nextState.children
@@ -3009,19 +2989,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, scxmlEv
3009
2989
  } catch (e) {
3010
2990
  // TODO: Refactor this once proper error handling is implemented.
3011
2991
  // See https://github.com/statelyai/rfcs/pull/4
3012
- if (machine.config.scxml) {
3013
- return cloneState(currentState, {
3014
- actions: [],
3015
- configuration: Array.from(mutConfiguration),
3016
- historyValue: historyValue,
3017
- _internalQueue: [toSCXMLEvent({
3018
- type: 'error.execution'
3019
- })],
3020
- context: currentState.context
3021
- });
3022
- } else {
3023
- throw e;
3024
- }
2992
+ throw e;
3025
2993
  }
3026
2994
  }
3027
2995
  function enterStates(filteredTransitions, mutConfiguration, actions, internalQueue, currentState, historyValue) {
@@ -3046,7 +3014,7 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
3046
3014
  try {
3047
3015
  for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
3048
3016
  var invokeDef = _step23.value;
3049
- actions.push(invoke$1(invokeDef));
3017
+ actions.push(invoke(invokeDef));
3050
3018
  }
3051
3019
 
3052
3020
  // Add entry actions
@@ -3076,14 +3044,14 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
3076
3044
  if (!parent.parent) {
3077
3045
  continue;
3078
3046
  }
3079
- internalQueue.push(toSCXMLEvent(done(parent.id, stateNodeToEnter.doneData ? mapContext(stateNodeToEnter.doneData, currentState.context, currentState._event) : undefined)));
3047
+ internalQueue.push(done(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, currentState.event) : undefined));
3080
3048
  if (parent.parent) {
3081
3049
  var grandparent = parent.parent;
3082
3050
  if (grandparent.type === 'parallel') {
3083
3051
  if (getChildren(grandparent).every(function (parentNode) {
3084
3052
  return isInFinalState(_toConsumableArray(mutConfiguration), parentNode);
3085
3053
  })) {
3086
- internalQueue.push(toSCXMLEvent(done(grandparent.id)));
3054
+ internalQueue.push(done(grandparent.id));
3087
3055
  }
3088
3056
  }
3089
3057
  }
@@ -3356,7 +3324,7 @@ function exitStates(transitions, mutConfiguration, historyValue, actions) {
3356
3324
  for (_iterator40.s(); !(_step40 = _iterator40.n()).done;) {
3357
3325
  var s = _step40.value;
3358
3326
  actions.push.apply(actions, _toConsumableArray(s.exit.flat()).concat(_toConsumableArray(s.invoke.map(function (def) {
3359
- return stop$1(def.id);
3327
+ return stop(def.id);
3360
3328
  }))));
3361
3329
  mutConfiguration["delete"](s);
3362
3330
  }
@@ -3366,7 +3334,7 @@ function exitStates(transitions, mutConfiguration, historyValue, actions) {
3366
3334
  _iterator40.f();
3367
3335
  }
3368
3336
  }
3369
- function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3337
+ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
3370
3338
  var machine = currentState.machine;
3371
3339
  var resolvedActions = [];
3372
3340
  var raiseActions = [];
@@ -3384,7 +3352,7 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3384
3352
  var executableActionObject = resolveActionObject(actionObject, machine.options.actions);
3385
3353
  if (isDynamicAction(executableActionObject)) {
3386
3354
  var _resolvedAction$param;
3387
- var _executableActionObje = executableActionObject.resolve(scxmlEvent, {
3355
+ var _executableActionObje = executableActionObject.resolve(event, {
3388
3356
  state: intermediateState,
3389
3357
  action: actionObject,
3390
3358
  actorContext: actorCtx
@@ -3394,12 +3362,12 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3394
3362
  resolvedAction = _executableActionObje2[1];
3395
3363
  var matchedActions = (_resolvedAction$param = resolvedAction.params) === null || _resolvedAction$param === void 0 ? void 0 : _resolvedAction$param.actions;
3396
3364
  intermediateState = nextState;
3397
- if ((resolvedAction.type === raise || resolvedAction.type === send && resolvedAction.params.internal) && typeof resolvedAction.params.delay !== 'number') {
3365
+ if ((resolvedAction.type === raise$1 || resolvedAction.type === send$1 && resolvedAction.params.internal) && typeof resolvedAction.params.delay !== 'number') {
3398
3366
  raiseActions.push(resolvedAction);
3399
3367
  }
3400
3368
 
3401
3369
  // TODO: remove the check; just handleAction
3402
- if (resolvedAction.type !== pure) {
3370
+ if (resolvedAction.type !== pure$1) {
3403
3371
  handleAction(resolvedAction);
3404
3372
  }
3405
3373
  toActionObjects(matchedActions).forEach(resolveAction);
@@ -3423,21 +3391,21 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3423
3391
  nextState: cloneState(intermediateState, {
3424
3392
  actions: resolvedActions,
3425
3393
  _internalQueue: raiseActions.map(function (a) {
3426
- return a.params._event;
3394
+ return a.params.event;
3427
3395
  })
3428
3396
  })
3429
3397
  };
3430
3398
  }
3431
- function macrostep(state, scxmlEvent, actorCtx) {
3432
- if (!IS_PRODUCTION && scxmlEvent.name === WILDCARD) {
3399
+ function macrostep(state, event, actorCtx) {
3400
+ if (!IS_PRODUCTION && event.type === WILDCARD) {
3433
3401
  throw new Error("An event cannot have the wildcard type ('".concat(WILDCARD, "')"));
3434
3402
  }
3435
3403
  var nextState = state;
3436
3404
  var states = [];
3437
3405
 
3438
3406
  // Handle stop event
3439
- if ((scxmlEvent === null || scxmlEvent === void 0 ? void 0 : scxmlEvent.name) === stopSignalType) {
3440
- nextState = stopStep(scxmlEvent, nextState, actorCtx);
3407
+ if (event.type === stopSignalType) {
3408
+ nextState = stopStep(event, nextState, actorCtx);
3441
3409
  states.push(nextState);
3442
3410
  return {
3443
3411
  state: nextState,
@@ -3447,9 +3415,9 @@ function macrostep(state, scxmlEvent, actorCtx) {
3447
3415
 
3448
3416
  // Assume the state is at rest (no raised events)
3449
3417
  // Determine the next state based on the next microstep
3450
- if (scxmlEvent.name !== init) {
3451
- var transitions = selectTransitions(scxmlEvent, nextState);
3452
- nextState = microstep(transitions, state, actorCtx, scxmlEvent);
3418
+ if (event.type !== init) {
3419
+ var transitions = selectTransitions(event, nextState);
3420
+ nextState = microstep(transitions, state, actorCtx, event);
3453
3421
  states.push(nextState);
3454
3422
  }
3455
3423
  while (!nextState.done) {
@@ -3481,21 +3449,21 @@ function macrostep(state, scxmlEvent, actorCtx) {
3481
3449
  if (enabledTransitions.length) {
3482
3450
  var _nextState$actions2;
3483
3451
  var _currentActions = nextState.actions;
3484
- nextState = microstep(enabledTransitions, nextState, actorCtx, nextState._event);
3452
+ nextState = microstep(enabledTransitions, nextState, actorCtx, nextState.event);
3485
3453
  (_nextState$actions2 = nextState.actions).unshift.apply(_nextState$actions2, _toConsumableArray(_currentActions));
3486
3454
  states.push(nextState);
3487
3455
  }
3488
3456
  }
3489
3457
  if (nextState.done) {
3490
3458
  // Perform the stop step to ensure that child actors are stopped
3491
- stopStep(nextState._event, nextState, actorCtx);
3459
+ stopStep(nextState.event, nextState, actorCtx);
3492
3460
  }
3493
3461
  return {
3494
3462
  state: nextState,
3495
3463
  microstates: states
3496
3464
  };
3497
3465
  }
3498
- function stopStep(scxmlEvent, nextState, actorCtx) {
3466
+ function stopStep(event, nextState, actorCtx) {
3499
3467
  var actions = [];
3500
3468
  var _iterator43 = _createForOfIteratorHelper(nextState.configuration.sort(function (a, b) {
3501
3469
  return b.order - a.order;
@@ -3513,14 +3481,14 @@ function stopStep(scxmlEvent, nextState, actorCtx) {
3513
3481
  }
3514
3482
  for (var _i4 = 0, _Object$values = Object.values(nextState.children); _i4 < _Object$values.length; _i4++) {
3515
3483
  var child = _Object$values[_i4];
3516
- actions.push(stop$1(child));
3484
+ actions.push(stop(child));
3517
3485
  }
3518
- var _resolveActionsAndCon2 = resolveActionsAndContext(actions, scxmlEvent, nextState, actorCtx),
3486
+ var _resolveActionsAndCon2 = resolveActionsAndContext(actions, event, nextState, actorCtx),
3519
3487
  stoppedState = _resolveActionsAndCon2.nextState;
3520
3488
  return stoppedState;
3521
3489
  }
3522
- function selectTransitions(scxmlEvent, nextState) {
3523
- return nextState.machine.getTransitionData(nextState, scxmlEvent);
3490
+ function selectTransitions(event, nextState) {
3491
+ return nextState.machine.getTransitionData(nextState, event);
3524
3492
  }
3525
3493
  function selectEventlessTransitions(nextState) {
3526
3494
  var enabledTransitionSet = new Set();
@@ -3543,7 +3511,7 @@ function selectEventlessTransitions(nextState) {
3543
3511
  try {
3544
3512
  for (_iterator46.s(); !(_step46 = _iterator46.n()).done;) {
3545
3513
  var transition = _step46.value;
3546
- if (transition.guard === undefined || evaluateGuard(transition.guard, nextState.context, nextState._event, nextState)) {
3514
+ if (transition.guard === undefined || evaluateGuard(transition.guard, nextState.context, nextState.event, nextState)) {
3547
3515
  enabledTransitionSet.add(transition);
3548
3516
  break loop;
3549
3517
  }
@@ -3637,16 +3605,14 @@ var State = /*#__PURE__*/function () {
3637
3605
  _defineProperty(this, "actions", []);
3638
3606
  _defineProperty(this, "event", void 0);
3639
3607
  _defineProperty(this, "_internalQueue", void 0);
3640
- _defineProperty(this, "_event", void 0);
3641
3608
  _defineProperty(this, "_initial", false);
3642
3609
  _defineProperty(this, "changed", void 0);
3643
3610
  _defineProperty(this, "configuration", void 0);
3644
3611
  _defineProperty(this, "transitions", void 0);
3645
3612
  _defineProperty(this, "children", void 0);
3646
3613
  this.context = config.context;
3647
- this._event = config._event;
3648
3614
  this._internalQueue = (_config$_internalQueu = config._internalQueue) !== null && _config$_internalQueu !== void 0 ? _config$_internalQueu : [];
3649
- this.event = this._event.data;
3615
+ this.event = config.event;
3650
3616
  this.historyValue = config.historyValue || {};
3651
3617
  this.actions = (_config$actions = config.actions) !== null && _config$actions !== void 0 ? _config$actions : [];
3652
3618
  this.matches = this.matches.bind(this);
@@ -3686,11 +3652,11 @@ var State = /*#__PURE__*/function () {
3686
3652
  }, {
3687
3653
  key: "toJSON",
3688
3654
  value: function toJSON() {
3689
- var configuration = this.configuration,
3690
- transitions = this.transitions,
3691
- tags = this.tags,
3692
- machine = this.machine,
3693
- jsonValues = _objectWithoutProperties(this, _excluded);
3655
+ this.configuration;
3656
+ this.transitions;
3657
+ var tags = this.tags;
3658
+ this.machine;
3659
+ var jsonValues = _objectWithoutProperties(this, _excluded);
3694
3660
  return _objectSpread2(_objectSpread2({}, jsonValues), {}, {
3695
3661
  tags: Array.from(tags),
3696
3662
  meta: this.meta
@@ -3731,7 +3697,7 @@ var State = /*#__PURE__*/function () {
3731
3697
  if (IS_PRODUCTION) {
3732
3698
  warn(!!this.machine, "state.can(...) used outside of a machine-created State object; this will always return false.");
3733
3699
  }
3734
- var transitionData = this.machine.getTransitionData(this, toSCXMLEvent(event));
3700
+ var transitionData = this.machine.getTransitionData(this, event);
3735
3701
  return !!(transitionData !== null && transitionData !== void 0 && transitionData.length) &&
3736
3702
  // Check that at least one transition is not forbidden
3737
3703
  transitionData.some(function (t) {
@@ -3808,7 +3774,7 @@ var State = /*#__PURE__*/function () {
3808
3774
  return new State({
3809
3775
  value: stateValue.value,
3810
3776
  context: context,
3811
- _event: stateValue._event,
3777
+ event: stateValue.event,
3812
3778
  actions: [],
3813
3779
  meta: {},
3814
3780
  configuration: [],
@@ -3819,13 +3785,13 @@ var State = /*#__PURE__*/function () {
3819
3785
  }
3820
3786
  return stateValue;
3821
3787
  }
3822
- var _event = createInitEvent({}); // TODO: fix
3788
+ var event = createInitEvent({}); // TODO: fix
3823
3789
 
3824
3790
  var configuration = getConfiguration(getStateNodes(machine.root, stateValue));
3825
3791
  return new State({
3826
3792
  value: stateValue,
3827
3793
  context: context,
3828
- _event: _event,
3794
+ event: event,
3829
3795
  actions: [],
3830
3796
  meta: undefined,
3831
3797
  configuration: Array.from(configuration),
@@ -3841,11 +3807,11 @@ function cloneState(state) {
3841
3807
  return new State(_objectSpread2(_objectSpread2({}, state), config), state.machine);
3842
3808
  }
3843
3809
  function getPersistedState(state) {
3844
- var configuration = state.configuration,
3845
- transitions = state.transitions,
3846
- tags = state.tags,
3847
- machine = state.machine,
3848
- children = state.children,
3810
+ state.configuration;
3811
+ state.transitions;
3812
+ state.tags;
3813
+ state.machine;
3814
+ var children = state.children,
3849
3815
  jsonValues = _objectWithoutProperties(state, _excluded2);
3850
3816
  var childrenJson = {};
3851
3817
  for (var id in children) {
@@ -3860,14 +3826,14 @@ function getPersistedState(state) {
3860
3826
  });
3861
3827
  }
3862
3828
 
3863
- function invoke$1(invokeDef) {
3829
+ function invoke(invokeDef) {
3864
3830
  return createDynamicAction({
3865
- type: invoke,
3831
+ type: invoke$1,
3866
3832
  params: invokeDef
3867
- }, function (_event, _ref) {
3833
+ }, function (event, _ref) {
3868
3834
  var state = _ref.state,
3869
3835
  actorContext = _ref.actorContext;
3870
- var type = invoke;
3836
+ var type = invoke$1;
3871
3837
  var id = invokeDef.id,
3872
3838
  src = invokeDef.src;
3873
3839
  var resolvedInvokeAction;
@@ -3894,7 +3860,7 @@ function invoke$1(invokeDef) {
3894
3860
  systemId: invokeDef.systemId,
3895
3861
  input: typeof input === 'function' ? input({
3896
3862
  context: state.context,
3897
- event: _event.data,
3863
+ event: event,
3898
3864
  self: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self
3899
3865
  }) : input
3900
3866
  });
@@ -3929,7 +3895,7 @@ function invoke$1(invokeDef) {
3929
3895
  var _actorRef$start;
3930
3896
  (_actorRef$start = actorRef.start) === null || _actorRef$start === void 0 ? void 0 : _actorRef$start.call(actorRef);
3931
3897
  } catch (err) {
3932
- parent.send(error$1(id, err));
3898
+ parent.send(error(id, err));
3933
3899
  return;
3934
3900
  }
3935
3901
  });
@@ -3938,7 +3904,7 @@ function invoke$1(invokeDef) {
3938
3904
  });
3939
3905
  }
3940
3906
 
3941
- function createSpawner(self, machine, context, _event, mutCapturedActions) {
3907
+ function createSpawner(self, machine, context, event, mutCapturedActions) {
3942
3908
  return function (src) {
3943
3909
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3944
3910
  if (isString(src)) {
@@ -3954,11 +3920,11 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3954
3920
  parent: self,
3955
3921
  input: typeof input === 'function' ? input({
3956
3922
  context: context,
3957
- event: _event.data,
3923
+ event: event,
3958
3924
  self: self
3959
3925
  }) : input
3960
3926
  });
3961
- mutCapturedActions.push(invoke$1({
3927
+ mutCapturedActions.push(invoke({
3962
3928
  id: actorRef.id,
3963
3929
  // @ts-ignore TODO: fix types
3964
3930
  src: actorRef,
@@ -3979,7 +3945,7 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3979
3945
  parent: self,
3980
3946
  input: options.input
3981
3947
  });
3982
- mutCapturedActions.push(invoke$1({
3948
+ mutCapturedActions.push(invoke({
3983
3949
  // @ts-ignore TODO: fix types
3984
3950
  src: _actorRef,
3985
3951
  ref: _actorRef,
@@ -3997,13 +3963,13 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3997
3963
  *
3998
3964
  * @param assignment An object that represents the partial context to update.
3999
3965
  */
4000
- function assign$1(assignment) {
3966
+ function assign(assignment) {
4001
3967
  return createDynamicAction({
4002
- type: assign,
3968
+ type: assign$1,
4003
3969
  params: {
4004
3970
  assignment: assignment
4005
3971
  }
4006
- }, function (_event, _ref) {
3972
+ }, function (event, _ref) {
4007
3973
  var _actorContext$self;
4008
3974
  var state = _ref.state,
4009
3975
  action = _ref.action,
@@ -4014,10 +3980,9 @@ function assign$1(assignment) {
4014
3980
  }
4015
3981
  var args = {
4016
3982
  context: state.context,
4017
- event: _event.data,
3983
+ event: event,
4018
3984
  action: action,
4019
- _event: _event,
4020
- spawn: createSpawner(actorContext === null || actorContext === void 0 ? void 0 : actorContext.self, state.machine, state.context, _event, capturedActions),
3985
+ spawn: createSpawner(actorContext === null || actorContext === void 0 ? void 0 : actorContext.self, state.machine, state.context, event, capturedActions),
4021
3986
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
4022
3987
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
4023
3988
  };
@@ -4035,7 +4000,7 @@ function assign$1(assignment) {
4035
4000
  return [cloneState(state, {
4036
4001
  context: updatedContext
4037
4002
  }), {
4038
- type: assign,
4003
+ type: assign$1,
4039
4004
  params: {
4040
4005
  context: updatedContext,
4041
4006
  actions: capturedActions
@@ -4051,15 +4016,15 @@ function assign$1(assignment) {
4051
4016
  * @param eventType The event to raise.
4052
4017
  */
4053
4018
 
4054
- function raise$1(eventOrExpr, options) {
4019
+ function raise(eventOrExpr, options) {
4055
4020
  return createDynamicAction({
4056
- type: raise,
4021
+ type: raise$1,
4057
4022
  params: {
4058
4023
  delay: options ? options.delay : undefined,
4059
4024
  event: eventOrExpr,
4060
4025
  id: options && options.id !== undefined ? options.id : typeof eventOrExpr === 'function' ? eventOrExpr.name : eventOrExpr.type
4061
4026
  }
4062
- }, function (_event, _ref) {
4027
+ }, function (event, _ref) {
4063
4028
  var _actorContext$self;
4064
4029
  var state = _ref.state,
4065
4030
  actorContext = _ref.actorContext;
@@ -4070,15 +4035,17 @@ function raise$1(eventOrExpr, options) {
4070
4035
  };
4071
4036
  var args = {
4072
4037
  context: state.context,
4073
- event: _event.data,
4074
- _event: _event,
4038
+ event: event,
4075
4039
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
4076
4040
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
4077
4041
  };
4078
4042
  var delaysMap = state.machine.options.delays;
4079
4043
 
4080
4044
  // TODO: helper function for resolving Expr
4081
- var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr);
4045
+ if (typeof eventOrExpr === 'string') {
4046
+ throw new Error("Only event objects may be used with raise; use raise({ type: \"".concat(eventOrExpr, "\" }) instead"));
4047
+ }
4048
+ var resolvedEvent = typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr;
4082
4049
  var resolvedDelay;
4083
4050
  if (typeof params.delay === 'string') {
4084
4051
  var configDelay = delaysMap && delaysMap[params.delay];
@@ -4087,10 +4054,9 @@ function raise$1(eventOrExpr, options) {
4087
4054
  resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
4088
4055
  }
4089
4056
  var resolvedAction = {
4090
- type: raise,
4057
+ type: raise$1,
4091
4058
  params: _objectSpread2(_objectSpread2({}, params), {}, {
4092
- _event: resolvedEvent,
4093
- event: resolvedEvent.data,
4059
+ event: resolvedEvent,
4094
4060
  delay: resolvedDelay
4095
4061
  }),
4096
4062
  execute: function execute(actorCtx) {
@@ -4104,23 +4070,23 @@ function raise$1(eventOrExpr, options) {
4104
4070
  });
4105
4071
  }
4106
4072
 
4107
- function choose$1(guards) {
4073
+ function choose(guards) {
4108
4074
  return createDynamicAction({
4109
- type: choose,
4075
+ type: choose$1,
4110
4076
  params: {
4111
4077
  guards: guards
4112
4078
  }
4113
- }, function (_event, _ref) {
4079
+ }, function (event, _ref) {
4114
4080
  var _guards$find;
4115
4081
  var state = _ref.state;
4116
4082
  var matchedActions = (_guards$find = guards.find(function (condition) {
4117
4083
  var guard = condition.guard && toGuardDefinition(condition.guard, function (guardType) {
4118
4084
  return state.machine.options.guards[guardType];
4119
4085
  });
4120
- return !guard || evaluateGuard(guard, state.context, _event, state);
4086
+ return !guard || evaluateGuard(guard, state.context, event, state);
4121
4087
  })) === null || _guards$find === void 0 ? void 0 : _guards$find.actions;
4122
4088
  return [state, {
4123
- type: choose,
4089
+ type: choose$1,
4124
4090
  params: {
4125
4091
  actions: toActionObjects(matchedActions)
4126
4092
  }
@@ -4128,9 +4094,30 @@ function choose$1(guards) {
4128
4094
  });
4129
4095
  }
4130
4096
 
4131
- var initEvent = toSCXMLEvent({
4097
+ function pure(getActions) {
4098
+ return createDynamicAction({
4099
+ type: pure$1,
4100
+ params: {
4101
+ get: getActions
4102
+ }
4103
+ }, function (event, _ref) {
4104
+ var _toArray;
4105
+ var state = _ref.state;
4106
+ return [state, {
4107
+ type: pure$1,
4108
+ params: {
4109
+ actions: (_toArray = toArray(toActionObjects(getActions({
4110
+ context: state.context,
4111
+ event: event
4112
+ })))) !== null && _toArray !== void 0 ? _toArray : []
4113
+ }
4114
+ }];
4115
+ });
4116
+ }
4117
+
4118
+ var initEvent = {
4132
4119
  type: init
4133
- });
4120
+ };
4134
4121
  function resolveActionObject(actionObject, actionFunctionMap) {
4135
4122
  if (isDynamicAction(actionObject)) {
4136
4123
  return actionObject;
@@ -4141,7 +4128,7 @@ function resolveActionObject(actionObject, actionFunctionMap) {
4141
4128
  return createDynamicAction({
4142
4129
  type: 'xstate.function',
4143
4130
  params: (_actionObject$params = actionObject.params) !== null && _actionObject$params !== void 0 ? _actionObject$params : {}
4144
- }, function (_event, _ref) {
4131
+ }, function (event, _ref) {
4145
4132
  var state = _ref.state;
4146
4133
  var a = {
4147
4134
  type: actionObject.type,
@@ -4149,9 +4136,8 @@ function resolveActionObject(actionObject, actionFunctionMap) {
4149
4136
  execute: function execute(actorCtx) {
4150
4137
  return dereferencedAction({
4151
4138
  context: state.context,
4152
- event: state.event,
4139
+ event: event,
4153
4140
  action: a,
4154
- _event: state._event,
4155
4141
  system: actorCtx.system,
4156
4142
  self: actorCtx.self
4157
4143
  });
@@ -4180,7 +4166,7 @@ function toActionObject(action) {
4180
4166
  return createDynamicAction({
4181
4167
  type: type,
4182
4168
  params: {}
4183
- }, function (_event, _ref2) {
4169
+ }, function (event, _ref2) {
4184
4170
  var state = _ref2.state;
4185
4171
  var actionObject = {
4186
4172
  type: type,
@@ -4190,9 +4176,8 @@ function toActionObject(action) {
4190
4176
  execute: function execute(actorCtx) {
4191
4177
  return action({
4192
4178
  context: state.context,
4193
- event: _event.data,
4179
+ event: event,
4194
4180
  action: actionObject,
4195
- _event: _event,
4196
4181
  self: actorCtx.self,
4197
4182
  system: actorCtx.system
4198
4183
  });
@@ -4220,7 +4205,7 @@ var toActionObjects = function toActionObjects(action) {
4220
4205
  * @param delayRef The delay in milliseconds
4221
4206
  * @param id The state node ID where this event is handled
4222
4207
  */
4223
- function after$1(delayRef, id) {
4208
+ function after(delayRef, id) {
4224
4209
  var idSuffix = id ? "#".concat(id) : '';
4225
4210
  return "".concat(ActionTypes.After, "(").concat(delayRef, ")").concat(idSuffix);
4226
4211
  }
@@ -4230,13 +4215,13 @@ function after$1(delayRef, id) {
4230
4215
  * has been reached in the parent state node.
4231
4216
  *
4232
4217
  * @param id The final state node's parent state node `id`
4233
- * @param data The data to pass into the event
4218
+ * @param output The data to pass into the event
4234
4219
  */
4235
- function done(id, data) {
4220
+ function done(id, output) {
4236
4221
  var type = "".concat(ActionTypes.DoneState, ".").concat(id);
4237
4222
  var eventObject = {
4238
4223
  type: type,
4239
- data: data
4224
+ output: output
4240
4225
  };
4241
4226
  eventObject.toString = function () {
4242
4227
  return type;
@@ -4251,20 +4236,20 @@ function done(id, data) {
4251
4236
  * but not when it is canceled.
4252
4237
  *
4253
4238
  * @param invokeId The invoked service ID
4254
- * @param data The data to pass into the event
4239
+ * @param output The data to pass into the event
4255
4240
  */
4256
- function doneInvoke(invokeId, data) {
4241
+ function doneInvoke(invokeId, output) {
4257
4242
  var type = "".concat(ActionTypes.DoneInvoke, ".").concat(invokeId);
4258
4243
  var eventObject = {
4259
4244
  type: type,
4260
- data: data
4245
+ output: output
4261
4246
  };
4262
4247
  eventObject.toString = function () {
4263
4248
  return type;
4264
4249
  };
4265
4250
  return eventObject;
4266
4251
  }
4267
- function error$1(id, data) {
4252
+ function error(id, data) {
4268
4253
  var type = "".concat(ActionTypes.ErrorPlatform, ".").concat(id);
4269
4254
  var eventObject = {
4270
4255
  type: type,
@@ -4276,10 +4261,10 @@ function error$1(id, data) {
4276
4261
  return eventObject;
4277
4262
  }
4278
4263
  function createInitEvent(input) {
4279
- return toSCXMLEvent({
4264
+ return {
4280
4265
  type: init,
4281
4266
  input: input
4282
- });
4267
+ };
4283
4268
  }
4284
4269
 
4285
- export { log$1 as $, getConfiguration as A, getStateNodes as B, resolveStateValue as C, isInFinalState as D, toSCXMLEvent as E, isSCXMLErrorEvent as F, macrostep as G, transitionNode as H, _slicedToArray as I, getInitialConfiguration as J, resolveActionsAndContext as K, microstep as L, error$1 as M, NULL_EVENT as N, isStateId as O, getPersistedState as P, resolveReferencedActor as Q, interpret as R, State as S, STATE_DELIMITER as T, initEvent as U, matchesState as V, raise$1 as W, send$1 as X, sendParent as Y, sendTo as Z, _createClass as _, toActionObjects as a, cancel$1 as a0, stop$1 as a1, assign$1 as a2, after$1 as a3, done as a4, respond as a5, forwardTo as a6, escalate as a7, choose$1 as a8, Interpreter as a9, ActorStatus as aa, doneInvoke as ab, pathToStateValue as ac, toObserver as ad, ActionTypes as ae, SpecialTargets as af, startSignalType as ag, stopSignalType as ah, startSignal as ai, stopSignal as aj, isSignal as ak, isActorRef as al, toActorRef as am, fromTransition as an, fromPromise as ao, fromObservable as ap, fromEventObservable as aq, fromCallback as ar, stateIn as as, not as at, and as au, or as av, toGuardDefinition as aw, actionTypes as ax, resolveActionObject as ay, toActionObject as az, toTransitionConfigArray as b, createDynamicAction as c, formatTransition as d, memo as e, formatTransitions as f, _createForOfIteratorHelper as g, evaluateGuard as h, _toConsumableArray as i, flatten as j, _classCallCheck as k, _defineProperty as l, mapValues as m, createInvokeId as n, toInvokeConfig as o, pure as p, _objectSpread2 as q, invoke as r, _objectWithoutProperties as s, toArray as t, getDelayedTransitions as u, formatInitialTransition as v, getCandidates as w, isString as x, createSpawner as y, createInitEvent as z };
4270
+ export { assign as $, isInFinalState as A, isErrorEvent as B, macrostep as C, transitionNode as D, _slicedToArray as E, getInitialConfiguration as F, createInitEvent as G, resolveActionsAndContext as H, microstep as I, error as J, isStateId as K, getStateNodeByPath as L, getPersistedState as M, NULL_EVENT as N, resolveReferencedActor as O, interpret as P, STATE_DELIMITER as Q, initEvent as R, State as S, matchesState as T, sendTo as U, sendParent as V, forwardTo as W, Interpreter as X, ActorStatus as Y, doneInvoke as Z, _createClass as _, formatTransition as a, cancel as a0, choose as a1, log as a2, pure as a3, raise as a4, stop as a5, pathToStateValue as a6, toObserver as a7, fromPromise as a8, fromObservable as a9, fromCallback as aa, fromEventObservable as ab, fromTransition as ac, stateIn as ad, not as ae, and as af, or as ag, ActionTypes as ah, SpecialTargets as ai, startSignalType as aj, stopSignalType as ak, startSignal as al, stopSignal as am, isSignal as an, isActorRef as ao, toActorRef as ap, createEmptyActor as aq, toGuardDefinition as ar, actionTypes as as, resolveActionObject as at, toActionObject as au, after as av, done as aw, send as ax, escalate as ay, 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, getConfiguration as x, getStateNodes as y, resolveStateValue as z };