@xmachines/docs 2.0.0-alpha.1 → 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 +6 -5
- package/api/@xmachines/play/README.md +1 -4
- package/api/@xmachines/play/classes/NonNullableError.md +11 -11
- package/api/@xmachines/play/classes/PlayError.md +11 -11
- package/api/@xmachines/play/functions/assertNonNullable.md +1 -1
- package/api/@xmachines/play/type-aliases/PlayEvent.md +4 -4
- package/api/@xmachines/play-actor/README.md +81 -26
- package/api/@xmachines/play-actor/classes/AbstractActor.md +35 -20
- 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 +7 -7
- package/api/@xmachines/play-actor/interfaces/BaseViewContextValue.md +7 -7
- 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 +5 -5
- 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 +4 -4
- package/api/@xmachines/play-actor/variables/CONTEXT_STATE_KEY.md +15 -0
- package/api/@xmachines/play-dom/README.md +6 -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 +10 -10
- 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 +5 -5
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +12 -12
- 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 +3 -3
- 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 +2 -2
- package/api/@xmachines/play-dom-router/functions/createRouter.md +1 -1
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +16 -16
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +16 -16
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +6 -6
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +5 -5
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +6 -6
- package/api/@xmachines/play-react/README.md +4 -3
- 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 +10 -10
- package/api/@xmachines/play-react/interfaces/ComponentContext.md +9 -8
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +6 -6
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +5 -5
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +13 -13
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +7 -7
- 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 +2 -4
- 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 +2 -2
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-react-router/interfaces/PlayActor.md +7 -7
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderBaseProps.md +7 -7
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +7 -7
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +5 -5
- 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 +9 -17
- 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 +2 -2
- 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 +2 -2
- 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 +6 -6
- package/api/@xmachines/play-router/interfaces/LocationLike.md +5 -5
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +5 -7
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +7 -7
- package/api/@xmachines/play-router/interfaces/PlayActor.md +7 -7
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-router/interfaces/ResolvedRoutePath.md +5 -5
- package/api/@xmachines/play-router/interfaces/RoutableActor.md +6 -6
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +10 -10
- package/api/@xmachines/play-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-router/interfaces/RouteMapping.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteNode.md +12 -12
- package/api/@xmachines/play-router/interfaces/RouteObject.md +4 -4
- package/api/@xmachines/play-router/interfaces/RouteTree.md +7 -7
- 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 +2 -2
- package/api/@xmachines/play-signals/functions/watchSignal.md +1 -1
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +4 -4
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +4 -4
- 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 +2 -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 +10 -10
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +13 -13
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +7 -7
- 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 +7 -7
- 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 +2 -2
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +35 -20
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +7 -7
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderBaseProps.md +7 -7
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +7 -7
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +5 -5
- 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 +22 -4
- 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 +10 -10
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +6 -6
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +13 -13
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +7 -7
- package/api/@xmachines/play-svelte/type-aliases/AnyPlayActor.md +1 -1
- package/api/@xmachines/play-svelte-spa-router/README.md +19 -28
- 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 +2 -2
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +6 -6
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +5 -5
- 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 +7 -7
- 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 +2 -2
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +6 -6
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +5 -5
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +5 -5
- 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 -3
- 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 +2 -2
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +2 -2
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayActor.md +7 -7
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderBaseProps.md +7 -7
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +7 -7
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +5 -5
- 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 +2 -0
- 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 +7 -7
- 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 +2 -2
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayActor.md +7 -7
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderBaseProps.md +7 -7
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +7 -7
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +5 -5
- 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 -5
- 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 +7 -7
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +10 -10
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +7 -7
- 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 +4 -4
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue-router/README.md +3 -3
- 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 +2 -2
- package/api/@xmachines/play-vue-router/interfaces/PlayActor.md +7 -7
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +8 -8
- package/api/@xmachines/play-vue-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +5 -5
- 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 +100 -111
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +81 -58
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +5 -12
- package/api/@xmachines/play-xstate/functions/composeGuards.md +23 -24
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +22 -17
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +7 -2
- package/api/@xmachines/play-xstate/functions/definePlayer.md +3 -3
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +1 -1
- package/api/@xmachines/play-xstate/functions/eventMatches.md +7 -2
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +11 -45
- package/api/@xmachines/play-xstate/functions/hasContext.md +7 -4
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
- package/api/@xmachines/play-xstate/functions/negateGuard.md +21 -16
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +5 -5
- package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +4 -4
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +10 -11
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +7 -7
- package/api/@xmachines/play-xstate/interfaces/RouteObject.md +4 -4
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +9 -25
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +7 -5
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +7 -5
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +11 -15
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +6 -13
- package/api/@xmachines/play-xstate/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -16
- package/api/@xmachines/shared/README.md +2 -2
- 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 +12 -7
- package/api/@xmachines/shared/vite-aliases/functions/xmResolve.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmSvelteRunes.md +9 -4
- 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 +6 -6
- package/contributing/architecture.md +27 -28
- package/contributing/configuration.md +10 -10
- package/contributing/deployment.md +51 -30
- package/contributing/development.md +62 -21
- package/contributing/testing.md +36 -14
- 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-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-solid-demo/functions/App.md +1 -1
- package/examples/@xmachines/play-solid-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/About.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Contact.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Dashboard.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/DebugPanel.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Home.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Login.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/NavBar.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/NavBarView.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Navigation.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Overview.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Profile.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Settings.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Shell.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/Stats.md +1 -1
- package/examples/@xmachines/play-solid-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-svelte-demo/variables/authCatalog.md +1 -1
- package/examples/@xmachines/play-vue-demo/type-aliases/AuthCatalog.md +1 -1
- package/examples/@xmachines/play-vue-demo/variables/App.md +1 -1
- package/examples/@xmachines/play-vue-demo/variables/authCatalog.md +1 -1
- package/examples/README.md +4 -1
- package/examples/basic-state-machine.md +24 -24
- package/examples/form-validation.md +110 -121
- package/examples/multi-router-integration.md +0 -2
- package/examples/routing-patterns.md +60 -94
- package/examples/traffic-light.md +57 -48
- package/guides/README.md +6 -2
- package/guides/actor-model.md +1 -1
- package/guides/getting-started.md +89 -90
- package/guides/inspector.md +197 -0
- package/guides/state-machines.md +55 -69
- package/package.json +10 -7
- package/rfc/play.md +15 -6
- package/api/@xmachines/play-xstate/functions/createRoutedMachine.md +0 -87
- package/api/@xmachines/play-xstate/type-aliases/PlayRoutePayload.md +0 -30
- package/api/@xmachines/play-xstate/type-aliases/SetupLike.md +0 -33
- package/api/@xmachines/play-xstate/type-aliases/WithOptional.md +0 -31
- package/api/@xmachines/play-xstate/variables/emptyEventSchema.md +0 -37
- package/api/@xmachines/play-xstate/variables/playMetaSchema.md +0 -40
- package/api/@xmachines/play-xstate/variables/playRouteEventSchema.md +0 -9
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: PlayRouteEvent
|
|
4
4
|
|
|
5
|
-
Defined in: [play-router/src/types.ts:
|
|
5
|
+
Defined in: [play-router/src/types.ts:225](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L225)
|
|
6
6
|
|
|
7
7
|
Enhanced routing event with parameter and query support
|
|
8
8
|
|
|
@@ -120,10 +120,10 @@ URLPatternResult for advanced use cases (debugging, pattern analysis).
|
|
|
120
120
|
|
|
121
121
|
## Properties
|
|
122
122
|
|
|
123
|
-
| Property | Modifier | Type | Defined in
|
|
124
|
-
| -------------------------------------- | ---------- | ------------------------------ |
|
|
125
|
-
| <a id="property-match"></a> `match?` | `readonly` | `unknown` | [play-router/src/types.ts:
|
|
126
|
-
| <a id="property-params"></a> `params?` | `readonly` | `Record`\<`string`, `string`\> | [play-router/src/types.ts:
|
|
127
|
-
| <a id="property-query"></a> `query?` | `readonly` | `Record`\<`string`, `string`\> | [play-router/src/types.ts:
|
|
128
|
-
| <a id="property-to"></a> `to` | `readonly` | `string` | [play-router/src/types.ts:
|
|
129
|
-
| <a id="property-type"></a> `type` | `readonly` | `"play.route"` | [play-router/src/types.ts:
|
|
123
|
+
| Property | Modifier | Type | Defined in |
|
|
124
|
+
| -------------------------------------- | ---------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
125
|
+
| <a id="property-match"></a> `match?` | `readonly` | `unknown` | [play-router/src/types.ts:230](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L230) |
|
|
126
|
+
| <a id="property-params"></a> `params?` | `readonly` | `Record`\<`string`, `string`\> | [play-router/src/types.ts:228](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L228) |
|
|
127
|
+
| <a id="property-query"></a> `query?` | `readonly` | `Record`\<`string`, `string`\> | [play-router/src/types.ts:229](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L229) |
|
|
128
|
+
| <a id="property-to"></a> `to` | `readonly` | `string` | [play-router/src/types.ts:227](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L227) |
|
|
129
|
+
| <a id="property-type"></a> `type` | `readonly` | `"play.route"` | [play-router/src/types.ts:226](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L226) |
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: RouteMapOptions
|
|
4
4
|
|
|
5
|
-
Defined in: [play-router/src/create-route-map.ts:9](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0
|
|
5
|
+
Defined in: [play-router/src/create-route-map.ts:9](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/create-route-map.ts#L9)
|
|
6
6
|
|
|
7
7
|
Options for `createRouteMap` and `createRouteMapFromTree`.
|
|
8
8
|
|
|
9
9
|
## Properties
|
|
10
10
|
|
|
11
|
-
| Property | Type | Description | Defined in
|
|
12
|
-
| -------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
13
|
-
| <a id="property-cachesize"></a> `cacheSize?` | `number` | Maximum number of resolved parameterized path lookups to cache. `RouteMap.getStateIdByPath()` resolves parameterized patterns (e.g. `/profile/:userId`) via URLPattern on every call. Frequently visited paths are cached in an LRU so subsequent lookups are O(1). Increase this value for applications with large parameterized route sets or high navigation frequency. Default: `500`. | [play-router/src/create-route-map.ts:20](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0
|
|
11
|
+
| Property | Type | Description | Defined in |
|
|
12
|
+
| -------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| <a id="property-cachesize"></a> `cacheSize?` | `number` | Maximum number of resolved parameterized path lookups to cache. `RouteMap.getStateIdByPath()` resolves parameterized patterns (e.g. `/profile/:userId`) via URLPattern on every call. Frequently visited paths are cached in an LRU so subsequent lookups are O(1). Increase this value for applications with large parameterized route sets or high navigation frequency. Default: `500`. | [play-router/src/create-route-map.ts:20](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/create-route-map.ts#L20) |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: RouteMapping
|
|
4
4
|
|
|
5
|
-
Defined in: [play-router/src/base-route-map.ts:51](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0
|
|
5
|
+
Defined in: [play-router/src/base-route-map.ts:51](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/base-route-map.ts#L51)
|
|
6
6
|
|
|
7
7
|
A single state ID ↔ path mapping entry.
|
|
8
8
|
|
|
@@ -21,7 +21,7 @@ const optionalMapping: RouteMapping = { stateId: "settings", path: "/settings/:s
|
|
|
21
21
|
|
|
22
22
|
## Properties
|
|
23
23
|
|
|
24
|
-
| Property | Modifier | Type | Description | Defined in
|
|
25
|
-
| --------------------------------------- | ---------- | -------- | ----------------------------------------------------------------------------- |
|
|
26
|
-
| <a id="property-path"></a> `path` | `readonly` | `string` | URL path pattern (e.g., `"/"`, `"/profile/:userId"`, `"/settings/:section?"`) | [play-router/src/base-route-map.ts:55](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0
|
|
27
|
-
| <a id="property-stateid"></a> `stateId` | `readonly` | `string` | State machine state ID (e.g., `"home"`, `"#profile"`) | [play-router/src/base-route-map.ts:53](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0
|
|
24
|
+
| Property | Modifier | Type | Description | Defined in |
|
|
25
|
+
| --------------------------------------- | ---------- | -------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| <a id="property-path"></a> `path` | `readonly` | `string` | URL path pattern (e.g., `"/"`, `"/profile/:userId"`, `"/settings/:section?"`) | [play-router/src/base-route-map.ts:55](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/base-route-map.ts#L55) |
|
|
27
|
+
| <a id="property-stateid"></a> `stateId` | `readonly` | `string` | State machine state ID (e.g., `"home"`, `"#profile"`) | [play-router/src/base-route-map.ts:53](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/base-route-map.ts#L53) |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: RouterBridge
|
|
4
4
|
|
|
5
|
-
Defined in: [play-router/src/types.ts:
|
|
5
|
+
Defined in: [play-router/src/types.ts:341](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L341)
|
|
6
6
|
|
|
7
7
|
RouterBridge interface for runtime infrastructure adapters
|
|
8
8
|
|
|
@@ -54,7 +54,7 @@ class MyRouterBridge implements RouterBridge {
|
|
|
54
54
|
connect(): void | Promise<void>;
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
Defined in: [play-router/src/types.ts:
|
|
57
|
+
Defined in: [play-router/src/types.ts:357](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L357)
|
|
58
58
|
|
|
59
59
|
Connect the router bridge to the Actor
|
|
60
60
|
|
|
@@ -83,7 +83,7 @@ await bridge.connect();
|
|
|
83
83
|
disconnect(): void | Promise<void>;
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
Defined in: [play-router/src/types.ts:
|
|
86
|
+
Defined in: [play-router/src/types.ts:373](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-router/src/types.ts#L373)
|
|
87
87
|
|
|
88
88
|
Disconnect the router bridge from the Actor
|
|
89
89
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
type RoutableActor = PlayActor;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [play-vue-router/src/play-router-provider.ts:10](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0
|
|
9
|
+
Defined in: [play-vue-router/src/play-router-provider.ts:10](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-vue-router/src/play-router-provider.ts#L10)
|
|
10
10
|
|
|
11
11
|
## Deprecated
|
|
12
12
|
|
|
@@ -64,7 +64,7 @@ const PlayRouterProvider: DefineComponent<
|
|
|
64
64
|
>;
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
Defined in: [play-vue-router/src/play-router-provider.ts:19](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0
|
|
67
|
+
Defined in: [play-vue-router/src/play-router-provider.ts:19](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.0.0/packages/play-vue-router/src/play-router-provider.ts#L19)
|
|
68
68
|
|
|
69
69
|
PlayRouterProvider — Vue convenience wrapper for VueRouterBridge.
|
|
70
70
|
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
[API](../../README.md) / @xmachines/play-xstate
|
|
2
2
|
|
|
3
|
-
<!-- generated-by: gsd-doc-writer -->
|
|
4
|
-
|
|
5
3
|
# @xmachines/play-xstate
|
|
6
4
|
|
|
7
|
-
> XState
|
|
5
|
+
> XState v5 adapter for the XMachines Play Architecture — bind state machines to the actor base with signal-driven reactivity and router integration.
|
|
8
6
|
|
|
9
|
-
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://www.npmjs.com/package/@xmachines/play-xstate)
|
|
7
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-xstate)
|
|
11
8
|
|
|
12
9
|
Part of the [XMachines Play](../../README.md) monorepo.
|
|
13
10
|
|
|
@@ -19,7 +16,7 @@ Part of the [XMachines Play](../../README.md) monorepo.
|
|
|
19
16
|
pnpm add @xmachines/play-xstate xstate
|
|
20
17
|
```
|
|
21
18
|
|
|
22
|
-
`xstate ^
|
|
19
|
+
`xstate ^5.31.0` is a peer dependency and must be installed alongside this package.
|
|
23
20
|
|
|
24
21
|
---
|
|
25
22
|
|
|
@@ -27,18 +24,13 @@ pnpm add @xmachines/play-xstate xstate
|
|
|
27
24
|
|
|
28
25
|
```typescript
|
|
29
26
|
import { setup } from "xstate";
|
|
30
|
-
import { definePlayer
|
|
27
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
31
28
|
|
|
32
|
-
// 1. Define your XState
|
|
33
|
-
const machine = setup({
|
|
34
|
-
schemas: {
|
|
35
|
-
events: { activate: emptyEventSchema },
|
|
36
|
-
meta: playMetaSchema, // types meta.route / meta.view on state nodes
|
|
37
|
-
},
|
|
38
|
-
}).createMachine({
|
|
29
|
+
// 1. Define your XState v5 machine
|
|
30
|
+
const machine = setup({}).createMachine({
|
|
39
31
|
initial: "idle",
|
|
40
32
|
states: {
|
|
41
|
-
idle: { meta: { route: "/" }
|
|
33
|
+
idle: { meta: { route: "/" } },
|
|
42
34
|
active: { meta: { route: "/active" } },
|
|
43
35
|
},
|
|
44
36
|
});
|
|
@@ -66,16 +58,16 @@ actor.stop();
|
|
|
66
58
|
|
|
67
59
|
### `definePlayer(config)`
|
|
68
60
|
|
|
69
|
-
Creates a `PlayerFactory` from an XState
|
|
61
|
+
Creates a `PlayerFactory` from an XState v5 machine. The factory pattern enables multiple independent actor instances from a single configuration — useful for multi-user scenarios, SSR, or testing.
|
|
70
62
|
|
|
71
63
|
```typescript
|
|
72
|
-
import { setup
|
|
64
|
+
import { setup } from "xstate";
|
|
73
65
|
import { definePlayer } from "@xmachines/play-xstate";
|
|
74
66
|
|
|
75
67
|
const machine = setup({
|
|
76
|
-
|
|
77
|
-
context:
|
|
78
|
-
input:
|
|
68
|
+
types: {
|
|
69
|
+
context: {} as { userId: string },
|
|
70
|
+
input: {} as { userId: string },
|
|
79
71
|
},
|
|
80
72
|
}).createMachine({
|
|
81
73
|
context: ({ input }) => ({ userId: input.userId }),
|
|
@@ -91,6 +83,7 @@ const createPlayer = definePlayer({
|
|
|
91
83
|
onTransition: (actor, prev, next) => console.log("transitioned"),
|
|
92
84
|
onStateChange: (actor, state) => console.log("state changed"),
|
|
93
85
|
onError: (actor, err) => console.error(err),
|
|
86
|
+
inspect: (event) => console.log(event.type), // handed to XState's actor constructor — enables @statelyai/inspect
|
|
94
87
|
},
|
|
95
88
|
});
|
|
96
89
|
|
|
@@ -101,17 +94,27 @@ const bob = createPlayer({ userId: "bob" });
|
|
|
101
94
|
|
|
102
95
|
#### `PlayerFactory` signature
|
|
103
96
|
|
|
97
|
+
`input` requiredness mirrors XState's `createActor`: a machine whose input type
|
|
98
|
+
cannot be `undefined` makes the factory's first argument required, so forgetting
|
|
99
|
+
it is a compile error instead of an actor stuck in an error status.
|
|
100
|
+
|
|
104
101
|
```typescript
|
|
105
|
-
type PlayerFactory<TMachine> =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
type PlayerFactory<TMachine> =
|
|
103
|
+
undefined extends InputFrom<TMachine>
|
|
104
|
+
? (
|
|
105
|
+
input?: InputFrom<TMachine>,
|
|
106
|
+
options?: PlayerFactoryResumeOptions<TMachine>,
|
|
107
|
+
) => PlayerActor<TMachine>
|
|
108
|
+
: (
|
|
109
|
+
input: InputFrom<TMachine>,
|
|
110
|
+
options?: PlayerFactoryResumeOptions<TMachine>,
|
|
111
|
+
) => PlayerActor<TMachine>;
|
|
109
112
|
```
|
|
110
113
|
|
|
111
114
|
#### Restoring from a snapshot
|
|
112
115
|
|
|
113
116
|
```typescript
|
|
114
|
-
const snapshot = actor.
|
|
117
|
+
const snapshot = actor.getPersistedSnapshot();
|
|
115
118
|
actor.stop();
|
|
116
119
|
|
|
117
120
|
// Restore to the exact saved state
|
|
@@ -120,11 +123,15 @@ restored.start();
|
|
|
120
123
|
console.log(restored.currentRoute.get()); // same route as when saved
|
|
121
124
|
```
|
|
122
125
|
|
|
126
|
+
> **Note:** Persist with `getPersistedSnapshot()`, not `getSnapshot()` — it is
|
|
127
|
+
> the form `createActor` accepts, and the only one that round-trips machines
|
|
128
|
+
> with invoked or spawned children.
|
|
129
|
+
|
|
123
130
|
---
|
|
124
131
|
|
|
125
132
|
### `PlayerActor<TMachine>`
|
|
126
133
|
|
|
127
|
-
Concrete actor class
|
|
134
|
+
Concrete actor class: an XState v5 actor that also exposes TC39 Signal-based reactive signals. Implements both `Routable` and `Viewable` interfaces from `@xmachines/play-actor`.
|
|
128
135
|
|
|
129
136
|
#### Signals
|
|
130
137
|
|
|
@@ -165,7 +172,11 @@ actor.start();
|
|
|
165
172
|
|
|
166
173
|
### Guard utilities
|
|
167
174
|
|
|
168
|
-
|
|
175
|
+
> **Deprecated:** the guard helpers wrap XState's own `and()` / `or()` / `not()`
|
|
176
|
+
> combinators without composing with `setup()`-typed guard slots. Use XState's
|
|
177
|
+
> combinators directly; this module will be removed in the next major.
|
|
178
|
+
|
|
179
|
+
Composable guard helpers that wrap XState's built-in `and()`, `or()`, and `not()` for use in machine `setup({ guards })` definitions.
|
|
169
180
|
|
|
170
181
|
```typescript
|
|
171
182
|
import { setup } from "xstate";
|
|
@@ -178,24 +189,20 @@ import {
|
|
|
178
189
|
contextFieldMatches, // guard: context field equals a value
|
|
179
190
|
} from "@xmachines/play-xstate";
|
|
180
191
|
|
|
181
|
-
const canAccessAdmin = composeGuards(["isLoggedIn", "hasAdminRole"]);
|
|
182
|
-
const isAuthenticated = negateGuard("isGuest");
|
|
183
|
-
|
|
184
192
|
const machine = setup({
|
|
185
193
|
guards: {
|
|
186
194
|
isLoggedIn: ({ context }) => !!context.userId,
|
|
187
195
|
hasAdminRole: ({ context }) => context.role === "admin",
|
|
188
|
-
isGuest: ({ context }) => !context.userId,
|
|
189
196
|
},
|
|
190
197
|
}).createMachine({
|
|
191
198
|
on: {
|
|
192
|
-
accessAdmin:
|
|
193
|
-
|
|
194
|
-
|
|
199
|
+
accessAdmin: {
|
|
200
|
+
guard: composeGuards(["isLoggedIn", "hasAdminRole"]),
|
|
201
|
+
target: "adminPanel",
|
|
195
202
|
},
|
|
196
|
-
accessDashboard:
|
|
197
|
-
|
|
198
|
-
|
|
203
|
+
accessDashboard: {
|
|
204
|
+
guard: negateGuard("isGuest"),
|
|
205
|
+
target: "dashboard",
|
|
199
206
|
},
|
|
200
207
|
},
|
|
201
208
|
// ...
|
|
@@ -208,42 +215,13 @@ const machine = setup({
|
|
|
208
215
|
|
|
209
216
|
Helper functions for declarative route configuration in XState machines.
|
|
210
217
|
|
|
211
|
-
#### `createRoutedMachine(setup)`
|
|
212
|
-
|
|
213
|
-
The recommended entry point: returns a `createMachine` with the same signature as the setup's own — full contextual typing for the config — that wires routing up at runtime.
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
import { setup } from "xstate";
|
|
217
|
-
import { createRoutedMachine } from "@xmachines/play-xstate";
|
|
218
|
-
|
|
219
|
-
const appSetup = setup({/* schemas, guards, ... */});
|
|
220
|
-
|
|
221
|
-
const machine = createRoutedMachine(appSetup)({
|
|
222
|
-
id: "app",
|
|
223
|
-
states: {
|
|
224
|
-
home: {
|
|
225
|
-
id: "home",
|
|
226
|
-
meta: { route: "/home" },
|
|
227
|
-
},
|
|
228
|
-
profile: {
|
|
229
|
-
id: "profile",
|
|
230
|
-
meta: { route: "/users/:userId" },
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
```
|
|
235
|
-
|
|
236
218
|
#### `formatPlayRouteTransitions(machineConfig)`
|
|
237
219
|
|
|
238
|
-
|
|
220
|
+
Crawls machine states with `meta.route` and auto-generates `play.route` event handlers at the root level — eliminating boilerplate routing transitions.
|
|
239
221
|
|
|
240
222
|
```typescript
|
|
241
223
|
import { setup } from "xstate";
|
|
242
|
-
import {
|
|
243
|
-
formatPlayRouteTransitions,
|
|
244
|
-
playMetaSchema,
|
|
245
|
-
playRouteEventSchema,
|
|
246
|
-
} from "@xmachines/play-xstate";
|
|
224
|
+
import { formatPlayRouteTransitions } from "@xmachines/play-xstate";
|
|
247
225
|
|
|
248
226
|
const config = formatPlayRouteTransitions({
|
|
249
227
|
id: "app",
|
|
@@ -259,47 +237,69 @@ const config = formatPlayRouteTransitions({
|
|
|
259
237
|
},
|
|
260
238
|
});
|
|
261
239
|
|
|
262
|
-
// config now
|
|
263
|
-
//
|
|
264
|
-
|
|
265
|
-
// The forwarder navigates injected-route targets directly (atomically);
|
|
266
|
-
// xstate.route is raised only for states declaring their own route config.
|
|
267
|
-
const machine = setup({
|
|
268
|
-
schemas: {
|
|
269
|
-
events: { "play.route": playRouteEventSchema },
|
|
270
|
-
meta: playMetaSchema,
|
|
271
|
-
},
|
|
272
|
-
}).createMachine(config);
|
|
240
|
+
// config now includes auto-generated play.route handlers:
|
|
241
|
+
// on: { "play.route": [ { target: ".home", guard: e => e.to === "#home" }, ... ] }
|
|
242
|
+
const machine = setup({}).createMachine(config);
|
|
273
243
|
```
|
|
274
244
|
|
|
275
|
-
Because the injected `route` configs are static, route transitions keep statically-known targets — `machineToGraph()` sees real edges to every routed state, so reachability queries work.
|
|
276
|
-
|
|
277
245
|
> **Note:** Every state with `meta.route` must also have an explicit `id` field; omitting it throws `MissingStateIdError` at machine-definition time.
|
|
278
246
|
|
|
279
247
|
#### Other routing exports
|
|
280
248
|
|
|
281
249
|
| Export | Description |
|
|
282
250
|
| ---------------------------------- | ------------------------------------------------------------------------- |
|
|
283
|
-
| `playMetaSchema` | Shared `schemas.meta` declaration for `meta.route` / `meta.view` metadata |
|
|
284
|
-
| `playRouteEventSchema` | Shared `schemas.events` entry for the `play.route` event payload |
|
|
285
|
-
| `emptyEventSchema` | Shared `schemas.events` entry for events that carry no payload |
|
|
286
251
|
| `deriveRoute(meta)` | Extract the route template string from a state's metadata object |
|
|
287
252
|
| `isAbsoluteRoute(route)` | Returns `true` if the route string is an absolute URL path |
|
|
288
253
|
| `buildRouteUrl(template, context)` | Substitute `:param` placeholders in a route template using context values |
|
|
289
254
|
|
|
290
255
|
---
|
|
291
256
|
|
|
257
|
+
## Inspection
|
|
258
|
+
|
|
259
|
+
`options.inspect` is forwarded verbatim to XState's `createActor`, so every XState
|
|
260
|
+
inspection tool — [`@statelyai/inspect`](https://stately.ai/docs/inspector)
|
|
261
|
+
included — works against a `PlayerActor` unchanged:
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import { createBrowserInspector } from "@statelyai/inspect";
|
|
265
|
+
|
|
266
|
+
const { inspect } = createBrowserInspector();
|
|
267
|
+
const createPlayer = definePlayer({ machine, options: { inspect } });
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Three things are worth knowing:
|
|
271
|
+
|
|
272
|
+
- **It is a factory option, not a per-instance one.** Every actor a factory creates
|
|
273
|
+
reports to the same observer. Demultiplex by root: `event.rootId === actor.sessionId`
|
|
274
|
+
covers an actor's whole tree, children included.
|
|
275
|
+
- **It is the only route that sees construction.** `actor.system.inspect(fn)` attaches
|
|
276
|
+
later and only sees events from that point on — including missing the `@xstate.actor`
|
|
277
|
+
registration an inspector needs in order to draw the machine at all.
|
|
278
|
+
- **A `PlayerActor` is the actor.** Its own events carry `actorRef === playerActor`, so a
|
|
279
|
+
player can be recognised by identity. The one caveat: `@xstate.actor` fires from inside
|
|
280
|
+
the constructor, where `state`, `currentRoute`, `currentView` and `initialRoute` do not
|
|
281
|
+
exist yet — reading them there throws.
|
|
282
|
+
|
|
283
|
+
For an inspector created after the factory (a dev-tools toggle, say), pass a forwarding
|
|
284
|
+
function: `inspect: (event) => currentInspector?.(event)`.
|
|
285
|
+
|
|
286
|
+
See the [inspector guide](../../../guides/inspector.md) for the full walkthrough —
|
|
287
|
+
late attachment with replay, browser-free WebSocket inspection, and production
|
|
288
|
+
considerations.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
292
|
## Exported Types
|
|
293
293
|
|
|
294
294
|
```typescript
|
|
295
295
|
import type {
|
|
296
296
|
PlayerConfig, // definePlayer() config argument shape
|
|
297
|
-
PlayerOptions, // Lifecycle hooks (onStart, onStop, onTransition, onStateChange, onError)
|
|
297
|
+
PlayerOptions, // Lifecycle hooks (onStart, onStop, onTransition, onStateChange, onError) + inspect
|
|
298
298
|
PlayerFactory, // Factory function returned by definePlayer()
|
|
299
299
|
PlayerFactoryResumeOptions, // { snapshot? } for restoring actor state
|
|
300
|
-
Guard, //
|
|
301
|
-
GuardArray, //
|
|
302
|
-
ComposedGuard, //
|
|
300
|
+
Guard, // deprecated with the guard utilities — removed in the next major
|
|
301
|
+
GuardArray, // deprecated with the guard utilities — removed in the next major
|
|
302
|
+
ComposedGuard, // deprecated with the guard utilities — removed in the next major
|
|
303
303
|
RouteMachineConfig, // Minimal machine config accepted by formatPlayRouteTransitions
|
|
304
304
|
RouteStateNode, // Single state node shape used during route crawling
|
|
305
305
|
RouteContext, // Context shape expected by buildRouteUrl ({ params?, query?, basePath?, hash? })
|
|
@@ -317,14 +317,13 @@ Error classes are exported from the `@xmachines/play-xstate/errors` sub-path to
|
|
|
317
317
|
```typescript
|
|
318
318
|
import {
|
|
319
319
|
MissingRouteParamError, // Required :param absent from context when resolving currentRoute
|
|
320
|
-
MissingQueryContextError, //
|
|
320
|
+
MissingQueryContextError, // deprecated: no longer thrown
|
|
321
321
|
MissingStateIdError, // meta.route declared without a state id field
|
|
322
322
|
InvalidMachineError, // PlayerActor constructed with a non-object machine
|
|
323
323
|
InvalidEventError, // actor.send() called with null/undefined/non-object
|
|
324
|
+
ActorThrewNonErrorError, // actor failed with a thrown value that is not an Error
|
|
324
325
|
InvalidRouteMetadataError, // meta.route is neither a string nor { path: string }
|
|
325
326
|
EmptyGuardArrayError, // composeGuards/composeGuardsOr called with empty array
|
|
326
|
-
UnresolvableGuardNameError, // string guard name could not be resolved at call time
|
|
327
|
-
InvalidGuardEntryError, // guard entry was neither a predicate nor a name (e.g. undefined)
|
|
328
327
|
} from "@xmachines/play-xstate/errors";
|
|
329
328
|
```
|
|
330
329
|
|
|
@@ -350,7 +349,7 @@ Tests use [Vitest](https://vitest.dev/) and live in `packages/play-xstate/test/`
|
|
|
350
349
|
|
|
351
350
|
MIT — see [LICENSE](LICENSE) for details.
|
|
352
351
|
|
|
353
|
-
@xmachines/play-xstate - XState
|
|
352
|
+
@xmachines/play-xstate - XState v5 adapter for Play Architecture
|
|
354
353
|
|
|
355
354
|
Provides definePlayer() API for binding XState state machines to the
|
|
356
355
|
actor base with signal lifecycle and DevTools integration.
|
|
@@ -373,34 +372,24 @@ reactivity.
|
|
|
373
372
|
|
|
374
373
|
## Type Aliases
|
|
375
374
|
|
|
376
|
-
- [ComposedGuard](type-aliases/ComposedGuard.md)
|
|
377
|
-
- [Guard](type-aliases/Guard.md)
|
|
378
|
-
- [GuardArray](type-aliases/GuardArray.md)
|
|
375
|
+
- [~~ComposedGuard~~](type-aliases/ComposedGuard.md)
|
|
376
|
+
- [~~Guard~~](type-aliases/Guard.md)
|
|
377
|
+
- [~~GuardArray~~](type-aliases/GuardArray.md)
|
|
379
378
|
- [PlayerFactory](type-aliases/PlayerFactory.md)
|
|
380
|
-
- [PlayRoutePayload](type-aliases/PlayRoutePayload.md)
|
|
381
379
|
- [RouteMachineConfig](type-aliases/RouteMachineConfig.md)
|
|
382
380
|
- [RouteMetadata](type-aliases/RouteMetadata.md)
|
|
383
381
|
- [RouteStateNode](type-aliases/RouteStateNode.md)
|
|
384
|
-
- [SetupLike](type-aliases/SetupLike.md)
|
|
385
|
-
- [WithOptional](type-aliases/WithOptional.md)
|
|
386
|
-
|
|
387
|
-
## Variables
|
|
388
|
-
|
|
389
|
-
- [emptyEventSchema](variables/emptyEventSchema.md)
|
|
390
|
-
- [playMetaSchema](variables/playMetaSchema.md)
|
|
391
|
-
- [playRouteEventSchema](variables/playRouteEventSchema.md)
|
|
392
382
|
|
|
393
383
|
## Functions
|
|
394
384
|
|
|
395
385
|
- [buildRouteUrl](functions/buildRouteUrl.md)
|
|
396
|
-
- [composeGuards](functions/composeGuards.md)
|
|
397
|
-
- [composeGuardsOr](functions/composeGuardsOr.md)
|
|
398
|
-
- [contextFieldMatches](functions/contextFieldMatches.md)
|
|
399
|
-
- [createRoutedMachine](functions/createRoutedMachine.md)
|
|
386
|
+
- [~~composeGuards~~](functions/composeGuards.md)
|
|
387
|
+
- [~~composeGuardsOr~~](functions/composeGuardsOr.md)
|
|
388
|
+
- [~~contextFieldMatches~~](functions/contextFieldMatches.md)
|
|
400
389
|
- [definePlayer](functions/definePlayer.md)
|
|
401
390
|
- [deriveRoute](functions/deriveRoute.md)
|
|
402
|
-
- [eventMatches](functions/eventMatches.md)
|
|
391
|
+
- [~~eventMatches~~](functions/eventMatches.md)
|
|
403
392
|
- [formatPlayRouteTransitions](functions/formatPlayRouteTransitions.md)
|
|
404
|
-
- [hasContext](functions/hasContext.md)
|
|
393
|
+
- [~~hasContext~~](functions/hasContext.md)
|
|
405
394
|
- [isAbsoluteRoute](functions/isAbsoluteRoute.md)
|
|
406
|
-
- [negateGuard](functions/negateGuard.md)
|
|
395
|
+
- [~~negateGuard~~](functions/negateGuard.md)
|