xstate 6.0.0-alpha.35 → 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 (57) 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/index.d.ts +1 -1
  12. package/dist/declarations/src/machineVersions.d.ts +17 -2
  13. package/dist/declarations/src/setup.d.ts +7 -3
  14. package/dist/declarations/src/types.v6.d.ts +31 -2
  15. package/dist/index-13e54113.cjs.js +985 -0
  16. package/dist/index-14478488.development.cjs.js +985 -0
  17. package/dist/index-abf9ab72.esm.js +976 -0
  18. package/dist/index-acf2bd02.development.esm.js +976 -0
  19. package/dist/transition-169651ca.cjs.js +148 -0
  20. package/dist/transition-61a126e0.development.esm.js +142 -0
  21. package/dist/transition-760b0fc6.esm.js +142 -0
  22. package/dist/transition-a306226e.development.cjs.js +148 -0
  23. package/dist/xstate-actors.cjs.js +6 -5
  24. package/dist/xstate-actors.development.cjs.js +6 -5
  25. package/dist/xstate-actors.development.esm.js +2 -1
  26. package/dist/xstate-actors.esm.js +2 -1
  27. package/dist/xstate-actors.umd.min.js.map +1 -1
  28. package/dist/xstate-durable.cjs.d.mts +2 -0
  29. package/dist/xstate-durable.cjs.d.ts +2 -0
  30. package/dist/xstate-durable.cjs.js +106 -0
  31. package/dist/xstate-durable.cjs.mjs +5 -0
  32. package/dist/xstate-durable.development.cjs.js +106 -0
  33. package/dist/xstate-durable.development.cjs.mjs +5 -0
  34. package/dist/xstate-durable.development.esm.js +100 -0
  35. package/dist/xstate-durable.esm.js +100 -0
  36. package/dist/xstate-durable.umd.min.js +2 -0
  37. package/dist/xstate-durable.umd.min.js.map +1 -0
  38. package/dist/xstate-graph.cjs.js +13 -12
  39. package/dist/xstate-graph.development.cjs.js +13 -12
  40. package/dist/xstate-graph.development.esm.js +5 -4
  41. package/dist/xstate-graph.esm.js +5 -4
  42. package/dist/xstate-graph.umd.min.js +1 -1
  43. package/dist/xstate-graph.umd.min.js.map +1 -1
  44. package/dist/xstate-validation.cjs.js +1 -1
  45. package/dist/xstate-validation.development.cjs.js +1 -1
  46. package/dist/xstate-validation.development.esm.js +1 -1
  47. package/dist/xstate-validation.esm.js +1 -1
  48. package/dist/xstate-validation.umd.min.js +1 -1
  49. package/dist/xstate-validation.umd.min.js.map +1 -1
  50. package/dist/xstate.cjs.js +123 -191
  51. package/dist/xstate.development.cjs.js +123 -191
  52. package/dist/xstate.development.esm.js +82 -150
  53. package/dist/xstate.esm.js +82 -150
  54. package/dist/xstate.umd.min.js +1 -1
  55. package/dist/xstate.umd.min.js.map +1 -1
  56. package/durable/package.json +8 -0
  57. package/package.json +18 -2
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var dist_xstateActors = require('./index-0acba787.development.cjs.js');
3
+ var createActor = require('./createActor-8462b9cc.development.cjs.js');
4
+ var dist_xstateActors = require('./index-14478488.development.cjs.js');
4
5
 
5
6
  function createSpawner(actorScope, actors, spawnedChildren) {
6
7
  return (src, options) => {
@@ -106,14 +107,14 @@ class StateNode {
106
107
  this.machine = options._machine;
107
108
  this.path = this.parent ? this.parent.path.concat(this.key) : [];
108
109
  const firstStateKey = this.config.states ? Object.keys(this.config.states)[0] : undefined;
109
- this.id = this.config.id || [this.machine.id, ...this.path].join(dist_xstateActors.STATE_DELIMITER);
110
+ this.id = this.config.id || [this.machine.id, ...this.path].join(createActor.STATE_DELIMITER);
110
111
  this.type = this.config.type || (firstStateKey !== undefined ? 'compound' : this.config.history ? 'history' : 'atomic');
111
112
  this.description = this.config.description;
112
113
  this.schemas = this.config.schemas;
113
114
  validateStateNodeConfig(this);
114
115
  this.order = this.machine.idMap.size;
115
116
  this.machine.idMap.set(this.id, this);
116
- this.states = this.config.states ? dist_xstateActors.mapValues(this.config.states, (stateConfig, key) => {
117
+ this.states = this.config.states ? createActor.mapValues(this.config.states, (stateConfig, key) => {
117
118
  const stateNode = new StateNode(stateConfig, {
118
119
  _parent: this,
119
120
  _key: key,
@@ -139,13 +140,13 @@ class StateNode {
139
140
  }
140
141
  this.meta = this.config.meta;
141
142
  this.output = this.type === 'final' || !this.parent ? this.config.output : undefined;
142
- this.tags = dist_xstateActors.toArray(config.tags).slice();
143
- this.invoke = dist_xstateActors.toArray(this.config.invoke).map((invokeConfig, i) => {
143
+ this.tags = createActor.toArray(config.tags).slice();
144
+ this.invoke = createActor.toArray(this.config.invoke).map((invokeConfig, i) => {
144
145
  const {
145
146
  src,
146
147
  registryKey
147
148
  } = invokeConfig;
148
- const invokeId = dist_xstateActors.createInvokeId(this.id, i);
149
+ const invokeId = createActor.createInvokeId(this.id, i);
149
150
  const resolvedId = invokeConfig.id ?? invokeId;
150
151
  // Referenced (string) actors keep their logical name so persisted
151
152
  // snapshots reference `src: 'fetchUser'` rather than a positional id;
@@ -163,12 +164,12 @@ class StateNode {
163
164
 
164
165
  /** @internal */
165
166
  _initialize() {
166
- this.after = dist_xstateActors.getDelayedTransitions(this);
167
+ this.after = createActor.getDelayedTransitions(this);
167
168
  this.transitions = formatTransitions(this);
168
169
  if (this.type === 'choice') {
169
170
  this.always = formatChoiceTransitions(this);
170
171
  } else if (this.config.always) {
171
- this.always = mapTransitionConfigs(this.config.always, transition => dist_xstateActors.formatTransition(this, dist_xstateActors.NULL_EVENT, transition));
172
+ this.always = mapTransitionConfigs(this.config.always, transition => createActor.formatTransition(this, createActor.NULL_EVENT, transition));
172
173
  }
173
174
  for (const key of Object.keys(this.states)) {
174
175
  this.states[key]._initialize();
@@ -202,14 +203,14 @@ class StateNode {
202
203
 
203
204
  /** @internal */
204
205
  next(snapshot, event, actorScope, selectionResults) {
205
- const descriptorKey = dist_xstateActors.getEventDescriptorKey(event);
206
+ const descriptorKey = createActor.getEventDescriptorKey(event);
206
207
  let candidates = this._candidateCache?.get(descriptorKey);
207
208
  if (!candidates) {
208
- candidates = dist_xstateActors.getCandidates(this, event);
209
+ candidates = createActor.getCandidates(this, event);
209
210
  (this._candidateCache ??= new Map()).set(descriptorKey, candidates);
210
211
  }
211
212
  for (const candidate of candidates) {
212
- const guardPassed = dist_xstateActors.evaluateCandidate(candidate, event, snapshot, this, actorScope, selectionResults);
213
+ const guardPassed = createActor.evaluateCandidate(candidate, event, snapshot, this, actorScope, selectionResults);
213
214
  if (guardPassed) {
214
215
  return [candidate];
215
216
  }
@@ -254,12 +255,12 @@ function formatChoiceTransitions(stateNode) {
254
255
  }
255
256
  return result;
256
257
  };
257
- return [dist_xstateActors.formatTransition(stateNode, dist_xstateActors.NULL_EVENT, {
258
+ return [createActor.formatTransition(stateNode, createActor.NULL_EVENT, {
258
259
  to: args => validateChoiceResult(choice(args))
259
260
  })];
260
261
  }
261
262
  function mapTransitionConfigs(transitionsConfig, mapper) {
262
- const transitionConfigs = dist_xstateActors.toTransitionConfigArray(transitionsConfig);
263
+ const transitionConfigs = createActor.toTransitionConfigArray(transitionsConfig);
263
264
  const transitions = new Array(transitionConfigs.length);
264
265
  for (let i = 0; i < transitionConfigs.length; i++) {
265
266
  transitions[i] = mapper(transitionConfigs[i]);
@@ -273,16 +274,16 @@ function formatTransitions(stateNode) {
273
274
  };
274
275
  if (stateNode.config.on) {
275
276
  for (const descriptor of Object.keys(stateNode.config.on)) {
276
- if (descriptor === dist_xstateActors.NULL_EVENT) {
277
+ if (descriptor === createActor.NULL_EVENT) {
277
278
  throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.' );
278
279
  }
279
280
  const transitionsConfig = stateNode.config.on[descriptor];
280
- transitions.set(descriptor, mapTransitionConfigs(transitionsConfig, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
281
+ transitions.set(descriptor, mapTransitionConfigs(transitionsConfig, transition => createActor.formatTransition(stateNode, descriptor, transition)));
281
282
  }
282
283
  }
283
284
  if (stateNode.config.onDone) {
284
285
  const descriptor = 'xstate.done.state';
285
- addTransitions(descriptor, mapTransitionConfigs(stateNode.config.onDone, transition => dist_xstateActors.formatTransition(stateNode, descriptor, {
286
+ addTransitions(descriptor, mapTransitionConfigs(stateNode.config.onDone, transition => createActor.formatTransition(stateNode, descriptor, {
286
287
  ...transition,
287
288
  matches: {
288
289
  ...transition.matches,
@@ -292,13 +293,13 @@ function formatTransitions(stateNode) {
292
293
  }
293
294
  if (stateNode.config.onError) {
294
295
  const descriptor = 'xstate.error.*';
295
- transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onError, transition => dist_xstateActors.formatTransition(stateNode, descriptor, transition)));
296
+ transitions.set(descriptor, mapTransitionConfigs(stateNode.config.onError, transition => createActor.formatTransition(stateNode, descriptor, transition)));
296
297
  }
297
- const createCancelInvokeTimeoutTransition = (descriptor, timeoutEventId, actorId) => dist_xstateActors.formatTransition(stateNode, descriptor, {
298
+ const createCancelInvokeTimeoutTransition = (descriptor, timeoutEventId, actorId) => createActor.formatTransition(stateNode, descriptor, {
298
299
  matches: {
299
300
  actorId
300
301
  },
301
- _eventMatcher: (event, snapshot) => dist_xstateActors.matchesActorSession(event, snapshot, actorId),
302
+ _eventMatcher: (event, snapshot) => createActor.matchesActorSession(event, snapshot, actorId),
302
303
  to: (_args, enq) => {
303
304
  enq.cancel(timeoutEventId);
304
305
  return {};
@@ -311,7 +312,7 @@ function formatTransitions(stateNode) {
311
312
  reenter,
312
313
  ...rest
313
314
  } = transitionConfig;
314
- return dist_xstateActors.formatTransition(stateNode, descriptor, {
315
+ return createActor.formatTransition(stateNode, descriptor, {
315
316
  ...rest,
316
317
  reenter,
317
318
  to: (args, enq) => {
@@ -354,14 +355,14 @@ function formatTransitions(stateNode) {
354
355
  ...transition.matches,
355
356
  actorId: invokeDef.id
356
357
  },
357
- _eventMatcher: (event, snapshot) => dist_xstateActors.matchesActorSession(event, snapshot, invokeDef.id)
358
+ _eventMatcher: (event, snapshot) => createActor.matchesActorSession(event, snapshot, invokeDef.id)
358
359
  });
359
- const invokeTimeoutEventId = invokeDef.timeout !== undefined ? dist_xstateActors.createInvokeTimeoutEventId(invokeDef.id) : undefined;
360
+ const invokeTimeoutEventId = invokeDef.timeout !== undefined ? createActor.createInvokeTimeoutEventId(invokeDef.id) : undefined;
360
361
  if (invokeDef.onDone) {
361
362
  const descriptor = 'xstate.done.actor';
362
363
  const invokeDoneTransitions = mapTransitionConfigs(invokeDef.onDone, rawTransition => {
363
364
  const transition = withInvokeMatch(rawTransition);
364
- return invokeTimeoutEventId ? formatInvokeCompletionTransition(descriptor, transition, invokeTimeoutEventId) : dist_xstateActors.formatTransition(stateNode, descriptor, transition);
365
+ return invokeTimeoutEventId ? formatInvokeCompletionTransition(descriptor, transition, invokeTimeoutEventId) : createActor.formatTransition(stateNode, descriptor, transition);
365
366
  });
366
367
  if (invokeTimeoutEventId) {
367
368
  invokeDoneTransitions.push(createCancelInvokeTimeoutTransition(descriptor, invokeTimeoutEventId, invokeDef.id));
@@ -375,12 +376,12 @@ function formatTransitions(stateNode) {
375
376
  const descriptor = 'xstate.error.actor';
376
377
  addTransitions(descriptor, mapTransitionConfigs(invokeDef.onError, rawTransition => {
377
378
  const transition = withInvokeMatch(rawTransition);
378
- return invokeTimeoutEventId ? formatInvokeCompletionTransition(descriptor, transition, invokeTimeoutEventId) : dist_xstateActors.formatTransition(stateNode, descriptor, transition);
379
+ return invokeTimeoutEventId ? formatInvokeCompletionTransition(descriptor, transition, invokeTimeoutEventId) : createActor.formatTransition(stateNode, descriptor, transition);
379
380
  }));
380
381
  }
381
382
  if (invokeDef.onSnapshot) {
382
383
  const descriptor = 'xstate.snapshot.actor';
383
- addTransitions(descriptor, mapTransitionConfigs(invokeDef.onSnapshot, transition => dist_xstateActors.formatTransition(stateNode, descriptor, withInvokeMatch(transition))));
384
+ addTransitions(descriptor, mapTransitionConfigs(invokeDef.onSnapshot, transition => createActor.formatTransition(stateNode, descriptor, withInvokeMatch(transition))));
384
385
  }
385
386
  }
386
387
  for (const delayedTransition of stateNode.after) {
@@ -415,7 +416,7 @@ function getEmptyCanActor() {
415
416
  // A minimal inert actor used purely as the `self`/`parent` argument when
416
417
  // dry-running transitions for `snapshot.can(...)`. Intentionally not built
417
418
  // on `createLogic` so `can()` does not pull that machinery into bundles.
418
- return emptyCanActor ??= dist_xstateActors.createActor({
419
+ return emptyCanActor ??= createActor.createActor({
419
420
  transition: snapshot => [snapshot, []],
420
421
  initialTransition: () => [{
421
422
  status: 'active',
@@ -513,7 +514,7 @@ class StateMachine {
513
514
  _machine: this
514
515
  });
515
516
  this.root._initialize();
516
- dist_xstateActors.formatRouteTransitions(this.root);
517
+ createActor.formatRouteTransitions(this.root);
517
518
  this.root._refreshEventMetadata();
518
519
  this._hasEventlessTransitions = Array.from(this.idMap.values()).some(stateNode => !!stateNode.always?.length);
519
520
  this.states = this.root.states; // TODO: remove!
@@ -557,15 +558,15 @@ class StateMachine {
557
558
  return provided;
558
559
  }
559
560
  resolveState(config) {
560
- const resolvedStateValue = dist_xstateActors.resolveStateValue(this.root, config.value);
561
- const nodeSet = dist_xstateActors.getAllStateNodes(dist_xstateActors.getStateNodes(this.root, resolvedStateValue));
561
+ const resolvedStateValue = createActor.resolveStateValue(this.root, config.value);
562
+ const nodeSet = createActor.getAllStateNodes(createActor.getStateNodes(this.root, resolvedStateValue));
562
563
  const nodes = [...nodeSet];
563
- return dist_xstateActors.createMachineSnapshot({
564
+ return createActor.createMachineSnapshot({
564
565
  _nodes: nodes,
565
566
  value: resolvedStateValue,
566
567
  context: config.context || {},
567
568
  children: {},
568
- status: dist_xstateActors.isInFinalState(nodeSet, this.root) ? 'done' : config.status || 'active',
569
+ status: createActor.isInFinalState(nodeSet, this.root) ? 'done' : config.status || 'active',
569
570
  output: config.output,
570
571
  error: config.error,
571
572
  historyValue: config.historyValue
@@ -581,7 +582,7 @@ class StateMachine {
581
582
  */
582
583
  transition(snapshot, event, actorScope) {
583
584
  const usesInertScope = !actorScope;
584
- const resolvedActorScope = actorScope ?? dist_xstateActors.createInertActorScope(this, snapshot);
585
+ const resolvedActorScope = actorScope ?? createActor.createInertActorScope(this, snapshot);
585
586
  if (this.validator) {
586
587
  dist_xstateActors.assertValid(this.validator, {
587
588
  kind: 'event',
@@ -591,14 +592,14 @@ class StateMachine {
591
592
  });
592
593
  }
593
594
  if (usesInertScope) {
594
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, snapshot, false);
595
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, snapshot, false);
595
596
  }
596
597
  const fastSnapshot = this._transitionFast(snapshot, event, resolvedActorScope);
597
598
  if (fastSnapshot) {
598
599
  if (usesInertScope) {
599
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, fastSnapshot, false);
600
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, fastSnapshot, false);
600
601
  }
601
- const returnedSnapshot = usesInertScope && fastSnapshot !== snapshot ? dist_xstateActors.attachSnapshotActorRef(resolvedActorScope, fastSnapshot) : this._attachPureActorRef(fastSnapshot, resolvedActorScope);
602
+ const returnedSnapshot = usesInertScope && fastSnapshot !== snapshot ? createActor.attachSnapshotActorRef(resolvedActorScope, fastSnapshot) : this._attachPureActorRef(fastSnapshot, resolvedActorScope);
602
603
  if (this.validator) {
603
604
  dist_xstateActors.assertValid(this.validator, {
604
605
  kind: 'result',
@@ -612,11 +613,11 @@ class StateMachine {
612
613
  const {
613
614
  snapshot: nextSnapshot,
614
615
  microsteps
615
- } = dist_xstateActors.macrostep(snapshot, event, resolvedActorScope, []);
616
+ } = createActor.macrostep(snapshot, event, resolvedActorScope, []);
616
617
  if (usesInertScope) {
617
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, nextSnapshot, false);
618
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, nextSnapshot, false);
618
619
  }
619
- const returnedSnapshot = usesInertScope ? nextSnapshot === snapshot ? nextSnapshot : dist_xstateActors.attachSnapshotActorRef(resolvedActorScope, nextSnapshot) : this._attachPureActorRef(nextSnapshot, resolvedActorScope);
620
+ const returnedSnapshot = usesInertScope ? nextSnapshot === snapshot ? nextSnapshot : createActor.attachSnapshotActorRef(resolvedActorScope, nextSnapshot) : this._attachPureActorRef(nextSnapshot, resolvedActorScope);
620
621
  const effects = this._collectEffects(microsteps);
621
622
  if (this.validator) {
622
623
  dist_xstateActors.assertValid(this.validator, {
@@ -632,13 +633,13 @@ class StateMachine {
632
633
  return microsteps.flatMap(([, actions]) => actions);
633
634
  }
634
635
  _attachPureActorRef(snapshot, actorScope, skipInitializingActor = false) {
635
- if (dist_xstateActors.isInertActorScope(actorScope)) {
636
+ if (createActor.isInertActorScope(actorScope)) {
636
637
  return snapshot;
637
638
  }
638
639
  if (skipInitializingActor && actorScope.self._actorScope === actorScope && actorScope.self._snapshot === undefined) {
639
640
  return snapshot;
640
641
  }
641
- dist_xstateActors.setSnapshotActorRef(snapshot, actorScope.self, actorScope.system);
642
+ createActor.setSnapshotActorRef(snapshot, actorScope.self, actorScope.system);
642
643
  return snapshot;
643
644
  }
644
645
  _transitionFast(snapshot, event, actorScope) {
@@ -666,12 +667,12 @@ class StateMachine {
666
667
  ...snapshot.context,
667
668
  ...selected.context
668
669
  } : snapshot.context;
669
- if (!dist_xstateActors.isInertActorScope(actorScope) && (actorScope.system._hasInspectionObservers?.() ?? true)) {
670
+ if (!createActor.isInertActorScope(actorScope) && (actorScope.system._hasInspectionObservers?.() ?? true)) {
670
671
  const collectedMicrosteps = actorScope.self._collectedMicrosteps || [];
671
672
  collectedMicrosteps.push(selected);
672
673
  actorScope.self._collectedMicrosteps = collectedMicrosteps;
673
674
  }
674
- return dist_xstateActors.cloneMachineSnapshot(snapshot, {
675
+ return createActor.cloneMachineSnapshot(snapshot, {
675
676
  ...(context !== snapshot.context ? {
676
677
  context
677
678
  } : {}),
@@ -691,7 +692,7 @@ class StateMachine {
691
692
  microstep(snapshot, event, actorScope) {
692
693
  const {
693
694
  microsteps
694
- } = dist_xstateActors.macrostep(snapshot, event, actorScope, []);
695
+ } = createActor.macrostep(snapshot, event, actorScope, []);
695
696
  const snapshots = new Array(microsteps.length);
696
697
  for (let i = 0; i < microsteps.length; i++) {
697
698
  snapshots[i] = microsteps[i][0];
@@ -699,14 +700,14 @@ class StateMachine {
699
700
  return snapshots;
700
701
  }
701
702
  getTransitionData(snapshot, event, actorScope, selectionResults) {
702
- return dist_xstateActors.transitionNode(this.root, snapshot.value, snapshot, event, actorScope, selectionResults) || [];
703
+ return createActor.transitionNode(this.root, snapshot.value, snapshot, event, actorScope, selectionResults) || [];
703
704
  }
704
705
  isInternalEventType(eventType) {
705
- if (eventType === dist_xstateActors.XSTATE_TIMER) {
706
+ if (eventType === createActor.XSTATE_TIMER) {
706
707
  return true;
707
708
  }
708
709
  for (const descriptor of this.internalEventDescriptors) {
709
- if (dist_xstateActors.matchesEventDescriptor(eventType, descriptor)) {
710
+ if (createActor.matchesEventDescriptor(eventType, descriptor)) {
710
711
  return true;
711
712
  }
712
713
  }
@@ -732,10 +733,10 @@ class StateMachine {
732
733
  if (transition.target !== undefined) {
733
734
  return true;
734
735
  }
735
- const res = dist_xstateActors.getTransitionResult(transition, snapshot, event, emptyActorScope, {
736
+ const res = createActor.getTransitionResult(transition, snapshot, event, emptyActorScope, {
736
737
  resolveActions: false
737
738
  });
738
- if (res.targets?.length || res.context || dist_xstateActors.hasEffect(transition, snapshot.context, event, snapshot, emptyActorScope)) {
739
+ if (res.targets?.length || res.context || createActor.hasEffect(transition, snapshot.context, event, snapshot, emptyActorScope)) {
739
740
  return true;
740
741
  }
741
742
  }
@@ -749,10 +750,10 @@ class StateMachine {
749
750
  * @internal
750
751
  */
751
752
  getExecutionErrorEvent(snapshot, error) {
752
- if (snapshot?.status !== 'active' || !snapshot._nodes?.some(stateNode => stateNode.config.onError)) {
753
+ if (snapshot?.status !== 'active' || !snapshot.nodes?.some(stateNode => stateNode.config.onError)) {
753
754
  return undefined;
754
755
  }
755
- return dist_xstateActors.createErrorPlatformEvent('execution', error);
756
+ return createActor.createErrorPlatformEvent('execution', error);
756
757
  }
757
758
 
758
759
  /**
@@ -765,7 +766,7 @@ class StateMachine {
765
766
  const {
766
767
  context
767
768
  } = this.config;
768
- const preInitial = dist_xstateActors.createMachineSnapshot({
769
+ const preInitial = createActor.createMachineSnapshot({
769
770
  context: typeof context !== 'function' && context ? context : {},
770
771
  _nodes: [this.root],
771
772
  children: {},
@@ -774,12 +775,12 @@ class StateMachine {
774
775
  if (typeof context === 'function') {
775
776
  const children = {};
776
777
  const spawn = createSpawner(actorScope, this.sources.actors, children);
777
- const resolvedContext = context(dist_xstateActors.withActorSelf({
778
+ const resolvedContext = context(createActor.withActorSelf({
778
779
  spawn,
779
780
  input: initEvent.input,
780
781
  actors: this.sources.actors
781
782
  }, actorScope));
782
- const [nextState] = dist_xstateActors.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
783
+ const [nextState] = createActor.resolveActionsWithContext(preInitial, initEvent, actorScope, []);
783
784
  if (resolvedContext) {
784
785
  nextState.context = resolvedContext;
785
786
  }
@@ -810,16 +811,16 @@ class StateMachine {
810
811
  });
811
812
  }
812
813
  const usesInertScope = !actorScope;
813
- const resolvedActorScope = actorScope ?? dist_xstateActors.createInertActorScope(this);
814
- const initEvent = dist_xstateActors.createInitEvent(input); // TODO: fix;
814
+ const resolvedActorScope = actorScope ?? createActor.createInertActorScope(this);
815
+ const initEvent = createActor.createInitEvent(input); // TODO: fix;
815
816
  const internalQueue = [];
816
817
  const preInitialState = this._getPreInitialState(resolvedActorScope, initEvent);
817
- const contextSpawnEffects = Object.values(preInitialState.children).filter(Boolean).map(actor => dist_xstateActors.createSpawnEffect(actor));
818
+ const contextSpawnEffects = Object.values(preInitialState.children).filter(Boolean).map(actor => createActor.createSpawnEffect(actor));
818
819
  const finalizeInitialResult = (macroState, microsteps) => {
819
820
  if (usesInertScope) {
820
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, macroState, false);
821
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, macroState, false);
821
822
  }
822
- const returnedSnapshot = usesInertScope ? dist_xstateActors.attachSnapshotActorRef(resolvedActorScope, macroState) : this._attachPureActorRef(macroState, resolvedActorScope, true);
823
+ const returnedSnapshot = usesInertScope ? createActor.attachSnapshotActorRef(resolvedActorScope, macroState) : this._attachPureActorRef(macroState, resolvedActorScope, true);
823
824
  const effects = this._collectEffects(microsteps);
824
825
  if (this.validator) {
825
826
  dist_xstateActors.assertValid(this.validator, {
@@ -832,18 +833,18 @@ class StateMachine {
832
833
  return [returnedSnapshot, effects];
833
834
  };
834
835
  try {
835
- const [nextState, initialActions] = dist_xstateActors.initialMicrostep(this.root, preInitialState, resolvedActorScope, initEvent, internalQueue);
836
+ const [nextState, initialActions] = createActor.initialMicrostep(this.root, preInitialState, resolvedActorScope, initEvent, internalQueue);
836
837
  const {
837
838
  snapshot: macroState,
838
839
  microsteps
839
- } = dist_xstateActors.macrostep(nextState, initEvent, resolvedActorScope, internalQueue, [[nextState, [...contextSpawnEffects, ...initialActions]]]);
840
+ } = createActor.macrostep(nextState, initEvent, resolvedActorScope, internalQueue, [[nextState, [...contextSpawnEffects, ...initialActions]]]);
840
841
  return finalizeInitialResult(macroState, microsteps);
841
842
  } catch (err) {
842
843
  if (!this.root.config.onError) {
843
844
  throw err;
844
845
  }
845
- const errorEvent = dist_xstateActors.createErrorPlatformEvent('execution', err);
846
- const errorMacrostep = dist_xstateActors.macrostep(preInitialState, errorEvent, resolvedActorScope, [], [[preInitialState, contextSpawnEffects]]);
846
+ const errorEvent = createActor.createErrorPlatformEvent('execution', err);
847
+ const errorMacrostep = createActor.macrostep(preInitialState, errorEvent, resolvedActorScope, [], [[preInitialState, contextSpawnEffects]]);
847
848
  return finalizeInitialResult(errorMacrostep.snapshot, errorMacrostep.microsteps);
848
849
  }
849
850
  }
@@ -866,21 +867,21 @@ class StateMachine {
866
867
  }
867
868
  }
868
869
  getStateNodeById(stateId) {
869
- const fullPath = dist_xstateActors.toStatePath(stateId);
870
+ const fullPath = createActor.toStatePath(stateId);
870
871
  const relativePath = fullPath.slice(1);
871
- const resolvedStateId = dist_xstateActors.isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];
872
+ const resolvedStateId = createActor.isStateId(fullPath[0]) ? fullPath[0].slice(STATE_IDENTIFIER.length) : fullPath[0];
872
873
  const stateNode = this.idMap.get(resolvedStateId);
873
874
  if (!stateNode) {
874
875
  throw new Error(`Child state node '#${resolvedStateId}' does not exist on machine '${this.id}'`);
875
876
  }
876
- return dist_xstateActors.getStateNodeByPath(stateNode, relativePath);
877
+ return createActor.getStateNodeByPath(stateNode, relativePath);
877
878
  }
878
879
  getPersistedSnapshot(snapshot, options) {
879
- return dist_xstateActors.getPersistedSnapshot(snapshot, options);
880
+ return createActor.getPersistedSnapshot(snapshot, options);
880
881
  }
881
882
  restoreSnapshot(snapshot, actorScope) {
882
883
  const usesInertScope = !actorScope;
883
- const resolvedActorScope = actorScope ?? dist_xstateActors.createInertActorScope(this);
884
+ const resolvedActorScope = actorScope ?? createActor.createInertActorScope(this);
884
885
  const persistedMachine = snapshot.machine;
885
886
  const legacyPersistedVersion = snapshot.version;
886
887
  const persistedVersion = typeof persistedMachine?.version === 'string' ? persistedMachine.version : legacyPersistedVersion;
@@ -904,7 +905,7 @@ class StateMachine {
904
905
  const actorData = snapshotChildren[actorId];
905
906
  const childState = actorData.snapshot;
906
907
  const src = actorData.src;
907
- const logic = typeof src === 'string' ? dist_xstateActors.resolveReferencedActor(this, src) : src;
908
+ const logic = typeof src === 'string' ? createActor.resolveReferencedActor(this, src) : src;
908
909
  if (!logic) {
909
910
  const sourceId = typeof src === 'string' ? src : '<unknown>';
910
911
  throw new Error(`Unable to restore child actor '${actorId}': child source '${sourceId}' is not provided in machine '${this.id}'.`);
@@ -930,7 +931,7 @@ class StateMachine {
930
931
  const actorId = event.actorId;
931
932
  const child = children[actorId];
932
933
  if (child) {
933
- event = dist_xstateActors.createInvokeTimeoutEvent(actorId, child.sessionId);
934
+ event = createActor.createInvokeTimeoutEvent(actorId, child.sessionId);
934
935
  }
935
936
  }
936
937
  const target = typeof timer.target === 'string' ? timer.target === 'self' ? 'self' : children[timer.target] : resolvedActorScope.self._parent;
@@ -974,12 +975,12 @@ class StateMachine {
974
975
  return revived;
975
976
  };
976
977
  const revivedHistoryValue = reviveHistoryValue(snapshotData.historyValue);
977
- const nodes = Array.from(dist_xstateActors.getAllStateNodes(dist_xstateActors.getStateNodes(this.root, snapshotData.value)));
978
+ const nodes = Array.from(createActor.getAllStateNodes(createActor.getStateNodes(this.root, snapshotData.value)));
978
979
  const {
979
980
  version: _persistedSnapshotVersion,
980
981
  ...persistedRest
981
982
  } = snapshot;
982
- const restoredSnapshot = dist_xstateActors.createMachineSnapshot({
983
+ const restoredSnapshot = createActor.createMachineSnapshot({
983
984
  ...persistedRest,
984
985
  children,
985
986
  timers,
@@ -997,7 +998,7 @@ class StateMachine {
997
998
  for (const key of Object.keys(contextPart)) {
998
999
  const value = contextPart[key];
999
1000
  if (value && typeof value === 'object') {
1000
- if ('xstate$$type' in value && value.xstate$$type === dist_xstateActors.$$ACTOR_TYPE) {
1001
+ if ('xstate$$type' in value && value.xstate$$type === createActor.$$ACTOR_TYPE) {
1001
1002
  contextPart[key] = children[value.id];
1002
1003
  continue;
1003
1004
  }
@@ -1007,8 +1008,8 @@ class StateMachine {
1007
1008
  }
1008
1009
  reviveContext(restoredSnapshot.context);
1009
1010
  if (usesInertScope) {
1010
- dist_xstateActors.setInertActorScopeSnapshot(resolvedActorScope, restoredSnapshot, false);
1011
- return dist_xstateActors.attachSnapshotActorRef(resolvedActorScope, restoredSnapshot);
1011
+ createActor.setInertActorScopeSnapshot(resolvedActorScope, restoredSnapshot, false);
1012
+ return createActor.attachSnapshotActorRef(resolvedActorScope, restoredSnapshot);
1012
1013
  }
1013
1014
  return this._attachPureActorRef(restoredSnapshot, resolvedActorScope);
1014
1015
  }
@@ -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-9d364b4a.development.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-164c86f5.development.esm.js';
2
+ import { g as assertValid } from './index-acf2bd02.development.esm.js';
2
3
 
3
4
  function createSpawner(actorScope, actors, spawnedChildren) {
4
5
  return (src, options) => {
@@ -747,7 +748,7 @@ class StateMachine {
747
748
  * @internal
748
749
  */
749
750
  getExecutionErrorEvent(snapshot, error) {
750
- if (snapshot?.status !== 'active' || !snapshot._nodes?.some(stateNode => stateNode.config.onError)) {
751
+ if (snapshot?.status !== 'active' || !snapshot.nodes?.some(stateNode => stateNode.config.onError)) {
751
752
  return undefined;
752
753
  }
753
754
  return createErrorPlatformEvent('execution', error);