@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
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
function assertNonNullable<V>(value, name?): NonNullable<V>;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/play/src/utils.ts:39](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.
|
|
9
|
+
Defined in: [packages/play/src/utils.ts:39](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/utils.ts#L39)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
Asserts that `value` is not `null` and not `undefined`, then returns it with the
|
|
12
|
+
type `NonNullable<V>`. One expression therefore holds the guard and the narrowed
|
|
13
|
+
value.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
A non-null assertion (`value!`) is different: it produces `undefined`, and your
|
|
16
|
+
code then fails later with a message such as "undefined is not an object". This
|
|
17
|
+
function throws a clear error at the point of the failure.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
An assertion function of the form `asserts value is T` is also different: this
|
|
20
|
+
function returns the narrowed value directly. Therefore the call site needs no
|
|
21
|
+
second variable and no `as` cast.
|
|
22
22
|
|
|
23
23
|
## Type Parameters
|
|
24
24
|
|
|
@@ -28,16 +28,16 @@ site.
|
|
|
28
28
|
|
|
29
29
|
## Parameters
|
|
30
30
|
|
|
31
|
-
| Parameter | Type | Description
|
|
32
|
-
| --------- | -------- |
|
|
33
|
-
| `value` | `V` | The value to check.
|
|
34
|
-
| `name?` | `string` |
|
|
31
|
+
| Parameter | Type | Description |
|
|
32
|
+
| --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `value` | `V` | The value to check. |
|
|
34
|
+
| `name?` | `string` | The optional name in the error message. It identifies the missing value, for example the name of the variable or of the injection key. |
|
|
35
35
|
|
|
36
36
|
## Returns
|
|
37
37
|
|
|
38
38
|
`NonNullable`\<`V`\>
|
|
39
39
|
|
|
40
|
-
`value`
|
|
40
|
+
`value` with the type `NonNullable<V>`, without `null` and without `undefined`.
|
|
41
41
|
|
|
42
42
|
## Throws
|
|
43
43
|
|
|
@@ -48,9 +48,9 @@ When `value` is `null` or `undefined`.
|
|
|
48
48
|
```ts
|
|
49
49
|
import { assertNonNullable } from "@xmachines/play";
|
|
50
50
|
|
|
51
|
-
// inject()
|
|
51
|
+
// inject() and assertNonNullable in one line, with no `!` and no second variable:
|
|
52
52
|
const actor = assertNonNullable(inject<AuthActor>("actor"), "actor");
|
|
53
53
|
|
|
54
|
-
//
|
|
54
|
+
// A lookup of an element:
|
|
55
55
|
const el = assertNonNullable(document.getElementById("app"), "#app");
|
|
56
56
|
```
|
|
@@ -6,50 +6,51 @@
|
|
|
6
6
|
type PlayEvent<TPayload> = object & TPayload;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/play/src/types.ts:
|
|
9
|
+
Defined in: [packages/play/src/types.ts:71](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/types.ts#L71)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The generic event type of the Play Architecture
|
|
12
12
|
|
|
13
|
-
PlayEvent
|
|
14
|
-
with a `type` string property.
|
|
15
|
-
Actor
|
|
13
|
+
PlayEvent is the minimal event contract of the Actor communication: it is every
|
|
14
|
+
object with a `type` string property. The infrastructure sends each event to the
|
|
15
|
+
Actor, and the guards of the Actor state machine decide the validity.
|
|
16
16
|
|
|
17
|
-
**
|
|
18
|
-
|
|
17
|
+
**The type parameter:** the generic `TPayload` gives the shape of the event fields
|
|
18
|
+
after `type`. Its default is `Record<string, unknown>`, which accepts each shape.
|
|
19
19
|
|
|
20
|
-
**Architectural
|
|
21
|
-
infrastructure
|
|
22
|
-
|
|
20
|
+
**Architectural context:** the type implements **Passive Infrastructure
|
|
21
|
+
(INV-04)**. The infrastructure converts each user action into an event, and it
|
|
22
|
+
makes no decision. The guards of the Actor state machine decide if each event is
|
|
23
|
+
valid in the current state.
|
|
23
24
|
|
|
24
|
-
**Framework
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
**Framework-agnostic:** this type is generic on purpose, and it is bound to no
|
|
26
|
+
state machine framework. It matches the common event shape of XState, of Robot,
|
|
27
|
+
and of the other state machine libraries.
|
|
27
28
|
|
|
28
|
-
**
|
|
29
|
+
**The common event types:**
|
|
29
30
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
31
|
+
- A domain event: `{ type: 'auth.login', userId: '123' }`
|
|
32
|
+
- Your own event: `{ type: 'form.submit', data: {...} }`
|
|
32
33
|
|
|
33
34
|
## Type Declaration
|
|
34
35
|
|
|
35
|
-
| Name | Type | Defined in
|
|
36
|
-
| ------ | -------- |
|
|
37
|
-
| `type` | `string` | [packages/play/src/types.ts:
|
|
36
|
+
| Name | Type | Defined in |
|
|
37
|
+
| ------ | -------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
38
|
+
| `type` | `string` | [packages/play/src/types.ts:72](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/types.ts#L72) |
|
|
38
39
|
|
|
39
40
|
## Type Parameters
|
|
40
41
|
|
|
41
|
-
| Type Parameter | Default type | Description
|
|
42
|
-
| ---------------------------------------------------- | ------------------------------- |
|
|
43
|
-
| `TPayload` _extends_ `Record`\<`string`, `unknown`\> | `Record`\<`string`, `unknown`\> |
|
|
42
|
+
| Type Parameter | Default type | Description |
|
|
43
|
+
| ---------------------------------------------------- | ------------------------------- | ----------------------------------------------------------------- |
|
|
44
|
+
| `TPayload` _extends_ `Record`\<`string`, `unknown`\> | `Record`\<`string`, `unknown`\> | The fields after `type`. The default is `Record<string, unknown>` |
|
|
44
45
|
|
|
45
46
|
## Examples
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
The use without the type parameter, which is flexible
|
|
48
49
|
|
|
49
50
|
```typescript
|
|
50
51
|
import type { PlayEvent } from "@xmachines/play";
|
|
51
52
|
|
|
52
|
-
//
|
|
53
|
+
// It accepts every event with type: string
|
|
53
54
|
const loginEvent: PlayEvent = {
|
|
54
55
|
type: "auth.login",
|
|
55
56
|
userId: "user123",
|
|
@@ -58,12 +59,12 @@ const loginEvent: PlayEvent = {
|
|
|
58
59
|
actor.send(loginEvent);
|
|
59
60
|
```
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
The use with the type parameter, which is type-safe
|
|
62
63
|
|
|
63
64
|
```typescript
|
|
64
65
|
import type { PlayEvent } from "@xmachines/play";
|
|
65
66
|
|
|
66
|
-
//
|
|
67
|
+
// A type-safe event with a known shape
|
|
67
68
|
type LoginEvent = PlayEvent<{ userId: string; timestamp: number }>;
|
|
68
69
|
|
|
69
70
|
const loginEvent: LoginEvent = {
|
|
@@ -72,7 +73,7 @@ const loginEvent: LoginEvent = {
|
|
|
72
73
|
timestamp: Date.now(),
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
// TypeScript error:
|
|
76
|
+
// A TypeScript error: a necessary field is absent
|
|
76
77
|
const invalid: LoginEvent = { type: "auth.login" }; // Error!
|
|
77
78
|
```
|
|
78
79
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
[API](../../README.md) / @xmachines/play-actor
|
|
2
2
|
|
|
3
|
-
<!-- generated-by: gsd-doc-writer -->
|
|
4
|
-
|
|
5
3
|
# @xmachines/play-actor
|
|
6
4
|
|
|
7
5
|
Abstract Actor base class for XMachines Play Architecture.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-actor)
|
|
10
8
|
|
|
11
9
|
## Installation
|
|
12
10
|
|
|
@@ -14,90 +12,101 @@ Part of the [xmachines-js monorepo](../../README.md).
|
|
|
14
12
|
pnpm add @xmachines/play-actor
|
|
15
13
|
```
|
|
16
14
|
|
|
17
|
-
**Peer dependencies
|
|
15
|
+
**Peer dependencies.** Install them with the package:
|
|
18
16
|
|
|
19
17
|
```bash
|
|
20
|
-
pnpm add xstate @xmachines/play @xmachines/play-signals
|
|
18
|
+
pnpm add xstate @xmachines/play @xmachines/play-signals @xmachines/json-render-core
|
|
21
19
|
```
|
|
22
20
|
|
|
23
21
|
## Overview
|
|
24
22
|
|
|
25
|
-
`@xmachines/play-actor`
|
|
23
|
+
`@xmachines/play-actor` gives you `AbstractActor`, a minimal base class. The class extends the XState `Actor` class, and it enforces the **signal protocol** of the Play Architecture (RFC section 5.3). It exposes reactive TC39 Signals for the infrastructure layer. It also keeps the complete compatibility with the XState ecosystem, which includes the devtools and the inspection.
|
|
26
24
|
|
|
27
|
-
The core protocol is
|
|
25
|
+
The core protocol is small on purpose:
|
|
28
26
|
|
|
29
27
|
| Property | Type | Description |
|
|
30
28
|
| -------- | ------------------------- | ---------------------------------------- |
|
|
31
29
|
| `state` | `Signal.State<unknown>` | Reactive snapshot of current actor state |
|
|
32
30
|
| `send` | `(event: TEvent) => void` | Event dispatch method |
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
Separate interfaces declare the optional capabilities. A concrete actor implements only the interfaces that it needs:
|
|
35
33
|
|
|
36
34
|
| Interface | Property | Description |
|
|
37
35
|
| ---------- | ----------------------------------------------- | ------------------------------------- |
|
|
38
36
|
| `Routable` | `currentRoute: Signal.Computed<string \| null>` | Current route path derived from state |
|
|
39
|
-
| `Routable` | `initialRoute: string \| null` |
|
|
37
|
+
| `Routable` | `initialRoute: string \| null` | The route where the actor starts |
|
|
40
38
|
| `Viewable` | `currentView: Signal.State<PlaySpec \| null>` | Current JSON-render view spec |
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
An adapter, such as [`@xmachines/play-xstate`](../play-xstate/README.md), makes the concrete implementations.
|
|
43
41
|
|
|
44
42
|
## API Summary
|
|
45
43
|
|
|
46
44
|
### `AbstractActor<TLogic, TEvent>`
|
|
47
45
|
|
|
48
|
-
|
|
46
|
+
The abstract base class extends the XState `Actor<TLogic>` class.
|
|
47
|
+
|
|
48
|
+
A subclass **is** the actor. Give the logic and its options to `super()`, so that one
|
|
49
|
+
instance holds the running machine. Reach the `send` method of XState through the
|
|
50
|
+
prototype. This class declares `send` as abstract for one reason only: to narrow the
|
|
51
|
+
event type. TypeScript forbids a `super` call to an abstract member.
|
|
49
52
|
|
|
50
53
|
```ts
|
|
51
54
|
import { AbstractActor } from "@xmachines/play-actor";
|
|
52
55
|
import { Signal } from "@xmachines/play-signals";
|
|
53
|
-
import type
|
|
56
|
+
import { Actor, type ActorOptions, type AnyActorLogic } from "xstate";
|
|
54
57
|
|
|
55
58
|
class MyActor extends AbstractActor<AnyActorLogic> {
|
|
56
59
|
// Required: reactive state signal
|
|
57
|
-
state
|
|
60
|
+
state: Signal.State<unknown>;
|
|
61
|
+
|
|
62
|
+
constructor(logic: AnyActorLogic, options?: ActorOptions<AnyActorLogic>) {
|
|
63
|
+
super(logic, options);
|
|
64
|
+
this.state = new Signal.State(this.getSnapshot());
|
|
65
|
+
super.subscribe((snapshot) => this.state.set(snapshot));
|
|
66
|
+
}
|
|
58
67
|
|
|
59
68
|
// Required: typed event dispatch
|
|
60
|
-
send
|
|
61
|
-
|
|
62
|
-
}
|
|
69
|
+
override send(event: { type: string }): void {
|
|
70
|
+
Actor.prototype.send.call(this, event);
|
|
71
|
+
}
|
|
63
72
|
}
|
|
64
73
|
```
|
|
65
74
|
|
|
66
75
|
With a typed event union:
|
|
67
76
|
|
|
68
77
|
```ts
|
|
78
|
+
// imports as in the previous example
|
|
69
79
|
type AuthEvent = { type: "auth.login"; username: string } | { type: "auth.logout" };
|
|
70
80
|
|
|
71
81
|
class AuthActor extends AbstractActor<AnyActorLogic, AuthEvent> {
|
|
72
82
|
state = new Signal.State({ isAuthenticated: false, username: null });
|
|
73
83
|
|
|
74
|
-
send
|
|
75
|
-
|
|
76
|
-
}
|
|
84
|
+
override send(event: AuthEvent): void {
|
|
85
|
+
Actor.prototype.send.call(this, event);
|
|
86
|
+
}
|
|
77
87
|
}
|
|
78
88
|
```
|
|
79
89
|
|
|
80
|
-
### `typedSpec
|
|
90
|
+
### `typedSpec(spec)`
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
This identity helper gives a view-spec literal the type `PlaySpec` at the definition site. The
|
|
93
|
+
XState `meta` field has the type `Record<string, unknown>`. Therefore this helper is the place
|
|
94
|
+
where the spec shape receives the compile-time check and the IDE autocomplete. The helper has no
|
|
95
|
+
cost at run time.
|
|
83
96
|
|
|
84
97
|
```ts
|
|
85
98
|
import { typedSpec } from "@xmachines/play-actor";
|
|
86
99
|
|
|
87
|
-
interface DashboardCtx {
|
|
88
|
-
username: string;
|
|
89
|
-
params: Record<string, string>;
|
|
90
|
-
query: Record<string, string>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
100
|
// In an XState machine meta block:
|
|
94
101
|
meta: {
|
|
95
|
-
view: typedSpec
|
|
102
|
+
view: typedSpec({
|
|
96
103
|
root: "root",
|
|
97
|
-
contextProps: ["username"], // ✓ key of DashboardCtx
|
|
98
|
-
// contextProps: ["usernaem"], // ✗ compile error
|
|
99
104
|
elements: {
|
|
100
|
-
root: {
|
|
105
|
+
root: {
|
|
106
|
+
type: "Dashboard",
|
|
107
|
+
props: { username: { $state: "/context/username" } },
|
|
108
|
+
children: [],
|
|
109
|
+
},
|
|
101
110
|
},
|
|
102
111
|
}),
|
|
103
112
|
}
|
|
@@ -105,36 +114,76 @@ meta: {
|
|
|
105
114
|
|
|
106
115
|
### `PlaySpec`
|
|
107
116
|
|
|
108
|
-
|
|
117
|
+
This type extends the `Spec` type of `@xmachines/json-render-core`. Each derived view receives
|
|
118
|
+
the complete machine context in its state store, under the read-only **`/context` subtree**. A
|
|
119
|
+
spec therefore reads the context through the ordinary `{ $state: "/context/…" }` grammar: in a
|
|
120
|
+
prop, in a `visible` condition, and in `repeat.statePath`.
|
|
121
|
+
|
|
122
|
+
`/context` is read-only by design. Nothing can write to it. The machine context changes through
|
|
123
|
+
an event only. A `$bindState` write or a `setState` write under `/context` throws an error, and
|
|
124
|
+
the error names the event to send. This is the model: the bindable ephemeral state is at the
|
|
125
|
+
root of the store, from `spec.state`; the domain state is in the machine, and it changes through
|
|
126
|
+
events that are meaningful and easy to inspect.
|
|
127
|
+
|
|
128
|
+
The path shows the origin of each value. `/context/params/username` comes from the URL.
|
|
129
|
+
`/context/username` belongs to the machine. One value can never hide the other.
|
|
130
|
+
|
|
131
|
+
The model projects everything, and this has two consequences. The first consequence is
|
|
132
|
+
**exposure**. The complete context is visible to the client in the view store, which includes a
|
|
133
|
+
debug panel, an inspector, and a validator. The context is a client-side value in each case, so
|
|
134
|
+
keep a secret out of it.
|
|
135
|
+
|
|
136
|
+
The second consequence is **emission granularity**. The emit gate compares the context field by
|
|
137
|
+
field, at the top level only. Therefore an event that changes any field emits the view again
|
|
138
|
+
with the same `viewKey`. A provider refreshes `/context` in the live store, and it does not seed
|
|
139
|
+
the store again. The component does not remount, and the ephemeral view state and the focus
|
|
140
|
+
stay. However, a new emission is still a render pass in the framework layer. Keep
|
|
141
|
+
high-frequency ephemeral data, such as a draft for each keystroke or a timer, in the view store
|
|
142
|
+
(`spec.state` with `$bindState`) or in a child actor. The domain state belongs in the context. A
|
|
143
|
+
keystroke does not.
|
|
109
144
|
|
|
110
145
|
```ts
|
|
111
146
|
import type { PlaySpec } from "@xmachines/play-actor";
|
|
112
147
|
|
|
113
148
|
const spec: PlaySpec = {
|
|
114
149
|
root: "root",
|
|
115
|
-
contextProps: ["username"], // only these keys are exposed to components
|
|
116
150
|
elements: {
|
|
117
|
-
root: {
|
|
151
|
+
root: {
|
|
152
|
+
type: "Profile",
|
|
153
|
+
props: { username: { $state: "/context/username" } },
|
|
154
|
+
children: [],
|
|
155
|
+
},
|
|
118
156
|
},
|
|
119
157
|
};
|
|
120
158
|
```
|
|
121
159
|
|
|
160
|
+
> Historical note: an earlier version had a `contextProps` field. At first the field drove an
|
|
161
|
+
> implicit prop-enrichment pass. That pass merged the allowlisted context fields and the URL
|
|
162
|
+
> params into the props of every element. We removed it, because it put values into components
|
|
163
|
+
> that never asked for them, and it let URL data from the user hide machine-owned state. The
|
|
164
|
+
> field was then a projection filter for a short time. We removed that filter too, because a
|
|
165
|
+
> limit on what a view can read added machinery without a real problem to solve. Always
|
|
166
|
+
> validate the **derived** view (`actor.currentView.get()`), not the raw `meta.view`. The
|
|
167
|
+
> `state` of the derived spec carries the projection, so a tool such as `validateSpec` sees a
|
|
168
|
+
> spec that is consistent with itself.
|
|
169
|
+
|
|
122
170
|
### `Routable`
|
|
123
171
|
|
|
124
172
|
Interface for actors that support routing.
|
|
125
173
|
|
|
126
174
|
```ts
|
|
127
|
-
import type
|
|
175
|
+
import { AbstractActor, type Routable } from "@xmachines/play-actor";
|
|
128
176
|
import { Signal } from "@xmachines/play-signals";
|
|
177
|
+
import type { AnyActorLogic, EventObject } from "xstate";
|
|
129
178
|
|
|
130
179
|
// Implement in a concrete actor (note: RoutableActor interface is exported from @xmachines/play-router):
|
|
131
180
|
class MyRoutableActor extends AbstractActor<AnyActorLogic> implements Routable {
|
|
132
|
-
state = new Signal.State({});
|
|
133
|
-
currentRoute = new Signal.Computed(() => this.state.get().path ?? null);
|
|
181
|
+
state = new Signal.State<{ path?: string }>({});
|
|
182
|
+
currentRoute = new Signal.Computed<string | null>(() => this.state.get().path ?? null);
|
|
134
183
|
initialRoute = "/";
|
|
135
|
-
send
|
|
184
|
+
override send(event: EventObject): void {
|
|
136
185
|
/* dispatch */
|
|
137
|
-
}
|
|
186
|
+
}
|
|
138
187
|
}
|
|
139
188
|
```
|
|
140
189
|
|
|
@@ -154,7 +203,7 @@ const viewable: Viewable = { currentView: signal };
|
|
|
154
203
|
|
|
155
204
|
### `BaseActorProviderProps<TRegistry>`
|
|
156
205
|
|
|
157
|
-
|
|
206
|
+
The framework-agnostic base props. Every `ActorProvider` implementation shares them: React, Vue, Solid, and Svelte. Each framework renderer package extends this interface.
|
|
158
207
|
|
|
159
208
|
```ts
|
|
160
209
|
import type { BaseActorProviderProps } from "@xmachines/play-actor";
|
|
@@ -168,7 +217,7 @@ interface ActorProviderProps extends BaseActorProviderProps<DefineRegistryResult
|
|
|
168
217
|
|
|
169
218
|
### `BaseViewContextValue<TRegistry>`
|
|
170
219
|
|
|
171
|
-
|
|
220
|
+
The framework-agnostic base of the `ViewContextValue` type in each framework. It holds the `spec`, `handlers`, `registry`, and `store` fields. These fields are identical in React, Vue, Solid, and Svelte.
|
|
172
221
|
|
|
173
222
|
## Testing
|
|
174
223
|
|
|
@@ -191,19 +240,21 @@ pnpm --filter @xmachines/play-actor run test:watch
|
|
|
191
240
|
- **TypeScript** `>=5.7` (strict mode)
|
|
192
241
|
- **ESM only** — `"type": "module"`
|
|
193
242
|
|
|
194
|
-
@xmachines/play-actor -
|
|
243
|
+
@xmachines/play-actor - the abstract Actor base class of the Play Architecture
|
|
195
244
|
|
|
196
|
-
This package
|
|
197
|
-
|
|
245
|
+
This package gives you AbstractActor, a minimal base class. It extends the XState
|
|
246
|
+
Actor class, and it enforces the signal protocol of the Play Architecture (RFC
|
|
247
|
+
section 5.3).
|
|
198
248
|
|
|
199
|
-
The core protocol is minimal
|
|
200
|
-
|
|
249
|
+
The core protocol is minimal: state and send. Two interfaces give the optional
|
|
250
|
+
capabilities:
|
|
201
251
|
|
|
202
|
-
- Routable:
|
|
203
|
-
- Viewable:
|
|
252
|
+
- Routable: for an actor with a routing support
|
|
253
|
+
- Viewable: for an actor with a view rendering
|
|
204
254
|
|
|
205
|
-
|
|
206
|
-
reactive signals
|
|
255
|
+
The class keeps the compatibility with the XState ecosystem, such as the
|
|
256
|
+
inspection and the devtools. It also exposes the reactive signals of the
|
|
257
|
+
communication with the infrastructure layer.
|
|
207
258
|
|
|
208
259
|
## See
|
|
209
260
|
|
|
@@ -218,11 +269,24 @@ reactive signals for Infrastructure layer communication.
|
|
|
218
269
|
- [BaseActorProviderProps](interfaces/BaseActorProviderProps.md)
|
|
219
270
|
- [BaseViewContextValue](interfaces/BaseViewContextValue.md)
|
|
220
271
|
- [PlaySpec](interfaces/PlaySpec.md)
|
|
272
|
+
- [ResolveViewStoreOptions](interfaces/ResolveViewStoreOptions.md)
|
|
221
273
|
- [Routable](interfaces/Routable.md)
|
|
222
274
|
- [Viewable](interfaces/Viewable.md)
|
|
275
|
+
- [ViewStoreLifecycle](interfaces/ViewStoreLifecycle.md)
|
|
276
|
+
- [ViewStoreResolution](interfaces/ViewStoreResolution.md)
|
|
277
|
+
|
|
278
|
+
## Variables
|
|
279
|
+
|
|
280
|
+
- [CONTEXT\_STATE\_KEY](variables/CONTEXT_STATE_KEY.md)
|
|
223
281
|
|
|
224
282
|
## Functions
|
|
225
283
|
|
|
226
284
|
- [attachRenderErrorHandler](functions/attachRenderErrorHandler.md)
|
|
285
|
+
- [composePlayState](functions/composePlayState.md)
|
|
286
|
+
- [createViewStoreLifecycle](functions/createViewStoreLifecycle.md)
|
|
287
|
+
- [guardContextWrites](functions/guardContextWrites.md)
|
|
288
|
+
- [refreshContextSubtree](functions/refreshContextSubtree.md)
|
|
289
|
+
- [reuseComposedState](functions/reuseComposedState.md)
|
|
290
|
+
- [shallowEqualExcept](functions/shallowEqualExcept.md)
|
|
227
291
|
- [toAtomState](functions/toAtomState.md)
|
|
228
292
|
- [typedSpec](functions/typedSpec.md)
|