@xmachines/docs 1.0.0-beta.51 → 1.0.0-beta.52
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 +13 -11
- package/api/@xmachines/play/README.md +6 -5
- 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 +2 -2
- 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 +125 -47
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +20 -10
- package/api/@xmachines/play-dom/functions/createPlayUI.md +9 -9
- package/api/@xmachines/play-dom/functions/createRenderer.md +3 -2
- package/api/@xmachines/play-dom/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-dom/functions/renderSpec.md +17 -13
- package/api/@xmachines/play-dom/interfaces/ComponentContext.md +7 -7
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +15 -12
- package/api/@xmachines/play-dom/interfaces/DefineRegistryResult.md +4 -4
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +17 -14
- package/api/@xmachines/play-dom/interfaces/EventHandle.md +4 -4
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +10 -6
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +20 -8
- package/api/@xmachines/play-dom/interfaces/UIProviderOptions.md +13 -10
- 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 +6 -4
- 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 +23 -25
- 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 +6 -6
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +68 -0
- 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-react/README.md +3 -3
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +5 -5
- package/api/@xmachines/play-react/functions/useActor.md +3 -3
- 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/AnyPlayActor.md +11 -0
- 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 +16 -1
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +85 -41
- package/api/@xmachines/play-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +4 -4
- 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/PlayActor.md +68 -0
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +8 -8
- 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 +21 -18
- package/api/@xmachines/play-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +83 -43
- 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/PlayActor.md +68 -0
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-router/interfaces/RoutableActor.md +64 -0
- 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 +4 -3
- 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 +18 -20
- package/api/@xmachines/play-solid/functions/useActor.md +3 -3
- 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/AnyPlayActor.md +11 -0
- package/api/@xmachines/play-solid/variables/ActorContext.md +2 -2
- 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 +77 -10
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +83 -35
- package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +4 -4
- 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/PlayActor.md +68 -0
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +8 -8
- 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 +6 -4
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-svelte/README.md +23 -14
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-svelte/functions/getActorContext.md +3 -3
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/setActorContext.md +4 -4
- 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/AnyPlayActor.md +11 -0
- package/api/@xmachines/play-svelte-spa-router/README.md +13 -13
- 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 +6 -6
- 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 +20 -20
- 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 +6 -6
- 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 +3 -6
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +80 -35
- package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +4 -4
- 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/PlayActor.md +68 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +8 -8
- 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 +23 -17
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/classes/{SolidRouterBridge.md → TanStackSolidRouterBridge.md} +86 -38
- package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayActor.md +68 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +8 -8
- 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 +6 -4
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +2 -2
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +3 -3
- package/api/@xmachines/play-vue/README.md +3 -3
- 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 +3 -3
- 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/AnyPlayActor.md +11 -0
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue-router/README.md +27 -17
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +81 -33
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-vue-router/interfaces/PlayActor.md +68 -0
- 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 +6 -4
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +3 -3
- package/api/@xmachines/play-xstate/README.md +7 -3
- 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/interfaces/RouteObject.md +17 -0
- 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/RouteMetadata.md +9 -0
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
- package/api/@xmachines/shared/README.md +25 -12
- 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/contributing/architecture.md +599 -0
- package/contributing/configuration.md +262 -419
- package/contributing/development.md +300 -453
- package/contributing/testing.md +165 -172
- package/examples/@xmachines/play-dom-demo/README.md +30 -21
- 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 +23 -18
- package/examples/@xmachines/play-react-demo/README.md +38 -37
- 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 +37 -33
- package/examples/@xmachines/play-solid-demo/README.md +5 -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 +38 -25
- package/examples/@xmachines/play-svelte-demo/README.md +8 -5
- 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 +11 -9
- package/examples/@xmachines/play-sveltekit-router-demo/README.md +14 -9
- package/examples/@xmachines/play-tanstack-react-router-demo/README.md +39 -13
- package/examples/@xmachines/play-tanstack-solid-router-demo/README.md +27 -13
- package/examples/@xmachines/play-vue-demo/README.md +35 -24
- 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 +2 -0
- package/examples/README.md +7 -7
- package/examples/multi-router-integration.md +13 -16
- package/examples/routing-patterns.md +2 -2
- package/guides/README.md +1 -1
- package/guides/actor-model.md +2 -2
- package/guides/getting-started.md +325 -132
- package/guides/signals.md +1 -1
- package/guides/state-machines.md +1 -1
- package/package.json +2 -2
- package/api/@xmachines/play-dom/functions/connectRenderer.md +0 -70
- package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +0 -28
- package/api/@xmachines/play-dom-router/type-aliases/RoutableActor.md +0 -9
- package/api/@xmachines/play-react/type-aliases/PlayActor.md +0 -9
- package/api/@xmachines/play-solid/type-aliases/PlayActor.md +0 -9
- package/api/@xmachines/play-svelte/type-aliases/PlayActor.md +0 -9
- package/api/@xmachines/play-vue/type-aliases/PlayActor.md +0 -9
- package/guides/architecture.md +0 -500
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
function xmOptimizeDeps(extra?): DepOptimizationOptions;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [vite-aliases.ts:179](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [vite-aliases.ts:179](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.52/packages/shared/config/vite-aliases.ts#L179)
|
|
10
10
|
|
|
11
11
|
Returns the standard Vite `optimizeDeps` config for browser test projects.
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
function xmResolve(importMetaUrl, extra?): ResolveOptions & object;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [vite-aliases.ts:151](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [vite-aliases.ts:151](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.52/packages/shared/config/vite-aliases.ts#L151)
|
|
10
10
|
|
|
11
11
|
Full Vite `resolve` config for @xmachines/\* workspace packages.
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
function defineXmVitestConfig(importMetaUrl, overrides): UserConfig;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [vitest.ts:55](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [vitest.ts:55](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.52/packages/shared/config/vitest.ts#L55)
|
|
10
10
|
|
|
11
11
|
Create a Vitest config with XMachines workspace defaults.
|
|
12
12
|
|
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
<!-- generated-by: gsd-doc-writer -->
|
|
2
|
+
|
|
3
|
+
# Architecture
|
|
4
|
+
|
|
5
|
+
XMachines Play implements the **Universal Player Architecture** — a layered, actor-authority design where XState machines are the single source of truth for routing, navigation, and view selection. Infrastructure (routers, renderers) is strictly passive: it observes actor signals and reflects them, never enforcing guards or making decisions.
|
|
6
|
+
|
|
7
|
+
## System Overview
|
|
8
|
+
|
|
9
|
+
XMachines JS is the JavaScript/TypeScript reference implementation of the **Universal Player Architecture** ([Play RFC](../packages/docs/rfc/play.md)). It is a monorepo of modular packages that strictly separates **business logic (the Actor)** from **infrastructure (router adapters and view renderers)**. An XState v5 state machine is the single source of truth; it owns all state, guards, and route validity. Infrastructure is passive: it observes TC39 Signals emitted by the Actor and proposes state changes via typed events. The Actor's guards make every navigation and transition decision. Communication across the boundary is exclusively through TC39 Signals — never subscriptions, callbacks, or direct state mutation. Five architectural invariants (documented in the [Play RFC](../packages/docs/rfc/play.md)) enforce this contract across the entire package graph.
|
|
10
|
+
|
|
11
|
+
## Architectural Invariants
|
|
12
|
+
|
|
13
|
+
| ID | Name | Rule |
|
|
14
|
+
| ------ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| INV-01 | **Actor Authority** | Infrastructure proposes intents via `play.route` events; Actor decides via XState guards |
|
|
16
|
+
| INV-02 | **Strict Separation** | No direct dependencies between Actor and Infrastructure layers. `play-xstate` never imports UI frameworks or routing libraries |
|
|
17
|
+
| INV-03 | **Passive Infrastructure** | Infrastructure observes Actor signals, never controls state |
|
|
18
|
+
| INV-04 | **Signal-Only Reactivity** | All Actor→Infrastructure state changes flow through TC39 Signals (`Signal.State`, `Signal.Computed`). No subscriptions or event emitters |
|
|
19
|
+
| INV-05 | **State-Driven Reset** | Invalid external navigation is overwritten by Actor-derived state |
|
|
20
|
+
|
|
21
|
+
## Component Diagram
|
|
22
|
+
|
|
23
|
+
```mermaid
|
|
24
|
+
graph TD
|
|
25
|
+
subgraph Layer0["Layer 0 — Protocol / Primitives"]
|
|
26
|
+
play["@xmachines/play\n(PlayEvent, PlayError)"]
|
|
27
|
+
signals["@xmachines/play-signals\n(TC39 Signal, watchSignal)"]
|
|
28
|
+
shared["@xmachines/shared\n(tsconfig, oxlint, oxfmt)"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
subgraph Layer1["Layer 1 — Abstract Actor Base"]
|
|
32
|
+
actor["@xmachines/play-actor\n(AbstractActor, Routable, Viewable, PlaySpec)"]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
subgraph Layer2["Layer 2 — Concrete Implementations"]
|
|
36
|
+
xstate["@xmachines/play-xstate\n(PlayerActor, definePlayer, guards, routing)"]
|
|
37
|
+
router["@xmachines/play-router\n(RouterBridgeBase, RouteMap, extractMachineRoutes)"]
|
|
38
|
+
|
|
39
|
+
subgraph Views["View Renderers"]
|
|
40
|
+
react["@xmachines/play-react"]
|
|
41
|
+
vue["@xmachines/play-vue"]
|
|
42
|
+
solid["@xmachines/play-solid"]
|
|
43
|
+
svelte["@xmachines/play-svelte"]
|
|
44
|
+
dom["@xmachines/play-dom"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
subgraph RouterAdapters["Router Adapters"]
|
|
48
|
+
tsr["@xmachines/play-tanstack-react-router"]
|
|
49
|
+
rr["@xmachines/play-react-router"]
|
|
50
|
+
vr["@xmachines/play-vue-router"]
|
|
51
|
+
sr["@xmachines/play-solid-router"]
|
|
52
|
+
tss["@xmachines/play-tanstack-solid-router"]
|
|
53
|
+
sk["@xmachines/play-sveltekit-router"]
|
|
54
|
+
ssr["@xmachines/play-svelte-spa-router"]
|
|
55
|
+
dr["@xmachines/play-dom-router"]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
play --> actor
|
|
60
|
+
signals --> actor
|
|
61
|
+
actor --> xstate
|
|
62
|
+
actor --> router
|
|
63
|
+
actor --> Views
|
|
64
|
+
signals --> xstate
|
|
65
|
+
signals --> router
|
|
66
|
+
play --> xstate
|
|
67
|
+
play --> router
|
|
68
|
+
router --> RouterAdapters
|
|
69
|
+
xstate -.->|"play.route events"| router
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Component Responsibilities
|
|
73
|
+
|
|
74
|
+
| Package | Responsibility | Key File |
|
|
75
|
+
| --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
76
|
+
| [`@xmachines/play`](../packages/docs/api/@xmachines/play/README.md) | Core protocol types and error base class | `packages/play/src/index.ts` |
|
|
77
|
+
| [`@xmachines/play-signals`](../packages/docs/api/@xmachines/play-signals/README.md) | TC39 Signal polyfill isolation wrapper | `packages/play-signals/src/index.ts` |
|
|
78
|
+
| [`@xmachines/play-actor`](../packages/docs/api/@xmachines/play-actor/README.md) | `AbstractActor` base class + capability interfaces | `packages/play-actor/src/abstract-actor.ts` |
|
|
79
|
+
| [`@xmachines/play-xstate`](../packages/docs/api/@xmachines/play-xstate/README.md) | XState v5 adapter: `definePlayer`, `PlayerActor` | `packages/play-xstate/src/player-actor.ts` |
|
|
80
|
+
| [`@xmachines/play-router`](../packages/docs/api/@xmachines/play-router/README.md) | Route extraction, `RouteMap`, `RouterBridgeBase` | `packages/play-router/src/router-bridge-base.ts` |
|
|
81
|
+
| [`@xmachines/play-react`](../packages/docs/api/@xmachines/play-react/README.md) | React renderer: `ActorProvider`, `PlayRenderer` | `packages/play-react/src/ActorProvider.tsx` |
|
|
82
|
+
| [`@xmachines/play-vue`](../packages/docs/api/@xmachines/play-vue/README.md) | Vue 3 renderer: `ActorProvider.vue`, `PlayRenderer.vue` | `packages/play-vue/src/ActorProvider.vue` |
|
|
83
|
+
| [`@xmachines/play-solid`](../packages/docs/api/@xmachines/play-solid/README.md) | SolidJS renderer | `packages/play-solid/src/ActorProvider.tsx` |
|
|
84
|
+
| [`@xmachines/play-svelte`](../packages/docs/api/@xmachines/play-svelte/README.md) | Svelte 5 renderer | `packages/play-svelte/src/ActorProvider.svelte` |
|
|
85
|
+
| [`@xmachines/play-dom`](../packages/docs/api/@xmachines/play-dom/README.md) | Vanilla DOM renderer | `packages/play-dom/src/create-play-ui.ts` |
|
|
86
|
+
| [`@xmachines/play-tanstack-react-router`](../packages/docs/api/@xmachines/play-tanstack-react-router/README.md) | TanStack React Router bridge | `packages/play-tanstack-react-router/src/tanstack-router-bridge.ts` |
|
|
87
|
+
| [`@xmachines/play-tanstack-solid-router`](../packages/docs/api/@xmachines/play-tanstack-solid-router/README.md) | TanStack SolidJS Router bridge | `packages/play-tanstack-solid-router/src/solid-router-bridge.ts` |
|
|
88
|
+
| [`@xmachines/play-vue-router`](../packages/docs/api/@xmachines/play-vue-router/README.md) | Vue Router 4/5 bridge | `packages/play-vue-router/src/vue-router-bridge.ts` |
|
|
89
|
+
| [`@xmachines/play-react-router`](../packages/docs/api/@xmachines/play-react-router/README.md) | React Router v7 bridge | `packages/play-react-router/src/react-router-bridge.ts` |
|
|
90
|
+
| [`@xmachines/play-solid-router`](../packages/docs/api/@xmachines/play-solid-router/README.md) | SolidJS Router bridge | `packages/play-solid-router/src/solid-router-bridge.ts` |
|
|
91
|
+
| [`@xmachines/play-dom-router`](../packages/docs/api/@xmachines/play-dom-router/README.md) | Vanilla DOM hash/history router bridge | `packages/play-dom-router/src/dom-router-bridge.ts` |
|
|
92
|
+
| [`@xmachines/play-sveltekit-router`](../packages/docs/api/@xmachines/play-sveltekit-router/README.md) | SvelteKit router bridge | `packages/play-sveltekit-router/src/sveltekit-router-bridge.ts` |
|
|
93
|
+
| [`@xmachines/play-svelte-spa-router`](../packages/docs/api/@xmachines/play-svelte-spa-router/README.md) | Svelte SPA Router bridge | `packages/play-svelte-spa-router/src/svelte-spa-router-bridge.ts` |
|
|
94
|
+
| `@xmachines/shared` | Shared configs: tsconfig, oxlint, oxfmt, vitest | `packages/shared/config/` |
|
|
95
|
+
| `@xmachines/docs` | API docs and RFC documentation | `packages/docs/` |
|
|
96
|
+
|
|
97
|
+
## Data Flow
|
|
98
|
+
|
|
99
|
+
### Actor State Change → UI Render
|
|
100
|
+
|
|
101
|
+
```mermaid
|
|
102
|
+
flowchart TD
|
|
103
|
+
A["XState machine transition"]
|
|
104
|
+
B["PlayerActor xstateActor.subscribe(snapshot)"]
|
|
105
|
+
C["StateSignalManager.scheduleUpdate(snapshot)\nactor.state Signal.State updated — synchronous"]
|
|
106
|
+
D["actor.currentRoute Signal.Computed recomputes\nderives URL from meta.route + context.params"]
|
|
107
|
+
E["validateAndCacheView(snapshot)\nactor.currentView Signal.State updated"]
|
|
108
|
+
F["Framework signal watcher fires\nmicrotask"]
|
|
109
|
+
G["ActorProvider reads actor.currentView.get()"]
|
|
110
|
+
H["PlayRenderer renders via @json-render/* Renderer"]
|
|
111
|
+
|
|
112
|
+
A --> B --> C --> D --> E --> F --> G --> H
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### User Navigation (Browser URL → Actor)
|
|
116
|
+
|
|
117
|
+
```mermaid
|
|
118
|
+
flowchart TD
|
|
119
|
+
A["Browser popstate / router navigation event"]
|
|
120
|
+
B["Router adapter watchRouterChanges() handler fires"]
|
|
121
|
+
C["RouterBridgeBase.syncActorFromRouter(pathname, search)"]
|
|
122
|
+
D["sanitizePathname(pathname)\nlength/content guard"]
|
|
123
|
+
E["buildPlayRouteEvent(path, routeMap)\nresolves stateId from URL via URLPattern"]
|
|
124
|
+
F["actor.send({ type: 'play.route', to: '#stateId', params, query })"]
|
|
125
|
+
G["XState machine guard evaluates transition"]
|
|
126
|
+
H["machine transitions → signals update\n→ URL bar updated"]
|
|
127
|
+
I["guard blocks → machine stays\n→ router re-syncs to actor's current route"]
|
|
128
|
+
|
|
129
|
+
A --> B --> C --> D --> E --> F --> G
|
|
130
|
+
G -->|valid| H
|
|
131
|
+
G -->|invalid| I
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Actor State Change → Router URL Sync
|
|
135
|
+
|
|
136
|
+
```mermaid
|
|
137
|
+
flowchart TD
|
|
138
|
+
A["actor.currentRoute Signal.Computed changes"]
|
|
139
|
+
B["RouterBridgeBase routeWatcher\nTC39 Signal.subtle.Watcher fires"]
|
|
140
|
+
C["watchSignal microtask queued\nneedsEnqueue dedup guard"]
|
|
141
|
+
D["syncRouterFromActor(route) called"]
|
|
142
|
+
E["lastSyncedPath set\necho suppression — prevents circular callback"]
|
|
143
|
+
F["navigateRouter(path)\ncalls framework router's navigate API"]
|
|
144
|
+
G["Router updates URL bar"]
|
|
145
|
+
|
|
146
|
+
A --> B --> C --> D --> E --> F --> G
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Initial Connection (deep-link vs. restore detection)
|
|
150
|
+
|
|
151
|
+
```mermaid
|
|
152
|
+
flowchart TD
|
|
153
|
+
A["bridge.connect()"]
|
|
154
|
+
B["routeWatcher armed on actor.currentRoute"]
|
|
155
|
+
C["watchRouterChanges() subscribed"]
|
|
156
|
+
D["getInitialRouterPath() reads current browser URL"]
|
|
157
|
+
E["resolves sanitized URL path → stateId via routeMap"]
|
|
158
|
+
F{"Compare stateId vs actor.initialRoute"}
|
|
159
|
+
G["syncActorFromRouter()\nrouter wins — deep-link"]
|
|
160
|
+
H["navigateRouter()\nactor wins — restore"]
|
|
161
|
+
|
|
162
|
+
A --> B --> C --> D --> E --> F
|
|
163
|
+
F -->|"URL ≠ machine initial state"| G
|
|
164
|
+
F -->|"URL = machine initial state"| H
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### View Prop Enrichment
|
|
168
|
+
|
|
169
|
+
```mermaid
|
|
170
|
+
flowchart TD
|
|
171
|
+
A["XState snapshot.getMeta()"]
|
|
172
|
+
B["resolveViewMeta(meta)\nfinds first meta.view with root + elements"]
|
|
173
|
+
C["Extract context.params\nURL path params set by formatPlayRouteTransitions assign"]
|
|
174
|
+
D["Extract contextProps allowlist\nexplicit opt-in from PlaySpec.contextProps"]
|
|
175
|
+
E["mergeRouteParamsIntoProps()\npriority: spec prop > URL param > contextProps value"]
|
|
176
|
+
F["Enriched PlaySpec set on currentView signal"]
|
|
177
|
+
|
|
178
|
+
A --> B --> C --> D --> E --> F
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**State signals on the actor:**
|
|
182
|
+
|
|
183
|
+
| Signal | Type | Description |
|
|
184
|
+
| -------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
185
|
+
| `actor.state` | `Signal.State<AnyMachineSnapshot>` | XState snapshot; updated synchronously on active states only |
|
|
186
|
+
| `actor.currentRoute` | `Signal.Computed<string \| null>` | Derived from `meta.route` + `context.params`; `null` when unroutable |
|
|
187
|
+
| `actor.currentView` | `Signal.State<PlaySpec \| null>` | Set explicitly per-transition (not computed) to ensure watcher notifications on self-transitions |
|
|
188
|
+
|
|
189
|
+
## Key Abstractions
|
|
190
|
+
|
|
191
|
+
### [`PlayEvent<TPayload>`](../packages/docs/api/@xmachines/play/type-aliases/PlayEvent.md)
|
|
192
|
+
|
|
193
|
+
The minimal event contract for Actor communication: any object with a `readonly type: string` property. `TPayload` extends `Record<string, unknown>` for additional fields. Framework-agnostic; used directly by XState, router adapters, and domain logic. Part of [`@xmachines/play`](../packages/docs/api/@xmachines/play/README.md).
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import type { PlayEvent } from "@xmachines/play";
|
|
197
|
+
|
|
198
|
+
type LoginEvent = PlayEvent<{ userId: string; timestamp: number }>;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### [`PlayError`](../packages/docs/api/@xmachines/play/classes/PlayError.md)
|
|
202
|
+
|
|
203
|
+
Base class for all `@xmachines/*` typed runtime errors. Carries `scope` (throwing class/module) and `code` (stable machine-readable identifier, e.g. `"PLAY_ROUTER_SYNC_FAILED"`). Subclassed per package, exported from each package's `./errors` subpath. Never match on `.message` — always match on `.code` or the subclass.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { PlayError } from "@xmachines/play";
|
|
207
|
+
import { RouterSyncError } from "@xmachines/play-router/errors";
|
|
208
|
+
|
|
209
|
+
if (err instanceof RouterSyncError) {
|
|
210
|
+
/* err.scope, err.code, err.cause */
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### [`AbstractActor<TLogic, TEvent>`](../packages/docs/api/@xmachines/play-actor/classes/AbstractActor.md)
|
|
215
|
+
|
|
216
|
+
Abstract base class extending XState `Actor`. Declares `public abstract state: Signal.State<unknown>` and `public abstract override send(event: TEvent): void`. Maintains XState ecosystem compatibility (devtools, inspection) while enforcing the signal protocol. Concrete implementations extend this (e.g. [`PlayerActor`](../packages/docs/api/@xmachines/play-xstate/classes/PlayerActor.md)).
|
|
217
|
+
|
|
218
|
+
### [`Routable`](../packages/docs/api/@xmachines/play-actor/interfaces/Routable.md)
|
|
219
|
+
|
|
220
|
+
Optional capability interface. Exposes `currentRoute: Signal.Computed<string | null>` (derived URL path) and `readonly initialRoute: string | null` (machine's initial route, fixed at definition time). Router bridges consume this interface directly — they never depend on the concrete [`PlayerActor`](../packages/docs/api/@xmachines/play-xstate/classes/PlayerActor.md).
|
|
221
|
+
|
|
222
|
+
### [`Viewable`](../packages/docs/api/@xmachines/play-actor/interfaces/Viewable.md)
|
|
223
|
+
|
|
224
|
+
Optional capability interface. Exposes `currentView: Signal.State<PlaySpec | null>`. View renderers (`PlayRenderer`) consume this contract to resolve the current view description into UI without coupling to the framework or actor implementation.
|
|
225
|
+
|
|
226
|
+
### [`PlaySpec`](../packages/docs/api/@xmachines/play-actor/interfaces/PlaySpec.md)
|
|
227
|
+
|
|
228
|
+
Extends `@json-render/core` `Spec` with `readonly contextProps?: readonly string[]` — an explicit allowlist of machine context fields that `deriveCurrentView` merges into element props. Only fields named here are ever exposed to components. `typedSpec<TContext>()` provides compile-time validation of `contextProps` entries against the machine's context type.
|
|
229
|
+
|
|
230
|
+
### [`PlayerActor<TMachine>`](../packages/docs/api/@xmachines/play-xstate/classes/PlayerActor.md)
|
|
231
|
+
|
|
232
|
+
Concrete XState v5 actor implementing the full signal protocol. Extends [`AbstractActor`](../packages/docs/api/@xmachines/play-actor/classes/AbstractActor.md); implements both [`Routable`](../packages/docs/api/@xmachines/play-actor/interfaces/Routable.md) and [`Viewable`](../packages/docs/api/@xmachines/play-actor/interfaces/Viewable.md). Wraps an internal `xstate.Actor` and bridges its subscription to TC39 Signals via `StateSignalManager`. Exposes: `state`, `currentRoute`, `currentView`, `initialRoute`, `send()`, `start()`, `stop()`, `can()`, `dispose()`.
|
|
233
|
+
|
|
234
|
+
### [`definePlayer(config)`](../packages/docs/api/@xmachines/play-xstate/functions/definePlayer.md) → [`PlayerFactory`](../packages/docs/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md)
|
|
235
|
+
|
|
236
|
+
Factory creator. Pre-computes `initialRoute` once from the machine's initial state (zero extra actor instantiation per factory call). Returns `(input?, restore?) => PlayerActor<TMachine>`.
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
240
|
+
|
|
241
|
+
const createPlayer = definePlayer({ machine, options });
|
|
242
|
+
const actor = createPlayer(); // or createPlayer(input) or createPlayer(undefined, { snapshot })
|
|
243
|
+
actor.start();
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### [`RouterBridgeBase`](../packages/docs/api/@xmachines/play-router/classes/RouterBridgeBase.md)
|
|
247
|
+
|
|
248
|
+
Abstract base class capturing all common router bridge logic. Template Method pattern — subclasses implement exactly three abstract methods: `navigateRouter(path)`, `watchRouterChanges()`, `unwatchRouterChanges()`. Manages `isConnected`, `lastSyncedPath` (echo suppression), `isProcessingNavigation` (re-entrant guard redirect prevention), and `routeWatcher` lifecycle. Enforces one-bridge-per-actor via a module-level `WeakMap`.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
class MyRouterBridge extends RouterBridgeBase {
|
|
252
|
+
protected navigateRouter(path: string): void {
|
|
253
|
+
/* push URL */
|
|
254
|
+
}
|
|
255
|
+
protected watchRouterChanges(): void {
|
|
256
|
+
/* subscribe to router */
|
|
257
|
+
}
|
|
258
|
+
protected unwatchRouterChanges(): void {
|
|
259
|
+
/* unsubscribe */
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### [`RouteMap`](../packages/docs/api/@xmachines/play-router/classes/RouteMap.md) / [`createRouteMap`](../packages/docs/api/@xmachines/play-router/functions/createRouteMap.md)
|
|
265
|
+
|
|
266
|
+
Bidirectional `stateId ↔ URL path` lookup. [`createRouteMap(machine)`](../packages/docs/api/@xmachines/play-router/functions/createRouteMap.md) → [`RouteMap`](../packages/docs/api/@xmachines/play-router/classes/RouteMap.md). [`createRouteMapFromTree(routeTree)`](../packages/docs/api/@xmachines/play-router/functions/createRouteMapFromTree.md) takes the output of [`extractMachineRoutes(machine)`](../packages/docs/api/@xmachines/play-router/functions/extractMachineRoutes.md) directly. Internally uses `URLPattern` for parameterized route matching (e.g. `/profile/:userId`).
|
|
267
|
+
|
|
268
|
+
### [`PlayRouteEvent`](../packages/docs/api/@xmachines/play-router/interfaces/PlayRouteEvent.md)
|
|
269
|
+
|
|
270
|
+
Unified routing event sent by router adapters to the Actor.
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
interface PlayRouteEvent {
|
|
274
|
+
readonly type: "play.route";
|
|
275
|
+
readonly to: string; // e.g. "#home", "#profile"
|
|
276
|
+
readonly params?: Record<string, string>; // URL path params, e.g. { userId: "123" }
|
|
277
|
+
readonly query?: Record<string, string>; // Query string params
|
|
278
|
+
readonly match?: unknown; // URLPatternResult (optional, for debugging)
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### [`watchSignal(signal, callback)`](../packages/docs/api/@xmachines/play-signals/functions/watchSignal.md)
|
|
283
|
+
|
|
284
|
+
Subscribe to a single TC39 signal with microtask batching and memory-safe cleanup. Uses a one-shot `Signal.subtle.Watcher` lifecycle — re-arms after each notification. `disposed` flag guards post-cleanup callbacks; `needsEnqueue` deduplicates rapid synchronous signal changes. Returns a `() => void` cleanup function.
|
|
285
|
+
|
|
286
|
+
### [`formatPlayRouteTransitions(machineConfig)`](../packages/docs/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md)
|
|
287
|
+
|
|
288
|
+
Crawls machine state configs looking for states with `meta.route` and auto-generates `play.route` transition handlers at the root machine level. Each generated transition targets the matching state, guards on `event.to === "#stateId"`, and assigns `event.params` and `event.query` to context. Returns the same config type `T` — directly usable by `setup().createMachine()`.
|
|
289
|
+
|
|
290
|
+
## View Renderer Pattern
|
|
291
|
+
|
|
292
|
+
All five view renderer packages follow an identical structural pattern:
|
|
293
|
+
|
|
294
|
+
| Component | Role |
|
|
295
|
+
| ---------------- | -------------------------------------------------------------------------------------- |
|
|
296
|
+
| `ActorProvider` | Subscribes to `actor.currentView` signal; owns signal lifecycle; provides view context |
|
|
297
|
+
| `PlayUIProvider` | Convenience wrapper combining `ActorProvider` + framework's `JSONUIProvider` |
|
|
298
|
+
| `PlayRenderer` | Zero-prop leaf component; reads from context; delegates to `@json-render/*` `Renderer` |
|
|
299
|
+
| `useActor()` | Hook/composable for accessing the raw actor in consuming components |
|
|
300
|
+
|
|
301
|
+
**Framework-specific signal bridging:**
|
|
302
|
+
|
|
303
|
+
| Package | Signal → Render mechanism |
|
|
304
|
+
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
305
|
+
| [`@xmachines/play-react`](../packages/docs/api/@xmachines/play-react/README.md) | `useSignalEffect` → `useReducer` force-update |
|
|
306
|
+
| [`@xmachines/play-vue`](../packages/docs/api/@xmachines/play-vue/README.md) | Vue reactivity bridge via `watchEffect` equivalent |
|
|
307
|
+
| [`@xmachines/play-solid`](../packages/docs/api/@xmachines/play-solid/README.md) | SolidJS native reactive integration |
|
|
308
|
+
| [`@xmachines/play-svelte`](../packages/docs/api/@xmachines/play-svelte/README.md) | Svelte 5 runes (`$effect`) via `actor-context.svelte.ts` |
|
|
309
|
+
| [`@xmachines/play-dom`](../packages/docs/api/@xmachines/play-dom/README.md) | Manual DOM updates via [`createPlayUI`](../packages/docs/api/@xmachines/play-dom/functions/createPlayUI.md) / [`createRenderer`](../packages/docs/api/@xmachines/play-dom/functions/createRenderer.md) / [`PlayRenderer`](../packages/docs/api/@xmachines/play-dom/classes/PlayRenderer.md) |
|
|
310
|
+
|
|
311
|
+
Per-view component state is managed by `@xstate/store`: a fresh store atom is created per [`PlaySpec`](../packages/docs/api/@xmachines/play-actor/interfaces/PlaySpec.md) transition (uncontrolled mode), or an external `store` prop is passed via `ActorProvider`/`PlayUIProvider` (controlled mode).
|
|
312
|
+
|
|
313
|
+
## Router Adapter Pattern
|
|
314
|
+
|
|
315
|
+
All eight router adapter packages follow the Template Method pattern via [`RouterBridgeBase`](../packages/docs/api/@xmachines/play-router/classes/RouterBridgeBase.md). Each adapter implements exactly three abstract methods:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// How to tell the framework router to change URL
|
|
319
|
+
protected abstract navigateRouter(path: string): void;
|
|
320
|
+
|
|
321
|
+
// How to subscribe to router location change events
|
|
322
|
+
protected abstract watchRouterChanges(): void;
|
|
323
|
+
|
|
324
|
+
// How to unsubscribe from router location change events
|
|
325
|
+
protected abstract unwatchRouterChanges(): void;
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
| Package | Bridge class |
|
|
329
|
+
| --------------------------------------------------------------------------------------------------------------- | --------------------------- |
|
|
330
|
+
| [`@xmachines/play-tanstack-react-router`](../packages/docs/api/@xmachines/play-tanstack-react-router/README.md) | `TanStackReactRouterBridge` |
|
|
331
|
+
| [`@xmachines/play-react-router`](../packages/docs/api/@xmachines/play-react-router/README.md) | `ReactRouterBridge` |
|
|
332
|
+
| [`@xmachines/play-vue-router`](../packages/docs/api/@xmachines/play-vue-router/README.md) | `VueRouterBridge` |
|
|
333
|
+
| [`@xmachines/play-solid-router`](../packages/docs/api/@xmachines/play-solid-router/README.md) | `SolidRouterBridge` |
|
|
334
|
+
| [`@xmachines/play-tanstack-solid-router`](../packages/docs/api/@xmachines/play-tanstack-solid-router/README.md) | `TanStackSolidRouterBridge` |
|
|
335
|
+
| [`@xmachines/play-sveltekit-router`](../packages/docs/api/@xmachines/play-sveltekit-router/README.md) | `SvelteKitRouterBridge` |
|
|
336
|
+
| [`@xmachines/play-svelte-spa-router`](../packages/docs/api/@xmachines/play-svelte-spa-router/README.md) | `SvelteSpaRouterBridge` |
|
|
337
|
+
| [`@xmachines/play-dom-router`](../packages/docs/api/@xmachines/play-dom-router/README.md) | `DomRouterBridge` |
|
|
338
|
+
|
|
339
|
+
Each adapter also exports a framework-integrated provider component (e.g. `PlayRouterProvider`) and a `createRouteMapFrom*` factory appropriate for its router's route definition format.
|
|
340
|
+
|
|
341
|
+
## Directory Structure
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
packages/
|
|
345
|
+
├── shared/ # Zero-dependency shared configs (tsconfig, oxlint, oxfmt, vitest)
|
|
346
|
+
├── play/ # Layer 0: Core protocol: PlayEvent, PlayError, assertNonNullable
|
|
347
|
+
├── play-signals/ # Layer 0: TC39 Signal polyfill wrapper — all signal imports go here
|
|
348
|
+
│ └── src/ # Re-exports signal-polyfill; watchSignal utility
|
|
349
|
+
├── play-actor/ # Layer 1: AbstractActor base + Routable, Viewable, PlaySpec interfaces
|
|
350
|
+
│
|
|
351
|
+
├── play-xstate/ # Layer 2: Concrete XState v5 actor: definePlayer, PlayerActor
|
|
352
|
+
│ └── src/
|
|
353
|
+
│ ├── player-actor.ts # PlayerActor — concrete actor
|
|
354
|
+
│ ├── define-player.ts # definePlayer factory
|
|
355
|
+
│ ├── guards/ # composeGuards, composeGuardsOr, negateGuard, hasContext...
|
|
356
|
+
│ ├── routing/ # deriveRoute, buildRouteUrl, formatPlayRouteTransitions
|
|
357
|
+
│ └── signals/ # StateSignalManager (XState → TC39 Signal bridge)
|
|
358
|
+
│
|
|
359
|
+
├── play-router/ # Layer 2: Route extraction, bidirectional mapping, bridge base
|
|
360
|
+
│ └── src/
|
|
361
|
+
│ ├── router-bridge-base.ts # RouterBridgeBase (Template Method for all adapters)
|
|
362
|
+
│ ├── extract-routes.ts # extractMachineRoutes → RouteTree
|
|
363
|
+
│ ├── base-route-map.ts # RouteMap (bidirectional stateId ↔ path)
|
|
364
|
+
│ ├── create-route-map.ts # createRouteMap factory (URLPattern-based)
|
|
365
|
+
│ ├── router-sync.ts # buildPlayRouteEvent, extractRouteParams, sanitizePathname
|
|
366
|
+
│ └── types.ts # PlayRouteEvent, RouterBridge, RouteTree, WindowLike...
|
|
367
|
+
│
|
|
368
|
+
├── play-react/ # View renderer: React (ActorProvider, PlayRenderer)
|
|
369
|
+
├── play-vue/ # View renderer: Vue 3
|
|
370
|
+
├── play-solid/ # View renderer: SolidJS
|
|
371
|
+
├── play-svelte/ # View renderer: Svelte 5
|
|
372
|
+
├── play-dom/ # View renderer: Vanilla DOM
|
|
373
|
+
│
|
|
374
|
+
├── play-tanstack-react-router/ # Router adapter: TanStack Router (React)
|
|
375
|
+
├── play-tanstack-solid-router/ # Router adapter: TanStack Router (SolidJS)
|
|
376
|
+
├── play-react-router/ # Router adapter: React Router v7
|
|
377
|
+
├── play-vue-router/ # Router adapter: Vue Router 4/5
|
|
378
|
+
├── play-solid-router/ # Router adapter: SolidJS Router
|
|
379
|
+
├── play-svelte-spa-router/ # Router adapter: Svelte SPA Router
|
|
380
|
+
├── play-sveltekit-router/ # Router adapter: SvelteKit
|
|
381
|
+
├── play-dom-router/ # Router adapter: Vanilla DOM (History API)
|
|
382
|
+
│
|
|
383
|
+
└── docs/ # @xmachines/docs — API docs (auto-generated) + RFC specifications
|
|
384
|
+
└── rfc/ # Living RFC documents (play.md, streams.md, etc.)
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
Each package follows the same internal structure:
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
packages/<name>/
|
|
391
|
+
├── src/
|
|
392
|
+
│ ├── index.ts # Single public barrel — only file consumers import
|
|
393
|
+
│ └── *.ts / *.tsx # Implementation files (kebab-case)
|
|
394
|
+
├── test/ # Test files (*.spec.ts, *.test.ts)
|
|
395
|
+
├── dist/ # Build output (gitignored)
|
|
396
|
+
├── examples/ # Runnable demo apps (present in some packages)
|
|
397
|
+
├── package.json # "type": "module"; exports only via "./dist/index.js"
|
|
398
|
+
└── tsconfig.json # Extends @xmachines/shared/tsconfig; composite: true
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## TypeScript Build Graph
|
|
402
|
+
|
|
403
|
+
The monorepo uses **TypeScript composite project references** (`"composite": true` per package) for a correct, incremental, dependency-ordered build. The root `tsconfig.json` lists all packages in layer order — leaves first, dependents last. `tsc --build` at the root resolves the full dependency graph automatically.
|
|
404
|
+
|
|
405
|
+
```mermaid
|
|
406
|
+
flowchart LR
|
|
407
|
+
subgraph L0["Layer 0 — no internal deps"]
|
|
408
|
+
ps[play-signals]
|
|
409
|
+
p[play]
|
|
410
|
+
d[docs]
|
|
411
|
+
end
|
|
412
|
+
subgraph L1["Layer 1 — depends on L0"]
|
|
413
|
+
pa[play-actor]
|
|
414
|
+
end
|
|
415
|
+
subgraph L2["Layer 2 — depends on L0 + L1"]
|
|
416
|
+
pr[play-router]
|
|
417
|
+
pdr[play-dom-router]
|
|
418
|
+
psk[play-sveltekit-router]
|
|
419
|
+
px[play-xstate]
|
|
420
|
+
prea[play-react]
|
|
421
|
+
pv[play-vue]
|
|
422
|
+
pso[play-solid]
|
|
423
|
+
psv[play-svelte]
|
|
424
|
+
pdo[play-dom]
|
|
425
|
+
ptsr[play-tanstack-react-router]
|
|
426
|
+
pvr[play-vue-router]
|
|
427
|
+
psor[play-solid-router]
|
|
428
|
+
pssr[play-svelte-spa-router]
|
|
429
|
+
ptss[play-tanstack-solid-router]
|
|
430
|
+
end
|
|
431
|
+
subgraph L3["Layer 3 — examples / play-react-router"]
|
|
432
|
+
ex["play-react-router\nplay-*/examples/demo"]
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
L0 --> L1 --> L2 --> L3
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
With `declarationMap: true` in the base tsconfig (from `@xmachines/shared/tsconfig`), IDE "Go to Definition" jumps to TypeScript source files rather than compiled `.d.ts` files, and refactoring works correctly across package boundaries without requiring a build step.
|
|
439
|
+
|
|
440
|
+
**Dependency rules:**
|
|
441
|
+
|
|
442
|
+
| Layer | May import from | Must not import from |
|
|
443
|
+
| ----------------------------------------------- | --------------------------------------------------- | -------------------------------- |
|
|
444
|
+
| Protocol (`play`, `play-signals`, `play-actor`) | External libs only | Any other `@xmachines/*` package |
|
|
445
|
+
| Actor logic (`play-xstate`) | Protocol layer | View renderers, router adapters |
|
|
446
|
+
| Router infrastructure (`play-router`) | Protocol layer, `@statelyai/graph` | View renderers |
|
|
447
|
+
| Router adapters (`play-*-router`) | `play-router`, protocol layer, framework router lib | Other view renderers |
|
|
448
|
+
| View renderers (`play-*`) | Protocol layer, `@json-render/*` | Router adapters |
|
|
449
|
+
|
|
450
|
+
## Error Handling
|
|
451
|
+
|
|
452
|
+
All `@xmachines/*` errors extend [`PlayError`](../packages/docs/api/@xmachines/play/classes/PlayError.md) and carry two stable fields:
|
|
453
|
+
|
|
454
|
+
- `scope` — the class or module that threw (e.g. `"RouterBridgeBase"`)
|
|
455
|
+
- `code` — a stable machine-readable identifier (e.g. `"PLAY_ROUTER_SYNC_FAILED"`)
|
|
456
|
+
|
|
457
|
+
**Error hierarchy:**
|
|
458
|
+
|
|
459
|
+
```mermaid
|
|
460
|
+
flowchart TD
|
|
461
|
+
PE["PlayError\n@xmachines/play"]
|
|
462
|
+
PE --> NNE["NonNullableError\nPLAY_NON_NULLABLE"]
|
|
463
|
+
PE --> RSE["RouterSyncError\nPLAY_ROUTER_SYNC_FAILED"]
|
|
464
|
+
PE --> UPE["URLPatternUnavailableError\nPLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE"]
|
|
465
|
+
PE --> DBE["DuplicateBridgeError\nPLAY_ROUTER_DUPLICATE_BRIDGE"]
|
|
466
|
+
PE --> IEE["InvalidEventError\nPLAY_INVALID_EVENT"]
|
|
467
|
+
PE --> IME["InvalidMachineError\nPLAY_INVALID_MACHINE"]
|
|
468
|
+
PE --> MRP["MissingRouteParamError\nPLAY_ROUTE_PARAM_MISSING"]
|
|
469
|
+
PE --> MSI["MissingStateIdError\nPLAY_MISSING_STATE_ID"]
|
|
470
|
+
PE --> MQC["MissingQueryContextError\nPLAY_MISSING_QUERY_CONTEXT"]
|
|
471
|
+
PE --> IRE["InvalidRouteMetadataError\nPLAY_INVALID_ROUTE_METADATA"]
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
Package-specific errors are exported from `./errors` subpath imports:
|
|
475
|
+
|
|
476
|
+
```typescript
|
|
477
|
+
import { PlayError } from "@xmachines/play";
|
|
478
|
+
import { RouterSyncError } from "@xmachines/play-router/errors";
|
|
479
|
+
import { InvalidEventError } from "@xmachines/play-xstate/errors";
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
**Error behavior by case:**
|
|
483
|
+
|
|
484
|
+
| Error | Package | Behavior |
|
|
485
|
+
| ---------------------------- | ------------- | ----------------------------------------------------------------------------------------- |
|
|
486
|
+
| `MissingRouteParamError` | `play-xstate` | Transient — `currentRoute` returns `null`; does not throw |
|
|
487
|
+
| `MissingQueryContextError` | `play-xstate` | Structural programmer error — always re-throws |
|
|
488
|
+
| `RouterSyncError` | `play-router` | Wraps router sync failures |
|
|
489
|
+
| `DuplicateBridgeError` | `play-router` | Two bridges registered for the same actor |
|
|
490
|
+
| `URLPatternUnavailableError` | `play-router` | URLPattern API missing — load `urlpattern-polyfill` |
|
|
491
|
+
| View errors | `play-xstate` | Caught in `validateAndCacheView()`; forwarded to `onError` hook; last valid view retained |
|
|
492
|
+
|
|
493
|
+
## Application Bootstrap (React example)
|
|
494
|
+
|
|
495
|
+
```typescript
|
|
496
|
+
import { setup } from "xstate";
|
|
497
|
+
import { definePlayer, formatPlayRouteTransitions } from "@xmachines/play-xstate";
|
|
498
|
+
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
499
|
+
import { createRouteMapFromTree, PlayRouterProvider } from "@xmachines/play-tanstack-react-router";
|
|
500
|
+
import { PlayUIProvider, PlayRenderer, defineRegistry } from "@xmachines/play-react";
|
|
501
|
+
|
|
502
|
+
// 1. Define machine — meta.route declares virtual routes; meta.view declares UI specs
|
|
503
|
+
const machineConfig = formatPlayRouteTransitions({
|
|
504
|
+
id: "app",
|
|
505
|
+
initial: "home",
|
|
506
|
+
context: { params: {}, query: {} },
|
|
507
|
+
states: {
|
|
508
|
+
home: {
|
|
509
|
+
id: "home",
|
|
510
|
+
meta: {
|
|
511
|
+
route: "/",
|
|
512
|
+
view: { root: "home", elements: { home: { type: "HomePage", props: {}, children: [] } } }
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
profile: {
|
|
516
|
+
id: "profile",
|
|
517
|
+
meta: {
|
|
518
|
+
route: "/profile/:userId",
|
|
519
|
+
view: { root: "profile", elements: { profile: { type: "ProfilePage", props: { userId: undefined }, children: [] } } }
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
const machine = setup({}).createMachine(machineConfig);
|
|
526
|
+
|
|
527
|
+
// 2. Build route map from machine definition (done once at startup)
|
|
528
|
+
const routeTree = extractMachineRoutes(machine);
|
|
529
|
+
const routeMap = createRouteMapFromTree(routeTree);
|
|
530
|
+
|
|
531
|
+
// 3. Create player factory and start actor
|
|
532
|
+
const createPlayer = definePlayer({ machine });
|
|
533
|
+
const actor = createPlayer();
|
|
534
|
+
actor.start();
|
|
535
|
+
|
|
536
|
+
// 4. Define component registry for json-render
|
|
537
|
+
const registryResult = defineRegistry({ /* components */ });
|
|
538
|
+
|
|
539
|
+
// 5. Render — framework providers wire actor → router → view
|
|
540
|
+
function App() {
|
|
541
|
+
return (
|
|
542
|
+
<PlayRouterProvider actor={actor} router={router} routeMap={routeMap}>
|
|
543
|
+
<PlayUIProvider actor={actor} registryResult={registryResult}>
|
|
544
|
+
<PlayRenderer />
|
|
545
|
+
</PlayUIProvider>
|
|
546
|
+
</PlayRouterProvider>
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
## Anti-Patterns
|
|
552
|
+
|
|
553
|
+
### Importing `signal-polyfill` directly
|
|
554
|
+
|
|
555
|
+
```typescript
|
|
556
|
+
// ❌ Wrong — bypasses the TC39 Signal isolation layer
|
|
557
|
+
import { Signal } from "signal-polyfill";
|
|
558
|
+
|
|
559
|
+
// ✅ Correct — all signal imports go through play-signals
|
|
560
|
+
import { Signal } from "@xmachines/play-signals";
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### Using framework state for business logic
|
|
564
|
+
|
|
565
|
+
```typescript
|
|
566
|
+
// ❌ Wrong — violates INV-04 (Signal-Only Reactivity) and INV-02 (Passive Infrastructure)
|
|
567
|
+
const [currentUser, setCurrentUser] = useState(null);
|
|
568
|
+
|
|
569
|
+
// ✅ Correct — observe the actor signal directly
|
|
570
|
+
const currentUser = useActorSelector(actor, (s) => s.context.currentUser);
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Calling `navigateRouter` inside `watchRouterChanges`
|
|
574
|
+
|
|
575
|
+
Calling `navigateRouter()` before updating `lastSyncedPath` inside the `watchRouterChanges` callback causes an echo loop. The router navigation fires the watcher again, which sends a duplicate `play.route` event. Always update `lastSyncedPath` before calling `navigateRouter()` — see [`RouterBridgeBase`](../packages/docs/api/@xmachines/play-router/classes/RouterBridgeBase.md) source at `packages/play-router/src/router-bridge-base.ts`.
|
|
576
|
+
|
|
577
|
+
### Skipping `sanitizePathname` in custom bridge implementations
|
|
578
|
+
|
|
579
|
+
Custom `watchRouterChanges()` implementations that bypass `syncActorFromRouter()` and process pathnames directly skip the length/content guards that protect the route-map lookup from malformed or oversized paths. Always call [`sanitizePathname(path)`](../packages/docs/api/@xmachines/play-router/functions/sanitizePathname.md) before processing.
|
|
580
|
+
|
|
581
|
+
## Cross-Cutting Concerns
|
|
582
|
+
|
|
583
|
+
**Circular update prevention:** `lastSyncedPath` in [`RouterBridgeBase`](../packages/docs/api/@xmachines/play-router/classes/RouterBridgeBase.md) provides echo suppression for the actor→router direction; `isProcessingNavigation` flag guards against re-entrant guard-redirect loops in `syncActorFromRouter`. `needsEnqueue` in [`watchSignal`](../packages/docs/api/@xmachines/play-signals/functions/watchSignal.md) deduplicates rapid synchronous signal changes via microtask batching.
|
|
584
|
+
|
|
585
|
+
**SSR / test injection:** [`WindowLike`](../packages/docs/api/@xmachines/play-router/interfaces/WindowLike.md) and [`LocationLike`](../packages/docs/api/@xmachines/play-router/interfaces/LocationLike.md) structural interfaces in [`@xmachines/play-router`](../packages/docs/api/@xmachines/play-router/README.md) allow injecting mock objects in router adapters, enabling testing without a real browser environment.
|
|
586
|
+
|
|
587
|
+
**Logging:** No structured logging framework. [`PlayerOptions`](../packages/docs/api/@xmachines/play-xstate/interfaces/PlayerOptions.md) exposes lifecycle hooks — `onStart`, `onStop`, `onTransition`, `onStateChange`, `onError` — as observability extension points. No `console.*` calls in library source code.
|
|
588
|
+
|
|
589
|
+
**Authentication:** Not in scope. Enforced via XState guards on `play.route` transitions. The guard evaluates machine `context` (e.g., `isLoggedIn`) before permitting navigation. No library-level auth primitives — the machine defines all access control.
|
|
590
|
+
|
|
591
|
+
**TC39 Signal isolation:** All signal imports go through [`@xmachines/play-signals`](../packages/docs/api/@xmachines/play-signals/README.md), which re-exports the `signal-polyfill` reference implementation. This isolates the codebase from Stage-1 API churn — a polyfill version upgrade or API change requires editing only one package.
|
|
592
|
+
|
|
593
|
+
**Global state:** An `activeBridges` WeakMap at module level in `packages/play-router/src/router-bridge-base.ts` prevents duplicate bridges per actor. This is the only module-level mutable state in the library.
|
|
594
|
+
|
|
595
|
+
**Threading:** Single-threaded event loop. No worker threads. XState actor subscription callbacks fire synchronously in `send()`. Signal updates are synchronous to ensure router bridges see guard redirects immediately.
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
_See [Play RFC](../packages/docs/rfc/play.md) for the authoritative protocol specification._
|