@xmachines/docs 1.0.0-beta.9 → 2.0.0-alpha.1
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 +137 -7
- package/api/@xmachines/play/README.md +160 -38
- package/api/@xmachines/play/classes/NonNullableError.md +189 -0
- package/api/@xmachines/play/classes/PlayError.md +251 -0
- package/api/@xmachines/play/functions/assertNonNullable.md +56 -0
- package/api/@xmachines/play/type-aliases/PlayEvent.md +6 -6
- package/api/@xmachines/play-actor/README.md +141 -160
- package/api/@xmachines/play-actor/classes/AbstractActor.md +96 -126
- package/api/@xmachines/play-actor/functions/attachRenderErrorHandler.md +40 -0
- package/api/@xmachines/play-actor/functions/toAtomState.md +33 -0
- package/api/@xmachines/play-actor/functions/typedSpec.md +54 -0
- package/api/@xmachines/play-actor/interfaces/BaseActorProviderProps.md +46 -0
- package/api/@xmachines/play-actor/interfaces/BaseViewContextValue.md +33 -0
- package/api/@xmachines/play-actor/interfaces/PlaySpec.md +28 -0
- package/api/@xmachines/play-actor/interfaces/Routable.md +6 -21
- package/api/@xmachines/play-actor/interfaces/Viewable.md +12 -6
- package/api/@xmachines/play-dom/README.md +384 -0
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +115 -0
- package/api/@xmachines/play-dom/functions/createPlayUI.md +28 -0
- package/api/@xmachines/play-dom/functions/createRenderer.md +44 -0
- package/api/@xmachines/play-dom/functions/defineRegistry.md +26 -0
- package/api/@xmachines/play-dom/functions/renderSpec.md +67 -0
- package/api/@xmachines/play-dom/interfaces/ComponentContext.md +23 -0
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +34 -0
- package/api/@xmachines/play-dom/interfaces/DefineRegistryResult.md +17 -0
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +28 -0
- package/api/@xmachines/play-dom/interfaces/EventHandle.md +15 -0
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +18 -0
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +30 -0
- package/api/@xmachines/play-dom/interfaces/RenderSpecOptions.md +26 -0
- package/api/@xmachines/play-dom/interfaces/UIProviderOptions.md +32 -0
- package/api/@xmachines/play-dom/type-aliases/ActionFn.md +46 -0
- package/api/@xmachines/play-dom/type-aliases/Actions.md +18 -0
- package/api/@xmachines/play-dom/type-aliases/BaseComponentProps.md +114 -0
- package/api/@xmachines/play-dom/type-aliases/CatalogHasActions.md +25 -0
- package/api/@xmachines/play-dom/type-aliases/ComponentFn.md +26 -0
- package/api/@xmachines/play-dom/type-aliases/ComponentRegistry.md +15 -0
- package/api/@xmachines/play-dom/type-aliases/ConfirmHandler.md +44 -0
- package/api/@xmachines/play-dom/type-aliases/DefineRegistryOptions.md +39 -0
- package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +20 -0
- package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +9 -0
- package/api/@xmachines/play-dom/type-aliases/DomSchema.md +9 -0
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +27 -0
- package/api/@xmachines/play-dom/type-aliases/RenderErrorHandler.md +23 -0
- package/api/@xmachines/play-dom/type-aliases/SetState.md +30 -0
- package/api/@xmachines/play-dom/variables/schema.md +62 -0
- package/api/@xmachines/play-dom-router/README.md +271 -0
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +43 -0
- package/api/@xmachines/{play-router → play-dom-router}/functions/createBrowserHistory.md +10 -2
- package/api/@xmachines/play-dom-router/functions/createRouteMap.md +39 -0
- package/api/@xmachines/play-dom-router/functions/createRouter.md +54 -0
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +176 -0
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +69 -0
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +15 -0
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +129 -0
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +68 -0
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +54 -0
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +121 -0
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +27 -0
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +28 -0
- package/api/@xmachines/play-react/README.md +185 -334
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +46 -42
- package/api/@xmachines/play-react/functions/ActionProvider.md +21 -0
- package/api/@xmachines/play-react/functions/JSONUIProvider.md +21 -0
- package/api/@xmachines/play-react/functions/Renderer.md +21 -0
- package/api/@xmachines/play-react/functions/StateProvider.md +27 -0
- package/api/@xmachines/play-react/functions/ValidationProvider.md +21 -0
- package/api/@xmachines/play-react/functions/VisibilityProvider.md +21 -0
- package/api/@xmachines/play-react/functions/defineRegistry.md +49 -0
- package/api/@xmachines/play-react/functions/useActor.md +13 -0
- package/api/@xmachines/play-react/functions/useBoundProp.md +45 -0
- package/api/@xmachines/play-react/functions/usePlayView.md +32 -0
- package/api/@xmachines/play-react/functions/useSignalEffect.md +29 -20
- package/api/@xmachines/play-react/interfaces/ActionProviderProps.md +15 -0
- package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +27 -0
- package/api/@xmachines/play-react/interfaces/ComponentContext.md +37 -0
- package/api/@xmachines/play-react/interfaces/JSONUIProviderProps.md +22 -0
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +7 -7
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +6 -6
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +26 -0
- package/api/@xmachines/play-react/interfaces/RendererProps.md +17 -0
- package/api/@xmachines/play-react/interfaces/StateProviderProps.md +16 -0
- package/api/@xmachines/play-react/interfaces/ValidationProviderProps.md +14 -0
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +20 -0
- package/api/@xmachines/play-react/interfaces/VisibilityProviderProps.md +13 -0
- package/api/@xmachines/play-react/type-aliases/AnyPlayActor.md +11 -0
- package/api/@xmachines/play-react/type-aliases/ComponentFn.md +36 -0
- package/api/@xmachines/play-react/type-aliases/RenderErrorHandler.md +23 -0
- package/api/@xmachines/play-react/variables/ActorProvider.md +33 -0
- package/api/@xmachines/play-react/variables/PlayRenderer.md +6 -56
- package/api/@xmachines/play-react/variables/PlayUIProvider.md +43 -0
- package/api/@xmachines/play-react-router/README.md +130 -114
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +19 -242
- package/api/@xmachines/play-react-router/classes/RouteMap.md +48 -36
- package/api/@xmachines/play-react-router/functions/createPlayRouterProvider.md +45 -0
- package/api/@xmachines/play-react-router/functions/createRouteMap.md +39 -0
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +23 -12
- package/api/@xmachines/play-react-router/interfaces/PlayActor.md +68 -0
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +22 -12
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderBaseProps.md +32 -0
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +25 -9
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +19 -9
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +8 -8
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterBridgeConstructor.md +30 -0
- package/api/@xmachines/play-react-router/variables/PlayRouterProvider.md +32 -0
- package/api/@xmachines/play-router/README.md +285 -355
- package/api/@xmachines/play-router/classes/RouteMap.md +149 -0
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +21 -221
- package/api/@xmachines/play-router/functions/buildPlayRouteEvent.md +32 -0
- package/api/@xmachines/play-router/functions/buildRouteTree.md +12 -2
- package/api/@xmachines/play-router/functions/createRouteMap.md +22 -36
- package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +46 -0
- package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +14 -7
- package/api/@xmachines/play-router/functions/extractMachineRoutes.md +10 -46
- package/api/@xmachines/play-router/functions/extractQuery.md +22 -0
- package/api/@xmachines/play-router/functions/extractRouteParams.md +54 -0
- package/api/@xmachines/play-router/functions/findRouteById.md +2 -2
- package/api/@xmachines/play-router/functions/findRouteByPath.md +2 -2
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +2 -2
- package/api/@xmachines/play-router/functions/getRoutableRoutes.md +2 -2
- package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +43 -0
- package/api/@xmachines/play-router/functions/isRouteReachable.md +38 -0
- package/api/@xmachines/play-router/functions/machineToGraph.md +19 -0
- package/api/@xmachines/play-router/functions/routeExists.md +2 -2
- package/api/@xmachines/play-router/functions/sanitizePathname.md +40 -0
- package/api/@xmachines/play-router/functions/validateRouteFormat.md +10 -9
- package/api/@xmachines/play-router/functions/validateStateExists.md +9 -9
- package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +13 -0
- package/api/@xmachines/play-router/interfaces/LocationLike.md +27 -0
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +17 -0
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +17 -0
- package/api/@xmachines/play-router/interfaces/PlayActor.md +68 -0
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +22 -12
- package/api/@xmachines/play-router/interfaces/ResolvedRoutePath.md +17 -0
- package/api/@xmachines/play-router/interfaces/RoutableActor.md +64 -0
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +11 -11
- package/api/@xmachines/play-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-router/interfaces/RouteMapping.md +27 -0
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +12 -0
- package/api/@xmachines/play-router/interfaces/RouteNode.md +13 -13
- package/api/@xmachines/play-router/interfaces/RouteObject.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteTree.md +8 -7
- package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +55 -0
- package/api/@xmachines/play-router/interfaces/RouterBridge.md +8 -8
- package/api/@xmachines/play-router/interfaces/WindowLike.md +65 -0
- package/api/@xmachines/play-router/type-aliases/MachineGraph.md +20 -0
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +2 -2
- package/api/@xmachines/play-signals/README.md +116 -65
- package/api/@xmachines/play-signals/functions/watchSignal.md +42 -0
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +7 -5
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +3 -3
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +7 -5
- package/api/@xmachines/play-signals/interfaces/SignalState.md +4 -4
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +5 -5
- package/api/@xmachines/play-signals/namespaces/Signal/README.md +1 -1
- package/api/@xmachines/play-signals/namespaces/Signal/classes/Computed.md +7 -7
- package/api/@xmachines/play-signals/namespaces/Signal/classes/State.md +8 -8
- package/api/@xmachines/play-signals/namespaces/Signal/interfaces/Options.md +7 -7
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/README.md +1 -1
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/classes/Watcher.md +9 -9
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/currentComputed.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSinks.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSources.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSinks.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSources.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/untrack.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/unwatched.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/watched.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isComputed.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isState.md +2 -2
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isWatcher.md +2 -2
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +2 -2
- package/api/@xmachines/play-solid/README.md +196 -234
- package/api/@xmachines/play-solid/functions/ActionProvider.md +19 -0
- package/api/@xmachines/play-solid/functions/JSONUIProvider.md +21 -0
- package/api/@xmachines/play-solid/functions/Renderer.md +21 -0
- package/api/@xmachines/play-solid/functions/StateProvider.md +19 -0
- package/api/@xmachines/play-solid/functions/ValidationProvider.md +19 -0
- package/api/@xmachines/play-solid/functions/VisibilityProvider.md +20 -0
- package/api/@xmachines/play-solid/functions/defineRegistry.md +49 -0
- package/api/@xmachines/play-solid/functions/useAction.md +24 -0
- package/api/@xmachines/play-solid/functions/useActions.md +13 -0
- package/api/@xmachines/play-solid/functions/useActor.md +13 -0
- package/api/@xmachines/play-solid/functions/useBoundProp.md +45 -0
- package/api/@xmachines/play-solid/functions/useFieldValidation.md +29 -0
- package/api/@xmachines/play-solid/functions/useIsVisible.md +19 -0
- package/api/@xmachines/play-solid/functions/useOptionalValidation.md +13 -0
- package/api/@xmachines/play-solid/functions/usePlayView.md +30 -0
- package/api/@xmachines/play-solid/functions/useStateBinding.md +25 -0
- package/api/@xmachines/play-solid/functions/useStateStore.md +13 -0
- package/api/@xmachines/play-solid/functions/useStateValue.md +25 -0
- package/api/@xmachines/play-solid/functions/useVisibility.md +13 -0
- package/api/@xmachines/play-solid/interfaces/ActionProviderProps.md +12 -0
- package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +30 -0
- package/api/@xmachines/play-solid/interfaces/ComponentContext.md +37 -0
- package/api/@xmachines/play-solid/interfaces/DefineRegistryResult.md +15 -0
- package/api/@xmachines/play-solid/interfaces/JSONUIProviderProps.md +22 -0
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +26 -0
- package/api/@xmachines/play-solid/interfaces/RendererProps.md +17 -0
- package/api/@xmachines/play-solid/interfaces/StateProviderProps.md +13 -0
- package/api/@xmachines/play-solid/interfaces/ValidationProviderProps.md +11 -0
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +21 -0
- package/api/@xmachines/play-solid/type-aliases/AnyPlayActor.md +11 -0
- package/api/@xmachines/play-solid/type-aliases/ComponentFn.md +36 -0
- package/api/@xmachines/play-solid/type-aliases/ComponentRegistry.md +11 -0
- package/api/@xmachines/play-solid/type-aliases/RenderErrorHandler.md +23 -0
- package/api/@xmachines/play-solid/type-aliases/SetState.md +21 -0
- package/api/@xmachines/play-solid/type-aliases/VisibilityProviderProps.md +9 -0
- package/api/@xmachines/play-solid/variables/ActorContext.md +13 -0
- package/api/@xmachines/play-solid/variables/ActorProvider.md +27 -0
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +6 -62
- package/api/@xmachines/play-solid/variables/PlayUIProvider.md +26 -0
- package/api/@xmachines/play-solid-router/README.md +153 -562
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +31 -32
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +27 -242
- package/api/@xmachines/play-solid-router/functions/createPlayRouterProvider.md +44 -0
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +18 -11
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +89 -119
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +68 -0
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +22 -12
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderBaseProps.md +30 -0
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +25 -9
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +20 -7
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +8 -8
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterBridgeConstructor.md +34 -0
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +8 -4
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +22 -19
- package/api/@xmachines/play-solid-router/variables/PlayRouterProvider.md +52 -0
- package/api/@xmachines/play-svelte/README.md +269 -0
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +31 -0
- package/api/@xmachines/play-svelte/functions/getActorContext.md +21 -0
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +19 -0
- package/api/@xmachines/play-svelte/functions/setActorContext.md +19 -0
- package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +44 -0
- package/api/@xmachines/play-svelte/interfaces/BaseComponentProps.md +29 -0
- package/api/@xmachines/play-svelte/interfaces/ComponentContext.md +29 -0
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +24 -0
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +43 -0
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +24 -0
- package/api/@xmachines/play-svelte/type-aliases/ActionFn.md +30 -0
- package/api/@xmachines/play-svelte/type-aliases/Actions.md +17 -0
- package/api/@xmachines/play-svelte/type-aliases/AnyPlayActor.md +11 -0
- package/api/@xmachines/play-svelte/type-aliases/ComponentFn.md +18 -0
- package/api/@xmachines/play-svelte/type-aliases/JSONUIProviderProps.md +7 -0
- package/api/@xmachines/play-svelte/type-aliases/PlayRenderer.md +9 -0
- package/api/@xmachines/play-svelte/type-aliases/RenderErrorHandler.md +23 -0
- package/api/@xmachines/play-svelte/type-aliases/SetState.md +21 -0
- package/api/@xmachines/play-svelte/variables/PlayRenderer.md +9 -0
- package/api/@xmachines/play-svelte-spa-router/README.md +205 -0
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +149 -0
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +32 -0
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +39 -0
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +17 -0
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +129 -0
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +27 -0
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +65 -0
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +9 -0
- package/api/@xmachines/play-sveltekit-router/README.md +211 -0
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +149 -0
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +32 -0
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +39 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +13 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +27 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +129 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +27 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +9 -0
- package/api/@xmachines/play-tanstack-react-router/README.md +155 -126
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +48 -36
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +31 -252
- package/api/@xmachines/play-tanstack-react-router/functions/createPlayRouterProvider.md +45 -0
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +22 -36
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +23 -12
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +28 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayActor.md +68 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +22 -12
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderBaseProps.md +32 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +25 -9
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +19 -9
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +6 -6
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +8 -8
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterBridgeConstructor.md +30 -0
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +2 -2
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +40 -18
- package/api/@xmachines/play-tanstack-react-router/variables/PlayRouterProvider.md +34 -0
- package/api/@xmachines/play-tanstack-router/README.md +58 -0
- package/api/@xmachines/play-tanstack-router/classes/TanStackRouterBridgeBase.md +131 -0
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouteMapLike.md +57 -0
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouterLike.md +100 -0
- package/api/@xmachines/play-tanstack-solid-router/README.md +215 -175
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +31 -32
- package/api/@xmachines/play-tanstack-solid-router/classes/TanStackSolidRouterBridge.md +121 -0
- package/api/@xmachines/play-tanstack-solid-router/functions/createPlayRouterProvider.md +44 -0
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +18 -11
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayActor.md +68 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +22 -12
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderBaseProps.md +31 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +23 -9
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +14 -10
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +8 -8
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterBridgeConstructor.md +30 -0
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +8 -4
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +40 -18
- package/api/@xmachines/play-tanstack-solid-router/variables/PlayRouterProvider.md +33 -0
- package/api/@xmachines/play-vue/README.md +192 -210
- package/api/@xmachines/play-vue/functions/defineRegistry.md +32 -0
- package/api/@xmachines/play-vue/functions/getPlayViewContext.md +28 -0
- package/api/@xmachines/play-vue/functions/useActor.md +13 -0
- package/api/@xmachines/play-vue/functions/useBoundProp.md +45 -0
- package/api/@xmachines/play-vue/interfaces/ActionProviderProps.md +12 -0
- package/api/@xmachines/play-vue/interfaces/ActorProviderProps.md +25 -0
- package/api/@xmachines/play-vue/interfaces/ComponentContext.md +37 -0
- package/api/@xmachines/play-vue/interfaces/DefineRegistryResult.md +15 -0
- package/api/@xmachines/play-vue/interfaces/JSONUIProviderProps.md +21 -0
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +24 -0
- package/api/@xmachines/play-vue/interfaces/RendererProps.md +17 -0
- package/api/@xmachines/play-vue/interfaces/StateProviderProps.md +15 -0
- package/api/@xmachines/play-vue/interfaces/ValidationProviderProps.md +11 -0
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +21 -0
- package/api/@xmachines/play-vue/interfaces/VisibilityProviderProps.md +5 -0
- package/api/@xmachines/play-vue/type-aliases/AnyPlayActor.md +11 -0
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +16 -0
- package/api/@xmachines/play-vue/type-aliases/ComponentFn.md +35 -0
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +15 -0
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +22 -0
- package/api/@xmachines/play-vue/type-aliases/RenderErrorHandler.md +23 -0
- package/api/@xmachines/play-vue/variables/ActionProvider.md +64 -0
- package/api/@xmachines/play-vue/variables/JSONUIProvider.md +105 -0
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +2 -2
- package/api/@xmachines/play-vue/variables/Renderer.md +88 -0
- package/api/@xmachines/play-vue/variables/StateProvider.md +79 -0
- package/api/@xmachines/play-vue/variables/ValidationProvider.md +55 -0
- package/api/@xmachines/play-vue/variables/VisibilityProvider.md +40 -0
- package/api/@xmachines/play-vue-router/README.md +173 -487
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +56 -116
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +23 -271
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +26 -6
- package/api/@xmachines/play-vue-router/interfaces/PlayActor.md +68 -0
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +22 -12
- package/api/@xmachines/play-vue-router/interfaces/RouteMapOptions.md +13 -0
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +20 -8
- package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +8 -8
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +8 -4
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +12 -6
- package/api/@xmachines/play-xstate/README.md +234 -340
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +166 -195
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +31 -20
- package/api/@xmachines/play-xstate/functions/composeGuards.md +24 -18
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +17 -17
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +38 -0
- package/api/@xmachines/play-xstate/functions/createRoutedMachine.md +87 -0
- package/api/@xmachines/play-xstate/functions/definePlayer.md +14 -63
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +3 -3
- package/api/@xmachines/play-xstate/functions/eventMatches.md +2 -2
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +46 -12
- package/api/@xmachines/play-xstate/functions/hasContext.md +2 -2
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +2 -2
- package/api/@xmachines/play-xstate/functions/negateGuard.md +16 -16
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +10 -14
- package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +22 -0
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +12 -13
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +15 -13
- package/api/@xmachines/play-xstate/interfaces/RouteObject.md +17 -0
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +27 -6
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +2 -2
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +3 -3
- package/api/@xmachines/play-xstate/type-aliases/PlayRoutePayload.md +30 -0
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +10 -9
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +22 -5
- package/api/@xmachines/play-xstate/type-aliases/RouteMetadata.md +9 -0
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +34 -6
- package/api/@xmachines/play-xstate/type-aliases/SetupLike.md +33 -0
- package/api/@xmachines/play-xstate/type-aliases/WithOptional.md +31 -0
- package/api/@xmachines/play-xstate/variables/emptyEventSchema.md +37 -0
- package/api/@xmachines/play-xstate/variables/playMetaSchema.md +40 -0
- package/api/@xmachines/play-xstate/variables/playRouteEventSchema.md +9 -0
- package/api/@xmachines/shared/README.md +95 -295
- package/api/@xmachines/shared/vite-aliases/README.md +11 -0
- package/api/@xmachines/shared/vite-aliases/functions/xmAliases.md +38 -0
- package/api/@xmachines/shared/vite-aliases/functions/xmCacheDir.md +27 -0
- package/api/@xmachines/shared/vite-aliases/functions/xmOptimizeDeps.md +30 -0
- package/api/@xmachines/shared/vite-aliases/functions/xmResolve.md +42 -0
- package/api/@xmachines/shared/vite-aliases/functions/xmSvelteRunes.md +33 -0
- package/api/@xmachines/shared/vitest/README.md +12 -0
- package/api/@xmachines/shared/vitest/functions/defineXmBrowserConfig.md +42 -0
- package/api/@xmachines/shared/vitest/functions/defineXmVitestConfig.md +34 -0
- package/api/@xmachines/shared/vitest/interfaces/XmBrowserConfigOptions.md +16 -0
- package/api/README.md +6 -7
- package/api/llms.txt +72 -23
- package/contributing/README.md +10 -0
- package/contributing/architecture.md +602 -0
- package/contributing/configuration.md +368 -0
- package/contributing/deployment.md +312 -0
- package/contributing/development.md +464 -0
- package/contributing/testing.md +453 -0
- package/examples/@xmachines/play-dom-demo/README.md +181 -0
- package/examples/@xmachines/play-dom-demo/functions/createNavBar.md +24 -0
- package/examples/@xmachines/play-dom-demo/functions/initShell.md +24 -0
- package/examples/@xmachines/play-dom-demo/type-aliases/AuthCatalog.md +9 -0
- package/examples/@xmachines/play-dom-demo/variables/About.md +12 -0
- package/examples/@xmachines/play-dom-demo/variables/Contact.md +12 -0
- package/examples/@xmachines/play-dom-demo/variables/Dashboard.md +13 -0
- package/examples/@xmachines/play-dom-demo/variables/Home.md +13 -0
- package/examples/@xmachines/play-dom-demo/variables/Login.md +13 -0
- package/examples/@xmachines/play-dom-demo/variables/NavBarView.md +16 -0
- package/examples/@xmachines/play-dom-demo/variables/Navigation.md +13 -0
- package/examples/@xmachines/play-dom-demo/variables/Overview.md +13 -0
- package/examples/@xmachines/play-dom-demo/variables/Profile.md +13 -0
- package/examples/@xmachines/play-dom-demo/variables/Settings.md +13 -0
- package/examples/@xmachines/play-dom-demo/variables/Stats.md +13 -0
- package/examples/@xmachines/play-dom-demo/variables/authCatalog.md +172 -0
- package/examples/@xmachines/play-dom-router-demo/README.md +145 -0
- package/examples/@xmachines/play-react-demo/README.md +187 -0
- package/examples/@xmachines/play-react-demo/functions/App.md +13 -0
- package/examples/@xmachines/play-react-demo/functions/DebugPanel.md +20 -0
- package/examples/@xmachines/play-react-demo/functions/HeaderNav.md +20 -0
- package/examples/@xmachines/play-react-demo/functions/Shell.md +22 -0
- package/examples/@xmachines/play-react-demo/type-aliases/AuthCatalog.md +9 -0
- package/examples/@xmachines/play-react-demo/variables/About.md +14 -0
- package/examples/@xmachines/play-react-demo/variables/Contact.md +14 -0
- package/examples/@xmachines/play-react-demo/variables/Dashboard.md +15 -0
- package/examples/@xmachines/play-react-demo/variables/DebugPanel.md +15 -0
- package/examples/@xmachines/play-react-demo/variables/Home.md +14 -0
- package/examples/@xmachines/play-react-demo/variables/Login.md +16 -0
- package/examples/@xmachines/play-react-demo/variables/NavBar.md +16 -0
- package/examples/@xmachines/play-react-demo/variables/NavBarView.md +15 -0
- package/examples/@xmachines/play-react-demo/variables/Navigation.md +14 -0
- package/examples/@xmachines/play-react-demo/variables/Overview.md +14 -0
- package/examples/@xmachines/play-react-demo/variables/Profile.md +14 -0
- package/examples/@xmachines/play-react-demo/variables/Settings.md +14 -0
- package/examples/@xmachines/play-react-demo/variables/Shell.md +18 -0
- package/examples/@xmachines/play-react-demo/variables/Stats.md +14 -0
- package/examples/@xmachines/play-react-demo/variables/authCatalog.md +172 -0
- package/examples/@xmachines/play-react-router-demo/README.md +151 -0
- package/examples/@xmachines/play-solid-demo/README.md +187 -0
- package/examples/@xmachines/play-solid-demo/functions/App.md +13 -0
- package/examples/@xmachines/play-solid-demo/functions/DebugPanel.md +20 -0
- package/examples/@xmachines/play-solid-demo/functions/HeaderNav.md +20 -0
- package/examples/@xmachines/play-solid-demo/functions/Shell.md +22 -0
- package/examples/@xmachines/play-solid-demo/type-aliases/AuthCatalog.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/About.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/Contact.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/Dashboard.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/DebugPanel.md +15 -0
- package/examples/@xmachines/play-solid-demo/variables/Home.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/Login.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/NavBar.md +11 -0
- package/examples/@xmachines/play-solid-demo/variables/NavBarView.md +15 -0
- package/examples/@xmachines/play-solid-demo/variables/Navigation.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/Overview.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/Profile.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/Settings.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/Shell.md +17 -0
- package/examples/@xmachines/play-solid-demo/variables/Stats.md +9 -0
- package/examples/@xmachines/play-solid-demo/variables/authCatalog.md +172 -0
- package/examples/@xmachines/play-solid-router-demo/README.md +137 -0
- package/examples/@xmachines/play-svelte-demo/README.md +143 -0
- package/examples/@xmachines/play-svelte-demo/type-aliases/App.md +9 -0
- package/examples/@xmachines/play-svelte-demo/type-aliases/AuthCatalog.md +9 -0
- package/examples/@xmachines/play-svelte-demo/variables/App.md +9 -0
- package/examples/@xmachines/play-svelte-demo/variables/authCatalog.md +172 -0
- package/examples/@xmachines/play-svelte-spa-router-demo/README.md +129 -0
- package/examples/@xmachines/play-sveltekit-router-demo/README.md +133 -0
- package/examples/@xmachines/play-tanstack-react-router-demo/README.md +156 -0
- package/examples/@xmachines/play-tanstack-solid-router-demo/README.md +139 -0
- package/examples/@xmachines/play-vue-demo/README.md +183 -0
- package/examples/@xmachines/play-vue-demo/type-aliases/AuthCatalog.md +9 -0
- package/examples/@xmachines/play-vue-demo/variables/App.md +9 -0
- package/examples/@xmachines/play-vue-demo/variables/authCatalog.md +172 -0
- package/examples/@xmachines/play-vue-router-demo/README.md +139 -0
- package/examples/README.md +78 -30
- package/examples/basic-state-machine.md +73 -31
- package/examples/form-validation.md +267 -115
- package/examples/multi-router-integration.md +314 -194
- package/examples/routing-patterns.md +260 -187
- package/examples/traffic-light.md +96 -58
- package/guides/README.md +9 -21
- package/guides/actor-model.md +180 -0
- package/guides/getting-started.md +630 -137
- package/guides/signals.md +166 -0
- package/guides/state-machines.md +300 -0
- package/package.json +18 -7
- package/rfc/broker.md +100 -0
- package/rfc/browser.md +44 -0
- package/rfc/cli.md +118 -0
- package/rfc/git.md +61 -0
- package/rfc/mcp.md +43 -0
- package/rfc/node.md +36 -0
- package/rfc/play.md +472 -0
- package/rfc/rest.md +102 -0
- package/rfc/run.md +159 -0
- package/rfc/streams.md +168 -0
- package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +0 -17
- package/api/@xmachines/play-catalog/README.md +0 -331
- package/api/@xmachines/play-catalog/functions/defineCatalog.md +0 -98
- package/api/@xmachines/play-catalog/functions/defineComponents.md +0 -134
- package/api/@xmachines/play-catalog/type-aliases/Catalog.md +0 -48
- package/api/@xmachines/play-catalog/type-aliases/ComponentsFor.md +0 -20
- package/api/@xmachines/play-catalog/type-aliases/InferComponentProps.md +0 -65
- package/api/@xmachines/play-catalog/type-aliases/NoExtraKeys.md +0 -17
- package/api/@xmachines/play-react/interfaces/PlayRendererProps.md +0 -15
- package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +0 -19
- package/api/@xmachines/play-react-router-demo/README.md +0 -137
- package/api/@xmachines/play-router/classes/BaseRouteMap.md +0 -142
- package/api/@xmachines/play-router/functions/connectRouter.md +0 -67
- package/api/@xmachines/play-router/functions/crawlMachine.md +0 -92
- package/api/@xmachines/play-router/functions/createRouter.md +0 -76
- package/api/@xmachines/play-router/functions/extractRoute.md +0 -45
- package/api/@xmachines/play-router/interfaces/BaseRouteMapping.md +0 -27
- package/api/@xmachines/play-router/interfaces/BrowserHistory.md +0 -172
- package/api/@xmachines/play-router/interfaces/BrowserWindow.md +0 -69
- package/api/@xmachines/play-router/interfaces/ConnectRouterOptions.md +0 -13
- package/api/@xmachines/play-router/interfaces/RouteMap.md +0 -56
- package/api/@xmachines/play-router/interfaces/StateVisit.md +0 -15
- package/api/@xmachines/play-router/interfaces/VanillaRouter.md +0 -28
- package/api/@xmachines/play-router-demo/README.md +0 -137
- package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +0 -15
- package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +0 -19
- package/api/@xmachines/play-solid-router-demo/README.md +0 -127
- package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +0 -19
- package/api/@xmachines/play-tanstack-react-router/functions/extractParams.md +0 -38
- package/api/@xmachines/play-tanstack-react-router/functions/extractQueryParams.md +0 -33
- package/api/@xmachines/play-tanstack-react-router/variables/extractMachineRoutes.md +0 -64
- package/api/@xmachines/play-tanstack-react-router-demo/README.md +0 -126
- package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +0 -343
- package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +0 -19
- package/api/@xmachines/play-tanstack-solid-router-demo/README.md +0 -126
- package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +0 -14
- package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +0 -201
- package/api/@xmachines/play-vue-router-demo/README.md +0 -133
- package/api/@xmachines/play-xstate/functions/mergeViewProps.md +0 -26
- package/api/@xmachines/play-xstate/functions/stateMatches.md +0 -25
- package/api/@xmachines/play-xstate/functions/validateComponentBinding.md +0 -39
- package/api/@xmachines/play-xstate/functions/validateViewProps.md +0 -80
- package/api/@xmachines/play-xstate/interfaces/CatalogEntry.md +0 -16
- package/api/@xmachines/play-xstate/type-aliases/Catalog.md +0 -21
- package/api/@xmachines/play-xstate/type-aliases/ValidationResult.md +0 -17
- package/api/@xmachines/play-xstate/type-aliases/ViewMergeContext.md +0 -35
- package/api/@xmachines/shared/functions/defineXmVitestConfig.md +0 -29
- package/api/@xmachines/shared/functions/xmAliases.md +0 -24
- package/guides/installation.md +0 -323
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
[
|
|
1
|
+
[API](../../README.md) / @xmachines/play-router
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**Route tree extraction from XState v5 state machines with routing patterns**
|
|
6
|
-
|
|
7
|
-
BFS graph crawling and bidirectional route lookup enabling Actor Authority over navigation.
|
|
8
|
-
|
|
9
|
-
## Overview
|
|
10
|
-
|
|
11
|
-
`@xmachines/play-router` extracts route trees from XState state machines by crawling the state graph using breadth-first traversal. It extracts `meta.route` paths from state machines and builds hierarchical route trees with bidirectional state ID ↔ path mapping.
|
|
3
|
+
<!-- generated-by: gsd-doc-writer -->
|
|
12
4
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`RouterBridgeBase` is the policy point; framework adapters are thin ports that implement only framework-specific navigate/subscribe/unsubscribe behavior.
|
|
5
|
+
# @xmachines/play-router
|
|
16
6
|
|
|
17
|
-
|
|
7
|
+
Route tree extraction from XState v6 state machines. Part of [@xmachines/play](../play/README.md) Universal Player Architecture.
|
|
18
8
|
|
|
19
|
-
-
|
|
9
|
+
Graph-based route extraction and bidirectional lookup enabling Actor Authority over navigation.
|
|
20
10
|
|
|
21
|
-
|
|
11
|
+
Part of the [xmachines-js monorepo](../../README.md).
|
|
22
12
|
|
|
23
13
|
## Installation
|
|
24
14
|
|
|
25
15
|
```bash
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
pnpm add xstate@^6.0.0-alpha.19
|
|
17
|
+
pnpm add @xmachines/play-router
|
|
28
18
|
```
|
|
29
19
|
|
|
30
20
|
**Peer dependencies:**
|
|
31
21
|
|
|
32
|
-
- `xstate` ^
|
|
22
|
+
- `xstate` ^6.0.0-alpha.19 — XState v6 state machine runtime
|
|
33
23
|
|
|
34
24
|
**URLPattern polyfill (Node.js < 24 / older browsers):**
|
|
35
25
|
|
|
@@ -45,458 +35,398 @@ import "urlpattern-polyfill";
|
|
|
45
35
|
Install the polyfill:
|
|
46
36
|
|
|
47
37
|
```bash
|
|
48
|
-
|
|
38
|
+
pnpm add urlpattern-polyfill
|
|
49
39
|
```
|
|
50
40
|
|
|
51
|
-
`urlpattern-polyfill` is declared as an optional peer dependency. Package managers will not install it automatically —
|
|
41
|
+
`urlpattern-polyfill` is declared as an optional peer dependency. Package managers will not install it automatically — consumers must install and load it when their runtime lacks native URLPattern support.
|
|
52
42
|
|
|
53
|
-
##
|
|
43
|
+
## Usage
|
|
54
44
|
|
|
55
|
-
|
|
56
|
-
import { createMachine } from "xstate";
|
|
57
|
-
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
45
|
+
### Extract routes from a machine
|
|
58
46
|
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
```typescript
|
|
48
|
+
import { setup, types } from "xstate";
|
|
49
|
+
import { extractMachineRoutes, createRouteMap } from "@xmachines/play-router";
|
|
50
|
+
|
|
51
|
+
// meta.route on state nodes needs a declared meta schema —
|
|
52
|
+
// without it, XState v6 types `meta` as `never`.
|
|
53
|
+
const machine = setup({
|
|
54
|
+
schemas: {
|
|
55
|
+
meta: types<{ route?: string }>(),
|
|
56
|
+
},
|
|
57
|
+
}).createMachine({
|
|
61
58
|
id: "app",
|
|
62
59
|
initial: "home",
|
|
63
60
|
states: {
|
|
64
61
|
home: {
|
|
65
62
|
id: "home",
|
|
66
|
-
meta: { route: "/"
|
|
63
|
+
meta: { route: "/" },
|
|
67
64
|
},
|
|
68
65
|
dashboard: {
|
|
69
66
|
id: "dashboard",
|
|
70
|
-
meta: { route: "/dashboard"
|
|
67
|
+
meta: { route: "/dashboard" },
|
|
71
68
|
initial: "overview",
|
|
72
69
|
states: {
|
|
73
70
|
overview: {
|
|
74
71
|
id: "overview",
|
|
75
|
-
meta: { route: "/overview"
|
|
72
|
+
meta: { route: "/overview" },
|
|
76
73
|
},
|
|
77
74
|
settings: {
|
|
78
75
|
id: "settings",
|
|
79
|
-
meta: { route: "/settings/:section?"
|
|
76
|
+
meta: { route: "/settings/:section?" }, // optional parameter
|
|
80
77
|
},
|
|
81
78
|
},
|
|
82
79
|
},
|
|
80
|
+
profile: {
|
|
81
|
+
id: "profile",
|
|
82
|
+
meta: { route: "/profile/:userId" }, // required parameter
|
|
83
|
+
},
|
|
83
84
|
},
|
|
84
85
|
});
|
|
85
86
|
|
|
87
|
+
// Build hierarchical route tree with bidirectional maps
|
|
86
88
|
const tree = extractMachineRoutes(machine);
|
|
87
89
|
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
console.log(tree.byId.get("overview")); // RouteNode
|
|
91
|
-
|
|
92
|
-
// Pattern matching for dynamic routes
|
|
93
|
-
const settingsRoute = tree.byPath.get("/settings/profile");
|
|
94
|
-
console.log(settingsRoute?.id); // "settings"
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Vanilla Browser Example
|
|
98
|
-
|
|
99
|
-
See `examples/vanilla-demo/` for a complete example using vanilla TypeScript with the browser History API.
|
|
100
|
-
|
|
101
|
-
The demo demonstrates:
|
|
90
|
+
// Path → RouteNode
|
|
91
|
+
const node = tree.byPath.get("/dashboard"); // RouteNode for "dashboard"
|
|
102
92
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- **Protected route guards** (authentication redirects)
|
|
107
|
-
- **Dynamic route parameters** (/profile/:userId)
|
|
93
|
+
// State ID → RouteNode
|
|
94
|
+
const overview = tree.byStateId.get("overview");
|
|
95
|
+
console.log(overview?.fullPath); // "/overview"
|
|
108
96
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
npm install
|
|
114
|
-
npm run dev
|
|
97
|
+
// Build a RouteMap for framework adapters
|
|
98
|
+
const routeMap = createRouteMap(machine);
|
|
99
|
+
routeMap.getStateIdByPath("/profile/123"); // "profile"
|
|
100
|
+
routeMap.getPathByStateId("profile"); // "/profile/:userId"
|
|
115
101
|
```
|
|
116
102
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
1. Login with any username
|
|
120
|
-
2. Navigate between home and profile
|
|
121
|
-
3. Use browser back/forward buttons
|
|
122
|
-
4. Try accessing protected routes directly
|
|
123
|
-
|
|
124
|
-
**Key implementation patterns:**
|
|
103
|
+
### Sending `play.route` events
|
|
125
104
|
|
|
126
105
|
```typescript
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
106
|
+
import type { PlayRouteEvent } from "@xmachines/play-router";
|
|
107
|
+
|
|
108
|
+
// Navigate to a state by ID
|
|
109
|
+
const event: PlayRouteEvent = {
|
|
110
|
+
type: "play.route",
|
|
111
|
+
to: "#dashboard",
|
|
112
|
+
};
|
|
113
|
+
actor.send(event);
|
|
114
|
+
|
|
115
|
+
// Navigate with route parameters
|
|
116
|
+
actor.send({
|
|
117
|
+
type: "play.route",
|
|
118
|
+
to: "#profile",
|
|
119
|
+
params: { userId: "123" },
|
|
141
120
|
});
|
|
142
121
|
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
122
|
+
// Navigate with query parameters
|
|
123
|
+
actor.send({
|
|
124
|
+
type: "play.route",
|
|
125
|
+
to: "#settings",
|
|
126
|
+
params: { section: "billing" },
|
|
127
|
+
query: { tab: "invoices" },
|
|
150
128
|
});
|
|
151
|
-
|
|
152
|
-
// Initial URL handling
|
|
153
|
-
const initialPath = window.location.pathname;
|
|
154
|
-
if (initialPath !== "/") {
|
|
155
|
-
const { to, params } = routeMap.resolve(initialPath);
|
|
156
|
-
if (to) {
|
|
157
|
-
actor.send({ type: "play.route", to, params });
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
129
|
```
|
|
161
130
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
## Canonical Watcher Lifecycle
|
|
165
|
-
|
|
166
|
-
Bridge implementations should use one watcher flow:
|
|
167
|
-
|
|
168
|
-
1. `notify`
|
|
169
|
-
2. `queueMicrotask`
|
|
170
|
-
3. `getPending()`
|
|
171
|
-
4. read actor route and sync infrastructure state
|
|
172
|
-
5. re-arm with `watch(...)` or `watch()`
|
|
173
|
-
|
|
174
|
-
Watcher notification is one-shot; re-arm is required.
|
|
175
|
-
|
|
176
|
-
## Bridge Cleanup Contract
|
|
177
|
-
|
|
178
|
-
Bridge teardown must be explicit and deterministic:
|
|
179
|
-
|
|
180
|
-
- `disconnect`/`dispose` must unwatch signal subscriptions and unhook router listeners.
|
|
181
|
-
- Do not rely on GC-only cleanup guidance.
|
|
182
|
-
- Infrastructure remains passive: bridges observe and forward intents, actors decide validity.
|
|
183
|
-
|
|
184
|
-
## API Reference
|
|
185
|
-
|
|
186
|
-
### extractMachineRoutes()
|
|
131
|
+
### Implementing a `RouterBridgeBase` adapter
|
|
187
132
|
|
|
188
|
-
|
|
133
|
+
Extend `RouterBridgeBase` and implement the three abstract methods for your framework:
|
|
189
134
|
|
|
190
135
|
```typescript
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
**Throws:** Error if routes are invalid (malformed paths, missing state IDs, duplicates)
|
|
136
|
+
import { RouterBridgeBase } from "@xmachines/play-router";
|
|
137
|
+
import type { RoutableActor } from "@xmachines/play-router";
|
|
138
|
+
|
|
139
|
+
export class MyRouterBridge extends RouterBridgeBase {
|
|
140
|
+
private unsubscribe: (() => void) | null = null;
|
|
141
|
+
|
|
142
|
+
constructor(
|
|
143
|
+
private readonly myRouter: MyRouter,
|
|
144
|
+
actor: RoutableActor,
|
|
145
|
+
routeMap: ReturnType<typeof createRouteMap>,
|
|
146
|
+
) {
|
|
147
|
+
super(actor, routeMap);
|
|
148
|
+
}
|
|
205
149
|
|
|
206
|
-
|
|
150
|
+
// Tell the framework router to navigate to a path
|
|
151
|
+
protected navigateRouter(path: string): void {
|
|
152
|
+
this.myRouter.navigate(path);
|
|
153
|
+
}
|
|
207
154
|
|
|
208
|
-
|
|
209
|
-
|
|
155
|
+
// Subscribe to router location changes, call syncActorFromRouter on each
|
|
156
|
+
protected watchRouterChanges(): void {
|
|
157
|
+
this.unsubscribe = this.myRouter.subscribe((location) => {
|
|
158
|
+
this.syncActorFromRouter(location.pathname, location.search);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
210
161
|
|
|
211
|
-
|
|
162
|
+
// Unsubscribe from router location changes
|
|
163
|
+
protected unwatchRouterChanges(): void {
|
|
164
|
+
this.unsubscribe?.();
|
|
165
|
+
this.unsubscribe = null;
|
|
166
|
+
}
|
|
212
167
|
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
|
|
168
|
+
// Provide the router's current path for initial deep-link sync
|
|
169
|
+
protected override getInitialRouterPath(): string {
|
|
170
|
+
return this.myRouter.state.location.pathname;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
216
173
|
|
|
217
|
-
|
|
218
|
-
|
|
174
|
+
// Usage
|
|
175
|
+
const routeMap = createRouteMap(machine);
|
|
176
|
+
const bridge = new MyRouterBridge(myRouter, actor, routeMap);
|
|
177
|
+
bridge.connect();
|
|
178
|
+
// ...
|
|
179
|
+
bridge.disconnect();
|
|
219
180
|
```
|
|
220
181
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
Low-level BFS traversal of state machine graph:
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
const visits = crawlMachine(machine: AnyStateMachine): StateVisit[];
|
|
227
|
-
```
|
|
182
|
+
## API Summary
|
|
228
183
|
|
|
229
|
-
|
|
184
|
+
### Route Extraction
|
|
230
185
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
186
|
+
| Export | Description |
|
|
187
|
+
| ---------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
188
|
+
| `extractMachineRoutes(machine)` | Convert an XState machine to a `RouteTree` with bidirectional state ID ↔ path maps |
|
|
189
|
+
| `createRouteMap(machine, options?)` | Build a `RouteMap` directly from a machine (preferred form for adapters) |
|
|
190
|
+
| `createRouteMapFromTree(tree, options?)` | Build a `RouteMap` from an already-extracted `RouteTree` |
|
|
191
|
+
| `buildRouteTree(routes)` | Build a `RouteTree` from an array of `RouteInfo` objects |
|
|
192
|
+
| `machineToGraph(machine)` | Convert a machine to a typed `@statelyai/graph` `Graph` for graph algorithm access |
|
|
234
193
|
|
|
235
|
-
**
|
|
194
|
+
> **Graph shape under XState v6:** machines wired by `formatPlayRouteTransitions` expose their route navigation as statically-targeted `xstate.route` edges (one per routed state) plus a single dynamic `play.route` forwarder edge — tooling that previously filtered for per-route `play.route` edges should query `xstate.route` instead. Edge data marks guard presence with `guarded: true`; guard _names_ are unrecoverable under v6 (`guardType` is never populated).
|
|
236
195
|
|
|
237
|
-
|
|
238
|
-
import { crawlMachine } from "@xmachines/play-router";
|
|
196
|
+
### Route Matching
|
|
239
197
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
```
|
|
198
|
+
| Export | Description |
|
|
199
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------ |
|
|
200
|
+
| `RouteMap` | Bidirectional `stateId ↔ path` lookup class; supports O(1) exact and O(k) pattern matching |
|
|
201
|
+
| `findRouteById(tree, id)` | Look up a `RouteNode` by state ID |
|
|
202
|
+
| `findRouteByPath(tree, path)` | Look up a `RouteNode` by URL path (supports dynamic patterns) |
|
|
246
203
|
|
|
247
204
|
### Query Utilities
|
|
248
205
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
206
|
+
| Export | Description |
|
|
207
|
+
| ------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
208
|
+
| `getRoutableRoutes(tree)` | All routable `RouteNode`s as a flat array |
|
|
209
|
+
| `getNavigableRoutes(tree, stateId)` | Child routes reachable from a state (hierarchical + transition-reachable) |
|
|
210
|
+
| `routeExists(tree, path)` | Check whether a path is registered in the tree |
|
|
211
|
+
| `getTransitionReachableRoutes(graph, stateId)` | Route paths reachable via XState transitions from a state |
|
|
212
|
+
| `isRouteReachable(graph, fromStateId, toStateId)` | Check whether a transition path exists between two states |
|
|
213
|
+
|
|
214
|
+
### Router Bridge
|
|
215
|
+
|
|
216
|
+
| Export | Description |
|
|
217
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
218
|
+
| `RouterBridgeBase` | Abstract base class for framework router adapters; implements `RouterBridge` protocol |
|
|
219
|
+
| `sanitizePathname(path)` | Normalize a raw pathname; returns `null` for paths > 2048 chars or malformed input |
|
|
220
|
+
| `buildPlayRouteEvent(options)` | Build a `PlayRouteEvent` from a pathname + route-map match result |
|
|
221
|
+
| `extractRouteParams(pathname, pattern)` | Extract path parameters from a URL using URLPattern |
|
|
222
|
+
| `extractQuery(search)` | Extract query parameters from a URL search string |
|
|
223
|
+
|
|
224
|
+
### Validation
|
|
225
|
+
|
|
226
|
+
| Export | Description |
|
|
227
|
+
| ---------------------------------------- | ----------------------------------------------------- |
|
|
228
|
+
| `validateRouteFormat(route, stateId)` | Assert route path is non-empty |
|
|
229
|
+
| `validateStateExists(stateId, stateIds)` | Assert a state ID is present in the machine graph |
|
|
230
|
+
| `detectDuplicateRoutes(routes)` | Throw if any two states resolve to the same full path |
|
|
231
|
+
|
|
232
|
+
### Key Types
|
|
233
|
+
|
|
234
|
+
| Export | Description |
|
|
235
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
236
|
+
| `RouterBridge` | Interface for `connect()` / `disconnect()` lifecycle |
|
|
237
|
+
| `RouteTree` | Hierarchical tree with `root`, `byStateId`, `byPath`, and optional `graph` |
|
|
238
|
+
| `RouteNode` | Single node in the tree with `id`, `path`, `fullPath`, `stateId`, `children`, `parent` |
|
|
239
|
+
| `RouteInfo` | Flat route descriptor extracted from a state node |
|
|
240
|
+
| `PlayRouteEvent` | Routing event `{ type: "play.route", to, params?, query? }` |
|
|
241
|
+
| `RoutableActor` | Minimal actor interface required by `RouterBridgeBase` — `currentRoute`, `initialRoute`, and `send(PlayRouteEvent)` |
|
|
242
|
+
| `PlayActor` | Full actor interface used by `PlayRouterProvider` — extends `RoutableActor` with `currentView` (`Routable + Viewable`) |
|
|
243
|
+
| `RouteMapping` | `{ stateId, path }` pair used to build a `RouteMap` |
|
|
244
|
+
| `RouteMapping as BaseRouteMapping` | Alias for `RouteMapping` (backwards-compat re-export) |
|
|
245
|
+
| `MachineGraph` | Typed `@statelyai/graph` Graph with `MachineNodeData` / `MachineEdgeData` |
|
|
246
|
+
| `WindowLike` | Injectable minimal `window` interface for SSR / testing |
|
|
247
|
+
| `LocationLike` | Injectable minimal `location` interface for SSR / testing |
|
|
248
|
+
|
|
249
|
+
### Errors (subpath `@xmachines/play-router/errors`)
|
|
250
|
+
|
|
251
|
+
| Class | Code | When thrown |
|
|
252
|
+
| ---------------------------- | --------------------------------------- | ----------------------------------------------------------------- |
|
|
253
|
+
| `RouterSyncError` | `PLAY_ROUTER_SYNC_FAILED` | `syncActorFromRouter()` fails to send a `play.route` event |
|
|
254
|
+
| `DuplicateBridgeError` | `PLAY_ROUTER_DUPLICATE_BRIDGE` | A second bridge tries to connect to an actor that already has one |
|
|
255
|
+
| `URLPatternUnavailableError` | `PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE` | URLPattern API is absent and no polyfill is loaded |
|
|
256
|
+
| `InvalidRoutePatternError` | `PLAY_ROUTE_MAP_INVALID_PATTERN` | A route pattern string is rejected by the URLPattern constructor |
|
|
257
|
+
| `EmptyRoutePathError` | `PLAY_ROUTE_EMPTY_PATH` | A state declares `meta.route: ""` |
|
|
258
|
+
| `InvalidStateIdError` | `PLAY_ROUTE_INVALID_STATE_ID` | A route references a state ID not in the machine graph |
|
|
259
|
+
| `DuplicateRoutePathError` | `PLAY_ROUTE_DUPLICATE_PATH` | Two or more states share the same URL path |
|
|
260
|
+
| `UnknownStateTypeError` | `PLAY_ROUTE_UNKNOWN_STATE_TYPE` | A state node has an unrecognised XState `.type` value |
|
|
260
261
|
|
|
261
262
|
```typescript
|
|
262
|
-
import {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
id: "settings",
|
|
278
|
-
meta: { route: "/settings/:section?", view: { component: "Settings" } }, // Optional parameter
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const tree = extractMachineRoutes(machine);
|
|
284
|
-
|
|
285
|
-
// Bidirectional mapping
|
|
286
|
-
const profileById = tree.byId.get("profile");
|
|
287
|
-
console.log(profileById?.path); // "/profile/:userId"
|
|
288
|
-
|
|
289
|
-
const profileByPath = tree.byPath.get("/profile/user123");
|
|
290
|
-
console.log(profileByPath?.id); // "profile"
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
### Hierarchical Route Tree
|
|
294
|
-
|
|
295
|
-
```typescript
|
|
296
|
-
import { extractMachineRoutes, getNavigableRoutes } from "@xmachines/play-router";
|
|
297
|
-
|
|
298
|
-
const machine = createMachine({
|
|
299
|
-
initial: "app",
|
|
300
|
-
states: {
|
|
301
|
-
app: {
|
|
302
|
-
id: "app",
|
|
303
|
-
meta: { route: "/", view: { component: "AppShell" } },
|
|
304
|
-
initial: "dashboard",
|
|
305
|
-
states: {
|
|
306
|
-
dashboard: {
|
|
307
|
-
id: "dashboard",
|
|
308
|
-
meta: { route: "/dashboard", view: { component: "Dashboard" } },
|
|
309
|
-
initial: "overview",
|
|
310
|
-
states: {
|
|
311
|
-
overview: {
|
|
312
|
-
id: "overview",
|
|
313
|
-
meta: { route: "/overview", view: { component: "Overview" } },
|
|
314
|
-
},
|
|
315
|
-
analytics: {
|
|
316
|
-
id: "analytics",
|
|
317
|
-
meta: { route: "/analytics", view: { component: "Analytics" } },
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
const tree = extractMachineRoutes(machine);
|
|
327
|
-
|
|
328
|
-
// Get child routes
|
|
329
|
-
const dashboardChildren = getNavigableRoutes(tree, "dashboard");
|
|
330
|
-
console.log(dashboardChildren.map((r) => r.id)); // ["overview", "analytics"]
|
|
331
|
-
|
|
332
|
-
// Route inheritance
|
|
333
|
-
const analyticsRoute = tree.byId.get("analytics");
|
|
334
|
-
console.log(analyticsRoute?.path); // "/dashboard/analytics" (inherited parent path)
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
### Pattern Matching
|
|
338
|
-
|
|
339
|
-
```typescript
|
|
340
|
-
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
341
|
-
|
|
342
|
-
const machine = createMachine({
|
|
343
|
-
states: {
|
|
344
|
-
user: {
|
|
345
|
-
id: "user",
|
|
346
|
-
meta: { route: "/user/:userId", view: { component: "User" } }, // Required parameter
|
|
347
|
-
},
|
|
348
|
-
settings: {
|
|
349
|
-
id: "settings",
|
|
350
|
-
meta: { route: "/settings/:section?", view: { component: "Settings" } }, // Optional parameter
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
const tree = extractMachineRoutes(machine);
|
|
356
|
-
|
|
357
|
-
// Pattern matching for actual URLs
|
|
358
|
-
const userRoute = tree.byPath.get("/user/user123");
|
|
359
|
-
console.log(userRoute?.id); // "user"
|
|
360
|
-
|
|
361
|
-
const settingsDefault = tree.byPath.get("/settings");
|
|
362
|
-
console.log(settingsDefault?.id); // "settings" (optional param)
|
|
363
|
-
|
|
364
|
-
const settingsProfile = tree.byPath.get("/settings/profile");
|
|
365
|
-
console.log(settingsProfile?.id); // "settings" (with param)
|
|
263
|
+
import {
|
|
264
|
+
RouterSyncError,
|
|
265
|
+
DuplicateBridgeError,
|
|
266
|
+
URLPatternUnavailableError,
|
|
267
|
+
} from "@xmachines/play-router/errors";
|
|
268
|
+
|
|
269
|
+
try {
|
|
270
|
+
bridge.connect();
|
|
271
|
+
} catch (err) {
|
|
272
|
+
if (err instanceof DuplicateBridgeError) {
|
|
273
|
+
// Actor already bridged — call disconnect() first
|
|
274
|
+
} else if (err instanceof RouterSyncError) {
|
|
275
|
+
console.error("Router sync failed:", err.message, err.cause);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
366
278
|
```
|
|
367
279
|
|
|
368
280
|
## Route Configuration
|
|
369
281
|
|
|
370
|
-
###
|
|
282
|
+
### `meta.route` patterns
|
|
371
283
|
|
|
372
|
-
|
|
373
|
-
states: {
|
|
374
|
-
dashboard: {
|
|
375
|
-
id: "dashboard", // Required for bidirectional lookup
|
|
376
|
-
meta: {
|
|
377
|
-
route: "/dashboard", // URL path - marks state as routable
|
|
378
|
-
},
|
|
379
|
-
},
|
|
380
|
-
}
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### Alternative Pattern
|
|
284
|
+
Routes are declared on XState state nodes via the `meta.route` field. The machine's `setup({ schemas })` must declare a matching `meta` schema (e.g. `meta: types<{ route?: string | { path: string; title?: string } }>()`) — without one, XState v6 types state `meta` as `never`:
|
|
384
285
|
|
|
385
286
|
```typescript
|
|
386
287
|
states: {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
288
|
+
home: {
|
|
289
|
+
id: "home",
|
|
290
|
+
meta: { route: "/" }, // static route
|
|
291
|
+
},
|
|
292
|
+
profile: {
|
|
293
|
+
id: "profile",
|
|
294
|
+
meta: { route: "/profile/:userId" }, // required parameter
|
|
295
|
+
},
|
|
296
|
+
settings: {
|
|
297
|
+
id: "settings",
|
|
298
|
+
meta: { route: "/settings/:section?" }, // optional parameter
|
|
299
|
+
},
|
|
300
|
+
docs: {
|
|
301
|
+
id: "docs",
|
|
302
|
+
meta: { route: { path: "/docs", title: "Documentation" } }, // object form
|
|
303
|
+
},
|
|
393
304
|
}
|
|
394
305
|
```
|
|
395
306
|
|
|
396
|
-
###
|
|
307
|
+
### Relative vs absolute paths
|
|
308
|
+
|
|
309
|
+
Child routes with a leading `/` are absolute (do not inherit the parent path). Without a leading `/`, they resolve relative to their nearest routable ancestor:
|
|
397
310
|
|
|
398
311
|
```typescript
|
|
399
312
|
states: {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
},
|
|
313
|
+
dashboard: {
|
|
314
|
+
id: "dashboard",
|
|
315
|
+
meta: { route: "/dashboard" },
|
|
316
|
+
states: {
|
|
317
|
+
overview: {
|
|
318
|
+
id: "overview",
|
|
319
|
+
meta: { route: "/overview" }, // absolute → fullPath: "/overview"
|
|
320
|
+
},
|
|
321
|
+
stats: {
|
|
322
|
+
id: "stats",
|
|
323
|
+
meta: { route: "stats" }, // relative → fullPath: "/dashboard/stats"
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
},
|
|
415
327
|
}
|
|
416
328
|
```
|
|
417
329
|
|
|
418
|
-
|
|
330
|
+
Always use `node.fullPath` (never `node.path`) for browser URL matching and route map construction.
|
|
419
331
|
|
|
420
|
-
|
|
421
|
-
meta: {
|
|
422
|
-
route: "/profile/:userId", // Required parameter
|
|
423
|
-
route: "/settings/:section?", // Optional parameter
|
|
424
|
-
route: "/docs/:category/:page", // Multiple parameters
|
|
425
|
-
view: { component: "AnyView" },
|
|
426
|
-
}
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
**Parameter substitution:** Values extracted from context or event params (handled by play-xstate adapter).
|
|
332
|
+
## Testing
|
|
430
333
|
|
|
431
|
-
|
|
334
|
+
```bash
|
|
335
|
+
# Run tests for this package
|
|
336
|
+
pnpm --filter @xmachines/play-router test
|
|
432
337
|
|
|
433
|
-
|
|
338
|
+
# Watch mode
|
|
339
|
+
pnpm --filter @xmachines/play-router run test:watch
|
|
340
|
+
```
|
|
434
341
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
342
|
+
A router bridge contract test suite for adapter authors lives in
|
|
343
|
+
`@xmachines/play-router-shared` (it drives a real actor, so it sits one layer
|
|
344
|
+
above this package to keep `@xmachines/play-router` free of an actor-runtime
|
|
345
|
+
dependency):
|
|
439
346
|
|
|
440
|
-
|
|
347
|
+
```typescript
|
|
348
|
+
import { runBridgeContractTests } from "@xmachines/play-router-shared/test/router-bridge-contract.js";
|
|
441
349
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
350
|
+
runBridgeContractTests({
|
|
351
|
+
name: "MyRouterBridge",
|
|
352
|
+
createHarness(initialPath) {
|
|
353
|
+
// return ContractHarness with bridge, actor, simulateNavigation, getLastNavigatedPath
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
```
|
|
445
357
|
|
|
446
358
|
## Related Packages
|
|
447
359
|
|
|
448
|
-
- **[@xmachines/play
|
|
449
|
-
- **[@xmachines/play-
|
|
450
|
-
- **[@xmachines/play-
|
|
451
|
-
- **[@xmachines/play](../play/README.md)**
|
|
360
|
+
- **[@xmachines/play](../play/README.md)** — Core protocol types (`PlayEvent`, `PlayError`)
|
|
361
|
+
- **[@xmachines/play-actor](../play-actor/README.md)** — Abstract actor base class (`AbstractActor`, `Routable`); all `AbstractActor` subclasses satisfy `RoutableActor` structurally
|
|
362
|
+
- **[@xmachines/play-signals](../play-signals/README.md)** — TC39 Signals polyfill used for actor route observation
|
|
363
|
+
- **[@xmachines/play-xstate](../play-xstate/README.md)** — XState v6 logic adapter that integrates with route trees
|
|
364
|
+
- **[@xmachines/play-tanstack-router](../play-tanstack-router/README.md)** — Shared TanStack Router bridge base (framework-agnostic)
|
|
365
|
+
- **[@xmachines/play-tanstack-react-router](../play-tanstack-react-router/README.md)** — TanStack Router adapter (React)
|
|
366
|
+
- **[@xmachines/play-tanstack-solid-router](../play-tanstack-solid-router/README.md)** — TanStack Router adapter (SolidJS)
|
|
367
|
+
- **[@xmachines/play-react-router](../play-react-router/README.md)** — React Router v7 adapter
|
|
368
|
+
- **[@xmachines/play-vue-router](../play-vue-router/README.md)** — Vue Router adapter
|
|
369
|
+
- **[@xmachines/play-solid-router](../play-solid-router/README.md)** — SolidJS Router adapter
|
|
452
370
|
|
|
453
371
|
## License
|
|
454
372
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
This work is licensed under the terms of the MIT license.
|
|
458
|
-
For a copy, see <https://opensource.org/licenses/MIT>.
|
|
373
|
+
MIT — see [LICENSE](LICENSE).
|
|
459
374
|
|
|
460
375
|
## Classes
|
|
461
376
|
|
|
462
|
-
- [
|
|
377
|
+
- [RouteMap](classes/RouteMap.md)
|
|
463
378
|
- [RouterBridgeBase](classes/RouterBridgeBase.md)
|
|
464
379
|
|
|
465
380
|
## Interfaces
|
|
466
381
|
|
|
467
|
-
- [
|
|
468
|
-
- [
|
|
469
|
-
- [
|
|
470
|
-
- [
|
|
382
|
+
- [BuildPlayRouteEventOptions](interfaces/BuildPlayRouteEventOptions.md)
|
|
383
|
+
- [LocationLike](interfaces/LocationLike.md)
|
|
384
|
+
- [MachineEdgeData](interfaces/MachineEdgeData.md)
|
|
385
|
+
- [MachineNodeData](interfaces/MachineNodeData.md)
|
|
386
|
+
- [PlayActor](interfaces/PlayActor.md)
|
|
471
387
|
- [PlayRouteEvent](interfaces/PlayRouteEvent.md)
|
|
388
|
+
- [ResolvedRoutePath](interfaces/ResolvedRoutePath.md)
|
|
389
|
+
- [RoutableActor](interfaces/RoutableActor.md)
|
|
472
390
|
- [RouteInfo](interfaces/RouteInfo.md)
|
|
473
|
-
- [
|
|
391
|
+
- [RouteMapOptions](interfaces/RouteMapOptions.md)
|
|
392
|
+
- [RouteMapping](interfaces/RouteMapping.md)
|
|
393
|
+
- [RouteMatch](interfaces/RouteMatch.md)
|
|
474
394
|
- [RouteNode](interfaces/RouteNode.md)
|
|
475
395
|
- [RouteObject](interfaces/RouteObject.md)
|
|
476
396
|
- [RouterBridge](interfaces/RouterBridge.md)
|
|
477
397
|
- [RouteTree](interfaces/RouteTree.md)
|
|
478
|
-
- [
|
|
479
|
-
- [
|
|
398
|
+
- [RouteWatcherHandle](interfaces/RouteWatcherHandle.md)
|
|
399
|
+
- [WindowLike](interfaces/WindowLike.md)
|
|
480
400
|
|
|
481
401
|
## Type Aliases
|
|
482
402
|
|
|
403
|
+
- [MachineGraph](type-aliases/MachineGraph.md)
|
|
483
404
|
- [RouteMetadata](type-aliases/RouteMetadata.md)
|
|
484
405
|
|
|
485
406
|
## Functions
|
|
486
407
|
|
|
408
|
+
- [buildPlayRouteEvent](functions/buildPlayRouteEvent.md)
|
|
487
409
|
- [buildRouteTree](functions/buildRouteTree.md)
|
|
488
|
-
- [connectRouter](functions/connectRouter.md)
|
|
489
|
-
- [crawlMachine](functions/crawlMachine.md)
|
|
490
|
-
- [createBrowserHistory](functions/createBrowserHistory.md)
|
|
491
410
|
- [createRouteMap](functions/createRouteMap.md)
|
|
492
|
-
- [
|
|
411
|
+
- [createRouteMapFromTree](functions/createRouteMapFromTree.md)
|
|
493
412
|
- [detectDuplicateRoutes](functions/detectDuplicateRoutes.md)
|
|
494
413
|
- [extractMachineRoutes](functions/extractMachineRoutes.md)
|
|
495
|
-
- [
|
|
414
|
+
- [extractQuery](functions/extractQuery.md)
|
|
415
|
+
- [extractRouteParams](functions/extractRouteParams.md)
|
|
496
416
|
- [findRouteById](functions/findRouteById.md)
|
|
497
417
|
- [findRouteByPath](functions/findRouteByPath.md)
|
|
498
418
|
- [getNavigableRoutes](functions/getNavigableRoutes.md)
|
|
499
419
|
- [getRoutableRoutes](functions/getRoutableRoutes.md)
|
|
420
|
+
- [getTransitionReachableRoutes](functions/getTransitionReachableRoutes.md)
|
|
421
|
+
- [isRouteReachable](functions/isRouteReachable.md)
|
|
422
|
+
- [machineToGraph](functions/machineToGraph.md)
|
|
500
423
|
- [routeExists](functions/routeExists.md)
|
|
424
|
+
- [sanitizePathname](functions/sanitizePathname.md)
|
|
501
425
|
- [validateRouteFormat](functions/validateRouteFormat.md)
|
|
502
426
|
- [validateStateExists](functions/validateStateExists.md)
|
|
427
|
+
|
|
428
|
+
## References
|
|
429
|
+
|
|
430
|
+
### BaseRouteMapping
|
|
431
|
+
|
|
432
|
+
Renames and re-exports [RouteMapping](interfaces/RouteMapping.md)
|