@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
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# `@xmachines/play-react-router`
|
|
4
4
|
|
|
5
|
-
> React Router v7 adapter for the XMachines Play Universal Player Architecture
|
|
5
|
+
> React Router v7 adapter for the XMachines Play Universal Player Architecture. It keeps the actor state and the browser URL in step, in both directions, through the `createBrowserRouter` data API.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-react-router)
|
|
7
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-react-router)
|
|
10
8
|
|
|
11
9
|
---
|
|
12
10
|
|
|
@@ -16,7 +14,7 @@ Part of the [XMachines Play monorepo](../../README.md).
|
|
|
16
14
|
pnpm add @xmachines/play-react-router
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
**Peer dependencies
|
|
17
|
+
**Peer dependencies.** Install them if they are not present:
|
|
20
18
|
|
|
21
19
|
```bash
|
|
22
20
|
pnpm add react@"^18 || ^19" react-router@"^7.0.0" xstate@"^5.31.0"
|
|
@@ -28,9 +26,9 @@ pnpm add react@"^18 || ^19" react-router@"^7.0.0" xstate@"^5.31.0"
|
|
|
28
26
|
|
|
29
27
|
### `PlayRouterProvider` — Recommended (React component)
|
|
30
28
|
|
|
31
|
-
`PlayRouterProvider` connects a `PlayerActor` to React Router inside a React component tree. It creates a `ReactRouterBridge` on mount
|
|
29
|
+
`PlayRouterProvider` connects a `PlayerActor` to React Router inside a React component tree. It creates a `ReactRouterBridge` on mount. It keeps the actor state and the browser URL in step, in both directions. It disconnects the bridge on unmount.
|
|
32
30
|
|
|
33
|
-
> **All three props (`actor`, `router`, `routeMap`) must be stable references.** Create them outside
|
|
31
|
+
> **All three props (`actor`, `router`, `routeMap`) must be stable references.** Create them outside the JSX, or hold them with `useMemo`. An inline value makes the bridge disconnect and connect again on every render.
|
|
34
32
|
|
|
35
33
|
```tsx
|
|
36
34
|
import { useMemo, useEffect } from "react";
|
|
@@ -42,6 +40,12 @@ import { myMachine } from "./machine.js";
|
|
|
42
40
|
const createPlayer = definePlayer({ machine: myMachine });
|
|
43
41
|
const routeMap = createRouteMap(myMachine);
|
|
44
42
|
|
|
43
|
+
// Minimal app shell stub — a real app renders PlayUIProvider + PlayRenderer from
|
|
44
|
+
// @xmachines/play-react here (see the workspace-only @xmachines/play-react-demo Shell)
|
|
45
|
+
function App({ actor }: { actor: ReturnType<typeof createPlayer> }) {
|
|
46
|
+
return <main />; // render your UI from the actor here
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
function createAppRuntime() {
|
|
46
50
|
const actor = createPlayer();
|
|
47
51
|
actor.start();
|
|
@@ -69,13 +73,17 @@ export default function Root() {
|
|
|
69
73
|
|
|
70
74
|
Use `ReactRouterBridge` directly when you need imperative lifecycle control outside React.
|
|
71
75
|
|
|
72
|
-
> **
|
|
76
|
+
> **The bridge requires `createBrowserRouter`** (the data router API). It does not support the old `<BrowserRouter>` component, because that component has no `subscribe` or `navigate` API.
|
|
73
77
|
|
|
74
78
|
```typescript
|
|
75
79
|
import { createBrowserRouter } from "react-router";
|
|
76
80
|
import { ReactRouterBridge, createRouteMap } from "@xmachines/play-react-router";
|
|
81
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
77
82
|
import { myMachine } from "./machine.js";
|
|
78
83
|
|
|
84
|
+
const actor = definePlayer({ machine: myMachine })();
|
|
85
|
+
actor.start();
|
|
86
|
+
|
|
79
87
|
const router = createBrowserRouter([/* routes */]);
|
|
80
88
|
const routeMap = createRouteMap(myMachine);
|
|
81
89
|
|
|
@@ -113,29 +121,29 @@ interface PlayRouterProviderProps<TActor> {
|
|
|
113
121
|
|
|
114
122
|
Extends `RouterBridgeBase` from `@xmachines/play-router`. Implements the `RouterBridge` protocol.
|
|
115
123
|
|
|
116
|
-
| Method | Description
|
|
117
|
-
| -------------- |
|
|
118
|
-
| `connect()` | Subscribes to router changes and
|
|
119
|
-
| `disconnect()` |
|
|
124
|
+
| Method | Description |
|
|
125
|
+
| -------------- | ------------------------------------------------------------------------------ |
|
|
126
|
+
| `connect()` | Subscribes to the router changes and sets the actor state from the current URL |
|
|
127
|
+
| `disconnect()` | Cancels the subscription and stops all synchronization |
|
|
120
128
|
|
|
121
129
|
### Types exported from this package
|
|
122
130
|
|
|
123
|
-
| Export | Description
|
|
124
|
-
| ------------------------- |
|
|
125
|
-
| `PlayRouterProviderProps` | Props interface for `PlayRouterProvider`
|
|
126
|
-
| `PlayActor` |
|
|
131
|
+
| Export | Description |
|
|
132
|
+
| ------------------------- | -------------------------------------------------------------------------------- |
|
|
133
|
+
| `PlayRouterProviderProps` | Props interface for `PlayRouterProvider` |
|
|
134
|
+
| `PlayActor` | The constraint type for an actor that `PlayRouterProvider` and the bridge accept |
|
|
127
135
|
|
|
128
136
|
### Route map utilities (re-exported from `@xmachines/play-router`)
|
|
129
137
|
|
|
130
|
-
| Export | Description
|
|
131
|
-
| ------------------------------ |
|
|
132
|
-
| `RouteMap` | Bidirectional state ID ↔ URL path map
|
|
133
|
-
| `createRouteMap(machine)` | Build a `RouteMap` directly from an XState machine definition
|
|
134
|
-
| `createRouteMapFromTree(tree)` | Build a `RouteMap` from a `RouteTree` object
|
|
135
|
-
| `RouteMapOptions` | Options type for `createRouteMap`
|
|
136
|
-
| `RouteMapping` | Type for a single `{ stateId, path }` entry
|
|
137
|
-
| `RouterBridge` | Interface that `ReactRouterBridge` satisfies
|
|
138
|
-
| `PlayRouteEvent` | The `play.route` event type
|
|
138
|
+
| Export | Description |
|
|
139
|
+
| ------------------------------ | ------------------------------------------------------------------------- |
|
|
140
|
+
| `RouteMap` | Bidirectional state ID ↔ URL path map |
|
|
141
|
+
| `createRouteMap(machine)` | Build a `RouteMap` directly from an XState machine definition |
|
|
142
|
+
| `createRouteMapFromTree(tree)` | Build a `RouteMap` from a `RouteTree` object |
|
|
143
|
+
| `RouteMapOptions` | Options type for `createRouteMap` |
|
|
144
|
+
| `RouteMapping` | Type for a single `{ stateId, path }` entry |
|
|
145
|
+
| `RouterBridge` | Interface that `ReactRouterBridge` satisfies |
|
|
146
|
+
| `PlayRouteEvent` | The `play.route` event type that a router sends to an actor on navigation |
|
|
139
147
|
|
|
140
148
|
---
|
|
141
149
|
|
|
@@ -155,7 +163,7 @@ pnpm test
|
|
|
155
163
|
|
|
156
164
|
Tests use [Vitest](https://vitest.dev/). Component tests (`*.test.tsx`) run in a `jsdom` environment via `@testing-library/react`. Unit tests (`*.test.ts`) run in Node.
|
|
157
165
|
|
|
158
|
-
**Browser tests** (`test/browser/**/*.browser.test.ts`) run
|
|
166
|
+
**Browser tests** (`test/browser/**/*.browser.test.ts`) run in real Chromium through Playwright. They cover the asynchronous sequences that jsdom cannot reproduce: BACK and FORWARD navigation, the callback order of `router.subscribe`, echo suppression under real microtask timing, and subscriber teardown on `disconnect()`.
|
|
159
167
|
|
|
160
168
|
```bash
|
|
161
169
|
# Run browser tests only
|
|
@@ -179,8 +187,9 @@ Coverage thresholds (v8 provider):
|
|
|
179
187
|
|
|
180
188
|
@xmachines/play-react-router
|
|
181
189
|
|
|
182
|
-
React Router v7 adapter for XMachines Play architecture.
|
|
183
|
-
|
|
190
|
+
React Router v7 adapter for the XMachines Play architecture.
|
|
191
|
+
It keeps the browser URL and the actor state in step through the
|
|
192
|
+
createBrowserRouter data API.
|
|
184
193
|
|
|
185
194
|
## Classes
|
|
186
195
|
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
# Class: ReactRouterBridge
|
|
4
4
|
|
|
5
|
-
Defined in: [play-react-router/src/react-router-bridge.ts:
|
|
5
|
+
Defined in: [play-react-router/src/react-router-bridge.ts:29](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-react-router/src/react-router-bridge.ts#L29)
|
|
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
|
## Extends
|
|
14
14
|
|
|
@@ -25,7 +25,7 @@ new ReactRouterBridge(
|
|
|
25
25
|
routeMap): ReactRouterBridge;
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
Defined in: [play-react-router/src/react-router-bridge.ts:
|
|
28
|
+
Defined in: [play-react-router/src/react-router-bridge.ts:32](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-react-router/src/react-router-bridge.ts#L32)
|
|
29
29
|
|
|
30
30
|
#### Parameters
|
|
31
31
|
|
|
@@ -51,21 +51,23 @@ Defined in: [play-react-router/src/react-router-bridge.ts:30](https://gitlab.com
|
|
|
51
51
|
connect(): void;
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Defined in: [play-router/src/router-bridge-base.ts:
|
|
54
|
+
Defined in: [play-router/src/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)
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Connects the router bridge to the Actor.
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
starts
|
|
58
|
+
The method installs the TC39 Signal watcher of the direction from the actor to the
|
|
59
|
+
router. It then starts the watch of the router changes, which each framework does
|
|
60
|
+
in its own way.
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
The order of these steps is part of the contract of the bridge:
|
|
62
63
|
|
|
63
|
-
- `lastSyncedPath`
|
|
64
|
-
- the actor watcher
|
|
65
|
-
-
|
|
64
|
+
- The constructor seeds `lastSyncedPath` from `actor.currentRoute`
|
|
65
|
+
- The method installs the actor watcher before the router subscriptions of the adapter
|
|
66
|
+
- The first synchronization then separates a deep link from a restore, with `actor.initialRoute`
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
`getInitialRouterPath()
|
|
68
|
+
An adapter that needs a different behavior of the first synchronization overrides
|
|
69
|
+
`getInitialRouterPath()`. It does not change the order of the steps of
|
|
70
|
+
`connect()`.
|
|
69
71
|
|
|
70
72
|
#### Returns
|
|
71
73
|
|
|
@@ -83,11 +85,12 @@ Adapters that need custom initial-sync behavior should override
|
|
|
83
85
|
disconnect(): void;
|
|
84
86
|
```
|
|
85
87
|
|
|
86
|
-
Defined in: [play-router/src/router-bridge-base.ts:
|
|
88
|
+
Defined in: [play-router/src/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)
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
Disconnects the router bridge from the Actor.
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
The method stops the watch of the signal, and it removes the router listener of the
|
|
93
|
+
framework.
|
|
91
94
|
|
|
92
95
|
#### Returns
|
|
93
96
|
|
|
@@ -2,32 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
# Class: RouteMap
|
|
4
4
|
|
|
5
|
-
Defined in: [play-router/src/base-route-map.ts:
|
|
5
|
+
Defined in: [play-router/src/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: [play-router/src/base-route-map.ts:
|
|
61
|
+
Defined in: [play-router/src/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: [play-router/src/base-route-map.ts:
|
|
90
|
+
Defined in: [play-router/src/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: [play-router/src/base-route-map.ts:
|
|
126
|
+
Defined in: [play-router/src/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
|
|
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
function createPlayRouterProvider<TRouter>(BridgeCtor): <TActor>(__namedParameters) => Element;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-react-router/src/create-play-router-provider.tsx:
|
|
9
|
+
Defined in: [play-react-router/src/create-play-router-provider.tsx:83](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-react-router/src/create-play-router-provider.tsx#L83)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Creates a React `PlayRouterProvider` component of one bridge class.
|
|
12
12
|
|
|
13
|
-
The
|
|
14
|
-
|
|
13
|
+
The component of the return value connects a `PlayerActor` to the framework
|
|
14
|
+
router. It keeps the actor state and the browser URL in step, in both directions.
|
|
15
15
|
|
|
16
|
-
The bridge
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
The component creates the bridge one time, on mount, and it disconnects the bridge
|
|
17
|
+
on unmount. It also builds the bridge again on a change of the identity of `actor`,
|
|
18
|
+
of `router`, or of `routeMap`. Therefore all three props must be **stable
|
|
19
|
+
references**: create them outside the JSX, or hold them with `useMemo`. Under the
|
|
20
|
+
React `<StrictMode>`, the effect runs two times on mount (connect, disconnect,
|
|
21
|
+
connect), and the bridges support this.
|
|
21
22
|
|
|
22
23
|
## Type Parameters
|
|
23
24
|
|
|
@@ -27,14 +28,15 @@ Under React `<StrictMode>` the effect runs twice on mount
|
|
|
27
28
|
|
|
28
29
|
## Parameters
|
|
29
30
|
|
|
30
|
-
| Parameter | Type | Description
|
|
31
|
-
| ------------ | -------------------------------------------------------------------------------------------- |
|
|
32
|
-
| `BridgeCtor` | [`PlayRouterBridgeConstructor`](../type-aliases/PlayRouterBridgeConstructor.md)\<`TRouter`\> |
|
|
31
|
+
| Parameter | Type | Description |
|
|
32
|
+
| ------------ | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
33
|
+
| `BridgeCtor` | [`PlayRouterBridgeConstructor`](../type-aliases/PlayRouterBridgeConstructor.md)\<`TRouter`\> | The bridge class. The provider builds it as `new BridgeCtor(router, actor, routeMap)`. |
|
|
33
34
|
|
|
34
35
|
## Returns
|
|
35
36
|
|
|
36
|
-
A `PlayRouterProvider` component
|
|
37
|
-
`renderer` callback receives the same concrete actor type
|
|
37
|
+
A `PlayRouterProvider` component. It is generic over the actor type.
|
|
38
|
+
Therefore the `renderer` callback receives the same concrete actor type as the
|
|
39
|
+
prop.
|
|
38
40
|
|
|
39
41
|
\<`TActor`\>(`__namedParameters`) => `Element`
|
|
40
42
|
|
|
@@ -6,27 +6,28 @@
|
|
|
6
6
|
function createRouteMap(machine, options?): RouteMap;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-router/src/create-route-map.ts:
|
|
9
|
+
Defined in: [play-router/src/create-route-map.ts:47](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/create-route-map.ts#L47)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Creates a `RouteMap` from an XState state machine.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
The function reads every state with a route, which means each state with a
|
|
14
|
+
`meta.route` field. It then builds the lookup structure between a path and a
|
|
15
|
+
stateId, for both directions. A subclass of `RouterBridgeBase` uses the map: it
|
|
16
|
+
converts each change of the browser URL into a `play.route` actor event, and each
|
|
17
|
+
actor route into a URL.
|
|
17
18
|
|
|
18
19
|
## Parameters
|
|
19
20
|
|
|
20
|
-
| Parameter | Type | Description
|
|
21
|
-
| ---------- | ------------------------------------------------------------------------- |
|
|
22
|
-
| `machine` | [`AnyStateMachine`](https://www.jsdocs.io/package/xstate#AnyStateMachine) | XState v5 state machine with `meta.route`
|
|
23
|
-
| `options?` | [`RouteMapOptions`](../interfaces/RouteMapOptions.md) |
|
|
21
|
+
| Parameter | Type | Description |
|
|
22
|
+
| ---------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| `machine` | [`AnyStateMachine`](https://www.jsdocs.io/package/xstate#AnyStateMachine) | The XState v5 state machine, with a `meta.route` annotation on each state with a route. |
|
|
24
|
+
| `options?` | [`RouteMapOptions`](../interfaces/RouteMapOptions.md) | The optional configuration. Give `{ cacheSize }` to change the default size of the LRU cache of the parameterized path lookups. |
|
|
24
25
|
|
|
25
26
|
## Returns
|
|
26
27
|
|
|
27
28
|
[`RouteMap`](../classes/RouteMap.md)
|
|
28
29
|
|
|
29
|
-
A `RouteMap` for
|
|
30
|
+
A `RouteMap` for each adapter on `RouterBridgeBase`.
|
|
30
31
|
|
|
31
32
|
## Example
|
|
32
33
|
|
|
@@ -6,41 +6,41 @@
|
|
|
6
6
|
function createRouteMapFromTree(routeTree, options?): RouteMap;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-router/src/create-route-map-from-tree.ts:33](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.
|
|
9
|
+
Defined in: [play-router/src/create-route-map-from-tree.ts:33](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/create-route-map-from-tree.ts#L33)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Creates a `RouteMap` from the node structure of a `RouteTree`.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
`
|
|
15
|
-
`createRouteMap()` directly.
|
|
13
|
+
A framework router adapter uses this function when it gives a `RouteTree` from
|
|
14
|
+
`extractMachineRoutes()`, and not when it calls `createRouteMap()` directly.
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
`node.fullPath` is always the
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
The function walks every node, and it collects the pairs
|
|
17
|
+
`{ stateId: node.id, path: node.fullPath }`. `node.fullPath` is always the
|
|
18
|
+
absolute resolved path, for example `"/dashboard/overview"`, and `RouteMap` needs
|
|
19
|
+
that path for the match of a browser URL. `createRouteMap(machine)` behaves in the
|
|
20
|
+
same way, because it also uses `node.fullPath`.
|
|
21
21
|
|
|
22
22
|
## Parameters
|
|
23
23
|
|
|
24
|
-
| Parameter | Type | Description
|
|
25
|
-
| ----------- | -------------------------------------------------------- |
|
|
26
|
-
| `routeTree` | [`RouteTree`](../../play-router/interfaces/RouteTree.md) | A `RouteTree
|
|
27
|
-
| `options?` | [`RouteMapOptions`](../interfaces/RouteMapOptions.md) |
|
|
24
|
+
| Parameter | Type | Description |
|
|
25
|
+
| ----------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
26
|
+
| `routeTree` | [`RouteTree`](../../play-router/interfaces/RouteTree.md) | A `RouteTree`, as `extractMachineRoutes()` returns it. |
|
|
27
|
+
| `options?` | [`RouteMapOptions`](../interfaces/RouteMapOptions.md) | The optional configuration, for example `{ cacheSize }` to change the size of the LRU cache. |
|
|
28
28
|
|
|
29
29
|
## Returns
|
|
30
30
|
|
|
31
31
|
[`RouteMap`](../classes/RouteMap.md)
|
|
32
32
|
|
|
33
|
-
A `RouteMap` for
|
|
33
|
+
A `RouteMap` for each adapter on `RouterBridgeBase`.
|
|
34
34
|
|
|
35
35
|
## Example
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
//
|
|
38
|
+
// The preferred form — one call for an XState machine:
|
|
39
39
|
import { createRouteMap } from "@xmachines/play-router";
|
|
40
|
-
const routeMap = createRouteMap(machine); // takes AnyStateMachine
|
|
40
|
+
const routeMap = createRouteMap(machine); // it takes an AnyStateMachine
|
|
41
41
|
|
|
42
|
-
//
|
|
42
|
+
// The two-step form, for a framework adapter that works with a route tree:
|
|
43
43
|
import { extractMachineRoutes, createRouteMapFromTree } from "@xmachines/play-router";
|
|
44
44
|
const routeTree = extractMachineRoutes(machine);
|
|
45
|
-
const routeMap = createRouteMapFromTree(routeTree); // uses node.fullPath
|
|
45
|
+
const routeMap = createRouteMapFromTree(routeTree); // it uses node.fullPath, which is absolute
|
|
46
46
|
```
|