xstate 6.0.0-alpha.24 → 6.0.0-alpha.26

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 (39) hide show
  1. package/dist/{StateMachine-0d7aa36b.cjs.js → StateMachine-1a51a14a.cjs.js} +37 -26
  2. package/dist/{StateMachine-f3d5f2d8.development.esm.js → StateMachine-70bbb88f.development.esm.js} +40 -29
  3. package/dist/{StateMachine-27ce068a.development.cjs.js → StateMachine-89f725ff.development.cjs.js} +40 -29
  4. package/dist/{StateMachine-4f3ebd99.esm.js → StateMachine-bfbf8d6e.esm.js} +37 -26
  5. package/dist/declarations/src/StateMachine.d.ts +11 -11
  6. package/dist/declarations/src/StateNode.d.ts +2 -0
  7. package/dist/declarations/src/createMachine.d.ts +6 -6
  8. package/dist/declarations/src/createMachineFromConfig.d.ts +5 -5
  9. package/dist/declarations/src/fsm.d.ts +2 -2
  10. package/dist/declarations/src/index.d.ts +1 -1
  11. package/dist/declarations/src/schema.types.d.ts +5 -0
  12. package/dist/declarations/src/serialize.d.ts +3 -3
  13. package/dist/declarations/src/setup.d.ts +51 -50
  14. package/dist/declarations/src/spawn.d.ts +1 -1
  15. package/dist/declarations/src/types.d.ts +39 -39
  16. package/dist/declarations/src/types.v6.d.ts +28 -26
  17. package/dist/{index-cf2e8954.esm.js → index-036a773f.esm.js} +85 -39
  18. package/dist/{index-46c96e83.development.cjs.js → index-1ad8a761.development.cjs.js} +85 -38
  19. package/dist/{index-1a180503.development.esm.js → index-b90ebcd4.development.esm.js} +85 -39
  20. package/dist/{index-0ef8d20d.cjs.js → index-f58cc498.cjs.js} +85 -38
  21. package/dist/xstate-actors.cjs.js +1 -1
  22. package/dist/xstate-actors.development.cjs.js +1 -1
  23. package/dist/xstate-actors.development.esm.js +1 -1
  24. package/dist/xstate-actors.esm.js +1 -1
  25. package/dist/xstate-actors.umd.min.js +1 -1
  26. package/dist/xstate-actors.umd.min.js.map +1 -1
  27. package/dist/xstate-graph.cjs.js +2 -2
  28. package/dist/xstate-graph.development.cjs.js +2 -2
  29. package/dist/xstate-graph.development.esm.js +2 -2
  30. package/dist/xstate-graph.esm.js +2 -2
  31. package/dist/xstate-graph.umd.min.js +1 -1
  32. package/dist/xstate-graph.umd.min.js.map +1 -1
  33. package/dist/xstate.cjs.js +85 -52
  34. package/dist/xstate.development.cjs.js +85 -52
  35. package/dist/xstate.development.esm.js +87 -54
  36. package/dist/xstate.esm.js +87 -54
  37. package/dist/xstate.umd.min.js +1 -1
  38. package/dist/xstate.umd.min.js.map +1 -1
  39. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var dist_xstateActors = require('./index-0ef8d20d.cjs.js');
3
+ var dist_xstateActors = require('./index-f58cc498.cjs.js');
4
4
 
5
- function createSpawner(actorScope, actorSources, spawnedChildren) {
5
+ function createSpawner(actorScope, actors, spawnedChildren) {
6
6
  return (src, options) => {
7
- const referencedSrc = Object.entries(actorSources).find(([, logic]) => logic === src)?.[0];
7
+ const referencedSrc = Object.entries(actors).find(([, logic]) => logic === src)?.[0];
8
8
  const actor = actorScope.system.createActorRef(src, {
9
9
  id: options?.id,
10
10
  parent: actorScope.self,
@@ -47,7 +47,8 @@ function createInertActorScope(actorLogic, snapshot, sourceSelf) {
47
47
  const self = dist_xstateActors.createActor(actorLogic, {
48
48
  _inert: true,
49
49
  ...(previousSelf ? {
50
- id: previousSelf.id
50
+ id: previousSelf.id,
51
+ _sessionId: previousSelf.sessionId
51
52
  } : {}),
52
53
  ...(system ? {
53
54
  _systemRef: {
@@ -194,6 +195,7 @@ class StateNode {
194
195
  */
195
196
  this.order = -1;
196
197
  this.description = void 0;
198
+ this.schemas = void 0;
197
199
  this.tags = [];
198
200
  this.transitions = void 0;
199
201
  this.always = void 0;
@@ -210,6 +212,7 @@ class StateNode {
210
212
  this.id = this.config.id || [this.machine.id, ...this.path].join(dist_xstateActors.STATE_DELIMITER);
211
213
  this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
212
214
  this.description = this.config.description;
215
+ this.schemas = this.config.schemas;
213
216
  validateStateNodeConfig(this);
214
217
  this.order = this.machine.idMap.size;
215
218
  this.machine.idMap.set(this.id, this);
@@ -525,12 +528,12 @@ function getEmptyCanActorScope() {
525
528
  }
526
529
  class StateMachine {
527
530
  constructor(/** The raw config used to create the machine. */
528
- config, implementations) {
531
+ config, sources) {
529
532
  this.config = config;
530
533
  /** The machine's own version. */
531
534
  this.version = void 0;
532
535
  this.schemas = void 0;
533
- this.implementations = void 0;
536
+ this.sources = void 0;
534
537
  /** Runtime options for machine execution. */
535
538
  this.options = void 0;
536
539
  /** @internal */
@@ -549,12 +552,12 @@ class StateMachine {
549
552
  */
550
553
  this._json = void 0;
551
554
  this.id = config.id || '(machine)';
552
- this.implementations = {
553
- actorSources: config.actorSources ?? {},
555
+ this.sources = {
556
+ actors: config.actors ?? {},
554
557
  actions: config.actions ?? {},
555
558
  delays: config.delays ?? {},
556
559
  guards: config.guards ?? {},
557
- ...implementations
560
+ ...sources
558
561
  };
559
562
  this.version = this.config.version;
560
563
  this.schemas = this.config.schemas;
@@ -581,38 +584,38 @@ class StateMachine {
581
584
  }
582
585
 
583
586
  /**
584
- * Clones this state machine with the provided implementations.
587
+ * Clones this state machine with the provided sources.
585
588
  *
586
- * @param implementations Options (`actions`, `guards`, `actorSources`,
587
- * `delays`) to recursively merge with the existing options.
588
- * @returns A new `StateMachine` instance with the provided implementations.
589
+ * @param sources Options (`actions`, `guards`, `actors`, `delays`) to
590
+ * recursively merge with the existing options.
591
+ * @returns A new `StateMachine` instance with the provided sources.
589
592
  */
590
- provide(implementations) {
593
+ provide(sources) {
591
594
  const {
592
595
  actions,
593
596
  guards,
594
- actorSources,
597
+ actors,
595
598
  delays
596
- } = this.implementations;
599
+ } = this.sources;
597
600
  const provided = new StateMachine(this.config, {
598
601
  actions: {
599
602
  ...actions,
600
- ...implementations.actions
603
+ ...sources.actions
601
604
  },
602
605
  guards: {
603
606
  ...guards,
604
- ...implementations.guards
607
+ ...sources.guards
605
608
  },
606
- actorSources: {
607
- ...actorSources,
608
- ...implementations.actorSources
609
+ actors: {
610
+ ...actors,
611
+ ...sources.actors
609
612
  },
610
613
  delays: {
611
614
  ...delays,
612
- ...implementations.delays
615
+ ...sources.delays
613
616
  }
614
617
  });
615
- // Providing implementations does not change the serializable definition.
618
+ // Providing sources does not change the serializable definition.
616
619
  provided._json = this._json;
617
620
  return provided;
618
621
  }
@@ -803,12 +806,12 @@ class StateMachine {
803
806
  }, this, actorScope.self);
804
807
  if (typeof context === 'function') {
805
808
  const children = {};
806
- const spawn = createSpawner(actorScope, this.implementations.actorSources, children);
809
+ const spawn = createSpawner(actorScope, this.sources.actors, children);
807
810
  const resolvedContext = context({
808
811
  spawn,
809
812
  input: initEvent.input,
810
813
  self: actorScope.self,
811
- actorSources: this.implementations.actorSources
814
+ actors: this.sources.actors
812
815
  });
813
816
  const [nextState] = dist_xstateActors.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
814
817
  if (resolvedContext) {
@@ -920,7 +923,6 @@ class StateMachine {
920
923
  syncSnapshot: actorData.syncSnapshot,
921
924
  snapshot: childState,
922
925
  src,
923
- _sessionId: actorData.sessionId,
924
926
  registryKey: actorData.registryKey
925
927
  });
926
928
  // Mark so `start()` knows to start this child (freshly invoked/spawned
@@ -931,6 +933,14 @@ class StateMachine {
931
933
  const timers = {};
932
934
  const persistedTimers = snapshotData.timers ?? {};
933
935
  for (const [id, timer] of Object.entries(persistedTimers)) {
936
+ let event = timer.event;
937
+ if (event.type === 'xstate.timeout.actor') {
938
+ const actorId = event.actorId;
939
+ const child = children[actorId];
940
+ if (child) {
941
+ event = dist_xstateActors.createInvokeTimeoutEvent(actorId, child.sessionId);
942
+ }
943
+ }
934
944
  const target = typeof timer.target === 'string' ? timer.target === 'self' ? 'self' : children[timer.target] : resolvedActorScope.self._parent;
935
945
  if (!target) {
936
946
  const targetDescription = typeof timer.target === 'string' ? timer.target : timer.target.type;
@@ -938,6 +948,7 @@ class StateMachine {
938
948
  }
939
949
  timers[id] = {
940
950
  ...timer,
951
+ event,
941
952
  target
942
953
  };
943
954
  }
@@ -1,8 +1,8 @@
1
- import { M as setSnapshotActorRef, N as getSnapshotActorRef, O as createSnapshotSystem, q as isMachineSnapshot, h as createActor, S as STATE_DELIMITER, P as mapValues, t as toArray, Q as createInvokeId, R as getDelayedTransitions, U as getEventDescriptorKey, V as evaluateCandidate, W as formatTransition, Y as NULL_EVENT, Z as toTransitionConfigArray, _ as createInvokeTimeoutEventId, $ as getCandidates, a0 as matchesActorSession, a1 as formatRouteTransitions, a2 as resolveStateValue, a3 as getAllStateNodes, s as getStateNodes, a4 as createMachineSnapshot, a5 as isInFinalState, j as macrostep, a6 as cloneMachineSnapshot, a7 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a8 as getTransitionResult, a9 as hasEffect, aa as createErrorPlatformEvent, r as resolveActionsWithContext, k as createInitEvent, l as createSpawnEffect, n as initialMicrostep, ab as toStatePath, ac as isStateId, ad as getStateNodeByPath, ae as getPersistedSnapshot, af as resolveReferencedActor, ag as $$ACTOR_TYPE } from './index-1a180503.development.esm.js';
1
+ import { M as setSnapshotActorRef, N as getSnapshotActorRef, O as createSnapshotSystem, q as isMachineSnapshot, h as createActor, S as STATE_DELIMITER, P as mapValues, t as toArray, Q as createInvokeId, R as getDelayedTransitions, U as getEventDescriptorKey, V as evaluateCandidate, W as formatTransition, Y as NULL_EVENT, Z as toTransitionConfigArray, _ as createInvokeTimeoutEventId, $ as getCandidates, a0 as matchesActorSession, a1 as formatRouteTransitions, a2 as resolveStateValue, a3 as getAllStateNodes, s as getStateNodes, a4 as createMachineSnapshot, a5 as isInFinalState, j as macrostep, a6 as cloneMachineSnapshot, a7 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a8 as getTransitionResult, a9 as hasEffect, aa as createErrorPlatformEvent, r as resolveActionsWithContext, k as createInitEvent, l as createSpawnEffect, n as initialMicrostep, ab as toStatePath, ac as isStateId, ad as getStateNodeByPath, ae as getPersistedSnapshot, af as resolveReferencedActor, ag as createInvokeTimeoutEvent, ah as $$ACTOR_TYPE } from './index-b90ebcd4.development.esm.js';
2
2
 
3
- function createSpawner(actorScope, actorSources, spawnedChildren) {
3
+ function createSpawner(actorScope, actors, spawnedChildren) {
4
4
  return (src, options) => {
5
- const referencedSrc = Object.entries(actorSources).find(([, logic]) => logic === src)?.[0];
5
+ const referencedSrc = Object.entries(actors).find(([, logic]) => logic === src)?.[0];
6
6
  const actor = actorScope.system.createActorRef(src, {
7
7
  id: options?.id,
8
8
  parent: actorScope.self,
@@ -45,7 +45,8 @@ function createInertActorScope(actorLogic, snapshot, sourceSelf) {
45
45
  const self = createActor(actorLogic, {
46
46
  _inert: true,
47
47
  ...(previousSelf ? {
48
- id: previousSelf.id
48
+ id: previousSelf.id,
49
+ _sessionId: previousSelf.sessionId
49
50
  } : {}),
50
51
  ...(system ? {
51
52
  _systemRef: {
@@ -193,6 +194,7 @@ class StateNode {
193
194
  */
194
195
  this.order = -1;
195
196
  this.description = void 0;
197
+ this.schemas = void 0;
196
198
  this.tags = [];
197
199
  this.transitions = void 0;
198
200
  this.always = void 0;
@@ -209,6 +211,7 @@ class StateNode {
209
211
  this.id = this.config.id || [this.machine.id, ...this.path].join(STATE_DELIMITER);
210
212
  this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
211
213
  this.description = this.config.description;
214
+ this.schemas = this.config.schemas;
212
215
  validateStateNodeConfig(this);
213
216
  this.order = this.machine.idMap.size;
214
217
  this.machine.idMap.set(this.id, this);
@@ -541,12 +544,12 @@ function getEmptyCanActorScope() {
541
544
  }
542
545
  class StateMachine {
543
546
  constructor(/** The raw config used to create the machine. */
544
- config, implementations) {
547
+ config, sources) {
545
548
  this.config = config;
546
549
  /** The machine's own version. */
547
550
  this.version = void 0;
548
551
  this.schemas = void 0;
549
- this.implementations = void 0;
552
+ this.sources = void 0;
550
553
  /** Runtime options for machine execution. */
551
554
  this.options = void 0;
552
555
  /** @internal */
@@ -565,18 +568,18 @@ class StateMachine {
565
568
  */
566
569
  this._json = void 0;
567
570
  this.id = config.id || '(machine)';
568
- this.implementations = {
569
- actorSources: config.actorSources ?? {},
571
+ this.sources = {
572
+ actors: config.actors ?? {},
570
573
  actions: config.actions ?? {},
571
574
  delays: config.delays ?? {},
572
575
  guards: config.guards ?? {},
573
- ...implementations
576
+ ...sources
574
577
  };
575
578
  {
576
579
  // The `@xstate.` prefix is reserved for built-in serialized action and
577
- // guard descriptors — user implementation names must not collide.
578
- for (const kind of ['actions', 'guards', 'actorSources', 'delays']) {
579
- for (const key of Object.keys(this.implementations[kind])) {
580
+ // guard descriptors — user source names must not collide.
581
+ for (const kind of ['actions', 'guards', 'actors', 'delays']) {
582
+ for (const key of Object.keys(this.sources[kind])) {
580
583
  if (key.startsWith('@xstate.')) {
581
584
  throw new Error(`Invalid ${kind} name '${key}': the '@xstate.' prefix is reserved for built-in descriptors.`);
582
585
  }
@@ -608,38 +611,38 @@ class StateMachine {
608
611
  }
609
612
 
610
613
  /**
611
- * Clones this state machine with the provided implementations.
614
+ * Clones this state machine with the provided sources.
612
615
  *
613
- * @param implementations Options (`actions`, `guards`, `actorSources`,
614
- * `delays`) to recursively merge with the existing options.
615
- * @returns A new `StateMachine` instance with the provided implementations.
616
+ * @param sources Options (`actions`, `guards`, `actors`, `delays`) to
617
+ * recursively merge with the existing options.
618
+ * @returns A new `StateMachine` instance with the provided sources.
616
619
  */
617
- provide(implementations) {
620
+ provide(sources) {
618
621
  const {
619
622
  actions,
620
623
  guards,
621
- actorSources,
624
+ actors,
622
625
  delays
623
- } = this.implementations;
626
+ } = this.sources;
624
627
  const provided = new StateMachine(this.config, {
625
628
  actions: {
626
629
  ...actions,
627
- ...implementations.actions
630
+ ...sources.actions
628
631
  },
629
632
  guards: {
630
633
  ...guards,
631
- ...implementations.guards
634
+ ...sources.guards
632
635
  },
633
- actorSources: {
634
- ...actorSources,
635
- ...implementations.actorSources
636
+ actors: {
637
+ ...actors,
638
+ ...sources.actors
636
639
  },
637
640
  delays: {
638
641
  ...delays,
639
- ...implementations.delays
642
+ ...sources.delays
640
643
  }
641
644
  });
642
- // Providing implementations does not change the serializable definition.
645
+ // Providing sources does not change the serializable definition.
643
646
  provided._json = this._json;
644
647
  return provided;
645
648
  }
@@ -830,12 +833,12 @@ class StateMachine {
830
833
  }, this, actorScope.self);
831
834
  if (typeof context === 'function') {
832
835
  const children = {};
833
- const spawn = createSpawner(actorScope, this.implementations.actorSources, children);
836
+ const spawn = createSpawner(actorScope, this.sources.actors, children);
834
837
  const resolvedContext = context({
835
838
  spawn,
836
839
  input: initEvent.input,
837
840
  self: actorScope.self,
838
- actorSources: this.implementations.actorSources
841
+ actors: this.sources.actors
839
842
  });
840
843
  const [nextState] = resolveActionsWithContext(preInitial, initEvent, actorScope, []);
841
844
  if (resolvedContext) {
@@ -947,7 +950,6 @@ class StateMachine {
947
950
  syncSnapshot: actorData.syncSnapshot,
948
951
  snapshot: childState,
949
952
  src,
950
- _sessionId: actorData.sessionId,
951
953
  registryKey: actorData.registryKey
952
954
  });
953
955
  // Mark so `start()` knows to start this child (freshly invoked/spawned
@@ -958,6 +960,14 @@ class StateMachine {
958
960
  const timers = {};
959
961
  const persistedTimers = snapshotData.timers ?? {};
960
962
  for (const [id, timer] of Object.entries(persistedTimers)) {
963
+ let event = timer.event;
964
+ if (event.type === 'xstate.timeout.actor') {
965
+ const actorId = event.actorId;
966
+ const child = children[actorId];
967
+ if (child) {
968
+ event = createInvokeTimeoutEvent(actorId, child.sessionId);
969
+ }
970
+ }
961
971
  const target = typeof timer.target === 'string' ? timer.target === 'self' ? 'self' : children[timer.target] : resolvedActorScope.self._parent;
962
972
  if (!target) {
963
973
  const targetDescription = typeof timer.target === 'string' ? timer.target : timer.target.type;
@@ -965,6 +975,7 @@ class StateMachine {
965
975
  }
966
976
  timers[id] = {
967
977
  ...timer,
978
+ event,
968
979
  target
969
980
  };
970
981
  }
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var dist_xstateActors = require('./index-46c96e83.development.cjs.js');
3
+ var dist_xstateActors = require('./index-1ad8a761.development.cjs.js');
4
4
 
5
- function createSpawner(actorScope, actorSources, spawnedChildren) {
5
+ function createSpawner(actorScope, actors, spawnedChildren) {
6
6
  return (src, options) => {
7
- const referencedSrc = Object.entries(actorSources).find(([, logic]) => logic === src)?.[0];
7
+ const referencedSrc = Object.entries(actors).find(([, logic]) => logic === src)?.[0];
8
8
  const actor = actorScope.system.createActorRef(src, {
9
9
  id: options?.id,
10
10
  parent: actorScope.self,
@@ -47,7 +47,8 @@ function createInertActorScope(actorLogic, snapshot, sourceSelf) {
47
47
  const self = dist_xstateActors.createActor(actorLogic, {
48
48
  _inert: true,
49
49
  ...(previousSelf ? {
50
- id: previousSelf.id
50
+ id: previousSelf.id,
51
+ _sessionId: previousSelf.sessionId
51
52
  } : {}),
52
53
  ...(system ? {
53
54
  _systemRef: {
@@ -195,6 +196,7 @@ class StateNode {
195
196
  */
196
197
  this.order = -1;
197
198
  this.description = void 0;
199
+ this.schemas = void 0;
198
200
  this.tags = [];
199
201
  this.transitions = void 0;
200
202
  this.always = void 0;
@@ -211,6 +213,7 @@ class StateNode {
211
213
  this.id = this.config.id || [this.machine.id, ...this.path].join(dist_xstateActors.STATE_DELIMITER);
212
214
  this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
213
215
  this.description = this.config.description;
216
+ this.schemas = this.config.schemas;
214
217
  validateStateNodeConfig(this);
215
218
  this.order = this.machine.idMap.size;
216
219
  this.machine.idMap.set(this.id, this);
@@ -543,12 +546,12 @@ function getEmptyCanActorScope() {
543
546
  }
544
547
  class StateMachine {
545
548
  constructor(/** The raw config used to create the machine. */
546
- config, implementations) {
549
+ config, sources) {
547
550
  this.config = config;
548
551
  /** The machine's own version. */
549
552
  this.version = void 0;
550
553
  this.schemas = void 0;
551
- this.implementations = void 0;
554
+ this.sources = void 0;
552
555
  /** Runtime options for machine execution. */
553
556
  this.options = void 0;
554
557
  /** @internal */
@@ -567,18 +570,18 @@ class StateMachine {
567
570
  */
568
571
  this._json = void 0;
569
572
  this.id = config.id || '(machine)';
570
- this.implementations = {
571
- actorSources: config.actorSources ?? {},
573
+ this.sources = {
574
+ actors: config.actors ?? {},
572
575
  actions: config.actions ?? {},
573
576
  delays: config.delays ?? {},
574
577
  guards: config.guards ?? {},
575
- ...implementations
578
+ ...sources
576
579
  };
577
580
  {
578
581
  // The `@xstate.` prefix is reserved for built-in serialized action and
579
- // guard descriptors — user implementation names must not collide.
580
- for (const kind of ['actions', 'guards', 'actorSources', 'delays']) {
581
- for (const key of Object.keys(this.implementations[kind])) {
582
+ // guard descriptors — user source names must not collide.
583
+ for (const kind of ['actions', 'guards', 'actors', 'delays']) {
584
+ for (const key of Object.keys(this.sources[kind])) {
582
585
  if (key.startsWith('@xstate.')) {
583
586
  throw new Error(`Invalid ${kind} name '${key}': the '@xstate.' prefix is reserved for built-in descriptors.`);
584
587
  }
@@ -610,38 +613,38 @@ class StateMachine {
610
613
  }
611
614
 
612
615
  /**
613
- * Clones this state machine with the provided implementations.
616
+ * Clones this state machine with the provided sources.
614
617
  *
615
- * @param implementations Options (`actions`, `guards`, `actorSources`,
616
- * `delays`) to recursively merge with the existing options.
617
- * @returns A new `StateMachine` instance with the provided implementations.
618
+ * @param sources Options (`actions`, `guards`, `actors`, `delays`) to
619
+ * recursively merge with the existing options.
620
+ * @returns A new `StateMachine` instance with the provided sources.
618
621
  */
619
- provide(implementations) {
622
+ provide(sources) {
620
623
  const {
621
624
  actions,
622
625
  guards,
623
- actorSources,
626
+ actors,
624
627
  delays
625
- } = this.implementations;
628
+ } = this.sources;
626
629
  const provided = new StateMachine(this.config, {
627
630
  actions: {
628
631
  ...actions,
629
- ...implementations.actions
632
+ ...sources.actions
630
633
  },
631
634
  guards: {
632
635
  ...guards,
633
- ...implementations.guards
636
+ ...sources.guards
634
637
  },
635
- actorSources: {
636
- ...actorSources,
637
- ...implementations.actorSources
638
+ actors: {
639
+ ...actors,
640
+ ...sources.actors
638
641
  },
639
642
  delays: {
640
643
  ...delays,
641
- ...implementations.delays
644
+ ...sources.delays
642
645
  }
643
646
  });
644
- // Providing implementations does not change the serializable definition.
647
+ // Providing sources does not change the serializable definition.
645
648
  provided._json = this._json;
646
649
  return provided;
647
650
  }
@@ -832,12 +835,12 @@ class StateMachine {
832
835
  }, this, actorScope.self);
833
836
  if (typeof context === 'function') {
834
837
  const children = {};
835
- const spawn = createSpawner(actorScope, this.implementations.actorSources, children);
838
+ const spawn = createSpawner(actorScope, this.sources.actors, children);
836
839
  const resolvedContext = context({
837
840
  spawn,
838
841
  input: initEvent.input,
839
842
  self: actorScope.self,
840
- actorSources: this.implementations.actorSources
843
+ actors: this.sources.actors
841
844
  });
842
845
  const [nextState] = dist_xstateActors.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
843
846
  if (resolvedContext) {
@@ -949,7 +952,6 @@ class StateMachine {
949
952
  syncSnapshot: actorData.syncSnapshot,
950
953
  snapshot: childState,
951
954
  src,
952
- _sessionId: actorData.sessionId,
953
955
  registryKey: actorData.registryKey
954
956
  });
955
957
  // Mark so `start()` knows to start this child (freshly invoked/spawned
@@ -960,6 +962,14 @@ class StateMachine {
960
962
  const timers = {};
961
963
  const persistedTimers = snapshotData.timers ?? {};
962
964
  for (const [id, timer] of Object.entries(persistedTimers)) {
965
+ let event = timer.event;
966
+ if (event.type === 'xstate.timeout.actor') {
967
+ const actorId = event.actorId;
968
+ const child = children[actorId];
969
+ if (child) {
970
+ event = dist_xstateActors.createInvokeTimeoutEvent(actorId, child.sessionId);
971
+ }
972
+ }
963
973
  const target = typeof timer.target === 'string' ? timer.target === 'self' ? 'self' : children[timer.target] : resolvedActorScope.self._parent;
964
974
  if (!target) {
965
975
  const targetDescription = typeof timer.target === 'string' ? timer.target : timer.target.type;
@@ -967,6 +977,7 @@ class StateMachine {
967
977
  }
968
978
  timers[id] = {
969
979
  ...timer,
980
+ event,
970
981
  target
971
982
  };
972
983
  }