xstate 5.0.0-alpha.2 → 5.0.0-alpha.4

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 (51) hide show
  1. package/actions/dist/xstate-actions.cjs.dev.js +1 -1
  2. package/actions/dist/xstate-actions.cjs.prod.js +1 -1
  3. package/actions/dist/xstate-actions.esm.js +1 -1
  4. package/actions/dist/xstate-actions.umd.min.js +1 -1
  5. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  6. package/actors/dist/xstate-actors.cjs.dev.js +1 -1
  7. package/actors/dist/xstate-actors.cjs.prod.js +1 -1
  8. package/actors/dist/xstate-actors.esm.js +1 -1
  9. package/actors/dist/xstate-actors.umd.min.js +1 -1
  10. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  11. package/dev/dist/xstate-dev.umd.min.js.map +1 -1
  12. package/dist/{actions-acb29ffe.cjs.prod.js → actions-2479953d.cjs.prod.js} +173 -134
  13. package/dist/{actions-9778f6fb.esm.js → actions-7678b87b.esm.js} +173 -134
  14. package/dist/{actions-1e9778c2.cjs.dev.js → actions-96f799fc.cjs.dev.js} +173 -134
  15. package/dist/declarations/src/Machine.d.ts +3 -3
  16. package/dist/declarations/src/SimulatedClock.d.ts +1 -1
  17. package/dist/declarations/src/State.d.ts +3 -3
  18. package/dist/declarations/src/StateMachine.d.ts +4 -4
  19. package/dist/declarations/src/StateNode.d.ts +3 -3
  20. package/dist/declarations/src/actionTypes.d.ts +1 -1
  21. package/dist/declarations/src/actions/assign.d.ts +1 -1
  22. package/dist/declarations/src/actions/cancel.d.ts +2 -2
  23. package/dist/declarations/src/actions/choose.d.ts +2 -2
  24. package/dist/declarations/src/actions/invoke.d.ts +2 -2
  25. package/dist/declarations/src/actions/log.d.ts +2 -2
  26. package/dist/declarations/src/actions/pure.d.ts +5 -2
  27. package/dist/declarations/src/actions/raise.d.ts +1 -1
  28. package/dist/declarations/src/actions/send.d.ts +2 -2
  29. package/dist/declarations/src/actions/stop.d.ts +1 -1
  30. package/dist/declarations/src/actions.d.ts +10 -10
  31. package/dist/declarations/src/actors/index.d.ts +5 -5
  32. package/dist/declarations/src/dev/index.d.ts +1 -1
  33. package/dist/declarations/src/guards.d.ts +2 -2
  34. package/dist/declarations/src/index.d.ts +21 -21
  35. package/dist/declarations/src/interpreter.d.ts +4 -4
  36. package/dist/declarations/src/spawn.d.ts +1 -1
  37. package/dist/declarations/src/stateUtils.d.ts +4 -4
  38. package/dist/declarations/src/typegenTypes.d.ts +1 -1
  39. package/dist/declarations/src/types.d.ts +47 -23
  40. package/dist/declarations/src/utils.d.ts +4 -4
  41. package/dist/xstate.cjs.dev.js +5 -2
  42. package/dist/xstate.cjs.prod.js +5 -2
  43. package/dist/xstate.esm.js +6 -3
  44. package/dist/xstate.umd.min.js +1 -1
  45. package/dist/xstate.umd.min.js.map +1 -1
  46. package/guards/dist/xstate-guards.cjs.dev.js +1 -1
  47. package/guards/dist/xstate-guards.cjs.prod.js +1 -1
  48. package/guards/dist/xstate-guards.esm.js +1 -1
  49. package/guards/dist/xstate-guards.umd.min.js +1 -1
  50. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  51. package/package.json +1 -1
@@ -377,14 +377,21 @@ function toArray(value) {
377
377
  }
378
378
  function mapContext(mapper, context, _event) {
379
379
  if (isFunction(mapper)) {
380
- return mapper(context, _event.data);
380
+ return mapper({
381
+ context: context,
382
+ event: _event.data
383
+ });
381
384
  }
382
385
  var result = {};
386
+ var args = {
387
+ context: context,
388
+ event: _event.data
389
+ };
383
390
  for (var _i4 = 0, _Object$keys2 = Object.keys(mapper); _i4 < _Object$keys2.length; _i4++) {
384
391
  var _key3 = _Object$keys2[_i4];
385
392
  var subMapper = mapper[_key3];
386
393
  if (isFunction(subMapper)) {
387
- result[_key3] = subMapper(context, _event.data);
394
+ result[_key3] = subMapper(args);
388
395
  } else {
389
396
  result[_key3] = subMapper;
390
397
  }
@@ -549,24 +556,25 @@ function send$1(eventOrExpr, options) {
549
556
  // there is too big chance of the ID collision
550
557
  id: options && options.id !== undefined ? options.id : isFunction(eventOrExpr) ? eventOrExpr.name : eventOrExpr.type
551
558
  };
552
- var meta = {
559
+ var args = {
560
+ context: state.context,
561
+ event: _event.data,
553
562
  _event: _event,
554
- state: state,
555
563
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : null,
556
564
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
557
565
  };
558
566
  var delaysMap = state.machine.options.delays;
559
567
 
560
568
  // TODO: helper function for resolving Expr
561
- var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(state.context, _event.data, meta) : eventOrExpr);
569
+ var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(args) : eventOrExpr);
562
570
  var resolvedDelay;
563
571
  if (isString(params.delay)) {
564
572
  var configDelay = delaysMap && delaysMap[params.delay];
565
- resolvedDelay = isFunction(configDelay) ? configDelay(state.context, _event.data, meta) : configDelay;
573
+ resolvedDelay = isFunction(configDelay) ? configDelay(args) : configDelay;
566
574
  } else {
567
- resolvedDelay = isFunction(params.delay) ? params.delay(state.context, _event.data, meta) : params.delay;
575
+ resolvedDelay = isFunction(params.delay) ? params.delay(args) : params.delay;
568
576
  }
569
- var resolvedTarget = isFunction(params.to) ? params.to(state.context, _event.data, meta) : params.to;
577
+ var resolvedTarget = isFunction(params.to) ? params.to(args) : params.to;
570
578
  var targetActorRef;
571
579
  if (typeof resolvedTarget === 'string') {
572
580
  if (resolvedTarget === SpecialTargets.Parent) {
@@ -638,7 +646,7 @@ function sendParent(event, options) {
638
646
  */
639
647
  function respond(event, options) {
640
648
  return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
641
- to: function to(_, __, _ref2) {
649
+ to: function to(_ref2) {
642
650
  var _event = _ref2._event;
643
651
  return _event.origin; // TODO: handle when _event.origin is undefined
644
652
  }
@@ -662,7 +670,8 @@ function forwardTo(target, options) {
662
670
  return resolvedTarget;
663
671
  };
664
672
  }
665
- return send$1(function (_, event) {
673
+ return send$1(function (_ref3) {
674
+ var event = _ref3.event;
666
675
  return event;
667
676
  }, _objectSpread2(_objectSpread2({}, options), {}, {
668
677
  to: target
@@ -677,10 +686,10 @@ function forwardTo(target, options) {
677
686
  * @param options Options to pass into the send action creator.
678
687
  */
679
688
  function escalate(errorData, options) {
680
- return sendParent(function (context, event, meta) {
689
+ return sendParent(function (arg) {
681
690
  return {
682
691
  type: error,
683
- data: isFunction(errorData) ? errorData(context, event, meta) : errorData
692
+ data: isFunction(errorData) ? errorData(arg) : errorData
684
693
  };
685
694
  }, _objectSpread2(_objectSpread2({}, options), {}, {
686
695
  to: SpecialTargets.Parent
@@ -725,6 +734,86 @@ function _createClass(Constructor, protoProps, staticProps) {
725
734
  return Constructor;
726
735
  }
727
736
 
737
+ var Mailbox = /*#__PURE__*/function () {
738
+ function Mailbox(_process) {
739
+ _classCallCheck(this, Mailbox);
740
+ this._process = _process;
741
+ _defineProperty(this, "_active", false);
742
+ _defineProperty(this, "_current", null);
743
+ _defineProperty(this, "_last", null);
744
+ }
745
+ _createClass(Mailbox, [{
746
+ key: "start",
747
+ value: function start() {
748
+ this._active = true;
749
+ this.flush();
750
+ }
751
+ }, {
752
+ key: "clear",
753
+ value: function clear() {
754
+ // we can't set _current to null because we might be currently processing
755
+ // and enqueue following clear shouldnt start processing the enqueued item immediately
756
+ if (this._current) {
757
+ this._current.next = null;
758
+ this._last = this._current;
759
+ }
760
+ }
761
+
762
+ // TODO: rethink this design
763
+ }, {
764
+ key: "prepend",
765
+ value: function prepend(event) {
766
+ if (!this._current) {
767
+ this.enqueue(event);
768
+ return;
769
+ }
770
+
771
+ // we know that something is already queued up
772
+ // so the mailbox is already flushing or it's inactive
773
+ // therefore the only thing that we need to do is to reassign `this._current`
774
+ this._current = {
775
+ value: event,
776
+ next: this._current
777
+ };
778
+ }
779
+ }, {
780
+ key: "enqueue",
781
+ value: function enqueue(event) {
782
+ var enqueued = {
783
+ value: event,
784
+ next: null
785
+ };
786
+ if (this._current) {
787
+ this._last.next = enqueued;
788
+ this._last = enqueued;
789
+ return;
790
+ }
791
+ this._current = enqueued;
792
+ this._last = enqueued;
793
+ if (this._active) {
794
+ this.flush();
795
+ }
796
+ }
797
+ }, {
798
+ key: "flush",
799
+ value: function flush() {
800
+ while (this._current) {
801
+ // atm the given _process is responsible for implementing proper try/catch handling
802
+ // we assume here that this won't throw in a way that can affect this mailbox
803
+ var consumed = this._current;
804
+ this._process(consumed.value);
805
+ // something could have been prepended in the meantime
806
+ // so we need to be defensive here to avoid skipping over a prepended item
807
+ if (consumed === this._current) {
808
+ this._current = this._current.next;
809
+ }
810
+ }
811
+ this._last = null;
812
+ }
813
+ }]);
814
+ return Mailbox;
815
+ }();
816
+
728
817
  var symbolObservable = function () {
729
818
  return typeof Symbol === 'function' && Symbol.observable || '@@observable';
730
819
  }();
@@ -1190,86 +1279,6 @@ function toActorRef(actorRefLike) {
1190
1279
  }), _objectSpread2$1), actorRefLike);
1191
1280
  }
1192
1281
 
1193
- var Mailbox = /*#__PURE__*/function () {
1194
- function Mailbox(_process) {
1195
- _classCallCheck(this, Mailbox);
1196
- this._process = _process;
1197
- _defineProperty(this, "_active", false);
1198
- _defineProperty(this, "_current", null);
1199
- _defineProperty(this, "_last", null);
1200
- }
1201
- _createClass(Mailbox, [{
1202
- key: "start",
1203
- value: function start() {
1204
- this._active = true;
1205
- this.flush();
1206
- }
1207
- }, {
1208
- key: "clear",
1209
- value: function clear() {
1210
- // we can't set _current to null because we might be currently processing
1211
- // and enqueue following clear shouldnt start processing the enqueued item immediately
1212
- if (this._current) {
1213
- this._current.next = null;
1214
- this._last = this._current;
1215
- }
1216
- }
1217
-
1218
- // TODO: rethink this design
1219
- }, {
1220
- key: "prepend",
1221
- value: function prepend(event) {
1222
- if (!this._current) {
1223
- this.enqueue(event);
1224
- return;
1225
- }
1226
-
1227
- // we know that something is already queued up
1228
- // so the mailbox is already flushing or it's inactive
1229
- // therefore the only thing that we need to do is to reassign `this._current`
1230
- this._current = {
1231
- value: event,
1232
- next: this._current
1233
- };
1234
- }
1235
- }, {
1236
- key: "enqueue",
1237
- value: function enqueue(event) {
1238
- var enqueued = {
1239
- value: event,
1240
- next: null
1241
- };
1242
- if (this._current) {
1243
- this._last.next = enqueued;
1244
- this._last = enqueued;
1245
- return;
1246
- }
1247
- this._current = enqueued;
1248
- this._last = enqueued;
1249
- if (this._active) {
1250
- this.flush();
1251
- }
1252
- }
1253
- }, {
1254
- key: "flush",
1255
- value: function flush() {
1256
- while (this._current) {
1257
- // atm the given _process is responsible for implementing proper try/catch handling
1258
- // we assume here that this won't throw in a way that can affect this mailbox
1259
- var consumed = this._current;
1260
- this._process(consumed.value);
1261
- // something could have been prepended in the meantime
1262
- // so we need to be defensive here to avoid skipping over a prepended item
1263
- if (consumed === this._current) {
1264
- this._current = this._current.next;
1265
- }
1266
- }
1267
- this._last = null;
1268
- }
1269
- }]);
1270
- return Mailbox;
1271
- }();
1272
-
1273
1282
  function createSystem() {
1274
1283
  var sessionIdCounter = 0;
1275
1284
  var children = new Map();
@@ -1774,7 +1783,10 @@ function stop$1(actorRef) {
1774
1783
  }
1775
1784
  }, function (_event, _ref) {
1776
1785
  var state = _ref.state;
1777
- var actorRefOrString = isFunction(actor) ? actor(state.context, _event.data) : actor;
1786
+ var actorRefOrString = isFunction(actor) ? actor({
1787
+ context: state.context,
1788
+ event: _event.data
1789
+ }) : actor;
1778
1790
  var actorRef = typeof actorRefOrString === 'string' ? state.children[actorRefOrString] : actorRefOrString;
1779
1791
  return [state, {
1780
1792
  type: 'xstate.stop',
@@ -1797,7 +1809,9 @@ function stop$1(actorRef) {
1797
1809
  });
1798
1810
  }
1799
1811
 
1800
- var defaultLogExpr = function defaultLogExpr(context, event) {
1812
+ var defaultLogExpr = function defaultLogExpr(_ref) {
1813
+ var context = _ref.context,
1814
+ event = _ref.event;
1801
1815
  return {
1802
1816
  context: context,
1803
1817
  event: event
@@ -1822,13 +1836,14 @@ function log$1() {
1822
1836
  label: label,
1823
1837
  expr: expr
1824
1838
  }
1825
- }, function (_event, _ref) {
1839
+ }, function (_event, _ref2) {
1826
1840
  var _actorContext$self;
1827
- var state = _ref.state,
1828
- actorContext = _ref.actorContext;
1829
- var resolvedValue = typeof expr === 'function' ? expr(state.context, _event.data, {
1841
+ var state = _ref2.state,
1842
+ actorContext = _ref2.actorContext;
1843
+ var resolvedValue = typeof expr === 'function' ? expr({
1844
+ context: state.context,
1845
+ event: _event.data,
1830
1846
  _event: _event,
1831
- state: state,
1832
1847
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
1833
1848
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
1834
1849
  }) : expr;
@@ -1869,10 +1884,10 @@ function cancel$1(sendId) {
1869
1884
  var _actorContext$self;
1870
1885
  var state = _ref.state,
1871
1886
  actorContext = _ref.actorContext;
1872
- var resolvedSendId = isFunction(sendId) ? sendId(state.context, _event.data, {
1887
+ var resolvedSendId = isFunction(sendId) ? sendId({
1888
+ context: state.context,
1889
+ event: _event.data,
1873
1890
  _event: _event,
1874
- state: state,
1875
- // TODO: fix types,
1876
1891
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
1877
1892
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
1878
1893
  }) : sendId;
@@ -1936,7 +1951,7 @@ function stateIn(stateValue) {
1936
1951
  params: {
1937
1952
  stateValue: stateValue
1938
1953
  },
1939
- predicate: function predicate(_, __, _ref) {
1954
+ predicate: function predicate(_ref) {
1940
1955
  var state = _ref.state;
1941
1956
  if (isString(stateValue) && isStateId(stateValue)) {
1942
1957
  return state.configuration.some(function (sn) {
@@ -1954,8 +1969,13 @@ function not(guard) {
1954
1969
  op: 'not'
1955
1970
  },
1956
1971
  children: [toGuardDefinition(guard)],
1957
- predicate: function predicate(ctx, _, meta) {
1958
- return !meta.evaluate(meta.guard.children[0], ctx, meta._event, meta.state);
1972
+ predicate: function predicate(_ref2) {
1973
+ var evaluate = _ref2.evaluate,
1974
+ guard = _ref2.guard,
1975
+ context = _ref2.context,
1976
+ _event = _ref2._event,
1977
+ state = _ref2.state;
1978
+ return !evaluate(guard.children[0], context, _event, state);
1959
1979
  }
1960
1980
  };
1961
1981
  }
@@ -1968,9 +1988,14 @@ function and(guards) {
1968
1988
  children: guards.map(function (guard) {
1969
1989
  return toGuardDefinition(guard);
1970
1990
  }),
1971
- predicate: function predicate(ctx, _, meta) {
1972
- return meta.guard.children.every(function (childGuard) {
1973
- return meta.evaluate(childGuard, ctx, meta._event, meta.state);
1991
+ predicate: function predicate(_ref3) {
1992
+ var evaluate = _ref3.evaluate,
1993
+ guard = _ref3.guard,
1994
+ context = _ref3.context,
1995
+ _event = _ref3._event,
1996
+ state = _ref3.state;
1997
+ return guard.children.every(function (childGuard) {
1998
+ return evaluate(childGuard, context, _event, state);
1974
1999
  });
1975
2000
  }
1976
2001
  };
@@ -1984,9 +2009,14 @@ function or(guards) {
1984
2009
  children: guards.map(function (guard) {
1985
2010
  return toGuardDefinition(guard);
1986
2011
  }),
1987
- predicate: function predicate(ctx, _, meta) {
1988
- return meta.guard.children.some(function (childGuard) {
1989
- return meta.evaluate(childGuard, ctx, meta._event, meta.state);
2012
+ predicate: function predicate(_ref4) {
2013
+ var evaluate = _ref4.evaluate,
2014
+ guard = _ref4.guard,
2015
+ context = _ref4.context,
2016
+ _event = _ref4._event,
2017
+ state = _ref4.state;
2018
+ return guard.children.some(function (childGuard) {
2019
+ return evaluate(childGuard, context, _event, state);
1990
2020
  });
1991
2021
  }
1992
2022
  };
@@ -1994,17 +2024,18 @@ function or(guards) {
1994
2024
  function evaluateGuard(guard, context, _event, state) {
1995
2025
  var _machine$options$guar, _machine$options, _machine$options$guar2;
1996
2026
  var machine = state.machine;
1997
- var guardMeta = {
1998
- state: state,
1999
- guard: guard,
2000
- _event: _event,
2001
- evaluate: evaluateGuard
2002
- };
2003
2027
  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;
2004
2028
  if (!predicate) {
2005
2029
  throw new Error("Guard '".concat(guard.type, "' is not implemented.'."));
2006
2030
  }
2007
- return predicate(context, _event.data, guardMeta);
2031
+ return predicate({
2032
+ context: context,
2033
+ event: _event.data,
2034
+ state: state,
2035
+ guard: guard,
2036
+ _event: _event,
2037
+ evaluate: evaluateGuard
2038
+ });
2008
2039
  }
2009
2040
  function toGuardDefinition(guardConfig, getPredicate) {
2010
2041
  var _guardConfig$children;
@@ -3861,8 +3892,10 @@ function invoke$1(invokeDef) {
3861
3892
  src: src,
3862
3893
  parent: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self,
3863
3894
  systemId: invokeDef.systemId,
3864
- input: typeof input === 'function' ? input(state.context, _event.data, {
3865
- self: actorContext.self
3895
+ input: typeof input === 'function' ? input({
3896
+ context: state.context,
3897
+ event: _event.data,
3898
+ self: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self
3866
3899
  }) : input
3867
3900
  });
3868
3901
  resolvedInvokeAction = {
@@ -3919,7 +3952,9 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3919
3952
  var actorRef = interpret(referenced.src, {
3920
3953
  id: resolvedName,
3921
3954
  parent: self,
3922
- input: typeof input === 'function' ? input(context, _event.data, {
3955
+ input: typeof input === 'function' ? input({
3956
+ context: context,
3957
+ event: _event.data,
3923
3958
  self: self
3924
3959
  }) : input
3925
3960
  });
@@ -3977,8 +4012,9 @@ function assign$1(assignment) {
3977
4012
  if (!state.context) {
3978
4013
  throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
3979
4014
  }
3980
- var meta = {
3981
- state: state,
4015
+ var args = {
4016
+ context: state.context,
4017
+ event: _event.data,
3982
4018
  action: action,
3983
4019
  _event: _event,
3984
4020
  spawn: createSpawner(actorContext === null || actorContext === void 0 ? void 0 : actorContext.self, state.machine, state.context, _event, capturedActions),
@@ -3987,12 +4023,12 @@ function assign$1(assignment) {
3987
4023
  };
3988
4024
  var partialUpdate = {};
3989
4025
  if (isFunction(assignment)) {
3990
- partialUpdate = assignment(state.context, _event.data, meta);
4026
+ partialUpdate = assignment(args);
3991
4027
  } else {
3992
4028
  for (var _i = 0, _Object$keys = Object.keys(assignment); _i < _Object$keys.length; _i++) {
3993
4029
  var key = _Object$keys[_i];
3994
4030
  var propAssignment = assignment[key];
3995
- partialUpdate[key] = isFunction(propAssignment) ? propAssignment(state.context, _event.data, meta) : propAssignment;
4031
+ partialUpdate[key] = isFunction(propAssignment) ? propAssignment(args) : propAssignment;
3996
4032
  }
3997
4033
  }
3998
4034
  var updatedContext = Object.assign({}, state.context, partialUpdate);
@@ -4032,22 +4068,23 @@ function raise$1(eventOrExpr, options) {
4032
4068
  event: eventOrExpr,
4033
4069
  id: options && options.id !== undefined ? options.id : typeof eventOrExpr === 'function' ? eventOrExpr.name : eventOrExpr.type
4034
4070
  };
4035
- var meta = {
4071
+ var args = {
4072
+ context: state.context,
4073
+ event: _event.data,
4036
4074
  _event: _event,
4037
- state: state,
4038
4075
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
4039
4076
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
4040
4077
  };
4041
4078
  var delaysMap = state.machine.options.delays;
4042
4079
 
4043
4080
  // TODO: helper function for resolving Expr
4044
- var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(state.context, _event.data, meta) : eventOrExpr);
4081
+ var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr);
4045
4082
  var resolvedDelay;
4046
4083
  if (typeof params.delay === 'string') {
4047
4084
  var configDelay = delaysMap && delaysMap[params.delay];
4048
- resolvedDelay = typeof configDelay === 'function' ? configDelay(state.context, _event.data, meta) : configDelay;
4085
+ resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
4049
4086
  } else {
4050
- resolvedDelay = typeof params.delay === 'function' ? params.delay(state.context, _event.data, meta) : params.delay;
4087
+ resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
4051
4088
  }
4052
4089
  var resolvedAction = {
4053
4090
  type: raise,
@@ -4110,10 +4147,11 @@ function resolveActionObject(actionObject, actionFunctionMap) {
4110
4147
  type: actionObject.type,
4111
4148
  params: actionObject.params,
4112
4149
  execute: function execute(actorCtx) {
4113
- return dereferencedAction(state.context, state.event, {
4150
+ return dereferencedAction({
4151
+ context: state.context,
4152
+ event: state.event,
4114
4153
  action: a,
4115
4154
  _event: state._event,
4116
- state: state,
4117
4155
  system: actorCtx.system,
4118
4156
  self: actorCtx.self
4119
4157
  });
@@ -4150,10 +4188,11 @@ function toActionObject(action) {
4150
4188
  "function": action
4151
4189
  },
4152
4190
  execute: function execute(actorCtx) {
4153
- return action(state.context, _event.data, {
4191
+ return action({
4192
+ context: state.context,
4193
+ event: _event.data,
4154
4194
  action: actionObject,
4155
4195
  _event: _event,
4156
- state: state,
4157
4196
  self: actorCtx.self,
4158
4197
  system: actorCtx.system
4159
4198
  });