@xmachines/docs 2.0.0-alpha.1 → 2.1.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 +16 -17
- package/api/@xmachines/play/README.md +58 -66
- package/api/@xmachines/play/classes/NonNullableError.md +14 -14
- package/api/@xmachines/play/classes/PlayError.md +32 -34
- package/api/@xmachines/play/functions/assertNonNullable.md +17 -17
- package/api/@xmachines/play/type-aliases/PlayEvent.md +28 -27
- package/api/@xmachines/play-actor/README.md +114 -50
- package/api/@xmachines/play-actor/classes/AbstractActor.md +45 -30
- package/api/@xmachines/play-actor/functions/attachRenderErrorHandler.md +19 -18
- package/api/@xmachines/play-actor/functions/composePlayState.md +27 -0
- package/api/@xmachines/play-actor/functions/createViewStoreLifecycle.md +21 -0
- package/api/@xmachines/play-actor/functions/guardContextWrites.md +43 -0
- package/api/@xmachines/play-actor/functions/refreshContextSubtree.md +28 -0
- package/api/@xmachines/play-actor/functions/reuseComposedState.md +42 -0
- package/api/@xmachines/play-actor/functions/shallowEqualExcept.md +29 -0
- package/api/@xmachines/play-actor/functions/toAtomState.md +16 -14
- package/api/@xmachines/play-actor/functions/typedSpec.md +25 -27
- package/api/@xmachines/play-actor/interfaces/BaseActorProviderProps.md +17 -15
- package/api/@xmachines/play-actor/interfaces/BaseViewContextValue.md +15 -14
- package/api/@xmachines/play-actor/interfaces/PlaySpec.md +13 -15
- package/api/@xmachines/play-actor/interfaces/ResolveViewStoreOptions.md +11 -0
- package/api/@xmachines/play-actor/interfaces/Routable.md +6 -6
- 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 +9 -9
- package/api/@xmachines/play-actor/variables/CONTEXT_STATE_KEY.md +15 -0
- package/api/@xmachines/play-dom/README.md +123 -86
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +34 -32
- package/api/@xmachines/play-dom/functions/createPlayUI.md +10 -10
- package/api/@xmachines/play-dom/functions/createRenderer.md +21 -17
- 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 +16 -16
- 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 +9 -9
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +17 -17
- 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 +5 -5
- package/api/@xmachines/play-dom/variables/schema.md +35 -45
- package/api/@xmachines/play-dom-router/README.md +68 -51
- package/api/@xmachines/play-dom-router/classes/DomRouterBridge.md +116 -0
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +4 -3
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +16 -14
- package/api/@xmachines/play-dom-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-dom-router/functions/createRouter.md +14 -14
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +25 -26
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +21 -20
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +7 -7
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +18 -17
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +9 -9
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +39 -38
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +7 -7
- package/api/@xmachines/play-react/README.md +65 -55
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +14 -13
- 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 +4 -4
- package/api/@xmachines/play-react/functions/useSignalEffect.md +39 -39
- package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +11 -11
- package/api/@xmachines/play-react/interfaces/ComponentContext.md +9 -8
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +7 -7
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +6 -6
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +14 -14
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-react/type-aliases/AnyPlayActor.md +2 -2
- package/api/@xmachines/play-react/type-aliases/PlayRendererProps.md +13 -0
- package/api/@xmachines/play-react/variables/ActorProvider.md +9 -8
- package/api/@xmachines/play-react/variables/PlayRenderer.md +5 -4
- package/api/@xmachines/play-react/variables/PlayUIProvider.md +6 -6
- package/api/@xmachines/play-react-router/README.md +38 -31
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +22 -19
- package/api/@xmachines/play-react-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-react-router/functions/createPlayRouterProvider.md +16 -14
- package/api/@xmachines/play-react-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +18 -18
- package/api/@xmachines/play-react-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderBaseProps.md +12 -12
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +11 -11
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterBridgeConstructor.md +2 -2
- package/api/@xmachines/play-react-router/variables/PlayRouterProvider.md +7 -6
- package/api/@xmachines/play-router/README.md +99 -95
- package/api/@xmachines/play-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +29 -23
- package/api/@xmachines/play-router/functions/buildPlayRouteEvent.md +6 -5
- package/api/@xmachines/play-router/functions/buildRouteTree.md +16 -15
- package/api/@xmachines/play-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-router/functions/createRouteMapFromTree.md +18 -18
- package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +18 -17
- package/api/@xmachines/play-router/functions/extractMachineRoutes.md +11 -10
- package/api/@xmachines/play-router/functions/extractQuery.md +3 -3
- package/api/@xmachines/play-router/functions/extractRouteParams.md +22 -19
- package/api/@xmachines/play-router/functions/findRouteById.md +10 -9
- package/api/@xmachines/play-router/functions/findRouteByPath.md +14 -12
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +9 -9
- package/api/@xmachines/play-router/functions/getRoutableRoutes.md +9 -9
- package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +16 -15
- package/api/@xmachines/play-router/functions/isRouteReachable.md +12 -11
- package/api/@xmachines/play-router/functions/machineToGraph.md +1 -1
- package/api/@xmachines/play-router/functions/routeExists.md +8 -8
- package/api/@xmachines/play-router/functions/sanitizePathname.md +15 -13
- package/api/@xmachines/play-router/functions/validateRouteFormat.md +10 -10
- package/api/@xmachines/play-router/functions/validateStateExists.md +9 -9
- package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +6 -6
- package/api/@xmachines/play-router/interfaces/LocationLike.md +11 -11
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +7 -9
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +9 -9
- package/api/@xmachines/play-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-router/interfaces/ResolvedRoutePath.md +7 -7
- package/api/@xmachines/play-router/interfaces/RoutableActor.md +18 -17
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +11 -11
- package/api/@xmachines/play-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +5 -5
- package/api/@xmachines/play-router/interfaces/RouteNode.md +13 -13
- package/api/@xmachines/play-router/interfaces/RouteObject.md +6 -6
- package/api/@xmachines/play-router/interfaces/RouteTree.md +11 -11
- package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +13 -13
- package/api/@xmachines/play-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-router/interfaces/WindowLike.md +10 -10
- package/api/@xmachines/play-router/type-aliases/BaseRouteMapping.md +13 -0
- package/api/@xmachines/play-router/type-aliases/MachineGraph.md +4 -3
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +2 -2
- package/api/@xmachines/play-signals/README.md +38 -36
- package/api/@xmachines/play-signals/functions/watchSignal.md +15 -15
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +6 -6
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +10 -10
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +6 -6
- package/api/@xmachines/play-signals/interfaces/SignalState.md +13 -13
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +18 -18
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +6 -5
- package/api/@xmachines/play-solid/README.md +46 -42
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/functions/usePlayView.md +3 -3
- package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +13 -13
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +14 -14
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +9 -9
- package/api/@xmachines/play-solid/type-aliases/AnyPlayActor.md +2 -2
- package/api/@xmachines/play-solid/variables/ActorContext.md +5 -4
- package/api/@xmachines/play-solid/variables/ActorProvider.md +8 -7
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +6 -4
- package/api/@xmachines/play-solid/variables/PlayUIProvider.md +7 -7
- package/api/@xmachines/play-solid-router/README.md +39 -34
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +43 -34
- package/api/@xmachines/play-solid-router/functions/createPlayRouterProvider.md +15 -13
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +45 -30
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderBaseProps.md +10 -10
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +11 -11
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterBridgeConstructor.md +5 -5
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +2 -2
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +11 -11
- package/api/@xmachines/play-solid-router/variables/PlayRouterProvider.md +9 -8
- package/api/@xmachines/play-svelte/README.md +60 -33
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +9 -8
- package/api/@xmachines/play-svelte/functions/getActorContext.md +5 -4
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +3 -3
- package/api/@xmachines/play-svelte/functions/setActorContext.md +1 -1
- package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +17 -15
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +9 -9
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +20 -18
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +12 -11
- package/api/@xmachines/play-svelte/type-aliases/AnyPlayActor.md +2 -2
- package/api/@xmachines/play-svelte-spa-router/README.md +43 -52
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-svelte-spa-router/classes/SvelteSpaRouterBridge.md +133 -0
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +7 -7
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +10 -10
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-sveltekit-router/README.md +43 -39
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-sveltekit-router/classes/SvelteKitRouterBridge.md +132 -0
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +3 -3
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +6 -6
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +11 -11
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/README.md +67 -49
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +43 -38
- package/api/@xmachines/play-tanstack-react-router/functions/createPlayRouterProvider.md +16 -14
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +18 -18
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +11 -10
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderBaseProps.md +12 -12
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +11 -11
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +16 -11
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterBridgeConstructor.md +2 -2
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +15 -13
- package/api/@xmachines/play-tanstack-react-router/variables/PlayRouterProvider.md +9 -8
- package/api/@xmachines/play-tanstack-router/README.md +38 -16
- package/api/@xmachines/play-tanstack-router/classes/TanStackRouterBridgeBase.md +43 -38
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouteMapLike.md +9 -9
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouterLike.md +15 -13
- package/api/@xmachines/play-tanstack-solid-router/README.md +76 -50
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-tanstack-solid-router/classes/TanStackSolidRouterBridge.md +38 -30
- package/api/@xmachines/play-tanstack-solid-router/functions/createPlayRouterProvider.md +15 -13
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderBaseProps.md +11 -11
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +9 -9
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterBridgeConstructor.md +2 -2
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +2 -2
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +15 -13
- package/api/@xmachines/play-tanstack-solid-router/variables/PlayRouterProvider.md +7 -7
- package/api/@xmachines/play-vue/README.md +39 -39
- package/api/@xmachines/play-vue/functions/defineRegistry.md +10 -9
- 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/functions/usePlayView.md +28 -0
- package/api/@xmachines/play-vue/interfaces/ActorProviderProps.md +10 -9
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +13 -12
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +10 -9
- package/api/@xmachines/play-vue/interfaces/VisibilityProviderProps.md +6 -2
- package/api/@xmachines/play-vue/type-aliases/AnyPlayActor.md +2 -2
- 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/variables/getPlayViewContext.md +34 -0
- package/api/@xmachines/play-vue-router/README.md +66 -57
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +50 -48
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +26 -19
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +12 -11
- package/api/@xmachines/play-vue-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +41 -35
- package/api/@xmachines/play-vue-router/interfaces/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +11 -10
- package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +27 -24
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +2 -2
- package/api/@xmachines/play-vue-router/type-aliases/VueRouteMap.md +13 -0
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +5 -5
- package/api/@xmachines/play-vue-router/variables/VueRouteMap.md +13 -0
- package/api/@xmachines/play-xstate/README.md +129 -138
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +148 -114
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +19 -23
- package/api/@xmachines/play-xstate/functions/composeGuards.md +34 -33
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +27 -22
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +19 -14
- package/api/@xmachines/play-xstate/functions/definePlayer.md +19 -19
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +26 -25
- package/api/@xmachines/play-xstate/functions/eventMatches.md +12 -7
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +17 -48
- package/api/@xmachines/play-xstate/functions/hasContext.md +12 -9
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +10 -10
- package/api/@xmachines/play-xstate/functions/negateGuard.md +26 -20
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +6 -6
- package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +7 -7
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +10 -11
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +15 -14
- 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 +13 -11
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +8 -5
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +11 -15
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +12 -19
- package/api/@xmachines/play-xstate/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +15 -26
- package/api/@xmachines/shared/README.md +12 -14
- 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 +90 -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-vue/functions/getPlayViewContext.md +0 -28
- 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
|
@@ -1,15 +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
|
|
8
|
-
|
|
9
|
-
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://www.npmjs.com/package/@xmachines/play-xstate)
|
|
5
|
+
> XState v5 adapter for the XMachines Play Architecture. It binds a state machine to the actor base, with signal-driven reactivity and a router integration.
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-xstate)
|
|
13
8
|
|
|
14
9
|
---
|
|
15
10
|
|
|
@@ -19,7 +14,7 @@ Part of the [XMachines Play](../../README.md) monorepo.
|
|
|
19
14
|
pnpm add @xmachines/play-xstate xstate
|
|
20
15
|
```
|
|
21
16
|
|
|
22
|
-
`xstate ^
|
|
17
|
+
`xstate ^5.31.0` is a peer dependency. Install it with this package.
|
|
23
18
|
|
|
24
19
|
---
|
|
25
20
|
|
|
@@ -27,18 +22,13 @@ pnpm add @xmachines/play-xstate xstate
|
|
|
27
22
|
|
|
28
23
|
```typescript
|
|
29
24
|
import { setup } from "xstate";
|
|
30
|
-
import { definePlayer
|
|
25
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
31
26
|
|
|
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({
|
|
27
|
+
// 1. Define your XState v5 machine
|
|
28
|
+
const machine = setup({}).createMachine({
|
|
39
29
|
initial: "idle",
|
|
40
30
|
states: {
|
|
41
|
-
idle: { meta: { route: "/" }, on: { activate:
|
|
31
|
+
idle: { meta: { route: "/" }, on: { activate: "active" } },
|
|
42
32
|
active: { meta: { route: "/active" } },
|
|
43
33
|
},
|
|
44
34
|
});
|
|
@@ -66,16 +56,16 @@ actor.stop();
|
|
|
66
56
|
|
|
67
57
|
### `definePlayer(config)`
|
|
68
58
|
|
|
69
|
-
|
|
59
|
+
This function creates a `PlayerFactory` from an XState v5 machine. One configuration can therefore make more than one independent actor instance. This helps with a multi-user application, with SSR, and with a test.
|
|
70
60
|
|
|
71
61
|
```typescript
|
|
72
|
-
import { setup
|
|
62
|
+
import { setup } from "xstate";
|
|
73
63
|
import { definePlayer } from "@xmachines/play-xstate";
|
|
74
64
|
|
|
75
65
|
const machine = setup({
|
|
76
|
-
|
|
77
|
-
context:
|
|
78
|
-
input:
|
|
66
|
+
types: {
|
|
67
|
+
context: {} as { userId: string },
|
|
68
|
+
input: {} as { userId: string },
|
|
79
69
|
},
|
|
80
70
|
}).createMachine({
|
|
81
71
|
context: ({ input }) => ({ userId: input.userId }),
|
|
@@ -91,6 +81,7 @@ const createPlayer = definePlayer({
|
|
|
91
81
|
onTransition: (actor, prev, next) => console.log("transitioned"),
|
|
92
82
|
onStateChange: (actor, state) => console.log("state changed"),
|
|
93
83
|
onError: (actor, err) => console.error(err),
|
|
84
|
+
inspect: (event) => console.log(event.type), // handed to XState's actor constructor — enables @statelyai/inspect
|
|
94
85
|
},
|
|
95
86
|
});
|
|
96
87
|
|
|
@@ -101,17 +92,27 @@ const bob = createPlayer({ userId: "bob" });
|
|
|
101
92
|
|
|
102
93
|
#### `PlayerFactory` signature
|
|
103
94
|
|
|
95
|
+
The `input` argument follows the rule of `createActor` in XState. If the input type of a
|
|
96
|
+
machine cannot be `undefined`, the first argument of the factory is necessary. An absent
|
|
97
|
+
input is then a compile error, not an actor that stops in an error status.
|
|
98
|
+
|
|
104
99
|
```typescript
|
|
105
|
-
type PlayerFactory<TMachine> =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
type PlayerFactory<TMachine> =
|
|
101
|
+
undefined extends InputFrom<TMachine>
|
|
102
|
+
? (
|
|
103
|
+
input?: InputFrom<TMachine>,
|
|
104
|
+
options?: PlayerFactoryResumeOptions<TMachine>,
|
|
105
|
+
) => PlayerActor<TMachine>
|
|
106
|
+
: (
|
|
107
|
+
input: InputFrom<TMachine>,
|
|
108
|
+
options?: PlayerFactoryResumeOptions<TMachine>,
|
|
109
|
+
) => PlayerActor<TMachine>;
|
|
109
110
|
```
|
|
110
111
|
|
|
111
112
|
#### Restoring from a snapshot
|
|
112
113
|
|
|
113
114
|
```typescript
|
|
114
|
-
const snapshot = actor.
|
|
115
|
+
const snapshot = actor.getPersistedSnapshot();
|
|
115
116
|
actor.stop();
|
|
116
117
|
|
|
117
118
|
// Restore to the exact saved state
|
|
@@ -120,31 +121,35 @@ restored.start();
|
|
|
120
121
|
console.log(restored.currentRoute.get()); // same route as when saved
|
|
121
122
|
```
|
|
122
123
|
|
|
124
|
+
> **Note:** persist the state with `getPersistedSnapshot()`, not with
|
|
125
|
+
> `getSnapshot()`. `createActor` accepts that form only, and it is the only form
|
|
126
|
+
> that restores a machine with an invoked child or a spawned child.
|
|
127
|
+
|
|
123
128
|
---
|
|
124
129
|
|
|
125
130
|
### `PlayerActor<TMachine>`
|
|
126
131
|
|
|
127
|
-
|
|
132
|
+
This concrete actor class is an XState v5 actor that also exposes reactive TC39 Signals. It implements both the `Routable` interface and the `Viewable` interface from `@xmachines/play-actor`.
|
|
128
133
|
|
|
129
134
|
#### Signals
|
|
130
135
|
|
|
131
|
-
| Signal | Type | Description
|
|
132
|
-
| -------------- | -------------------------------------- |
|
|
133
|
-
| `state` | `Signal.State<SnapshotFrom<TMachine>>` |
|
|
134
|
-
| `currentRoute` | `Signal.Computed<string \| null>` |
|
|
135
|
-
| `currentView` | `Signal.State<PlaySpec \| null>` |
|
|
136
|
-
| `initialRoute` | `readonly string \| null` |
|
|
136
|
+
| Signal | Type | Description |
|
|
137
|
+
| -------------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
138
|
+
| `state` | `Signal.State<SnapshotFrom<TMachine>>` | The current XState snapshot. The actor updates it on every active transition |
|
|
139
|
+
| `currentRoute` | `Signal.Computed<string \| null>` | The URL that comes from the `meta.route` template of the active state and from the context |
|
|
140
|
+
| `currentView` | `Signal.State<PlaySpec \| null>` | The view spec from the `meta.view` metadata of the active state, with the context params added |
|
|
141
|
+
| `initialRoute` | `readonly string \| null` | The route of the initial state of the machine. The constructor fixes it, and a router bridge uses it to detect a deep link or a restore |
|
|
137
142
|
|
|
138
143
|
#### Methods
|
|
139
144
|
|
|
140
|
-
| Method | Description
|
|
141
|
-
| --------------- |
|
|
142
|
-
| `start()` |
|
|
143
|
-
| `stop()` |
|
|
144
|
-
| `send(event)` |
|
|
145
|
-
| `can(event)` | Returns `true`
|
|
146
|
-
| `getSnapshot()` | Returns the current XState snapshot
|
|
147
|
-
| `dispose()` |
|
|
145
|
+
| Method | Description |
|
|
146
|
+
| --------------- | ------------------------------------------------------------------------- |
|
|
147
|
+
| `start()` | Starts the actor and calls the `onStart` hook |
|
|
148
|
+
| `stop()` | Stops the actor, cleans up the subscriptions, and calls the `onStop` hook |
|
|
149
|
+
| `send(event)` | Sends a typed event to the machine and calls the `onTransition` hook |
|
|
150
|
+
| `can(event)` | Returns `true` when the current state accepts the given event |
|
|
151
|
+
| `getSnapshot()` | Returns the current XState snapshot |
|
|
152
|
+
| `dispose()` | The alias of `stop()` |
|
|
148
153
|
|
|
149
154
|
#### Signal usage example
|
|
150
155
|
|
|
@@ -165,7 +170,12 @@ actor.start();
|
|
|
165
170
|
|
|
166
171
|
### Guard utilities
|
|
167
172
|
|
|
168
|
-
|
|
173
|
+
> **Deprecated:** these guard helpers wrap the `and()`, `or()`, and `not()`
|
|
174
|
+
> combinators of XState, but they do not compose with a guard slot that
|
|
175
|
+
> `setup()` types. Use the combinators of XState directly. The next major
|
|
176
|
+
> version removes this module.
|
|
177
|
+
|
|
178
|
+
These composable guard helpers wrap the `and()`, `or()`, and `not()` functions of XState. Use them in a machine `setup({ guards })` definition.
|
|
169
179
|
|
|
170
180
|
```typescript
|
|
171
181
|
import { setup } from "xstate";
|
|
@@ -178,24 +188,20 @@ import {
|
|
|
178
188
|
contextFieldMatches, // guard: context field equals a value
|
|
179
189
|
} from "@xmachines/play-xstate";
|
|
180
190
|
|
|
181
|
-
const canAccessAdmin = composeGuards(["isLoggedIn", "hasAdminRole"]);
|
|
182
|
-
const isAuthenticated = negateGuard("isGuest");
|
|
183
|
-
|
|
184
191
|
const machine = setup({
|
|
185
192
|
guards: {
|
|
186
193
|
isLoggedIn: ({ context }) => !!context.userId,
|
|
187
194
|
hasAdminRole: ({ context }) => context.role === "admin",
|
|
188
|
-
isGuest: ({ context }) => !context.userId,
|
|
189
195
|
},
|
|
190
196
|
}).createMachine({
|
|
191
197
|
on: {
|
|
192
|
-
accessAdmin:
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
accessAdmin: {
|
|
199
|
+
guard: composeGuards(["isLoggedIn", "hasAdminRole"]),
|
|
200
|
+
target: "adminPanel",
|
|
195
201
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
accessLogin: {
|
|
203
|
+
guard: negateGuard("isLoggedIn"),
|
|
204
|
+
target: "login",
|
|
199
205
|
},
|
|
200
206
|
},
|
|
201
207
|
// ...
|
|
@@ -206,19 +212,17 @@ const machine = setup({
|
|
|
206
212
|
|
|
207
213
|
### Routing utilities
|
|
208
214
|
|
|
209
|
-
|
|
215
|
+
These helper functions configure the routes of an XState machine declaratively.
|
|
210
216
|
|
|
211
|
-
#### `
|
|
217
|
+
#### `formatPlayRouteTransitions(machineConfig)`
|
|
212
218
|
|
|
213
|
-
|
|
219
|
+
This function reads each machine state that has a `meta.route` field. It then generates the `play.route` event handlers at the root level. You therefore write no repetitive routing transition.
|
|
214
220
|
|
|
215
221
|
```typescript
|
|
216
222
|
import { setup } from "xstate";
|
|
217
|
-
import {
|
|
218
|
-
|
|
219
|
-
const appSetup = setup({/* schemas, guards, ... */});
|
|
223
|
+
import { formatPlayRouteTransitions } from "@xmachines/play-xstate";
|
|
220
224
|
|
|
221
|
-
const
|
|
225
|
+
const config = formatPlayRouteTransitions({
|
|
222
226
|
id: "app",
|
|
223
227
|
states: {
|
|
224
228
|
home: {
|
|
@@ -231,61 +235,58 @@ const machine = createRoutedMachine(appSetup)({
|
|
|
231
235
|
},
|
|
232
236
|
},
|
|
233
237
|
});
|
|
238
|
+
|
|
239
|
+
// config now includes auto-generated play.route handlers:
|
|
240
|
+
// on: { "play.route": [ { target: ".home", guard: e => e.to === "#home" }, ... ] }
|
|
241
|
+
const machine = setup({}).createMachine(config);
|
|
234
242
|
```
|
|
235
243
|
|
|
236
|
-
|
|
244
|
+
> **Note:** every state with a `meta.route` field must also have an explicit `id` field. A state without an `id` field throws `MissingStateIdError` when you define the machine.
|
|
237
245
|
|
|
238
|
-
|
|
246
|
+
#### Other routing exports
|
|
239
247
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
playRouteEventSchema,
|
|
246
|
-
} from "@xmachines/play-xstate";
|
|
248
|
+
| Export | Description |
|
|
249
|
+
| ---------------------------------- | --------------------------------------------------------------------------- |
|
|
250
|
+
| `deriveRoute(meta)` | Reads the route template string from the metadata object of a state |
|
|
251
|
+
| `isAbsoluteRoute(route)` | Returns `true` when the route string is an absolute URL path |
|
|
252
|
+
| `buildRouteUrl(template, context)` | Replaces each `:param` placeholder of a route template with a context value |
|
|
247
253
|
|
|
248
|
-
|
|
249
|
-
id: "app",
|
|
250
|
-
states: {
|
|
251
|
-
home: {
|
|
252
|
-
id: "home",
|
|
253
|
-
meta: { route: "/home" },
|
|
254
|
-
},
|
|
255
|
-
profile: {
|
|
256
|
-
id: "profile",
|
|
257
|
-
meta: { route: "/users/:userId" },
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
});
|
|
254
|
+
---
|
|
261
255
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
})
|
|
256
|
+
## Inspection
|
|
257
|
+
|
|
258
|
+
The factory gives `options.inspect` to `createActor` of XState without a change.
|
|
259
|
+
Therefore every XState inspection tool works with a `PlayerActor`, and this
|
|
260
|
+
includes [`@statelyai/inspect`](https://stately.ai/docs/inspector):
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
import { createBrowserInspector } from "@statelyai/inspect";
|
|
264
|
+
|
|
265
|
+
const { inspect } = createBrowserInspector();
|
|
266
|
+
const createPlayer = definePlayer({ machine, options: { inspect } });
|
|
273
267
|
```
|
|
274
268
|
|
|
275
|
-
|
|
269
|
+
Three points are important:
|
|
276
270
|
|
|
277
|
-
|
|
271
|
+
- **`inspect` is an option of the factory, not of one instance.** Every actor of a
|
|
272
|
+
factory reports to the same observer. Separate the actors by root:
|
|
273
|
+
`event.rootId === actor.sessionId` covers the complete tree of an actor, with its
|
|
274
|
+
children.
|
|
275
|
+
- **`inspect` is the only path that sees the construction.** `actor.system.inspect(fn)`
|
|
276
|
+
attaches later, and it sees only the events after that moment. It therefore misses the
|
|
277
|
+
`@xstate.actor` registration, and an inspector needs that registration to draw the
|
|
278
|
+
machine.
|
|
279
|
+
- **A `PlayerActor` is the actor.** Its own events carry `actorRef === playerActor`, so
|
|
280
|
+
you can recognize a player by its identity. Note one point: `@xstate.actor` fires from
|
|
281
|
+
inside the constructor, and `state`, `currentRoute`, `currentView`, and `initialRoute`
|
|
282
|
+
do not exist yet. A read of one of them there throws.
|
|
278
283
|
|
|
279
|
-
|
|
284
|
+
For an inspector that you create after the factory, such as a dev-tools switch, give the
|
|
285
|
+
factory a function that forwards each event: `inspect: (event) => currentInspector?.(event)`.
|
|
280
286
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
| `deriveRoute(meta)` | Extract the route template string from a state's metadata object |
|
|
287
|
-
| `isAbsoluteRoute(route)` | Returns `true` if the route string is an absolute URL path |
|
|
288
|
-
| `buildRouteUrl(template, context)` | Substitute `:param` placeholders in a route template using context values |
|
|
287
|
+
The [inspector guide](../../../guides/inspector.md) gives the complete procedure: a late
|
|
288
|
+
attachment with a replay, a WebSocket inspection without a browser, and the points to
|
|
289
|
+
consider in production.
|
|
289
290
|
|
|
290
291
|
---
|
|
291
292
|
|
|
@@ -294,12 +295,12 @@ Because the injected `route` configs are static, route transitions keep statical
|
|
|
294
295
|
```typescript
|
|
295
296
|
import type {
|
|
296
297
|
PlayerConfig, // definePlayer() config argument shape
|
|
297
|
-
PlayerOptions, // Lifecycle hooks (onStart, onStop, onTransition, onStateChange, onError)
|
|
298
|
+
PlayerOptions, // Lifecycle hooks (onStart, onStop, onTransition, onStateChange, onError) + inspect
|
|
298
299
|
PlayerFactory, // Factory function returned by definePlayer()
|
|
299
300
|
PlayerFactoryResumeOptions, // { snapshot? } for restoring actor state
|
|
300
|
-
Guard, //
|
|
301
|
-
GuardArray, //
|
|
302
|
-
ComposedGuard, //
|
|
301
|
+
Guard, // deprecated with the guard utilities — removed in the next major
|
|
302
|
+
GuardArray, // deprecated with the guard utilities — removed in the next major
|
|
303
|
+
ComposedGuard, // deprecated with the guard utilities — removed in the next major
|
|
303
304
|
RouteMachineConfig, // Minimal machine config accepted by formatPlayRouteTransitions
|
|
304
305
|
RouteStateNode, // Single state node shape used during route crawling
|
|
305
306
|
RouteContext, // Context shape expected by buildRouteUrl ({ params?, query?, basePath?, hash? })
|
|
@@ -312,23 +313,22 @@ import type {
|
|
|
312
313
|
|
|
313
314
|
## Error Classes
|
|
314
315
|
|
|
315
|
-
|
|
316
|
+
The `@xmachines/play-xstate/errors` subpath exports the error classes. The main bundle therefore stays small.
|
|
316
317
|
|
|
317
318
|
```typescript
|
|
318
319
|
import {
|
|
319
320
|
MissingRouteParamError, // Required :param absent from context when resolving currentRoute
|
|
320
|
-
MissingQueryContextError, //
|
|
321
|
+
MissingQueryContextError, // deprecated: no longer thrown
|
|
321
322
|
MissingStateIdError, // meta.route declared without a state id field
|
|
322
323
|
InvalidMachineError, // PlayerActor constructed with a non-object machine
|
|
323
324
|
InvalidEventError, // actor.send() called with null/undefined/non-object
|
|
325
|
+
ActorThrewNonErrorError, // actor failed with a thrown value that is not an Error
|
|
324
326
|
InvalidRouteMetadataError, // meta.route is neither a string nor { path: string }
|
|
325
327
|
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
328
|
} from "@xmachines/play-xstate/errors";
|
|
329
329
|
```
|
|
330
330
|
|
|
331
|
-
|
|
331
|
+
Every error class extends `PlayError` from `@xmachines/play`. Each class also carries typed detail fields, such as `param`, `template`, and `combinator`. Your code therefore reads the details of an error, and it does not parse the message.
|
|
332
332
|
|
|
333
333
|
---
|
|
334
334
|
|
|
@@ -342,7 +342,7 @@ pnpm --filter @xmachines/play-xstate test
|
|
|
342
342
|
pnpm --filter @xmachines/play-xstate run test:watch
|
|
343
343
|
```
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
The tests use [Vitest](https://vitest.dev/). They are in `packages/play-xstate/test/`.
|
|
346
346
|
|
|
347
347
|
---
|
|
348
348
|
|
|
@@ -350,13 +350,14 @@ Tests use [Vitest](https://vitest.dev/) and live in `packages/play-xstate/test/`
|
|
|
350
350
|
|
|
351
351
|
MIT — see [LICENSE](LICENSE) for details.
|
|
352
352
|
|
|
353
|
-
@xmachines/play-xstate - XState
|
|
353
|
+
@xmachines/play-xstate - the XState v5 adapter of the Play Architecture
|
|
354
354
|
|
|
355
|
-
|
|
356
|
-
actor base with signal lifecycle and DevTools
|
|
355
|
+
This package gives you the definePlayer() API. That function binds an XState state
|
|
356
|
+
machine to the actor base, with the signal lifecycle and the DevTools
|
|
357
|
+
integration.
|
|
357
358
|
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
The Play RFC gives this package as the adapter of the logic layer. It converts a
|
|
360
|
+
declarative machine definition into a live actor with a signal-driven
|
|
360
361
|
reactivity.
|
|
361
362
|
|
|
362
363
|
## Classes
|
|
@@ -373,34 +374,24 @@ reactivity.
|
|
|
373
374
|
|
|
374
375
|
## Type Aliases
|
|
375
376
|
|
|
376
|
-
- [ComposedGuard](type-aliases/ComposedGuard.md)
|
|
377
|
-
- [Guard](type-aliases/Guard.md)
|
|
378
|
-
- [GuardArray](type-aliases/GuardArray.md)
|
|
377
|
+
- [~~ComposedGuard~~](type-aliases/ComposedGuard.md)
|
|
378
|
+
- [~~Guard~~](type-aliases/Guard.md)
|
|
379
|
+
- [~~GuardArray~~](type-aliases/GuardArray.md)
|
|
379
380
|
- [PlayerFactory](type-aliases/PlayerFactory.md)
|
|
380
|
-
- [PlayRoutePayload](type-aliases/PlayRoutePayload.md)
|
|
381
381
|
- [RouteMachineConfig](type-aliases/RouteMachineConfig.md)
|
|
382
382
|
- [RouteMetadata](type-aliases/RouteMetadata.md)
|
|
383
383
|
- [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
384
|
|
|
393
385
|
## Functions
|
|
394
386
|
|
|
395
387
|
- [buildRouteUrl](functions/buildRouteUrl.md)
|
|
396
|
-
- [composeGuards](functions/composeGuards.md)
|
|
397
|
-
- [composeGuardsOr](functions/composeGuardsOr.md)
|
|
398
|
-
- [contextFieldMatches](functions/contextFieldMatches.md)
|
|
399
|
-
- [createRoutedMachine](functions/createRoutedMachine.md)
|
|
388
|
+
- [~~composeGuards~~](functions/composeGuards.md)
|
|
389
|
+
- [~~composeGuardsOr~~](functions/composeGuardsOr.md)
|
|
390
|
+
- [~~contextFieldMatches~~](functions/contextFieldMatches.md)
|
|
400
391
|
- [definePlayer](functions/definePlayer.md)
|
|
401
392
|
- [deriveRoute](functions/deriveRoute.md)
|
|
402
|
-
- [eventMatches](functions/eventMatches.md)
|
|
393
|
+
- [~~eventMatches~~](functions/eventMatches.md)
|
|
403
394
|
- [formatPlayRouteTransitions](functions/formatPlayRouteTransitions.md)
|
|
404
|
-
- [hasContext](functions/hasContext.md)
|
|
395
|
+
- [~~hasContext~~](functions/hasContext.md)
|
|
405
396
|
- [isAbsoluteRoute](functions/isAbsoluteRoute.md)
|
|
406
|
-
- [negateGuard](functions/negateGuard.md)
|
|
397
|
+
- [~~negateGuard~~](functions/negateGuard.md)
|