@xmachines/docs 1.0.0-beta.25 → 1.0.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/@xmachines/play/classes/PlayError.md +10 -4
- package/api/@xmachines/play/type-aliases/PlayEvent.md +2 -2
- package/api/@xmachines/play-actor/README.md +4 -0
- package/api/@xmachines/play-actor/classes/AbstractActor.md +49 -92
- package/api/@xmachines/play-actor/functions/typedSpec.md +57 -0
- package/api/@xmachines/play-actor/interfaces/PlaySpec.md +9 -18
- package/api/@xmachines/play-actor/interfaces/Routable.md +5 -21
- package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +6 -6
- package/api/@xmachines/play-actor/interfaces/Viewable.md +5 -6
- package/api/@xmachines/play-dom/README.md +24 -8
- 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/defineRegistry.md +61 -0
- package/api/@xmachines/play-dom/functions/renderSpec.md +29 -12
- package/api/@xmachines/play-dom/interfaces/ComponentContext.md +62 -0
- package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +9 -9
- package/api/@xmachines/play-dom/interfaces/DefineRegistryOptions.md +25 -0
- package/api/@xmachines/play-dom/interfaces/DefineRegistryResult.md +18 -0
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +13 -10
- package/api/@xmachines/play-dom/interfaces/EventHandle.md +29 -0
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +5 -5
- package/api/@xmachines/play-dom/type-aliases/ComponentFn.md +53 -0
- package/api/@xmachines/play-dom/type-aliases/ComponentRegistry.md +21 -0
- package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +16 -3
- package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +5 -2
- package/api/@xmachines/play-dom-router/README.md +10 -0
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +18 -46
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createRouteMap.md +38 -0
- package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +16 -16
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +16 -16
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +6 -6
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +119 -0
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +114 -0
- package/api/@xmachines/play-dom-router/interfaces/RouteMapLike.md +50 -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 +6 -6
- package/api/@xmachines/play-dom-router/type-aliases/RoutableActor.md +9 -0
- package/api/@xmachines/play-dom-router-demo/README.md +46 -51
- package/api/@xmachines/play-react/README.md +4 -4
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +31 -5
- package/api/@xmachines/play-react/functions/defineRegistry.md +2 -0
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/useBoundProp.md +2 -0
- package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
- package/api/@xmachines/play-react/functions/useStateBinding.md +2 -0
- package/api/@xmachines/play-react/interfaces/ComponentContext.md +2 -0
- 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/PlayRendererProps.md +7 -7
- package/api/@xmachines/play-react/type-aliases/ComponentFn.md +2 -0
- package/api/@xmachines/play-react/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-react-router/README.md +5 -1
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +102 -25
- package/api/@xmachines/play-react-router/classes/RouteMap.md +17 -33
- package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +8 -1
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +21 -11
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +7 -7
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +18 -8
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-router/README.md +42 -5
- package/api/@xmachines/play-router/classes/BaseRouteMap.md +12 -19
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +100 -25
- 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/createRouteMapFromMachine.md +38 -0
- package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +45 -0
- 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 +46 -0
- 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 +27 -0
- 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 +8 -8
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
- package/api/@xmachines/play-router/interfaces/RouteMap.md +4 -4
- package/api/@xmachines/play-router/interfaces/{BaseRouteMapping.md → RouteMapping.md} +5 -5
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteNode.md +12 -12
- 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 +65 -0
- 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/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/namespaces/Signal/classes/Computed.md +6 -0
- package/api/@xmachines/play-signals/namespaces/Signal/classes/State.md +8 -0
- package/api/@xmachines/play-signals/namespaces/Signal/interfaces/Options.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/classes/Watcher.md +10 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/currentComputed.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSinks.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSources.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSinks.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSources.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/untrack.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/unwatched.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/watched.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isComputed.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isState.md +2 -0
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isWatcher.md +2 -0
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
- package/api/@xmachines/play-solid/README.md +4 -4
- package/api/@xmachines/play-solid/functions/defineRegistry.md +2 -0
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/functions/useStateBinding.md +2 -0
- package/api/@xmachines/play-solid/interfaces/ComponentContext.md +2 -0
- package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +7 -7
- package/api/@xmachines/play-solid/type-aliases/ComponentFn.md +2 -0
- package/api/@xmachines/play-solid/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-solid-router/README.md +2 -2
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +13 -26
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +121 -46
- package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +15 -9
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +47 -92
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +19 -6
- 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 +21 -18
- package/api/@xmachines/play-solid-router-demo/README.md +25 -28
- package/api/@xmachines/play-svelte/README.md +28 -0
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +2 -0
- package/api/@xmachines/play-svelte/interfaces/BaseComponentProps.md +2 -0
- package/api/@xmachines/play-svelte/interfaces/ComponentContext.md +2 -0
- package/api/@xmachines/play-svelte/interfaces/PlayRendererProps.md +9 -9
- package/api/@xmachines/play-svelte/type-aliases/ComponentFn.md +2 -0
- package/api/@xmachines/play-svelte/type-aliases/PlayRenderer.md +2 -0
- package/api/@xmachines/play-svelte/variables/PlayRenderer.md +2 -0
- package/api/@xmachines/play-svelte-spa-router/README.md +1 -0
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +13 -26
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +14 -1
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +23 -4
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +6 -5
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +10 -10
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +20 -5
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +65 -0
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-svelte-spa-router-demo/README.md +119 -12
- package/api/@xmachines/play-sveltekit-router/README.md +2 -1
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +46 -24
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +14 -1
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +23 -4
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +6 -5
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +27 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +10 -10
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +20 -5
- 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-sveltekit-router-demo/README.md +120 -12
- package/api/@xmachines/play-tanstack-react-router/README.md +5 -3
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +17 -33
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +93 -25
- 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 +21 -11
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +18 -8
- 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 +13 -19
- package/api/@xmachines/play-tanstack-react-router-demo/README.md +23 -29
- package/api/@xmachines/play-tanstack-solid-router/README.md +8 -8
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +13 -26
- package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +101 -36
- package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +15 -9
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +13 -9
- 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 +23 -24
- package/api/@xmachines/play-tanstack-solid-router-demo/README.md +25 -26
- package/api/@xmachines/play-vue/README.md +4 -4
- package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-vue/functions/useActor.md +1 -1
- package/api/@xmachines/play-vue/functions/useStateBinding.md +2 -0
- package/api/@xmachines/play-vue/interfaces/ComponentContext.md +2 -0
- package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +5 -5
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentFn.md +2 -0
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +4 -3
- 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 +2 -2
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +18 -108
- package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +44 -104
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +127 -62
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +19 -7
- 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-vue-router-demo/README.md +47 -40
- package/api/@xmachines/play-xstate/README.md +15 -15
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +46 -30
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +20 -15
- 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 +2 -2
- 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 +14 -12
- 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/functions/defineXmVitestConfig.md +3 -7
- package/api/@xmachines/shared/functions/xmAliases.md +1 -1
- package/api/README.md +4 -4
- package/api/llms.txt +3 -3
- package/examples/README.md +50 -32
- package/examples/basic-state-machine.md +75 -31
- package/examples/form-validation.md +199 -127
- package/examples/multi-router-integration.md +312 -230
- package/examples/routing-patterns.md +243 -187
- package/examples/traffic-light.md +114 -65
- package/guides/README.md +29 -15
- package/guides/getting-started.md +224 -144
- package/guides/installation.md +153 -213
- package/package.json +2 -2
- package/api/@xmachines/play-tanstack-react-router/functions/extractParams.md +0 -38
- package/api/@xmachines/play-tanstack-react-router/functions/extractQueryParams.md +0 -33
|
@@ -1,23 +1,131 @@
|
|
|
1
1
|
[Documentation](../../README.md) / @xmachines/play-sveltekit-router-demo
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# SvelteKit Router Demo
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Svelte 5 + SvelteKit router adapter integration demo for the XMachines Play architecture using browser pathname URL routing.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## What This Demonstrates
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- Shared auth machine reused without framework-specific business logic
|
|
10
|
+
- `connectRouter` pathname URL ↔ actor sync via `@xmachines/play-sveltekit-router`
|
|
11
|
+
- Shell-driven rendering via `PlayRenderer` with actor-authoritative navigation
|
|
12
|
+
- Canonical TC39 Signals lifecycle integrated with Svelte 5 runes
|
|
13
|
+
- Non-browser invariant tests plus browser E2E coverage
|
|
11
14
|
|
|
12
|
-
##
|
|
15
|
+
## Running the Demo
|
|
16
|
+
|
|
17
|
+
From the repository root:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
npm run dev -w packages/play-sveltekit-router/examples/demo
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Then open `http://localhost:5173`.
|
|
25
|
+
|
|
26
|
+
## Step-by-Step Code Flow
|
|
27
|
+
|
|
28
|
+
Use this order to understand the implementation:
|
|
29
|
+
|
|
30
|
+
1. `src/main.ts` mounts `App.svelte` and registers HMR cleanup via `cleanupDemo`.
|
|
31
|
+
2. `src/lib/router.ts` creates the actor, builds the registry, calls `createRouteMap(authMachine)`, and wires `connectRouter({ actor, routeMap })`.
|
|
32
|
+
3. `connectRouter` synchronizes browser pathname changes with the actor via `play.route` events and reflects actor-approved routes back to the pathname URL.
|
|
33
|
+
4. `src/App.svelte` imports the singleton `actor` and `registry` from `src/lib/router.ts` and delegates to the shared `Shell.svelte`.
|
|
34
|
+
5. `Shell.svelte` renders `<PlayRenderer>` with the actor and registry and provides the shared UI shell (nav, debug panel).
|
|
35
|
+
6. Browser tests in `test/browser/` validate startup and auth route transitions.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// src/lib/router.ts (shape)
|
|
39
|
+
const createDemoPlayer = definePlayer({ machine: authMachine });
|
|
40
|
+
export const actor = createDemoPlayer();
|
|
41
|
+
actor.start();
|
|
42
|
+
|
|
43
|
+
export const routeMap = createRouteMap(authMachine);
|
|
44
|
+
export const disconnectRouter = connectRouter({ actor, routeMap });
|
|
45
|
+
|
|
46
|
+
export function cleanupDemo(): void {
|
|
47
|
+
disconnectRouter();
|
|
48
|
+
actor.stop();
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```svelte
|
|
53
|
+
<!-- src/App.svelte (shape) -->
|
|
54
|
+
<script lang="ts">
|
|
55
|
+
import Shell from "@xmachines/play-svelte-demo/src/components/Shell.svelte";
|
|
56
|
+
import { actor, registry } from "./lib/router.js";
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<Shell {actor} {registry} />
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```svelte
|
|
63
|
+
<!-- Shell.svelte — sending events (shape) -->
|
|
64
|
+
<PlayRenderer
|
|
65
|
+
actor={props.actor}
|
|
66
|
+
registry={props.registry}
|
|
67
|
+
actions={{ login: "auth.login", logout: "auth.logout" }}
|
|
68
|
+
/>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Key Files
|
|
72
|
+
|
|
73
|
+
- `src/main.ts` - Svelte app mount and HMR cleanup registration
|
|
74
|
+
- `src/lib/router.ts` - actor creation, registry construction, route map, and `connectRouter` wiring
|
|
75
|
+
- `src/lib/navigation.ts` - SvelteKit navigation helpers for pathname observation
|
|
76
|
+
- `src/App.svelte` - minimal root component delegating to shared `Shell.svelte`
|
|
77
|
+
- `test/library-pattern.test.ts` - architecture boundary and invariant assertions
|
|
78
|
+
- `test/browser/shared-demo.browser.test.ts` - browser startup and auth route flow coverage
|
|
79
|
+
|
|
80
|
+
## State Machine & Architecture Details
|
|
81
|
+
|
|
82
|
+
The demo utilizes XMachines architectural invariants:
|
|
83
|
+
|
|
84
|
+
1. **Actor Authority:** When a user clicks a nav link, the browser pathname changes. `connectRouter` intercepts this, translates it to a `play.route` event, and sends it to the actor. The actor evaluates guards (e.g. `isAuthenticated`) and transitions to the appropriate state.
|
|
85
|
+
2. **Passive Infrastructure:** The SvelteKit router adapter does not execute business logic. The actor dictates whether navigation is permitted. The Svelte application only renders the state.
|
|
86
|
+
3. **Signal-Only Reactivity:** The bridge leverages Svelte 5 rune reactivity internally to react precisely when actor signals update, without ad-hoc `$state` stores for business logic.
|
|
87
|
+
|
|
88
|
+
## Watcher Lifecycle and Cleanup Contract
|
|
89
|
+
|
|
90
|
+
This demo follows the canonical watcher lifecycle used across all `@xmachines` framework adapters:
|
|
91
|
+
|
|
92
|
+
1. `notify`
|
|
93
|
+
2. `queueMicrotask`
|
|
94
|
+
3. `getPending()`
|
|
95
|
+
4. Read actor signals and project Svelte-local render state
|
|
96
|
+
5. Re-arm with `watch()`/`watch(...signals)`
|
|
97
|
+
|
|
98
|
+
Watcher notifications are one-shot. Cleanup is explicit: `cleanupDemo()` calls `disconnectRouter()` and `actor.stop()` during HMR disposal, preventing memory leaks and ghost subscriptions.
|
|
99
|
+
|
|
100
|
+
## Adapter Boundaries
|
|
101
|
+
|
|
102
|
+
`connectRouter` (from `@xmachines/play-sveltekit-router`) is passive infrastructure. It translates pathname URL changes into `play.route` events and reflects actor-approved route changes back to the browser pathname. Business validity remains actor-owned. The shared `Shell.svelte` from `@xmachines/play-svelte-demo` is reused to avoid duplicating view components across router demos.
|
|
103
|
+
|
|
104
|
+
## Available Scripts
|
|
105
|
+
|
|
106
|
+
These commands are defined in `package.json`:
|
|
107
|
+
|
|
108
|
+
| Command | Description |
|
|
109
|
+
| ---------------------------------------------------------------------- | -------------------------------- |
|
|
110
|
+
| `npm run dev -w packages/play-sveltekit-router/examples/demo` | Start Vite dev server |
|
|
111
|
+
| `npm run build -w packages/play-sveltekit-router/examples/demo` | Build production bundle |
|
|
112
|
+
| `npm run preview -w packages/play-sveltekit-router/examples/demo` | Preview built bundle |
|
|
113
|
+
| `npm run test -w packages/play-sveltekit-router/examples/demo` | Run Vitest test suite |
|
|
114
|
+
| `npm run test:browser -w packages/play-sveltekit-router/examples/demo` | Run browser-focused Vitest suite |
|
|
115
|
+
|
|
116
|
+
## Verification
|
|
117
|
+
|
|
118
|
+
Use these checks to validate README claims against the current demo implementation:
|
|
13
119
|
|
|
14
120
|
```bash
|
|
15
|
-
npm run
|
|
16
|
-
npm run
|
|
17
|
-
npm run test:browser -w @xmachines/play-sveltekit-router-demo
|
|
121
|
+
npm run test -w packages/play-sveltekit-router/examples/demo
|
|
122
|
+
npm run test:browser -w packages/play-sveltekit-router/examples/demo
|
|
18
123
|
```
|
|
19
124
|
|
|
20
|
-
|
|
125
|
+
Expected result: library-pattern invariant tests pass and the browser demo suite validates startup rendering and auth navigation.
|
|
126
|
+
|
|
127
|
+
## Learn More
|
|
21
128
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
129
|
+
- [SvelteKit Router package README](../play-sveltekit-router/README.md)
|
|
130
|
+
- [Svelte package README](../play-svelte/README.md)
|
|
131
|
+
- [Svelte SPA Router demo README](../play-svelte-spa-router-demo/README.md)
|
|
@@ -123,6 +123,10 @@ function createRouteMapFromTree(routeTree: RouteTree): RouteMap
|
|
|
123
123
|
|
|
124
124
|
`getStateIdByPath` returns `null` (not `undefined`) for unmatched paths.
|
|
125
125
|
|
|
126
|
+
`createRouteMapFromTree` uses `node.fullPath` (the fully resolved absolute path) for all
|
|
127
|
+
route entries. This is correct for both flat routes (e.g. `"/login"`) and nested relative
|
|
128
|
+
routes (e.g. `meta.route: "overview"` under `"/dashboard"` resolves to `"/dashboard/overview"`).
|
|
129
|
+
|
|
126
130
|
```ts
|
|
127
131
|
const routeMap = new RouteMap([
|
|
128
132
|
{ stateId: "home", path: "/" },
|
|
@@ -166,7 +170,7 @@ interface PlayRouterProviderProps {
|
|
|
166
170
|
|
|
167
171
|
Bridge-first flow:
|
|
168
172
|
|
|
169
|
-
1. `RouterBridgeBase.connect()` performs initial actor/router synchronization.
|
|
173
|
+
1. `RouterBridgeBase.connect()` performs initial actor/router synchronization — both pathname and query string from `router.history.location` are forwarded to the actor on first connect.
|
|
170
174
|
2. Actor route updates call TanStack navigation (`router.navigate({ to })`).
|
|
171
175
|
3. TanStack history updates are subscribed and translated to `play.route` events.
|
|
172
176
|
4. Actor guards accept or reject transitions; infrastructure reflects resulting state.
|
|
@@ -214,6 +218,4 @@ Synchronizes browser URL with actor state through passive infrastructure.
|
|
|
214
218
|
- [createRouteMap](functions/createRouteMap.md)
|
|
215
219
|
- [createRouteMapFromTree](functions/createRouteMapFromTree.md)
|
|
216
220
|
- [extractMachineRoutes](functions/extractMachineRoutes.md)
|
|
217
|
-
- [extractParams](functions/extractParams.md)
|
|
218
|
-
- [extractQueryParams](functions/extractQueryParams.md)
|
|
219
221
|
- [PlayRouterProvider](functions/PlayRouterProvider.md)
|
|
@@ -2,45 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
# Class: RouteMap
|
|
4
4
|
|
|
5
|
-
Defined in: [play-tanstack-react-router/src/route-map.ts:
|
|
5
|
+
Defined in: [play-tanstack-react-router/src/route-map.ts:12](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/route-map.ts#L12)
|
|
6
6
|
|
|
7
7
|
Bidirectional route mapper for TanStack React Router.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
This class exists to provide a TanStack React Router-specific type name and to
|
|
11
|
-
allow future adapter-specific extensions without breaking the shared base.
|
|
12
|
-
|
|
13
|
-
**Inherited API:**
|
|
14
|
-
|
|
15
|
-
- `getStateIdByPath(path): string | null` — path → state ID
|
|
16
|
-
- `getPathByStateId(stateId): string | null` — state ID → path pattern
|
|
17
|
-
|
|
18
|
-
## Example
|
|
19
|
-
|
|
20
|
-
```typescript
|
|
21
|
-
const routeMap = new RouteMap([
|
|
22
|
-
{ stateId: "home", path: "/" },
|
|
23
|
-
{ stateId: "profile", path: "/profile/:userId" },
|
|
24
|
-
{ stateId: "settings", path: "/settings/:section?" },
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
routeMap.getStateIdByPath("/profile/123"); // "profile"
|
|
28
|
-
routeMap.getPathByStateId("home"); // "/"
|
|
29
|
-
```
|
|
9
|
+
Alias for [BaseRouteMap](../../play-dom-router/interfaces/RouteMap.md) from `@xmachines/play-router`.
|
|
30
10
|
|
|
31
11
|
## Extends
|
|
32
12
|
|
|
33
|
-
- [`
|
|
13
|
+
- [`RouteMap`](../../play-dom-router/interfaces/RouteMap.md)
|
|
34
14
|
|
|
35
15
|
## Constructors
|
|
36
16
|
|
|
37
17
|
### Constructor
|
|
38
18
|
|
|
39
19
|
```ts
|
|
40
|
-
new RouteMap(mappings): RouteMap;
|
|
20
|
+
new RouteMap(mappings, options?): RouteMap;
|
|
41
21
|
```
|
|
42
22
|
|
|
43
|
-
Defined in: [play-router/src/base-route-map.ts:
|
|
23
|
+
Defined in: [play-router/src/base-route-map.ts:125](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/base-route-map.ts#L125)
|
|
44
24
|
|
|
45
25
|
Build a route map from an array of state ID ↔ path mappings.
|
|
46
26
|
|
|
@@ -50,9 +30,11 @@ buckets for efficient candidate selection.
|
|
|
50
30
|
|
|
51
31
|
#### Parameters
|
|
52
32
|
|
|
53
|
-
| Parameter
|
|
54
|
-
|
|
|
55
|
-
| `mappings`
|
|
33
|
+
| Parameter | Type | Description |
|
|
34
|
+
| -------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
35
|
+
| `mappings` | [`RouteMapping`](../interfaces/RouteMapping.md)[] | Array of `{ stateId, path }` entries. Order determines priority when multiple patterns could match the same path. |
|
|
36
|
+
| `options` | \{ `cacheSize?`: `number`; \} | Optional configuration. `options.cacheSize`: Maximum number of resolved parameterized path lookups to cache. Defaults to `500`. Increase for applications with many unique parameterized URL values (e.g. user profile pages with thousands of distinct IDs). After eviction the path falls back to the O(k) bucket pattern scan — correct but slower. Minimum effective value is `1` (QuickLRU constraint). |
|
|
37
|
+
| `options.cacheSize?` | `number` | - |
|
|
56
38
|
|
|
57
39
|
#### Returns
|
|
58
40
|
|
|
@@ -60,7 +42,9 @@ buckets for efficient candidate selection.
|
|
|
60
42
|
|
|
61
43
|
#### Inherited from
|
|
62
44
|
|
|
63
|
-
|
|
45
|
+
```ts
|
|
46
|
+
BaseRouteMap.constructor;
|
|
47
|
+
```
|
|
64
48
|
|
|
65
49
|
## Methods
|
|
66
50
|
|
|
@@ -70,7 +54,7 @@ buckets for efficient candidate selection.
|
|
|
70
54
|
getPathByStateId(stateId): string | null;
|
|
71
55
|
```
|
|
72
56
|
|
|
73
|
-
Defined in: [play-router/src/base-route-map.ts:
|
|
57
|
+
Defined in: [play-router/src/base-route-map.ts:209](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/base-route-map.ts#L209)
|
|
74
58
|
|
|
75
59
|
Look up the path pattern registered for a state ID.
|
|
76
60
|
|
|
@@ -95,7 +79,7 @@ map.getPathByStateId("missing"); // null
|
|
|
95
79
|
|
|
96
80
|
#### Inherited from
|
|
97
81
|
|
|
98
|
-
[`
|
|
82
|
+
[`RouteMap`](../../play-dom-router/interfaces/RouteMap.md).[`getPathByStateId`](../../play-dom-router/interfaces/RouteMap.md#getpathbystateid)
|
|
99
83
|
|
|
100
84
|
---
|
|
101
85
|
|
|
@@ -105,7 +89,7 @@ map.getPathByStateId("missing"); // null
|
|
|
105
89
|
getStateIdByPath(path): string | null;
|
|
106
90
|
```
|
|
107
91
|
|
|
108
|
-
Defined in: [play-router/src/base-route-map.ts:
|
|
92
|
+
Defined in: [play-router/src/base-route-map.ts:174](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/base-route-map.ts#L174)
|
|
109
93
|
|
|
110
94
|
Resolve a URL path to its mapped state ID.
|
|
111
95
|
|
|
@@ -134,4 +118,4 @@ map.getStateIdByPath("/unknown"); // null
|
|
|
134
118
|
|
|
135
119
|
#### Inherited from
|
|
136
120
|
|
|
137
|
-
[`
|
|
121
|
+
[`RouteMap`](../../play-dom-router/interfaces/RouteMap.md).[`getStateIdByPath`](../../play-dom-router/interfaces/RouteMap.md#getstateidbypath)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Class: TanStackReactRouterBridge
|
|
4
4
|
|
|
5
|
-
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:
|
|
5
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:84](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L84)
|
|
6
6
|
|
|
7
7
|
TanStack React Router adapter implementing RouterBridge protocol via RouterBridgeBase
|
|
8
8
|
|
|
@@ -47,7 +47,7 @@ new TanStackReactRouterBridge(
|
|
|
47
47
|
routeMap): TanStackReactRouterBridge;
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:
|
|
50
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:94](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L94)
|
|
51
51
|
|
|
52
52
|
Create TanStack React Router bridge
|
|
53
53
|
|
|
@@ -71,15 +71,15 @@ Create TanStack React Router bridge
|
|
|
71
71
|
|
|
72
72
|
| Property | Modifier | Type | Default value | Description | Inherited from | Defined in |
|
|
73
73
|
| --------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
-
| <a id="property-actor"></a> `actor` | `readonly` | [`AbstractActor`](../../play-actor/classes/AbstractActor.md)\<[`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\> & [`Routable`](../../play-actor/interfaces/Routable.md) | `undefined` | A `Routable` actor exposing `currentRoute` and `send`. | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`actor`](../../play-router/classes/RouterBridgeBase.md#property-actor) | [play-router/src/router-bridge-base.ts:
|
|
75
|
-
| <a id="property-hasconnectedonce"></a> `hasConnectedOnce` | `protected` | `boolean` | `false` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`hasConnectedOnce`](../../play-router/classes/RouterBridgeBase.md#property-hasconnectedonce) | [play-router/src/router-bridge-base.ts:
|
|
76
|
-
| <a id="property-isconnected"></a> `isConnected` | `protected` | `boolean` | `false` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`isConnected`](../../play-router/classes/RouterBridgeBase.md#property-isconnected) | [play-router/src/router-bridge-base.ts:
|
|
77
|
-
| <a id="property-isprocessingnavigation"></a> `isProcessingNavigation` | `protected` | `boolean` | `false` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`isProcessingNavigation`](../../play-router/classes/RouterBridgeBase.md#property-isprocessingnavigation) | [play-router/src/router-bridge-base.ts:
|
|
78
|
-
| <a id="property-lastsyncedpath"></a> `lastSyncedPath` | `protected` | `string` \| `null` | `null` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`lastSyncedPath`](../../play-router/classes/RouterBridgeBase.md#property-lastsyncedpath) | [play-router/src/router-bridge-base.ts:
|
|
79
|
-
| <a id="property-routemap"></a> `routeMap` | `readonly` | `object` | `undefined` | Bidirectional route map for `stateId ↔ path` resolution. Provide `getStateIdByPath` and `getPathByStateId`. Framework adapters typically wrap the result of `createRouteMap()` or an equivalent. | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`routeMap`](../../play-router/classes/RouterBridgeBase.md#property-routemap) | [play-router/src/router-bridge-base.ts:
|
|
80
|
-
| `routeMap.getPathByStateId` | `public` | `string` \| `null` \| `undefined` | `undefined` | - | - | [play-router/src/router-bridge-base.ts:
|
|
81
|
-
| `routeMap.getStateIdByPath` | `public` | `string` \| `null` \| `undefined` | `undefined` | - | - | [play-router/src/router-bridge-base.ts:
|
|
82
|
-
| <a id="property-routewatcher"></a> `routeWatcher` | `protected` | \| [`RouteWatcherHandle`](../../play-router/interfaces/RouteWatcherHandle.md) \| `null` | `null` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`routeWatcher`](../../play-router/classes/RouterBridgeBase.md#property-routewatcher) | [play-router/src/router-bridge-base.ts:
|
|
74
|
+
| <a id="property-actor"></a> `actor` | `readonly` | [`AbstractActor`](../../play-actor/classes/AbstractActor.md)\<[`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\> & [`Routable`](../../play-actor/interfaces/Routable.md) | `undefined` | A `Routable` actor exposing `currentRoute` and `send`. | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`actor`](../../play-router/classes/RouterBridgeBase.md#property-actor) | [play-router/src/router-bridge-base.ts:99](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L99) |
|
|
75
|
+
| <a id="property-hasconnectedonce"></a> `hasConnectedOnce` | `protected` | `boolean` | `false` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`hasConnectedOnce`](../../play-router/classes/RouterBridgeBase.md#property-hasconnectedonce) | [play-router/src/router-bridge-base.ts:87](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L87) |
|
|
76
|
+
| <a id="property-isconnected"></a> `isConnected` | `protected` | `boolean` | `false` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`isConnected`](../../play-router/classes/RouterBridgeBase.md#property-isconnected) | [play-router/src/router-bridge-base.ts:86](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L86) |
|
|
77
|
+
| <a id="property-isprocessingnavigation"></a> `isProcessingNavigation` | `protected` | `boolean` | `false` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`isProcessingNavigation`](../../play-router/classes/RouterBridgeBase.md#property-isprocessingnavigation) | [play-router/src/router-bridge-base.ts:89](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L89) |
|
|
78
|
+
| <a id="property-lastsyncedpath"></a> `lastSyncedPath` | `protected` | `string` \| `null` | `null` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`lastSyncedPath`](../../play-router/classes/RouterBridgeBase.md#property-lastsyncedpath) | [play-router/src/router-bridge-base.ts:88](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L88) |
|
|
79
|
+
| <a id="property-routemap"></a> `routeMap` | `readonly` | `object` | `undefined` | Bidirectional route map for `stateId ↔ path` resolution. Provide `getStateIdByPath` and `getPathByStateId`. Framework adapters typically wrap the result of `createRouteMap()` or an equivalent. | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`routeMap`](../../play-router/classes/RouterBridgeBase.md#property-routemap) | [play-router/src/router-bridge-base.ts:100](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L100) |
|
|
80
|
+
| `routeMap.getPathByStateId` | `public` | `string` \| `null` \| `undefined` | `undefined` | - | - | [play-router/src/router-bridge-base.ts:102](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L102) |
|
|
81
|
+
| `routeMap.getStateIdByPath` | `public` | `string` \| `null` \| `undefined` | `undefined` | - | - | [play-router/src/router-bridge-base.ts:101](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L101) |
|
|
82
|
+
| <a id="property-routewatcher"></a> `routeWatcher` | `protected` | \| [`RouteWatcherHandle`](../../play-router/interfaces/RouteWatcherHandle.md) \| `null` | `null` | - | [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`routeWatcher`](../../play-router/classes/RouterBridgeBase.md#property-routewatcher) | [play-router/src/router-bridge-base.ts:90](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L90) |
|
|
83
83
|
|
|
84
84
|
## Methods
|
|
85
85
|
|
|
@@ -89,7 +89,7 @@ Create TanStack React Router bridge
|
|
|
89
89
|
connect(): void;
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
Defined in: [play-router/src/router-bridge-base.ts:
|
|
92
|
+
Defined in: [play-router/src/router-bridge-base.ts:126](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L126)
|
|
93
93
|
|
|
94
94
|
Connect the router bridge to the Actor.
|
|
95
95
|
|
|
@@ -121,7 +121,7 @@ Adapters that need custom initial-sync behavior should override
|
|
|
121
121
|
disconnect(): void;
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
Defined in: [play-router/src/router-bridge-base.ts:
|
|
124
|
+
Defined in: [play-router/src/router-bridge-base.ts:209](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L209)
|
|
125
125
|
|
|
126
126
|
Disconnect the router bridge from the Actor.
|
|
127
127
|
|
|
@@ -143,14 +143,14 @@ Stops signal watching and unregisters framework-specific router listener.
|
|
|
143
143
|
protected extractParams(pathname, stateId): Record<string, string>;
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
Defined in: [play-router/src/router-bridge-base.ts:
|
|
146
|
+
Defined in: [play-router/src/router-bridge-base.ts:318](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L318)
|
|
147
147
|
|
|
148
148
|
Extract path parameters from URL using the URLPattern API.
|
|
149
149
|
|
|
150
150
|
Accesses `globalThis.URLPattern` at runtime — no polyfill is imported by this
|
|
151
|
-
library. If `URLPattern` is unavailable
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
library. If `URLPattern` is unavailable and the matched route has parameterized
|
|
152
|
+
segments, a `URLPatternUnavailableError` is thrown — callers must provide a polyfill
|
|
153
|
+
for environments without native URLPattern support (Node.js < 24, older browsers).
|
|
154
154
|
|
|
155
155
|
#### Parameters
|
|
156
156
|
|
|
@@ -163,7 +163,11 @@ works, params will be empty).
|
|
|
163
163
|
|
|
164
164
|
`Record`\<`string`, `string`\>
|
|
165
165
|
|
|
166
|
-
Extracted path parameters, or empty object if
|
|
166
|
+
Extracted path parameters, or empty object if no match
|
|
167
|
+
|
|
168
|
+
#### Throws
|
|
169
|
+
|
|
170
|
+
When URLPattern is absent and the route is parameterized
|
|
167
171
|
|
|
168
172
|
#### Inherited from
|
|
169
173
|
|
|
@@ -177,7 +181,7 @@ Extracted path parameters, or empty object if URLPattern is unavailable or no ma
|
|
|
177
181
|
protected extractQuery(search): Record<string, string>;
|
|
178
182
|
```
|
|
179
183
|
|
|
180
|
-
Defined in: [play-router/src/router-bridge-base.ts:
|
|
184
|
+
Defined in: [play-router/src/router-bridge-base.ts:355](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L355)
|
|
181
185
|
|
|
182
186
|
Extract query parameters from URL search string.
|
|
183
187
|
|
|
@@ -205,7 +209,7 @@ Extracted query parameters or empty object
|
|
|
205
209
|
protected getInitialRouterPath(): string | null;
|
|
206
210
|
```
|
|
207
211
|
|
|
208
|
-
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:
|
|
212
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:128](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L128)
|
|
209
213
|
|
|
210
214
|
Read the router's current pathname for initial sync.
|
|
211
215
|
|
|
@@ -234,13 +238,38 @@ The base class `connect()` uses `actor.initialRoute` to distinguish:
|
|
|
234
238
|
|
|
235
239
|
---
|
|
236
240
|
|
|
241
|
+
### getInitialRouterSearch()
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
protected getInitialRouterSearch(): string | undefined;
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:144](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L144)
|
|
248
|
+
|
|
249
|
+
Return the initial URL search string for query-param forwarding on `connect()`.
|
|
250
|
+
|
|
251
|
+
Reads `router.history.location.search` — the same source used by
|
|
252
|
+
`getInitialRouterPath()`, which reflects `window.location` immediately before
|
|
253
|
+
`router.load()` or `<RouterProvider>` mounts. An empty string returns `undefined`
|
|
254
|
+
so `syncActorFromRouter` produces `query: {}` rather than parsing an empty string.
|
|
255
|
+
|
|
256
|
+
#### Returns
|
|
257
|
+
|
|
258
|
+
`string` \| `undefined`
|
|
259
|
+
|
|
260
|
+
#### Overrides
|
|
261
|
+
|
|
262
|
+
[`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`getInitialRouterSearch`](../../play-router/classes/RouterBridgeBase.md#getinitialroutersearch)
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
237
266
|
### navigateRouter()
|
|
238
267
|
|
|
239
268
|
```ts
|
|
240
269
|
protected navigateRouter(path): void;
|
|
241
270
|
```
|
|
242
271
|
|
|
243
|
-
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:
|
|
272
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:106](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L106)
|
|
244
273
|
|
|
245
274
|
Navigate the framework router to the given path.
|
|
246
275
|
|
|
@@ -263,13 +292,52 @@ Must trigger the framework router's navigation (e.g., router.navigate(path)).
|
|
|
263
292
|
|
|
264
293
|
---
|
|
265
294
|
|
|
295
|
+
### resolveNavigationPath()
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
protected resolveNavigationPath(route): string | null;
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Defined in: [play-router/src/router-bridge-base.ts:340](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L340)
|
|
302
|
+
|
|
303
|
+
Resolve an actor route value to a concrete URL path for navigation.
|
|
304
|
+
|
|
305
|
+
Bridges that receive raw `actor.currentRoute` values in `navigateRouter`
|
|
306
|
+
can call this to normalize stateIds (with or without `#` prefix) to paths.
|
|
307
|
+
Returns `null` when navigation is not possible:
|
|
308
|
+
|
|
309
|
+
- unknown stateId with no route map entry
|
|
310
|
+
- parameterized pattern (e.g. `/profile/:id`) — no concrete values available
|
|
311
|
+
- non-path string that isn't a known stateId
|
|
312
|
+
|
|
313
|
+
Route maps may store stateIds with or without the `#` prefix; both forms
|
|
314
|
+
are tried automatically.
|
|
315
|
+
|
|
316
|
+
#### Parameters
|
|
317
|
+
|
|
318
|
+
| Parameter | Type | Description |
|
|
319
|
+
| --------- | -------- | -------------------------------------------------------------- |
|
|
320
|
+
| `route` | `string` | Raw actor route value (stateId, `#`-stateId, or concrete path) |
|
|
321
|
+
|
|
322
|
+
#### Returns
|
|
323
|
+
|
|
324
|
+
`string` \| `null`
|
|
325
|
+
|
|
326
|
+
Concrete URL path, or `null` if navigation should be skipped
|
|
327
|
+
|
|
328
|
+
#### Inherited from
|
|
329
|
+
|
|
330
|
+
[`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`resolveNavigationPath`](../../play-router/classes/RouterBridgeBase.md#resolvenavigationpath)
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
266
334
|
### syncActorFromRouter()
|
|
267
335
|
|
|
268
336
|
```ts
|
|
269
337
|
protected syncActorFromRouter(pathname, search?): void;
|
|
270
338
|
```
|
|
271
339
|
|
|
272
|
-
Defined in: [play-router/src/router-bridge-base.ts:
|
|
340
|
+
Defined in: [play-router/src/router-bridge-base.ts:260](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L260)
|
|
273
341
|
|
|
274
342
|
Sync actor state when router location changes.
|
|
275
343
|
|
|
@@ -299,7 +367,7 @@ Prevents circular updates via isProcessingNavigation flag.
|
|
|
299
367
|
protected syncRouterFromActor(route): void;
|
|
300
368
|
```
|
|
301
369
|
|
|
302
|
-
Defined in: [play-router/src/router-bridge-base.ts:
|
|
370
|
+
Defined in: [play-router/src/router-bridge-base.ts:240](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/router-bridge-base.ts#L240)
|
|
303
371
|
|
|
304
372
|
Sync router location when actor route signal changes.
|
|
305
373
|
|
|
@@ -332,7 +400,7 @@ suppressed as circular echoes.
|
|
|
332
400
|
protected unwatchRouterChanges(): void;
|
|
333
401
|
```
|
|
334
402
|
|
|
335
|
-
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:
|
|
403
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:166](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L166)
|
|
336
404
|
|
|
337
405
|
Stop watching for router location changes.
|
|
338
406
|
|
|
@@ -354,7 +422,7 @@ Called by disconnect(). Should clean up the framework-specific subscription.
|
|
|
354
422
|
protected watchRouterChanges(): void;
|
|
355
423
|
```
|
|
356
424
|
|
|
357
|
-
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:
|
|
425
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:157](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L157)
|
|
358
426
|
|
|
359
427
|
Subscribe to ALL navigation events via router.history.
|
|
360
428
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
function PlayRouterProvider<TActor>(__namedParameters): Element;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-tanstack-react-router/src/play-router-provider.tsx:41](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [play-tanstack-react-router/src/play-router-provider.tsx:41](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-tanstack-react-router/src/play-router-provider.tsx#L41)
|
|
10
10
|
|
|
11
11
|
## Type Parameters
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
function createRouteMap(routeTree): RouteMap;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-router/src/create-route-map.ts:74](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [play-router/src/create-route-map.ts:74](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/create-route-map.ts#L74)
|
|
10
10
|
|
|
11
11
|
Create a RouteMap from a RouteTree for efficient path lookups.
|
|
12
12
|
|
|
@@ -6,30 +6,40 @@
|
|
|
6
6
|
function createRouteMapFromTree(routeTree): RouteMap;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-
|
|
9
|
+
Defined in: [play-router/src/create-route-map-from-tree.ts:31](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/create-route-map-from-tree.ts#L31)
|
|
10
10
|
|
|
11
|
-
Create
|
|
11
|
+
Create a `BaseRouteMap` from a `RouteTree` node structure.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Used by framework-router adapters (React Router, TanStack Router) that pass a
|
|
14
|
+
`RouteTree` produced by `extractMachineRoutes()` rather than calling
|
|
15
|
+
`createRouteMapFromMachine()` directly.
|
|
16
|
+
|
|
17
|
+
Traverses all nodes collecting `{ stateId: node.id, path: node.fullPath }` pairs.
|
|
18
|
+
`node.fullPath` is always the absolute resolved path (e.g. `"/dashboard/overview"`),
|
|
19
|
+
which is what `BaseRouteMap` needs for browser URL matching. This matches the
|
|
20
|
+
behaviour of `createRouteMapFromMachine`, which also uses `node.fullPath`.
|
|
14
21
|
|
|
15
22
|
## Parameters
|
|
16
23
|
|
|
17
|
-
| Parameter | Type | Description
|
|
18
|
-
| ----------- | -------------------------------------------------------- |
|
|
19
|
-
| `routeTree` | [`RouteTree`](../../play-router/interfaces/RouteTree.md) |
|
|
24
|
+
| Parameter | Type | Description |
|
|
25
|
+
| ----------- | -------------------------------------------------------- | ------------------------------------------------------ |
|
|
26
|
+
| `routeTree` | [`RouteTree`](../../play-router/interfaces/RouteTree.md) | A `RouteTree` as returned by `extractMachineRoutes()`. |
|
|
20
27
|
|
|
21
28
|
## Returns
|
|
22
29
|
|
|
23
|
-
[`RouteMap`](
|
|
30
|
+
[`RouteMap`](../../play-dom-router/interfaces/RouteMap.md)
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
A `BaseRouteMap` for use with any `RouterBridgeBase`-based adapter.
|
|
26
33
|
|
|
27
34
|
## Example
|
|
28
35
|
|
|
29
36
|
```typescript
|
|
30
|
-
|
|
31
|
-
import {
|
|
37
|
+
// Preferred — single call for XState machines:
|
|
38
|
+
import { createRouteMapFromMachine } from "@xmachines/play-router";
|
|
39
|
+
const routeMap = createRouteMapFromMachine(machine);
|
|
32
40
|
|
|
41
|
+
// Equivalent two-step form used by framework adapters:
|
|
42
|
+
import { extractMachineRoutes, createRouteMapFromTree } from "@xmachines/play-router";
|
|
33
43
|
const routeTree = extractMachineRoutes(machine);
|
|
34
|
-
const routeMap = createRouteMapFromTree(routeTree);
|
|
44
|
+
const routeMap = createRouteMapFromTree(routeTree); // uses node.fullPath (absolute)
|
|
35
45
|
```
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
function extractMachineRoutes(machine): RouteTree;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-router/src/extract-routes.ts:93](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [play-router/src/extract-routes.ts:93](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.27/packages/play-router/src/extract-routes.ts#L93)
|
|
10
10
|
|
|
11
11
|
Extract complete route tree from state machine graph
|
|
12
12
|
|