xstate 5.0.0-beta.29 → 5.0.0-beta.31

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 (52) 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 +100 -104
  8. package/actors/dist/xstate-actors.development.cjs.js +100 -104
  9. package/actors/dist/xstate-actors.development.esm.js +100 -104
  10. package/actors/dist/xstate-actors.esm.js +100 -104
  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/Machine.d.ts +2 -2
  14. package/dist/declarations/src/State.d.ts +4 -6
  15. package/dist/declarations/src/StateMachine.d.ts +28 -21
  16. package/dist/declarations/src/StateNode.d.ts +3 -3
  17. package/dist/declarations/src/actions/stop.d.ts +1 -1
  18. package/dist/declarations/src/actors/callback.d.ts +8 -8
  19. package/dist/declarations/src/actors/index.d.ts +3 -3
  20. package/dist/declarations/src/actors/observable.d.ts +12 -13
  21. package/dist/declarations/src/actors/promise.d.ts +11 -14
  22. package/dist/declarations/src/actors/transition.d.ts +10 -7
  23. package/dist/declarations/src/index.d.ts +1 -1
  24. package/dist/declarations/src/interpreter.d.ts +4 -4
  25. package/dist/declarations/src/spawn.d.ts +3 -0
  26. package/dist/declarations/src/stateUtils.d.ts +5 -6
  27. package/dist/declarations/src/types.d.ts +74 -69
  28. package/dist/declarations/src/utils.d.ts +4 -4
  29. package/dist/{interpreter-c357bc50.cjs.js → interpreter-05e11c15.cjs.js} +11 -13
  30. package/dist/{interpreter-e2c6a579.development.cjs.js → interpreter-a2236840.development.cjs.js} +12 -14
  31. package/dist/{interpreter-498891b2.esm.js → interpreter-d5fa7ce0.esm.js} +11 -13
  32. package/dist/{interpreter-6e7909c8.development.esm.js → interpreter-e4d2487f.development.esm.js} +12 -14
  33. package/dist/{raise-59f2c242.esm.js → raise-6a68d0cc.esm.js} +61 -32
  34. package/dist/{raise-e778a828.development.esm.js → raise-6fbd4513.development.esm.js} +61 -32
  35. package/dist/{raise-03e57569.cjs.js → raise-90808d65.cjs.js} +61 -32
  36. package/dist/{raise-f751dfac.development.cjs.js → raise-b4bfe138.development.cjs.js} +61 -32
  37. package/dist/{send-f53778f6.development.cjs.js → send-4163d2af.development.cjs.js} +52 -20
  38. package/dist/{send-51717e53.cjs.js → send-72e85cc6.cjs.js} +52 -20
  39. package/dist/{send-42c83fb2.development.esm.js → send-7baeedcb.development.esm.js} +52 -20
  40. package/dist/{send-fff224db.esm.js → send-e5f0f3f6.esm.js} +52 -20
  41. package/dist/xstate.cjs.js +15 -24
  42. package/dist/xstate.development.cjs.js +18 -24
  43. package/dist/xstate.development.esm.js +21 -27
  44. package/dist/xstate.esm.js +18 -27
  45. package/dist/xstate.umd.min.js +1 -1
  46. package/dist/xstate.umd.min.js.map +1 -1
  47. package/guards/dist/xstate-guards.cjs.js +2 -2
  48. package/guards/dist/xstate-guards.development.cjs.js +2 -2
  49. package/guards/dist/xstate-guards.development.esm.js +2 -2
  50. package/guards/dist/xstate-guards.esm.js +2 -2
  51. package/guards/dist/xstate-guards.umd.min.js.map +1 -1
  52. package/package.json +1 -1
@@ -271,7 +271,7 @@ function toArray(value) {
271
271
  }
272
272
  return toArrayStrict(value);
273
273
  }
274
- function mapContext(mapper, context, event, self) {
274
+ function resolveOutput(mapper, context, event, self) {
275
275
  if (typeof mapper === 'function') {
276
276
  return mapper({
277
277
  context,
@@ -279,7 +279,7 @@ function mapContext(mapper, context, event, self) {
279
279
  self
280
280
  });
281
281
  }
282
- if (typeof mapper === 'object' && Object.values(mapper).some(val => typeof val === 'function')) {
282
+ if (!!mapper && typeof mapper === 'object' && Object.values(mapper).some(val => typeof val === 'function')) {
283
283
  console.warn(`Dynamically mapping values to individual properties is deprecated. Use a single function that returns the mapped object instead.\nFound object containing properties whose values are possibly mapping functions: ${Object.entries(mapper).filter(([key, value]) => typeof value === 'function').map(([key, value]) => `\n - ${key}: ${value.toString().replace(/\n\s*/g, '')}`).join('')}`);
284
284
  }
285
285
  return mapper;
@@ -452,10 +452,9 @@ class Actor {
452
452
 
453
453
  // array of functions to defer
454
454
 
455
- update(state) {
455
+ update(snapshot) {
456
456
  // Update state
457
- this._state = state;
458
- const snapshot = this.getSnapshot();
457
+ this._state = snapshot;
459
458
 
460
459
  // Execute deferred effects
461
460
  let deferredFn;
@@ -470,18 +469,17 @@ class Actor {
470
469
  reportUnhandledError(err);
471
470
  }
472
471
  }
473
- const status = this.logic.getStatus?.(state);
474
- switch (status?.status) {
472
+ switch (this._state.status) {
475
473
  case 'done':
476
474
  this._stopProcedure();
477
475
  this._complete();
478
- this._doneEvent = createDoneActorEvent(this.id, status.data);
476
+ this._doneEvent = createDoneActorEvent(this.id, this._state.output);
479
477
  this._parent?.send(this._doneEvent);
480
478
  break;
481
479
  case 'error':
482
480
  this._stopProcedure();
483
- this._error(status.data);
484
- this._parent?.send(createErrorActorEvent(this.id, status.data));
481
+ this._error(this._state.error);
482
+ this._parent?.send(createErrorActorEvent(this.id, this._state.error));
485
483
  break;
486
484
  }
487
485
  }
@@ -516,8 +514,8 @@ class Actor {
516
514
  this.system._set(this._systemId, this);
517
515
  }
518
516
  this.status = ActorStatus.Running;
519
- const status = this.logic.getStatus?.(this._state);
520
- switch (status?.status) {
517
+ const status = this._state.status;
518
+ switch (status) {
521
519
  case 'done':
522
520
  // a state machine can be "done" upon intialization (it could reach a final state using initial microsteps)
523
521
  // we still need to complete observers, flush deferreds etc
@@ -721,7 +719,7 @@ class Actor {
721
719
  return this;
722
720
  }
723
721
  getSnapshot() {
724
- return this.logic.getSnapshot ? this.logic.getSnapshot(this._state) : this._state;
722
+ return this._state;
725
723
  }
726
724
  }
727
725
 
@@ -768,11 +766,11 @@ exports.flatten = flatten;
768
766
  exports.interpret = interpret;
769
767
  exports.isArray = isArray;
770
768
  exports.isErrorActorEvent = isErrorActorEvent;
771
- exports.mapContext = mapContext;
772
769
  exports.mapValues = mapValues;
773
770
  exports.matchesState = matchesState;
774
771
  exports.normalizeTarget = normalizeTarget;
775
772
  exports.pathToStateValue = pathToStateValue;
773
+ exports.resolveOutput = resolveOutput;
776
774
  exports.resolveReferencedActor = resolveReferencedActor;
777
775
  exports.toArray = toArray;
778
776
  exports.toObserver = toObserver;
@@ -269,7 +269,7 @@ function toArray(value) {
269
269
  }
270
270
  return toArrayStrict(value);
271
271
  }
272
- function mapContext(mapper, context, event, self) {
272
+ function resolveOutput(mapper, context, event, self) {
273
273
  if (typeof mapper === 'function') {
274
274
  return mapper({
275
275
  context,
@@ -447,10 +447,9 @@ class Actor {
447
447
 
448
448
  // array of functions to defer
449
449
 
450
- update(state) {
450
+ update(snapshot) {
451
451
  // Update state
452
- this._state = state;
453
- const snapshot = this.getSnapshot();
452
+ this._state = snapshot;
454
453
 
455
454
  // Execute deferred effects
456
455
  let deferredFn;
@@ -465,18 +464,17 @@ class Actor {
465
464
  reportUnhandledError(err);
466
465
  }
467
466
  }
468
- const status = this.logic.getStatus?.(state);
469
- switch (status?.status) {
467
+ switch (this._state.status) {
470
468
  case 'done':
471
469
  this._stopProcedure();
472
470
  this._complete();
473
- this._doneEvent = createDoneActorEvent(this.id, status.data);
471
+ this._doneEvent = createDoneActorEvent(this.id, this._state.output);
474
472
  this._parent?.send(this._doneEvent);
475
473
  break;
476
474
  case 'error':
477
475
  this._stopProcedure();
478
- this._error(status.data);
479
- this._parent?.send(createErrorActorEvent(this.id, status.data));
476
+ this._error(this._state.error);
477
+ this._parent?.send(createErrorActorEvent(this.id, this._state.error));
480
478
  break;
481
479
  }
482
480
  }
@@ -511,8 +509,8 @@ class Actor {
511
509
  this.system._set(this._systemId, this);
512
510
  }
513
511
  this.status = ActorStatus.Running;
514
- const status = this.logic.getStatus?.(this._state);
515
- switch (status?.status) {
512
+ const status = this._state.status;
513
+ switch (status) {
516
514
  case 'done':
517
515
  // a state machine can be "done" upon intialization (it could reach a final state using initial microsteps)
518
516
  // we still need to complete observers, flush deferreds etc
@@ -711,7 +709,7 @@ class Actor {
711
709
  return this;
712
710
  }
713
711
  getSnapshot() {
714
- return this.logic.getSnapshot ? this.logic.getSnapshot(this._state) : this._state;
712
+ return this._state;
715
713
  }
716
714
  }
717
715
 
@@ -738,4 +736,4 @@ const interpret = createActor;
738
736
  * @deprecated Use `Actor` instead.
739
737
  */
740
738
 
741
- export { Actor as A, InterpreterStatus as I, NULL_EVENT as N, STATE_DELIMITER as S, WILDCARD as W, XSTATE_INIT 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, XSTATE_STOP as j, createErrorActorEvent as k, toStateValue as l, mapValues as m, STATE_IDENTIFIER as n, normalizeTarget as o, pathToStateValue as p, toStatePath as q, resolveReferencedActor as r, createDoneStateEvent as s, toArray as t, mapContext as u, isArray as v, createAfterEvent as w, flatten as x, XSTATE_ERROR as y };
739
+ export { Actor as A, InterpreterStatus as I, NULL_EVENT as N, STATE_DELIMITER as S, WILDCARD as W, XSTATE_INIT 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, XSTATE_STOP as j, createErrorActorEvent as k, toStateValue as l, mapValues as m, STATE_IDENTIFIER as n, normalizeTarget as o, pathToStateValue as p, toStatePath as q, resolveReferencedActor as r, createDoneStateEvent as s, toArray as t, resolveOutput as u, isArray as v, createAfterEvent as w, flatten as x, XSTATE_ERROR as y };
@@ -269,7 +269,7 @@ function toArray(value) {
269
269
  }
270
270
  return toArrayStrict(value);
271
271
  }
272
- function mapContext(mapper, context, event, self) {
272
+ function resolveOutput(mapper, context, event, self) {
273
273
  if (typeof mapper === 'function') {
274
274
  return mapper({
275
275
  context,
@@ -277,7 +277,7 @@ function mapContext(mapper, context, event, self) {
277
277
  self
278
278
  });
279
279
  }
280
- if (typeof mapper === 'object' && Object.values(mapper).some(val => typeof val === 'function')) {
280
+ if (!!mapper && typeof mapper === 'object' && Object.values(mapper).some(val => typeof val === 'function')) {
281
281
  console.warn(`Dynamically mapping values to individual properties is deprecated. Use a single function that returns the mapped object instead.\nFound object containing properties whose values are possibly mapping functions: ${Object.entries(mapper).filter(([key, value]) => typeof value === 'function').map(([key, value]) => `\n - ${key}: ${value.toString().replace(/\n\s*/g, '')}`).join('')}`);
282
282
  }
283
283
  return mapper;
@@ -450,10 +450,9 @@ class Actor {
450
450
 
451
451
  // array of functions to defer
452
452
 
453
- update(state) {
453
+ update(snapshot) {
454
454
  // Update state
455
- this._state = state;
456
- const snapshot = this.getSnapshot();
455
+ this._state = snapshot;
457
456
 
458
457
  // Execute deferred effects
459
458
  let deferredFn;
@@ -468,18 +467,17 @@ class Actor {
468
467
  reportUnhandledError(err);
469
468
  }
470
469
  }
471
- const status = this.logic.getStatus?.(state);
472
- switch (status?.status) {
470
+ switch (this._state.status) {
473
471
  case 'done':
474
472
  this._stopProcedure();
475
473
  this._complete();
476
- this._doneEvent = createDoneActorEvent(this.id, status.data);
474
+ this._doneEvent = createDoneActorEvent(this.id, this._state.output);
477
475
  this._parent?.send(this._doneEvent);
478
476
  break;
479
477
  case 'error':
480
478
  this._stopProcedure();
481
- this._error(status.data);
482
- this._parent?.send(createErrorActorEvent(this.id, status.data));
479
+ this._error(this._state.error);
480
+ this._parent?.send(createErrorActorEvent(this.id, this._state.error));
483
481
  break;
484
482
  }
485
483
  }
@@ -514,8 +512,8 @@ class Actor {
514
512
  this.system._set(this._systemId, this);
515
513
  }
516
514
  this.status = ActorStatus.Running;
517
- const status = this.logic.getStatus?.(this._state);
518
- switch (status?.status) {
515
+ const status = this._state.status;
516
+ switch (status) {
519
517
  case 'done':
520
518
  // a state machine can be "done" upon intialization (it could reach a final state using initial microsteps)
521
519
  // we still need to complete observers, flush deferreds etc
@@ -719,7 +717,7 @@ class Actor {
719
717
  return this;
720
718
  }
721
719
  getSnapshot() {
722
- return this.logic.getSnapshot ? this.logic.getSnapshot(this._state) : this._state;
720
+ return this._state;
723
721
  }
724
722
  }
725
723
 
@@ -746,4 +744,4 @@ const interpret = createActor;
746
744
  * @deprecated Use `Actor` instead.
747
745
  */
748
746
 
749
- export { Actor as A, InterpreterStatus as I, NULL_EVENT as N, STATE_DELIMITER as S, WILDCARD as W, XSTATE_INIT 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, XSTATE_STOP as j, createErrorActorEvent as k, toStateValue as l, mapValues as m, STATE_IDENTIFIER as n, normalizeTarget as o, pathToStateValue as p, toStatePath as q, resolveReferencedActor as r, createDoneStateEvent as s, toArray as t, mapContext as u, isArray as v, createAfterEvent as w, flatten as x, XSTATE_ERROR as y };
747
+ export { Actor as A, InterpreterStatus as I, NULL_EVENT as N, STATE_DELIMITER as S, WILDCARD as W, XSTATE_INIT 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, XSTATE_STOP as j, createErrorActorEvent as k, toStateValue as l, mapValues as m, STATE_IDENTIFIER as n, normalizeTarget as o, pathToStateValue as p, toStatePath as q, resolveReferencedActor as r, createDoneStateEvent as s, toArray as t, resolveOutput as u, isArray as v, createAfterEvent as w, flatten as x, XSTATE_ERROR as y };
@@ -1,4 +1,4 @@
1
- import { r as resolveReferencedActor, d as createActor, f as ActorStatus, k as createErrorActorEvent, l as toStateValue, n as STATE_IDENTIFIER, o as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, q as toStatePath, s as createDoneStateEvent, u as mapContext, j as XSTATE_STOP, X as XSTATE_INIT, W as WILDCARD, v as isArray, w as createAfterEvent, x as flatten, e as matchesState } from './interpreter-498891b2.esm.js';
1
+ import { r as resolveReferencedActor, d as createActor, f as ActorStatus, k as createErrorActorEvent, l as toStateValue, n as STATE_IDENTIFIER, o as normalizeTarget, t as toArray, N as NULL_EVENT, a as toTransitionConfigArray, S as STATE_DELIMITER, q as toStatePath, s as createDoneStateEvent, u as resolveOutput, j as XSTATE_STOP, X as XSTATE_INIT, W as WILDCARD, v as isArray, w as createAfterEvent, x as flatten, e as matchesState } from './interpreter-d5fa7ce0.esm.js';
2
2
 
3
3
  const cache = new WeakMap();
4
4
  function memo(object, key, fn) {
@@ -14,13 +14,13 @@ function memo(object, key, fn) {
14
14
  return memoizedData[key];
15
15
  }
16
16
 
17
- function resolve$3(_, state, actionArgs, {
17
+ function resolveCancel(_, state, actionArgs, {
18
18
  sendId
19
19
  }) {
20
20
  const resolvedSendId = typeof sendId === 'function' ? sendId(actionArgs) : sendId;
21
21
  return [state, resolvedSendId];
22
22
  }
23
- function execute$3(actorContext, resolvedSendId) {
23
+ function executeCancel(actorContext, resolvedSendId) {
24
24
  actorContext.self.cancel(resolvedSendId);
25
25
  }
26
26
  /**
@@ -35,16 +35,17 @@ function cancel(sendId) {
35
35
  }
36
36
  cancel.type = 'xstate.cancel';
37
37
  cancel.sendId = sendId;
38
- cancel.resolve = resolve$3;
39
- cancel.execute = execute$3;
38
+ cancel.resolve = resolveCancel;
39
+ cancel.execute = executeCancel;
40
40
  return cancel;
41
41
  }
42
42
 
43
- function resolve$2(actorContext, state, actionArgs, {
43
+ function resolveInvoke(actorContext, state, actionArgs, {
44
44
  id,
45
45
  systemId,
46
46
  src,
47
- input
47
+ input,
48
+ syncSnapshot
48
49
  }) {
49
50
  const referenced = resolveReferencedActor(state.machine.implementations.actors[src]);
50
51
  let actorRef;
@@ -62,6 +63,21 @@ function resolve$2(actorContext, state, actionArgs, {
62
63
  self: actorContext?.self
63
64
  }) : configuredInput
64
65
  });
66
+ if (syncSnapshot) {
67
+ actorRef.subscribe({
68
+ next: snapshot => {
69
+ if (snapshot.status === 'active') {
70
+ actorContext.self.send({
71
+ type: `xstate.snapshot.${id}`,
72
+ snapshot
73
+ });
74
+ }
75
+ },
76
+ error: () => {
77
+ /* TODO */
78
+ }
79
+ });
80
+ }
65
81
  }
66
82
  return [cloneState(state, {
67
83
  children: {
@@ -73,7 +89,7 @@ function resolve$2(actorContext, state, actionArgs, {
73
89
  actorRef
74
90
  }];
75
91
  }
76
- function execute$2(actorContext, {
92
+ function executeInvoke(actorContext, {
77
93
  id,
78
94
  actorRef
79
95
  }) {
@@ -99,7 +115,8 @@ function invoke({
99
115
  id,
100
116
  systemId,
101
117
  src,
102
- input
118
+ input,
119
+ onSnapshot
103
120
  }) {
104
121
  function invoke(_) {
105
122
  }
@@ -108,12 +125,13 @@ function invoke({
108
125
  invoke.systemId = systemId;
109
126
  invoke.src = src;
110
127
  invoke.input = input;
111
- invoke.resolve = resolve$2;
112
- invoke.execute = execute$2;
128
+ invoke.syncSnapshot = !!onSnapshot;
129
+ invoke.resolve = resolveInvoke;
130
+ invoke.execute = executeInvoke;
113
131
  return invoke;
114
132
  }
115
133
 
116
- function resolve$1(_, state, args, {
134
+ function resolveStop(_, state, args, {
117
135
  actorRef
118
136
  }) {
119
137
  const actorRefOrString = typeof actorRef === 'function' ? actorRef(args) : actorRef;
@@ -129,7 +147,7 @@ function resolve$1(_, state, args, {
129
147
  children
130
148
  }), resolvedActorRef];
131
149
  }
132
- function execute$1(actorContext, actorRef) {
150
+ function executeStop(actorContext, actorRef) {
133
151
  if (!actorRef) {
134
152
  return;
135
153
  }
@@ -152,8 +170,8 @@ function stop(actorRef) {
152
170
  }
153
171
  stop.type = 'xstate.stop';
154
172
  stop.actorRef = actorRef;
155
- stop.resolve = resolve$1;
156
- stop.execute = execute$1;
173
+ stop.resolve = resolveStop;
174
+ stop.execute = executeStop;
157
175
  return stop;
158
176
  }
159
177
 
@@ -260,9 +278,18 @@ function evaluateGuard(guard, context, event, state) {
260
278
  }
261
279
 
262
280
  function getOutput(configuration, context, event, self) {
263
- const machine = configuration[0].machine;
281
+ const {
282
+ machine
283
+ } = configuration[0];
284
+ const {
285
+ root
286
+ } = machine;
287
+ if (!root.output) {
288
+ return undefined;
289
+ }
264
290
  const finalChildStateNode = configuration.find(stateNode => stateNode.type === 'final' && stateNode.parent === machine.root);
265
- return finalChildStateNode && finalChildStateNode.output ? mapContext(finalChildStateNode.output, context, event, self) : undefined;
291
+ const doneStateEvent = createDoneStateEvent(finalChildStateNode.id, finalChildStateNode.output ? resolveOutput(finalChildStateNode.output, context, event, self) : undefined);
292
+ return resolveOutput(root.output, context, doneStateEvent, self);
266
293
  }
267
294
  const isAtomicStateNode = stateNode => stateNode.type === 'atomic' || stateNode.type === 'final';
268
295
  function getChildren(stateNode) {
@@ -890,7 +917,7 @@ function microstepProcedure(transitions, currentState, mutConfiguration, event,
890
917
  historyValue,
891
918
  _internalQueue: internalQueue,
892
919
  context: nextState.context,
893
- done,
920
+ status: done ? 'done' : currentState.status,
894
921
  output,
895
922
  children: nextState.children
896
923
  });
@@ -928,7 +955,7 @@ function enterStates(event, filteredTransitions, mutConfiguration, actions, inte
928
955
  if (!parent.parent) {
929
956
  continue;
930
957
  }
931
- internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output ? mapContext(stateNodeToEnter.output, currentState.context, event, actorContext.self) : undefined));
958
+ internalQueue.push(createDoneStateEvent(parent.id, stateNodeToEnter.output ? resolveOutput(stateNodeToEnter.output, currentState.context, event, actorContext.self) : undefined));
932
959
  if (parent.parent) {
933
960
  const grandparent = parent.parent;
934
961
  if (grandparent.type === 'parallel') {
@@ -1119,7 +1146,7 @@ function macrostep(state, event, actorCtx) {
1119
1146
  nextState = microstep(transitions, state, actorCtx, nextEvent, false);
1120
1147
  states.push(nextState);
1121
1148
  }
1122
- while (!nextState.done) {
1149
+ while (nextState.status === 'active') {
1123
1150
  let enabledTransitions = selectEventlessTransitions(nextState, nextEvent);
1124
1151
  if (!enabledTransitions.length) {
1125
1152
  if (!nextState._internalQueue.length) {
@@ -1136,7 +1163,7 @@ function macrostep(state, event, actorCtx) {
1136
1163
  states.push(nextState);
1137
1164
  }
1138
1165
  }
1139
- if (nextState.done) {
1166
+ if (nextState.status !== 'active') {
1140
1167
  // Perform the stop step to ensure that child actors are stopped
1141
1168
  stopStep(nextEvent, nextState, actorCtx);
1142
1169
  }
@@ -1229,7 +1256,8 @@ class State {
1229
1256
  meta: {},
1230
1257
  configuration: [],
1231
1258
  // TODO: fix,
1232
- children: {}
1259
+ children: {},
1260
+ status: 'active'
1233
1261
  }, machine);
1234
1262
  }
1235
1263
  return stateValue;
@@ -1240,7 +1268,8 @@ class State {
1240
1268
  context,
1241
1269
  meta: undefined,
1242
1270
  configuration: Array.from(configuration),
1243
- children: {}
1271
+ children: {},
1272
+ status: 'active'
1244
1273
  }, machine);
1245
1274
  }
1246
1275
 
@@ -1253,8 +1282,7 @@ class State {
1253
1282
  this.machine = machine;
1254
1283
  this.tags = void 0;
1255
1284
  this.value = void 0;
1256
- this.done = void 0;
1257
- this.output = void 0;
1285
+ this.status = void 0;
1258
1286
  this.error = void 0;
1259
1287
  this.context = void 0;
1260
1288
  this.historyValue = {};
@@ -1270,7 +1298,7 @@ class State {
1270
1298
  this.children = config.children;
1271
1299
  this.value = getStateValue(machine.root, this.configuration);
1272
1300
  this.tags = new Set(flatten(this.configuration.map(sn => sn.tags)));
1273
- this.done = config.done ?? false;
1301
+ this.status = config.status;
1274
1302
  this.output = config.output;
1275
1303
  this.error = config.error;
1276
1304
  }
@@ -1365,9 +1393,10 @@ function getPersistedState(state) {
1365
1393
  } = state;
1366
1394
  const childrenJson = {};
1367
1395
  for (const id in children) {
1396
+ const child = children[id];
1368
1397
  childrenJson[id] = {
1369
- state: children[id].getPersistedState?.(),
1370
- src: children[id].src
1398
+ state: child.getPersistedState?.(),
1399
+ src: child.src
1371
1400
  };
1372
1401
  }
1373
1402
  return {
@@ -1376,7 +1405,7 @@ function getPersistedState(state) {
1376
1405
  };
1377
1406
  }
1378
1407
 
1379
- function resolve(_, state, args, {
1408
+ function resolveRaise(_, state, args, {
1380
1409
  event: eventOrExpr,
1381
1410
  id,
1382
1411
  delay
@@ -1401,7 +1430,7 @@ function resolve(_, state, args, {
1401
1430
  delay: resolvedDelay
1402
1431
  }];
1403
1432
  }
1404
- function execute(actorContext, params) {
1433
+ function executeRaise(actorContext, params) {
1405
1434
  if (typeof params.delay === 'number') {
1406
1435
  actorContext.self.delaySend(params);
1407
1436
  return;
@@ -1420,8 +1449,8 @@ function raise(eventOrExpr, options) {
1420
1449
  raise.event = eventOrExpr;
1421
1450
  raise.id = options?.id;
1422
1451
  raise.delay = options?.delay;
1423
- raise.resolve = resolve;
1424
- raise.execute = execute;
1452
+ raise.resolve = resolveRaise;
1453
+ raise.execute = executeRaise;
1425
1454
  return raise;
1426
1455
  }
1427
1456