xstate 6.0.0-alpha.11 → 6.0.0-alpha.13

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 (40) hide show
  1. package/dist/{StateMachine-0aa98f54.development.esm.js → StateMachine-193c2d4d.development.esm.js} +43 -2
  2. package/dist/{StateMachine-aef700df.cjs.js → StateMachine-1b26c5de.cjs.js} +43 -2
  3. package/dist/{StateMachine-da872dde.development.cjs.js → StateMachine-3120a7ff.development.cjs.js} +43 -2
  4. package/dist/{StateMachine-d4931336.esm.js → StateMachine-614c0f36.esm.js} +43 -2
  5. package/dist/declarations/src/StateMachine.d.ts +1 -0
  6. package/dist/declarations/src/actors/promise.d.ts +4 -2
  7. package/dist/declarations/src/createActor.d.ts +2 -8
  8. package/dist/declarations/src/createMachineFromConfig.d.ts +56 -25
  9. package/dist/declarations/src/fsm.d.ts +74 -0
  10. package/dist/declarations/src/index.d.ts +2 -1
  11. package/dist/declarations/src/serialize.d.ts +8 -22
  12. package/dist/declarations/src/setup.d.ts +54 -23
  13. package/dist/declarations/src/stateUtils.d.ts +3 -1
  14. package/dist/declarations/src/transitionActions.d.ts +1 -1
  15. package/dist/declarations/src/types.d.ts +17 -7
  16. package/dist/declarations/src/types.v6.d.ts +25 -6
  17. package/dist/{index-219cb621.development.cjs.js → index-08d86676.development.cjs.js} +48 -27
  18. package/dist/{index-559ceab3.cjs.js → index-32631949.cjs.js} +48 -27
  19. package/dist/{index-8828376f.esm.js → index-603c1cda.esm.js} +45 -28
  20. package/dist/{index-2f2fbd9b.development.esm.js → index-7081e0c9.development.esm.js} +45 -28
  21. package/dist/xstate-actors.cjs.js +1 -1
  22. package/dist/xstate-actors.development.cjs.js +1 -1
  23. package/dist/xstate-actors.development.esm.js +1 -1
  24. package/dist/xstate-actors.esm.js +1 -1
  25. package/dist/xstate-actors.umd.min.js.map +1 -1
  26. package/dist/xstate-graph.cjs.js +2 -2
  27. package/dist/xstate-graph.development.cjs.js +2 -2
  28. package/dist/xstate-graph.development.esm.js +2 -2
  29. package/dist/xstate-graph.esm.js +2 -2
  30. package/dist/xstate-graph.umd.min.js +1 -1
  31. package/dist/xstate-graph.umd.min.js.map +1 -1
  32. package/dist/xstate.cjs.js +835 -144
  33. package/dist/xstate.cjs.mjs +1 -0
  34. package/dist/xstate.development.cjs.js +835 -144
  35. package/dist/xstate.development.cjs.mjs +1 -0
  36. package/dist/xstate.development.esm.js +838 -148
  37. package/dist/xstate.esm.js +838 -148
  38. package/dist/xstate.umd.min.js +1 -1
  39. package/dist/xstate.umd.min.js.map +1 -1
  40. package/package.json +1 -1
@@ -384,7 +384,7 @@ function pushStartedChild(actions, actor, id) {
384
384
  pushBuiltInAction(actions, builtInActions['@xstate.start'], actor);
385
385
  actions.push(registerSpawnedChild(actor, id ?? actor.id));
386
386
  }
387
- function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubscriptions = false) {
387
+ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubscriptions = false, createActors = true) {
388
388
  const props = {
389
389
  cancel: id => {
390
390
  pushBuiltInAction(actions, builtInActions['@xstate.cancel'], actorScope, id);
@@ -406,6 +406,12 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
406
406
  }
407
407
  },
408
408
  spawn: (logic, options) => {
409
+ if (!createActors) {
410
+ // TODO: replace this speculative placeholder with a typed inert actor ref.
411
+ return {
412
+ id: options?.id ?? options?.registryKey ?? logic.id
413
+ };
414
+ }
409
415
  const actor = createActor(logic, {
410
416
  ...options,
411
417
  parent: actorScope.self
@@ -920,9 +926,6 @@ function formatRouteTransitions(rootStateNode) {
920
926
  }
921
927
  return;
922
928
  }
923
- if ('$unserializable' in routeConfig) {
924
- throw new Error(`State "${sn.id}" has a route that is not serializable. Re-provide the route function when reviving this machine.`);
925
- }
926
929
  const {
927
930
  guard: _guard,
928
931
  ...routeOptions
@@ -1184,7 +1187,9 @@ function getEffectiveTargetStates(transition, snapshot, event, actorScope) {
1184
1187
  const historyValue = snapshot.historyValue;
1185
1188
  const {
1186
1189
  targets
1187
- } = getTransitionResult(transition, snapshot, event, actorScope);
1190
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1191
+ resolveActions: false
1192
+ });
1188
1193
  if (!targets) {
1189
1194
  return [];
1190
1195
  }
@@ -1210,7 +1215,9 @@ function getTransitionDomain(transition, snapshot, event, actorScope) {
1210
1215
  const targetStates = getEffectiveTargetStates(transition, snapshot, event, actorScope);
1211
1216
  const {
1212
1217
  reenter
1213
- } = getTransitionResult(transition, snapshot, event, actorScope);
1218
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1219
+ resolveActions: false
1220
+ });
1214
1221
  if (!reenter && targetStates.every(target => target === transition.source || isDescendant(target, transition.source))) {
1215
1222
  return transition.source;
1216
1223
  }
@@ -1233,7 +1240,9 @@ function computeExitSet(transitions, stateNodeSet, snapshot, event, actorScope)
1233
1240
  for (const transition of transitions) {
1234
1241
  const {
1235
1242
  targets
1236
- } = getTransitionResult(transition, snapshot, event, actorScope);
1243
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1244
+ resolveActions: false
1245
+ });
1237
1246
  if (targets?.length) {
1238
1247
  const domain = getTransitionDomain(transition, snapshot, event, actorScope);
1239
1248
  if (transition.reenter && transition.source === domain) {
@@ -1473,7 +1482,9 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1473
1482
  const {
1474
1483
  targets,
1475
1484
  reenter
1476
- } = getCurrentTransitionResult(transition);
1485
+ } = getTransitionResult(transition, currentSnapshot, event, actorScope, {
1486
+ resolveActions: false
1487
+ });
1477
1488
  for (const targetNode of targets ?? []) {
1478
1489
  if (!isHistoryNode(targetNode) && (transition.source !== targetNode || transition.source !== domain || reenter)) {
1479
1490
  statesToEnter.add(targetNode);
@@ -1500,7 +1511,9 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1500
1511
  const {
1501
1512
  targets,
1502
1513
  input
1503
- } = getCurrentTransitionResult(transition);
1514
+ } = getTransitionResult(transition, currentSnapshot, event, actorScope, {
1515
+ resolveActions: false
1516
+ });
1504
1517
  if (input && targets) {
1505
1518
  for (const targetNode of targets) {
1506
1519
  stateInputMap[targetNode.id] = input;
@@ -1685,25 +1698,26 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1685
1698
  * Gets the transition result for a given transition without executing the
1686
1699
  * transition.
1687
1700
  */
1688
- function getTransitionResult(transition, snapshot, event, actorScope) {
1701
+ function getTransitionResult(transition, snapshot, event, actorScope, options) {
1702
+ const transitionArgs = {
1703
+ context: snapshot.context,
1704
+ event,
1705
+ output: getEventOutput(event),
1706
+ value: snapshot.value,
1707
+ children: snapshot.children,
1708
+ system: actorScope.system,
1709
+ parent: actorScope.self._parent,
1710
+ self: actorScope.self,
1711
+ actions: snapshot.machine.implementations.actions,
1712
+ actorSources: snapshot.machine.implementations.actorSources,
1713
+ guards: snapshot.machine.implementations.guards,
1714
+ delays: snapshot.machine.implementations.delays
1715
+ };
1689
1716
  if (transition.to) {
1690
1717
  const actions = [];
1691
1718
  const internalEvents = [];
1692
- const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents);
1693
- const res = transition.to({
1694
- context: snapshot.context,
1695
- event,
1696
- output: getEventOutput(event),
1697
- value: snapshot.value,
1698
- children: snapshot.children,
1699
- system: actorScope.system,
1700
- parent: actorScope.self._parent,
1701
- self: actorScope.self,
1702
- actions: snapshot.machine.implementations.actions,
1703
- actorSources: snapshot.machine.implementations.actorSources,
1704
- guards: snapshot.machine.implementations.guards,
1705
- delays: snapshot.machine.implementations.delays
1706
- }, enqueue);
1719
+ const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents, false, options?.resolveActions ?? true);
1720
+ const res = transition.to(transitionArgs, enqueue);
1707
1721
  const targets = res?.target ? resolveTarget(transition.source, toArray(res.target)) : undefined;
1708
1722
  // Resolve input for .to transitions
1709
1723
  const resolvedInput = typeof transition.input === 'function' ? transition.input({
@@ -1727,9 +1741,10 @@ function getTransitionResult(transition, snapshot, event, actorScope) {
1727
1741
  event,
1728
1742
  output: getEventOutput(event)
1729
1743
  }) : transition.input;
1744
+ const resolvedContext = typeof transition.context === 'function' ? transition.context(transitionArgs) : transition.context;
1730
1745
  return {
1731
1746
  targets: transition.target,
1732
- context: transition.context,
1747
+ context: resolvedContext,
1733
1748
  reenter: transition.reenter,
1734
1749
  actions: undefined,
1735
1750
  internalEvents: undefined,
@@ -2000,7 +2015,9 @@ const machineSnapshotCan = function can(event) {
2000
2015
  if (transition.target !== undefined) {
2001
2016
  return true;
2002
2017
  }
2003
- const res = getTransitionResult(transition, this, event, emptyActorScope);
2018
+ const res = getTransitionResult(transition, this, event, emptyActorScope, {
2019
+ resolveActions: false
2020
+ });
2004
2021
  if (res.targets?.length || res.context || hasEffect(transition, this.context, event, this, emptyActor)) {
2005
2022
  return true;
2006
2023
  }
@@ -4388,7 +4405,10 @@ exports.ProcessingStatus = ProcessingStatus;
4388
4405
  exports.STATE_DELIMITER = STATE_DELIMITER;
4389
4406
  exports.TimeoutError = TimeoutError;
4390
4407
  exports.XSTATE_INIT = XSTATE_INIT;
4408
+ exports.XSTATE_STOP = XSTATE_STOP;
4409
+ exports.builtInActions = builtInActions;
4391
4410
  exports.checkStateIn = checkStateIn;
4411
+ exports.cloneMachineSnapshot = cloneMachineSnapshot;
4392
4412
  exports.createActor = createActor;
4393
4413
  exports.createAsyncLogic = createAsyncLogic;
4394
4414
  exports.createCallbackLogic = createCallbackLogic;
@@ -4402,6 +4422,7 @@ exports.createLogic = createLogic;
4402
4422
  exports.createMachineSnapshot = createMachineSnapshot;
4403
4423
  exports.createObservableLogic = createObservableLogic;
4404
4424
  exports.createSubscriptionLogic = createSubscriptionLogic;
4425
+ exports.createTransitionEnqueue = createTransitionEnqueue;
4405
4426
  exports.evaluateCandidate = evaluateCandidate;
4406
4427
  exports.formatRouteTransitions = formatRouteTransitions;
4407
4428
  exports.formatTransition = formatTransition;
@@ -382,7 +382,7 @@ function pushStartedChild(actions, actor, id) {
382
382
  pushBuiltInAction(actions, builtInActions['@xstate.start'], actor);
383
383
  actions.push(registerSpawnedChild(actor, id ?? actor.id));
384
384
  }
385
- function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubscriptions = false) {
385
+ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubscriptions = false, createActors = true) {
386
386
  const props = {
387
387
  cancel: id => {
388
388
  pushBuiltInAction(actions, builtInActions['@xstate.cancel'], actorScope, id);
@@ -404,6 +404,12 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
404
404
  }
405
405
  },
406
406
  spawn: (logic, options) => {
407
+ if (!createActors) {
408
+ // TODO: replace this speculative placeholder with a typed inert actor ref.
409
+ return {
410
+ id: options?.id ?? options?.registryKey ?? logic.id
411
+ };
412
+ }
407
413
  const actor = createActor(logic, {
408
414
  ...options,
409
415
  parent: actorScope.self
@@ -918,9 +924,6 @@ function formatRouteTransitions(rootStateNode) {
918
924
  }
919
925
  return;
920
926
  }
921
- if ('$unserializable' in routeConfig) {
922
- throw new Error(`State "${sn.id}" has a route that is not serializable. Re-provide the route function when reviving this machine.`);
923
- }
924
927
  const {
925
928
  guard: _guard,
926
929
  ...routeOptions
@@ -1182,7 +1185,9 @@ function getEffectiveTargetStates(transition, snapshot, event, actorScope) {
1182
1185
  const historyValue = snapshot.historyValue;
1183
1186
  const {
1184
1187
  targets
1185
- } = getTransitionResult(transition, snapshot, event, actorScope);
1188
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1189
+ resolveActions: false
1190
+ });
1186
1191
  if (!targets) {
1187
1192
  return [];
1188
1193
  }
@@ -1208,7 +1213,9 @@ function getTransitionDomain(transition, snapshot, event, actorScope) {
1208
1213
  const targetStates = getEffectiveTargetStates(transition, snapshot, event, actorScope);
1209
1214
  const {
1210
1215
  reenter
1211
- } = getTransitionResult(transition, snapshot, event, actorScope);
1216
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1217
+ resolveActions: false
1218
+ });
1212
1219
  if (!reenter && targetStates.every(target => target === transition.source || isDescendant(target, transition.source))) {
1213
1220
  return transition.source;
1214
1221
  }
@@ -1231,7 +1238,9 @@ function computeExitSet(transitions, stateNodeSet, snapshot, event, actorScope)
1231
1238
  for (const transition of transitions) {
1232
1239
  const {
1233
1240
  targets
1234
- } = getTransitionResult(transition, snapshot, event, actorScope);
1241
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1242
+ resolveActions: false
1243
+ });
1235
1244
  if (targets?.length) {
1236
1245
  const domain = getTransitionDomain(transition, snapshot, event, actorScope);
1237
1246
  if (transition.reenter && transition.source === domain) {
@@ -1471,7 +1480,9 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1471
1480
  const {
1472
1481
  targets,
1473
1482
  reenter
1474
- } = getCurrentTransitionResult(transition);
1483
+ } = getTransitionResult(transition, currentSnapshot, event, actorScope, {
1484
+ resolveActions: false
1485
+ });
1475
1486
  for (const targetNode of targets ?? []) {
1476
1487
  if (!isHistoryNode(targetNode) && (transition.source !== targetNode || transition.source !== domain || reenter)) {
1477
1488
  statesToEnter.add(targetNode);
@@ -1498,7 +1509,9 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1498
1509
  const {
1499
1510
  targets,
1500
1511
  input
1501
- } = getCurrentTransitionResult(transition);
1512
+ } = getTransitionResult(transition, currentSnapshot, event, actorScope, {
1513
+ resolveActions: false
1514
+ });
1502
1515
  if (input && targets) {
1503
1516
  for (const targetNode of targets) {
1504
1517
  stateInputMap[targetNode.id] = input;
@@ -1683,25 +1696,26 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1683
1696
  * Gets the transition result for a given transition without executing the
1684
1697
  * transition.
1685
1698
  */
1686
- function getTransitionResult(transition, snapshot, event, actorScope) {
1699
+ function getTransitionResult(transition, snapshot, event, actorScope, options) {
1700
+ const transitionArgs = {
1701
+ context: snapshot.context,
1702
+ event,
1703
+ output: getEventOutput(event),
1704
+ value: snapshot.value,
1705
+ children: snapshot.children,
1706
+ system: actorScope.system,
1707
+ parent: actorScope.self._parent,
1708
+ self: actorScope.self,
1709
+ actions: snapshot.machine.implementations.actions,
1710
+ actorSources: snapshot.machine.implementations.actorSources,
1711
+ guards: snapshot.machine.implementations.guards,
1712
+ delays: snapshot.machine.implementations.delays
1713
+ };
1687
1714
  if (transition.to) {
1688
1715
  const actions = [];
1689
1716
  const internalEvents = [];
1690
- const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents);
1691
- const res = transition.to({
1692
- context: snapshot.context,
1693
- event,
1694
- output: getEventOutput(event),
1695
- value: snapshot.value,
1696
- children: snapshot.children,
1697
- system: actorScope.system,
1698
- parent: actorScope.self._parent,
1699
- self: actorScope.self,
1700
- actions: snapshot.machine.implementations.actions,
1701
- actorSources: snapshot.machine.implementations.actorSources,
1702
- guards: snapshot.machine.implementations.guards,
1703
- delays: snapshot.machine.implementations.delays
1704
- }, enqueue);
1717
+ const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents, false, options?.resolveActions ?? true);
1718
+ const res = transition.to(transitionArgs, enqueue);
1705
1719
  const targets = res?.target ? resolveTarget(transition.source, toArray(res.target)) : undefined;
1706
1720
  // Resolve input for .to transitions
1707
1721
  const resolvedInput = typeof transition.input === 'function' ? transition.input({
@@ -1725,9 +1739,10 @@ function getTransitionResult(transition, snapshot, event, actorScope) {
1725
1739
  event,
1726
1740
  output: getEventOutput(event)
1727
1741
  }) : transition.input;
1742
+ const resolvedContext = typeof transition.context === 'function' ? transition.context(transitionArgs) : transition.context;
1728
1743
  return {
1729
1744
  targets: transition.target,
1730
- context: transition.context,
1745
+ context: resolvedContext,
1731
1746
  reenter: transition.reenter,
1732
1747
  actions: undefined,
1733
1748
  internalEvents: undefined,
@@ -1998,7 +2013,9 @@ const machineSnapshotCan = function can(event) {
1998
2013
  if (transition.target !== undefined) {
1999
2014
  return true;
2000
2015
  }
2001
- const res = getTransitionResult(transition, this, event, emptyActorScope);
2016
+ const res = getTransitionResult(transition, this, event, emptyActorScope, {
2017
+ resolveActions: false
2018
+ });
2002
2019
  if (res.targets?.length || res.context || hasEffect(transition, this.context, event, this, emptyActor)) {
2003
2020
  return true;
2004
2021
  }
@@ -4379,4 +4396,4 @@ function createEmptyActor() {
4379
4396
  return createActor(emptyLogic);
4380
4397
  }
4381
4398
 
4382
- export { $$ACTOR_TYPE as $, Actor as A, subscriptionLogic as B, resolveReferencedActor as C, mapValues as D, createInvokeId as E, getDelayedTransitions as F, evaluateCandidate as G, formatTransition as H, toTransitionConfigArray as I, createInvokeTimeoutEvent as J, getCandidates as K, formatRouteTransitions as L, resolveStateValue as M, NULL_EVENT as N, getAllStateNodes as O, ProcessingStatus as P, createMachineSnapshot as Q, isInFinalState as R, STATE_DELIMITER as S, TimeoutError as T, transitionNode as U, resolveActionsWithContext as V, toStatePath as W, isStateId as X, getStateNodeByPath as Y, getPersistedSnapshot as Z, XSTATE_INIT as _, macrostep as a, createInitEvent as b, createActor as c, initialMicrostep as d, isMachineSnapshot as e, getStateNodes as f, getProperAncestors as g, getAllOwnEventDescriptors as h, isAtomicStateNode as i, matchesState as j, checkStateIn as k, pathToStateValue as l, matchesEventDescriptor as m, toObserver as n, isBuiltInExecutableAction as o, parseDelayToMilliseconds as p, createEmptyActor as q, createCallbackLogic as r, createObservableLogic as s, toArray as t, createEventObservableLogic as u, createLogic as v, createAsyncLogic as w, createListenerLogic as x, listenerLogic as y, createSubscriptionLogic as z };
4399
+ export { toStatePath as $, Actor as A, createAsyncLogic as B, createListenerLogic as C, listenerLogic as D, createSubscriptionLogic as E, subscriptionLogic as F, resolveReferencedActor as G, mapValues as H, createInvokeId as I, getDelayedTransitions as J, evaluateCandidate as K, formatTransition as L, toTransitionConfigArray as M, NULL_EVENT as N, createInvokeTimeoutEvent as O, ProcessingStatus as P, getCandidates as Q, formatRouteTransitions as R, STATE_DELIMITER as S, TimeoutError as T, resolveStateValue as U, getAllStateNodes as V, createMachineSnapshot as W, XSTATE_INIT as X, isInFinalState as Y, cloneMachineSnapshot as Z, transitionNode as _, XSTATE_STOP as a, isStateId as a0, getStateNodeByPath as a1, getPersistedSnapshot as a2, $$ACTOR_TYPE as a3, builtInActions as b, createTransitionEnqueue as c, createActor as d, macrostep as e, createInitEvent as f, initialMicrostep as g, getProperAncestors as h, isAtomicStateNode as i, isMachineSnapshot as j, getStateNodes as k, getAllOwnEventDescriptors as l, matchesEventDescriptor as m, matchesState as n, checkStateIn as o, parseDelayToMilliseconds as p, pathToStateValue as q, resolveActionsWithContext as r, toObserver as s, toArray as t, isBuiltInExecutableAction as u, createEmptyActor as v, createCallbackLogic as w, createObservableLogic as x, createEventObservableLogic as y, createLogic as z };
@@ -383,7 +383,7 @@ function pushStartedChild(actions, actor, id) {
383
383
  pushBuiltInAction(actions, builtInActions['@xstate.start'], actor);
384
384
  actions.push(registerSpawnedChild(actor, id ?? actor.id));
385
385
  }
386
- function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubscriptions = false) {
386
+ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubscriptions = false, createActors = true) {
387
387
  const props = {
388
388
  cancel: id => {
389
389
  pushBuiltInAction(actions, builtInActions['@xstate.cancel'], actorScope, id);
@@ -405,6 +405,12 @@ function createTransitionEnqueue(actorScope, actions, internalEvents, actorSubsc
405
405
  }
406
406
  },
407
407
  spawn: (logic, options) => {
408
+ if (!createActors) {
409
+ // TODO: replace this speculative placeholder with a typed inert actor ref.
410
+ return {
411
+ id: options?.id ?? options?.registryKey ?? logic.id
412
+ };
413
+ }
408
414
  const actor = createActor(logic, {
409
415
  ...options,
410
416
  parent: actorScope.self
@@ -929,9 +935,6 @@ function formatRouteTransitions(rootStateNode) {
929
935
  }
930
936
  return;
931
937
  }
932
- if ('$unserializable' in routeConfig) {
933
- throw new Error(`State "${sn.id}" has a route that is not serializable. Re-provide the route function when reviving this machine.`);
934
- }
935
938
  const {
936
939
  guard: _guard,
937
940
  ...routeOptions
@@ -1193,7 +1196,9 @@ function getEffectiveTargetStates(transition, snapshot, event, actorScope) {
1193
1196
  const historyValue = snapshot.historyValue;
1194
1197
  const {
1195
1198
  targets
1196
- } = getTransitionResult(transition, snapshot, event, actorScope);
1199
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1200
+ resolveActions: false
1201
+ });
1197
1202
  if (!targets) {
1198
1203
  return [];
1199
1204
  }
@@ -1219,7 +1224,9 @@ function getTransitionDomain(transition, snapshot, event, actorScope) {
1219
1224
  const targetStates = getEffectiveTargetStates(transition, snapshot, event, actorScope);
1220
1225
  const {
1221
1226
  reenter
1222
- } = getTransitionResult(transition, snapshot, event, actorScope);
1227
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1228
+ resolveActions: false
1229
+ });
1223
1230
  if (!reenter && targetStates.every(target => target === transition.source || isDescendant(target, transition.source))) {
1224
1231
  return transition.source;
1225
1232
  }
@@ -1242,7 +1249,9 @@ function computeExitSet(transitions, stateNodeSet, snapshot, event, actorScope)
1242
1249
  for (const transition of transitions) {
1243
1250
  const {
1244
1251
  targets
1245
- } = getTransitionResult(transition, snapshot, event, actorScope);
1252
+ } = getTransitionResult(transition, snapshot, event, actorScope, {
1253
+ resolveActions: false
1254
+ });
1246
1255
  if (targets?.length) {
1247
1256
  const domain = getTransitionDomain(transition, snapshot, event, actorScope);
1248
1257
  if (transition.reenter && transition.source === domain) {
@@ -1482,7 +1491,9 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1482
1491
  const {
1483
1492
  targets,
1484
1493
  reenter
1485
- } = getCurrentTransitionResult(transition);
1494
+ } = getTransitionResult(transition, currentSnapshot, event, actorScope, {
1495
+ resolveActions: false
1496
+ });
1486
1497
  for (const targetNode of targets ?? []) {
1487
1498
  if (!isHistoryNode(targetNode) && (transition.source !== targetNode || transition.source !== domain || reenter)) {
1488
1499
  statesToEnter.add(targetNode);
@@ -1509,7 +1520,9 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1509
1520
  const {
1510
1521
  targets,
1511
1522
  input
1512
- } = getCurrentTransitionResult(transition);
1523
+ } = getTransitionResult(transition, currentSnapshot, event, actorScope, {
1524
+ resolveActions: false
1525
+ });
1513
1526
  if (input && targets) {
1514
1527
  for (const targetNode of targets) {
1515
1528
  stateInputMap[targetNode.id] = input;
@@ -1694,25 +1707,26 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
1694
1707
  * Gets the transition result for a given transition without executing the
1695
1708
  * transition.
1696
1709
  */
1697
- function getTransitionResult(transition, snapshot, event, actorScope) {
1710
+ function getTransitionResult(transition, snapshot, event, actorScope, options) {
1711
+ const transitionArgs = {
1712
+ context: snapshot.context,
1713
+ event,
1714
+ output: getEventOutput(event),
1715
+ value: snapshot.value,
1716
+ children: snapshot.children,
1717
+ system: actorScope.system,
1718
+ parent: actorScope.self._parent,
1719
+ self: actorScope.self,
1720
+ actions: snapshot.machine.implementations.actions,
1721
+ actorSources: snapshot.machine.implementations.actorSources,
1722
+ guards: snapshot.machine.implementations.guards,
1723
+ delays: snapshot.machine.implementations.delays
1724
+ };
1698
1725
  if (transition.to) {
1699
1726
  const actions = [];
1700
1727
  const internalEvents = [];
1701
- const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents);
1702
- const res = transition.to({
1703
- context: snapshot.context,
1704
- event,
1705
- output: getEventOutput(event),
1706
- value: snapshot.value,
1707
- children: snapshot.children,
1708
- system: actorScope.system,
1709
- parent: actorScope.self._parent,
1710
- self: actorScope.self,
1711
- actions: snapshot.machine.implementations.actions,
1712
- actorSources: snapshot.machine.implementations.actorSources,
1713
- guards: snapshot.machine.implementations.guards,
1714
- delays: snapshot.machine.implementations.delays
1715
- }, enqueue);
1728
+ const enqueue = createTransitionEnqueue(actorScope, actions, internalEvents, false, options?.resolveActions ?? true);
1729
+ const res = transition.to(transitionArgs, enqueue);
1716
1730
  const targets = res?.target ? resolveTarget(transition.source, toArray(res.target)) : undefined;
1717
1731
  // Resolve input for .to transitions
1718
1732
  const resolvedInput = typeof transition.input === 'function' ? transition.input({
@@ -1736,9 +1750,10 @@ function getTransitionResult(transition, snapshot, event, actorScope) {
1736
1750
  event,
1737
1751
  output: getEventOutput(event)
1738
1752
  }) : transition.input;
1753
+ const resolvedContext = typeof transition.context === 'function' ? transition.context(transitionArgs) : transition.context;
1739
1754
  return {
1740
1755
  targets: transition.target,
1741
- context: transition.context,
1756
+ context: resolvedContext,
1742
1757
  reenter: transition.reenter,
1743
1758
  actions: undefined,
1744
1759
  internalEvents: undefined,
@@ -2012,7 +2027,9 @@ const machineSnapshotCan = function can(event) {
2012
2027
  if (transition.target !== undefined) {
2013
2028
  return true;
2014
2029
  }
2015
- const res = getTransitionResult(transition, this, event, emptyActorScope);
2030
+ const res = getTransitionResult(transition, this, event, emptyActorScope, {
2031
+ resolveActions: false
2032
+ });
2016
2033
  if (res.targets?.length || res.context || hasEffect(transition, this.context, event, this, emptyActor)) {
2017
2034
  return true;
2018
2035
  }
@@ -4418,4 +4435,4 @@ function createEmptyActor() {
4418
4435
  return createActor(emptyLogic);
4419
4436
  }
4420
4437
 
4421
- export { $$ACTOR_TYPE as $, Actor as A, subscriptionLogic as B, resolveReferencedActor as C, mapValues as D, createInvokeId as E, getDelayedTransitions as F, evaluateCandidate as G, formatTransition as H, toTransitionConfigArray as I, createInvokeTimeoutEvent as J, getCandidates as K, formatRouteTransitions as L, resolveStateValue as M, NULL_EVENT as N, getAllStateNodes as O, ProcessingStatus as P, createMachineSnapshot as Q, isInFinalState as R, STATE_DELIMITER as S, TimeoutError as T, transitionNode as U, resolveActionsWithContext as V, toStatePath as W, isStateId as X, getStateNodeByPath as Y, getPersistedSnapshot as Z, XSTATE_INIT as _, macrostep as a, createInitEvent as b, createActor as c, initialMicrostep as d, isMachineSnapshot as e, getStateNodes as f, getProperAncestors as g, getAllOwnEventDescriptors as h, isAtomicStateNode as i, matchesState as j, checkStateIn as k, pathToStateValue as l, matchesEventDescriptor as m, toObserver as n, isBuiltInExecutableAction as o, parseDelayToMilliseconds as p, createEmptyActor as q, createCallbackLogic as r, createObservableLogic as s, toArray as t, createEventObservableLogic as u, createLogic as v, createAsyncLogic as w, createListenerLogic as x, listenerLogic as y, createSubscriptionLogic as z };
4438
+ export { toStatePath as $, Actor as A, createAsyncLogic as B, createListenerLogic as C, listenerLogic as D, createSubscriptionLogic as E, subscriptionLogic as F, resolveReferencedActor as G, mapValues as H, createInvokeId as I, getDelayedTransitions as J, evaluateCandidate as K, formatTransition as L, toTransitionConfigArray as M, NULL_EVENT as N, createInvokeTimeoutEvent as O, ProcessingStatus as P, getCandidates as Q, formatRouteTransitions as R, STATE_DELIMITER as S, TimeoutError as T, resolveStateValue as U, getAllStateNodes as V, createMachineSnapshot as W, XSTATE_INIT as X, isInFinalState as Y, cloneMachineSnapshot as Z, transitionNode as _, XSTATE_STOP as a, isStateId as a0, getStateNodeByPath as a1, getPersistedSnapshot as a2, $$ACTOR_TYPE as a3, builtInActions as b, createTransitionEnqueue as c, createActor as d, macrostep as e, createInitEvent as f, initialMicrostep as g, getProperAncestors as h, isAtomicStateNode as i, isMachineSnapshot as j, getStateNodes as k, getAllOwnEventDescriptors as l, matchesEventDescriptor as m, matchesState as n, checkStateIn as o, parseDelayToMilliseconds as p, pathToStateValue as q, resolveActionsWithContext as r, toObserver as s, toArray as t, isBuiltInExecutableAction as u, createEmptyActor as v, createCallbackLogic as w, createObservableLogic as x, createEventObservableLogic as y, createLogic as z };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_xstateActors = require('./index-559ceab3.cjs.js');
5
+ var dist_xstateActors = require('./index-32631949.cjs.js');
6
6
 
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_xstateActors = require('./index-219cb621.development.cjs.js');
5
+ var dist_xstateActors = require('./index-08d86676.development.cjs.js');
6
6
 
7
7
 
8
8
 
@@ -1 +1 @@
1
- export { T as TimeoutError, w as createAsyncLogic, r as createCallbackLogic, q as createEmptyActor, u as createEventObservableLogic, x as createListenerLogic, v as createLogic, s as createObservableLogic, z as createSubscriptionLogic, y as listenerLogic, B as subscriptionLogic } from './index-2f2fbd9b.development.esm.js';
1
+ export { T as TimeoutError, B as createAsyncLogic, w as createCallbackLogic, v as createEmptyActor, y as createEventObservableLogic, C as createListenerLogic, z as createLogic, x as createObservableLogic, E as createSubscriptionLogic, D as listenerLogic, F as subscriptionLogic } from './index-7081e0c9.development.esm.js';
@@ -1 +1 @@
1
- export { T as TimeoutError, w as createAsyncLogic, r as createCallbackLogic, q as createEmptyActor, u as createEventObservableLogic, x as createListenerLogic, v as createLogic, s as createObservableLogic, z as createSubscriptionLogic, y as listenerLogic, B as subscriptionLogic } from './index-8828376f.esm.js';
1
+ export { T as TimeoutError, B as createAsyncLogic, w as createCallbackLogic, v as createEmptyActor, y as createEventObservableLogic, C as createListenerLogic, z as createLogic, x as createObservableLogic, E as createSubscriptionLogic, D as listenerLogic, F as subscriptionLogic } from './index-603c1cda.esm.js';