@xmachines/docs 2.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -16
- package/api/@xmachines/play/README.md +75 -97
- package/api/@xmachines/play/errors/README.md +8 -0
- package/api/@xmachines/play/{classes → errors/classes}/NonNullableError.md +6 -6
- package/api/@xmachines/play/{classes → errors/classes}/PlayError.md +35 -10
- package/api/@xmachines/play/index/README.md +75 -0
- package/api/@xmachines/play/index/functions/asCleanup.md +78 -0
- package/api/@xmachines/play/{functions → index/functions}/assertNonNullable.md +2 -2
- package/api/@xmachines/{play-actor → play/index}/functions/shallowEqualExcept.md +3 -3
- package/api/@xmachines/play/index/type-aliases/Cleanup.md +38 -0
- package/api/@xmachines/play/index/type-aliases/DisposeKey.md +32 -0
- package/api/@xmachines/play/{type-aliases → index/type-aliases}/PlayEvent.md +4 -4
- package/api/@xmachines/play/index/variables/DISPOSE.md +34 -0
- package/api/@xmachines/play-actor/README.md +78 -222
- package/api/@xmachines/play-actor/interfaces/ActorEvent.md +18 -0
- package/api/@xmachines/play-actor/interfaces/PlayActor.md +73 -0
- package/api/@xmachines/play-dom/README.md +99 -43
- package/api/@xmachines/play-dom/classes/PlayRenderer.md +12 -11
- package/api/@xmachines/play-dom/functions/asCleanup.md +78 -0
- package/api/@xmachines/play-dom/functions/createPlayUI.md +6 -6
- package/api/@xmachines/play-dom/functions/createRenderer.md +3 -3
- package/api/@xmachines/play-dom/interfaces/CreatePlayUIOptions.md +17 -11
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +5 -4
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +14 -12
- package/api/@xmachines/play-dom/type-aliases/Cleanup.md +38 -0
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +30 -8
- package/api/@xmachines/play-dom-router/README.md +99 -73
- package/api/@xmachines/play-dom-router/classes/DomRouterBridge.md +22 -21
- package/api/@xmachines/{play-vue-router → play-dom-router}/classes/RouteMap.md +12 -6
- package/api/@xmachines/play-dom-router/functions/asCleanup.md +78 -0
- package/api/@xmachines/play-dom-router/functions/connectRouter.md +3 -8
- package/api/@xmachines/play-dom-router/functions/createBrowserHistory.md +7 -1
- package/api/@xmachines/play-dom-router/functions/createRouter.md +12 -6
- package/api/@xmachines/play-dom-router/interfaces/BasePathOptions.md +5 -5
- package/api/@xmachines/play-dom-router/interfaces/BrowserHistory.md +73 -19
- package/api/@xmachines/play-dom-router/interfaces/BrowserWindow.md +16 -16
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +8 -8
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-dom-router/interfaces/RoutableActor.md +24 -21
- package/api/@xmachines/play-dom-router/interfaces/RouteLookupContract.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-dom-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-dom-router/interfaces/RouterConnection.md +36 -7
- package/api/@xmachines/play-dom-router/interfaces/VanillaRouter.md +40 -6
- package/api/@xmachines/play-dom-router/type-aliases/Cleanup.md +38 -0
- package/api/@xmachines/play-dom-router/variables/DISPOSE.md +34 -0
- package/api/@xmachines/play-react/README.md +18 -40
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +50 -11
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- package/api/@xmachines/play-react/functions/usePlayView.md +1 -1
- package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
- package/api/@xmachines/play-react/interfaces/ActorProviderProps.md +11 -11
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +8 -6
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +6 -5
- package/api/@xmachines/play-react/interfaces/PlayUIProviderProps.md +13 -13
- package/api/@xmachines/play-react/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-react/type-aliases/AnyPlayActor.md +11 -3
- package/api/@xmachines/play-react/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-react/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-react/variables/schema.md +52 -0
- package/api/@xmachines/play-react-router/README.md +22 -50
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +17 -16
- package/api/@xmachines/play-react-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-react-router/functions/createPlayRouterProvider.md +11 -8
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +16 -9
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +10 -10
- package/api/@xmachines/play-react-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-react-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterBridgeConstructor.md +17 -7
- package/api/@xmachines/play-react-router/type-aliases/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-react-router/variables/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-router/README.md +108 -189
- package/api/@xmachines/play-router/errors/README.md +15 -0
- package/api/@xmachines/play-router/errors/classes/DuplicateBridgeError.md +191 -0
- package/api/@xmachines/play-router/errors/classes/DuplicateRoutePathError.md +175 -0
- package/api/@xmachines/play-router/errors/classes/EmptyRoutePathError.md +175 -0
- package/api/@xmachines/play-router/errors/classes/InvalidBasePathError.md +200 -0
- package/api/@xmachines/play-router/errors/classes/InvalidRoutePatternError.md +203 -0
- package/api/@xmachines/play-router/errors/classes/InvalidStateIdError.md +175 -0
- package/api/@xmachines/play-router/errors/classes/MissingBasePathParamError.md +199 -0
- package/api/@xmachines/play-router/errors/classes/RouterSyncError.md +192 -0
- package/api/@xmachines/play-router/errors/classes/UnknownStateTypeError.md +182 -0
- package/api/@xmachines/play-router/index/README.md +75 -0
- package/api/@xmachines/play-router/{classes → index/classes}/RouteMap.md +12 -6
- package/api/@xmachines/play-router/{classes → index/classes}/RouterBridgeBase.md +19 -17
- package/api/@xmachines/play-router/{functions → index/functions}/buildPlayRouteEvent.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/buildRouteTree.md +14 -4
- package/api/@xmachines/play-router/{functions → index/functions}/cleanFrameworkParams.md +3 -4
- package/api/@xmachines/play-router/{functions → index/functions}/createRouteMapFromTree.md +13 -6
- package/api/@xmachines/play-router/{functions → index/functions}/createRouterConnection.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/detectDuplicateRoutes.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/extractQuery.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/extractRouteParams.md +3 -3
- package/api/@xmachines/play-router/{functions → index/functions}/findRouteById.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/findRouteByPath.md +2 -2
- package/api/@xmachines/play-router/index/functions/getPatternParamNames.md +29 -0
- package/api/@xmachines/play-router/index/functions/getRequiredPatternParamNames.md +39 -0
- package/api/@xmachines/play-router/{functions → index/functions}/isMountableBridge.md +2 -2
- package/api/@xmachines/play-router/index/functions/joinBasePath.md +37 -0
- package/api/@xmachines/play-router/{functions → index/functions}/mountKey.md +2 -2
- package/api/@xmachines/play-router/index/functions/normalizeBasePath.md +43 -0
- package/api/@xmachines/play-router/{functions → index/functions}/openProviderBridge.md +14 -14
- package/api/@xmachines/play-router/index/functions/pickOwnParams.md +41 -0
- package/api/@xmachines/play-router/{functions → index/functions}/repointProviderBridge.md +2 -2
- package/api/@xmachines/play-router/index/functions/resolveBasePath.md +51 -0
- package/api/@xmachines/play-router/{functions → index/functions}/resolveFrameworkParams.md +11 -13
- package/api/@xmachines/play-router/{functions → index/functions}/sanitizePathname.md +2 -2
- package/api/@xmachines/play-router/index/functions/stripBasePath.md +44 -0
- package/api/@xmachines/play-router/{functions → index/functions}/validateRouteFormat.md +2 -2
- package/api/@xmachines/play-router/{functions → index/functions}/validateStateExists.md +2 -2
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/BasePathOptions.md +6 -6
- package/api/@xmachines/play-router/index/interfaces/BuildPlayRouteEventOptions.md +13 -0
- package/api/@xmachines/play-router/index/interfaces/FrameworkParamsSource.md +47 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/LocationLike.md +6 -6
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/MountableRouterBridge.md +9 -9
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/OpenProviderBridgeArgs.md +13 -13
- package/api/@xmachines/play-router/index/interfaces/PlayRouteEvent.md +130 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/PlayRouterProviderBaseProps.md +15 -15
- package/api/@xmachines/play-router/index/interfaces/ResolvedBasePath.md +14 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/ResolvedRoutePath.md +6 -6
- package/api/@xmachines/play-router/index/interfaces/Routable.md +26 -0
- package/api/@xmachines/play-router/index/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteInfo.md +11 -11
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteMapping.md +6 -6
- package/api/@xmachines/play-router/index/interfaces/RouteMatch.md +12 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteNode.md +13 -13
- package/api/@xmachines/play-router/index/interfaces/RouteObject.md +34 -0
- package/api/@xmachines/play-router/index/interfaces/RouteTree.md +27 -0
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouteWatcherHandle.md +7 -7
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouterBridge.md +5 -5
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/RouterConnection.md +38 -9
- package/api/@xmachines/play-router/{interfaces → index/interfaces}/WindowLike.md +4 -4
- package/api/@xmachines/play-router/index/type-aliases/PlayRouterBridgeConstructor.md +46 -0
- package/api/@xmachines/play-router/index/type-aliases/RouteData.md +12 -0
- package/api/@xmachines/play-router/index/type-aliases/RouteDataResolver.md +31 -0
- package/api/@xmachines/play-router/index/type-aliases/RouteMetadata.md +11 -0
- package/api/@xmachines/play-router/index/variables/DISPOSE.md +34 -0
- package/api/@xmachines/play-router/index/variables/NO_BASE_PATH.md +18 -0
- package/api/@xmachines/play-router/index/variables/ROOT_NODE_ID.md +18 -0
- package/api/@xmachines/play-router/xstate/README.md +53 -0
- package/api/@xmachines/{play-dom-router → play-router/xstate}/functions/createRouteMap.md +8 -6
- package/api/@xmachines/play-router/{functions → xstate/functions}/extractMachineRoutes.md +4 -4
- package/api/@xmachines/play-router/xstate/functions/getNavigableRoutes.md +35 -0
- package/api/@xmachines/play-router/{functions → xstate/functions}/getRoutableRoutes.md +6 -6
- package/api/@xmachines/play-router/{functions → xstate/functions}/getRouteMappings.md +7 -7
- package/api/@xmachines/play-router/{functions → xstate/functions}/getTransitionReachableRoutes.md +2 -2
- package/api/@xmachines/play-router/{functions → xstate/functions}/isRouteReachable.md +2 -2
- package/api/@xmachines/play-router/{functions → xstate/functions}/machineToGraph.md +2 -2
- package/api/@xmachines/play-router/xstate/functions/routeExists.md +26 -0
- package/api/@xmachines/play-router/xstate/interfaces/MachineEdgeData.md +15 -0
- package/api/@xmachines/play-router/xstate/interfaces/MachineNodeData.md +17 -0
- package/api/@xmachines/play-router/{type-aliases → xstate/type-aliases}/MachineGraph.md +2 -2
- package/api/@xmachines/play-signals/README.md +5 -25
- package/api/@xmachines/play-signals/functions/watchSignal.md +27 -4
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
- package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
- package/api/@xmachines/play-signals/type-aliases/Cleanup.md +38 -0
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
- package/api/@xmachines/play-solid/README.md +36 -35
- package/api/@xmachines/play-solid/functions/useActor.md +1 -1
- package/api/@xmachines/play-solid/functions/usePlayView.md +14 -1
- package/api/@xmachines/play-solid/interfaces/ActorProviderProps.md +11 -11
- package/api/@xmachines/play-solid/interfaces/PlayUIProviderProps.md +13 -13
- package/api/@xmachines/play-solid/interfaces/ViewContextValue.md +16 -8
- package/api/@xmachines/play-solid/type-aliases/AnyPlayActor.md +11 -3
- package/api/@xmachines/play-solid/variables/ActorContext.md +1 -1
- package/api/@xmachines/play-solid/variables/ActorProvider.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-solid/variables/PlayUIProvider.md +1 -1
- package/api/@xmachines/play-solid/variables/schema.md +71 -0
- package/api/@xmachines/play-solid-router/README.md +31 -52
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +30 -53
- package/api/@xmachines/play-solid-router/functions/createPlayRouterProvider.md +9 -8
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +38 -35
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +12 -12
- package/api/@xmachines/play-solid-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-solid-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +5 -5
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterBridgeConstructor.md +17 -7
- package/api/@xmachines/play-solid-router/type-aliases/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
- package/api/@xmachines/play-solid-router/variables/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-svelte/README.md +13 -28
- package/api/@xmachines/play-svelte/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-svelte/functions/getActorContext.md +1 -1
- package/api/@xmachines/play-svelte/functions/getPlayViewContext.md +7 -1
- package/api/@xmachines/play-svelte/functions/setActorContext.md +1 -1
- package/api/@xmachines/play-svelte/interfaces/ActorProviderProps.md +12 -12
- package/api/@xmachines/play-svelte/interfaces/DefineRegistryOptions.md +4 -4
- package/api/@xmachines/play-svelte/interfaces/PlayUIProviderProps.md +14 -14
- package/api/@xmachines/play-svelte/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-svelte/type-aliases/AnyPlayActor.md +11 -3
- package/api/@xmachines/play-svelte/variables/schema.md +16 -0
- package/api/@xmachines/play-svelte-spa-router/README.md +22 -41
- package/api/@xmachines/play-svelte-spa-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-svelte-spa-router/classes/SvelteSpaRouterBridge.md +22 -21
- package/api/@xmachines/play-svelte-spa-router/functions/connectRouter.md +3 -2
- package/api/@xmachines/play-svelte-spa-router/interfaces/BasePathOptions.md +5 -5
- package/api/@xmachines/play-svelte-spa-router/interfaces/ConnectRouterOptions.md +8 -8
- package/api/@xmachines/play-svelte-spa-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-svelte-spa-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-svelte-spa-router/interfaces/RouterConnection.md +36 -7
- package/api/@xmachines/play-svelte-spa-router/interfaces/WindowLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/README.md +17 -35
- package/api/@xmachines/play-sveltekit-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-sveltekit-router/classes/SvelteKitRouterBridge.md +22 -21
- package/api/@xmachines/play-sveltekit-router/functions/connectRouter.md +3 -2
- package/api/@xmachines/play-sveltekit-router/interfaces/BasePathOptions.md +5 -5
- package/api/@xmachines/play-sveltekit-router/interfaces/ConnectRouterOptions.md +8 -8
- package/api/@xmachines/play-sveltekit-router/interfaces/LocationLike.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-sveltekit-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-sveltekit-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-sveltekit-router/interfaces/RouterConnection.md +36 -7
- package/api/@xmachines/play-tanstack-react-router/README.md +19 -43
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +18 -17
- package/api/@xmachines/play-tanstack-react-router/functions/createPlayRouterProvider.md +11 -8
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +16 -9
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +10 -10
- package/api/@xmachines/play-tanstack-react-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterBridgeConstructor.md +17 -7
- package/api/@xmachines/play-tanstack-react-router/type-aliases/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +5 -5
- package/api/@xmachines/play-tanstack-react-router/variables/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-tanstack-router/README.md +6 -4
- package/api/@xmachines/play-tanstack-router/classes/TanStackRouterBridgeBase.md +17 -20
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouteMapLike.md +3 -3
- package/api/@xmachines/play-tanstack-router/type-aliases/TanStackRouterLike.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/README.md +26 -52
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +11 -5
- package/api/@xmachines/play-tanstack-solid-router/classes/TanStackSolidRouterBridge.md +49 -45
- package/api/@xmachines/play-tanstack-solid-router/functions/createPlayRouterProvider.md +9 -8
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +9 -14
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +10 -10
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapOptions.md +4 -4
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +3 -3
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterBridgeConstructor.md +17 -7
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/PlayRouterProviderBaseProps.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +5 -5
- package/api/@xmachines/play-tanstack-solid-router/variables/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-url/README.md +69 -0
- package/api/@xmachines/play-url/errors/README.md +17 -0
- package/api/@xmachines/play-url/errors/classes/InvalidBasePathError.md +200 -0
- package/api/@xmachines/play-url/errors/classes/InvalidRoutePatternError.md +203 -0
- package/api/@xmachines/play-url/errors/classes/MissingBasePathParamError.md +199 -0
- package/api/@xmachines/play-url/index/README.md +65 -0
- package/api/@xmachines/play-url/index/functions/cleanFrameworkParams.md +39 -0
- package/api/@xmachines/play-url/index/functions/getCandidates.md +29 -0
- package/api/@xmachines/play-url/index/functions/getCompiledPattern.md +31 -0
- package/api/@xmachines/play-url/index/functions/getIndexKey.md +30 -0
- package/api/@xmachines/play-url/index/functions/getNormalizedParamNameMap.md +32 -0
- package/api/@xmachines/play-url/index/functions/getPatternParamNames.md +29 -0
- package/api/@xmachines/play-url/index/functions/getRequiredPatternParamNames.md +39 -0
- package/api/@xmachines/play-url/index/functions/holdsUnsubstitutedParam.md +36 -0
- package/api/@xmachines/play-url/index/functions/isParameterizedPattern.md +36 -0
- package/api/@xmachines/{play-router → play-url/index}/functions/joinBasePath.md +2 -2
- package/api/@xmachines/{play-router → play-url/index}/functions/normalizeBasePath.md +2 -2
- package/api/@xmachines/play-url/index/functions/normalizeParamNames.md +36 -0
- package/api/@xmachines/play-url/index/functions/parsePattern.md +27 -0
- package/api/@xmachines/{play-router → play-url/index}/functions/pickOwnParams.md +4 -4
- package/api/@xmachines/{play-router → play-url/index}/functions/resolveBasePath.md +2 -2
- package/api/@xmachines/play-url/index/functions/resolveFrameworkParams.md +49 -0
- package/api/@xmachines/{play-router → play-url/index}/functions/stripBasePath.md +2 -2
- package/api/@xmachines/play-url/index/interfaces/BasePathOptions.md +28 -0
- package/api/@xmachines/{play-router → play-url/index}/interfaces/FrameworkParamsSource.md +9 -9
- package/api/@xmachines/play-url/index/interfaces/GroupPart.md +15 -0
- package/api/@xmachines/play-url/index/interfaces/LiteralPart.md +14 -0
- package/api/@xmachines/play-url/index/interfaces/ParamPart.md +21 -0
- package/api/@xmachines/play-url/index/interfaces/ParsedPattern.md +23 -0
- package/api/@xmachines/play-url/index/interfaces/PatternParam.md +15 -0
- package/api/@xmachines/{play-router → play-url/index}/interfaces/ResolvedBasePath.md +6 -6
- package/api/@xmachines/play-url/index/type-aliases/PatternModifier.md +11 -0
- package/api/@xmachines/play-url/index/type-aliases/PatternPart.md +9 -0
- package/api/@xmachines/play-url/index/type-aliases/URLPatternCtor.md +22 -0
- package/api/@xmachines/play-url/index/type-aliases/URLPatternLike.md +68 -0
- package/api/@xmachines/{play-router → play-url/index}/variables/NO_BASE_PATH.md +2 -2
- package/api/@xmachines/play-url/index/variables/URLPattern.md +21 -0
- package/api/@xmachines/play-view/README.md +165 -0
- package/api/@xmachines/play-view/errors/README.md +17 -0
- package/api/@xmachines/play-view/errors/classes/ReadOnlyContextError.md +192 -0
- package/api/@xmachines/play-view/index/README.md +55 -0
- package/api/@xmachines/{play-actor → play-view/index}/functions/attachRenderErrorHandler.md +6 -6
- package/api/@xmachines/{play-actor → play-view/index}/functions/composePlayState.md +2 -2
- package/api/@xmachines/play-view/index/functions/createFailureLatch.md +20 -0
- package/api/@xmachines/play-view/index/functions/createReportGuard.md +26 -0
- package/api/@xmachines/{play-actor → play-view/index}/functions/createViewStoreLifecycle.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/guardContextWrites.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/refreshContextSubtree.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/reuseComposedState.md +3 -3
- package/api/@xmachines/play-view/index/functions/sameViewInputs.md +25 -0
- package/api/@xmachines/{play-actor → play-view/index}/functions/toAtomState.md +2 -2
- package/api/@xmachines/{play-actor → play-view/index}/functions/typedSpec.md +2 -2
- package/api/@xmachines/play-view/index/interfaces/BaseActorProviderProps.md +49 -0
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/BaseViewContextValue.md +12 -12
- package/api/@xmachines/play-view/index/interfaces/FailureLatch.md +60 -0
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/PlaySpec.md +8 -8
- package/api/@xmachines/play-view/index/interfaces/ReportGuard.md +92 -0
- package/api/@xmachines/play-view/index/interfaces/ReportGuardMessages.md +18 -0
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ResolveViewStoreOptions.md +5 -5
- package/api/@xmachines/play-view/index/interfaces/ViewInputs.md +19 -0
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ViewStoreLifecycle.md +6 -5
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/ViewStoreResolution.md +7 -7
- package/api/@xmachines/{play-actor → play-view/index}/interfaces/Viewable.md +5 -5
- package/api/@xmachines/play-view/index/type-aliases/ViewActor.md +26 -0
- package/api/@xmachines/{play-actor → play-view/index}/variables/CONTEXT_STATE_KEY.md +2 -2
- package/api/@xmachines/play-vue/README.md +46 -42
- package/api/@xmachines/play-vue/functions/defineRegistry.md +1 -1
- package/api/@xmachines/play-vue/functions/useActor.md +1 -1
- package/api/@xmachines/play-vue/functions/usePlayView.md +6 -1
- package/api/@xmachines/play-vue/interfaces/ActorProviderProps.md +13 -8
- package/api/@xmachines/play-vue/interfaces/PlayUIProviderProps.md +15 -10
- package/api/@xmachines/play-vue/interfaces/ViewContextValue.md +8 -8
- package/api/@xmachines/play-vue/type-aliases/AnyPlayActor.md +11 -3
- package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +1 -1
- package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +2 -2
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
- package/api/@xmachines/play-vue/variables/schema.md +71 -0
- package/api/@xmachines/play-vue-router/README.md +34 -77
- package/api/@xmachines/play-vue-router/errors/README.md +8 -0
- package/api/@xmachines/play-vue-router/errors/classes/VueRouterNavigationError.md +193 -0
- package/api/@xmachines/play-vue-router/errors/classes/VueRouterSendError.md +177 -0
- package/api/@xmachines/play-vue-router/index/README.md +20 -0
- package/api/@xmachines/play-vue-router/index/classes/RouteMap.md +157 -0
- package/api/@xmachines/play-vue-router/{classes → index/classes}/VueRouterBridge.md +24 -43
- package/api/@xmachines/play-vue-router/index/interfaces/PlayRouteEvent.md +130 -0
- package/api/@xmachines/play-vue-router/index/interfaces/RoutableActor.md +72 -0
- package/api/@xmachines/play-vue-router/{interfaces → index/interfaces}/RouteMapOptions.md +5 -5
- package/api/@xmachines/play-vue-router/{interfaces → index/interfaces}/RouteMapping.md +6 -6
- package/api/@xmachines/play-vue-router/{interfaces → index/interfaces}/RouterBridge.md +5 -5
- package/api/@xmachines/play-vue-router/{variables → index/variables}/PlayRouterProvider.md +4 -4
- package/api/@xmachines/play-xstate/README.md +163 -98
- package/api/@xmachines/play-xstate/errors/README.md +13 -0
- package/api/@xmachines/play-xstate/errors/classes/ActorThrewNonErrorError.md +199 -0
- package/api/@xmachines/play-xstate/errors/classes/InvalidEventError.md +198 -0
- package/api/@xmachines/play-xstate/errors/classes/InvalidMachineError.md +169 -0
- package/api/@xmachines/play-xstate/errors/classes/InvalidRouteHandlerError.md +197 -0
- package/api/@xmachines/play-xstate/errors/classes/InvalidRouteMetadataError.md +176 -0
- package/api/@xmachines/play-xstate/errors/classes/MissingRouteParamError.md +199 -0
- package/api/@xmachines/play-xstate/errors/classes/MissingStateIdError.md +203 -0
- package/api/@xmachines/play-xstate/index/README.md +38 -0
- package/api/@xmachines/play-xstate/index/classes/PlayerActor.md +584 -0
- package/api/@xmachines/play-xstate/index/functions/compose.md +224 -0
- package/api/@xmachines/play-xstate/index/functions/definePlayer.md +158 -0
- package/api/@xmachines/play-xstate/index/interfaces/PlayerConfig.md +22 -0
- package/api/@xmachines/play-xstate/{interfaces → index/interfaces}/PlayerFactoryResumeOptions.md +3 -3
- package/api/@xmachines/play-xstate/{interfaces → index/interfaces}/PlayerOptions.md +8 -8
- package/api/@xmachines/play-xstate/index/type-aliases/Capability.md +33 -0
- package/api/@xmachines/play-xstate/index/type-aliases/PlayerConstructor.md +39 -0
- package/api/@xmachines/play-xstate/index/type-aliases/PlayerFactory.md +27 -0
- package/api/@xmachines/play-xstate/index/variables/DISPOSE.md +34 -0
- package/api/@xmachines/play-xstate/with-routing/README.md +46 -0
- package/api/@xmachines/play-xstate/{functions → with-routing/functions}/buildRouteUrl.md +2 -2
- package/api/@xmachines/play-xstate/{functions → with-routing/functions}/deriveRoute.md +4 -4
- package/api/@xmachines/play-xstate/{functions → with-routing/functions}/formatPlayRouteTransitions.md +2 -2
- package/api/@xmachines/play-xstate/{functions → with-routing/functions}/isAbsoluteRoute.md +3 -3
- package/api/@xmachines/play-xstate/with-routing/functions/withRouting.md +36 -0
- package/api/@xmachines/play-xstate/{interfaces → with-routing/interfaces}/RouteContext.md +6 -6
- package/api/@xmachines/play-xstate/with-routing/interfaces/RouteObject.md +34 -0
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteData.md +12 -0
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteDataResolver.md +31 -0
- package/api/@xmachines/play-xstate/{type-aliases → with-routing/type-aliases}/RouteMachineConfig.md +5 -5
- package/api/@xmachines/play-xstate/with-routing/type-aliases/RouteMetadata.md +11 -0
- package/api/@xmachines/play-xstate/{type-aliases → with-routing/type-aliases}/RouteStateNode.md +21 -7
- package/api/@xmachines/play-xstate/with-view/README.md +31 -0
- package/api/@xmachines/play-xstate/with-view/functions/withView.md +32 -0
- package/api/@xmachines/shared/README.md +10 -32
- package/api/@xmachines/shared/vite-aliases/functions/xmAliases.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmCacheDir.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmOptimizeDeps.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmResolve.md +1 -1
- package/api/@xmachines/shared/vite-aliases/functions/xmSvelteRunes.md +2 -2
- package/api/@xmachines/shared/vitest/functions/defineXmBrowserConfig.md +1 -1
- package/api/@xmachines/shared/vitest/functions/defineXmVitestConfig.md +2 -1
- package/api/@xmachines/shared/vitest/interfaces/XmBrowserConfigOptions.md +4 -4
- package/api/README.md +2 -0
- package/api/llms.txt +15 -10
- package/contributing/architecture.md +97 -65
- package/contributing/configuration.md +142 -41
- package/contributing/deployment.md +30 -28
- package/contributing/development.md +94 -31
- package/contributing/testing.md +90 -31
- package/examples/README.md +9 -7
- package/examples/form-validation.md +3 -2
- package/examples/multi-router-integration.md +61 -39
- package/examples/routing-patterns.md +15 -14
- package/examples/traffic-light.md +11 -5
- package/guides/README.md +1 -0
- package/guides/actor-model.md +35 -26
- package/guides/getting-started.md +47 -44
- package/guides/inspector.md +4 -4
- package/guides/routing.md +245 -0
- package/guides/signals.md +43 -0
- package/guides/state-machines.md +16 -17
- package/package.json +10 -9
- package/rfc/play.md +35 -22
- package/api/@xmachines/play-actor/classes/AbstractActor.md +0 -505
- package/api/@xmachines/play-actor/interfaces/BaseActorProviderProps.md +0 -48
- package/api/@xmachines/play-actor/interfaces/Routable.md +0 -14
- package/api/@xmachines/play-dom-router/interfaces/RouteMap.md +0 -122
- package/api/@xmachines/play-react/type-aliases/PlayRendererProps.md +0 -13
- package/api/@xmachines/play-react-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-react-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +0 -35
- package/api/@xmachines/play-router/functions/getPatternParamNames.md +0 -24
- package/api/@xmachines/play-router/functions/getRequiredPatternParamNames.md +0 -36
- package/api/@xmachines/play-router/functions/routeExists.md +0 -26
- package/api/@xmachines/play-router/interfaces/BuildPlayRouteEventOptions.md +0 -13
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +0 -15
- package/api/@xmachines/play-router/interfaces/MachineNodeData.md +0 -17
- package/api/@xmachines/play-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +0 -135
- package/api/@xmachines/play-router/interfaces/RoutableActor.md +0 -65
- package/api/@xmachines/play-router/interfaces/RouteMatch.md +0 -12
- package/api/@xmachines/play-router/interfaces/RouteObject.md +0 -21
- package/api/@xmachines/play-router/interfaces/RouteTree.md +0 -21
- package/api/@xmachines/play-router/type-aliases/BaseRouteMapping.md +0 -13
- package/api/@xmachines/play-router/type-aliases/PlayRouterBridgeConstructor.md +0 -36
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +0 -11
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +0 -471
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +0 -13
- package/api/@xmachines/play-svelte-spa-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-svelte-spa-router/type-aliases/RoutableActor.md +0 -9
- package/api/@xmachines/play-sveltekit-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-sveltekit-router/type-aliases/RoutableActor.md +0 -9
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +0 -29
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +0 -31
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +0 -13
- package/api/@xmachines/play-vue/interfaces/VisibilityProviderProps.md +0 -9
- package/api/@xmachines/play-vue/variables/getPlayViewContext.md +0 -34
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +0 -40
- package/api/@xmachines/play-vue-router/interfaces/PlayActor.md +0 -70
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +0 -135
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +0 -13
- package/api/@xmachines/play-vue-router/type-aliases/VueRouteMap.md +0 -13
- package/api/@xmachines/play-vue-router/variables/VueRouteMap.md +0 -13
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +0 -532
- package/api/@xmachines/play-xstate/functions/composeGuards.md +0 -86
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +0 -72
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +0 -43
- package/api/@xmachines/play-xstate/functions/definePlayer.md +0 -78
- package/api/@xmachines/play-xstate/functions/eventMatches.md +0 -45
- package/api/@xmachines/play-xstate/functions/hasContext.md +0 -45
- package/api/@xmachines/play-xstate/functions/negateGuard.md +0 -67
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +0 -20
- package/api/@xmachines/play-xstate/interfaces/RouteObject.md +0 -17
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +0 -19
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +0 -36
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +0 -23
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +0 -26
- package/api/@xmachines/play-xstate/type-aliases/RouteMetadata.md +0 -9
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: MountOptions
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-dom/src/create-play-ui.ts:
|
|
5
|
+
Defined in: [packages/play-dom/src/create-play-ui.ts:50](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/create-play-ui.ts#L50)
|
|
6
6
|
|
|
7
7
|
The mount options of the `MountFn` that `createPlayUI` returns.
|
|
8
8
|
|
|
9
9
|
They replace or complete the factory options, for one actor and one container.
|
|
10
10
|
The `createPlayUI` call sets the factory options (`functions`,
|
|
11
|
-
`validationFunctions`, `navigate`, `onRenderError`, and `fallback`) one
|
|
11
|
+
`validationFunctions`, `navigate`, `onRenderError`, `onError`, and `fallback`) one
|
|
12
|
+
time.
|
|
12
13
|
|
|
13
14
|
## Properties
|
|
14
15
|
|
|
15
16
|
| Property | Type | Description | Defined in |
|
|
16
17
|
| ---------------------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
-
| <a id="property-loading"></a> `loading?` | `boolean` | With the value `true`, the renderer stops each warning about an absent child during the ingestion of a streaming spec. It also gives `ctx.ctx.loading` to each component implementation. | [packages/play-dom/src/create-play-ui.ts:
|
|
18
|
-
| <a id="property-store"></a> `store?` | `StateStore` | The optional external `StateStore`, which is the controlled mode. Without it, the renderer makes a new `@xstate/store` atom for each view transition, with the values of `spec.state`. | [packages/play-dom/src/create-play-ui.ts:
|
|
18
|
+
| <a id="property-loading"></a> `loading?` | `boolean` | With the value `true`, the renderer stops each warning about an absent child during the ingestion of a streaming spec. It also gives `ctx.ctx.loading` to each component implementation. | [packages/play-dom/src/create-play-ui.ts:62](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/create-play-ui.ts#L62) |
|
|
19
|
+
| <a id="property-store"></a> `store?` | `StateStore` | The optional external `StateStore`, which is the controlled mode. Without it, the renderer makes a new `@xstate/store` atom for each view transition, with the values of `spec.state`. | [packages/play-dom/src/create-play-ui.ts:56](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/create-play-ui.ts#L56) |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: PlayDomOptions
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-dom/src/types.ts:23](https://gitlab.com/xmachin-es/xmachines-js/-/blob/
|
|
5
|
+
Defined in: [packages/play-dom/src/types.ts:23](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/types.ts#L23)
|
|
6
6
|
|
|
7
7
|
The options of `PlayRenderer`.
|
|
8
8
|
|
|
@@ -17,14 +17,16 @@ reads them at `ctx.ctx.*`.
|
|
|
17
17
|
|
|
18
18
|
## Properties
|
|
19
19
|
|
|
20
|
-
| Property | Type | Description
|
|
21
|
-
| ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
22
|
-
| <a id="property-directives"></a> `directives?` | `DirectiveDefinition`\<`ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\>\>[] | Custom directives — user-defined `$`-prefixed dynamic values that extend the spec expression language (e.g. `{ $format: "currency", value: ... }`). Each entry is a `DirectiveDefinition` built with `defineDirective` from `@xmachines/json-render-core`. The array is converted to a `DirectiveRegistry` once per render pass and forwarded to `resolveElementProps` via `PropResolutionContext.directives`. Built-in expressions (`$state`, `$cond`, etc.) always take precedence over custom directives. Mirrors the `directives` prop on `JSONUIProvider` / `JsonUIProvider` introduced in **Json-render** 0.19. **Example** `import { defineDirective, resolvePropValue } from "@xmachines/json-render-core"; import { z } from "zod"; const formatDirective = defineDirective({ name: "$format", description: "Locale-aware number formatting.", schema: z.object({ $format: z.enum(["number", "currency"]), value: z.unknown() }), resolve(value, ctx) { const resolved = resolvePropValue(value.value, ctx); return new Intl.NumberFormat().format(resolved as number); }, }); renderSpec(spec, store, registry, { directives: [formatDirective] });`
|
|
23
|
-
| <a id="property-
|
|
24
|
-
| <a id="property-
|
|
25
|
-
| <a id="property-
|
|
26
|
-
| <a id="property-
|
|
27
|
-
| <a id="property-
|
|
28
|
-
| <a id="property-
|
|
29
|
-
| <a id="property-
|
|
30
|
-
| <a id="property-
|
|
20
|
+
| Property | Type | Description | Inherited from | Defined in |
|
|
21
|
+
| ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| <a id="property-directives"></a> `directives?` | `DirectiveDefinition`\<`ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\>\>[] | Custom directives — user-defined `$`-prefixed dynamic values that extend the spec expression language (e.g. `{ $format: "currency", value: ... }`). Each entry is a `DirectiveDefinition` built with `defineDirective` from `@xmachines/json-render-core`. The array is converted to a `DirectiveRegistry` once per render pass and forwarded to `resolveElementProps` via `PropResolutionContext.directives`. Built-in expressions (`$state`, `$cond`, etc.) always take precedence over custom directives. Mirrors the `directives` prop on `JSONUIProvider` / `JsonUIProvider` introduced in **Json-render** 0.19. **Example** `import { defineDirective, resolvePropValue } from "@xmachines/json-render-core"; import { z } from "zod"; const formatDirective = defineDirective({ name: "$format", description: "Locale-aware number formatting.", schema: z.object({ $format: z.enum(["number", "currency"]), value: z.unknown() }), resolve(value, ctx) { const resolved = resolvePropValue(value.value, ctx); return new Intl.NumberFormat().format(resolved as number); }, }); renderSpec(spec, store, registry, { directives: [formatDirective] });` | [`UIProviderOptions`](UIProviderOptions.md).[`directives`](UIProviderOptions.md#property-directives) | - |
|
|
23
|
+
| <a id="property-fallback"></a> `fallback?` | `HTMLElement` \| (() => `HTMLElement`) \| `null` | The optional element that the renderer shows when `currentView` is `null`, and after a failure of a rebuild that it contains. The renderer shows it for EVERY null view, and not for the first mount only: a view that returns to `null` after a view that was not `null` also shows it. The four framework providers hold the same rule for their placeholder content. The renderer shows it after a failure of a rebuild too. This option turns nothing on: the renderer contains such a failure always, and this option says only what the empty container shows. The next view that renders clears the container, which removes the element. **One element belongs to one renderer.** `appendChild` MOVES a node. Two renderers that hold the same element therefore take it from each other on every null view, and the container of the first one goes empty without a notice. Build one element for each `PlayRenderer`. A FUNCTION also works here. The renderer calls it at the first moment that it needs the element, and it keeps the result, so a renderer whose view is never null builds nothing. [CreatePlayUIOptions.fallback](CreatePlayUIOptions.md#property-fallback) passes such a function for each mount. A producer that THROWS is contained on BOTH paths — a null view, and a rebuild that failed — and the renderer writes it to `console.error` and NOT to [PlayDomOptions.onError](#property-onerror). On the second path the renderer calls the producer from inside the containment of the view, and a second trip through `onError` would report the failure of the fallback as a failure of the view. The container stays empty. | - | [packages/play-dom/src/types.ts:132](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/types.ts#L132) |
|
|
24
|
+
| <a id="property-functions"></a> `functions?` | `Record`\<`string`, `ComputedFunction`\> | Named compute functions for `{ $computed: "name", args: {...} }` prop expressions. Each function receives the resolved `args` object and returns the computed value. Forwarded directly to `resolveElementProps` via `PropResolutionContext.functions`, matching the `FunctionsContext` provider in the framework renderers. Without this option, `$computed` expressions resolve to `undefined` (no throw). **Example** `renderSpec(spec, store, registry, { functions: { fullName: (args) => `${args.first} ${args.last}`, formatCurrency: (args) => new Intl.NumberFormat().format(args.amount as number), }, });` Mirrors the `functions` prop on `JSONUIProvider` / `JsonUIProvider`. | [`UIProviderOptions`](UIProviderOptions.md).[`functions`](UIProviderOptions.md#property-functions) | - |
|
|
25
|
+
| <a id="property-loading"></a> `loading?` | `boolean` | With the value `true`, the spec is still streaming, for example from an AI provider. The renderer gives the flag to `renderSpec`. A component implementation therefore reads `ctx.ctx.loading`, and it can render a skeleton state. The flag also stops each warning about an absent child during the ingestion of the stream, because an element of a reference can still be absent from the incremental spec. This option matches the `loading` prop of the framework renderer providers. | - | [packages/play-dom/src/types.ts:54](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/types.ts#L54) |
|
|
26
|
+
| <a id="property-navigate"></a> `navigate?` | (`path`) => `void` | Programmatic navigation function. Called automatically when an action binding resolves with `onSuccess: { navigate: "/path" }`. The resolved path string is passed as the sole argument. Mirrors the `navigate` prop in `ActionProvider` from the framework renderers, where it is captured in the `execute()` closure. Also available to component implementations directly via `ctx.ctx.navigate` for cases where navigation needs to be triggered outside of an action binding. **Example** `import { useNavigate } from "my-router"; const navigate = useNavigate(); renderSpec(spec, store, registry, { navigate });` Spec binding that triggers navigation: `{ "on": { "click": { "action": "doSomething", "onSuccess": { "navigate": "/dashboard" } } } }` | [`UIProviderOptions`](UIProviderOptions.md).[`navigate`](UIProviderOptions.md#property-navigate) | - |
|
|
27
|
+
| <a id="property-onconfirm"></a> `onConfirm?` | [`ConfirmHandler`](../type-aliases/ConfirmHandler.md) | Confirmation hook for actions that declare `confirm` in their binding. Consulted by `emit()` before executing a confirm-gated action. Return (or resolve) `true` to execute, `false` to skip. Without this handler, confirm-gated actions are skipped with a `console.warn` — they never execute unconfirmed. See [ConfirmHandler](../type-aliases/ConfirmHandler.md) for the full contract. This is the headless equivalent of the `pendingConfirmation` / `confirmAction()` / `cancelAction()` flow in the framework adapters. | [`UIProviderOptions`](UIProviderOptions.md).[`onConfirm`](UIProviderOptions.md#property-onconfirm) | - |
|
|
28
|
+
| <a id="property-onerror"></a> `onError?` | (`error`, `reset`) => `void` | The optional handler of a failure of a complete rebuild of the view. This option is NOT the same as `onRenderError`, which [UIProviderOptions](UIProviderOptions.md) gives: the inner renderer routes a render error of one component, and a rejection of one action handler, to `onRenderError`. It contains each of them per element, and the rebuild continues. `onError` receives the failure of the complete rebuild that no per-element boundary caught. The renderer CONTAINS a rebuild that throws, with this option and without it: it resets the state of the failed rebuild, so that the next emission makes a complete render again, and it clears the container. `connect()` renders the first view synchronously, so a bad initial view makes `connect()` throw no more. A WRITE of the store takes the same path. The renderer resolves the props of every element that the write touched, so a `$computed` function that throws on the new state aborts that render too. The renderer contains such a failure as well, and the action handler that wrote the state receives no exception. This option says WHERE the report goes. Without it, the renderer writes the contained failure to `console.error`. A handler that THROWS reaches no caller: the renderer contains that throw too, and it writes the throw to `console.error`. A host that must escalate a failure raises it from a task of its own — `queueMicrotask(() => { throw error; })` — which reaches the global handler of the page and leaves the containment whole. The five renderers hold this one rule. The second parameter is the RESET, for a retry that the host starts — a "Retry" button of its own. It renders the view that the actor holds at the MOMENT OF THE CALL, so a host that keeps the callback cannot rewind the screen to the view that failed. A reset that the host calls from inside this handler does nothing, because no input changed between the two attempts, and a reset after `disconnect()` does nothing. A reset belongs to ONE connection. `connect()` starts a connection, and the reset of a report of an older connection does nothing. A host that calls `connect()` again from inside this handler abandons the connection that reported. The "Retry" button of that report must not render into the connection that took its place. Call the reset of the newest report. This option matches the `onError` prop of the framework renderer providers, and the five renderers hold the same three rules for the reset. | - | [packages/play-dom/src/types.ts:100](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/types.ts#L100) |
|
|
29
|
+
| <a id="property-onrendererror"></a> `onRenderError?` | [`RenderErrorHandler`](../type-aliases/RenderErrorHandler.md) | Unified error handler for component render errors and action handler rejections. Matches `RenderErrorHandler = (error: unknown, name: string) => void`. Invoked for three distinct error classes: - `(error, elementType)` — when a component renderer throws synchronously during `renderSpec` - `(error, actionName)` — when an action handler rejects during `emit()` (on-event path) - `(error, actionName)` — when an action handler rejects during a `watch` binding callback When provided, suppresses the `console.error` fallback for all three error types. Forwarded into `renderSpec` as the `onRenderError` parameter and into `DomRenderContext.onRenderError` so both `emit()` and `watch` handlers route their errors through the same channel as component render errors. **Example** `renderSpec(spec, store, registry, { onRenderError: (err, name) => { myErrorReporter.capture(err, { context: name }); }, });` | [`UIProviderOptions`](UIProviderOptions.md).[`onRenderError`](UIProviderOptions.md#property-onrendererror) | - |
|
|
30
|
+
| <a id="property-registryresult"></a> `registryResult?` | [`DefineRegistryResult`](DefineRegistryResult.md) | The result of `defineRegistry`. It gives the registry and the factory of the handlers. With this option, `PlayRenderer` connects `setState` and `getState` of the `StateStore` on @xstate/store to the factory of the handlers for you. This is the preferred way, because each action then always receives a live `setState` and a live `state` on the current store. | - | [packages/play-dom/src/types.ts:32](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/types.ts#L32) |
|
|
31
|
+
| <a id="property-store"></a> `store?` | `StateStore` | The optional external StateStore, for example from `xstateStoreStateStore` in @xmachines/json-render-xstate. With this option, `PlayRenderer` works in the controlled mode: it ignores `spec.state`, and this store is the single source of truth of the UI state, such as a form value. Without this option, the renderer makes a new `@xstate/store` atom for each view transition, with the values of `spec.state`. | - | [packages/play-dom/src/types.ts:42](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/types.ts#L42) |
|
|
32
|
+
| <a id="property-validationfunctions"></a> `validationFunctions?` | `Record`\<`string`, (`value`, `args?`) => `boolean`\> | Custom validation functions for inline field validation. Each function receives `(value, args?)` and returns `true` (valid) or `false` (invalid). Functions are available to component implementations via `ctx.ctx.validationFunctions` and should be passed as `customFunctions` to `runValidationCheck` / `runValidation` from `@xmachines/json-render-core`. Mirrors `customFunctions` in `ValidationProvider` from the framework renderers. The DOM renderer has no automatic `ValidationProvider` tree — validation must be invoked explicitly by component implementations. **Example** `import { runValidationCheck } from "@xmachines/json-render-core"; renderSpec(spec, store, registry, { validationFunctions: { isEven: (value) => typeof value === "number" && value % 2 === 0, phoneNumber: (value) => /^\+?[\d\s\-()]{7,}$/.test(String(value)), }, }); // Inside a ComponentFn: const MyField: ComponentFn<typeof catalog, "MyField"> = ({ ctx }) => { const result = runValidationCheck( { type: "isEven", message: "must be even" }, { value: someValue, stateModel: {}, customFunctions: ctx.ctx.validationFunctions }, ); // result.valid, result.message };` | [`UIProviderOptions`](UIProviderOptions.md).[`validationFunctions`](UIProviderOptions.md#property-validationfunctions) | - |
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[API](../../../README.md) / [@xmachines/play-dom](../README.md) / Cleanup
|
|
2
|
+
|
|
3
|
+
# Type Alias: Cleanup
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type Cleanup = () => void & { [Key in DisposeKey]: () => void };
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play/src/disposable.ts:66](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play/src/disposable.ts#L66)
|
|
10
|
+
|
|
11
|
+
The release of a subscription. A caller runs it, or a scope releases it.
|
|
12
|
+
|
|
13
|
+
The type is a function AND a `Disposable`, so one value serves both forms. A caller
|
|
14
|
+
that holds the release in a field and runs it from a teardown keeps that code. A
|
|
15
|
+
caller inside one scope writes `using` and writes no teardown at all:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// The explicit form. It stays correct.
|
|
19
|
+
const stop = watchSignal(count, render);
|
|
20
|
+
stop();
|
|
21
|
+
|
|
22
|
+
// The scoped form. The scope releases it, and an exception releases it too.
|
|
23
|
+
{
|
|
24
|
+
using stop = watchSignal(count, render);
|
|
25
|
+
render(count.get());
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`using` needs Node 24 or a browser with Explicit Resource Management, and it needs
|
|
30
|
+
`"lib": ["ESNext"]` of the consumer. The publishable packages build at
|
|
31
|
+
`target: "esnext"` and pass the syntax through, so the bundler of the consumer decides
|
|
32
|
+
how to emit it. The `Cleanup` VALUE needs neither: a runtime without `Symbol.dispose`
|
|
33
|
+
still calls it as a function, and a consumer that declares a lower `lib` still reads
|
|
34
|
+
the type. See [DisposeKey](../../play/index/type-aliases/DisposeKey.md) for the second half of that.
|
|
35
|
+
|
|
36
|
+
## See
|
|
37
|
+
|
|
38
|
+
[Play RFC](../../../../rfc/play.md)
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
# Type Alias: MountFn
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
type MountFn = (actor, container, options?) =>
|
|
6
|
+
type MountFn = (actor, container, options?) => Cleanup;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/play-dom/src/create-play-ui.ts:
|
|
9
|
+
Defined in: [packages/play-dom/src/create-play-ui.ts:94](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v4.0.0/packages/play-dom/src/create-play-ui.ts#L94)
|
|
10
10
|
|
|
11
11
|
The mount function that `createPlayUI` returns.
|
|
12
12
|
|
|
@@ -14,14 +14,36 @@ Call it with `(actor, container, mountOptions?)` to start the renderer.
|
|
|
14
14
|
It returns a `disconnect` cleanup function. That function stops the render and
|
|
15
15
|
clears the container.
|
|
16
16
|
|
|
17
|
+
The return is the release of the mount. A caller runs it, or a scope releases it:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const mount = createPlayUI(registryResult);
|
|
21
|
+
{
|
|
22
|
+
using stop = mount(actor, container);
|
|
23
|
+
// stop() runs at the end of the scope, and after an exception too
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
A `Cleanup` IS a `() => void`, so a caller that runs the release keeps that code. A
|
|
28
|
+
consumer that WRITES a value of this type — a wrapper of a mount, or a stand-in for
|
|
29
|
+
one — builds its release with `asCleanup` of `@xmachines/play`, which this package
|
|
30
|
+
re-exports:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const mount: MountFn = (actor, container, options) => {
|
|
34
|
+
const stop = realMount(actor, container, options);
|
|
35
|
+
return asCleanup(() => stop());
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
17
39
|
## Parameters
|
|
18
40
|
|
|
19
|
-
| Parameter | Type
|
|
20
|
-
| ----------- |
|
|
21
|
-
| `actor` | [`
|
|
22
|
-
| `container` | `HTMLElement`
|
|
23
|
-
| `options?` | [`MountOptions`](../interfaces/MountOptions.md)
|
|
41
|
+
| Parameter | Type |
|
|
42
|
+
| ----------- | -------------------------------------------------------------- |
|
|
43
|
+
| `actor` | [`ViewActor`](../../play-view/index/type-aliases/ViewActor.md) |
|
|
44
|
+
| `container` | `HTMLElement` |
|
|
45
|
+
| `options?` | [`MountOptions`](../interfaces/MountOptions.md) |
|
|
24
46
|
|
|
25
47
|
## Returns
|
|
26
48
|
|
|
27
|
-
()
|
|
49
|
+
[`Cleanup`](Cleanup.md)
|
|
@@ -4,22 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
**Vanilla DOM router (Browser History API) for XMachines Play Architecture.**
|
|
6
6
|
|
|
7
|
-
[](https://opensource.org/licenses/MIT) [](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-dom-router)
|
|
8
8
|
|
|
9
9
|
This framework-agnostic router integration keeps the `currentRoute` TC39 Signal of a Play actor and the `window.history` API of the browser in step. It needs no framework. It implements the same [`RouterBridgeBase`](../play-router/README.md) pattern as every other router adapter in the XMachines ecosystem.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
pnpm add @xmachines/play-dom-router @xmachines/play-router
|
|
14
|
+
pnpm add @xmachines/play-dom-router @xmachines/play-router
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Peer dependency:
|
|
17
|
+
**Peer dependency.** Install it with the package:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
pnpm add
|
|
20
|
+
pnpm add @xmachines/play
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
- `@xmachines/play` — the release protocol. This barrel re-exports `asCleanup`, `DISPOSE` and `Cleanup` from it.
|
|
24
|
+
|
|
25
|
+
`@xmachines/play-router` is a dependency of this package already. Install it directly to
|
|
26
|
+
reach `@xmachines/play-router/xstate`, which holds `createRouteMap` and
|
|
27
|
+
`extractMachineRoutes`.
|
|
28
|
+
|
|
23
29
|
## Overview
|
|
24
30
|
|
|
25
31
|
[`@xmachines/play-dom-router`](README.md) connects a Play actor to the browser URL through the `DomRouterBridge` (extends `RouterBridgeBase` from [`@xmachines/play-router`](../play-router/README.md)):
|
|
@@ -33,32 +39,55 @@ pnpm add xstate@^5.31.0
|
|
|
33
39
|
|
|
34
40
|
| Export | Description |
|
|
35
41
|
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
36
|
-
| `createBrowserHistory(options)` | Wraps `window.history
|
|
37
|
-
| `createRouter(options)` | Creates a `VanillaRouter` from a `BrowserHistory` and a `RouteTree`
|
|
38
|
-
| `connectRouter(options)` | Connects a
|
|
42
|
+
| `createBrowserHistory(options)` | Wraps `window.history`. It returns a `BrowserHistory`, which `using` releases |
|
|
43
|
+
| `createRouter(options)` | Creates a `VanillaRouter` from a `BrowserHistory` and a `RouteTree`, which `using` releases |
|
|
44
|
+
| `connectRouter(options)` | Connects a history to a `Routable` actor — returns a `RouterConnection`, which `using` releases |
|
|
39
45
|
| `DomRouterBridge` | The low-level bridge class. It extends `RouterBridgeBase`. Use it directly for full lifecycle control |
|
|
40
|
-
| `
|
|
41
|
-
| `BrowserHistory` | Interface for the history wrapper |
|
|
46
|
+
| `BrowserHistory` | Interface for the history wrapper. Implement it to inject a history of your own — see the note below |
|
|
42
47
|
| `BrowserWindow` | Structural window interface (accepts `Window`, JSDOM, or any test double) |
|
|
43
|
-
| `VanillaRouter` |
|
|
48
|
+
| `VanillaRouter` | The router wrapper: a history, a route tree, and the release of the history under two keys |
|
|
44
49
|
| `ConnectRouterOptions` | Options type for `connectRouter` |
|
|
45
50
|
| `RouteLookupContract` | Structural interface for bidirectional route lookup |
|
|
46
51
|
| `RoutableActor` | Minimal actor interface from `@xmachines/play-router` — `currentRoute`, `initialRoute`, and `send(PlayRouteEvent)` |
|
|
47
52
|
| `RouterBridge`, `PlayRouteEvent` | Types re-exported from `@xmachines/play-router` |
|
|
48
|
-
| `RouteMap`, `RouteMapping`, `RouteMapOptions` |
|
|
53
|
+
| `RouteMap`, `RouteMapping`, `RouteMapOptions` | The route map class and its types, re-exported from `@xmachines/play-router` |
|
|
54
|
+
| `asCleanup`, `DISPOSE`, `Cleanup` | The release protocol that `BrowserHistory` names, re-exported from `@xmachines/play` |
|
|
55
|
+
|
|
56
|
+
### Implementing `BrowserHistory`
|
|
57
|
+
|
|
58
|
+
`subscribe` returns a `Cleanup`, and the history carries the dispose key. A history that you inject for a test or for SSR therefore writes two things that a plain object does not:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { asCleanup, DISPOSE, type BrowserHistory } from "@xmachines/play-dom-router";
|
|
62
|
+
|
|
63
|
+
const history: BrowserHistory = {
|
|
64
|
+
// ...
|
|
65
|
+
subscribe(listener) {
|
|
66
|
+
listeners.add(listener);
|
|
67
|
+
return asCleanup(() => void listeners.delete(listener));
|
|
68
|
+
},
|
|
69
|
+
destroy() {
|
|
70
|
+
listeners.clear();
|
|
71
|
+
},
|
|
72
|
+
[DISPOSE]() {
|
|
73
|
+
this.destroy();
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`asCleanup` gives the function back as itself, with the dispose key added, so a caller that runs the release keeps that code. A caller that writes `using` releases at the end of the scope, and after an exception too.
|
|
79
|
+
|
|
80
|
+
Of this interface `connectRouter` reads three members — `location`, `push` and `subscribe` — and it releases the history never. The type asks for the whole of it, because that is the type of a history, and a test that stands in for one builds it from a factory rather than from a narrower type.
|
|
49
81
|
|
|
50
82
|
## Quick Start
|
|
51
83
|
|
|
52
84
|
```typescript
|
|
53
85
|
import { createMachine } from "xstate";
|
|
54
|
-
import { definePlayer,
|
|
55
|
-
import {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
createRouteMap,
|
|
60
|
-
} from "@xmachines/play-dom-router";
|
|
61
|
-
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
86
|
+
import { definePlayer, compose, PlayerActor } from "@xmachines/play-xstate";
|
|
87
|
+
import { formatPlayRouteTransitions, withRouting } from "@xmachines/play-xstate/routing";
|
|
88
|
+
import { createBrowserHistory, createRouter, connectRouter } from "@xmachines/play-dom-router";
|
|
89
|
+
import { createRouteMap } from "@xmachines/play-router/xstate";
|
|
90
|
+
import { extractMachineRoutes } from "@xmachines/play-router/xstate";
|
|
62
91
|
|
|
63
92
|
// 1. Define a routable machine — states carry meta.route
|
|
64
93
|
const machine = createMachine(
|
|
@@ -82,8 +111,8 @@ const history = createBrowserHistory({ window });
|
|
|
82
111
|
// 4. Create router
|
|
83
112
|
const router = createRouter({ routeTree, history });
|
|
84
113
|
|
|
85
|
-
// 5. Start actor and connect
|
|
86
|
-
const actor = definePlayer({ machine })();
|
|
114
|
+
// 5. Start actor and connect — `connectRouter` needs the routing capability
|
|
115
|
+
const actor = definePlayer({ machine, actor: compose(PlayerActor, withRouting) })();
|
|
87
116
|
actor.start();
|
|
88
117
|
|
|
89
118
|
const disconnect = connectRouter({ actor, router, routeMap });
|
|
@@ -121,17 +150,17 @@ history.destroy();
|
|
|
121
150
|
|
|
122
151
|
**`BrowserHistory` interface:**
|
|
123
152
|
|
|
124
|
-
| Method | Description
|
|
125
|
-
| ----------------------- |
|
|
126
|
-
| `location` | Read-only `{ pathname, search, hash, state }`
|
|
127
|
-
| `push(path, state?)` | Push a new entry to history
|
|
128
|
-
| `replace(path, state?)` | Replace the current history entry
|
|
129
|
-
| `go(delta)` | Navigate relative to current position
|
|
130
|
-
| `back()` | Navigate backward
|
|
131
|
-
| `forward()` | Navigate forward
|
|
132
|
-
| `subscribe(listener)` | Subscribe to location changes — returns unsubscribe function
|
|
133
|
-
| `createHref(path)` | Create an href from a path
|
|
134
|
-
| `destroy()` | Cleans up. It removes the listeners, and it restores the patched methods when it is the last wrapper
|
|
153
|
+
| Method | Description |
|
|
154
|
+
| ----------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
155
|
+
| `location` | Read-only `{ pathname, search, hash, state }` |
|
|
156
|
+
| `push(path, state?)` | Push a new entry to history |
|
|
157
|
+
| `replace(path, state?)` | Replace the current history entry |
|
|
158
|
+
| `go(delta)` | Navigate relative to current position |
|
|
159
|
+
| `back()` | Navigate backward |
|
|
160
|
+
| `forward()` | Navigate forward |
|
|
161
|
+
| `subscribe(listener)` | Subscribe to location changes — returns an unsubscribe function, a `Cleanup` from `createBrowserHistory` |
|
|
162
|
+
| `createHref(path)` | Create an href from a path |
|
|
163
|
+
| `destroy()` | Cleans up. It removes the listeners, and it restores the patched methods when it is the last wrapper |
|
|
135
164
|
|
|
136
165
|
**`BrowserWindow` interface:**
|
|
137
166
|
|
|
@@ -149,9 +178,22 @@ const router = createRouter({ routeTree, history });
|
|
|
149
178
|
// router.destroy() — calls history.destroy()
|
|
150
179
|
```
|
|
151
180
|
|
|
181
|
+
Or let a scope release it, which also releases the history on an exception:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
using router = createRouter({ routeTree, history });
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The dispose key and `destroy()` run the same body, and the release is idempotent, so a
|
|
188
|
+
caller that keeps `destroy()` keeps it.
|
|
189
|
+
|
|
190
|
+
**The release covers the history alone.** `connectRouter` hands back its own
|
|
191
|
+
`RouterConnection`, and a scope that ends releases no connection for you. Release the
|
|
192
|
+
connection first, then the router.
|
|
193
|
+
|
|
152
194
|
### `connectRouter(options)`
|
|
153
195
|
|
|
154
|
-
This function connects a
|
|
196
|
+
This function connects a history to a `Routable` actor. It does all the work in both directions:
|
|
155
197
|
|
|
156
198
|
- On connect: it sets the actor state from the initial URL, or it writes the actor route to the browser. The bridge detects a restore and a deep link.
|
|
157
199
|
- While it is connected: each actor route change goes to the history, and each browser navigation sends a `play.route` event.
|
|
@@ -159,8 +201,8 @@ This function connects a `VanillaRouter` to a `Routable` actor. It does all the
|
|
|
159
201
|
|
|
160
202
|
```typescript
|
|
161
203
|
const disconnect = connectRouter({
|
|
162
|
-
actor, // RoutableActor —
|
|
163
|
-
router, //
|
|
204
|
+
actor, // RoutableActor — an actor of the `PlayActor` contract that adds `Routable` satisfies this structurally
|
|
205
|
+
router, // the router from createRouter(), or any { history }
|
|
164
206
|
routeMap, // RouteLookupContract — any object with getStateIdByPath / getPathByStateId
|
|
165
207
|
});
|
|
166
208
|
|
|
@@ -170,11 +212,11 @@ disconnect();
|
|
|
170
212
|
|
|
171
213
|
**`ConnectRouterOptions`:**
|
|
172
214
|
|
|
173
|
-
| Option | Type | Description
|
|
174
|
-
| ---------- | --------------------- |
|
|
175
|
-
| `actor` | `RoutableActor` | The actor to keep in step with the browser URL
|
|
176
|
-
| `router` | `
|
|
177
|
-
| `routeMap` | `RouteLookupContract` | Bidirectional path ↔ state ID lookup
|
|
215
|
+
| Option | Type | Description |
|
|
216
|
+
| ---------- | --------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
217
|
+
| `actor` | `RoutableActor` | The actor to keep in step with the browser URL |
|
|
218
|
+
| `router` | `{ history }` | The router from `createRouter()`, or any `{ history }`. Of the history it reads `location`, `push` and `subscribe` |
|
|
219
|
+
| `routeMap` | `RouteLookupContract` | Bidirectional path ↔ state ID lookup |
|
|
178
220
|
|
|
179
221
|
**`RouteLookupContract`:**
|
|
180
222
|
|
|
@@ -187,44 +229,18 @@ interface RouteLookupContract {
|
|
|
187
229
|
|
|
188
230
|
The bridge accepts every object that implements this structural interface. A `RouteMap` instance from `@xmachines/play-router`, a subclass, and a test double all work.
|
|
189
231
|
|
|
190
|
-
### `createRouteMap`
|
|
232
|
+
### `createRouteMap` — from `@xmachines/play-router/xstate`
|
|
191
233
|
|
|
192
|
-
This
|
|
234
|
+
This package re-exports it never: the barrel names no state machine. The function builds a bidirectional `RouteMap` from an XState machine:
|
|
193
235
|
|
|
194
236
|
```typescript
|
|
195
|
-
import { createRouteMap } from "@xmachines/play-
|
|
196
|
-
|
|
237
|
+
import { createRouteMap } from "@xmachines/play-router/xstate";
|
|
197
238
|
// machine from the Quick Start above (states carry meta.route)
|
|
198
239
|
const routeMap = createRouteMap(machine);
|
|
199
240
|
routeMap.getStateIdByPath("/dashboard"); // "dashboard"
|
|
200
241
|
routeMap.getPathByStateId("dashboard"); // "/dashboard"
|
|
201
242
|
```
|
|
202
243
|
|
|
203
|
-
## URLPattern Support
|
|
204
|
-
|
|
205
|
-
This package matches each route pattern with the [URLPattern API](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern), through [`@xmachines/play-router`](../play-router/README.md). URLPattern is native in Node.js 24+ and in a modern browser (Chrome 95+, Firefox 117+, Safari 16.4+). In an older environment, load a polyfill **before** you import this package. See [`@xmachines/play-router`](../play-router/README.md) for the details.
|
|
206
|
-
|
|
207
|
-
## Testing
|
|
208
|
-
|
|
209
|
-
Run tests in isolation:
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
pnpm test
|
|
213
|
-
# or from monorepo root:
|
|
214
|
-
pnpm --filter @xmachines/play-dom-router test
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
The tests run in a Node.js environment with the `URLPattern` polyfill setup. The browser tests are in `test/browser/`. They run separately, through `vitest.browser.config.ts`.
|
|
218
|
-
|
|
219
|
-
Coverage thresholds:
|
|
220
|
-
|
|
221
|
-
| Type | Threshold |
|
|
222
|
-
| ---------- | --------- |
|
|
223
|
-
| Lines | 80% |
|
|
224
|
-
| Functions | 80% |
|
|
225
|
-
| Branches | 75% |
|
|
226
|
-
| Statements | 80% |
|
|
227
|
-
|
|
228
244
|
## Architecture
|
|
229
245
|
|
|
230
246
|
The bridge-first data flow:
|
|
@@ -253,10 +269,12 @@ Browser URL
|
|
|
253
269
|
|
|
254
270
|
## Related Packages
|
|
255
271
|
|
|
256
|
-
- [@xmachines/play-router](../play-router/README.md) — `RouterBridgeBase`, `
|
|
257
|
-
- [@xmachines/play-
|
|
272
|
+
- [@xmachines/play-router](../play-router/README.md) — `RouterBridgeBase`, `RouteMap`, `Routable`
|
|
273
|
+
- [@xmachines/play-router/xstate](../play-router/README.md) — `createRouteMap`, `extractMachineRoutes`
|
|
274
|
+
- [@xmachines/play-actor](../play-actor/README.md) — `PlayActor`; an actor that adds `Routable` satisfies `RoutableActor` structurally
|
|
258
275
|
- [@xmachines/play-dom](../play-dom/README.md) — the vanilla DOM renderer, for the view beside the routing
|
|
259
276
|
- [@xmachines/play-xstate](../play-xstate/README.md) — `definePlayer`, `PlayerActor`
|
|
277
|
+
- [Routing guide](../../../guides/routing.md) — the URLPattern language that a `meta.route` path declares
|
|
260
278
|
|
|
261
279
|
## License
|
|
262
280
|
|
|
@@ -265,6 +283,7 @@ MIT — see [LICENSE](LICENSE).
|
|
|
265
283
|
## Classes
|
|
266
284
|
|
|
267
285
|
- [DomRouterBridge](classes/DomRouterBridge.md)
|
|
286
|
+
- [RouteMap](classes/RouteMap.md)
|
|
268
287
|
|
|
269
288
|
## Interfaces
|
|
270
289
|
|
|
@@ -275,16 +294,23 @@ MIT — see [LICENSE](LICENSE).
|
|
|
275
294
|
- [PlayRouteEvent](interfaces/PlayRouteEvent.md)
|
|
276
295
|
- [RoutableActor](interfaces/RoutableActor.md)
|
|
277
296
|
- [RouteLookupContract](interfaces/RouteLookupContract.md)
|
|
278
|
-
- [RouteMap](interfaces/RouteMap.md)
|
|
279
297
|
- [RouteMapOptions](interfaces/RouteMapOptions.md)
|
|
280
298
|
- [RouteMapping](interfaces/RouteMapping.md)
|
|
281
299
|
- [RouterBridge](interfaces/RouterBridge.md)
|
|
282
300
|
- [RouterConnection](interfaces/RouterConnection.md)
|
|
283
301
|
- [VanillaRouter](interfaces/VanillaRouter.md)
|
|
284
302
|
|
|
303
|
+
## Type Aliases
|
|
304
|
+
|
|
305
|
+
- [Cleanup](type-aliases/Cleanup.md)
|
|
306
|
+
|
|
307
|
+
## Variables
|
|
308
|
+
|
|
309
|
+
- [DISPOSE](variables/DISPOSE.md)
|
|
310
|
+
|
|
285
311
|
## Functions
|
|
286
312
|
|
|
313
|
+
- [asCleanup](functions/asCleanup.md)
|
|
287
314
|
- [connectRouter](functions/connectRouter.md)
|
|
288
315
|
- [createBrowserHistory](functions/createBrowserHistory.md)
|
|
289
|
-
- [createRouteMap](functions/createRouteMap.md)
|
|
290
316
|
- [createRouter](functions/createRouter.md)
|