xstate 5.0.0-beta.39 → 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 (45) 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 +2 -2
  8. package/actors/dist/xstate-actors.development.cjs.js +2 -2
  9. package/actors/dist/xstate-actors.development.esm.js +2 -2
  10. package/actors/dist/xstate-actors.esm.js +2 -2
  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/actors/callback.d.ts +1 -1
  16. package/dist/declarations/src/index.d.ts +2 -2
  17. package/dist/declarations/src/interpreter.d.ts +2 -10
  18. package/dist/declarations/src/system.d.ts +7 -3
  19. package/dist/declarations/src/types.d.ts +4 -9
  20. package/dist/{interpreter-1e8c1c0c.esm.js → interpreter-480db258.esm.js} +28 -33
  21. package/dist/{interpreter-03a5c3f5.development.cjs.js → interpreter-70ed981b.development.cjs.js} +28 -34
  22. package/dist/{interpreter-70cd9217.development.esm.js → interpreter-936da690.development.esm.js} +28 -33
  23. package/dist/{interpreter-5dfcd203.cjs.js → interpreter-fb2829f1.cjs.js} +28 -34
  24. package/dist/{raise-17cb3d9d.development.cjs.js → raise-5ab465ed.development.cjs.js} +9 -9
  25. package/dist/{raise-62de3670.esm.js → raise-9d6921da.esm.js} +8 -8
  26. package/dist/{raise-291d2181.cjs.js → raise-beae3fd3.cjs.js} +8 -8
  27. package/dist/{raise-e044f460.development.esm.js → raise-f757be00.development.esm.js} +9 -9
  28. package/dist/{send-1249d4ac.esm.js → send-a931d1b8.esm.js} +4 -5
  29. package/dist/{send-f1a2a827.development.esm.js → send-b26e3812.development.esm.js} +4 -5
  30. package/dist/{send-af152aca.cjs.js → send-ca5f706c.cjs.js} +4 -5
  31. package/dist/{send-33433787.development.cjs.js → send-fb87a01a.development.cjs.js} +4 -5
  32. package/dist/xstate.cjs.js +8 -10
  33. package/dist/xstate.cjs.mjs +0 -2
  34. package/dist/xstate.development.cjs.js +8 -10
  35. package/dist/xstate.development.cjs.mjs +0 -2
  36. package/dist/xstate.development.esm.js +11 -11
  37. package/dist/xstate.esm.js +11 -11
  38. package/dist/xstate.umd.min.js +1 -1
  39. package/dist/xstate.umd.min.js.map +1 -1
  40. package/guards/dist/xstate-guards.cjs.js +2 -2
  41. package/guards/dist/xstate-guards.development.cjs.js +2 -2
  42. package/guards/dist/xstate-guards.development.esm.js +2 -2
  43. package/guards/dist/xstate-guards.esm.js +2 -2
  44. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  45. package/package.json +1 -1
@@ -174,7 +174,7 @@ function createSystem(rootActor) {
174
174
  system._sendInspectionEvent({
175
175
  type: '@xstate.event',
176
176
  sourceRef: source,
177
- targetRef: target,
177
+ actorRef: target,
178
178
  event
179
179
  });
180
180
  target._send(event);
@@ -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,12 +590,14 @@ 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',
604
599
  sourceRef: this._parent,
605
- targetRef: this,
600
+ actorRef: this,
606
601
  event: initEvent
607
602
  });
608
603
  const status = this._state.status;
@@ -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;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var interpreter = require('./interpreter-03a5c3f5.development.cjs.js');
3
+ var interpreter = require('./interpreter-70ed981b.development.cjs.js');
4
4
 
5
5
  const cache = new WeakMap();
6
6
  function memo(object, key, fn) {
@@ -63,7 +63,7 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
63
63
  const configuredInput = input || referenced.input;
64
64
  actorRef = interpreter.createActor(referenced.src, {
65
65
  id: resolvedId,
66
- src: typeof src === 'string' ? src : undefined,
66
+ src,
67
67
  parent: actorScope?.self,
68
68
  systemId,
69
69
  input: typeof configuredInput === 'function' ? configuredInput({
@@ -107,7 +107,7 @@ function executeSpawn(actorScope, {
107
107
  return;
108
108
  }
109
109
  actorScope.defer(() => {
110
- if (actorRef.status === interpreter.ActorStatus.Stopped) {
110
+ if (actorRef._processingStatus === interpreter.ProcessingStatus.Stopped) {
111
111
  return;
112
112
  }
113
113
  try {
@@ -168,7 +168,7 @@ function executeStop(actorScope, actorRef) {
168
168
 
169
169
  // this allows us to prevent an actor from being started if it gets stopped within the same macrostep
170
170
  // this can happen, for example, when the invoking state is being exited immediately by an always transition
171
- if (actorRef.status !== interpreter.ActorStatus.Running) {
171
+ if (actorRef._processingStatus !== interpreter.ProcessingStatus.Running) {
172
172
  actorScope.stopChild(actorRef);
173
173
  return;
174
174
  }
@@ -1129,7 +1129,7 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
1129
1129
  event
1130
1130
  }) : action.params : undefined;
1131
1131
  if (!('resolve' in resolvedAction)) {
1132
- if (actorScope?.self.status === interpreter.ActorStatus.Running) {
1132
+ if (actorScope?.self._processingStatus === interpreter.ProcessingStatus.Running) {
1133
1133
  resolvedAction(actionArgs, actionParams);
1134
1134
  } else {
1135
1135
  actorScope?.defer(() => {
@@ -1147,7 +1147,7 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
1147
1147
  retries?.push([builtinAction, params]);
1148
1148
  }
1149
1149
  if ('execute' in builtinAction) {
1150
- if (actorScope?.self.status === interpreter.ActorStatus.Running) {
1150
+ if (actorScope?.self._processingStatus === interpreter.ProcessingStatus.Running) {
1151
1151
  builtinAction.execute(actorScope, params);
1152
1152
  } else {
1153
1153
  actorScope?.defer(builtinAction.execute.bind(null, actorScope, params));
@@ -1428,7 +1428,7 @@ function cloneState(state, config = {}) {
1428
1428
  ...config
1429
1429
  }, state.machine);
1430
1430
  }
1431
- function getPersistedState(state) {
1431
+ function getPersistedState(state, options) {
1432
1432
  const {
1433
1433
  configuration,
1434
1434
  tags,
@@ -1440,11 +1440,11 @@ function getPersistedState(state) {
1440
1440
  const childrenJson = {};
1441
1441
  for (const id in children) {
1442
1442
  const child = children[id];
1443
- if (typeof child.src !== 'string') {
1443
+ if (typeof child.src !== 'string' && (!options || !('__unsafeAllowInlineActors' in options))) {
1444
1444
  throw new Error('An inline child actor cannot be persisted.');
1445
1445
  }
1446
1446
  childrenJson[id] = {
1447
- state: child.getPersistedState(),
1447
+ state: child.getPersistedState(options),
1448
1448
  src: child.src,
1449
1449
  systemId: child._systemId
1450
1450
  };
@@ -1,4 +1,4 @@
1
- import { r as resolveReferencedActor, d as createActor, f as ActorStatus, j as createErrorActorEvent, k as toStateValue, l as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, o as toStatePath, q as createDoneStateEvent, s as resolveOutput, X as XSTATE_STOP, u as XSTATE_INIT, W as WILDCARD, v as createAfterEvent, w as flatten, e as matchesState, $ as $$ACTOR_TYPE } from './interpreter-1e8c1c0c.esm.js';
1
+ import { r as resolveReferencedActor, d as createActor, P as ProcessingStatus, h as createErrorActorEvent, j as toStateValue, k as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, l as toStatePath, o as createDoneStateEvent, q as resolveOutput, X as XSTATE_STOP, s as XSTATE_INIT, W as WILDCARD, u as createAfterEvent, v as flatten, e as matchesState, $ as $$ACTOR_TYPE } from './interpreter-480db258.esm.js';
2
2
 
3
3
  const cache = new WeakMap();
4
4
  function memo(object, key, fn) {
@@ -58,7 +58,7 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
58
58
  const configuredInput = input || referenced.input;
59
59
  actorRef = createActor(referenced.src, {
60
60
  id: resolvedId,
61
- src: typeof src === 'string' ? src : undefined,
61
+ src,
62
62
  parent: actorScope?.self,
63
63
  systemId,
64
64
  input: typeof configuredInput === 'function' ? configuredInput({
@@ -99,7 +99,7 @@ function executeSpawn(actorScope, {
99
99
  return;
100
100
  }
101
101
  actorScope.defer(() => {
102
- if (actorRef.status === ActorStatus.Stopped) {
102
+ if (actorRef._processingStatus === ProcessingStatus.Stopped) {
103
103
  return;
104
104
  }
105
105
  try {
@@ -157,7 +157,7 @@ function executeStop(actorScope, actorRef) {
157
157
 
158
158
  // this allows us to prevent an actor from being started if it gets stopped within the same macrostep
159
159
  // this can happen, for example, when the invoking state is being exited immediately by an always transition
160
- if (actorRef.status !== ActorStatus.Running) {
160
+ if (actorRef._processingStatus !== ProcessingStatus.Running) {
161
161
  actorScope.stopChild(actorRef);
162
162
  return;
163
163
  }
@@ -1096,7 +1096,7 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
1096
1096
  event
1097
1097
  }) : action.params : undefined;
1098
1098
  if (!('resolve' in resolvedAction)) {
1099
- if (actorScope?.self.status === ActorStatus.Running) {
1099
+ if (actorScope?.self._processingStatus === ProcessingStatus.Running) {
1100
1100
  resolvedAction(actionArgs, actionParams);
1101
1101
  } else {
1102
1102
  actorScope?.defer(() => {
@@ -1114,7 +1114,7 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
1114
1114
  retries?.push([builtinAction, params]);
1115
1115
  }
1116
1116
  if ('execute' in builtinAction) {
1117
- if (actorScope?.self.status === ActorStatus.Running) {
1117
+ if (actorScope?.self._processingStatus === ProcessingStatus.Running) {
1118
1118
  builtinAction.execute(actorScope, params);
1119
1119
  } else {
1120
1120
  actorScope?.defer(builtinAction.execute.bind(null, actorScope, params));
@@ -1389,7 +1389,7 @@ function cloneState(state, config = {}) {
1389
1389
  ...config
1390
1390
  }, state.machine);
1391
1391
  }
1392
- function getPersistedState(state) {
1392
+ function getPersistedState(state, options) {
1393
1393
  const {
1394
1394
  configuration,
1395
1395
  tags,
@@ -1402,7 +1402,7 @@ function getPersistedState(state) {
1402
1402
  for (const id in children) {
1403
1403
  const child = children[id];
1404
1404
  childrenJson[id] = {
1405
- state: child.getPersistedState(),
1405
+ state: child.getPersistedState(options),
1406
1406
  src: child.src,
1407
1407
  systemId: child._systemId
1408
1408
  };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var interpreter = require('./interpreter-5dfcd203.cjs.js');
3
+ var interpreter = require('./interpreter-fb2829f1.cjs.js');
4
4
 
5
5
  const cache = new WeakMap();
6
6
  function memo(object, key, fn) {
@@ -60,7 +60,7 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
60
60
  const configuredInput = input || referenced.input;
61
61
  actorRef = interpreter.createActor(referenced.src, {
62
62
  id: resolvedId,
63
- src: typeof src === 'string' ? src : undefined,
63
+ src,
64
64
  parent: actorScope?.self,
65
65
  systemId,
66
66
  input: typeof configuredInput === 'function' ? configuredInput({
@@ -101,7 +101,7 @@ function executeSpawn(actorScope, {
101
101
  return;
102
102
  }
103
103
  actorScope.defer(() => {
104
- if (actorRef.status === interpreter.ActorStatus.Stopped) {
104
+ if (actorRef._processingStatus === interpreter.ProcessingStatus.Stopped) {
105
105
  return;
106
106
  }
107
107
  try {
@@ -159,7 +159,7 @@ function executeStop(actorScope, actorRef) {
159
159
 
160
160
  // this allows us to prevent an actor from being started if it gets stopped within the same macrostep
161
161
  // this can happen, for example, when the invoking state is being exited immediately by an always transition
162
- if (actorRef.status !== interpreter.ActorStatus.Running) {
162
+ if (actorRef._processingStatus !== interpreter.ProcessingStatus.Running) {
163
163
  actorScope.stopChild(actorRef);
164
164
  return;
165
165
  }
@@ -1098,7 +1098,7 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
1098
1098
  event
1099
1099
  }) : action.params : undefined;
1100
1100
  if (!('resolve' in resolvedAction)) {
1101
- if (actorScope?.self.status === interpreter.ActorStatus.Running) {
1101
+ if (actorScope?.self._processingStatus === interpreter.ProcessingStatus.Running) {
1102
1102
  resolvedAction(actionArgs, actionParams);
1103
1103
  } else {
1104
1104
  actorScope?.defer(() => {
@@ -1116,7 +1116,7 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
1116
1116
  retries?.push([builtinAction, params]);
1117
1117
  }
1118
1118
  if ('execute' in builtinAction) {
1119
- if (actorScope?.self.status === interpreter.ActorStatus.Running) {
1119
+ if (actorScope?.self._processingStatus === interpreter.ProcessingStatus.Running) {
1120
1120
  builtinAction.execute(actorScope, params);
1121
1121
  } else {
1122
1122
  actorScope?.defer(builtinAction.execute.bind(null, actorScope, params));
@@ -1391,7 +1391,7 @@ function cloneState(state, config = {}) {
1391
1391
  ...config
1392
1392
  }, state.machine);
1393
1393
  }
1394
- function getPersistedState(state) {
1394
+ function getPersistedState(state, options) {
1395
1395
  const {
1396
1396
  configuration,
1397
1397
  tags,
@@ -1404,7 +1404,7 @@ function getPersistedState(state) {
1404
1404
  for (const id in children) {
1405
1405
  const child = children[id];
1406
1406
  childrenJson[id] = {
1407
- state: child.getPersistedState(),
1407
+ state: child.getPersistedState(options),
1408
1408
  src: child.src,
1409
1409
  systemId: child._systemId
1410
1410
  };
@@ -1,4 +1,4 @@
1
- import { r as resolveReferencedActor, d as createActor, f as ActorStatus, j as createErrorActorEvent, k as toStateValue, l as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, o as toStatePath, q as createDoneStateEvent, s as resolveOutput, W as WILDCARD, X as XSTATE_STOP, u as XSTATE_INIT, v as createAfterEvent, w as flatten, e as matchesState, $ as $$ACTOR_TYPE } from './interpreter-70cd9217.development.esm.js';
1
+ import { r as resolveReferencedActor, d as createActor, P as ProcessingStatus, h as createErrorActorEvent, j as toStateValue, k as STATE_IDENTIFIER, n as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, l as toStatePath, o as createDoneStateEvent, q as resolveOutput, W as WILDCARD, X as XSTATE_STOP, s as XSTATE_INIT, u as createAfterEvent, v as flatten, e as matchesState, $ as $$ACTOR_TYPE } from './interpreter-936da690.development.esm.js';
2
2
 
3
3
  const cache = new WeakMap();
4
4
  function memo(object, key, fn) {
@@ -61,7 +61,7 @@ function resolveSpawn(actorScope, state, actionArgs, _actionParams, {
61
61
  const configuredInput = input || referenced.input;
62
62
  actorRef = createActor(referenced.src, {
63
63
  id: resolvedId,
64
- src: typeof src === 'string' ? src : undefined,
64
+ src,
65
65
  parent: actorScope?.self,
66
66
  systemId,
67
67
  input: typeof configuredInput === 'function' ? configuredInput({
@@ -105,7 +105,7 @@ function executeSpawn(actorScope, {
105
105
  return;
106
106
  }
107
107
  actorScope.defer(() => {
108
- if (actorRef.status === ActorStatus.Stopped) {
108
+ if (actorRef._processingStatus === ProcessingStatus.Stopped) {
109
109
  return;
110
110
  }
111
111
  try {
@@ -166,7 +166,7 @@ function executeStop(actorScope, actorRef) {
166
166
 
167
167
  // this allows us to prevent an actor from being started if it gets stopped within the same macrostep
168
168
  // this can happen, for example, when the invoking state is being exited immediately by an always transition
169
- if (actorRef.status !== ActorStatus.Running) {
169
+ if (actorRef._processingStatus !== ProcessingStatus.Running) {
170
170
  actorScope.stopChild(actorRef);
171
171
  return;
172
172
  }
@@ -1127,7 +1127,7 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
1127
1127
  event
1128
1128
  }) : action.params : undefined;
1129
1129
  if (!('resolve' in resolvedAction)) {
1130
- if (actorScope?.self.status === ActorStatus.Running) {
1130
+ if (actorScope?.self._processingStatus === ProcessingStatus.Running) {
1131
1131
  resolvedAction(actionArgs, actionParams);
1132
1132
  } else {
1133
1133
  actorScope?.defer(() => {
@@ -1145,7 +1145,7 @@ function resolveActionsAndContextWorker(currentState, event, actorScope, actions
1145
1145
  retries?.push([builtinAction, params]);
1146
1146
  }
1147
1147
  if ('execute' in builtinAction) {
1148
- if (actorScope?.self.status === ActorStatus.Running) {
1148
+ if (actorScope?.self._processingStatus === ProcessingStatus.Running) {
1149
1149
  builtinAction.execute(actorScope, params);
1150
1150
  } else {
1151
1151
  actorScope?.defer(builtinAction.execute.bind(null, actorScope, params));
@@ -1426,7 +1426,7 @@ function cloneState(state, config = {}) {
1426
1426
  ...config
1427
1427
  }, state.machine);
1428
1428
  }
1429
- function getPersistedState(state) {
1429
+ function getPersistedState(state, options) {
1430
1430
  const {
1431
1431
  configuration,
1432
1432
  tags,
@@ -1438,11 +1438,11 @@ function getPersistedState(state) {
1438
1438
  const childrenJson = {};
1439
1439
  for (const id in children) {
1440
1440
  const child = children[id];
1441
- if (typeof child.src !== 'string') {
1441
+ if (typeof child.src !== 'string' && (!options || !('__unsafeAllowInlineActors' in options))) {
1442
1442
  throw new Error('An inline child actor cannot be persisted.');
1443
1443
  }
1444
1444
  childrenJson[id] = {
1445
- state: child.getPersistedState(),
1445
+ state: child.getPersistedState(options),
1446
1446
  src: child.src,
1447
1447
  systemId: child._systemId
1448
1448
  };
@@ -1,5 +1,5 @@
1
- import { j as cloneState, e as evaluateGuard } from './raise-62de3670.esm.js';
2
- import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-1e8c1c0c.esm.js';
1
+ import { j as cloneState, e as evaluateGuard } from './raise-9d6921da.esm.js';
2
+ import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, w as XSTATE_ERROR } from './interpreter-480db258.esm.js';
3
3
 
4
4
  function createSpawner(actorScope, {
5
5
  machine,
@@ -44,12 +44,11 @@ function createSpawner(actorScope, {
44
44
  }
45
45
  return actorRef;
46
46
  } else {
47
- // TODO: this should also receive `src`
48
47
  const actorRef = createActor(src, {
49
48
  id: options.id,
50
49
  parent: actorScope.self,
51
50
  input: options.input,
52
- src: undefined,
51
+ src,
53
52
  systemId
54
53
  });
55
54
  if (options.syncSnapshot) {
@@ -73,7 +72,7 @@ function createSpawner(actorScope, {
73
72
  const actorRef = spawn(src, options); // TODO: fix types
74
73
  spawnedChildren[actorRef.id] = actorRef;
75
74
  actorScope.defer(() => {
76
- if (actorRef.status === ActorStatus.Stopped) {
75
+ if (actorRef._processingStatus === ProcessingStatus.Stopped) {
77
76
  return;
78
77
  }
79
78
  try {
@@ -1,5 +1,5 @@
1
- import { j as cloneState, e as evaluateGuard } from './raise-e044f460.development.esm.js';
2
- import { f as ActorStatus, j as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, x as XSTATE_ERROR } from './interpreter-70cd9217.development.esm.js';
1
+ import { j as cloneState, e as evaluateGuard } from './raise-f757be00.development.esm.js';
2
+ import { P as ProcessingStatus, h as createErrorActorEvent, r as resolveReferencedActor, d as createActor, t as toArray, w as XSTATE_ERROR } from './interpreter-936da690.development.esm.js';
3
3
 
4
4
  function createSpawner(actorScope, {
5
5
  machine,
@@ -44,12 +44,11 @@ function createSpawner(actorScope, {
44
44
  }
45
45
  return actorRef;
46
46
  } else {
47
- // TODO: this should also receive `src`
48
47
  const actorRef = createActor(src, {
49
48
  id: options.id,
50
49
  parent: actorScope.self,
51
50
  input: options.input,
52
- src: undefined,
51
+ src,
53
52
  systemId
54
53
  });
55
54
  if (options.syncSnapshot) {
@@ -73,7 +72,7 @@ function createSpawner(actorScope, {
73
72
  const actorRef = spawn(src, options); // TODO: fix types
74
73
  spawnedChildren[actorRef.id] = actorRef;
75
74
  actorScope.defer(() => {
76
- if (actorRef.status === ActorStatus.Stopped) {
75
+ if (actorRef._processingStatus === ProcessingStatus.Stopped) {
77
76
  return;
78
77
  }
79
78
  try {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-291d2181.cjs.js');
4
- var interpreter = require('./interpreter-5dfcd203.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-beae3fd3.cjs.js');
4
+ var interpreter = require('./interpreter-fb2829f1.cjs.js');
5
5
 
6
6
  function createSpawner(actorScope, {
7
7
  machine,
@@ -46,12 +46,11 @@ function createSpawner(actorScope, {
46
46
  }
47
47
  return actorRef;
48
48
  } else {
49
- // TODO: this should also receive `src`
50
49
  const actorRef = interpreter.createActor(src, {
51
50
  id: options.id,
52
51
  parent: actorScope.self,
53
52
  input: options.input,
54
- src: undefined,
53
+ src,
55
54
  systemId
56
55
  });
57
56
  if (options.syncSnapshot) {
@@ -75,7 +74,7 @@ function createSpawner(actorScope, {
75
74
  const actorRef = spawn(src, options); // TODO: fix types
76
75
  spawnedChildren[actorRef.id] = actorRef;
77
76
  actorScope.defer(() => {
78
- if (actorRef.status === interpreter.ActorStatus.Stopped) {
77
+ if (actorRef._processingStatus === interpreter.ProcessingStatus.Stopped) {
79
78
  return;
80
79
  }
81
80
  try {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var guards_dist_xstateGuards = require('./raise-17cb3d9d.development.cjs.js');
4
- var interpreter = require('./interpreter-03a5c3f5.development.cjs.js');
3
+ var guards_dist_xstateGuards = require('./raise-5ab465ed.development.cjs.js');
4
+ var interpreter = require('./interpreter-70ed981b.development.cjs.js');
5
5
 
6
6
  function createSpawner(actorScope, {
7
7
  machine,
@@ -46,12 +46,11 @@ function createSpawner(actorScope, {
46
46
  }
47
47
  return actorRef;
48
48
  } else {
49
- // TODO: this should also receive `src`
50
49
  const actorRef = interpreter.createActor(src, {
51
50
  id: options.id,
52
51
  parent: actorScope.self,
53
52
  input: options.input,
54
- src: undefined,
53
+ src,
55
54
  systemId
56
55
  });
57
56
  if (options.syncSnapshot) {
@@ -75,7 +74,7 @@ function createSpawner(actorScope, {
75
74
  const actorRef = spawn(src, options); // TODO: fix types
76
75
  spawnedChildren[actorRef.id] = actorRef;
77
76
  actorScope.defer(() => {
78
- if (actorRef.status === interpreter.ActorStatus.Stopped) {
77
+ if (actorRef._processingStatus === interpreter.ProcessingStatus.Stopped) {
79
78
  return;
80
79
  }
81
80
  try {
@@ -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-5dfcd203.cjs.js');
7
- var guards_dist_xstateGuards = require('./raise-291d2181.cjs.js');
8
- var send = require('./send-af152aca.cjs.js');
6
+ var interpreter = require('./interpreter-fb2829f1.cjs.js');
7
+ var guards_dist_xstateGuards = require('./raise-beae3fd3.cjs.js');
8
+ var send = require('./send-ca5f706c.cjs.js');
9
9
  require('../dev/dist/xstate-dev.cjs.js');
10
10
 
11
11
  class SimulatedClock {
@@ -403,7 +403,6 @@ class StateMachine {
403
403
  this.getInitialState = this.getInitialState.bind(this);
404
404
  this.restoreState = this.restoreState.bind(this);
405
405
  this.start = this.start.bind(this);
406
- this.getPersistedState = this.getPersistedState.bind(this);
407
406
  this.root = new StateNode(config, {
408
407
  _key: this.id,
409
408
  _machine: this
@@ -579,8 +578,8 @@ class StateMachine {
579
578
  toJSON() {
580
579
  return this.definition;
581
580
  }
582
- getPersistedState(state) {
583
- return guards_dist_xstateGuards.getPersistedState(state);
581
+ getPersistedState(state, options) {
582
+ return guards_dist_xstateGuards.getPersistedState(state, options);
584
583
  }
585
584
  createState(stateConfig) {
586
585
  return stateConfig instanceof guards_dist_xstateGuards.State ? stateConfig : new guards_dist_xstateGuards.State(stateConfig, this);
@@ -592,7 +591,7 @@ class StateMachine {
592
591
  const actorData = snapshotChildren[actorId];
593
592
  const childState = actorData.state;
594
593
  const src = actorData.src;
595
- const logic = src ? interpreter.resolveReferencedActor(this, src)?.src : undefined;
594
+ const logic = typeof src === 'string' ? interpreter.resolveReferencedActor(this, src)?.src : src;
596
595
  if (!logic) {
597
596
  return;
598
597
  }
@@ -601,6 +600,7 @@ class StateMachine {
601
600
  id: actorId,
602
601
  parent: _actorScope?.self,
603
602
  state: actorState,
603
+ src,
604
604
  systemId: actorData.systemId
605
605
  });
606
606
  children[actorId] = actorRef;
@@ -634,7 +634,7 @@ class StateMachine {
634
634
  }
635
635
 
636
636
  const defaultWaitForOptions = {
637
- timeout: 10_000 // 10 seconds
637
+ timeout: Infinity // much more than 10 seconds
638
638
  };
639
639
 
640
640
  /**
@@ -725,8 +725,6 @@ exports.fromObservable = actors_dist_xstateActors.fromObservable;
725
725
  exports.fromPromise = actors_dist_xstateActors.fromPromise;
726
726
  exports.fromTransition = actors_dist_xstateActors.fromTransition;
727
727
  exports.Actor = interpreter.Actor;
728
- exports.ActorStatus = interpreter.ActorStatus;
729
- exports.InterpreterStatus = interpreter.InterpreterStatus;
730
728
  exports.createActor = interpreter.createActor;
731
729
  exports.interpret = interpreter.interpret;
732
730
  exports.matchesState = interpreter.matchesState;
@@ -1,7 +1,5 @@
1
1
  export {
2
2
  Actor,
3
- ActorStatus,
4
- InterpreterStatus,
5
3
  SimulatedClock,
6
4
  SpecialTargets,
7
5
  State,