@xmachines/docs 1.0.0-beta.45 → 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 +4 -4
- 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 +3 -3
- package/examples/@xmachines/play-react-demo/README.md +2 -2
- 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 +2 -2
- package/examples/@xmachines/play-solid-demo/README.md +2 -2
- 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-solid-router-demo/README.md +1 -1
- package/examples/@xmachines/play-svelte-demo/README.md +2 -2
- 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 +3 -3
- package/examples/@xmachines/play-sveltekit-router-demo/README.md +3 -3
- package/examples/@xmachines/play-tanstack-react-router-demo/README.md +1 -1
- package/examples/@xmachines/play-tanstack-solid-router-demo/README.md +1 -1
- package/examples/@xmachines/play-vue-demo/README.md +2 -2
- 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/@xmachines/play-vue-router-demo/README.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,50 +1,95 @@
|
|
|
1
1
|
<!-- generated-by: gsd-doc-writer -->
|
|
2
2
|
|
|
3
|
-
# Getting Started
|
|
3
|
+
# Getting Started with XMachines Play
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This guide walks you through installing XMachines packages, wiring a state machine with [`definePlayer`](../api/@xmachines/play-xstate/functions/definePlayer.md), connecting a view renderer, and plugging in a router adapter — from zero to a running actor-driven application.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Prerequisites
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- **Node.js** `>= 22.0.0`
|
|
12
|
+
- **npm** `>= 10.0.0`
|
|
13
|
+
- **TypeScript** `>= 5.7` (strict mode recommended)
|
|
14
|
+
- **XState** `v5` (required peer dependency for [`@xmachines/play-xstate`](../api/@xmachines/play-xstate/README.md))
|
|
15
|
+
|
|
16
|
+
All packages are ES modules (`"type": "module"`). Use `.js` extensions in all TypeScript imports.
|
|
17
|
+
|
|
18
|
+
---
|
|
12
19
|
|
|
13
20
|
## Installation
|
|
14
21
|
|
|
15
|
-
Install the core packages
|
|
22
|
+
### Step 1: Install the core packages
|
|
23
|
+
|
|
24
|
+
Every XMachines application needs these three packages plus XState:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install xstate @xmachines/play-xstate @xmachines/play-actor @xmachines/play-signals
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Package | Role |
|
|
31
|
+
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| `xstate` | XState v5 state machine engine (peer dependency) |
|
|
33
|
+
| [`@xmachines/play-xstate`](../api/@xmachines/play-xstate/README.md) | [`definePlayer()`](../api/@xmachines/play-xstate/functions/definePlayer.md), [`PlayerActor`](../api/@xmachines/play-xstate/classes/PlayerActor.md), routing helpers |
|
|
34
|
+
| [`@xmachines/play-actor`](../api/@xmachines/play-actor/README.md) | Abstract actor base class and interface types |
|
|
35
|
+
| [`@xmachines/play-signals`](../api/@xmachines/play-signals/README.md) | TC39 Signals polyfill (`Signal.State`, `Signal.Computed`, [`watchSignal`](../api/@xmachines/play-signals/functions/watchSignal.md)) |
|
|
36
|
+
|
|
37
|
+
### Step 2: Install a router adapter (pick one)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Framework-integrated routers (provider pattern)
|
|
41
|
+
npm install @xmachines/play-tanstack-react-router # TanStack Router (React)
|
|
42
|
+
npm install @xmachines/play-tanstack-solid-router # TanStack Router (SolidJS)
|
|
43
|
+
npm install @xmachines/play-react-router # React Router v7
|
|
44
|
+
npm install @xmachines/play-vue-router # Vue Router 4.x/5.x
|
|
45
|
+
npm install @xmachines/play-solid-router # SolidJS Router
|
|
46
|
+
|
|
47
|
+
# connectRouter pattern (framework-agnostic)
|
|
48
|
+
npm install @xmachines/play-dom-router # Vanilla DOM (Browser History API)
|
|
49
|
+
npm install @xmachines/play-sveltekit-router # SvelteKit
|
|
50
|
+
npm install @xmachines/play-svelte-spa-router # Svelte SPA Router
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Step 3: Install a view renderer (pick one)
|
|
16
54
|
|
|
17
55
|
```bash
|
|
18
|
-
npm install @xmachines/play-
|
|
56
|
+
npm install @xmachines/play-react # React 18/19
|
|
57
|
+
npm install @xmachines/play-vue # Vue 3
|
|
58
|
+
npm install @xmachines/play-solid # SolidJS
|
|
59
|
+
npm install @xmachines/play-svelte # Svelte 5
|
|
60
|
+
npm install @xmachines/play-dom # Vanilla DOM
|
|
19
61
|
```
|
|
20
62
|
|
|
21
|
-
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## First Run: Core Actor (No Router, No Renderer)
|
|
22
66
|
|
|
23
|
-
|
|
67
|
+
The minimum viable XMachines actor — no framework dependencies:
|
|
24
68
|
|
|
25
69
|
```typescript
|
|
26
70
|
import { setup } from "xstate";
|
|
71
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
27
72
|
|
|
28
|
-
|
|
73
|
+
// 1. Declare types with setup() — the XState v5 typed entry point
|
|
74
|
+
const appSetup = setup({
|
|
29
75
|
types: {
|
|
30
76
|
context: {} as { count: number },
|
|
31
77
|
events: {} as { type: "toggle" },
|
|
32
|
-
input: {} as
|
|
78
|
+
input: {} as undefined,
|
|
33
79
|
},
|
|
34
80
|
});
|
|
35
81
|
|
|
36
|
-
|
|
37
|
-
|
|
82
|
+
// 2. Create the machine using setup().createMachine()
|
|
83
|
+
const machine = appSetup.createMachine({
|
|
84
|
+
id: "app",
|
|
38
85
|
initial: "off",
|
|
39
|
-
context:
|
|
40
|
-
count: input?.count ?? 0,
|
|
41
|
-
}),
|
|
86
|
+
context: { count: 0 },
|
|
42
87
|
states: {
|
|
43
88
|
off: {
|
|
44
89
|
on: {
|
|
45
90
|
toggle: {
|
|
46
91
|
target: "on",
|
|
47
|
-
actions:
|
|
92
|
+
actions: appSetup.assign({ count: ({ context }) => context.count + 1 }),
|
|
48
93
|
},
|
|
49
94
|
},
|
|
50
95
|
},
|
|
@@ -52,70 +97,46 @@ const toggleMachine = toggleSetup.createMachine({
|
|
|
52
97
|
on: {
|
|
53
98
|
toggle: {
|
|
54
99
|
target: "off",
|
|
55
|
-
actions:
|
|
100
|
+
actions: appSetup.assign({ count: ({ context }) => context.count + 1 }),
|
|
56
101
|
},
|
|
57
102
|
},
|
|
58
103
|
},
|
|
59
104
|
},
|
|
60
105
|
});
|
|
61
|
-
```
|
|
62
106
|
|
|
63
|
-
|
|
107
|
+
// 3. Create a player factory
|
|
108
|
+
const createPlayer = definePlayer({ machine });
|
|
64
109
|
|
|
65
|
-
|
|
66
|
-
- Use `setup.assign(...)` (not the bare `assign` from xstate) for context mutations.
|
|
67
|
-
- Event types use lowercase dot-separated names: `"toggle"`, `"auth.login"`, `"play.route"`.
|
|
68
|
-
|
|
69
|
-
## Step 2: Define a Player
|
|
70
|
-
|
|
71
|
-
`definePlayer` wraps the machine in a factory. Each call to the factory creates an independent `PlayerActor` instance:
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
import { definePlayer } from "@xmachines/play-xstate";
|
|
75
|
-
|
|
76
|
-
const createPlayer = definePlayer({ machine: toggleMachine });
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Step 3: Create and Start an Actor
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
110
|
+
// 4. Create and start an actor
|
|
82
111
|
const actor = createPlayer();
|
|
83
112
|
actor.start();
|
|
84
113
|
|
|
85
|
-
// Read
|
|
114
|
+
// 5. Read state
|
|
86
115
|
console.log(actor.getSnapshot().value); // "off"
|
|
87
|
-
console.log(actor.
|
|
116
|
+
console.log(actor.state.get().value); // "off" (TC39 Signal)
|
|
88
117
|
|
|
89
|
-
// Send events
|
|
118
|
+
// 6. Send events — the machine's guards decide all transitions
|
|
90
119
|
actor.send({ type: "toggle" });
|
|
91
120
|
console.log(actor.getSnapshot().value); // "on"
|
|
92
|
-
console.log(actor.getSnapshot().context.count); // 1
|
|
93
121
|
|
|
94
|
-
// Cleanup
|
|
122
|
+
// 7. Cleanup
|
|
95
123
|
actor.stop();
|
|
96
124
|
```
|
|
97
125
|
|
|
98
|
-
|
|
126
|
+
**Key rules:**
|
|
99
127
|
|
|
100
|
-
|
|
128
|
+
- Always use `setup({ types })` before `createMachine` — never bare `createMachine` from xstate.
|
|
129
|
+
- Use `setup.assign(...)` for context mutations — not the bare `assign` from xstate.
|
|
130
|
+
- Call `actor.start()` before sending events.
|
|
131
|
+
- Call `actor.stop()` when done to clean up signal subscriptions.
|
|
101
132
|
|
|
102
|
-
|
|
103
|
-
import { watchSignal } from "@xmachines/play-signals";
|
|
133
|
+
---
|
|
104
134
|
|
|
105
|
-
|
|
106
|
-
const unwatch = watchSignal(actor.state, () => {
|
|
107
|
-
console.log("State changed to:", actor.state.get().value);
|
|
108
|
-
});
|
|
135
|
+
## Adding Routing
|
|
109
136
|
|
|
110
|
-
|
|
137
|
+
State machines control navigation through `meta.route` on states and `play.route` events. The router is passive infrastructure that observes `actor.currentRoute`.
|
|
111
138
|
|
|
112
|
-
|
|
113
|
-
unwatch();
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Step 5: Add Routing (Optional)
|
|
117
|
-
|
|
118
|
-
Add `meta.route` to states and wrap the config with `formatPlayRouteTransitions`. The machine's context must include `params` and `query` fields:
|
|
139
|
+
### Define a routable machine
|
|
119
140
|
|
|
120
141
|
```typescript
|
|
121
142
|
import { setup } from "xstate";
|
|
@@ -124,24 +145,55 @@ import type { PlayRouteEvent } from "@xmachines/play-router";
|
|
|
124
145
|
|
|
125
146
|
const appSetup = setup({
|
|
126
147
|
types: {
|
|
148
|
+
// params and query are REQUIRED for formatPlayRouteTransitions
|
|
127
149
|
context: {} as {
|
|
128
150
|
isAuthenticated: boolean;
|
|
129
151
|
params: Record<string, string>;
|
|
130
152
|
query: Record<string, string>;
|
|
131
153
|
},
|
|
132
|
-
events: {} as
|
|
154
|
+
events: {} as
|
|
155
|
+
| PlayRouteEvent
|
|
156
|
+
| { type: "auth.login"; username: string }
|
|
157
|
+
| { type: "auth.logout" },
|
|
133
158
|
input: {} as undefined,
|
|
134
159
|
},
|
|
135
160
|
});
|
|
136
161
|
|
|
137
162
|
const appMachine = appSetup.createMachine(
|
|
163
|
+
// formatPlayRouteTransitions auto-generates play.route handlers from id + meta.route pairs
|
|
138
164
|
formatPlayRouteTransitions({
|
|
139
165
|
id: "app",
|
|
140
166
|
initial: "home",
|
|
141
167
|
context: { isAuthenticated: false, params: {}, query: {} },
|
|
142
168
|
states: {
|
|
143
169
|
home: { id: "home", meta: { route: "/" } },
|
|
170
|
+
about: { id: "about", meta: { route: "/about" } },
|
|
144
171
|
login: { id: "login", meta: { route: "/login" } },
|
|
172
|
+
dashboard: {
|
|
173
|
+
id: "dashboard",
|
|
174
|
+
meta: { route: "/dashboard" },
|
|
175
|
+
// always guard: redirect to /login if not authenticated
|
|
176
|
+
always: {
|
|
177
|
+
guard: ({ context }) => !context.isAuthenticated,
|
|
178
|
+
target: "login",
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
profile: { id: "profile", meta: { route: "/profile/:username" } },
|
|
182
|
+
},
|
|
183
|
+
on: {
|
|
184
|
+
"auth.login": {
|
|
185
|
+
target: ".dashboard",
|
|
186
|
+
guard: ({ context }) => !context.isAuthenticated,
|
|
187
|
+
actions: appSetup.assign({
|
|
188
|
+
isAuthenticated: true,
|
|
189
|
+
username: ({ event }) => (event.type === "auth.login" ? event.username : null),
|
|
190
|
+
}),
|
|
191
|
+
},
|
|
192
|
+
"auth.logout": {
|
|
193
|
+
target: ".home",
|
|
194
|
+
guard: ({ context }) => context.isAuthenticated,
|
|
195
|
+
actions: appSetup.assign({ isAuthenticated: false }),
|
|
196
|
+
},
|
|
145
197
|
},
|
|
146
198
|
}),
|
|
147
199
|
);
|
|
@@ -150,30 +202,118 @@ const createPlayer = definePlayer({ machine: appMachine });
|
|
|
150
202
|
const actor = createPlayer();
|
|
151
203
|
actor.start();
|
|
152
204
|
|
|
205
|
+
// Read the current route via TC39 Signal
|
|
153
206
|
console.log(actor.currentRoute.get()); // "/"
|
|
154
207
|
|
|
155
|
-
actor
|
|
156
|
-
|
|
208
|
+
// Navigate — actor guards validate the transition
|
|
209
|
+
actor.send({ type: "play.route", to: "#about" });
|
|
210
|
+
console.log(actor.currentRoute.get()); // "/about"
|
|
211
|
+
|
|
212
|
+
// Attempt a protected route — always guard redirects to login
|
|
213
|
+
actor.send({ type: "play.route", to: "#dashboard" });
|
|
214
|
+
console.log(actor.getSnapshot().value); // "login" (guard fired)
|
|
215
|
+
|
|
216
|
+
// Navigate with params
|
|
217
|
+
actor.send({ type: "auth.login", username: "alice" });
|
|
218
|
+
actor.send({ type: "play.route", to: "#profile", params: { username: "alice" } });
|
|
219
|
+
console.log(actor.currentRoute.get()); // "/profile/alice"
|
|
157
220
|
|
|
158
221
|
actor.stop();
|
|
159
222
|
```
|
|
160
223
|
|
|
161
|
-
|
|
224
|
+
**Routing rules:**
|
|
225
|
+
|
|
226
|
+
- Every routable state **must** have an `id` — [`formatPlayRouteTransitions`](../api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md) throws `MissingStateIdError` if absent.
|
|
227
|
+
- Send `play.route` events with `to: "#stateId"` — always use the `id` field prefixed with `#`, never raw URL paths.
|
|
228
|
+
- The machine's context must include `params: Record<string, string>` and `query: Record<string, string>` for [`formatPlayRouteTransitions`](../api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md) to work.
|
|
229
|
+
- Use `always` guards to protect states from direct URL access — these fire even on browser back/forward.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Connecting a Router Adapter
|
|
234
|
+
|
|
235
|
+
Router adapters synchronize `actor.currentRoute` with the browser URL bidirectionally. There are two integration patterns:
|
|
162
236
|
|
|
163
|
-
|
|
237
|
+
### Pattern 1: Provider pattern (React, Vue, SolidJS)
|
|
164
238
|
|
|
165
|
-
|
|
239
|
+
```typescript
|
|
240
|
+
// React + TanStack Router example
|
|
241
|
+
import { useMemo, useEffect } from "react";
|
|
242
|
+
import { createRouter, createRootRoute } from "@tanstack/react-router";
|
|
243
|
+
import {
|
|
244
|
+
PlayRouterProvider,
|
|
245
|
+
createRouteMapFromTree,
|
|
246
|
+
} from "@xmachines/play-tanstack-react-router";
|
|
247
|
+
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
248
|
+
|
|
249
|
+
// Build these OUTSIDE of JSX — must be stable references
|
|
250
|
+
const routeTree = extractMachineRoutes(appMachine);
|
|
251
|
+
const routeMap = createRouteMapFromTree(routeTree);
|
|
252
|
+
const router = createRouter({ routeTree: createRootRoute() });
|
|
253
|
+
|
|
254
|
+
export function App() {
|
|
255
|
+
const actor = useMemo(() => {
|
|
256
|
+
const a = createPlayer();
|
|
257
|
+
a.start();
|
|
258
|
+
return a;
|
|
259
|
+
}, []);
|
|
260
|
+
|
|
261
|
+
useEffect(() => () => { actor.stop(); }, [actor]);
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<PlayRouterProvider
|
|
265
|
+
actor={actor}
|
|
266
|
+
router={router}
|
|
267
|
+
routeMap={routeMap}
|
|
268
|
+
renderer={(currentActor) => (
|
|
269
|
+
// Your shell/layout component here
|
|
270
|
+
<Shell actor={currentActor} />
|
|
271
|
+
)}
|
|
272
|
+
/>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Pattern 2: `connectRouter` pattern (Vanilla DOM, SvelteKit, Svelte)
|
|
166
278
|
|
|
167
279
|
```typescript
|
|
168
|
-
import {
|
|
280
|
+
import { connectRouter, createRouteMap } from "@xmachines/play-dom-router";
|
|
281
|
+
|
|
282
|
+
const routeMap = createRouteMap(appMachine);
|
|
283
|
+
const actor = createPlayer();
|
|
284
|
+
actor.start();
|
|
285
|
+
|
|
286
|
+
// connectRouter handles bidirectional sync:
|
|
287
|
+
// - actor.currentRoute signal → browser URL
|
|
288
|
+
// - browser URL changes → play.route event sent to actor
|
|
289
|
+
const disconnectRouter = connectRouter({ actor, routeMap });
|
|
290
|
+
|
|
291
|
+
// Cleanup on unload
|
|
292
|
+
window.addEventListener("beforeunload", () => {
|
|
293
|
+
disconnectRouter();
|
|
294
|
+
actor.stop();
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Connecting a View Renderer
|
|
301
|
+
|
|
302
|
+
View renderers map `meta.view` specs from your machine states to real UI components. Each framework has a [`defineRegistry`](../api/@xmachines/play-dom/functions/defineRegistry.md) function that binds components and actions to a catalog.
|
|
303
|
+
|
|
304
|
+
### Vanilla DOM
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
import { createPlayUI, defineRegistry, schema } from "@xmachines/play-dom";
|
|
169
308
|
import { defineCatalog } from "@json-render/core";
|
|
170
309
|
import { z } from "zod";
|
|
171
310
|
import type { ComponentFn } from "@xmachines/play-dom";
|
|
172
311
|
|
|
312
|
+
// 1. Define a catalog (schema of components and actions)
|
|
173
313
|
const catalog = defineCatalog(schema, {
|
|
174
314
|
components: {
|
|
175
315
|
Home: { props: z.object({ title: z.string() }) },
|
|
176
|
-
Login: { props: z.object({
|
|
316
|
+
Login: { props: z.object({}) },
|
|
177
317
|
},
|
|
178
318
|
actions: {
|
|
179
319
|
login: { params: z.object({ username: z.string() }) },
|
|
@@ -181,42 +321,46 @@ const catalog = defineCatalog(schema, {
|
|
|
181
321
|
},
|
|
182
322
|
});
|
|
183
323
|
|
|
324
|
+
// 2. Implement components
|
|
184
325
|
const Home: ComponentFn<typeof catalog, "Home"> = ({ props }) => {
|
|
185
326
|
const el = document.createElement("section");
|
|
186
327
|
el.textContent = props.title;
|
|
187
328
|
return el;
|
|
188
329
|
};
|
|
189
|
-
const Login: ComponentFn<typeof catalog, "Login"> = ({
|
|
190
|
-
const el = document.createElement("
|
|
330
|
+
const Login: ComponentFn<typeof catalog, "Login"> = ({ on }) => {
|
|
331
|
+
const el = document.createElement("div");
|
|
191
332
|
const btn = document.createElement("button");
|
|
192
|
-
|
|
193
|
-
btn.addEventListener("click", () => submit.emit());
|
|
333
|
+
btn.textContent = "Log in";
|
|
334
|
+
btn.addEventListener("click", () => on("submit").emit());
|
|
194
335
|
el.append(btn);
|
|
195
336
|
return el;
|
|
196
337
|
};
|
|
197
338
|
|
|
198
|
-
// Build
|
|
199
|
-
const
|
|
200
|
-
|
|
339
|
+
// 3. Build registry and mount
|
|
340
|
+
const registryResult = defineRegistry(catalog, {
|
|
341
|
+
components: { Home, Login },
|
|
342
|
+
actions: {
|
|
343
|
+
login: async ({ username }) => actor.send({ type: "auth.login", username }),
|
|
344
|
+
logout: async () => actor.send({ type: "auth.logout" }),
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
const mount = createPlayUI(registryResult);
|
|
349
|
+
const disconnect = mount(actor, document.getElementById("app")!);
|
|
201
350
|
|
|
202
351
|
// Cleanup
|
|
203
|
-
window.addEventListener("beforeunload", () =>
|
|
204
|
-
disconnectRenderer();
|
|
205
|
-
actor.stop();
|
|
206
|
-
});
|
|
352
|
+
window.addEventListener("beforeunload", () => disconnect());
|
|
207
353
|
```
|
|
208
354
|
|
|
209
|
-
|
|
355
|
+
### React
|
|
210
356
|
|
|
211
357
|
```tsx
|
|
212
358
|
import { PlayUIProvider, PlayRenderer, defineRegistry } from "@xmachines/play-react";
|
|
213
|
-
import { authCatalog } from "@xmachines/play-actor-shared";
|
|
214
|
-
import { Home, Login } from "./components/index.js";
|
|
215
359
|
|
|
216
|
-
const registryResult = defineRegistry(
|
|
360
|
+
const registryResult = defineRegistry(catalog, {
|
|
217
361
|
components: { Home, Login },
|
|
218
362
|
actions: {
|
|
219
|
-
login: async (
|
|
363
|
+
login: async ({ username }) => actor.send({ type: "auth.login", username }),
|
|
220
364
|
logout: async () => actor.send({ type: "auth.logout" }),
|
|
221
365
|
},
|
|
222
366
|
});
|
|
@@ -230,83 +374,148 @@ function App() {
|
|
|
230
374
|
}
|
|
231
375
|
```
|
|
232
376
|
|
|
233
|
-
|
|
377
|
+
### Vue 3
|
|
234
378
|
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
379
|
+
```html
|
|
380
|
+
<!-- App.vue -->
|
|
381
|
+
<template>
|
|
382
|
+
<PlayUIProvider :actor="actor" :registry-result="registryResult">
|
|
383
|
+
<PlayRenderer />
|
|
384
|
+
</PlayUIProvider>
|
|
385
|
+
</template>
|
|
239
386
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
context: {} as { count: number },
|
|
243
|
-
events: {} as { type: "toggle" },
|
|
244
|
-
input: {} as undefined,
|
|
245
|
-
},
|
|
246
|
-
});
|
|
387
|
+
<script setup lang="ts">
|
|
388
|
+
import { PlayUIProvider, PlayRenderer, defineRegistry } from "@xmachines/play-vue";
|
|
247
389
|
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
off: {
|
|
254
|
-
on: {
|
|
255
|
-
toggle: {
|
|
256
|
-
target: "on",
|
|
257
|
-
actions: toggleSetup.assign({ count: ({ context }) => context.count + 1 }),
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
on: {
|
|
262
|
-
on: {
|
|
263
|
-
toggle: {
|
|
264
|
-
target: "off",
|
|
265
|
-
actions: toggleSetup.assign({ count: ({ context }) => context.count + 1 }),
|
|
266
|
-
},
|
|
267
|
-
},
|
|
390
|
+
const registryResult = defineRegistry(catalog, {
|
|
391
|
+
components: { Home, Login },
|
|
392
|
+
actions: {
|
|
393
|
+
login: async ({ username }) => actor.send({ type: "auth.login", username }),
|
|
394
|
+
logout: async () => actor.send({ type: "auth.logout" }),
|
|
268
395
|
},
|
|
396
|
+
});
|
|
397
|
+
</script>
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### SolidJS
|
|
401
|
+
|
|
402
|
+
```tsx
|
|
403
|
+
import { PlayUIProvider, PlayRenderer, defineRegistry } from "@xmachines/play-solid";
|
|
404
|
+
|
|
405
|
+
const registryResult = defineRegistry(catalog, {
|
|
406
|
+
components: { Home, Login },
|
|
407
|
+
actions: {
|
|
408
|
+
login: async ({ username }) => actor.send({ type: "auth.login", username }),
|
|
409
|
+
logout: async () => actor.send({ type: "auth.logout" }),
|
|
269
410
|
},
|
|
270
411
|
});
|
|
271
412
|
|
|
272
|
-
|
|
273
|
-
|
|
413
|
+
function App() {
|
|
414
|
+
return (
|
|
415
|
+
<PlayUIProvider actor={actor} registryResult={registryResult}>
|
|
416
|
+
<PlayRenderer />
|
|
417
|
+
</PlayUIProvider>
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
```
|
|
274
421
|
|
|
275
|
-
|
|
276
|
-
const snap = actor.state.get();
|
|
277
|
-
console.log(`State: ${String(snap.value)}, Count: ${snap.context.count}`);
|
|
278
|
-
});
|
|
422
|
+
---
|
|
279
423
|
|
|
280
|
-
|
|
281
|
-
// logs: State: off, Count: 0
|
|
424
|
+
## Common Setup Issues
|
|
282
425
|
|
|
283
|
-
|
|
284
|
-
|
|
426
|
+
### Missing `params` / `query` in context
|
|
427
|
+
|
|
428
|
+
**Error:** `MissingQueryContextError` at runtime when using [`formatPlayRouteTransitions`](../api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md).
|
|
429
|
+
|
|
430
|
+
**Fix:** Add `params` and `query` fields to your machine context:
|
|
431
|
+
|
|
432
|
+
```typescript
|
|
433
|
+
context: {} as {
|
|
434
|
+
params: Record<string, string>;
|
|
435
|
+
query: Record<string, string>;
|
|
436
|
+
// ...other fields
|
|
437
|
+
}
|
|
438
|
+
// and initialize them:
|
|
439
|
+
context: { params: {}, query: {}, /* ...other fields */ }
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### Missing `id` on routable states
|
|
443
|
+
|
|
444
|
+
**Error:** `MissingStateIdError: State "home" has meta.route "/" but no id`.
|
|
445
|
+
|
|
446
|
+
**Fix:** Every state with `meta.route` must declare an explicit `id`:
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
// ❌ Missing id
|
|
450
|
+
home: { meta: { route: "/" } }
|
|
451
|
+
|
|
452
|
+
// ✅ Correct
|
|
453
|
+
home: { id: "home", meta: { route: "/" } }
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### Actor sends events before `start()`
|
|
285
457
|
|
|
458
|
+
**Symptom:** Events are silently dropped; state never changes.
|
|
459
|
+
|
|
460
|
+
**Fix:** Always call `actor.start()` before `actor.send()`:
|
|
461
|
+
|
|
462
|
+
```typescript
|
|
463
|
+
const actor = createPlayer();
|
|
464
|
+
actor.start(); // required before any send()
|
|
286
465
|
actor.send({ type: "toggle" });
|
|
287
|
-
|
|
466
|
+
```
|
|
288
467
|
|
|
289
|
-
|
|
290
|
-
|
|
468
|
+
### `routeMap` or `actor` recreated on every render (React/Solid)
|
|
469
|
+
|
|
470
|
+
**Symptom:** The router bridge disconnects and reconnects on every render.
|
|
471
|
+
|
|
472
|
+
**Fix:** Construct stable references outside JSX or memoize them:
|
|
473
|
+
|
|
474
|
+
```typescript
|
|
475
|
+
// ✅ Built outside the component
|
|
476
|
+
const routeTree = extractMachineRoutes(appMachine);
|
|
477
|
+
const routeMap = createRouteMapFromTree(routeTree);
|
|
478
|
+
|
|
479
|
+
// ✅ Or memoized inside the component
|
|
480
|
+
const routeMap = useMemo(() => createRouteMapFromTree(routeTree), [routeTree]);
|
|
291
481
|
```
|
|
292
482
|
|
|
293
|
-
|
|
483
|
+
### Wrong Node.js version
|
|
484
|
+
|
|
485
|
+
**Error:** `SyntaxError: Cannot use import statement in a module` or TC39 Signals not available.
|
|
486
|
+
|
|
487
|
+
**Fix:** Use Node.js `>= 22.0.0`. Check with:
|
|
488
|
+
|
|
489
|
+
```bash
|
|
490
|
+
node --version
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
## Key Concepts Reference
|
|
496
|
+
|
|
497
|
+
| Term | Description |
|
|
498
|
+
| ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
499
|
+
| `setup({ types })` | XState v5 entry point — declares TypeScript types for context, events, and input |
|
|
500
|
+
| [`definePlayer({ machine })`](../api/@xmachines/play-xstate/functions/definePlayer.md) | Creates a factory that produces [`PlayerActor`](../api/@xmachines/play-xstate/classes/PlayerActor.md) instances |
|
|
501
|
+
| `actor.start()` | Activates the machine — always call before sending events |
|
|
502
|
+
| `actor.send({ type })` | Sends an event; machine guards decide whether a transition occurs |
|
|
503
|
+
| `actor.getSnapshot()` | Synchronous read of current state and context |
|
|
504
|
+
| `actor.state` | `Signal.State<Snapshot>` — TC39 Signal for reactive state observation |
|
|
505
|
+
| `actor.currentRoute` | `Signal.Computed<string \| null>` — resolved URL from active state's `meta.route` |
|
|
506
|
+
| `actor.currentView` | `Signal.State<PlaySpec \| null>` — view spec from active state's `meta.view` |
|
|
507
|
+
| [`formatPlayRouteTransitions`](../api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md) | Generates `play.route` handlers from `id` + `meta.route` state pairs |
|
|
508
|
+
| `play.route` event | Navigation event — `to: "#stateId"`, `params`, `query` |
|
|
509
|
+
| `always` guard | Protects states — fires on entry before any event, even on direct URL access |
|
|
294
510
|
|
|
295
|
-
|
|
296
|
-
| ---------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
297
|
-
| `setup({ types })` | XState v5 entry point — declares TypeScript types for context, events, and input |
|
|
298
|
-
| `definePlayer({ machine })` | Creates a factory that produces `PlayerActor` instances from the machine |
|
|
299
|
-
| `actor.start()` | Activates the machine — always call before sending events |
|
|
300
|
-
| `actor.send({ type })` | Sends an event to the machine |
|
|
301
|
-
| `actor.getSnapshot()` | Synchronous snapshot of the current state and context |
|
|
302
|
-
| `actor.state` | `Signal.State<Snapshot>` — TC39 Signal for reactive state observation |
|
|
303
|
-
| `actor.currentRoute` | `Signal.Computed<string \| null>` — resolved URL from the active state's `meta.route` |
|
|
304
|
-
| `actor.currentView` | `Signal.State<PlaySpec \| null>` — view spec from the active state's `meta.view`; drives renderers |
|
|
305
|
-
| `formatPlayRouteTransitions` | Utility that generates `play.route` handlers from `id` + `meta.route` state pairs |
|
|
511
|
+
---
|
|
306
512
|
|
|
307
513
|
## Next Steps
|
|
308
514
|
|
|
309
|
-
- **[
|
|
310
|
-
- **[
|
|
311
|
-
- **[
|
|
515
|
+
- **[ARCHITECTURE.md](ARCHITECTURE.md)** — System design, component diagram, data flow, and architectural invariants
|
|
516
|
+
- **[CONFIGURATION.md](CONFIGURATION.md)** — Environment variables and configuration options
|
|
517
|
+
- **[Routing Patterns](../packages/docs/examples/routing-patterns.md)** — `meta.route`, `play.route`, `always` guards, and parameter routes
|
|
518
|
+
- **[Multi-Router Integration](../packages/docs/examples/multi-router-integration.md)** — All 8 router adapters with full code examples
|
|
519
|
+
- **[Examples Index](../packages/docs/examples/README.md)** — Basic state machine, form validation, and traffic light demos
|
|
520
|
+
- **[API Reference](../packages/docs/api/README.md)** — Auto-generated API docs for all packages
|
|
312
521
|
- **[Play RFC](../rfc/play.md)** — Complete architectural specification
|