@xmachines/docs 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/api/@xmachines/play/README.md +1 -2
- 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 +61 -18
- package/api/@xmachines/play-actor/classes/AbstractActor.md +3 -3
- package/api/@xmachines/play-actor/functions/attachRenderErrorHandler.md +1 -1
- package/api/@xmachines/play-actor/functions/composePlayState.md +26 -0
- package/api/@xmachines/play-actor/functions/createViewStoreLifecycle.md +21 -0
- package/api/@xmachines/play-actor/functions/guardContextWrites.md +41 -0
- package/api/@xmachines/play-actor/functions/refreshContextSubtree.md +27 -0
- package/api/@xmachines/play-actor/functions/reuseComposedState.md +41 -0
- package/api/@xmachines/play-actor/functions/shallowEqualExcept.md +28 -0
- package/api/@xmachines/play-actor/functions/toAtomState.md +1 -1
- package/api/@xmachines/play-actor/functions/typedSpec.md +23 -26
- 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 +12 -14
- package/api/@xmachines/play-actor/interfaces/ResolveViewStoreOptions.md +11 -0
- package/api/@xmachines/play-actor/interfaces/Routable.md +3 -3
- package/api/@xmachines/play-actor/interfaces/ViewStoreLifecycle.md +50 -0
- package/api/@xmachines/play-actor/interfaces/ViewStoreResolution.md +15 -0
- package/api/@xmachines/play-actor/interfaces/Viewable.md +2 -2
- package/api/@xmachines/play-actor/variables/CONTEXT_STATE_KEY.md +15 -0
- package/api/@xmachines/play-dom/README.md +5 -3
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +4 -4
- package/api/@xmachines/play-dom/functions/createPlayUI.md +1 -1
- package/api/@xmachines/play-dom/functions/createRenderer.md +1 -1
- package/api/@xmachines/play-dom/functions/createValidationRegistry.md +22 -0
- package/api/@xmachines/play-dom/functions/defineRegistry.md +5 -5
- package/api/@xmachines/play-dom/interfaces/ComponentContext.md +9 -8
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +2 -2
- package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +2 -0
- package/api/@xmachines/play-dom/interfaces/FieldValidationState.md +16 -0
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +3 -3
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +4 -4
- package/api/@xmachines/play-dom/interfaces/RenderSpecOptions.md +2 -0
- package/api/@xmachines/play-dom/interfaces/ValidationRegistry.md +21 -0
- package/api/@xmachines/play-dom/type-aliases/BaseComponentProps.md +10 -0
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +1 -1
- package/api/@xmachines/play-dom/variables/schema.md +35 -45
- package/api/@xmachines/play-dom-router/README.md +1 -2
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +4 -4
- 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 +2 -2
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +5 -5
- package/api/@xmachines/play-react/functions/defineRegistry.md +5 -5
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/useFieldValidation.md +31 -0
- package/api/@xmachines/play-react/functions/usePlayView.md +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/ComponentContext.md +9 -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 +1 -1
- package/api/@xmachines/play-react/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-react/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-react-router/README.md +1 -2
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +4 -4
- package/api/@xmachines/play-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-react-router/functions/createPlayRouterProvider.md +1 -1
- package/api/@xmachines/play-react-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-react-router/interfaces/PlayActor.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterBridgeConstructor.md +1 -1
- package/api/@xmachines/play-react-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-router/README.md +1 -2
- package/api/@xmachines/play-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +4 -4
- 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/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 +5 -5
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-router/interfaces/ResolvedRoutePath.md +3 -3
- package/api/@xmachines/play-router/interfaces/RoutableActor.md +4 -4
- 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/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 +1 -2
- 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 +1 -2
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +8 -8
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +8 -8
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-solid/type-aliases/AnyPlayActor.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorContext.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-solid-router/README.md +1 -2
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +5 -5
- package/api/@xmachines/play-solid-router/functions/createPlayRouterProvider.md +1 -1
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +3 -3
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterBridgeConstructor.md +1 -1
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-solid-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-svelte/README.md +20 -3
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-svelte/functions/getActorContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/setActorContext.md +1 -1
- package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +8 -8
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +4 -4
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +11 -11
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +5 -5
- package/api/@xmachines/play-svelte/type-aliases/AnyPlayActor.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/README.md +1 -2
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-sveltekit-router/README.md +1 -2
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +1 -1
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +4 -4
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/README.md +1 -2
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/functions/createPlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayActor.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterBridgeConstructor.md +1 -1
- 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-react-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-router/README.md +1 -2
- package/api/@xmachines/play-tanstack-router/classes/TanStackRouterBridgeBase.md +2 -2
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouteMapLike.md +3 -3
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouterLike.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/README.md +1 -2
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/classes/TanStackSolidRouterBridge.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/functions/createPlayRouterProvider.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayActor.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterBridgeConstructor.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/variables/PlayRouterProvider.md +1 -1
- 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 +1 -1
- package/api/@xmachines/play-vue/functions/useFieldValidation.md +31 -0
- 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 +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue-router/README.md +1 -2
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +4 -4
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +5 -5
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
- package/api/@xmachines/play-vue-router/interfaces/PlayActor.md +5 -5
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +6 -6
- package/api/@xmachines/play-vue-router/interfaces/RouteMapOptions.md +2 -2
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +1 -1
- package/api/@xmachines/play-xstate/README.md +36 -2
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +28 -28
- 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 +7 -7
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +5 -5
- package/api/@xmachines/play-xstate/interfaces/RouteObject.md +2 -2
- 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 +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
- 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/vite-aliases/functions/xmSvelteRunes.md +7 -2
- package/api/@xmachines/shared/vitest/functions/defineXmBrowserConfig.md +1 -1
- package/api/@xmachines/shared/vitest/functions/defineXmVitestConfig.md +1 -1
- package/api/@xmachines/shared/vitest/interfaces/XmBrowserConfigOptions.md +4 -4
- package/contributing/architecture.md +6 -6
- package/contributing/deployment.md +2 -2
- package/contributing/development.md +5 -3
- package/contributing/testing.md +24 -10
- package/examples/@xmachines/play-dom-demo/README.md +2 -2
- package/examples/@xmachines/play-dom-demo/functions/createNavBar.md +1 -1
- package/examples/@xmachines/play-dom-demo/functions/initShell.md +6 -7
- package/examples/@xmachines/play-dom-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Home.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Login.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/NavBarView.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Navigation.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Overview.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Profile.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Settings.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-dom-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-dom-router-demo/README.md +2 -2
- package/examples/@xmachines/play-react-demo/README.md +2 -2
- package/examples/@xmachines/play-react-demo/functions/App.md +1 -1
- package/examples/@xmachines/play-react-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/DebugPanel.md +2 -3
- 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 -2
- package/examples/@xmachines/play-react-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-react-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-react-router-demo/README.md +2 -2
- package/examples/@xmachines/play-solid-demo/README.md +2 -2
- package/examples/@xmachines/play-solid-demo/functions/App.md +1 -1
- package/examples/@xmachines/play-solid-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/DebugPanel.md +2 -4
- 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 -2
- 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 +2 -2
- package/examples/@xmachines/play-svelte-demo/README.md +2 -2
- package/examples/@xmachines/play-svelte-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-spa-router-demo/README.md +2 -2
- package/examples/@xmachines/play-sveltekit-router-demo/README.md +2 -2
- package/examples/@xmachines/play-tanstack-react-router-demo/README.md +2 -2
- package/examples/@xmachines/play-tanstack-solid-router-demo/README.md +2 -2
- package/examples/@xmachines/play-vue-demo/README.md +2 -2
- package/examples/@xmachines/play-vue-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-vue-demo/variables/App.md +1 -1
- package/examples/@xmachines/play-vue-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-vue-router-demo/README.md +2 -2
- package/examples/README.md +3 -0
- package/examples/form-validation.md +1 -1
- package/guides/README.md +6 -0
- package/guides/actor-model.md +1 -1
- package/guides/getting-started.md +4 -2
- package/guides/inspector.md +197 -0
- package/guides/state-machines.md +3 -1
- package/package.json +2 -2
- package/rfc/play.md +11 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[Examples](../../README.md) / @xmachines/play-vue-demo
|
|
2
2
|
|
|
3
|
+
<!-- generated-by: gsd-doc-writer -->
|
|
4
|
+
|
|
3
5
|
# @xmachines/play-vue-demo
|
|
4
6
|
|
|
5
7
|
Vue 3 renderer demo for [`@xmachines/play-vue`](../../../api/@xmachines/play-vue/README.md) — actor + `PlayRenderer` without a router.
|
|
6
8
|
|
|
7
|
-
[](https://opensource.org/licenses/MIT)
|
|
8
|
-
|
|
9
9
|
## What This Demonstrates
|
|
10
10
|
|
|
11
11
|
- Shared auth machine reused without framework-specific business logic
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
type AuthCatalog = typeof authCatalog;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/play-vue/examples/demo/src/catalog.ts:6](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.
|
|
9
|
+
Defined in: [packages/play-vue/examples/demo/src/catalog.ts:6](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.56/packages/play-vue/examples/demo/src/catalog.ts#L6)
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
const App: DefineComponent<{}, {}, unknown>;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/play-vue/examples/demo/src/env.d.ts:5](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.
|
|
9
|
+
Defined in: [packages/play-vue/examples/demo/src/env.d.ts:5](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.56/packages/play-vue/examples/demo/src/env.d.ts#L5)
|
|
@@ -169,4 +169,4 @@ const authCatalog: Catalog<
|
|
|
169
169
|
>;
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
Defined in: [packages/play-vue/examples/demo/src/catalog.ts:5](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.
|
|
172
|
+
Defined in: [packages/play-vue/examples/demo/src/catalog.ts:5](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.56/packages/play-vue/examples/demo/src/catalog.ts#L5)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[Examples](../../README.md) / @xmachines/play-vue-router-demo
|
|
2
2
|
|
|
3
|
+
<!-- generated-by: gsd-doc-writer -->
|
|
4
|
+
|
|
3
5
|
# @xmachines/play-vue-router-demo
|
|
4
6
|
|
|
5
7
|
Vue Router integration demo for the XMachines Play architecture using Vue Composition API.
|
|
6
8
|
|
|
7
|
-
[](https://opensource.org/licenses/MIT)
|
|
8
|
-
|
|
9
9
|
## What This Demonstrates
|
|
10
10
|
|
|
11
11
|
- Shared auth machine reused without framework-specific business logic
|
package/examples/README.md
CHANGED
|
@@ -23,6 +23,8 @@ Learn how state machines control navigation:
|
|
|
23
23
|
|
|
24
24
|
Complete working implementations of actor-authoritative routing with all architectural invariants enforced.
|
|
25
25
|
|
|
26
|
+
Every demo below also wires the [Stately inspector](../guides/inspector.md): the debug panel's **Show Inspector** button opens the live machine — history replayed — in its own window.
|
|
27
|
+
|
|
26
28
|
## Complete Demo Applications
|
|
27
29
|
|
|
28
30
|
### Renderer Demos
|
|
@@ -107,5 +109,6 @@ pnpm --filter @xmachines/play-dom-router-demo run dev
|
|
|
107
109
|
## Related Documentation
|
|
108
110
|
|
|
109
111
|
- **[Getting Started](../guides/getting-started.md)** — Installation, first actor, routing, and view renderer setup
|
|
112
|
+
- **[Inspecting a Running Actor](../guides/inspector.md)** — Attaching the Stately inspector to a `PlayerActor`, in the browser and out of it
|
|
110
113
|
- **[API Reference](../api/README.md)** — Generated API docs for all public packages
|
|
111
114
|
- **[Play RFC](../rfc/play.md)** — Complete architectural specification
|
|
@@ -304,5 +304,5 @@ window.addEventListener("beforeunload", () => {
|
|
|
304
304
|
|
|
305
305
|
- **[Basic State Machine](basic-state-machine.md)** — Foundational concepts without a view layer
|
|
306
306
|
- **[Routing Patterns](routing-patterns.md)** — Parameter routes, relative routes, and `always` auth guards
|
|
307
|
-
- **[`PlaySpec`](../api/@xmachines/play-actor/interfaces/PlaySpec.md)** — Spec type governing `meta.view`, `$bindState`, `$state
|
|
307
|
+
- **[`PlaySpec`](../api/@xmachines/play-actor/interfaces/PlaySpec.md)** — Spec type governing `meta.view`, `$bindState`, and `$state`
|
|
308
308
|
- **[`@xmachines/play-router`](../api/@xmachines/play-router/README.md)** — Route extraction and tree building
|
package/guides/README.md
CHANGED
|
@@ -13,3 +13,9 @@ Background reading that explains the _why_ behind XMachines design decisions.
|
|
|
13
13
|
- **[Understanding State Machines](state-machines.md)** — What finite state machines are, how `meta.route` and `meta.view` extend them, and why they replace boolean flags and component-level routing logic
|
|
14
14
|
- **[Understanding the Actor Model](actor-model.md)** — The actor/infrastructure split, why the machine has zero framework imports, and how the reset invariant works
|
|
15
15
|
- **[Understanding TC39 Signals](signals.md)** — The three signal primitives (`Signal.State`, `Signal.Computed`, `Signal.subtle.Watcher`), why XMachines uses them instead of observables, and the architectural invariants they enforce
|
|
16
|
+
|
|
17
|
+
## Tooling
|
|
18
|
+
|
|
19
|
+
Working with a running actor.
|
|
20
|
+
|
|
21
|
+
- **[Inspecting a Running Actor](inspector.md)** — Attaching the Stately inspector via `PlayerOptions.inspect`, reading inspection events, enabling an inspector after startup, and inspecting without a browser
|
package/guides/actor-model.md
CHANGED
|
@@ -91,7 +91,7 @@ This is why the invariant is called **State-Driven Reset** in the Play RFC.
|
|
|
91
91
|
|
|
92
92
|
[`AbstractActor`](../api/@xmachines/play-actor/classes/AbstractActor.md) (from [`@xmachines/play-actor`](../api/@xmachines/play-actor/README.md)) is the abstract base class that all actor implementations must extend. It extends XState's `Actor`, which means:
|
|
93
93
|
|
|
94
|
-
- XState's inspection API works (`@
|
|
94
|
+
- XState's inspection API works ([`@statelyai/inspect`](https://stately.ai/docs/inspector) — see [Inspecting a Running Actor](inspector.md))
|
|
95
95
|
- XState DevTools attach to actors normally
|
|
96
96
|
- The full XState ecosystem (testing utilities, visualization) is compatible
|
|
97
97
|
|
|
@@ -151,10 +151,10 @@ All packages are ES modules (`"type": "module"`). Use `.js` extensions in all Ty
|
|
|
151
151
|
|
|
152
152
|
#### Step 1: Install the core packages
|
|
153
153
|
|
|
154
|
-
Every XMachines application needs these
|
|
154
|
+
Every XMachines application needs these four packages plus XState:
|
|
155
155
|
|
|
156
156
|
```bash
|
|
157
|
-
pnpm add xstate @xmachines/play-xstate @xmachines/play-actor @xmachines/play-signals
|
|
157
|
+
pnpm add xstate @xmachines/play-xstate @xmachines/play-actor @xmachines/play-signals @xmachines/json-render-core
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
| Package | Role |
|
|
@@ -163,6 +163,7 @@ pnpm add xstate @xmachines/play-xstate @xmachines/play-actor @xmachines/play-sig
|
|
|
163
163
|
| [`@xmachines/play-xstate`](../api/@xmachines/play-xstate/README.md) | [`definePlayer()`](../api/@xmachines/play-xstate/functions/definePlayer.md), [`PlayerActor`](../api/@xmachines/play-xstate/classes/PlayerActor.md), routing helpers |
|
|
164
164
|
| [`@xmachines/play-actor`](../api/@xmachines/play-actor/README.md) | Abstract actor base class and interface types |
|
|
165
165
|
| [`@xmachines/play-signals`](../api/@xmachines/play-signals/README.md) | TC39 Signals polyfill (`Signal.State`, `Signal.Computed`, [`watchSignal`](../api/@xmachines/play-signals/functions/watchSignal.md)) |
|
|
166
|
+
| `@xmachines/json-render-core` | Spec and store types the actor layer builds on — a peer of `@xmachines/play-actor`, and of every renderer package |
|
|
166
167
|
|
|
167
168
|
#### Step 2: Install a router adapter (pick one)
|
|
168
169
|
|
|
@@ -706,6 +707,7 @@ node --version
|
|
|
706
707
|
|
|
707
708
|
## Next Steps
|
|
708
709
|
|
|
710
|
+
- **[Inspecting a Running Actor](inspector.md)** — Attaching the Stately inspector to see the machine, its transitions, and its context live
|
|
709
711
|
- **[Architecture](../contributing/architecture.md)** — System design, layers, invariants, and data flow
|
|
710
712
|
- **[Play RFC](../rfc/play.md)** — Complete architectural specification
|
|
711
713
|
- **[API Reference](../api/README.md)** — Auto-generated API docs for all packages
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Inspecting a Running Actor
|
|
2
|
+
|
|
3
|
+
A `PlayerActor` is an XState actor, so every XState inspection tool works on it unchanged. This guide covers how to attach an inspector, what the events look like once they arrive, and the two things that are specific to XMachines: the actor _is_ the actor an inspector sees, and the observer is configured on the factory rather than on each instance.
|
|
4
|
+
|
|
5
|
+
After reading this you will be able to open the [Stately inspector](https://stately.ai/docs/inspector) against a running demo or your own app, inspect an actor that has no browser around it, and wire an inspector that can be turned on after the actor has already started.
|
|
6
|
+
|
|
7
|
+
- [Quick start](#quick-start) — three lines to a live inspector
|
|
8
|
+
- [Where the observer attaches](#where-the-observer-attaches) — factory-level, creation-time
|
|
9
|
+
- [Reading the events](#reading-the-events) — identity, `rootId`, the construction caveat
|
|
10
|
+
- [Turning the inspector on later](#turning-the-inspector-on-later) — dev-tools toggles and replay
|
|
11
|
+
- [Inspecting without a browser](#inspecting-without-a-browser) — WebSocket transport, Node and SSR
|
|
12
|
+
- [Trying it in the demos](#trying-it-in-the-demos) — the shared demo controller
|
|
13
|
+
- [Production considerations](#production-considerations) — cost and data exposure
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
Install the inspect client alongside your existing XState dependency:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add -D @statelyai/inspect
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Create an inspector and hand its `inspect` observer to [`definePlayer`](../api/@xmachines/play-xstate/functions/definePlayer.md):
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { createBrowserInspector } from "@statelyai/inspect";
|
|
29
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
30
|
+
import { appMachine } from "./machine.js";
|
|
31
|
+
|
|
32
|
+
const { inspect } = createBrowserInspector();
|
|
33
|
+
|
|
34
|
+
const createPlayer = definePlayer({
|
|
35
|
+
machine: appMachine,
|
|
36
|
+
options: { inspect },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const actor = createPlayer();
|
|
40
|
+
actor.start();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`createBrowserInspector()` opens Stately's hosted inspector in a new tab and streams the actor's events to it. From there the machine draws itself, every transition animates, and the context is readable at each step.
|
|
44
|
+
|
|
45
|
+
That is the whole integration. [`PlayerOptions.inspect`](../api/@xmachines/play-xstate/interfaces/PlayerOptions.md) is forwarded verbatim to XState's `createActor`, so anything XState accepts there is accepted here — a function, or an observer object with a `next` method:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// Function form — the common case
|
|
49
|
+
definePlayer({ machine, options: { inspect: (event) => console.log(event.type) } });
|
|
50
|
+
|
|
51
|
+
// Observer form — also forwarded as-is
|
|
52
|
+
definePlayer({ machine, options: { inspect: { next: (event) => sink.write(event) } } });
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Where the observer attaches
|
|
58
|
+
|
|
59
|
+
Two properties of the attachment point matter in practice.
|
|
60
|
+
|
|
61
|
+
**It is configured on the factory, not on the instance.** `definePlayer({ machine, options })` returns a factory; `options.inspect` belongs to that configuration, and every actor the factory creates reports to the same observer. The factory's per-call options bag carries `snapshot` for restoring persisted state and nothing else — there is no per-instance `inspect` override. When one factory produces several live actors (multi-user scenarios, SSR, tests), demultiplex the stream by root instead:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const createPlayer = definePlayer({ machine, options: { inspect } });
|
|
65
|
+
|
|
66
|
+
const alice = createPlayer({ userId: "alice" });
|
|
67
|
+
const bob = createPlayer({ userId: "bob" });
|
|
68
|
+
|
|
69
|
+
// Events from alice's tree, children included
|
|
70
|
+
const forAlice = (event: InspectionEvent) => event.rootId === alice.sessionId;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**It is the only route that sees construction.** Attaching after the fact with `actor.system.inspect(fn)` works and needs no factory changes, but it only receives events from the moment it subscribes — the `@xstate.actor` registration event has already fired by then, and an inspector that never receives it has no machine to draw. Use `options.inspect` when you want the full history; use `actor.system.inspect(fn)` when you only care about what happens next.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Reading the events
|
|
78
|
+
|
|
79
|
+
Because a `PlayerActor` _is_ the XState actor rather than a wrapper around a hidden one, the events name it directly:
|
|
80
|
+
|
|
81
|
+
- `event.actorRef === actor` for the player's own events — recognise a player by identity, no bookkeeping required.
|
|
82
|
+
- `event.rootId === actor.sessionId` for the whole tree, including invoked and spawned children, whose `actorRef` is the child rather than the player.
|
|
83
|
+
|
|
84
|
+
The event types are XState's: `@xstate.actor` when an actor registers, `@xstate.event` when an event is sent, `@xstate.snapshot` after a transition, `@xstate.action` for executed actions, and `@xstate.microstep` for intermediate steps.
|
|
85
|
+
|
|
86
|
+
### The construction caveat
|
|
87
|
+
|
|
88
|
+
`@xstate.actor` fires from _inside_ the actor's constructor. The `actorRef` it carries is a real `PlayerActor`, but a mid-construction one: `state`, `currentRoute`, `currentView` and `initialRoute` do not exist yet, and reading them there throws — XState itself refuses to read a snapshot in that window.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
const inspect = (event: InspectionEvent) => {
|
|
92
|
+
if (event.type === "@xstate.actor") {
|
|
93
|
+
// ❌ throws — the signals are not assigned yet
|
|
94
|
+
console.log(event.actorRef.currentRoute.get());
|
|
95
|
+
}
|
|
96
|
+
if (event.type === "@xstate.snapshot") {
|
|
97
|
+
// ✅ construction has returned; signals are live
|
|
98
|
+
console.log(event.actorRef.getSnapshot().value);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Capture the reference during construction if you need it, and read the signals from a later event or from outside the observer entirely.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Turning the inspector on later
|
|
108
|
+
|
|
109
|
+
An inspector that is only created when the user asks for it — a dev-tools toggle, a keyboard shortcut, a debug panel button — cannot be passed to `definePlayer`, which ran at module scope long before the click. Pass a forwarding function instead, so the attachment point is fixed at factory time while the destination stays swappable:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
let current: ((event: InspectionEvent) => void) | undefined;
|
|
113
|
+
|
|
114
|
+
const createPlayer = definePlayer({
|
|
115
|
+
machine: appMachine,
|
|
116
|
+
options: { inspect: (event) => current?.(event) },
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Later, from a click handler
|
|
120
|
+
export function enableInspector() {
|
|
121
|
+
const { inspect } = createBrowserInspector();
|
|
122
|
+
current = inspect;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
This attaches at creation time (so nothing is missed structurally) while forwarding to nothing until the toggle flips.
|
|
127
|
+
|
|
128
|
+
There is a catch worth knowing before you ship it: events that arrive while `current` is undefined are dropped, so an inspector enabled after startup opens on a machine with no registration event and no history — it has nothing to draw until the next transition. If late opening should show the machine as it stands, buffer the events from creation and replay the buffer when the inspector connects. The demo controller described below does exactly that, and is worth reading as a worked example.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Inspecting without a browser
|
|
133
|
+
|
|
134
|
+
`createBrowserInspector` is one transport, not the only one. `@statelyai/inspect` also exports `createWebSocketInspector`, which pairs with `createInspectorServer` from `@statelyai/inspect/server` to stream the same events over a socket — the route to an actor with no browser around it at all, such as one running in a Node process or on the server half of an SSR render:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { createWebSocketInspector } from "@statelyai/inspect";
|
|
138
|
+
|
|
139
|
+
const { inspect } = createWebSocketInspector({ url: "ws://localhost:8080" });
|
|
140
|
+
|
|
141
|
+
const createPlayer = definePlayer({ machine: appMachine, options: { inspect } });
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Both transports consume the identical `options.inspect` observer, so switching between them touches only the line that creates the inspector. The same is true of an observer you write yourself: a `console.log`, a test spy asserting a transition sequence, or a writer that appends events to a log are all valid `inspect` values, and none of them require the inspect client at all.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Trying it in the demos
|
|
149
|
+
|
|
150
|
+
Every demo in this repository — all five renderer demos and all eight router demos — wires the inspector the same way, so any of them can be used to see the flow end to end:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
pnpm --filter @xmachines/play-react-demo run dev
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Click **Show Inspector** in the debug panel at the bottom of the page. The inspector opens in its own window with the machine already drawn and the session's history replayed, and it keeps updating as you log in, navigate, and log out.
|
|
157
|
+
|
|
158
|
+
The demos share one controller, `createDemoInspector()` from `@xmachines/play-actor-shared`, which each demo passes straight through to `definePlayer`:
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
const inspector = createDemoInspector();
|
|
162
|
+
|
|
163
|
+
const actor = definePlayer({
|
|
164
|
+
machine: authMachine,
|
|
165
|
+
options: { inspect: inspector.inspect },
|
|
166
|
+
})();
|
|
167
|
+
actor.start();
|
|
168
|
+
|
|
169
|
+
// The debug panel's button
|
|
170
|
+
<button onClick={() => inspector.show()}>Show Inspector</button>;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The controller answers the late-opening problem from the previous section: it buffers serialized events from actor creation, pins the current root's registration so it can never roll out of the bounded buffer, and flushes the buffer when the inspector window completes its handshake. That is a demo trade-off rather than a general recommendation — every transition pays serialization whether or not anyone ever opens the inspector — but it is what makes the button work at any point in a session. See the [shared demo package README](../../play-actor/examples/shared/README.md) for the design in full.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Production considerations
|
|
178
|
+
|
|
179
|
+
**Cost.** Inspection serializes events. A `console.log` observer is cheap; a browser inspector posting every transition, and any buffering scheme layered on top, is not. Gate the inspector behind a development-only branch, and prefer letting the bundler drop it entirely:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
const options = import.meta.env.DEV ? { inspect: createBrowserInspector().inspect } : {};
|
|
183
|
+
|
|
184
|
+
const createPlayer = definePlayer({ machine: appMachine, options });
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Data exposure.** Inspection events carry the machine's definition and its context — which in a real application may include user identifiers, tokens, or form input. The browser transport posts that data to the inspector's origin over `postMessage`, and the WebSocket transport sends it to whatever server is listening. Treat an inspector connection as a data egress path: keep it out of production builds, and when inspecting a shared environment, know where the events are going.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Related documentation
|
|
192
|
+
|
|
193
|
+
- **[`PlayerOptions`](../api/@xmachines/play-xstate/interfaces/PlayerOptions.md)** — the full options bag, `inspect` included
|
|
194
|
+
- **[`PlayerActor`](../api/@xmachines/play-xstate/classes/PlayerActor.md)** — the actor an inspector observes
|
|
195
|
+
- **[Understanding the Actor Model](actor-model.md)** — why the actor is the actor, and what that buys
|
|
196
|
+
- **[Getting Started](getting-started.md)** — installing packages and creating your first actor
|
|
197
|
+
- **[Stately inspect docs](https://stately.ai/docs/inspector)** — the inspector itself, its transports and options
|
package/guides/state-machines.md
CHANGED
|
@@ -122,7 +122,9 @@ const appMachine = setup({/* ... */}).createMachine({
|
|
|
122
122
|
|
|
123
123
|
`meta.route` is a string path. When the machine enters a state, `actor.currentRoute` (a `Signal.Computed`) derives this path and emits it. The router bridge reads it and updates the URL.
|
|
124
124
|
|
|
125
|
-
`meta.view` is a [`PlaySpec`](../api/@xmachines/play-actor/interfaces/PlaySpec.md) — a `@xmachines/json-render-core` spec object describing what to render. Use `typedSpec
|
|
125
|
+
`meta.view` is a [`PlaySpec`](../api/@xmachines/play-actor/interfaces/PlaySpec.md) — a `@xmachines/json-render-core` spec object describing what to render. Use `typedSpec(...)` from [`@xmachines/play-actor`](../api/@xmachines/play-actor/README.md) to type-check the spec literal at the definition site (XState's `meta` is untyped). When the machine enters a state, `actor.currentView` is updated with the derived spec. The renderer reads it and projects it through framework components.
|
|
126
|
+
|
|
127
|
+
The machine's whole context is available to every view through the **`/context` projection**: the derived spec's `state` carries `context: <machine context>`. Specs read it with ordinary state expressions — `{ $state: "/context/username" }` in props, `visible` conditions, or `repeat.statePath`. The subtree is **read-only**: context changes only through machine events, and a `$bindState`/`setState` write under `/context` throws. URL data lives at its own paths (`/context/params/…`, `/context/query/…`, written into context by `formatPlayRouteTransitions`), so a URL param can never shadow a machine-owned field. When validating specs with tools like `validateSpec`, validate the **derived** view (`actor.currentView.get()`) — its `state` honestly describes the store contents — not the raw `meta.view`. A context change re-emits the view with the same `viewKey`; providers respond by refreshing `/context` in the live store, not by remounting the UI.
|
|
126
128
|
|
|
127
129
|
**The machine is the single source of truth for both routing and views.** There is no separate route configuration file. There is no switch statement in a component deciding what to render based on the URL. The state machine encodes all of that.
|
|
128
130
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmachines/docs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Documentation for XMachines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"documentation",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"author": "Mikael Karon <mikael@karon.se>",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git+
|
|
18
|
+
"url": "git+https://gitlab.com/xmachin-es/xmachines-js.git",
|
|
19
19
|
"directory": "packages/docs"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
package/rfc/play.md
CHANGED
|
@@ -153,7 +153,16 @@ export interface Routable {
|
|
|
153
153
|
|
|
154
154
|
// Optional capability: View rendering
|
|
155
155
|
export interface PlaySpec extends Spec {
|
|
156
|
-
|
|
156
|
+
// The machine's whole context is projected into the derived view's state
|
|
157
|
+
// under the read-only /context subtree; specs read it via
|
|
158
|
+
// { $state: "/context/…" } in props, visible conditions, and
|
|
159
|
+
// repeat.statePath. /context never accepts writes — machine context
|
|
160
|
+
// changes only through events.
|
|
161
|
+
//
|
|
162
|
+
// Stamped by view derivation from the selected meta entry (never
|
|
163
|
+
// authored): providers key their store lifecycle on it — changed key
|
|
164
|
+
// reseeds the store, unchanged key refreshes /context in place.
|
|
165
|
+
viewKey?: string;
|
|
157
166
|
}
|
|
158
167
|
|
|
159
168
|
export interface Viewable {
|
|
@@ -393,7 +402,7 @@ export const machine = setup({/* types, guards, actions */}).createMachine({
|
|
|
393
402
|
overview: {
|
|
394
403
|
meta: {
|
|
395
404
|
route: "/dashboard",
|
|
396
|
-
view: typedSpec
|
|
405
|
+
view: typedSpec({
|
|
397
406
|
root: "root",
|
|
398
407
|
elements: {
|
|
399
408
|
root: {
|