xstate 5.1.0 → 5.2.0

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 (37) hide show
  1. package/actions/dist/xstate-actions.cjs.js +2 -2
  2. package/actions/dist/xstate-actions.development.cjs.js +2 -2
  3. package/actions/dist/xstate-actions.development.esm.js +2 -2
  4. package/actions/dist/xstate-actions.esm.js +2 -2
  5. package/actions/dist/xstate-actions.umd.min.js +1 -1
  6. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  7. package/actors/dist/xstate-actors.cjs.js +1 -1
  8. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  9. package/actors/dist/xstate-actors.development.esm.js +1 -1
  10. package/actors/dist/xstate-actors.esm.js +1 -1
  11. package/actors/dist/xstate-actors.umd.min.js +1 -1
  12. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  13. package/dist/declarations/src/index.d.ts +6 -5
  14. package/dist/declarations/src/spawn.d.ts +3 -2
  15. package/dist/declarations/src/toPromise.d.ts +24 -0
  16. package/dist/declarations/src/types.d.ts +2 -0
  17. package/dist/{log-6e1b5540.esm.js → log-5409ee89.esm.js} +4 -1
  18. package/dist/{log-2cbae8e5.development.esm.js → log-557e5fa3.development.esm.js} +4 -1
  19. package/dist/{log-dca6710c.cjs.js → log-74467f02.cjs.js} +4 -1
  20. package/dist/{log-aa639ffe.development.cjs.js → log-a56e34a9.development.cjs.js} +4 -1
  21. package/dist/{raise-dd0e6cd2.development.esm.js → raise-0ff85b7b.development.esm.js} +23 -5
  22. package/dist/{raise-525f78b5.esm.js → raise-5d7ae4b7.esm.js} +23 -5
  23. package/dist/{raise-23324e7c.development.cjs.js → raise-6fb30f8b.development.cjs.js} +22 -4
  24. package/dist/{raise-9f420f96.cjs.js → raise-746abff7.cjs.js} +22 -4
  25. package/dist/xstate.cjs.js +36 -2
  26. package/dist/xstate.cjs.mjs +1 -0
  27. package/dist/xstate.development.cjs.js +36 -2
  28. package/dist/xstate.development.cjs.mjs +1 -0
  29. package/dist/xstate.development.esm.js +38 -5
  30. package/dist/xstate.esm.js +38 -5
  31. package/dist/xstate.umd.min.js +1 -1
  32. package/dist/xstate.umd.min.js.map +1 -1
  33. package/guards/dist/xstate-guards.cjs.js +1 -1
  34. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  35. package/guards/dist/xstate-guards.development.esm.js +1 -1
  36. package/guards/dist/xstate-guards.esm.js +1 -1
  37. package/package.json +1 -1
@@ -1,5 +1,8 @@
1
- import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-525f78b5.esm.js';
1
+ import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-5d7ae4b7.esm.js';
2
2
 
3
+ // it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
4
+ // but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
5
+ // and we strive to support TS 5.0 whenever possible
3
6
  function createSpawner(actorScope, {
4
7
  machine,
5
8
  context
@@ -1,5 +1,8 @@
1
- import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-dd0e6cd2.development.esm.js';
1
+ import { R as ProcessingStatus, y as resolveReferencedActor, z as createActor, T as cloneMachineSnapshot, U as XSTATE_ERROR, V as createErrorActorEvent, e as evaluateGuard, L as cancel, M as raise, O as spawnChild, Q as stopChild } from './raise-0ff85b7b.development.esm.js';
2
2
 
3
+ // it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
4
+ // but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
5
+ // and we strive to support TS 5.0 whenever possible
3
6
  function createSpawner(actorScope, {
4
7
  machine,
5
8
  context
@@ -1,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-9f420f96.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-746abff7.cjs.js');
4
4
 
5
+ // it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
6
+ // but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
7
+ // and we strive to support TS 5.0 whenever possible
5
8
  function createSpawner(actorScope, {
6
9
  machine,
7
10
  context
@@ -1,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-23324e7c.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-6fb30f8b.development.cjs.js');
4
4
 
5
+ // it's likely-ish that `(TActor & { src: TSrc })['logic']` would be faster
6
+ // but it's only possible to do it since https://github.com/microsoft/TypeScript/pull/53098 (TS 5.1)
7
+ // and we strive to support TS 5.0 whenever possible
5
8
  function createSpawner(actorScope, {
6
9
  machine,
7
10
  context
@@ -647,10 +647,28 @@ class Actor {
647
647
  if (this._processingStatus !== ProcessingStatus.Stopped) {
648
648
  this.observers.add(observer);
649
649
  } else {
650
- try {
651
- observer.complete?.();
652
- } catch (err) {
653
- reportUnhandledError(err);
650
+ switch (this._snapshot.status) {
651
+ case 'done':
652
+ try {
653
+ observer.complete?.();
654
+ } catch (err) {
655
+ reportUnhandledError(err);
656
+ }
657
+ break;
658
+ case 'error':
659
+ {
660
+ const err = this._snapshot.error;
661
+ if (!observer.error) {
662
+ reportUnhandledError(err);
663
+ } else {
664
+ try {
665
+ observer.error(err);
666
+ } catch (err) {
667
+ reportUnhandledError(err);
668
+ }
669
+ }
670
+ break;
671
+ }
654
672
  }
655
673
  }
656
674
  return {
@@ -2416,4 +2434,4 @@ function raise(eventOrExpr, options) {
2416
2434
  return raise;
2417
2435
  }
2418
2436
 
2419
- export { $$ACTOR_TYPE as $, Actor as A, interpret as B, isMachineSnapshot as C, matchesState as D, pathToStateValue as E, toObserver as F, getAllOwnEventDescriptors as G, and as H, not as I, or as J, stateIn as K, cancel as L, raise as M, NULL_EVENT as N, spawnChild as O, stop as P, stopChild as Q, ProcessingStatus as R, STATE_DELIMITER as S, cloneMachineSnapshot as T, XSTATE_ERROR as U, createErrorActorEvent as V, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, isStateId as v, getStateNodeByPath as w, getPersistedSnapshot as x, resolveReferencedActor as y, createActor as z };
2437
+ export { $$ACTOR_TYPE as $, Actor as A, interpret as B, isMachineSnapshot as C, and as D, not as E, or as F, stateIn as G, getAllOwnEventDescriptors as H, matchesState as I, pathToStateValue as J, toObserver as K, cancel as L, raise as M, NULL_EVENT as N, spawnChild as O, stop as P, stopChild as Q, ProcessingStatus as R, STATE_DELIMITER as S, cloneMachineSnapshot as T, XSTATE_ERROR as U, createErrorActorEvent as V, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, isStateId as v, getStateNodeByPath as w, getPersistedSnapshot as x, resolveReferencedActor as y, createActor as z };
@@ -644,10 +644,28 @@ class Actor {
644
644
  if (this._processingStatus !== ProcessingStatus.Stopped) {
645
645
  this.observers.add(observer);
646
646
  } else {
647
- try {
648
- observer.complete?.();
649
- } catch (err) {
650
- reportUnhandledError(err);
647
+ switch (this._snapshot.status) {
648
+ case 'done':
649
+ try {
650
+ observer.complete?.();
651
+ } catch (err) {
652
+ reportUnhandledError(err);
653
+ }
654
+ break;
655
+ case 'error':
656
+ {
657
+ const err = this._snapshot.error;
658
+ if (!observer.error) {
659
+ reportUnhandledError(err);
660
+ } else {
661
+ try {
662
+ observer.error(err);
663
+ } catch (err) {
664
+ reportUnhandledError(err);
665
+ }
666
+ }
667
+ break;
668
+ }
651
669
  }
652
670
  }
653
671
  return {
@@ -2362,4 +2380,4 @@ function raise(eventOrExpr, options) {
2362
2380
  return raise;
2363
2381
  }
2364
2382
 
2365
- export { $$ACTOR_TYPE as $, Actor as A, interpret as B, isMachineSnapshot as C, matchesState as D, pathToStateValue as E, toObserver as F, getAllOwnEventDescriptors as G, and as H, not as I, or as J, stateIn as K, cancel as L, raise as M, NULL_EVENT as N, spawnChild as O, stop as P, stopChild as Q, ProcessingStatus as R, STATE_DELIMITER as S, cloneMachineSnapshot as T, XSTATE_ERROR as U, createErrorActorEvent as V, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, isStateId as v, getStateNodeByPath as w, getPersistedSnapshot as x, resolveReferencedActor as y, createActor as z };
2383
+ export { $$ACTOR_TYPE as $, Actor as A, interpret as B, isMachineSnapshot as C, and as D, not as E, or as F, stateIn as G, getAllOwnEventDescriptors as H, matchesState as I, pathToStateValue as J, toObserver as K, cancel as L, raise as M, NULL_EVENT as N, spawnChild as O, stop as P, stopChild as Q, ProcessingStatus as R, STATE_DELIMITER as S, cloneMachineSnapshot as T, XSTATE_ERROR as U, createErrorActorEvent as V, XSTATE_STOP as X, toTransitionConfigArray as a, formatTransition as b, createInvokeId as c, formatInitialTransition as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, getCandidates as h, getAllStateNodes as i, getStateNodes as j, createMachineSnapshot as k, isInFinalState as l, mapValues as m, macrostep as n, transitionNode as o, resolveActionsAndContext as p, createInitEvent as q, resolveStateValue as r, microstep as s, toArray as t, getInitialStateNodes as u, isStateId as v, getStateNodeByPath as w, getPersistedSnapshot as x, resolveReferencedActor as y, createActor as z };
@@ -649,10 +649,28 @@ class Actor {
649
649
  if (this._processingStatus !== ProcessingStatus.Stopped) {
650
650
  this.observers.add(observer);
651
651
  } else {
652
- try {
653
- observer.complete?.();
654
- } catch (err) {
655
- reportUnhandledError(err);
652
+ switch (this._snapshot.status) {
653
+ case 'done':
654
+ try {
655
+ observer.complete?.();
656
+ } catch (err) {
657
+ reportUnhandledError(err);
658
+ }
659
+ break;
660
+ case 'error':
661
+ {
662
+ const err = this._snapshot.error;
663
+ if (!observer.error) {
664
+ reportUnhandledError(err);
665
+ } else {
666
+ try {
667
+ observer.error(err);
668
+ } catch (err) {
669
+ reportUnhandledError(err);
670
+ }
671
+ }
672
+ break;
673
+ }
656
674
  }
657
675
  }
658
676
  return {
@@ -646,10 +646,28 @@ class Actor {
646
646
  if (this._processingStatus !== ProcessingStatus.Stopped) {
647
647
  this.observers.add(observer);
648
648
  } else {
649
- try {
650
- observer.complete?.();
651
- } catch (err) {
652
- reportUnhandledError(err);
649
+ switch (this._snapshot.status) {
650
+ case 'done':
651
+ try {
652
+ observer.complete?.();
653
+ } catch (err) {
654
+ reportUnhandledError(err);
655
+ }
656
+ break;
657
+ case 'error':
658
+ {
659
+ const err = this._snapshot.error;
660
+ if (!observer.error) {
661
+ reportUnhandledError(err);
662
+ } else {
663
+ try {
664
+ observer.error(err);
665
+ } catch (err) {
666
+ reportUnhandledError(err);
667
+ }
668
+ }
669
+ break;
670
+ }
653
671
  }
654
672
  }
655
673
  return {
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var actors_dist_xstateActors = require('../actors/dist/xstate-actors.cjs.js');
6
- var guards_dist_xstateGuards = require('./raise-9f420f96.cjs.js');
7
- var log = require('./log-dca6710c.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-746abff7.cjs.js');
7
+ var log = require('./log-74467f02.cjs.js');
8
8
  require('../dev/dist/xstate-dev.cjs.js');
9
9
 
10
10
  class SimulatedClock {
@@ -710,6 +710,39 @@ function setup({
710
710
  };
711
711
  }
712
712
 
713
+ /**
714
+ * Returns a promise that resolves to the `output` of the actor when it is done.
715
+ *
716
+ * @example
717
+ * ```ts
718
+ * const machine = createMachine({
719
+ * // ...
720
+ * output: {
721
+ * count: 42
722
+ * }
723
+ * });
724
+ *
725
+ * const actor = createActor(machine);
726
+ *
727
+ * actor.start();
728
+ *
729
+ * const output = await toPromise(actor);
730
+ *
731
+ * console.log(output);
732
+ * // logs { count: 42 }
733
+ * ```
734
+ */
735
+ function toPromise(actor) {
736
+ return new Promise((resolve, reject) => {
737
+ actor.subscribe({
738
+ complete: () => {
739
+ resolve(actor.getSnapshot().output);
740
+ },
741
+ error: reject
742
+ });
743
+ });
744
+ }
745
+
713
746
  exports.createEmptyActor = actors_dist_xstateActors.createEmptyActor;
714
747
  exports.fromCallback = actors_dist_xstateActors.fromCallback;
715
748
  exports.fromEventObservable = actors_dist_xstateActors.fromEventObservable;
@@ -746,4 +779,5 @@ exports.StateMachine = StateMachine;
746
779
  exports.StateNode = StateNode;
747
780
  exports.createMachine = createMachine;
748
781
  exports.setup = setup;
782
+ exports.toPromise = toPromise;
749
783
  exports.waitFor = waitFor;
@@ -35,5 +35,6 @@ export {
35
35
  stop,
36
36
  stopChild,
37
37
  toObserver,
38
+ toPromise,
38
39
  waitFor
39
40
  } from "./xstate.cjs.js";
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var actors_dist_xstateActors = require('../actors/dist/xstate-actors.development.cjs.js');
6
- var guards_dist_xstateGuards = require('./raise-23324e7c.development.cjs.js');
7
- var log = require('./log-aa639ffe.development.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-6fb30f8b.development.cjs.js');
7
+ var log = require('./log-a56e34a9.development.cjs.js');
8
8
  require('../dev/dist/xstate-dev.development.cjs.js');
9
9
 
10
10
  class SimulatedClock {
@@ -716,6 +716,39 @@ function setup({
716
716
  };
717
717
  }
718
718
 
719
+ /**
720
+ * Returns a promise that resolves to the `output` of the actor when it is done.
721
+ *
722
+ * @example
723
+ * ```ts
724
+ * const machine = createMachine({
725
+ * // ...
726
+ * output: {
727
+ * count: 42
728
+ * }
729
+ * });
730
+ *
731
+ * const actor = createActor(machine);
732
+ *
733
+ * actor.start();
734
+ *
735
+ * const output = await toPromise(actor);
736
+ *
737
+ * console.log(output);
738
+ * // logs { count: 42 }
739
+ * ```
740
+ */
741
+ function toPromise(actor) {
742
+ return new Promise((resolve, reject) => {
743
+ actor.subscribe({
744
+ complete: () => {
745
+ resolve(actor.getSnapshot().output);
746
+ },
747
+ error: reject
748
+ });
749
+ });
750
+ }
751
+
719
752
  exports.createEmptyActor = actors_dist_xstateActors.createEmptyActor;
720
753
  exports.fromCallback = actors_dist_xstateActors.fromCallback;
721
754
  exports.fromEventObservable = actors_dist_xstateActors.fromEventObservable;
@@ -752,4 +785,5 @@ exports.StateMachine = StateMachine;
752
785
  exports.StateNode = StateNode;
753
786
  exports.createMachine = createMachine;
754
787
  exports.setup = setup;
788
+ exports.toPromise = toPromise;
755
789
  exports.waitFor = waitFor;
@@ -35,5 +35,6 @@ export {
35
35
  stop,
36
36
  stopChild,
37
37
  toObserver,
38
+ toPromise,
38
39
  waitFor
39
40
  } from "./xstate.development.cjs.js";
@@ -1,8 +1,8 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
2
- import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as getPersistedSnapshot, y as resolveReferencedActor, z as createActor, $ as $$ACTOR_TYPE } from './raise-dd0e6cd2.development.esm.js';
3
- export { A as Actor, G as __unsafe_getAllOwnEventDescriptors, H as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, D as matchesState, I as not, J as or, E as pathToStateValue, M as raise, O as spawnChild, K as stateIn, P as stop, Q as stopChild, F as toObserver } from './raise-dd0e6cd2.development.esm.js';
4
- import { a as assign } from './log-2cbae8e5.development.esm.js';
5
- export { S as SpecialTargets, a as assign, e as enqueueActions, f as forwardTo, l as log, s as sendParent, b as sendTo } from './log-2cbae8e5.development.esm.js';
2
+ import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as getPersistedSnapshot, y as resolveReferencedActor, z as createActor, $ as $$ACTOR_TYPE } from './raise-0ff85b7b.development.esm.js';
3
+ export { A as Actor, H as __unsafe_getAllOwnEventDescriptors, D as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, I as matchesState, E as not, F as or, J as pathToStateValue, M as raise, O as spawnChild, G as stateIn, P as stop, Q as stopChild, K as toObserver } from './raise-0ff85b7b.development.esm.js';
4
+ import { a as assign } from './log-557e5fa3.development.esm.js';
5
+ export { S as SpecialTargets, a as assign, e as enqueueActions, f as forwardTo, l as log, s as sendParent, b as sendTo } from './log-557e5fa3.development.esm.js';
6
6
  import '../dev/dist/xstate-dev.development.esm.js';
7
7
 
8
8
  class SimulatedClock {
@@ -714,4 +714,37 @@ function setup({
714
714
  };
715
715
  }
716
716
 
717
- export { SimulatedClock, StateMachine, StateNode, createMachine, setup, waitFor };
717
+ /**
718
+ * Returns a promise that resolves to the `output` of the actor when it is done.
719
+ *
720
+ * @example
721
+ * ```ts
722
+ * const machine = createMachine({
723
+ * // ...
724
+ * output: {
725
+ * count: 42
726
+ * }
727
+ * });
728
+ *
729
+ * const actor = createActor(machine);
730
+ *
731
+ * actor.start();
732
+ *
733
+ * const output = await toPromise(actor);
734
+ *
735
+ * console.log(output);
736
+ * // logs { count: 42 }
737
+ * ```
738
+ */
739
+ function toPromise(actor) {
740
+ return new Promise((resolve, reject) => {
741
+ actor.subscribe({
742
+ complete: () => {
743
+ resolve(actor.getSnapshot().output);
744
+ },
745
+ error: reject
746
+ });
747
+ });
748
+ }
749
+
750
+ export { SimulatedClock, StateMachine, StateNode, createMachine, setup, toPromise, waitFor };
@@ -1,8 +1,8 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
2
- import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as getPersistedSnapshot, y as resolveReferencedActor, z as createActor, $ as $$ACTOR_TYPE } from './raise-525f78b5.esm.js';
3
- export { A as Actor, G as __unsafe_getAllOwnEventDescriptors, H as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, D as matchesState, I as not, J as or, E as pathToStateValue, M as raise, O as spawnChild, K as stateIn, P as stop, Q as stopChild, F as toObserver } from './raise-525f78b5.esm.js';
4
- import { a as assign } from './log-6e1b5540.esm.js';
5
- export { S as SpecialTargets, a as assign, e as enqueueActions, f as forwardTo, l as log, s as sendParent, b as sendTo } from './log-6e1b5540.esm.js';
2
+ import { S as STATE_DELIMITER, m as mapValues, t as toArray, f as formatTransitions, a as toTransitionConfigArray, b as formatTransition, N as NULL_EVENT, e as evaluateGuard, c as createInvokeId, g as getDelayedTransitions, d as formatInitialTransition, h as getCandidates, r as resolveStateValue, i as getAllStateNodes, j as getStateNodes, k as createMachineSnapshot, l as isInFinalState, n as macrostep, o as transitionNode, p as resolveActionsAndContext, q as createInitEvent, s as microstep, u as getInitialStateNodes, v as isStateId, w as getStateNodeByPath, x as getPersistedSnapshot, y as resolveReferencedActor, z as createActor, $ as $$ACTOR_TYPE } from './raise-5d7ae4b7.esm.js';
3
+ export { A as Actor, H as __unsafe_getAllOwnEventDescriptors, D as and, L as cancel, z as createActor, j as getStateNodes, B as interpret, C as isMachineSnapshot, I as matchesState, E as not, F as or, J as pathToStateValue, M as raise, O as spawnChild, G as stateIn, P as stop, Q as stopChild, K as toObserver } from './raise-5d7ae4b7.esm.js';
4
+ import { a as assign } from './log-5409ee89.esm.js';
5
+ export { S as SpecialTargets, a as assign, e as enqueueActions, f as forwardTo, l as log, s as sendParent, b as sendTo } from './log-5409ee89.esm.js';
6
6
  import '../dev/dist/xstate-dev.esm.js';
7
7
 
8
8
  class SimulatedClock {
@@ -708,4 +708,37 @@ function setup({
708
708
  };
709
709
  }
710
710
 
711
- export { SimulatedClock, StateMachine, StateNode, createMachine, setup, waitFor };
711
+ /**
712
+ * Returns a promise that resolves to the `output` of the actor when it is done.
713
+ *
714
+ * @example
715
+ * ```ts
716
+ * const machine = createMachine({
717
+ * // ...
718
+ * output: {
719
+ * count: 42
720
+ * }
721
+ * });
722
+ *
723
+ * const actor = createActor(machine);
724
+ *
725
+ * actor.start();
726
+ *
727
+ * const output = await toPromise(actor);
728
+ *
729
+ * console.log(output);
730
+ * // logs { count: 42 }
731
+ * ```
732
+ */
733
+ function toPromise(actor) {
734
+ return new Promise((resolve, reject) => {
735
+ actor.subscribe({
736
+ complete: () => {
737
+ resolve(actor.getSnapshot().output);
738
+ },
739
+ error: reject
740
+ });
741
+ });
742
+ }
743
+
744
+ export { SimulatedClock, StateMachine, StateNode, createMachine, setup, toPromise, waitFor };