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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/actions/dist/xstate-actions.cjs.d.mts +2 -0
  2. package/actions/dist/xstate-actions.cjs.d.mts.map +1 -0
  3. package/actions/dist/xstate-actions.cjs.d.ts +1 -0
  4. package/actions/dist/xstate-actions.cjs.d.ts.map +1 -0
  5. package/actions/dist/xstate-actions.cjs.dev.js +2 -2
  6. package/actions/dist/xstate-actions.cjs.mjs +24 -0
  7. package/actions/dist/xstate-actions.cjs.prod.js +3 -3
  8. package/actions/dist/xstate-actions.esm.js +1 -1
  9. package/actions/dist/xstate-actions.umd.min.js +1 -1
  10. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  11. package/actors/dist/xstate-actors.cjs.d.mts +2 -0
  12. package/actors/dist/xstate-actors.cjs.d.mts.map +1 -0
  13. package/actors/dist/xstate-actors.cjs.d.ts +1 -0
  14. package/actors/dist/xstate-actors.cjs.d.ts.map +1 -0
  15. package/actors/dist/xstate-actors.cjs.dev.js +2 -1
  16. package/actors/dist/xstate-actors.cjs.mjs +15 -0
  17. package/actors/dist/xstate-actors.cjs.prod.js +3 -2
  18. package/actors/dist/xstate-actors.esm.js +1 -1
  19. package/actors/dist/xstate-actors.umd.min.js +1 -1
  20. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  21. package/dev/dist/xstate-dev.cjs.d.mts +2 -0
  22. package/dev/dist/xstate-dev.cjs.d.mts.map +1 -0
  23. package/dev/dist/xstate-dev.cjs.d.ts +1 -0
  24. package/dev/dist/xstate-dev.cjs.d.ts.map +1 -0
  25. package/dev/dist/xstate-dev.cjs.mjs +5 -0
  26. package/dev/dist/xstate-dev.cjs.prod.js +6 -43
  27. package/dev/dist/xstate-dev.umd.min.js.map +1 -1
  28. package/dist/{actions-96f799fc.cjs.dev.js → actions-109712d3.cjs.dev.js} +397 -379
  29. package/dist/{actions-7678b87b.esm.js → actions-67f1d04e.esm.js} +351 -366
  30. package/dist/{actions-2479953d.cjs.prod.js → actions-d0262a43.cjs.prod.js} +420 -388
  31. package/dist/declarations/src/State.d.ts +2 -3
  32. package/dist/declarations/src/StateMachine.d.ts +6 -6
  33. package/dist/declarations/src/StateNode.d.ts +5 -11
  34. package/dist/declarations/src/actions/send.d.ts +0 -7
  35. package/dist/declarations/src/actions.d.ts +13 -12
  36. package/dist/declarations/src/actors/index.d.ts +2 -1
  37. package/dist/declarations/src/actors/observable.d.ts +1 -2
  38. package/dist/declarations/src/actors/promise.d.ts +1 -2
  39. package/dist/declarations/src/guards.d.ts +2 -2
  40. package/dist/declarations/src/index.d.ts +13 -29
  41. package/dist/declarations/src/interpreter.d.ts +5 -4
  42. package/dist/declarations/src/spawn.d.ts +2 -2
  43. package/dist/declarations/src/stateUtils.d.ts +15 -14
  44. package/dist/declarations/src/typegenTypes.d.ts +10 -4
  45. package/dist/declarations/src/types.d.ts +27 -101
  46. package/dist/declarations/src/utils.d.ts +3 -5
  47. package/dist/declarations/src/waitFor.d.ts +33 -0
  48. package/dist/index-0f3fdf0c.cjs.prod.js +52 -0
  49. package/dist/xstate.cjs.d.mts +2 -0
  50. package/dist/xstate.cjs.d.mts.map +1 -0
  51. package/dist/xstate.cjs.d.ts +1 -0
  52. package/dist/xstate.cjs.d.ts.map +1 -0
  53. package/dist/xstate.cjs.dev.js +125 -111
  54. package/dist/xstate.cjs.mjs +38 -0
  55. package/dist/xstate.cjs.prod.js +123 -112
  56. package/dist/xstate.esm.js +108 -99
  57. package/dist/xstate.umd.min.js +1 -1
  58. package/dist/xstate.umd.min.js.map +1 -1
  59. package/guards/dist/xstate-guards.cjs.d.mts +2 -0
  60. package/guards/dist/xstate-guards.cjs.d.mts.map +1 -0
  61. package/guards/dist/xstate-guards.cjs.d.ts +1 -0
  62. package/guards/dist/xstate-guards.cjs.d.ts.map +1 -0
  63. package/guards/dist/xstate-guards.cjs.dev.js +1 -1
  64. package/guards/dist/xstate-guards.cjs.mjs +8 -0
  65. package/guards/dist/xstate-guards.cjs.prod.js +2 -2
  66. package/guards/dist/xstate-guards.esm.js +1 -1
  67. package/guards/dist/xstate-guards.umd.min.js +1 -1
  68. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  69. package/package.json +7 -1
  70. package/dist/declarations/src/schema.d.ts +0 -2
@@ -1,28 +1,7 @@
1
- import { c as createDynamicAction, p as pure$1, t as toArray, a as toActionObjects, _ as _createClass, f as formatTransitions, b as toTransitionConfigArray, N as NULL_EVENT, d as formatTransition, m as mapValues, e as memo, g as _createForOfIteratorHelper, h as evaluateGuard, i as _toConsumableArray, j as flatten, k as _classCallCheck, l as _defineProperty, n as createInvokeId, o as toInvokeConfig, q as _objectSpread2, r as invoke, s as _objectWithoutProperties, u as getDelayedTransitions, v as formatInitialTransition, w as getCandidates, x as isString, y as createSpawner, z as createInitEvent, A as getConfiguration, B as getStateNodes, C as resolveStateValue, D as isInFinalState, S as State, E as toSCXMLEvent, F as isSCXMLErrorEvent, G as macrostep, H as transitionNode, I as _slicedToArray, J as getInitialConfiguration, K as resolveActionsAndContext, L as microstep, M as error, O as isStateId, P as getPersistedState, Q as resolveReferencedActor, R as interpret, T as STATE_DELIMITER, U as initEvent, V as matchesState, W as raise, X as send, Y as sendParent, Z as sendTo, $ as log, a0 as cancel, a1 as stop, a2 as assign, a3 as after, a4 as done, a5 as respond, a6 as forwardTo, a7 as escalate, a8 as choose } from './actions-7678b87b.esm.js';
2
- export { ae as ActionTypes, a9 as Interpreter, aa as InterpreterStatus, af as SpecialTargets, S as State, a2 as assign, ab as doneInvoke, a6 as forwardTo, B as getStateNodes, R as interpret, V as matchesState, ac as pathToStateValue, X as send, Y as sendParent, Z as sendTo, ad as toObserver, E as toSCXMLEvent } from './actions-7678b87b.esm.js';
1
+ import { _ as _createClass, f as formatTransitions, t as toTransitionConfigArray, N as NULL_EVENT, a as formatTransition, m as mapValues, b as memo, c as _createForOfIteratorHelper, e as evaluateGuard, d as _toConsumableArray, g as flatten, h as _classCallCheck, i as _defineProperty, j as toActionObjects, k as toArray, l as createInvokeId, n as toInvokeConfig, o as _objectSpread2, p as invoke, q as _objectWithoutProperties, r as getDelayedTransitions, s as formatInitialTransition, u as getCandidates, v as isString, w as createSpawner, x as getConfiguration, y as getStateNodes, z as resolveStateValue, A as isInFinalState, S as State, B as isErrorEvent, C as macrostep, D as transitionNode, E as _slicedToArray, F as getInitialConfiguration, G as createInitEvent, H as resolveActionsAndContext, I as microstep, J as error, K as isStateId, L as getStateNodeByPath, M as getPersistedState, O as resolveReferencedActor, P as interpret, Q as STATE_DELIMITER, R as initEvent, T as matchesState } from './actions-67f1d04e.esm.js';
2
+ export { ah as ActionTypes, X as Interpreter, Y as InterpreterStatus, ai as SpecialTargets, S as State, af as and, $ as assign, a0 as cancel, a1 as choose, Z as doneInvoke, W as forwardTo, aa as fromCallback, ab as fromEventObservable, a9 as fromObservable, a8 as fromPromise, ac as fromTransition, y as getStateNodes, P as interpret, a2 as log, T as matchesState, ae as not, ag as or, a6 as pathToStateValue, a3 as pure, a4 as raise, V as sendParent, U as sendTo, ad as stateIn, a5 as stop, a7 as toObserver } from './actions-67f1d04e.esm.js';
3
3
  import './index-50bd0aff.esm.js';
4
4
 
5
- function pure(getActions) {
6
- return createDynamicAction({
7
- type: pure$1,
8
- params: {
9
- get: getActions
10
- }
11
- }, function (_event, _ref) {
12
- var _toArray;
13
- var state = _ref.state;
14
- return [state, {
15
- type: pure$1,
16
- params: {
17
- actions: (_toArray = toArray(toActionObjects(getActions({
18
- context: state.context,
19
- event: _event.data
20
- })))) !== null && _toArray !== void 0 ? _toArray : []
21
- }
22
- }];
23
- });
24
- }
25
-
26
5
  var _excluded = ["onDone", "onError"];
27
6
  var EMPTY_OBJECT = {};
28
7
  var StateNode = /*#__PURE__*/function () {
@@ -80,11 +59,11 @@ var StateNode = /*#__PURE__*/function () {
80
59
  */
81
60
 
82
61
  /**
83
- * The data sent with the "done.state._id_" event if this is a final state node.
62
+ * The output data sent with the "done.state._id_" event if this is a final state node.
84
63
  */
85
64
 
86
65
  /**
87
- * The order this state node appears. Corresponds to the implicit SCXML document order.
66
+ * The order this state node appears. Corresponds to the implicit document order.
88
67
  */
89
68
 
90
69
  function StateNode(
@@ -106,7 +85,7 @@ var StateNode = /*#__PURE__*/function () {
106
85
  _defineProperty(this, "parent", void 0);
107
86
  _defineProperty(this, "machine", void 0);
108
87
  _defineProperty(this, "meta", void 0);
109
- _defineProperty(this, "doneData", void 0);
88
+ _defineProperty(this, "output", void 0);
110
89
  _defineProperty(this, "order", -1);
111
90
  _defineProperty(this, "description", void 0);
112
91
  _defineProperty(this, "tags", []);
@@ -138,7 +117,7 @@ var StateNode = /*#__PURE__*/function () {
138
117
  this.entry = toActionObjects(this.config.entry);
139
118
  this.exit = toActionObjects(this.config.exit);
140
119
  this.meta = this.config.meta;
141
- this.doneData = this.type === 'final' ? this.config.data : undefined;
120
+ this.output = this.type === 'final' ? this.config.output : undefined;
142
121
  this.tags = toArray(config.tags);
143
122
  }
144
123
  _createClass(StateNode, [{
@@ -173,7 +152,7 @@ var StateNode = /*#__PURE__*/function () {
173
152
  source: this,
174
153
  actions: this.initial.actions,
175
154
  eventType: null,
176
- external: false,
155
+ reenter: false,
177
156
  toJSON: function toJSON() {
178
157
  return {
179
158
  target: _this3.initial.target.map(function (t) {
@@ -195,7 +174,7 @@ var StateNode = /*#__PURE__*/function () {
195
174
  exit: this.exit,
196
175
  meta: this.meta,
197
176
  order: this.order || -1,
198
- data: this.doneData,
177
+ output: this.output,
199
178
  invoke: this.invoke,
200
179
  description: this.description,
201
180
  tags: this.tags
@@ -232,9 +211,9 @@ var StateNode = /*#__PURE__*/function () {
232
211
  id: resolvedId,
233
212
  systemId: systemId,
234
213
  toJSON: function toJSON() {
235
- var onDone = invokeConfig.onDone,
236
- onError = invokeConfig.onError,
237
- invokeDefValues = _objectWithoutProperties(invokeConfig, _excluded);
214
+ invokeConfig.onDone;
215
+ invokeConfig.onError;
216
+ var invokeDefValues = _objectWithoutProperties(invokeConfig, _excluded);
238
217
  return _objectSpread2(_objectSpread2({}, invokeDefValues), {}, {
239
218
  type: invoke,
240
219
  src: resolvedSrc,
@@ -278,27 +257,15 @@ var StateNode = /*#__PURE__*/function () {
278
257
  return formatInitialTransition(_this7, _this7.config.initial || []);
279
258
  });
280
259
  }
281
-
282
- /**
283
- * Returns `true` if this state node explicitly handles the given event.
284
- *
285
- * @param event The event in question
286
- */
287
- }, {
288
- key: "handles",
289
- value: function handles(event) {
290
- return this.events.includes(event.type);
291
- }
292
260
  }, {
293
261
  key: "next",
294
- value: function next(state, _event) {
262
+ value: function next(state, event) {
295
263
  var _this8 = this;
296
- var eventName = _event.name;
264
+ var eventType = event.type;
297
265
  var actions = [];
298
266
  var selectedTransition;
299
- var candidates = memo(this, "candidates-".concat(eventName.toString()), function () {
300
- return getCandidates(_this8, eventName, _this8.machine.config.scxml // Whether token matching should be used
301
- );
267
+ var candidates = memo(this, "candidates-".concat(eventType), function () {
268
+ return getCandidates(_this8, eventType);
302
269
  });
303
270
  var _iterator = _createForOfIteratorHelper(candidates),
304
271
  _step;
@@ -309,9 +276,9 @@ var StateNode = /*#__PURE__*/function () {
309
276
  var resolvedContext = state.context;
310
277
  var guardPassed = false;
311
278
  try {
312
- guardPassed = !guard || evaluateGuard(guard, resolvedContext, _event, state);
279
+ guardPassed = !guard || evaluateGuard(guard, resolvedContext, event, state);
313
280
  } catch (err) {
314
- throw new Error("Unable to evaluate guard '".concat(guard.type, "' in transition for event '").concat(eventName, "' in state node '").concat(this.id, "':\n").concat(err.message));
281
+ throw new Error("Unable to evaluate guard '".concat(guard.type, "' in transition for event '").concat(eventType, "' in state node '").concat(this.id, "':\n").concat(err.message));
315
282
  }
316
283
  if (guardPassed) {
317
284
  actions.push.apply(actions, _toConsumableArray(candidate.actions));
@@ -397,7 +364,7 @@ var StateNode = /*#__PURE__*/function () {
397
364
  key: "ownEvents",
398
365
  get: function get() {
399
366
  var events = new Set(this.transitions.filter(function (transition) {
400
- return !(!transition.target && !transition.actions.length && !transition.external);
367
+ return !(!transition.target && !transition.actions.length && !transition.reenter);
401
368
  }).map(function (transition) {
402
369
  return transition.eventType;
403
370
  }));
@@ -423,13 +390,13 @@ var StateMachine = /*#__PURE__*/function () {
423
390
  * The raw config used to create the machine.
424
391
  */
425
392
  config, options) {
426
- var _this$config$schema;
393
+ var _this$config$types;
427
394
  _classCallCheck(this, StateMachine);
428
395
  this.config = config;
429
396
  _defineProperty(this, "version", void 0);
430
397
  _defineProperty(this, "delimiter", void 0);
431
398
  _defineProperty(this, "options", void 0);
432
- _defineProperty(this, "schema", void 0);
399
+ _defineProperty(this, "types", void 0);
433
400
  _defineProperty(this, "__xstatenode", true);
434
401
  _defineProperty(this, "idMap", new Map());
435
402
  _defineProperty(this, "root", void 0);
@@ -445,7 +412,7 @@ var StateMachine = /*#__PURE__*/function () {
445
412
  this.options = Object.assign(createDefaultOptions(), options);
446
413
  this.delimiter = this.config.delimiter || STATE_DELIMITER;
447
414
  this.version = this.config.version;
448
- this.schema = (_this$config$schema = this.config.schema) !== null && _this$config$schema !== void 0 ? _this$config$schema : {};
415
+ this.types = (_this$config$types = this.config.types) !== null && _this$config$types !== void 0 ? _this$config$types : {};
449
416
  this.transition = this.transition.bind(this);
450
417
  this.root = new StateNode(config, {
451
418
  _key: this.id,
@@ -545,13 +512,12 @@ var StateMachine = /*#__PURE__*/function () {
545
512
  var actorCtx = arguments.length > 2 ? arguments[2] : undefined;
546
513
  var currentState = state instanceof State ? state : this.resolveStateValue(state);
547
514
  // TODO: handle error events in a better way
548
- var scxmlEvent = toSCXMLEvent(event);
549
- if (isSCXMLErrorEvent(scxmlEvent) && !currentState.nextEvents.some(function (nextEvent) {
550
- return nextEvent === scxmlEvent.name;
515
+ if (isErrorEvent(event) && !currentState.nextEvents.some(function (nextEvent) {
516
+ return nextEvent === event.type;
551
517
  })) {
552
- throw scxmlEvent.data.data;
518
+ throw event.data;
553
519
  }
554
- var _macrostep = macrostep(currentState, scxmlEvent, actorCtx),
520
+ var _macrostep = macrostep(currentState, event, actorCtx),
555
521
  nextState = _macrostep.state;
556
522
  return nextState;
557
523
  }
@@ -569,15 +535,12 @@ var StateMachine = /*#__PURE__*/function () {
569
535
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.initialState;
570
536
  var event = arguments.length > 1 ? arguments[1] : undefined;
571
537
  var actorCtx = arguments.length > 2 ? arguments[2] : undefined;
572
- var scxmlEvent = toSCXMLEvent(event);
573
- var _macrostep2 = macrostep(state, scxmlEvent, actorCtx),
574
- microstates = _macrostep2.microstates;
575
- return microstates;
538
+ return macrostep(state, event, actorCtx).microstates;
576
539
  }
577
540
  }, {
578
541
  key: "getTransitionData",
579
- value: function getTransitionData(state, _event) {
580
- return transitionNode(this.root, state.value, state, _event) || [];
542
+ value: function getTransitionData(state, event) {
543
+ return transitionNode(this.root, state.value, state, event) || [];
581
544
  }
582
545
 
583
546
  /**
@@ -597,7 +560,7 @@ var StateMachine = /*#__PURE__*/function () {
597
560
  value: {},
598
561
  // TODO: this is computed in state constructor
599
562
  context: context,
600
- _event: createInitEvent({}),
563
+ event: createInitEvent({}),
601
564
  actions: [],
602
565
  meta: undefined,
603
566
  configuration: config,
@@ -637,8 +600,8 @@ var StateMachine = /*#__PURE__*/function () {
637
600
  var preInitialState = this.getPreInitialState(actorCtx, input);
638
601
  var nextState = microstep([], preInitialState, actorCtx, initEvent);
639
602
  (_nextState$actions = nextState.actions).unshift.apply(_nextState$actions, _toConsumableArray(preInitialState.actions));
640
- var _macrostep3 = macrostep(nextState, initEvent, actorCtx),
641
- macroState = _macrostep3.state;
603
+ var _macrostep2 = macrostep(nextState, initEvent, actorCtx),
604
+ macroState = _macrostep2.state;
642
605
  return macroState;
643
606
  }
644
607
  }, {
@@ -663,12 +626,14 @@ var StateMachine = /*#__PURE__*/function () {
663
626
  }, {
664
627
  key: "getStateNodeById",
665
628
  value: function getStateNodeById(stateId) {
666
- var resolvedStateId = isStateId(stateId) ? stateId.slice(STATE_IDENTIFIER.length) : stateId;
629
+ var fullPath = stateId.split(this.delimiter);
630
+ var relativePath = fullPath.slice(1);
631
+ var resolvedStateId = isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];
667
632
  var stateNode = this.idMap.get(resolvedStateId);
668
633
  if (!stateNode) {
669
634
  throw new Error("Child state node '#".concat(resolvedStateId, "' does not exist on machine '").concat(this.id, "'"));
670
635
  }
671
- return stateNode;
636
+ return getStateNodeByPath(stateNode, relativePath);
672
637
  }
673
638
  }, {
674
639
  key: "definition",
@@ -691,7 +656,7 @@ var StateMachine = /*#__PURE__*/function () {
691
656
  key: "createState",
692
657
  value: function createState(stateConfig) {
693
658
  var state = stateConfig instanceof State ? stateConfig : new State(stateConfig, this);
694
- var _resolveActionsAndCon2 = resolveActionsAndContext(state.actions, state._event, state, undefined),
659
+ var _resolveActionsAndCon2 = resolveActionsAndContext(state.actions, state.event, state, undefined),
695
660
  resolvedState = _resolveActionsAndCon2.nextState;
696
661
  return resolvedState;
697
662
  }
@@ -775,11 +740,6 @@ function mapState(stateMap, stateId) {
775
740
  return stateMap[foundStateId];
776
741
  }
777
742
 
778
- function createSchema(schema) {
779
- return schema;
780
- }
781
- var t = createSchema;
782
-
783
743
  var SimulatedClock = /*#__PURE__*/function () {
784
744
  function SimulatedClock() {
785
745
  _classCallCheck(this, SimulatedClock);
@@ -827,12 +787,12 @@ var SimulatedClock = /*#__PURE__*/function () {
827
787
  value: function flushTimeouts() {
828
788
  var _this = this;
829
789
  _toConsumableArray(this.timeouts).sort(function (_ref, _ref2) {
830
- var _ref3 = _slicedToArray(_ref, 2),
831
- _idA = _ref3[0],
832
- timeoutA = _ref3[1];
833
- var _ref4 = _slicedToArray(_ref2, 2),
834
- _idB = _ref4[0],
835
- timeoutB = _ref4[1];
790
+ var _ref3 = _slicedToArray(_ref, 2);
791
+ _ref3[0];
792
+ var timeoutA = _ref3[1];
793
+ var _ref4 = _slicedToArray(_ref2, 2);
794
+ _ref4[0];
795
+ var timeoutB = _ref4[1];
836
796
  var endA = timeoutA.start + timeoutA.timeout;
837
797
  var endB = timeoutB.start + timeoutB.timeout;
838
798
  return endB > endA ? -1 : 1;
@@ -856,22 +816,71 @@ var SimulatedClock = /*#__PURE__*/function () {
856
816
  return SimulatedClock;
857
817
  }();
858
818
 
859
- var actions = {
860
- raise: raise,
861
- send: send,
862
- sendParent: sendParent,
863
- sendTo: sendTo,
864
- log: log,
865
- cancel: cancel,
866
- stop: stop,
867
- assign: assign,
868
- after: after,
869
- done: done,
870
- respond: respond,
871
- forwardTo: forwardTo,
872
- escalate: escalate,
873
- choose: choose,
874
- pure: pure
819
+ var defaultWaitForOptions = {
820
+ timeout: 10000 // 10 seconds
875
821
  };
876
822
 
877
- export { SimulatedClock, StateMachine, StateNode, actions, createMachine, createSchema, mapState, t };
823
+ /**
824
+ * Subscribes to an actor ref and waits for its emitted value to satisfy
825
+ * a predicate, and then resolves with that value.
826
+ * Will throw if the desired state is not reached after a timeout
827
+ * (defaults to 10 seconds).
828
+ *
829
+ * @example
830
+ * ```js
831
+ * const state = await waitFor(someService, state => {
832
+ * return state.hasTag('loaded');
833
+ * });
834
+ *
835
+ * state.hasTag('loaded'); // true
836
+ * ```
837
+ *
838
+ * @param actorRef The actor ref to subscribe to
839
+ * @param predicate Determines if a value matches the condition to wait for
840
+ * @param options
841
+ * @returns A promise that eventually resolves to the emitted value
842
+ * that matches the condition
843
+ */
844
+ function waitFor(actorRef, predicate, options) {
845
+ var resolvedOptions = _objectSpread2(_objectSpread2({}, defaultWaitForOptions), options);
846
+ return new Promise(function (res, rej) {
847
+ var done = false;
848
+ if (process.env.NODE_ENV !== 'production' && resolvedOptions.timeout < 0) {
849
+ console.error('`timeout` passed to `waitFor` is negative and it will reject its internal promise immediately.');
850
+ }
851
+ var handle = resolvedOptions.timeout === Infinity ? undefined : setTimeout(function () {
852
+ sub.unsubscribe();
853
+ rej(new Error("Timeout of ".concat(resolvedOptions.timeout, " ms exceeded")));
854
+ }, resolvedOptions.timeout);
855
+ var dispose = function dispose() {
856
+ clearTimeout(handle);
857
+ done = true;
858
+ sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
859
+ };
860
+ function checkEmitted(emitted) {
861
+ if (predicate(emitted)) {
862
+ dispose();
863
+ res(emitted);
864
+ }
865
+ }
866
+
867
+ // See if the current snapshot already matches the predicate
868
+ checkEmitted(actorRef.getSnapshot());
869
+ var sub = actorRef.subscribe({
870
+ next: checkEmitted,
871
+ error: function error(err) {
872
+ dispose();
873
+ rej(err);
874
+ },
875
+ complete: function complete() {
876
+ dispose();
877
+ rej(new Error("Actor terminated without satisfying predicate"));
878
+ }
879
+ });
880
+ if (done) {
881
+ sub.unsubscribe();
882
+ }
883
+ });
884
+ }
885
+
886
+ export { SimulatedClock, StateMachine, StateNode, createMachine, mapState, waitFor };