xstate 5.0.0-beta.46 → 5.0.0-beta.48

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 (40) hide show
  1. package/actions/dist/xstate-actions.cjs.js +4 -3
  2. package/actions/dist/xstate-actions.cjs.mjs +3 -2
  3. package/actions/dist/xstate-actions.development.cjs.js +4 -3
  4. package/actions/dist/xstate-actions.development.cjs.mjs +3 -2
  5. package/actions/dist/xstate-actions.development.esm.js +2 -2
  6. package/actions/dist/xstate-actions.esm.js +2 -2
  7. package/actions/dist/xstate-actions.umd.min.js +1 -1
  8. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  9. package/actors/dist/xstate-actors.cjs.js +1 -1
  10. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  11. package/actors/dist/xstate-actors.development.esm.js +1 -1
  12. package/actors/dist/xstate-actors.esm.js +1 -1
  13. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  14. package/dist/declarations/src/actions/{spawn.d.ts → spawnChild.d.ts} +1 -1
  15. package/dist/declarations/src/actions/{stop.d.ts → stopChild.d.ts} +8 -2
  16. package/dist/declarations/src/actions.d.ts +2 -2
  17. package/dist/declarations/src/interpreter.d.ts +30 -4
  18. package/dist/declarations/src/setup.d.ts +3 -3
  19. package/dist/{raise-a9e7e31c.development.cjs.js → raise-0eafc1df.development.cjs.js} +55 -21
  20. package/dist/{raise-fa23c2b9.development.esm.js → raise-286581d5.development.esm.js} +54 -21
  21. package/dist/{raise-1682abb7.esm.js → raise-84fd7a92.esm.js} +54 -21
  22. package/dist/{raise-a1d3d7e9.cjs.js → raise-cd0dde81.cjs.js} +55 -21
  23. package/dist/{send-5b256a89.development.cjs.js → send-32a63473.development.cjs.js} +1 -1
  24. package/dist/{send-2fa3a204.cjs.js → send-355ba004.cjs.js} +1 -1
  25. package/dist/{send-a237e4e8.esm.js → send-ae491737.esm.js} +1 -1
  26. package/dist/{send-9acdf858.development.esm.js → send-f0a3179c.development.esm.js} +1 -1
  27. package/dist/xstate.cjs.js +4 -3
  28. package/dist/xstate.cjs.mjs +2 -1
  29. package/dist/xstate.development.cjs.js +4 -3
  30. package/dist/xstate.development.cjs.mjs +2 -1
  31. package/dist/xstate.development.esm.js +4 -4
  32. package/dist/xstate.esm.js +4 -4
  33. package/dist/xstate.umd.min.js +1 -1
  34. package/dist/xstate.umd.min.js.map +1 -1
  35. package/guards/dist/xstate-guards.cjs.js +1 -1
  36. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  37. package/guards/dist/xstate-guards.development.esm.js +1 -1
  38. package/guards/dist/xstate-guards.esm.js +1 -1
  39. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  40. package/package.json +1 -1
@@ -851,10 +851,36 @@ class Actor {
851
851
  }
852
852
 
853
853
  /**
854
- * Creates a new `ActorRef` instance for the given machine with the provided options, if any.
854
+ * Creates a new actor instance for the given actor logic with the provided options, if any.
855
855
  *
856
- * @param machine The machine to create an actor from
857
- * @param options `ActorRef` options
856
+ * @remarks
857
+ * When you create an actor from actor logic via `createActor(logic)`, you implicitly create an actor system where the created actor is the root actor.
858
+ * Any actors spawned from this root actor and its descendants are part of that actor system.
859
+ *
860
+ * @example
861
+ * ```ts
862
+ * import { createActor } from 'xstate';
863
+ * import { someActorLogic } from './someActorLogic.ts';
864
+ *
865
+ * // Creating the actor, which implicitly creates an actor system with itself as the root actor
866
+ * const actor = createActor(someActorLogic);
867
+ *
868
+ * actor.subscribe((snapshot) => {
869
+ * console.log(snapshot);
870
+ * });
871
+ *
872
+ * // Actors must be started by calling `actor.start()`, which will also start the actor system.
873
+ * actor.start();
874
+ *
875
+ * // Actors can receive events
876
+ * actor.send({ type: 'someEvent' });
877
+ *
878
+ * // You can stop root actors by calling `actor.stop()`, which will also stop the actor system and all actors in that system.
879
+ * actor.stop();
880
+ * ```
881
+ *
882
+ * @param logic - The actor logic to create an actor from. For a state machine actor logic creator, see {@link createMachine}. Other actor logic creators include {@link fromCallback}, {@link fromEventObservable}, {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.
883
+ * @param options - Actor options
858
884
  */
859
885
 
860
886
  function createActor(logic, options) {
@@ -958,26 +984,26 @@ function executeSpawn(actorScope, {
958
984
  }
959
985
  });
960
986
  }
961
- function spawn(...[src, {
987
+ function spawnChild(...[src, {
962
988
  id,
963
989
  systemId,
964
990
  input,
965
991
  syncSnapshot = false
966
992
  } = {}]) {
967
- function spawn(args, params) {
993
+ function spawnChild(args, params) {
968
994
  {
969
995
  throw new Error(`This isn't supposed to be called`);
970
996
  }
971
997
  }
972
- spawn.type = 'xstate.spawn';
973
- spawn.id = id;
974
- spawn.systemId = systemId;
975
- spawn.src = src;
976
- spawn.input = input;
977
- spawn.syncSnapshot = syncSnapshot;
978
- spawn.resolve = resolveSpawn;
979
- spawn.execute = executeSpawn;
980
- return spawn;
998
+ spawnChild.type = 'xstate.spawnChild';
999
+ spawnChild.id = id;
1000
+ spawnChild.systemId = systemId;
1001
+ spawnChild.src = src;
1002
+ spawnChild.input = input;
1003
+ spawnChild.syncSnapshot = syncSnapshot;
1004
+ spawnChild.resolve = resolveSpawn;
1005
+ spawnChild.execute = executeSpawn;
1006
+ return spawnChild;
981
1007
  }
982
1008
 
983
1009
  function resolveStop(_, state, args, actionParams, {
@@ -1021,23 +1047,30 @@ function executeStop(actorScope, actorRef) {
1021
1047
  });
1022
1048
  }
1023
1049
  /**
1024
- * Stops an actor.
1050
+ * Stops a child actor.
1025
1051
  *
1026
1052
  * @param actorRef The actor to stop.
1027
1053
  */
1028
- function stop(actorRef) {
1054
+ function stopChild(actorRef) {
1029
1055
  function stop(args, params) {
1030
1056
  {
1031
1057
  throw new Error(`This isn't supposed to be called`);
1032
1058
  }
1033
1059
  }
1034
- stop.type = 'xstate.stop';
1060
+ stop.type = 'xstate.stopChild';
1035
1061
  stop.actorRef = actorRef;
1036
1062
  stop.resolve = resolveStop;
1037
1063
  stop.execute = executeStop;
1038
1064
  return stop;
1039
1065
  }
1040
1066
 
1067
+ /**
1068
+ * Stops a child actor.
1069
+ *
1070
+ * @deprecated Use `stopChild(...)` instead
1071
+ */
1072
+ const stop = stopChild;
1073
+
1041
1074
  function checkStateIn(state, _, {
1042
1075
  stateValue
1043
1076
  }) {
@@ -1785,7 +1818,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
1785
1818
  // Add entry actions
1786
1819
  actions.push(...stateNodeToEnter.entry);
1787
1820
  for (const invokeDef of stateNodeToEnter.invoke) {
1788
- actions.push(spawn(invokeDef.src, {
1821
+ actions.push(spawnChild(invokeDef.src, {
1789
1822
  ...invokeDef,
1790
1823
  syncSnapshot: !!invokeDef.onSnapshot
1791
1824
  }));
@@ -1936,7 +1969,7 @@ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSe
1936
1969
  }
1937
1970
  }
1938
1971
  for (const s of statesToExit) {
1939
- nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stop(def.id))], internalQueue);
1972
+ nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
1940
1973
  mutStateNodeSet.delete(s);
1941
1974
  }
1942
1975
  return [nextState, changedHistory || historyValue];
@@ -2062,7 +2095,7 @@ function macrostep(state, event, actorScope, internalQueue = []) {
2062
2095
  };
2063
2096
  }
2064
2097
  function stopChildren(nextState, event, actorScope) {
2065
- return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stop(child)), []);
2098
+ return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);
2066
2099
  }
2067
2100
  function selectTransitions(event, nextState) {
2068
2101
  return nextState.machine.getTransitionData(nextState, event);
@@ -2324,9 +2357,10 @@ exports.raise = raise;
2324
2357
  exports.resolveActionsAndContext = resolveActionsAndContext;
2325
2358
  exports.resolveReferencedActor = resolveReferencedActor;
2326
2359
  exports.resolveStateValue = resolveStateValue;
2327
- exports.spawn = spawn;
2360
+ exports.spawnChild = spawnChild;
2328
2361
  exports.stateIn = stateIn;
2329
2362
  exports.stop = stop;
2363
+ exports.stopChild = stopChild;
2330
2364
  exports.toArray = toArray;
2331
2365
  exports.toObserver = toObserver;
2332
2366
  exports.toTransitionConfigArray = toTransitionConfigArray;
@@ -849,10 +849,36 @@ class Actor {
849
849
  }
850
850
 
851
851
  /**
852
- * Creates a new `ActorRef` instance for the given machine with the provided options, if any.
852
+ * Creates a new actor instance for the given actor logic with the provided options, if any.
853
853
  *
854
- * @param machine The machine to create an actor from
855
- * @param options `ActorRef` options
854
+ * @remarks
855
+ * When you create an actor from actor logic via `createActor(logic)`, you implicitly create an actor system where the created actor is the root actor.
856
+ * Any actors spawned from this root actor and its descendants are part of that actor system.
857
+ *
858
+ * @example
859
+ * ```ts
860
+ * import { createActor } from 'xstate';
861
+ * import { someActorLogic } from './someActorLogic.ts';
862
+ *
863
+ * // Creating the actor, which implicitly creates an actor system with itself as the root actor
864
+ * const actor = createActor(someActorLogic);
865
+ *
866
+ * actor.subscribe((snapshot) => {
867
+ * console.log(snapshot);
868
+ * });
869
+ *
870
+ * // Actors must be started by calling `actor.start()`, which will also start the actor system.
871
+ * actor.start();
872
+ *
873
+ * // Actors can receive events
874
+ * actor.send({ type: 'someEvent' });
875
+ *
876
+ * // You can stop root actors by calling `actor.stop()`, which will also stop the actor system and all actors in that system.
877
+ * actor.stop();
878
+ * ```
879
+ *
880
+ * @param logic - The actor logic to create an actor from. For a state machine actor logic creator, see {@link createMachine}. Other actor logic creators include {@link fromCallback}, {@link fromEventObservable}, {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.
881
+ * @param options - Actor options
856
882
  */
857
883
 
858
884
  function createActor(logic, options) {
@@ -956,26 +982,26 @@ function executeSpawn(actorScope, {
956
982
  }
957
983
  });
958
984
  }
959
- function spawn(...[src, {
985
+ function spawnChild(...[src, {
960
986
  id,
961
987
  systemId,
962
988
  input,
963
989
  syncSnapshot = false
964
990
  } = {}]) {
965
- function spawn(args, params) {
991
+ function spawnChild(args, params) {
966
992
  {
967
993
  throw new Error(`This isn't supposed to be called`);
968
994
  }
969
995
  }
970
- spawn.type = 'xstate.spawn';
971
- spawn.id = id;
972
- spawn.systemId = systemId;
973
- spawn.src = src;
974
- spawn.input = input;
975
- spawn.syncSnapshot = syncSnapshot;
976
- spawn.resolve = resolveSpawn;
977
- spawn.execute = executeSpawn;
978
- return spawn;
996
+ spawnChild.type = 'xstate.spawnChild';
997
+ spawnChild.id = id;
998
+ spawnChild.systemId = systemId;
999
+ spawnChild.src = src;
1000
+ spawnChild.input = input;
1001
+ spawnChild.syncSnapshot = syncSnapshot;
1002
+ spawnChild.resolve = resolveSpawn;
1003
+ spawnChild.execute = executeSpawn;
1004
+ return spawnChild;
979
1005
  }
980
1006
 
981
1007
  function resolveStop(_, state, args, actionParams, {
@@ -1019,23 +1045,30 @@ function executeStop(actorScope, actorRef) {
1019
1045
  });
1020
1046
  }
1021
1047
  /**
1022
- * Stops an actor.
1048
+ * Stops a child actor.
1023
1049
  *
1024
1050
  * @param actorRef The actor to stop.
1025
1051
  */
1026
- function stop(actorRef) {
1052
+ function stopChild(actorRef) {
1027
1053
  function stop(args, params) {
1028
1054
  {
1029
1055
  throw new Error(`This isn't supposed to be called`);
1030
1056
  }
1031
1057
  }
1032
- stop.type = 'xstate.stop';
1058
+ stop.type = 'xstate.stopChild';
1033
1059
  stop.actorRef = actorRef;
1034
1060
  stop.resolve = resolveStop;
1035
1061
  stop.execute = executeStop;
1036
1062
  return stop;
1037
1063
  }
1038
1064
 
1065
+ /**
1066
+ * Stops a child actor.
1067
+ *
1068
+ * @deprecated Use `stopChild(...)` instead
1069
+ */
1070
+ const stop = stopChild;
1071
+
1039
1072
  function checkStateIn(state, _, {
1040
1073
  stateValue
1041
1074
  }) {
@@ -1783,7 +1816,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
1783
1816
  // Add entry actions
1784
1817
  actions.push(...stateNodeToEnter.entry);
1785
1818
  for (const invokeDef of stateNodeToEnter.invoke) {
1786
- actions.push(spawn(invokeDef.src, {
1819
+ actions.push(spawnChild(invokeDef.src, {
1787
1820
  ...invokeDef,
1788
1821
  syncSnapshot: !!invokeDef.onSnapshot
1789
1822
  }));
@@ -1934,7 +1967,7 @@ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSe
1934
1967
  }
1935
1968
  }
1936
1969
  for (const s of statesToExit) {
1937
- nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stop(def.id))], internalQueue);
1970
+ nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
1938
1971
  mutStateNodeSet.delete(s);
1939
1972
  }
1940
1973
  return [nextState, changedHistory || historyValue];
@@ -2060,7 +2093,7 @@ function macrostep(state, event, actorScope, internalQueue = []) {
2060
2093
  };
2061
2094
  }
2062
2095
  function stopChildren(nextState, event, actorScope) {
2063
- return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stop(child)), []);
2096
+ return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);
2064
2097
  }
2065
2098
  function selectTransitions(event, nextState) {
2066
2099
  return nextState.machine.getTransitionData(nextState, event);
@@ -2279,4 +2312,4 @@ function raise(eventOrExpr, options) {
2279
2312
  return raise;
2280
2313
  }
2281
2314
 
2282
- export { $$ACTOR_TYPE as $, getPersistedState as A, resolveReferencedActor as B, createActor as C, Actor as D, interpret as E, isMachineSnapshot as F, matchesState as G, pathToStateValue as H, toObserver as I, and as J, not as K, or as L, stateIn as M, NULL_EVENT as N, cancel as O, raise as P, stop as Q, spawn as R, STATE_DELIMITER as S, ProcessingStatus as T, createErrorActorEvent as U, XSTATE_ERROR 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, isErrorActorEvent as n, getAllOwnEventDescriptors as o, cloneMachineSnapshot as p, macrostep as q, resolveStateValue as r, transitionNode as s, toArray as t, resolveActionsAndContext as u, createInitEvent as v, microstep as w, getInitialStateNodes as x, isStateId as y, getStateNodeByPath as z };
2315
+ export { $$ACTOR_TYPE as $, getPersistedState as A, resolveReferencedActor as B, createActor as C, Actor as D, interpret as E, isMachineSnapshot as F, matchesState as G, pathToStateValue as H, toObserver as I, and as J, not as K, or as L, stateIn as M, NULL_EVENT as N, cancel as O, raise as P, stop as Q, stopChild as R, STATE_DELIMITER as S, spawnChild as T, ProcessingStatus as U, createErrorActorEvent as V, XSTATE_ERROR as W, 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, isErrorActorEvent as n, getAllOwnEventDescriptors as o, cloneMachineSnapshot as p, macrostep as q, resolveStateValue as r, transitionNode as s, toArray as t, resolveActionsAndContext as u, createInitEvent as v, microstep as w, getInitialStateNodes as x, isStateId as y, getStateNodeByPath as z };
@@ -838,10 +838,36 @@ class Actor {
838
838
  }
839
839
 
840
840
  /**
841
- * Creates a new `ActorRef` instance for the given machine with the provided options, if any.
841
+ * Creates a new actor instance for the given actor logic with the provided options, if any.
842
842
  *
843
- * @param machine The machine to create an actor from
844
- * @param options `ActorRef` options
843
+ * @remarks
844
+ * When you create an actor from actor logic via `createActor(logic)`, you implicitly create an actor system where the created actor is the root actor.
845
+ * Any actors spawned from this root actor and its descendants are part of that actor system.
846
+ *
847
+ * @example
848
+ * ```ts
849
+ * import { createActor } from 'xstate';
850
+ * import { someActorLogic } from './someActorLogic.ts';
851
+ *
852
+ * // Creating the actor, which implicitly creates an actor system with itself as the root actor
853
+ * const actor = createActor(someActorLogic);
854
+ *
855
+ * actor.subscribe((snapshot) => {
856
+ * console.log(snapshot);
857
+ * });
858
+ *
859
+ * // Actors must be started by calling `actor.start()`, which will also start the actor system.
860
+ * actor.start();
861
+ *
862
+ * // Actors can receive events
863
+ * actor.send({ type: 'someEvent' });
864
+ *
865
+ * // You can stop root actors by calling `actor.stop()`, which will also stop the actor system and all actors in that system.
866
+ * actor.stop();
867
+ * ```
868
+ *
869
+ * @param logic - The actor logic to create an actor from. For a state machine actor logic creator, see {@link createMachine}. Other actor logic creators include {@link fromCallback}, {@link fromEventObservable}, {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.
870
+ * @param options - Actor options
845
871
  */
846
872
 
847
873
  function createActor(logic, options) {
@@ -939,23 +965,23 @@ function executeSpawn(actorScope, {
939
965
  }
940
966
  });
941
967
  }
942
- function spawn(...[src, {
968
+ function spawnChild(...[src, {
943
969
  id,
944
970
  systemId,
945
971
  input,
946
972
  syncSnapshot = false
947
973
  } = {}]) {
948
- function spawn(args, params) {
974
+ function spawnChild(args, params) {
949
975
  }
950
- spawn.type = 'xstate.spawn';
951
- spawn.id = id;
952
- spawn.systemId = systemId;
953
- spawn.src = src;
954
- spawn.input = input;
955
- spawn.syncSnapshot = syncSnapshot;
956
- spawn.resolve = resolveSpawn;
957
- spawn.execute = executeSpawn;
958
- return spawn;
976
+ spawnChild.type = 'xstate.spawnChild';
977
+ spawnChild.id = id;
978
+ spawnChild.systemId = systemId;
979
+ spawnChild.src = src;
980
+ spawnChild.input = input;
981
+ spawnChild.syncSnapshot = syncSnapshot;
982
+ spawnChild.resolve = resolveSpawn;
983
+ spawnChild.execute = executeSpawn;
984
+ return spawnChild;
959
985
  }
960
986
 
961
987
  function resolveStop(_, state, args, actionParams, {
@@ -999,20 +1025,27 @@ function executeStop(actorScope, actorRef) {
999
1025
  });
1000
1026
  }
1001
1027
  /**
1002
- * Stops an actor.
1028
+ * Stops a child actor.
1003
1029
  *
1004
1030
  * @param actorRef The actor to stop.
1005
1031
  */
1006
- function stop(actorRef) {
1032
+ function stopChild(actorRef) {
1007
1033
  function stop(args, params) {
1008
1034
  }
1009
- stop.type = 'xstate.stop';
1035
+ stop.type = 'xstate.stopChild';
1010
1036
  stop.actorRef = actorRef;
1011
1037
  stop.resolve = resolveStop;
1012
1038
  stop.execute = executeStop;
1013
1039
  return stop;
1014
1040
  }
1015
1041
 
1042
+ /**
1043
+ * Stops a child actor.
1044
+ *
1045
+ * @deprecated Use `stopChild(...)` instead
1046
+ */
1047
+ const stop = stopChild;
1048
+
1016
1049
  function checkStateIn(state, _, {
1017
1050
  stateValue
1018
1051
  }) {
@@ -1741,7 +1774,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
1741
1774
  // Add entry actions
1742
1775
  actions.push(...stateNodeToEnter.entry);
1743
1776
  for (const invokeDef of stateNodeToEnter.invoke) {
1744
- actions.push(spawn(invokeDef.src, {
1777
+ actions.push(spawnChild(invokeDef.src, {
1745
1778
  ...invokeDef,
1746
1779
  syncSnapshot: !!invokeDef.onSnapshot
1747
1780
  }));
@@ -1892,7 +1925,7 @@ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSe
1892
1925
  }
1893
1926
  }
1894
1927
  for (const s of statesToExit) {
1895
- nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stop(def.id))], internalQueue);
1928
+ nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
1896
1929
  mutStateNodeSet.delete(s);
1897
1930
  }
1898
1931
  return [nextState, changedHistory || historyValue];
@@ -2015,7 +2048,7 @@ function macrostep(state, event, actorScope, internalQueue = []) {
2015
2048
  };
2016
2049
  }
2017
2050
  function stopChildren(nextState, event, actorScope) {
2018
- return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stop(child)), []);
2051
+ return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);
2019
2052
  }
2020
2053
  function selectTransitions(event, nextState) {
2021
2054
  return nextState.machine.getTransitionData(nextState, event);
@@ -2225,4 +2258,4 @@ function raise(eventOrExpr, options) {
2225
2258
  return raise;
2226
2259
  }
2227
2260
 
2228
- export { $$ACTOR_TYPE as $, getPersistedState as A, resolveReferencedActor as B, createActor as C, Actor as D, interpret as E, isMachineSnapshot as F, matchesState as G, pathToStateValue as H, toObserver as I, and as J, not as K, or as L, stateIn as M, NULL_EVENT as N, cancel as O, raise as P, stop as Q, spawn as R, STATE_DELIMITER as S, ProcessingStatus as T, createErrorActorEvent as U, XSTATE_ERROR 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, isErrorActorEvent as n, getAllOwnEventDescriptors as o, cloneMachineSnapshot as p, macrostep as q, resolveStateValue as r, transitionNode as s, toArray as t, resolveActionsAndContext as u, createInitEvent as v, microstep as w, getInitialStateNodes as x, isStateId as y, getStateNodeByPath as z };
2261
+ export { $$ACTOR_TYPE as $, getPersistedState as A, resolveReferencedActor as B, createActor as C, Actor as D, interpret as E, isMachineSnapshot as F, matchesState as G, pathToStateValue as H, toObserver as I, and as J, not as K, or as L, stateIn as M, NULL_EVENT as N, cancel as O, raise as P, stop as Q, stopChild as R, STATE_DELIMITER as S, spawnChild as T, ProcessingStatus as U, createErrorActorEvent as V, XSTATE_ERROR as W, 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, isErrorActorEvent as n, getAllOwnEventDescriptors as o, cloneMachineSnapshot as p, macrostep as q, resolveStateValue as r, transitionNode as s, toArray as t, resolveActionsAndContext as u, createInitEvent as v, microstep as w, getInitialStateNodes as x, isStateId as y, getStateNodeByPath as z };
@@ -840,10 +840,36 @@ class Actor {
840
840
  }
841
841
 
842
842
  /**
843
- * Creates a new `ActorRef` instance for the given machine with the provided options, if any.
843
+ * Creates a new actor instance for the given actor logic with the provided options, if any.
844
844
  *
845
- * @param machine The machine to create an actor from
846
- * @param options `ActorRef` options
845
+ * @remarks
846
+ * When you create an actor from actor logic via `createActor(logic)`, you implicitly create an actor system where the created actor is the root actor.
847
+ * Any actors spawned from this root actor and its descendants are part of that actor system.
848
+ *
849
+ * @example
850
+ * ```ts
851
+ * import { createActor } from 'xstate';
852
+ * import { someActorLogic } from './someActorLogic.ts';
853
+ *
854
+ * // Creating the actor, which implicitly creates an actor system with itself as the root actor
855
+ * const actor = createActor(someActorLogic);
856
+ *
857
+ * actor.subscribe((snapshot) => {
858
+ * console.log(snapshot);
859
+ * });
860
+ *
861
+ * // Actors must be started by calling `actor.start()`, which will also start the actor system.
862
+ * actor.start();
863
+ *
864
+ * // Actors can receive events
865
+ * actor.send({ type: 'someEvent' });
866
+ *
867
+ * // You can stop root actors by calling `actor.stop()`, which will also stop the actor system and all actors in that system.
868
+ * actor.stop();
869
+ * ```
870
+ *
871
+ * @param logic - The actor logic to create an actor from. For a state machine actor logic creator, see {@link createMachine}. Other actor logic creators include {@link fromCallback}, {@link fromEventObservable}, {@link fromObservable}, {@link fromPromise}, and {@link fromTransition}.
872
+ * @param options - Actor options
847
873
  */
848
874
 
849
875
  function createActor(logic, options) {
@@ -941,23 +967,23 @@ function executeSpawn(actorScope, {
941
967
  }
942
968
  });
943
969
  }
944
- function spawn(...[src, {
970
+ function spawnChild(...[src, {
945
971
  id,
946
972
  systemId,
947
973
  input,
948
974
  syncSnapshot = false
949
975
  } = {}]) {
950
- function spawn(args, params) {
976
+ function spawnChild(args, params) {
951
977
  }
952
- spawn.type = 'xstate.spawn';
953
- spawn.id = id;
954
- spawn.systemId = systemId;
955
- spawn.src = src;
956
- spawn.input = input;
957
- spawn.syncSnapshot = syncSnapshot;
958
- spawn.resolve = resolveSpawn;
959
- spawn.execute = executeSpawn;
960
- return spawn;
978
+ spawnChild.type = 'xstate.spawnChild';
979
+ spawnChild.id = id;
980
+ spawnChild.systemId = systemId;
981
+ spawnChild.src = src;
982
+ spawnChild.input = input;
983
+ spawnChild.syncSnapshot = syncSnapshot;
984
+ spawnChild.resolve = resolveSpawn;
985
+ spawnChild.execute = executeSpawn;
986
+ return spawnChild;
961
987
  }
962
988
 
963
989
  function resolveStop(_, state, args, actionParams, {
@@ -1001,20 +1027,27 @@ function executeStop(actorScope, actorRef) {
1001
1027
  });
1002
1028
  }
1003
1029
  /**
1004
- * Stops an actor.
1030
+ * Stops a child actor.
1005
1031
  *
1006
1032
  * @param actorRef The actor to stop.
1007
1033
  */
1008
- function stop(actorRef) {
1034
+ function stopChild(actorRef) {
1009
1035
  function stop(args, params) {
1010
1036
  }
1011
- stop.type = 'xstate.stop';
1037
+ stop.type = 'xstate.stopChild';
1012
1038
  stop.actorRef = actorRef;
1013
1039
  stop.resolve = resolveStop;
1014
1040
  stop.execute = executeStop;
1015
1041
  return stop;
1016
1042
  }
1017
1043
 
1044
+ /**
1045
+ * Stops a child actor.
1046
+ *
1047
+ * @deprecated Use `stopChild(...)` instead
1048
+ */
1049
+ const stop = stopChild;
1050
+
1018
1051
  function checkStateIn(state, _, {
1019
1052
  stateValue
1020
1053
  }) {
@@ -1743,7 +1776,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutSt
1743
1776
  // Add entry actions
1744
1777
  actions.push(...stateNodeToEnter.entry);
1745
1778
  for (const invokeDef of stateNodeToEnter.invoke) {
1746
- actions.push(spawn(invokeDef.src, {
1779
+ actions.push(spawnChild(invokeDef.src, {
1747
1780
  ...invokeDef,
1748
1781
  syncSnapshot: !!invokeDef.onSnapshot
1749
1782
  }));
@@ -1894,7 +1927,7 @@ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSe
1894
1927
  }
1895
1928
  }
1896
1929
  for (const s of statesToExit) {
1897
- nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stop(def.id))], internalQueue);
1930
+ nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stopChild(def.id))], internalQueue);
1898
1931
  mutStateNodeSet.delete(s);
1899
1932
  }
1900
1933
  return [nextState, changedHistory || historyValue];
@@ -2017,7 +2050,7 @@ function macrostep(state, event, actorScope, internalQueue = []) {
2017
2050
  };
2018
2051
  }
2019
2052
  function stopChildren(nextState, event, actorScope) {
2020
- return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stop(child)), []);
2053
+ return resolveActionsAndContext(nextState, event, actorScope, Object.values(nextState.children).map(child => stopChild(child)), []);
2021
2054
  }
2022
2055
  function selectTransitions(event, nextState) {
2023
2056
  return nextState.machine.getTransitionData(nextState, event);
@@ -2270,9 +2303,10 @@ exports.raise = raise;
2270
2303
  exports.resolveActionsAndContext = resolveActionsAndContext;
2271
2304
  exports.resolveReferencedActor = resolveReferencedActor;
2272
2305
  exports.resolveStateValue = resolveStateValue;
2273
- exports.spawn = spawn;
2306
+ exports.spawnChild = spawnChild;
2274
2307
  exports.stateIn = stateIn;
2275
2308
  exports.stop = stop;
2309
+ exports.stopChild = stopChild;
2276
2310
  exports.toArray = toArray;
2277
2311
  exports.toObserver = toObserver;
2278
2312
  exports.toTransitionConfigArray = toTransitionConfigArray;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-a9e7e31c.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-0eafc1df.development.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-a1d3d7e9.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-cd0dde81.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -1,4 +1,4 @@
1
- import { T as ProcessingStatus, U as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, V as XSTATE_ERROR } from './raise-1682abb7.esm.js';
1
+ import { U as ProcessingStatus, V as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, W as XSTATE_ERROR } from './raise-84fd7a92.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -1,4 +1,4 @@
1
- import { T as ProcessingStatus, U as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, V as XSTATE_ERROR } from './raise-fa23c2b9.development.esm.js';
1
+ import { U as ProcessingStatus, V as createErrorActorEvent, B as resolveReferencedActor, C as createActor, p as cloneMachineSnapshot, e as evaluateGuard, t as toArray, W as XSTATE_ERROR } from './raise-286581d5.development.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -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-a1d3d7e9.cjs.js');
7
- var send = require('./send-2fa3a204.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-cd0dde81.cjs.js');
7
+ var send = require('./send-355ba004.cjs.js');
8
8
  require('../dev/dist/xstate-dev.cjs.js');
9
9
 
10
10
  class SimulatedClock {
@@ -720,9 +720,10 @@ exports.not = guards_dist_xstateGuards.not;
720
720
  exports.or = guards_dist_xstateGuards.or;
721
721
  exports.pathToStateValue = guards_dist_xstateGuards.pathToStateValue;
722
722
  exports.raise = guards_dist_xstateGuards.raise;
723
- exports.spawn = guards_dist_xstateGuards.spawn;
723
+ exports.spawnChild = guards_dist_xstateGuards.spawnChild;
724
724
  exports.stateIn = guards_dist_xstateGuards.stateIn;
725
725
  exports.stop = guards_dist_xstateGuards.stop;
726
+ exports.stopChild = guards_dist_xstateGuards.stopChild;
726
727
  exports.toObserver = guards_dist_xstateGuards.toObserver;
727
728
  exports.SpecialTargets = send.SpecialTargets;
728
729
  exports.assign = send.assign;
@@ -32,9 +32,10 @@ export {
32
32
  sendParent,
33
33
  sendTo,
34
34
  setup,
35
- spawn,
35
+ spawnChild,
36
36
  stateIn,
37
37
  stop,
38
+ stopChild,
38
39
  toObserver,
39
40
  waitFor
40
41
  } 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-a9e7e31c.development.cjs.js');
7
- var send = require('./send-5b256a89.development.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-0eafc1df.development.cjs.js');
7
+ var send = require('./send-32a63473.development.cjs.js');
8
8
  require('../dev/dist/xstate-dev.development.cjs.js');
9
9
 
10
10
  class SimulatedClock {
@@ -726,9 +726,10 @@ exports.not = guards_dist_xstateGuards.not;
726
726
  exports.or = guards_dist_xstateGuards.or;
727
727
  exports.pathToStateValue = guards_dist_xstateGuards.pathToStateValue;
728
728
  exports.raise = guards_dist_xstateGuards.raise;
729
- exports.spawn = guards_dist_xstateGuards.spawn;
729
+ exports.spawnChild = guards_dist_xstateGuards.spawnChild;
730
730
  exports.stateIn = guards_dist_xstateGuards.stateIn;
731
731
  exports.stop = guards_dist_xstateGuards.stop;
732
+ exports.stopChild = guards_dist_xstateGuards.stopChild;
732
733
  exports.toObserver = guards_dist_xstateGuards.toObserver;
733
734
  exports.SpecialTargets = send.SpecialTargets;
734
735
  exports.assign = send.assign;