xstate 5.19.1 → 5.19.3

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 (29) 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.map +1 -1
  6. package/actors/dist/xstate-actors.cjs.js +1 -1
  7. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  8. package/actors/dist/xstate-actors.development.esm.js +1 -1
  9. package/actors/dist/xstate-actors.esm.js +1 -1
  10. package/dist/declarations/src/types.d.ts +7 -4
  11. package/dist/{log-3d9d72a9.esm.js → log-12aa30c9.esm.js} +5 -3
  12. package/dist/{log-a019fbd0.cjs.js → log-179b5431.cjs.js} +5 -3
  13. package/dist/{log-8aa651a0.development.cjs.js → log-210b28c2.development.cjs.js} +5 -3
  14. package/dist/{log-0acd9069.development.esm.js → log-b47a3833.development.esm.js} +5 -3
  15. package/dist/{raise-4acdb210.development.cjs.js → raise-32fab6fb.development.cjs.js} +17 -1
  16. package/dist/{raise-1db27a82.development.esm.js → raise-527db318.development.esm.js} +17 -1
  17. package/dist/{raise-c17ec2bc.esm.js → raise-59f80ebb.esm.js} +17 -1
  18. package/dist/{raise-60cebf03.cjs.js → raise-cbaedcda.cjs.js} +17 -1
  19. package/dist/xstate.cjs.js +35 -3
  20. package/dist/xstate.development.cjs.js +38 -3
  21. package/dist/xstate.development.esm.js +40 -5
  22. package/dist/xstate.esm.js +37 -5
  23. package/dist/xstate.umd.min.js +1 -1
  24. package/dist/xstate.umd.min.js.map +1 -1
  25. package/guards/dist/xstate-guards.cjs.js +1 -1
  26. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  27. package/guards/dist/xstate-guards.development.esm.js +1 -1
  28. package/guards/dist/xstate-guards.esm.js +1 -1
  29. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var guards_dist_xstateGuards = require('../../dist/raise-60cebf03.cjs.js');
5
+ var guards_dist_xstateGuards = require('../../dist/raise-cbaedcda.cjs.js');
6
6
  require('../../dev/dist/xstate-dev.cjs.js');
7
7
 
8
8
  /**
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var guards_dist_xstateGuards = require('../../dist/raise-4acdb210.development.cjs.js');
5
+ var guards_dist_xstateGuards = require('../../dist/raise-32fab6fb.development.cjs.js');
6
6
  require('../../dev/dist/xstate-dev.development.cjs.js');
7
7
 
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { X as XSTATE_STOP, A as createActor } from '../../dist/raise-1db27a82.development.esm.js';
1
+ import { X as XSTATE_STOP, A as createActor } from '../../dist/raise-527db318.development.esm.js';
2
2
  import '../../dev/dist/xstate-dev.development.esm.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { X as XSTATE_STOP, A as createActor } from '../../dist/raise-c17ec2bc.esm.js';
1
+ import { X as XSTATE_STOP, A as createActor } from '../../dist/raise-59f80ebb.esm.js';
2
2
  import '../../dev/dist/xstate-dev.esm.js';
3
3
 
4
4
  /**
@@ -248,8 +248,8 @@ export type InvokeConfig<TContext extends MachineContext, TEvent extends EventOb
248
248
  onDone?: string | SingleOrArray<TransitionConfigOrTarget<TContext, DoneActorEvent<any>, // TODO: consider replacing with `unknown`
249
249
  TEvent, TActor, TAction, TGuard, TDelay, TEmitted, TMeta>>;
250
250
  /**
251
- * The transition to take upon the invoked child machine sending an error
252
- * event.
251
+ * The transition to take upon the invoked child machine sending an
252
+ * error event.
253
253
  */
254
254
  onError?: string | SingleOrArray<TransitionConfigOrTarget<TContext, ErrorActorEvent, TEvent, TActor, TAction, TGuard, TDelay, TEmitted, TMeta>>;
255
255
  onSnapshot?: string | SingleOrArray<TransitionConfigOrTarget<TContext, SnapshotEvent, TEvent, TActor, TAction, TGuard, TDelay, TEmitted, TMeta>>;
@@ -340,7 +340,7 @@ export interface StateNodeConfig<TContext extends MachineContext, TEvent extends
340
340
  /** A text description of the state node */
341
341
  description?: string;
342
342
  /** A default target for a history state */
343
- target?: string;
343
+ target?: string | undefined;
344
344
  }
345
345
  export type AnyStateNodeConfig = StateNodeConfig<any, any, any, any, any, any, any, any, any, // emitted
346
346
  any>;
@@ -462,7 +462,7 @@ export type UnknownMachineConfig = MachineConfig<MachineContext, EventObject>;
462
462
  export interface ProvidedActor {
463
463
  src: string;
464
464
  logic: UnknownActorLogic;
465
- id?: string;
465
+ id?: string | undefined;
466
466
  }
467
467
  export interface SetupTypes<TContext extends MachineContext, TEvent extends EventObject, TChildrenMap extends Record<string, string>, TTag extends string, TInput, TOutput, TEmitted extends EventObject, TMeta extends MetaObject> {
468
468
  context?: TContext;
@@ -486,6 +486,9 @@ export interface HistoryStateNode<TContext extends MachineContext> extends State
486
486
  target: string | undefined;
487
487
  }
488
488
  export type HistoryValue<TContext extends MachineContext, TEvent extends EventObject> = Record<string, Array<StateNode<TContext, TEvent>>>;
489
+ export type PersistedHistoryValue = Record<string, Array<{
490
+ id: string;
491
+ }>>;
489
492
  export type AnyHistoryValue = HistoryValue<any, any>;
490
493
  export type StateFrom<T extends AnyStateMachine | ((...args: any[]) => AnyStateMachine)> = T extends AnyStateMachine ? ReturnType<T['transition']> : T extends (...args: any[]) => AnyStateMachine ? ReturnType<ReturnType<T>['transition']> : never;
491
494
  export type Transitions<TContext extends MachineContext, TEvent extends EventObject> = Array<TransitionDefinition<TContext, TEvent>>;
@@ -1,4 +1,4 @@
1
- import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-c17ec2bc.esm.js';
1
+ import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as XSTATE_ERROR, W as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-59f80ebb.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -203,8 +203,10 @@ eventOrExpr) {
203
203
 
204
204
  // https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
205
205
 
206
- // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
207
- // https://github.com/microsoft/TypeScript/pull/57673
206
+ // @TODO: we can't use native `NoInfer` as we need those:
207
+ // https://github.com/microsoft/TypeScript/pull/61092
208
+ // https://github.com/microsoft/TypeScript/pull/61077
209
+ // but even with those fixes native NoInfer still doesn't work - further issues have to be reproduced and fixed
208
210
 
209
211
  /** @deprecated Use the built-in `NoInfer` type instead */
210
212
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-60cebf03.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-cbaedcda.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -205,8 +205,10 @@ eventOrExpr) {
205
205
 
206
206
  // https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
207
207
 
208
- // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
209
- // https://github.com/microsoft/TypeScript/pull/57673
208
+ // @TODO: we can't use native `NoInfer` as we need those:
209
+ // https://github.com/microsoft/TypeScript/pull/61092
210
+ // https://github.com/microsoft/TypeScript/pull/61077
211
+ // but even with those fixes native NoInfer still doesn't work - further issues have to be reproduced and fixed
210
212
 
211
213
  /** @deprecated Use the built-in `NoInfer` type instead */
212
214
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-4acdb210.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-32fab6fb.development.cjs.js');
4
4
 
5
5
  function createSpawner(actorScope, {
6
6
  machine,
@@ -217,8 +217,10 @@ eventOrExpr) {
217
217
 
218
218
  // https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
219
219
 
220
- // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
221
- // https://github.com/microsoft/TypeScript/pull/57673
220
+ // @TODO: we can't use native `NoInfer` as we need those:
221
+ // https://github.com/microsoft/TypeScript/pull/61092
222
+ // https://github.com/microsoft/TypeScript/pull/61077
223
+ // but even with those fixes native NoInfer still doesn't work - further issues have to be reproduced and fixed
222
224
 
223
225
  /** @deprecated Use the built-in `NoInfer` type instead */
224
226
 
@@ -1,4 +1,4 @@
1
- import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as executingCustomAction, W as XSTATE_ERROR, Y as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-1db27a82.development.esm.js';
1
+ import { T as ProcessingStatus, z as resolveReferencedActor, A as createActor, U as cloneMachineSnapshot, V as executingCustomAction, W as XSTATE_ERROR, Y as createErrorActorEvent, e as evaluateGuard, M as cancel, O as raise, P as spawnChild, R as stopChild } from './raise-527db318.development.esm.js';
2
2
 
3
3
  function createSpawner(actorScope, {
4
4
  machine,
@@ -215,8 +215,10 @@ eventOrExpr) {
215
215
 
216
216
  // https://github.com/microsoft/TypeScript/issues/23182#issuecomment-379091887
217
217
 
218
- // @TODO: Replace with native `NoInfer` when TS issue gets fixed:
219
- // https://github.com/microsoft/TypeScript/pull/57673
218
+ // @TODO: we can't use native `NoInfer` as we need those:
219
+ // https://github.com/microsoft/TypeScript/pull/61092
220
+ // https://github.com/microsoft/TypeScript/pull/61077
221
+ // but even with those fixes native NoInfer still doesn't work - further issues have to be reproduced and fixed
220
222
 
221
223
  /** @deprecated Use the built-in `NoInfer` type instead */
222
224
 
@@ -2560,6 +2560,21 @@ function cloneMachineSnapshot(snapshot, config = {}) {
2560
2560
  ...config
2561
2561
  }, snapshot.machine);
2562
2562
  }
2563
+ function serializeHistoryValue(historyValue) {
2564
+ if (typeof historyValue !== 'object' || historyValue === null) {
2565
+ return {};
2566
+ }
2567
+ const result = {};
2568
+ for (const key in historyValue) {
2569
+ const value = historyValue[key];
2570
+ if (Array.isArray(value)) {
2571
+ result[key] = value.map(item => ({
2572
+ id: item.id
2573
+ }));
2574
+ }
2575
+ }
2576
+ return result;
2577
+ }
2563
2578
  function getPersistedSnapshot(snapshot, options) {
2564
2579
  const {
2565
2580
  _nodes: nodes,
@@ -2590,7 +2605,8 @@ function getPersistedSnapshot(snapshot, options) {
2590
2605
  const persisted = {
2591
2606
  ...jsonValues,
2592
2607
  context: persistContext(context),
2593
- children: childrenJson
2608
+ children: childrenJson,
2609
+ historyValue: serializeHistoryValue(jsonValues.historyValue)
2594
2610
  };
2595
2611
  return persisted;
2596
2612
  }
@@ -2558,6 +2558,21 @@ function cloneMachineSnapshot(snapshot, config = {}) {
2558
2558
  ...config
2559
2559
  }, snapshot.machine);
2560
2560
  }
2561
+ function serializeHistoryValue(historyValue) {
2562
+ if (typeof historyValue !== 'object' || historyValue === null) {
2563
+ return {};
2564
+ }
2565
+ const result = {};
2566
+ for (const key in historyValue) {
2567
+ const value = historyValue[key];
2568
+ if (Array.isArray(value)) {
2569
+ result[key] = value.map(item => ({
2570
+ id: item.id
2571
+ }));
2572
+ }
2573
+ }
2574
+ return result;
2575
+ }
2561
2576
  function getPersistedSnapshot(snapshot, options) {
2562
2577
  const {
2563
2578
  _nodes: nodes,
@@ -2588,7 +2603,8 @@ function getPersistedSnapshot(snapshot, options) {
2588
2603
  const persisted = {
2589
2604
  ...jsonValues,
2590
2605
  context: persistContext(context),
2591
- children: childrenJson
2606
+ children: childrenJson,
2607
+ historyValue: serializeHistoryValue(jsonValues.historyValue)
2592
2608
  };
2593
2609
  return persisted;
2594
2610
  }
@@ -2505,6 +2505,21 @@ function cloneMachineSnapshot(snapshot, config = {}) {
2505
2505
  ...config
2506
2506
  }, snapshot.machine);
2507
2507
  }
2508
+ function serializeHistoryValue(historyValue) {
2509
+ if (typeof historyValue !== 'object' || historyValue === null) {
2510
+ return {};
2511
+ }
2512
+ const result = {};
2513
+ for (const key in historyValue) {
2514
+ const value = historyValue[key];
2515
+ if (Array.isArray(value)) {
2516
+ result[key] = value.map(item => ({
2517
+ id: item.id
2518
+ }));
2519
+ }
2520
+ }
2521
+ return result;
2522
+ }
2508
2523
  function getPersistedSnapshot(snapshot, options) {
2509
2524
  const {
2510
2525
  _nodes: nodes,
@@ -2532,7 +2547,8 @@ function getPersistedSnapshot(snapshot, options) {
2532
2547
  const persisted = {
2533
2548
  ...jsonValues,
2534
2549
  context: persistContext(context),
2535
- children: childrenJson
2550
+ children: childrenJson,
2551
+ historyValue: serializeHistoryValue(jsonValues.historyValue)
2536
2552
  };
2537
2553
  return persisted;
2538
2554
  }
@@ -2507,6 +2507,21 @@ function cloneMachineSnapshot(snapshot, config = {}) {
2507
2507
  ...config
2508
2508
  }, snapshot.machine);
2509
2509
  }
2510
+ function serializeHistoryValue(historyValue) {
2511
+ if (typeof historyValue !== 'object' || historyValue === null) {
2512
+ return {};
2513
+ }
2514
+ const result = {};
2515
+ for (const key in historyValue) {
2516
+ const value = historyValue[key];
2517
+ if (Array.isArray(value)) {
2518
+ result[key] = value.map(item => ({
2519
+ id: item.id
2520
+ }));
2521
+ }
2522
+ }
2523
+ return result;
2524
+ }
2510
2525
  function getPersistedSnapshot(snapshot, options) {
2511
2526
  const {
2512
2527
  _nodes: nodes,
@@ -2534,7 +2549,8 @@ function getPersistedSnapshot(snapshot, options) {
2534
2549
  const persisted = {
2535
2550
  ...jsonValues,
2536
2551
  context: persistContext(context),
2537
- children: childrenJson
2552
+ children: childrenJson,
2553
+ historyValue: serializeHistoryValue(jsonValues.historyValue)
2538
2554
  };
2539
2555
  return persisted;
2540
2556
  }
@@ -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-60cebf03.cjs.js');
7
- var log = require('./log-a019fbd0.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-cbaedcda.cjs.js');
7
+ var log = require('./log-179b5431.cjs.js');
8
8
  require('../dev/dist/xstate-dev.cjs.js');
9
9
 
10
10
  /**
@@ -536,10 +536,42 @@ class StateMachine {
536
536
  });
537
537
  children[actorId] = actorRef;
538
538
  });
539
+ function resolveStateNodeFromIdOrPath(idOrPath, root) {
540
+ try {
541
+ return root.machine.getStateNodeById(idOrPath);
542
+ } catch {
543
+ try {
544
+ return guards_dist_xstateGuards.getStateNodeByPath(root, idOrPath.split('.'));
545
+ } catch {
546
+ return idOrPath;
547
+ }
548
+ }
549
+ }
550
+ function reviveHistoryValue(historyValue, root) {
551
+ if (!historyValue || typeof historyValue !== 'object') return {};
552
+ const revived = {};
553
+ for (const key in historyValue) {
554
+ const arr = historyValue[key];
555
+ revived[key] = arr.map(item => {
556
+ if (item instanceof StateNode) return item;
557
+ if (typeof item === 'object' && 'id' in item && typeof item.id === 'string') {
558
+ const resolved = resolveStateNodeFromIdOrPath(item.id, root);
559
+ if (resolved instanceof StateNode) return resolved;
560
+ }
561
+ return undefined;
562
+ }).filter(item => item !== undefined);
563
+ if (revived[key].length === 0) {
564
+ delete revived[key];
565
+ }
566
+ }
567
+ return revived;
568
+ }
569
+ const revivedHistoryValue = reviveHistoryValue(snapshot.historyValue, this.root);
539
570
  const restoredSnapshot = guards_dist_xstateGuards.createMachineSnapshot({
540
571
  ...snapshot,
541
572
  children,
542
- _nodes: Array.from(guards_dist_xstateGuards.getAllStateNodes(guards_dist_xstateGuards.getStateNodes(this.root, snapshot.value)))
573
+ _nodes: Array.from(guards_dist_xstateGuards.getAllStateNodes(guards_dist_xstateGuards.getStateNodes(this.root, snapshot.value))),
574
+ historyValue: revivedHistoryValue
543
575
  }, this);
544
576
  const seen = new Set();
545
577
  function reviveContext(contextPart, children) {
@@ -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-4acdb210.development.cjs.js');
7
- var log = require('./log-8aa651a0.development.cjs.js');
6
+ var guards_dist_xstateGuards = require('./raise-32fab6fb.development.cjs.js');
7
+ var log = require('./log-210b28c2.development.cjs.js');
8
8
  require('../dev/dist/xstate-dev.development.cjs.js');
9
9
 
10
10
  /**
@@ -539,10 +539,45 @@ class StateMachine {
539
539
  });
540
540
  children[actorId] = actorRef;
541
541
  });
542
+ function resolveStateNodeFromIdOrPath(idOrPath, root) {
543
+ try {
544
+ return root.machine.getStateNodeById(idOrPath);
545
+ } catch {
546
+ try {
547
+ return guards_dist_xstateGuards.getStateNodeByPath(root, idOrPath.split('.'));
548
+ } catch {
549
+ {
550
+ console.warn(`Could not resolve StateNode for id/path: ${idOrPath}`);
551
+ }
552
+ return idOrPath;
553
+ }
554
+ }
555
+ }
556
+ function reviveHistoryValue(historyValue, root) {
557
+ if (!historyValue || typeof historyValue !== 'object') return {};
558
+ const revived = {};
559
+ for (const key in historyValue) {
560
+ const arr = historyValue[key];
561
+ revived[key] = arr.map(item => {
562
+ if (item instanceof StateNode) return item;
563
+ if (typeof item === 'object' && 'id' in item && typeof item.id === 'string') {
564
+ const resolved = resolveStateNodeFromIdOrPath(item.id, root);
565
+ if (resolved instanceof StateNode) return resolved;
566
+ }
567
+ return undefined;
568
+ }).filter(item => item !== undefined);
569
+ if (revived[key].length === 0) {
570
+ delete revived[key];
571
+ }
572
+ }
573
+ return revived;
574
+ }
575
+ const revivedHistoryValue = reviveHistoryValue(snapshot.historyValue, this.root);
542
576
  const restoredSnapshot = guards_dist_xstateGuards.createMachineSnapshot({
543
577
  ...snapshot,
544
578
  children,
545
- _nodes: Array.from(guards_dist_xstateGuards.getAllStateNodes(guards_dist_xstateGuards.getStateNodes(this.root, snapshot.value)))
579
+ _nodes: Array.from(guards_dist_xstateGuards.getAllStateNodes(guards_dist_xstateGuards.getStateNodes(this.root, snapshot.value))),
580
+ historyValue: revivedHistoryValue
546
581
  }, this);
547
582
  const seen = new Set();
548
583
  function reviveContext(contextPart, children) {
@@ -1,8 +1,8 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
2
- import { t as toArray, S as STATE_DELIMITER, m as mapValues, 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 toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-1db27a82.development.esm.js';
3
- export { B as Actor, I as __unsafe_getAllOwnEventDescriptors, D as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, H as isMachineSnapshot, J as matchesState, E as not, F as or, K as pathToStateValue, O as raise, P as spawnChild, G as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-1db27a82.development.esm.js';
4
- import { a as assign } from './log-0acd9069.development.esm.js';
5
- export { S as SpecialTargets, a as assign, e as emit, b as enqueueActions, f as forwardTo, l as log, s as sendParent, c as sendTo } from './log-0acd9069.development.esm.js';
2
+ import { t as toArray, S as STATE_DELIMITER, m as mapValues, 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 toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-527db318.development.esm.js';
3
+ export { B as Actor, I as __unsafe_getAllOwnEventDescriptors, D as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, H as isMachineSnapshot, J as matchesState, E as not, F as or, K as pathToStateValue, O as raise, P as spawnChild, G as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-527db318.development.esm.js';
4
+ import { a as assign } from './log-b47a3833.development.esm.js';
5
+ export { S as SpecialTargets, a as assign, e as emit, b as enqueueActions, f as forwardTo, l as log, s as sendParent, c as sendTo } from './log-b47a3833.development.esm.js';
6
6
  import '../dev/dist/xstate-dev.development.esm.js';
7
7
 
8
8
  /**
@@ -537,10 +537,45 @@ class StateMachine {
537
537
  });
538
538
  children[actorId] = actorRef;
539
539
  });
540
+ function resolveStateNodeFromIdOrPath(idOrPath, root) {
541
+ try {
542
+ return root.machine.getStateNodeById(idOrPath);
543
+ } catch {
544
+ try {
545
+ return getStateNodeByPath(root, idOrPath.split('.'));
546
+ } catch {
547
+ {
548
+ console.warn(`Could not resolve StateNode for id/path: ${idOrPath}`);
549
+ }
550
+ return idOrPath;
551
+ }
552
+ }
553
+ }
554
+ function reviveHistoryValue(historyValue, root) {
555
+ if (!historyValue || typeof historyValue !== 'object') return {};
556
+ const revived = {};
557
+ for (const key in historyValue) {
558
+ const arr = historyValue[key];
559
+ revived[key] = arr.map(item => {
560
+ if (item instanceof StateNode) return item;
561
+ if (typeof item === 'object' && 'id' in item && typeof item.id === 'string') {
562
+ const resolved = resolveStateNodeFromIdOrPath(item.id, root);
563
+ if (resolved instanceof StateNode) return resolved;
564
+ }
565
+ return undefined;
566
+ }).filter(item => item !== undefined);
567
+ if (revived[key].length === 0) {
568
+ delete revived[key];
569
+ }
570
+ }
571
+ return revived;
572
+ }
573
+ const revivedHistoryValue = reviveHistoryValue(snapshot.historyValue, this.root);
540
574
  const restoredSnapshot = createMachineSnapshot({
541
575
  ...snapshot,
542
576
  children,
543
- _nodes: Array.from(getAllStateNodes(getStateNodes(this.root, snapshot.value)))
577
+ _nodes: Array.from(getAllStateNodes(getStateNodes(this.root, snapshot.value))),
578
+ historyValue: revivedHistoryValue
544
579
  }, this);
545
580
  const seen = new Set();
546
581
  function reviveContext(contextPart, children) {
@@ -1,8 +1,8 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
2
- import { t as toArray, S as STATE_DELIMITER, m as mapValues, 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 toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-c17ec2bc.esm.js';
3
- export { B as Actor, I as __unsafe_getAllOwnEventDescriptors, D as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, H as isMachineSnapshot, J as matchesState, E as not, F as or, K as pathToStateValue, O as raise, P as spawnChild, G as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-c17ec2bc.esm.js';
4
- import { a as assign } from './log-3d9d72a9.esm.js';
5
- export { S as SpecialTargets, a as assign, e as emit, b as enqueueActions, f as forwardTo, l as log, s as sendParent, c as sendTo } from './log-3d9d72a9.esm.js';
2
+ import { t as toArray, S as STATE_DELIMITER, m as mapValues, 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 toStatePath, w as isStateId, x as getStateNodeByPath, y as getPersistedSnapshot, z as resolveReferencedActor, A as createActor, $ as $$ACTOR_TYPE } from './raise-59f80ebb.esm.js';
3
+ export { B as Actor, I as __unsafe_getAllOwnEventDescriptors, D as and, M as cancel, A as createActor, j as getStateNodes, C as interpret, H as isMachineSnapshot, J as matchesState, E as not, F as or, K as pathToStateValue, O as raise, P as spawnChild, G as stateIn, Q as stop, R as stopChild, L as toObserver } from './raise-59f80ebb.esm.js';
4
+ import { a as assign } from './log-12aa30c9.esm.js';
5
+ export { S as SpecialTargets, a as assign, e as emit, b as enqueueActions, f as forwardTo, l as log, s as sendParent, c as sendTo } from './log-12aa30c9.esm.js';
6
6
  import '../dev/dist/xstate-dev.esm.js';
7
7
 
8
8
  /**
@@ -534,10 +534,42 @@ class StateMachine {
534
534
  });
535
535
  children[actorId] = actorRef;
536
536
  });
537
+ function resolveStateNodeFromIdOrPath(idOrPath, root) {
538
+ try {
539
+ return root.machine.getStateNodeById(idOrPath);
540
+ } catch {
541
+ try {
542
+ return getStateNodeByPath(root, idOrPath.split('.'));
543
+ } catch {
544
+ return idOrPath;
545
+ }
546
+ }
547
+ }
548
+ function reviveHistoryValue(historyValue, root) {
549
+ if (!historyValue || typeof historyValue !== 'object') return {};
550
+ const revived = {};
551
+ for (const key in historyValue) {
552
+ const arr = historyValue[key];
553
+ revived[key] = arr.map(item => {
554
+ if (item instanceof StateNode) return item;
555
+ if (typeof item === 'object' && 'id' in item && typeof item.id === 'string') {
556
+ const resolved = resolveStateNodeFromIdOrPath(item.id, root);
557
+ if (resolved instanceof StateNode) return resolved;
558
+ }
559
+ return undefined;
560
+ }).filter(item => item !== undefined);
561
+ if (revived[key].length === 0) {
562
+ delete revived[key];
563
+ }
564
+ }
565
+ return revived;
566
+ }
567
+ const revivedHistoryValue = reviveHistoryValue(snapshot.historyValue, this.root);
537
568
  const restoredSnapshot = createMachineSnapshot({
538
569
  ...snapshot,
539
570
  children,
540
- _nodes: Array.from(getAllStateNodes(getStateNodes(this.root, snapshot.value)))
571
+ _nodes: Array.from(getAllStateNodes(getStateNodes(this.root, snapshot.value))),
572
+ historyValue: revivedHistoryValue
541
573
  }, this);
542
574
  const seen = new Set();
543
575
  function reviveContext(contextPart, children) {