xstate 5.0.0-beta.37 → 5.0.0-beta.39

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 (62) hide show
  1. package/actions/dist/xstate-actions.cjs.js +4 -3
  2. package/actions/dist/xstate-actions.cjs.mjs +1 -0
  3. package/actions/dist/xstate-actions.development.cjs.js +4 -3
  4. package/actions/dist/xstate-actions.development.cjs.mjs +1 -0
  5. package/actions/dist/xstate-actions.development.esm.js +3 -3
  6. package/actions/dist/xstate-actions.esm.js +3 -3
  7. package/actions/dist/xstate-actions.umd.min.js +1 -1
  8. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  9. package/actors/dist/xstate-actors.cjs.js +60 -3
  10. package/actors/dist/xstate-actors.development.cjs.js +60 -3
  11. package/actors/dist/xstate-actors.development.esm.js +60 -3
  12. package/actors/dist/xstate-actors.esm.js +60 -3
  13. package/actors/dist/xstate-actors.umd.min.js +1 -1
  14. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  15. package/dist/declarations/src/State.d.ts +2 -2
  16. package/dist/declarations/src/StateMachine.d.ts +7 -7
  17. package/dist/declarations/src/actions/assign.d.ts +4 -4
  18. package/dist/declarations/src/actions/cancel.d.ts +4 -4
  19. package/dist/declarations/src/actions/choose.d.ts +3 -3
  20. package/dist/declarations/src/actions/log.d.ts +4 -4
  21. package/dist/declarations/src/actions/pure.d.ts +4 -4
  22. package/dist/declarations/src/actions/raise.d.ts +3 -3
  23. package/dist/declarations/src/actions/send.d.ts +7 -7
  24. package/dist/declarations/src/actions/spawn.d.ts +34 -0
  25. package/dist/declarations/src/actions/stop.d.ts +4 -4
  26. package/dist/declarations/src/actions.d.ts +1 -0
  27. package/dist/declarations/src/actors/callback.d.ts +76 -2
  28. package/dist/declarations/src/actors/observable.d.ts +2 -3
  29. package/dist/declarations/src/actors/promise.d.ts +0 -1
  30. package/dist/declarations/src/actors/transition.d.ts +3 -3
  31. package/dist/declarations/src/guards.d.ts +9 -10
  32. package/dist/declarations/src/interpreter.d.ts +71 -10
  33. package/dist/declarations/src/spawn.d.ts +3 -4
  34. package/dist/declarations/src/stateUtils.d.ts +4 -9
  35. package/dist/declarations/src/types.d.ts +51 -62
  36. package/dist/{interpreter-e58ca48d.development.cjs.js → interpreter-03a5c3f5.development.cjs.js} +91 -12
  37. package/dist/{interpreter-8def682e.esm.js → interpreter-1e8c1c0c.esm.js} +91 -12
  38. package/dist/{interpreter-97aff8d2.cjs.js → interpreter-5dfcd203.cjs.js} +91 -12
  39. package/dist/{interpreter-1c52b23c.development.esm.js → interpreter-70cd9217.development.esm.js} +91 -12
  40. package/dist/{raise-1fd59c65.development.cjs.js → raise-17cb3d9d.development.cjs.js} +145 -152
  41. package/dist/{raise-800296d7.cjs.js → raise-291d2181.cjs.js} +145 -152
  42. package/dist/{raise-21c417c1.esm.js → raise-62de3670.esm.js} +145 -153
  43. package/dist/{raise-e342a840.development.esm.js → raise-e044f460.development.esm.js} +145 -153
  44. package/dist/{send-92854675.esm.js → send-1249d4ac.esm.js} +45 -44
  45. package/dist/{send-b309ef4e.development.cjs.js → send-33433787.development.cjs.js} +45 -44
  46. package/dist/{send-4cc29786.cjs.js → send-af152aca.cjs.js} +45 -44
  47. package/dist/{send-83ccc98b.development.esm.js → send-f1a2a827.development.esm.js} +45 -44
  48. package/dist/xstate.cjs.js +23 -20
  49. package/dist/xstate.cjs.mjs +1 -0
  50. package/dist/xstate.development.cjs.js +23 -20
  51. package/dist/xstate.development.cjs.mjs +1 -0
  52. package/dist/xstate.development.esm.js +25 -23
  53. package/dist/xstate.esm.js +25 -23
  54. package/dist/xstate.umd.min.js +1 -1
  55. package/dist/xstate.umd.min.js.map +1 -1
  56. package/guards/dist/xstate-guards.cjs.js +2 -2
  57. package/guards/dist/xstate-guards.development.cjs.js +2 -2
  58. package/guards/dist/xstate-guards.development.esm.js +2 -2
  59. package/guards/dist/xstate-guards.esm.js +2 -2
  60. package/guards/dist/xstate-guards.umd.min.js +1 -1
  61. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  62. package/package.json +1 -1
@@ -3,9 +3,9 @@
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 interpreter = require('./interpreter-97aff8d2.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-800296d7.cjs.js');
8
- var send = require('./send-4cc29786.cjs.js');
6
+ var interpreter = require('./interpreter-5dfcd203.cjs.js');
7
+ var guards_dist_xstateGuards = require('./raise-291d2181.cjs.js');
8
+ var send = require('./send-af152aca.cjs.js');
9
9
  require('../dev/dist/xstate-dev.cjs.js');
10
10
 
11
11
  class SimulatedClock {
@@ -478,7 +478,7 @@ class StateMachine {
478
478
  * @param state The current State instance or state value
479
479
  * @param event The received event
480
480
  */
481
- transition(state, event, actorCtx) {
481
+ transition(state, event, actorScope) {
482
482
  // TODO: handle error events in a better way
483
483
  if (interpreter.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
484
484
  return guards_dist_xstateGuards.cloneState(state, {
@@ -488,7 +488,7 @@ class StateMachine {
488
488
  }
489
489
  const {
490
490
  state: nextState
491
- } = guards_dist_xstateGuards.macrostep(state, event, actorCtx);
491
+ } = guards_dist_xstateGuards.macrostep(state, event, actorScope);
492
492
  return nextState;
493
493
  }
494
494
 
@@ -499,8 +499,8 @@ class StateMachine {
499
499
  * @param state The current state
500
500
  * @param event The received event
501
501
  */
502
- microstep(state, event, actorCtx) {
503
- return guards_dist_xstateGuards.macrostep(state, event, actorCtx).microstates;
502
+ microstep(state, event, actorScope) {
503
+ return guards_dist_xstateGuards.macrostep(state, event, actorScope).microstates;
504
504
  }
505
505
  getTransitionData(state, event) {
506
506
  return guards_dist_xstateGuards.transitionNode(this.root, state.value, state, event) || [];
@@ -510,7 +510,7 @@ class StateMachine {
510
510
  * The initial state _before_ evaluating any microsteps.
511
511
  * This "pre-initial" state is provided to initial actions executed in the initial state.
512
512
  */
513
- getPreInitialState(actorCtx, initEvent, internalQueue) {
513
+ getPreInitialState(actorScope, initEvent, internalQueue) {
514
514
  const {
515
515
  context
516
516
  } = this.config;
@@ -531,7 +531,7 @@ class StateMachine {
531
531
  spawn,
532
532
  input: event.input
533
533
  });
534
- return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorCtx, [send.assign(assignment)], internalQueue);
534
+ return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [send.assign(assignment)], internalQueue);
535
535
  }
536
536
  return preInitial;
537
537
  }
@@ -539,10 +539,10 @@ class StateMachine {
539
539
  /**
540
540
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
541
541
  */
542
- getInitialState(actorCtx, input) {
542
+ getInitialState(actorScope, input) {
543
543
  const initEvent = interpreter.createInitEvent(input); // TODO: fix;
544
544
  const internalQueue = [];
545
- const preInitialState = this.getPreInitialState(actorCtx, initEvent, internalQueue);
545
+ const preInitialState = this.getPreInitialState(actorScope, initEvent, internalQueue);
546
546
  const nextState = guards_dist_xstateGuards.microstep([{
547
547
  target: [...guards_dist_xstateGuards.getInitialStateNodes(this.root)],
548
548
  source: this.root,
@@ -550,15 +550,15 @@ class StateMachine {
550
550
  actions: [],
551
551
  eventType: null,
552
552
  toJSON: null // TODO: fix
553
- }], preInitialState, actorCtx, initEvent, true, internalQueue);
553
+ }], preInitialState, actorScope, initEvent, true, internalQueue);
554
554
  const {
555
555
  state: macroState
556
- } = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorCtx, internalQueue);
556
+ } = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorScope, internalQueue);
557
557
  return macroState;
558
558
  }
559
559
  start(state) {
560
560
  Object.values(state.children).forEach(child => {
561
- if (child.status === 0) {
561
+ if (child.getSnapshot().status === 'active') {
562
562
  child.start();
563
563
  }
564
564
  });
@@ -585,21 +585,23 @@ class StateMachine {
585
585
  createState(stateConfig) {
586
586
  return stateConfig instanceof guards_dist_xstateGuards.State ? stateConfig : new guards_dist_xstateGuards.State(stateConfig, this);
587
587
  }
588
- restoreState(snapshot, _actorCtx) {
588
+ restoreState(snapshot, _actorScope) {
589
589
  const children = {};
590
- Object.keys(snapshot.children).forEach(actorId => {
591
- const actorData = snapshot.children[actorId];
590
+ const snapshotChildren = snapshot.children;
591
+ Object.keys(snapshotChildren).forEach(actorId => {
592
+ const actorData = snapshotChildren[actorId];
592
593
  const childState = actorData.state;
593
594
  const src = actorData.src;
594
595
  const logic = src ? interpreter.resolveReferencedActor(this, src)?.src : undefined;
595
596
  if (!logic) {
596
597
  return;
597
598
  }
598
- const actorState = logic.restoreState?.(childState, _actorCtx);
599
+ const actorState = logic.restoreState?.(childState, _actorScope);
599
600
  const actorRef = interpreter.createActor(logic, {
600
601
  id: actorId,
601
- parent: _actorCtx?.self,
602
- state: actorState
602
+ parent: _actorScope?.self,
603
+ state: actorState,
604
+ systemId: actorData.systemId
603
605
  });
604
606
  children[actorId] = actorRef;
605
607
  });
@@ -737,6 +739,7 @@ exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
737
739
  exports.not = guards_dist_xstateGuards.not;
738
740
  exports.or = guards_dist_xstateGuards.or;
739
741
  exports.raise = guards_dist_xstateGuards.raise;
742
+ exports.spawn = guards_dist_xstateGuards.spawn;
740
743
  exports.stateIn = guards_dist_xstateGuards.stateIn;
741
744
  exports.stop = guards_dist_xstateGuards.stop;
742
745
  exports.SpecialTargets = send.SpecialTargets;
@@ -33,6 +33,7 @@ export {
33
33
  raise,
34
34
  sendParent,
35
35
  sendTo,
36
+ spawn,
36
37
  stateIn,
37
38
  stop,
38
39
  toObserver,
@@ -3,9 +3,9 @@
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 interpreter = require('./interpreter-e58ca48d.development.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-1fd59c65.development.cjs.js');
8
- var send = require('./send-b309ef4e.development.cjs.js');
6
+ var interpreter = require('./interpreter-03a5c3f5.development.cjs.js');
7
+ var guards_dist_xstateGuards = require('./raise-17cb3d9d.development.cjs.js');
8
+ var send = require('./send-33433787.development.cjs.js');
9
9
  require('../dev/dist/xstate-dev.development.cjs.js');
10
10
 
11
11
  class SimulatedClock {
@@ -481,7 +481,7 @@ class StateMachine {
481
481
  * @param state The current State instance or state value
482
482
  * @param event The received event
483
483
  */
484
- transition(state, event, actorCtx) {
484
+ transition(state, event, actorScope) {
485
485
  // TODO: handle error events in a better way
486
486
  if (interpreter.isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
487
487
  return guards_dist_xstateGuards.cloneState(state, {
@@ -491,7 +491,7 @@ class StateMachine {
491
491
  }
492
492
  const {
493
493
  state: nextState
494
- } = guards_dist_xstateGuards.macrostep(state, event, actorCtx);
494
+ } = guards_dist_xstateGuards.macrostep(state, event, actorScope);
495
495
  return nextState;
496
496
  }
497
497
 
@@ -502,8 +502,8 @@ class StateMachine {
502
502
  * @param state The current state
503
503
  * @param event The received event
504
504
  */
505
- microstep(state, event, actorCtx) {
506
- return guards_dist_xstateGuards.macrostep(state, event, actorCtx).microstates;
505
+ microstep(state, event, actorScope) {
506
+ return guards_dist_xstateGuards.macrostep(state, event, actorScope).microstates;
507
507
  }
508
508
  getTransitionData(state, event) {
509
509
  return guards_dist_xstateGuards.transitionNode(this.root, state.value, state, event) || [];
@@ -513,7 +513,7 @@ class StateMachine {
513
513
  * The initial state _before_ evaluating any microsteps.
514
514
  * This "pre-initial" state is provided to initial actions executed in the initial state.
515
515
  */
516
- getPreInitialState(actorCtx, initEvent, internalQueue) {
516
+ getPreInitialState(actorScope, initEvent, internalQueue) {
517
517
  const {
518
518
  context
519
519
  } = this.config;
@@ -534,7 +534,7 @@ class StateMachine {
534
534
  spawn,
535
535
  input: event.input
536
536
  });
537
- return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorCtx, [send.assign(assignment)], internalQueue);
537
+ return guards_dist_xstateGuards.resolveActionsAndContext(preInitial, initEvent, actorScope, [send.assign(assignment)], internalQueue);
538
538
  }
539
539
  return preInitial;
540
540
  }
@@ -542,10 +542,10 @@ class StateMachine {
542
542
  /**
543
543
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
544
544
  */
545
- getInitialState(actorCtx, input) {
545
+ getInitialState(actorScope, input) {
546
546
  const initEvent = interpreter.createInitEvent(input); // TODO: fix;
547
547
  const internalQueue = [];
548
- const preInitialState = this.getPreInitialState(actorCtx, initEvent, internalQueue);
548
+ const preInitialState = this.getPreInitialState(actorScope, initEvent, internalQueue);
549
549
  const nextState = guards_dist_xstateGuards.microstep([{
550
550
  target: [...guards_dist_xstateGuards.getInitialStateNodes(this.root)],
551
551
  source: this.root,
@@ -553,15 +553,15 @@ class StateMachine {
553
553
  actions: [],
554
554
  eventType: null,
555
555
  toJSON: null // TODO: fix
556
- }], preInitialState, actorCtx, initEvent, true, internalQueue);
556
+ }], preInitialState, actorScope, initEvent, true, internalQueue);
557
557
  const {
558
558
  state: macroState
559
- } = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorCtx, internalQueue);
559
+ } = guards_dist_xstateGuards.macrostep(nextState, initEvent, actorScope, internalQueue);
560
560
  return macroState;
561
561
  }
562
562
  start(state) {
563
563
  Object.values(state.children).forEach(child => {
564
- if (child.status === 0) {
564
+ if (child.getSnapshot().status === 'active') {
565
565
  child.start();
566
566
  }
567
567
  });
@@ -588,21 +588,23 @@ class StateMachine {
588
588
  createState(stateConfig) {
589
589
  return stateConfig instanceof guards_dist_xstateGuards.State ? stateConfig : new guards_dist_xstateGuards.State(stateConfig, this);
590
590
  }
591
- restoreState(snapshot, _actorCtx) {
591
+ restoreState(snapshot, _actorScope) {
592
592
  const children = {};
593
- Object.keys(snapshot.children).forEach(actorId => {
594
- const actorData = snapshot.children[actorId];
593
+ const snapshotChildren = snapshot.children;
594
+ Object.keys(snapshotChildren).forEach(actorId => {
595
+ const actorData = snapshotChildren[actorId];
595
596
  const childState = actorData.state;
596
597
  const src = actorData.src;
597
598
  const logic = src ? interpreter.resolveReferencedActor(this, src)?.src : undefined;
598
599
  if (!logic) {
599
600
  return;
600
601
  }
601
- const actorState = logic.restoreState?.(childState, _actorCtx);
602
+ const actorState = logic.restoreState?.(childState, _actorScope);
602
603
  const actorRef = interpreter.createActor(logic, {
603
604
  id: actorId,
604
- parent: _actorCtx?.self,
605
- state: actorState
605
+ parent: _actorScope?.self,
606
+ state: actorState,
607
+ systemId: actorData.systemId
606
608
  });
607
609
  children[actorId] = actorRef;
608
610
  });
@@ -743,6 +745,7 @@ exports.getStateNodes = guards_dist_xstateGuards.getStateNodes;
743
745
  exports.not = guards_dist_xstateGuards.not;
744
746
  exports.or = guards_dist_xstateGuards.or;
745
747
  exports.raise = guards_dist_xstateGuards.raise;
748
+ exports.spawn = guards_dist_xstateGuards.spawn;
746
749
  exports.stateIn = guards_dist_xstateGuards.stateIn;
747
750
  exports.stop = guards_dist_xstateGuards.stop;
748
751
  exports.SpecialTargets = send.SpecialTargets;
@@ -33,6 +33,7 @@ export {
33
33
  raise,
34
34
  sendParent,
35
35
  sendTo,
36
+ spawn,
36
37
  stateIn,
37
38
  stop,
38
39
  toObserver,
@@ -1,10 +1,10 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.development.esm.js';
2
- import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-1c52b23c.development.esm.js';
3
- export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-1c52b23c.development.esm.js';
4
- import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-e342a840.development.esm.js';
5
- export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-e342a840.development.esm.js';
6
- import { a as assign } from './send-83ccc98b.development.esm.js';
7
- export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-83ccc98b.development.esm.js';
2
+ import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-70cd9217.development.esm.js';
3
+ export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-70cd9217.development.esm.js';
4
+ import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-e044f460.development.esm.js';
5
+ export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-e044f460.development.esm.js';
6
+ import { a as assign } from './send-f1a2a827.development.esm.js';
7
+ export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-f1a2a827.development.esm.js';
8
8
  import '../dev/dist/xstate-dev.development.esm.js';
9
9
 
10
10
  class SimulatedClock {
@@ -480,7 +480,7 @@ class StateMachine {
480
480
  * @param state The current State instance or state value
481
481
  * @param event The received event
482
482
  */
483
- transition(state, event, actorCtx) {
483
+ transition(state, event, actorScope) {
484
484
  // TODO: handle error events in a better way
485
485
  if (isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
486
486
  return cloneState(state, {
@@ -490,7 +490,7 @@ class StateMachine {
490
490
  }
491
491
  const {
492
492
  state: nextState
493
- } = macrostep(state, event, actorCtx);
493
+ } = macrostep(state, event, actorScope);
494
494
  return nextState;
495
495
  }
496
496
 
@@ -501,8 +501,8 @@ class StateMachine {
501
501
  * @param state The current state
502
502
  * @param event The received event
503
503
  */
504
- microstep(state, event, actorCtx) {
505
- return macrostep(state, event, actorCtx).microstates;
504
+ microstep(state, event, actorScope) {
505
+ return macrostep(state, event, actorScope).microstates;
506
506
  }
507
507
  getTransitionData(state, event) {
508
508
  return transitionNode(this.root, state.value, state, event) || [];
@@ -512,7 +512,7 @@ class StateMachine {
512
512
  * The initial state _before_ evaluating any microsteps.
513
513
  * This "pre-initial" state is provided to initial actions executed in the initial state.
514
514
  */
515
- getPreInitialState(actorCtx, initEvent, internalQueue) {
515
+ getPreInitialState(actorScope, initEvent, internalQueue) {
516
516
  const {
517
517
  context
518
518
  } = this.config;
@@ -533,7 +533,7 @@ class StateMachine {
533
533
  spawn,
534
534
  input: event.input
535
535
  });
536
- return resolveActionsAndContext(preInitial, initEvent, actorCtx, [assign(assignment)], internalQueue);
536
+ return resolveActionsAndContext(preInitial, initEvent, actorScope, [assign(assignment)], internalQueue);
537
537
  }
538
538
  return preInitial;
539
539
  }
@@ -541,10 +541,10 @@ class StateMachine {
541
541
  /**
542
542
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
543
543
  */
544
- getInitialState(actorCtx, input) {
544
+ getInitialState(actorScope, input) {
545
545
  const initEvent = createInitEvent(input); // TODO: fix;
546
546
  const internalQueue = [];
547
- const preInitialState = this.getPreInitialState(actorCtx, initEvent, internalQueue);
547
+ const preInitialState = this.getPreInitialState(actorScope, initEvent, internalQueue);
548
548
  const nextState = microstep([{
549
549
  target: [...getInitialStateNodes(this.root)],
550
550
  source: this.root,
@@ -552,15 +552,15 @@ class StateMachine {
552
552
  actions: [],
553
553
  eventType: null,
554
554
  toJSON: null // TODO: fix
555
- }], preInitialState, actorCtx, initEvent, true, internalQueue);
555
+ }], preInitialState, actorScope, initEvent, true, internalQueue);
556
556
  const {
557
557
  state: macroState
558
- } = macrostep(nextState, initEvent, actorCtx, internalQueue);
558
+ } = macrostep(nextState, initEvent, actorScope, internalQueue);
559
559
  return macroState;
560
560
  }
561
561
  start(state) {
562
562
  Object.values(state.children).forEach(child => {
563
- if (child.status === 0) {
563
+ if (child.getSnapshot().status === 'active') {
564
564
  child.start();
565
565
  }
566
566
  });
@@ -587,21 +587,23 @@ class StateMachine {
587
587
  createState(stateConfig) {
588
588
  return stateConfig instanceof State ? stateConfig : new State(stateConfig, this);
589
589
  }
590
- restoreState(snapshot, _actorCtx) {
590
+ restoreState(snapshot, _actorScope) {
591
591
  const children = {};
592
- Object.keys(snapshot.children).forEach(actorId => {
593
- const actorData = snapshot.children[actorId];
592
+ const snapshotChildren = snapshot.children;
593
+ Object.keys(snapshotChildren).forEach(actorId => {
594
+ const actorData = snapshotChildren[actorId];
594
595
  const childState = actorData.state;
595
596
  const src = actorData.src;
596
597
  const logic = src ? resolveReferencedActor(this, src)?.src : undefined;
597
598
  if (!logic) {
598
599
  return;
599
600
  }
600
- const actorState = logic.restoreState?.(childState, _actorCtx);
601
+ const actorState = logic.restoreState?.(childState, _actorScope);
601
602
  const actorRef = createActor(logic, {
602
603
  id: actorId,
603
- parent: _actorCtx?.self,
604
- state: actorState
604
+ parent: _actorScope?.self,
605
+ state: actorState,
606
+ systemId: actorData.systemId
605
607
  });
606
608
  children[actorId] = actorRef;
607
609
  });
@@ -1,10 +1,10 @@
1
1
  export { createEmptyActor, fromCallback, fromEventObservable, fromObservable, fromPromise, fromTransition } from '../actors/dist/xstate-actors.esm.js';
2
- import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-8def682e.esm.js';
3
- export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-8def682e.esm.js';
4
- import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-21c417c1.esm.js';
5
- export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, y as stateIn, B as stop } from './raise-21c417c1.esm.js';
6
- import { a as assign } from './send-92854675.esm.js';
7
- export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-92854675.esm.js';
2
+ import { S as STATE_DELIMITER, m as mapValues, t as toArray, a as toTransitionConfigArray, N as NULL_EVENT, c as createInvokeId, i as isErrorActorEvent, b as createInitEvent, r as resolveReferencedActor, d as createActor, $ as $$ACTOR_TYPE, e as matchesState } from './interpreter-1e8c1c0c.esm.js';
3
+ export { A as Actor, f as ActorStatus, I as InterpreterStatus, d as createActor, g as interpret, e as matchesState, p as pathToStateValue, h as toObserver } from './interpreter-1e8c1c0c.esm.js';
4
+ import { f as formatTransitions, a as formatTransition, m as memo, e as evaluateGuard, g as getDelayedTransitions, b as formatInitialTransition, c as getCandidates, d as getConfiguration, h as getStateNodes, r as resolveStateValue, i as isInFinalState, S as State, j as cloneState, k as macrostep, t as transitionNode, l as getInitialConfiguration, n as resolveActionsAndContext, o as microstep, p as getInitialStateNodes, q as isStateId, s as getStateNodeByPath, u as getPersistedState } from './raise-62de3670.esm.js';
5
+ export { S as State, v as and, z as cancel, h as getStateNodes, w as not, x as or, A as raise, C as spawn, y as stateIn, B as stop } from './raise-62de3670.esm.js';
6
+ import { a as assign } from './send-1249d4ac.esm.js';
7
+ export { S as SpecialTargets, a as assign, c as choose, e as escalate, f as forwardTo, l as log, p as pure, s as sendParent, b as sendTo } from './send-1249d4ac.esm.js';
8
8
  import '../dev/dist/xstate-dev.esm.js';
9
9
 
10
10
  class SimulatedClock {
@@ -477,7 +477,7 @@ class StateMachine {
477
477
  * @param state The current State instance or state value
478
478
  * @param event The received event
479
479
  */
480
- transition(state, event, actorCtx) {
480
+ transition(state, event, actorScope) {
481
481
  // TODO: handle error events in a better way
482
482
  if (isErrorActorEvent(event) && !state.nextEvents.some(nextEvent => nextEvent === event.type)) {
483
483
  return cloneState(state, {
@@ -487,7 +487,7 @@ class StateMachine {
487
487
  }
488
488
  const {
489
489
  state: nextState
490
- } = macrostep(state, event, actorCtx);
490
+ } = macrostep(state, event, actorScope);
491
491
  return nextState;
492
492
  }
493
493
 
@@ -498,8 +498,8 @@ class StateMachine {
498
498
  * @param state The current state
499
499
  * @param event The received event
500
500
  */
501
- microstep(state, event, actorCtx) {
502
- return macrostep(state, event, actorCtx).microstates;
501
+ microstep(state, event, actorScope) {
502
+ return macrostep(state, event, actorScope).microstates;
503
503
  }
504
504
  getTransitionData(state, event) {
505
505
  return transitionNode(this.root, state.value, state, event) || [];
@@ -509,7 +509,7 @@ class StateMachine {
509
509
  * The initial state _before_ evaluating any microsteps.
510
510
  * This "pre-initial" state is provided to initial actions executed in the initial state.
511
511
  */
512
- getPreInitialState(actorCtx, initEvent, internalQueue) {
512
+ getPreInitialState(actorScope, initEvent, internalQueue) {
513
513
  const {
514
514
  context
515
515
  } = this.config;
@@ -530,7 +530,7 @@ class StateMachine {
530
530
  spawn,
531
531
  input: event.input
532
532
  });
533
- return resolveActionsAndContext(preInitial, initEvent, actorCtx, [assign(assignment)], internalQueue);
533
+ return resolveActionsAndContext(preInitial, initEvent, actorScope, [assign(assignment)], internalQueue);
534
534
  }
535
535
  return preInitial;
536
536
  }
@@ -538,10 +538,10 @@ class StateMachine {
538
538
  /**
539
539
  * Returns the initial `State` instance, with reference to `self` as an `ActorRef`.
540
540
  */
541
- getInitialState(actorCtx, input) {
541
+ getInitialState(actorScope, input) {
542
542
  const initEvent = createInitEvent(input); // TODO: fix;
543
543
  const internalQueue = [];
544
- const preInitialState = this.getPreInitialState(actorCtx, initEvent, internalQueue);
544
+ const preInitialState = this.getPreInitialState(actorScope, initEvent, internalQueue);
545
545
  const nextState = microstep([{
546
546
  target: [...getInitialStateNodes(this.root)],
547
547
  source: this.root,
@@ -549,15 +549,15 @@ class StateMachine {
549
549
  actions: [],
550
550
  eventType: null,
551
551
  toJSON: null // TODO: fix
552
- }], preInitialState, actorCtx, initEvent, true, internalQueue);
552
+ }], preInitialState, actorScope, initEvent, true, internalQueue);
553
553
  const {
554
554
  state: macroState
555
- } = macrostep(nextState, initEvent, actorCtx, internalQueue);
555
+ } = macrostep(nextState, initEvent, actorScope, internalQueue);
556
556
  return macroState;
557
557
  }
558
558
  start(state) {
559
559
  Object.values(state.children).forEach(child => {
560
- if (child.status === 0) {
560
+ if (child.getSnapshot().status === 'active') {
561
561
  child.start();
562
562
  }
563
563
  });
@@ -584,21 +584,23 @@ class StateMachine {
584
584
  createState(stateConfig) {
585
585
  return stateConfig instanceof State ? stateConfig : new State(stateConfig, this);
586
586
  }
587
- restoreState(snapshot, _actorCtx) {
587
+ restoreState(snapshot, _actorScope) {
588
588
  const children = {};
589
- Object.keys(snapshot.children).forEach(actorId => {
590
- const actorData = snapshot.children[actorId];
589
+ const snapshotChildren = snapshot.children;
590
+ Object.keys(snapshotChildren).forEach(actorId => {
591
+ const actorData = snapshotChildren[actorId];
591
592
  const childState = actorData.state;
592
593
  const src = actorData.src;
593
594
  const logic = src ? resolveReferencedActor(this, src)?.src : undefined;
594
595
  if (!logic) {
595
596
  return;
596
597
  }
597
- const actorState = logic.restoreState?.(childState, _actorCtx);
598
+ const actorState = logic.restoreState?.(childState, _actorScope);
598
599
  const actorRef = createActor(logic, {
599
600
  id: actorId,
600
- parent: _actorCtx?.self,
601
- state: actorState
601
+ parent: _actorScope?.self,
602
+ state: actorState,
603
+ systemId: actorData.systemId
602
604
  });
603
605
  children[actorId] = actorRef;
604
606
  });