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
@@ -389,6 +389,7 @@ class Actor {
389
389
  this.logger = void 0;
390
390
  this._processingStatus = ProcessingStatus.NotStarted;
391
391
  this._parent = void 0;
392
+ this._syncSnapshot = void 0;
392
393
  this.ref = void 0;
393
394
  this._actorScope = void 0;
394
395
  this._systemId = void 0;
@@ -405,6 +406,7 @@ class Actor {
405
406
  clock,
406
407
  logger,
407
408
  parent,
409
+ syncSnapshot,
408
410
  id,
409
411
  systemId,
410
412
  inspect
@@ -419,6 +421,7 @@ class Actor {
419
421
  this.logger = logger;
420
422
  this.clock = clock;
421
423
  this._parent = parent;
424
+ this._syncSnapshot = syncSnapshot;
422
425
  this.options = resolvedOptions;
423
426
  this.src = resolvedOptions.src ?? logic;
424
427
  this.ref = this;
@@ -577,6 +580,19 @@ class Actor {
577
580
  // Do not restart the service if it is already started
578
581
  return this;
579
582
  }
583
+ if (this._syncSnapshot) {
584
+ this.subscribe({
585
+ next: snapshot => {
586
+ if (snapshot.status === 'active') {
587
+ this._parent.send({
588
+ type: `xstate.snapshot.${this.id}`,
589
+ snapshot
590
+ });
591
+ }
592
+ },
593
+ error: () => {}
594
+ });
595
+ }
580
596
  this.system._register(this.sessionId, this);
581
597
  if (this._systemId) {
582
598
  this.system._set(this._systemId, this);
@@ -862,20 +878,6 @@ const interpret = createActor;
862
878
  * @deprecated Use `Actor` instead.
863
879
  */
864
880
 
865
- const cache = new WeakMap();
866
- function memo(object, key, fn) {
867
- let memoizedData = cache.get(object);
868
- if (!memoizedData) {
869
- memoizedData = {
870
- [key]: fn()
871
- };
872
- cache.set(object, memoizedData);
873
- } else if (!(key in memoizedData)) {
874
- memoizedData[key] = fn();
875
- }
876
- return memoizedData[key];
877
- }
878
-
879
881
  function resolveCancel(_, state, actionArgs, actionParams, {
880
882
  sendId
881
883
  }) {
@@ -920,6 +922,7 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
920
922
  id: resolvedId,
921
923
  src,
922
924
  parent: actorScope?.self,
925
+ syncSnapshot,
923
926
  systemId,
924
927
  input: typeof input === 'function' ? input({
925
928
  context: state.context,
@@ -927,19 +930,6 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
927
930
  self: actorScope?.self
928
931
  }) : input
929
932
  });
930
- if (syncSnapshot) {
931
- actorRef.subscribe({
932
- next: snapshot => {
933
- if (snapshot.status === 'active') {
934
- actorScope.self.send({
935
- type: `xstate.snapshot.${id}`,
936
- snapshot
937
- });
938
- }
939
- },
940
- error: () => {}
941
- });
942
- }
943
933
  }
944
934
  if (!actorRef) {
945
935
  console.warn(`Actor type '${src}' not found in machine '${actorScope.id}'.`);
@@ -1058,7 +1048,7 @@ function checkStateIn(state, _, {
1058
1048
  }) {
1059
1049
  if (typeof stateValue === 'string' && isStateId(stateValue)) {
1060
1050
  const target = state.machine.getStateNodeById(stateValue);
1061
- return state.configuration.some(sn => sn === target);
1051
+ return state._nodes.some(sn => sn === target);
1062
1052
  }
1063
1053
  return state.matches(stateValue);
1064
1054
  }
@@ -1177,26 +1167,25 @@ function getProperAncestors(stateNode, toStateNode) {
1177
1167
  }
1178
1168
  return ancestors;
1179
1169
  }
1180
- function getConfiguration(stateNodes) {
1181
- const configuration = new Set(stateNodes);
1182
- const configurationSet = new Set(stateNodes);
1183
- const adjList = getAdjList(configurationSet);
1170
+ function getAllStateNodes(stateNodes) {
1171
+ const nodeSet = new Set(stateNodes);
1172
+ const adjList = getAdjList(nodeSet);
1184
1173
 
1185
1174
  // add descendants
1186
- for (const s of configuration) {
1175
+ for (const s of nodeSet) {
1187
1176
  // if previously active, add existing child nodes
1188
1177
  if (s.type === 'compound' && (!adjList.get(s) || !adjList.get(s).length)) {
1189
- getInitialStateNodesWithTheirAncestors(s).forEach(sn => configurationSet.add(sn));
1178
+ getInitialStateNodesWithTheirAncestors(s).forEach(sn => nodeSet.add(sn));
1190
1179
  } else {
1191
1180
  if (s.type === 'parallel') {
1192
1181
  for (const child of getChildren(s)) {
1193
1182
  if (child.type === 'history') {
1194
1183
  continue;
1195
1184
  }
1196
- if (!configurationSet.has(child)) {
1185
+ if (!nodeSet.has(child)) {
1197
1186
  const initialStates = getInitialStateNodesWithTheirAncestors(child);
1198
1187
  for (const initialStateNode of initialStates) {
1199
- configurationSet.add(initialStateNode);
1188
+ nodeSet.add(initialStateNode);
1200
1189
  }
1201
1190
  }
1202
1191
  }
@@ -1205,14 +1194,14 @@ function getConfiguration(stateNodes) {
1205
1194
  }
1206
1195
 
1207
1196
  // add all ancestors
1208
- for (const s of configurationSet) {
1197
+ for (const s of nodeSet) {
1209
1198
  let m = s.parent;
1210
1199
  while (m) {
1211
- configurationSet.add(m);
1200
+ nodeSet.add(m);
1212
1201
  m = m.parent;
1213
1202
  }
1214
1203
  }
1215
- return configurationSet;
1204
+ return nodeSet;
1216
1205
  }
1217
1206
  function getValueFromAdj(baseNode, adjList) {
1218
1207
  const childStateNodes = adjList.get(baseNode);
@@ -1236,9 +1225,9 @@ function getValueFromAdj(baseNode, adjList) {
1236
1225
  }
1237
1226
  return stateValue;
1238
1227
  }
1239
- function getAdjList(configuration) {
1228
+ function getAdjList(stateNodes) {
1240
1229
  const adjList = new Map();
1241
- for (const s of configuration) {
1230
+ for (const s of stateNodes) {
1242
1231
  if (!adjList.has(s)) {
1243
1232
  adjList.set(s, []);
1244
1233
  }
@@ -1251,16 +1240,16 @@ function getAdjList(configuration) {
1251
1240
  }
1252
1241
  return adjList;
1253
1242
  }
1254
- function getStateValue(rootNode, configuration) {
1255
- const config = getConfiguration(configuration);
1243
+ function getStateValue(rootNode, stateNodes) {
1244
+ const config = getAllStateNodes(stateNodes);
1256
1245
  return getValueFromAdj(rootNode, getAdjList(config));
1257
1246
  }
1258
- function isInFinalState(configuration, stateNode) {
1247
+ function isInFinalState(stateNodeSet, stateNode) {
1259
1248
  if (stateNode.type === 'compound') {
1260
- return getChildren(stateNode).some(s => s.type === 'final' && configuration.has(s));
1249
+ return getChildren(stateNode).some(s => s.type === 'final' && stateNodeSet.has(s));
1261
1250
  }
1262
1251
  if (stateNode.type === 'parallel') {
1263
- return getChildren(stateNode).every(sn => isInFinalState(configuration, sn));
1252
+ return getChildren(stateNode).every(sn => isInFinalState(stateNodeSet, sn));
1264
1253
  }
1265
1254
  return stateNode.type === 'final';
1266
1255
  }
@@ -1631,13 +1620,13 @@ function hasIntersection(s1, s2) {
1631
1620
  }
1632
1621
  return false;
1633
1622
  }
1634
- function removeConflictingTransitions(enabledTransitions, configuration, historyValue) {
1623
+ function removeConflictingTransitions(enabledTransitions, stateNodeSet, historyValue) {
1635
1624
  const filteredTransitions = new Set();
1636
1625
  for (const t1 of enabledTransitions) {
1637
1626
  let t1Preempted = false;
1638
1627
  const transitionsToRemove = new Set();
1639
1628
  for (const t2 of filteredTransitions) {
1640
- if (hasIntersection(computeExitSet([t1], configuration, historyValue), computeExitSet([t2], configuration, historyValue))) {
1629
+ if (hasIntersection(computeExitSet([t1], stateNodeSet, historyValue), computeExitSet([t2], stateNodeSet, historyValue))) {
1641
1630
  if (isDescendant(t1.source, t2.source)) {
1642
1631
  transitionsToRemove.add(t2);
1643
1632
  } else {
@@ -1704,7 +1693,7 @@ function getTransitionDomain(transition, historyValue) {
1704
1693
  }
1705
1694
  return transition.source.machine.root;
1706
1695
  }
1707
- function computeExitSet(transitions, configuration, historyValue) {
1696
+ function computeExitSet(transitions, stateNodeSet, historyValue) {
1708
1697
  const statesToExit = new Set();
1709
1698
  for (const t of transitions) {
1710
1699
  if (t.target?.length) {
@@ -1712,7 +1701,7 @@ function computeExitSet(transitions, configuration, historyValue) {
1712
1701
  if (t.reenter && t.source === domain) {
1713
1702
  statesToExit.add(domain);
1714
1703
  }
1715
- for (const stateNode of configuration) {
1704
+ for (const stateNode of stateNodeSet) {
1716
1705
  if (isDescendant(stateNode, domain)) {
1717
1706
  statesToExit.add(stateNode);
1718
1707
  }
@@ -1721,12 +1710,12 @@ function computeExitSet(transitions, configuration, historyValue) {
1721
1710
  }
1722
1711
  return [...statesToExit];
1723
1712
  }
1724
- function areConfigurationsEqual(previousConfiguration, nextConfigurationSet) {
1725
- if (previousConfiguration.length !== nextConfigurationSet.size) {
1713
+ function areStateNodeCollectionsEqual(prevStateNodes, nextStateNodeSet) {
1714
+ if (prevStateNodes.length !== nextStateNodeSet.size) {
1726
1715
  return false;
1727
1716
  }
1728
- for (const node of previousConfiguration) {
1729
- if (!nextConfigurationSet.has(node)) {
1717
+ for (const node of prevStateNodes) {
1718
+ if (!nextStateNodeSet.has(node)) {
1730
1719
  return false;
1731
1720
  }
1732
1721
  }
@@ -1740,31 +1729,31 @@ function microstep(transitions, currentState, actorScope, event, isInitial, inte
1740
1729
  if (!transitions.length) {
1741
1730
  return currentState;
1742
1731
  }
1743
- const mutConfiguration = new Set(currentState.configuration);
1732
+ const mutStateNodeSet = new Set(currentState._nodes);
1744
1733
  let historyValue = currentState.historyValue;
1745
- const filteredTransitions = removeConflictingTransitions(transitions, mutConfiguration, historyValue);
1734
+ const filteredTransitions = removeConflictingTransitions(transitions, mutStateNodeSet, historyValue);
1746
1735
  let nextState = currentState;
1747
1736
 
1748
1737
  // Exit states
1749
1738
  if (!isInitial) {
1750
- [nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutConfiguration, historyValue, internalQueue);
1739
+ [nextState, historyValue] = exitStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, historyValue, internalQueue);
1751
1740
  }
1752
1741
 
1753
1742
  // Execute transition content
1754
1743
  nextState = resolveActionsAndContext(nextState, event, actorScope, filteredTransitions.flatMap(t => t.actions), internalQueue);
1755
1744
 
1756
1745
  // Enter states
1757
- nextState = enterStates(nextState, event, actorScope, filteredTransitions, mutConfiguration, internalQueue, historyValue, isInitial);
1758
- const nextConfiguration = [...mutConfiguration];
1746
+ nextState = enterStates(nextState, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial);
1747
+ const nextStateNodes = [...mutStateNodeSet];
1759
1748
  if (nextState.status === 'done') {
1760
- nextState = resolveActionsAndContext(nextState, event, actorScope, nextConfiguration.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue);
1749
+ nextState = resolveActionsAndContext(nextState, event, actorScope, nextStateNodes.sort((a, b) => b.order - a.order).flatMap(state => state.exit), internalQueue);
1761
1750
  }
1762
1751
  try {
1763
- if (historyValue === currentState.historyValue && areConfigurationsEqual(currentState.configuration, mutConfiguration)) {
1752
+ if (historyValue === currentState.historyValue && areStateNodeCollectionsEqual(currentState._nodes, mutStateNodeSet)) {
1764
1753
  return nextState;
1765
1754
  }
1766
1755
  return cloneMachineSnapshot(nextState, {
1767
- configuration: nextConfiguration,
1756
+ _nodes: nextStateNodes,
1768
1757
  historyValue
1769
1758
  });
1770
1759
  } catch (e) {
@@ -1780,7 +1769,7 @@ function getMachineOutput(state, event, actorScope, rootNode, rootCompletionNode
1780
1769
  const doneStateEvent = createDoneStateEvent(rootCompletionNode.id, rootCompletionNode.output && rootCompletionNode.parent ? resolveOutput(rootCompletionNode.output, state.context, event, actorScope.self) : undefined);
1781
1770
  return resolveOutput(rootNode.output, state.context, doneStateEvent, actorScope.self);
1782
1771
  }
1783
- function enterStates(currentState, event, actorScope, filteredTransitions, mutConfiguration, internalQueue, historyValue, isInitial) {
1772
+ function enterStates(currentState, event, actorScope, filteredTransitions, mutStateNodeSet, internalQueue, historyValue, isInitial) {
1784
1773
  let nextState = currentState;
1785
1774
  const statesToEnter = new Set();
1786
1775
  // those are states that were directly targeted or indirectly targeted by the explicit target
@@ -1795,7 +1784,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutCo
1795
1784
  }
1796
1785
  const completedNodes = new Set();
1797
1786
  for (const stateNodeToEnter of [...statesToEnter].sort((a, b) => a.order - b.order)) {
1798
- mutConfiguration.add(stateNodeToEnter);
1787
+ mutStateNodeSet.add(stateNodeToEnter);
1799
1788
  const actions = [];
1800
1789
 
1801
1790
  // Add entry actions
@@ -1818,7 +1807,7 @@ function enterStates(currentState, event, actorScope, filteredTransitions, mutCo
1818
1807
  if (parent?.type === 'compound') {
1819
1808
  internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output ? resolveOutput(stateNodeToEnter.output, nextState.context, event, actorScope.self) : undefined));
1820
1809
  }
1821
- while (ancestorMarker?.type === 'parallel' && !completedNodes.has(ancestorMarker) && isInFinalState(mutConfiguration, ancestorMarker)) {
1810
+ while (ancestorMarker?.type === 'parallel' && !completedNodes.has(ancestorMarker) && isInFinalState(mutStateNodeSet, ancestorMarker)) {
1822
1811
  completedNodes.add(ancestorMarker);
1823
1812
  internalQueue.push(createDoneStateEvent(ancestorMarker.id));
1824
1813
  rootCompletionNode = ancestorMarker;
@@ -1928,9 +1917,9 @@ function addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultE
1928
1917
  function addProperAncestorStatesToEnter(stateNode, toStateNode, statesToEnter, historyValue, statesForDefaultEntry) {
1929
1918
  addAncestorStatesToEnter(statesToEnter, historyValue, statesForDefaultEntry, getProperAncestors(stateNode, toStateNode));
1930
1919
  }
1931
- function exitStates(currentState, event, actorScope, transitions, mutConfiguration, historyValue, internalQueue) {
1920
+ function exitStates(currentState, event, actorScope, transitions, mutStateNodeSet, historyValue, internalQueue) {
1932
1921
  let nextState = currentState;
1933
- const statesToExit = computeExitSet(transitions, mutConfiguration, historyValue);
1922
+ const statesToExit = computeExitSet(transitions, mutStateNodeSet, historyValue);
1934
1923
  statesToExit.sort((a, b) => b.order - a.order);
1935
1924
  let changedHistory;
1936
1925
 
@@ -1948,12 +1937,12 @@ function exitStates(currentState, event, actorScope, transitions, mutConfigurati
1948
1937
  changedHistory ??= {
1949
1938
  ...historyValue
1950
1939
  };
1951
- changedHistory[historyNode.id] = Array.from(mutConfiguration).filter(predicate);
1940
+ changedHistory[historyNode.id] = Array.from(mutStateNodeSet).filter(predicate);
1952
1941
  }
1953
1942
  }
1954
1943
  for (const s of statesToExit) {
1955
1944
  nextState = resolveActionsAndContext(nextState, event, actorScope, [...s.exit, ...s.invoke.map(def => stop(def.id))], internalQueue);
1956
- mutConfiguration.delete(s);
1945
+ mutStateNodeSet.delete(s);
1957
1946
  }
1958
1947
  return [nextState, changedHistory || historyValue];
1959
1948
  }
@@ -2085,7 +2074,7 @@ function selectTransitions(event, nextState) {
2085
2074
  }
2086
2075
  function selectEventlessTransitions(nextState, event) {
2087
2076
  const enabledTransitionSet = new Set();
2088
- const atomicStates = nextState.configuration.filter(isAtomicStateNode);
2077
+ const atomicStates = nextState._nodes.filter(isAtomicStateNode);
2089
2078
  for (const stateNode of atomicStates) {
2090
2079
  loop: for (const s of [stateNode].concat(getProperAncestors(stateNode, undefined))) {
2091
2080
  if (!s.always) {
@@ -2099,7 +2088,7 @@ function selectEventlessTransitions(nextState, event) {
2099
2088
  }
2100
2089
  }
2101
2090
  }
2102
- return removeConflictingTransitions(Array.from(enabledTransitionSet), new Set(nextState.configuration), nextState.historyValue);
2091
+ return removeConflictingTransitions(Array.from(enabledTransitionSet), new Set(nextState._nodes), nextState.historyValue);
2103
2092
  }
2104
2093
 
2105
2094
  /**
@@ -2108,8 +2097,8 @@ function selectEventlessTransitions(nextState, event) {
2108
2097
  * @param stateValue The partial state value to resolve.
2109
2098
  */
2110
2099
  function resolveStateValue(rootNode, stateValue) {
2111
- const configuration = getConfiguration(getStateNodes(rootNode, stateValue));
2112
- return getStateValue(rootNode, [...configuration]);
2100
+ const allStateNodes = getAllStateNodes(getStateNodes(rootNode, stateValue));
2101
+ return getStateValue(rootNode, [...allStateNodes]);
2113
2102
  }
2114
2103
 
2115
2104
  function isMachineSnapshot(value) {
@@ -2132,10 +2121,11 @@ const machineSnapshotCan = function can(event) {
2132
2121
  };
2133
2122
  const machineSnapshotToJSON = function toJSON() {
2134
2123
  const {
2135
- configuration,
2124
+ _nodes: nodes,
2136
2125
  tags,
2137
2126
  machine,
2138
- nextEvents,
2127
+ getNextEvents,
2128
+ getMeta,
2139
2129
  toJSON,
2140
2130
  can,
2141
2131
  hasTag,
@@ -2147,13 +2137,11 @@ const machineSnapshotToJSON = function toJSON() {
2147
2137
  tags: Array.from(tags)
2148
2138
  };
2149
2139
  };
2150
- const machineSnapshotNextEvents = function nextEvents() {
2151
- return memo(this, 'nextEvents', () => {
2152
- return [...new Set(flatten([...this.configuration.map(sn => sn.ownEvents)]))];
2153
- });
2140
+ const machineSnapshotGetNextEvents = function getNextEvents() {
2141
+ return [...new Set(flatten([...this._nodes.map(sn => sn.ownEvents)]))];
2154
2142
  };
2155
- const machineSnapshotMeta = function nextEvents() {
2156
- return this.configuration.reduce((acc, stateNode) => {
2143
+ const machineSnapshotGetMeta = function getMeta() {
2144
+ return this._nodes.reduce((acc, stateNode) => {
2157
2145
  if (stateNode.meta !== undefined) {
2158
2146
  acc[stateNode.id] = stateNode.meta;
2159
2147
  }
@@ -2161,48 +2149,35 @@ const machineSnapshotMeta = function nextEvents() {
2161
2149
  }, {});
2162
2150
  };
2163
2151
  function createMachineSnapshot(config, machine) {
2164
- const snapshot = {
2152
+ return {
2165
2153
  status: config.status,
2166
2154
  output: config.output,
2167
2155
  error: config.error,
2168
2156
  machine,
2169
2157
  context: config.context,
2170
- configuration: config.configuration,
2171
- value: getStateValue(machine.root, config.configuration),
2172
- tags: new Set(flatten(config.configuration.map(sn => sn.tags))),
2158
+ _nodes: config._nodes,
2159
+ value: getStateValue(machine.root, config._nodes),
2160
+ tags: new Set(flatten(config._nodes.map(sn => sn.tags))),
2173
2161
  children: config.children,
2174
2162
  historyValue: config.historyValue || {},
2175
2163
  // this one is generic in the target and it's hard to create a matching non-generic source signature
2176
2164
  matches: machineSnapshotMatches,
2177
2165
  hasTag: machineSnapshotHasTag,
2178
2166
  can: machineSnapshotCan,
2167
+ getNextEvents: machineSnapshotGetNextEvents,
2168
+ getMeta: machineSnapshotGetMeta,
2179
2169
  toJSON: machineSnapshotToJSON
2180
2170
  };
2181
- Object.defineProperties(snapshot, {
2182
- nextEvents: {
2183
- get: machineSnapshotNextEvents,
2184
- configurable: true,
2185
- enumerable: true
2186
- },
2187
- meta: {
2188
- get: machineSnapshotMeta,
2189
- configurable: true,
2190
- enumerable: true
2191
- }
2192
- });
2193
- return snapshot;
2194
2171
  }
2195
2172
  function cloneMachineSnapshot(state, config = {}) {
2196
- return createMachineSnapshot(
2197
- // TODO: it's wasteful that this spread triggers getters
2198
- {
2173
+ return createMachineSnapshot({
2199
2174
  ...state,
2200
2175
  ...config
2201
2176
  }, state.machine);
2202
2177
  }
2203
2178
  function getPersistedState(state, options) {
2204
2179
  const {
2205
- configuration,
2180
+ _nodes: nodes,
2206
2181
  tags,
2207
2182
  machine,
2208
2183
  children,
@@ -2210,8 +2185,9 @@ function getPersistedState(state, options) {
2210
2185
  can,
2211
2186
  hasTag,
2212
2187
  matches,
2188
+ getNextEvents,
2189
+ getMeta,
2213
2190
  toJSON,
2214
- nextEvents,
2215
2191
  ...jsonValues
2216
2192
  } = state;
2217
2193
  const childrenJson = {};
@@ -2223,7 +2199,8 @@ function getPersistedState(state, options) {
2223
2199
  childrenJson[id] = {
2224
2200
  state: child.getPersistedState(options),
2225
2201
  src: child.src,
2226
- systemId: child._systemId
2202
+ systemId: child._systemId,
2203
+ syncSnapshot: child._syncSnapshot
2227
2204
  };
2228
2205
  }
2229
2206
  const persisted = {
@@ -2315,4 +2292,4 @@ function raise(eventOrExpr, options) {
2315
2292
  return raise;
2316
2293
  }
2317
2294
 
2318
- 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, memo as c, createInvokeId as d, evaluateGuard as e, formatTransitions as f, getDelayedTransitions as g, formatInitialTransition as h, getCandidates as i, getConfiguration as j, getStateNodes as k, createMachineSnapshot as l, mapValues as m, isInFinalState as n, isErrorActorEvent 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 };
2295
+ export { $$ACTOR_TYPE as $, resolveReferencedActor as A, createActor as B, Actor as C, interpret as D, isMachineSnapshot as E, matchesState as F, pathToStateValue as G, toObserver as H, and as I, not as J, or as K, stateIn as L, cancel as M, NULL_EVENT as N, raise as O, stop as P, spawn as Q, ProcessingStatus as R, STATE_DELIMITER as S, createErrorActorEvent as T, XSTATE_ERROR as U, 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, cloneMachineSnapshot as o, macrostep as p, transitionNode as q, resolveStateValue as r, resolveActionsAndContext as s, toArray as t, createInitEvent as u, microstep as v, getInitialStateNodes as w, isStateId as x, getStateNodeByPath as y, getPersistedState as z };