xstate 5.0.0-beta.44 → 5.0.0-beta.45

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 (48) 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 +93 -5
  8. package/actors/dist/xstate-actors.development.cjs.js +93 -5
  9. package/actors/dist/xstate-actors.development.esm.js +93 -5
  10. package/actors/dist/xstate-actors.esm.js +93 -5
  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/State.d.ts +11 -11
  14. package/dist/declarations/src/StateMachine.d.ts +1 -1
  15. package/dist/declarations/src/actions/choose.d.ts +3 -3
  16. package/dist/declarations/src/actions/pure.d.ts +4 -4
  17. package/dist/declarations/src/actors/observable.d.ts +39 -0
  18. package/dist/declarations/src/actors/transition.d.ts +53 -4
  19. package/dist/declarations/src/{Machine.d.ts → createMachine.d.ts} +1 -1
  20. package/dist/declarations/src/guards.d.ts +26 -4
  21. package/dist/declarations/src/index.d.ts +2 -1
  22. package/dist/declarations/src/interpreter.d.ts +1 -0
  23. package/dist/declarations/src/setup.d.ts +32 -0
  24. package/dist/declarations/src/stateUtils.d.ts +7 -7
  25. package/dist/declarations/src/types.d.ts +16 -13
  26. package/dist/{raise-5854eaca.esm.js → raise-2b5a4e4c.esm.js} +82 -105
  27. package/dist/{raise-348cc74e.development.esm.js → raise-90139fbc.development.esm.js} +82 -105
  28. package/dist/{raise-ed700d14.development.cjs.js → raise-b3fb3c65.development.cjs.js} +82 -106
  29. package/dist/{raise-fb6f017b.cjs.js → raise-fabffc3d.cjs.js} +82 -106
  30. package/dist/{send-a0193bdb.development.esm.js → send-24cc8018.development.esm.js} +3 -28
  31. package/dist/{send-b7b4befa.esm.js → send-8e7e41e7.esm.js} +3 -28
  32. package/dist/{send-53e5693c.cjs.js → send-c124176f.cjs.js} +3 -28
  33. package/dist/{send-00466e37.development.cjs.js → send-d0bc7eed.development.cjs.js} +3 -28
  34. package/dist/xstate.cjs.js +46 -14
  35. package/dist/xstate.cjs.mjs +1 -0
  36. package/dist/xstate.development.cjs.js +46 -14
  37. package/dist/xstate.development.cjs.mjs +1 -0
  38. package/dist/xstate.development.esm.js +42 -11
  39. package/dist/xstate.esm.js +42 -11
  40. package/dist/xstate.umd.min.js +1 -1
  41. package/dist/xstate.umd.min.js.map +1 -1
  42. package/guards/dist/xstate-guards.cjs.js +1 -1
  43. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  44. package/guards/dist/xstate-guards.development.esm.js +1 -1
  45. package/guards/dist/xstate-guards.esm.js +1 -1
  46. package/guards/dist/xstate-guards.umd.min.js +1 -1
  47. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  48. package/package.json +1 -1
@@ -388,6 +388,7 @@ class Actor {
388
388
  this.logger = void 0;
389
389
  this._processingStatus = ProcessingStatus.NotStarted;
390
390
  this._parent = void 0;
391
+ this._syncSnapshot = void 0;
391
392
  this.ref = void 0;
392
393
  this._actorScope = void 0;
393
394
  this._systemId = void 0;
@@ -404,6 +405,7 @@ class Actor {
404
405
  clock,
405
406
  logger,
406
407
  parent,
408
+ syncSnapshot,
407
409
  id,
408
410
  systemId,
409
411
  inspect
@@ -418,6 +420,7 @@ class Actor {
418
420
  this.logger = logger;
419
421
  this.clock = clock;
420
422
  this._parent = parent;
423
+ this._syncSnapshot = syncSnapshot;
421
424
  this.options = resolvedOptions;
422
425
  this.src = resolvedOptions.src ?? logic;
423
426
  this.ref = this;
@@ -576,6 +579,19 @@ class Actor {
576
579
  // Do not restart the service if it is already started
577
580
  return this;
578
581
  }
582
+ if (this._syncSnapshot) {
583
+ this.subscribe({
584
+ next: snapshot => {
585
+ if (snapshot.status === 'active') {
586
+ this._parent.send({
587
+ type: `xstate.snapshot.${this.id}`,
588
+ snapshot
589
+ });
590
+ }
591
+ },
592
+ error: () => {}
593
+ });
594
+ }
579
595
  this.system._register(this.sessionId, this);
580
596
  if (this._systemId) {
581
597
  this.system._set(this._systemId, this);
@@ -853,20 +869,6 @@ const interpret = createActor;
853
869
  * @deprecated Use `Actor` instead.
854
870
  */
855
871
 
856
- const cache = new WeakMap();
857
- function memo(object, key, fn) {
858
- let memoizedData = cache.get(object);
859
- if (!memoizedData) {
860
- memoizedData = {
861
- [key]: fn()
862
- };
863
- cache.set(object, memoizedData);
864
- } else if (!(key in memoizedData)) {
865
- memoizedData[key] = fn();
866
- }
867
- return memoizedData[key];
868
- }
869
-
870
872
  function resolveCancel(_, state, actionArgs, actionParams, {
871
873
  sendId
872
874
  }) {
@@ -908,6 +910,7 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
908
910
  id: resolvedId,
909
911
  src,
910
912
  parent: actorScope?.self,
913
+ syncSnapshot,
911
914
  systemId,
912
915
  input: typeof input === 'function' ? input({
913
916
  context: state.context,
@@ -915,19 +918,6 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
915
918
  self: actorScope?.self
916
919
  }) : input
917
920
  });
918
- if (syncSnapshot) {
919
- actorRef.subscribe({
920
- next: snapshot => {
921
- if (snapshot.status === 'active') {
922
- actorScope.self.send({
923
- type: `xstate.snapshot.${id}`,
924
- snapshot
925
- });
926
- }
927
- },
928
- error: () => {}
929
- });
930
- }
931
921
  }
932
922
  return [cloneMachineSnapshot(state, {
933
923
  children: {
@@ -1037,7 +1027,7 @@ function checkStateIn(state, _, {
1037
1027
  }) {
1038
1028
  if (typeof stateValue === 'string' && isStateId(stateValue)) {
1039
1029
  const target = state.machine.getStateNodeById(stateValue);
1040
- return state.configuration.some(sn => sn === target);
1030
+ return state._nodes.some(sn => sn === target);
1041
1031
  }
1042
1032
  return state.matches(stateValue);
1043
1033
  }
@@ -1148,26 +1138,25 @@ function getProperAncestors(stateNode, toStateNode) {
1148
1138
  }
1149
1139
  return ancestors;
1150
1140
  }
1151
- function getConfiguration(stateNodes) {
1152
- const configuration = new Set(stateNodes);
1153
- const configurationSet = new Set(stateNodes);
1154
- const adjList = getAdjList(configurationSet);
1141
+ function getAllStateNodes(stateNodes) {
1142
+ const nodeSet = new Set(stateNodes);
1143
+ const adjList = getAdjList(nodeSet);
1155
1144
 
1156
1145
  // add descendants
1157
- for (const s of configuration) {
1146
+ for (const s of nodeSet) {
1158
1147
  // if previously active, add existing child nodes
1159
1148
  if (s.type === 'compound' && (!adjList.get(s) || !adjList.get(s).length)) {
1160
- getInitialStateNodesWithTheirAncestors(s).forEach(sn => configurationSet.add(sn));
1149
+ getInitialStateNodesWithTheirAncestors(s).forEach(sn => nodeSet.add(sn));
1161
1150
  } else {
1162
1151
  if (s.type === 'parallel') {
1163
1152
  for (const child of getChildren(s)) {
1164
1153
  if (child.type === 'history') {
1165
1154
  continue;
1166
1155
  }
1167
- if (!configurationSet.has(child)) {
1156
+ if (!nodeSet.has(child)) {
1168
1157
  const initialStates = getInitialStateNodesWithTheirAncestors(child);
1169
1158
  for (const initialStateNode of initialStates) {
1170
- configurationSet.add(initialStateNode);
1159
+ nodeSet.add(initialStateNode);
1171
1160
  }
1172
1161
  }
1173
1162
  }
@@ -1176,14 +1165,14 @@ function getConfiguration(stateNodes) {
1176
1165
  }
1177
1166
 
1178
1167
  // add all ancestors
1179
- for (const s of configurationSet) {
1168
+ for (const s of nodeSet) {
1180
1169
  let m = s.parent;
1181
1170
  while (m) {
1182
- configurationSet.add(m);
1171
+ nodeSet.add(m);
1183
1172
  m = m.parent;
1184
1173
  }
1185
1174
  }
1186
- return configurationSet;
1175
+ return nodeSet;
1187
1176
  }
1188
1177
  function getValueFromAdj(baseNode, adjList) {
1189
1178
  const childStateNodes = adjList.get(baseNode);
@@ -1207,9 +1196,9 @@ function getValueFromAdj(baseNode, adjList) {
1207
1196
  }
1208
1197
  return stateValue;
1209
1198
  }
1210
- function getAdjList(configuration) {
1199
+ function getAdjList(stateNodes) {
1211
1200
  const adjList = new Map();
1212
- for (const s of configuration) {
1201
+ for (const s of stateNodes) {
1213
1202
  if (!adjList.has(s)) {
1214
1203
  adjList.set(s, []);
1215
1204
  }
@@ -1222,16 +1211,16 @@ function getAdjList(configuration) {
1222
1211
  }
1223
1212
  return adjList;
1224
1213
  }
1225
- function getStateValue(rootNode, configuration) {
1226
- const config = getConfiguration(configuration);
1214
+ function getStateValue(rootNode, stateNodes) {
1215
+ const config = getAllStateNodes(stateNodes);
1227
1216
  return getValueFromAdj(rootNode, getAdjList(config));
1228
1217
  }
1229
- function isInFinalState(configuration, stateNode) {
1218
+ function isInFinalState(stateNodeSet, stateNode) {
1230
1219
  if (stateNode.type === 'compound') {
1231
- return getChildren(stateNode).some(s => s.type === 'final' && configuration.has(s));
1220
+ return getChildren(stateNode).some(s => s.type === 'final' && stateNodeSet.has(s));
1232
1221
  }
1233
1222
  if (stateNode.type === 'parallel') {
1234
- return getChildren(stateNode).every(sn => isInFinalState(configuration, sn));
1223
+ return getChildren(stateNode).every(sn => isInFinalState(stateNodeSet, sn));
1235
1224
  }
1236
1225
  return stateNode.type === 'final';
1237
1226
  }
@@ -1591,13 +1580,13 @@ function hasIntersection(s1, s2) {
1591
1580
  }
1592
1581
  return false;
1593
1582
  }
1594
- function removeConflictingTransitions(enabledTransitions, configuration, historyValue) {
1583
+ function removeConflictingTransitions(enabledTransitions, stateNodeSet, historyValue) {
1595
1584
  const filteredTransitions = new Set();
1596
1585
  for (const t1 of enabledTransitions) {
1597
1586
  let t1Preempted = false;
1598
1587
  const transitionsToRemove = new Set();
1599
1588
  for (const t2 of filteredTransitions) {
1600
- if (hasIntersection(computeExitSet([t1], configuration, historyValue), computeExitSet([t2], configuration, historyValue))) {
1589
+ if (hasIntersection(computeExitSet([t1], stateNodeSet, historyValue), computeExitSet([t2], stateNodeSet, historyValue))) {
1601
1590
  if (isDescendant(t1.source, t2.source)) {
1602
1591
  transitionsToRemove.add(t2);
1603
1592
  } else {
@@ -1664,7 +1653,7 @@ function getTransitionDomain(transition, historyValue) {
1664
1653
  }
1665
1654
  return transition.source.machine.root;
1666
1655
  }
1667
- function computeExitSet(transitions, configuration, historyValue) {
1656
+ function computeExitSet(transitions, stateNodeSet, historyValue) {
1668
1657
  const statesToExit = new Set();
1669
1658
  for (const t of transitions) {
1670
1659
  if (t.target?.length) {
@@ -1672,7 +1661,7 @@ function computeExitSet(transitions, configuration, historyValue) {
1672
1661
  if (t.reenter && t.source === domain) {
1673
1662
  statesToExit.add(domain);
1674
1663
  }
1675
- for (const stateNode of configuration) {
1664
+ for (const stateNode of stateNodeSet) {
1676
1665
  if (isDescendant(stateNode, domain)) {
1677
1666
  statesToExit.add(stateNode);
1678
1667
  }
@@ -1681,12 +1670,12 @@ function computeExitSet(transitions, configuration, historyValue) {
1681
1670
  }
1682
1671
  return [...statesToExit];
1683
1672
  }
1684
- function areConfigurationsEqual(previousConfiguration, nextConfigurationSet) {
1685
- if (previousConfiguration.length !== nextConfigurationSet.size) {
1673
+ function areStateNodeCollectionsEqual(prevStateNodes, nextStateNodeSet) {
1674
+ if (prevStateNodes.length !== nextStateNodeSet.size) {
1686
1675
  return false;
1687
1676
  }
1688
- for (const node of previousConfiguration) {
1689
- if (!nextConfigurationSet.has(node)) {
1677
+ for (const node of prevStateNodes) {
1678
+ if (!nextStateNodeSet.has(node)) {
1690
1679
  return false;
1691
1680
  }
1692
1681
  }
@@ -1700,31 +1689,31 @@ function microstep(transitions, currentState, actorScope, event, isInitial, inte
1700
1689
  if (!transitions.length) {
1701
1690
  return currentState;
1702
1691
  }
1703
- const mutConfiguration = new Set(currentState.configuration);
1692
+ const mutStateNodeSet = new Set(currentState._nodes);
1704
1693
  let historyValue = currentState.historyValue;
1705
- const filteredTransitions = removeConflictingTransitions(transitions, mutConfiguration, historyValue);
1694
+ const filteredTransitions = removeConflictingTransitions(transitions, mutStateNodeSet, historyValue);
1706
1695
  let nextState = currentState;
1707
1696
 
1708
1697
  // Exit states
1709
1698
  if (!isInitial) {
1710
- [nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutConfiguration, historyValue, internalQueue);
1699
+ [nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, historyValue, internalQueue);
1711
1700
  }
1712
1701
 
1713
1702
  // Execute transition content
1714
1703
  nextState = resolveActionsAndContext(nextState, event, actorScope, filteredTransitions.flatMap(t => t.actions), internalQueue);
1715
1704
 
1716
1705
  // Enter states
1717
- nextState = enterStates(nextState, event, actorScope, filteredTransitions, mutConfiguration, internalQueue, historyValue, isInitial);
1718
- const nextConfiguration = [...mutConfiguration];
1706
+ nextState = enterStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial);
1707
+ const nextStateNodes = [...mutStateNodeSet];
1719
1708
  if (nextState.status === 'done') {
1720
- nextState = resolveActionsAndContext(nextState, event, actorScope, nextConfiguration.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue);
1709
+ nextState = resolveActionsAndContext(nextState, event, actorScope, nextStateNodes.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue);
1721
1710
  }
1722
1711
  try {
1723
- if (historyValue === currentState.historyValue && areConfigurationsEqual(currentState.configuration, mutConfiguration)) {
1712
+ if (historyValue === currentState.historyValue && areStateNodeCollectionsEqual(currentState._nodes, mutStateNodeSet)) {
1724
1713
  return nextState;
1725
1714
  }
1726
1715
  return cloneMachineSnapshot(nextState, {
1727
- configuration: nextConfiguration,
1716
+ _nodes: nextStateNodes,
1728
1717
  historyValue
1729
1718
  });
1730
1719
  } catch (e) {
@@ -1740,7 +1729,7 @@ function getMachineOutput(state, event, actorScope, rootNode, rootCompletionNode
1740
1729
  const doneStateEvent = createDoneStateEvent(rootCompletionNode.id, rootCompletionNode.output && rootCompletionNode.parent ? resolveOutput(rootCompletionNode.output, state.context, event, actorScope.self) : undefined);
1741
1730
  return resolveOutput(rootNode.output, state.context, doneStateEvent, actorScope.self);
1742
1731
  }
1743
- function enterStates(currentState, event, actorScope, filteredTransitions, mutConfiguration, internalQueue, historyValue, isInitial) {
1732
+ function enterStates(currentState, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial) {
1744
1733
  let nextState = currentState;
1745
1734
  const statesToEnter = new Set();
1746
1735
  // those are states that were directly targeted or indirectly targeted by the explicit target
@@ -1755,7 +1744,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutCo
1755
1744
  }
1756
1745
  const completedNodes = new Set();
1757
1746
  for (const stateNodeToEnter of [...statesToEnter].sort((a, b) => a.order - b.order)) {
1758
- mutConfiguration.add(stateNodeToEnter);
1747
+ mutStateNodeSet.add(stateNodeToEnter);
1759
1748
  const actions = [];
1760
1749
 
1761
1750
  // Add entry actions
@@ -1778,7 +1767,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutCo
1778
1767
  if (parent?.type === 'compound') {
1779
1768
  internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output ? resolveOutput(stateNodeToEnter.output, nextState.context, event, actorScope.self) : undefined));
1780
1769
  }
1781
- while (ancestorMarker?.type === 'parallel' && !completedNodes.has(ancestorMarker) && isInFinalState(mutConfiguration, ancestorMarker)) {
1770
+ while (ancestorMarker?.type === 'parallel' && !completedNodes.has(ancestorMarker) && isInFinalState(mutStateNodeSet, ancestorMarker)) {
1782
1771
  completedNodes.add(ancestorMarker);
1783
1772
  internalQueue.push(createDoneStateEvent(ancestorMarker.id));
1784
1773
  rootCompletionNode = ancestorMarker;
@@ -1888,9 +1877,9 @@ function addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultE
1888
1877
  function addProperAncestorStatesToEnter(stateNode, toStateNode, statesToEnter, historyValue, statesForDefaultEntry) {
1889
1878
  addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultEntry, getProperAncestors(stateNode, toStateNode));
1890
1879
  }
1891
- function exitStates(currentState, event, actorScope, transitions, mutConfiguration, historyValue, internalQueue) {
1880
+ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSet, historyValue, internalQueue) {
1892
1881
  let nextState = currentState;
1893
- const statesToExit = computeExitSet(transitions, mutConfiguration, historyValue);
1882
+ const statesToExit = computeExitSet(transitions, mutStateNodeSet, historyValue);
1894
1883
  statesToExit.sort((a, b) => b.order - a.order);
1895
1884
  let changedHistory;
1896
1885
 
@@ -1908,12 +1897,12 @@ function exitStates(currentState, event, actorScope, transitions, mutConfigurati
1908
1897
  changedHistory ??= {
1909
1898
  ...historyValue
1910
1899
  };
1911
- changedHistory[historyNode.id] = Array.from(mutConfiguration).filter(predicate);
1900
+ changedHistory[historyNode.id] = Array.from(mutStateNodeSet).filter(predicate);
1912
1901
  }
1913
1902
  }
1914
1903
  for (const s of statesToExit) {
1915
1904
  nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stop(def.id))], internalQueue);
1916
- mutConfiguration.delete(s);
1905
+ mutStateNodeSet.delete(s);
1917
1906
  }
1918
1907
  return [nextState, changedHistory || historyValue];
1919
1908
  }
@@ -2042,7 +2031,7 @@ function selectTransitions(event, nextState) {
2042
2031
  }
2043
2032
  function selectEventlessTransitions(nextState, event) {
2044
2033
  const enabledTransitionSet = new Set();
2045
- const atomicStates = nextState.configuration.filter(isAtomicStateNode);
2034
+ const atomicStates = nextState._nodes.filter(isAtomicStateNode);
2046
2035
  for (const stateNode of atomicStates) {
2047
2036
  loop: for (const s of [stateNode].concat(getProperAncestors(stateNode, undefined))) {
2048
2037
  if (!s.always) {
@@ -2056,7 +2045,7 @@ function selectEventlessTransitions(nextState, event) {
2056
2045
  }
2057
2046
  }
2058
2047
  }
2059
- return removeConflictingTransitions(Array.from(enabledTransitionSet), new Set(nextState.configuration), nextState.historyValue);
2048
+ return removeConflictingTransitions(Array.from(enabledTransitionSet), new Set(nextState._nodes), nextState.historyValue);
2060
2049
  }
2061
2050
 
2062
2051
  /**
@@ -2065,8 +2054,8 @@ function selectEventlessTransitions(nextState, event) {
2065
2054
  * @param stateValue The partial state value to resolve.
2066
2055
  */
2067
2056
  function resolveStateValue(rootNode, stateValue) {
2068
- const configuration = getConfiguration(getStateNodes(rootNode, stateValue));
2069
- return getStateValue(rootNode, [...configuration]);
2057
+ const allStateNodes = getAllStateNodes(getStateNodes(rootNode, stateValue));
2058
+ return getStateValue(rootNode, [...allStateNodes]);
2070
2059
  }
2071
2060
 
2072
2061
  function isMachineSnapshot(value) {
@@ -2086,10 +2075,11 @@ const machineSnapshotCan = function can(event) {
2086
2075
  };
2087
2076
  const machineSnapshotToJSON = function toJSON() {
2088
2077
  const {
2089
- configuration,
2078
+ _nodes: nodes,
2090
2079
  tags,
2091
2080
  machine,
2092
- nextEvents,
2081
+ getNextEvents,
2082
+ getMeta,
2093
2083
  toJSON,
2094
2084
  can,
2095
2085
  hasTag,
@@ -2101,13 +2091,11 @@ const machineSnapshotToJSON = function toJSON() {
2101
2091
  tags: Array.from(tags)
2102
2092
  };
2103
2093
  };
2104
- const machineSnapshotNextEvents = function nextEvents() {
2105
- return memo(this, 'nextEvents', () => {
2106
- return [...new Set(flatten([...this.configuration.map(sn => sn.ownEvents)]))];
2107
- });
2094
+ const machineSnapshotGetNextEvents = function getNextEvents() {
2095
+ return [...new Set(flatten([...this._nodes.map(sn => sn.ownEvents)]))];
2108
2096
  };
2109
- const machineSnapshotMeta = function nextEvents() {
2110
- return this.configuration.reduce((acc, stateNode) => {
2097
+ const machineSnapshotGetMeta = function getMeta() {
2098
+ return this._nodes.reduce((acc, stateNode) => {
2111
2099
  if (stateNode.meta !== undefined) {
2112
2100
  acc[stateNode.id] = stateNode.meta;
2113
2101
  }
@@ -2115,48 +2103,35 @@ const machineSnapshotMeta = function nextEvents() {
2115
2103
  }, {});
2116
2104
  };
2117
2105
  function createMachineSnapshot(config, machine) {
2118
- const snapshot = {
2106
+ return {
2119
2107
  status: config.status,
2120
2108
  output: config.output,
2121
2109
  error: config.error,
2122
2110
  machine,
2123
2111
  context: config.context,
2124
- configuration: config.configuration,
2125
- value: getStateValue(machine.root, config.configuration),
2126
- tags: new Set(flatten(config.configuration.map(sn => sn.tags))),
2112
+ _nodes: config._nodes,
2113
+ value: getStateValue(machine.root, config._nodes),
2114
+ tags: new Set(flatten(config._nodes.map(sn => sn.tags))),
2127
2115
  children: config.children,
2128
2116
  historyValue: config.historyValue || {},
2129
2117
  // this one is generic in the target and it's hard to create a matching non-generic source signature
2130
2118
  matches: machineSnapshotMatches,
2131
2119
  hasTag: machineSnapshotHasTag,
2132
2120
  can: machineSnapshotCan,
2121
+ getNextEvents: machineSnapshotGetNextEvents,
2122
+ getMeta: machineSnapshotGetMeta,
2133
2123
  toJSON: machineSnapshotToJSON
2134
2124
  };
2135
- Object.defineProperties(snapshot, {
2136
- nextEvents: {
2137
- get: machineSnapshotNextEvents,
2138
- configurable: true,
2139
- enumerable: true
2140
- },
2141
- meta: {
2142
- get: machineSnapshotMeta,
2143
- configurable: true,
2144
- enumerable: true
2145
- }
2146
- });
2147
- return snapshot;
2148
2125
  }
2149
2126
  function cloneMachineSnapshot(state, config = {}) {
2150
- return createMachineSnapshot(
2151
- // TODO: it's wasteful that this spread triggers getters
2152
- {
2127
+ return createMachineSnapshot({
2153
2128
  ...state,
2154
2129
  ...config
2155
2130
  }, state.machine);
2156
2131
  }
2157
2132
  function getPersistedState(state, options) {
2158
2133
  const {
2159
- configuration,
2134
+ _nodes: nodes,
2160
2135
  tags,
2161
2136
  machine,
2162
2137
  children,
@@ -2164,8 +2139,9 @@ function getPersistedState(state, options) {
2164
2139
  can,
2165
2140
  hasTag,
2166
2141
  matches,
2142
+ getNextEvents,
2143
+ getMeta,
2167
2144
  toJSON,
2168
- nextEvents,
2169
2145
  ...jsonValues
2170
2146
  } = state;
2171
2147
  const childrenJson = {};
@@ -2174,7 +2150,8 @@ function getPersistedState(state, options) {
2174
2150
  childrenJson[id] = {
2175
2151
  state: child.getPersistedState(options),
2176
2152
  src: child.src,
2177
- systemId: child._systemId
2153
+ systemId: child._systemId,
2154
+ syncSnapshot: child._syncSnapshot
2178
2155
  };
2179
2156
  }
2180
2157
  const persisted = {
@@ -2282,8 +2259,8 @@ exports.evaluateGuard = evaluateGuard;
2282
2259
  exports.formatInitialTransition = formatInitialTransition;
2283
2260
  exports.formatTransition = formatTransition;
2284
2261
  exports.formatTransitions = formatTransitions;
2262
+ exports.getAllStateNodes = getAllStateNodes;
2285
2263
  exports.getCandidates = getCandidates;
2286
- exports.getConfiguration = getConfiguration;
2287
2264
  exports.getDelayedTransitions = getDelayedTransitions;
2288
2265
  exports.getInitialStateNodes = getInitialStateNodes;
2289
2266
  exports.getPersistedState = getPersistedState;
@@ -2297,7 +2274,6 @@ exports.isStateId = isStateId;
2297
2274
  exports.macrostep = macrostep;
2298
2275
  exports.mapValues = mapValues;
2299
2276
  exports.matchesState = matchesState;
2300
- exports.memo = memo;
2301
2277
  exports.microstep = microstep;
2302
2278
  exports.not = not;
2303
2279
  exports.or = or;
@@ -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-348cc74e.development.esm.js';
1
+ import { R as ProcessingStatus, T as createErrorActorEvent, A as resolveReferencedActor, B as createActor, o as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR } from './raise-90139fbc.development.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -17,6 +17,7 @@ function createSpawner(actorScope, {
17
17
  const actorRef = createActor(logic, {
18
18
  id: options.id,
19
19
  parent: actorScope.self,
20
+ syncSnapshot: options.syncSnapshot,
20
21
  input: typeof input === 'function' ? input({
21
22
  context,
22
23
  event,
@@ -26,42 +27,16 @@ function createSpawner(actorScope, {
26
27
  systemId
27
28
  });
28
29
  spawnedChildren[actorRef.id] = actorRef;
29
- if (options.syncSnapshot) {
30
- actorRef.subscribe({
31
- next: snapshot => {
32
- if (snapshot.status === 'active') {
33
- actorScope.self.send({
34
- type: `xstate.snapshot.${actorRef.id}`,
35
- snapshot
36
- });
37
- }
38
- },
39
- error: () => {}
40
- });
41
- }
42
30
  return actorRef;
43
31
  } else {
44
32
  const actorRef = createActor(src, {
45
33
  id: options.id,
46
34
  parent: actorScope.self,
35
+ syncSnapshot: options.syncSnapshot,
47
36
  input: options.input,
48
37
  src,
49
38
  systemId
50
39
  });
51
- if (options.syncSnapshot) {
52
- actorRef.subscribe({
53
- next: snapshot => {
54
- if (snapshot.status === 'active') {
55
- actorScope.self.send({
56
- type: `xstate.snapshot.${actorRef.id}`,
57
- snapshot,
58
- id: actorRef.id
59
- });
60
- }
61
- },
62
- error: () => {}
63
- });
64
- }
65
40
  return actorRef;
66
41
  }
67
42
  };
@@ -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-5854eaca.esm.js';
1
+ import { R as ProcessingStatus, T as createErrorActorEvent, A as resolveReferencedActor, B as createActor, o as cloneMachineSnapshot, e as evaluateGuard, t as toArray, U as XSTATE_ERROR } from './raise-2b5a4e4c.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -17,6 +17,7 @@ function createSpawner(actorScope, {
17
17
  const actorRef = createActor(logic, {
18
18
  id: options.id,
19
19
  parent: actorScope.self,
20
+ syncSnapshot: options.syncSnapshot,
20
21
  input: typeof input === 'function' ? input({
21
22
  context,
22
23
  event,
@@ -26,42 +27,16 @@ function createSpawner(actorScope, {
26
27
  systemId
27
28
  });
28
29
  spawnedChildren[actorRef.id] = actorRef;
29
- if (options.syncSnapshot) {
30
- actorRef.subscribe({
31
- next: snapshot => {
32
- if (snapshot.status === 'active') {
33
- actorScope.self.send({
34
- type: `xstate.snapshot.${actorRef.id}`,
35
- snapshot
36
- });
37
- }
38
- },
39
- error: () => {}
40
- });
41
- }
42
30
  return actorRef;
43
31
  } else {
44
32
  const actorRef = createActor(src, {
45
33
  id: options.id,
46
34
  parent: actorScope.self,
35
+ syncSnapshot: options.syncSnapshot,
47
36
  input: options.input,
48
37
  src,
49
38
  systemId
50
39
  });
51
- if (options.syncSnapshot) {
52
- actorRef.subscribe({
53
- next: snapshot => {
54
- if (snapshot.status === 'active') {
55
- actorScope.self.send({
56
- type: `xstate.snapshot.${actorRef.id}`,
57
- snapshot,
58
- id: actorRef.id
59
- });
60
- }
61
- },
62
- error: () => {}
63
- });
64
- }
65
40
  return actorRef;
66
41
  }
67
42
  };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-fb6f017b.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-fabffc3d.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -19,6 +19,7 @@ function createSpawner(actorScope, {
19
19
  const actorRef = guards_dist_xstateGuards.createActor(logic, {
20
20
  id: options.id,
21
21
  parent: actorScope.self,
22
+ syncSnapshot: options.syncSnapshot,
22
23
  input: typeof input === 'function' ? input({
23
24
  context,
24
25
  event,
@@ -28,42 +29,16 @@ function createSpawner(actorScope, {
28
29
  systemId
29
30
  });
30
31
  spawnedChildren[actorRef.id] = actorRef;
31
- if (options.syncSnapshot) {
32
- actorRef.subscribe({
33
- next: snapshot => {
34
- if (snapshot.status === 'active') {
35
- actorScope.self.send({
36
- type: `xstate.snapshot.${actorRef.id}`,
37
- snapshot
38
- });
39
- }
40
- },
41
- error: () => {}
42
- });
43
- }
44
32
  return actorRef;
45
33
  } else {
46
34
  const actorRef = guards_dist_xstateGuards.createActor(src, {
47
35
  id: options.id,
48
36
  parent: actorScope.self,
37
+ syncSnapshot: options.syncSnapshot,
49
38
  input: options.input,
50
39
  src,
51
40
  systemId
52
41
  });
53
- if (options.syncSnapshot) {
54
- actorRef.subscribe({
55
- next: snapshot => {
56
- if (snapshot.status === 'active') {
57
- actorScope.self.send({
58
- type: `xstate.snapshot.${actorRef.id}`,
59
- snapshot,
60
- id: actorRef.id
61
- });
62
- }
63
- },
64
- error: () => {}
65
- });
66
- }
67
42
  return actorRef;
68
43
  }
69
44
  };