@xmachines/docs 2.0.0 → 2.1.0
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 +11 -13
- package/api/@xmachines/play/README.md +58 -63
- package/api/@xmachines/play/classes/NonNullableError.md +7 -7
- package/api/@xmachines/play/classes/PlayError.md +25 -27
- package/api/@xmachines/play/functions/assertNonNullable.md +17 -17
- package/api/@xmachines/play/type-aliases/PlayEvent.md +26 -25
- package/api/@xmachines/play-actor/README.md +72 -63
- package/api/@xmachines/play-actor/classes/AbstractActor.md +39 -39
- package/api/@xmachines/play-actor/functions/attachRenderErrorHandler.md +19 -18
- package/api/@xmachines/play-actor/functions/composePlayState.md +9 -8
- package/api/@xmachines/play-actor/functions/createViewStoreLifecycle.md +5 -5
- package/api/@xmachines/play-actor/functions/guardContextWrites.md +27 -25
- package/api/@xmachines/play-actor/functions/refreshContextSubtree.md +12 -11
- package/api/@xmachines/play-actor/functions/reuseComposedState.md +23 -22
- package/api/@xmachines/play-actor/functions/shallowEqualExcept.md +6 -5
- package/api/@xmachines/play-actor/functions/toAtomState.md +16 -14
- package/api/@xmachines/play-actor/functions/typedSpec.md +12 -11
- package/api/@xmachines/play-actor/interfaces/BaseActorProviderProps.md +17 -15
- package/api/@xmachines/play-actor/interfaces/BaseViewContextValue.md +15 -14
- package/api/@xmachines/play-actor/interfaces/PlaySpec.md +13 -13
- package/api/@xmachines/play-actor/interfaces/ResolveViewStoreOptions.md +4 -4
- package/api/@xmachines/play-actor/interfaces/Routable.md +4 -4
- package/api/@xmachines/play-actor/interfaces/ViewStoreLifecycle.md +11 -11
- package/api/@xmachines/play-actor/interfaces/ViewStoreResolution.md +7 -7
- package/api/@xmachines/play-actor/interfaces/Viewable.md +9 -9
- package/api/@xmachines/play-actor/variables/CONTEXT_STATE_KEY.md +5 -5
- package/api/@xmachines/play-dom/README.md +119 -85
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +34 -32
- package/api/@xmachines/play-dom/functions/createPlayUI.md +10 -10
- package/api/@xmachines/play-dom/functions/createRenderer.md +21 -17
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +8 -8
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +9 -9
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +9 -9
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +5 -5
- package/api/@xmachines/play-dom-router/README.md +66 -49
- package/api/@xmachines/play-dom-router/classes/DomRouterBridge.md +116 -0
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +4 -3
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +16 -14
- package/api/@xmachines/play-dom-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-dom-router/functions/createRouter.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +25 -26
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +19 -18
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +7 -7
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +18 -17
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +9 -9
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +39 -38
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +7 -7
- package/api/@xmachines/play-react/README.md +63 -54
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +14 -13
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/usePlayView.md +4 -4
- package/api/@xmachines/play-react/functions/useSignalEffect.md +39 -39
- package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +11 -11
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +7 -7
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +4 -4
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +14 -14
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-react/type-aliases/AnyPlayActor.md +2 -2
- package/api/@xmachines/play-react/type-aliases/PlayRendererProps.md +13 -0
- package/api/@xmachines/play-react/variables/ActorProvider.md +9 -8
- package/api/@xmachines/play-react/variables/PlayRenderer.md +5 -4
- package/api/@xmachines/play-react/variables/PlayUIProvider.md +6 -6
- package/api/@xmachines/play-react-router/README.md +37 -28
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +22 -19
- package/api/@xmachines/play-react-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-react-router/functions/createPlayRouterProvider.md +16 -14
- package/api/@xmachines/play-react-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +18 -18
- package/api/@xmachines/play-react-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderBaseProps.md +12 -12
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +11 -11
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterBridgeConstructor.md +2 -2
- package/api/@xmachines/play-react-router/variables/PlayRouterProvider.md +7 -6
- package/api/@xmachines/play-router/README.md +94 -82
- package/api/@xmachines/play-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +29 -23
- package/api/@xmachines/play-router/functions/buildPlayRouteEvent.md +6 -5
- package/api/@xmachines/play-router/functions/buildRouteTree.md +16 -15
- package/api/@xmachines/play-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +18 -18
- package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +18 -17
- package/api/@xmachines/play-router/functions/extractMachineRoutes.md +11 -10
- package/api/@xmachines/play-router/functions/extractQuery.md +3 -3
- package/api/@xmachines/play-router/functions/extractRouteParams.md +22 -19
- package/api/@xmachines/play-router/functions/findRouteById.md +10 -9
- package/api/@xmachines/play-router/functions/findRouteByPath.md +14 -12
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +9 -9
- package/api/@xmachines/play-router/functions/getRoutableRoutes.md +9 -9
- package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +16 -15
- package/api/@xmachines/play-router/functions/isRouteReachable.md +12 -11
- package/api/@xmachines/play-router/functions/machineToGraph.md +1 -1
- package/api/@xmachines/play-router/functions/routeExists.md +8 -8
- package/api/@xmachines/play-router/functions/sanitizePathname.md +15 -13
- package/api/@xmachines/play-router/functions/validateRouteFormat.md +10 -10
- package/api/@xmachines/play-router/functions/validateStateExists.md +9 -9
- package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +4 -4
- package/api/@xmachines/play-router/interfaces/LocationLike.md +9 -9
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +7 -7
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +9 -9
- package/api/@xmachines/play-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-router/interfaces/ResolvedRoutePath.md +7 -7
- package/api/@xmachines/play-router/interfaces/RoutableActor.md +18 -17
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +11 -11
- package/api/@xmachines/play-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +3 -3
- package/api/@xmachines/play-router/interfaces/RouteNode.md +13 -13
- package/api/@xmachines/play-router/interfaces/RouteObject.md +6 -6
- package/api/@xmachines/play-router/interfaces/RouteTree.md +11 -11
- package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +13 -13
- package/api/@xmachines/play-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-router/interfaces/WindowLike.md +10 -10
- package/api/@xmachines/play-router/type-aliases/BaseRouteMapping.md +13 -0
- package/api/@xmachines/play-router/type-aliases/MachineGraph.md +4 -3
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +2 -2
- package/api/@xmachines/play-signals/README.md +38 -36
- package/api/@xmachines/play-signals/functions/watchSignal.md +15 -15
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +6 -6
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +10 -10
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +6 -6
- package/api/@xmachines/play-signals/interfaces/SignalState.md +13 -13
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +18 -18
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +6 -5
- package/api/@xmachines/play-solid/README.md +46 -42
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/functions/usePlayView.md +3 -3
- package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +13 -13
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +14 -14
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +9 -9
- package/api/@xmachines/play-solid/type-aliases/AnyPlayActor.md +2 -2
- package/api/@xmachines/play-solid/variables/ActorContext.md +5 -4
- package/api/@xmachines/play-solid/variables/ActorProvider.md +8 -7
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +6 -4
- package/api/@xmachines/play-solid/variables/PlayUIProvider.md +7 -7
- package/api/@xmachines/play-solid-router/README.md +34 -29
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +43 -34
- package/api/@xmachines/play-solid-router/functions/createPlayRouterProvider.md +15 -13
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +39 -39
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderBaseProps.md +10 -10
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +11 -11
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterBridgeConstructor.md +5 -5
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +2 -2
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +11 -11
- package/api/@xmachines/play-solid-router/variables/PlayRouterProvider.md +9 -8
- package/api/@xmachines/play-svelte/README.md +40 -31
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +9 -8
- package/api/@xmachines/play-svelte/functions/getActorContext.md +5 -4
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +3 -3
- package/api/@xmachines/play-svelte/functions/setActorContext.md +1 -1
- package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +17 -15
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +9 -9
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +20 -18
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +12 -11
- package/api/@xmachines/play-svelte/type-aliases/AnyPlayActor.md +2 -2
- package/api/@xmachines/play-svelte-spa-router/README.md +25 -25
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-svelte-spa-router/classes/SvelteSpaRouterBridge.md +133 -0
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +7 -7
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +10 -10
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-sveltekit-router/README.md +38 -34
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-sveltekit-router/classes/SvelteKitRouterBridge.md +132 -0
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +3 -3
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +6 -6
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +9 -9
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/README.md +66 -48
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +43 -38
- package/api/@xmachines/play-tanstack-react-router/functions/createPlayRouterProvider.md +16 -14
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +18 -18
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +11 -10
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderBaseProps.md +12 -12
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +11 -11
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +16 -11
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterBridgeConstructor.md +2 -2
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +15 -13
- package/api/@xmachines/play-tanstack-react-router/variables/PlayRouterProvider.md +9 -8
- package/api/@xmachines/play-tanstack-router/README.md +37 -17
- package/api/@xmachines/play-tanstack-router/classes/TanStackRouterBridgeBase.md +43 -38
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouteMapLike.md +9 -9
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouterLike.md +15 -13
- package/api/@xmachines/play-tanstack-solid-router/README.md +71 -45
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-tanstack-solid-router/classes/TanStackSolidRouterBridge.md +38 -30
- package/api/@xmachines/play-tanstack-solid-router/functions/createPlayRouterProvider.md +15 -13
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderBaseProps.md +11 -11
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +9 -9
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterBridgeConstructor.md +2 -2
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +2 -2
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +15 -13
- package/api/@xmachines/play-tanstack-solid-router/variables/PlayRouterProvider.md +7 -7
- package/api/@xmachines/play-vue/README.md +37 -35
- package/api/@xmachines/play-vue/functions/defineRegistry.md +10 -9
- package/api/@xmachines/play-vue/functions/useActor.md +1 -1
- package/api/@xmachines/play-vue/functions/usePlayView.md +28 -0
- package/api/@xmachines/play-vue/interfaces/ActorProviderProps.md +10 -9
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +13 -12
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +10 -9
- package/api/@xmachines/play-vue/interfaces/VisibilityProviderProps.md +6 -2
- package/api/@xmachines/play-vue/type-aliases/AnyPlayActor.md +2 -2
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue/variables/getPlayViewContext.md +34 -0
- package/api/@xmachines/play-vue-router/README.md +65 -56
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +26 -19
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-vue-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +39 -33
- package/api/@xmachines/play-vue-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +2 -2
- package/api/@xmachines/play-vue-router/type-aliases/VueRouteMap.md +13 -0
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +5 -5
- package/api/@xmachines/play-vue-router/variables/VueRouteMap.md +13 -0
- package/api/@xmachines/play-xstate/README.md +72 -70
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +123 -112
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +19 -16
- package/api/@xmachines/play-xstate/functions/composeGuards.md +25 -23
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +20 -20
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +15 -15
- package/api/@xmachines/play-xstate/functions/definePlayer.md +19 -19
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +26 -25
- package/api/@xmachines/play-xstate/functions/eventMatches.md +8 -8
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +16 -13
- package/api/@xmachines/play-xstate/functions/hasContext.md +8 -8
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +10 -10
- package/api/@xmachines/play-xstate/functions/negateGuard.md +19 -18
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +6 -6
- package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +7 -7
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +10 -10
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +15 -14
- package/api/@xmachines/play-xstate/interfaces/RouteObject.md +2 -2
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +5 -5
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +9 -9
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +4 -3
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +7 -7
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +12 -12
- package/api/@xmachines/play-xstate/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +15 -14
- package/api/@xmachines/shared/README.md +11 -13
- package/api/@xmachines/shared/vite-aliases/functions/xmAliases.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmCacheDir.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmOptimizeDeps.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmResolve.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmSvelteRunes.md +2 -2
- package/api/@xmachines/shared/vitest/functions/defineXmBrowserConfig.md +1 -1
- package/api/@xmachines/shared/vitest/functions/defineXmVitestConfig.md +1 -1
- package/api/@xmachines/shared/vitest/interfaces/XmBrowserConfigOptions.md +4 -4
- package/contributing/development.md +28 -0
- package/guides/inspector.md +1 -1
- package/package.json +1 -1
- package/api/@xmachines/play-vue/functions/getPlayViewContext.md +0 -28
|
@@ -4,11 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Route tree extraction from XState v5 state machines. Part of [@xmachines/play](../play/README.md) Universal Player Architecture.
|
|
6
6
|
|
|
7
|
-
[](https://opensource.org/licenses/MIT) [](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-router)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Part of the [xmachines-js monorepo](../../README.md).
|
|
9
|
+
This package extracts the routes from a machine graph and looks them up in both directions. The Actor therefore keeps the authority over the navigation.
|
|
12
10
|
|
|
13
11
|
## Installation
|
|
14
12
|
|
|
@@ -23,9 +21,9 @@ pnpm add @xmachines/play-router
|
|
|
23
21
|
|
|
24
22
|
**URLPattern polyfill (Node.js < 24 / older browsers):**
|
|
25
23
|
|
|
26
|
-
`@xmachines/play-router`
|
|
24
|
+
`@xmachines/play-router` matches each dynamic route with the [URLPattern API](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern). URLPattern is native in Node.js 24+ and in a modern browser (Chrome 95+, Firefox 117+, Safari 16.4+).
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
In an environment without the native API, load a polyfill **before** you import this package:
|
|
29
27
|
|
|
30
28
|
```typescript
|
|
31
29
|
// Entry point — must run before any @xmachines/play-router import
|
|
@@ -38,7 +36,7 @@ Install the polyfill:
|
|
|
38
36
|
pnpm add urlpattern-polyfill
|
|
39
37
|
```
|
|
40
38
|
|
|
41
|
-
`urlpattern-polyfill` is
|
|
39
|
+
`urlpattern-polyfill` is an optional peer dependency. A package manager does not install it for you. Install it and load it yourself when your runtime has no native URLPattern.
|
|
42
40
|
|
|
43
41
|
## Usage
|
|
44
42
|
|
|
@@ -97,8 +95,13 @@ routeMap.getPathByStateId("profile"); // "/profile/:userId"
|
|
|
97
95
|
### Sending `play.route` events
|
|
98
96
|
|
|
99
97
|
```typescript
|
|
98
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
100
99
|
import type { PlayRouteEvent } from "@xmachines/play-router";
|
|
101
100
|
|
|
101
|
+
// machine: your routable machine (states carry meta.route)
|
|
102
|
+
const actor = definePlayer({ machine })();
|
|
103
|
+
actor.start();
|
|
104
|
+
|
|
102
105
|
// Navigate to a state by ID
|
|
103
106
|
const event: PlayRouteEvent = {
|
|
104
107
|
type: "play.route",
|
|
@@ -122,14 +125,21 @@ actor.send({
|
|
|
122
125
|
});
|
|
123
126
|
```
|
|
124
127
|
|
|
125
|
-
###
|
|
128
|
+
### How to write a `RouterBridgeBase` adapter
|
|
126
129
|
|
|
127
|
-
Extend `RouterBridgeBase
|
|
130
|
+
Extend `RouterBridgeBase`, then implement the three abstract methods for your framework:
|
|
128
131
|
|
|
129
132
|
```typescript
|
|
130
|
-
import { RouterBridgeBase } from "@xmachines/play-router";
|
|
133
|
+
import { RouterBridgeBase, createRouteMap } from "@xmachines/play-router";
|
|
131
134
|
import type { RoutableActor } from "@xmachines/play-router";
|
|
132
135
|
|
|
136
|
+
// Shape of your framework's router — adjust to its real API
|
|
137
|
+
type MyRouter = {
|
|
138
|
+
navigate(path: string): void;
|
|
139
|
+
subscribe(handler: (location: { pathname: string; search: string }) => void): () => void;
|
|
140
|
+
state: { location: { pathname: string } };
|
|
141
|
+
};
|
|
142
|
+
|
|
133
143
|
export class MyRouterBridge extends RouterBridgeBase {
|
|
134
144
|
private unsubscribe: (() => void) | null = null;
|
|
135
145
|
|
|
@@ -165,7 +175,8 @@ export class MyRouterBridge extends RouterBridgeBase {
|
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
177
|
|
|
168
|
-
// Usage
|
|
178
|
+
// Usage — myRouter: your framework's router instance;
|
|
179
|
+
// machine/actor: your routable machine and its started actor
|
|
169
180
|
const routeMap = createRouteMap(machine);
|
|
170
181
|
const bridge = new MyRouterBridge(myRouter, actor, routeMap);
|
|
171
182
|
bridge.connect();
|
|
@@ -177,79 +188,79 @@ bridge.disconnect();
|
|
|
177
188
|
|
|
178
189
|
### Route Extraction
|
|
179
190
|
|
|
180
|
-
| Export | Description
|
|
181
|
-
| ---------------------------------------- |
|
|
182
|
-
| `extractMachineRoutes(machine)` |
|
|
183
|
-
| `createRouteMap(machine, options?)` |
|
|
184
|
-
| `createRouteMapFromTree(tree, options?)` |
|
|
185
|
-
| `buildRouteTree(routes)` |
|
|
186
|
-
| `machineToGraph(machine)` |
|
|
191
|
+
| Export | Description |
|
|
192
|
+
| ---------------------------------------- | --------------------------------------------------------------------------------- |
|
|
193
|
+
| `extractMachineRoutes(machine)` | Converts an XState machine into a `RouteTree` with the state ID ↔ path maps |
|
|
194
|
+
| `createRouteMap(machine, options?)` | Builds a `RouteMap` directly from a machine. An adapter uses this form |
|
|
195
|
+
| `createRouteMapFromTree(tree, options?)` | Builds a `RouteMap` from a `RouteTree` that you extracted before |
|
|
196
|
+
| `buildRouteTree(routes)` | Builds a `RouteTree` from an array of `RouteInfo` objects |
|
|
197
|
+
| `machineToGraph(machine)` | Converts a machine into a typed `@statelyai/graph` `Graph`, for a graph algorithm |
|
|
187
198
|
|
|
188
199
|
### Route Matching
|
|
189
200
|
|
|
190
|
-
| Export | Description
|
|
191
|
-
| ----------------------------- |
|
|
192
|
-
| `RouteMap` |
|
|
193
|
-
| `findRouteById(tree, id)` |
|
|
194
|
-
| `findRouteByPath(tree, path)` |
|
|
201
|
+
| Export | Description |
|
|
202
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
203
|
+
| `RouteMap` | The `stateId ↔ path` lookup class for both directions. It matches an exact path in O(1) and a pattern in O(k) |
|
|
204
|
+
| `findRouteById(tree, id)` | Finds a `RouteNode` by its state ID |
|
|
205
|
+
| `findRouteByPath(tree, path)` | Finds a `RouteNode` by its URL path. It also matches a dynamic pattern |
|
|
195
206
|
|
|
196
207
|
### Query Utilities
|
|
197
208
|
|
|
198
|
-
| Export | Description
|
|
199
|
-
| ------------------------------------------------- |
|
|
200
|
-
| `getRoutableRoutes(tree)` |
|
|
201
|
-
| `getNavigableRoutes(tree, stateId)` |
|
|
202
|
-
| `routeExists(tree, path)` |
|
|
203
|
-
| `getTransitionReachableRoutes(graph, stateId)` |
|
|
204
|
-
| `isRouteReachable(graph, fromStateId, toStateId)` |
|
|
209
|
+
| Export | Description |
|
|
210
|
+
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
211
|
+
| `getRoutableRoutes(tree)` | Returns every routable `RouteNode` in one flat array |
|
|
212
|
+
| `getNavigableRoutes(tree, stateId)` | Returns the child routes that a state can reach, through the hierarchy and through a transition |
|
|
213
|
+
| `routeExists(tree, path)` | Tells you if the tree holds a path |
|
|
214
|
+
| `getTransitionReachableRoutes(graph, stateId)` | Returns the route paths that a state can reach through an XState transition |
|
|
215
|
+
| `isRouteReachable(graph, fromStateId, toStateId)` | Tells you if a transition path is present between two states |
|
|
205
216
|
|
|
206
217
|
### Router Bridge
|
|
207
218
|
|
|
208
|
-
| Export | Description
|
|
209
|
-
| --------------------------------------- |
|
|
210
|
-
| `RouterBridgeBase` |
|
|
211
|
-
| `sanitizePathname(path)` |
|
|
212
|
-
| `buildPlayRouteEvent(options)` |
|
|
213
|
-
| `extractRouteParams(pathname, pattern)` |
|
|
214
|
-
| `extractQuery(search)` |
|
|
219
|
+
| Export | Description |
|
|
220
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
221
|
+
| `RouterBridgeBase` | The abstract base class of each framework router adapter. It implements the `RouterBridge` protocol |
|
|
222
|
+
| `sanitizePathname(path)` | Normalizes a raw pathname. It returns `null` for a path of more than 2048 characters, and for malformed input |
|
|
223
|
+
| `buildPlayRouteEvent(options)` | Builds a `PlayRouteEvent` from a pathname and a route-map match result |
|
|
224
|
+
| `extractRouteParams(pathname, pattern)` | Reads the path parameters of a URL with URLPattern |
|
|
225
|
+
| `extractQuery(search)` | Reads the query parameters of a URL search string |
|
|
215
226
|
|
|
216
227
|
### Validation
|
|
217
228
|
|
|
218
|
-
| Export | Description
|
|
219
|
-
| ---------------------------------------- |
|
|
220
|
-
| `validateRouteFormat(route, stateId)` |
|
|
221
|
-
| `validateStateExists(stateId, stateIds)` |
|
|
222
|
-
| `detectDuplicateRoutes(routes)` |
|
|
229
|
+
| Export | Description |
|
|
230
|
+
| ---------------------------------------- | ---------------------------------------------------- |
|
|
231
|
+
| `validateRouteFormat(route, stateId)` | Asserts that the route path is not empty |
|
|
232
|
+
| `validateStateExists(stateId, stateIds)` | Asserts that the machine graph holds the state ID |
|
|
233
|
+
| `detectDuplicateRoutes(routes)` | Throws when two states resolve to the same full path |
|
|
223
234
|
|
|
224
235
|
### Key Types
|
|
225
236
|
|
|
226
|
-
| Export | Description
|
|
227
|
-
| ---------------------------------- |
|
|
228
|
-
| `RouterBridge` |
|
|
229
|
-
| `RouteTree` |
|
|
230
|
-
| `RouteNode` |
|
|
231
|
-
| `RouteInfo` |
|
|
232
|
-
| `PlayRouteEvent` | Routing event `{ type: "play.route", to, params?, query? }`
|
|
233
|
-
| `RoutableActor` |
|
|
234
|
-
| `PlayActor` |
|
|
235
|
-
| `RouteMapping` | `{ stateId, path }` pair
|
|
236
|
-
| `RouteMapping as BaseRouteMapping` |
|
|
237
|
-
| `MachineGraph` |
|
|
238
|
-
| `WindowLike` |
|
|
239
|
-
| `LocationLike` |
|
|
237
|
+
| Export | Description |
|
|
238
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
239
|
+
| `RouterBridge` | The interface of the `connect()` and `disconnect()` lifecycle |
|
|
240
|
+
| `RouteTree` | The hierarchical tree, with `root`, `byStateId`, `byPath`, and an optional `graph` |
|
|
241
|
+
| `RouteNode` | One node of the tree, with `id`, `path`, `fullPath`, `stateId`, `children`, and `parent` |
|
|
242
|
+
| `RouteInfo` | The flat route descriptor that comes from a state node |
|
|
243
|
+
| `PlayRouteEvent` | Routing event `{ type: "play.route", to, params?, query? }` |
|
|
244
|
+
| `RoutableActor` | The minimal actor interface that `RouterBridgeBase` requires: `currentRoute`, `initialRoute`, and `send(PlayRouteEvent)` |
|
|
245
|
+
| `PlayActor` | The complete actor interface that `PlayRouterProvider` uses. It extends `RoutableActor` with `currentView` (`Routable + Viewable`) |
|
|
246
|
+
| `RouteMapping` | The `{ stateId, path }` pair that builds a `RouteMap` |
|
|
247
|
+
| `RouteMapping as BaseRouteMapping` | The alias of `RouteMapping`, for compatibility with an earlier version |
|
|
248
|
+
| `MachineGraph` | The typed `@statelyai/graph` Graph, with `MachineNodeData` and `MachineEdgeData` |
|
|
249
|
+
| `WindowLike` | The minimal `window` interface that you can inject for SSR and for a test |
|
|
250
|
+
| `LocationLike` | The minimal `location` interface that you can inject for SSR and for a test |
|
|
240
251
|
|
|
241
252
|
### Errors (subpath `@xmachines/play-router/errors`)
|
|
242
253
|
|
|
243
|
-
| Class | Code | When thrown
|
|
244
|
-
| ---------------------------- | --------------------------------------- |
|
|
245
|
-
| `RouterSyncError` | `PLAY_ROUTER_SYNC_FAILED` | `syncActorFromRouter()`
|
|
246
|
-
| `DuplicateBridgeError` | `PLAY_ROUTER_DUPLICATE_BRIDGE` | A second bridge tries to connect to an actor that already has one
|
|
247
|
-
| `URLPatternUnavailableError` | `PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE` | URLPattern API is absent and no polyfill is loaded
|
|
248
|
-
| `InvalidRoutePatternError` | `PLAY_ROUTE_MAP_INVALID_PATTERN` |
|
|
249
|
-
| `EmptyRoutePathError` | `PLAY_ROUTE_EMPTY_PATH` | A state declares `meta.route: ""`
|
|
250
|
-
| `InvalidStateIdError` | `PLAY_ROUTE_INVALID_STATE_ID` | A route
|
|
251
|
-
| `DuplicateRoutePathError` | `PLAY_ROUTE_DUPLICATE_PATH` | Two or more states share the same URL path
|
|
252
|
-
| `UnknownStateTypeError` | `PLAY_ROUTE_UNKNOWN_STATE_TYPE` | A state node has an
|
|
254
|
+
| Class | Code | When thrown |
|
|
255
|
+
| ---------------------------- | --------------------------------------- | ----------------------------------------------------------------------- |
|
|
256
|
+
| `RouterSyncError` | `PLAY_ROUTER_SYNC_FAILED` | `syncActorFromRouter()` cannot send a `play.route` event |
|
|
257
|
+
| `DuplicateBridgeError` | `PLAY_ROUTER_DUPLICATE_BRIDGE` | A second bridge tries to connect to an actor that already has one |
|
|
258
|
+
| `URLPatternUnavailableError` | `PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE` | The URLPattern API is absent, and no polyfill is loaded |
|
|
259
|
+
| `InvalidRoutePatternError` | `PLAY_ROUTE_MAP_INVALID_PATTERN` | The URLPattern constructor refuses a route pattern string |
|
|
260
|
+
| `EmptyRoutePathError` | `PLAY_ROUTE_EMPTY_PATH` | A state declares `meta.route: ""` |
|
|
261
|
+
| `InvalidStateIdError` | `PLAY_ROUTE_INVALID_STATE_ID` | A route names a state ID that the machine graph does not hold |
|
|
262
|
+
| `DuplicateRoutePathError` | `PLAY_ROUTE_DUPLICATE_PATH` | Two or more states share the same URL path |
|
|
263
|
+
| `UnknownStateTypeError` | `PLAY_ROUTE_UNKNOWN_STATE_TYPE` | A state node has an XState `.type` value that the package does not know |
|
|
253
264
|
|
|
254
265
|
```typescript
|
|
255
266
|
import {
|
|
@@ -258,6 +269,7 @@ import {
|
|
|
258
269
|
URLPatternUnavailableError,
|
|
259
270
|
} from "@xmachines/play-router/errors";
|
|
260
271
|
|
|
272
|
+
// bridge from the adapter example above
|
|
261
273
|
try {
|
|
262
274
|
bridge.connect();
|
|
263
275
|
} catch (err) {
|
|
@@ -273,7 +285,7 @@ try {
|
|
|
273
285
|
|
|
274
286
|
### `meta.route` patterns
|
|
275
287
|
|
|
276
|
-
|
|
288
|
+
Declare the route of an XState state node in its `meta.route` field:
|
|
277
289
|
|
|
278
290
|
```typescript
|
|
279
291
|
states: {
|
|
@@ -298,7 +310,7 @@ states: {
|
|
|
298
310
|
|
|
299
311
|
### Relative vs absolute paths
|
|
300
312
|
|
|
301
|
-
|
|
313
|
+
A child route that starts with `/` is absolute, and it does not inherit the path of its parent. A child route without the first `/` is relative to its nearest routable ancestor:
|
|
302
314
|
|
|
303
315
|
```typescript
|
|
304
316
|
states: {
|
|
@@ -319,7 +331,7 @@ states: {
|
|
|
319
331
|
}
|
|
320
332
|
```
|
|
321
333
|
|
|
322
|
-
Always use `node.fullPath`
|
|
334
|
+
Always use `node.fullPath` to match a browser URL and to build a route map. Never use `node.path` for this.
|
|
323
335
|
|
|
324
336
|
## Testing
|
|
325
337
|
|
|
@@ -331,10 +343,11 @@ pnpm --filter @xmachines/play-router test
|
|
|
331
343
|
pnpm --filter @xmachines/play-router run test:watch
|
|
332
344
|
```
|
|
333
345
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
346
|
+
`@xmachines/play-router-shared` holds a contract test suite of the router bridge, for the
|
|
347
|
+
author of an adapter. That suite drives a real actor. Therefore it is one layer above this
|
|
348
|
+
package, and `@xmachines/play-router` keeps no dependency on an actor runtime.
|
|
349
|
+
`@xmachines/play-router-shared` is a private workspace package. Thus only an adapter author
|
|
350
|
+
in this repository can use the suite:
|
|
338
351
|
|
|
339
352
|
```typescript
|
|
340
353
|
import { runBridgeContractTests } from "@xmachines/play-router-shared/test/router-bridge-contract.js";
|
|
@@ -344,15 +357,19 @@ runBridgeContractTests({
|
|
|
344
357
|
createHarness(initialPath) {
|
|
345
358
|
// return ContractHarness with bridge, actor, simulateNavigation, getLastNavigatedPath
|
|
346
359
|
},
|
|
360
|
+
createRestoredHarness(routedPath) {
|
|
361
|
+
// return ContractHarness whose actor is restored to routedPath
|
|
362
|
+
// while the mock router starts at the machine's initial route
|
|
363
|
+
},
|
|
347
364
|
});
|
|
348
365
|
```
|
|
349
366
|
|
|
350
367
|
## Related Packages
|
|
351
368
|
|
|
352
369
|
- **[@xmachines/play](../play/README.md)** — Core protocol types (`PlayEvent`, `PlayError`)
|
|
353
|
-
- **[@xmachines/play-actor](../play-actor/README.md)** —
|
|
354
|
-
- **[@xmachines/play-signals](../play-signals/README.md)** — TC39 Signals polyfill
|
|
355
|
-
- **[@xmachines/play-xstate](../play-xstate/README.md)** — XState v5 logic adapter
|
|
370
|
+
- **[@xmachines/play-actor](../play-actor/README.md)** — the abstract actor base class (`AbstractActor`, `Routable`). Every `AbstractActor` subclass satisfies `RoutableActor` structurally
|
|
371
|
+
- **[@xmachines/play-signals](../play-signals/README.md)** — the TC39 Signals polyfill that observes the actor route
|
|
372
|
+
- **[@xmachines/play-xstate](../play-xstate/README.md)** — the XState v5 logic adapter, which works with a route tree
|
|
356
373
|
- **[@xmachines/play-tanstack-router](../play-tanstack-router/README.md)** — Shared TanStack Router bridge base (framework-agnostic)
|
|
357
374
|
- **[@xmachines/play-tanstack-react-router](../play-tanstack-react-router/README.md)** — TanStack Router adapter (React)
|
|
358
375
|
- **[@xmachines/play-tanstack-solid-router](../play-tanstack-solid-router/README.md)** — TanStack Router adapter (SolidJS)
|
|
@@ -392,6 +409,7 @@ MIT — see [LICENSE](LICENSE).
|
|
|
392
409
|
|
|
393
410
|
## Type Aliases
|
|
394
411
|
|
|
412
|
+
- [~~BaseRouteMapping~~](type-aliases/BaseRouteMapping.md)
|
|
395
413
|
- [MachineGraph](type-aliases/MachineGraph.md)
|
|
396
414
|
- [RouteMetadata](type-aliases/RouteMetadata.md)
|
|
397
415
|
|
|
@@ -416,9 +434,3 @@ MIT — see [LICENSE](LICENSE).
|
|
|
416
434
|
- [sanitizePathname](functions/sanitizePathname.md)
|
|
417
435
|
- [validateRouteFormat](functions/validateRouteFormat.md)
|
|
418
436
|
- [validateStateExists](functions/validateStateExists.md)
|
|
419
|
-
|
|
420
|
-
## References
|
|
421
|
-
|
|
422
|
-
### BaseRouteMapping
|
|
423
|
-
|
|
424
|
-
Renames and re-exports [RouteMapping](interfaces/RouteMapping.md)
|
|
@@ -2,32 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
# Class: RouteMap
|
|
4
4
|
|
|
5
|
-
Defined in: [base-route-map.ts:
|
|
5
|
+
Defined in: [base-route-map.ts:105](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/base-route-map.ts#L105)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The shared base class of the route map for both directions.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
own and
|
|
9
|
+
Every framework adapter uses this class as its route map. An adapter adds no logic
|
|
10
|
+
of its own, and it inherits the complete public API from here.
|
|
11
11
|
|
|
12
|
-
**
|
|
12
|
+
**The strategy of a lookup:**
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
of routes
|
|
17
|
-
-
|
|
18
|
-
|
|
14
|
+
- A static path, without a `:param` → a `Map` lookup in O(1)
|
|
15
|
+
- A dynamic path → a scan of the bucket index in O(k), with `URLPattern`, where
|
|
16
|
+
`k` is the number of the routes with the same first path segment
|
|
17
|
+
- The class keeps each result of a first match in an LRU cache. The default size
|
|
18
|
+
is 500 entries, and the `cacheSize` constructor option changes it
|
|
19
19
|
|
|
20
|
-
**
|
|
20
|
+
**The syntax of a pattern** (`:param`, `:param?`, and `*`):
|
|
21
21
|
|
|
22
|
-
- `:param` —
|
|
23
|
-
- `:param?` — optional segment
|
|
24
|
-
- `*` — wildcard
|
|
22
|
+
- `:param` — a necessary segment. It matches exactly one segment without a `/`
|
|
23
|
+
- `:param?` — an optional segment. It matches zero segments or one segment without a `/`
|
|
24
|
+
- `*` — a wildcard. It matches each number of segments, as URLPattern defines
|
|
25
25
|
|
|
26
|
-
**
|
|
27
|
-
`"#stateId"` or `"stateId"
|
|
28
|
-
`getStateIdByPath` returns the stateId exactly as
|
|
29
|
-
`getPathByStateId` accepts both forms.
|
|
30
|
-
forms
|
|
26
|
+
**The forms of a stateId:** you can register a stateId, and you can look one up,
|
|
27
|
+
in the form `"#stateId"` or in the form `"stateId"`. `RouteMap` makes the
|
|
28
|
+
canonical form itself. `getStateIdByPath` returns the stateId exactly as you
|
|
29
|
+
registered it, and `getPathByStateId` accepts both forms. A registration of the
|
|
30
|
+
same stateId in both forms gives one entry, and the later registration wins for
|
|
31
|
+
the lookup in the other direction.
|
|
31
32
|
|
|
32
33
|
## Example
|
|
33
34
|
|
|
@@ -57,21 +58,22 @@ map.getPathByStateId("missing"); // null
|
|
|
57
58
|
new RouteMap(mappings, options?): RouteMap;
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
Defined in: [base-route-map.ts:
|
|
61
|
+
Defined in: [base-route-map.ts:133](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/base-route-map.ts#L133)
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
Builds a route map from an array of the mappings between a state ID and a path.
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
buckets
|
|
65
|
+
The constructor puts each static path, which holds no `:param`, into a `Map` for a
|
|
66
|
+
lookup in O(1). It compiles each parameterized path to a `URLPattern`, and it
|
|
67
|
+
groups the patterns into the buckets of the first segment. The selection of the
|
|
68
|
+
candidates is therefore efficient.
|
|
67
69
|
|
|
68
70
|
#### Parameters
|
|
69
71
|
|
|
70
|
-
| Parameter | Type | Description
|
|
71
|
-
| -------------------- | ------------------------------------------------- |
|
|
72
|
-
| `mappings` | [`RouteMapping`](../interfaces/RouteMapping.md)[] |
|
|
73
|
-
| `options` | \{ `cacheSize?`: `number`; \} |
|
|
74
|
-
| `options.cacheSize?` | `number` | -
|
|
72
|
+
| Parameter | Type | Description |
|
|
73
|
+
| -------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| `mappings` | [`RouteMapping`](../interfaces/RouteMapping.md)[] | The array of the `{ stateId, path }` entries. The order gives the priority when more than one pattern can match the same path. |
|
|
75
|
+
| `options` | \{ `cacheSize?`: `number`; \} | The optional configuration. `options.cacheSize`: the maximum number of the resolved parameterized path lookups in the cache. The default is `500`. Raise it for an application with many different values in a parameterized URL, for example a page of a user profile with thousands of different IDs. After an eviction, the path goes to the bucket pattern scan in O(k) again, which is correct but slower. The smallest effective value is `1`, because QuickLRU requires it. |
|
|
76
|
+
| `options.cacheSize?` | `number` | - |
|
|
75
77
|
|
|
76
78
|
#### Returns
|
|
77
79
|
|
|
@@ -85,31 +87,31 @@ buckets for efficient candidate selection.
|
|
|
85
87
|
getPathByStateId(stateId): string | null;
|
|
86
88
|
```
|
|
87
89
|
|
|
88
|
-
Defined in: [base-route-map.ts:
|
|
90
|
+
Defined in: [base-route-map.ts:225](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/base-route-map.ts#L225)
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
Returns the path pattern of a state ID.
|
|
91
93
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
The method accepts the stateId in the form `"#stateId"` and in the form
|
|
95
|
+
`"stateId"`, and the form of the registration has no effect. The method makes the
|
|
96
|
+
canonical form itself. Therefore a consumer tries never both forms.
|
|
95
97
|
|
|
96
98
|
#### Parameters
|
|
97
99
|
|
|
98
|
-
| Parameter | Type | Description
|
|
99
|
-
| --------- | -------- |
|
|
100
|
-
| `stateId` | `string` |
|
|
100
|
+
| Parameter | Type | Description |
|
|
101
|
+
| --------- | -------- | --------------------------------------------------------------------------- |
|
|
102
|
+
| `stateId` | `string` | The state ID of the state machine, for example `"profile"` or `"#settings"` |
|
|
101
103
|
|
|
102
104
|
#### Returns
|
|
103
105
|
|
|
104
106
|
`string` \| `null`
|
|
105
107
|
|
|
106
|
-
The registered path pattern, or `null`
|
|
108
|
+
The registered path pattern, or `null` when the state ID is unknown
|
|
107
109
|
|
|
108
110
|
#### Example
|
|
109
111
|
|
|
110
112
|
```typescript
|
|
111
113
|
map.getPathByStateId("profile"); // "/profile/:userId"
|
|
112
|
-
map.getPathByStateId("#profile"); // "/profile/:userId"
|
|
114
|
+
map.getPathByStateId("#profile"); // "/profile/:userId" — the same entry
|
|
113
115
|
map.getPathByStateId("missing"); // null
|
|
114
116
|
```
|
|
115
117
|
|
|
@@ -121,25 +123,25 @@ map.getPathByStateId("missing"); // null
|
|
|
121
123
|
getStateIdByPath(path): string | null;
|
|
122
124
|
```
|
|
123
125
|
|
|
124
|
-
Defined in: [base-route-map.ts:
|
|
126
|
+
Defined in: [base-route-map.ts:185](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/base-route-map.ts#L185)
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
Resolves a URL path to its state ID.
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
lookup first, then
|
|
130
|
-
|
|
130
|
+
The method removes the query string and the hash fragment before the match. It
|
|
131
|
+
tries an exact lookup in O(1) first, then it uses the pattern match on the bucket
|
|
132
|
+
index. It keeps each result of a first pattern match in the cache.
|
|
131
133
|
|
|
132
134
|
#### Parameters
|
|
133
135
|
|
|
134
|
-
| Parameter | Type | Description
|
|
135
|
-
| --------- | -------- |
|
|
136
|
-
| `path` | `string` | URL pathname
|
|
136
|
+
| Parameter | Type | Description |
|
|
137
|
+
| --------- | -------- | -------------------------------------------------------------------------------------- |
|
|
138
|
+
| `path` | `string` | The URL pathname. It can hold a query and a hash, for example `"/profile/123?ref=nav"` |
|
|
137
139
|
|
|
138
140
|
#### Returns
|
|
139
141
|
|
|
140
142
|
`string` \| `null`
|
|
141
143
|
|
|
142
|
-
The
|
|
144
|
+
The state ID of the path, or `null` when no route matches
|
|
143
145
|
|
|
144
146
|
#### Example
|
|
145
147
|
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
# Abstract Class: RouterBridgeBase
|
|
4
4
|
|
|
5
|
-
Defined in: [router-bridge-base.ts:
|
|
5
|
+
Defined in: [router-bridge-base.ts:99](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/router-bridge-base.ts#L99)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The abstract base class of every router adapter bridge of `@xmachines`.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
The class implements the RouterBridge protocol, and it holds every part of the
|
|
10
|
+
bridge logic that the adapters share. A subclass implements the 3 abstract methods
|
|
11
|
+
that are different in each framework, and it implements nothing more.
|
|
12
12
|
|
|
13
13
|
## Extended by
|
|
14
14
|
|
|
15
|
+
- [`DomRouterBridge`](../../play-dom-router/classes/DomRouterBridge.md)
|
|
15
16
|
- [`ReactRouterBridge`](../../play-react-router/classes/ReactRouterBridge.md)
|
|
16
17
|
- [`TanStackRouterBridgeBase`](../../play-tanstack-router/classes/TanStackRouterBridgeBase.md)
|
|
17
18
|
- [`SolidRouterBridge`](../../play-solid-router/classes/SolidRouterBridge.md)
|
|
19
|
+
- [`SvelteKitRouterBridge`](../../play-sveltekit-router/classes/SvelteKitRouterBridge.md)
|
|
20
|
+
- [`SvelteSpaRouterBridge`](../../play-svelte-spa-router/classes/SvelteSpaRouterBridge.md)
|
|
18
21
|
- [`TanStackReactRouterBridge`](../../play-tanstack-react-router/classes/TanStackReactRouterBridge.md)
|
|
19
22
|
- [`VueRouterBridge`](../../play-vue-router/classes/VueRouterBridge.md)
|
|
20
23
|
|
|
@@ -30,14 +33,14 @@ between frameworks.
|
|
|
30
33
|
new RouterBridgeBase(actor, routeMap): RouterBridgeBase;
|
|
31
34
|
```
|
|
32
35
|
|
|
33
|
-
Defined in: [router-bridge-base.ts:
|
|
36
|
+
Defined in: [router-bridge-base.ts:127](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/router-bridge-base.ts#L127)
|
|
34
37
|
|
|
35
38
|
#### Parameters
|
|
36
39
|
|
|
37
|
-
| Parameter | Type | Description
|
|
38
|
-
| --------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
-
| `actor` | [`RoutableActor`](../interfaces/RoutableActor.md) | A `RoutableActor
|
|
40
|
-
| `routeMap` | \{ `getPathByStateId`: `string` \| `null` \| `undefined`; `getStateIdByPath`: `string` \| `null` \| `undefined`; \} |
|
|
40
|
+
| Parameter | Type | Description |
|
|
41
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
42
|
+
| `actor` | [`RoutableActor`](../interfaces/RoutableActor.md) | A `RoutableActor`, with `currentRoute`, `initialRoute`, and `send`. |
|
|
43
|
+
| `routeMap` | \{ `getPathByStateId`: `string` \| `null` \| `undefined`; `getStateIdByPath`: `string` \| `null` \| `undefined`; \} | The route map of both directions, for the resolution between a `stateId` and a `path`. Give `getStateIdByPath` and `getPathByStateId`. A framework adapter usually wraps the result of `createRouteMap(machine)`, or an equivalent value. The key of `getPathByStateId` is the form `"#stateId"` or the bare form `"stateId"`. The bridge tries both forms. Therefore an implementation of your own, for example a plain test object, handles one form only. |
|
|
41
44
|
| `routeMap.getPathByStateId` | - |
|
|
42
45
|
| `routeMap.getStateIdByPath` | - |
|
|
43
46
|
|
|
@@ -53,21 +56,23 @@ Defined in: [router-bridge-base.ts:123](https://gitlab.com/xmachin-es/xmachines-
|
|
|
53
56
|
connect(): void;
|
|
54
57
|
```
|
|
55
58
|
|
|
56
|
-
Defined in: [router-bridge-base.ts:
|
|
59
|
+
Defined in: [router-bridge-base.ts:158](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/router-bridge-base.ts#L158)
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
Connects the router bridge to the Actor.
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
starts
|
|
63
|
+
The method installs the TC39 Signal watcher of the direction from the actor to the
|
|
64
|
+
router. It then starts the watch of the router changes, which each framework does
|
|
65
|
+
in its own way.
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
The order of these steps is part of the contract of the bridge:
|
|
64
68
|
|
|
65
|
-
- `lastSyncedPath`
|
|
66
|
-
- the actor watcher
|
|
67
|
-
-
|
|
69
|
+
- The constructor seeds `lastSyncedPath` from `actor.currentRoute`
|
|
70
|
+
- The method installs the actor watcher before the router subscriptions of the adapter
|
|
71
|
+
- The first synchronization then separates a deep link from a restore, with `actor.initialRoute`
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
`getInitialRouterPath()
|
|
73
|
+
An adapter that needs a different behavior of the first synchronization overrides
|
|
74
|
+
`getInitialRouterPath()`. It does not change the order of the steps of
|
|
75
|
+
`connect()`.
|
|
71
76
|
|
|
72
77
|
#### Returns
|
|
73
78
|
|
|
@@ -85,11 +90,12 @@ Adapters that need custom initial-sync behavior should override
|
|
|
85
90
|
disconnect(): void;
|
|
86
91
|
```
|
|
87
92
|
|
|
88
|
-
Defined in: [router-bridge-base.ts:
|
|
93
|
+
Defined in: [router-bridge-base.ts:270](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/router-bridge-base.ts#L270)
|
|
89
94
|
|
|
90
|
-
|
|
95
|
+
Disconnects the router bridge from the Actor.
|
|
91
96
|
|
|
92
|
-
|
|
97
|
+
The method stops the watch of the signal, and it removes the router listener of the
|
|
98
|
+
framework.
|
|
93
99
|
|
|
94
100
|
#### Returns
|
|
95
101
|
|