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
@@ -346,14 +346,21 @@ function toArray(value) {
346
346
  }
347
347
  function mapContext(mapper, context, _event) {
348
348
  if (isFunction(mapper)) {
349
- return mapper(context, _event.data);
349
+ return mapper({
350
+ context: context,
351
+ event: _event.data
352
+ });
350
353
  }
351
354
  var result = {};
355
+ var args = {
356
+ context: context,
357
+ event: _event.data
358
+ };
352
359
  for (var _i4 = 0, _Object$keys2 = Object.keys(mapper); _i4 < _Object$keys2.length; _i4++) {
353
360
  var _key3 = _Object$keys2[_i4];
354
361
  var subMapper = mapper[_key3];
355
362
  if (isFunction(subMapper)) {
356
- result[_key3] = subMapper(context, _event.data);
363
+ result[_key3] = subMapper(args);
357
364
  } else {
358
365
  result[_key3] = subMapper;
359
366
  }
@@ -518,24 +525,25 @@ function send$1(eventOrExpr, options) {
518
525
  // there is too big chance of the ID collision
519
526
  id: options && options.id !== undefined ? options.id : isFunction(eventOrExpr) ? eventOrExpr.name : eventOrExpr.type
520
527
  };
521
- var meta = {
528
+ var args = {
529
+ context: state.context,
530
+ event: _event.data,
522
531
  _event: _event,
523
- state: state,
524
532
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : null,
525
533
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
526
534
  };
527
535
  var delaysMap = state.machine.options.delays;
528
536
 
529
537
  // TODO: helper function for resolving Expr
530
- var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(state.context, _event.data, meta) : eventOrExpr);
538
+ var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(args) : eventOrExpr);
531
539
  var resolvedDelay;
532
540
  if (isString(params.delay)) {
533
541
  var configDelay = delaysMap && delaysMap[params.delay];
534
- resolvedDelay = isFunction(configDelay) ? configDelay(state.context, _event.data, meta) : configDelay;
542
+ resolvedDelay = isFunction(configDelay) ? configDelay(args) : configDelay;
535
543
  } else {
536
- resolvedDelay = isFunction(params.delay) ? params.delay(state.context, _event.data, meta) : params.delay;
544
+ resolvedDelay = isFunction(params.delay) ? params.delay(args) : params.delay;
537
545
  }
538
- var resolvedTarget = isFunction(params.to) ? params.to(state.context, _event.data, meta) : params.to;
546
+ var resolvedTarget = isFunction(params.to) ? params.to(args) : params.to;
539
547
  var targetActorRef;
540
548
  if (typeof resolvedTarget === 'string') {
541
549
  if (resolvedTarget === exports.SpecialTargets.Parent) {
@@ -607,7 +615,7 @@ function sendParent(event, options) {
607
615
  */
608
616
  function respond(event, options) {
609
617
  return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
610
- to: function to(_, __, _ref2) {
618
+ to: function to(_ref2) {
611
619
  var _event = _ref2._event;
612
620
  return _event.origin; // TODO: handle when _event.origin is undefined
613
621
  }
@@ -631,7 +639,8 @@ function forwardTo(target, options) {
631
639
  return resolvedTarget;
632
640
  };
633
641
  }
634
- return send$1(function (_, event) {
642
+ return send$1(function (_ref3) {
643
+ var event = _ref3.event;
635
644
  return event;
636
645
  }, _objectSpread2(_objectSpread2({}, options), {}, {
637
646
  to: target
@@ -646,10 +655,10 @@ function forwardTo(target, options) {
646
655
  * @param options Options to pass into the send action creator.
647
656
  */
648
657
  function escalate(errorData, options) {
649
- return sendParent(function (context, event, meta) {
658
+ return sendParent(function (arg) {
650
659
  return {
651
660
  type: error,
652
- data: isFunction(errorData) ? errorData(context, event, meta) : errorData
661
+ data: isFunction(errorData) ? errorData(arg) : errorData
653
662
  };
654
663
  }, _objectSpread2(_objectSpread2({}, options), {}, {
655
664
  to: exports.SpecialTargets.Parent
@@ -694,6 +703,86 @@ function _createClass(Constructor, protoProps, staticProps) {
694
703
  return Constructor;
695
704
  }
696
705
 
706
+ var Mailbox = /*#__PURE__*/function () {
707
+ function Mailbox(_process) {
708
+ _classCallCheck(this, Mailbox);
709
+ this._process = _process;
710
+ _defineProperty(this, "_active", false);
711
+ _defineProperty(this, "_current", null);
712
+ _defineProperty(this, "_last", null);
713
+ }
714
+ _createClass(Mailbox, [{
715
+ key: "start",
716
+ value: function start() {
717
+ this._active = true;
718
+ this.flush();
719
+ }
720
+ }, {
721
+ key: "clear",
722
+ value: function clear() {
723
+ // we can't set _current to null because we might be currently processing
724
+ // and enqueue following clear shouldnt start processing the enqueued item immediately
725
+ if (this._current) {
726
+ this._current.next = null;
727
+ this._last = this._current;
728
+ }
729
+ }
730
+
731
+ // TODO: rethink this design
732
+ }, {
733
+ key: "prepend",
734
+ value: function prepend(event) {
735
+ if (!this._current) {
736
+ this.enqueue(event);
737
+ return;
738
+ }
739
+
740
+ // we know that something is already queued up
741
+ // so the mailbox is already flushing or it's inactive
742
+ // therefore the only thing that we need to do is to reassign `this._current`
743
+ this._current = {
744
+ value: event,
745
+ next: this._current
746
+ };
747
+ }
748
+ }, {
749
+ key: "enqueue",
750
+ value: function enqueue(event) {
751
+ var enqueued = {
752
+ value: event,
753
+ next: null
754
+ };
755
+ if (this._current) {
756
+ this._last.next = enqueued;
757
+ this._last = enqueued;
758
+ return;
759
+ }
760
+ this._current = enqueued;
761
+ this._last = enqueued;
762
+ if (this._active) {
763
+ this.flush();
764
+ }
765
+ }
766
+ }, {
767
+ key: "flush",
768
+ value: function flush() {
769
+ while (this._current) {
770
+ // atm the given _process is responsible for implementing proper try/catch handling
771
+ // we assume here that this won't throw in a way that can affect this mailbox
772
+ var consumed = this._current;
773
+ this._process(consumed.value);
774
+ // something could have been prepended in the meantime
775
+ // so we need to be defensive here to avoid skipping over a prepended item
776
+ if (consumed === this._current) {
777
+ this._current = this._current.next;
778
+ }
779
+ }
780
+ this._last = null;
781
+ }
782
+ }]);
783
+ return Mailbox;
784
+ }();
785
+
697
786
  var symbolObservable = function () {
698
787
  return typeof Symbol === 'function' && Symbol.observable || '@@observable';
699
788
  }();
@@ -1159,86 +1248,6 @@ function toActorRef(actorRefLike) {
1159
1248
  }), _objectSpread2$1), actorRefLike);
1160
1249
  }
1161
1250
 
1162
- var Mailbox = /*#__PURE__*/function () {
1163
- function Mailbox(_process) {
1164
- _classCallCheck(this, Mailbox);
1165
- this._process = _process;
1166
- _defineProperty(this, "_active", false);
1167
- _defineProperty(this, "_current", null);
1168
- _defineProperty(this, "_last", null);
1169
- }
1170
- _createClass(Mailbox, [{
1171
- key: "start",
1172
- value: function start() {
1173
- this._active = true;
1174
- this.flush();
1175
- }
1176
- }, {
1177
- key: "clear",
1178
- value: function clear() {
1179
- // we can't set _current to null because we might be currently processing
1180
- // and enqueue following clear shouldnt start processing the enqueued item immediately
1181
- if (this._current) {
1182
- this._current.next = null;
1183
- this._last = this._current;
1184
- }
1185
- }
1186
-
1187
- // TODO: rethink this design
1188
- }, {
1189
- key: "prepend",
1190
- value: function prepend(event) {
1191
- if (!this._current) {
1192
- this.enqueue(event);
1193
- return;
1194
- }
1195
-
1196
- // we know that something is already queued up
1197
- // so the mailbox is already flushing or it's inactive
1198
- // therefore the only thing that we need to do is to reassign `this._current`
1199
- this._current = {
1200
- value: event,
1201
- next: this._current
1202
- };
1203
- }
1204
- }, {
1205
- key: "enqueue",
1206
- value: function enqueue(event) {
1207
- var enqueued = {
1208
- value: event,
1209
- next: null
1210
- };
1211
- if (this._current) {
1212
- this._last.next = enqueued;
1213
- this._last = enqueued;
1214
- return;
1215
- }
1216
- this._current = enqueued;
1217
- this._last = enqueued;
1218
- if (this._active) {
1219
- this.flush();
1220
- }
1221
- }
1222
- }, {
1223
- key: "flush",
1224
- value: function flush() {
1225
- while (this._current) {
1226
- // atm the given _process is responsible for implementing proper try/catch handling
1227
- // we assume here that this won't throw in a way that can affect this mailbox
1228
- var consumed = this._current;
1229
- this._process(consumed.value);
1230
- // something could have been prepended in the meantime
1231
- // so we need to be defensive here to avoid skipping over a prepended item
1232
- if (consumed === this._current) {
1233
- this._current = this._current.next;
1234
- }
1235
- }
1236
- this._last = null;
1237
- }
1238
- }]);
1239
- return Mailbox;
1240
- }();
1241
-
1242
1251
  function createSystem() {
1243
1252
  var sessionIdCounter = 0;
1244
1253
  var children = new Map();
@@ -1742,7 +1751,10 @@ function stop$1(actorRef) {
1742
1751
  }
1743
1752
  }, function (_event, _ref) {
1744
1753
  var state = _ref.state;
1745
- var actorRefOrString = isFunction(actor) ? actor(state.context, _event.data) : actor;
1754
+ var actorRefOrString = isFunction(actor) ? actor({
1755
+ context: state.context,
1756
+ event: _event.data
1757
+ }) : actor;
1746
1758
  var actorRef = typeof actorRefOrString === 'string' ? state.children[actorRefOrString] : actorRefOrString;
1747
1759
  return [state, {
1748
1760
  type: 'xstate.stop',
@@ -1765,7 +1777,9 @@ function stop$1(actorRef) {
1765
1777
  });
1766
1778
  }
1767
1779
 
1768
- var defaultLogExpr = function defaultLogExpr(context, event) {
1780
+ var defaultLogExpr = function defaultLogExpr(_ref) {
1781
+ var context = _ref.context,
1782
+ event = _ref.event;
1769
1783
  return {
1770
1784
  context: context,
1771
1785
  event: event
@@ -1790,13 +1804,14 @@ function log$1() {
1790
1804
  label: label,
1791
1805
  expr: expr
1792
1806
  }
1793
- }, function (_event, _ref) {
1807
+ }, function (_event, _ref2) {
1794
1808
  var _actorContext$self;
1795
- var state = _ref.state,
1796
- actorContext = _ref.actorContext;
1797
- var resolvedValue = typeof expr === 'function' ? expr(state.context, _event.data, {
1809
+ var state = _ref2.state,
1810
+ actorContext = _ref2.actorContext;
1811
+ var resolvedValue = typeof expr === 'function' ? expr({
1812
+ context: state.context,
1813
+ event: _event.data,
1798
1814
  _event: _event,
1799
- state: state,
1800
1815
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
1801
1816
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
1802
1817
  }) : expr;
@@ -1837,10 +1852,10 @@ function cancel$1(sendId) {
1837
1852
  var _actorContext$self;
1838
1853
  var state = _ref.state,
1839
1854
  actorContext = _ref.actorContext;
1840
- var resolvedSendId = isFunction(sendId) ? sendId(state.context, _event.data, {
1855
+ var resolvedSendId = isFunction(sendId) ? sendId({
1856
+ context: state.context,
1857
+ event: _event.data,
1841
1858
  _event: _event,
1842
- state: state,
1843
- // TODO: fix types,
1844
1859
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
1845
1860
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
1846
1861
  }) : sendId;
@@ -1904,7 +1919,7 @@ function stateIn(stateValue) {
1904
1919
  params: {
1905
1920
  stateValue: stateValue
1906
1921
  },
1907
- predicate: function predicate(_, __, _ref) {
1922
+ predicate: function predicate(_ref) {
1908
1923
  var state = _ref.state;
1909
1924
  if (isString(stateValue) && isStateId(stateValue)) {
1910
1925
  return state.configuration.some(function (sn) {
@@ -1922,8 +1937,13 @@ function not(guard) {
1922
1937
  op: 'not'
1923
1938
  },
1924
1939
  children: [toGuardDefinition(guard)],
1925
- predicate: function predicate(ctx, _, meta) {
1926
- return !meta.evaluate(meta.guard.children[0], ctx, meta._event, meta.state);
1940
+ predicate: function predicate(_ref2) {
1941
+ var evaluate = _ref2.evaluate,
1942
+ guard = _ref2.guard,
1943
+ context = _ref2.context,
1944
+ _event = _ref2._event,
1945
+ state = _ref2.state;
1946
+ return !evaluate(guard.children[0], context, _event, state);
1927
1947
  }
1928
1948
  };
1929
1949
  }
@@ -1936,9 +1956,14 @@ function and(guards) {
1936
1956
  children: guards.map(function (guard) {
1937
1957
  return toGuardDefinition(guard);
1938
1958
  }),
1939
- predicate: function predicate(ctx, _, meta) {
1940
- return meta.guard.children.every(function (childGuard) {
1941
- return meta.evaluate(childGuard, ctx, meta._event, meta.state);
1959
+ predicate: function predicate(_ref3) {
1960
+ var evaluate = _ref3.evaluate,
1961
+ guard = _ref3.guard,
1962
+ context = _ref3.context,
1963
+ _event = _ref3._event,
1964
+ state = _ref3.state;
1965
+ return guard.children.every(function (childGuard) {
1966
+ return evaluate(childGuard, context, _event, state);
1942
1967
  });
1943
1968
  }
1944
1969
  };
@@ -1952,9 +1977,14 @@ function or(guards) {
1952
1977
  children: guards.map(function (guard) {
1953
1978
  return toGuardDefinition(guard);
1954
1979
  }),
1955
- predicate: function predicate(ctx, _, meta) {
1956
- return meta.guard.children.some(function (childGuard) {
1957
- return meta.evaluate(childGuard, ctx, meta._event, meta.state);
1980
+ predicate: function predicate(_ref4) {
1981
+ var evaluate = _ref4.evaluate,
1982
+ guard = _ref4.guard,
1983
+ context = _ref4.context,
1984
+ _event = _ref4._event,
1985
+ state = _ref4.state;
1986
+ return guard.children.some(function (childGuard) {
1987
+ return evaluate(childGuard, context, _event, state);
1958
1988
  });
1959
1989
  }
1960
1990
  };
@@ -1962,17 +1992,18 @@ function or(guards) {
1962
1992
  function evaluateGuard(guard, context, _event, state) {
1963
1993
  var _machine$options$guar, _machine$options, _machine$options$guar2;
1964
1994
  var machine = state.machine;
1965
- var guardMeta = {
1966
- state: state,
1967
- guard: guard,
1968
- _event: _event,
1969
- evaluate: evaluateGuard
1970
- };
1971
1995
  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;
1972
1996
  if (!predicate) {
1973
1997
  throw new Error("Guard '".concat(guard.type, "' is not implemented.'."));
1974
1998
  }
1975
- return predicate(context, _event.data, guardMeta);
1999
+ return predicate({
2000
+ context: context,
2001
+ event: _event.data,
2002
+ state: state,
2003
+ guard: guard,
2004
+ _event: _event,
2005
+ evaluate: evaluateGuard
2006
+ });
1976
2007
  }
1977
2008
  function toGuardDefinition(guardConfig, getPredicate) {
1978
2009
  var _guardConfig$children;
@@ -3829,8 +3860,10 @@ function invoke$1(invokeDef) {
3829
3860
  src: src,
3830
3861
  parent: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self,
3831
3862
  systemId: invokeDef.systemId,
3832
- input: typeof input === 'function' ? input(state.context, _event.data, {
3833
- self: actorContext.self
3863
+ input: typeof input === 'function' ? input({
3864
+ context: state.context,
3865
+ event: _event.data,
3866
+ self: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self
3834
3867
  }) : input
3835
3868
  });
3836
3869
  resolvedInvokeAction = {
@@ -3887,7 +3920,9 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3887
3920
  var actorRef = interpret(referenced.src, {
3888
3921
  id: resolvedName,
3889
3922
  parent: self,
3890
- input: typeof input === 'function' ? input(context, _event.data, {
3923
+ input: typeof input === 'function' ? input({
3924
+ context: context,
3925
+ event: _event.data,
3891
3926
  self: self
3892
3927
  }) : input
3893
3928
  });
@@ -3945,8 +3980,9 @@ function assign$1(assignment) {
3945
3980
  if (!state.context) {
3946
3981
  throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
3947
3982
  }
3948
- var meta = {
3949
- state: state,
3983
+ var args = {
3984
+ context: state.context,
3985
+ event: _event.data,
3950
3986
  action: action,
3951
3987
  _event: _event,
3952
3988
  spawn: createSpawner(actorContext === null || actorContext === void 0 ? void 0 : actorContext.self, state.machine, state.context, _event, capturedActions),
@@ -3955,12 +3991,12 @@ function assign$1(assignment) {
3955
3991
  };
3956
3992
  var partialUpdate = {};
3957
3993
  if (isFunction(assignment)) {
3958
- partialUpdate = assignment(state.context, _event.data, meta);
3994
+ partialUpdate = assignment(args);
3959
3995
  } else {
3960
3996
  for (var _i = 0, _Object$keys = Object.keys(assignment); _i < _Object$keys.length; _i++) {
3961
3997
  var key = _Object$keys[_i];
3962
3998
  var propAssignment = assignment[key];
3963
- partialUpdate[key] = isFunction(propAssignment) ? propAssignment(state.context, _event.data, meta) : propAssignment;
3999
+ partialUpdate[key] = isFunction(propAssignment) ? propAssignment(args) : propAssignment;
3964
4000
  }
3965
4001
  }
3966
4002
  var updatedContext = Object.assign({}, state.context, partialUpdate);
@@ -4000,22 +4036,23 @@ function raise$1(eventOrExpr, options) {
4000
4036
  event: eventOrExpr,
4001
4037
  id: options && options.id !== undefined ? options.id : typeof eventOrExpr === 'function' ? eventOrExpr.name : eventOrExpr.type
4002
4038
  };
4003
- var meta = {
4039
+ var args = {
4040
+ context: state.context,
4041
+ event: _event.data,
4004
4042
  _event: _event,
4005
- state: state,
4006
4043
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
4007
4044
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
4008
4045
  };
4009
4046
  var delaysMap = state.machine.options.delays;
4010
4047
 
4011
4048
  // TODO: helper function for resolving Expr
4012
- var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(state.context, _event.data, meta) : eventOrExpr);
4049
+ var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr);
4013
4050
  var resolvedDelay;
4014
4051
  if (typeof params.delay === 'string') {
4015
4052
  var configDelay = delaysMap && delaysMap[params.delay];
4016
- resolvedDelay = typeof configDelay === 'function' ? configDelay(state.context, _event.data, meta) : configDelay;
4053
+ resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
4017
4054
  } else {
4018
- resolvedDelay = typeof params.delay === 'function' ? params.delay(state.context, _event.data, meta) : params.delay;
4055
+ resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
4019
4056
  }
4020
4057
  var resolvedAction = {
4021
4058
  type: raise,
@@ -4078,10 +4115,11 @@ function resolveActionObject(actionObject, actionFunctionMap) {
4078
4115
  type: actionObject.type,
4079
4116
  params: actionObject.params,
4080
4117
  execute: function execute(actorCtx) {
4081
- return dereferencedAction(state.context, state.event, {
4118
+ return dereferencedAction({
4119
+ context: state.context,
4120
+ event: state.event,
4082
4121
  action: a,
4083
4122
  _event: state._event,
4084
- state: state,
4085
4123
  system: actorCtx.system,
4086
4124
  self: actorCtx.self
4087
4125
  });
@@ -4118,10 +4156,11 @@ function toActionObject(action) {
4118
4156
  "function": action
4119
4157
  },
4120
4158
  execute: function execute(actorCtx) {
4121
- return action(state.context, _event.data, {
4159
+ return action({
4160
+ context: state.context,
4161
+ event: _event.data,
4122
4162
  action: actionObject,
4123
4163
  _event: _event,
4124
- state: state,
4125
4164
  self: actorCtx.self,
4126
4165
  system: actorCtx.system
4127
4166
  });
@@ -1,4 +1,4 @@
1
- import { MachineConfig, EventObject, AnyEventObject, MachineContext, ActorMap, InternalMachineImplementations, ParameterizedObject } from './types.js';
2
- import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from './typegenTypes.js';
3
- import { StateMachine } from './StateMachine.js';
1
+ import { MachineConfig, EventObject, AnyEventObject, MachineContext, ActorMap, InternalMachineImplementations, ParameterizedObject } from './types.ts';
2
+ import { TypegenConstraint, TypegenDisabled, ResolveTypegenMeta } from './typegenTypes.ts';
3
+ import { StateMachine } from './StateMachine.ts';
4
4
  export declare function createMachine<TContext extends MachineContext, TEvent extends EventObject = AnyEventObject, TActorMap extends ActorMap = ActorMap, TTypesMeta extends TypegenConstraint = TypegenDisabled>(config: MachineConfig<TContext, TEvent, ParameterizedObject, TActorMap, TTypesMeta>, implementations?: InternalMachineImplementations<TContext, TEvent, ResolveTypegenMeta<TTypesMeta, TEvent, ParameterizedObject, TActorMap>>): StateMachine<TContext, TEvent, ParameterizedObject, TActorMap, ResolveTypegenMeta<TTypesMeta, TEvent, ParameterizedObject, TActorMap>>;
@@ -1,4 +1,4 @@
1
- import { Clock } from './interpreter.js';
1
+ import { Clock } from './interpreter.ts';
2
2
  export interface SimulatedClock extends Clock {
3
3
  start(speed: number): void;
4
4
  increment(ms: number): void;
@@ -1,6 +1,6 @@
1
- import type { StateNode } from './StateNode.js';
2
- import { TypegenDisabled, TypegenEnabled } from './typegenTypes.js';
3
- import type { ActorRef, AnyState, AnyStateMachine, BaseActionObject, EventObject, HistoryValue, MachineContext, PersistedMachineState, Prop, SCXML, StateConfig, StateValue, TransitionDefinition } from './types.js';
1
+ import type { StateNode } from './StateNode.ts';
2
+ import { TypegenDisabled, TypegenEnabled } from './typegenTypes.ts';
3
+ import type { ActorRef, AnyState, AnyStateMachine, BaseActionObject, EventObject, HistoryValue, MachineContext, PersistedMachineState, Prop, SCXML, StateConfig, StateValue, TransitionDefinition } from './types.ts';
4
4
  export declare function isStateConfig<TContext extends MachineContext, TEvent extends EventObject>(state: any): state is StateConfig<TContext, TEvent>;
5
5
  /**
6
6
  * @deprecated Use `isStateConfig(object)` or `state instanceof State` instead.
@@ -1,7 +1,7 @@
1
- import { State } from './State.js';
2
- import { StateNode } from './StateNode.js';
3
- import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, ResolveTypegenMeta, TypegenDisabled } from './typegenTypes.js';
4
- import type { ActorContext, ActorMap, ActorBehavior, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineSchema, NoInfer, SCXML, StateConfig, StateMachineDefinition, StateValue, TransitionDefinition, AnyActorContext, PersistedMachineState, ParameterizedObject } from './types.js';
1
+ import { State } from './State.ts';
2
+ import { StateNode } from './StateNode.ts';
3
+ import type { AreAllImplementationsAssumedToBeProvided, MarkAllImplementationsAsProvided, ResolveTypegenMeta, TypegenDisabled } from './typegenTypes.ts';
4
+ import type { ActorContext, ActorMap, ActorBehavior, EventObject, InternalMachineImplementations, MachineConfig, MachineContext, MachineImplementationsSimplified, MachineSchema, NoInfer, SCXML, StateConfig, StateMachineDefinition, StateValue, TransitionDefinition, PersistedMachineState, ParameterizedObject, AnyActorContext } from './types.ts';
5
5
  export declare const NULL_EVENT = "";
6
6
  export declare const STATE_IDENTIFIER = "#";
7
7
  export declare const WILDCARD = "*";
@@ -1,6 +1,6 @@
1
- import type { EventObject, StateNodeDefinition, TransitionDefinition, DelayedTransitionDefinition, StateNodeConfig, StateNodesConfig, InvokeDefinition, Mapper, PropertyMapper, SCXML, TransitionDefinitionMap, InitialTransitionDefinition, MachineContext, BaseActionObject } from './types.js';
2
- import type { State } from './State.js';
3
- import type { StateMachine } from './StateMachine.js';
1
+ import type { EventObject, StateNodeDefinition, TransitionDefinition, DelayedTransitionDefinition, StateNodeConfig, StateNodesConfig, InvokeDefinition, Mapper, PropertyMapper, SCXML, TransitionDefinitionMap, InitialTransitionDefinition, MachineContext, BaseActionObject } from './types.ts';
2
+ import type { State } from './State.ts';
3
+ import type { StateMachine } from './StateMachine.ts';
4
4
  interface StateNodeOptions<TContext extends MachineContext, TEvent extends EventObject> {
5
5
  _key: string;
6
6
  _parent?: StateNode<TContext, TEvent>;
@@ -1,4 +1,4 @@
1
- import { ActionTypes } from './types.js';
1
+ import { ActionTypes } from './types.ts';
2
2
  export declare const stop = ActionTypes.Stop;
3
3
  export declare const raise = ActionTypes.Raise;
4
4
  export declare const send = ActionTypes.Send;
@@ -1,4 +1,4 @@
1
- import type { EventObject, Assigner, PropertyAssigner, MachineContext, DynamicAssignAction, LowInfer } from '../types.js';
1
+ import type { EventObject, Assigner, PropertyAssigner, MachineContext, DynamicAssignAction, LowInfer } from '../types.ts';
2
2
  /**
3
3
  * Updates the current context of the machine.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { EventObject, ExprWithMeta, MachineContext } from '../types.js';
2
- import { BaseDynamicActionObject, CancelActionObject, DynamicCancelActionObject } from '../index.js';
1
+ import { EventObject, ExprWithMeta, MachineContext } from '../types.ts';
2
+ import { BaseDynamicActionObject, CancelActionObject, DynamicCancelActionObject } from '../index.ts';
3
3
  /**
4
4
  * Cancels an in-flight `send(...)` action. A canceled sent action will not
5
5
  * be executed, nor will its event be sent, unless it has already been sent
@@ -1,3 +1,3 @@
1
- import { EventObject, ChooseCondition, MachineContext } from '../types.js';
2
- import { BaseDynamicActionObject, ChooseAction, ResolvedChooseAction } from '../index.js';
1
+ import { EventObject, ChooseCondition, MachineContext } from '../types.ts';
2
+ import { BaseDynamicActionObject, ChooseAction, ResolvedChooseAction } from '../index.ts';
3
3
  export declare function choose<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(guards: Array<ChooseCondition<TContext, TExpressionEvent>>): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, ResolvedChooseAction, ChooseAction<TContext, TExpressionEvent>['params']>;
@@ -1,3 +1,3 @@
1
- import { EventObject, InvokeDefinition, MachineContext } from '../types.js';
2
- import { BaseDynamicActionObject, DynamicInvokeActionObject, InvokeActionObject } from '../index.js';
1
+ import { EventObject, InvokeDefinition, MachineContext } from '../types.ts';
2
+ import { BaseDynamicActionObject, DynamicInvokeActionObject, InvokeActionObject } from '../index.ts';
3
3
  export declare function invoke<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject>(invokeDef: InvokeDefinition<TContext, TEvent>): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, InvokeActionObject, DynamicInvokeActionObject<TContext, TEvent>['params']>;
@@ -1,5 +1,5 @@
1
- import { EventObject, LogExpr, MachineContext, LogActionObject } from '../types.js';
2
- import { BaseDynamicActionObject, DynamicLogAction } from '../index.js';
1
+ import { EventObject, LogExpr, MachineContext, LogActionObject } from '../types.ts';
2
+ import { BaseDynamicActionObject, DynamicLogAction } from '../index.ts';
3
3
  /**
4
4
  *
5
5
  * @param expr The expression function to evaluate which will be logged.
@@ -1,3 +1,6 @@
1
- import { EventObject, SingleOrArray, MachineContext } from '../types.js';
1
+ import { EventObject, SingleOrArray, MachineContext } from '../types.ts';
2
2
  import { BaseActionObject, BaseDynamicActionObject, DynamicPureActionObject, PureActionObject } from '..';
3
- export declare function pure<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(getActions: (context: TContext, event: TExpressionEvent) => SingleOrArray<BaseActionObject | string> | undefined): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, PureActionObject, DynamicPureActionObject<TContext, TExpressionEvent>['params']>;
3
+ export declare function pure<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject = TExpressionEvent>(getActions: ({ context, event }: {
4
+ context: TContext;
5
+ event: TExpressionEvent;
6
+ }) => SingleOrArray<BaseActionObject | string> | undefined): BaseDynamicActionObject<TContext, TExpressionEvent, TEvent, PureActionObject, DynamicPureActionObject<TContext, TExpressionEvent>['params']>;
@@ -1,4 +1,4 @@
1
- import { EventObject, MachineContext, RaiseActionObject, BaseDynamicActionObject, RaiseActionOptions, SendExpr, RaiseActionParams, NoInfer } from '../types.js';
1
+ import { EventObject, MachineContext, RaiseActionObject, BaseDynamicActionObject, RaiseActionOptions, SendExpr, RaiseActionParams, NoInfer } from '../types.ts';
2
2
  /**
3
3
  * Raises an event. This places the event in the internal event queue, so that
4
4
  * the event is immediately consumed by the machine in the current step.
@@ -1,5 +1,5 @@
1
- import { EventObject, SendActionParams, SendExpr, AnyEventObject, MachineContext } from '../types.js';
2
- import { AnyActorRef, BaseDynamicActionObject, Cast, EventFrom, ExprWithMeta, InferEvent, SendActionObject, SendActionOptions } from '../index.js';
1
+ import { EventObject, SendActionParams, SendExpr, AnyEventObject, MachineContext } from '../types.ts';
2
+ import { AnyActorRef, BaseDynamicActionObject, Cast, EventFrom, ExprWithMeta, InferEvent, SendActionObject, SendActionOptions } from '../index.ts';
3
3
  /**
4
4
  * Sends an event. This returns an action that will be read by an interpreter to
5
5
  * send the event in the next step, after the current step is finished executing.
@@ -1,4 +1,4 @@
1
- import { ActorRef, BaseDynamicActionObject, DynamicStopActionObject, EventObject, Expr, MachineContext, StopActionObject } from '../types.js';
1
+ import { ActorRef, BaseDynamicActionObject, DynamicStopActionObject, EventObject, Expr, MachineContext, StopActionObject } from '../types.ts';
2
2
  /**
3
3
  * Stops an actor.
4
4
  *