@xmachines/docs 1.0.0-beta.51 → 1.0.0-beta.53
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 +303 -110
- 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
package/contributing/testing.md
CHANGED
|
@@ -2,38 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
# Testing
|
|
4
4
|
|
|
5
|
-
This document describes the test framework,
|
|
5
|
+
This document describes the test framework, conventions, and CI integration for the XMachines JS monorepo.
|
|
6
6
|
|
|
7
7
|
## Test Framework and Setup
|
|
8
8
|
|
|
9
|
-
**
|
|
9
|
+
The monorepo uses **[Vitest](https://vitest.dev/) `^4.1.5`** as its test framework, with **@vitest/coverage-v8** for coverage reporting and **@vitest/browser-playwright** (Playwright/Chromium) for browser-mode tests.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
All packages extend the shared Vitest configuration helper `defineXmVitestConfig` (from `@xmachines/shared/vitest`) which automatically applies:
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
// packages/<name>/vitest.config.ts
|
|
19
|
-
import { defineXmVitestConfig } from "@xmachines/shared/vitest";
|
|
20
|
-
|
|
21
|
-
export default defineXmVitestConfig(import.meta.url, {
|
|
22
|
-
test: {
|
|
23
|
-
environment: "node", // or "jsdom" for UI renderer packages
|
|
24
|
-
include: ["test/**/*.spec.ts", "test/**/*.test.ts"],
|
|
25
|
-
exclude: ["node_modules/**"],
|
|
26
|
-
coverage: {
|
|
27
|
-
provider: "v8",
|
|
28
|
-
reporter: ["text", "html", "json-summary"],
|
|
29
|
-
include: ["src/**/*.ts"],
|
|
30
|
-
exclude: ["test/**/*", "**/*.test.ts", "**/*.d.ts", "dist/**/*"],
|
|
31
|
-
all: true,
|
|
32
|
-
thresholds: { lines: 90, functions: 90, branches: 85, statements: 90 },
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
```
|
|
13
|
+
- `@xmachines/*` source aliases so imports resolve to source during test runs
|
|
14
|
+
- `@xmachines/shared/vitest-setup` — extends Vitest matchers with `@testing-library/jest-dom`
|
|
15
|
+
- `@xmachines/shared/vitest-node-setup` — enforces Node.js ≥ 22 on non-browser projects
|
|
37
16
|
|
|
38
17
|
**Auto-injected setup files:**
|
|
39
18
|
|
|
@@ -42,23 +21,21 @@ export default defineXmVitestConfig(import.meta.url, {
|
|
|
42
21
|
| `packages/shared/config/vitest.node.setup.ts` | All non-browser projects | Validates Node.js ≥ 22 runtime; throws if wrong runtime |
|
|
43
22
|
| `packages/shared/config/vitest.setup.ts` | All projects | Imports `@testing-library/jest-dom/vitest` matchers |
|
|
44
23
|
|
|
45
|
-
|
|
24
|
+
Before running any tests, ensure all dependencies are installed:
|
|
46
25
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
| `jsdom` | UI renderers: [`@xmachines/play-react`](../api/@xmachines/play-react/README.md), `play-vue`, `play-solid`, `play-svelte`, `play-dom` |
|
|
51
|
-
| Browser (Playwright/Chromium) | Browser-specific and E2E demo tests |
|
|
26
|
+
```bash
|
|
27
|
+
npm ci
|
|
28
|
+
```
|
|
52
29
|
|
|
53
30
|
## Running Tests
|
|
54
31
|
|
|
55
|
-
###
|
|
32
|
+
### Full test suite (Node environments)
|
|
56
33
|
|
|
57
34
|
```bash
|
|
58
35
|
npm test
|
|
59
36
|
```
|
|
60
37
|
|
|
61
|
-
Runs `vitest run` across all 30
|
|
38
|
+
Runs `vitest run` across all 30 package-level projects defined in the root `vitest.config.ts`. Uses the `forks` pool (up to 4 workers) with process-level isolation between test files.
|
|
62
39
|
|
|
63
40
|
### Watch mode (development)
|
|
64
41
|
|
|
@@ -66,39 +43,48 @@ Runs `vitest run` across all 30+ package-level projects defined in `vitest.confi
|
|
|
66
43
|
npm run test:watch
|
|
67
44
|
```
|
|
68
45
|
|
|
69
|
-
Runs `vitest` in interactive watch mode. Re-runs affected
|
|
46
|
+
Runs `vitest` in interactive watch mode. Re-runs affected tests on file change.
|
|
70
47
|
|
|
71
|
-
### Browser tests (Playwright/Chromium)
|
|
48
|
+
### Browser tests (Playwright / Chromium)
|
|
72
49
|
|
|
73
50
|
```bash
|
|
74
51
|
npm run test:browser
|
|
75
52
|
```
|
|
76
53
|
|
|
77
|
-
Runs `vitest run --config vitest.browser.config.ts`.
|
|
54
|
+
Runs `vitest run --config vitest.browser.config.ts`. Launches all browser-mode projects using headless Chromium via Playwright. Includes both package-level browser unit tests and full demo-app integration flows. The browser global setup (`vitest.browser.global-setup.ts`) raises `process.setMaxListeners` to 32 before workers spawn to prevent false-positive `MaxListenersExceededWarning` with multiple parallel browser projects.
|
|
78
55
|
|
|
79
|
-
###
|
|
56
|
+
### With coverage
|
|
80
57
|
|
|
81
58
|
```bash
|
|
82
|
-
npm run test:coverage
|
|
83
|
-
npm run coverage:report # HTML coverage report
|
|
84
|
-
npm run coverage:summary # JSON summary for CI
|
|
59
|
+
npm run test:coverage
|
|
85
60
|
```
|
|
86
61
|
|
|
87
|
-
|
|
62
|
+
Produces coverage output in `text`, `html`, and `json-summary` formats.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm run coverage:report # HTML report
|
|
66
|
+
npm run coverage:summary # JSON summary only
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Verify TypeScript test graph compiles
|
|
88
70
|
|
|
89
71
|
```bash
|
|
90
72
|
npm run test:build
|
|
91
73
|
```
|
|
92
74
|
|
|
93
|
-
Runs `tsc --build tsconfig.test.json
|
|
75
|
+
Runs `tsc --build tsconfig.test.json`. This validates that all test TypeScript files across the monorepo type-check correctly without running the tests themselves. Also compiles `.typecheck.ts` files in `src/` directories.
|
|
76
|
+
|
|
77
|
+
### Running tests for a single package
|
|
94
78
|
|
|
95
|
-
|
|
79
|
+
From the monorepo root:
|
|
96
80
|
|
|
97
81
|
```bash
|
|
98
|
-
npm test -w packages/play
|
|
82
|
+
npm test -w packages/play
|
|
99
83
|
npm run test:coverage -w packages/play-react
|
|
100
84
|
```
|
|
101
85
|
|
|
86
|
+
Or from within a package directory, run `npx vitest run` directly after building the workspace.
|
|
87
|
+
|
|
102
88
|
## Test File Organization
|
|
103
89
|
|
|
104
90
|
Tests live in a separate `test/` directory within each package — never co-located with source files.
|
|
@@ -117,7 +103,7 @@ packages/<name>/
|
|
|
117
103
|
└── tsconfig.json # Test-specific tsconfig (extends shared/tsconfig-test)
|
|
118
104
|
```
|
|
119
105
|
|
|
120
|
-
|
|
106
|
+
### File naming conventions
|
|
121
107
|
|
|
122
108
|
| Extension | Purpose |
|
|
123
109
|
| ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -127,13 +113,46 @@ packages/<name>/
|
|
|
127
113
|
| `.typecheck.ts` (in `src/`) | Compile-time-only type assertion files; not Vitest test files; validated by `npm run test:build` |
|
|
128
114
|
| `router-bridge-contract.ts` | Shared contract test runner; not a test file itself; imported by adapter test files |
|
|
129
115
|
|
|
116
|
+
### Test environments
|
|
117
|
+
|
|
118
|
+
| Environment | Packages |
|
|
119
|
+
| ----------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
120
|
+
| `node` | Core logic: `@xmachines/play`, `play-actor`, `play-signals`, `play-xstate`, `play-router`, router adapters |
|
|
121
|
+
| `jsdom` | UI renderers: `@xmachines/play-react`, `play-vue`, `play-solid`, `play-svelte`, `play-dom` |
|
|
122
|
+
| Browser (Playwright/Chromium) | Browser-specific and E2E demo tests |
|
|
123
|
+
|
|
124
|
+
### Test helpers and shared setup
|
|
125
|
+
|
|
126
|
+
- **`@xmachines/shared/vitest-setup`** — Injects `@testing-library/jest-dom` matchers. Applied automatically by `defineXmVitestConfig`.
|
|
127
|
+
- **`@xmachines/shared/vitest-node-setup`** — Enforces Node ≥ 22 at runtime. Auto-injected for non-browser configs.
|
|
128
|
+
- **`@xmachines/shared/vitest-urlpattern-setup`** — Polyfills `URLPattern` for packages that need it (e.g. `@xmachines/play-router`). Must be declared explicitly in `setupFiles`.
|
|
129
|
+
- **`packages/play-react/test/test-utils.ts`** — React-specific test utilities for the `play-react` package.
|
|
130
|
+
- **`packages/play-router/examples/shared/`** and **`packages/play-actor/examples/shared/`** — Shared test fixtures for router and actor integration tests.
|
|
131
|
+
|
|
130
132
|
## Writing New Tests
|
|
131
133
|
|
|
132
|
-
###
|
|
134
|
+
### Adding a new package test config
|
|
135
|
+
|
|
136
|
+
1. Place test files under `packages/<pkg>/test/`.
|
|
137
|
+
2. Name them following the convention above.
|
|
138
|
+
3. Import `defineXmVitestConfig` in the package's `vitest.config.ts`:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { defineXmVitestConfig } from "@xmachines/shared/vitest";
|
|
142
|
+
|
|
143
|
+
export default defineXmVitestConfig(import.meta.url, {
|
|
144
|
+
test: {
|
|
145
|
+
environment: "node",
|
|
146
|
+
include: ["test/**/*.test.ts"],
|
|
147
|
+
exclude: ["node_modules/**"],
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
133
151
|
|
|
134
|
-
|
|
152
|
+
4. Register the new config in the root `vitest.config.ts` `projects` array.
|
|
153
|
+
5. Add the package's `tsconfig.test.json` to `tsconfig.test.json` references in the root.
|
|
135
154
|
|
|
136
|
-
|
|
155
|
+
### Basic test structure
|
|
137
156
|
|
|
138
157
|
```typescript
|
|
139
158
|
import { describe, it, test, expect, vi, beforeEach, afterEach } from "vitest";
|
|
@@ -161,12 +180,6 @@ import { AbstractActor } from "../src/abstract-actor.js";
|
|
|
161
180
|
import { Signal } from "@xmachines/play-signals";
|
|
162
181
|
```
|
|
163
182
|
|
|
164
|
-
**`it` vs `test`:** Both are interchangeable. Some files alias one to the other for consistency within a file:
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
import { it as test } from "vitest";
|
|
168
|
-
```
|
|
169
|
-
|
|
170
183
|
### Lifecycle hooks
|
|
171
184
|
|
|
172
185
|
```typescript
|
|
@@ -180,57 +193,43 @@ afterEach(() => {
|
|
|
180
193
|
});
|
|
181
194
|
```
|
|
182
195
|
|
|
183
|
-
###
|
|
196
|
+
### What to mock / what not to mock
|
|
184
197
|
|
|
185
|
-
**
|
|
198
|
+
**Mock these:**
|
|
186
199
|
|
|
187
|
-
|
|
188
|
-
const mocks = vi.hoisted(() => ({
|
|
189
|
-
machineToGraph: vi.fn(),
|
|
190
|
-
buildRouteTree: vi.fn(),
|
|
191
|
-
}));
|
|
192
|
-
|
|
193
|
-
vi.mock("../src/machine-to-graph.js", () => ({
|
|
194
|
-
machineToGraph: mocks.machineToGraph,
|
|
195
|
-
}));
|
|
196
|
-
```
|
|
200
|
+
- **Framework router objects** (TanStack Router, Vue Router, React Router, SolidJS Router) — mock with typed `vi.fn()` interfaces because they are external framework dependencies and carry significant setup complexity:
|
|
197
201
|
|
|
198
|
-
|
|
202
|
+
```typescript
|
|
203
|
+
const mocks = vi.hoisted(() => ({
|
|
204
|
+
machineToGraph: vi.fn(),
|
|
205
|
+
buildRouteTree: vi.fn(),
|
|
206
|
+
}));
|
|
199
207
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
205
|
-
const mockReturnValue = vi.fn().mockReturnValue(stubValue);
|
|
206
|
-
const asyncMock = vi.fn().mockResolvedValue(undefined);
|
|
207
|
-
const failingMock = vi.fn().mockRejectedValue(new Error("fail"));
|
|
208
|
-
```
|
|
208
|
+
vi.mock("../src/machine-to-graph.js", () => ({
|
|
209
|
+
machineToGraph: mocks.machineToGraph,
|
|
210
|
+
}));
|
|
211
|
+
```
|
|
209
212
|
|
|
210
|
-
|
|
213
|
+
- **`console.warn` / `console.error`** when testing code that legitimately emits warnings — mock to suppress noise and assert call counts:
|
|
211
214
|
|
|
212
|
-
```typescript
|
|
213
|
-
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
214
|
-
// ... test ...
|
|
215
|
-
expect(warnSpy).toHaveBeenCalled();
|
|
216
|
-
vi.restoreAllMocks(); // in afterEach
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
**What to mock:**
|
|
215
|
+
```typescript
|
|
216
|
+
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
217
|
+
// ... test ...
|
|
218
|
+
expect(warnSpy).toHaveBeenCalled();
|
|
219
|
+
vi.restoreAllMocks(); // in afterEach
|
|
220
|
+
```
|
|
220
221
|
|
|
221
|
-
-
|
|
222
|
-
- `console.warn` / `console.error` when testing code that legitimately logs warnings
|
|
223
|
-
- External module collaborators when testing a unit in isolation
|
|
222
|
+
- **External module collaborators** when testing a unit in isolation.
|
|
224
223
|
|
|
225
|
-
**
|
|
224
|
+
**Never mock these:**
|
|
226
225
|
|
|
227
|
-
- Signals (`Signal.State`, `Signal.Computed`, `Signal.subtle.Watcher`) — use real implementations
|
|
228
|
-
- Internal `@xmachines/*` packages — resolved to source via
|
|
229
|
-
- XState — use real `setup()` / `createMachine()` / `createActor()
|
|
226
|
+
- **TC39 Signals** (`Signal.State`, `Signal.Computed`, `Signal.subtle.Watcher`) — always use real implementations from `@xmachines/play-signals`. Signals have precise reactive semantics (synchronous propagation, lazy computation) that mocks cannot replicate accurately.
|
|
227
|
+
- **Internal `@xmachines/*` packages** — these are resolved directly to source via the `xmAliases` Vite plugin in the Vitest config. Mocking them would hide integration bugs and defeat the purpose of cross-package testing.
|
|
228
|
+
- **XState** — always use real `setup()` / `createMachine()` / `createActor()`. XState's actor lifecycle (start, stop, snapshot, subscription) is a behavioral contract that mocks cannot reliably emulate.
|
|
230
229
|
|
|
231
230
|
### Test actor patterns
|
|
232
231
|
|
|
233
|
-
**Preferred: extend
|
|
232
|
+
**Preferred: extend `AbstractActor` for full type safety:**
|
|
234
233
|
|
|
235
234
|
```typescript
|
|
236
235
|
import { AbstractActor } from "@xmachines/play-actor";
|
|
@@ -274,34 +273,6 @@ function createMockActor(initialView: PlaySpec | null = null) {
|
|
|
274
273
|
}
|
|
275
274
|
```
|
|
276
275
|
|
|
277
|
-
### Compile-time type tests
|
|
278
|
-
|
|
279
|
-
For type-only assertions, use `@ts-expect-error` in `.spec.ts` files:
|
|
280
|
-
|
|
281
|
-
```typescript
|
|
282
|
-
const bad: PlaySpec = typedSpec<MyCtx>({
|
|
283
|
-
root: "root",
|
|
284
|
-
// @ts-expect-error "typo" is not a key of MyCtx — typedSpec enforces this
|
|
285
|
-
contextProps: ["typo"],
|
|
286
|
-
elements: {},
|
|
287
|
-
});
|
|
288
|
-
// At runtime the object exists; only the compile-time error is being tested
|
|
289
|
-
expect(bad.contextProps).toEqual(["typo"]);
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
For purely structural type assertions with no runtime test needed, use `.typecheck.ts` files in `src/`:
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
// packages/play-xstate/src/define-player.typecheck.ts
|
|
296
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
297
|
-
type AssertFalse<T extends false> = T;
|
|
298
|
-
|
|
299
|
-
const actorNotAny: AssertFalse<IsAny<typeof actor>> = false;
|
|
300
|
-
void actorNotAny;
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
These files are validated by `npm run test:build` (`tsc --build tsconfig.test.json`) — never executed by Vitest.
|
|
304
|
-
|
|
305
276
|
### Async and signal patterns
|
|
306
277
|
|
|
307
278
|
**Flushing the microtask queue (required for Signal propagation):**
|
|
@@ -333,7 +304,35 @@ expect(notified).toBe(true);
|
|
|
333
304
|
watcher.unwatch(actor.currentRoute); // Always clean up
|
|
334
305
|
```
|
|
335
306
|
|
|
336
|
-
|
|
307
|
+
### Compile-time type tests
|
|
308
|
+
|
|
309
|
+
For type-only assertions, use `@ts-expect-error` in `.spec.ts` files:
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
const bad: PlaySpec = typedSpec<MyCtx>({
|
|
313
|
+
root: "root",
|
|
314
|
+
// @ts-expect-error "typo" is not a key of MyCtx — typedSpec enforces this
|
|
315
|
+
contextProps: ["typo"],
|
|
316
|
+
elements: {},
|
|
317
|
+
});
|
|
318
|
+
// At runtime the object exists; only the compile-time error is being tested
|
|
319
|
+
expect(bad.contextProps).toEqual(["typo"]);
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
For purely structural type assertions with no runtime test needed, use `.typecheck.ts` files in `src/`:
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
// packages/play-xstate/src/define-player.typecheck.ts
|
|
326
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
327
|
+
type AssertFalse<T extends false> = T;
|
|
328
|
+
|
|
329
|
+
const actorNotAny: AssertFalse<IsAny<typeof actor>> = false;
|
|
330
|
+
void actorNotAny;
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
These files are validated by `npm run test:build` (`tsc --build tsconfig.test.json`) — never executed by Vitest.
|
|
334
|
+
|
|
335
|
+
### Error testing
|
|
337
336
|
|
|
338
337
|
```typescript
|
|
339
338
|
// Synchronous throws
|
|
@@ -352,34 +351,9 @@ try {
|
|
|
352
351
|
}
|
|
353
352
|
```
|
|
354
353
|
|
|
355
|
-
**Testing-library pattern (React/Vue/Solid/Svelte):**
|
|
356
|
-
|
|
357
|
-
```typescript
|
|
358
|
-
// React
|
|
359
|
-
const { getByTestId } = render(withRenderer({ actor, registryResult }));
|
|
360
|
-
expect(getByTestId("fallback")).toBeTruthy();
|
|
361
|
-
await waitFor(() => expect(screen.getByRole("heading")).toBeInTheDocument());
|
|
362
|
-
|
|
363
|
-
// Vue
|
|
364
|
-
const wrapper = mount(ActorProvider, { props: { actor, registryResult }, slots: { ... } });
|
|
365
|
-
await flushPromises();
|
|
366
|
-
expect(wrapper.find("[data-testid='message']").text()).toBe("Hello");
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
**Performance/timing assertions:**
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
const start = performance.now();
|
|
373
|
-
for (let i = 0; i < iterations; i++) {
|
|
374
|
-
actor.send({ type: "play.route", to: `#route${i}` });
|
|
375
|
-
}
|
|
376
|
-
const duration = performance.now() - start;
|
|
377
|
-
expect(duration / iterations).toBeLessThan(2.5); // ms per operation
|
|
378
|
-
```
|
|
379
|
-
|
|
380
354
|
## Contract Tests
|
|
381
355
|
|
|
382
|
-
The
|
|
356
|
+
The `@xmachines/play-router` package exports a shared behavioral contract suite that all router bridge adapters must satisfy:
|
|
383
357
|
|
|
384
358
|
```typescript
|
|
385
359
|
// packages/play-router/test/router-bridge-contract.ts
|
|
@@ -401,7 +375,7 @@ runBridgeContractTests({
|
|
|
401
375
|
|
|
402
376
|
The contract covers: deep-link sync on connect, router→actor navigation sync, actor→router sync, guard redirect flows, duplicate event deduplication, and restore-from-snapshot behavior.
|
|
403
377
|
|
|
404
|
-
**Used by:**
|
|
378
|
+
**Used by:** `@xmachines/play-router`, `play-tanstack-react-router`, `play-vue-router`, `play-solid-router`, `play-react-router`, and other adapter packages.
|
|
405
379
|
|
|
406
380
|
**Compile-time bridge contract verification:**
|
|
407
381
|
|
|
@@ -414,38 +388,57 @@ assertImplementsRouterBridge<MyRouterBridge>(); // Zero runtime cost
|
|
|
414
388
|
|
|
415
389
|
## Coverage Requirements
|
|
416
390
|
|
|
417
|
-
**
|
|
391
|
+
Coverage is collected using the **v8** provider. The root `vitest.config.ts` defines monorepo-wide regression thresholds:
|
|
418
392
|
|
|
419
|
-
|
|
393
|
+
| Type | Monorepo threshold |
|
|
394
|
+
| ---------- | ------------------ |
|
|
395
|
+
| Lines | 80% |
|
|
396
|
+
| Functions | 80% |
|
|
397
|
+
| Branches | 75% |
|
|
398
|
+
| Statements | 80% |
|
|
420
399
|
|
|
421
|
-
|
|
400
|
+
Individual packages enforce their own (typically stricter) thresholds inside their `vitest.config.ts`:
|
|
422
401
|
|
|
423
|
-
|
|
|
424
|
-
|
|
|
425
|
-
|
|
|
426
|
-
|
|
|
427
|
-
|
|
|
428
|
-
| Statements | 80% |
|
|
402
|
+
| Package tier | Lines | Functions | Branches | Statements |
|
|
403
|
+
| -------------------------------------------------------------------------- | ----- | --------- | -------- | ---------- |
|
|
404
|
+
| Core packages (`@xmachines/play`, `@xmachines/play-actor`) | 90% | 90% | 85% | 90% |
|
|
405
|
+
| Complex logic (`@xmachines/play-xstate`, `@xmachines/play-router`) | 85% | 85% | 80% | 85% |
|
|
406
|
+
| Integration packages (e.g. `@xmachines/play-react`, `@xmachines/play-dom`) | 80% | 80% | 80% | 80% |
|
|
429
407
|
|
|
430
|
-
|
|
408
|
+
Coverage includes: `src/**/*.ts`, `src/**/*.tsx`, `src/**/*.vue`, `src/**/*.svelte`
|
|
431
409
|
|
|
432
|
-
|
|
433
|
-
| ------------------------------------------------------------------------------------------------------------------ | ----- | --------- | -------- | ---------- |
|
|
434
|
-
| Core packages ([`@xmachines/play`](../api/@xmachines/play/README.md), `play-actor`) | 90% | 90% | 85% | 90% |
|
|
435
|
-
| Complex logic ([`@xmachines/play-xstate`](../api/@xmachines/play-xstate/README.md), `play-router`) | 85% | 85% | 80% | 85% |
|
|
436
|
-
| Integration/adapter packages ([`@xmachines/play-react`](../api/@xmachines/play-react/README.md), `play-vue`, etc.) | 80% | 80% | 80% | 80% |
|
|
410
|
+
Coverage is excluded for: `test/**/*`, `**/*.test.ts`, `**/*.test.tsx`, `**/*.d.ts`, `dist/**/*`.
|
|
437
411
|
|
|
438
|
-
|
|
412
|
+
## CI Integration
|
|
439
413
|
|
|
440
|
-
|
|
414
|
+
Tests run in GitLab CI using the `to-be-continuous/node` pipeline component (version `5.1.2`).
|
|
441
415
|
|
|
442
|
-
|
|
416
|
+
**Workflow:** The pipeline runs on:
|
|
417
|
+
|
|
418
|
+
- Tag pushes (`$CI_COMMIT_TAG`)
|
|
419
|
+
- Pushes to the default branch (`$CI_DEFAULT_BRANCH`)
|
|
420
|
+
- Merge requests (`$CI_MERGE_REQUEST_IID`)
|
|
421
|
+
|
|
422
|
+
**CI test command** (from `.gitlab-ci.yml`):
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
npm run test:coverage -- \
|
|
426
|
+
--coverage.reporter=text \
|
|
427
|
+
--coverage.reporter=cobertura \
|
|
428
|
+
--coverage.reportsDirectory=reports/coverage \
|
|
429
|
+
--reporter=default \
|
|
430
|
+
--reporter=junit \
|
|
431
|
+
--outputFile.junit=reports/junit.xml
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Artifacts:** The CI job (`node-build`) publishes:
|
|
443
435
|
|
|
444
|
-
|
|
436
|
+
- JUnit XML report at `reports/junit.xml` (surfaced in GitLab's test results panel)
|
|
437
|
+
- Cobertura coverage XML at `reports/coverage/cobertura-coverage.xml` (used for GitLab's coverage percentage badge — extracted from the `All files` line)
|
|
445
438
|
|
|
446
|
-
|
|
439
|
+
Coverage and test results are always uploaded (`when: always`) so failures are visible even when the job itself fails.
|
|
447
440
|
|
|
448
|
-
|
|
441
|
+
The `npm run format:check` and `npm run lint` commands enforce code style and are run separately from tests (via the `lint-enabled: true` input to the pipeline component).
|
|
449
442
|
|
|
450
443
|
## Test Types Reference
|
|
451
444
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
[Examples](../../README.md) / @xmachines/play-dom-demo
|
|
2
2
|
|
|
3
|
+
<!-- generated-by: gsd-doc-writer -->
|
|
4
|
+
|
|
3
5
|
# @xmachines/play-dom-demo
|
|
4
6
|
|
|
5
|
-
Vanilla DOM renderer demo for [`@xmachines/play-dom`](../../../api/@xmachines/play-dom/README.md) — actor + `
|
|
7
|
+
Vanilla DOM renderer demo for [`@xmachines/play-dom`](../../../api/@xmachines/play-dom/README.md) — actor + `createPlayUI` without a router.
|
|
6
8
|
|
|
7
9
|
## What This Demonstrates
|
|
8
10
|
|
|
9
11
|
- Shared auth machine reused without framework-specific business logic
|
|
10
|
-
- `
|
|
12
|
+
- `createPlayUI` wiring `PlayRenderer`-equivalent DOM rendering without a framework
|
|
11
13
|
- Auth machine states (home → login → dashboard) drive DOM updates via TC39 Signal watchers
|
|
12
14
|
- `watchSignal` for reactive nav visibility and debug panel updates
|
|
13
15
|
- Non-browser invariant tests plus browser renderer coverage
|
|
@@ -28,23 +30,27 @@ Then open `http://localhost:5173`.
|
|
|
28
30
|
Use this order to understand the implementation:
|
|
29
31
|
|
|
30
32
|
1. `src/main.ts` calls `definePlayer({ machine: authMachine })` and starts the actor.
|
|
31
|
-
2. `initShell(actor, app)` from `src/
|
|
33
|
+
2. `initShell(actor, app)` from `src/components/Shell.ts` builds the HTML scaffold, mounts a reactive `NavBar`, wires the debug panel, and returns a disconnect function.
|
|
32
34
|
3. `defineRegistry(authCatalog, { components, actions })` builds the typed `registryResult` — real async action handlers dispatching to `actor.send()`.
|
|
33
|
-
4. `
|
|
34
|
-
5. `
|
|
35
|
-
6.
|
|
35
|
+
4. `createPlayUI(registryResult)` produces a `mount` function; `mount(actor, container)` wires the registry to the actor — view switches happen automatically when `actor.currentView` changes.
|
|
36
|
+
5. `createNavBar(actor, headerEl)` in `src/components/NavBar.ts` uses `watchSignal(actor.state, ...)` to update nav button visibility based on auth state.
|
|
37
|
+
6. `createDebugPanel(actor, shell)` in `src/components/DebugPanel.ts` uses `watchSignal(actor.state, ...)` and `watchSignal(actor.currentRoute, ...)` to drive live debug panel updates.
|
|
38
|
+
7. Browser tests in `test/browser/` validate startup rendering and auth interactions.
|
|
36
39
|
|
|
37
40
|
```ts
|
|
38
41
|
// src/main.ts (shape)
|
|
39
|
-
const
|
|
42
|
+
const createPlayer = definePlayer({ machine: authMachine });
|
|
43
|
+
const actor = createPlayer();
|
|
40
44
|
actor.start();
|
|
41
45
|
|
|
42
46
|
const app = document.getElementById("app");
|
|
43
|
-
if (app)
|
|
47
|
+
if (!app) throw new Error("Root element not found");
|
|
48
|
+
|
|
49
|
+
initShell(actor, app);
|
|
44
50
|
```
|
|
45
51
|
|
|
46
52
|
```ts
|
|
47
|
-
// src/
|
|
53
|
+
// src/components/Shell.ts (shape)
|
|
48
54
|
const registryResult = defineRegistry(authCatalog, {
|
|
49
55
|
components: {
|
|
50
56
|
Home,
|
|
@@ -77,21 +83,24 @@ const registryResult = defineRegistry(authCatalog, {
|
|
|
77
83
|
},
|
|
78
84
|
});
|
|
79
85
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
registryResult,
|
|
85
|
-
});
|
|
86
|
+
const disconnectNavBar = createNavBar(actor, headerEl);
|
|
87
|
+
const mount = createPlayUI(registryResult);
|
|
88
|
+
const disconnectRenderer = mount(actor, viewContent);
|
|
89
|
+
const disconnectDebugPanel = createDebugPanel(actor, shell);
|
|
86
90
|
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
return () => {
|
|
92
|
+
disconnectNavBar();
|
|
93
|
+
disconnectRenderer();
|
|
94
|
+
disconnectDebugPanel();
|
|
95
|
+
};
|
|
89
96
|
```
|
|
90
97
|
|
|
91
98
|
## Key Files
|
|
92
99
|
|
|
93
100
|
- `src/main.ts` - actor creation and shell bootstrap
|
|
94
|
-
- `src/
|
|
101
|
+
- `src/components/Shell.ts` - DOM scaffold, `DomRegistry` construction, `createPlayUI` wiring, `createNavBar`, and `createDebugPanel`
|
|
102
|
+
- `src/components/NavBar.ts` - reactive nav bar using `watchSignal(actor.state, ...)` for auth-driven button visibility
|
|
103
|
+
- `src/components/DebugPanel.ts` - live debug footer using `watchSignal` on both `actor.state` and `actor.currentRoute`
|
|
95
104
|
- `test/library-pattern.test.ts` - architecture boundary and invariant assertions
|
|
96
105
|
- `test/browser/renderer-demo.browser.test.ts` - browser-mode renderer coverage
|
|
97
106
|
|
|
@@ -100,7 +109,7 @@ const unwatchRoute = watchSignal(actor.currentRoute, () => updateDebugPanel(acto
|
|
|
100
109
|
The demo utilizes XMachines architectural invariants:
|
|
101
110
|
|
|
102
111
|
1. **Actor Authority:** Navigation buttons dispatch `play.route` events to the actor. The actor evaluates guards and transitions to the correct state — the DOM never decides which view to show.
|
|
103
|
-
2. **Passive Infrastructure:** `
|
|
112
|
+
2. **Passive Infrastructure:** `createPlayUI` and `watchSignal` only react to actor signals. They do not hold business state or make routing decisions.
|
|
104
113
|
3. **Signal-Only Reactivity:** `watchSignal` (from [`@xmachines/play-signals`](../../../api/@xmachines/play-signals/README.md)) wraps the canonical TC39 Signals watcher lifecycle, keeping all reactivity in the actor signal layer rather than in ad-hoc DOM event listeners.
|
|
105
114
|
|
|
106
115
|
## Watcher Lifecycle and Cleanup Contract
|
|
@@ -113,11 +122,11 @@ This demo follows the canonical watcher lifecycle:
|
|
|
113
122
|
4. Read actor signals and project DOM state
|
|
114
123
|
5. Re-arm with `watch()`/`watch(...signals)`
|
|
115
124
|
|
|
116
|
-
Watcher notifications are one-shot. Cleanup is explicit:
|
|
125
|
+
Watcher notifications are one-shot. Cleanup is explicit: `disconnectNavBar()`, `disconnectRenderer()`, and `disconnectDebugPanel()` are all called from the disconnect function returned by `initShell`. In this demo, cleanup is called on `beforeunload` via `actor.stop()`.
|
|
117
126
|
|
|
118
127
|
## Adapter Boundaries
|
|
119
128
|
|
|
120
|
-
`
|
|
129
|
+
`createPlayUI` (from [`@xmachines/play-dom`](../../../api/@xmachines/play-dom/README.md)) is passive infrastructure. It translates actor view signals into DOM mutations but holds no business logic. The `DomRegistry` maps catalog component keys to factory functions — the actor owns which key is active.
|
|
121
130
|
|
|
122
131
|
## Available Scripts
|
|
123
132
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
function createNavBar(actor, container): () => void;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-dom/examples/demo/src/components/NavBar.ts:9](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [play-dom/examples/demo/src/components/NavBar.ts:9](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.53/packages/play-dom/examples/demo/src/components/NavBar.ts#L9)
|
|
10
10
|
|
|
11
11
|
NavBar — App-shell navigation factory. Mounts a reactive nav into
|
|
12
12
|
`container`, observes actor.state via watchSignal, and updates button
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
function initShell(actor, appElement): () => void;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-dom/examples/demo/src/components/Shell.ts:24](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [play-dom/examples/demo/src/components/Shell.ts:24](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.53/packages/play-dom/examples/demo/src/components/Shell.ts#L24)
|
|
10
10
|
|
|
11
11
|
Shell — DOM shell layout factory. Renders demo chrome (header + main +
|
|
12
12
|
debug panel), mounts NavBar, connects DOM renderer, and wires DebugPanel.
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
type AuthCatalog = typeof authCatalog;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-dom/examples/demo/src/catalog.ts:6](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [play-dom/examples/demo/src/catalog.ts:6](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.53/packages/play-dom/examples/demo/src/catalog.ts#L6)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const About: ComponentFn<AuthCatalog, "About">;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-dom/examples/demo/src/components/About.ts:8](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [play-dom/examples/demo/src/components/About.ts:8](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.53/packages/play-dom/examples/demo/src/components/About.ts#L8)
|
|
10
10
|
|
|
11
11
|
About — Public information page. Catalog-typed DOM component
|
|
12
12
|
(ComponentFn<AuthCatalog, 'About'>). Renders static content from props.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const Contact: ComponentFn<AuthCatalog, "Contact">;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-dom/examples/demo/src/components/Contact.ts:8](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.
|
|
9
|
+
Defined in: [play-dom/examples/demo/src/components/Contact.ts:8](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.53/packages/play-dom/examples/demo/src/components/Contact.ts#L8)
|
|
10
10
|
|
|
11
11
|
Contact — Public contact page. Catalog-typed DOM component
|
|
12
12
|
(ComponentFn<AuthCatalog, 'Contact'>). Renders static content from props.
|