@xmachines/docs 2.0.0-alpha.1 → 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 +16 -17
- package/api/@xmachines/play/README.md +58 -66
- package/api/@xmachines/play/classes/NonNullableError.md +14 -14
- package/api/@xmachines/play/classes/PlayError.md +32 -34
- package/api/@xmachines/play/functions/assertNonNullable.md +17 -17
- package/api/@xmachines/play/type-aliases/PlayEvent.md +28 -27
- package/api/@xmachines/play-actor/README.md +114 -50
- package/api/@xmachines/play-actor/classes/AbstractActor.md +45 -30
- package/api/@xmachines/play-actor/functions/attachRenderErrorHandler.md +19 -18
- package/api/@xmachines/play-actor/functions/composePlayState.md +27 -0
- package/api/@xmachines/play-actor/functions/createViewStoreLifecycle.md +21 -0
- package/api/@xmachines/play-actor/functions/guardContextWrites.md +43 -0
- package/api/@xmachines/play-actor/functions/refreshContextSubtree.md +28 -0
- package/api/@xmachines/play-actor/functions/reuseComposedState.md +42 -0
- package/api/@xmachines/play-actor/functions/shallowEqualExcept.md +29 -0
- package/api/@xmachines/play-actor/functions/toAtomState.md +16 -14
- package/api/@xmachines/play-actor/functions/typedSpec.md +25 -27
- 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 -15
- package/api/@xmachines/play-actor/interfaces/ResolveViewStoreOptions.md +11 -0
- package/api/@xmachines/play-actor/interfaces/Routable.md +6 -6
- package/api/@xmachines/play-actor/interfaces/ViewStoreLifecycle.md +50 -0
- package/api/@xmachines/play-actor/interfaces/ViewStoreResolution.md +15 -0
- package/api/@xmachines/play-actor/interfaces/Viewable.md +9 -9
- package/api/@xmachines/play-actor/variables/CONTEXT_STATE_KEY.md +15 -0
- package/api/@xmachines/play-dom/README.md +123 -86
- 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/functions/createValidationRegistry.md +22 -0
- package/api/@xmachines/play-dom/functions/defineRegistry.md +5 -5
- package/api/@xmachines/play-dom/interfaces/ComponentContext.md +9 -8
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +16 -16
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +2 -0
- package/api/@xmachines/play-dom/interfaces/FieldValidationState.md +16 -0
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +9 -9
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +17 -17
- package/api/@xmachines/play-dom/interfaces/RenderSpecOptions.md +2 -0
- package/api/@xmachines/play-dom/interfaces/ValidationRegistry.md +21 -0
- package/api/@xmachines/play-dom/type-aliases/BaseComponentProps.md +10 -0
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +5 -5
- package/api/@xmachines/play-dom/variables/schema.md +35 -45
- package/api/@xmachines/play-dom-router/README.md +68 -51
- 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 +21 -20
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +7 -7
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +41 -35
- 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 +65 -55
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +14 -13
- package/api/@xmachines/play-react/functions/defineRegistry.md +5 -5
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/useFieldValidation.md +31 -0
- 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/ComponentContext.md +9 -8
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +7 -7
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +6 -6
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +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 +38 -31
- 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 +41 -35
- 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 +99 -95
- 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 +6 -6
- package/api/@xmachines/play-router/interfaces/LocationLike.md +11 -11
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +7 -9
- 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 +41 -35
- 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 +5 -5
- 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 +39 -34
- 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 +45 -30
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +41 -35
- 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 +60 -33
- 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 +43 -52
- 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 +41 -35
- 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 +43 -39
- 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 +11 -11
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +41 -35
- 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 +67 -49
- 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 +41 -35
- 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 +38 -16
- 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 +76 -50
- 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 +41 -35
- 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 +39 -39
- 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/useFieldValidation.md +31 -0
- 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 +4 -4
- 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 +66 -57
- 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 +41 -35
- 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 +129 -138
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +148 -114
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +19 -23
- package/api/@xmachines/play-xstate/functions/composeGuards.md +34 -33
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +27 -22
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +19 -14
- 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 +12 -7
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +17 -48
- package/api/@xmachines/play-xstate/functions/hasContext.md +12 -9
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +10 -10
- package/api/@xmachines/play-xstate/functions/negateGuard.md +26 -20
- 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 -11
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +15 -14
- package/api/@xmachines/play-xstate/interfaces/RouteObject.md +4 -4
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +9 -25
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +13 -11
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +8 -5
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +11 -15
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +12 -19
- package/api/@xmachines/play-xstate/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +15 -26
- package/api/@xmachines/shared/README.md +12 -14
- 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 +12 -7
- package/api/@xmachines/shared/vite-aliases/functions/xmResolve.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmSvelteRunes.md +9 -4
- 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 +6 -6
- package/contributing/architecture.md +27 -28
- package/contributing/configuration.md +10 -10
- package/contributing/deployment.md +51 -30
- package/contributing/development.md +90 -21
- package/contributing/testing.md +36 -14
- package/examples/@xmachines/play-dom-demo/functions/createNavBar.md +1 -1
- package/examples/@xmachines/play-dom-demo/functions/initShell.md +1 -1
- package/examples/@xmachines/play-dom-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Home.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Login.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/NavBarView.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Navigation.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Overview.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Profile.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Settings.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-react-demo/functions/App.md +1 -1
- package/examples/@xmachines/play-react-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/DebugPanel.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Home.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Login.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/NavBar.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/NavBarView.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Navigation.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Overview.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Profile.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Settings.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Shell.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-solid-demo/functions/App.md +1 -1
- package/examples/@xmachines/play-solid-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/DebugPanel.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Home.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Login.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/NavBar.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/NavBarView.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Navigation.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Overview.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Profile.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Settings.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Shell.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-vue-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-vue-demo/variables/App.md +1 -1
- package/examples/@xmachines/play-vue-demo/variables/authCatalog.md +1 -1
- package/examples/README.md +4 -1
- package/examples/basic-state-machine.md +24 -24
- package/examples/form-validation.md +110 -121
- package/examples/multi-router-integration.md +0 -2
- package/examples/routing-patterns.md +60 -94
- package/examples/traffic-light.md +57 -48
- package/guides/README.md +6 -2
- package/guides/actor-model.md +1 -1
- package/guides/getting-started.md +89 -90
- package/guides/inspector.md +197 -0
- package/guides/state-machines.md +55 -69
- package/package.json +10 -7
- package/rfc/play.md +15 -6
- package/api/@xmachines/play-vue/functions/getPlayViewContext.md +0 -28
- package/api/@xmachines/play-xstate/functions/createRoutedMachine.md +0 -87
- package/api/@xmachines/play-xstate/type-aliases/PlayRoutePayload.md +0 -30
- package/api/@xmachines/play-xstate/type-aliases/SetupLike.md +0 -33
- package/api/@xmachines/play-xstate/type-aliases/WithOptional.md +0 -31
- package/api/@xmachines/play-xstate/variables/emptyEventSchema.md +0 -37
- package/api/@xmachines/play-xstate/variables/playMetaSchema.md +0 -40
- package/api/@xmachines/play-xstate/variables/playRouteEventSchema.md +0 -9
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: RouterBridge
|
|
4
4
|
|
|
5
|
-
Defined in: [play-router/src/types.ts:
|
|
5
|
+
Defined in: [play-router/src/types.ts:358](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/types.ts#L358)
|
|
6
6
|
|
|
7
|
-
RouterBridge interface
|
|
7
|
+
The RouterBridge interface of a runtime infrastructure adapter
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
The interface defines the connection of the lifecycle between the infrastructure,
|
|
10
|
+
for example a framework router, and the Actor. The infrastructure builds a "bridge"
|
|
11
|
+
to the Actor: it observes the signals of the Actor, and it manages its own
|
|
12
|
+
lifecycle accordingly.
|
|
12
13
|
|
|
13
|
-
**Architectural
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
**Architectural context:** the interface implements **Passive Infrastructure
|
|
15
|
+
(INV-04)**, because it gives an observation in one direction. The infrastructure
|
|
16
|
+
connects to observe the signals of the Actor (currentRoute, currentView, and
|
|
17
|
+
state), and it reflects each change. It makes no decision about the state.
|
|
16
18
|
|
|
17
19
|
## Example
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
The implementation of a framework router bridge
|
|
20
22
|
|
|
21
23
|
```typescript
|
|
22
24
|
import type { RouterBridge } from "@xmachines/play-router";
|
|
@@ -26,7 +28,7 @@ class MyRouterBridge implements RouterBridge {
|
|
|
26
28
|
private watcher: Signal.Watcher | null = null;
|
|
27
29
|
|
|
28
30
|
async connect(): Promise<void> {
|
|
29
|
-
// Start
|
|
31
|
+
// Start the observation of the actor.currentRoute signal
|
|
30
32
|
this.watcher = new Signal.subtle.Watcher(() => {
|
|
31
33
|
const route = actor.currentRoute.get();
|
|
32
34
|
if (route) router.navigate(route);
|
|
@@ -35,7 +37,7 @@ class MyRouterBridge implements RouterBridge {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
async disconnect(): Promise<void> {
|
|
38
|
-
// Stop
|
|
40
|
+
// Stop the observation, and clean the watchers up
|
|
39
41
|
this.watcher?.unwatch(actor.currentRoute);
|
|
40
42
|
this.watcher = null;
|
|
41
43
|
}
|
|
@@ -44,7 +46,7 @@ class MyRouterBridge implements RouterBridge {
|
|
|
44
46
|
|
|
45
47
|
## See
|
|
46
48
|
|
|
47
|
-
[Play RFC](../../../../rfc/play.md) -
|
|
49
|
+
[Play RFC](../../../../rfc/play.md) - invariant INV-04
|
|
48
50
|
|
|
49
51
|
## Methods
|
|
50
52
|
|
|
@@ -54,25 +56,26 @@ class MyRouterBridge implements RouterBridge {
|
|
|
54
56
|
connect(): void | Promise<void>;
|
|
55
57
|
```
|
|
56
58
|
|
|
57
|
-
Defined in: [play-router/src/types.ts:
|
|
59
|
+
Defined in: [play-router/src/types.ts:375](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/types.ts#L375)
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
Connects the router bridge to the Actor
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
The infrastructure calls it when it must start the observation of the Actor
|
|
64
|
+
signals, and when it must bring its own state, for example the browser URL, in line
|
|
65
|
+
with the Actor state.
|
|
63
66
|
|
|
64
67
|
#### Returns
|
|
65
68
|
|
|
66
69
|
`void` \| `Promise`\<`void`\>
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
The promise that resolves after the connection, or void for a synchronous connection
|
|
69
72
|
|
|
70
73
|
#### Example
|
|
71
74
|
|
|
72
75
|
```typescript
|
|
73
76
|
const bridge: RouterBridge = createBridge(actor, router);
|
|
74
77
|
await bridge.connect();
|
|
75
|
-
//
|
|
78
|
+
// The bridge observes the actor.currentRoute signal now
|
|
76
79
|
```
|
|
77
80
|
|
|
78
81
|
---
|
|
@@ -83,22 +86,22 @@ await bridge.connect();
|
|
|
83
86
|
disconnect(): void | Promise<void>;
|
|
84
87
|
```
|
|
85
88
|
|
|
86
|
-
Defined in: [play-router/src/types.ts:
|
|
89
|
+
Defined in: [play-router/src/types.ts:391](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/types.ts#L391)
|
|
87
90
|
|
|
88
|
-
|
|
91
|
+
Disconnects the router bridge from the Actor
|
|
89
92
|
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
The infrastructure calls it when it must stop the observation and free its
|
|
94
|
+
resources, for example a signal watcher and an event listener.
|
|
92
95
|
|
|
93
96
|
#### Returns
|
|
94
97
|
|
|
95
98
|
`void` \| `Promise`\<`void`\>
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
The promise that resolves after the disconnection, or void for a synchronous disconnection
|
|
98
101
|
|
|
99
102
|
#### Example
|
|
100
103
|
|
|
101
104
|
```typescript
|
|
102
105
|
await bridge.disconnect();
|
|
103
|
-
//
|
|
106
|
+
// The bridge stopped its observation, and it freed its resources
|
|
104
107
|
```
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
type PlayRouterBridgeConstructor<TRouter> = (router, actor, routeMap) => RouterBridge;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-react-router/src/create-play-router-provider.tsx:20](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.
|
|
9
|
+
Defined in: [play-react-router/src/create-play-router-provider.tsx:20](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-react-router/src/create-play-router-provider.tsx#L20)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The constructor shape that a bridge class must satisfy for
|
|
12
12
|
`createPlayRouterProvider`: `(router, actor, routeMap) → RouterBridge`.
|
|
13
13
|
|
|
14
14
|
## Type Parameters
|
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
const PlayRouterProvider: <TActor>(__namedParameters) => Element;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-react-router/src/play-router-provider.tsx:
|
|
9
|
+
Defined in: [play-react-router/src/play-router-provider.tsx:40](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-react-router/src/play-router-provider.tsx#L40)
|
|
10
10
|
|
|
11
|
-
Connects a `PlayerActor` to React Router
|
|
12
|
-
in
|
|
11
|
+
Connects a `PlayerActor` to React Router. It keeps the actor state and the browser
|
|
12
|
+
URL in step, in both directions.
|
|
13
13
|
|
|
14
|
-
The bridge
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
The component creates the bridge one time, on mount, and it disconnects the bridge
|
|
15
|
+
on unmount. It also builds the bridge again on a change of the identity of `actor`,
|
|
16
|
+
of `router`, or of `routeMap`. Therefore all three props must be **stable
|
|
17
|
+
references**: create them outside the JSX, or hold them with `useMemo`.
|
|
17
18
|
|
|
18
19
|
## Type Parameters
|
|
19
20
|
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
[API](../../README.md) / @xmachines/play-router
|
|
2
2
|
|
|
3
|
-
<!-- generated-by: gsd-doc-writer -->
|
|
4
|
-
|
|
5
3
|
# @xmachines/play-router
|
|
6
4
|
|
|
7
|
-
Route tree extraction from XState
|
|
5
|
+
Route tree extraction from XState v5 state machines. Part of [@xmachines/play](../play/README.md) Universal Player Architecture.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-router)
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
This package extracts the routes from a machine graph and looks them up in both directions. The Actor therefore keeps the authority over the navigation.
|
|
12
10
|
|
|
13
11
|
## Installation
|
|
14
12
|
|
|
15
13
|
```bash
|
|
16
|
-
pnpm add xstate@^
|
|
14
|
+
pnpm add xstate@^5.31.0
|
|
17
15
|
pnpm add @xmachines/play-router
|
|
18
16
|
```
|
|
19
17
|
|
|
20
18
|
**Peer dependencies:**
|
|
21
19
|
|
|
22
|
-
- `xstate` ^
|
|
20
|
+
- `xstate` ^5.31.0 — XState v5 state machine runtime
|
|
23
21
|
|
|
24
22
|
**URLPattern polyfill (Node.js < 24 / older browsers):**
|
|
25
23
|
|
|
26
|
-
`@xmachines/play-router`
|
|
24
|
+
`@xmachines/play-router` matches each dynamic route with the [URLPattern API](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern). URLPattern is native in Node.js 24+ and in a modern browser (Chrome 95+, Firefox 117+, Safari 16.4+).
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
In an environment without the native API, load a polyfill **before** you import this package:
|
|
29
27
|
|
|
30
28
|
```typescript
|
|
31
29
|
// Entry point — must run before any @xmachines/play-router import
|
|
@@ -38,23 +36,17 @@ Install the polyfill:
|
|
|
38
36
|
pnpm add urlpattern-polyfill
|
|
39
37
|
```
|
|
40
38
|
|
|
41
|
-
`urlpattern-polyfill` is
|
|
39
|
+
`urlpattern-polyfill` is an optional peer dependency. A package manager does not install it for you. Install it and load it yourself when your runtime has no native URLPattern.
|
|
42
40
|
|
|
43
41
|
## Usage
|
|
44
42
|
|
|
45
43
|
### Extract routes from a machine
|
|
46
44
|
|
|
47
45
|
```typescript
|
|
48
|
-
import {
|
|
46
|
+
import { createMachine } from "xstate";
|
|
49
47
|
import { extractMachineRoutes, createRouteMap } from "@xmachines/play-router";
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
// without it, XState v6 types `meta` as `never`.
|
|
53
|
-
const machine = setup({
|
|
54
|
-
schemas: {
|
|
55
|
-
meta: types<{ route?: string }>(),
|
|
56
|
-
},
|
|
57
|
-
}).createMachine({
|
|
49
|
+
const machine = createMachine({
|
|
58
50
|
id: "app",
|
|
59
51
|
initial: "home",
|
|
60
52
|
states: {
|
|
@@ -103,8 +95,13 @@ routeMap.getPathByStateId("profile"); // "/profile/:userId"
|
|
|
103
95
|
### Sending `play.route` events
|
|
104
96
|
|
|
105
97
|
```typescript
|
|
98
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
106
99
|
import type { PlayRouteEvent } from "@xmachines/play-router";
|
|
107
100
|
|
|
101
|
+
// machine: your routable machine (states carry meta.route)
|
|
102
|
+
const actor = definePlayer({ machine })();
|
|
103
|
+
actor.start();
|
|
104
|
+
|
|
108
105
|
// Navigate to a state by ID
|
|
109
106
|
const event: PlayRouteEvent = {
|
|
110
107
|
type: "play.route",
|
|
@@ -128,14 +125,21 @@ actor.send({
|
|
|
128
125
|
});
|
|
129
126
|
```
|
|
130
127
|
|
|
131
|
-
###
|
|
128
|
+
### How to write a `RouterBridgeBase` adapter
|
|
132
129
|
|
|
133
|
-
Extend `RouterBridgeBase
|
|
130
|
+
Extend `RouterBridgeBase`, then implement the three abstract methods for your framework:
|
|
134
131
|
|
|
135
132
|
```typescript
|
|
136
|
-
import { RouterBridgeBase } from "@xmachines/play-router";
|
|
133
|
+
import { RouterBridgeBase, createRouteMap } from "@xmachines/play-router";
|
|
137
134
|
import type { RoutableActor } from "@xmachines/play-router";
|
|
138
135
|
|
|
136
|
+
// Shape of your framework's router — adjust to its real API
|
|
137
|
+
type MyRouter = {
|
|
138
|
+
navigate(path: string): void;
|
|
139
|
+
subscribe(handler: (location: { pathname: string; search: string }) => void): () => void;
|
|
140
|
+
state: { location: { pathname: string } };
|
|
141
|
+
};
|
|
142
|
+
|
|
139
143
|
export class MyRouterBridge extends RouterBridgeBase {
|
|
140
144
|
private unsubscribe: (() => void) | null = null;
|
|
141
145
|
|
|
@@ -171,7 +175,8 @@ export class MyRouterBridge extends RouterBridgeBase {
|
|
|
171
175
|
}
|
|
172
176
|
}
|
|
173
177
|
|
|
174
|
-
// Usage
|
|
178
|
+
// Usage — myRouter: your framework's router instance;
|
|
179
|
+
// machine/actor: your routable machine and its started actor
|
|
175
180
|
const routeMap = createRouteMap(machine);
|
|
176
181
|
const bridge = new MyRouterBridge(myRouter, actor, routeMap);
|
|
177
182
|
bridge.connect();
|
|
@@ -183,81 +188,79 @@ bridge.disconnect();
|
|
|
183
188
|
|
|
184
189
|
### Route Extraction
|
|
185
190
|
|
|
186
|
-
| Export | Description
|
|
187
|
-
| ---------------------------------------- |
|
|
188
|
-
| `extractMachineRoutes(machine)` |
|
|
189
|
-
| `createRouteMap(machine, options?)` |
|
|
190
|
-
| `createRouteMapFromTree(tree, options?)` |
|
|
191
|
-
| `buildRouteTree(routes)` |
|
|
192
|
-
| `machineToGraph(machine)` |
|
|
193
|
-
|
|
194
|
-
> **Graph shape under XState v6:** machines wired by `formatPlayRouteTransitions` expose their route navigation as statically-targeted `xstate.route` edges (one per routed state) plus a single dynamic `play.route` forwarder edge — tooling that previously filtered for per-route `play.route` edges should query `xstate.route` instead. Edge data marks guard presence with `guarded: true`; guard _names_ are unrecoverable under v6 (`guardType` is never populated).
|
|
191
|
+
| Export | Description |
|
|
192
|
+
| ---------------------------------------- | --------------------------------------------------------------------------------- |
|
|
193
|
+
| `extractMachineRoutes(machine)` | Converts an XState machine into a `RouteTree` with the state ID ↔ path maps |
|
|
194
|
+
| `createRouteMap(machine, options?)` | Builds a `RouteMap` directly from a machine. An adapter uses this form |
|
|
195
|
+
| `createRouteMapFromTree(tree, options?)` | Builds a `RouteMap` from a `RouteTree` that you extracted before |
|
|
196
|
+
| `buildRouteTree(routes)` | Builds a `RouteTree` from an array of `RouteInfo` objects |
|
|
197
|
+
| `machineToGraph(machine)` | Converts a machine into a typed `@statelyai/graph` `Graph`, for a graph algorithm |
|
|
195
198
|
|
|
196
199
|
### Route Matching
|
|
197
200
|
|
|
198
|
-
| Export | Description
|
|
199
|
-
| ----------------------------- |
|
|
200
|
-
| `RouteMap` |
|
|
201
|
-
| `findRouteById(tree, id)` |
|
|
202
|
-
| `findRouteByPath(tree, path)` |
|
|
201
|
+
| Export | Description |
|
|
202
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
203
|
+
| `RouteMap` | The `stateId ↔ path` lookup class for both directions. It matches an exact path in O(1) and a pattern in O(k) |
|
|
204
|
+
| `findRouteById(tree, id)` | Finds a `RouteNode` by its state ID |
|
|
205
|
+
| `findRouteByPath(tree, path)` | Finds a `RouteNode` by its URL path. It also matches a dynamic pattern |
|
|
203
206
|
|
|
204
207
|
### Query Utilities
|
|
205
208
|
|
|
206
|
-
| Export | Description
|
|
207
|
-
| ------------------------------------------------- |
|
|
208
|
-
| `getRoutableRoutes(tree)` |
|
|
209
|
-
| `getNavigableRoutes(tree, stateId)` |
|
|
210
|
-
| `routeExists(tree, path)` |
|
|
211
|
-
| `getTransitionReachableRoutes(graph, stateId)` |
|
|
212
|
-
| `isRouteReachable(graph, fromStateId, toStateId)` |
|
|
209
|
+
| Export | Description |
|
|
210
|
+
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
211
|
+
| `getRoutableRoutes(tree)` | Returns every routable `RouteNode` in one flat array |
|
|
212
|
+
| `getNavigableRoutes(tree, stateId)` | Returns the child routes that a state can reach, through the hierarchy and through a transition |
|
|
213
|
+
| `routeExists(tree, path)` | Tells you if the tree holds a path |
|
|
214
|
+
| `getTransitionReachableRoutes(graph, stateId)` | Returns the route paths that a state can reach through an XState transition |
|
|
215
|
+
| `isRouteReachable(graph, fromStateId, toStateId)` | Tells you if a transition path is present between two states |
|
|
213
216
|
|
|
214
217
|
### Router Bridge
|
|
215
218
|
|
|
216
|
-
| Export | Description
|
|
217
|
-
| --------------------------------------- |
|
|
218
|
-
| `RouterBridgeBase` |
|
|
219
|
-
| `sanitizePathname(path)` |
|
|
220
|
-
| `buildPlayRouteEvent(options)` |
|
|
221
|
-
| `extractRouteParams(pathname, pattern)` |
|
|
222
|
-
| `extractQuery(search)` |
|
|
219
|
+
| Export | Description |
|
|
220
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
221
|
+
| `RouterBridgeBase` | The abstract base class of each framework router adapter. It implements the `RouterBridge` protocol |
|
|
222
|
+
| `sanitizePathname(path)` | Normalizes a raw pathname. It returns `null` for a path of more than 2048 characters, and for malformed input |
|
|
223
|
+
| `buildPlayRouteEvent(options)` | Builds a `PlayRouteEvent` from a pathname and a route-map match result |
|
|
224
|
+
| `extractRouteParams(pathname, pattern)` | Reads the path parameters of a URL with URLPattern |
|
|
225
|
+
| `extractQuery(search)` | Reads the query parameters of a URL search string |
|
|
223
226
|
|
|
224
227
|
### Validation
|
|
225
228
|
|
|
226
|
-
| Export | Description
|
|
227
|
-
| ---------------------------------------- |
|
|
228
|
-
| `validateRouteFormat(route, stateId)` |
|
|
229
|
-
| `validateStateExists(stateId, stateIds)` |
|
|
230
|
-
| `detectDuplicateRoutes(routes)` |
|
|
229
|
+
| Export | Description |
|
|
230
|
+
| ---------------------------------------- | ---------------------------------------------------- |
|
|
231
|
+
| `validateRouteFormat(route, stateId)` | Asserts that the route path is not empty |
|
|
232
|
+
| `validateStateExists(stateId, stateIds)` | Asserts that the machine graph holds the state ID |
|
|
233
|
+
| `detectDuplicateRoutes(routes)` | Throws when two states resolve to the same full path |
|
|
231
234
|
|
|
232
235
|
### Key Types
|
|
233
236
|
|
|
234
|
-
| Export | Description
|
|
235
|
-
| ---------------------------------- |
|
|
236
|
-
| `RouterBridge` |
|
|
237
|
-
| `RouteTree` |
|
|
238
|
-
| `RouteNode` |
|
|
239
|
-
| `RouteInfo` |
|
|
240
|
-
| `PlayRouteEvent` | Routing event `{ type: "play.route", to, params?, query? }`
|
|
241
|
-
| `RoutableActor` |
|
|
242
|
-
| `PlayActor` |
|
|
243
|
-
| `RouteMapping` | `{ stateId, path }` pair
|
|
244
|
-
| `RouteMapping as BaseRouteMapping` |
|
|
245
|
-
| `MachineGraph` |
|
|
246
|
-
| `WindowLike` |
|
|
247
|
-
| `LocationLike` |
|
|
237
|
+
| Export | Description |
|
|
238
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
239
|
+
| `RouterBridge` | The interface of the `connect()` and `disconnect()` lifecycle |
|
|
240
|
+
| `RouteTree` | The hierarchical tree, with `root`, `byStateId`, `byPath`, and an optional `graph` |
|
|
241
|
+
| `RouteNode` | One node of the tree, with `id`, `path`, `fullPath`, `stateId`, `children`, and `parent` |
|
|
242
|
+
| `RouteInfo` | The flat route descriptor that comes from a state node |
|
|
243
|
+
| `PlayRouteEvent` | Routing event `{ type: "play.route", to, params?, query? }` |
|
|
244
|
+
| `RoutableActor` | The minimal actor interface that `RouterBridgeBase` requires: `currentRoute`, `initialRoute`, and `send(PlayRouteEvent)` |
|
|
245
|
+
| `PlayActor` | The complete actor interface that `PlayRouterProvider` uses. It extends `RoutableActor` with `currentView` (`Routable + Viewable`) |
|
|
246
|
+
| `RouteMapping` | The `{ stateId, path }` pair that builds a `RouteMap` |
|
|
247
|
+
| `RouteMapping as BaseRouteMapping` | The alias of `RouteMapping`, for compatibility with an earlier version |
|
|
248
|
+
| `MachineGraph` | The typed `@statelyai/graph` Graph, with `MachineNodeData` and `MachineEdgeData` |
|
|
249
|
+
| `WindowLike` | The minimal `window` interface that you can inject for SSR and for a test |
|
|
250
|
+
| `LocationLike` | The minimal `location` interface that you can inject for SSR and for a test |
|
|
248
251
|
|
|
249
252
|
### Errors (subpath `@xmachines/play-router/errors`)
|
|
250
253
|
|
|
251
|
-
| Class | Code | When thrown
|
|
252
|
-
| ---------------------------- | --------------------------------------- |
|
|
253
|
-
| `RouterSyncError` | `PLAY_ROUTER_SYNC_FAILED` | `syncActorFromRouter()`
|
|
254
|
-
| `DuplicateBridgeError` | `PLAY_ROUTER_DUPLICATE_BRIDGE` | A second bridge tries to connect to an actor that already has one
|
|
255
|
-
| `URLPatternUnavailableError` | `PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE` | URLPattern API is absent and no polyfill is loaded
|
|
256
|
-
| `InvalidRoutePatternError` | `PLAY_ROUTE_MAP_INVALID_PATTERN` |
|
|
257
|
-
| `EmptyRoutePathError` | `PLAY_ROUTE_EMPTY_PATH` | A state declares `meta.route: ""`
|
|
258
|
-
| `InvalidStateIdError` | `PLAY_ROUTE_INVALID_STATE_ID` | A route
|
|
259
|
-
| `DuplicateRoutePathError` | `PLAY_ROUTE_DUPLICATE_PATH` | Two or more states share the same URL path
|
|
260
|
-
| `UnknownStateTypeError` | `PLAY_ROUTE_UNKNOWN_STATE_TYPE` | A state node has an
|
|
254
|
+
| Class | Code | When thrown |
|
|
255
|
+
| ---------------------------- | --------------------------------------- | ----------------------------------------------------------------------- |
|
|
256
|
+
| `RouterSyncError` | `PLAY_ROUTER_SYNC_FAILED` | `syncActorFromRouter()` cannot send a `play.route` event |
|
|
257
|
+
| `DuplicateBridgeError` | `PLAY_ROUTER_DUPLICATE_BRIDGE` | A second bridge tries to connect to an actor that already has one |
|
|
258
|
+
| `URLPatternUnavailableError` | `PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE` | The URLPattern API is absent, and no polyfill is loaded |
|
|
259
|
+
| `InvalidRoutePatternError` | `PLAY_ROUTE_MAP_INVALID_PATTERN` | The URLPattern constructor refuses a route pattern string |
|
|
260
|
+
| `EmptyRoutePathError` | `PLAY_ROUTE_EMPTY_PATH` | A state declares `meta.route: ""` |
|
|
261
|
+
| `InvalidStateIdError` | `PLAY_ROUTE_INVALID_STATE_ID` | A route names a state ID that the machine graph does not hold |
|
|
262
|
+
| `DuplicateRoutePathError` | `PLAY_ROUTE_DUPLICATE_PATH` | Two or more states share the same URL path |
|
|
263
|
+
| `UnknownStateTypeError` | `PLAY_ROUTE_UNKNOWN_STATE_TYPE` | A state node has an XState `.type` value that the package does not know |
|
|
261
264
|
|
|
262
265
|
```typescript
|
|
263
266
|
import {
|
|
@@ -266,6 +269,7 @@ import {
|
|
|
266
269
|
URLPatternUnavailableError,
|
|
267
270
|
} from "@xmachines/play-router/errors";
|
|
268
271
|
|
|
272
|
+
// bridge from the adapter example above
|
|
269
273
|
try {
|
|
270
274
|
bridge.connect();
|
|
271
275
|
} catch (err) {
|
|
@@ -281,7 +285,7 @@ try {
|
|
|
281
285
|
|
|
282
286
|
### `meta.route` patterns
|
|
283
287
|
|
|
284
|
-
|
|
288
|
+
Declare the route of an XState state node in its `meta.route` field:
|
|
285
289
|
|
|
286
290
|
```typescript
|
|
287
291
|
states: {
|
|
@@ -306,7 +310,7 @@ states: {
|
|
|
306
310
|
|
|
307
311
|
### Relative vs absolute paths
|
|
308
312
|
|
|
309
|
-
|
|
313
|
+
A child route that starts with `/` is absolute, and it does not inherit the path of its parent. A child route without the first `/` is relative to its nearest routable ancestor:
|
|
310
314
|
|
|
311
315
|
```typescript
|
|
312
316
|
states: {
|
|
@@ -327,7 +331,7 @@ states: {
|
|
|
327
331
|
}
|
|
328
332
|
```
|
|
329
333
|
|
|
330
|
-
Always use `node.fullPath`
|
|
334
|
+
Always use `node.fullPath` to match a browser URL and to build a route map. Never use `node.path` for this.
|
|
331
335
|
|
|
332
336
|
## Testing
|
|
333
337
|
|
|
@@ -339,10 +343,11 @@ pnpm --filter @xmachines/play-router test
|
|
|
339
343
|
pnpm --filter @xmachines/play-router run test:watch
|
|
340
344
|
```
|
|
341
345
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
+
`@xmachines/play-router-shared` holds a contract test suite of the router bridge, for the
|
|
347
|
+
author of an adapter. That suite drives a real actor. Therefore it is one layer above this
|
|
348
|
+
package, and `@xmachines/play-router` keeps no dependency on an actor runtime.
|
|
349
|
+
`@xmachines/play-router-shared` is a private workspace package. Thus only an adapter author
|
|
350
|
+
in this repository can use the suite:
|
|
346
351
|
|
|
347
352
|
```typescript
|
|
348
353
|
import { runBridgeContractTests } from "@xmachines/play-router-shared/test/router-bridge-contract.js";
|
|
@@ -352,15 +357,19 @@ runBridgeContractTests({
|
|
|
352
357
|
createHarness(initialPath) {
|
|
353
358
|
// return ContractHarness with bridge, actor, simulateNavigation, getLastNavigatedPath
|
|
354
359
|
},
|
|
360
|
+
createRestoredHarness(routedPath) {
|
|
361
|
+
// return ContractHarness whose actor is restored to routedPath
|
|
362
|
+
// while the mock router starts at the machine's initial route
|
|
363
|
+
},
|
|
355
364
|
});
|
|
356
365
|
```
|
|
357
366
|
|
|
358
367
|
## Related Packages
|
|
359
368
|
|
|
360
369
|
- **[@xmachines/play](../play/README.md)** — Core protocol types (`PlayEvent`, `PlayError`)
|
|
361
|
-
- **[@xmachines/play-actor](../play-actor/README.md)** —
|
|
362
|
-
- **[@xmachines/play-signals](../play-signals/README.md)** — TC39 Signals polyfill
|
|
363
|
-
- **[@xmachines/play-xstate](../play-xstate/README.md)** — XState
|
|
370
|
+
- **[@xmachines/play-actor](../play-actor/README.md)** — the abstract actor base class (`AbstractActor`, `Routable`). Every `AbstractActor` subclass satisfies `RoutableActor` structurally
|
|
371
|
+
- **[@xmachines/play-signals](../play-signals/README.md)** — the TC39 Signals polyfill that observes the actor route
|
|
372
|
+
- **[@xmachines/play-xstate](../play-xstate/README.md)** — the XState v5 logic adapter, which works with a route tree
|
|
364
373
|
- **[@xmachines/play-tanstack-router](../play-tanstack-router/README.md)** — Shared TanStack Router bridge base (framework-agnostic)
|
|
365
374
|
- **[@xmachines/play-tanstack-react-router](../play-tanstack-react-router/README.md)** — TanStack Router adapter (React)
|
|
366
375
|
- **[@xmachines/play-tanstack-solid-router](../play-tanstack-solid-router/README.md)** — TanStack Router adapter (SolidJS)
|
|
@@ -400,6 +409,7 @@ MIT — see [LICENSE](LICENSE).
|
|
|
400
409
|
|
|
401
410
|
## Type Aliases
|
|
402
411
|
|
|
412
|
+
- [~~BaseRouteMapping~~](type-aliases/BaseRouteMapping.md)
|
|
403
413
|
- [MachineGraph](type-aliases/MachineGraph.md)
|
|
404
414
|
- [RouteMetadata](type-aliases/RouteMetadata.md)
|
|
405
415
|
|
|
@@ -424,9 +434,3 @@ MIT — see [LICENSE](LICENSE).
|
|
|
424
434
|
- [sanitizePathname](functions/sanitizePathname.md)
|
|
425
435
|
- [validateRouteFormat](functions/validateRouteFormat.md)
|
|
426
436
|
- [validateStateExists](functions/validateStateExists.md)
|
|
427
|
-
|
|
428
|
-
## References
|
|
429
|
-
|
|
430
|
-
### BaseRouteMapping
|
|
431
|
-
|
|
432
|
-
Renames and re-exports [RouteMapping](interfaces/RouteMapping.md)
|