@xmachines/docs 1.0.0-beta.26 → 1.0.0-beta.27

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 (216) hide show
  1. package/api/@xmachines/play/classes/PlayError.md +4 -4
  2. package/api/@xmachines/play/type-aliases/PlayEvent.md +2 -2
  3. package/api/@xmachines/play-actor/classes/AbstractActor.md +3 -3
  4. package/api/@xmachines/play-actor/functions/typedSpec.md +1 -1
  5. package/api/@xmachines/play-actor/interfaces/PlaySpec.md +2 -2
  6. package/api/@xmachines/play-actor/interfaces/Routable.md +3 -3
  7. package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +3 -3
  8. package/api/@xmachines/play-actor/interfaces/Viewable.md +2 -2
  9. package/api/@xmachines/play-dom/README.md +24 -8
  10. package/api/@xmachines/play-dom/classes/PlayRenderer.md +4 -4
  11. package/api/@xmachines/play-dom/functions/connectRenderer.md +1 -1
  12. package/api/@xmachines/play-dom/functions/defineRegistry.md +61 -0
  13. package/api/@xmachines/play-dom/functions/renderSpec.md +29 -12
  14. package/api/@xmachines/play-dom/interfaces/ComponentContext.md +62 -0
  15. package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +9 -9
  16. package/api/@xmachines/play-dom/interfaces/DefineRegistryOptions.md +25 -0
  17. package/api/@xmachines/play-dom/interfaces/DefineRegistryResult.md +18 -0
  18. package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +13 -10
  19. package/api/@xmachines/play-dom/interfaces/EventHandle.md +29 -0
  20. package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +5 -5
  21. package/api/@xmachines/play-dom/type-aliases/ComponentFn.md +53 -0
  22. package/api/@xmachines/play-dom/type-aliases/ComponentRegistry.md +21 -0
  23. package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +16 -3
  24. package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +5 -2
  25. package/api/@xmachines/play-dom-router/functions/connectRouter.md +1 -1
  26. package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +1 -1
  27. package/api/@xmachines/play-dom-router/functions/createRouteMap.md +1 -1
  28. package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
  29. package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +14 -14
  30. package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +14 -14
  31. package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +4 -4
  32. package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +6 -6
  33. package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +3 -3
  34. package/api/@xmachines/play-dom-router/interfaces/RouteMapLike.md +3 -3
  35. package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +3 -3
  36. package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +3 -3
  37. package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +4 -4
  38. package/api/@xmachines/play-dom-router/type-aliases/RoutableActor.md +1 -1
  39. package/api/@xmachines/play-dom-router-demo/README.md +46 -51
  40. package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +5 -5
  41. package/api/@xmachines/play-react/functions/useActor.md +1 -1
  42. package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
  43. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +4 -4
  44. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +3 -3
  45. package/api/@xmachines/play-react/interfaces/PlayRendererProps.md +7 -7
  46. package/api/@xmachines/play-react/type-aliases/PlayActor.md +1 -1
  47. package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
  48. package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +23 -23
  49. package/api/@xmachines/play-react-router/classes/RouteMap.md +4 -4
  50. package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +1 -1
  51. package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
  52. package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +6 -6
  53. package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +5 -5
  54. package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
  55. package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
  56. package/api/@xmachines/play-router/classes/BaseRouteMap.md +4 -4
  57. package/api/@xmachines/play-router/classes/RouterBridgeBase.md +23 -23
  58. package/api/@xmachines/play-router/functions/buildPlayRouteEvent.md +1 -1
  59. package/api/@xmachines/play-router/functions/buildRouteTree.md +1 -1
  60. package/api/@xmachines/play-router/functions/createRouteMap.md +1 -1
  61. package/api/@xmachines/play-router/functions/createRouteMapFromMachine.md +1 -1
  62. package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +1 -1
  63. package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +1 -1
  64. package/api/@xmachines/play-router/functions/extractMachineRoutes.md +1 -1
  65. package/api/@xmachines/play-router/functions/extractQuery.md +1 -1
  66. package/api/@xmachines/play-router/functions/extractRouteParams.md +1 -1
  67. package/api/@xmachines/play-router/functions/findRouteById.md +1 -1
  68. package/api/@xmachines/play-router/functions/findRouteByPath.md +1 -1
  69. package/api/@xmachines/play-router/functions/getNavigableRoutes.md +1 -1
  70. package/api/@xmachines/play-router/functions/getRoutableRoutes.md +1 -1
  71. package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +1 -1
  72. package/api/@xmachines/play-router/functions/isRouteReachable.md +1 -1
  73. package/api/@xmachines/play-router/functions/machineToGraph.md +1 -1
  74. package/api/@xmachines/play-router/functions/routeExists.md +1 -1
  75. package/api/@xmachines/play-router/functions/sanitizePathname.md +1 -1
  76. package/api/@xmachines/play-router/functions/validateRouteFormat.md +1 -1
  77. package/api/@xmachines/play-router/functions/validateStateExists.md +1 -1
  78. package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +4 -4
  79. package/api/@xmachines/play-router/interfaces/LocationLike.md +3 -3
  80. package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +3 -3
  81. package/api/@xmachines/play-router/interfaces/MachineNodeData.md +5 -5
  82. package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +6 -6
  83. package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
  84. package/api/@xmachines/play-router/interfaces/RouteMap.md +4 -4
  85. package/api/@xmachines/play-router/interfaces/RouteMapping.md +3 -3
  86. package/api/@xmachines/play-router/interfaces/RouteMatch.md +3 -3
  87. package/api/@xmachines/play-router/interfaces/RouteNode.md +10 -10
  88. package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
  89. package/api/@xmachines/play-router/interfaces/RouteTree.md +5 -5
  90. package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +3 -3
  91. package/api/@xmachines/play-router/interfaces/RouterBridge.md +3 -3
  92. package/api/@xmachines/play-router/interfaces/WindowLike.md +3 -3
  93. package/api/@xmachines/play-router/type-aliases/MachineGraph.md +1 -1
  94. package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
  95. package/api/@xmachines/play-signals/functions/watchSignal.md +1 -1
  96. package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
  97. package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
  98. package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
  99. package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
  100. package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
  101. package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
  102. package/api/@xmachines/play-solid/functions/useActor.md +1 -1
  103. package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +7 -7
  104. package/api/@xmachines/play-solid/type-aliases/PlayActor.md +1 -1
  105. package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
  106. package/api/@xmachines/play-solid-router/classes/RouteMap.md +4 -4
  107. package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +24 -24
  108. package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +1 -1
  109. package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
  110. package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +3 -3
  111. package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +6 -6
  112. package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
  113. package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
  114. package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +3 -3
  115. package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +1 -1
  116. package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
  117. package/api/@xmachines/play-solid-router-demo/README.md +25 -28
  118. package/api/@xmachines/play-svelte/interfaces/PlayRendererProps.md +7 -7
  119. package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +4 -4
  120. package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +1 -1
  121. package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +1 -1
  122. package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +4 -4
  123. package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +6 -6
  124. package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +3 -3
  125. package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
  126. package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +3 -3
  127. package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
  128. package/api/@xmachines/play-svelte-spa-router-demo/README.md +119 -12
  129. package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +4 -4
  130. package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +1 -1
  131. package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +1 -1
  132. package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +4 -4
  133. package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +3 -3
  134. package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +6 -6
  135. package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +3 -3
  136. package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +3 -3
  137. package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +1 -1
  138. package/api/@xmachines/play-sveltekit-router-demo/README.md +120 -12
  139. package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +4 -4
  140. package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +23 -23
  141. package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +1 -1
  142. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +1 -1
  143. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
  144. package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +1 -1
  145. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +6 -6
  146. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
  147. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
  148. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
  149. package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +3 -3
  150. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
  151. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +17 -3
  152. package/api/@xmachines/play-tanstack-react-router-demo/README.md +23 -29
  153. package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +4 -4
  154. package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +24 -24
  155. package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +1 -1
  156. package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
  157. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +6 -6
  158. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
  159. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
  160. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +3 -3
  161. package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +1 -1
  162. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
  163. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +3 -3
  164. package/api/@xmachines/play-tanstack-solid-router-demo/README.md +25 -26
  165. package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
  166. package/api/@xmachines/play-vue/functions/useActor.md +1 -1
  167. package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +5 -5
  168. package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
  169. package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
  170. package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +4 -3
  171. package/api/@xmachines/play-vue/type-aliases/PlayActor.md +1 -1
  172. package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
  173. package/api/@xmachines/play-vue-router/classes/RouteMap.md +4 -4
  174. package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +4 -4
  175. package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +24 -24
  176. package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
  177. package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +6 -6
  178. package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +3 -3
  179. package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +3 -3
  180. package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +1 -1
  181. package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +1 -1
  182. package/api/@xmachines/play-vue-router-demo/README.md +47 -40
  183. package/api/@xmachines/play-xstate/classes/PlayerActor.md +11 -11
  184. package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +1 -1
  185. package/api/@xmachines/play-xstate/functions/composeGuards.md +1 -1
  186. package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +1 -1
  187. package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +1 -1
  188. package/api/@xmachines/play-xstate/functions/definePlayer.md +1 -1
  189. package/api/@xmachines/play-xstate/functions/deriveRoute.md +1 -1
  190. package/api/@xmachines/play-xstate/functions/eventMatches.md +1 -1
  191. package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +1 -1
  192. package/api/@xmachines/play-xstate/functions/hasContext.md +1 -1
  193. package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
  194. package/api/@xmachines/play-xstate/functions/negateGuard.md +1 -1
  195. package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +3 -3
  196. package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +2 -2
  197. package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +6 -6
  198. package/api/@xmachines/play-xstate/interfaces/RouteContext.md +5 -5
  199. package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +1 -1
  200. package/api/@xmachines/play-xstate/type-aliases/Guard.md +1 -1
  201. package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +1 -1
  202. package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +1 -1
  203. package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +4 -4
  204. package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
  205. package/api/@xmachines/shared/functions/defineXmVitestConfig.md +3 -7
  206. package/api/@xmachines/shared/functions/xmAliases.md +1 -1
  207. package/examples/README.md +48 -35
  208. package/examples/basic-state-machine.md +75 -31
  209. package/examples/form-validation.md +199 -127
  210. package/examples/multi-router-integration.md +312 -230
  211. package/examples/routing-patterns.md +243 -189
  212. package/examples/traffic-light.md +114 -65
  213. package/guides/README.md +29 -15
  214. package/guides/getting-started.md +224 -144
  215. package/guides/installation.md +153 -213
  216. package/package.json +2 -2
@@ -1,99 +1,148 @@
1
+ <!-- generated-by: gsd-doc-writer -->
2
+
1
3
  # Traffic Light State Machine
2
4
 
3
- Multi-state machine with automatic transitions demonstrating cyclic state flows.
5
+ Multi-state machine with `meta.route` on every state, demonstrating cyclic transitions and `formatPlayRouteTransitions`.
4
6
 
5
7
  ## Use Case
6
8
 
7
- This example models a traffic light with a red → green → yellow → red cycle. It demonstrates how to handle multiple states with cyclic transitions, making it useful for:
9
+ This example models a traffic light with a red → green → yellow → red cycle. Because traffic lights map naturally to URLs (each light colour is a distinct page in a web app), it is a good vehicle for showing how `meta.route` and `formatPlayRouteTransitions` work together.
10
+
11
+ Applicable patterns:
8
12
 
9
13
  - Traffic light controllers
10
14
  - Multi-step workflows with repeating cycles
11
- - Game state loops (menu playing game over → menu)
12
- - Carousel or slideshow controls
15
+ - Tab or wizard navigation where each step has a URL
16
+ - Game state loops with distinct URL states
13
17
 
14
18
  ## Complete Code
15
19
 
16
20
  ```typescript
17
- import { createMachine } from "xstate";
18
-
19
- // Define states
20
- type TrafficState = "red" | "yellow" | "green";
21
-
22
- // Define events
23
- type TrafficEvent = { type: "TIMER" };
24
-
25
- // Create machine
26
- const trafficMachine = createMachine<TrafficState, TrafficEvent>({
27
- id: "traffic",
28
- initial: "red",
29
- states: {
30
- red: {
31
- on: {
32
- TIMER: "green",
33
- },
34
- },
35
- green: {
36
- on: {
37
- TIMER: "yellow",
38
- },
39
- },
40
- yellow: {
41
- on: {
42
- TIMER: "red",
43
- },
21
+ import { setup } from "xstate";
22
+ import { definePlayer, formatPlayRouteTransitions } from "@xmachines/play-xstate";
23
+
24
+ // 1. Typed setup
25
+ const trafficSetup = setup({
26
+ types: {
27
+ context: {} as {
28
+ params: Record<string, string>;
29
+ query: Record<string, string>;
44
30
  },
31
+ events: {} as
32
+ | { type: "timer" }
33
+ | {
34
+ type: "play.route";
35
+ to: string;
36
+ params?: Record<string, string>;
37
+ query?: Record<string, string>;
38
+ },
39
+ input: {} as undefined,
45
40
  },
46
41
  });
47
42
 
48
- // Usage with timer
49
- let state = trafficMachine.initialState;
50
- console.log(state); // 'red'
43
+ // 2. Machine with meta.route on every state
44
+ // formatPlayRouteTransitions() reads each state's id + meta.route and
45
+ // auto-generates the root-level play.route event handlers.
46
+ const trafficMachine = trafficSetup.createMachine(
47
+ formatPlayRouteTransitions({
48
+ id: "traffic",
49
+ initial: "red",
50
+ context: {
51
+ params: {},
52
+ query: {},
53
+ },
54
+ states: {
55
+ red: {
56
+ id: "red",
57
+ meta: { route: "/red" },
58
+ on: { timer: "green" },
59
+ },
60
+ green: {
61
+ id: "green",
62
+ meta: { route: "/green" },
63
+ on: { timer: "yellow" },
64
+ },
65
+ yellow: {
66
+ id: "yellow",
67
+ meta: { route: "/yellow" },
68
+ on: { timer: "red" },
69
+ },
70
+ },
71
+ }),
72
+ );
51
73
 
52
- // Simulate automatic transitions
53
- setInterval(() => {
54
- state = trafficMachine.transition(state, { type: "TIMER" });
55
- console.log(`Light changed to: ${state}`);
56
- }, 3000); // Change every 3 seconds
57
- ```
74
+ // 3. Player factory
75
+ const createPlayer = definePlayer({ machine: trafficMachine });
58
76
 
59
- ## Code Explanation
77
+ // 4. Create and start actor
78
+ const actor = createPlayer();
79
+ actor.start();
60
80
 
61
- 1. **Multiple states** - Defines three distinct states (`'red'`, `'yellow'`, `'green'`) instead of just two, showing how state machines scale beyond binary toggles.
81
+ // 5. Read current route via signal
82
+ console.log(actor.currentRoute.get()); // "/red"
62
83
 
63
- 2. **Cyclic transitions** - Each state transitions to the next state in the cycle when receiving a `TIMER` event, creating a continuous loop.
84
+ // 6. Advance with domain events
85
+ actor.send({ type: "timer" });
86
+ console.log(actor.currentRoute.get()); // "/green"
64
87
 
65
- 3. **Timer integration** - Uses `setInterval` to automatically trigger state transitions, demonstrating how external timing mechanisms integrate with state machines.
88
+ actor.send({ type: "timer" });
89
+ console.log(actor.currentRoute.get()); // "/yellow"
66
90
 
67
- 4. **Deterministic behavior** - No matter how many cycles complete, the state is always predictable based on the number of `TIMER` events received.
91
+ actor.send({ type: "timer" });
92
+ console.log(actor.currentRoute.get()); // "/red"
68
93
 
69
- ## Key Concepts
94
+ // 7. Or navigate directly via play.route events (generated by formatPlayRouteTransitions)
95
+ actor.send({ type: "play.route", to: "#green" });
96
+ console.log(actor.currentRoute.get()); // "/green"
70
97
 
71
- - **Multi-state machines**: Not limited to two states - model complex workflows with many states
72
- - **Cyclic transitions**: States can form loops, returning to previous states in a predictable pattern
73
- - **External triggers**: State machines react to external events like timers, user actions, or network responses
74
- - **Deterministic**: Same sequence of events always produces the same sequence of states
98
+ // 8. Cleanup
99
+ actor.stop();
100
+ ```
75
101
 
76
- ## Variations
102
+ ## How `formatPlayRouteTransitions` Works
77
103
 
78
- **Different timing per state:**
104
+ `formatPlayRouteTransitions` crawls every state that has **both** an `id` and a `meta.route`, then generates root-level `play.route` event handlers of the form:
79
105
 
80
106
  ```typescript
81
- const timings = { red: 5000, green: 4000, yellow: 2000 };
82
- let state = trafficMachine.initialState;
83
-
84
- function scheduleNext() {
85
- setTimeout(() => {
86
- state = trafficMachine.transition(state, { type: "TIMER" });
87
- console.log(`Light: ${state}`);
88
- scheduleNext();
89
- }, timings[state]);
107
+ // Auto-generated by formatPlayRouteTransitions you don't write this manually:
108
+ on: {
109
+ "play.route": [
110
+ { target: ".red", guard: ({ event }) => event.to === "#red", reenter: true, actions: assign({ params, query }) },
111
+ { target: ".green", guard: ({ event }) => event.to === "#green", reenter: true, actions: assign({ params, query }) },
112
+ { target: ".yellow", guard: ({ event }) => event.to === "#yellow", reenter: true, actions: assign({ params, query }) },
113
+ ],
90
114
  }
115
+ ```
116
+
117
+ **Requirements:**
118
+
119
+ - Every routable state must have both `id` (the `#id` navigation target) and `meta.route` (the URL template).
120
+ - The machine's context must include `params` and `query` fields (both `Record<string, string>`), because `formatPlayRouteTransitions` assigns them on every `play.route` transition.
91
121
 
92
- scheduleNext();
122
+ ## `actor.currentRoute` Signal
123
+
124
+ `actor.currentRoute` is a `Signal.Computed<string | null>` derived from the active state's `meta.route` template and `context.params`. Route signals let router bridges observe URL changes reactively without polling.
125
+
126
+ ```typescript
127
+ import { watchSignal } from "@xmachines/play-signals";
128
+
129
+ const unwatch = watchSignal(actor.currentRoute, () => {
130
+ console.log("URL changed to:", actor.currentRoute.get());
131
+ });
132
+
133
+ // later...
134
+ unwatch();
93
135
  ```
94
136
 
137
+ ## Key Concepts
138
+
139
+ - **`meta.route`**: Marks a state as routable. The value is a URL template (e.g. `"/profile/:username"`).
140
+ - **`formatPlayRouteTransitions`**: Utility that auto-generates `play.route` handlers from `id` + `meta.route` pairs. Wrap your machine config before passing to `createMachine`.
141
+ - **`actor.currentRoute`**: TC39 `Signal.Computed` containing the resolved URL for the active state.
142
+ - **`play.route` events**: Navigation events with a `to: "#stateId"` target. Use `to: "#red"` (state ID), not `to: "/red"` (URL path).
143
+
95
144
  ## Next Steps
96
145
 
97
- - **[Form Validation Example](form-validation.md)** - Learn about guards and conditional transitions
98
- - **[Basic State Machine](basic-state-machine.md)** - Return to foundational concepts
99
- - **[API Documentation](../api/@xmachines/play/README.md)** - Explore advanced features like actions and context
146
+ - **[Form Validation Example](form-validation.md)** Context mutations with `setup.assign` and guards
147
+ - **[Routing Patterns](routing-patterns.md)** Parameter routes, relative routes, and `always` auth guards
148
+ - **[Play RFC](../rfc/play.md)** Complete architectural specification
package/guides/README.md CHANGED
@@ -1,29 +1,43 @@
1
+ <!-- generated-by: gsd-doc-writer -->
2
+
1
3
  # XMachines Guides
2
4
 
3
- Entry points for current XMachines Play architecture and package documentation.
5
+ Entry points for the current XMachines Play architecture.
4
6
 
5
7
  ## Start Here
6
8
 
7
- - [Examples Index](../examples/README.md) - Runnable and conceptual usage patterns
9
+ - **[Installation](installation.md)** — Core packages, framework-specific additions, TypeScript config, ESM setup
10
+ - **[Getting Started](getting-started.md)** — `setup().createMachine()` → `definePlayer()` → `actor.start()` → TC39 Signals
11
+
12
+ ## Examples
13
+
14
+ - **[Examples Index](../examples/README.md)** — Conceptual patterns and complete runnable demo applications
8
15
 
9
16
  ## Router Adapter Guides
10
17
 
11
- Use these READMEs for the current RouterBridge-first integrations:
18
+ Framework-specific adapter documentation:
19
+
20
+ - **[@xmachines/play-router](../api/@xmachines/play-router/README.md)** — Route extraction, route maps, and `RouterBridgeBase`
21
+ - **[@xmachines/play-tanstack-react-router](../api/@xmachines/play-tanstack-react-router/README.md)** — TanStack React adapter (`PlayRouterProvider`, `createRouteMapFromTree`)
22
+ - **[@xmachines/play-react-router](../api/@xmachines/play-react-router/README.md)** — React Router v7 data-router adapter
23
+ - **[@xmachines/play-tanstack-solid-router](../api/@xmachines/play-tanstack-solid-router/README.md)** — TanStack Solid adapter
24
+ - **[@xmachines/play-solid-router](../api/@xmachines/play-solid-router/README.md)** — SolidJS Router adapter
25
+ - **[@xmachines/play-vue-router](../api/@xmachines/play-vue-router/README.md)** — Vue Router adapter
26
+ - **[@xmachines/play-dom-router](../api/@xmachines/play-dom-router/README.md)** — Vanilla DOM: `connectRouter`, `createBrowserHistory`, `createRouter`
27
+ - **[@xmachines/play-sveltekit-router](../api/@xmachines/play-sveltekit-router/README.md)** — SvelteKit adapter
28
+ - **[@xmachines/play-svelte-spa-router](../api/@xmachines/play-svelte-spa-router/README.md)** — Svelte SPA Router (hash-based) adapter
12
29
 
13
- - [@xmachines/play-router](../api/@xmachines/play-router/README.md) - Route extraction, route maps, and `RouterBridgeBase`
14
- - [@xmachines/play-tanstack-react-router](../api/@xmachines/play-tanstack-react-router/README.md) - TanStack React adapter
15
- - [@xmachines/play-react-router](../api/@xmachines/play-react-router/README.md) - `react-router` v7 data-router adapter
16
- - [@xmachines/play-tanstack-solid-router](../api/@xmachines/play-tanstack-solid-router/README.md) - TanStack Solid adapter
17
- - [@xmachines/play-solid-router](../api/@xmachines/play-solid-router/README.md) - SolidJS Router adapter
18
- - [@xmachines/play-vue-router](../api/@xmachines/play-vue-router/README.md) - Vue Router adapter
30
+ ## Renderer Guides
19
31
 
20
- ## Core Runtime Guides
32
+ View layer documentation by framework:
21
33
 
22
- - [@xmachines/play-xstate](../api/@xmachines/play-xstate/README.md) - `definePlayer`, routing transitions, and actor lifecycle
23
- - [@xmachines/play-react](../api/@xmachines/play-react/README.md) - React rendering from actor-driven view state
24
- - [@xmachines/play-vue](../api/@xmachines/play-vue/README.md) - Vue rendering from actor-driven view state
25
- - [@xmachines/play-solid](../api/@xmachines/play-solid/README.md) - SolidJS rendering from actor-driven view state
34
+ - **[@xmachines/play-xstate](../api/@xmachines/play-xstate/README.md)** `definePlayer`, `formatPlayRouteTransitions`, `PlayerActor`
35
+ - **[@xmachines/play-react](../api/@xmachines/play-react/README.md)** React rendering from actor-driven view state (`PlayRenderer`, `defineRegistry`)
36
+ - **[@xmachines/play-vue](../api/@xmachines/play-vue/README.md)** Vue rendering from actor-driven view state
37
+ - **[@xmachines/play-solid](../api/@xmachines/play-solid/README.md)** SolidJS rendering from actor-driven view state
38
+ - **[@xmachines/play-svelte](../api/@xmachines/play-svelte/README.md)** — Svelte 5 rendering from actor-driven view state
39
+ - **[@xmachines/play-dom](../api/@xmachines/play-dom/README.md)** — Vanilla DOM rendering (`connectRenderer`, `defineRegistry`)
26
40
 
27
41
  ## API Reference
28
42
 
29
- - [API Reference](../api/README.md) - Generated API docs for all public packages
43
+ - **[API Reference](../api/README.md)** Generated TypeDoc API docs for all public packages