xstate 5.0.0-alpha.6 → 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-bf7bb1c5.cjs.dev.js → actions-109712d3.cjs.dev.js} +386 -371
  29. package/dist/{actions-41b74cdc.esm.js → actions-67f1d04e.esm.js} +341 -358
  30. package/dist/{actions-c46e4911.cjs.prod.js → actions-d0262a43.cjs.prod.js} +409 -380
  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 +3 -9
  34. package/dist/declarations/src/actions/send.d.ts +0 -7
  35. package/dist/declarations/src/actions.d.ts +9 -8
  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 +9 -14
  44. package/dist/declarations/src/typegenTypes.d.ts +7 -1
  45. package/dist/declarations/src/types.d.ts +18 -92
  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 +117 -105
  54. package/dist/xstate.cjs.mjs +38 -0
  55. package/dist/xstate.cjs.prod.js +115 -106
  56. package/dist/xstate.esm.js +100 -93
  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,12 +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
- return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, _event) : undefined;
2056
+ return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, event) : undefined;
2077
2057
  }
2078
2058
  var isAtomicStateNode = function isAtomicStateNode(stateNode) {
2079
2059
  return stateNode.type === 'atomic' || stateNode.type === 'final';
@@ -2237,7 +2217,6 @@ var isStateId = function isStateId(str) {
2237
2217
  return str[0] === STATE_IDENTIFIER;
2238
2218
  };
2239
2219
  function getCandidates(stateNode, receivedEventType) {
2240
- var partialMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2241
2220
  var candidates = stateNode.transitions.filter(function (transition) {
2242
2221
  var eventType = transition.eventType;
2243
2222
  // First, check the trivial case: event names are exactly equal
@@ -2250,7 +2229,7 @@ function getCandidates(stateNode, receivedEventType) {
2250
2229
  if (eventType === WILDCARD) {
2251
2230
  return true;
2252
2231
  }
2253
- if (!partialMatch && !eventType.endsWith('.*')) {
2232
+ if (!eventType.endsWith('.*')) {
2254
2233
  return false;
2255
2234
  }
2256
2235
  if (!IS_PRODUCTION) {
@@ -2287,13 +2266,13 @@ function getDelayedTransitions(stateNode) {
2287
2266
  }
2288
2267
  var mutateEntryExit = function mutateEntryExit(delay, i) {
2289
2268
  var delayRef = isFunction(delay) ? "".concat(stateNode.id, ":delay[").concat(i, "]") : delay;
2290
- var eventType = after$1(delayRef, stateNode.id);
2291
- stateNode.entry.push(send$1({
2269
+ var eventType = after(delayRef, stateNode.id);
2270
+ stateNode.entry.push(raise({
2292
2271
  type: eventType
2293
2272
  }, {
2294
2273
  delay: delay
2295
2274
  }));
2296
- stateNode.exit.push(cancel$1(eventType));
2275
+ stateNode.exit.push(cancel(eventType));
2297
2276
  return eventType;
2298
2277
  };
2299
2278
  var delayedTransitions = isArray(afterConfig) ? afterConfig.map(function (transition, i) {
@@ -2323,9 +2302,9 @@ function getDelayedTransitions(stateNode) {
2323
2302
  });
2324
2303
  }
2325
2304
  function formatTransition(stateNode, transitionConfig) {
2326
- var _transitionConfig$ext;
2305
+ var _transitionConfig$ree;
2327
2306
  var normalizedTarget = normalizeTarget(transitionConfig.target);
2328
- 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;
2329
2308
  var guards = stateNode.machine.options.guards;
2330
2309
  var target = resolveTarget(stateNode, normalizedTarget);
2331
2310
 
@@ -2340,7 +2319,7 @@ function formatTransition(stateNode, transitionConfig) {
2340
2319
  }) : undefined,
2341
2320
  target: target,
2342
2321
  source: stateNode,
2343
- external: external,
2322
+ reenter: reenter,
2344
2323
  eventType: transitionConfig.event,
2345
2324
  toJSON: function toJSON() {
2346
2325
  return _objectSpread2(_objectSpread2({}, transition), {}, {
@@ -2427,7 +2406,7 @@ function formatInitialTransition(stateNode, _target) {
2427
2406
  source: stateNode,
2428
2407
  actions: [],
2429
2408
  eventType: null,
2430
- external: false,
2409
+ reenter: false,
2431
2410
  target: resolvedTarget,
2432
2411
  toJSON: function toJSON() {
2433
2412
  return _objectSpread2(_objectSpread2({}, transition), {}, {
@@ -2610,24 +2589,24 @@ function getStateNodes(stateNode, state) {
2610
2589
  return allSubStateNodes.concat(subStateNodes);
2611
2590
  }, []));
2612
2591
  }
2613
- function transitionAtomicNode(stateNode, stateValue, state, _event) {
2592
+ function transitionAtomicNode(stateNode, stateValue, state, event) {
2614
2593
  var childStateNode = getStateNode(stateNode, stateValue);
2615
- var next = childStateNode.next(state, _event);
2594
+ var next = childStateNode.next(state, event);
2616
2595
  if (!next || !next.length) {
2617
- return stateNode.next(state, _event);
2596
+ return stateNode.next(state, event);
2618
2597
  }
2619
2598
  return next;
2620
2599
  }
2621
- function transitionCompoundNode(stateNode, stateValue, state, _event) {
2600
+ function transitionCompoundNode(stateNode, stateValue, state, event) {
2622
2601
  var subStateKeys = Object.keys(stateValue);
2623
2602
  var childStateNode = getStateNode(stateNode, subStateKeys[0]);
2624
- var next = transitionNode(childStateNode, stateValue[subStateKeys[0]], state, _event);
2603
+ var next = transitionNode(childStateNode, stateValue[subStateKeys[0]], state, event);
2625
2604
  if (!next || !next.length) {
2626
- return stateNode.next(state, _event);
2605
+ return stateNode.next(state, event);
2627
2606
  }
2628
2607
  return next;
2629
2608
  }
2630
- function transitionParallelNode(stateNode, stateValue, state, _event) {
2609
+ function transitionParallelNode(stateNode, stateValue, state, event) {
2631
2610
  var allInnerTransitions = [];
2632
2611
  for (var _i3 = 0, _Object$keys2 = Object.keys(stateValue); _i3 < _Object$keys2.length; _i3++) {
2633
2612
  var subStateKey = _Object$keys2[_i3];
@@ -2636,29 +2615,29 @@ function transitionParallelNode(stateNode, stateValue, state, _event) {
2636
2615
  continue;
2637
2616
  }
2638
2617
  var subStateNode = getStateNode(stateNode, subStateKey);
2639
- var innerTransitions = transitionNode(subStateNode, subStateValue, state, _event);
2618
+ var innerTransitions = transitionNode(subStateNode, subStateValue, state, event);
2640
2619
  if (innerTransitions) {
2641
2620
  allInnerTransitions.push.apply(allInnerTransitions, _toConsumableArray(innerTransitions));
2642
2621
  }
2643
2622
  }
2644
2623
  if (!allInnerTransitions.length) {
2645
- return stateNode.next(state, _event);
2624
+ return stateNode.next(state, event);
2646
2625
  }
2647
2626
  return allInnerTransitions;
2648
2627
  }
2649
- function transitionNode(stateNode, stateValue, state, _event) {
2628
+ function transitionNode(stateNode, stateValue, state, event) {
2650
2629
  // leaf node
2651
2630
  if (isString(stateValue)) {
2652
- return transitionAtomicNode(stateNode, stateValue, state, _event);
2631
+ return transitionAtomicNode(stateNode, stateValue, state, event);
2653
2632
  }
2654
2633
 
2655
2634
  // compound node
2656
2635
  if (Object.keys(stateValue).length === 1) {
2657
- return transitionCompoundNode(stateNode, stateValue, state, _event);
2636
+ return transitionCompoundNode(stateNode, stateValue, state, event);
2658
2637
  }
2659
2638
 
2660
2639
  // parallel node
2661
- return transitionParallelNode(stateNode, stateValue, state, _event);
2640
+ return transitionParallelNode(stateNode, stateValue, state, event);
2662
2641
  }
2663
2642
  function getHistoryNodes(stateNode) {
2664
2643
  return Object.keys(stateNode.states).map(function (key) {
@@ -2850,7 +2829,7 @@ function getTransitionDomain(transition, historyValue) {
2850
2829
  if (!targetStates) {
2851
2830
  return null;
2852
2831
  }
2853
- if (!transition.external && transition.source.type === 'compound' && targetStates.every(function (targetStateNode) {
2832
+ if (!transition.reenter && transition.source.type !== 'parallel' && targetStates.every(function (targetStateNode) {
2854
2833
  return isDescendant(targetStateNode, transition.source);
2855
2834
  })) {
2856
2835
  return transition.source;
@@ -2901,7 +2880,7 @@ function computeExitSet(transitions, configuration, historyValue) {
2901
2880
  * @param mutConfiguration
2902
2881
  */
2903
2882
 
2904
- function microstep(transitions, currentState, actorCtx, scxmlEvent) {
2883
+ function microstep(transitions, currentState, actorCtx, event) {
2905
2884
  var machine = currentState.machine;
2906
2885
  // Transition will "apply" if:
2907
2886
  // - the state node is the initial state (there is no current state)
@@ -2910,7 +2889,7 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
2910
2889
  var mutConfiguration = new Set(currentState.configuration);
2911
2890
  if (!currentState._initial && !willTransition) {
2912
2891
  var inertState = cloneState(currentState, {
2913
- _event: scxmlEvent,
2892
+ event: event,
2914
2893
  actions: [],
2915
2894
  transitions: []
2916
2895
  });
@@ -2920,11 +2899,11 @@ function microstep(transitions, currentState, actorCtx, scxmlEvent) {
2920
2899
  var microstate = microstepProcedure(currentState._initial ? [{
2921
2900
  target: _toConsumableArray(currentState.configuration).filter(isAtomicStateNode),
2922
2901
  source: machine.root,
2923
- external: true,
2902
+ reenter: true,
2924
2903
  actions: [],
2925
2904
  eventType: null,
2926
2905
  toJSON: null // TODO: fix
2927
- }] : transitions, currentState, mutConfiguration, scxmlEvent, actorCtx);
2906
+ }] : transitions, currentState, mutConfiguration, event, actorCtx);
2928
2907
  var context = microstate.context,
2929
2908
  nonRaisedActions = microstate.actions;
2930
2909
  var children = setChildren(currentState, nonRaisedActions);
@@ -2944,12 +2923,12 @@ function setChildren(currentState, nonRaisedActions) {
2944
2923
  try {
2945
2924
  for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
2946
2925
  var action = _step21.value;
2947
- if (action.type === invoke && action.params.ref) {
2926
+ if (action.type === invoke$1 && action.params.ref) {
2948
2927
  var ref = action.params.ref;
2949
2928
  if (ref) {
2950
2929
  children[ref.id] = ref;
2951
2930
  }
2952
- } else if (action.type === stop) {
2931
+ } else if (action.type === stop$1) {
2953
2932
  var _ref = action.params.actor;
2954
2933
  if (_ref) {
2955
2934
  delete children[_ref.id];
@@ -2963,8 +2942,7 @@ function setChildren(currentState, nonRaisedActions) {
2963
2942
  }
2964
2943
  return children;
2965
2944
  }
2966
- function microstepProcedure(transitions, currentState, mutConfiguration, scxmlEvent, actorCtx) {
2967
- var machine = currentState.machine;
2945
+ function microstepProcedure(transitions, currentState, mutConfiguration, event, actorCtx) {
2968
2946
  var actions = [];
2969
2947
  var historyValue = _objectSpread2({}, currentState.historyValue);
2970
2948
  var filteredTransitions = removeConflictingTransitions(transitions, mutConfiguration, historyValue);
@@ -2993,9 +2971,9 @@ function microstepProcedure(transitions, currentState, mutConfiguration, scxmlEv
2993
2971
  actions.push.apply(actions, _toConsumableArray(finalActions));
2994
2972
  }
2995
2973
  try {
2996
- var _resolveActionsAndCon = resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx),
2974
+ var _resolveActionsAndCon = resolveActionsAndContext(actions, event, currentState, actorCtx),
2997
2975
  nextState = _resolveActionsAndCon.nextState;
2998
- var output = done ? getOutput(nextConfiguration, nextState.context, scxmlEvent) : undefined;
2976
+ var output = done ? getOutput(nextConfiguration, nextState.context, event) : undefined;
2999
2977
  internalQueue.push.apply(internalQueue, _toConsumableArray(nextState._internalQueue));
3000
2978
  return cloneState(currentState, {
3001
2979
  actions: nextState.actions,
@@ -3003,7 +2981,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, scxmlEv
3003
2981
  historyValue: historyValue,
3004
2982
  _internalQueue: internalQueue,
3005
2983
  context: nextState.context,
3006
- _event: scxmlEvent,
2984
+ event: event,
3007
2985
  done: done,
3008
2986
  output: output,
3009
2987
  children: nextState.children
@@ -3011,19 +2989,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, scxmlEv
3011
2989
  } catch (e) {
3012
2990
  // TODO: Refactor this once proper error handling is implemented.
3013
2991
  // See https://github.com/statelyai/rfcs/pull/4
3014
- if (machine.config.scxml) {
3015
- return cloneState(currentState, {
3016
- actions: [],
3017
- configuration: Array.from(mutConfiguration),
3018
- historyValue: historyValue,
3019
- _internalQueue: [toSCXMLEvent({
3020
- type: 'error.execution'
3021
- })],
3022
- context: currentState.context
3023
- });
3024
- } else {
3025
- throw e;
3026
- }
2992
+ throw e;
3027
2993
  }
3028
2994
  }
3029
2995
  function enterStates(filteredTransitions, mutConfiguration, actions, internalQueue, currentState, historyValue) {
@@ -3048,7 +3014,7 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
3048
3014
  try {
3049
3015
  for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
3050
3016
  var invokeDef = _step23.value;
3051
- actions.push(invoke$1(invokeDef));
3017
+ actions.push(invoke(invokeDef));
3052
3018
  }
3053
3019
 
3054
3020
  // Add entry actions
@@ -3078,14 +3044,14 @@ function enterStates(filteredTransitions, mutConfiguration, actions, internalQue
3078
3044
  if (!parent.parent) {
3079
3045
  continue;
3080
3046
  }
3081
- internalQueue.push(toSCXMLEvent(done(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, currentState._event) : undefined)));
3047
+ internalQueue.push(done(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, currentState.event) : undefined));
3082
3048
  if (parent.parent) {
3083
3049
  var grandparent = parent.parent;
3084
3050
  if (grandparent.type === 'parallel') {
3085
3051
  if (getChildren(grandparent).every(function (parentNode) {
3086
3052
  return isInFinalState(_toConsumableArray(mutConfiguration), parentNode);
3087
3053
  })) {
3088
- internalQueue.push(toSCXMLEvent(done(grandparent.id)));
3054
+ internalQueue.push(done(grandparent.id));
3089
3055
  }
3090
3056
  }
3091
3057
  }
@@ -3358,7 +3324,7 @@ function exitStates(transitions, mutConfiguration, historyValue, actions) {
3358
3324
  for (_iterator40.s(); !(_step40 = _iterator40.n()).done;) {
3359
3325
  var s = _step40.value;
3360
3326
  actions.push.apply(actions, _toConsumableArray(s.exit.flat()).concat(_toConsumableArray(s.invoke.map(function (def) {
3361
- return stop$1(def.id);
3327
+ return stop(def.id);
3362
3328
  }))));
3363
3329
  mutConfiguration["delete"](s);
3364
3330
  }
@@ -3368,7 +3334,7 @@ function exitStates(transitions, mutConfiguration, historyValue, actions) {
3368
3334
  _iterator40.f();
3369
3335
  }
3370
3336
  }
3371
- function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3337
+ function resolveActionsAndContext(actions, event, currentState, actorCtx) {
3372
3338
  var machine = currentState.machine;
3373
3339
  var resolvedActions = [];
3374
3340
  var raiseActions = [];
@@ -3386,7 +3352,7 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3386
3352
  var executableActionObject = resolveActionObject(actionObject, machine.options.actions);
3387
3353
  if (isDynamicAction(executableActionObject)) {
3388
3354
  var _resolvedAction$param;
3389
- var _executableActionObje = executableActionObject.resolve(scxmlEvent, {
3355
+ var _executableActionObje = executableActionObject.resolve(event, {
3390
3356
  state: intermediateState,
3391
3357
  action: actionObject,
3392
3358
  actorContext: actorCtx
@@ -3396,12 +3362,12 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3396
3362
  resolvedAction = _executableActionObje2[1];
3397
3363
  var matchedActions = (_resolvedAction$param = resolvedAction.params) === null || _resolvedAction$param === void 0 ? void 0 : _resolvedAction$param.actions;
3398
3364
  intermediateState = nextState;
3399
- 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') {
3400
3366
  raiseActions.push(resolvedAction);
3401
3367
  }
3402
3368
 
3403
3369
  // TODO: remove the check; just handleAction
3404
- if (resolvedAction.type !== pure) {
3370
+ if (resolvedAction.type !== pure$1) {
3405
3371
  handleAction(resolvedAction);
3406
3372
  }
3407
3373
  toActionObjects(matchedActions).forEach(resolveAction);
@@ -3425,21 +3391,21 @@ function resolveActionsAndContext(actions, scxmlEvent, currentState, actorCtx) {
3425
3391
  nextState: cloneState(intermediateState, {
3426
3392
  actions: resolvedActions,
3427
3393
  _internalQueue: raiseActions.map(function (a) {
3428
- return a.params._event;
3394
+ return a.params.event;
3429
3395
  })
3430
3396
  })
3431
3397
  };
3432
3398
  }
3433
- function macrostep(state, scxmlEvent, actorCtx) {
3434
- if (!IS_PRODUCTION && scxmlEvent.name === WILDCARD) {
3399
+ function macrostep(state, event, actorCtx) {
3400
+ if (!IS_PRODUCTION && event.type === WILDCARD) {
3435
3401
  throw new Error("An event cannot have the wildcard type ('".concat(WILDCARD, "')"));
3436
3402
  }
3437
3403
  var nextState = state;
3438
3404
  var states = [];
3439
3405
 
3440
3406
  // Handle stop event
3441
- if ((scxmlEvent === null || scxmlEvent === void 0 ? void 0 : scxmlEvent.name) === stopSignalType) {
3442
- nextState = stopStep(scxmlEvent, nextState, actorCtx);
3407
+ if (event.type === stopSignalType) {
3408
+ nextState = stopStep(event, nextState, actorCtx);
3443
3409
  states.push(nextState);
3444
3410
  return {
3445
3411
  state: nextState,
@@ -3449,9 +3415,9 @@ function macrostep(state, scxmlEvent, actorCtx) {
3449
3415
 
3450
3416
  // Assume the state is at rest (no raised events)
3451
3417
  // Determine the next state based on the next microstep
3452
- if (scxmlEvent.name !== init) {
3453
- var transitions = selectTransitions(scxmlEvent, nextState);
3454
- nextState = microstep(transitions, state, actorCtx, scxmlEvent);
3418
+ if (event.type !== init) {
3419
+ var transitions = selectTransitions(event, nextState);
3420
+ nextState = microstep(transitions, state, actorCtx, event);
3455
3421
  states.push(nextState);
3456
3422
  }
3457
3423
  while (!nextState.done) {
@@ -3483,21 +3449,21 @@ function macrostep(state, scxmlEvent, actorCtx) {
3483
3449
  if (enabledTransitions.length) {
3484
3450
  var _nextState$actions2;
3485
3451
  var _currentActions = nextState.actions;
3486
- nextState = microstep(enabledTransitions, nextState, actorCtx, nextState._event);
3452
+ nextState = microstep(enabledTransitions, nextState, actorCtx, nextState.event);
3487
3453
  (_nextState$actions2 = nextState.actions).unshift.apply(_nextState$actions2, _toConsumableArray(_currentActions));
3488
3454
  states.push(nextState);
3489
3455
  }
3490
3456
  }
3491
3457
  if (nextState.done) {
3492
3458
  // Perform the stop step to ensure that child actors are stopped
3493
- stopStep(nextState._event, nextState, actorCtx);
3459
+ stopStep(nextState.event, nextState, actorCtx);
3494
3460
  }
3495
3461
  return {
3496
3462
  state: nextState,
3497
3463
  microstates: states
3498
3464
  };
3499
3465
  }
3500
- function stopStep(scxmlEvent, nextState, actorCtx) {
3466
+ function stopStep(event, nextState, actorCtx) {
3501
3467
  var actions = [];
3502
3468
  var _iterator43 = _createForOfIteratorHelper(nextState.configuration.sort(function (a, b) {
3503
3469
  return b.order - a.order;
@@ -3515,14 +3481,14 @@ function stopStep(scxmlEvent, nextState, actorCtx) {
3515
3481
  }
3516
3482
  for (var _i4 = 0, _Object$values = Object.values(nextState.children); _i4 < _Object$values.length; _i4++) {
3517
3483
  var child = _Object$values[_i4];
3518
- actions.push(stop$1(child));
3484
+ actions.push(stop(child));
3519
3485
  }
3520
- var _resolveActionsAndCon2 = resolveActionsAndContext(actions, scxmlEvent, nextState, actorCtx),
3486
+ var _resolveActionsAndCon2 = resolveActionsAndContext(actions, event, nextState, actorCtx),
3521
3487
  stoppedState = _resolveActionsAndCon2.nextState;
3522
3488
  return stoppedState;
3523
3489
  }
3524
- function selectTransitions(scxmlEvent, nextState) {
3525
- return nextState.machine.getTransitionData(nextState, scxmlEvent);
3490
+ function selectTransitions(event, nextState) {
3491
+ return nextState.machine.getTransitionData(nextState, event);
3526
3492
  }
3527
3493
  function selectEventlessTransitions(nextState) {
3528
3494
  var enabledTransitionSet = new Set();
@@ -3545,7 +3511,7 @@ function selectEventlessTransitions(nextState) {
3545
3511
  try {
3546
3512
  for (_iterator46.s(); !(_step46 = _iterator46.n()).done;) {
3547
3513
  var transition = _step46.value;
3548
- 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)) {
3549
3515
  enabledTransitionSet.add(transition);
3550
3516
  break loop;
3551
3517
  }
@@ -3639,16 +3605,14 @@ var State = /*#__PURE__*/function () {
3639
3605
  _defineProperty(this, "actions", []);
3640
3606
  _defineProperty(this, "event", void 0);
3641
3607
  _defineProperty(this, "_internalQueue", void 0);
3642
- _defineProperty(this, "_event", void 0);
3643
3608
  _defineProperty(this, "_initial", false);
3644
3609
  _defineProperty(this, "changed", void 0);
3645
3610
  _defineProperty(this, "configuration", void 0);
3646
3611
  _defineProperty(this, "transitions", void 0);
3647
3612
  _defineProperty(this, "children", void 0);
3648
3613
  this.context = config.context;
3649
- this._event = config._event;
3650
3614
  this._internalQueue = (_config$_internalQueu = config._internalQueue) !== null && _config$_internalQueu !== void 0 ? _config$_internalQueu : [];
3651
- this.event = this._event.data;
3615
+ this.event = config.event;
3652
3616
  this.historyValue = config.historyValue || {};
3653
3617
  this.actions = (_config$actions = config.actions) !== null && _config$actions !== void 0 ? _config$actions : [];
3654
3618
  this.matches = this.matches.bind(this);
@@ -3688,11 +3652,11 @@ var State = /*#__PURE__*/function () {
3688
3652
  }, {
3689
3653
  key: "toJSON",
3690
3654
  value: function toJSON() {
3691
- var configuration = this.configuration,
3692
- transitions = this.transitions,
3693
- tags = this.tags,
3694
- machine = this.machine,
3695
- jsonValues = _objectWithoutProperties(this, _excluded);
3655
+ this.configuration;
3656
+ this.transitions;
3657
+ var tags = this.tags;
3658
+ this.machine;
3659
+ var jsonValues = _objectWithoutProperties(this, _excluded);
3696
3660
  return _objectSpread2(_objectSpread2({}, jsonValues), {}, {
3697
3661
  tags: Array.from(tags),
3698
3662
  meta: this.meta
@@ -3733,7 +3697,7 @@ var State = /*#__PURE__*/function () {
3733
3697
  if (IS_PRODUCTION) {
3734
3698
  warn(!!this.machine, "state.can(...) used outside of a machine-created State object; this will always return false.");
3735
3699
  }
3736
- var transitionData = this.machine.getTransitionData(this, toSCXMLEvent(event));
3700
+ var transitionData = this.machine.getTransitionData(this, event);
3737
3701
  return !!(transitionData !== null && transitionData !== void 0 && transitionData.length) &&
3738
3702
  // Check that at least one transition is not forbidden
3739
3703
  transitionData.some(function (t) {
@@ -3810,7 +3774,7 @@ var State = /*#__PURE__*/function () {
3810
3774
  return new State({
3811
3775
  value: stateValue.value,
3812
3776
  context: context,
3813
- _event: stateValue._event,
3777
+ event: stateValue.event,
3814
3778
  actions: [],
3815
3779
  meta: {},
3816
3780
  configuration: [],
@@ -3821,13 +3785,13 @@ var State = /*#__PURE__*/function () {
3821
3785
  }
3822
3786
  return stateValue;
3823
3787
  }
3824
- var _event = createInitEvent({}); // TODO: fix
3788
+ var event = createInitEvent({}); // TODO: fix
3825
3789
 
3826
3790
  var configuration = getConfiguration(getStateNodes(machine.root, stateValue));
3827
3791
  return new State({
3828
3792
  value: stateValue,
3829
3793
  context: context,
3830
- _event: _event,
3794
+ event: event,
3831
3795
  actions: [],
3832
3796
  meta: undefined,
3833
3797
  configuration: Array.from(configuration),
@@ -3843,11 +3807,11 @@ function cloneState(state) {
3843
3807
  return new State(_objectSpread2(_objectSpread2({}, state), config), state.machine);
3844
3808
  }
3845
3809
  function getPersistedState(state) {
3846
- var configuration = state.configuration,
3847
- transitions = state.transitions,
3848
- tags = state.tags,
3849
- machine = state.machine,
3850
- children = state.children,
3810
+ state.configuration;
3811
+ state.transitions;
3812
+ state.tags;
3813
+ state.machine;
3814
+ var children = state.children,
3851
3815
  jsonValues = _objectWithoutProperties(state, _excluded2);
3852
3816
  var childrenJson = {};
3853
3817
  for (var id in children) {
@@ -3862,14 +3826,14 @@ function getPersistedState(state) {
3862
3826
  });
3863
3827
  }
3864
3828
 
3865
- function invoke$1(invokeDef) {
3829
+ function invoke(invokeDef) {
3866
3830
  return createDynamicAction({
3867
- type: invoke,
3831
+ type: invoke$1,
3868
3832
  params: invokeDef
3869
- }, function (_event, _ref) {
3833
+ }, function (event, _ref) {
3870
3834
  var state = _ref.state,
3871
3835
  actorContext = _ref.actorContext;
3872
- var type = invoke;
3836
+ var type = invoke$1;
3873
3837
  var id = invokeDef.id,
3874
3838
  src = invokeDef.src;
3875
3839
  var resolvedInvokeAction;
@@ -3896,7 +3860,7 @@ function invoke$1(invokeDef) {
3896
3860
  systemId: invokeDef.systemId,
3897
3861
  input: typeof input === 'function' ? input({
3898
3862
  context: state.context,
3899
- event: _event.data,
3863
+ event: event,
3900
3864
  self: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self
3901
3865
  }) : input
3902
3866
  });
@@ -3931,7 +3895,7 @@ function invoke$1(invokeDef) {
3931
3895
  var _actorRef$start;
3932
3896
  (_actorRef$start = actorRef.start) === null || _actorRef$start === void 0 ? void 0 : _actorRef$start.call(actorRef);
3933
3897
  } catch (err) {
3934
- parent.send(error$1(id, err));
3898
+ parent.send(error(id, err));
3935
3899
  return;
3936
3900
  }
3937
3901
  });
@@ -3940,7 +3904,7 @@ function invoke$1(invokeDef) {
3940
3904
  });
3941
3905
  }
3942
3906
 
3943
- function createSpawner(self, machine, context, _event, mutCapturedActions) {
3907
+ function createSpawner(self, machine, context, event, mutCapturedActions) {
3944
3908
  return function (src) {
3945
3909
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3946
3910
  if (isString(src)) {
@@ -3956,11 +3920,11 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3956
3920
  parent: self,
3957
3921
  input: typeof input === 'function' ? input({
3958
3922
  context: context,
3959
- event: _event.data,
3923
+ event: event,
3960
3924
  self: self
3961
3925
  }) : input
3962
3926
  });
3963
- mutCapturedActions.push(invoke$1({
3927
+ mutCapturedActions.push(invoke({
3964
3928
  id: actorRef.id,
3965
3929
  // @ts-ignore TODO: fix types
3966
3930
  src: actorRef,
@@ -3981,7 +3945,7 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3981
3945
  parent: self,
3982
3946
  input: options.input
3983
3947
  });
3984
- mutCapturedActions.push(invoke$1({
3948
+ mutCapturedActions.push(invoke({
3985
3949
  // @ts-ignore TODO: fix types
3986
3950
  src: _actorRef,
3987
3951
  ref: _actorRef,
@@ -3999,13 +3963,13 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3999
3963
  *
4000
3964
  * @param assignment An object that represents the partial context to update.
4001
3965
  */
4002
- function assign$1(assignment) {
3966
+ function assign(assignment) {
4003
3967
  return createDynamicAction({
4004
- type: assign,
3968
+ type: assign$1,
4005
3969
  params: {
4006
3970
  assignment: assignment
4007
3971
  }
4008
- }, function (_event, _ref) {
3972
+ }, function (event, _ref) {
4009
3973
  var _actorContext$self;
4010
3974
  var state = _ref.state,
4011
3975
  action = _ref.action,
@@ -4016,10 +3980,9 @@ function assign$1(assignment) {
4016
3980
  }
4017
3981
  var args = {
4018
3982
  context: state.context,
4019
- event: _event.data,
3983
+ event: event,
4020
3984
  action: action,
4021
- _event: _event,
4022
- 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),
4023
3986
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
4024
3987
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
4025
3988
  };
@@ -4037,7 +4000,7 @@ function assign$1(assignment) {
4037
4000
  return [cloneState(state, {
4038
4001
  context: updatedContext
4039
4002
  }), {
4040
- type: assign,
4003
+ type: assign$1,
4041
4004
  params: {
4042
4005
  context: updatedContext,
4043
4006
  actions: capturedActions
@@ -4053,15 +4016,15 @@ function assign$1(assignment) {
4053
4016
  * @param eventType The event to raise.
4054
4017
  */
4055
4018
 
4056
- function raise$1(eventOrExpr, options) {
4019
+ function raise(eventOrExpr, options) {
4057
4020
  return createDynamicAction({
4058
- type: raise,
4021
+ type: raise$1,
4059
4022
  params: {
4060
4023
  delay: options ? options.delay : undefined,
4061
4024
  event: eventOrExpr,
4062
4025
  id: options && options.id !== undefined ? options.id : typeof eventOrExpr === 'function' ? eventOrExpr.name : eventOrExpr.type
4063
4026
  }
4064
- }, function (_event, _ref) {
4027
+ }, function (event, _ref) {
4065
4028
  var _actorContext$self;
4066
4029
  var state = _ref.state,
4067
4030
  actorContext = _ref.actorContext;
@@ -4072,15 +4035,17 @@ function raise$1(eventOrExpr, options) {
4072
4035
  };
4073
4036
  var args = {
4074
4037
  context: state.context,
4075
- event: _event.data,
4076
- _event: _event,
4038
+ event: event,
4077
4039
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
4078
4040
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
4079
4041
  };
4080
4042
  var delaysMap = state.machine.options.delays;
4081
4043
 
4082
4044
  // TODO: helper function for resolving Expr
4083
- 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;
4084
4049
  var resolvedDelay;
4085
4050
  if (typeof params.delay === 'string') {
4086
4051
  var configDelay = delaysMap && delaysMap[params.delay];
@@ -4089,10 +4054,9 @@ function raise$1(eventOrExpr, options) {
4089
4054
  resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
4090
4055
  }
4091
4056
  var resolvedAction = {
4092
- type: raise,
4057
+ type: raise$1,
4093
4058
  params: _objectSpread2(_objectSpread2({}, params), {}, {
4094
- _event: resolvedEvent,
4095
- event: resolvedEvent.data,
4059
+ event: resolvedEvent,
4096
4060
  delay: resolvedDelay
4097
4061
  }),
4098
4062
  execute: function execute(actorCtx) {
@@ -4106,23 +4070,23 @@ function raise$1(eventOrExpr, options) {
4106
4070
  });
4107
4071
  }
4108
4072
 
4109
- function choose$1(guards) {
4073
+ function choose(guards) {
4110
4074
  return createDynamicAction({
4111
- type: choose,
4075
+ type: choose$1,
4112
4076
  params: {
4113
4077
  guards: guards
4114
4078
  }
4115
- }, function (_event, _ref) {
4079
+ }, function (event, _ref) {
4116
4080
  var _guards$find;
4117
4081
  var state = _ref.state;
4118
4082
  var matchedActions = (_guards$find = guards.find(function (condition) {
4119
4083
  var guard = condition.guard && toGuardDefinition(condition.guard, function (guardType) {
4120
4084
  return state.machine.options.guards[guardType];
4121
4085
  });
4122
- return !guard || evaluateGuard(guard, state.context, _event, state);
4086
+ return !guard || evaluateGuard(guard, state.context, event, state);
4123
4087
  })) === null || _guards$find === void 0 ? void 0 : _guards$find.actions;
4124
4088
  return [state, {
4125
- type: choose,
4089
+ type: choose$1,
4126
4090
  params: {
4127
4091
  actions: toActionObjects(matchedActions)
4128
4092
  }
@@ -4130,9 +4094,30 @@ function choose$1(guards) {
4130
4094
  });
4131
4095
  }
4132
4096
 
4133
- 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 = {
4134
4119
  type: init
4135
- });
4120
+ };
4136
4121
  function resolveActionObject(actionObject, actionFunctionMap) {
4137
4122
  if (isDynamicAction(actionObject)) {
4138
4123
  return actionObject;
@@ -4143,7 +4128,7 @@ function resolveActionObject(actionObject, actionFunctionMap) {
4143
4128
  return createDynamicAction({
4144
4129
  type: 'xstate.function',
4145
4130
  params: (_actionObject$params = actionObject.params) !== null && _actionObject$params !== void 0 ? _actionObject$params : {}
4146
- }, function (_event, _ref) {
4131
+ }, function (event, _ref) {
4147
4132
  var state = _ref.state;
4148
4133
  var a = {
4149
4134
  type: actionObject.type,
@@ -4151,9 +4136,8 @@ function resolveActionObject(actionObject, actionFunctionMap) {
4151
4136
  execute: function execute(actorCtx) {
4152
4137
  return dereferencedAction({
4153
4138
  context: state.context,
4154
- event: state.event,
4139
+ event: event,
4155
4140
  action: a,
4156
- _event: state._event,
4157
4141
  system: actorCtx.system,
4158
4142
  self: actorCtx.self
4159
4143
  });
@@ -4182,7 +4166,7 @@ function toActionObject(action) {
4182
4166
  return createDynamicAction({
4183
4167
  type: type,
4184
4168
  params: {}
4185
- }, function (_event, _ref2) {
4169
+ }, function (event, _ref2) {
4186
4170
  var state = _ref2.state;
4187
4171
  var actionObject = {
4188
4172
  type: type,
@@ -4192,9 +4176,8 @@ function toActionObject(action) {
4192
4176
  execute: function execute(actorCtx) {
4193
4177
  return action({
4194
4178
  context: state.context,
4195
- event: _event.data,
4179
+ event: event,
4196
4180
  action: actionObject,
4197
- _event: _event,
4198
4181
  self: actorCtx.self,
4199
4182
  system: actorCtx.system
4200
4183
  });
@@ -4222,7 +4205,7 @@ var toActionObjects = function toActionObjects(action) {
4222
4205
  * @param delayRef The delay in milliseconds
4223
4206
  * @param id The state node ID where this event is handled
4224
4207
  */
4225
- function after$1(delayRef, id) {
4208
+ function after(delayRef, id) {
4226
4209
  var idSuffix = id ? "#".concat(id) : '';
4227
4210
  return "".concat(ActionTypes.After, "(").concat(delayRef, ")").concat(idSuffix);
4228
4211
  }
@@ -4266,7 +4249,7 @@ function doneInvoke(invokeId, output) {
4266
4249
  };
4267
4250
  return eventObject;
4268
4251
  }
4269
- function error$1(id, data) {
4252
+ function error(id, data) {
4270
4253
  var type = "".concat(ActionTypes.ErrorPlatform, ".").concat(id);
4271
4254
  var eventObject = {
4272
4255
  type: type,
@@ -4278,10 +4261,10 @@ function error$1(id, data) {
4278
4261
  return eventObject;
4279
4262
  }
4280
4263
  function createInitEvent(input) {
4281
- return toSCXMLEvent({
4264
+ return {
4282
4265
  type: init,
4283
4266
  input: input
4284
- });
4267
+ };
4285
4268
  }
4286
4269
 
4287
- export { sendTo 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, getStateNodeByPath as P, getPersistedState as Q, resolveReferencedActor as R, State as S, interpret as T, STATE_DELIMITER as U, initEvent as V, matchesState as W, raise$1 as X, send$1 as Y, sendParent as Z, _createClass as _, toActionObjects as a, log$1 as a0, cancel$1 as a1, stop$1 as a2, assign$1 as a3, after$1 as a4, done as a5, respond as a6, forwardTo as a7, escalate as a8, choose$1 as a9, toActionObject as aA, Interpreter as aa, ActorStatus as ab, doneInvoke as ac, pathToStateValue as ad, toObserver as ae, ActionTypes as af, SpecialTargets as ag, startSignalType as ah, stopSignalType as ai, startSignal as aj, stopSignal as ak, isSignal as al, isActorRef as am, toActorRef as an, fromTransition as ao, fromPromise as ap, fromObservable as aq, fromEventObservable as ar, fromCallback as as, stateIn as at, not as au, and as av, or as aw, toGuardDefinition as ax, actionTypes as ay, resolveActionObject 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 };