@xmachines/docs 1.0.0-beta.46 → 1.0.0-beta.48

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 (346) hide show
  1. package/README.md +135 -7
  2. package/api/@xmachines/play/README.md +134 -57
  3. package/api/@xmachines/play/classes/NonNullableError.md +4 -4
  4. package/api/@xmachines/play/classes/PlayError.md +4 -4
  5. package/api/@xmachines/play/functions/assertNonNullable.md +1 -1
  6. package/api/@xmachines/play/type-aliases/PlayEvent.md +2 -2
  7. package/api/@xmachines/play-actor/README.md +130 -155
  8. package/api/@xmachines/play-actor/classes/AbstractActor.md +3 -3
  9. package/api/@xmachines/play-actor/functions/typedSpec.md +1 -1
  10. package/api/@xmachines/play-actor/interfaces/BaseActorProviderProps.md +5 -5
  11. package/api/@xmachines/play-actor/interfaces/BaseViewContextValue.md +5 -5
  12. package/api/@xmachines/play-actor/interfaces/PlaySpec.md +2 -2
  13. package/api/@xmachines/play-actor/interfaces/Routable.md +3 -3
  14. package/api/@xmachines/play-actor/interfaces/Viewable.md +2 -2
  15. package/api/@xmachines/play-dom/README.md +140 -232
  16. package/api/@xmachines/play-dom/classes/PlayRenderer.md +4 -4
  17. package/api/@xmachines/play-dom/functions/connectRenderer.md +1 -1
  18. package/api/@xmachines/play-dom/functions/createPlayUI.md +1 -1
  19. package/api/@xmachines/play-dom/functions/createRenderer.md +1 -1
  20. package/api/@xmachines/play-dom/functions/defineRegistry.md +1 -1
  21. package/api/@xmachines/play-dom/functions/renderSpec.md +1 -1
  22. package/api/@xmachines/play-dom/interfaces/ComponentContext.md +7 -7
  23. package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +13 -13
  24. package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +6 -6
  25. package/api/@xmachines/play-dom/interfaces/DefineRegistryResult.md +4 -4
  26. package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +12 -12
  27. package/api/@xmachines/play-dom/interfaces/EventHandle.md +4 -4
  28. package/api/@xmachines/play-dom/interfaces/MountOptions.md +3 -3
  29. package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +5 -5
  30. package/api/@xmachines/play-dom/interfaces/UIProviderOptions.md +5 -5
  31. package/api/@xmachines/play-dom/type-aliases/ActionFn.md +1 -1
  32. package/api/@xmachines/play-dom/type-aliases/Actions.md +1 -1
  33. package/api/@xmachines/play-dom/type-aliases/BaseComponentProps.md +7 -7
  34. package/api/@xmachines/play-dom/type-aliases/CatalogHasActions.md +1 -1
  35. package/api/@xmachines/play-dom/type-aliases/ComponentFn.md +1 -1
  36. package/api/@xmachines/play-dom/type-aliases/ComponentRegistry.md +1 -1
  37. package/api/@xmachines/play-dom/type-aliases/DefineRegistryOptions.md +2 -2
  38. package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +1 -1
  39. package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +1 -1
  40. package/api/@xmachines/play-dom/type-aliases/DomSchema.md +1 -1
  41. package/api/@xmachines/play-dom/type-aliases/MountFn.md +1 -1
  42. package/api/@xmachines/play-dom/type-aliases/SetState.md +1 -1
  43. package/api/@xmachines/play-dom/variables/schema.md +1 -1
  44. package/api/@xmachines/play-dom-router/README.md +160 -158
  45. package/api/@xmachines/play-dom-router/functions/connectRouter.md +1 -1
  46. package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +1 -1
  47. package/api/@xmachines/play-dom-router/functions/createRouteMap.md +1 -1
  48. package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
  49. package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +14 -14
  50. package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +14 -14
  51. package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +4 -4
  52. package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +6 -6
  53. package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +3 -3
  54. package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +3 -3
  55. package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +2 -2
  56. package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +3 -3
  57. package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +3 -3
  58. package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +4 -4
  59. package/api/@xmachines/play-dom-router/type-aliases/RoutableActor.md +1 -1
  60. package/api/@xmachines/play-react/README.md +109 -320
  61. package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +5 -5
  62. package/api/@xmachines/play-react/functions/useActor.md +1 -1
  63. package/api/@xmachines/play-react/functions/usePlayView.md +1 -1
  64. package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
  65. package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +8 -8
  66. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +4 -4
  67. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +3 -3
  68. package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +8 -8
  69. package/api/@xmachines/play-react/interfaces/ViewContextValue.md +5 -5
  70. package/api/@xmachines/play-react/type-aliases/PlayActor.md +1 -1
  71. package/api/@xmachines/play-react/variables/ActorProvider.md +1 -1
  72. package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
  73. package/api/@xmachines/play-react/variables/PlayUIProvider.md +1 -1
  74. package/api/@xmachines/play-react-router/README.md +107 -124
  75. package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +23 -23
  76. package/api/@xmachines/play-react-router/classes/RouteMap.md +4 -4
  77. package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +1 -1
  78. package/api/@xmachines/play-react-router/functions/createRouteMap.md +1 -1
  79. package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
  80. package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +6 -6
  81. package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +5 -5
  82. package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +2 -2
  83. package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
  84. package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
  85. package/api/@xmachines/play-router/README.md +235 -475
  86. package/api/@xmachines/play-router/classes/RouteMap.md +4 -4
  87. package/api/@xmachines/play-router/classes/RouterBridgeBase.md +23 -23
  88. package/api/@xmachines/play-router/functions/buildPlayRouteEvent.md +1 -1
  89. package/api/@xmachines/play-router/functions/buildRouteTree.md +1 -1
  90. package/api/@xmachines/play-router/functions/createRouteMap.md +1 -1
  91. package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +1 -1
  92. package/api/@xmachines/play-router/functions/createRouteMatcher.md +1 -1
  93. package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +1 -1
  94. package/api/@xmachines/play-router/functions/extractMachineRoutes.md +1 -1
  95. package/api/@xmachines/play-router/functions/extractQuery.md +1 -1
  96. package/api/@xmachines/play-router/functions/extractRouteParams.md +1 -1
  97. package/api/@xmachines/play-router/functions/findRouteById.md +1 -1
  98. package/api/@xmachines/play-router/functions/findRouteByPath.md +1 -1
  99. package/api/@xmachines/play-router/functions/getNavigableRoutes.md +1 -1
  100. package/api/@xmachines/play-router/functions/getRoutableRoutes.md +1 -1
  101. package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +1 -1
  102. package/api/@xmachines/play-router/functions/isRouteReachable.md +1 -1
  103. package/api/@xmachines/play-router/functions/machineToGraph.md +1 -1
  104. package/api/@xmachines/play-router/functions/routeExists.md +1 -1
  105. package/api/@xmachines/play-router/functions/sanitizePathname.md +1 -1
  106. package/api/@xmachines/play-router/functions/validateRouteFormat.md +1 -1
  107. package/api/@xmachines/play-router/functions/validateStateExists.md +1 -1
  108. package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +4 -4
  109. package/api/@xmachines/play-router/interfaces/LocationLike.md +3 -3
  110. package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +3 -3
  111. package/api/@xmachines/play-router/interfaces/MachineNodeData.md +5 -5
  112. package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +6 -6
  113. package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
  114. package/api/@xmachines/play-router/interfaces/RouteMapOptions.md +2 -2
  115. package/api/@xmachines/play-router/interfaces/RouteMapping.md +3 -3
  116. package/api/@xmachines/play-router/interfaces/RouteMatch.md +3 -3
  117. package/api/@xmachines/play-router/interfaces/RouteMatcher.md +4 -4
  118. package/api/@xmachines/play-router/interfaces/RouteNode.md +10 -10
  119. package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
  120. package/api/@xmachines/play-router/interfaces/RouteTree.md +5 -5
  121. package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +3 -3
  122. package/api/@xmachines/play-router/interfaces/RouterBridge.md +3 -3
  123. package/api/@xmachines/play-router/interfaces/WindowLike.md +3 -3
  124. package/api/@xmachines/play-router/type-aliases/MachineGraph.md +1 -1
  125. package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
  126. package/api/@xmachines/play-signals/README.md +105 -73
  127. package/api/@xmachines/play-signals/functions/watchSignal.md +1 -1
  128. package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
  129. package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
  130. package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
  131. package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
  132. package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
  133. package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
  134. package/api/@xmachines/play-solid/README.md +117 -263
  135. package/api/@xmachines/play-solid/functions/useActor.md +1 -1
  136. package/api/@xmachines/play-solid/functions/usePlayView.md +1 -1
  137. package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +8 -8
  138. package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +8 -8
  139. package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +5 -5
  140. package/api/@xmachines/play-solid/type-aliases/PlayActor.md +1 -1
  141. package/api/@xmachines/play-solid/variables/ActorContext.md +1 -1
  142. package/api/@xmachines/play-solid/variables/ActorProvider.md +1 -1
  143. package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
  144. package/api/@xmachines/play-solid/variables/PlayUIProvider.md +1 -1
  145. package/api/@xmachines/play-solid-router/README.md +93 -606
  146. package/api/@xmachines/play-solid-router/classes/RouteMap.md +4 -4
  147. package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +24 -24
  148. package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +1 -1
  149. package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
  150. package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +3 -3
  151. package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +6 -6
  152. package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
  153. package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +2 -2
  154. package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
  155. package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +3 -3
  156. package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +1 -1
  157. package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
  158. package/api/@xmachines/play-svelte/README.md +111 -103
  159. package/api/@xmachines/play-svelte/functions/defineRegistry.md +1 -1
  160. package/api/@xmachines/play-svelte/functions/getActorContext.md +1 -1
  161. package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +1 -1
  162. package/api/@xmachines/play-svelte/functions/setActorContext.md +1 -1
  163. package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +8 -8
  164. package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +4 -4
  165. package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +11 -11
  166. package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +5 -5
  167. package/api/@xmachines/play-svelte/type-aliases/PlayActor.md +1 -1
  168. package/api/@xmachines/play-svelte-spa-router/README.md +156 -17
  169. package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +4 -4
  170. package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +1 -1
  171. package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +1 -1
  172. package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +4 -4
  173. package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +6 -6
  174. package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +2 -2
  175. package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +3 -3
  176. package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
  177. package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +3 -3
  178. package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
  179. package/api/@xmachines/play-sveltekit-router/README.md +168 -17
  180. package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +4 -4
  181. package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +1 -1
  182. package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +1 -1
  183. package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +4 -4
  184. package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +3 -3
  185. package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +6 -6
  186. package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +2 -2
  187. package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +3 -3
  188. package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +3 -3
  189. package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +1 -1
  190. package/api/@xmachines/play-tanstack-react-router/README.md +147 -122
  191. package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +4 -4
  192. package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +23 -23
  193. package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +1 -1
  194. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +1 -1
  195. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
  196. package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +1 -1
  197. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +6 -6
  198. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
  199. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +2 -2
  200. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
  201. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
  202. package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +3 -3
  203. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
  204. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +4 -4
  205. package/api/@xmachines/play-tanstack-solid-router/README.md +195 -173
  206. package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +4 -4
  207. package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +24 -24
  208. package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +1 -1
  209. package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
  210. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +6 -6
  211. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
  212. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +2 -2
  213. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
  214. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +3 -3
  215. package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +1 -1
  216. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
  217. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +3 -3
  218. package/api/@xmachines/play-vue/README.md +126 -271
  219. package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
  220. package/api/@xmachines/play-vue/functions/getPlayViewContext.md +1 -1
  221. package/api/@xmachines/play-vue/functions/useActor.md +1 -1
  222. package/api/@xmachines/play-vue/interfaces/ActorProviderProps.md +5 -5
  223. package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +8 -8
  224. package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +5 -5
  225. package/api/@xmachines/play-vue/interfaces/VisibilityProviderProps.md +1 -1
  226. package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
  227. package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
  228. package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +2 -2
  229. package/api/@xmachines/play-vue/type-aliases/PlayActor.md +1 -1
  230. package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
  231. package/api/@xmachines/play-vue-router/README.md +148 -528
  232. package/api/@xmachines/play-vue-router/classes/RouteMap.md +4 -4
  233. package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +24 -24
  234. package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
  235. package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +6 -6
  236. package/api/@xmachines/play-vue-router/interfaces/RouteMapOptions.md +2 -2
  237. package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +3 -3
  238. package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +3 -3
  239. package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +1 -1
  240. package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +1 -1
  241. package/api/@xmachines/play-xstate/README.md +167 -496
  242. package/api/@xmachines/play-xstate/classes/PlayerActor.md +12 -12
  243. package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +1 -1
  244. package/api/@xmachines/play-xstate/functions/composeGuards.md +1 -1
  245. package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +1 -1
  246. package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +1 -1
  247. package/api/@xmachines/play-xstate/functions/definePlayer.md +1 -1
  248. package/api/@xmachines/play-xstate/functions/deriveRoute.md +1 -1
  249. package/api/@xmachines/play-xstate/functions/eventMatches.md +1 -1
  250. package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +1 -1
  251. package/api/@xmachines/play-xstate/functions/hasContext.md +1 -1
  252. package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
  253. package/api/@xmachines/play-xstate/functions/negateGuard.md +1 -1
  254. package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +3 -3
  255. package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +2 -2
  256. package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +6 -6
  257. package/api/@xmachines/play-xstate/interfaces/RouteContext.md +5 -5
  258. package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +1 -1
  259. package/api/@xmachines/play-xstate/type-aliases/Guard.md +1 -1
  260. package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +1 -1
  261. package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +1 -1
  262. package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +4 -4
  263. package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
  264. package/api/@xmachines/shared/README.md +81 -294
  265. package/api/@xmachines/shared/vite-aliases/functions/xmAliases.md +1 -1
  266. package/api/@xmachines/shared/vite-aliases/functions/xmCacheDir.md +1 -1
  267. package/api/@xmachines/shared/vite-aliases/functions/xmOptimizeDeps.md +1 -1
  268. package/api/@xmachines/shared/vite-aliases/functions/xmResolve.md +1 -1
  269. package/api/@xmachines/shared/vitest/functions/defineXmVitestConfig.md +1 -1
  270. package/examples/@xmachines/play-dom-demo/README.md +3 -3
  271. package/examples/@xmachines/play-dom-demo/functions/createNavBar.md +1 -1
  272. package/examples/@xmachines/play-dom-demo/functions/initShell.md +1 -1
  273. package/examples/@xmachines/play-dom-demo/type-aliases/AuthCatalog.md +1 -1
  274. package/examples/@xmachines/play-dom-demo/variables/About.md +1 -1
  275. package/examples/@xmachines/play-dom-demo/variables/Contact.md +1 -1
  276. package/examples/@xmachines/play-dom-demo/variables/Dashboard.md +1 -1
  277. package/examples/@xmachines/play-dom-demo/variables/Home.md +1 -1
  278. package/examples/@xmachines/play-dom-demo/variables/Login.md +1 -1
  279. package/examples/@xmachines/play-dom-demo/variables/NavBarView.md +1 -1
  280. package/examples/@xmachines/play-dom-demo/variables/Navigation.md +1 -1
  281. package/examples/@xmachines/play-dom-demo/variables/Overview.md +1 -1
  282. package/examples/@xmachines/play-dom-demo/variables/Profile.md +1 -1
  283. package/examples/@xmachines/play-dom-demo/variables/Settings.md +1 -1
  284. package/examples/@xmachines/play-dom-demo/variables/Stats.md +1 -1
  285. package/examples/@xmachines/play-dom-demo/variables/authCatalog.md +1 -1
  286. package/examples/@xmachines/play-dom-router-demo/README.md +2 -2
  287. package/examples/@xmachines/play-react-demo/README.md +1 -1
  288. package/examples/@xmachines/play-react-demo/functions/App.md +1 -1
  289. package/examples/@xmachines/play-react-demo/type-aliases/AuthCatalog.md +1 -1
  290. package/examples/@xmachines/play-react-demo/variables/About.md +1 -1
  291. package/examples/@xmachines/play-react-demo/variables/Contact.md +1 -1
  292. package/examples/@xmachines/play-react-demo/variables/Dashboard.md +1 -1
  293. package/examples/@xmachines/play-react-demo/variables/DebugPanel.md +1 -1
  294. package/examples/@xmachines/play-react-demo/variables/Home.md +1 -1
  295. package/examples/@xmachines/play-react-demo/variables/Login.md +1 -1
  296. package/examples/@xmachines/play-react-demo/variables/NavBar.md +1 -1
  297. package/examples/@xmachines/play-react-demo/variables/NavBarView.md +1 -1
  298. package/examples/@xmachines/play-react-demo/variables/Navigation.md +1 -1
  299. package/examples/@xmachines/play-react-demo/variables/Overview.md +1 -1
  300. package/examples/@xmachines/play-react-demo/variables/Profile.md +1 -1
  301. package/examples/@xmachines/play-react-demo/variables/Settings.md +1 -1
  302. package/examples/@xmachines/play-react-demo/variables/Shell.md +1 -1
  303. package/examples/@xmachines/play-react-demo/variables/Stats.md +1 -1
  304. package/examples/@xmachines/play-react-demo/variables/authCatalog.md +1 -1
  305. package/examples/@xmachines/play-react-router-demo/README.md +1 -1
  306. package/examples/@xmachines/play-solid-demo/README.md +1 -1
  307. package/examples/@xmachines/play-solid-demo/functions/App.md +1 -1
  308. package/examples/@xmachines/play-solid-demo/type-aliases/AuthCatalog.md +1 -1
  309. package/examples/@xmachines/play-solid-demo/variables/About.md +1 -1
  310. package/examples/@xmachines/play-solid-demo/variables/Contact.md +1 -1
  311. package/examples/@xmachines/play-solid-demo/variables/Dashboard.md +1 -1
  312. package/examples/@xmachines/play-solid-demo/variables/DebugPanel.md +1 -1
  313. package/examples/@xmachines/play-solid-demo/variables/Home.md +1 -1
  314. package/examples/@xmachines/play-solid-demo/variables/Login.md +1 -1
  315. package/examples/@xmachines/play-solid-demo/variables/NavBar.md +1 -1
  316. package/examples/@xmachines/play-solid-demo/variables/NavBarView.md +1 -1
  317. package/examples/@xmachines/play-solid-demo/variables/Navigation.md +1 -1
  318. package/examples/@xmachines/play-solid-demo/variables/Overview.md +1 -1
  319. package/examples/@xmachines/play-solid-demo/variables/Profile.md +1 -1
  320. package/examples/@xmachines/play-solid-demo/variables/Settings.md +1 -1
  321. package/examples/@xmachines/play-solid-demo/variables/Shell.md +1 -1
  322. package/examples/@xmachines/play-solid-demo/variables/Stats.md +1 -1
  323. package/examples/@xmachines/play-solid-demo/variables/authCatalog.md +1 -1
  324. package/examples/@xmachines/play-svelte-demo/README.md +1 -1
  325. package/examples/@xmachines/play-svelte-demo/type-aliases/AuthCatalog.md +1 -1
  326. package/examples/@xmachines/play-svelte-demo/variables/authCatalog.md +1 -1
  327. package/examples/@xmachines/play-svelte-spa-router-demo/README.md +2 -2
  328. package/examples/@xmachines/play-sveltekit-router-demo/README.md +2 -2
  329. package/examples/@xmachines/play-vue-demo/README.md +1 -1
  330. package/examples/@xmachines/play-vue-demo/type-aliases/AuthCatalog.md +1 -1
  331. package/examples/@xmachines/play-vue-demo/variables/App.md +1 -1
  332. package/examples/@xmachines/play-vue-demo/variables/authCatalog.md +1 -1
  333. package/examples/README.md +24 -25
  334. package/examples/form-validation.md +2 -2
  335. package/guides/README.md +7 -7
  336. package/guides/actor-model.md +18 -18
  337. package/guides/architecture.md +500 -0
  338. package/guides/configuration.md +556 -0
  339. package/guides/deployment.md +336 -0
  340. package/guides/development.md +617 -0
  341. package/guides/getting-started.md +351 -142
  342. package/guides/signals.md +19 -19
  343. package/guides/state-machines.md +16 -16
  344. package/guides/testing.md +460 -0
  345. package/package.json +5 -5
  346. package/guides/installation.md +0 -257
@@ -1,628 +1,299 @@
1
1
  [API](../../README.md) / @xmachines/play-xstate
2
2
 
3
- # @xmachines/play-xstate
4
-
5
- **XState v5 adapter for Play Architecture with signal-driven reactivity and routing**
6
-
7
- Transform declarative state machines into live actors with TC39 Signals and parameter-aware navigation.
3
+ <!-- generated-by: gsd-doc-writer -->
8
4
 
9
- ## Overview
5
+ # @xmachines/play-xstate
10
6
 
11
- `@xmachines/play-xstate` provides `definePlayer()`, the primary API for binding XState v5 state machines to the Play Architecture actor base. It enables business logic to control routing and state through guard-enforced transitions, signal lifecycle management, and XState DevTools compatibility.
7
+ > XState v5 adapter for the XMachines Play Architecture bind state machines to the actor base with signal-driven reactivity and router integration.
12
8
 
13
- Per [Play RFC](../../../rfc/play.md), this package implements:
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
+ [![Version](https://img.shields.io/badge/version-1.0.0--beta.46-blue)](https://www.npmjs.com/package/@xmachines/play-xstate)
14
11
 
15
- - **Actor Authority (INV-01):** State machine guards decide navigation validity
16
- - **Strict Separation (INV-02):** Zero React/framework imports in business logic
17
- - **Signal-Only Reactivity (INV-05):** TC39 Signals expose all state changes
12
+ Part of the [XMachines Play](../../README.md) monorepo.
18
13
 
19
- **Routing:** Supports `meta.route` patterns, `play.route` events with parameters, and route extraction.
14
+ ---
20
15
 
21
16
  ## Installation
22
17
 
23
18
  ```bash
24
- npm install xstate@^5.0.0
25
- npm install @xmachines/play-xstate
19
+ npm install @xmachines/play-xstate xstate
26
20
  ```
27
21
 
28
- **Peer dependencies:**
22
+ `xstate ^5.30.0` is a peer dependency and must be installed alongside this package.
29
23
 
30
- - `xstate` ^5.0.0 — State machine runtime
24
+ ---
31
25
 
32
26
  ## Quick Start
33
27
 
34
28
  ```typescript
35
- import { setup, assign } from "xstate";
36
- import { definePlayer, formatPlayRouteTransitions } from "@xmachines/play-xstate";
29
+ import { setup } from "xstate";
30
+ import { definePlayer } from "@xmachines/play-xstate";
37
31
 
38
- // 1. Define XState machine with meta.route and view spec
39
- const machine = setup({
40
- types: {
41
- context: {} as {
42
- isAuthenticated: boolean;
43
- params: Record<string, string>;
44
- query: Record<string, string>;
45
- },
46
- events: {} as
47
- | { type: "play.route"; to: string; params?: Record<string, string> }
48
- | { type: "auth.login" }
49
- | { type: "auth.logout" },
32
+ // 1. Define your XState v5 machine
33
+ const machine = setup({}).createMachine({
34
+ initial: "idle",
35
+ states: {
36
+ idle: { meta: { route: "/" } },
37
+ active: { meta: { route: "/active" } },
50
38
  },
51
- }).createMachine(
52
- formatPlayRouteTransitions({
53
- id: "app",
54
- initial: "login",
55
- context: { isAuthenticated: false, params: {}, query: {} },
56
- states: {
57
- login: {
58
- id: "login",
59
- meta: {
60
- route: "/login",
61
- view: {
62
- component: "Login",
63
- spec: {
64
- root: "root",
65
- elements: {
66
- root: { type: "Login", props: { title: "Sign In" }, children: [] },
67
- },
68
- },
69
- },
70
- },
71
- },
72
- dashboard: {
73
- id: "dashboard",
74
- meta: {
75
- route: "/dashboard",
76
- view: {
77
- component: "Dashboard",
78
- spec: {
79
- root: "root",
80
- elements: {
81
- root: { type: "Dashboard", props: {}, children: [] },
82
- },
83
- },
84
- },
85
- },
86
- always: [{ target: "login", guard: ({ context }) => !context.isAuthenticated }],
87
- },
88
- },
89
- on: {
90
- "auth.login": {
91
- target: ".dashboard",
92
- guard: ({ context }) => !context.isAuthenticated,
93
- actions: assign({ isAuthenticated: true }),
94
- },
95
- "auth.logout": {
96
- target: ".login",
97
- actions: assign({ isAuthenticated: false }),
98
- },
99
- },
100
- }),
101
- );
39
+ });
102
40
 
103
- // 2. Create player factory
41
+ // 2. Create a player factory
104
42
  const createPlayer = definePlayer({ machine });
105
43
 
106
- // 3. Create and start actor
44
+ // 3. Instantiate and start an actor
107
45
  const actor = createPlayer();
108
46
  actor.start();
109
47
 
110
- // 4. Observe signals
111
- console.log(actor.currentRoute.get()); // "/login"
112
- console.log(actor.currentView.get()); // { component: "Login", spec: {...} }
48
+ // 4. Observe TC39 Signal-based reactive state
49
+ console.log(actor.currentRoute.get()); // "/"
50
+ console.log(actor.state.get().value); // "idle"
113
51
 
114
- // 5. Cleanup
115
- actor.dispose();
116
- ```
52
+ // 5. Send events — machine guards decide transitions
53
+ actor.send({ type: "activate" });
117
54
 
118
- ## API Reference
119
-
120
- ### definePlayer()
121
-
122
- Create a player factory from an XState machine:
123
-
124
- ```typescript
125
- const createPlayer = definePlayer<TMachine>({
126
- machine: AnyStateMachine,
127
- options?: PlayerOptions,
128
- }): PlayerFactory;
55
+ actor.stop();
129
56
  ```
130
57
 
131
- **Config:**
58
+ ---
132
59
 
133
- - `machine` (required) - XState v5 state machine
134
- - `options` (optional) - Lifecycle hooks
60
+ ## API Summary
135
61
 
136
- **Returns:** Factory function `(input?, { snapshot }?) => PlayerActor`
62
+ ### `definePlayer(config)`
137
63
 
138
- **Example:**
64
+ Creates a `PlayerFactory` from an XState v5 machine. The factory pattern enables multiple independent actor instances from a single configuration — useful for multi-user scenarios, SSR, or testing.
139
65
 
140
66
  ```typescript
67
+ import { setup } from "xstate";
68
+ import { definePlayer } from "@xmachines/play-xstate";
69
+
70
+ const machine = setup({
71
+ types: {
72
+ context: {} as { userId: string },
73
+ input: {} as { userId: string },
74
+ },
75
+ }).createMachine({
76
+ context: ({ input }) => ({ userId: input.userId }),
77
+ initial: "home",
78
+ states: { home: {} },
79
+ });
80
+
141
81
  const createPlayer = definePlayer({
142
- machine: authMachine,
82
+ machine,
143
83
  options: {
144
- onStart: (actor) => console.log("Started:", actor.id),
145
- onTransition: (actor, prev, next) => {
146
- console.log("Transition:", prev.value, "", next.value);
147
- },
84
+ onStart: (actor) => console.log("started"),
85
+ onStop: (actor) => console.log("stopped"),
86
+ onTransition: (actor, prev, next) => console.log("transitioned"),
87
+ onStateChange: (actor, state) => console.log("state changed"),
88
+ onError: (actor, err) => console.error(err),
148
89
  },
149
90
  });
150
91
 
151
- const actor1 = createPlayer({ userId: "user1" });
152
- const actor2 = createPlayer({ userId: "user2" });
153
- // Multiple independent actor instances
92
+ // Each call returns an independent PlayerActor instance
93
+ const alice = createPlayer({ userId: "alice" });
94
+ const bob = createPlayer({ userId: "bob" });
154
95
  ```
155
96
 
156
- **Restoring from a snapshot:**
97
+ #### `PlayerFactory` signature
157
98
 
158
99
  ```typescript
159
- const createPlayer = definePlayer({ machine });
100
+ type PlayerFactory<TMachine> = (
101
+ input?: InputFrom<TMachine>,
102
+ options?: PlayerFactoryResumeOptions<TMachine>,
103
+ ) => PlayerActor<TMachine>;
104
+ ```
160
105
 
161
- const actor = createPlayer();
162
- actor.start();
106
+ #### Restoring from a snapshot
163
107
 
164
- // ...persist the actor snapshot however your app stores it
108
+ ```typescript
165
109
  const snapshot = actor.getSnapshot();
166
110
  actor.stop();
167
111
 
168
- const restoredActor = createPlayer(undefined, { snapshot });
169
- restoredActor.start();
112
+ // Restore to the exact saved state
113
+ const restored = createPlayer({ userId: "alice" }, { snapshot });
114
+ restored.start();
115
+ console.log(restored.currentRoute.get()); // same route as when saved
170
116
  ```
171
117
 
172
- `restoredActor.initialRoute` still reflects the machine's default initial route, not the
173
- restored snapshot route. Router bridges rely on that invariant to distinguish a deep-link
174
- from a restored session during `connect()`.
175
-
176
- ### PlayerActor
177
-
178
- Concrete actor implementing Play signal protocol:
179
-
180
- **Signal Properties:**
181
-
182
- - `state: Signal.State<AnyMachineSnapshot>` — Reactive snapshot of current state
183
- - `currentRoute: Signal.Computed<string | null>` — Derived URL from the current state's `meta.route` and `context.params`. Returns `null` when no route metadata is present or a required route parameter is missing from context.
184
- - `currentView: Signal.State<ViewMetadata | null>` — Current view spec (updated on every state transition). The spec is automatically enriched with `context.params` (URL params) and any `contextProps`-allowlisted context fields before being emitted (see [Prop Enrichment from Routing and Context](#prop-enrichment-from-routing-and-context)).
118
+ ---
185
119
 
186
- **Lifecycle ordering:**
120
+ ### `PlayerActor<TMachine>`
187
121
 
188
- - `state` and `currentRoute` update synchronously from the active XState snapshot.
189
- - `currentView` is then validated and cached from that same snapshot.
190
- - `onStateChange` runs after those signals are current.
191
- - `onTransition` runs after `send()` completes, with both previous and next snapshots.
192
- - `onStart` runs after the initial active snapshot has been published.
122
+ Concrete actor class that wraps an XState v5 actor and exposes TC39 Signal-based reactive signals. Implements both `Routable` and `Viewable` interfaces from `@xmachines/play-actor`.
193
123
 
194
- **Methods:**
124
+ #### Signals
195
125
 
196
- - `start()` Start the actor (must call after creation)
197
- - `stop()` Stop the actor
198
- - `send(event)` Send event to actor. Typed as `EventFromLogic<TMachine>` when `TMachine` is specified.
199
- - `can(event)` Returns `true` if the current state can accept the given event. Typed as `EventFromLogic<TMachine>` passing an unknown event type is a compile error. Reads from the `state` signal (no allocation). Use instead of `getSnapshot().can()`.
200
- - `dispose()` Convenience cleanup (calls `stop()`)
201
- - `getSnapshot()` Get current XState snapshot, typed as `SnapshotFrom<TMachine>`
126
+ | Signal | Type | Description |
127
+ | -------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
128
+ | `state` | `Signal.State<SnapshotFrom<TMachine>>` | Current XState snapshot; updated on every active transition |
129
+ | `currentRoute` | `Signal.Computed<string \| null>` | Derived URL from active state's `meta.route` template and context |
130
+ | `currentView` | `Signal.State<PlaySpec \| null>` | View spec from active state's `meta.view` metadata; enriched with context params |
131
+ | `initialRoute` | `readonly string \| null` | Machine's initial-state route (fixed at construction; used by router bridges for deep-link vs restore detection) |
202
132
 
203
- **Routing failure behavior:**
133
+ #### Methods
204
134
 
205
- - `currentRoute` returns `null` instead of throwing when a required route parameter (e.g. `:username`) is absent from context. This handles transient states during navigation without crashing signal watchers.
206
- - Errors from `buildRouteUrl()` are typed as `MissingRouteParamError` (importable from `@xmachines/play-xstate/errors`).
135
+ | Method | Description |
136
+ | --------------- | -------------------------------------------------------------- |
137
+ | `start()` | Start the actor and fire `onStart` hook |
138
+ | `stop()` | Stop the actor, clean up subscriptions, fire `onStop` hook |
139
+ | `send(event)` | Send a typed event to the machine; fires `onTransition` hook |
140
+ | `can(event)` | Returns `true` if the current state can accept the given event |
141
+ | `getSnapshot()` | Returns the current XState snapshot |
142
+ | `dispose()` | Alias for `stop()` |
207
143
 
208
- **View derivation and route-param enrichment:**
209
-
210
- - `currentView` emits a fresh `ViewMetadata` object on every transition so TC39 Signal equality checks always detect changes (including re-entries to the same state with different params).
211
- - `context.params` and `contextProps`-allowlisted context fields are merged into spec element props — see [Prop Enrichment from Routing and Context](#prop-enrichment-from-routing-and-context).
212
-
213
- **Example:**
144
+ #### Signal usage example
214
145
 
215
146
  ```typescript
216
- const actor = createPlayer();
217
- actor.start();
147
+ import { Signal } from "@xmachines/play-signals";
218
148
 
219
- // Observe signals with watcher
220
149
  const watcher = new Signal.subtle.Watcher(() => {
221
150
  queueMicrotask(() => {
222
- const route = actor.currentRoute.get();
223
- console.log("Route changed:", route);
151
+ console.log("Route changed:", actor.currentRoute.get());
224
152
  });
225
153
  });
154
+
226
155
  watcher.watch(actor.currentRoute);
227
- actor.currentRoute.get(); // Initial read
156
+ actor.start();
228
157
  ```
229
158
 
230
- ### Guard Composition
159
+ ---
160
+
161
+ ### Guard utilities
162
+
163
+ Composable guard helpers that wrap XState's built-in `and()`, `or()`, and `not()` for use in machine `setup({ guards })` definitions.
231
164
 
232
165
  ```typescript
166
+ import { setup } from "xstate";
233
167
  import {
234
- composeGuards,
235
- composeGuardsOr,
236
- negateGuard,
237
- hasContext,
238
- eventMatches,
239
- contextFieldMatches,
168
+ composeGuards, // AND logic: all guards must pass
169
+ composeGuardsOr, // OR logic: at least one guard must pass
170
+ negateGuard, // NOT logic: inverts a guard
171
+ hasContext, // guard: context field is present and non-null
172
+ eventMatches, // guard: event type matches a string
173
+ contextFieldMatches, // guard: context field equals a value
240
174
  } from "@xmachines/play-xstate";
241
175
 
242
176
  const machine = setup({
243
177
  guards: {
244
- isLoggedIn: hasContext("userId"),
245
- isAdmin: ({ context }) => context.role === "admin",
178
+ isLoggedIn: ({ context }) => !!context.userId,
179
+ hasAdminRole: ({ context }) => context.role === "admin",
246
180
  },
247
181
  }).createMachine({
248
182
  on: {
249
183
  accessAdmin: {
250
- // Array means AND - all guards must pass
251
- guard: composeGuards(["isLoggedIn", "isAdmin"]),
184
+ guard: composeGuards(["isLoggedIn", "hasAdminRole"]),
252
185
  target: "adminPanel",
253
186
  },
254
- accessPublic: {
255
- // OR composition - any guard passes
256
- guard: composeGuardsOr(["isLoggedIn", ({ event }) => event.type === "guest.access"]),
257
- target: "publicArea",
258
- },
259
- logout: {
260
- // NOT composition
261
- guard: negateGuard("isLoggedIn"),
262
- target: "login",
187
+ accessDashboard: {
188
+ guard: negateGuard("isGuest"),
189
+ target: "dashboard",
263
190
  },
264
191
  },
192
+ // ...
265
193
  });
266
194
  ```
267
195
 
268
- **Helpers:**
196
+ ---
269
197
 
270
- - `hasContext(path: string)` - Check if context property is truthy
271
- - `eventMatches(type: string)` - Check event type
272
- - `contextFieldMatches(fieldPath: string, expectedValue: unknown)` - Check context field with strict structural equality
273
- - `composeGuards(guards: Array)` - AND composition
274
- - `composeGuardsOr(guards: Array)` - OR composition
275
- - `negateGuard(guard)` - NOT composition
198
+ ### Routing utilities
276
199
 
277
- ## Examples
200
+ Helper functions for declarative route configuration in XState machines.
278
201
 
279
- ### Guard Placement Philosophy
202
+ #### `formatPlayRouteTransitions(machineConfig)`
280
203
 
281
- **Guards check if you can BE in a state (state entry), not if you can TAKE an event (event handlers).**
204
+ Crawls machine states with `meta.route` and auto-generates `play.route` event handlers at the root level eliminating boilerplate routing transitions.
282
205
 
283
206
  ```typescript
284
207
  import { setup } from "xstate";
285
- import { definePlayer, formatPlayRouteTransitions } from "@xmachines/play-xstate";
208
+ import { formatPlayRouteTransitions } from "@xmachines/play-xstate";
286
209
 
287
- // Pattern 1: RECOMMENDED - Use formatPlayRouteTransitions utility
288
- const machineConfig = {
210
+ const config = formatPlayRouteTransitions({
289
211
  id: "app",
290
- initial: "home",
291
- context: { isAuthenticated: false },
292
212
  states: {
293
213
  home: {
294
214
  id: "home",
295
- meta: { route: "/", view: { component: "Home" } },
296
- },
297
- dashboard: {
298
- id: "dashboard",
299
- meta: { route: "/dashboard", view: { component: "Dashboard" } },
300
- // Always-guard validates state entry
301
- always: [
302
- {
303
- target: "login",
304
- guard: ({ context }) => !context.isAuthenticated,
305
- },
306
- ],
307
- },
308
- login: {
309
- id: "login",
310
- meta: { route: "/login", view: { component: "Login" } },
311
- },
312
- },
313
- };
314
-
315
- // formatPlayRouteTransitions handles routing infrastructure
316
- const machine = setup({
317
- types: {
318
- context: {} as {
319
- isAuthenticated: boolean;
320
- params: Record<string, string>;
321
- query: Record<string, string>;
322
- },
323
- events: {} as
324
- | { type: "play.route"; to: string; params?: Record<string, string> }
325
- | { type: "auth.login" },
326
- },
327
- }).createMachine(formatPlayRouteTransitions(machineConfig));
328
-
329
- const createPlayer = definePlayer({ machine });
330
- const actor = createPlayer();
331
- actor.start();
332
-
333
- // Navigation via play.route event
334
- actor.send({ type: "play.route", to: "/dashboard" });
335
- // Guard validates: Can I BE in dashboard state?
336
- // If !isAuthenticated → redirects to login
337
- ```
338
-
339
- **Why this works:**
340
-
341
- - `formatPlayRouteTransitions` adds routing infrastructure (event.to → state mapping)
342
- - Always-guards handle business logic (authentication checks)
343
- - Clear separation: routing is infrastructure, guards are business logic
344
-
345
- **Anti-pattern (DON'T DO THIS):**
346
-
347
- ```typescript
348
- // ❌ WRONG - Guard on event checking event properties
349
- on: {
350
- "play.route": {
351
- guard: ({ event }) => event.to === "/dashboard",
352
- target: "dashboard"
353
- }
354
- }
355
- ```
356
-
357
- **Reference:** See `docs/examples/routing-patterns.md` for canonical `formatPlayRouteTransitions` usage with always-guards for authentication.
358
-
359
- ### Lifecycle Hooks
360
-
361
- ```typescript
362
- const createPlayer = definePlayer({
363
- machine,
364
- options: {
365
- onStart: (actor) => {
366
- console.log("Actor started:", actor.id);
367
- },
368
- onStop: (actor) => {
369
- console.log("Actor stopped:", actor.id);
370
- },
371
- onTransition: (actor, prev, next) => {
372
- console.log("State change:", {
373
- from: prev.value,
374
- to: next.value,
375
- timestamp: Date.now(),
376
- });
215
+ meta: { route: "/home" },
377
216
  },
378
- onStateChange: (actor, state) => {
379
- // Called on every state update
380
- console.log("Snapshot updated:", state.value);
381
- },
382
- onError: (actor, error) => {
383
- console.error("Actor error:", error);
384
- // Log to monitoring service, show error UI, etc.
217
+ profile: {
218
+ id: "profile",
219
+ meta: { route: "/users/:userId" },
385
220
  },
386
221
  },
387
222
  });
388
- ```
389
-
390
- ### XState DevTools Integration
391
-
392
- ```typescript
393
- import { createBrowserInspector } from "@statelyai/inspect";
394
- import { definePlayer } from "@xmachines/play-xstate";
395
223
 
396
- const { inspect } = createBrowserInspector();
397
-
398
- const createPlayer = definePlayer({ machine });
399
- const actor = createPlayer();
400
- actor.start();
401
-
402
- // PlayerActor maintains XState Inspector compatibility
403
- // Inspector displays:
404
- // - State transitions and values
405
- // - Context data
406
- // - Events sent to actor
407
- // - Guard evaluation results
408
-
409
- // Signals accessible via actor properties, not snapshots
410
- console.log(actor.currentRoute.get()); // "/dashboard"
224
+ // config now includes auto-generated play.route handlers:
225
+ // on: { "play.route": [ { target: ".home", guard: e => e.to === "#home" }, ... ] }
226
+ const machine = setup({}).createMachine(config);
411
227
  ```
412
228
 
413
- ## Metadata Conventions
229
+ > **Note:** Every state with `meta.route` must also have an explicit `id` field; omitting it throws `MissingStateIdError` at machine-definition time.
414
230
 
415
- ### Route Metadata
231
+ #### Other routing exports
416
232
 
417
- ```typescript
418
- // meta.route marks states as routable
419
- states: {
420
- dashboard: {
421
- id: "dashboard",
422
- meta: {
423
- route: "/dashboard", // URL path - marks state as routable
424
- },
425
- },
426
- }
427
-
428
- // Parameters
429
- meta: {
430
- route: "/profile/:userId", // Required parameter
431
- route: "/settings/:section?", // Optional parameter
432
- }
433
-
434
- // Inheritance
435
- meta: {
436
- route: "/absolute", // Starts with / → doesn't inherit parent route
437
- route: "relative", // Doesn't start with / → inherits parent route
438
- }
439
- ```
440
-
441
- ### View Metadata
233
+ | Export | Description |
234
+ | ---------------------------------- | ------------------------------------------------------------------------- |
235
+ | `deriveRoute(meta)` | Extract the route template string from a state's metadata object |
236
+ | `isAbsoluteRoute(route)` | Returns `true` if the route string is an absolute URL path |
237
+ | `buildRouteUrl(template, context)` | Substitute `:param` placeholders in a route template using context values |
442
238
 
443
- View metadata drives the `currentView` signal. The `spec` field follows the `@json-render/core` `Spec` shape:
444
-
445
- ```typescript
446
- meta: {
447
- view: {
448
- component: "Dashboard", // Component name — must exist in the registry
449
- spec: {
450
- root: "root", // Root element key
451
- state: { tab: "general" }, // Optional: initial UI state (form values etc.)
452
- elements: {
453
- root: {
454
- type: "Dashboard",
455
- props: { title: "Dashboard" }, // Static props (non-undefined = cannot be overridden by route params)
456
- children: [],
457
- },
458
- },
459
- },
460
- },
461
- }
462
- ```
239
+ ---
463
240
 
464
- **Prop slots:** Declare a prop as `undefined` to allow URL params or context fields to fill
465
- it in automatically (see [Prop Enrichment from Routing and Context](#prop-enrichment-from-routing-and-context)):
241
+ ## Exported Types
466
242
 
467
243
  ```typescript
468
- // Route: /settings/:section? Context: { username: "alice" }
469
- spec: {
470
- root: "root",
471
- contextProps: ["username"], // expose context.username to components
472
- elements: {
473
- root: { type: "Settings", props: { section: undefined, username: undefined, theme: "dark" }, children: [] },
474
- },
475
- }
476
- // After play.route to /settings/profile:
477
- // Component receives: { section: "profile", username: "alice", theme: "dark" }
478
- // section → from context.params (URL)
479
- // username from contextProps (context)
480
- // theme → from spec (explicit value, untouched)
481
- ```
482
-
483
- ## Error Handling
484
-
485
- All runtime errors thrown by this package extend `PlayError` from `@xmachines/play` and
486
- are exported from the `./errors` subpath:
487
-
488
- ```typescript
489
- import { MissingRouteParamError, InvalidEventError } from "@xmachines/play-xstate/errors";
490
- ```
491
-
492
- | Class | Code | When thrown |
493
- | ------------------------ | -------------------------- | -------------------------------------------------------- |
494
- | `MissingRouteParamError` | `PLAY_ROUTE_PARAM_MISSING` | Required `:param` has no matching value in actor context |
495
- | `InvalidEventError` | `PLAY_INVALID_EVENT` | `actor.send()` called with a non-object value |
496
-
497
- `MissingRouteParamError` carries `param` and `template` fields for programmatic access.
498
- `InvalidEventError` carries a `detail` property with the offending value.
499
-
500
- > **Note:** `currentRoute` does NOT throw `MissingRouteParamError` — it catches the error internally and returns `null` instead, keeping signal watchers stable during transient states.
501
-
502
- ```typescript
503
- import { MissingRouteParamError, InvalidEventError } from "@xmachines/play-xstate/errors";
504
-
505
- try {
506
- actor.send(null as any);
507
- } catch (err) {
508
- if (err instanceof InvalidEventError) {
509
- console.error("Non-object event passed to actor.send():", err.detail);
510
- }
511
- }
512
-
513
- try {
514
- const route = actor.currentRoute.get();
515
- } catch (err) {
516
- if (err instanceof MissingRouteParamError) {
517
- console.error(`Missing "${err.param}" for template "${err.template}"`);
518
- }
519
- }
244
+ import type {
245
+ PlayerConfig, // definePlayer() config argument shape
246
+ PlayerOptions, // Lifecycle hooks (onStart, onStop, onTransition, onStateChange, onError)
247
+ PlayerFactory, // Factory function returned by definePlayer()
248
+ PlayerFactoryResumeOptions, // { snapshot? } for restoring actor state
249
+ Guard, // Single XState guard predicate
250
+ GuardArray, // Array of guards for compose helpers
251
+ ComposedGuard, // Return type of composeGuards / composeGuardsOr / negateGuard
252
+ RouteMachineConfig, // Minimal machine config accepted by formatPlayRouteTransitions
253
+ RouteStateNode, // Single state node shape used during route crawling
254
+ RouteContext, // Context shape expected by buildRouteUrl ({ params?, query? })
255
+ } from "@xmachines/play-xstate";
520
256
  ```
521
257
 
522
- ## Prop Enrichment from Routing and Context
523
-
524
- When `currentView` is derived, each spec element's `props` are enriched from two sources.
525
- Both use the **opt-in slot** pattern: declare a prop as `undefined` in the spec to allow
526
- it to be filled in automatically.
527
-
528
- ### Merge priority (highest → lowest)
529
-
530
- | Source | When it applies | Wins over |
531
- | ---------------------------------- | -------------------------------- | ------------------------- |
532
- | Explicit non-`undefined` spec prop | Always | Everything |
533
- | URL route param (`context.params`) | State has a `:param` URL segment | `contextProps` values |
534
- | `contextProps` field | Listed in `spec.contextProps` | Nothing (lowest priority) |
535
-
536
- ### URL route parameters
537
-
538
- URL path parameters (`:section?`, `:username`) are filled automatically — declare the prop
539
- as `undefined` to opt in:
540
-
541
- ```typescript
542
- // Route: /settings/:section?
543
- elements: {
544
- root: { type: "Settings", props: { section: undefined, user: "alice" }, children: [] }
545
- }
258
+ ---
546
259
 
547
- // play.route event: { to: "#settings", params: { section: "profile" } }
548
- // Component receives: { section: "profile", user: "alice" }
549
- ```
260
+ ## Error Classes
550
261
 
551
- Extra params not declared in the spec are also passed through:
262
+ Error classes are exported from the `@xmachines/play-xstate/errors` sub-path to keep the main bundle lean.
552
263
 
553
264
  ```typescript
554
- // params: { section: "profile", tab: "security" }
555
- // Component receives: { section: "profile", tab: "security", user: "alice" }
265
+ import {
266
+ MissingRouteParamError, // Required :param absent from context when resolving currentRoute
267
+ MissingQueryContextError, // context.params present but context.query missing
268
+ MissingStateIdError, // meta.route declared without a state id field
269
+ InvalidMachineError, // PlayerActor constructed with a non-object machine
270
+ InvalidEventError, // actor.send() called with null/undefined/non-object
271
+ InvalidRouteMetadataError, // meta.route is neither a string nor { path: string }
272
+ EmptyGuardArrayError, // composeGuards/composeGuardsOr called with empty array
273
+ } from "@xmachines/play-xstate/errors";
556
274
  ```
557
275
 
558
- ### Context fields via `contextProps`
276
+ All error classes extend `PlayError` from `@xmachines/play` and carry typed detail fields (`param`, `template`, `combinator`, etc.) for programmatic inspection without message parsing.
559
277
 
560
- For states where context data (e.g. `context.username`) should reach a component but there
561
- is no corresponding URL param, declare `contextProps` in the spec as an explicit allowlist:
278
+ ---
562
279
 
563
- ```typescript
564
- // Dashboard at /dashboard — no :username URL param, but we want to show context.username
565
- spec: {
566
- root: "root",
567
- contextProps: ["username"], // ← explicit allowlist
568
- elements: {
569
- root: { type: "Dashboard", props: { username: undefined }, children: [] },
570
- },
571
- }
572
-
573
- // After auth.login sets context.username = "alice":
574
- // Component receives: { username: "alice" }
575
- ```
280
+ ## Testing
576
281
 
577
- **Nothing leaks from context without an explicit `contextProps` declaration.**
578
- Only the named fields are ever exposed. `null` and `undefined` context values are excluded.
579
-
580
- If both a route param and a `contextProps` field share the same key, the route param wins:
282
+ ```bash
283
+ # Run tests for this package in isolation
284
+ npm test -w packages/play-xstate
581
285
 
582
- ```typescript
583
- // context.username = "alice" (logged-in user)
584
- // play.route to /profile/demo → context.params.username = "demo"
585
- // contextProps: ["username"], props: { username: undefined }
586
- // Component receives: { username: "demo" } ← route param wins
286
+ # Watch mode
287
+ npm run test:watch -w packages/play-xstate
587
288
  ```
588
289
 
589
- ## Architecture
590
-
591
- This package implements Play RFC requirements:
290
+ Tests use [Vitest](https://vitest.dev/) and live in `packages/play-xstate/test/`.
592
291
 
593
- **Architectural Invariants:**
594
-
595
- - **Actor Authority (INV-01):** Guards decide navigation validity
596
- - **Strict Separation (INV-02):** Zero framework imports
597
- - **Signal-Only Reactivity (INV-05):** All state via TC39 Signals
598
-
599
- **XState DevTools:** Maintains Inspector compatibility — snapshots remain pure XState format, signals accessible via actor properties.
600
-
601
- **Routing:**
602
-
603
- - `meta.route` property marks states as routable
604
- - `play.route` events support parameters (enhancement)
605
- - Route extraction for URL patterns
606
-
607
- **Note:** Route parameter extraction uses URLPattern API. See [@xmachines/play-tanstack-react-router](../play-tanstack-react-router/README.md) for polyfill requirements.
608
-
609
- ## Related Packages
610
-
611
- - **[@xmachines/play-actor](../play-actor/README.md)** - AbstractActor base class
612
- - **[@xmachines/play-signals](../play-signals/README.md)** - TC39 Signals polyfill
613
- - **[@xmachines/play-router](../play-router/README.md)** - Route extraction utilities
614
- - **[@xmachines/play-react](../play-react/README.md)** - React renderer
615
- - **[@xmachines/play-vue](../play-vue/README.md)** - Vue renderer
616
- - **[@xmachines/play-solid](../play-solid/README.md)** - SolidJS renderer
617
- - **[@xmachines/play-dom](../play-dom/README.md)** - Vanilla DOM renderer
618
- - **[@xmachines/play](../play/README.md)** - Protocol types (PlayEvent)
292
+ ---
619
293
 
620
294
  ## License
621
295
 
622
- Copyright (c) 2016 [Mikael Karon](mailto:mikael@karon.se). All rights reserved.
623
-
624
- This work is licensed under the terms of the MIT license.
625
- For a copy, see <https://opensource.org/licenses/MIT>.
296
+ MIT see [LICENSE](LICENSE) for details.
626
297
 
627
298
  @xmachines/play-xstate - XState v5 adapter for Play Architecture
628
299