@xmachines/docs 1.0.0-beta.46 → 1.0.0-beta.48
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 +135 -7
- package/api/@xmachines/play/README.md +134 -57
- package/api/@xmachines/play/classes/NonNullableError.md +4 -4
- package/api/@xmachines/play/classes/PlayError.md +4 -4
- package/api/@xmachines/play/functions/assertNonNullable.md +1 -1
- package/api/@xmachines/play/type-aliases/PlayEvent.md +2 -2
- package/api/@xmachines/play-actor/README.md +130 -155
- package/api/@xmachines/play-actor/classes/AbstractActor.md +3 -3
- package/api/@xmachines/play-actor/functions/typedSpec.md +1 -1
- package/api/@xmachines/play-actor/interfaces/BaseActorProviderProps.md +5 -5
- package/api/@xmachines/play-actor/interfaces/BaseViewContextValue.md +5 -5
- package/api/@xmachines/play-actor/interfaces/PlaySpec.md +2 -2
- package/api/@xmachines/play-actor/interfaces/Routable.md +3 -3
- package/api/@xmachines/play-actor/interfaces/Viewable.md +2 -2
- package/api/@xmachines/play-dom/README.md +140 -232
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +4 -4
- package/api/@xmachines/play-dom/functions/connectRenderer.md +1 -1
- package/api/@xmachines/play-dom/functions/createPlayUI.md +1 -1
- package/api/@xmachines/play-dom/functions/createRenderer.md +1 -1
- package/api/@xmachines/play-dom/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-dom/functions/renderSpec.md +1 -1
- package/api/@xmachines/play-dom/interfaces/ComponentContext.md +7 -7
- package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +13 -13
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +6 -6
- package/api/@xmachines/play-dom/interfaces/DefineRegistryResult.md +4 -4
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +12 -12
- package/api/@xmachines/play-dom/interfaces/EventHandle.md +4 -4
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +3 -3
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +5 -5
- package/api/@xmachines/play-dom/interfaces/UIProviderOptions.md +5 -5
- package/api/@xmachines/play-dom/type-aliases/ActionFn.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/Actions.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/BaseComponentProps.md +7 -7
- package/api/@xmachines/play-dom/type-aliases/CatalogHasActions.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/ComponentFn.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/ComponentRegistry.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/DomSchema.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +1 -1
- package/api/@xmachines/play-dom/type-aliases/SetState.md +1 -1
- package/api/@xmachines/play-dom/variables/schema.md +1 -1
- package/api/@xmachines/play-dom-router/README.md +160 -158
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +4 -4
- package/api/@xmachines/play-dom-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-react/README.md +109 -320
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +5 -5
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
- package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +8 -8
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +4 -4
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +3 -3
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +8 -8
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-react/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-react/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-react/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-react-router/README.md +107 -124
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +23 -23
- package/api/@xmachines/play-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-react-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-router/README.md +235 -475
- package/api/@xmachines/play-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +23 -23
- package/api/@xmachines/play-router/functions/buildPlayRouteEvent.md +1 -1
- package/api/@xmachines/play-router/functions/buildRouteTree.md +1 -1
- package/api/@xmachines/play-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-router/functions/createRouteMatcher.md +1 -1
- package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/extractMachineRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/extractQuery.md +1 -1
- package/api/@xmachines/play-router/functions/extractRouteParams.md +1 -1
- package/api/@xmachines/play-router/functions/findRouteById.md +1 -1
- package/api/@xmachines/play-router/functions/findRouteByPath.md +1 -1
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/getRoutableRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +1 -1
- package/api/@xmachines/play-router/functions/isRouteReachable.md +1 -1
- package/api/@xmachines/play-router/functions/machineToGraph.md +1 -1
- package/api/@xmachines/play-router/functions/routeExists.md +1 -1
- package/api/@xmachines/play-router/functions/sanitizePathname.md +1 -1
- package/api/@xmachines/play-router/functions/validateRouteFormat.md +1 -1
- package/api/@xmachines/play-router/functions/validateStateExists.md +1 -1
- package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +4 -4
- package/api/@xmachines/play-router/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +3 -3
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +5 -5
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
- package/api/@xmachines/play-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +3 -3
- package/api/@xmachines/play-router/interfaces/RouteMatcher.md +4 -4
- package/api/@xmachines/play-router/interfaces/RouteNode.md +10 -10
- package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
- package/api/@xmachines/play-router/interfaces/RouteTree.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +3 -3
- package/api/@xmachines/play-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-router/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-router/type-aliases/MachineGraph.md +1 -1
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-signals/README.md +105 -73
- package/api/@xmachines/play-signals/functions/watchSignal.md +1 -1
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
- package/api/@xmachines/play-solid/README.md +117 -263
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +8 -8
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +8 -8
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-solid/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorContext.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-solid-router/README.md +93 -606
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +24 -24
- package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +3 -3
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-svelte/README.md +111 -103
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-svelte/functions/getActorContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/setActorContext.md +1 -1
- package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +8 -8
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +4 -4
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +11 -11
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-svelte/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/README.md +156 -17
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-sveltekit-router/README.md +168 -17
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/README.md +147 -122
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +23 -23
- package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/README.md +195 -173
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +24 -24
- package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +3 -3
- package/api/@xmachines/play-vue/README.md +126 -271
- package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-vue/functions/getPlayViewContext.md +1 -1
- package/api/@xmachines/play-vue/functions/useActor.md +1 -1
- package/api/@xmachines/play-vue/interfaces/ActorProviderProps.md +5 -5
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +8 -8
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-vue/interfaces/VisibilityProviderProps.md +1 -1
- 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/type-aliases/PlayActor.md +1 -1
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue-router/README.md +148 -528
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +24 -24
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-vue-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-xstate/README.md +167 -496
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +12 -12
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +1 -1
- package/api/@xmachines/play-xstate/functions/composeGuards.md +1 -1
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +1 -1
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +1 -1
- package/api/@xmachines/play-xstate/functions/definePlayer.md +1 -1
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +1 -1
- package/api/@xmachines/play-xstate/functions/eventMatches.md +1 -1
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +1 -1
- package/api/@xmachines/play-xstate/functions/hasContext.md +1 -1
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
- package/api/@xmachines/play-xstate/functions/negateGuard.md +1 -1
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +3 -3
- package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +2 -2
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +6 -6
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +5 -5
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +4 -4
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
- package/api/@xmachines/shared/README.md +81 -294
- 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/vitest/functions/defineXmVitestConfig.md +1 -1
- package/examples/@xmachines/play-dom-demo/README.md +3 -3
- 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-dom-router-demo/README.md +2 -2
- package/examples/@xmachines/play-react-demo/README.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-react-router-demo/README.md +1 -1
- package/examples/@xmachines/play-solid-demo/README.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/README.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-svelte-spa-router-demo/README.md +2 -2
- package/examples/@xmachines/play-sveltekit-router-demo/README.md +2 -2
- package/examples/@xmachines/play-vue-demo/README.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 +24 -25
- package/examples/form-validation.md +2 -2
- package/guides/README.md +7 -7
- package/guides/actor-model.md +18 -18
- package/guides/architecture.md +500 -0
- package/guides/configuration.md +556 -0
- package/guides/deployment.md +336 -0
- package/guides/development.md +617 -0
- package/guides/getting-started.md +351 -142
- package/guides/signals.md +19 -19
- package/guides/state-machines.md +16 -16
- package/guides/testing.md +460 -0
- package/package.json +5 -5
- package/guides/installation.md +0 -257
|
@@ -1,628 +1,299 @@
|
|
|
1
1
|
[API](../../README.md) / @xmachines/play-xstate
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**XState v5 adapter for Play Architecture with signal-driven reactivity and routing**
|
|
6
|
-
|
|
7
|
-
Transform declarative state machines into live actors with TC39 Signals and parameter-aware navigation.
|
|
3
|
+
<!-- generated-by: gsd-doc-writer -->
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
# @xmachines/play-xstate
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
> XState v5 adapter for the XMachines Play Architecture — bind state machines to the actor base with signal-driven reactivity and router integration.
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[](https://www.npmjs.com/package/@xmachines/play-xstate)
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
- **Strict Separation (INV-02):** Zero React/framework imports in business logic
|
|
17
|
-
- **Signal-Only Reactivity (INV-05):** TC39 Signals expose all state changes
|
|
12
|
+
Part of the [XMachines Play](../../README.md) monorepo.
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
---
|
|
20
15
|
|
|
21
16
|
## Installation
|
|
22
17
|
|
|
23
18
|
```bash
|
|
24
|
-
npm install xstate
|
|
25
|
-
npm install @xmachines/play-xstate
|
|
19
|
+
npm install @xmachines/play-xstate xstate
|
|
26
20
|
```
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
`xstate ^5.30.0` is a peer dependency and must be installed alongside this package.
|
|
29
23
|
|
|
30
|
-
|
|
24
|
+
---
|
|
31
25
|
|
|
32
26
|
## Quick Start
|
|
33
27
|
|
|
34
28
|
```typescript
|
|
35
|
-
import { setup
|
|
36
|
-
import { definePlayer
|
|
29
|
+
import { setup } from "xstate";
|
|
30
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
37
31
|
|
|
38
|
-
// 1. Define XState machine
|
|
39
|
-
const machine = setup({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
query: Record<string, string>;
|
|
45
|
-
},
|
|
46
|
-
events: {} as
|
|
47
|
-
| { type: "play.route"; to: string; params?: Record<string, string> }
|
|
48
|
-
| { type: "auth.login" }
|
|
49
|
-
| { type: "auth.logout" },
|
|
32
|
+
// 1. Define your XState v5 machine
|
|
33
|
+
const machine = setup({}).createMachine({
|
|
34
|
+
initial: "idle",
|
|
35
|
+
states: {
|
|
36
|
+
idle: { meta: { route: "/" } },
|
|
37
|
+
active: { meta: { route: "/active" } },
|
|
50
38
|
},
|
|
51
|
-
})
|
|
52
|
-
formatPlayRouteTransitions({
|
|
53
|
-
id: "app",
|
|
54
|
-
initial: "login",
|
|
55
|
-
context: { isAuthenticated: false, params: {}, query: {} },
|
|
56
|
-
states: {
|
|
57
|
-
login: {
|
|
58
|
-
id: "login",
|
|
59
|
-
meta: {
|
|
60
|
-
route: "/login",
|
|
61
|
-
view: {
|
|
62
|
-
component: "Login",
|
|
63
|
-
spec: {
|
|
64
|
-
root: "root",
|
|
65
|
-
elements: {
|
|
66
|
-
root: { type: "Login", props: { title: "Sign In" }, children: [] },
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
dashboard: {
|
|
73
|
-
id: "dashboard",
|
|
74
|
-
meta: {
|
|
75
|
-
route: "/dashboard",
|
|
76
|
-
view: {
|
|
77
|
-
component: "Dashboard",
|
|
78
|
-
spec: {
|
|
79
|
-
root: "root",
|
|
80
|
-
elements: {
|
|
81
|
-
root: { type: "Dashboard", props: {}, children: [] },
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
always: [{ target: "login", guard: ({ context }) => !context.isAuthenticated }],
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
on: {
|
|
90
|
-
"auth.login": {
|
|
91
|
-
target: ".dashboard",
|
|
92
|
-
guard: ({ context }) => !context.isAuthenticated,
|
|
93
|
-
actions: assign({ isAuthenticated: true }),
|
|
94
|
-
},
|
|
95
|
-
"auth.logout": {
|
|
96
|
-
target: ".login",
|
|
97
|
-
actions: assign({ isAuthenticated: false }),
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
}),
|
|
101
|
-
);
|
|
39
|
+
});
|
|
102
40
|
|
|
103
|
-
// 2. Create player factory
|
|
41
|
+
// 2. Create a player factory
|
|
104
42
|
const createPlayer = definePlayer({ machine });
|
|
105
43
|
|
|
106
|
-
// 3.
|
|
44
|
+
// 3. Instantiate and start an actor
|
|
107
45
|
const actor = createPlayer();
|
|
108
46
|
actor.start();
|
|
109
47
|
|
|
110
|
-
// 4. Observe
|
|
111
|
-
console.log(actor.currentRoute.get()); // "/
|
|
112
|
-
console.log(actor.
|
|
48
|
+
// 4. Observe TC39 Signal-based reactive state
|
|
49
|
+
console.log(actor.currentRoute.get()); // "/"
|
|
50
|
+
console.log(actor.state.get().value); // "idle"
|
|
113
51
|
|
|
114
|
-
// 5.
|
|
115
|
-
actor.
|
|
116
|
-
```
|
|
52
|
+
// 5. Send events — machine guards decide transitions
|
|
53
|
+
actor.send({ type: "activate" });
|
|
117
54
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
### definePlayer()
|
|
121
|
-
|
|
122
|
-
Create a player factory from an XState machine:
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
const createPlayer = definePlayer<TMachine>({
|
|
126
|
-
machine: AnyStateMachine,
|
|
127
|
-
options?: PlayerOptions,
|
|
128
|
-
}): PlayerFactory;
|
|
55
|
+
actor.stop();
|
|
129
56
|
```
|
|
130
57
|
|
|
131
|
-
|
|
58
|
+
---
|
|
132
59
|
|
|
133
|
-
|
|
134
|
-
- `options` (optional) - Lifecycle hooks
|
|
60
|
+
## API Summary
|
|
135
61
|
|
|
136
|
-
|
|
62
|
+
### `definePlayer(config)`
|
|
137
63
|
|
|
138
|
-
|
|
64
|
+
Creates a `PlayerFactory` from an XState v5 machine. The factory pattern enables multiple independent actor instances from a single configuration — useful for multi-user scenarios, SSR, or testing.
|
|
139
65
|
|
|
140
66
|
```typescript
|
|
67
|
+
import { setup } from "xstate";
|
|
68
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
69
|
+
|
|
70
|
+
const machine = setup({
|
|
71
|
+
types: {
|
|
72
|
+
context: {} as { userId: string },
|
|
73
|
+
input: {} as { userId: string },
|
|
74
|
+
},
|
|
75
|
+
}).createMachine({
|
|
76
|
+
context: ({ input }) => ({ userId: input.userId }),
|
|
77
|
+
initial: "home",
|
|
78
|
+
states: { home: {} },
|
|
79
|
+
});
|
|
80
|
+
|
|
141
81
|
const createPlayer = definePlayer({
|
|
142
|
-
machine
|
|
82
|
+
machine,
|
|
143
83
|
options: {
|
|
144
|
-
onStart: (actor) => console.log("
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
84
|
+
onStart: (actor) => console.log("started"),
|
|
85
|
+
onStop: (actor) => console.log("stopped"),
|
|
86
|
+
onTransition: (actor, prev, next) => console.log("transitioned"),
|
|
87
|
+
onStateChange: (actor, state) => console.log("state changed"),
|
|
88
|
+
onError: (actor, err) => console.error(err),
|
|
148
89
|
},
|
|
149
90
|
});
|
|
150
91
|
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
92
|
+
// Each call returns an independent PlayerActor instance
|
|
93
|
+
const alice = createPlayer({ userId: "alice" });
|
|
94
|
+
const bob = createPlayer({ userId: "bob" });
|
|
154
95
|
```
|
|
155
96
|
|
|
156
|
-
|
|
97
|
+
#### `PlayerFactory` signature
|
|
157
98
|
|
|
158
99
|
```typescript
|
|
159
|
-
|
|
100
|
+
type PlayerFactory<TMachine> = (
|
|
101
|
+
input?: InputFrom<TMachine>,
|
|
102
|
+
options?: PlayerFactoryResumeOptions<TMachine>,
|
|
103
|
+
) => PlayerActor<TMachine>;
|
|
104
|
+
```
|
|
160
105
|
|
|
161
|
-
|
|
162
|
-
actor.start();
|
|
106
|
+
#### Restoring from a snapshot
|
|
163
107
|
|
|
164
|
-
|
|
108
|
+
```typescript
|
|
165
109
|
const snapshot = actor.getSnapshot();
|
|
166
110
|
actor.stop();
|
|
167
111
|
|
|
168
|
-
|
|
169
|
-
|
|
112
|
+
// Restore to the exact saved state
|
|
113
|
+
const restored = createPlayer({ userId: "alice" }, { snapshot });
|
|
114
|
+
restored.start();
|
|
115
|
+
console.log(restored.currentRoute.get()); // same route as when saved
|
|
170
116
|
```
|
|
171
117
|
|
|
172
|
-
|
|
173
|
-
restored snapshot route. Router bridges rely on that invariant to distinguish a deep-link
|
|
174
|
-
from a restored session during `connect()`.
|
|
175
|
-
|
|
176
|
-
### PlayerActor
|
|
177
|
-
|
|
178
|
-
Concrete actor implementing Play signal protocol:
|
|
179
|
-
|
|
180
|
-
**Signal Properties:**
|
|
181
|
-
|
|
182
|
-
- `state: Signal.State<AnyMachineSnapshot>` — Reactive snapshot of current state
|
|
183
|
-
- `currentRoute: Signal.Computed<string | null>` — Derived URL from the current state's `meta.route` and `context.params`. Returns `null` when no route metadata is present or a required route parameter is missing from context.
|
|
184
|
-
- `currentView: Signal.State<ViewMetadata | null>` — Current view spec (updated on every state transition). The spec is automatically enriched with `context.params` (URL params) and any `contextProps`-allowlisted context fields before being emitted (see [Prop Enrichment from Routing and Context](#prop-enrichment-from-routing-and-context)).
|
|
118
|
+
---
|
|
185
119
|
|
|
186
|
-
|
|
120
|
+
### `PlayerActor<TMachine>`
|
|
187
121
|
|
|
188
|
-
- `
|
|
189
|
-
- `currentView` is then validated and cached from that same snapshot.
|
|
190
|
-
- `onStateChange` runs after those signals are current.
|
|
191
|
-
- `onTransition` runs after `send()` completes, with both previous and next snapshots.
|
|
192
|
-
- `onStart` runs after the initial active snapshot has been published.
|
|
122
|
+
Concrete actor class that wraps an XState v5 actor and exposes TC39 Signal-based reactive signals. Implements both `Routable` and `Viewable` interfaces from `@xmachines/play-actor`.
|
|
193
123
|
|
|
194
|
-
|
|
124
|
+
#### Signals
|
|
195
125
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
126
|
+
| Signal | Type | Description |
|
|
127
|
+
| -------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
128
|
+
| `state` | `Signal.State<SnapshotFrom<TMachine>>` | Current XState snapshot; updated on every active transition |
|
|
129
|
+
| `currentRoute` | `Signal.Computed<string \| null>` | Derived URL from active state's `meta.route` template and context |
|
|
130
|
+
| `currentView` | `Signal.State<PlaySpec \| null>` | View spec from active state's `meta.view` metadata; enriched with context params |
|
|
131
|
+
| `initialRoute` | `readonly string \| null` | Machine's initial-state route (fixed at construction; used by router bridges for deep-link vs restore detection) |
|
|
202
132
|
|
|
203
|
-
|
|
133
|
+
#### Methods
|
|
204
134
|
|
|
205
|
-
|
|
206
|
-
|
|
135
|
+
| Method | Description |
|
|
136
|
+
| --------------- | -------------------------------------------------------------- |
|
|
137
|
+
| `start()` | Start the actor and fire `onStart` hook |
|
|
138
|
+
| `stop()` | Stop the actor, clean up subscriptions, fire `onStop` hook |
|
|
139
|
+
| `send(event)` | Send a typed event to the machine; fires `onTransition` hook |
|
|
140
|
+
| `can(event)` | Returns `true` if the current state can accept the given event |
|
|
141
|
+
| `getSnapshot()` | Returns the current XState snapshot |
|
|
142
|
+
| `dispose()` | Alias for `stop()` |
|
|
207
143
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
- `currentView` emits a fresh `ViewMetadata` object on every transition so TC39 Signal equality checks always detect changes (including re-entries to the same state with different params).
|
|
211
|
-
- `context.params` and `contextProps`-allowlisted context fields are merged into spec element props — see [Prop Enrichment from Routing and Context](#prop-enrichment-from-routing-and-context).
|
|
212
|
-
|
|
213
|
-
**Example:**
|
|
144
|
+
#### Signal usage example
|
|
214
145
|
|
|
215
146
|
```typescript
|
|
216
|
-
|
|
217
|
-
actor.start();
|
|
147
|
+
import { Signal } from "@xmachines/play-signals";
|
|
218
148
|
|
|
219
|
-
// Observe signals with watcher
|
|
220
149
|
const watcher = new Signal.subtle.Watcher(() => {
|
|
221
150
|
queueMicrotask(() => {
|
|
222
|
-
|
|
223
|
-
console.log("Route changed:", route);
|
|
151
|
+
console.log("Route changed:", actor.currentRoute.get());
|
|
224
152
|
});
|
|
225
153
|
});
|
|
154
|
+
|
|
226
155
|
watcher.watch(actor.currentRoute);
|
|
227
|
-
actor.
|
|
156
|
+
actor.start();
|
|
228
157
|
```
|
|
229
158
|
|
|
230
|
-
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### Guard utilities
|
|
162
|
+
|
|
163
|
+
Composable guard helpers that wrap XState's built-in `and()`, `or()`, and `not()` for use in machine `setup({ guards })` definitions.
|
|
231
164
|
|
|
232
165
|
```typescript
|
|
166
|
+
import { setup } from "xstate";
|
|
233
167
|
import {
|
|
234
|
-
composeGuards,
|
|
235
|
-
composeGuardsOr,
|
|
236
|
-
negateGuard,
|
|
237
|
-
hasContext,
|
|
238
|
-
eventMatches,
|
|
239
|
-
contextFieldMatches,
|
|
168
|
+
composeGuards, // AND logic: all guards must pass
|
|
169
|
+
composeGuardsOr, // OR logic: at least one guard must pass
|
|
170
|
+
negateGuard, // NOT logic: inverts a guard
|
|
171
|
+
hasContext, // guard: context field is present and non-null
|
|
172
|
+
eventMatches, // guard: event type matches a string
|
|
173
|
+
contextFieldMatches, // guard: context field equals a value
|
|
240
174
|
} from "@xmachines/play-xstate";
|
|
241
175
|
|
|
242
176
|
const machine = setup({
|
|
243
177
|
guards: {
|
|
244
|
-
isLoggedIn:
|
|
245
|
-
|
|
178
|
+
isLoggedIn: ({ context }) => !!context.userId,
|
|
179
|
+
hasAdminRole: ({ context }) => context.role === "admin",
|
|
246
180
|
},
|
|
247
181
|
}).createMachine({
|
|
248
182
|
on: {
|
|
249
183
|
accessAdmin: {
|
|
250
|
-
|
|
251
|
-
guard: composeGuards(["isLoggedIn", "isAdmin"]),
|
|
184
|
+
guard: composeGuards(["isLoggedIn", "hasAdminRole"]),
|
|
252
185
|
target: "adminPanel",
|
|
253
186
|
},
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
target: "publicArea",
|
|
258
|
-
},
|
|
259
|
-
logout: {
|
|
260
|
-
// NOT composition
|
|
261
|
-
guard: negateGuard("isLoggedIn"),
|
|
262
|
-
target: "login",
|
|
187
|
+
accessDashboard: {
|
|
188
|
+
guard: negateGuard("isGuest"),
|
|
189
|
+
target: "dashboard",
|
|
263
190
|
},
|
|
264
191
|
},
|
|
192
|
+
// ...
|
|
265
193
|
});
|
|
266
194
|
```
|
|
267
195
|
|
|
268
|
-
|
|
196
|
+
---
|
|
269
197
|
|
|
270
|
-
|
|
271
|
-
- `eventMatches(type: string)` - Check event type
|
|
272
|
-
- `contextFieldMatches(fieldPath: string, expectedValue: unknown)` - Check context field with strict structural equality
|
|
273
|
-
- `composeGuards(guards: Array)` - AND composition
|
|
274
|
-
- `composeGuardsOr(guards: Array)` - OR composition
|
|
275
|
-
- `negateGuard(guard)` - NOT composition
|
|
198
|
+
### Routing utilities
|
|
276
199
|
|
|
277
|
-
|
|
200
|
+
Helper functions for declarative route configuration in XState machines.
|
|
278
201
|
|
|
279
|
-
|
|
202
|
+
#### `formatPlayRouteTransitions(machineConfig)`
|
|
280
203
|
|
|
281
|
-
|
|
204
|
+
Crawls machine states with `meta.route` and auto-generates `play.route` event handlers at the root level — eliminating boilerplate routing transitions.
|
|
282
205
|
|
|
283
206
|
```typescript
|
|
284
207
|
import { setup } from "xstate";
|
|
285
|
-
import {
|
|
208
|
+
import { formatPlayRouteTransitions } from "@xmachines/play-xstate";
|
|
286
209
|
|
|
287
|
-
|
|
288
|
-
const machineConfig = {
|
|
210
|
+
const config = formatPlayRouteTransitions({
|
|
289
211
|
id: "app",
|
|
290
|
-
initial: "home",
|
|
291
|
-
context: { isAuthenticated: false },
|
|
292
212
|
states: {
|
|
293
213
|
home: {
|
|
294
214
|
id: "home",
|
|
295
|
-
meta: { route: "/"
|
|
296
|
-
},
|
|
297
|
-
dashboard: {
|
|
298
|
-
id: "dashboard",
|
|
299
|
-
meta: { route: "/dashboard", view: { component: "Dashboard" } },
|
|
300
|
-
// Always-guard validates state entry
|
|
301
|
-
always: [
|
|
302
|
-
{
|
|
303
|
-
target: "login",
|
|
304
|
-
guard: ({ context }) => !context.isAuthenticated,
|
|
305
|
-
},
|
|
306
|
-
],
|
|
307
|
-
},
|
|
308
|
-
login: {
|
|
309
|
-
id: "login",
|
|
310
|
-
meta: { route: "/login", view: { component: "Login" } },
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
// formatPlayRouteTransitions handles routing infrastructure
|
|
316
|
-
const machine = setup({
|
|
317
|
-
types: {
|
|
318
|
-
context: {} as {
|
|
319
|
-
isAuthenticated: boolean;
|
|
320
|
-
params: Record<string, string>;
|
|
321
|
-
query: Record<string, string>;
|
|
322
|
-
},
|
|
323
|
-
events: {} as
|
|
324
|
-
| { type: "play.route"; to: string; params?: Record<string, string> }
|
|
325
|
-
| { type: "auth.login" },
|
|
326
|
-
},
|
|
327
|
-
}).createMachine(formatPlayRouteTransitions(machineConfig));
|
|
328
|
-
|
|
329
|
-
const createPlayer = definePlayer({ machine });
|
|
330
|
-
const actor = createPlayer();
|
|
331
|
-
actor.start();
|
|
332
|
-
|
|
333
|
-
// Navigation via play.route event
|
|
334
|
-
actor.send({ type: "play.route", to: "/dashboard" });
|
|
335
|
-
// Guard validates: Can I BE in dashboard state?
|
|
336
|
-
// If !isAuthenticated → redirects to login
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
**Why this works:**
|
|
340
|
-
|
|
341
|
-
- `formatPlayRouteTransitions` adds routing infrastructure (event.to → state mapping)
|
|
342
|
-
- Always-guards handle business logic (authentication checks)
|
|
343
|
-
- Clear separation: routing is infrastructure, guards are business logic
|
|
344
|
-
|
|
345
|
-
**Anti-pattern (DON'T DO THIS):**
|
|
346
|
-
|
|
347
|
-
```typescript
|
|
348
|
-
// ❌ WRONG - Guard on event checking event properties
|
|
349
|
-
on: {
|
|
350
|
-
"play.route": {
|
|
351
|
-
guard: ({ event }) => event.to === "/dashboard",
|
|
352
|
-
target: "dashboard"
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
**Reference:** See `docs/examples/routing-patterns.md` for canonical `formatPlayRouteTransitions` usage with always-guards for authentication.
|
|
358
|
-
|
|
359
|
-
### Lifecycle Hooks
|
|
360
|
-
|
|
361
|
-
```typescript
|
|
362
|
-
const createPlayer = definePlayer({
|
|
363
|
-
machine,
|
|
364
|
-
options: {
|
|
365
|
-
onStart: (actor) => {
|
|
366
|
-
console.log("Actor started:", actor.id);
|
|
367
|
-
},
|
|
368
|
-
onStop: (actor) => {
|
|
369
|
-
console.log("Actor stopped:", actor.id);
|
|
370
|
-
},
|
|
371
|
-
onTransition: (actor, prev, next) => {
|
|
372
|
-
console.log("State change:", {
|
|
373
|
-
from: prev.value,
|
|
374
|
-
to: next.value,
|
|
375
|
-
timestamp: Date.now(),
|
|
376
|
-
});
|
|
215
|
+
meta: { route: "/home" },
|
|
377
216
|
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
},
|
|
382
|
-
onError: (actor, error) => {
|
|
383
|
-
console.error("Actor error:", error);
|
|
384
|
-
// Log to monitoring service, show error UI, etc.
|
|
217
|
+
profile: {
|
|
218
|
+
id: "profile",
|
|
219
|
+
meta: { route: "/users/:userId" },
|
|
385
220
|
},
|
|
386
221
|
},
|
|
387
222
|
});
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
### XState DevTools Integration
|
|
391
|
-
|
|
392
|
-
```typescript
|
|
393
|
-
import { createBrowserInspector } from "@statelyai/inspect";
|
|
394
|
-
import { definePlayer } from "@xmachines/play-xstate";
|
|
395
223
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
const
|
|
399
|
-
const actor = createPlayer();
|
|
400
|
-
actor.start();
|
|
401
|
-
|
|
402
|
-
// PlayerActor maintains XState Inspector compatibility
|
|
403
|
-
// Inspector displays:
|
|
404
|
-
// - State transitions and values
|
|
405
|
-
// - Context data
|
|
406
|
-
// - Events sent to actor
|
|
407
|
-
// - Guard evaluation results
|
|
408
|
-
|
|
409
|
-
// Signals accessible via actor properties, not snapshots
|
|
410
|
-
console.log(actor.currentRoute.get()); // "/dashboard"
|
|
224
|
+
// config now includes auto-generated play.route handlers:
|
|
225
|
+
// on: { "play.route": [ { target: ".home", guard: e => e.to === "#home" }, ... ] }
|
|
226
|
+
const machine = setup({}).createMachine(config);
|
|
411
227
|
```
|
|
412
228
|
|
|
413
|
-
|
|
229
|
+
> **Note:** Every state with `meta.route` must also have an explicit `id` field; omitting it throws `MissingStateIdError` at machine-definition time.
|
|
414
230
|
|
|
415
|
-
|
|
231
|
+
#### Other routing exports
|
|
416
232
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
meta: {
|
|
423
|
-
route: "/dashboard", // URL path - marks state as routable
|
|
424
|
-
},
|
|
425
|
-
},
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// Parameters
|
|
429
|
-
meta: {
|
|
430
|
-
route: "/profile/:userId", // Required parameter
|
|
431
|
-
route: "/settings/:section?", // Optional parameter
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// Inheritance
|
|
435
|
-
meta: {
|
|
436
|
-
route: "/absolute", // Starts with / → doesn't inherit parent route
|
|
437
|
-
route: "relative", // Doesn't start with / → inherits parent route
|
|
438
|
-
}
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### View Metadata
|
|
233
|
+
| Export | Description |
|
|
234
|
+
| ---------------------------------- | ------------------------------------------------------------------------- |
|
|
235
|
+
| `deriveRoute(meta)` | Extract the route template string from a state's metadata object |
|
|
236
|
+
| `isAbsoluteRoute(route)` | Returns `true` if the route string is an absolute URL path |
|
|
237
|
+
| `buildRouteUrl(template, context)` | Substitute `:param` placeholders in a route template using context values |
|
|
442
238
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
```typescript
|
|
446
|
-
meta: {
|
|
447
|
-
view: {
|
|
448
|
-
component: "Dashboard", // Component name — must exist in the registry
|
|
449
|
-
spec: {
|
|
450
|
-
root: "root", // Root element key
|
|
451
|
-
state: { tab: "general" }, // Optional: initial UI state (form values etc.)
|
|
452
|
-
elements: {
|
|
453
|
-
root: {
|
|
454
|
-
type: "Dashboard",
|
|
455
|
-
props: { title: "Dashboard" }, // Static props (non-undefined = cannot be overridden by route params)
|
|
456
|
-
children: [],
|
|
457
|
-
},
|
|
458
|
-
},
|
|
459
|
-
},
|
|
460
|
-
},
|
|
461
|
-
}
|
|
462
|
-
```
|
|
239
|
+
---
|
|
463
240
|
|
|
464
|
-
|
|
465
|
-
it in automatically (see [Prop Enrichment from Routing and Context](#prop-enrichment-from-routing-and-context)):
|
|
241
|
+
## Exported Types
|
|
466
242
|
|
|
467
243
|
```typescript
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
//
|
|
477
|
-
//
|
|
478
|
-
//
|
|
479
|
-
|
|
480
|
-
// theme → from spec (explicit value, untouched)
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
## Error Handling
|
|
484
|
-
|
|
485
|
-
All runtime errors thrown by this package extend `PlayError` from `@xmachines/play` and
|
|
486
|
-
are exported from the `./errors` subpath:
|
|
487
|
-
|
|
488
|
-
```typescript
|
|
489
|
-
import { MissingRouteParamError, InvalidEventError } from "@xmachines/play-xstate/errors";
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
| Class | Code | When thrown |
|
|
493
|
-
| ------------------------ | -------------------------- | -------------------------------------------------------- |
|
|
494
|
-
| `MissingRouteParamError` | `PLAY_ROUTE_PARAM_MISSING` | Required `:param` has no matching value in actor context |
|
|
495
|
-
| `InvalidEventError` | `PLAY_INVALID_EVENT` | `actor.send()` called with a non-object value |
|
|
496
|
-
|
|
497
|
-
`MissingRouteParamError` carries `param` and `template` fields for programmatic access.
|
|
498
|
-
`InvalidEventError` carries a `detail` property with the offending value.
|
|
499
|
-
|
|
500
|
-
> **Note:** `currentRoute` does NOT throw `MissingRouteParamError` — it catches the error internally and returns `null` instead, keeping signal watchers stable during transient states.
|
|
501
|
-
|
|
502
|
-
```typescript
|
|
503
|
-
import { MissingRouteParamError, InvalidEventError } from "@xmachines/play-xstate/errors";
|
|
504
|
-
|
|
505
|
-
try {
|
|
506
|
-
actor.send(null as any);
|
|
507
|
-
} catch (err) {
|
|
508
|
-
if (err instanceof InvalidEventError) {
|
|
509
|
-
console.error("Non-object event passed to actor.send():", err.detail);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
try {
|
|
514
|
-
const route = actor.currentRoute.get();
|
|
515
|
-
} catch (err) {
|
|
516
|
-
if (err instanceof MissingRouteParamError) {
|
|
517
|
-
console.error(`Missing "${err.param}" for template "${err.template}"`);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
244
|
+
import type {
|
|
245
|
+
PlayerConfig, // definePlayer() config argument shape
|
|
246
|
+
PlayerOptions, // Lifecycle hooks (onStart, onStop, onTransition, onStateChange, onError)
|
|
247
|
+
PlayerFactory, // Factory function returned by definePlayer()
|
|
248
|
+
PlayerFactoryResumeOptions, // { snapshot? } for restoring actor state
|
|
249
|
+
Guard, // Single XState guard predicate
|
|
250
|
+
GuardArray, // Array of guards for compose helpers
|
|
251
|
+
ComposedGuard, // Return type of composeGuards / composeGuardsOr / negateGuard
|
|
252
|
+
RouteMachineConfig, // Minimal machine config accepted by formatPlayRouteTransitions
|
|
253
|
+
RouteStateNode, // Single state node shape used during route crawling
|
|
254
|
+
RouteContext, // Context shape expected by buildRouteUrl ({ params?, query? })
|
|
255
|
+
} from "@xmachines/play-xstate";
|
|
520
256
|
```
|
|
521
257
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
When `currentView` is derived, each spec element's `props` are enriched from two sources.
|
|
525
|
-
Both use the **opt-in slot** pattern: declare a prop as `undefined` in the spec to allow
|
|
526
|
-
it to be filled in automatically.
|
|
527
|
-
|
|
528
|
-
### Merge priority (highest → lowest)
|
|
529
|
-
|
|
530
|
-
| Source | When it applies | Wins over |
|
|
531
|
-
| ---------------------------------- | -------------------------------- | ------------------------- |
|
|
532
|
-
| Explicit non-`undefined` spec prop | Always | Everything |
|
|
533
|
-
| URL route param (`context.params`) | State has a `:param` URL segment | `contextProps` values |
|
|
534
|
-
| `contextProps` field | Listed in `spec.contextProps` | Nothing (lowest priority) |
|
|
535
|
-
|
|
536
|
-
### URL route parameters
|
|
537
|
-
|
|
538
|
-
URL path parameters (`:section?`, `:username`) are filled automatically — declare the prop
|
|
539
|
-
as `undefined` to opt in:
|
|
540
|
-
|
|
541
|
-
```typescript
|
|
542
|
-
// Route: /settings/:section?
|
|
543
|
-
elements: {
|
|
544
|
-
root: { type: "Settings", props: { section: undefined, user: "alice" }, children: [] }
|
|
545
|
-
}
|
|
258
|
+
---
|
|
546
259
|
|
|
547
|
-
|
|
548
|
-
// Component receives: { section: "profile", user: "alice" }
|
|
549
|
-
```
|
|
260
|
+
## Error Classes
|
|
550
261
|
|
|
551
|
-
|
|
262
|
+
Error classes are exported from the `@xmachines/play-xstate/errors` sub-path to keep the main bundle lean.
|
|
552
263
|
|
|
553
264
|
```typescript
|
|
554
|
-
|
|
555
|
-
//
|
|
265
|
+
import {
|
|
266
|
+
MissingRouteParamError, // Required :param absent from context when resolving currentRoute
|
|
267
|
+
MissingQueryContextError, // context.params present but context.query missing
|
|
268
|
+
MissingStateIdError, // meta.route declared without a state id field
|
|
269
|
+
InvalidMachineError, // PlayerActor constructed with a non-object machine
|
|
270
|
+
InvalidEventError, // actor.send() called with null/undefined/non-object
|
|
271
|
+
InvalidRouteMetadataError, // meta.route is neither a string nor { path: string }
|
|
272
|
+
EmptyGuardArrayError, // composeGuards/composeGuardsOr called with empty array
|
|
273
|
+
} from "@xmachines/play-xstate/errors";
|
|
556
274
|
```
|
|
557
275
|
|
|
558
|
-
|
|
276
|
+
All error classes extend `PlayError` from `@xmachines/play` and carry typed detail fields (`param`, `template`, `combinator`, etc.) for programmatic inspection without message parsing.
|
|
559
277
|
|
|
560
|
-
|
|
561
|
-
is no corresponding URL param, declare `contextProps` in the spec as an explicit allowlist:
|
|
278
|
+
---
|
|
562
279
|
|
|
563
|
-
|
|
564
|
-
// Dashboard at /dashboard — no :username URL param, but we want to show context.username
|
|
565
|
-
spec: {
|
|
566
|
-
root: "root",
|
|
567
|
-
contextProps: ["username"], // ← explicit allowlist
|
|
568
|
-
elements: {
|
|
569
|
-
root: { type: "Dashboard", props: { username: undefined }, children: [] },
|
|
570
|
-
},
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// After auth.login sets context.username = "alice":
|
|
574
|
-
// Component receives: { username: "alice" }
|
|
575
|
-
```
|
|
280
|
+
## Testing
|
|
576
281
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
If both a route param and a `contextProps` field share the same key, the route param wins:
|
|
282
|
+
```bash
|
|
283
|
+
# Run tests for this package in isolation
|
|
284
|
+
npm test -w packages/play-xstate
|
|
581
285
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
// play.route to /profile/demo → context.params.username = "demo"
|
|
585
|
-
// contextProps: ["username"], props: { username: undefined }
|
|
586
|
-
// Component receives: { username: "demo" } ← route param wins
|
|
286
|
+
# Watch mode
|
|
287
|
+
npm run test:watch -w packages/play-xstate
|
|
587
288
|
```
|
|
588
289
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
This package implements Play RFC requirements:
|
|
290
|
+
Tests use [Vitest](https://vitest.dev/) and live in `packages/play-xstate/test/`.
|
|
592
291
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
- **Actor Authority (INV-01):** Guards decide navigation validity
|
|
596
|
-
- **Strict Separation (INV-02):** Zero framework imports
|
|
597
|
-
- **Signal-Only Reactivity (INV-05):** All state via TC39 Signals
|
|
598
|
-
|
|
599
|
-
**XState DevTools:** Maintains Inspector compatibility — snapshots remain pure XState format, signals accessible via actor properties.
|
|
600
|
-
|
|
601
|
-
**Routing:**
|
|
602
|
-
|
|
603
|
-
- `meta.route` property marks states as routable
|
|
604
|
-
- `play.route` events support parameters (enhancement)
|
|
605
|
-
- Route extraction for URL patterns
|
|
606
|
-
|
|
607
|
-
**Note:** Route parameter extraction uses URLPattern API. See [@xmachines/play-tanstack-react-router](../play-tanstack-react-router/README.md) for polyfill requirements.
|
|
608
|
-
|
|
609
|
-
## Related Packages
|
|
610
|
-
|
|
611
|
-
- **[@xmachines/play-actor](../play-actor/README.md)** - AbstractActor base class
|
|
612
|
-
- **[@xmachines/play-signals](../play-signals/README.md)** - TC39 Signals polyfill
|
|
613
|
-
- **[@xmachines/play-router](../play-router/README.md)** - Route extraction utilities
|
|
614
|
-
- **[@xmachines/play-react](../play-react/README.md)** - React renderer
|
|
615
|
-
- **[@xmachines/play-vue](../play-vue/README.md)** - Vue renderer
|
|
616
|
-
- **[@xmachines/play-solid](../play-solid/README.md)** - SolidJS renderer
|
|
617
|
-
- **[@xmachines/play-dom](../play-dom/README.md)** - Vanilla DOM renderer
|
|
618
|
-
- **[@xmachines/play](../play/README.md)** - Protocol types (PlayEvent)
|
|
292
|
+
---
|
|
619
293
|
|
|
620
294
|
## License
|
|
621
295
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
This work is licensed under the terms of the MIT license.
|
|
625
|
-
For a copy, see <https://opensource.org/licenses/MIT>.
|
|
296
|
+
MIT — see [LICENSE](LICENSE) for details.
|
|
626
297
|
|
|
627
298
|
@xmachines/play-xstate - XState v5 adapter for Play Architecture
|
|
628
299
|
|