@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,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
**Vanilla DOM router (Browser History API) for XMachines Play Architecture.**
|
|
6
6
|
|
|
7
|
-
[](https://opensource.org/licenses/MIT) [](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-dom-router)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This framework-agnostic router integration keeps the `currentRoute` TC39 Signal of a Play actor and the `window.history` API of the browser in step. It needs no framework. It implements the same [`RouterBridgeBase`](../play-router/README.md) pattern as every other router adapter in the XMachines ecosystem.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -24,19 +24,20 @@ pnpm add xstate@^5.31.0
|
|
|
24
24
|
|
|
25
25
|
[`@xmachines/play-dom-router`](README.md) connects a Play actor to the browser URL through the `DomRouterBridge` (extends `RouterBridgeBase` from [`@xmachines/play-router`](../play-router/README.md)):
|
|
26
26
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
27
|
+
- The actor route signal (`actor.currentRoute`) drives `history.push()`. The actor is the authority.
|
|
28
|
+
- Each browser navigation event (`popstate`, `pushState`, `replaceState`) sends a `play.route` intent to the actor.
|
|
29
|
+
- The actor keeps the ownership of each guarded state transition (Actor Authority).
|
|
30
|
+
- The `isProcessingNavigation` flag stops a circular update. The bridge inherits the flag from `RouterBridgeBase`.
|
|
31
31
|
|
|
32
32
|
## Key Exports
|
|
33
33
|
|
|
34
34
|
| Export | Description |
|
|
35
35
|
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
36
36
|
| `createBrowserHistory(options)` | Wraps `window.history` with a subscribable `BrowserHistory` interface |
|
|
37
|
-
| `createRouter(options)` | Creates a `VanillaRouter`
|
|
37
|
+
| `createRouter(options)` | Creates a `VanillaRouter` from a `BrowserHistory` and a `RouteTree` |
|
|
38
38
|
| `connectRouter(options)` | Connects a `VanillaRouter` to a `Routable` actor — returns a `disconnect` cleanup function |
|
|
39
|
-
| `
|
|
39
|
+
| `DomRouterBridge` | The low-level bridge class. It extends `RouterBridgeBase`. Use it directly for full lifecycle control |
|
|
40
|
+
| `createRouteMap` | It comes from `@xmachines/play-router`. It builds the bidirectional path ↔ state ID map |
|
|
40
41
|
| `BrowserHistory` | Interface for the history wrapper |
|
|
41
42
|
| `BrowserWindow` | Structural window interface (accepts `Window`, JSDOM, or any test double) |
|
|
42
43
|
| `VanillaRouter` | Interface for the router wrapper |
|
|
@@ -49,6 +50,8 @@ pnpm add xstate@^5.31.0
|
|
|
49
50
|
## Quick Start
|
|
50
51
|
|
|
51
52
|
```typescript
|
|
53
|
+
import { createMachine } from "xstate";
|
|
54
|
+
import { definePlayer, formatPlayRouteTransitions } from "@xmachines/play-xstate";
|
|
52
55
|
import {
|
|
53
56
|
createBrowserHistory,
|
|
54
57
|
createRouter,
|
|
@@ -57,18 +60,30 @@ import {
|
|
|
57
60
|
} from "@xmachines/play-dom-router";
|
|
58
61
|
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
59
62
|
|
|
60
|
-
// 1.
|
|
63
|
+
// 1. Define a routable machine — states carry meta.route
|
|
64
|
+
const machine = createMachine(
|
|
65
|
+
formatPlayRouteTransitions({
|
|
66
|
+
id: "app",
|
|
67
|
+
initial: "home",
|
|
68
|
+
states: {
|
|
69
|
+
home: { id: "home", meta: { route: "/" } },
|
|
70
|
+
about: { id: "about", meta: { route: "/about" } },
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// 2. Extract route tree and build route map from the machine
|
|
61
76
|
const routeTree = extractMachineRoutes(machine);
|
|
62
77
|
const routeMap = createRouteMap(machine);
|
|
63
78
|
|
|
64
|
-
//
|
|
79
|
+
// 3. Create browser history wrapper (accepts window or any BrowserWindow-compatible object)
|
|
65
80
|
const history = createBrowserHistory({ window });
|
|
66
81
|
|
|
67
|
-
//
|
|
82
|
+
// 4. Create router
|
|
68
83
|
const router = createRouter({ routeTree, history });
|
|
69
84
|
|
|
70
|
-
//
|
|
71
|
-
const actor = definePlayer({ machine
|
|
85
|
+
// 5. Start actor and connect
|
|
86
|
+
const actor = definePlayer({ machine })();
|
|
72
87
|
actor.start();
|
|
73
88
|
|
|
74
89
|
const disconnect = connectRouter({ actor, router, routeMap });
|
|
@@ -84,7 +99,7 @@ window.addEventListener("beforeunload", () => {
|
|
|
84
99
|
|
|
85
100
|
### `createBrowserHistory(options)`
|
|
86
101
|
|
|
87
|
-
|
|
102
|
+
This function wraps `window.history`, and it gives you a history interface with a subscription. It patches `pushState` and `replaceState`. Therefore the wrapper also detects a navigation from the code, not only a `popstate` event from the BACK or FORWARD button.
|
|
88
103
|
|
|
89
104
|
```typescript
|
|
90
105
|
const history = createBrowserHistory({ window });
|
|
@@ -106,27 +121,28 @@ history.destroy();
|
|
|
106
121
|
|
|
107
122
|
**`BrowserHistory` interface:**
|
|
108
123
|
|
|
109
|
-
| Method | Description
|
|
110
|
-
| ----------------------- |
|
|
111
|
-
| `location` | Read-only `{ pathname, search, hash, state }`
|
|
112
|
-
| `push(path, state?)` | Push a new entry to history
|
|
113
|
-
| `replace(path, state?)` | Replace the current history entry
|
|
114
|
-
| `go(delta)` | Navigate relative to current position
|
|
115
|
-
| `back()` | Navigate backward
|
|
116
|
-
| `forward()` | Navigate forward
|
|
117
|
-
| `subscribe(listener)` | Subscribe to location changes — returns unsubscribe function
|
|
118
|
-
| `createHref(path)` | Create an href from a path
|
|
119
|
-
| `destroy()` |
|
|
124
|
+
| Method | Description |
|
|
125
|
+
| ----------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
126
|
+
| `location` | Read-only `{ pathname, search, hash, state }` |
|
|
127
|
+
| `push(path, state?)` | Push a new entry to history |
|
|
128
|
+
| `replace(path, state?)` | Replace the current history entry |
|
|
129
|
+
| `go(delta)` | Navigate relative to current position |
|
|
130
|
+
| `back()` | Navigate backward |
|
|
131
|
+
| `forward()` | Navigate forward |
|
|
132
|
+
| `subscribe(listener)` | Subscribe to location changes — returns unsubscribe function |
|
|
133
|
+
| `createHref(path)` | Create an href from a path |
|
|
134
|
+
| `destroy()` | Cleans up. It removes the listeners, and it restores the patched methods when it is the last wrapper |
|
|
120
135
|
|
|
121
136
|
**`BrowserWindow` interface:**
|
|
122
137
|
|
|
123
|
-
|
|
138
|
+
The interface accepts `window`, a JSDOM window, or every other object that implements it. It holds only the properties that the package uses. Therefore the package does not depend on `Window & typeof globalThis`.
|
|
124
139
|
|
|
125
140
|
### `createRouter(options)`
|
|
126
141
|
|
|
127
|
-
|
|
142
|
+
This function creates a `VanillaRouter` around a `history` and a `routeTree`. Its setup flow is the same as the setup flow of TanStack Router.
|
|
128
143
|
|
|
129
144
|
```typescript
|
|
145
|
+
// routeTree and history from the Quick Start above
|
|
130
146
|
const router = createRouter({ routeTree, history });
|
|
131
147
|
// router.history — the BrowserHistory instance
|
|
132
148
|
// router.routeTree — for structure reference
|
|
@@ -135,10 +151,10 @@ const router = createRouter({ routeTree, history });
|
|
|
135
151
|
|
|
136
152
|
### `connectRouter(options)`
|
|
137
153
|
|
|
138
|
-
|
|
154
|
+
This function connects a `VanillaRouter` to a `Routable` actor. It does all the work in both directions:
|
|
139
155
|
|
|
140
|
-
- On connect:
|
|
141
|
-
- While connected: actor route
|
|
156
|
+
- On connect: it sets the actor state from the initial URL, or it writes the actor route to the browser. The bridge detects a restore and a deep link.
|
|
157
|
+
- While it is connected: each actor route change goes to the history, and each browser navigation sends a `play.route` event.
|
|
142
158
|
- Returns a cleanup function that disconnects the bridge.
|
|
143
159
|
|
|
144
160
|
```typescript
|
|
@@ -154,11 +170,11 @@ disconnect();
|
|
|
154
170
|
|
|
155
171
|
**`ConnectRouterOptions`:**
|
|
156
172
|
|
|
157
|
-
| Option | Type | Description
|
|
158
|
-
| ---------- | --------------------- |
|
|
159
|
-
| `actor` | `RoutableActor` |
|
|
160
|
-
| `router` | `VanillaRouter` | Router from `createRouter()`
|
|
161
|
-
| `routeMap` | `RouteLookupContract` | Bidirectional path ↔ state ID lookup
|
|
173
|
+
| Option | Type | Description |
|
|
174
|
+
| ---------- | --------------------- | ---------------------------------------------- |
|
|
175
|
+
| `actor` | `RoutableActor` | The actor to keep in step with the browser URL |
|
|
176
|
+
| `router` | `VanillaRouter` | Router from `createRouter()` |
|
|
177
|
+
| `routeMap` | `RouteLookupContract` | Bidirectional path ↔ state ID lookup |
|
|
162
178
|
|
|
163
179
|
**`RouteLookupContract`:**
|
|
164
180
|
|
|
@@ -169,15 +185,16 @@ interface RouteLookupContract {
|
|
|
169
185
|
}
|
|
170
186
|
```
|
|
171
187
|
|
|
172
|
-
|
|
188
|
+
The bridge accepts every object that implements this structural interface. A `RouteMap` instance from `@xmachines/play-router`, a subclass, and a test double all work.
|
|
173
189
|
|
|
174
190
|
### `createRouteMap` (re-export)
|
|
175
191
|
|
|
176
|
-
|
|
192
|
+
This function comes from `@xmachines/play-router`. It builds a bidirectional `RouteMap` from an XState machine:
|
|
177
193
|
|
|
178
194
|
```typescript
|
|
179
195
|
import { createRouteMap } from "@xmachines/play-dom-router";
|
|
180
196
|
|
|
197
|
+
// machine from the Quick Start above (states carry meta.route)
|
|
181
198
|
const routeMap = createRouteMap(machine);
|
|
182
199
|
routeMap.getStateIdByPath("/dashboard"); // "dashboard"
|
|
183
200
|
routeMap.getPathByStateId("dashboard"); // "/dashboard"
|
|
@@ -185,7 +202,7 @@ routeMap.getPathByStateId("dashboard"); // "/dashboard"
|
|
|
185
202
|
|
|
186
203
|
## URLPattern Support
|
|
187
204
|
|
|
188
|
-
This package
|
|
205
|
+
This package matches each route pattern with the [URLPattern API](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern), through [`@xmachines/play-router`](../play-router/README.md). URLPattern is native in Node.js 24+ and in a modern browser (Chrome 95+, Firefox 117+, Safari 16.4+). In an older environment, load a polyfill **before** you import this package. See [`@xmachines/play-router`](../play-router/README.md) for the details.
|
|
189
206
|
|
|
190
207
|
## Testing
|
|
191
208
|
|
|
@@ -197,7 +214,7 @@ pnpm test
|
|
|
197
214
|
pnpm --filter @xmachines/play-dom-router test
|
|
198
215
|
```
|
|
199
216
|
|
|
200
|
-
|
|
217
|
+
The tests run in a Node.js environment with the `URLPattern` polyfill setup. The browser tests are in `test/browser/`. They run separately, through `vitest.browser.config.ts`.
|
|
201
218
|
|
|
202
219
|
Coverage thresholds:
|
|
203
220
|
|
|
@@ -212,11 +229,11 @@ Coverage thresholds:
|
|
|
212
229
|
|
|
213
230
|
The bridge-first data flow:
|
|
214
231
|
|
|
215
|
-
1. `connectRouter`
|
|
216
|
-
2. On connect, `RouterBridgeBase`
|
|
217
|
-
3.
|
|
218
|
-
4.
|
|
219
|
-
5.
|
|
232
|
+
1. `connectRouter` creates a `DomRouterBridge`, which extends `RouterBridgeBase`, and calls `bridge.connect()`.
|
|
233
|
+
2. On connect, `RouterBridgeBase` does the first synchronization. If the browser URL is different from the actor route, the bridge sends a `play.route` event. If the actor route is different and the browser is at the initial route of the machine (a restore), the actor wins, and the bridge updates the history.
|
|
234
|
+
3. Each actor route change, through the `currentRoute` Signal, calls `history.push(path)`.
|
|
235
|
+
4. Each browser URL change (a `popstate` event, or a patched `pushState` or `replaceState` call) calls `syncActorFromRouter(pathname, search)`, which sends a `play.route` event.
|
|
236
|
+
5. The `isProcessingNavigation` flag in `RouterBridgeBase` stops a circular update.
|
|
220
237
|
|
|
221
238
|
```
|
|
222
239
|
Browser URL
|
|
@@ -238,17 +255,17 @@ Browser URL
|
|
|
238
255
|
|
|
239
256
|
- [@xmachines/play-router](../play-router/README.md) — `RouterBridgeBase`, `createRouteMap`, `extractMachineRoutes`
|
|
240
257
|
- [@xmachines/play-actor](../play-actor/README.md) — `AbstractActor`, `Routable`, `Viewable`; all subclasses satisfy `RoutableActor` structurally
|
|
241
|
-
- [@xmachines/play-dom](../play-dom/README.md) —
|
|
258
|
+
- [@xmachines/play-dom](../play-dom/README.md) — the vanilla DOM renderer, for the view beside the routing
|
|
242
259
|
- [@xmachines/play-xstate](../play-xstate/README.md) — `definePlayer`, `PlayerActor`
|
|
243
260
|
|
|
244
|
-
## Part of the XMachines monorepo
|
|
245
|
-
|
|
246
|
-
This package is part of the [xmachines-js](../../README.md) monorepo.
|
|
247
|
-
|
|
248
261
|
## License
|
|
249
262
|
|
|
250
263
|
MIT — see [LICENSE](LICENSE).
|
|
251
264
|
|
|
265
|
+
## Classes
|
|
266
|
+
|
|
267
|
+
- [DomRouterBridge](classes/DomRouterBridge.md)
|
|
268
|
+
|
|
252
269
|
## Interfaces
|
|
253
270
|
|
|
254
271
|
- [BrowserHistory](interfaces/BrowserHistory.md)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
[API](../../../README.md) / [@xmachines/play-dom-router](../README.md) / DomRouterBridge
|
|
2
|
+
|
|
3
|
+
# Class: DomRouterBridge
|
|
4
|
+
|
|
5
|
+
Defined in: [play-dom-router/src/dom-router-bridge.ts:26](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-dom-router/src/dom-router-bridge.ts#L26)
|
|
6
|
+
|
|
7
|
+
The DOM router bridge — it puts a BrowserHistory from `createBrowserHistory`
|
|
8
|
+
behind the `RouterBridgeBase` protocol.
|
|
9
|
+
|
|
10
|
+
It implements the three abstract methods:
|
|
11
|
+
|
|
12
|
+
- `navigateRouter` → `history.push(path)`
|
|
13
|
+
- `watchRouterChanges` → `history.subscribe(...)`, and it keeps the unsubscribe handle
|
|
14
|
+
- `unwatchRouterChanges` → it calls the handle that it kept
|
|
15
|
+
|
|
16
|
+
It overrides two optional hooks:
|
|
17
|
+
|
|
18
|
+
- `getInitialRouterPath` → `history.location.pathname`
|
|
19
|
+
- `getInitialRouterSearch` → `history.location.search`
|
|
20
|
+
|
|
21
|
+
The bridge inherits the prevention of a circular update, the
|
|
22
|
+
restore-or-deeplink detection, and the `lastSyncedPath` deduplication from
|
|
23
|
+
`RouterBridgeBase`.
|
|
24
|
+
|
|
25
|
+
Use `connectRouter` for the usual case. Use this class directly when you need
|
|
26
|
+
full control of the connection lifecycle.
|
|
27
|
+
|
|
28
|
+
## Extends
|
|
29
|
+
|
|
30
|
+
- [`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md)
|
|
31
|
+
|
|
32
|
+
## Constructors
|
|
33
|
+
|
|
34
|
+
### Constructor
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
new DomRouterBridge(
|
|
38
|
+
actor,
|
|
39
|
+
routeMap,
|
|
40
|
+
history): DomRouterBridge;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Defined in: [play-dom-router/src/dom-router-bridge.ts:34](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-dom-router/src/dom-router-bridge.ts#L34)
|
|
44
|
+
|
|
45
|
+
#### Parameters
|
|
46
|
+
|
|
47
|
+
| Parameter | Type | Description |
|
|
48
|
+
| ---------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
49
|
+
| `actor` | [`RoutableActor`](../interfaces/RoutableActor.md) | A `Routable` actor with `currentRoute` and `send`. |
|
|
50
|
+
| `routeMap` | [`RouteLookupContract`](../interfaces/RouteLookupContract.md) | The route lookup for both directions. Every object that satisfies [RouteLookupContract](../interfaces/RouteLookupContract.md) works. |
|
|
51
|
+
| `history` | [`BrowserHistory`](../interfaces/BrowserHistory.md) | The BrowserHistory instance from `createBrowserHistory`. |
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`DomRouterBridge`
|
|
56
|
+
|
|
57
|
+
#### Overrides
|
|
58
|
+
|
|
59
|
+
[`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`constructor`](../../play-router/classes/RouterBridgeBase.md#constructor)
|
|
60
|
+
|
|
61
|
+
## Methods
|
|
62
|
+
|
|
63
|
+
### connect()
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
connect(): void;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
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)
|
|
70
|
+
|
|
71
|
+
Connects the router bridge to the Actor.
|
|
72
|
+
|
|
73
|
+
The method installs the TC39 Signal watcher of the direction from the actor to the
|
|
74
|
+
router. It then starts the watch of the router changes, which each framework does
|
|
75
|
+
in its own way.
|
|
76
|
+
|
|
77
|
+
The order of these steps is part of the contract of the bridge:
|
|
78
|
+
|
|
79
|
+
- The constructor seeds `lastSyncedPath` from `actor.currentRoute`
|
|
80
|
+
- The method installs the actor watcher before the router subscriptions of the adapter
|
|
81
|
+
- The first synchronization then separates a deep link from a restore, with `actor.initialRoute`
|
|
82
|
+
|
|
83
|
+
An adapter that needs a different behavior of the first synchronization overrides
|
|
84
|
+
`getInitialRouterPath()`. It does not change the order of the steps of
|
|
85
|
+
`connect()`.
|
|
86
|
+
|
|
87
|
+
#### Returns
|
|
88
|
+
|
|
89
|
+
`void`
|
|
90
|
+
|
|
91
|
+
#### Inherited from
|
|
92
|
+
|
|
93
|
+
[`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`connect`](../../play-router/classes/RouterBridgeBase.md#connect)
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### disconnect()
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
disconnect(): void;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
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)
|
|
104
|
+
|
|
105
|
+
Disconnects the router bridge from the Actor.
|
|
106
|
+
|
|
107
|
+
The method stops the watch of the signal, and it removes the router listener of the
|
|
108
|
+
framework.
|
|
109
|
+
|
|
110
|
+
#### Returns
|
|
111
|
+
|
|
112
|
+
`void`
|
|
113
|
+
|
|
114
|
+
#### Inherited from
|
|
115
|
+
|
|
116
|
+
[`RouterBridgeBase`](../../play-router/classes/RouterBridgeBase.md).[`disconnect`](../../play-router/classes/RouterBridgeBase.md#disconnect)
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
function connectRouter(options): () => void;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-dom-router/src/connect-router.ts:
|
|
9
|
+
Defined in: [play-dom-router/src/connect-router.ts:52](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-dom-router/src/connect-router.ts#L52)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Connects the vanilla router to an actor. This is a pure browser integration.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The function returns a cleanup function. That function calls
|
|
14
|
+
`bridge.disconnect()` to stop the synchronization.
|
|
14
15
|
|
|
15
16
|
## Parameters
|
|
16
17
|
|
|
@@ -6,20 +6,21 @@
|
|
|
6
6
|
function createBrowserHistory(options): BrowserHistory;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-dom-router/src/create-browser-history.ts:
|
|
9
|
+
Defined in: [play-dom-router/src/create-browser-history.ts:122](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-dom-router/src/create-browser-history.ts#L122)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Creates a browser history that wraps window.history
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The interface is the same as the history interface of TanStack Router, so that
|
|
14
|
+
the two APIs stay parallel.
|
|
14
15
|
|
|
15
16
|
Architecture:
|
|
16
17
|
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
18
|
+
- It patches window.history.pushState and window.history.replaceState, to detect a change
|
|
19
|
+
- It listens for popstate, for the browser BACK and FORWARD buttons
|
|
20
|
+
- It gives you subscribe() for a listener, such as PlayRouterProvider
|
|
21
|
+
- It accepts a window object, so a test can give a double
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Use:
|
|
23
24
|
|
|
24
25
|
```typescript
|
|
25
26
|
const history = createBrowserHistory({ window });
|
|
@@ -35,13 +36,14 @@ unsubscribe();
|
|
|
35
36
|
history.destroy();
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
`destroy()` is idempotent and cooperates with other
|
|
39
|
-
|
|
39
|
+
`destroy()` is idempotent, and it cooperates with each other wrapper of the same
|
|
40
|
+
`window` instance.
|
|
40
41
|
|
|
41
|
-
**Warning**: `createBrowserHistory()`
|
|
42
|
-
(`pushState` and `replaceState`) and coordinates wrappers with shared
|
|
43
|
-
|
|
44
|
-
boundary and always
|
|
42
|
+
**Warning**: `createBrowserHistory()` changes the global `window.history` methods
|
|
43
|
+
(`pushState` and `replaceState`), and it coordinates the wrappers with a shared
|
|
44
|
+
reference count. Therefore create one history wrapper for each browser window, at
|
|
45
|
+
the boundary of the application, and always call `destroy()` during the
|
|
46
|
+
teardown.
|
|
45
47
|
|
|
46
48
|
## Parameters
|
|
47
49
|
|
|
@@ -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`](../interfaces/RouteMap.md)
|
|
28
29
|
|
|
29
|
-
A `RouteMap` for
|
|
30
|
+
A `RouteMap` for each adapter on `RouterBridgeBase`.
|
|
30
31
|
|
|
31
32
|
## Example
|
|
32
33
|
|
|
@@ -6,37 +6,37 @@
|
|
|
6
6
|
function createRouter(options): VanillaRouter;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-dom-router/src/create-router.ts:52](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.
|
|
9
|
+
Defined in: [play-dom-router/src/create-router.ts:52](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-dom-router/src/create-router.ts#L52)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Creates the vanilla router for a framework-agnostic routing.
|
|
12
12
|
|
|
13
13
|
Architecture:
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
15
|
+
- The router wraps a history and a routeTree, and it does nothing more
|
|
16
|
+
- It does NOT hold the routeMap, because a provider needs the routeMap as a prop
|
|
17
|
+
- It manages the history only, and it knows no framework
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
The reason for no routeMap:
|
|
20
20
|
|
|
21
|
-
-
|
|
22
|
-
- RouteMap is the bridge between router and actor
|
|
23
|
-
-
|
|
21
|
+
- The router knows nothing about a state ID, because a state ID belongs to Play
|
|
22
|
+
- The RouteMap is the bridge between the router and the actor
|
|
23
|
+
- The provider receives the routeMap as a prop, and it resolves a path to a state ID
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Use, parallel to the TanStack mode:
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
// Both modes:
|
|
28
|
+
// Both modes: the same setup
|
|
29
29
|
const routeTree = extractMachineRoutes(machine);
|
|
30
30
|
const routeMap = createRouteMapFromTree(routeTree);
|
|
31
31
|
const history = createBrowserHistory({ window });
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// The vanilla router
|
|
34
34
|
const router = createRouter({ routeTree, history });
|
|
35
35
|
|
|
36
|
-
// Connect router to actor
|
|
36
|
+
// Connect the router to the actor. This does all the work in both directions
|
|
37
37
|
const disconnect = connectRouter({ actor, router, routeMap });
|
|
38
38
|
|
|
39
|
-
// Later:
|
|
39
|
+
// Later: clean up
|
|
40
40
|
disconnect();
|
|
41
41
|
router.destroy();
|
|
42
42
|
```
|