xstate 5.0.0-beta.40 → 5.0.0-beta.41

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 (43) hide show
  1. package/actions/dist/xstate-actions.cjs.js +3 -3
  2. package/actions/dist/xstate-actions.development.cjs.js +3 -3
  3. package/actions/dist/xstate-actions.development.esm.js +3 -3
  4. package/actions/dist/xstate-actions.esm.js +3 -3
  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 +1 -1
  8. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  9. package/actors/dist/xstate-actors.development.esm.js +1 -1
  10. package/actors/dist/xstate-actors.esm.js +1 -1
  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 +1 -1
  14. package/dist/declarations/src/StateMachine.d.ts +1 -1
  15. package/dist/declarations/src/index.d.ts +2 -2
  16. package/dist/declarations/src/interpreter.d.ts +2 -10
  17. package/dist/declarations/src/types.d.ts +4 -9
  18. package/dist/{interpreter-ed0fac7e.esm.js → interpreter-480db258.esm.js} +26 -31
  19. package/dist/{interpreter-bae5c279.development.cjs.js → interpreter-70ed981b.development.cjs.js} +26 -32
  20. package/dist/{interpreter-410d7ca9.development.esm.js → interpreter-936da690.development.esm.js} +26 -31
  21. package/dist/{interpreter-586abde4.cjs.js → interpreter-fb2829f1.cjs.js} +26 -32
  22. package/dist/{raise-8325e2df.development.cjs.js → raise-5ab465ed.development.cjs.js} +9 -9
  23. package/dist/{raise-2b2fdec3.esm.js → raise-9d6921da.esm.js} +8 -8
  24. package/dist/{raise-27909189.cjs.js → raise-beae3fd3.cjs.js} +8 -8
  25. package/dist/{raise-37f9f3b8.development.esm.js → raise-f757be00.development.esm.js} +9 -9
  26. package/dist/{send-59f66c58.esm.js → send-a931d1b8.esm.js} +4 -5
  27. package/dist/{send-f6b49072.development.esm.js → send-b26e3812.development.esm.js} +4 -5
  28. package/dist/{send-4fdf275e.cjs.js → send-ca5f706c.cjs.js} +4 -5
  29. package/dist/{send-c45d0d2c.development.cjs.js → send-fb87a01a.development.cjs.js} +4 -5
  30. package/dist/xstate.cjs.js +7 -10
  31. package/dist/xstate.cjs.mjs +0 -2
  32. package/dist/xstate.development.cjs.js +7 -10
  33. package/dist/xstate.development.cjs.mjs +0 -2
  34. package/dist/xstate.development.esm.js +10 -11
  35. package/dist/xstate.esm.js +10 -11
  36. package/dist/xstate.umd.min.js +1 -1
  37. package/dist/xstate.umd.min.js.map +1 -1
  38. package/guards/dist/xstate-guards.cjs.js +2 -2
  39. package/guards/dist/xstate-guards.development.cjs.js +2 -2
  40. package/guards/dist/xstate-guards.development.esm.js +2 -2
  41. package/guards/dist/xstate-guards.esm.js +2 -2
  42. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  43. package/package.json +1 -1
@@ -331,17 +331,13 @@ function resolveReferencedActor(machine, src) {
331
331
  }
332
332
 
333
333
  const $$ACTOR_TYPE = 1;
334
- let ActorStatus = /*#__PURE__*/function (ActorStatus) {
335
- ActorStatus[ActorStatus["NotStarted"] = 0] = "NotStarted";
336
- ActorStatus[ActorStatus["Running"] = 1] = "Running";
337
- ActorStatus[ActorStatus["Stopped"] = 2] = "Stopped";
338
- return ActorStatus;
334
+ // those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
335
+ let ProcessingStatus = /*#__PURE__*/function (ProcessingStatus) {
336
+ ProcessingStatus[ProcessingStatus["NotStarted"] = 0] = "NotStarted";
337
+ ProcessingStatus[ProcessingStatus["Running"] = 1] = "Running";
338
+ ProcessingStatus[ProcessingStatus["Stopped"] = 2] = "Stopped";
339
+ return ProcessingStatus;
339
340
  }({});
340
-
341
- /**
342
- * @deprecated Use `ActorStatus` instead.
343
- */
344
- const InterpreterStatus = ActorStatus;
345
341
  const defaultOptions = {
346
342
  clock: {
347
343
  setTimeout: (fn, ms) => {
@@ -371,9 +367,7 @@ class Actor {
371
367
  * The unique identifier for this actor relative to its parent.
372
368
  */
373
369
 
374
- /**
375
- * Whether the service is started.
376
- */
370
+ /** @internal */
377
371
 
378
372
  // Actor Ref
379
373
 
@@ -403,7 +397,7 @@ class Actor {
403
397
  this.delayedEventsMap = {};
404
398
  this.observers = new Set();
405
399
  this.logger = void 0;
406
- this.status = ActorStatus.NotStarted;
400
+ this._processingStatus = ProcessingStatus.NotStarted;
407
401
  this._parent = void 0;
408
402
  this.ref = void 0;
409
403
  this._actorScope = void 0;
@@ -436,7 +430,7 @@ class Actor {
436
430
  this.clock = clock;
437
431
  this._parent = parent;
438
432
  this.options = resolvedOptions;
439
- this.src = resolvedOptions.src;
433
+ this.src = resolvedOptions.src ?? logic;
440
434
  this.ref = this;
441
435
  this._actorScope = {
442
436
  self: this,
@@ -462,14 +456,14 @@ class Actor {
462
456
  type: '@xstate.actor',
463
457
  actorRef: this
464
458
  });
465
- this._initState();
459
+ this._initState(options?.state);
466
460
  if (systemId && this._state.status === 'active') {
467
461
  this._systemId = systemId;
468
462
  this.system._set(systemId, this);
469
463
  }
470
464
  }
471
- _initState() {
472
- this._state = this.options.state ? this.logic.restoreState ? this.logic.restoreState(this.options.state, this._actorScope) : this.options.state : this.logic.getInitialState(this._actorScope, this.options?.input);
465
+ _initState(persistedState) {
466
+ this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
473
467
  }
474
468
 
475
469
  // array of functions to defer
@@ -484,7 +478,6 @@ class Actor {
484
478
  deferredFn();
485
479
  }
486
480
  for (const observer of this.observers) {
487
- // TODO: should observers be notified in case of the error?
488
481
  try {
489
482
  observer.next?.(snapshot);
490
483
  } catch (err) {
@@ -567,7 +560,7 @@ class Actor {
567
560
 
568
561
  subscribe(nextListenerOrObserver, errorListener, completeListener) {
569
562
  const observer = toObserver(nextListenerOrObserver, errorListener, completeListener);
570
- if (this.status !== ActorStatus.Stopped) {
563
+ if (this._processingStatus !== ProcessingStatus.Stopped) {
571
564
  this.observers.add(observer);
572
565
  } else {
573
566
  try {
@@ -587,7 +580,7 @@ class Actor {
587
580
  * Starts the Actor from the initial state
588
581
  */
589
582
  start() {
590
- if (this.status === ActorStatus.Running) {
583
+ if (this._processingStatus === ProcessingStatus.Running) {
591
584
  // Do not restart the service if it is already started
592
585
  return this;
593
586
  }
@@ -595,7 +588,9 @@ class Actor {
595
588
  if (this._systemId) {
596
589
  this.system._set(this._systemId, this);
597
590
  }
598
- this.status = ActorStatus.Running;
591
+ this._processingStatus = ProcessingStatus.Running;
592
+
593
+ // TODO: this isn't correct when rehydrating
599
594
  const initEvent = createInitEvent(this.options.input);
600
595
  this.system._sendInspectionEvent({
601
596
  type: '@xstate.event',
@@ -663,12 +658,12 @@ class Actor {
663
658
  }
664
659
  }
665
660
  _stop() {
666
- if (this.status === ActorStatus.Stopped) {
661
+ if (this._processingStatus === ProcessingStatus.Stopped) {
667
662
  return this;
668
663
  }
669
664
  this.mailbox.clear();
670
- if (this.status === ActorStatus.NotStarted) {
671
- this.status = ActorStatus.Stopped;
665
+ if (this._processingStatus === ProcessingStatus.NotStarted) {
666
+ this._processingStatus = ProcessingStatus.Stopped;
672
667
  return this;
673
668
  }
674
669
  this.mailbox.enqueue({
@@ -719,7 +714,7 @@ class Actor {
719
714
  }
720
715
  }
721
716
  _stopProcedure() {
722
- if (this.status !== ActorStatus.Running) {
717
+ if (this._processingStatus !== ProcessingStatus.Running) {
723
718
  // Actor already stopped; do nothing
724
719
  return this;
725
720
  }
@@ -736,7 +731,7 @@ class Actor {
736
731
  // it seems like this should be the common behavior for all of our consumers
737
732
  // so perhaps this should be unified somehow for all of them
738
733
  this.mailbox = new Mailbox(this._process.bind(this));
739
- this.status = ActorStatus.Stopped;
734
+ this._processingStatus = ProcessingStatus.Stopped;
740
735
  this.system._unregister(this);
741
736
  return this;
742
737
  }
@@ -745,7 +740,7 @@ class Actor {
745
740
  * @internal
746
741
  */
747
742
  _send(event) {
748
- if (this.status === ActorStatus.Stopped) {
743
+ if (this._processingStatus === ProcessingStatus.Stopped) {
749
744
  return;
750
745
  }
751
746
  this.mailbox.enqueue(event);
@@ -803,8 +798,8 @@ class Actor {
803
798
  id: this.id
804
799
  };
805
800
  }
806
- getPersistedState() {
807
- return this.logic.getPersistedState(this._state);
801
+ getPersistedState(options) {
802
+ return this.logic.getPersistedState(this._state, options);
808
803
  }
809
804
  [symbolObservable]() {
810
805
  return this;
@@ -852,4 +847,4 @@ const interpret = createActor;
852
847
  * @deprecated Use `Actor` instead.
853
848
  */
854
849
 
855
- export { $$ACTOR_TYPE as $, Actor as A, InterpreterStatus as I, NULL_EVENT as N, STATE_DELIMITER as S, WILDCARD as W, XSTATE_STOP as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, matchesState as e, ActorStatus as f, interpret as g, toObserver as h, isErrorActorEvent as i, createErrorActorEvent as j, toStateValue as k, STATE_IDENTIFIER as l, mapValues as m, normalizeTarget as n, toStatePath as o, pathToStateValue as p, createDoneStateEvent as q, resolveReferencedActor as r, resolveOutput as s, toArray as t, XSTATE_INIT as u, createAfterEvent as v, flatten as w, XSTATE_ERROR as x };
850
+ export { $$ACTOR_TYPE as $, Actor as A, NULL_EVENT as N, ProcessingStatus as P, STATE_DELIMITER as S, WILDCARD as W, XSTATE_STOP as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, matchesState as e, interpret as f, toObserver as g, createErrorActorEvent as h, isErrorActorEvent as i, toStateValue as j, STATE_IDENTIFIER as k, toStatePath as l, mapValues as m, normalizeTarget as n, createDoneStateEvent as o, pathToStateValue as p, resolveOutput as q, resolveReferencedActor as r, XSTATE_INIT as s, toArray as t, createAfterEvent as u, flatten as v, XSTATE_ERROR as w };
@@ -336,17 +336,13 @@ function resolveReferencedActor(machine, src) {
336
336
  }
337
337
 
338
338
  const $$ACTOR_TYPE = 1;
339
- let ActorStatus = /*#__PURE__*/function (ActorStatus) {
340
- ActorStatus[ActorStatus["NotStarted"] = 0] = "NotStarted";
341
- ActorStatus[ActorStatus["Running"] = 1] = "Running";
342
- ActorStatus[ActorStatus["Stopped"] = 2] = "Stopped";
343
- return ActorStatus;
339
+ // those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
340
+ let ProcessingStatus = /*#__PURE__*/function (ProcessingStatus) {
341
+ ProcessingStatus[ProcessingStatus["NotStarted"] = 0] = "NotStarted";
342
+ ProcessingStatus[ProcessingStatus["Running"] = 1] = "Running";
343
+ ProcessingStatus[ProcessingStatus["Stopped"] = 2] = "Stopped";
344
+ return ProcessingStatus;
344
345
  }({});
345
-
346
- /**
347
- * @deprecated Use `ActorStatus` instead.
348
- */
349
- const InterpreterStatus = ActorStatus;
350
346
  const defaultOptions = {
351
347
  clock: {
352
348
  setTimeout: (fn, ms) => {
@@ -376,9 +372,7 @@ class Actor {
376
372
  * The unique identifier for this actor relative to its parent.
377
373
  */
378
374
 
379
- /**
380
- * Whether the service is started.
381
- */
375
+ /** @internal */
382
376
 
383
377
  // Actor Ref
384
378
 
@@ -408,7 +402,7 @@ class Actor {
408
402
  this.delayedEventsMap = {};
409
403
  this.observers = new Set();
410
404
  this.logger = void 0;
411
- this.status = ActorStatus.NotStarted;
405
+ this._processingStatus = ProcessingStatus.NotStarted;
412
406
  this._parent = void 0;
413
407
  this.ref = void 0;
414
408
  this._actorScope = void 0;
@@ -441,7 +435,7 @@ class Actor {
441
435
  this.clock = clock;
442
436
  this._parent = parent;
443
437
  this.options = resolvedOptions;
444
- this.src = resolvedOptions.src;
438
+ this.src = resolvedOptions.src ?? logic;
445
439
  this.ref = this;
446
440
  this._actorScope = {
447
441
  self: this,
@@ -467,14 +461,14 @@ class Actor {
467
461
  type: '@xstate.actor',
468
462
  actorRef: this
469
463
  });
470
- this._initState();
464
+ this._initState(options?.state);
471
465
  if (systemId && this._state.status === 'active') {
472
466
  this._systemId = systemId;
473
467
  this.system._set(systemId, this);
474
468
  }
475
469
  }
476
- _initState() {
477
- this._state = this.options.state ? this.logic.restoreState ? this.logic.restoreState(this.options.state, this._actorScope) : this.options.state : this.logic.getInitialState(this._actorScope, this.options?.input);
470
+ _initState(persistedState) {
471
+ this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
478
472
  }
479
473
 
480
474
  // array of functions to defer
@@ -489,7 +483,6 @@ class Actor {
489
483
  deferredFn();
490
484
  }
491
485
  for (const observer of this.observers) {
492
- // TODO: should observers be notified in case of the error?
493
486
  try {
494
487
  observer.next?.(snapshot);
495
488
  } catch (err) {
@@ -572,7 +565,7 @@ class Actor {
572
565
 
573
566
  subscribe(nextListenerOrObserver, errorListener, completeListener) {
574
567
  const observer = toObserver(nextListenerOrObserver, errorListener, completeListener);
575
- if (this.status !== ActorStatus.Stopped) {
568
+ if (this._processingStatus !== ProcessingStatus.Stopped) {
576
569
  this.observers.add(observer);
577
570
  } else {
578
571
  try {
@@ -592,7 +585,7 @@ class Actor {
592
585
  * Starts the Actor from the initial state
593
586
  */
594
587
  start() {
595
- if (this.status === ActorStatus.Running) {
588
+ if (this._processingStatus === ProcessingStatus.Running) {
596
589
  // Do not restart the service if it is already started
597
590
  return this;
598
591
  }
@@ -600,7 +593,9 @@ class Actor {
600
593
  if (this._systemId) {
601
594
  this.system._set(this._systemId, this);
602
595
  }
603
- this.status = ActorStatus.Running;
596
+ this._processingStatus = ProcessingStatus.Running;
597
+
598
+ // TODO: this isn't correct when rehydrating
604
599
  const initEvent = createInitEvent(this.options.input);
605
600
  this.system._sendInspectionEvent({
606
601
  type: '@xstate.event',
@@ -668,12 +663,12 @@ class Actor {
668
663
  }
669
664
  }
670
665
  _stop() {
671
- if (this.status === ActorStatus.Stopped) {
666
+ if (this._processingStatus === ProcessingStatus.Stopped) {
672
667
  return this;
673
668
  }
674
669
  this.mailbox.clear();
675
- if (this.status === ActorStatus.NotStarted) {
676
- this.status = ActorStatus.Stopped;
670
+ if (this._processingStatus === ProcessingStatus.NotStarted) {
671
+ this._processingStatus = ProcessingStatus.Stopped;
677
672
  return this;
678
673
  }
679
674
  this.mailbox.enqueue({
@@ -724,7 +719,7 @@ class Actor {
724
719
  }
725
720
  }
726
721
  _stopProcedure() {
727
- if (this.status !== ActorStatus.Running) {
722
+ if (this._processingStatus !== ProcessingStatus.Running) {
728
723
  // Actor already stopped; do nothing
729
724
  return this;
730
725
  }
@@ -741,7 +736,7 @@ class Actor {
741
736
  // it seems like this should be the common behavior for all of our consumers
742
737
  // so perhaps this should be unified somehow for all of them
743
738
  this.mailbox = new Mailbox(this._process.bind(this));
744
- this.status = ActorStatus.Stopped;
739
+ this._processingStatus = ProcessingStatus.Stopped;
745
740
  this.system._unregister(this);
746
741
  return this;
747
742
  }
@@ -750,7 +745,7 @@ class Actor {
750
745
  * @internal
751
746
  */
752
747
  _send(event) {
753
- if (this.status === ActorStatus.Stopped) {
748
+ if (this._processingStatus === ProcessingStatus.Stopped) {
754
749
  // do nothing
755
750
  {
756
751
  const eventString = JSON.stringify(event);
@@ -816,8 +811,8 @@ class Actor {
816
811
  id: this.id
817
812
  };
818
813
  }
819
- getPersistedState() {
820
- return this.logic.getPersistedState(this._state);
814
+ getPersistedState(options) {
815
+ return this.logic.getPersistedState(this._state, options);
821
816
  }
822
817
  [symbolObservable]() {
823
818
  return this;
@@ -867,9 +862,8 @@ const interpret = createActor;
867
862
 
868
863
  exports.$$ACTOR_TYPE = $$ACTOR_TYPE;
869
864
  exports.Actor = Actor;
870
- exports.ActorStatus = ActorStatus;
871
- exports.InterpreterStatus = InterpreterStatus;
872
865
  exports.NULL_EVENT = NULL_EVENT;
866
+ exports.ProcessingStatus = ProcessingStatus;
873
867
  exports.STATE_DELIMITER = STATE_DELIMITER;
874
868
  exports.STATE_IDENTIFIER = STATE_IDENTIFIER;
875
869
  exports.WILDCARD = WILDCARD;
@@ -334,17 +334,13 @@ function resolveReferencedActor(machine, src) {
334
334
  }
335
335
 
336
336
  const $$ACTOR_TYPE = 1;
337
- let ActorStatus = /*#__PURE__*/function (ActorStatus) {
338
- ActorStatus[ActorStatus["NotStarted"] = 0] = "NotStarted";
339
- ActorStatus[ActorStatus["Running"] = 1] = "Running";
340
- ActorStatus[ActorStatus["Stopped"] = 2] = "Stopped";
341
- return ActorStatus;
337
+ // those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
338
+ let ProcessingStatus = /*#__PURE__*/function (ProcessingStatus) {
339
+ ProcessingStatus[ProcessingStatus["NotStarted"] = 0] = "NotStarted";
340
+ ProcessingStatus[ProcessingStatus["Running"] = 1] = "Running";
341
+ ProcessingStatus[ProcessingStatus["Stopped"] = 2] = "Stopped";
342
+ return ProcessingStatus;
342
343
  }({});
343
-
344
- /**
345
- * @deprecated Use `ActorStatus` instead.
346
- */
347
- const InterpreterStatus = ActorStatus;
348
344
  const defaultOptions = {
349
345
  clock: {
350
346
  setTimeout: (fn, ms) => {
@@ -374,9 +370,7 @@ class Actor {
374
370
  * The unique identifier for this actor relative to its parent.
375
371
  */
376
372
 
377
- /**
378
- * Whether the service is started.
379
- */
373
+ /** @internal */
380
374
 
381
375
  // Actor Ref
382
376
 
@@ -406,7 +400,7 @@ class Actor {
406
400
  this.delayedEventsMap = {};
407
401
  this.observers = new Set();
408
402
  this.logger = void 0;
409
- this.status = ActorStatus.NotStarted;
403
+ this._processingStatus = ProcessingStatus.NotStarted;
410
404
  this._parent = void 0;
411
405
  this.ref = void 0;
412
406
  this._actorScope = void 0;
@@ -439,7 +433,7 @@ class Actor {
439
433
  this.clock = clock;
440
434
  this._parent = parent;
441
435
  this.options = resolvedOptions;
442
- this.src = resolvedOptions.src;
436
+ this.src = resolvedOptions.src ?? logic;
443
437
  this.ref = this;
444
438
  this._actorScope = {
445
439
  self: this,
@@ -465,14 +459,14 @@ class Actor {
465
459
  type: '@xstate.actor',
466
460
  actorRef: this
467
461
  });
468
- this._initState();
462
+ this._initState(options?.state);
469
463
  if (systemId && this._state.status === 'active') {
470
464
  this._systemId = systemId;
471
465
  this.system._set(systemId, this);
472
466
  }
473
467
  }
474
- _initState() {
475
- this._state = this.options.state ? this.logic.restoreState ? this.logic.restoreState(this.options.state, this._actorScope) : this.options.state : this.logic.getInitialState(this._actorScope, this.options?.input);
468
+ _initState(persistedState) {
469
+ this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
476
470
  }
477
471
 
478
472
  // array of functions to defer
@@ -487,7 +481,6 @@ class Actor {
487
481
  deferredFn();
488
482
  }
489
483
  for (const observer of this.observers) {
490
- // TODO: should observers be notified in case of the error?
491
484
  try {
492
485
  observer.next?.(snapshot);
493
486
  } catch (err) {
@@ -570,7 +563,7 @@ class Actor {
570
563
 
571
564
  subscribe(nextListenerOrObserver, errorListener, completeListener) {
572
565
  const observer = toObserver(nextListenerOrObserver, errorListener, completeListener);
573
- if (this.status !== ActorStatus.Stopped) {
566
+ if (this._processingStatus !== ProcessingStatus.Stopped) {
574
567
  this.observers.add(observer);
575
568
  } else {
576
569
  try {
@@ -590,7 +583,7 @@ class Actor {
590
583
  * Starts the Actor from the initial state
591
584
  */
592
585
  start() {
593
- if (this.status === ActorStatus.Running) {
586
+ if (this._processingStatus === ProcessingStatus.Running) {
594
587
  // Do not restart the service if it is already started
595
588
  return this;
596
589
  }
@@ -598,7 +591,9 @@ class Actor {
598
591
  if (this._systemId) {
599
592
  this.system._set(this._systemId, this);
600
593
  }
601
- this.status = ActorStatus.Running;
594
+ this._processingStatus = ProcessingStatus.Running;
595
+
596
+ // TODO: this isn't correct when rehydrating
602
597
  const initEvent = createInitEvent(this.options.input);
603
598
  this.system._sendInspectionEvent({
604
599
  type: '@xstate.event',
@@ -666,12 +661,12 @@ class Actor {
666
661
  }
667
662
  }
668
663
  _stop() {
669
- if (this.status === ActorStatus.Stopped) {
664
+ if (this._processingStatus === ProcessingStatus.Stopped) {
670
665
  return this;
671
666
  }
672
667
  this.mailbox.clear();
673
- if (this.status === ActorStatus.NotStarted) {
674
- this.status = ActorStatus.Stopped;
668
+ if (this._processingStatus === ProcessingStatus.NotStarted) {
669
+ this._processingStatus = ProcessingStatus.Stopped;
675
670
  return this;
676
671
  }
677
672
  this.mailbox.enqueue({
@@ -722,7 +717,7 @@ class Actor {
722
717
  }
723
718
  }
724
719
  _stopProcedure() {
725
- if (this.status !== ActorStatus.Running) {
720
+ if (this._processingStatus !== ProcessingStatus.Running) {
726
721
  // Actor already stopped; do nothing
727
722
  return this;
728
723
  }
@@ -739,7 +734,7 @@ class Actor {
739
734
  // it seems like this should be the common behavior for all of our consumers
740
735
  // so perhaps this should be unified somehow for all of them
741
736
  this.mailbox = new Mailbox(this._process.bind(this));
742
- this.status = ActorStatus.Stopped;
737
+ this._processingStatus = ProcessingStatus.Stopped;
743
738
  this.system._unregister(this);
744
739
  return this;
745
740
  }
@@ -748,7 +743,7 @@ class Actor {
748
743
  * @internal
749
744
  */
750
745
  _send(event) {
751
- if (this.status === ActorStatus.Stopped) {
746
+ if (this._processingStatus === ProcessingStatus.Stopped) {
752
747
  // do nothing
753
748
  {
754
749
  const eventString = JSON.stringify(event);
@@ -814,8 +809,8 @@ class Actor {
814
809
  id: this.id
815
810
  };
816
811
  }
817
- getPersistedState() {
818
- return this.logic.getPersistedState(this._state);
812
+ getPersistedState(options) {
813
+ return this.logic.getPersistedState(this._state, options);
819
814
  }
820
815
  [symbolObservable]() {
821
816
  return this;
@@ -863,4 +858,4 @@ const interpret = createActor;
863
858
  * @deprecated Use `Actor` instead.
864
859
  */
865
860
 
866
- export { $$ACTOR_TYPE as $, Actor as A, InterpreterStatus as I, NULL_EVENT as N, STATE_DELIMITER as S, WILDCARD as W, XSTATE_STOP as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, matchesState as e, ActorStatus as f, interpret as g, toObserver as h, isErrorActorEvent as i, createErrorActorEvent as j, toStateValue as k, STATE_IDENTIFIER as l, mapValues as m, normalizeTarget as n, toStatePath as o, pathToStateValue as p, createDoneStateEvent as q, resolveReferencedActor as r, resolveOutput as s, toArray as t, XSTATE_INIT as u, createAfterEvent as v, flatten as w, XSTATE_ERROR as x };
861
+ export { $$ACTOR_TYPE as $, Actor as A, NULL_EVENT as N, ProcessingStatus as P, STATE_DELIMITER as S, WILDCARD as W, XSTATE_STOP as X, toTransitionConfigArray as a, createInitEvent as b, createInvokeId as c, createActor as d, matchesState as e, interpret as f, toObserver as g, createErrorActorEvent as h, isErrorActorEvent as i, toStateValue as j, STATE_IDENTIFIER as k, toStatePath as l, mapValues as m, normalizeTarget as n, createDoneStateEvent as o, pathToStateValue as p, resolveOutput as q, resolveReferencedActor as r, XSTATE_INIT as s, toArray as t, createAfterEvent as u, flatten as v, XSTATE_ERROR as w };
@@ -333,17 +333,13 @@ function resolveReferencedActor(machine, src) {
333
333
  }
334
334
 
335
335
  const $$ACTOR_TYPE = 1;
336
- let ActorStatus = /*#__PURE__*/function (ActorStatus) {
337
- ActorStatus[ActorStatus["NotStarted"] = 0] = "NotStarted";
338
- ActorStatus[ActorStatus["Running"] = 1] = "Running";
339
- ActorStatus[ActorStatus["Stopped"] = 2] = "Stopped";
340
- return ActorStatus;
336
+ // those values are currently used by @xstate/react directly so it's important to keep the assigned values in sync
337
+ let ProcessingStatus = /*#__PURE__*/function (ProcessingStatus) {
338
+ ProcessingStatus[ProcessingStatus["NotStarted"] = 0] = "NotStarted";
339
+ ProcessingStatus[ProcessingStatus["Running"] = 1] = "Running";
340
+ ProcessingStatus[ProcessingStatus["Stopped"] = 2] = "Stopped";
341
+ return ProcessingStatus;
341
342
  }({});
342
-
343
- /**
344
- * @deprecated Use `ActorStatus` instead.
345
- */
346
- const InterpreterStatus = ActorStatus;
347
343
  const defaultOptions = {
348
344
  clock: {
349
345
  setTimeout: (fn, ms) => {
@@ -373,9 +369,7 @@ class Actor {
373
369
  * The unique identifier for this actor relative to its parent.
374
370
  */
375
371
 
376
- /**
377
- * Whether the service is started.
378
- */
372
+ /** @internal */
379
373
 
380
374
  // Actor Ref
381
375
 
@@ -405,7 +399,7 @@ class Actor {
405
399
  this.delayedEventsMap = {};
406
400
  this.observers = new Set();
407
401
  this.logger = void 0;
408
- this.status = ActorStatus.NotStarted;
402
+ this._processingStatus = ProcessingStatus.NotStarted;
409
403
  this._parent = void 0;
410
404
  this.ref = void 0;
411
405
  this._actorScope = void 0;
@@ -438,7 +432,7 @@ class Actor {
438
432
  this.clock = clock;
439
433
  this._parent = parent;
440
434
  this.options = resolvedOptions;
441
- this.src = resolvedOptions.src;
435
+ this.src = resolvedOptions.src ?? logic;
442
436
  this.ref = this;
443
437
  this._actorScope = {
444
438
  self: this,
@@ -464,14 +458,14 @@ class Actor {
464
458
  type: '@xstate.actor',
465
459
  actorRef: this
466
460
  });
467
- this._initState();
461
+ this._initState(options?.state);
468
462
  if (systemId && this._state.status === 'active') {
469
463
  this._systemId = systemId;
470
464
  this.system._set(systemId, this);
471
465
  }
472
466
  }
473
- _initState() {
474
- this._state = this.options.state ? this.logic.restoreState ? this.logic.restoreState(this.options.state, this._actorScope) : this.options.state : this.logic.getInitialState(this._actorScope, this.options?.input);
467
+ _initState(persistedState) {
468
+ this._state = persistedState ? this.logic.restoreState ? this.logic.restoreState(persistedState, this._actorScope) : persistedState : this.logic.getInitialState(this._actorScope, this.options?.input);
475
469
  }
476
470
 
477
471
  // array of functions to defer
@@ -486,7 +480,6 @@ class Actor {
486
480
  deferredFn();
487
481
  }
488
482
  for (const observer of this.observers) {
489
- // TODO: should observers be notified in case of the error?
490
483
  try {
491
484
  observer.next?.(snapshot);
492
485
  } catch (err) {
@@ -569,7 +562,7 @@ class Actor {
569
562
 
570
563
  subscribe(nextListenerOrObserver, errorListener, completeListener) {
571
564
  const observer = toObserver(nextListenerOrObserver, errorListener, completeListener);
572
- if (this.status !== ActorStatus.Stopped) {
565
+ if (this._processingStatus !== ProcessingStatus.Stopped) {
573
566
  this.observers.add(observer);
574
567
  } else {
575
568
  try {
@@ -589,7 +582,7 @@ class Actor {
589
582
  * Starts the Actor from the initial state
590
583
  */
591
584
  start() {
592
- if (this.status === ActorStatus.Running) {
585
+ if (this._processingStatus === ProcessingStatus.Running) {
593
586
  // Do not restart the service if it is already started
594
587
  return this;
595
588
  }
@@ -597,7 +590,9 @@ class Actor {
597
590
  if (this._systemId) {
598
591
  this.system._set(this._systemId, this);
599
592
  }
600
- this.status = ActorStatus.Running;
593
+ this._processingStatus = ProcessingStatus.Running;
594
+
595
+ // TODO: this isn't correct when rehydrating
601
596
  const initEvent = createInitEvent(this.options.input);
602
597
  this.system._sendInspectionEvent({
603
598
  type: '@xstate.event',
@@ -665,12 +660,12 @@ class Actor {
665
660
  }
666
661
  }
667
662
  _stop() {
668
- if (this.status === ActorStatus.Stopped) {
663
+ if (this._processingStatus === ProcessingStatus.Stopped) {
669
664
  return this;
670
665
  }
671
666
  this.mailbox.clear();
672
- if (this.status === ActorStatus.NotStarted) {
673
- this.status = ActorStatus.Stopped;
667
+ if (this._processingStatus === ProcessingStatus.NotStarted) {
668
+ this._processingStatus = ProcessingStatus.Stopped;
674
669
  return this;
675
670
  }
676
671
  this.mailbox.enqueue({
@@ -721,7 +716,7 @@ class Actor {
721
716
  }
722
717
  }
723
718
  _stopProcedure() {
724
- if (this.status !== ActorStatus.Running) {
719
+ if (this._processingStatus !== ProcessingStatus.Running) {
725
720
  // Actor already stopped; do nothing
726
721
  return this;
727
722
  }
@@ -738,7 +733,7 @@ class Actor {
738
733
  // it seems like this should be the common behavior for all of our consumers
739
734
  // so perhaps this should be unified somehow for all of them
740
735
  this.mailbox = new Mailbox(this._process.bind(this));
741
- this.status = ActorStatus.Stopped;
736
+ this._processingStatus = ProcessingStatus.Stopped;
742
737
  this.system._unregister(this);
743
738
  return this;
744
739
  }
@@ -747,7 +742,7 @@ class Actor {
747
742
  * @internal
748
743
  */
749
744
  _send(event) {
750
- if (this.status === ActorStatus.Stopped) {
745
+ if (this._processingStatus === ProcessingStatus.Stopped) {
751
746
  return;
752
747
  }
753
748
  this.mailbox.enqueue(event);
@@ -805,8 +800,8 @@ class Actor {
805
800
  id: this.id
806
801
  };
807
802
  }
808
- getPersistedState() {
809
- return this.logic.getPersistedState(this._state);
803
+ getPersistedState(options) {
804
+ return this.logic.getPersistedState(this._state, options);
810
805
  }
811
806
  [symbolObservable]() {
812
807
  return this;
@@ -856,9 +851,8 @@ const interpret = createActor;
856
851
 
857
852
  exports.$$ACTOR_TYPE = $$ACTOR_TYPE;
858
853
  exports.Actor = Actor;
859
- exports.ActorStatus = ActorStatus;
860
- exports.InterpreterStatus = InterpreterStatus;
861
854
  exports.NULL_EVENT = NULL_EVENT;
855
+ exports.ProcessingStatus = ProcessingStatus;
862
856
  exports.STATE_DELIMITER = STATE_DELIMITER;
863
857
  exports.STATE_IDENTIFIER = STATE_IDENTIFIER;
864
858
  exports.WILDCARD = WILDCARD;