xstate 6.0.0-alpha.50 → 6.0.0-alpha.52

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 (75) hide show
  1. package/README.md +13 -8
  2. package/dist/{createActor-27fd819f.cjs.js → createActor-20277025.cjs.js} +6 -2
  3. package/dist/{createActor-74e185ee.development.esm.js → createActor-41e3bbc3.development.esm.js} +7 -1
  4. package/dist/{createActor-ea9a560c.development.cjs.js → createActor-4d94dd53.development.cjs.js} +6 -2
  5. package/dist/{createActor-ad3a1abe.esm.js → createActor-6fa87eea.esm.js} +7 -1
  6. package/dist/declarations/src/fsm/index.d.ts +2 -2
  7. package/dist/declarations/src/fsm.d.ts +120 -64
  8. package/dist/declarations/src/graph/graph.d.ts +1 -0
  9. package/dist/declarations/src/index.d.ts +2 -2
  10. package/dist/declarations/src/schema.types.d.ts +4 -1
  11. package/dist/declarations/src/setup.d.ts +565 -62
  12. package/dist/declarations/src/types.d.ts +3 -1
  13. package/dist/declarations/src/types.v6.d.ts +14 -12
  14. package/dist/{effectDescriptor-40ca302f.development.cjs.js → effectDescriptor-6991ab90.development.cjs.js} +1 -1
  15. package/dist/{effectDescriptor-7dac431a.esm.js → effectDescriptor-c56bd9d5.esm.js} +1 -1
  16. package/dist/{effectDescriptor-38598bd3.development.esm.js → effectDescriptor-e64efd18.development.esm.js} +1 -1
  17. package/dist/{effectDescriptor-16b6f3b4.cjs.js → effectDescriptor-fa21710c.cjs.js} +1 -1
  18. package/dist/schema.types-1b4319f7.development.esm.js +108 -0
  19. package/dist/schema.types-20693e6b.cjs.js +113 -0
  20. package/dist/schema.types-7439a117.esm.js +108 -0
  21. package/dist/schema.types-a2b10853.development.cjs.js +113 -0
  22. package/dist/{StateMachine-1e6ee14a.cjs.js → types-5d934c5c.cjs.js} +191 -1
  23. package/dist/{StateMachine-bc28e207.development.esm.js → types-63cc2400.development.esm.js} +189 -2
  24. package/dist/{StateMachine-70df737c.development.cjs.js → types-84a9c6a1.development.cjs.js} +191 -1
  25. package/dist/{StateMachine-8cea8974.esm.js → types-ab7eb7a3.esm.js} +189 -2
  26. package/dist/xstate-actors.cjs.js +1 -1
  27. package/dist/xstate-actors.development.cjs.js +1 -1
  28. package/dist/xstate-actors.development.esm.js +2 -2
  29. package/dist/xstate-actors.esm.js +2 -2
  30. package/dist/xstate-actors.umd.min.js.map +1 -1
  31. package/dist/xstate-durable.cjs.js +2 -2
  32. package/dist/xstate-durable.development.cjs.js +2 -2
  33. package/dist/xstate-durable.development.esm.js +2 -2
  34. package/dist/xstate-durable.esm.js +2 -2
  35. package/dist/xstate-durable.umd.min.js.map +1 -1
  36. package/dist/xstate-fsm.cjs.js +4 -402
  37. package/dist/xstate-fsm.cjs.mjs +2 -2
  38. package/dist/xstate-fsm.development.cjs.js +4 -402
  39. package/dist/xstate-fsm.development.cjs.mjs +2 -2
  40. package/dist/xstate-fsm.development.esm.js +1 -403
  41. package/dist/xstate-fsm.esm.js +1 -403
  42. package/dist/xstate-fsm.umd.min.js +1 -1
  43. package/dist/xstate-fsm.umd.min.js.map +1 -1
  44. package/dist/xstate-graph.cjs.js +9 -8
  45. package/dist/xstate-graph.development.cjs.js +9 -8
  46. package/dist/xstate-graph.development.esm.js +9 -8
  47. package/dist/xstate-graph.esm.js +9 -8
  48. package/dist/xstate-graph.umd.min.js +1 -1
  49. package/dist/xstate-graph.umd.min.js.map +1 -1
  50. package/dist/xstate-scxml.cjs.js +2 -3
  51. package/dist/xstate-scxml.development.cjs.js +2 -3
  52. package/dist/xstate-scxml.development.esm.js +2 -3
  53. package/dist/xstate-scxml.esm.js +2 -3
  54. package/dist/xstate-scxml.umd.min.js +1 -1
  55. package/dist/xstate-scxml.umd.min.js.map +1 -1
  56. package/dist/xstate-validation.cjs.js +1 -1
  57. package/dist/xstate-validation.development.cjs.js +1 -1
  58. package/dist/xstate-validation.development.esm.js +1 -1
  59. package/dist/xstate-validation.esm.js +1 -1
  60. package/dist/xstate.cjs.js +71 -75
  61. package/dist/xstate.development.cjs.js +71 -75
  62. package/dist/xstate.development.esm.js +64 -69
  63. package/dist/xstate.esm.js +64 -69
  64. package/dist/xstate.umd.min.js +1 -1
  65. package/dist/xstate.umd.min.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/declarations/src/fsm/createFSMActor.d.ts +0 -67
  68. package/dist/fsm-25f10f50.development.esm.js +0 -775
  69. package/dist/fsm-697ffd89.development.cjs.js +0 -777
  70. package/dist/fsm-7adaf0ea.cjs.js +0 -777
  71. package/dist/fsm-dc1bb88b.esm.js +0 -775
  72. package/dist/types-a14db10c.development.cjs.js +0 -194
  73. package/dist/types-a313e7e2.esm.js +0 -190
  74. package/dist/types-bc22b358.cjs.js +0 -194
  75. package/dist/types-c37714eb.development.esm.js +0 -190
package/README.md CHANGED
@@ -17,28 +17,33 @@ XState is a state management and orchestration solution for JavaScript and TypeS
17
17
 
18
18
  It uses event-driven programming, state machines, statecharts, and the actor model to handle complex logic in predictable, robust, and visual ways. XState provides a powerful and flexible way to manage application and workflow state by allowing developers to model logic as actors and state machines.
19
19
 
20
- For flat finite state machines, `xstate/fsm` provides a self-contained compact
21
- runtime and a specialized actor:
20
+ For flat finite state machines, `xstate/fsm` provides a tiny pure transition
21
+ table with context and TypeScript support:
22
22
 
23
23
  <!-- public exports from packages/core/src/fsm/index.ts; exact capabilities documented in docs/fsm.md -->
24
24
 
25
25
  ```ts
26
- import { createFSM, createFSMActor } from 'xstate/fsm';
26
+ import { createFSM } from 'xstate/fsm';
27
27
 
28
- const logic = createFSM({
28
+ const machine = createFSM({
29
29
  initial: 'inactive',
30
30
  states: {
31
- inactive: { on: { toggle: { target: 'active' } } },
32
- active: { on: { toggle: { target: 'inactive' } } }
31
+ inactive: { on: { toggle: 'active' } },
32
+ active: { on: { toggle: 'inactive' } }
33
33
  }
34
34
  });
35
35
 
36
- const actor = createFSMActor(logic).start();
36
+ let state = machine.initialState;
37
+ state = machine.transition(state, { type: 'toggle' });
37
38
  ```
38
39
 
40
+ For typed context, event payloads, or state-specific context snapshots, use
41
+ `setup` and `types` from `xstate/fsm`. These schemas are type-only in this
42
+ subpath; use root `xstate` for runtime schema validation.
43
+
39
44
  See the [exact supported surface](https://stately.ai/docs/fsm). Use the root `xstate`
40
45
  entry point for compound or parallel statecharts, invocation, named sources,
41
- schemas, serialization and inspection.
46
+ runtime schemas, serialization and inspection.
42
47
 
43
48
  ### ✨ Create state machines visually in Stately Studio → [state.new](https://state.new)
44
49
 
@@ -983,6 +983,7 @@ function getBuiltInActionFields(action, args) {
983
983
  {
984
984
  const [actor] = args;
985
985
  return {
986
+ type: '@xstate.spawn',
986
987
  kind: 'builtin',
987
988
  exec: execSpawnEffect,
988
989
  source: actor._parent,
@@ -997,6 +998,7 @@ function getBuiltInActionFields(action, args) {
997
998
  {
998
999
  const [, event, options] = args;
999
1000
  return {
1001
+ type: '@xstate.raise',
1000
1002
  kind: 'builtin',
1001
1003
  exec: execRaiseEffect,
1002
1004
  source: args[0].self,
@@ -1009,6 +1011,7 @@ function getBuiltInActionFields(action, args) {
1009
1011
  {
1010
1012
  const [, target, event, options] = args;
1011
1013
  return {
1014
+ type: '@xstate.sendTo',
1012
1015
  kind: 'builtin',
1013
1016
  exec: execSendToEffect,
1014
1017
  source: args[0].self,
@@ -1022,6 +1025,7 @@ function getBuiltInActionFields(action, args) {
1022
1025
  {
1023
1026
  const [, id] = args;
1024
1027
  return {
1028
+ type: '@xstate.cancel',
1025
1029
  kind: 'builtin',
1026
1030
  exec: execCancelEffect,
1027
1031
  source: args[0].self,
@@ -1032,6 +1036,7 @@ function getBuiltInActionFields(action, args) {
1032
1036
  {
1033
1037
  const [, actor] = args;
1034
1038
  return {
1039
+ type: '@xstate.stop',
1035
1040
  kind: 'builtin',
1036
1041
  exec: execStopEffect,
1037
1042
  source: args[0].self,
@@ -2987,6 +2992,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
2987
2992
  self: actorScope.self,
2988
2993
  context: nextState.context,
2989
2994
  event,
2995
+ input: stateInputMap[stateNodeToEnter.id],
2990
2996
  output: getEventOutput(event)
2991
2997
  }) : invokeDef.input;
2992
2998
  assertChildIdFree(actorScope, invokeDef.id);
@@ -5889,7 +5895,6 @@ exports.isAtomicStateNode = isAtomicStateNode;
5889
5895
  exports.isBuiltInExecutableAction = isBuiltInExecutableAction;
5890
5896
  exports.isInFinalState = isInFinalState;
5891
5897
  exports.isInertActorScope = isInertActorScope;
5892
- exports.isLazyActorScope = isLazyActorScope;
5893
5898
  exports.isMachineSnapshot = isMachineSnapshot;
5894
5899
  exports.isRemoteActorRef = isRemoteActorRef;
5895
5900
  exports.isStateId = isStateId;
@@ -5921,7 +5926,6 @@ exports.toObserver = toObserver;
5921
5926
  exports.toStatePath = toStatePath;
5922
5927
  exports.toTransitionConfigArray = toTransitionConfigArray;
5923
5928
  exports.transitionNode = transitionNode;
5924
- exports.withActorScope = withActorScope;
5925
5929
  exports.withActorSelf = withActorSelf;
5926
5930
  exports.withExecutionIdentity = withExecutionIdentity;
5927
5931
  exports.withSystemInspector = withSystemInspector;
@@ -989,6 +989,7 @@ function getBuiltInActionFields(action, args) {
989
989
  {
990
990
  const [actor] = args;
991
991
  return {
992
+ type: '@xstate.spawn',
992
993
  kind: 'builtin',
993
994
  exec: execSpawnEffect,
994
995
  source: actor._parent,
@@ -1003,6 +1004,7 @@ function getBuiltInActionFields(action, args) {
1003
1004
  {
1004
1005
  const [, event, options] = args;
1005
1006
  return {
1007
+ type: '@xstate.raise',
1006
1008
  kind: 'builtin',
1007
1009
  exec: execRaiseEffect,
1008
1010
  source: args[0].self,
@@ -1015,6 +1017,7 @@ function getBuiltInActionFields(action, args) {
1015
1017
  {
1016
1018
  const [, target, event, options] = args;
1017
1019
  return {
1020
+ type: '@xstate.sendTo',
1018
1021
  kind: 'builtin',
1019
1022
  exec: execSendToEffect,
1020
1023
  source: args[0].self,
@@ -1028,6 +1031,7 @@ function getBuiltInActionFields(action, args) {
1028
1031
  {
1029
1032
  const [, id] = args;
1030
1033
  return {
1034
+ type: '@xstate.cancel',
1031
1035
  kind: 'builtin',
1032
1036
  exec: execCancelEffect,
1033
1037
  source: args[0].self,
@@ -1038,6 +1042,7 @@ function getBuiltInActionFields(action, args) {
1038
1042
  {
1039
1043
  const [, actor] = args;
1040
1044
  return {
1045
+ type: '@xstate.stop',
1041
1046
  kind: 'builtin',
1042
1047
  exec: execStopEffect,
1043
1048
  source: args[0].self,
@@ -3003,6 +3008,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
3003
3008
  self: actorScope.self,
3004
3009
  context: nextState.context,
3005
3010
  event,
3011
+ input: stateInputMap[stateNodeToEnter.id],
3006
3012
  output: getEventOutput(event)
3007
3013
  }) : invokeDef.input;
3008
3014
  assertChildIdFree(actorScope, invokeDef.id);
@@ -5863,4 +5869,4 @@ function createActor(logic, options) {
5863
5869
  return new Actor(logic, options);
5864
5870
  }
5865
5871
 
5866
- export { createInvokeTimeoutEventId as $, Actor as A, createCustomEffect as B, XSTATE_LOGIC_EFFECT_START as C, XSTATE_LOGIC_EFFECT_RESOLVE as D, XSTATE_LOGIC_EFFECT_REJECT as E, finalizeTransitionResult as F, createEmitEffect as G, createSendToEffect as H, XSTATE_INIT as I, withActorScope as J, XSTATE_TIMER as K, isLazyActorScope as L, resolveRegisteredActorSource as M, allocateChildId as N, assertChildIdFree as O, reserveChildId as P, mapValues as Q, createInvokeId as R, STATE_DELIMITER as S, getDelayedTransitions as T, getEventDescriptorKey as U, getCandidates as V, evaluateCandidate as W, XSTATE_STOP as X, formatTransition as Y, NULL_EVENT as Z, toTransitionConfigArray as _, createListenerLogic as a, matchesActorSession as a0, formatRouteTransitions as a1, resolveStateValue as a2, getAllStateNodes as a3, createMachineSnapshot as a4, isInFinalState as a5, createInertActorScope as a6, setInertActorScopeSnapshot as a7, beginSpawnAllocation as a8, attachSnapshotActorRef as a9, getActorIdPrefix as aA, getAllOwnEvents as aB, matchesEvent as aC, encodeAddressSegment as aD, getRootActorId as aE, RUNTIME_OPERATIONS as aF, withSystemInspector as aG, getSnapshotActorRef as aH, withExecutionIdentity as aI, macrostep as aa, isInertActorScope as ab, setSnapshotActorRef as ac, cloneMachineSnapshot as ad, transitionNode as ae, getTransitionResult as af, hasEffect as ag, createErrorPlatformEvent as ah, withActorSelf as ai, resolveActionsWithContext as aj, takeSpawnAllocationCounters as ak, mergeActorIdCounters as al, createSpawnEffect as am, initialMicrostep as an, toStatePath as ao, isStateId as ap, getStateNodeByPath as aq, getPersistedSnapshot as ar, createRemoteActorRef as as, resolveReferencedActor as at, createInvokeTimeoutEvent as au, parseGeneratedActorId as av, ACTOR_REF_TYPE as aw, hasAmbientInspector as ax, getProperAncestors as ay, isRemoteActorRef as az, createSubscriptionLogic as b, createActor as c, getNextSnapshot as d, isMachineSnapshot as e, getStateNodes as f, getInitialSnapshot as g, getAllOwnEventDescriptors as h, isAtomicStateNode as i, matchesState as j, checkStateIn as k, listenerLogic as l, matchesEventDescriptor as m, pathToStateValue as n, toObserver as o, parseDelayToMilliseconds as p, executeEffects as q, isBuiltInExecutableAction as r, subscriptionLogic as s, toArray as t, deliverEvent as u, runStep as v, stopActor as w, terminateActor as x, createInitEvent as y, createDeadLetterEffect as z };
5872
+ export { resolveStateValue as $, Actor as A, createCustomEffect as B, XSTATE_LOGIC_EFFECT_START as C, XSTATE_LOGIC_EFFECT_RESOLVE as D, XSTATE_LOGIC_EFFECT_REJECT as E, finalizeTransitionResult as F, createEmitEffect as G, createSendToEffect as H, XSTATE_INIT as I, resolveRegisteredActorSource as J, allocateChildId as K, assertChildIdFree as L, reserveChildId as M, mapValues as N, createInvokeId as O, getDelayedTransitions as P, getEventDescriptorKey as Q, getCandidates as R, STATE_DELIMITER as S, evaluateCandidate as T, formatTransition as U, NULL_EVENT as V, toTransitionConfigArray as W, XSTATE_STOP as X, createInvokeTimeoutEventId as Y, matchesActorSession as Z, formatRouteTransitions as _, createListenerLogic as a, getAllStateNodes as a0, createMachineSnapshot as a1, isInFinalState as a2, createInertActorScope as a3, setInertActorScopeSnapshot as a4, beginSpawnAllocation as a5, attachSnapshotActorRef as a6, macrostep as a7, isInertActorScope as a8, setSnapshotActorRef as a9, matchesEvent as aA, encodeAddressSegment as aB, getRootActorId as aC, RUNTIME_OPERATIONS as aD, withSystemInspector as aE, getSnapshotActorRef as aF, withExecutionIdentity as aG, cloneMachineSnapshot as aa, transitionNode as ab, XSTATE_TIMER as ac, getTransitionResult as ad, hasEffect as ae, createErrorPlatformEvent as af, withActorSelf as ag, resolveActionsWithContext as ah, takeSpawnAllocationCounters as ai, mergeActorIdCounters as aj, createSpawnEffect as ak, initialMicrostep as al, toStatePath as am, isStateId as an, getStateNodeByPath as ao, getPersistedSnapshot as ap, createRemoteActorRef as aq, resolveReferencedActor as ar, createInvokeTimeoutEvent as as, parseGeneratedActorId as at, ACTOR_REF_TYPE as au, hasAmbientInspector as av, getProperAncestors as aw, isRemoteActorRef as ax, getActorIdPrefix as ay, getAllOwnEvents as az, createSubscriptionLogic as b, createActor as c, getNextSnapshot as d, isMachineSnapshot as e, getStateNodes as f, getInitialSnapshot as g, getAllOwnEventDescriptors as h, isAtomicStateNode as i, matchesState as j, checkStateIn as k, listenerLogic as l, matchesEventDescriptor as m, pathToStateValue as n, toObserver as o, parseDelayToMilliseconds as p, executeEffects as q, isBuiltInExecutableAction as r, subscriptionLogic as s, toArray as t, deliverEvent as u, runStep as v, stopActor as w, terminateActor as x, createInitEvent as y, createDeadLetterEffect as z };
@@ -991,6 +991,7 @@ function getBuiltInActionFields(action, args) {
991
991
  {
992
992
  const [actor] = args;
993
993
  return {
994
+ type: '@xstate.spawn',
994
995
  kind: 'builtin',
995
996
  exec: execSpawnEffect,
996
997
  source: actor._parent,
@@ -1005,6 +1006,7 @@ function getBuiltInActionFields(action, args) {
1005
1006
  {
1006
1007
  const [, event, options] = args;
1007
1008
  return {
1009
+ type: '@xstate.raise',
1008
1010
  kind: 'builtin',
1009
1011
  exec: execRaiseEffect,
1010
1012
  source: args[0].self,
@@ -1017,6 +1019,7 @@ function getBuiltInActionFields(action, args) {
1017
1019
  {
1018
1020
  const [, target, event, options] = args;
1019
1021
  return {
1022
+ type: '@xstate.sendTo',
1020
1023
  kind: 'builtin',
1021
1024
  exec: execSendToEffect,
1022
1025
  source: args[0].self,
@@ -1030,6 +1033,7 @@ function getBuiltInActionFields(action, args) {
1030
1033
  {
1031
1034
  const [, id] = args;
1032
1035
  return {
1036
+ type: '@xstate.cancel',
1033
1037
  kind: 'builtin',
1034
1038
  exec: execCancelEffect,
1035
1039
  source: args[0].self,
@@ -1040,6 +1044,7 @@ function getBuiltInActionFields(action, args) {
1040
1044
  {
1041
1045
  const [, actor] = args;
1042
1046
  return {
1047
+ type: '@xstate.stop',
1043
1048
  kind: 'builtin',
1044
1049
  exec: execStopEffect,
1045
1050
  source: args[0].self,
@@ -3005,6 +3010,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
3005
3010
  self: actorScope.self,
3006
3011
  context: nextState.context,
3007
3012
  event,
3013
+ input: stateInputMap[stateNodeToEnter.id],
3008
3014
  output: getEventOutput(event)
3009
3015
  }) : invokeDef.input;
3010
3016
  assertChildIdFree(actorScope, invokeDef.id);
@@ -5928,7 +5934,6 @@ exports.isAtomicStateNode = isAtomicStateNode;
5928
5934
  exports.isBuiltInExecutableAction = isBuiltInExecutableAction;
5929
5935
  exports.isInFinalState = isInFinalState;
5930
5936
  exports.isInertActorScope = isInertActorScope;
5931
- exports.isLazyActorScope = isLazyActorScope;
5932
5937
  exports.isMachineSnapshot = isMachineSnapshot;
5933
5938
  exports.isRemoteActorRef = isRemoteActorRef;
5934
5939
  exports.isStateId = isStateId;
@@ -5960,7 +5965,6 @@ exports.toObserver = toObserver;
5960
5965
  exports.toStatePath = toStatePath;
5961
5966
  exports.toTransitionConfigArray = toTransitionConfigArray;
5962
5967
  exports.transitionNode = transitionNode;
5963
- exports.withActorScope = withActorScope;
5964
5968
  exports.withActorSelf = withActorSelf;
5965
5969
  exports.withExecutionIdentity = withExecutionIdentity;
5966
5970
  exports.withSystemInspector = withSystemInspector;
@@ -981,6 +981,7 @@ function getBuiltInActionFields(action, args) {
981
981
  {
982
982
  const [actor] = args;
983
983
  return {
984
+ type: '@xstate.spawn',
984
985
  kind: 'builtin',
985
986
  exec: execSpawnEffect,
986
987
  source: actor._parent,
@@ -995,6 +996,7 @@ function getBuiltInActionFields(action, args) {
995
996
  {
996
997
  const [, event, options] = args;
997
998
  return {
999
+ type: '@xstate.raise',
998
1000
  kind: 'builtin',
999
1001
  exec: execRaiseEffect,
1000
1002
  source: args[0].self,
@@ -1007,6 +1009,7 @@ function getBuiltInActionFields(action, args) {
1007
1009
  {
1008
1010
  const [, target, event, options] = args;
1009
1011
  return {
1012
+ type: '@xstate.sendTo',
1010
1013
  kind: 'builtin',
1011
1014
  exec: execSendToEffect,
1012
1015
  source: args[0].self,
@@ -1020,6 +1023,7 @@ function getBuiltInActionFields(action, args) {
1020
1023
  {
1021
1024
  const [, id] = args;
1022
1025
  return {
1026
+ type: '@xstate.cancel',
1023
1027
  kind: 'builtin',
1024
1028
  exec: execCancelEffect,
1025
1029
  source: args[0].self,
@@ -1030,6 +1034,7 @@ function getBuiltInActionFields(action, args) {
1030
1034
  {
1031
1035
  const [, actor] = args;
1032
1036
  return {
1037
+ type: '@xstate.stop',
1033
1038
  kind: 'builtin',
1034
1039
  exec: execStopEffect,
1035
1040
  source: args[0].self,
@@ -2985,6 +2990,7 @@ function microstep(transitions, currentSnapshot, actorScope, event, isInitial, i
2985
2990
  self: actorScope.self,
2986
2991
  context: nextState.context,
2987
2992
  event,
2993
+ input: stateInputMap[stateNodeToEnter.id],
2988
2994
  output: getEventOutput(event)
2989
2995
  }) : invokeDef.input;
2990
2996
  assertChildIdFree(actorScope, invokeDef.id);
@@ -5824,4 +5830,4 @@ function createActor(logic, options) {
5824
5830
  return new Actor(logic, options);
5825
5831
  }
5826
5832
 
5827
- export { createInvokeTimeoutEventId as $, Actor as A, createCustomEffect as B, XSTATE_LOGIC_EFFECT_START as C, XSTATE_LOGIC_EFFECT_RESOLVE as D, XSTATE_LOGIC_EFFECT_REJECT as E, finalizeTransitionResult as F, createEmitEffect as G, createSendToEffect as H, XSTATE_INIT as I, withActorScope as J, XSTATE_TIMER as K, isLazyActorScope as L, resolveRegisteredActorSource as M, allocateChildId as N, assertChildIdFree as O, reserveChildId as P, mapValues as Q, createInvokeId as R, STATE_DELIMITER as S, getDelayedTransitions as T, getEventDescriptorKey as U, getCandidates as V, evaluateCandidate as W, XSTATE_STOP as X, formatTransition as Y, NULL_EVENT as Z, toTransitionConfigArray as _, createListenerLogic as a, matchesActorSession as a0, formatRouteTransitions as a1, resolveStateValue as a2, getAllStateNodes as a3, createMachineSnapshot as a4, isInFinalState as a5, createInertActorScope as a6, setInertActorScopeSnapshot as a7, beginSpawnAllocation as a8, attachSnapshotActorRef as a9, getActorIdPrefix as aA, getAllOwnEvents as aB, matchesEvent as aC, encodeAddressSegment as aD, getRootActorId as aE, RUNTIME_OPERATIONS as aF, withSystemInspector as aG, getSnapshotActorRef as aH, withExecutionIdentity as aI, macrostep as aa, isInertActorScope as ab, setSnapshotActorRef as ac, cloneMachineSnapshot as ad, transitionNode as ae, getTransitionResult as af, hasEffect as ag, createErrorPlatformEvent as ah, withActorSelf as ai, resolveActionsWithContext as aj, takeSpawnAllocationCounters as ak, mergeActorIdCounters as al, createSpawnEffect as am, initialMicrostep as an, toStatePath as ao, isStateId as ap, getStateNodeByPath as aq, getPersistedSnapshot as ar, createRemoteActorRef as as, resolveReferencedActor as at, createInvokeTimeoutEvent as au, parseGeneratedActorId as av, ACTOR_REF_TYPE as aw, hasAmbientInspector as ax, getProperAncestors as ay, isRemoteActorRef as az, createSubscriptionLogic as b, createActor as c, getNextSnapshot as d, isMachineSnapshot as e, getStateNodes as f, getInitialSnapshot as g, getAllOwnEventDescriptors as h, isAtomicStateNode as i, matchesState as j, checkStateIn as k, listenerLogic as l, matchesEventDescriptor as m, pathToStateValue as n, toObserver as o, parseDelayToMilliseconds as p, executeEffects as q, isBuiltInExecutableAction as r, subscriptionLogic as s, toArray as t, deliverEvent as u, runStep as v, stopActor as w, terminateActor as x, createInitEvent as y, createDeadLetterEffect as z };
5833
+ export { resolveStateValue as $, Actor as A, createCustomEffect as B, XSTATE_LOGIC_EFFECT_START as C, XSTATE_LOGIC_EFFECT_RESOLVE as D, XSTATE_LOGIC_EFFECT_REJECT as E, finalizeTransitionResult as F, createEmitEffect as G, createSendToEffect as H, XSTATE_INIT as I, resolveRegisteredActorSource as J, allocateChildId as K, assertChildIdFree as L, reserveChildId as M, mapValues as N, createInvokeId as O, getDelayedTransitions as P, getEventDescriptorKey as Q, getCandidates as R, STATE_DELIMITER as S, evaluateCandidate as T, formatTransition as U, NULL_EVENT as V, toTransitionConfigArray as W, XSTATE_STOP as X, createInvokeTimeoutEventId as Y, matchesActorSession as Z, formatRouteTransitions as _, createListenerLogic as a, getAllStateNodes as a0, createMachineSnapshot as a1, isInFinalState as a2, createInertActorScope as a3, setInertActorScopeSnapshot as a4, beginSpawnAllocation as a5, attachSnapshotActorRef as a6, macrostep as a7, isInertActorScope as a8, setSnapshotActorRef as a9, matchesEvent as aA, encodeAddressSegment as aB, getRootActorId as aC, RUNTIME_OPERATIONS as aD, withSystemInspector as aE, getSnapshotActorRef as aF, withExecutionIdentity as aG, cloneMachineSnapshot as aa, transitionNode as ab, XSTATE_TIMER as ac, getTransitionResult as ad, hasEffect as ae, createErrorPlatformEvent as af, withActorSelf as ag, resolveActionsWithContext as ah, takeSpawnAllocationCounters as ai, mergeActorIdCounters as aj, createSpawnEffect as ak, initialMicrostep as al, toStatePath as am, isStateId as an, getStateNodeByPath as ao, getPersistedSnapshot as ap, createRemoteActorRef as aq, resolveReferencedActor as ar, createInvokeTimeoutEvent as as, parseGeneratedActorId as at, ACTOR_REF_TYPE as au, hasAmbientInspector as av, getProperAncestors as aw, isRemoteActorRef as ax, getActorIdPrefix as ay, getAllOwnEvents as az, createSubscriptionLogic as b, createActor as c, getNextSnapshot as d, isMachineSnapshot as e, getStateNodes as f, getInitialSnapshot as g, getAllOwnEventDescriptors as h, isAtomicStateNode as i, matchesState as j, checkStateIn as k, listenerLogic as l, matchesEventDescriptor as m, pathToStateValue as n, toObserver as o, parseDelayToMilliseconds as p, executeEffects as q, isBuiltInExecutableAction as r, subscriptionLogic as s, toArray as t, deliverEvent as u, runStep as v, stopActor as w, terminateActor as x, createInitEvent as y, createDeadLetterEffect as z };
@@ -1,2 +1,2 @@
1
- export { createFSMActor, FSMActor } from "./createFSMActor.js";
2
- export { createFSM, type FSMActorLogic, type FSMConfig, type FSMSnapshot } from "../fsm.js";
1
+ export { types } from "../schema.types.js";
2
+ export { createFSM, setup, type FSM, type FSMArgs, type FSMConfig, type FSMContextPatch, type FSMStateConfig, type FSMTransition, type FSMTransitionConfig, type FSMTransitionFunction, type FSMSnapshot, type FSMSetupConfig, type FSMSetupReturn } from "../fsm.js";
@@ -1,78 +1,134 @@
1
- import type { ActorLogic, EnqueueObject, EventObject, MachineContext, LogicalTimer, NonReducibleUnknown, Snapshot } from "./types.js";
2
- export type FSMSnapshot<TContext extends MachineContext, TState extends string, TInput = unknown> = Snapshot<undefined> & {
3
- value: TState;
4
- context: TContext;
5
- input: TInput | undefined;
6
- children: {};
7
- timers: Record<string, LogicalTimer>;
8
- _nextTimerId: number;
9
- _nextActorIds?: Record<string, number>;
10
- _stateInput: Record<string, unknown> | undefined;
11
- machine: {
12
- id: string;
13
- sources: {
14
- actions: {};
15
- actors: {};
16
- guards: {};
17
- delays: {};
18
- };
19
- };
20
- };
21
- type FSMArgs<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = {
1
+ import type { EventObject, MachineContext } from "./types.js";
2
+ import type { StandardSchemaV1 } from "./schema.types.js";
3
+ import type { SetupSchemas, SetupStateSchema } from "./setup.js";
4
+ import type { InferEvents } from "./types.v6.js";
5
+ export type FSMArgs<TContext extends MachineContext, TEvent extends EventObject> = {
22
6
  context: TContext;
23
7
  event: TEvent;
24
- input: TInput | undefined;
25
- value: TState;
26
- self: any;
27
- system: any;
28
- parent: any;
29
- children: {};
30
8
  };
31
- type FSMAction<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = (args: FSMArgs<TContext, TEvent, TState, TInput> & {
32
- input: Record<string, unknown> | undefined;
33
- }, enq: EnqueueObject<TEvent, EventObject>) => void | {
9
+ export type FSMContextPatch<TContext extends MachineContext> = Partial<TContext>;
10
+ export type FSMTransitionConfig<TContext extends MachineContext, TState extends string> = {
11
+ target?: TState;
34
12
  context?: FSMContextPatch<TContext>;
35
13
  };
36
- type FSMGuard<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = (args: FSMArgs<TContext, TEvent, TState, TInput>) => boolean;
37
- type FSMContextPatch<TContext extends MachineContext> = Partial<TContext> & {
38
- call?: never;
39
- apply?: never;
40
- bind?: never;
14
+ export type FSMTransitionFunction<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TTransitionContext extends MachineContext = TContext> = (args: FSMArgs<TContext, TEvent>) => FSMTransitionConfig<TTransitionContext, TState> | undefined;
15
+ type EventForType<TEvent extends EventObject, TType extends string> = [
16
+ Extract<TEvent, {
17
+ type: TType;
18
+ }>
19
+ ] extends [never] ? TEvent : Extract<TEvent, {
20
+ type: TType;
21
+ }>;
22
+ export type FSMTransition<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TTransitionContext extends MachineContext = TContext> = TState | FSMTransitionConfig<TTransitionContext, TState> | FSMTransitionFunction<TContext, TEvent, TState, TTransitionContext>;
23
+ type FSMOn<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TTransitionContext extends MachineContext = TContext> = {
24
+ [TType in TEvent['type'] & string]?: FSMTransition<TContext, EventForType<TEvent, TType>, TState, TTransitionContext>;
41
25
  };
42
- type FSMContextMapper<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = (args: FSMArgs<TContext, TEvent, TState, TInput>) => FSMContextPatch<TContext>;
43
- type FSMTarget<TContext extends MachineContext> = {
44
- target?: string;
45
- context?: FSMContextPatch<TContext>;
46
- input?: Record<string, unknown> | ((args: {
47
- context: TContext;
48
- event: EventObject;
49
- }) => Record<string, unknown>);
26
+ export type FSMStateConfig<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TTransitionContext extends MachineContext = TContext> = {
27
+ on?: FSMOn<TContext, TEvent, TState, TTransitionContext>;
50
28
  };
51
- type FSMObjectTarget<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = Omit<FSMTarget<TContext>, 'context'> & {
52
- context?: FSMContextPatch<TContext> | FSMContextMapper<TContext, TEvent, TState, TInput>;
53
- };
54
- type FSMTransitionFunction<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = (args: FSMArgs<TContext, TEvent, TState, TInput>, enq: EnqueueObject<TEvent, EventObject>) => void | false | FSMTarget<TContext>;
55
- type FSMTransition<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = FSMObjectTarget<TContext, TEvent, TState, TInput> | (FSMObjectTarget<TContext, TEvent, TState, TInput> & {
56
- guard?: FSMGuard<TContext, TEvent, TState, TInput>;
57
- actions?: FSMAction<TContext, TEvent, TState, TInput> | Array<FSMAction<TContext, TEvent, TState, TInput>>;
58
- }) | FSMTransitionFunction<TContext, TEvent, TState, TInput>;
59
- type FSMStateConfig<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = {
60
- type?: 'final';
61
- entry?: FSMAction<TContext, TEvent, TState, TInput> | Array<FSMAction<TContext, TEvent, TState, TInput>>;
62
- exit?: FSMAction<TContext, TEvent, TState, TInput> | Array<FSMAction<TContext, TEvent, TState, TInput>>;
63
- always?: FSMTransition<TContext, TEvent, TState, TInput> | Array<FSMTransition<TContext, TEvent, TState, TInput>>;
64
- on?: Record<string, FSMTransition<TContext, TEvent, TState, TInput> | Array<FSMTransition<TContext, TEvent, TState, TInput>>>;
29
+ type FSMContextConfig<TContext extends MachineContext> = string extends keyof TContext ? {
30
+ context?: TContext;
31
+ } : keyof TContext extends never ? {
32
+ context?: TContext;
33
+ } : {
34
+ context: TContext;
65
35
  };
66
- export type FSMConfig<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput = NonReducibleUnknown> = {
36
+ export type FSMConfig<TContext extends MachineContext = {}, TEvent extends EventObject = EventObject, TState extends string = string> = {
67
37
  id?: string;
68
38
  initial: TState;
69
- context?: TContext | ((args: {
70
- input: TInput;
71
- }) => TContext);
72
- states: Record<TState, FSMStateConfig<TContext, TEvent, TState, TInput>>;
39
+ states: {
40
+ [K in TState]: FSMStateConfig<TContext, TEvent, TState>;
41
+ };
42
+ } & FSMContextConfig<TContext>;
43
+ type FSMConfigForStates<TContext extends MachineContext, TEvent extends EventObject, TStates extends Record<string, unknown>> = Omit<FSMConfig<TContext, TEvent, keyof TStates & string>, 'initial' | 'states'> & {
44
+ initial: keyof TStates & string;
45
+ states: {
46
+ [K in keyof TStates]: FSMStateConfig<TContext, TEvent, keyof TStates & string>;
47
+ };
73
48
  };
74
- export type FSMActorLogic<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TInput> = ActorLogic<FSMSnapshot<TContext, TState, TInput>, TEvent, TInput, any, EventObject> & {
49
+ export type FSMSnapshot<TContext extends MachineContext, TState extends string> = {
50
+ value: TState;
51
+ context: TContext;
52
+ };
53
+ export type FSM<TContext extends MachineContext, TEvent extends EventObject, TState extends string, TSnapshot extends {
54
+ value: TState;
55
+ context: MachineContext;
56
+ } = FSMSnapshot<TContext, TState>, TConfig = FSMConfig<TContext, TEvent, TState>> = {
57
+ readonly id: string | undefined;
58
+ readonly config: TConfig;
59
+ readonly initialState: TSnapshot;
60
+ transition(snapshot: TSnapshot, event: TEvent): TSnapshot;
61
+ };
62
+ type FSMSetupSchemas = Pick<SetupSchemas, 'context' | 'events'>;
63
+ type FSMSetupStates = Record<string, SetupStateSchema>;
64
+ type FSMSchemaContext<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<TSchema> extends MachineContext ? StandardSchemaV1.InferOutput<TSchema> : MachineContext;
65
+ type FSMSetupContext<TSchemas extends FSMSetupSchemas> = TSchemas extends {
66
+ context: infer TSchema extends StandardSchemaV1;
67
+ } ? FSMSchemaContext<TSchema> : MachineContext;
68
+ type FSMSetupEvents<TSchemas extends FSMSetupSchemas> = TSchemas extends {
69
+ events: infer TEventSchemas extends Record<string, StandardSchemaV1>;
70
+ } ? InferEvents<TEventSchemas> : EventObject;
71
+ type FSMStateContext<TStateSchema, TGlobalContext extends MachineContext> = TStateSchema extends {
72
+ schemas?: infer TSchemas;
73
+ } ? TSchemas extends {
74
+ context?: infer TSchema extends StandardSchemaV1;
75
+ } ? FSMSchemaContext<TSchema> & ([MachineContext] extends [TGlobalContext] ? unknown : TGlobalContext) : TGlobalContext : TGlobalContext;
76
+ type FSMContextFromDeclaredStates<TStates extends FSMSetupStates, TGlobalContext extends MachineContext> = {
77
+ [K in keyof TStates & string]: FSMStateContext<TStates[K], TGlobalContext>;
78
+ }[keyof TStates & string];
79
+ type FSMContextFromStates<TStates extends FSMSetupStates, TGlobalContext extends MachineContext> = [keyof TStates] extends [never] ? TGlobalContext : [MachineContext] extends [TGlobalContext] ? FSMContextFromDeclaredStates<TStates, TGlobalContext> : TGlobalContext | FSMContextFromDeclaredStates<TStates, TGlobalContext>;
80
+ type FSMSetupStateContext<TState extends string, TStates extends FSMSetupStates, TGlobalContext extends MachineContext> = TState extends keyof TStates ? FSMStateContext<TStates[TState], TGlobalContext> : TGlobalContext;
81
+ type FSMSetupSnapshot<TStates extends FSMSetupStates, TGlobalContext extends MachineContext, TMachineStates extends Record<string, unknown>> = [keyof TStates] extends [never] ? FSMSnapshot<TGlobalContext, keyof TMachineStates & string> : {
82
+ [K in keyof TMachineStates & string]: {
83
+ value: K;
84
+ context: FSMSetupStateContext<K, TStates, TGlobalContext>;
85
+ };
86
+ }[keyof TMachineStates & string];
87
+ type FSMSetupTargetTransitionConfig<TSourceContext extends MachineContext, TTarget extends string, TTargetContext extends MachineContext> = [FSMRequiredTargetContextKeys<TSourceContext, TTargetContext>] extends [
88
+ never
89
+ ] ? {
90
+ target: TTarget;
91
+ context?: FSMTargetContextPatch<TSourceContext, TTargetContext>;
92
+ } : {
93
+ target: TTarget;
94
+ context: FSMTargetContextPatch<TSourceContext, TTargetContext>;
95
+ };
96
+ type FSMRequiredTargetContextKeys<TSourceContext, TTargetContext> = {
97
+ [K in keyof TTargetContext]-?: K extends keyof TSourceContext ? [TSourceContext[K]] extends [TTargetContext[K]] ? never : K : K;
98
+ }[keyof TTargetContext];
99
+ type FSMTargetContextPatch<TSourceContext, TTargetContext> = Partial<TTargetContext> & Pick<TTargetContext, Extract<FSMRequiredTargetContextKeys<TSourceContext, TTargetContext>, string>>;
100
+ type FSMSetupTransitionConfig<TSourceContext extends MachineContext, TStates extends FSMSetupStates, TGlobalContext extends MachineContext> = {
101
+ target?: undefined;
102
+ context?: FSMContextPatch<TSourceContext>;
103
+ } | {
104
+ [TTarget in keyof TStates & string]: FSMSetupTargetTransitionConfig<TSourceContext, TTarget, FSMSetupStateContext<TTarget, TStates, TGlobalContext>>;
105
+ }[keyof TStates & string];
106
+ type FSMSetupStringTransition<TSourceContext extends MachineContext, TStates extends FSMSetupStates, TGlobalContext extends MachineContext> = {
107
+ [TTarget in keyof TStates & string]: [TSourceContext] extends [
108
+ FSMSetupStateContext<TTarget, TStates, TGlobalContext>
109
+ ] ? TTarget : never;
110
+ }[keyof TStates & string];
111
+ type FSMSetupTransitionFunction<TSourceContext extends MachineContext, TEvent extends EventObject, TStates extends FSMSetupStates, TGlobalContext extends MachineContext> = (args: FSMArgs<TSourceContext, TEvent>) => FSMSetupTransitionConfig<TSourceContext, TStates, TGlobalContext> | undefined;
112
+ type FSMSetupTransition<TSourceContext extends MachineContext, TEvent extends EventObject, TStates extends FSMSetupStates, TGlobalContext extends MachineContext, TMachineStates extends Record<string, unknown>> = [keyof TStates] extends [never] ? FSMTransition<TSourceContext, TEvent, keyof TMachineStates & string> : FSMSetupStringTransition<TSourceContext, TStates, TGlobalContext> | FSMSetupTransitionConfig<TSourceContext, TStates, TGlobalContext> | FSMSetupTransitionFunction<TSourceContext, TEvent, TStates, TGlobalContext>;
113
+ type FSMSetupStateConfig<TSourceContext extends MachineContext, TEvent extends EventObject, TStates extends FSMSetupStates, TGlobalContext extends MachineContext, TMachineStates extends Record<string, unknown>> = {
114
+ on?: {
115
+ [TType in TEvent['type'] & string]?: FSMSetupTransition<TSourceContext, EventForType<TEvent, TType>, TStates, TGlobalContext, TMachineStates>;
116
+ };
117
+ };
118
+ type FSMSetupMachineConfig<TSchemas extends FSMSetupSchemas, TStates extends FSMSetupStates, TMachineStates extends Record<string, unknown>> = {
75
119
  id?: string;
120
+ initial: keyof TMachineStates & string;
121
+ states: {
122
+ [K in keyof TMachineStates]: FSMSetupStateConfig<FSMStateContext<K extends keyof TStates ? TStates[K] : {}, FSMSetupContext<TSchemas>>, FSMSetupEvents<TSchemas>, TStates, FSMSetupContext<TSchemas>, TMachineStates>;
123
+ };
124
+ } & FSMContextConfig<FSMContextFromStates<TStates, FSMSetupContext<TSchemas>>>;
125
+ export type FSMSetupConfig<TSchemas extends FSMSetupSchemas = {}, TStates extends FSMSetupStates = {}> = {
126
+ schemas?: TSchemas;
127
+ states?: TStates;
128
+ };
129
+ export type FSMSetupReturn<TSchemas extends FSMSetupSchemas, TStates extends FSMSetupStates> = {
130
+ createFSM<const TMachineStates extends Record<string, unknown>>(config: FSMSetupMachineConfig<TSchemas, TStates, TMachineStates>): FSM<FSMContextFromStates<TStates, FSMSetupContext<TSchemas>>, FSMSetupEvents<TSchemas>, keyof TMachineStates & string, FSMSetupSnapshot<TStates, FSMSetupContext<TSchemas>, TMachineStates>, FSMSetupMachineConfig<TSchemas, TStates, TMachineStates>>;
76
131
  };
77
- export declare function createFSM<TContext extends MachineContext, TEvent extends EventObject, TInput = NonReducibleUnknown>(config: FSMConfig<TContext, TEvent, string, TInput>): FSMActorLogic<TContext, TEvent, string, TInput>;
132
+ export declare function setup<const TSchemas extends FSMSetupSchemas = {}, const TStates extends FSMSetupStates = {}>(_config?: FSMSetupConfig<TSchemas, TStates>): FSMSetupReturn<TSchemas, TStates>;
133
+ export declare function createFSM<TContext extends MachineContext = {}, TEvent extends EventObject = EventObject, const TStates extends Record<string, unknown> = Record<string, unknown>>(config: FSMConfigForStates<TContext, TEvent, TStates>): FSM<TContext, TEvent, keyof TStates & string, FSMSnapshot<TContext, keyof TStates & string>, FSMConfigForStates<TContext, TEvent, TStates>>;
78
134
  export {};
@@ -12,5 +12,6 @@ export declare function serializeSnapshot(snapshot: Snapshot<any>): SerializedSn
12
12
  export declare function createDefaultMachineOptions<TMachine extends AnyStateMachine>(machine: TMachine, options?: TraversalOptions<SnapshotFrom<TMachine>, EventFromLogic<TMachine>, InputFrom<TMachine>>): TraversalOptions<SnapshotFrom<TMachine>, EventFromLogic<TMachine>, InputFrom<TMachine>>;
13
13
  export declare function createDefaultLogicOptions(): TraversalOptions<any, any, any>;
14
14
  export declare function toDirectedGraph(stateMachine: AnyStateNode | AnyStateMachine): DirectedGraphNode;
15
+ export declare function isMachineLogic(logic: unknown): logic is AnyStateMachine;
15
16
  export declare function resolveTraversalOptions<TLogic extends AnyActorLogic>(logic: TLogic, traversalOptions?: TraversalOptions<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, InputFrom<TLogic>>, defaultOptions?: TraversalOptions<SnapshotFrom<TLogic>, EventFromLogic<TLogic>, InputFrom<TLogic>>): TraversalConfig<SnapshotFrom<TLogic>, EventFromLogic<TLogic>>;
16
17
  export declare function joinPaths<TSnapshot extends Snapshot<unknown>, TEvent extends EventObject>(headPath: StatePath<TSnapshot, TEvent>, tailPath: StatePath<TSnapshot, TEvent>): StatePath<TSnapshot, TEvent>;
@@ -2,7 +2,7 @@ export { createAsyncLogic, createCallbackLogic, createEmptyActor, createEventObs
2
2
  export { assertEvent } from "./assert.js";
3
3
  export { Actor, createActor, type RequiredActorOptionsKeys as RequiredActorOptionsKeys } from "./createActor.js";
4
4
  export { createMachine, createStateConfig } from "./createMachine.js";
5
- export { createFSM, type FSMActorLogic, type FSMConfig, type FSMSnapshot } from "./fsm.js";
5
+ export { createFSM, type FSM, type FSMArgs, type FSMConfig, type FSMContextPatch, type FSMStateConfig, type FSMTransition, type FSMTransitionConfig, type FSMTransitionFunction, type FSMSnapshot } from "./fsm.js";
6
6
  export { createMachineFromConfig } from "./createMachineFromConfig.js";
7
7
  export type { ActionJSON, GuardJSON, InvokeJSON, MachineJSON, StateNodeJSON, TransitionJSON } from "./createMachineFromConfig.js";
8
8
  export { machineConfigToJSON, serializeMachine, type CodeExpression } from "./serialize.js";
@@ -11,7 +11,7 @@ export { machineVersions, type AdaptEventsOptions, type EventAdapterHandlers, ty
11
11
  export { types, isTypeSchema, type StandardSchemaV1, type TypeSchema } from "./schema.types.js";
12
12
  export type { ActorValidationBoundary, ActorValidationEventOrigin, ActorValidationRequest, ActorLogicValidator } from "./validation.types.js";
13
13
  export { createSystem, setup } from "./setup.js";
14
- export type { AnySetupConfig, SetupConfig, SetupReturn, SetupReturnFromConfig, SetupSchemas, SystemActorMap, SystemConfig, SystemRuntime, SetupStateSchema, SetupStateSchemas } from "./setup.js";
14
+ export type { AnySetupConfig, SetupConfig, SetupReturn, SetupReturnFromConfig, SetupSchemas, SystemActorMap, SystemConfig, SystemRuntime, SetupStateSchema, SetupStateSchemas, SetupStateType } from "./setup.js";
15
15
  export { getInitialSnapshot, getNextSnapshot } from "./getNextSnapshot.js";
16
16
  export type { InspectionEvent, ActorInspectionEvent, DeadLetterInspectionEvent, TransitionInspectionEvent, ActionRecord, SentRecord } from "./inspection.js";
17
17
  export { SimulatedClock } from "./SimulatedClock.js";
@@ -5,6 +5,7 @@ export interface StandardSchemaV1<Input = unknown, Output = Input> {
5
5
  }
6
6
  /** Schemas that can be declared for an individual state node. */
7
7
  export type SetupStateSchemas = {
8
+ /** Refines the machine's root context schema while this state is active. */
8
9
  context?: StandardSchemaV1;
9
10
  input?: StandardSchemaV1;
10
11
  /** The output emitted when this state node completes. */
@@ -34,13 +35,15 @@ export interface TypeSchema<T> extends StandardSchemaV1<T, T> {
34
35
  * context: types<{ count: number }>(),
35
36
  * events: {
36
37
  * inc: types<{ by: number }>(),
37
- * reset: types<{}>()
38
+ * reset: types<void>()
38
39
  * }
39
40
  * },
40
41
  * context: { count: 0 }
41
42
  * // ...
42
43
  * });
43
44
  * ```
45
+ *
46
+ * Use `types<void>()` for events without a payload.
44
47
  */
45
48
  export declare function types<T>(): TypeSchema<T>;
46
49
  /** Returns true if the value is a type-only schema created by {@link types}. */