xstate 6.0.0-alpha.36 → 6.0.0-alpha.37

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 (55) hide show
  1. package/dist/{StateMachine-9d68f525.esm.js → StateMachine-009b5bc4.esm.js} +3 -2
  2. package/dist/{StateMachine-c6fc9d29.cjs.js → StateMachine-5d0aac92.cjs.js} +75 -74
  3. package/dist/{StateMachine-41dc03be.development.cjs.js → StateMachine-7197482a.development.cjs.js} +75 -74
  4. package/dist/{StateMachine-8dd1e4a0.development.esm.js → StateMachine-9da92cbf.development.esm.js} +3 -2
  5. package/dist/{index-9d364b4a.development.esm.js → createActor-164c86f5.development.esm.js} +15 -988
  6. package/dist/{index-9146dea1.esm.js → createActor-19e83fb9.esm.js} +15 -988
  7. package/dist/{index-0acba787.development.cjs.js → createActor-8462b9cc.development.cjs.js} +16 -995
  8. package/dist/{index-9683e24d.cjs.js → createActor-fd53ec92.cjs.js} +16 -995
  9. package/dist/declarations/src/State.d.ts +1 -1
  10. package/dist/declarations/src/durable/index.d.ts +66 -0
  11. package/dist/declarations/src/setup.d.ts +7 -3
  12. package/dist/declarations/src/types.v6.d.ts +31 -2
  13. package/dist/index-13e54113.cjs.js +985 -0
  14. package/dist/index-14478488.development.cjs.js +985 -0
  15. package/dist/index-abf9ab72.esm.js +976 -0
  16. package/dist/index-acf2bd02.development.esm.js +976 -0
  17. package/dist/transition-169651ca.cjs.js +148 -0
  18. package/dist/transition-61a126e0.development.esm.js +142 -0
  19. package/dist/transition-760b0fc6.esm.js +142 -0
  20. package/dist/transition-a306226e.development.cjs.js +148 -0
  21. package/dist/xstate-actors.cjs.js +6 -5
  22. package/dist/xstate-actors.development.cjs.js +6 -5
  23. package/dist/xstate-actors.development.esm.js +2 -1
  24. package/dist/xstate-actors.esm.js +2 -1
  25. package/dist/xstate-actors.umd.min.js.map +1 -1
  26. package/dist/xstate-durable.cjs.d.mts +2 -0
  27. package/dist/xstate-durable.cjs.d.ts +2 -0
  28. package/dist/xstate-durable.cjs.js +106 -0
  29. package/dist/xstate-durable.cjs.mjs +5 -0
  30. package/dist/xstate-durable.development.cjs.js +106 -0
  31. package/dist/xstate-durable.development.cjs.mjs +5 -0
  32. package/dist/xstate-durable.development.esm.js +100 -0
  33. package/dist/xstate-durable.esm.js +100 -0
  34. package/dist/xstate-durable.umd.min.js +2 -0
  35. package/dist/xstate-durable.umd.min.js.map +1 -0
  36. package/dist/xstate-graph.cjs.js +13 -12
  37. package/dist/xstate-graph.development.cjs.js +13 -12
  38. package/dist/xstate-graph.development.esm.js +5 -4
  39. package/dist/xstate-graph.esm.js +5 -4
  40. package/dist/xstate-graph.umd.min.js +1 -1
  41. package/dist/xstate-graph.umd.min.js.map +1 -1
  42. package/dist/xstate-validation.cjs.js +1 -1
  43. package/dist/xstate-validation.development.cjs.js +1 -1
  44. package/dist/xstate-validation.development.esm.js +1 -1
  45. package/dist/xstate-validation.esm.js +1 -1
  46. package/dist/xstate-validation.umd.min.js +1 -1
  47. package/dist/xstate-validation.umd.min.js.map +1 -1
  48. package/dist/xstate.cjs.js +53 -190
  49. package/dist/xstate.development.cjs.js +53 -190
  50. package/dist/xstate.development.esm.js +12 -149
  51. package/dist/xstate.esm.js +12 -149
  52. package/dist/xstate.umd.min.js +1 -1
  53. package/dist/xstate.umd.min.js.map +1 -1
  54. package/durable/package.json +8 -0
  55. package/package.json +18 -2
@@ -1,4 +1,5 @@
1
- import { U as STATE_DELIMITER, V as mapValues, t as toArray, W as createInvokeId, Y as getDelayedTransitions, Z as getEventDescriptorKey, _ as getCandidates, $ as evaluateCandidate, a0 as formatTransition, a1 as NULL_EVENT, a2 as toTransitionConfigArray, a3 as createInvokeTimeoutEventId, a4 as matchesActorSession, a5 as formatRouteTransitions, a6 as resolveStateValue, a7 as getAllStateNodes, B as getStateNodes, a8 as createMachineSnapshot, a9 as isInFinalState, k as createInertActorScope, aa as assertValid, s as setInertActorScopeSnapshot, l as attachSnapshotActorRef, n as macrostep, ab as isInertActorScope, ac as setSnapshotActorRef, ad as cloneMachineSnapshot, ae as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, af as getTransitionResult, ag as hasEffect, ah as createErrorPlatformEvent, ai as withActorSelf, r as resolveActionsWithContext, o as createInitEvent, q as createSpawnEffect, u as initialMicrostep, aj as toStatePath, ak as isStateId, al as getStateNodeByPath, am as getPersistedSnapshot, an as resolveReferencedActor, ao as createInvokeTimeoutEvent, ap as $$ACTOR_TYPE, j as createActor } from './index-9146dea1.esm.js';
1
+ import { S as STATE_DELIMITER, I as mapValues, t as toArray, J as createInvokeId, K as getDelayedTransitions, L as getEventDescriptorKey, M as getCandidates, N as evaluateCandidate, O as formatTransition, P as NULL_EVENT, Q as toTransitionConfigArray, R as createInvokeTimeoutEventId, T as matchesActorSession, U as formatRouteTransitions, V as resolveStateValue, W as getAllStateNodes, o as getStateNodes, Y as createMachineSnapshot, Z as isInFinalState, _ as createInertActorScope, $ as setInertActorScopeSnapshot, a0 as attachSnapshotActorRef, a1 as macrostep, a2 as isInertActorScope, a3 as setSnapshotActorRef, a4 as cloneMachineSnapshot, a5 as transitionNode, e as XSTATE_TIMER, m as matchesEventDescriptor, a6 as getTransitionResult, a7 as hasEffect, a8 as createErrorPlatformEvent, a9 as withActorSelf, r as resolveActionsWithContext, F as createInitEvent, aa as createSpawnEffect, ab as initialMicrostep, ac as toStatePath, ad as isStateId, ae as getStateNodeByPath, af as getPersistedSnapshot, ag as resolveReferencedActor, ah as createInvokeTimeoutEvent, ai as $$ACTOR_TYPE, j as createActor } from './createActor-19e83fb9.esm.js';
2
+ import { g as assertValid } from './index-abf9ab72.esm.js';
2
3
 
3
4
  function createSpawner(actorScope, actors, spawnedChildren) {
4
5
  return (src, options) => {
@@ -718,7 +719,7 @@ class StateMachine {
718
719
  * @internal
719
720
  */
720
721
  getExecutionErrorEvent(snapshot, error) {
721
- if (snapshot?.status !== 'active' || !snapshot._nodes?.some(stateNode => stateNode.config.onError)) {
722
+ if (snapshot?.status !== 'active' || !snapshot.nodes?.some(stateNode => stateNode.config.onError)) {
722
723
  return undefined;
723
724
  }
724
725
  return createErrorPlatformEvent('execution', error);
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var dist_xstateActors = require('./index-9683e24d.cjs.js');
3
+ var createActor = require('./createActor-fd53ec92.cjs.js');
4
+ var dist_xstateActors = require('./index-13e54113.cjs.js');
4
5
 
5
6
  function createSpawner(actorScope, actors, spawnedChildren) {
6
7
  return (src, options) => {
@@ -105,14 +106,14 @@ class StateNode {
105
106
  this.machine = options._machine;
106
107
  this.path = this.parent ? this.parent.path.concat(this.key) : [];
107
108
  const firstStateKey = this.config.states ? Object.keys(this.config.states)[0] : undefined;
108
- this.id = this.config.id || [this.machine.id, ...this.path].join(dist_xstateActors.STATE_DELIMITER);
109
+ this.id = this.config.id || [this.machine.id, ...this.path].join(createActor.STATE_DELIMITER);
109
110
  this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
110
111
  this.description = this.config.description;
111
112
  this.schemas = this.config.schemas;
112
113
  validateStateNodeConfig(this);
113
114
  this.order = this.machine.idMap.size;
114
115
  this.machine.idMap.set(this.id, this);
115
- this.states = this.config.states ? dist_xstateActors.mapValues(this.config.states, (stateConfig, key) => {
116
+ this.states = this.config.states ? createActor.mapValues(this.config.states, (stateConfig, key) => {
116
117
  const stateNode = new StateNode(stateConfig, {
117
118
  _parent: this,
118
119
  _key: key,
@@ -138,13 +139,13 @@ class StateNode {
138
139
  }
139
140
  this.meta = this.config.meta;
140
141
  this.output = this.type === 'final' || !this.parent ? this.config.output : undefined;
141
- this.tags = dist_xstateActors.toArray(config.tags).slice();
142
- this.invoke = dist_xstateActors.toArray(this.config.invoke).map((invokeConfig, i) => {
142
+ this.tags = createActor.toArray(config.tags).slice();
143
+ this.invoke = createActor.toArray(this.config.invoke).map((invokeConfig, i) => {
143
144
  const {
144
145
  src,
145
146
  registryKey
146
147
  } = invokeConfig;
147
- const invokeId = dist_xstateActors.createInvokeId(this.id, i);
148
+ const invokeId = createActor.createInvokeId(this.id, i);
148
149
  const resolvedId = invokeConfig.id ?? invokeId;
149
150
  // Referenced (string) actors keep their logical name so persisted
150
151
  // snapshots reference `src: 'fetchUser'` rather than a positional id;
@@ -162,12 +163,12 @@ class StateNode {
162
163
 
163
164
  /** @internal */
164
165
  _initialize() {
165
- this.after = dist_xstateActors.getDelayedTransitions(this);
166
+ this.after = createActor.getDelayedTransitions(this);
166
167
  this.transitions = formatTransitions(this);
167
168
  if (this.type === 'choice') {
168
169
  this.always = formatChoiceTransitions(this);
169
170
  } else if (this.config.always) {
170
- this.always = mapTransitionConfigs(this.config.always, transition => dist_xstateActors.formatTransition(this, dist_xstateActors.NULL_EVENT, transition));
171
+ this.always = mapTransitionConfigs(this.config.always, transition => createActor.formatTransition(this, createActor.NULL_EVENT, transition));
171
172
  }
172
173
  for (const key of Object.keys(this.states)) {
173
174
  this.states[key]._initialize();
@@ -201,14 +202,14 @@ class StateNode {
201
202
 
202
203
  /** @internal */
203
204
  next(snapshot, event, actorScope, selectionResults) {
204
- const descriptorKey = dist_xstateActors.getEventDescriptorKey(event);
205
+ const descriptorKey = createActor.getEventDescriptorKey(event);
205
206
  let candidates = this._candidateCache?.get(descriptorKey);
206
207
  if (!candidates) {
207
- candidates = dist_xstateActors.getCandidates(this, event);
208
+ candidates = createActor.getCandidates(this, event);
208
209
  (this._candidateCache ??= new Map()).set(descriptorKey, candidates);
209
210
  }
210
211
  for (const candidate of candidates) {
211
- const guardPassed = dist_xstateActors.evaluateCandidate(candidate, event, snapshot, this, actorScope, selectionResults);
212
+ const guardPassed = createActor.evaluateCandidate(candidate, event, snapshot, this, actorScope, selectionResults);
212
213
  if (guardPassed) {
213
214
  return [candidate];
214
215
  }
@@ -236,12 +237,12 @@ function formatChoiceTransitions(stateNode) {
236
237
  }
237
238
  return result;
238
239
  };
239
- return [dist_xstateActors.formatTransition(stateNode, dist_xstateActors.NULL_EVENT, {
240
+ return [createActor.formatTransition(stateNode, createActor.NULL_EVENT, {
240
241
  to: args => validateChoiceResult(choice(args))
241
242
  })];
242
243
  }
243
244
  function mapTransitionConfigs(transitionsConfig, mapper) {
244
- const transitionConfigs = dist_xstateActors.toTransitionConfigArray(transitionsConfig);
245
+ const transitionConfigs = createActor.toTransitionConfigArray(transitionsConfig);
245
246
  const transitions = new Array(transitionConfigs.length);
246
247
  for (let i = 0; i < transitionConfigs.length; i++) {
247
248
  transitions[i] = mapper(transitionConfigs[i]);
@@ -255,16 +256,16 @@ function formatTransitions(stateNode) {
255
256
  };
256
257
  if (stateNode.config.on) {
257
258
  for (const descriptor of Object.keys(stateNode.config.on)) {
258
- if (descriptor === dist_xstateActors.NULL_EVENT) {
259
+ if (descriptor === createActor.NULL_EVENT) {
259
260
  throw new Error('Null event transition key');
260
261
  }
261
262
  const transitionsConfig = stateNode.config.on[descriptor];
262
- transitions.set(descriptor, mapTransitionConfigs(transitionsConfig, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
263
+ transitions.set(descriptor, mapTransitionConfigs(transitionsConfig, transition => createActor.formatTransition(stateNode, descriptor, transition)));
263
264
  }
264
265
  }
265
266
  if (stateNode.config.onDone) {
266
267
  const descriptor = 'xstate.done.state';
267
- addTransitions(descriptor, mapTransitionConfigs(stateNode.config.onDone, transition => dist_xstateActors.formatTransition(stateNode, descriptor, {
268
+ addTransitions(descriptor, mapTransitionConfigs(stateNode.config.onDone, transition => createActor.formatTransition(stateNode, descriptor, {
268
269
  ...transition,
269
270
  matches: {
270
271
  ...transition.matches,
@@ -274,13 +275,13 @@ function formatTransitions(stateNode) {
274
275
  }
275
276
  if (stateNode.config.onError) {
276
277
  const descriptor = 'xstate.error.*';
277
- transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onError, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
278
+ transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onError, transition => createActor.formatTransition(stateNode, descriptor, transition)));
278
279
  }
279
- const createCancelInvokeTimeoutTransition = (descriptor, timeoutEventId, actorId) => dist_xstateActors.formatTransition(stateNode, descriptor, {
280
+ const createCancelInvokeTimeoutTransition = (descriptor, timeoutEventId, actorId) => createActor.formatTransition(stateNode, descriptor, {
280
281
  matches: {
281
282
  actorId
282
283
  },
283
- _eventMatcher: (event, snapshot) => dist_xstateActors.matchesActorSession(event, snapshot, actorId),
284
+ _eventMatcher: (event, snapshot) => createActor.matchesActorSession(event, snapshot, actorId),
284
285
  to: (_args, enq) => {
285
286
  enq.cancel(timeoutEventId);
286
287
  return {};
@@ -293,7 +294,7 @@ function formatTransitions(stateNode) {
293
294
  reenter,
294
295
  ...rest
295
296
  } = transitionConfig;
296
- return dist_xstateActors.formatTransition(stateNode, descriptor, {
297
+ return createActor.formatTransition(stateNode, descriptor, {
297
298
  ...rest,
298
299
  reenter,
299
300
  to: (args, enq) => {
@@ -336,14 +337,14 @@ function formatTransitions(stateNode) {
336
337
  ...transition.matches,
337
338
  actorId: invokeDef.id
338
339
  },
339
- _eventMatcher: (event, snapshot) => dist_xstateActors.matchesActorSession(event, snapshot, invokeDef.id)
340
+ _eventMatcher: (event, snapshot) => createActor.matchesActorSession(event, snapshot, invokeDef.id)
340
341
  });
341
- const invokeTimeoutEventId = invokeDef.timeout !== undefined ? dist_xstateActors.createInvokeTimeoutEventId(invokeDef.id) : undefined;
342
+ const invokeTimeoutEventId = invokeDef.timeout !== undefined ? createActor.createInvokeTimeoutEventId(invokeDef.id) : undefined;
342
343
  if (invokeDef.onDone) {
343
344
  const descriptor = 'xstate.done.actor';
344
345
  const invokeDoneTransitions = mapTransitionConfigs(invokeDef.onDone, rawTransition => {
345
346
  const transition = withInvokeMatch(rawTransition);
346
- return invokeTimeoutEventId ? formatInvokeCompletionTransition(descriptor, transition, invokeTimeoutEventId) : dist_xstateActors.formatTransition(stateNode, descriptor, transition);
347
+ return invokeTimeoutEventId ? formatInvokeCompletionTransition(descriptor, transition, invokeTimeoutEventId) : createActor.formatTransition(stateNode, descriptor, transition);
347
348
  });
348
349
  if (invokeTimeoutEventId) {
349
350
  invokeDoneTransitions.push(createCancelInvokeTimeoutTransition(descriptor, invokeTimeoutEventId, invokeDef.id));
@@ -357,12 +358,12 @@ function formatTransitions(stateNode) {
357
358
  const descriptor = 'xstate.error.actor';
358
359
  addTransitions(descriptor, mapTransitionConfigs(invokeDef.onError, rawTransition => {
359
360
  const transition = withInvokeMatch(rawTransition);
360
- return invokeTimeoutEventId ? formatInvokeCompletionTransition(descriptor, transition, invokeTimeoutEventId) : dist_xstateActors.formatTransition(stateNode, descriptor, transition);
361
+ return invokeTimeoutEventId ? formatInvokeCompletionTransition(descriptor, transition, invokeTimeoutEventId) : createActor.formatTransition(stateNode, descriptor, transition);
361
362
  }));
362
363
  }
363
364
  if (invokeDef.onSnapshot) {
364
365
  const descriptor = 'xstate.snapshot.actor';
365
- addTransitions(descriptor, mapTransitionConfigs(invokeDef.onSnapshot, transition => dist_xstateActors.formatTransition(stateNode, descriptor, withInvokeMatch(transition))));
366
+ addTransitions(descriptor, mapTransitionConfigs(invokeDef.onSnapshot, transition => createActor.formatTransition(stateNode, descriptor, withInvokeMatch(transition))));
366
367
  }
367
368
  }
368
369
  for (const delayedTransition of stateNode.after) {
@@ -397,7 +398,7 @@ function getEmptyCanActor() {
397
398
  // A minimal inert actor used purely as the `self`/`parent` argument when
398
399
  // dry-running transitions for `snapshot.can(...)`. Intentionally not built
399
400
  // on `createLogic` so `can()` does not pull that machinery into bundles.
400
- return emptyCanActor ??= dist_xstateActors.createActor({
401
+ return emptyCanActor ??= createActor.createActor({
401
402
  transition: snapshot => [snapshot, []],
402
403
  initialTransition: () => [{
403
404
  status: 'active',
@@ -484,7 +485,7 @@ class StateMachine {
484
485
  _machine: this
485
486
  });
486
487
  this.root._initialize();
487
- dist_xstateActors.formatRouteTransitions(this.root);
488
+ createActor.formatRouteTransitions(this.root);
488
489
  this.root._refreshEventMetadata();
489
490
  this._hasEventlessTransitions = Array.from(this.idMap.values()).some(stateNode => !!stateNode.always?.length);
490
491
  this.states = this.root.states; // TODO: remove!
@@ -528,15 +529,15 @@ class StateMachine {
528
529
  return provided;
529
530
  }
530
531
  resolveState(config) {
531
- const resolvedStateValue = dist_xstateActors.resolveStateValue(this.root, config.value);
532
- const nodeSet = dist_xstateActors.getAllStateNodes(dist_xstateActors.getStateNodes(this.root, resolvedStateValue));
532
+ const resolvedStateValue = createActor.resolveStateValue(this.root, config.value);
533
+ const nodeSet = createActor.getAllStateNodes(createActor.getStateNodes(this.root, resolvedStateValue));
533
534
  const nodes = [...nodeSet];
534
- return dist_xstateActors.createMachineSnapshot({
535
+ return createActor.createMachineSnapshot({
535
536
  _nodes: nodes,
536
537
  value: resolvedStateValue,
537
538
  context: config.context || {},
538
539
  children: {},
539
- status: dist_xstateActors.isInFinalState(nodeSet, this.root) ? 'done' : config.status || 'active',
540
+ status: createActor.isInFinalState(nodeSet, this.root) ? 'done' : config.status || 'active',
540
541
  output: config.output,
541
542
  error: config.error,
542
543
  historyValue: config.historyValue
@@ -552,7 +553,7 @@ class StateMachine {
552
553
  */
553
554
  transition(snapshot, event, actorScope) {
554
555
  const usesInertScope = !actorScope;
555
- const resolvedActorScope = actorScope ?? dist_xstateActors.createInertActorScope(this, snapshot);
556
+ const resolvedActorScope = actorScope ?? createActor.createInertActorScope(this, snapshot);
556
557
  if (this.validator) {
557
558
  dist_xstateActors.assertValid(this.validator, {
558
559
  kind: 'event',
@@ -562,14 +563,14 @@ class StateMachine {
562
563
  });
563
564
  }
564
565
  if (usesInertScope) {
565
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, snapshot, false);
566
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, snapshot, false);
566
567
  }
567
568
  const fastSnapshot = this._transitionFast(snapshot, event, resolvedActorScope);
568
569
  if (fastSnapshot) {
569
570
  if (usesInertScope) {
570
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, fastSnapshot, false);
571
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, fastSnapshot, false);
571
572
  }
572
- const returnedSnapshot = usesInertScope && fastSnapshot !== snapshot ? dist_xstateActors.attachSnapshotActorRef(resolvedActorScope, fastSnapshot) : this._attachPureActorRef(fastSnapshot, resolvedActorScope);
573
+ const returnedSnapshot = usesInertScope && fastSnapshot !== snapshot ? createActor.attachSnapshotActorRef(resolvedActorScope, fastSnapshot) : this._attachPureActorRef(fastSnapshot, resolvedActorScope);
573
574
  if (this.validator) {
574
575
  dist_xstateActors.assertValid(this.validator, {
575
576
  kind: 'result',
@@ -583,11 +584,11 @@ class StateMachine {
583
584
  const {
584
585
  snapshot: nextSnapshot,
585
586
  microsteps
586
- } = dist_xstateActors.macrostep(snapshot, event, resolvedActorScope, []);
587
+ } = createActor.macrostep(snapshot, event, resolvedActorScope, []);
587
588
  if (usesInertScope) {
588
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, nextSnapshot, false);
589
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, nextSnapshot, false);
589
590
  }
590
- const returnedSnapshot = usesInertScope ? nextSnapshot === snapshot ? nextSnapshot : dist_xstateActors.attachSnapshotActorRef(resolvedActorScope, nextSnapshot) : this._attachPureActorRef(nextSnapshot, resolvedActorScope);
591
+ const returnedSnapshot = usesInertScope ? nextSnapshot === snapshot ? nextSnapshot : createActor.attachSnapshotActorRef(resolvedActorScope, nextSnapshot) : this._attachPureActorRef(nextSnapshot, resolvedActorScope);
591
592
  const effects = this._collectEffects(microsteps);
592
593
  if (this.validator) {
593
594
  dist_xstateActors.assertValid(this.validator, {
@@ -603,13 +604,13 @@ class StateMachine {
603
604
  return microsteps.flatMap(([, actions]) => actions);
604
605
  }
605
606
  _attachPureActorRef(snapshot, actorScope, skipInitializingActor = false) {
606
- if (dist_xstateActors.isInertActorScope(actorScope)) {
607
+ if (createActor.isInertActorScope(actorScope)) {
607
608
  return snapshot;
608
609
  }
609
610
  if (skipInitializingActor && actorScope.self._actorScope === actorScope && actorScope.self._snapshot === undefined) {
610
611
  return snapshot;
611
612
  }
612
- dist_xstateActors.setSnapshotActorRef(snapshot, actorScope.self, actorScope.system);
613
+ createActor.setSnapshotActorRef(snapshot, actorScope.self, actorScope.system);
613
614
  return snapshot;
614
615
  }
615
616
  _transitionFast(snapshot, event, actorScope) {
@@ -637,12 +638,12 @@ class StateMachine {
637
638
  ...snapshot.context,
638
639
  ...selected.context
639
640
  } : snapshot.context;
640
- if (!dist_xstateActors.isInertActorScope(actorScope) && (actorScope.system._hasInspectionObservers?.() ?? true)) {
641
+ if (!createActor.isInertActorScope(actorScope) && (actorScope.system._hasInspectionObservers?.() ?? true)) {
641
642
  const collectedMicrosteps = actorScope.self._collectedMicrosteps || [];
642
643
  collectedMicrosteps.push(selected);
643
644
  actorScope.self._collectedMicrosteps = collectedMicrosteps;
644
645
  }
645
- return dist_xstateActors.cloneMachineSnapshot(snapshot, {
646
+ return createActor.cloneMachineSnapshot(snapshot, {
646
647
  ...(context !== snapshot.context ? {
647
648
  context
648
649
  } : {}),
@@ -662,7 +663,7 @@ class StateMachine {
662
663
  microstep(snapshot, event, actorScope) {
663
664
  const {
664
665
  microsteps
665
- } = dist_xstateActors.macrostep(snapshot, event, actorScope, []);
666
+ } = createActor.macrostep(snapshot, event, actorScope, []);
666
667
  const snapshots = new Array(microsteps.length);
667
668
  for (let i = 0; i < microsteps.length; i++) {
668
669
  snapshots[i] = microsteps[i][0];
@@ -670,14 +671,14 @@ class StateMachine {
670
671
  return snapshots;
671
672
  }
672
673
  getTransitionData(snapshot, event, actorScope, selectionResults) {
673
- return dist_xstateActors.transitionNode(this.root, snapshot.value, snapshot, event, actorScope, selectionResults) || [];
674
+ return createActor.transitionNode(this.root, snapshot.value, snapshot, event, actorScope, selectionResults) || [];
674
675
  }
675
676
  isInternalEventType(eventType) {
676
- if (eventType === dist_xstateActors.XSTATE_TIMER) {
677
+ if (eventType === createActor.XSTATE_TIMER) {
677
678
  return true;
678
679
  }
679
680
  for (const descriptor of this.internalEventDescriptors) {
680
- if (dist_xstateActors.matchesEventDescriptor(eventType, descriptor)) {
681
+ if (createActor.matchesEventDescriptor(eventType, descriptor)) {
681
682
  return true;
682
683
  }
683
684
  }
@@ -703,10 +704,10 @@ class StateMachine {
703
704
  if (transition.target !== undefined) {
704
705
  return true;
705
706
  }
706
- const res = dist_xstateActors.getTransitionResult(transition, snapshot, event, emptyActorScope, {
707
+ const res = createActor.getTransitionResult(transition, snapshot, event, emptyActorScope, {
707
708
  resolveActions: false
708
709
  });
709
- if (res.targets?.length || res.context || dist_xstateActors.hasEffect(transition, snapshot.context, event, snapshot, emptyActorScope)) {
710
+ if (res.targets?.length || res.context || createActor.hasEffect(transition, snapshot.context, event, snapshot, emptyActorScope)) {
710
711
  return true;
711
712
  }
712
713
  }
@@ -720,10 +721,10 @@ class StateMachine {
720
721
  * @internal
721
722
  */
722
723
  getExecutionErrorEvent(snapshot, error) {
723
- if (snapshot?.status !== 'active' || !snapshot._nodes?.some(stateNode => stateNode.config.onError)) {
724
+ if (snapshot?.status !== 'active' || !snapshot.nodes?.some(stateNode => stateNode.config.onError)) {
724
725
  return undefined;
725
726
  }
726
- return dist_xstateActors.createErrorPlatformEvent('execution', error);
727
+ return createActor.createErrorPlatformEvent('execution', error);
727
728
  }
728
729
 
729
730
  /**
@@ -736,7 +737,7 @@ class StateMachine {
736
737
  const {
737
738
  context
738
739
  } = this.config;
739
- const preInitial = dist_xstateActors.createMachineSnapshot({
740
+ const preInitial = createActor.createMachineSnapshot({
740
741
  context: typeof context !== 'function' && context ? context : {},
741
742
  _nodes: [this.root],
742
743
  children: {},
@@ -745,12 +746,12 @@ class StateMachine {
745
746
  if (typeof context === 'function') {
746
747
  const children = {};
747
748
  const spawn = createSpawner(actorScope, this.sources.actors, children);
748
- const resolvedContext = context(dist_xstateActors.withActorSelf({
749
+ const resolvedContext = context(createActor.withActorSelf({
749
750
  spawn,
750
751
  input: initEvent.input,
751
752
  actors: this.sources.actors
752
753
  }, actorScope));
753
- const [nextState] = dist_xstateActors.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
754
+ const [nextState] = createActor.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
754
755
  if (resolvedContext) {
755
756
  nextState.context = resolvedContext;
756
757
  }
@@ -781,16 +782,16 @@ class StateMachine {
781
782
  });
782
783
  }
783
784
  const usesInertScope = !actorScope;
784
- const resolvedActorScope = actorScope ?? dist_xstateActors.createInertActorScope(this);
785
- const initEvent = dist_xstateActors.createInitEvent(input); // TODO: fix;
785
+ const resolvedActorScope = actorScope ?? createActor.createInertActorScope(this);
786
+ const initEvent = createActor.createInitEvent(input); // TODO: fix;
786
787
  const internalQueue = [];
787
788
  const preInitialState = this._getPreInitialState(resolvedActorScope, initEvent);
788
- const contextSpawnEffects = Object.values(preInitialState.children).filter(Boolean).map(actor => dist_xstateActors.createSpawnEffect(actor));
789
+ const contextSpawnEffects = Object.values(preInitialState.children).filter(Boolean).map(actor => createActor.createSpawnEffect(actor));
789
790
  const finalizeInitialResult = (macroState, microsteps) => {
790
791
  if (usesInertScope) {
791
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, macroState, false);
792
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, macroState, false);
792
793
  }
793
- const returnedSnapshot = usesInertScope ? dist_xstateActors.attachSnapshotActorRef(resolvedActorScope, macroState) : this._attachPureActorRef(macroState, resolvedActorScope, true);
794
+ const returnedSnapshot = usesInertScope ? createActor.attachSnapshotActorRef(resolvedActorScope, macroState) : this._attachPureActorRef(macroState, resolvedActorScope, true);
794
795
  const effects = this._collectEffects(microsteps);
795
796
  if (this.validator) {
796
797
  dist_xstateActors.assertValid(this.validator, {
@@ -803,18 +804,18 @@ class StateMachine {
803
804
  return [returnedSnapshot, effects];
804
805
  };
805
806
  try {
806
- const [nextState, initialActions] = dist_xstateActors.initialMicrostep(this.root, preInitialState, resolvedActorScope, initEvent, internalQueue);
807
+ const [nextState, initialActions] = createActor.initialMicrostep(this.root, preInitialState, resolvedActorScope, initEvent, internalQueue);
807
808
  const {
808
809
  snapshot: macroState,
809
810
  microsteps
810
- } = dist_xstateActors.macrostep(nextState, initEvent, resolvedActorScope, internalQueue, [[nextState, [...contextSpawnEffects, ...initialActions]]]);
811
+ } = createActor.macrostep(nextState, initEvent, resolvedActorScope, internalQueue, [[nextState, [...contextSpawnEffects, ...initialActions]]]);
811
812
  return finalizeInitialResult(macroState, microsteps);
812
813
  } catch (err) {
813
814
  if (!this.root.config.onError) {
814
815
  throw err;
815
816
  }
816
- const errorEvent = dist_xstateActors.createErrorPlatformEvent('execution', err);
817
- const errorMacrostep = dist_xstateActors.macrostep(preInitialState, errorEvent, resolvedActorScope, [], [[preInitialState, contextSpawnEffects]]);
817
+ const errorEvent = createActor.createErrorPlatformEvent('execution', err);
818
+ const errorMacrostep = createActor.macrostep(preInitialState, errorEvent, resolvedActorScope, [], [[preInitialState, contextSpawnEffects]]);
818
819
  return finalizeInitialResult(errorMacrostep.snapshot, errorMacrostep.microsteps);
819
820
  }
820
821
  }
@@ -837,21 +838,21 @@ class StateMachine {
837
838
  }
838
839
  }
839
840
  getStateNodeById(stateId) {
840
- const fullPath = dist_xstateActors.toStatePath(stateId);
841
+ const fullPath = createActor.toStatePath(stateId);
841
842
  const relativePath = fullPath.slice(1);
842
- const resolvedStateId = dist_xstateActors.isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];
843
+ const resolvedStateId = createActor.isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];
843
844
  const stateNode = this.idMap.get(resolvedStateId);
844
845
  if (!stateNode) {
845
846
  throw new Error(`Child state node '#${resolvedStateId}' does not exist on machine '${this.id}'`);
846
847
  }
847
- return dist_xstateActors.getStateNodeByPath(stateNode, relativePath);
848
+ return createActor.getStateNodeByPath(stateNode, relativePath);
848
849
  }
849
850
  getPersistedSnapshot(snapshot, options) {
850
- return dist_xstateActors.getPersistedSnapshot(snapshot, options);
851
+ return createActor.getPersistedSnapshot(snapshot, options);
851
852
  }
852
853
  restoreSnapshot(snapshot, actorScope) {
853
854
  const usesInertScope = !actorScope;
854
- const resolvedActorScope = actorScope ?? dist_xstateActors.createInertActorScope(this);
855
+ const resolvedActorScope = actorScope ?? createActor.createInertActorScope(this);
855
856
  const persistedMachine = snapshot.machine;
856
857
  const legacyPersistedVersion = snapshot.version;
857
858
  const persistedVersion = typeof persistedMachine?.version === 'string' ? persistedMachine.version : legacyPersistedVersion;
@@ -875,7 +876,7 @@ class StateMachine {
875
876
  const actorData = snapshotChildren[actorId];
876
877
  const childState = actorData.snapshot;
877
878
  const src = actorData.src;
878
- const logic = typeof src === 'string' ? dist_xstateActors.resolveReferencedActor(this, src) : src;
879
+ const logic = typeof src === 'string' ? createActor.resolveReferencedActor(this, src) : src;
879
880
  if (!logic) {
880
881
  const sourceId = typeof src === 'string' ? src : '<unknown>';
881
882
  throw new Error(`Unable to restore child actor '${actorId}': child source '${sourceId}' is not provided in machine '${this.id}'.`);
@@ -901,7 +902,7 @@ class StateMachine {
901
902
  const actorId = event.actorId;
902
903
  const child = children[actorId];
903
904
  if (child) {
904
- event = dist_xstateActors.createInvokeTimeoutEvent(actorId, child.sessionId);
905
+ event = createActor.createInvokeTimeoutEvent(actorId, child.sessionId);
905
906
  }
906
907
  }
907
908
  const target = typeof timer.target === 'string' ? timer.target === 'self' ? 'self' : children[timer.target] : resolvedActorScope.self._parent;
@@ -942,12 +943,12 @@ class StateMachine {
942
943
  return revived;
943
944
  };
944
945
  const revivedHistoryValue = reviveHistoryValue(snapshotData.historyValue);
945
- const nodes = Array.from(dist_xstateActors.getAllStateNodes(dist_xstateActors.getStateNodes(this.root, snapshotData.value)));
946
+ const nodes = Array.from(createActor.getAllStateNodes(createActor.getStateNodes(this.root, snapshotData.value)));
946
947
  const {
947
948
  version: _persistedSnapshotVersion,
948
949
  ...persistedRest
949
950
  } = snapshot;
950
- const restoredSnapshot = dist_xstateActors.createMachineSnapshot({
951
+ const restoredSnapshot = createActor.createMachineSnapshot({
951
952
  ...persistedRest,
952
953
  children,
953
954
  timers,
@@ -965,7 +966,7 @@ class StateMachine {
965
966
  for (const key of Object.keys(contextPart)) {
966
967
  const value = contextPart[key];
967
968
  if (value && typeof value === 'object') {
968
- if ('xstate$$type' in value && value.xstate$$type === dist_xstateActors.$$ACTOR_TYPE) {
969
+ if ('xstate$$type' in value && value.xstate$$type === createActor.$$ACTOR_TYPE) {
969
970
  contextPart[key] = children[value.id];
970
971
  continue;
971
972
  }
@@ -975,8 +976,8 @@ class StateMachine {
975
976
  }
976
977
  reviveContext(restoredSnapshot.context);
977
978
  if (usesInertScope) {
978
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, restoredSnapshot, false);
979
- return dist_xstateActors.attachSnapshotActorRef(resolvedActorScope, restoredSnapshot);
979
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, restoredSnapshot, false);
980
+ return createActor.attachSnapshotActorRef(resolvedActorScope, restoredSnapshot);
980
981
  }
981
982
  return this._attachPureActorRef(restoredSnapshot, resolvedActorScope);
982
983
  }