@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.
- package/README.md +135 -7
- package/api/@xmachines/play/README.md +134 -57
- package/api/@xmachines/play/classes/NonNullableError.md +4 -4
- package/api/@xmachines/play/classes/PlayError.md +4 -4
- package/api/@xmachines/play/functions/assertNonNullable.md +1 -1
- package/api/@xmachines/play/type-aliases/PlayEvent.md +2 -2
- package/api/@xmachines/play-actor/README.md +130 -155
- package/api/@xmachines/play-actor/classes/AbstractActor.md +3 -3
- package/api/@xmachines/play-actor/functions/typedSpec.md +1 -1
- package/api/@xmachines/play-actor/interfaces/BaseActorProviderProps.md +5 -5
- package/api/@xmachines/play-actor/interfaces/BaseViewContextValue.md +5 -5
- package/api/@xmachines/play-actor/interfaces/PlaySpec.md +2 -2
- package/api/@xmachines/play-actor/interfaces/Routable.md +3 -3
- package/api/@xmachines/play-actor/interfaces/Viewable.md +2 -2
- package/api/@xmachines/play-dom/README.md +140 -232
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +4 -4
- package/api/@xmachines/play-dom/functions/connectRenderer.md +1 -1
- package/api/@xmachines/play-dom/functions/createPlayUI.md +1 -1
- package/api/@xmachines/play-dom/functions/createRenderer.md +1 -1
- package/api/@xmachines/play-dom/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-dom/functions/renderSpec.md +1 -1
- package/api/@xmachines/play-dom/interfaces/ComponentContext.md +7 -7
- package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +13 -13
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +6 -6
- package/api/@xmachines/play-dom/interfaces/DefineRegistryResult.md +4 -4
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +12 -12
- package/api/@xmachines/play-dom/interfaces/EventHandle.md +4 -4
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +3 -3
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +5 -5
- package/api/@xmachines/play-dom/interfaces/UIProviderOptions.md +5 -5
- package/api/@xmachines/play-dom/type-aliases/ActionFn.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/Actions.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/BaseComponentProps.md +7 -7
- package/api/@xmachines/play-dom/type-aliases/CatalogHasActions.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/ComponentFn.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/ComponentRegistry.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/DomSchema.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/SetState.md +1 -1
- package/api/@xmachines/play-dom/variables/schema.md +1 -1
- package/api/@xmachines/play-dom-router/README.md +160 -158
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +4 -4
- package/api/@xmachines/play-dom-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-react/README.md +109 -320
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +5 -5
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
- package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +8 -8
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +4 -4
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +3 -3
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +8 -8
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-react/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-react/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-react/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-react-router/README.md +107 -124
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +23 -23
- package/api/@xmachines/play-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-react-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-router/README.md +235 -475
- package/api/@xmachines/play-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +23 -23
- package/api/@xmachines/play-router/functions/buildPlayRouteEvent.md +1 -1
- package/api/@xmachines/play-router/functions/buildRouteTree.md +1 -1
- package/api/@xmachines/play-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-router/functions/createRouteMatcher.md +1 -1
- package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/extractMachineRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/extractQuery.md +1 -1
- package/api/@xmachines/play-router/functions/extractRouteParams.md +1 -1
- package/api/@xmachines/play-router/functions/findRouteById.md +1 -1
- package/api/@xmachines/play-router/functions/findRouteByPath.md +1 -1
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/getRoutableRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/isRouteReachable.md +1 -1
- package/api/@xmachines/play-router/functions/machineToGraph.md +1 -1
- package/api/@xmachines/play-router/functions/routeExists.md +1 -1
- package/api/@xmachines/play-router/functions/sanitizePathname.md +1 -1
- package/api/@xmachines/play-router/functions/validateRouteFormat.md +1 -1
- package/api/@xmachines/play-router/functions/validateStateExists.md +1 -1
- package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +4 -4
- package/api/@xmachines/play-router/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +3 -3
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +5 -5
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
- package/api/@xmachines/play-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +3 -3
- package/api/@xmachines/play-router/interfaces/RouteMatcher.md +4 -4
- package/api/@xmachines/play-router/interfaces/RouteNode.md +10 -10
- package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
- package/api/@xmachines/play-router/interfaces/RouteTree.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +3 -3
- package/api/@xmachines/play-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-router/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-router/type-aliases/MachineGraph.md +1 -1
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-signals/README.md +105 -73
- package/api/@xmachines/play-signals/functions/watchSignal.md +1 -1
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
- package/api/@xmachines/play-solid/README.md +117 -263
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +8 -8
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +8 -8
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-solid/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorContext.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-solid-router/README.md +93 -606
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +24 -24
- package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +3 -3
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-svelte/README.md +111 -103
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-svelte/functions/getActorContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/setActorContext.md +1 -1
- package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +8 -8
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +4 -4
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +11 -11
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-svelte/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/README.md +156 -17
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-sveltekit-router/README.md +168 -17
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/README.md +147 -122
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +23 -23
- package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/README.md +195 -173
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +24 -24
- package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +3 -3
- package/api/@xmachines/play-vue/README.md +126 -271
- package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-vue/functions/getPlayViewContext.md +1 -1
- package/api/@xmachines/play-vue/functions/useActor.md +1 -1
- package/api/@xmachines/play-vue/interfaces/ActorProviderProps.md +5 -5
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +8 -8
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-vue/interfaces/VisibilityProviderProps.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-vue/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue-router/README.md +148 -528
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +24 -24
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-vue-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-xstate/README.md +167 -496
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +12 -12
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +1 -1
- package/api/@xmachines/play-xstate/functions/composeGuards.md +1 -1
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +1 -1
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +1 -1
- package/api/@xmachines/play-xstate/functions/definePlayer.md +1 -1
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +1 -1
- package/api/@xmachines/play-xstate/functions/eventMatches.md +1 -1
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +1 -1
- package/api/@xmachines/play-xstate/functions/hasContext.md +1 -1
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
- package/api/@xmachines/play-xstate/functions/negateGuard.md +1 -1
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +3 -3
- package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +2 -2
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +6 -6
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +5 -5
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +4 -4
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
- package/api/@xmachines/shared/README.md +81 -294
- package/api/@xmachines/shared/vite-aliases/functions/xmAliases.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmCacheDir.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmOptimizeDeps.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmResolve.md +1 -1
- package/api/@xmachines/shared/vitest/functions/defineXmVitestConfig.md +1 -1
- package/examples/@xmachines/play-dom-demo/README.md +3 -3
- package/examples/@xmachines/play-dom-demo/functions/createNavBar.md +1 -1
- package/examples/@xmachines/play-dom-demo/functions/initShell.md +1 -1
- package/examples/@xmachines/play-dom-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Home.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Login.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/NavBarView.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Navigation.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Overview.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Profile.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Settings.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-dom-router-demo/README.md +2 -2
- package/examples/@xmachines/play-react-demo/README.md +1 -1
- package/examples/@xmachines/play-react-demo/functions/App.md +1 -1
- package/examples/@xmachines/play-react-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/DebugPanel.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Home.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Login.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/NavBar.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/NavBarView.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Navigation.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Overview.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Profile.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Settings.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Shell.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-react-router-demo/README.md +1 -1
- package/examples/@xmachines/play-solid-demo/README.md +1 -1
- package/examples/@xmachines/play-solid-demo/functions/App.md +1 -1
- package/examples/@xmachines/play-solid-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/DebugPanel.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Home.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Login.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/NavBar.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/NavBarView.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Navigation.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Overview.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Profile.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Settings.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Shell.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-demo/README.md +1 -1
- package/examples/@xmachines/play-svelte-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-spa-router-demo/README.md +2 -2
- package/examples/@xmachines/play-sveltekit-router-demo/README.md +2 -2
- package/examples/@xmachines/play-vue-demo/README.md +1 -1
- package/examples/@xmachines/play-vue-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-vue-demo/variables/App.md +1 -1
- package/examples/@xmachines/play-vue-demo/variables/authCatalog.md +1 -1
- package/examples/README.md +24 -25
- package/examples/form-validation.md +2 -2
- package/guides/README.md +7 -7
- package/guides/actor-model.md +18 -18
- package/guides/architecture.md +500 -0
- package/guides/configuration.md +556 -0
- package/guides/deployment.md +336 -0
- package/guides/development.md +617 -0
- package/guides/getting-started.md +351 -142
- package/guides/signals.md +19 -19
- package/guides/state-machines.md +16 -16
- package/guides/testing.md +460 -0
- package/package.json +5 -5
- package/guides/installation.md +0 -257
|
@@ -1,322 +1,94 @@
|
|
|
1
1
|
[API](../../README.md) / @xmachines/play-vue-router
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
- —
|
|
45
|
-
- —
|
|
46
|
-
|
|
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
|
-
|
|
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,
|
|
54
|
-
|
|
55
|
-
|
|
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:
|
|
71
|
-
path:
|
|
72
|
-
name:
|
|
73
|
-
|
|
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
|
-
//
|
|
78
|
-
const routeMap =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
//
|
|
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
|
-
//
|
|
95
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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 =
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
-
|
|
316
|
-
|
|
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
|
-
|
|
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
|
-
|
|
109
|
+
## API Reference
|
|
338
110
|
|
|
339
|
-
|
|
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
|
-
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
**
|
|
128
|
+
**Constructor parameters:**
|
|
386
129
|
|
|
387
|
-
|
|
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
|
-
|
|
136
|
+
**Methods:**
|
|
390
137
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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
|
-
|
|
161
|
+
The `renderer` prop is a render function that receives the actor and router and returns a `VNodeChild`.
|
|
442
162
|
|
|
443
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
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
|
-
|
|
182
|
+
### Exported error classes (`@xmachines/play-vue-router/errors`)
|
|
471
183
|
|
|
472
|
-
|
|
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 |
|
|
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` |
|
|
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
|
-
|
|
200
|
+
Each class carries a `cause` property with the original Vue Router error.
|
|
524
201
|
|
|
525
|
-
|
|
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
|
-
|
|
535
|
-
|
|
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
|
-
|
|
552
|
-
|
|
553
|
-
**Package Dependencies:**
|
|
554
|
-
|
|
555
|
-
-)
|
|
209
|
+
## Architecture
|
|
556
210
|
|
|
557
|
-
|
|
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
|
-
|
|
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
|
-
**
|
|
221
|
+
**Actor → Router** (TC39 Signal watcher):
|
|
584
222
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
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
|
-
|
|
229
|
+
### Echo suppression
|
|
590
230
|
|
|
591
|
-
|
|
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
|
-
|
|
594
|
-
- Cleaner param handling (object-based)
|
|
595
|
-
- Better Vue Router integration (recommended by docs)
|
|
233
|
+
### Vue effect scope
|
|
596
234
|
|
|
597
|
-
|
|
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
|
-
|
|
237
|
+
## Testing
|
|
600
238
|
|
|
601
|
-
|
|
239
|
+
```bash
|
|
240
|
+
# Run all tests for this package
|
|
241
|
+
npm test -w packages/play-vue-router
|
|
602
242
|
|
|
603
|
-
|
|
604
|
-
|
|
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
|
-
|
|
612
|
-
|
|
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
|
-
|
|
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
|
|