@xmachines/docs 1.0.0-beta.45 → 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 (350) 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 +4 -4
  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 +3 -3
  287. package/examples/@xmachines/play-react-demo/README.md +2 -2
  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 +2 -2
  306. package/examples/@xmachines/play-solid-demo/README.md +2 -2
  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-solid-router-demo/README.md +1 -1
  325. package/examples/@xmachines/play-svelte-demo/README.md +2 -2
  326. package/examples/@xmachines/play-svelte-demo/type-aliases/AuthCatalog.md +1 -1
  327. package/examples/@xmachines/play-svelte-demo/variables/authCatalog.md +1 -1
  328. package/examples/@xmachines/play-svelte-spa-router-demo/README.md +3 -3
  329. package/examples/@xmachines/play-sveltekit-router-demo/README.md +3 -3
  330. package/examples/@xmachines/play-tanstack-react-router-demo/README.md +1 -1
  331. package/examples/@xmachines/play-tanstack-solid-router-demo/README.md +1 -1
  332. package/examples/@xmachines/play-vue-demo/README.md +2 -2
  333. package/examples/@xmachines/play-vue-demo/type-aliases/AuthCatalog.md +1 -1
  334. package/examples/@xmachines/play-vue-demo/variables/App.md +1 -1
  335. package/examples/@xmachines/play-vue-demo/variables/authCatalog.md +1 -1
  336. package/examples/@xmachines/play-vue-router-demo/README.md +1 -1
  337. package/examples/README.md +24 -25
  338. package/examples/form-validation.md +2 -2
  339. package/guides/README.md +7 -7
  340. package/guides/actor-model.md +18 -18
  341. package/guides/architecture.md +500 -0
  342. package/guides/configuration.md +556 -0
  343. package/guides/deployment.md +336 -0
  344. package/guides/development.md +617 -0
  345. package/guides/getting-started.md +351 -142
  346. package/guides/signals.md +19 -19
  347. package/guides/state-machines.md +16 -16
  348. package/guides/testing.md +460 -0
  349. package/package.json +5 -5
  350. package/guides/installation.md +0 -257
@@ -1,322 +1,94 @@
1
1
  [API](../../README.md) / @xmachines/play-vue-router
2
2
 
3
- # @xmachines/play-vue-router
4
-
5
- **Vue Router 4.x adapter for XMachines Universal Player Architecture**
6
-
7
- Bidirectional sync between Vue Router and XMachines state machines with Composition API integration.
8
-
9
- ## Overview
10
-
11
- `@xmachines/play-vue-router` enables Vue.js applications to use XMachines state machines as the source of truth for routing logic. Your state machine controls navigation through Vue Router's reactive primitives.
3
+ <!-- generated-by: gsd-doc-writer -->
12
4
 
13
- Per [Play RFC](../../../rfc/play.md), this package implements:
14
-
15
- - **Actor Authority (INV-01):** State machine validates navigation, router reflects decisions
16
- - **Passive Infrastructure (INV-04):** Router observes `actor.currentRoute` signal
17
- - **Signal-Only Reactivity (INV-05):** Watcher synchronizes URL with actor state
18
-
19
- **Key Benefits:**
20
-
21
- - **Logic-driven navigation:** Business logic in state machines, not components
22
- - **Protected routes:** Guards live in state machine, not router config
23
- - **Bidirectional sync:** Actor ↔ Vue Router with circular update prevention
24
- - **Type-safe parameters:** Route params flow through state machine context
25
- - **Composition API:** Integrates with `useRouter`, `useRoute`, `onUnmounted`
5
+ # @xmachines/play-vue-router
26
6
 
27
- **Framework Compatibility:**
7
+ Vue Router 4.x adapter for XMachines Universal Player Architecture. Bidirectional sync between Vue Router and XMachines state machines using Vue's reactive primitives.
28
8
 
29
- - Vue 3.x with Composition API
30
- - Vue Router 4.x (`^4.0.0`)
31
- - Named routes pattern (recommended by Vue Router docs)
9
+ Part of the [xmachines-js monorepo](../../README.md).
32
10
 
33
11
  ## Installation
34
12
 
35
13
  ```bash
36
- npm install vue-router@^4.0.0 vue@^3.5.0 @xmachines/play-vue-router @xmachines/play-vue
14
+ npm install @xmachines/play-vue-router
37
15
  ```
38
16
 
39
17
  **Peer dependencies:**
40
18
 
41
- - `vue-router` ^4.0.0 || ^5.0.0 — Vue Router library
42
19
  - `vue` ^3.5.0 — Vue runtime
43
- -)
44
- - — Actor base
45
- - — Route extraction
46
- - — TC39 Signals primitives
20
+ - `@vue/reactivity` ^3.5.0 — Vue reactivity primitives
21
+ - `vue-router` ^4.0.0 || ^5.0.0 Vue Router library
22
+ - `xstate` ^5.30.0 XState v5 state machine runtime
23
+
24
+ ## Usage
25
+
26
+ ### VueRouterBridge — low-level adapter
47
27
 
48
- ## Quick Start
28
+ `VueRouterBridge` wires Vue Router's `currentRoute` ref to an XMachines actor's `currentRoute` signal. Both directions are active: the actor drives the URL, and the URL drives the actor.
49
29
 
50
30
  ```typescript
51
- import { createApp } from "vue";
52
31
  import { createRouter, createWebHistory } from "vue-router";
53
- import { VueRouterBridge, createRouteMap } from "@xmachines/play-vue-router";
54
- import { extractMachineRoutes, getRoutableRoutes } from "@xmachines/play-router";
55
- import { definePlayer } from "@xmachines/play-xstate";
56
- import Home from "./views/Home.vue";
57
- import Profile from "./views/Profile.vue";
58
-
59
- // 1. Extract routable states from machine (single source of truth)
60
- const routeTree = extractMachineRoutes(authMachine);
61
- const routableRoutes = getRoutableRoutes(routeTree);
62
- const routeComponents = {
63
- home: Home,
64
- profile: Profile,
65
- } as const;
66
-
67
- // 2. Define Vue Router routes from extracted machine routes
32
+ import { VueRouterBridge, RouteMap } from "@xmachines/play-vue-router";
33
+
34
+ // 1. Define routes
68
35
  const router = createRouter({
69
36
  history: createWebHistory(),
70
- routes: routableRoutes.map((route) => ({
71
- path: route.fullPath,
72
- name: route.stateId.replace(/^#/, ""),
73
- component: routeComponents[route.stateId.replace(/^#/, "") as keyof typeof routeComponents],
74
- })),
37
+ routes: [
38
+ { path: "/", name: "home", component: HomePage },
39
+ { path: "/profile/:userId", name: "profile", component: ProfilePage },
40
+ { path: "/settings/:section?", name: "settings", component: SettingsPage },
41
+ ],
75
42
  });
76
43
 
77
- // 3. Compute route mapping from machine routes
78
- const routeMap = createRouteMap(authMachine);
79
-
80
- // 4. Create actor with state machine
81
- const createPlayer = definePlayer({
82
- machine: authMachine,
83
- catalog: componentCatalog,
84
- });
85
- const actor = createPlayer();
86
- actor.start();
44
+ // 2. Create a bidirectional state ID ↔ path mapping
45
+ const routeMap = new RouteMap([
46
+ { stateId: "home", path: "/" },
47
+ { stateId: "profile", path: "/profile/:userId" },
48
+ { stateId: "settings", path: "/settings/:section?" },
49
+ ]);
87
50
 
88
- // 5. Create bridge to sync actor and router
51
+ // 3. Start the bridge after the router is ready
52
+ await router.isReady();
89
53
  const bridge = new VueRouterBridge(router, actor, routeMap);
90
-
91
- // 6. Connect bridge (required)
92
54
  bridge.connect();
93
55
 
94
- // 7. Create Vue app
95
- const app = createApp(App);
96
- app.use(router);
97
- app.mount("#app");
98
-
99
- // 8. Later, when tearing down your app/integration:
100
- // bridge.disconnect();
101
- ```
102
-
103
- ## API Reference
104
-
105
- ### `VueRouterBridge`
106
-
107
- Router adapter implementing the `RouterBridge` protocol for Vue Router 4.x.
108
-
109
- **Type Signature:**
110
-
111
- ```typescript
112
- class VueRouterBridge {
113
- constructor(router: Router, actor: AbstractActor<any>, routeMap: RouteMap);
114
- connect(): void;
115
- disconnect(): void;
116
- dispose(): void;
117
- }
118
- ```
119
-
120
- **Constructor Parameters:**
121
-
122
- - `router` - Vue Router instance from `createRouter()`
123
- - `actor` - XMachines actor instance (from `definePlayer().actor`)
124
- - `routeMap` - Bidirectional state ID ↔ route name mapping
125
-
126
- **Methods:**
127
-
128
- - `connect()` - Start bidirectional synchronization. Both pathname and query string from `router.currentRoute.value.fullPath` are forwarded to the actor on first connect, so users landing on `/profile?tab=posts` have `query: { tab: "posts" }` in the initial `play.route` event.
129
- - `disconnect()` - Stop synchronization and unhook listeners.
130
- - `dispose()` - Alias of `disconnect()` for ergonomic teardown.
131
-
132
- **Internal Behavior:**
133
-
134
- - Watches `actor.currentRoute` signal via `Signal.subtle.Watcher`
135
- - Updates Vue Router via `router.push({ name, params })` when actor state changes
136
- - Listens to router navigation via `router.afterEach()` hook using Vue's native `to.params` / `to.query` for accurate extraction (no URLPattern re-parsing)
137
- - Applies `sanitizePathname()` to all incoming router paths before route-map lookup (defense-in-depth: rejects malformed/oversized paths)
138
- - Sends `play.route` events to actor when user navigates
139
- - Prevents circular updates with multi-layer guards
140
-
141
- ### `RouteMap`
142
-
143
- Bidirectional mapping between XMachines state IDs and Vue Router route names.
144
-
145
- **Type Signature:**
146
-
147
- ```typescript
148
- interface RouteMapping {
149
- stateId: string;
150
- routeName: string;
151
- pattern?: string;
152
- }
153
-
154
- class RouteMap extends VueBaseRouteMap {
155
- // Inherits all VueBaseRouteMap methods — no additional API
156
- }
157
- ```
158
-
159
- **Constructor Parameters:**
160
-
161
- - `mappings` - Array of mapping objects with:
162
- - `stateId` - State machine state ID (e.g., `'#profile'`)
163
- - `routeName` - Vue Router route name (e.g., `'profile'`)
164
- - `pattern` - Optional path pattern for URL resolution (e.g., `'/profile/:userId'`)
165
-
166
- **Methods (inherited from `VueBaseRouteMap`):**
167
-
168
- - `getRouteName(stateId)` — Find route name from state ID
169
- - `getStateId(routeName)` — Find state ID from route name
170
- - `getPattern(stateId)` — Get URL pattern for state (optional metadata)
171
- - `getStateIdByPath(path)` — Resolve a URL path to a state ID (from `BaseRouteMap`)
172
- - `getPathByStateId(stateId)` — Get the URL path pattern for a state ID (from `BaseRouteMap`)
173
-
174
- ### `VueBaseRouteMap`
175
-
176
- Intermediate base class for Vue Router adapters. Extends `BaseRouteMap` (bucket-indexed O(k) pattern matching + QuickLRU cache) and adds Vue-specific named-route lookup.
177
-
178
- Exported for consumers who need to extend or test the Vue routing layer directly. Most consumers use `RouteMap` instead.
179
-
180
- ```typescript
181
- class VueBaseRouteMap extends BaseRouteMap {
182
- constructor(mappings: RouteMapping[]);
183
- getRouteName(stateId: string): string | undefined;
184
- getStateId(routeName: string): string | undefined;
185
- getPattern(stateId: string): string | undefined;
186
- }
56
+ // 4. Dispose when tearing down (e.g. onUnmounted)
57
+ bridge.dispose();
187
58
  ```
188
59
 
189
- ## Examples
190
-
191
- ### Basic Usage: Simple 2-3 Route Setup
192
-
193
- ```typescript
194
- // State machine with 3 states
195
- import { defineCatalog } from "@json-render/core";
196
- import { schema } from "@json-render/react/schema";
197
- import { defineRegistry } from "@xmachines/play-vue";
198
- import { z } from "zod";
199
-
200
- const appCatalog = defineCatalog(schema, {
201
- components: {
202
- Home: { props: z.object({}) },
203
- About: { props: z.object({}) },
204
- Contact: { props: z.object({}) },
205
- },
206
- });
207
-
208
- const appMachine = setup({
209
- types: {
210
- events: {} as PlayRouteEvent,
211
- },
212
- }).createMachine({
213
- id: "app",
214
- initial: "home",
215
- states: {
216
- home: {
217
- meta: { route: "/", view: { component: "Home" } },
218
- },
219
- about: {
220
- meta: { route: "/about", view: { component: "About" } },
221
- },
222
- contact: {
223
- meta: { route: "/contact", view: { component: "Contact" } },
224
- },
225
- },
226
- });
60
+ ### PlayRouterProvider — Vue component wrapper
227
61
 
228
- const registry = defineRegistry(appCatalog, { components: { Home, About, Contact } });
229
- const player = definePlayer({ machine: appMachine, catalog: appCatalog });
62
+ `PlayRouterProvider` is a convenience component that manages the bridge lifecycle automatically — it calls `bridge.connect()` after `router.isReady()` on mount and `bridge.disconnect()` on unmount.
230
63
 
231
- // Vue Router configuration
232
- const routeTree = extractMachineRoutes(appMachine);
233
- const routableRoutes = getRoutableRoutes(routeTree);
234
- const routeComponents = {
235
- home: Home,
236
- about: About,
237
- contact: Contact,
238
- } as const;
239
-
240
- const router = createRouter({
241
- history: createWebHistory(),
242
- routes: routableRoutes.map((route) => ({
243
- path: route.fullPath,
244
- name: route.stateId.replace(/^#/, ""),
245
- component: routeComponents[route.stateId.replace(/^#/, "") as keyof typeof routeComponents],
246
- })),
247
- });
248
-
249
- // Route mapping computed from machine routes
250
- const routeMap = createRouteMap(appMachine);
251
- ```
252
-
253
- ### Parameter Handling: Dynamic Routes with `:param` Syntax
254
-
255
- ```typescript
256
- // State machine with parameter routes
257
- import { formatPlayRouteTransitions } from "@xmachines/play-xstate";
258
- import { defineCatalog } from "@json-render/core";
259
- import { schema } from "@json-render/react/schema";
260
- import { defineRegistry } from "@xmachines/play-vue";
261
- import { z } from "zod";
262
-
263
- const appCatalog = defineCatalog(schema, {
264
- components: {
265
- Profile: { props: z.object({ userId: z.string() }) },
266
- Settings: { props: z.object({ section: z.string().optional() }) },
267
- },
268
- });
269
-
270
- const machineConfig = {
271
- id: "app",
272
- context: {},
273
- states: {
274
- profile: {
275
- meta: {
276
- route: "/profile/:userId",
277
- view: { component: "Profile" },
278
- },
279
- },
280
- settings: {
281
- meta: {
282
- route: "/settings/:section?",
283
- view: { component: "Settings" },
284
- },
285
- },
286
- },
287
- };
288
-
289
- const appMachine = setup({
290
- types: {
291
- context: {} as { userId?: string; section?: string },
292
- events: {} as PlayRouteEvent,
293
- },
294
- }).createMachine(formatPlayRouteTransitions(machineConfig));
295
-
296
- const registry = defineRegistry(appCatalog, { components: { Profile, Settings } });
297
- const player = definePlayer({ machine: appMachine, catalog: appCatalog });
298
-
299
- // Router with dynamic routes
300
- const routeTree = extractMachineRoutes(appMachine);
301
- const routableRoutes = getRoutableRoutes(routeTree);
302
- const routeComponents = {
303
- profile: Profile,
304
- settings: Settings,
305
- } as const;
64
+ ```vue
65
+ <script setup lang="ts">
66
+ import { markRaw } from "vue";
67
+ import { useRouter } from "vue-router";
68
+ import { PlayRouterProvider, RouteMap } from "@xmachines/play-vue-router";
306
69
 
307
- const router = createRouter({
308
- routes: routableRoutes.map((route) => ({
309
- path: route.fullPath,
310
- name: route.stateId.replace(/^#/, ""),
311
- component: routeComponents[route.stateId.replace(/^#/, "") as keyof typeof routeComponents],
312
- })),
313
- });
70
+ const router = useRouter();
71
+ const routeMap = new RouteMap([
72
+ { stateId: "home", path: "/" },
73
+ { stateId: "profile", path: "/profile/:userId" },
74
+ ]);
75
+
76
+ // markRaw prevents Vue from wrapping the actor in a reactive proxy,
77
+ // which would break TC39 Signal receivers.
78
+ const actor = markRaw(createActor());
79
+ </script>
314
80
 
315
- // Route mapping computed from machine routes
316
- const routeMap = createRouteMap(appMachine);
81
+ <template>
82
+ <PlayRouterProvider
83
+ :actor="actor"
84
+ :router="router"
85
+ :routeMap="routeMap"
86
+ :renderer="(actor, router) => h(AppShell, { actor, router })"
87
+ />
88
+ </template>
317
89
  ```
318
90
 
319
- **Usage in component:**
91
+ ### Sending route events from components
320
92
 
321
93
  ```vue
322
94
  <script setup>
@@ -334,150 +106,82 @@ function viewProfile(userId) {
334
106
  </template>
335
107
  ```
336
108
 
337
- ### Query Parameters: Search/Filters via Query Strings
109
+ ## API Reference
338
110
 
339
- ```typescript
340
- // State machine with query param handling
341
- import { formatPlayRouteTransitions } from "@xmachines/play-xstate";
342
- import { defineCatalog } from "@json-render/core";
343
- import { schema } from "@json-render/react/schema";
344
- import { defineRegistry } from "@xmachines/play-vue";
345
- import { z } from "zod";
346
-
347
- const searchCatalog = defineCatalog(schema, {
348
- components: {
349
- Search: { props: z.object({ query: z.string().optional() }) },
350
- },
351
- });
111
+ ### `VueRouterBridge`
352
112
 
353
- const machineConfig = {
354
- context: { query: "", filters: {} },
355
- states: {
356
- search: {
357
- meta: {
358
- route: "/search",
359
- view: { component: "Search" },
360
- },
361
- },
362
- },
363
- };
113
+ Implements the `RouterBridge` protocol by watching Vue Router's `currentRoute` shallowRef and the actor's `currentRoute` TC39 Signal.
364
114
 
365
- const searchMachine = setup({
366
- types: {
367
- context: {} as { query: string; filters: Record<string, string> },
368
- events: {} as PlayRouteEvent,
369
- },
370
- }).createMachine(formatPlayRouteTransitions(machineConfig));
371
-
372
- const registry = defineRegistry(searchCatalog, { components: { Search } });
373
- const player = definePlayer({ machine: searchMachine, catalog: searchCatalog });
374
-
375
- // Component sends query params
376
- function handleSearch(searchTerm, filters) {
377
- actor.send({
378
- type: "play.route",
379
- to: "#search",
380
- query: { q: searchTerm, ...filters },
381
- });
115
+ ```typescript
116
+ class VueRouterBridge {
117
+ constructor(
118
+ vueRouter: Router,
119
+ actor: AbstractActor<AnyActorLogic> & Routable,
120
+ routeMap: RouteMap,
121
+ );
122
+ connect(): void;
123
+ disconnect(): void;
124
+ dispose(): void; // alias for disconnect()
382
125
  }
383
126
  ```
384
127
 
385
- **Vue Router automatically reflects query params in URL:**
128
+ **Constructor parameters:**
386
129
 
387
- - `/search?q=xmachines&tag=typescript`
130
+ | Parameter | Type | Description |
131
+ | ----------- | ----------------------------------------- | -------------------------------------------- |
132
+ | `vueRouter` | `Router` | Vue Router instance from `createRouter()` |
133
+ | `actor` | `AbstractActor<AnyActorLogic> & Routable` | XMachines actor with a `currentRoute` signal |
134
+ | `routeMap` | `RouteMap` | Bidirectional state ID ↔ path mapping |
388
135
 
389
- ### Protected Routes: Authentication Guards
136
+ **Methods:**
390
137
 
391
- ```typescript
392
- // State machine with auth guards
393
- import { defineCatalog } from "@json-render/core";
394
- import { schema } from "@json-render/react/schema";
395
- import { defineRegistry } from "@xmachines/play-vue";
396
- import { z } from "zod";
397
-
398
- const authCatalog = defineCatalog(schema, {
399
- components: {
400
- Home: { props: z.object({}) },
401
- Login: { props: z.object({ title: z.string() }) },
402
- Dashboard: { props: z.object({ username: z.string() }) },
403
- },
404
- });
138
+ - `connect()` — Start bidirectional synchronization. Performs an initial sync from the router's current path to the actor (cold-load / direct-URL support). Uses `watch(router.currentRoute, …)` from `@vue/reactivity` (not `@vue/runtime-core`) so watcher errors propagate directly without being swallowed by Vue's global error handler.
139
+ - `disconnect()` Stop all watchers and stop the Vue effect scope.
140
+ - `dispose()` Alias for `disconnect()`, intended for `onUnmounted(() => bridge.dispose())`.
405
141
 
406
- const authMachine = setup({
407
- types: {
408
- context: {} as { isAuthenticated: boolean },
409
- events: {} as PlayRouteEvent | { type: "login" } | { type: "logout" },
410
- },
411
- }).createMachine({
412
- context: { isAuthenticated: false },
413
- initial: "home",
414
- states: {
415
- home: {
416
- meta: { route: "/", view: { component: "Home" } },
417
- },
418
- login: {
419
- meta: { route: "/login", view: { component: "Login" } },
420
- on: {
421
- login: {
422
- target: "dashboard",
423
- actions: assign({ isAuthenticated: true }),
424
- },
425
- },
426
- },
427
- dashboard: {
428
- meta: { route: "/dashboard", view: { component: "Dashboard" } },
429
- always: {
430
- guard: ({ context }) => !context.isAuthenticated,
431
- target: "login",
432
- },
142
+ ### `PlayRouterProvider`
143
+
144
+ Vue component that wraps `VueRouterBridge` in component lifecycle hooks.
145
+
146
+ ```typescript
147
+ defineComponent({
148
+ name: "PlayRouterProvider",
149
+ props: {
150
+ actor: { type: Object as PropType<RoutableActor>, required: true },
151
+ routeMap: { type: Object as PropType<RouteMap>, required: true },
152
+ router: { type: Object as PropType<Router>, required: true },
153
+ renderer: {
154
+ type: Function as PropType<(actor: RoutableActor, router: Router) => VNodeChild>,
155
+ required: true,
433
156
  },
434
157
  },
435
158
  });
436
-
437
- const registry = defineRegistry(authCatalog, { components: { Home, Login, Dashboard } });
438
- const player = definePlayer({ machine: authMachine, catalog: authCatalog });
439
159
  ```
440
160
 
441
- **Guard behavior:**
161
+ The `renderer` prop is a render function that receives the actor and router and returns a `VNodeChild`.
442
162
 
443
- - User navigates to `/dashboard`
444
- - Bridge sends `play.route` event to actor
445
- - Actor's `always` guard checks `isAuthenticated`
446
- - If `false`, actor transitions to `login` state
447
- - Bridge detects state change, redirects router to `/login`
448
- - Actor Authority principle enforced
163
+ ### `RouteMap` / `VueRouteMap`
449
164
 
450
- ### Cleanup: Proper Disposal on Component Unmount
165
+ `RouteMap` (re-exported from `@xmachines/play-router`) is the bidirectional state ID ↔ path mapping used by the bridge. `VueRouteMap` is an alias for `RouteMap` — both are identical.
451
166
 
452
- ```vue
453
- <script setup>
454
- import { onUnmounted } from "vue";
455
- import { VueRouterBridge } from "@xmachines/play-vue-router";
456
-
457
- const router = useRouter();
458
- const actor = inject("actor");
459
- const routeMap = inject("routeMap");
460
-
461
- const bridge = new VueRouterBridge(router, actor, routeMap);
462
-
463
- // CRITICAL: Cleanup watchers and guards
464
- onUnmounted(() => {
465
- bridge.dispose();
466
- });
467
- </script>
167
+ ```typescript
168
+ import { RouteMap, createRouteMap } from "@xmachines/play-vue-router";
169
+
170
+ // Explicit construction
171
+ const routeMap = new RouteMap([
172
+ { stateId: "home", path: "/" },
173
+ { stateId: "profile", path: "/profile/:userId" },
174
+ { stateId: "settings", path: "/settings/:section?" },
175
+ ]);
176
+
177
+ // Or derive from an XState machine
178
+ import { createRouteMap } from "@xmachines/play-router";
179
+ const routeMap = createRouteMap(machine);
468
180
  ```
469
181
 
470
- **Why cleanup matters:**
182
+ ### Exported error classes (`@xmachines/play-vue-router/errors`)
471
183
 
472
- - Navigation guards remain active after unmount (memory leak)
473
- - Watchers continue observing signals (event listeners pile up)
474
- - Multiple bridge instances send duplicate events
475
- - Tests fail with "Cannot send to stopped actor" errors
476
-
477
- ## Error Handling
478
-
479
- All runtime errors thrown by this package extend `PlayError` from and
480
- are exported from the `./errors` subpath:
184
+ All runtime errors extend `PlayError` from `@xmachines/play` and are available from the `./errors` subpath:
481
185
 
482
186
  ```typescript
483
187
  import {
@@ -487,147 +191,63 @@ import {
487
191
  } from "@xmachines/play-vue-router/errors";
488
192
  ```
489
193
 
490
- | Class | Code | When thrown |
491
- | -------------------------- | ----------------------------------- | ------------------------------------------------------- |
492
- | `VueRouterCorrectionError` | `PLAY_VUE_ROUTER_CORRECTION_FAILED` | `router.replace()` rejected when syncing actor → router |
493
- | `VueRouterNavigationError` | `PLAY_VUE_ROUTER_NAV_FAILED` | `router.push()` rejected (guard cancellation, redirect) |
494
- | `VueRouterSendError` | `PLAY_VUE_ROUTER_SEND_FAILED` | `afterEach` hook fails to send `play.route` to actor |
495
-
496
- All three classes carry a `cause` property wrapping the original Vue Router error.
497
-
498
- ## Architecture
499
-
500
- ### Bidirectional Sync (Actor ↔ Router)
501
-
502
- **Actor → Router (Signal-driven):**
503
-
504
- 1. Actor transitions to new state with `meta.route`
505
- 2. `actor.currentRoute` signal updates
506
- 3. `Signal.subtle.Watcher` detects change in microtask
507
- 4. Bridge extracts state ID from signal
508
- 5. Bridge looks up route name via `routeMap.getRouteName()`
509
- 6. Bridge calls `router.push({ name, params })`
510
- 7. Vue Router updates URL and renders component
511
-
512
- **Router → Actor (Navigation guard):**
513
-
514
- 1. User clicks link or browser back button
515
- 2. `router.afterEach()` hook fires with `to` route
516
- 3. Bridge resolves state ID from Vue route `name` via `routeMap.getStateId(...)`
517
- 4. Bridge extracts params from `to.params` (not `route.params` - see Pitfalls)
518
- 5. Bridge sends `play.route` event to actor
519
- 6. Actor validates navigation (guards, transitions)
520
- 7. If accepted: Actor transitions, signal updates, URL stays
521
- 8. If rejected: Actor redirects, bridge corrects URL via `router.replace()`
194
+ | Class | Error code | When thrown |
195
+ | -------------------------- | ----------------------------------- | ---------------------------------------------------------------------- |
196
+ | `VueRouterCorrectionError` | `PLAY_VUE_ROUTER_CORRECTION_FAILED` | `router.replace()` rejected when syncing actor → router (correction) |
197
+ | `VueRouterNavigationError` | `PLAY_VUE_ROUTER_NAV_FAILED` | `router.push()` rejected (navigation guard cancellation, redirect) |
198
+ | `VueRouterSendError` | `PLAY_VUE_ROUTER_SEND_FAILED` | Vue Router watcher callback fails to deliver `play.route` to the actor |
522
199
 
523
- ### Circular Update Prevention
200
+ Each class carries a `cause` property with the original Vue Router error.
524
201
 
525
- **Multi-layer guards prevent infinite loops:**
526
-
527
- 1. **`lastSyncedPath` tracking:** Stores last synchronized path, skips if unchanged
528
- 2. **`isProcessingNavigation` flag:** Set during router-initiated navigation, prevents actor→router sync
529
- 3. **Microtask timing:** Actor validation happens asynchronously, bridge checks result after transition completes
530
-
531
- **Pattern proven in the TanStack Router adapter:**
202
+ ### Exported types
532
203
 
533
204
  ```typescript
534
- private syncRouterFromActor(): void {
535
- if (this.isProcessingNavigation) return; // Guard 1
536
- const currentRoute = this.actor.currentRoute.get();
537
- if (currentRoute === this.lastSyncedPath) return; // Guard 2
538
- this.lastSyncedPath = currentRoute;
539
- this.router.push(currentRoute);
540
- }
541
-
542
- private syncActorFromRouter(to: RouteLocation): void {
543
- this.isProcessingNavigation = true; // Guard 3
544
- this.actor.send({ type: 'play.route', to: stateId, params });
545
- queueMicrotask(() => {
546
- this.isProcessingNavigation = false; // Guard 4
547
- });
548
- }
205
+ export type { RouteMapping, PlayRouteEvent, RouterBridge } from "@xmachines/play-router";
206
+ export type { RoutableActor } from "./play-router-provider.js";
549
207
  ```
550
208
 
551
- ### Relationship to Other Packages
552
-
553
- **Package Dependencies:**
554
-
555
- -)
209
+ ## Architecture
556
210
 
557
- - - Actor base class with signal protocol
558
- - - Route extraction and tree building
559
- - - TC39 Signals polyfill for reactivity
560
- - **Architecture Layers:**
211
+ ### Sync directions
561
212
 
562
- ```
563
- ┌─────────────────────────────────────┐
564
- │ Vue Components (View Layer) │
565
- │ - Uses inject('actor') │
566
- │ - Sends play.route events │
567
- └─────────────────────────────────────┘
568
-
569
- ┌─────────────────────────────────────┐
570
- │ VueRouterBridge (Adapter) │
571
- │ - Watches actor.currentRoute │
572
- │ - Listens to router.afterEach │
573
- └─────────────────────────────────────┘
574
- ↕ ↕
575
- ┌─────────────┐ ┌──────────────────┐
576
- │ Vue Router │ │ XMachines Actor │
577
- │ (Infra) │ │ (Business Logic) │
578
- └─────────────┘ └──────────────────┘
579
- ```
213
+ **Router → Actor** (`watch(router.currentRoute, …)`):
580
214
 
581
- ### Vue Router Composition API Integration
215
+ 1. User navigates (link click, browser back, programmatic `router.push`).
216
+ 2. Vue's `currentRoute` shallowRef is assigned a new object.
217
+ 3. `watch` from `@vue/reactivity` fires synchronously (`scheduler: (job) => job()`).
218
+ 4. Bridge sanitizes the path, looks up the state ID in `routeMap`.
219
+ 5. Bridge sends `{ type: "play.route", to: "#stateId", params, query }` to the actor.
582
220
 
583
- **Recommended patterns:**
221
+ **Actor → Router** (TC39 Signal watcher):
584
222
 
585
- - **`useRouter()`** - Get router instance for programmatic navigation (avoid in components - use actor)
586
- - **`useRoute()`** - Access current route params (prefer actor context for state-driven components)
587
- - **`onUnmounted()`** - Cleanup bridge to prevent leaks
223
+ 1. Actor transitions; `actor.currentRoute` signal updates to a new state ID or path.
224
+ 2. Signal watcher fires in a microtask.
225
+ 3. Bridge resolves the navigation path via `resolveNavigationPath`.
226
+ 4. Parameterized patterns without concrete params are skipped (returns `null`).
227
+ 5. Bridge calls `router.push(resolvedPath)`.
588
228
 
589
- **Named routes requirement:**
229
+ ### Echo suppression
590
230
 
591
- Vue Router adapter uses **named routes** (`router.push({ name: 'profile', params })`) instead of path-based navigation. This provides:
231
+ `lastSyncedPath` is set before every `router.push()` call. When the Vue watcher subsequently fires with the same path (the router echoing the actor-initiated push), the `sanitizedPath === lastSyncedPath` check short-circuits before any event is sent.
592
232
 
593
- - Type safety (TypeScript route names)
594
- - Cleaner param handling (object-based)
595
- - Better Vue Router integration (recommended by docs)
233
+ ### Vue effect scope
596
234
 
597
- All routes in your Vue Router config **must have a `name` property** for the bridge to work.
235
+ The `watch` watcher runs inside a dedicated `effectScope()`. Calling `disconnect()` / `dispose()` calls `scope.stop()`, fully removing the watcher without leaking into the global Vue effect scope.
598
236
 
599
- ### Pitfall: `to.params` vs `route.params`
237
+ ## Testing
600
238
 
601
- **⚠️ Common mistake:** Using global `useRoute()` in navigation guards
239
+ ```bash
240
+ # Run all tests for this package
241
+ npm test -w packages/play-vue-router
602
242
 
603
- ```typescript
604
- // WRONG: route.params is stale during transition
605
- router.afterEach((to) => {
606
- const route = useRoute(); // Returns "from" route
607
- const params = route.params; // STALE
608
- // ...
609
- });
243
+ # Watch mode
244
+ npm run test:watch -w packages/play-vue-router
610
245
 
611
- // CORRECT: to.params is fresh
612
- router.afterEach((to) => {
613
- const params = to.params; // FRESH
614
- // ...
615
- });
246
+ # With coverage (80 % threshold on lines/functions/branches/statements)
247
+ npm run test:coverage -w packages/play-vue-router
616
248
  ```
617
249
 
618
- **Why it happens:** Vue Router's global `route` object updates asynchronously during navigation. The `to` parameter in `afterEach` is the destination route with correct params.
619
-
620
- ## Learn More
621
-
622
- - [Demo](../../../examples/@xmachines/play-vue-router-demo/README.md)
623
- - [Vue renderer](../play-vue/README.md)
624
-
625
- ## License
626
-
627
- Copyright (c) 2016 [Mikael Karon](mailto:mikael@karon.se). All rights reserved.
628
-
629
- This work is licensed under the terms of the MIT license.
630
- For a copy, see <https://opensource.org/licenses/MIT>.
250
+ Test files use Vitest with jsdom and `@vue/test-utils`. Integration tests (`test/integration.test.ts`) use real Vue Router instances with SFC fixtures.
631
251
 
632
252
  ## Classes
633
253