@xmachines/docs 1.0.0-beta.25 → 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 (268) hide show
  1. package/api/@xmachines/play/classes/PlayError.md +10 -4
  2. package/api/@xmachines/play/type-aliases/PlayEvent.md +2 -2
  3. package/api/@xmachines/play-actor/README.md +4 -0
  4. package/api/@xmachines/play-actor/classes/AbstractActor.md +49 -92
  5. package/api/@xmachines/play-actor/functions/typedSpec.md +57 -0
  6. package/api/@xmachines/play-actor/interfaces/PlaySpec.md +9 -18
  7. package/api/@xmachines/play-actor/interfaces/Routable.md +5 -21
  8. package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +6 -6
  9. package/api/@xmachines/play-actor/interfaces/Viewable.md +5 -6
  10. package/api/@xmachines/play-dom/README.md +24 -8
  11. package/api/@xmachines/play-dom/classes/PlayRenderer.md +4 -4
  12. package/api/@xmachines/play-dom/functions/connectRenderer.md +1 -1
  13. package/api/@xmachines/play-dom/functions/defineRegistry.md +61 -0
  14. package/api/@xmachines/play-dom/functions/renderSpec.md +29 -12
  15. package/api/@xmachines/play-dom/interfaces/ComponentContext.md +62 -0
  16. package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +9 -9
  17. package/api/@xmachines/play-dom/interfaces/DefineRegistryOptions.md +25 -0
  18. package/api/@xmachines/play-dom/interfaces/DefineRegistryResult.md +18 -0
  19. package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +13 -10
  20. package/api/@xmachines/play-dom/interfaces/EventHandle.md +29 -0
  21. package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +5 -5
  22. package/api/@xmachines/play-dom/type-aliases/ComponentFn.md +53 -0
  23. package/api/@xmachines/play-dom/type-aliases/ComponentRegistry.md +21 -0
  24. package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +16 -3
  25. package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +5 -2
  26. package/api/@xmachines/play-dom-router/README.md +10 -0
  27. package/api/@xmachines/play-dom-router/functions/connectRouter.md +18 -46
  28. package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +1 -1
  29. package/api/@xmachines/play-dom-router/functions/createRouteMap.md +38 -0
  30. package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
  31. package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +16 -16
  32. package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +16 -16
  33. package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +6 -6
  34. package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +119 -0
  35. package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +114 -0
  36. package/api/@xmachines/play-dom-router/interfaces/RouteMapLike.md +50 -0
  37. package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +27 -0
  38. package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +104 -0
  39. package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +6 -6
  40. package/api/@xmachines/play-dom-router/type-aliases/RoutableActor.md +9 -0
  41. package/api/@xmachines/play-dom-router-demo/README.md +46 -51
  42. package/api/@xmachines/play-react/README.md +4 -4
  43. package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +31 -5
  44. package/api/@xmachines/play-react/functions/defineRegistry.md +2 -0
  45. package/api/@xmachines/play-react/functions/useActor.md +1 -1
  46. package/api/@xmachines/play-react/functions/useBoundProp.md +2 -0
  47. package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
  48. package/api/@xmachines/play-react/functions/useStateBinding.md +2 -0
  49. package/api/@xmachines/play-react/interfaces/ComponentContext.md +2 -0
  50. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +4 -4
  51. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +3 -3
  52. package/api/@xmachines/play-react/interfaces/PlayRendererProps.md +7 -7
  53. package/api/@xmachines/play-react/type-aliases/ComponentFn.md +2 -0
  54. package/api/@xmachines/play-react/type-aliases/PlayActor.md +1 -1
  55. package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
  56. package/api/@xmachines/play-react-router/README.md +5 -1
  57. package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +102 -25
  58. package/api/@xmachines/play-react-router/classes/RouteMap.md +17 -33
  59. package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +8 -1
  60. package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +21 -11
  61. package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +8 -8
  62. package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +7 -7
  63. package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +18 -8
  64. package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
  65. package/api/@xmachines/play-router/README.md +42 -5
  66. package/api/@xmachines/play-router/classes/BaseRouteMap.md +12 -19
  67. package/api/@xmachines/play-router/classes/RouterBridgeBase.md +100 -25
  68. package/api/@xmachines/play-router/functions/buildPlayRouteEvent.md +1 -1
  69. package/api/@xmachines/play-router/functions/buildRouteTree.md +1 -1
  70. package/api/@xmachines/play-router/functions/createRouteMap.md +1 -1
  71. package/api/@xmachines/play-router/functions/createRouteMapFromMachine.md +38 -0
  72. package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +45 -0
  73. package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +1 -1
  74. package/api/@xmachines/play-router/functions/extractMachineRoutes.md +1 -1
  75. package/api/@xmachines/play-router/functions/extractQuery.md +1 -1
  76. package/api/@xmachines/play-router/functions/extractRouteParams.md +46 -0
  77. package/api/@xmachines/play-router/functions/findRouteById.md +1 -1
  78. package/api/@xmachines/play-router/functions/findRouteByPath.md +1 -1
  79. package/api/@xmachines/play-router/functions/getNavigableRoutes.md +1 -1
  80. package/api/@xmachines/play-router/functions/getRoutableRoutes.md +1 -1
  81. package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +1 -1
  82. package/api/@xmachines/play-router/functions/isRouteReachable.md +1 -1
  83. package/api/@xmachines/play-router/functions/machineToGraph.md +1 -1
  84. package/api/@xmachines/play-router/functions/routeExists.md +1 -1
  85. package/api/@xmachines/play-router/functions/sanitizePathname.md +1 -1
  86. package/api/@xmachines/play-router/functions/validateRouteFormat.md +1 -1
  87. package/api/@xmachines/play-router/functions/validateStateExists.md +1 -1
  88. package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +4 -4
  89. package/api/@xmachines/play-router/interfaces/LocationLike.md +27 -0
  90. package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +3 -3
  91. package/api/@xmachines/play-router/interfaces/MachineNodeData.md +5 -5
  92. package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +8 -8
  93. package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
  94. package/api/@xmachines/play-router/interfaces/RouteMap.md +4 -4
  95. package/api/@xmachines/play-router/interfaces/{BaseRouteMapping.md → RouteMapping.md} +5 -5
  96. package/api/@xmachines/play-router/interfaces/RouteMatch.md +5 -5
  97. package/api/@xmachines/play-router/interfaces/RouteNode.md +12 -12
  98. package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
  99. package/api/@xmachines/play-router/interfaces/RouteTree.md +5 -5
  100. package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +3 -3
  101. package/api/@xmachines/play-router/interfaces/RouterBridge.md +3 -3
  102. package/api/@xmachines/play-router/interfaces/WindowLike.md +65 -0
  103. package/api/@xmachines/play-router/type-aliases/MachineGraph.md +1 -1
  104. package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
  105. package/api/@xmachines/play-signals/functions/watchSignal.md +1 -1
  106. package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
  107. package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
  108. package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
  109. package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
  110. package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
  111. package/api/@xmachines/play-signals/namespaces/Signal/classes/Computed.md +6 -0
  112. package/api/@xmachines/play-signals/namespaces/Signal/classes/State.md +8 -0
  113. package/api/@xmachines/play-signals/namespaces/Signal/interfaces/Options.md +2 -0
  114. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/classes/Watcher.md +10 -0
  115. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/currentComputed.md +2 -0
  116. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSinks.md +2 -0
  117. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSources.md +2 -0
  118. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSinks.md +2 -0
  119. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSources.md +2 -0
  120. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/untrack.md +2 -0
  121. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/unwatched.md +2 -0
  122. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/watched.md +2 -0
  123. package/api/@xmachines/play-signals/namespaces/Signal/variables/isComputed.md +2 -0
  124. package/api/@xmachines/play-signals/namespaces/Signal/variables/isState.md +2 -0
  125. package/api/@xmachines/play-signals/namespaces/Signal/variables/isWatcher.md +2 -0
  126. package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
  127. package/api/@xmachines/play-solid/README.md +4 -4
  128. package/api/@xmachines/play-solid/functions/defineRegistry.md +2 -0
  129. package/api/@xmachines/play-solid/functions/useActor.md +1 -1
  130. package/api/@xmachines/play-solid/functions/useStateBinding.md +2 -0
  131. package/api/@xmachines/play-solid/interfaces/ComponentContext.md +2 -0
  132. package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +7 -7
  133. package/api/@xmachines/play-solid/type-aliases/ComponentFn.md +2 -0
  134. package/api/@xmachines/play-solid/type-aliases/PlayActor.md +1 -1
  135. package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
  136. package/api/@xmachines/play-solid-router/README.md +2 -2
  137. package/api/@xmachines/play-solid-router/classes/RouteMap.md +13 -26
  138. package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +121 -46
  139. package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +1 -1
  140. package/api/@xmachines/play-solid-router/functions/createRouteMap.md +15 -9
  141. package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +47 -92
  142. package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +8 -8
  143. package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
  144. package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +19 -6
  145. package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +3 -3
  146. package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +1 -1
  147. package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +21 -18
  148. package/api/@xmachines/play-solid-router-demo/README.md +25 -28
  149. package/api/@xmachines/play-svelte/README.md +28 -0
  150. package/api/@xmachines/play-svelte/functions/defineRegistry.md +2 -0
  151. package/api/@xmachines/play-svelte/interfaces/BaseComponentProps.md +2 -0
  152. package/api/@xmachines/play-svelte/interfaces/ComponentContext.md +2 -0
  153. package/api/@xmachines/play-svelte/interfaces/PlayRendererProps.md +9 -9
  154. package/api/@xmachines/play-svelte/type-aliases/ComponentFn.md +2 -0
  155. package/api/@xmachines/play-svelte/type-aliases/PlayRenderer.md +2 -0
  156. package/api/@xmachines/play-svelte/variables/PlayRenderer.md +2 -0
  157. package/api/@xmachines/play-svelte-spa-router/README.md +1 -0
  158. package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +13 -26
  159. package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +14 -1
  160. package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +23 -4
  161. package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +6 -5
  162. package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +10 -10
  163. package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +20 -5
  164. package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
  165. package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +65 -0
  166. package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
  167. package/api/@xmachines/play-svelte-spa-router-demo/README.md +119 -12
  168. package/api/@xmachines/play-sveltekit-router/README.md +2 -1
  169. package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +46 -24
  170. package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +14 -1
  171. package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +23 -4
  172. package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +6 -5
  173. package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +27 -0
  174. package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +10 -10
  175. package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +20 -5
  176. package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +3 -3
  177. package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +1 -1
  178. package/api/@xmachines/play-sveltekit-router-demo/README.md +120 -12
  179. package/api/@xmachines/play-tanstack-react-router/README.md +5 -3
  180. package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +17 -33
  181. package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +93 -25
  182. package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +1 -1
  183. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +1 -1
  184. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +21 -11
  185. package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +1 -1
  186. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +8 -8
  187. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
  188. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +18 -8
  189. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
  190. package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +3 -3
  191. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
  192. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +13 -19
  193. package/api/@xmachines/play-tanstack-react-router-demo/README.md +23 -29
  194. package/api/@xmachines/play-tanstack-solid-router/README.md +8 -8
  195. package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +13 -26
  196. package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +101 -36
  197. package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +1 -1
  198. package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +15 -9
  199. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +8 -8
  200. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
  201. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +13 -9
  202. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +3 -3
  203. package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +1 -1
  204. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
  205. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +23 -24
  206. package/api/@xmachines/play-tanstack-solid-router-demo/README.md +25 -26
  207. package/api/@xmachines/play-vue/README.md +4 -4
  208. package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
  209. package/api/@xmachines/play-vue/functions/useActor.md +1 -1
  210. package/api/@xmachines/play-vue/functions/useStateBinding.md +2 -0
  211. package/api/@xmachines/play-vue/interfaces/ComponentContext.md +2 -0
  212. package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +5 -5
  213. package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
  214. package/api/@xmachines/play-vue/type-aliases/ComponentFn.md +2 -0
  215. package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
  216. package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +4 -3
  217. package/api/@xmachines/play-vue/type-aliases/PlayActor.md +1 -1
  218. package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
  219. package/api/@xmachines/play-vue-router/README.md +2 -2
  220. package/api/@xmachines/play-vue-router/classes/RouteMap.md +18 -108
  221. package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +44 -104
  222. package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +127 -62
  223. package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
  224. package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +8 -8
  225. package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +19 -7
  226. package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +3 -3
  227. package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +1 -1
  228. package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +1 -1
  229. package/api/@xmachines/play-vue-router-demo/README.md +47 -40
  230. package/api/@xmachines/play-xstate/README.md +15 -15
  231. package/api/@xmachines/play-xstate/classes/PlayerActor.md +46 -30
  232. package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +20 -15
  233. package/api/@xmachines/play-xstate/functions/composeGuards.md +1 -1
  234. package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +1 -1
  235. package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +1 -1
  236. package/api/@xmachines/play-xstate/functions/definePlayer.md +1 -1
  237. package/api/@xmachines/play-xstate/functions/deriveRoute.md +1 -1
  238. package/api/@xmachines/play-xstate/functions/eventMatches.md +1 -1
  239. package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +2 -2
  240. package/api/@xmachines/play-xstate/functions/hasContext.md +1 -1
  241. package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
  242. package/api/@xmachines/play-xstate/functions/negateGuard.md +1 -1
  243. package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +3 -3
  244. package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +2 -2
  245. package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +6 -6
  246. package/api/@xmachines/play-xstate/interfaces/RouteContext.md +14 -12
  247. package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +1 -1
  248. package/api/@xmachines/play-xstate/type-aliases/Guard.md +1 -1
  249. package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +1 -1
  250. package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +1 -1
  251. package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +4 -4
  252. package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
  253. package/api/@xmachines/shared/functions/defineXmVitestConfig.md +3 -7
  254. package/api/@xmachines/shared/functions/xmAliases.md +1 -1
  255. package/api/README.md +4 -4
  256. package/api/llms.txt +3 -3
  257. package/examples/README.md +50 -32
  258. package/examples/basic-state-machine.md +75 -31
  259. package/examples/form-validation.md +199 -127
  260. package/examples/multi-router-integration.md +312 -230
  261. package/examples/routing-patterns.md +243 -187
  262. package/examples/traffic-light.md +114 -65
  263. package/guides/README.md +29 -15
  264. package/guides/getting-started.md +224 -144
  265. package/guides/installation.md +153 -213
  266. package/package.json +2 -2
  267. package/api/@xmachines/play-tanstack-react-router/functions/extractParams.md +0 -38
  268. package/api/@xmachines/play-tanstack-react-router/functions/extractQueryParams.md +0 -33
@@ -6,7 +6,7 @@
6
6
  type GuardArray<TContext, TEvent> = Guard<TContext, TEvent>[] | string[];
7
7
  ```
8
8
 
9
- Defined in: [packages/play-xstate/src/guards/types.ts:23](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/guards/types.ts#L23)
9
+ Defined in: [packages/play-xstate/src/guards/types.ts:23](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/guards/types.ts#L23)
10
10
 
11
11
  Array of guard predicates or guard names
12
12
 
@@ -6,7 +6,7 @@
6
6
  type PlayerFactory<TMachine> = (input?, options?) => PlayerActor<TMachine>;
7
7
  ```
8
8
 
9
- Defined in: [packages/play-xstate/src/types.ts:57](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/types.ts#L57)
9
+ Defined in: [packages/play-xstate/src/types.ts:57](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/types.ts#L57)
10
10
 
11
11
  Factory function returned by definePlayer()
12
12
 
@@ -6,7 +6,7 @@
6
6
  type RouteMachineConfig = object;
7
7
  ```
8
8
 
9
- Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:52](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/routing/format-play-route-transitions.ts#L52)
9
+ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:48](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/routing/format-play-route-transitions.ts#L48)
10
10
 
11
11
  Minimal structural constraint for machine configs accepted by
12
12
  `formatPlayRouteTransitions`.
@@ -32,7 +32,7 @@ through the transform, so the return value remains directly usable by
32
32
  optional context?: unknown;
33
33
  ```
34
34
 
35
- Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:53](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/routing/format-play-route-transitions.ts#L53)
35
+ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:49](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/routing/format-play-route-transitions.ts#L49)
36
36
 
37
37
  ---
38
38
 
@@ -42,7 +42,7 @@ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:5
42
42
  optional on?: Record<string, unknown>;
43
43
  ```
44
44
 
45
- Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:55](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/routing/format-play-route-transitions.ts#L55)
45
+ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:51](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/routing/format-play-route-transitions.ts#L51)
46
46
 
47
47
  ---
48
48
 
@@ -52,4 +52,4 @@ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:5
52
52
  optional states?: Record<string, unknown>;
53
53
  ```
54
54
 
55
- Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:54](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/routing/format-play-route-transitions.ts#L54)
55
+ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:50](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/routing/format-play-route-transitions.ts#L50)
@@ -6,7 +6,7 @@
6
6
  type RouteStateNode = object;
7
7
  ```
8
8
 
9
- Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:21](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/routing/format-play-route-transitions.ts#L21)
9
+ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:13](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/routing/format-play-route-transitions.ts#L13)
10
10
 
11
11
  Minimal structural shape of a single XState state node as read by
12
12
  `formatPlayRouteTransitions` when crawling the machine config.
@@ -29,7 +29,7 @@ the index signature.
29
29
  optional id?: string;
30
30
  ```
31
31
 
32
- Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:23](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/routing/format-play-route-transitions.ts#L23)
32
+ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:15](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/routing/format-play-route-transitions.ts#L15)
33
33
 
34
34
  Optional explicit state ID (e.g. `"home"`, `"settings"`). Used as the `#id` target in `play.route` events.
35
35
 
@@ -41,7 +41,7 @@ Optional explicit state ID (e.g. `"home"`, `"settings"`). Used as the `#id` targ
41
41
  optional meta?: object;
42
42
  ```
43
43
 
44
- Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:25](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/routing/format-play-route-transitions.ts#L25)
44
+ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:17](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/routing/format-play-route-transitions.ts#L17)
45
45
 
46
46
  State metadata — `meta.route` marks the state as routable.
47
47
 
@@ -61,6 +61,6 @@ URL path template (e.g. `"/profile/:username"`, `"/settings/:section?"`).
61
61
  optional states?: Record<string, RouteStateNode>;
62
62
  ```
63
63
 
64
- Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:30](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/play-xstate/src/routing/format-play-route-transitions.ts#L30)
64
+ Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:22](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-xstate/src/routing/format-play-route-transitions.ts#L22)
65
65
 
66
66
  Nested child states, recursively crawled for additional route declarations.
@@ -3,10 +3,10 @@
3
3
  # Function: defineXmVitestConfig()
4
4
 
5
5
  ```ts
6
- function defineXmVitestConfig(importMetaUrl, overrides): object;
6
+ function defineXmVitestConfig(importMetaUrl, overrides): UserConfig;
7
7
  ```
8
8
 
9
- Defined in: [src/index.ts:10](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/shared/src/index.ts#L10)
9
+ Defined in: [index.ts:10](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/shared/src/index.ts#L10)
10
10
 
11
11
  Create a Vitest config with XMachines workspace defaults.
12
12
 
@@ -22,8 +22,4 @@ render it under `@xmachines/shared` instead of nested module pages.
22
22
 
23
23
  ## Returns
24
24
 
25
- `object`
26
-
27
- | Name | Type | Defined in |
28
- | ------ | ----- | ---------------------------------------------------------------------------------------------------------------------------- |
29
- | `test` | `any` | [config/vitest.ts:82](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/shared/config/vitest.ts#L82) |
25
+ `UserConfig`
@@ -6,7 +6,7 @@
6
6
  function xmAliases(importMetaUrl): Record<string, string>;
7
7
  ```
8
8
 
9
- Defined in: [src/index.ts:20](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.25/packages/shared/src/index.ts#L20)
9
+ Defined in: [index.ts:20](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/shared/src/index.ts#L20)
10
10
 
11
11
  Build Vite/Vitest alias entries for all `@xmachines/*` workspace packages.
12
12
 
package/api/README.md CHANGED
@@ -7,8 +7,8 @@ Generated API documentation for the XMachines JavaScript/TypeScript packages.
7
7
  - For actor contracts, start with [@xmachines/play-actor](@xmachines/play-actor/README.md).
8
8
  - For player creation from XState machines, start with [@xmachines/play-xstate](@xmachines/play-xstate/README.md).
9
9
  - For route extraction and shared URL synchronization logic, start with [@xmachines/play-router](@xmachines/play-router/README.md).
10
- - For rendering, choose one of [@xmachines/play-react](@xmachines/play-react/README.md), [@xmachines/play-solid](@xmachines/play-solid/README.md), or [@xmachines/play-vue](@xmachines/play-vue/README.md).
11
- - For framework router integration, choose the matching adapter package such as [@xmachines/play-react-router](@xmachines/play-react-router/README.md) or [@xmachines/play-vue-router](@xmachines/play-vue-router/README.md).
10
+ - For rendering, choose one of [@xmachines/play-react](@xmachines/play-react/README.md), [@xmachines/play-solid](@xmachines/play-solid/README.md), [@xmachines/play-svelte](@xmachines/play-svelte/README.md), or [@xmachines/play-vue](@xmachines/play-vue/README.md).
11
+ - For framework router integration, choose the matching adapter package such as [@xmachines/play-react-router](@xmachines/play-react-router/README.md), [@xmachines/play-vue-router](@xmachines/play-vue-router/README.md), [@xmachines/play-sveltekit-router](@xmachines/play-sveltekit-router/README.md), or [@xmachines/play-svelte-spa-router](@xmachines/play-svelte-spa-router/README.md).
12
12
 
13
13
  ## Key Concepts
14
14
 
@@ -19,8 +19,8 @@ Generated API documentation for the XMachines JavaScript/TypeScript packages.
19
19
  ## Package Roles
20
20
 
21
21
  - `Core runtime`: [@xmachines/play](@xmachines/play/README.md), [@xmachines/play-actor](@xmachines/play-actor/README.md), [@xmachines/play-signals](@xmachines/play-signals/README.md), [@xmachines/play-router](@xmachines/play-router/README.md), and [@xmachines/play-xstate](@xmachines/play-xstate/README.md)
22
- - `Rendering`: [@xmachines/play-react](@xmachines/play-react/README.md), [@xmachines/play-solid](@xmachines/play-solid/README.md), and [@xmachines/play-vue](@xmachines/play-vue/README.md)
23
- - `Router adapters`: [@xmachines/play-react-router](@xmachines/play-react-router/README.md), [@xmachines/play-tanstack-react-router](@xmachines/play-tanstack-react-router/README.md), [@xmachines/play-solid-router](@xmachines/play-solid-router/README.md), and [@xmachines/play-vue-router](@xmachines/play-vue-router/README.md)
22
+ - `Rendering`: [@xmachines/play-react](@xmachines/play-react/README.md), [@xmachines/play-solid](@xmachines/play-solid/README.md), [@xmachines/play-svelte](@xmachines/play-svelte/README.md), and [@xmachines/play-vue](@xmachines/play-vue/README.md)
23
+ - `Router adapters`: [@xmachines/play-react-router](@xmachines/play-react-router/README.md), [@xmachines/play-tanstack-react-router](@xmachines/play-tanstack-react-router/README.md), [@xmachines/play-solid-router](@xmachines/play-solid-router/README.md), [@xmachines/play-tanstack-solid-router](@xmachines/play-tanstack-solid-router/README.md), [@xmachines/play-vue-router](@xmachines/play-vue-router/README.md), [@xmachines/play-sveltekit-router](@xmachines/play-sveltekit-router/README.md), and [@xmachines/play-svelte-spa-router](@xmachines/play-svelte-spa-router/README.md)
24
24
  - `Shared tooling`: [@xmachines/shared](@xmachines/shared/README.md)
25
25
 
26
26
  ## Notes
package/api/llms.txt CHANGED
@@ -12,14 +12,14 @@
12
12
  - Understanding actor contracts: read [@xmachines/play-actor](@xmachines/play-actor/README.md) for [Viewable](@xmachines/play-actor/interfaces/Viewable.md) and [Routable](@xmachines/play-actor/interfaces/Routable.md).
13
13
  - [Viewable](@xmachines/play-actor/interfaces/Viewable.md) is the rendering contract: actors expose `currentView` plus a component catalog so rendering packages can resolve UI without owning application state.
14
14
  - [Routable](@xmachines/play-actor/interfaces/Routable.md) is the routing contract: actors expose `currentRoute` plus route-oriented event handling, while adapters translate browser or router changes into actor events.
15
- - Rendering actor-driven UI: use [@xmachines/play-react](@xmachines/play-react/README.md), [@xmachines/play-solid](@xmachines/play-solid/README.md), or [@xmachines/play-vue](@xmachines/play-vue/README.md).
15
+ - Rendering actor-driven UI: use [@xmachines/play-react](@xmachines/play-react/README.md), [@xmachines/play-solid](@xmachines/play-solid/README.md), [@xmachines/play-svelte](@xmachines/play-svelte/README.md), or [@xmachines/play-vue](@xmachines/play-vue/README.md).
16
16
  - Synchronizing URLs with actor state: use [@xmachines/play-router](@xmachines/play-router/README.md) plus a framework-specific router adapter.
17
17
 
18
18
  ## Package Roles
19
19
 
20
20
  - `Core runtime`: [@xmachines/play](@xmachines/play/README.md), [@xmachines/play-actor](@xmachines/play-actor/README.md), [@xmachines/play-signals](@xmachines/play-signals/README.md), [@xmachines/play-router](@xmachines/play-router/README.md), and [@xmachines/play-xstate](@xmachines/play-xstate/README.md). Catalog and component registry are provided by `@json-render/core` and the framework rendering packages.
21
- - `Rendering`: [@xmachines/play-react](@xmachines/play-react/README.md), [@xmachines/play-solid](@xmachines/play-solid/README.md), and [@xmachines/play-vue](@xmachines/play-vue/README.md).
22
- - `Router adapters`: [@xmachines/play-react-router](@xmachines/play-react-router/README.md), [@xmachines/play-tanstack-react-router](@xmachines/play-tanstack-react-router/README.md), [@xmachines/play-solid-router](@xmachines/play-solid-router/README.md), [@xmachines/play-tanstack-solid-router](@xmachines/play-tanstack-solid-router/README.md), and [@xmachines/play-vue-router](@xmachines/play-vue-router/README.md), all built on top of [Routable](@xmachines/play-actor/interfaces/Routable.md) actors and shared route metadata.
21
+ - `Rendering`: [@xmachines/play-react](@xmachines/play-react/README.md), [@xmachines/play-solid](@xmachines/play-solid/README.md), [@xmachines/play-svelte](@xmachines/play-svelte/README.md), and [@xmachines/play-vue](@xmachines/play-vue/README.md).
22
+ - `Router adapters`: [@xmachines/play-react-router](@xmachines/play-react-router/README.md), [@xmachines/play-tanstack-react-router](@xmachines/play-tanstack-react-router/README.md), [@xmachines/play-solid-router](@xmachines/play-solid-router/README.md), [@xmachines/play-tanstack-solid-router](@xmachines/play-tanstack-solid-router/README.md), [@xmachines/play-vue-router](@xmachines/play-vue-router/README.md), [@xmachines/play-sveltekit-router](@xmachines/play-sveltekit-router/README.md), and [@xmachines/play-svelte-spa-router](@xmachines/play-svelte-spa-router/README.md), all built on top of [Routable](@xmachines/play-actor/interfaces/Routable.md) actors and shared route metadata.
23
23
  - `Shared tooling`: [@xmachines/shared](@xmachines/shared/README.md) for shared config and workspace-level support files.
24
24
 
25
25
  ## API
@@ -1,76 +1,94 @@
1
+ <!-- generated-by: gsd-doc-writer -->
2
+
1
3
  # XMachines Examples
2
4
 
3
- Practical code examples demonstrating common XMachines patterns and use cases.
5
+ Practical code examples demonstrating current XMachines Play patterns and use cases.
4
6
 
5
7
  ## Learning Path
6
8
 
7
9
  ### Level 1: Basic Concepts
8
10
 
9
- Start with fundamental state machine concepts:
11
+ Start with the fundamental machine + actor pattern:
10
12
 
11
- - **[Basic State Machine](basic-state-machine.md)** - Simple two-state toggle machine
12
- - **[Traffic Light](traffic-light.md)** - Multi-state machine with cyclic transitions
13
- - **[Form Validation](form-validation.md)** - Validation with guards and conditional logic
13
+ - **[Basic State Machine](basic-state-machine.md)** `setup().createMachine()` + `definePlayer()` + TC39 Signals
14
+ - **[Traffic Light](traffic-light.md)** Multi-state machine with `meta.route` and `formatPlayRouteTransitions`
15
+ - **[Form Validation](form-validation.md)** Typed context mutations with `setup.assign`, guards, and `$bindState`
14
16
 
15
17
  ### Level 2: Routing Patterns
16
18
 
17
19
  Learn how state machines control navigation:
18
20
 
19
- - **[Routing Patterns](routing-patterns.md)** - State-driven routing and navigation guards
20
- - **[Multi-Router Integration](multi-router-integration.md)** - Framework-agnostic routing architecture
21
+ - **[Routing Patterns](routing-patterns.md)** `meta.route`, `play.route` events, `always` auth guards, and parameter routes
22
+ - **[Multi-Router Integration](multi-router-integration.md)** All 8 router adapters: provider pattern vs `connectRouter` pattern
21
23
 
22
24
  ### Level 3: Full Applications
23
25
 
24
- See complete working implementations demonstrating the current router integrations and all architectural invariants.
25
-
26
- ## Complete Examples
26
+ Complete working implementations of actor-authoritative routing with all architectural invariants enforced.
27
27
 
28
- Complete working applications demonstrating actor-authoritative routing, shared auth flows, and framework-specific rendering patterns:
28
+ ## Complete Demo Applications
29
29
 
30
30
  ### Framework-Agnostic Baseline
31
31
 
32
- - **[Vanilla JavaScript Router Demo](../api/@xmachines/play-dom-router-demo/README.md)** - Pure browser integration with the History API and DOM rendering; the lowest-level reference implementation for the router demos
32
+ - **[Vanilla JavaScript Router Demo](../api/@xmachines/play-dom-router-demo/README.md)** Pure browser integration: `connectRouter` + `connectRenderer` + DOM components. The lowest-level reference implementation.
33
33
 
34
34
  ### React Integrations
35
35
 
36
- - **[TanStack React Router Demo](../api/@xmachines/play-tanstack-react-router-demo/README.md)** - Canonical reference implementation showing all 5 invariants, comprehensive routing, authentication guards, and browser tests
37
- - **[React Router Demo](../api/@xmachines/play-react-router-demo/README.md)** - React Router v7 data-router integration using the same actor and shell patterns
36
+ - **[TanStack React Router Demo](../api/@xmachines/play-tanstack-react-router-demo/README.md)** Canonical reference implementation with all 5 invariants, comprehensive routing, authentication guards, and browser tests.
37
+ - **[React Router Demo](../api/@xmachines/play-react-router-demo/README.md)** React Router v7 data-router integration using a catch-all route and `ReactRouterBridge`.
38
38
 
39
39
  ### Vue Integration
40
40
 
41
- - **[Vue Router Demo](../api/@xmachines/play-vue-router-demo/README.md)** - Vue Composition API integration with the same shared auth and routing patterns
41
+ - **[Vue Router Demo](../api/@xmachines/play-vue-router-demo/README.md)** Vue Composition API integration with `PlayRouterProvider` and the shared `authMachine`.
42
42
 
43
- ### Solid Integrations
43
+ ### Svelte Integrations
44
44
 
45
- - **[Solid Router Demo](../api/@xmachines/play-solid-router-demo/README.md)** - Solid fine-grained reactivity with `@solidjs/router` and provider-based routing
46
- - **[TanStack Solid Router Demo](../api/@xmachines/play-tanstack-solid-router-demo/README.md)** - Solid + TanStack router integration with the same actor-authoritative flow
45
+ - **[SvelteKit Router Demo](../api/@xmachines/play-sveltekit-router-demo/README.md)** SvelteKit-style routing with `connectRouter` + `afterNavigate`/`goto` and Svelte 5 runes.
46
+ - **[Svelte SPA Router Demo](../api/@xmachines/play-svelte-spa-router-demo/README.md)** — Hash-based SPA routing using `svelte-spa-router` with the same actor-authoritative flow.
47
47
 
48
- ## Running Examples
48
+ ### SolidJS Integrations
49
49
 
50
- All examples are written in TypeScript and can be run in:
50
+ - **[Solid Router Demo](../api/@xmachines/play-solid-router-demo/README.md)** `@solidjs/router` integration with `PlayRouterProvider` and SolidJS fine-grained reactivity.
51
+ - **[TanStack Solid Router Demo](../api/@xmachines/play-tanstack-solid-router-demo/README.md)** — TanStack Router for Solid with dynamic route creation from the machine's route tree.
51
52
 
52
- **Node.js:**
53
+ ## Running the Code Examples
54
+
55
+ The conceptual examples in this directory are TypeScript snippets. To run them:
53
56
 
54
57
  ```bash
55
- npm install @xmachines/play
56
- npx tsx example.ts
57
- ```
58
+ # Install dependencies (from the monorepo root)
59
+ npm install @xmachines/play-xstate @xmachines/play-actor @xmachines/play-signals xstate
58
60
 
59
- **Browser:**
60
- Include via bundler (Vite, Webpack) or use browser platform package.
61
+ # Run with tsx
62
+ npx tsx my-example.ts
63
+ ```
61
64
 
62
- **Deno:**
65
+ To run a complete demo application, `cd` into the relevant package and start its dev server:
63
66
 
64
67
  ```bash
65
- deno run --allow-net example.ts
68
+ # Example: vanilla DOM router demo
69
+ cd packages/play-dom-router/examples/demo
70
+ npm install
71
+ npm run dev
66
72
  ```
67
73
 
74
+ ## Key Packages
75
+
76
+ | Package | Role |
77
+ | ------------------------- | ----------------------------------------------------------- |
78
+ | `@xmachines/play-xstate` | `definePlayer`, `formatPlayRouteTransitions`, `PlayerActor` |
79
+ | `@xmachines/play-actor` | `AbstractActor`, `typedSpec` |
80
+ | `@xmachines/play-signals` | TC39 Signals polyfill, `watchSignal` |
81
+ | `@xmachines/play-router` | `extractMachineRoutes`, `getRoutableRoutes` |
82
+ | `@xmachines/play-dom` | `connectRenderer`, `defineRegistry` (vanilla) |
83
+ | `@xmachines/play-react` | `PlayRenderer`, `defineRegistry` (React) |
84
+
68
85
  ## Related Documentation
69
86
 
70
- - **[Getting Started Guide](../guides/getting-started.md)** - First steps with XMachines
71
- - **[API Reference](../api/README.md)** - Complete API documentation
87
+ - **[Getting Started Guide](../guides/getting-started.md)** First steps with XMachines
88
+ - **[Installation Guide](../guides/installation.md)** Package installation and TypeScript setup
89
+ - **[API Reference](../api/README.md)** — Generated API docs for all public packages
90
+ - **[Play RFC](../rfc/play.md)** — Complete architectural specification
72
91
 
73
92
  ---
74
93
 
75
- **Contributing Examples:**
76
- Have a useful example to share? See the repository contribution guidelines.
94
+ **Contributing Examples:** Have a useful example to share? See the repository contribution guidelines.
@@ -1,70 +1,114 @@
1
+ <!-- generated-by: gsd-doc-writer -->
2
+
1
3
  # Basic State Machine
2
4
 
3
- Learn how to create a simple state machine with two states.
5
+ Learn how to define a simple toggle machine using the current XState v5 + XMachines `setup().createMachine()` + `definePlayer()` pattern.
4
6
 
5
7
  ## Use Case
6
8
 
7
- This example demonstrates a toggle switch or on/off button - the foundation for understanding state transitions in XMachines. It's the simplest possible state machine with just two states and one event type.
9
+ This example demonstrates a toggle switch the foundation for understanding state machines in XMachines. It is the simplest possible machine: two states, one event type, no router, no catalog.
8
10
 
9
11
  ## Complete Code
10
12
 
11
13
  ```typescript
12
- import { createMachine } from "xstate";
13
-
14
- // Define states
15
- type ToggleState = "off" | "on";
16
-
17
- // Define events
18
- type ToggleEvent = { type: "TOGGLE" };
14
+ import { setup } from "xstate";
15
+ import { definePlayer } from "@xmachines/play-xstate";
16
+
17
+ // 1. Declare types for context, events, and input via setup()
18
+ const toggleSetup = setup({
19
+ types: {
20
+ context: {} as { toggleCount: number },
21
+ events: {} as { type: "toggle" },
22
+ input: {} as { toggleCount?: number } | undefined,
23
+ },
24
+ });
19
25
 
20
- // Create machine
21
- const toggleMachine = createMachine<ToggleState, ToggleEvent>({
26
+ // 2. Create the machine using setup().createMachine()
27
+ const toggleMachine = toggleSetup.createMachine({
22
28
  id: "toggle",
23
29
  initial: "off",
30
+ context: ({ input }) => ({
31
+ toggleCount: input?.toggleCount ?? 0,
32
+ }),
24
33
  states: {
25
34
  off: {
26
35
  on: {
27
- TOGGLE: "on",
36
+ toggle: {
37
+ target: "on",
38
+ actions: toggleSetup.assign({
39
+ toggleCount: ({ context }) => context.toggleCount + 1,
40
+ }),
41
+ },
28
42
  },
29
43
  },
30
44
  on: {
31
45
  on: {
32
- TOGGLE: "off",
46
+ toggle: {
47
+ target: "off",
48
+ actions: toggleSetup.assign({
49
+ toggleCount: ({ context }) => context.toggleCount + 1,
50
+ }),
51
+ },
33
52
  },
34
53
  },
35
54
  },
36
55
  });
37
56
 
38
- // Usage
39
- let state = toggleMachine.initialState;
40
- console.log(state); // 'off'
57
+ // 3. Create a player factory
58
+ const createPlayer = definePlayer({ machine: toggleMachine });
59
+
60
+ // 4. Create and start an actor
61
+ const actor = createPlayer();
62
+ actor.start();
63
+
64
+ // 5. Read initial state via getSnapshot()
65
+ console.log(actor.getSnapshot().value); // "off"
66
+ console.log(actor.getSnapshot().context.toggleCount); // 0
41
67
 
42
- state = toggleMachine.transition(state, { type: "TOGGLE" });
43
- console.log(state); // 'on'
68
+ // 6. Read state via TC39 Signal
69
+ console.log(actor.state.get().value); // "off"
44
70
 
45
- state = toggleMachine.transition(state, { type: "TOGGLE" });
46
- console.log(state); // 'off'
71
+ // 7. Send events
72
+ actor.send({ type: "toggle" });
73
+ console.log(actor.getSnapshot().value); // "on"
74
+ console.log(actor.getSnapshot().context.toggleCount); // 1
75
+
76
+ actor.send({ type: "toggle" });
77
+ console.log(actor.getSnapshot().value); // "off"
78
+ console.log(actor.getSnapshot().context.toggleCount); // 2
79
+
80
+ // 8. Cleanup
81
+ actor.stop();
47
82
  ```
48
83
 
49
84
  ## Code Explanation
50
85
 
51
- 1. **Define TypeScript types** - Create union types for states (`'off' | 'on'`) and events (`{ type: 'TOGGLE' }`) to get type safety throughout your application.
86
+ 1. **`setup({ types })`** Declares TypeScript types for `context`, `events`, and `input` before the machine is created. This is the XState v5 typed entry point. Never pass type parameters directly to `createMachine`.
87
+
88
+ 2. **`toggleSetup.createMachine(...)`** — Creates the state machine. Using the scoped `toggleSetup.createMachine` (instead of the bare `createMachine` from xstate) ensures that guards and actions are type-checked against the declared types.
89
+
90
+ 3. **`toggleSetup.assign(...)`** — Assigns context mutations using the typed setup's `assign` helper. This provides full inference from the declared context type — no manual type assertions needed.
91
+
92
+ 4. **`definePlayer({ machine })`** — Wraps the machine in a factory. Calling `createPlayer()` returns a `PlayerActor` — XMachines' actor type that extends XState's actor with TC39 Signal reactivity and Play Architecture hooks.
93
+
94
+ 5. **`actor.start()`** — Activates the machine. Always call `start()` before sending events.
52
95
 
53
- 2. **Create machine with initial state** - Use `createMachine` with an `initial` property to specify which state the machine starts in.
96
+ 6. **`actor.getSnapshot()`** Returns the current XState snapshot synchronously. `.value` is the state name; `.context` is the typed context object.
54
97
 
55
- 3. **Define state transitions** - In the `states` config, each state has an `on` object mapping event types to target states.
98
+ 7. **`actor.state.get()`** TC39 Signal access to the current snapshot. Useful when wiring infrastructure that observes signals (renderers, router bridges). Equivalent to `actor.getSnapshot()` for one-time reads.
56
99
 
57
- 4. **Use the machine** - Call `transition(currentState, event)` to compute the next state based on the current state and incoming event.
100
+ 8. **Event types use dot-separated lowercase** `"toggle"` not `"TOGGLE"`. This matches the XMachines convention used throughout the codebase (e.g. `"auth.login"`, `"auth.logout"`, `"play.route"`).
58
101
 
59
102
  ## Key Concepts
60
103
 
61
- - **State**: The current mode or condition of the machine (`'off'` or `'on'`)
62
- - **Event**: A trigger that causes a state change (`{ type: 'TOGGLE' }`)
63
- - **Transition**: A rule defining how the machine moves from one state to another
64
- - **Type Safety**: TypeScript ensures you only use valid states and events, catching errors at compile time
104
+ - **`setup({ types })`**: The XState v5 typed entry point. Declares context, event, and input shapes before machine creation.
105
+ - **`definePlayer({ machine })`**: Creates a factory function that returns `PlayerActor` instances.
106
+ - **`actor.state`**: A `Signal.State<Snapshot>` TC39 Signals-based reactive handle on the machine snapshot.
107
+ - **`actor.getSnapshot()`**: Synchronous snapshot access use for one-time reads and TypeScript-typed context inspection.
108
+ - **Typed `assign`**: Always call `setup.assign(...)` (not the bare `assign` from xstate) for context mutations.
65
109
 
66
110
  ## Next Steps
67
111
 
68
- - **[Traffic Light Example](traffic-light.md)** - See how to handle multiple states with cyclic transitions
69
- - **[Form Validation Example](form-validation.md)** - Learn about guards and conditional transitions
70
- - **[API Documentation](../api/@xmachines/play/README.md)** - Explore the complete API reference
112
+ - **[Traffic Light Example](traffic-light.md)** — Multi-state machine with `meta.route` and `formatPlayRouteTransitions`
113
+ - **[Form Validation Example](form-validation.md)** Typed context mutations with `setup.assign` and guards
114
+ - **[Routing Patterns](routing-patterns.md)** Adding `meta.route` to states and using `play.route` events