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
@@ -1 +1 @@
1
- {"version":3,"file":"xstate-dev.umd.min.js","sources":["../../src/dev/index.ts"],"sourcesContent":["import { IS_PRODUCTION } from '../environment.js';\nimport { AnyInterpreter, DevToolsAdapter } from '../types.js';\n\ninterface DevInterface {\n services: Set<AnyInterpreter>;\n register(service: AnyInterpreter): void;\n onRegister(listener: ServiceListener): void;\n}\ntype ServiceListener = (service: AnyInterpreter) => void;\n\nexport interface XStateDevInterface {\n register: (service: AnyInterpreter) => void;\n unregister: (service: AnyInterpreter) => void;\n onRegister: (\n listener: ServiceListener\n ) => {\n unsubscribe: () => void;\n };\n services: Set<AnyInterpreter>;\n}\n\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis\nexport function getGlobal(): typeof globalThis | undefined {\n if (typeof globalThis !== 'undefined') {\n return globalThis;\n }\n if (typeof self !== 'undefined') {\n return self;\n }\n if (typeof window !== 'undefined') {\n return window;\n }\n if (typeof global !== 'undefined') {\n return global;\n }\n if (!IS_PRODUCTION) {\n console.warn(\n 'XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues'\n );\n }\n}\n\nfunction getDevTools(): DevInterface | undefined {\n const w = getGlobal();\n if (!!(w as any).__xstate__) {\n return (w as any).__xstate__;\n }\n\n return undefined;\n}\n\nexport function registerService(service: AnyInterpreter) {\n if (typeof window === 'undefined') {\n return;\n }\n\n const devTools = getDevTools();\n\n if (devTools) {\n devTools.register(service);\n }\n}\n\nexport const devToolsAdapter: DevToolsAdapter = (service) => {\n if (typeof window === 'undefined') {\n return;\n }\n\n const devTools = getDevTools();\n\n if (devTools) {\n devTools.register(service);\n }\n};\n"],"names":["getGlobal","globalThis","self","window","getDevTools","w","__xstate__","service","devTools","register"],"mappings":"iPAsBO,SAASA,IACd,MAA0B,oBAAfC,WACFA,WAEW,oBAATC,KACFA,KAGAC,OAYX,SAASC,IACP,IAAMC,EAAIL,IACV,GAAOK,EAAUC,WACf,OAAQD,EAAUC,6BAkB0B,SAACC,GAK/C,IAAMC,EAAWJ,IAEbI,GACFA,EAASC,SAASF,oCApBf,SAAyBA,GAK9B,IAAMC,EAAWJ,IAEbI,GACFA,EAASC,SAASF"}
1
+ {"version":3,"file":"xstate-dev.umd.min.js","sources":["../../src/dev/index.ts"],"sourcesContent":["import { IS_PRODUCTION } from '../environment.ts';\nimport { AnyInterpreter, DevToolsAdapter } from '../types.ts';\n\ninterface DevInterface {\n services: Set<AnyInterpreter>;\n register(service: AnyInterpreter): void;\n onRegister(listener: ServiceListener): void;\n}\ntype ServiceListener = (service: AnyInterpreter) => void;\n\nexport interface XStateDevInterface {\n register: (service: AnyInterpreter) => void;\n unregister: (service: AnyInterpreter) => void;\n onRegister: (listener: ServiceListener) => {\n unsubscribe: () => void;\n };\n services: Set<AnyInterpreter>;\n}\n\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis\nexport function getGlobal(): typeof globalThis | undefined {\n if (typeof globalThis !== 'undefined') {\n return globalThis;\n }\n if (typeof self !== 'undefined') {\n return self;\n }\n if (typeof window !== 'undefined') {\n return window;\n }\n if (typeof global !== 'undefined') {\n return global;\n }\n if (!IS_PRODUCTION) {\n console.warn(\n 'XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues'\n );\n }\n}\n\nfunction getDevTools(): DevInterface | undefined {\n const w = getGlobal();\n if (!!(w as any).__xstate__) {\n return (w as any).__xstate__;\n }\n\n return undefined;\n}\n\nexport function registerService(service: AnyInterpreter) {\n if (typeof window === 'undefined') {\n return;\n }\n\n const devTools = getDevTools();\n\n if (devTools) {\n devTools.register(service);\n }\n}\n\nexport const devToolsAdapter: DevToolsAdapter = (service) => {\n if (typeof window === 'undefined') {\n return;\n }\n\n const devTools = getDevTools();\n\n if (devTools) {\n devTools.register(service);\n }\n};\n"],"names":["getGlobal","globalThis","self","window","getDevTools","w","__xstate__","service","devTools","register"],"mappings":"iPAoBO,SAASA,IACd,MAA0B,oBAAfC,WACFA,WAEW,oBAATC,KACFA,KAGAC,OAYX,SAASC,IACP,IAAMC,EAAIL,IACV,GAAOK,EAAUC,WACf,OAAQD,EAAUC,6BAkB0B,SAACC,GAK/C,IAAMC,EAAWJ,IAEbI,GACFA,EAASC,SAASF,oCApBf,SAAyBA,GAK9B,IAAMC,EAAWJ,IAEbI,GACFA,EAASC,SAASF"}
@@ -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
  }
@@ -502,24 +509,25 @@ function send$1(eventOrExpr, options) {
502
509
  // there is too big chance of the ID collision
503
510
  id: options && options.id !== undefined ? options.id : isFunction(eventOrExpr) ? eventOrExpr.name : eventOrExpr.type
504
511
  };
505
- var meta = {
512
+ var args = {
513
+ context: state.context,
514
+ event: _event.data,
506
515
  _event: _event,
507
- state: state,
508
516
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : null,
509
517
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
510
518
  };
511
519
  var delaysMap = state.machine.options.delays;
512
520
 
513
521
  // TODO: helper function for resolving Expr
514
- var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(state.context, _event.data, meta) : eventOrExpr);
522
+ var resolvedEvent = toSCXMLEvent(isFunction(eventOrExpr) ? eventOrExpr(args) : eventOrExpr);
515
523
  var resolvedDelay;
516
524
  if (isString(params.delay)) {
517
525
  var configDelay = delaysMap && delaysMap[params.delay];
518
- resolvedDelay = isFunction(configDelay) ? configDelay(state.context, _event.data, meta) : configDelay;
526
+ resolvedDelay = isFunction(configDelay) ? configDelay(args) : configDelay;
519
527
  } else {
520
- resolvedDelay = isFunction(params.delay) ? params.delay(state.context, _event.data, meta) : params.delay;
528
+ resolvedDelay = isFunction(params.delay) ? params.delay(args) : params.delay;
521
529
  }
522
- var resolvedTarget = isFunction(params.to) ? params.to(state.context, _event.data, meta) : params.to;
530
+ var resolvedTarget = isFunction(params.to) ? params.to(args) : params.to;
523
531
  var targetActorRef;
524
532
  if (typeof resolvedTarget === 'string') {
525
533
  if (resolvedTarget === exports.SpecialTargets.Parent) {
@@ -591,7 +599,7 @@ function sendParent(event, options) {
591
599
  */
592
600
  function respond(event, options) {
593
601
  return send$1(event, _objectSpread2(_objectSpread2({}, options), {}, {
594
- to: function to(_, __, _ref2) {
602
+ to: function to(_ref2) {
595
603
  var _event = _ref2._event;
596
604
  return _event.origin; // TODO: handle when _event.origin is undefined
597
605
  }
@@ -615,7 +623,8 @@ function forwardTo(target, options) {
615
623
  return resolvedTarget;
616
624
  };
617
625
  }
618
- return send$1(function (_, event) {
626
+ return send$1(function (_ref3) {
627
+ var event = _ref3.event;
619
628
  return event;
620
629
  }, _objectSpread2(_objectSpread2({}, options), {}, {
621
630
  to: target
@@ -630,10 +639,10 @@ function forwardTo(target, options) {
630
639
  * @param options Options to pass into the send action creator.
631
640
  */
632
641
  function escalate(errorData, options) {
633
- return sendParent(function (context, event, meta) {
642
+ return sendParent(function (arg) {
634
643
  return {
635
644
  type: error,
636
- data: isFunction(errorData) ? errorData(context, event, meta) : errorData
645
+ data: isFunction(errorData) ? errorData(arg) : errorData
637
646
  };
638
647
  }, _objectSpread2(_objectSpread2({}, options), {}, {
639
648
  to: exports.SpecialTargets.Parent
@@ -678,6 +687,86 @@ function _createClass(Constructor, protoProps, staticProps) {
678
687
  return Constructor;
679
688
  }
680
689
 
690
+ var Mailbox = /*#__PURE__*/function () {
691
+ function Mailbox(_process) {
692
+ _classCallCheck(this, Mailbox);
693
+ this._process = _process;
694
+ _defineProperty(this, "_active", false);
695
+ _defineProperty(this, "_current", null);
696
+ _defineProperty(this, "_last", null);
697
+ }
698
+ _createClass(Mailbox, [{
699
+ key: "start",
700
+ value: function start() {
701
+ this._active = true;
702
+ this.flush();
703
+ }
704
+ }, {
705
+ key: "clear",
706
+ value: function clear() {
707
+ // we can't set _current to null because we might be currently processing
708
+ // and enqueue following clear shouldnt start processing the enqueued item immediately
709
+ if (this._current) {
710
+ this._current.next = null;
711
+ this._last = this._current;
712
+ }
713
+ }
714
+
715
+ // TODO: rethink this design
716
+ }, {
717
+ key: "prepend",
718
+ value: function prepend(event) {
719
+ if (!this._current) {
720
+ this.enqueue(event);
721
+ return;
722
+ }
723
+
724
+ // we know that something is already queued up
725
+ // so the mailbox is already flushing or it's inactive
726
+ // therefore the only thing that we need to do is to reassign `this._current`
727
+ this._current = {
728
+ value: event,
729
+ next: this._current
730
+ };
731
+ }
732
+ }, {
733
+ key: "enqueue",
734
+ value: function enqueue(event) {
735
+ var enqueued = {
736
+ value: event,
737
+ next: null
738
+ };
739
+ if (this._current) {
740
+ this._last.next = enqueued;
741
+ this._last = enqueued;
742
+ return;
743
+ }
744
+ this._current = enqueued;
745
+ this._last = enqueued;
746
+ if (this._active) {
747
+ this.flush();
748
+ }
749
+ }
750
+ }, {
751
+ key: "flush",
752
+ value: function flush() {
753
+ while (this._current) {
754
+ // atm the given _process is responsible for implementing proper try/catch handling
755
+ // we assume here that this won't throw in a way that can affect this mailbox
756
+ var consumed = this._current;
757
+ this._process(consumed.value);
758
+ // something could have been prepended in the meantime
759
+ // so we need to be defensive here to avoid skipping over a prepended item
760
+ if (consumed === this._current) {
761
+ this._current = this._current.next;
762
+ }
763
+ }
764
+ this._last = null;
765
+ }
766
+ }]);
767
+ return Mailbox;
768
+ }();
769
+
681
770
  var symbolObservable = function () {
682
771
  return typeof Symbol === 'function' && Symbol.observable || '@@observable';
683
772
  }();
@@ -1143,86 +1232,6 @@ function toActorRef(actorRefLike) {
1143
1232
  }), _objectSpread2$1), actorRefLike);
1144
1233
  }
1145
1234
 
1146
- var Mailbox = /*#__PURE__*/function () {
1147
- function Mailbox(_process) {
1148
- _classCallCheck(this, Mailbox);
1149
- this._process = _process;
1150
- _defineProperty(this, "_active", false);
1151
- _defineProperty(this, "_current", null);
1152
- _defineProperty(this, "_last", null);
1153
- }
1154
- _createClass(Mailbox, [{
1155
- key: "start",
1156
- value: function start() {
1157
- this._active = true;
1158
- this.flush();
1159
- }
1160
- }, {
1161
- key: "clear",
1162
- value: function clear() {
1163
- // we can't set _current to null because we might be currently processing
1164
- // and enqueue following clear shouldnt start processing the enqueued item immediately
1165
- if (this._current) {
1166
- this._current.next = null;
1167
- this._last = this._current;
1168
- }
1169
- }
1170
-
1171
- // TODO: rethink this design
1172
- }, {
1173
- key: "prepend",
1174
- value: function prepend(event) {
1175
- if (!this._current) {
1176
- this.enqueue(event);
1177
- return;
1178
- }
1179
-
1180
- // we know that something is already queued up
1181
- // so the mailbox is already flushing or it's inactive
1182
- // therefore the only thing that we need to do is to reassign `this._current`
1183
- this._current = {
1184
- value: event,
1185
- next: this._current
1186
- };
1187
- }
1188
- }, {
1189
- key: "enqueue",
1190
- value: function enqueue(event) {
1191
- var enqueued = {
1192
- value: event,
1193
- next: null
1194
- };
1195
- if (this._current) {
1196
- this._last.next = enqueued;
1197
- this._last = enqueued;
1198
- return;
1199
- }
1200
- this._current = enqueued;
1201
- this._last = enqueued;
1202
- if (this._active) {
1203
- this.flush();
1204
- }
1205
- }
1206
- }, {
1207
- key: "flush",
1208
- value: function flush() {
1209
- while (this._current) {
1210
- // atm the given _process is responsible for implementing proper try/catch handling
1211
- // we assume here that this won't throw in a way that can affect this mailbox
1212
- var consumed = this._current;
1213
- this._process(consumed.value);
1214
- // something could have been prepended in the meantime
1215
- // so we need to be defensive here to avoid skipping over a prepended item
1216
- if (consumed === this._current) {
1217
- this._current = this._current.next;
1218
- }
1219
- }
1220
- this._last = null;
1221
- }
1222
- }]);
1223
- return Mailbox;
1224
- }();
1225
-
1226
1235
  function createSystem() {
1227
1236
  var sessionIdCounter = 0;
1228
1237
  var children = new Map();
@@ -1721,7 +1730,10 @@ function stop$1(actorRef) {
1721
1730
  }
1722
1731
  }, function (_event, _ref) {
1723
1732
  var state = _ref.state;
1724
- var actorRefOrString = isFunction(actor) ? actor(state.context, _event.data) : actor;
1733
+ var actorRefOrString = isFunction(actor) ? actor({
1734
+ context: state.context,
1735
+ event: _event.data
1736
+ }) : actor;
1725
1737
  var actorRef = typeof actorRefOrString === 'string' ? state.children[actorRefOrString] : actorRefOrString;
1726
1738
  return [state, {
1727
1739
  type: 'xstate.stop',
@@ -1744,7 +1756,9 @@ function stop$1(actorRef) {
1744
1756
  });
1745
1757
  }
1746
1758
 
1747
- var defaultLogExpr = function defaultLogExpr(context, event) {
1759
+ var defaultLogExpr = function defaultLogExpr(_ref) {
1760
+ var context = _ref.context,
1761
+ event = _ref.event;
1748
1762
  return {
1749
1763
  context: context,
1750
1764
  event: event
@@ -1769,13 +1783,14 @@ function log$1() {
1769
1783
  label: label,
1770
1784
  expr: expr
1771
1785
  }
1772
- }, function (_event, _ref) {
1786
+ }, function (_event, _ref2) {
1773
1787
  var _actorContext$self;
1774
- var state = _ref.state,
1775
- actorContext = _ref.actorContext;
1776
- var resolvedValue = typeof expr === 'function' ? expr(state.context, _event.data, {
1788
+ var state = _ref2.state,
1789
+ actorContext = _ref2.actorContext;
1790
+ var resolvedValue = typeof expr === 'function' ? expr({
1791
+ context: state.context,
1792
+ event: _event.data,
1777
1793
  _event: _event,
1778
- state: state,
1779
1794
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
1780
1795
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
1781
1796
  }) : expr;
@@ -1816,10 +1831,10 @@ function cancel$1(sendId) {
1816
1831
  var _actorContext$self;
1817
1832
  var state = _ref.state,
1818
1833
  actorContext = _ref.actorContext;
1819
- var resolvedSendId = isFunction(sendId) ? sendId(state.context, _event.data, {
1834
+ var resolvedSendId = isFunction(sendId) ? sendId({
1835
+ context: state.context,
1836
+ event: _event.data,
1820
1837
  _event: _event,
1821
- state: state,
1822
- // TODO: fix types,
1823
1838
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
1824
1839
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
1825
1840
  }) : sendId;
@@ -1883,7 +1898,7 @@ function stateIn(stateValue) {
1883
1898
  params: {
1884
1899
  stateValue: stateValue
1885
1900
  },
1886
- predicate: function predicate(_, __, _ref) {
1901
+ predicate: function predicate(_ref) {
1887
1902
  var state = _ref.state;
1888
1903
  if (isString(stateValue) && isStateId(stateValue)) {
1889
1904
  return state.configuration.some(function (sn) {
@@ -1901,8 +1916,13 @@ function not(guard) {
1901
1916
  op: 'not'
1902
1917
  },
1903
1918
  children: [toGuardDefinition(guard)],
1904
- predicate: function predicate(ctx, _, meta) {
1905
- return !meta.evaluate(meta.guard.children[0], ctx, meta._event, meta.state);
1919
+ predicate: function predicate(_ref2) {
1920
+ var evaluate = _ref2.evaluate,
1921
+ guard = _ref2.guard,
1922
+ context = _ref2.context,
1923
+ _event = _ref2._event,
1924
+ state = _ref2.state;
1925
+ return !evaluate(guard.children[0], context, _event, state);
1906
1926
  }
1907
1927
  };
1908
1928
  }
@@ -1915,9 +1935,14 @@ function and(guards) {
1915
1935
  children: guards.map(function (guard) {
1916
1936
  return toGuardDefinition(guard);
1917
1937
  }),
1918
- predicate: function predicate(ctx, _, meta) {
1919
- return meta.guard.children.every(function (childGuard) {
1920
- return meta.evaluate(childGuard, ctx, meta._event, meta.state);
1938
+ predicate: function predicate(_ref3) {
1939
+ var evaluate = _ref3.evaluate,
1940
+ guard = _ref3.guard,
1941
+ context = _ref3.context,
1942
+ _event = _ref3._event,
1943
+ state = _ref3.state;
1944
+ return guard.children.every(function (childGuard) {
1945
+ return evaluate(childGuard, context, _event, state);
1921
1946
  });
1922
1947
  }
1923
1948
  };
@@ -1931,9 +1956,14 @@ function or(guards) {
1931
1956
  children: guards.map(function (guard) {
1932
1957
  return toGuardDefinition(guard);
1933
1958
  }),
1934
- predicate: function predicate(ctx, _, meta) {
1935
- return meta.guard.children.some(function (childGuard) {
1936
- return meta.evaluate(childGuard, ctx, meta._event, meta.state);
1959
+ predicate: function predicate(_ref4) {
1960
+ var evaluate = _ref4.evaluate,
1961
+ guard = _ref4.guard,
1962
+ context = _ref4.context,
1963
+ _event = _ref4._event,
1964
+ state = _ref4.state;
1965
+ return guard.children.some(function (childGuard) {
1966
+ return evaluate(childGuard, context, _event, state);
1937
1967
  });
1938
1968
  }
1939
1969
  };
@@ -1941,17 +1971,18 @@ function or(guards) {
1941
1971
  function evaluateGuard(guard, context, _event, state) {
1942
1972
  var _machine$options$guar, _machine$options, _machine$options$guar2;
1943
1973
  var machine = state.machine;
1944
- var guardMeta = {
1945
- state: state,
1946
- guard: guard,
1947
- _event: _event,
1948
- evaluate: evaluateGuard
1949
- };
1950
1974
  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;
1951
1975
  if (!predicate) {
1952
1976
  throw new Error("Guard '".concat(guard.type, "' is not implemented.'."));
1953
1977
  }
1954
- return predicate(context, _event.data, guardMeta);
1978
+ return predicate({
1979
+ context: context,
1980
+ event: _event.data,
1981
+ state: state,
1982
+ guard: guard,
1983
+ _event: _event,
1984
+ evaluate: evaluateGuard
1985
+ });
1955
1986
  }
1956
1987
  function toGuardDefinition(guardConfig, getPredicate) {
1957
1988
  var _guardConfig$children;
@@ -3794,8 +3825,10 @@ function invoke$1(invokeDef) {
3794
3825
  src: src,
3795
3826
  parent: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self,
3796
3827
  systemId: invokeDef.systemId,
3797
- input: typeof input === 'function' ? input(state.context, _event.data, {
3798
- self: actorContext.self
3828
+ input: typeof input === 'function' ? input({
3829
+ context: state.context,
3830
+ event: _event.data,
3831
+ self: actorContext === null || actorContext === void 0 ? void 0 : actorContext.self
3799
3832
  }) : input
3800
3833
  });
3801
3834
  resolvedInvokeAction = {
@@ -3849,7 +3882,9 @@ function createSpawner(self, machine, context, _event, mutCapturedActions) {
3849
3882
  var actorRef = interpret(referenced.src, {
3850
3883
  id: resolvedName,
3851
3884
  parent: self,
3852
- input: typeof input === 'function' ? input(context, _event.data, {
3885
+ input: typeof input === 'function' ? input({
3886
+ context: context,
3887
+ event: _event.data,
3853
3888
  self: self
3854
3889
  }) : input
3855
3890
  });
@@ -3907,8 +3942,9 @@ function assign$1(assignment) {
3907
3942
  if (!state.context) {
3908
3943
  throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
3909
3944
  }
3910
- var meta = {
3911
- state: state,
3945
+ var args = {
3946
+ context: state.context,
3947
+ event: _event.data,
3912
3948
  action: action,
3913
3949
  _event: _event,
3914
3950
  spawn: createSpawner(actorContext === null || actorContext === void 0 ? void 0 : actorContext.self, state.machine, state.context, _event, capturedActions),
@@ -3917,12 +3953,12 @@ function assign$1(assignment) {
3917
3953
  };
3918
3954
  var partialUpdate = {};
3919
3955
  if (isFunction(assignment)) {
3920
- partialUpdate = assignment(state.context, _event.data, meta);
3956
+ partialUpdate = assignment(args);
3921
3957
  } else {
3922
3958
  for (var _i = 0, _Object$keys = Object.keys(assignment); _i < _Object$keys.length; _i++) {
3923
3959
  var key = _Object$keys[_i];
3924
3960
  var propAssignment = assignment[key];
3925
- partialUpdate[key] = isFunction(propAssignment) ? propAssignment(state.context, _event.data, meta) : propAssignment;
3961
+ partialUpdate[key] = isFunction(propAssignment) ? propAssignment(args) : propAssignment;
3926
3962
  }
3927
3963
  }
3928
3964
  var updatedContext = Object.assign({}, state.context, partialUpdate);
@@ -3962,22 +3998,23 @@ function raise$1(eventOrExpr, options) {
3962
3998
  event: eventOrExpr,
3963
3999
  id: options && options.id !== undefined ? options.id : typeof eventOrExpr === 'function' ? eventOrExpr.name : eventOrExpr.type
3964
4000
  };
3965
- var meta = {
4001
+ var args = {
4002
+ context: state.context,
4003
+ event: _event.data,
3966
4004
  _event: _event,
3967
- state: state,
3968
4005
  self: (_actorContext$self = actorContext === null || actorContext === void 0 ? void 0 : actorContext.self) !== null && _actorContext$self !== void 0 ? _actorContext$self : {},
3969
4006
  system: actorContext === null || actorContext === void 0 ? void 0 : actorContext.system
3970
4007
  };
3971
4008
  var delaysMap = state.machine.options.delays;
3972
4009
 
3973
4010
  // TODO: helper function for resolving Expr
3974
- var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(state.context, _event.data, meta) : eventOrExpr);
4011
+ var resolvedEvent = toSCXMLEvent(typeof eventOrExpr === 'function' ? eventOrExpr(args) : eventOrExpr);
3975
4012
  var resolvedDelay;
3976
4013
  if (typeof params.delay === 'string') {
3977
4014
  var configDelay = delaysMap && delaysMap[params.delay];
3978
- resolvedDelay = typeof configDelay === 'function' ? configDelay(state.context, _event.data, meta) : configDelay;
4015
+ resolvedDelay = typeof configDelay === 'function' ? configDelay(args) : configDelay;
3979
4016
  } else {
3980
- resolvedDelay = typeof params.delay === 'function' ? params.delay(state.context, _event.data, meta) : params.delay;
4017
+ resolvedDelay = typeof params.delay === 'function' ? params.delay(args) : params.delay;
3981
4018
  }
3982
4019
  var resolvedAction = {
3983
4020
  type: raise,
@@ -4040,10 +4077,11 @@ function resolveActionObject(actionObject, actionFunctionMap) {
4040
4077
  type: actionObject.type,
4041
4078
  params: actionObject.params,
4042
4079
  execute: function execute(actorCtx) {
4043
- return dereferencedAction(state.context, state.event, {
4080
+ return dereferencedAction({
4081
+ context: state.context,
4082
+ event: state.event,
4044
4083
  action: a,
4045
4084
  _event: state._event,
4046
- state: state,
4047
4085
  system: actorCtx.system,
4048
4086
  self: actorCtx.self
4049
4087
  });
@@ -4080,10 +4118,11 @@ function toActionObject(action) {
4080
4118
  "function": action
4081
4119
  },
4082
4120
  execute: function execute(actorCtx) {
4083
- return action(state.context, _event.data, {
4121
+ return action({
4122
+ context: state.context,
4123
+ event: _event.data,
4084
4124
  action: actionObject,
4085
4125
  _event: _event,
4086
- state: state,
4087
4126
  self: actorCtx.self,
4088
4127
  system: actorCtx.system
4089
4128
  });