@xmachines/docs 2.0.0 → 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 +11 -13
- package/api/@xmachines/play/README.md +58 -63
- package/api/@xmachines/play/classes/NonNullableError.md +7 -7
- package/api/@xmachines/play/classes/PlayError.md +25 -27
- package/api/@xmachines/play/functions/assertNonNullable.md +17 -17
- package/api/@xmachines/play/type-aliases/PlayEvent.md +26 -25
- package/api/@xmachines/play-actor/README.md +72 -63
- package/api/@xmachines/play-actor/classes/AbstractActor.md +39 -39
- package/api/@xmachines/play-actor/functions/attachRenderErrorHandler.md +19 -18
- package/api/@xmachines/play-actor/functions/composePlayState.md +9 -8
- package/api/@xmachines/play-actor/functions/createViewStoreLifecycle.md +5 -5
- package/api/@xmachines/play-actor/functions/guardContextWrites.md +27 -25
- package/api/@xmachines/play-actor/functions/refreshContextSubtree.md +12 -11
- package/api/@xmachines/play-actor/functions/reuseComposedState.md +23 -22
- package/api/@xmachines/play-actor/functions/shallowEqualExcept.md +6 -5
- package/api/@xmachines/play-actor/functions/toAtomState.md +16 -14
- package/api/@xmachines/play-actor/functions/typedSpec.md +12 -11
- 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 -13
- package/api/@xmachines/play-actor/interfaces/ResolveViewStoreOptions.md +4 -4
- package/api/@xmachines/play-actor/interfaces/Routable.md +4 -4
- package/api/@xmachines/play-actor/interfaces/ViewStoreLifecycle.md +11 -11
- package/api/@xmachines/play-actor/interfaces/ViewStoreResolution.md +7 -7
- package/api/@xmachines/play-actor/interfaces/Viewable.md +9 -9
- package/api/@xmachines/play-actor/variables/CONTEXT_STATE_KEY.md +5 -5
- package/api/@xmachines/play-dom/README.md +119 -85
- 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/interfaces/CreatePlayUIOptions.md +8 -8
- package/api/@xmachines/play-dom/interfaces/MountOptions.md +9 -9
- package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +9 -9
- package/api/@xmachines/play-dom/type-aliases/MountFn.md +5 -5
- package/api/@xmachines/play-dom-router/README.md +66 -49
- 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 +19 -18
- package/api/@xmachines/play-dom-router/interfaces/ConnectRouterOptions.md +7 -7
- package/api/@xmachines/play-dom-router/interfaces/PlayRouteEvent.md +39 -33
- 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 +63 -54
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +14 -13
- package/api/@xmachines/play-react/functions/useActor.md +1 -1
- 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/PlayErrorBoundaryProps.md +7 -7
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +4 -4
- 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 +37 -28
- 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 +39 -33
- 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 +94 -82
- 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 +4 -4
- package/api/@xmachines/play-router/interfaces/LocationLike.md +9 -9
- package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +7 -7
- 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 +39 -33
- 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 +3 -3
- 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 +34 -29
- 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 +39 -39
- package/api/@xmachines/play-solid-router/interfaces/PlayActor.md +22 -20
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +39 -33
- 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 +40 -31
- 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 +25 -25
- 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 +39 -33
- 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 +38 -34
- 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 +9 -9
- package/api/@xmachines/play-sveltekit-router/interfaces/PlayRouteEvent.md +39 -33
- 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 +66 -48
- 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 +39 -33
- 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 +37 -17
- 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 +71 -45
- 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 +39 -33
- 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 +37 -35
- 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/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 +2 -2
- 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 +65 -56
- 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 +39 -33
- 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 +72 -70
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +123 -112
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +19 -16
- package/api/@xmachines/play-xstate/functions/composeGuards.md +25 -23
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +20 -20
- package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +15 -15
- 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 +8 -8
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +16 -13
- package/api/@xmachines/play-xstate/functions/hasContext.md +8 -8
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +10 -10
- package/api/@xmachines/play-xstate/functions/negateGuard.md +19 -18
- 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 -10
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +15 -14
- package/api/@xmachines/play-xstate/interfaces/RouteObject.md +2 -2
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +5 -5
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +9 -9
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +4 -3
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +7 -7
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +12 -12
- package/api/@xmachines/play-xstate/type-aliases/RouteMetadata.md +1 -1
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +15 -14
- package/api/@xmachines/shared/README.md +11 -13
- 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 +1 -1
- package/api/@xmachines/shared/vitest/interfaces/XmBrowserConfigOptions.md +4 -4
- package/contributing/development.md +28 -0
- package/guides/inspector.md +1 -1
- package/package.json +1 -1
- package/api/@xmachines/play-vue/functions/getPlayViewContext.md +0 -28
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: DefineRegistryOptions\<C\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-svelte/src/define-registry.ts:
|
|
5
|
+
Defined in: [packages/play-svelte/src/define-registry.ts:94](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/define-registry.ts#L94)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The options of `defineRegistry`.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
`Record<string, DefineRegistryActionFn>`
|
|
9
|
+
The shape is the same as the shape above it, but the untyped
|
|
10
|
+
`Record<string, DefineRegistryActionFn>` becomes the catalog-typed `Actions<C>` map.
|
|
11
11
|
|
|
12
12
|
## Type Parameters
|
|
13
13
|
|
|
@@ -17,8 +17,8 @@ Mirrors the upstream shape but replaces the untyped
|
|
|
17
17
|
|
|
18
18
|
## Properties
|
|
19
19
|
|
|
20
|
-
| Property | Type | Description
|
|
21
|
-
| ---------------------------------------------------- | ------------------------------------------------------------- |
|
|
22
|
-
| <a id="property-actions"></a> `actions?` | [`Actions`](../type-aliases/Actions.md)\<`C`\> |
|
|
23
|
-
| <a id="property-components"></a> `components?` | `Components`\<`C`\> | Svelte component implementations
|
|
24
|
-
| <a id="property-onrendererror"></a> `onRenderError?` | [`RenderErrorHandler`](../type-aliases/RenderErrorHandler.md) |
|
|
20
|
+
| Property | Type | Description | Defined in |
|
|
21
|
+
| ---------------------------------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
22
|
+
| <a id="property-actions"></a> `actions?` | [`Actions`](../type-aliases/Actions.md)\<`C`\> | The catalog-typed map of the action handlers. Each handler receives `params` with the exact schema of the catalog action, or `undefined` when the caller gives no params. It also receives the `setState` argument and the `state` argument of the package above. Test for `undefined` before you read a param: **Example** `actions: { login: async (params) => { if (!params) return; actor.send({ type: "auth.login", username: params.username }); }, logout: async () => actor.send({ type: "auth.logout" }), }` | [packages/play-svelte/src/define-registry.ts:118](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/define-registry.ts#L118) |
|
|
23
|
+
| <a id="property-components"></a> `components?` | `Components`\<`C`\> | The Svelte component implementations, with the catalog component name as the key. | [packages/play-svelte/src/define-registry.ts:98](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/define-registry.ts#L98) |
|
|
24
|
+
| <a id="property-onrendererror"></a> `onRenderError?` | [`RenderErrorHandler`](../type-aliases/RenderErrorHandler.md) | The callback that the renderer calls when a catalog component throws during a render. The inner `<svelte:boundary>` of `@xmachines/json-render-svelte` catches the error, and that boundary wraps each element. With this callback, the default `console.error(...)` fallback does not run: the renderer removes the component from the DOM, and your callback receives the error and the name of the element type. You can then report the error, or you can recover from it. **Example** `const { registry, handlers } = defineRegistry(authCatalog, { components: { Login, Dashboard }, actions: { ... }, onRenderError(error, elementType) { console.warn(`Component <${elementType}> crashed:`, error); reportToSentry(error, { componentType: elementType }); }, });` **Param** **error** The value that the component threw. It is not always an `Error` instance. **Param** **elementType** The name of the catalog component that failed, for example `"Dashboard"`. | [packages/play-svelte/src/define-registry.ts:143](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/define-registry.ts#L143) |
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: PlayUIProviderProps
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-svelte/src/actor-context.svelte.ts:
|
|
5
|
+
Defined in: [packages/play-svelte/src/actor-context.svelte.ts:82](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L82)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`DefineRegistryResult` type
|
|
10
|
-
`@xmachines/json-render-core
|
|
7
|
+
The framework-agnostic base props. Every `ActorProvider` implementation shares
|
|
8
|
+
them: React, Vue, Solid, and Svelte. `TRegistry` holds the
|
|
9
|
+
`DefineRegistryResult` type of the framework. `RenderErrorHandler` comes from
|
|
10
|
+
`@xmachines/json-render-core`, and a second generic parameter is therefore not
|
|
11
|
+
necessary.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
Each framework package extends this interface with its `fallback` field, its
|
|
14
|
+
`onError` field, and its `children` field.
|
|
13
15
|
|
|
14
16
|
## Example
|
|
15
17
|
|
|
@@ -29,15 +31,15 @@ interface ActorProviderProps extends BaseActorProviderProps<DefineRegistryResult
|
|
|
29
31
|
|
|
30
32
|
## Properties
|
|
31
33
|
|
|
32
|
-
| Property | Type | Description
|
|
33
|
-
| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
-
| <a id="property-actor"></a> `actor` | [`AbstractActor`](../../play-actor/classes/AbstractActor.md)\<[`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\> & [`Viewable`](../../play-actor/interfaces/Viewable.md) |
|
|
35
|
-
| <a id="property-children"></a> `children` | `Snippet` | -
|
|
36
|
-
| <a id="property-fallback"></a> `fallback?` | `Snippet`\<\[\]\> | -
|
|
37
|
-
| <a id="property-functions"></a> `functions?` | `Record`\<`string`, `unknown`\> | -
|
|
38
|
-
| <a id="property-navigate"></a> `navigate?` | (`path`) => `void` | -
|
|
39
|
-
| <a id="property-onerror"></a> `onError?` | (`error`, `reset`) => `void` | -
|
|
40
|
-
| <a id="property-onrendererror"></a> `onRenderError?` | [`RenderErrorHandler`](../type-aliases/RenderErrorHandler.md) |
|
|
41
|
-
| <a id="property-registryresult"></a> `registryResult` | `DefineRegistryResult` |
|
|
42
|
-
| <a id="property-store"></a> `store?` | `StateStore` |
|
|
43
|
-
| <a id="property-validationfunctions"></a> `validationFunctions?` | `Record`\<`string`, (`value`, `args?`) => `boolean`\> | -
|
|
34
|
+
| Property | Type | Description | Inherited from | Defined in |
|
|
35
|
+
| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| <a id="property-actor"></a> `actor` | [`AbstractActor`](../../play-actor/classes/AbstractActor.md)\<[`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\> & [`Viewable`](../../play-actor/interfaces/Viewable.md) | The actor instance with the currentView signal. It requires the Viewable capability. | [`ActorProviderProps`](ActorProviderProps.md).[`actor`](ActorProviderProps.md#property-actor) | [packages/play-actor/src/abstract-actor.ts:163](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-actor/src/abstract-actor.ts#L163) |
|
|
37
|
+
| <a id="property-children"></a> `children` | `Snippet` | - | [`ActorProviderProps`](ActorProviderProps.md).[`children`](ActorProviderProps.md#property-children) | [packages/play-svelte/src/actor-context.svelte.ts:75](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L75) |
|
|
38
|
+
| <a id="property-fallback"></a> `fallback?` | `Snippet`\<\[\]\> | - | [`ActorProviderProps`](ActorProviderProps.md).[`fallback`](ActorProviderProps.md#property-fallback) | [packages/play-svelte/src/actor-context.svelte.ts:73](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L73) |
|
|
39
|
+
| <a id="property-functions"></a> `functions?` | `Record`\<`string`, `unknown`\> | - | - | [packages/play-svelte/src/actor-context.svelte.ts:88](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L88) |
|
|
40
|
+
| <a id="property-navigate"></a> `navigate?` | (`path`) => `void` | - | - | [packages/play-svelte/src/actor-context.svelte.ts:87](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L87) |
|
|
41
|
+
| <a id="property-onerror"></a> `onError?` | (`error`, `reset`) => `void` | - | [`ActorProviderProps`](ActorProviderProps.md).[`onError`](ActorProviderProps.md#property-onerror) | [packages/play-svelte/src/actor-context.svelte.ts:74](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L74) |
|
|
42
|
+
| <a id="property-onrendererror"></a> `onRenderError?` | [`RenderErrorHandler`](../type-aliases/RenderErrorHandler.md) | The provider calls it when one catalog component throws during a render. This handler replaces every onRenderError of defineRegistry. | [`ActorProviderProps`](ActorProviderProps.md).[`onRenderError`](ActorProviderProps.md#property-onrendererror) | [packages/play-actor/src/abstract-actor.ts:177](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-actor/src/abstract-actor.ts#L177) |
|
|
43
|
+
| <a id="property-registryresult"></a> `registryResult` | `DefineRegistryResult` | The complete result of defineRegistry(). It holds the component registry and the factory of the action handlers. | [`ActorProviderProps`](ActorProviderProps.md).[`registryResult`](ActorProviderProps.md#property-registryresult) | [packages/play-actor/src/abstract-actor.ts:165](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-actor/src/abstract-actor.ts#L165) |
|
|
44
|
+
| <a id="property-store"></a> `store?` | `StateStore` | The optional external StateStore, which is the controlled mode. With this option, the provider ignores spec.state, and this store is the single source of truth. Without it, the provider makes a new @xstate/store atom for each view transition, with the values of spec.state. | [`ActorProviderProps`](ActorProviderProps.md).[`store`](ActorProviderProps.md#property-store) | [packages/play-actor/src/abstract-actor.ts:172](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-actor/src/abstract-actor.ts#L172) |
|
|
45
|
+
| <a id="property-validationfunctions"></a> `validationFunctions?` | `Record`\<`string`, (`value`, `args?`) => `boolean`\> | - | - | [packages/play-svelte/src/actor-context.svelte.ts:83](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L83) |
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
# Interface: ViewContextValue
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play-svelte/src/actor-context.svelte.ts:
|
|
5
|
+
Defined in: [packages/play-svelte/src/actor-context.svelte.ts:51](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L51)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The framework-agnostic base of the `ViewContextValue` type in each framework.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
`registry`
|
|
11
|
-
type
|
|
9
|
+
It holds the three fields that are identical in React, Vue, Solid, and Svelte.
|
|
10
|
+
The `registry` field belongs to one framework, because each framework has its own
|
|
11
|
+
`ComponentRegistry` type. Therefore `TRegistry` gives its type, and this is the
|
|
12
|
+
same generic parameter as in `BaseActorProviderProps`.
|
|
12
13
|
|
|
13
14
|
## Extends
|
|
14
15
|
|
|
@@ -16,9 +17,9 @@ type) so it is typed via `TRegistry` — the same generic used in `BaseActorProv
|
|
|
16
17
|
|
|
17
18
|
## Properties
|
|
18
19
|
|
|
19
|
-
| Property | Type | Description
|
|
20
|
-
| ----------------------------------------- | ----------------------------------------------------- |
|
|
21
|
-
| <a id="property-handlers"></a> `handlers` | `Record`\<`string`, `ActionHandler`\> |
|
|
22
|
-
| <a id="property-registry"></a> `registry` | `TRegistry` |
|
|
23
|
-
| <a id="property-spec"></a> `spec` | [`PlaySpec`](../../play-actor/interfaces/PlaySpec.md) | The current PlaySpec to render.
|
|
24
|
-
| <a id="property-store"></a> `store` | `StateStore` | The active StateStore
|
|
20
|
+
| Property | Type | Description | Inherited from | Defined in |
|
|
21
|
+
| ----------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| <a id="property-handlers"></a> `handlers` | `Record`\<`string`, `ActionHandler`\> | The action handlers, resolved against the live StateStore. | [`BaseViewContextValue`](../../play-actor/interfaces/BaseViewContextValue.md).[`handlers`](../../play-actor/interfaces/BaseViewContextValue.md#property-handlers) | [packages/play-actor/src/abstract-actor.ts:127](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-actor/src/abstract-actor.ts#L127) |
|
|
23
|
+
| <a id="property-registry"></a> `registry` | `TRegistry` | The component registry, from registryResult.registry. | [`BaseViewContextValue`](../../play-actor/interfaces/BaseViewContextValue.md).[`registry`](../../play-actor/interfaces/BaseViewContextValue.md#property-registry) | [packages/play-actor/src/abstract-actor.ts:129](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-actor/src/abstract-actor.ts#L129) |
|
|
24
|
+
| <a id="property-spec"></a> `spec` | [`PlaySpec`](../../play-actor/interfaces/PlaySpec.md) | The current PlaySpec to render. | [`BaseViewContextValue`](../../play-actor/interfaces/BaseViewContextValue.md).[`spec`](../../play-actor/interfaces/BaseViewContextValue.md#property-spec) | [packages/play-actor/src/abstract-actor.ts:125](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-actor/src/abstract-actor.ts#L125) |
|
|
25
|
+
| <a id="property-store"></a> `store` | `StateStore` | The active StateStore. Give it to JSONUIProvider or JsonUIProvider as `store`, and the providers then share the state. | [`BaseViewContextValue`](../../play-actor/interfaces/BaseViewContextValue.md).[`store`](../../play-actor/interfaces/BaseViewContextValue.md#property-store) | [packages/play-actor/src/abstract-actor.ts:133](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-actor/src/abstract-actor.ts#L133) |
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
type AnyPlayActor = AbstractActor<AnyActorLogic> & Viewable;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/play-svelte/src/actor-context.svelte.ts:
|
|
9
|
+
Defined in: [packages/play-svelte/src/actor-context.svelte.ts:25](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-svelte/src/actor-context.svelte.ts#L25)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The actor type that the Svelte `ActorProvider` and `getActorContext` accept. It requires `Viewable` for the view rendering. For the complete routing and view shape, use `PlayActor` from `@xmachines/play-router`.
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# @xmachines/play-svelte-spa-router
|
|
4
4
|
|
|
5
|
-
> Svelte SPA Router adapter for the XMachines Play architecture
|
|
5
|
+
> Svelte SPA Router adapter for the XMachines Play architecture. It connects hash-based routing to a `Routable` actor, so the state machine owns the navigation.
|
|
6
6
|
|
|
7
|
-
[](https://opensource.org/licenses/MIT) [.
|
|
7
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play-svelte-spa-router)
|
|
10
8
|
|
|
11
9
|
---
|
|
12
10
|
|
|
@@ -16,7 +14,7 @@ Part of the [XMachines Play monorepo](../../README.md).
|
|
|
16
14
|
pnpm add @xmachines/play-svelte-spa-router
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
**Peer dependencies
|
|
17
|
+
**Peer dependencies.** Install them with the adapter:
|
|
20
18
|
|
|
21
19
|
```bash
|
|
22
20
|
pnpm add svelte@^5.0.0 svelte-spa-router@^5.0.0 xstate@^5.31.0
|
|
@@ -28,7 +26,7 @@ pnpm add svelte@^5.0.0 svelte-spa-router@^5.0.0 xstate@^5.31.0
|
|
|
28
26
|
|
|
29
27
|
### 1. Define a routable XState machine
|
|
30
28
|
|
|
31
|
-
Declare
|
|
29
|
+
Declare the route of each state in its `meta.route` field:
|
|
32
30
|
|
|
33
31
|
```typescript
|
|
34
32
|
import { setup } from "xstate";
|
|
@@ -52,33 +50,32 @@ const machine = setup({
|
|
|
52
50
|
|
|
53
51
|
### 2. Create a player and connect the router
|
|
54
52
|
|
|
55
|
-
Use `createRouteMap` to build a bidirectional route map from the machine
|
|
53
|
+
Use `createRouteMap` to build a bidirectional route map from the machine. Then call `connectRouter` one time, usually in your root Svelte component or in a dedicated runtime module:
|
|
56
54
|
|
|
57
55
|
```typescript
|
|
56
|
+
// runtime.ts
|
|
58
57
|
import { definePlayer } from "@xmachines/play-xstate";
|
|
59
58
|
import { connectRouter, createRouteMap } from "@xmachines/play-svelte-spa-router";
|
|
59
|
+
import { machine } from "./machine.js"; // defined in the previous example
|
|
60
60
|
|
|
61
61
|
const createPlayer = definePlayer({ machine });
|
|
62
62
|
export const actor = createPlayer();
|
|
63
63
|
actor.start();
|
|
64
64
|
|
|
65
65
|
const routeMap = createRouteMap(machine);
|
|
66
|
-
const disconnectRouter = connectRouter({ actor, routeMap });
|
|
66
|
+
export const disconnectRouter = connectRouter({ actor, routeMap });
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
### 3. Clean up on destroy
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
Give the cleanup function of `connectRouter` to `onDestroy`, or to the equivalent lifecycle hook:
|
|
72
72
|
|
|
73
73
|
```svelte
|
|
74
74
|
<script lang="ts">
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const routeMap = createRouteMap(machine);
|
|
79
|
-
const disconnect = connectRouter({ actor, routeMap });
|
|
75
|
+
import { onDestroy } from "svelte";
|
|
76
|
+
import { disconnectRouter } from "./runtime.js"; // the module from the previous example
|
|
80
77
|
|
|
81
|
-
|
|
78
|
+
onDestroy(() => disconnectRouter());
|
|
82
79
|
</script>
|
|
83
80
|
```
|
|
84
81
|
|
|
@@ -103,20 +100,20 @@ interface ConnectRouterOptions {
|
|
|
103
100
|
}
|
|
104
101
|
```
|
|
105
102
|
|
|
106
|
-
**
|
|
103
|
+
**Behavior:**
|
|
107
104
|
|
|
108
|
-
- On `connect`: reads the current hash URL
|
|
109
|
-
- On actor `currentRoute
|
|
110
|
-
- On `hashchange`:
|
|
111
|
-
- On disconnect: removes the `hashchange` listener and
|
|
105
|
+
- On `connect`: it reads the current hash URL from `router.loc.location`, sets the actor state with a `play.route` event, and then listens for a `hashchange` event.
|
|
106
|
+
- On a change of the actor `currentRoute`: it calls `push(path)` from svelte-spa-router to update the URL.
|
|
107
|
+
- On `hashchange`: it reads the new location from `router.loc` and sends `play.route` to the actor.
|
|
108
|
+
- On disconnect: it removes the `hashchange` listener and cancels the subscriptions to the actor signals.
|
|
112
109
|
|
|
113
110
|
### `createRouteMap(machine): RouteMap`
|
|
114
111
|
|
|
115
|
-
|
|
112
|
+
This function comes from `@xmachines/play-router`. It reads every `meta.route` entry of an XState machine. Then it builds a bidirectional route map with `URLPattern` matching, which includes a parameter segment and an optional segment.
|
|
116
113
|
|
|
117
114
|
### `RouteMap`
|
|
118
115
|
|
|
119
|
-
|
|
116
|
+
This type comes from `@xmachines/play-router`. It is the bidirectional map between the state IDs and the URL paths.
|
|
120
117
|
|
|
121
118
|
| Method | Description |
|
|
122
119
|
| --------------------------- | ---------------------------------------------- |
|
|
@@ -127,9 +124,9 @@ Re-exported from `@xmachines/play-router`. Bidirectional map between state IDs a
|
|
|
127
124
|
|
|
128
125
|
| Type | Description |
|
|
129
126
|
| ---------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
130
|
-
| `ConnectRouterOptions` |
|
|
127
|
+
| `ConnectRouterOptions` | The options that `connectRouter` accepts |
|
|
131
128
|
| `RoutableActor` | Minimal actor interface — `AbstractActor` from `@xmachines/play-actor` combined with the `Routable` mixin |
|
|
132
|
-
| `PlayRouteEvent` | The `play.route` event type
|
|
129
|
+
| `PlayRouteEvent` | The `play.route` event type that the bridge sends to the actor |
|
|
133
130
|
| `RouterBridge` | Interface that all router bridges must satisfy |
|
|
134
131
|
| `RouteMapping` | Route-entry shape within a `RouteMap` |
|
|
135
132
|
| `RouteMapOptions` | Options for `createRouteMap` |
|
|
@@ -147,7 +144,9 @@ Re-exported from `@xmachines/play-router`. Bidirectional map between state IDs a
|
|
|
147
144
|
| `watchRouterChanges()` | `win.addEventListener("hashchange", …)` |
|
|
148
145
|
| `unwatchRouterChanges()` | `win.removeEventListener("hashchange", …)` |
|
|
149
146
|
|
|
150
|
-
|
|
147
|
+
The bridge reads the initial path from `router.loc.location`, and the initial search string from `router.loc.querystring`. It inherits the restore-or-deeplink detection, the guard-redirect flow, and the `isProcessingNavigation` debounce from `RouterBridgeBase`.
|
|
148
|
+
|
|
149
|
+
`SvelteSpaRouterBridge` is exported from the package — prefer `connectRouter` for the common case, and instantiate the bridge directly (`new SvelteSpaRouterBridge(actor, routeMap)` followed by `connect()`/`disconnect()`) when you need fine-grained control over the connection lifecycle.
|
|
151
150
|
|
|
152
151
|
---
|
|
153
152
|
|
|
@@ -176,6 +175,7 @@ MIT © XMachines Contributors. See [LICENSE](./LICENSE).
|
|
|
176
175
|
## Classes
|
|
177
176
|
|
|
178
177
|
- [RouteMap](classes/RouteMap.md)
|
|
178
|
+
- [SvelteSpaRouterBridge](classes/SvelteSpaRouterBridge.md)
|
|
179
179
|
|
|
180
180
|
## Interfaces
|
|
181
181
|
|
|
@@ -2,32 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
# Class: RouteMap
|
|
4
4
|
|
|
5
|
-
Defined in: [play-router/src/base-route-map.ts:
|
|
5
|
+
Defined in: [play-router/src/base-route-map.ts:105](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/base-route-map.ts#L105)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The shared base class of the route map for both directions.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
own and
|
|
9
|
+
Every framework adapter uses this class as its route map. An adapter adds no logic
|
|
10
|
+
of its own, and it inherits the complete public API from here.
|
|
11
11
|
|
|
12
|
-
**
|
|
12
|
+
**The strategy of a lookup:**
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
of routes
|
|
17
|
-
-
|
|
18
|
-
|
|
14
|
+
- A static path, without a `:param` → a `Map` lookup in O(1)
|
|
15
|
+
- A dynamic path → a scan of the bucket index in O(k), with `URLPattern`, where
|
|
16
|
+
`k` is the number of the routes with the same first path segment
|
|
17
|
+
- The class keeps each result of a first match in an LRU cache. The default size
|
|
18
|
+
is 500 entries, and the `cacheSize` constructor option changes it
|
|
19
19
|
|
|
20
|
-
**
|
|
20
|
+
**The syntax of a pattern** (`:param`, `:param?`, and `*`):
|
|
21
21
|
|
|
22
|
-
- `:param` —
|
|
23
|
-
- `:param?` — optional segment
|
|
24
|
-
- `*` — wildcard
|
|
22
|
+
- `:param` — a necessary segment. It matches exactly one segment without a `/`
|
|
23
|
+
- `:param?` — an optional segment. It matches zero segments or one segment without a `/`
|
|
24
|
+
- `*` — a wildcard. It matches each number of segments, as URLPattern defines
|
|
25
25
|
|
|
26
|
-
**
|
|
27
|
-
`"#stateId"` or `"stateId"
|
|
28
|
-
`getStateIdByPath` returns the stateId exactly as
|
|
29
|
-
`getPathByStateId` accepts both forms.
|
|
30
|
-
forms
|
|
26
|
+
**The forms of a stateId:** you can register a stateId, and you can look one up,
|
|
27
|
+
in the form `"#stateId"` or in the form `"stateId"`. `RouteMap` makes the
|
|
28
|
+
canonical form itself. `getStateIdByPath` returns the stateId exactly as you
|
|
29
|
+
registered it, and `getPathByStateId` accepts both forms. A registration of the
|
|
30
|
+
same stateId in both forms gives one entry, and the later registration wins for
|
|
31
|
+
the lookup in the other direction.
|
|
31
32
|
|
|
32
33
|
## Example
|
|
33
34
|
|
|
@@ -57,21 +58,22 @@ map.getPathByStateId("missing"); // null
|
|
|
57
58
|
new RouteMap(mappings, options?): RouteMap;
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
Defined in: [play-router/src/base-route-map.ts:
|
|
61
|
+
Defined in: [play-router/src/base-route-map.ts:133](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/base-route-map.ts#L133)
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
Builds a route map from an array of the mappings between a state ID and a path.
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
buckets
|
|
65
|
+
The constructor puts each static path, which holds no `:param`, into a `Map` for a
|
|
66
|
+
lookup in O(1). It compiles each parameterized path to a `URLPattern`, and it
|
|
67
|
+
groups the patterns into the buckets of the first segment. The selection of the
|
|
68
|
+
candidates is therefore efficient.
|
|
67
69
|
|
|
68
70
|
#### Parameters
|
|
69
71
|
|
|
70
|
-
| Parameter | Type | Description
|
|
71
|
-
| -------------------- | ------------------------------------------------- |
|
|
72
|
-
| `mappings` | [`RouteMapping`](../interfaces/RouteMapping.md)[] |
|
|
73
|
-
| `options` | \{ `cacheSize?`: `number`; \} |
|
|
74
|
-
| `options.cacheSize?` | `number` | -
|
|
72
|
+
| Parameter | Type | Description |
|
|
73
|
+
| -------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| `mappings` | [`RouteMapping`](../interfaces/RouteMapping.md)[] | The array of the `{ stateId, path }` entries. The order gives the priority when more than one pattern can match the same path. |
|
|
75
|
+
| `options` | \{ `cacheSize?`: `number`; \} | The optional configuration. `options.cacheSize`: the maximum number of the resolved parameterized path lookups in the cache. The default is `500`. Raise it for an application with many different values in a parameterized URL, for example a page of a user profile with thousands of different IDs. After an eviction, the path goes to the bucket pattern scan in O(k) again, which is correct but slower. The smallest effective value is `1`, because QuickLRU requires it. |
|
|
76
|
+
| `options.cacheSize?` | `number` | - |
|
|
75
77
|
|
|
76
78
|
#### Returns
|
|
77
79
|
|
|
@@ -85,31 +87,31 @@ buckets for efficient candidate selection.
|
|
|
85
87
|
getPathByStateId(stateId): string | null;
|
|
86
88
|
```
|
|
87
89
|
|
|
88
|
-
Defined in: [play-router/src/base-route-map.ts:
|
|
90
|
+
Defined in: [play-router/src/base-route-map.ts:225](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/base-route-map.ts#L225)
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
Returns the path pattern of a state ID.
|
|
91
93
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
The method accepts the stateId in the form `"#stateId"` and in the form
|
|
95
|
+
`"stateId"`, and the form of the registration has no effect. The method makes the
|
|
96
|
+
canonical form itself. Therefore a consumer tries never both forms.
|
|
95
97
|
|
|
96
98
|
#### Parameters
|
|
97
99
|
|
|
98
|
-
| Parameter | Type | Description
|
|
99
|
-
| --------- | -------- |
|
|
100
|
-
| `stateId` | `string` |
|
|
100
|
+
| Parameter | Type | Description |
|
|
101
|
+
| --------- | -------- | --------------------------------------------------------------------------- |
|
|
102
|
+
| `stateId` | `string` | The state ID of the state machine, for example `"profile"` or `"#settings"` |
|
|
101
103
|
|
|
102
104
|
#### Returns
|
|
103
105
|
|
|
104
106
|
`string` \| `null`
|
|
105
107
|
|
|
106
|
-
The registered path pattern, or `null`
|
|
108
|
+
The registered path pattern, or `null` when the state ID is unknown
|
|
107
109
|
|
|
108
110
|
#### Example
|
|
109
111
|
|
|
110
112
|
```typescript
|
|
111
113
|
map.getPathByStateId("profile"); // "/profile/:userId"
|
|
112
|
-
map.getPathByStateId("#profile"); // "/profile/:userId"
|
|
114
|
+
map.getPathByStateId("#profile"); // "/profile/:userId" — the same entry
|
|
113
115
|
map.getPathByStateId("missing"); // null
|
|
114
116
|
```
|
|
115
117
|
|
|
@@ -121,25 +123,25 @@ map.getPathByStateId("missing"); // null
|
|
|
121
123
|
getStateIdByPath(path): string | null;
|
|
122
124
|
```
|
|
123
125
|
|
|
124
|
-
Defined in: [play-router/src/base-route-map.ts:
|
|
126
|
+
Defined in: [play-router/src/base-route-map.ts:185](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play-router/src/base-route-map.ts#L185)
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
Resolves a URL path to its state ID.
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
lookup first, then
|
|
130
|
-
|
|
130
|
+
The method removes the query string and the hash fragment before the match. It
|
|
131
|
+
tries an exact lookup in O(1) first, then it uses the pattern match on the bucket
|
|
132
|
+
index. It keeps each result of a first pattern match in the cache.
|
|
131
133
|
|
|
132
134
|
#### Parameters
|
|
133
135
|
|
|
134
|
-
| Parameter | Type | Description
|
|
135
|
-
| --------- | -------- |
|
|
136
|
-
| `path` | `string` | URL pathname
|
|
136
|
+
| Parameter | Type | Description |
|
|
137
|
+
| --------- | -------- | -------------------------------------------------------------------------------------- |
|
|
138
|
+
| `path` | `string` | The URL pathname. It can hold a query and a hash, for example `"/profile/123?ref=nav"` |
|
|
137
139
|
|
|
138
140
|
#### Returns
|
|
139
141
|
|
|
140
142
|
`string` \| `null`
|
|
141
143
|
|
|
142
|
-
The
|
|
144
|
+
The state ID of the path, or `null` when no route matches
|
|
143
145
|
|
|
144
146
|
#### Example
|
|
145
147
|
|