@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
package/README.md
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
> Documentation, guides, RFCs, and generated API reference for XMachines.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/docs)
|
|
5
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/docs)
|
|
8
6
|
|
|
9
7
|
## Overview
|
|
10
8
|
|
|
11
|
-
`@xmachines/docs` is the documentation package
|
|
9
|
+
`@xmachines/docs` is the documentation package of the XMachines Play monorepo. It ships five categories of content:
|
|
12
10
|
|
|
13
11
|
| Location | Contents |
|
|
14
12
|
| --------------- | ---------------------------------------------------------------- |
|
|
@@ -16,7 +14,7 @@ Part of the `XMachines Play monorepo`.
|
|
|
16
14
|
| `guides/` | Concept guides, tutorials, and getting-started docs |
|
|
17
15
|
| `contributing/` | Operational docs for contributors and maintainers |
|
|
18
16
|
| `examples/` | Runnable code examples and demo application references |
|
|
19
|
-
| `api/` |
|
|
17
|
+
| `api/` | The API reference for every public package, generated by TypeDoc |
|
|
20
18
|
|
|
21
19
|
## Installation
|
|
22
20
|
|
|
@@ -28,7 +26,7 @@ pnpm add @xmachines/docs
|
|
|
28
26
|
|
|
29
27
|
### Import the package URL
|
|
30
28
|
|
|
31
|
-
The
|
|
29
|
+
The default export of the package is its own module URL. Use it to resolve documentation assets at run time:
|
|
32
30
|
|
|
33
31
|
```typescript
|
|
34
32
|
import docsUrl from "@xmachines/docs";
|
|
@@ -37,7 +35,7 @@ import docsUrl from "@xmachines/docs";
|
|
|
37
35
|
|
|
38
36
|
### Access documentation files directly
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
The package exports every documentation directory:
|
|
41
39
|
|
|
42
40
|
```typescript
|
|
43
41
|
// Access RFC files
|
|
@@ -62,7 +60,7 @@ Architectural specifications that define the XMachines system:
|
|
|
62
60
|
| File | Title | Description |
|
|
63
61
|
| ---------------------------------- | ------- | -------------------------------------------------------------------- |
|
|
64
62
|
| [`rfc/play.md`](rfc/play.md) | Play | Universal Player Architecture — core protocol, roles, and invariants |
|
|
65
|
-
| [`rfc/streams.md`](rfc/streams.md) | Streams | WHATWG Streams as integration boundary
|
|
63
|
+
| [`rfc/streams.md`](rfc/streams.md) | Streams | WHATWG Streams as the integration boundary |
|
|
66
64
|
| [`rfc/broker.md`](rfc/broker.md) | Broker | Event broker specification |
|
|
67
65
|
| [`rfc/git.md`](rfc/git.md) | Git | Git-compatible ID and history model |
|
|
68
66
|
| [`rfc/run.md`](rfc/run.md) | Run | Runtime execution model |
|
|
@@ -74,7 +72,7 @@ Architectural specifications that define the XMachines system:
|
|
|
74
72
|
|
|
75
73
|
### Guides
|
|
76
74
|
|
|
77
|
-
Concept guides and tutorials
|
|
75
|
+
Concept guides and tutorials that show how to use XMachines:
|
|
78
76
|
|
|
79
77
|
**Learning:**
|
|
80
78
|
|
|
@@ -99,7 +97,7 @@ Reference documentation for contributors and maintainers:
|
|
|
99
97
|
|
|
100
98
|
### Examples
|
|
101
99
|
|
|
102
|
-
Practical code examples
|
|
100
|
+
Practical code examples that show the XMachines patterns:
|
|
103
101
|
|
|
104
102
|
- **[Basic State Machine](examples/basic-state-machine.md)** — `setup().createMachine()` + `definePlayer()` + TC39 Signals
|
|
105
103
|
- **[Traffic Light](examples/traffic-light.md)** — Multi-state machine with `meta.route` and `formatPlayRouteTransitions`
|
|
@@ -109,9 +107,9 @@ Practical code examples demonstrating XMachines patterns:
|
|
|
109
107
|
|
|
110
108
|
### API Reference
|
|
111
109
|
|
|
112
|
-
TypeDoc
|
|
110
|
+
TypeDoc generates the API reference for every public package. See [`api/README.md`](api/README.md).
|
|
113
111
|
|
|
114
|
-
|
|
112
|
+
The documented packages:
|
|
115
113
|
|
|
116
114
|
- [`@xmachines/play`](../play/README.md) — Core protocols (`PlayEvent`, `PlayError`)
|
|
117
115
|
- [`@xmachines/play-actor`](../play-actor/README.md) — `AbstractActor`, `Routable`, `Viewable`
|
|
@@ -135,7 +133,7 @@ pnpm test
|
|
|
135
133
|
|
|
136
134
|
## Regenerating API Docs
|
|
137
135
|
|
|
138
|
-
|
|
136
|
+
TypeDoc generates the `api/` directory. Never edit it by hand. Generate it again from the monorepo root:
|
|
139
137
|
|
|
140
138
|
```bash
|
|
141
139
|
pnpm run docs
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# `@xmachines/play`
|
|
4
4
|
|
|
5
|
-
> Core protocol layer for the Universal Player Architecture
|
|
5
|
+
> Core protocol layer for the Universal Player Architecture. It defines `PlayEvent`, `PlayError`, and the contracts that keep the business logic loosely coupled to the runtime adapters.
|
|
6
6
|
|
|
7
|
-
[](https://opensource.org/licenses/MIT) [.
|
|
7
|
+
[](https://opensource.org/licenses/MIT) [](https://www.npmjs.com/package/@xmachines/play)
|
|
10
8
|
|
|
11
9
|
---
|
|
12
10
|
|
|
@@ -16,27 +14,27 @@ Part of the [XMachines JS monorepo](../../README.md).
|
|
|
16
14
|
pnpm add @xmachines/play
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
> **Node.js `>= 22.0.0
|
|
17
|
+
> **This package requires Node.js `>= 22.0.0`.** Every package is an ES module (`"type": "module"`).
|
|
20
18
|
|
|
21
19
|
---
|
|
22
20
|
|
|
23
21
|
## Overview
|
|
24
22
|
|
|
25
|
-
`@xmachines/play` is the
|
|
23
|
+
`@xmachines/play` is the base package of the XMachines ecosystem. It defines the smallest set of types and utilities that every other `@xmachines/*` package builds on:
|
|
26
24
|
|
|
27
25
|
- **`PlayEvent<TPayload>`** — the universal event contract for Actor ↔ Infrastructure communication
|
|
28
26
|
- **`PlayError`** — the typed base class for all `@xmachines/*` runtime errors
|
|
29
|
-
- **`NonNullableError`** —
|
|
30
|
-
- **`assertNonNullable()`** — assertion utility that narrows `T | null | undefined` to `T`
|
|
27
|
+
- **`NonNullableError`** — the error that a package throws when a required value is `null` or `undefined`
|
|
28
|
+
- **`assertNonNullable()`** — the assertion utility that narrows `T | null | undefined` to `T`
|
|
31
29
|
|
|
32
|
-
These protocols implement the architectural invariants
|
|
30
|
+
These protocols implement the architectural invariants that the Play RFC defines:
|
|
33
31
|
|
|
34
|
-
| # | Invariant | Description
|
|
35
|
-
| ------ | -------------------------- |
|
|
36
|
-
| INV-01 | **Actor Authority** | The Actor is the final authority
|
|
37
|
-
| INV-02 | **Strict Separation** |
|
|
38
|
-
| INV-04 | **Passive Infrastructure** |
|
|
39
|
-
| INV-05 | **Signal-Only Reactivity** | TC39 Signals are the
|
|
32
|
+
| # | Invariant | Description |
|
|
33
|
+
| ------ | -------------------------- | ------------------------------------------------------------------------ |
|
|
34
|
+
| INV-01 | **Actor Authority** | The Actor is the final authority. Guards decide all transitions |
|
|
35
|
+
| INV-02 | **Strict Separation** | The business logic never imports a UI framework or a routing library |
|
|
36
|
+
| INV-04 | **Passive Infrastructure** | The infrastructure observes the Actor signals. It never enforces a guard |
|
|
37
|
+
| INV-05 | **Signal-Only Reactivity** | TC39 Signals are the only medium that crosses a boundary |
|
|
40
38
|
|
|
41
39
|
---
|
|
42
40
|
|
|
@@ -44,7 +42,7 @@ These protocols implement the architectural invariants defined in the Play RFC:
|
|
|
44
42
|
|
|
45
43
|
### `PlayEvent<TPayload>`
|
|
46
44
|
|
|
47
|
-
The minimal event contract
|
|
45
|
+
The minimal event contract is any object with a `type: string` property. The contract is framework-agnostic. It works with XState, with Robot, and with every other state machine library.
|
|
48
46
|
|
|
49
47
|
```typescript
|
|
50
48
|
import type { PlayEvent } from "@xmachines/play";
|
|
@@ -67,14 +65,14 @@ const invalid: LoginEvent = { type: "auth.login" }; // Error!
|
|
|
67
65
|
|
|
68
66
|
### `PlayError`
|
|
69
67
|
|
|
70
|
-
Base class for
|
|
68
|
+
Base class for every `@xmachines/*` runtime error. Each error has a stable `scope` (the class or the module that throws it) and a stable `code` (a machine-readable identifier). Always branch on `.code` or on the subclass. Never branch on `.message`.
|
|
71
69
|
|
|
72
70
|
```typescript
|
|
73
|
-
import { PlayError } from "@xmachines/play";
|
|
71
|
+
import { PlayError, assertNonNullable } from "@xmachines/play";
|
|
74
72
|
import { NonNullableError } from "@xmachines/play/errors";
|
|
75
73
|
|
|
76
74
|
try {
|
|
77
|
-
|
|
75
|
+
assertNonNullable(document.getElementById("app"), "#app");
|
|
78
76
|
} catch (err) {
|
|
79
77
|
if (err instanceof NonNullableError) {
|
|
80
78
|
// err.scope === "assertNonNullable"
|
|
@@ -104,15 +102,12 @@ export class MyPackageError extends PlayError {
|
|
|
104
102
|
|
|
105
103
|
### `assertNonNullable(value, name?)`
|
|
106
104
|
|
|
107
|
-
|
|
105
|
+
The assertion utility returns `value` with the type `NonNullable<V>`, or it throws `NonNullableError`. It removes the unsafe `!` non-null assertion.
|
|
108
106
|
|
|
109
107
|
```typescript
|
|
110
108
|
import { assertNonNullable } from "@xmachines/play";
|
|
111
109
|
|
|
112
|
-
//
|
|
113
|
-
const actor = assertNonNullable(inject<AuthActor>("actor"), "actor");
|
|
114
|
-
|
|
115
|
-
// DOM element lookup:
|
|
110
|
+
// DOM element lookup — no intermediate variable or `!` needed:
|
|
116
111
|
const el = assertNonNullable(document.getElementById("app"), "#app");
|
|
117
112
|
```
|
|
118
113
|
|
|
@@ -122,18 +117,18 @@ const el = assertNonNullable(document.getElementById("app"), "#app");
|
|
|
122
117
|
|
|
123
118
|
### Exported from `@xmachines/play`
|
|
124
119
|
|
|
125
|
-
| Export | Kind | Description
|
|
126
|
-
| --------------------- | ---------- |
|
|
127
|
-
| `PlayEvent<TPayload>` | `type` | Universal event contract — `{ type: string } & TPayload`
|
|
128
|
-
| `PlayError` | `class` | Base class for all `@xmachines/*` typed errors
|
|
129
|
-
| `NonNullableError` | `class` |
|
|
130
|
-
| `assertNonNullable` | `function` | Asserts
|
|
120
|
+
| Export | Kind | Description |
|
|
121
|
+
| --------------------- | ---------- | ------------------------------------------------------------------- |
|
|
122
|
+
| `PlayEvent<TPayload>` | `type` | Universal event contract — `{ type: string } & TPayload` |
|
|
123
|
+
| `PlayError` | `class` | Base class for all `@xmachines/*` typed errors |
|
|
124
|
+
| `NonNullableError` | `class` | `assertNonNullable` throws it when a value is `null` or `undefined` |
|
|
125
|
+
| `assertNonNullable` | `function` | Asserts that the value is not null. It returns the narrowed value |
|
|
131
126
|
|
|
132
127
|
### Exported from `@xmachines/play/errors`
|
|
133
128
|
|
|
134
129
|
| Export | Kind | Description |
|
|
135
130
|
| ------------------ | ------- | --------------------------------------------------------- |
|
|
136
|
-
| `PlayError` | `class` |
|
|
131
|
+
| `PlayError` | `class` | The base error class, re-exported |
|
|
137
132
|
| `NonNullableError` | `class` | `scope: "assertNonNullable"`, `code: "PLAY_NON_NULLABLE"` |
|
|
138
133
|
|
|
139
134
|
---
|
|
@@ -144,15 +139,13 @@ const el = assertNonNullable(document.getElementById("app"), "#app");
|
|
|
144
139
|
| ------------------- | ------------------ | ---------------------------------------------------- |
|
|
145
140
|
| `PLAY_NON_NULLABLE` | `NonNullableError` | `assertNonNullable()` receives `null` or `undefined` |
|
|
146
141
|
|
|
147
|
-
|
|
142
|
+
Every other `@xmachines/*` package exports its own error subclasses from its `./errors` subpath:
|
|
148
143
|
|
|
149
144
|
| Package | Import path |
|
|
150
145
|
| ---------------------------- | ----------------------------------- |
|
|
151
146
|
| `@xmachines/play` | `@xmachines/play/errors` |
|
|
152
147
|
| `@xmachines/play-router` | `@xmachines/play-router/errors` |
|
|
153
148
|
| `@xmachines/play-xstate` | `@xmachines/play-xstate/errors` |
|
|
154
|
-
| `@xmachines/play-react` | `@xmachines/play-react/errors` |
|
|
155
|
-
| `@xmachines/play-solid` | `@xmachines/play-solid/errors` |
|
|
156
149
|
| `@xmachines/play-vue-router` | `@xmachines/play-vue-router/errors` |
|
|
157
150
|
|
|
158
151
|
---
|
|
@@ -181,59 +174,61 @@ MIT © [Mikael Karon](mailto:mikael@karon.se)
|
|
|
181
174
|
|
|
182
175
|
See [LICENSE](./LICENSE) for details.
|
|
183
176
|
|
|
184
|
-
@xmachines/play -
|
|
177
|
+
@xmachines/play - the core protocol layer
|
|
185
178
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
This package defines the architectural contracts that carry the communication
|
|
180
|
+
between the Actor and the infrastructure, with no direct dependency between them.
|
|
181
|
+
RFC section 5.2 gives these protocols. They are the base of the loose coupling
|
|
182
|
+
between the business logic and the runtime adapters.
|
|
189
183
|
|
|
190
|
-
##
|
|
184
|
+
## The exports
|
|
191
185
|
|
|
192
|
-
**PlayEvent<TPayload>** -
|
|
186
|
+
**PlayEvent<TPayload>** - the generic event type of the Actor communication
|
|
193
187
|
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
-
|
|
188
|
+
- It is every object with a `type: string` property
|
|
189
|
+
- The generic `TPayload` parameter gives a type-safe event shape, and it is optional
|
|
190
|
+
- The default is `Record<string, unknown>`, which accepts each shape
|
|
191
|
+
- It is framework-agnostic, and it is not bound to XState or to another library
|
|
198
192
|
|
|
199
|
-
**
|
|
193
|
+
**Use:**
|
|
200
194
|
|
|
201
195
|
```typescript
|
|
202
|
-
// Flexible
|
|
196
|
+
// Flexible, the default:
|
|
203
197
|
const event: PlayEvent = { type: "auth.login", userId: "123" };
|
|
204
198
|
|
|
205
|
-
// Type-safe
|
|
199
|
+
// Type-safe, with the generic parameter:
|
|
206
200
|
type LoginEvent = PlayEvent<{ userId: string }>;
|
|
207
201
|
const event: LoginEvent = { type: "auth.login", userId: "123" };
|
|
208
202
|
```
|
|
209
203
|
|
|
210
|
-
**
|
|
204
|
+
**The common event patterns:**
|
|
211
205
|
|
|
212
|
-
-
|
|
213
|
-
-
|
|
206
|
+
- A domain event: `{ type: 'auth.login', userId: '123' }`
|
|
207
|
+
- Your own event: `{ type: 'form.submit', data: {...} }`
|
|
214
208
|
|
|
215
|
-
**
|
|
209
|
+
**The routing events** come from @xmachines/play-router:
|
|
216
210
|
|
|
217
|
-
- PlayRouteEvent:
|
|
218
|
-
- RouterBridge:
|
|
211
|
+
- PlayRouteEvent: the routing event with the parameters and the target state ID
|
|
212
|
+
- RouterBridge: the protocol that connects a router adapter to an actor
|
|
219
213
|
|
|
220
|
-
**
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
**The browser navigation:** a router adapter handles the browser BACK and FORWARD
|
|
215
|
+
buttons, through the `popstate` event. The user presses BACK or FORWARD, the
|
|
216
|
+
router detects the new URL, and it sends a PlayRouteEvent to the actor. The actor
|
|
217
|
+
then checks the event.
|
|
223
218
|
|
|
224
219
|
```typescript
|
|
225
220
|
import type { PlayRouteEvent, RouterBridge } from "@xmachines/play-router";
|
|
226
221
|
```
|
|
227
222
|
|
|
228
|
-
##
|
|
223
|
+
## The architectural invariants
|
|
229
224
|
|
|
230
|
-
These protocols enforce the
|
|
225
|
+
These protocols enforce the invariants below:
|
|
231
226
|
|
|
232
|
-
1. **Actor Authority**:
|
|
233
|
-
2. **Strict Separation**:
|
|
234
|
-
3. **Passive Infrastructure**:
|
|
235
|
-
4. **Signal-Only Reactivity**:
|
|
236
|
-
5. **State-Driven Reset**:
|
|
227
|
+
1. **Actor Authority**: the infrastructure makes a request, and the Actor decides the validity
|
|
228
|
+
2. **Strict Separation**: no layer depends on another layer directly
|
|
229
|
+
3. **Passive Infrastructure**: the infrastructure observes the Actor signals. It never controls them
|
|
230
|
+
4. **Signal-Only Reactivity**: every state change goes through a TC39 Signal
|
|
231
|
+
5. **State-Driven Reset**: each navigation follows the transition rules of the state machine
|
|
237
232
|
|
|
238
233
|
## Classes
|
|
239
234
|
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# Class: NonNullableError
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play/src/errors.ts:
|
|
5
|
+
Defined in: [packages/play/src/errors.ts:110](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/errors.ts#L110)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[assertNonNullable](../functions/assertNonNullable.md) throws this error when a value is `null` or `undefined`.
|
|
8
8
|
|
|
9
|
-
Catch
|
|
10
|
-
|
|
9
|
+
Catch it to separate a failed assertion of a missing value from every other
|
|
10
|
+
runtime error:
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
13
|
import { NonNullableError } from "@xmachines/play/errors";
|
|
@@ -35,7 +35,7 @@ try {
|
|
|
35
35
|
new NonNullableError(message, options?): NonNullableError;
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Defined in: [packages/play/src/errors.ts:
|
|
38
|
+
Defined in: [packages/play/src/errors.ts:111](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/errors.ts#L111)
|
|
39
39
|
|
|
40
40
|
#### Parameters
|
|
41
41
|
|
|
@@ -57,10 +57,10 @@ Defined in: [packages/play/src/errors.ts:112](https://gitlab.com/xmachin-es/xmac
|
|
|
57
57
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
58
58
|
| ------------------------------------------------------- | ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
59
59
|
| <a id="property-cause"></a> `cause?` | `public` | `unknown` | - | [`PlayError`](PlayError.md).[`cause`](PlayError.md#property-cause) | - |
|
|
60
|
-
| <a id="property-code"></a> `code` | `readonly` | `string` | A stable, machine-readable error
|
|
60
|
+
| <a id="property-code"></a> `code` | `readonly` | `string` | A stable, machine-readable identifier of the error. An error code follows the naming convention `PLAY_<PACKAGE>_<DESCRIPTION>`. It stays the same across each patch release and each minor release of one major version. Never match on `.message`. Always match on `.code`, or on the subclass. | [`PlayError`](PlayError.md).[`code`](PlayError.md#property-code) | [packages/play/src/errors.ts:74](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/errors.ts#L74) |
|
|
61
61
|
| <a id="property-message"></a> `message` | `public` | `string` | - | [`PlayError`](PlayError.md).[`message`](PlayError.md#property-message) | - |
|
|
62
62
|
| <a id="property-name"></a> `name` | `public` | `string` | - | [`PlayError`](PlayError.md).[`name`](PlayError.md#property-name) | - |
|
|
63
|
-
| <a id="property-scope"></a> `scope` | `readonly` | `string` | The class or module that threw this error
|
|
63
|
+
| <a id="property-scope"></a> `scope` | `readonly` | `string` | The class or the module that threw this error, for example `"RouterBridgeBase"`. | [`PlayError`](PlayError.md).[`scope`](PlayError.md#property-scope) | [packages/play/src/errors.ts:64](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/errors.ts#L64) |
|
|
64
64
|
| <a id="property-stack"></a> `stack?` | `public` | `string` | - | [`PlayError`](PlayError.md).[`stack`](PlayError.md#property-stack) | - |
|
|
65
65
|
| <a id="property-stacktracelimit"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | [`PlayError`](PlayError.md).[`stackTraceLimit`](PlayError.md#property-stacktracelimit) | - |
|
|
66
66
|
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
# Class: PlayError
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/play/src/errors.ts:
|
|
5
|
+
Defined in: [packages/play/src/errors.ts:62](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/errors.ts#L62)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The base class of every typed runtime error of an `@xmachines/*` package.
|
|
8
8
|
|
|
9
|
-
`PlayError` gives
|
|
9
|
+
`PlayError` gives each error two structured fields:
|
|
10
10
|
|
|
11
|
-
- `scope` — the class or module that threw
|
|
12
|
-
- `code` — a stable, machine-readable identifier
|
|
11
|
+
- `scope` — the class or the module that threw the error, for example `"RouterBridgeBase"`
|
|
12
|
+
- `code` — a stable, machine-readable identifier, for example `"PLAY_ROUTER_SYNC_FAILED"`
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Your application code therefore branches on the type of an error, and it does not
|
|
15
|
+
parse the `.message` string. A message changes between releases.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## The error codes
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
An `@xmachines/*` package that defines typed subclasses exports them from an
|
|
20
20
|
`"./errors"` subpath:
|
|
21
21
|
|
|
22
22
|
| Package | Import |
|
|
@@ -25,13 +25,11 @@ Each `@xmachines/*` package exports its own typed subclasses from an
|
|
|
25
25
|
| `@xmachines/play-router` | `@xmachines/play-router/errors` |
|
|
26
26
|
| `@xmachines/play-vue-router` | `@xmachines/play-vue-router/errors` |
|
|
27
27
|
| `@xmachines/play-xstate` | `@xmachines/play-xstate/errors` |
|
|
28
|
-
| `@xmachines/play-react` | `@xmachines/play-react/errors` |
|
|
29
|
-
| `@xmachines/play-solid` | `@xmachines/play-solid/errors` |
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
The root `@xmachines/play` exports `PlayError` itself, and it is the base of every
|
|
30
|
+
subclass above.
|
|
33
31
|
|
|
34
|
-
##
|
|
32
|
+
## How to catch an error by its type
|
|
35
33
|
|
|
36
34
|
```typescript
|
|
37
35
|
import { PlayError } from "@xmachines/play";
|
|
@@ -43,18 +41,18 @@ try {
|
|
|
43
41
|
if (err instanceof RouterSyncError) {
|
|
44
42
|
// err.scope === "RouterBridgeBase"
|
|
45
43
|
// err.code === "PLAY_ROUTER_SYNC_FAILED"
|
|
46
|
-
// err.cause — the original error
|
|
44
|
+
// err.cause — the original error of the failed synchronization
|
|
47
45
|
reportToMonitoring(err);
|
|
48
46
|
} else if (err instanceof PlayError) {
|
|
49
|
-
//
|
|
47
|
+
// Every other @xmachines/* error
|
|
50
48
|
console.error(`[${err.scope}:${err.code}] ${err.message}`);
|
|
51
49
|
} else {
|
|
52
|
-
throw err; //
|
|
50
|
+
throw err; // Throw an unknown error again
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
```
|
|
56
54
|
|
|
57
|
-
##
|
|
55
|
+
## How to extend PlayError
|
|
58
56
|
|
|
59
57
|
```typescript
|
|
60
58
|
import { PlayError } from "@xmachines/play";
|
|
@@ -87,16 +85,16 @@ new PlayError(
|
|
|
87
85
|
options?): PlayError;
|
|
88
86
|
```
|
|
89
87
|
|
|
90
|
-
Defined in: [packages/play/src/errors.ts:
|
|
88
|
+
Defined in: [packages/play/src/errors.ts:82](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/errors.ts#L82)
|
|
91
89
|
|
|
92
90
|
#### Parameters
|
|
93
91
|
|
|
94
|
-
| Parameter | Type | Description
|
|
95
|
-
| ---------- | -------------- |
|
|
96
|
-
| `scope` | `string` | The class or module
|
|
97
|
-
| `code` | `string` |
|
|
98
|
-
| `message` | `string` |
|
|
99
|
-
| `options?` | `ErrorOptions` |
|
|
92
|
+
| Parameter | Type | Description |
|
|
93
|
+
| ---------- | -------------- | --------------------------------------------------------------------------------------- |
|
|
94
|
+
| `scope` | `string` | The class or the module that throws this error. |
|
|
95
|
+
| `code` | `string` | The machine-readable identifier of the error, for example `"PLAY_ROUTER_SYNC_FAILED"`. |
|
|
96
|
+
| `message` | `string` | The description for a person. Never match on it in your code. |
|
|
97
|
+
| `options?` | `ErrorOptions` | The standard `ErrorOptions`. Give `{ cause: originalError }` to make a chain of errors. |
|
|
100
98
|
|
|
101
99
|
#### Returns
|
|
102
100
|
|
|
@@ -113,10 +111,10 @@ Error.constructor;
|
|
|
113
111
|
| Property | Modifier | Type | Description | Inherited from | Defined in |
|
|
114
112
|
| ------------------------------------------------------- | ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
115
113
|
| <a id="property-cause"></a> `cause?` | `public` | `unknown` | - | `Error.cause` | - |
|
|
116
|
-
| <a id="property-code"></a> `code` | `readonly` | `string` | A stable, machine-readable error
|
|
114
|
+
| <a id="property-code"></a> `code` | `readonly` | `string` | A stable, machine-readable identifier of the error. An error code follows the naming convention `PLAY_<PACKAGE>_<DESCRIPTION>`. It stays the same across each patch release and each minor release of one major version. Never match on `.message`. Always match on `.code`, or on the subclass. | - | [packages/play/src/errors.ts:74](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/errors.ts#L74) |
|
|
117
115
|
| <a id="property-message"></a> `message` | `public` | `string` | - | `Error.message` | - |
|
|
118
116
|
| <a id="property-name"></a> `name` | `public` | `string` | - | `Error.name` | - |
|
|
119
|
-
| <a id="property-scope"></a> `scope` | `readonly` | `string` | The class or module that threw this error
|
|
117
|
+
| <a id="property-scope"></a> `scope` | `readonly` | `string` | The class or the module that threw this error, for example `"RouterBridgeBase"`. | - | [packages/play/src/errors.ts:64](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/errors.ts#L64) |
|
|
120
118
|
| <a id="property-stack"></a> `stack?` | `public` | `string` | - | `Error.stack` | - |
|
|
121
119
|
| <a id="property-stacktracelimit"></a> `stackTraceLimit` | `static` | `number` | The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | `Error.stackTraceLimit` | - |
|
|
122
120
|
|
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
function assertNonNullable<V>(value, name?): NonNullable<V>;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/play/src/utils.ts:39](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.
|
|
9
|
+
Defined in: [packages/play/src/utils.ts:39](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v2.1.0/packages/play/src/utils.ts#L39)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
Asserts that `value` is not `null` and not `undefined`, then returns it with the
|
|
12
|
+
type `NonNullable<V>`. One expression therefore holds the guard and the narrowed
|
|
13
|
+
value.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
A non-null assertion (`value!`) is different: it produces `undefined`, and your
|
|
16
|
+
code then fails later with a message such as "undefined is not an object". This
|
|
17
|
+
function throws a clear error at the point of the failure.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
An assertion function of the form `asserts value is T` is also different: this
|
|
20
|
+
function returns the narrowed value directly. Therefore the call site needs no
|
|
21
|
+
second variable and no `as` cast.
|
|
22
22
|
|
|
23
23
|
## Type Parameters
|
|
24
24
|
|
|
@@ -28,16 +28,16 @@ site.
|
|
|
28
28
|
|
|
29
29
|
## Parameters
|
|
30
30
|
|
|
31
|
-
| Parameter | Type | Description
|
|
32
|
-
| --------- | -------- |
|
|
33
|
-
| `value` | `V` | The value to check.
|
|
34
|
-
| `name?` | `string` |
|
|
31
|
+
| Parameter | Type | Description |
|
|
32
|
+
| --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `value` | `V` | The value to check. |
|
|
34
|
+
| `name?` | `string` | The optional name in the error message. It identifies the missing value, for example the name of the variable or of the injection key. |
|
|
35
35
|
|
|
36
36
|
## Returns
|
|
37
37
|
|
|
38
38
|
`NonNullable`\<`V`\>
|
|
39
39
|
|
|
40
|
-
`value`
|
|
40
|
+
`value` with the type `NonNullable<V>`, without `null` and without `undefined`.
|
|
41
41
|
|
|
42
42
|
## Throws
|
|
43
43
|
|
|
@@ -48,9 +48,9 @@ When `value` is `null` or `undefined`.
|
|
|
48
48
|
```ts
|
|
49
49
|
import { assertNonNullable } from "@xmachines/play";
|
|
50
50
|
|
|
51
|
-
// inject()
|
|
51
|
+
// inject() and assertNonNullable in one line, with no `!` and no second variable:
|
|
52
52
|
const actor = assertNonNullable(inject<AuthActor>("actor"), "actor");
|
|
53
53
|
|
|
54
|
-
//
|
|
54
|
+
// A lookup of an element:
|
|
55
55
|
const el = assertNonNullable(document.getElementById("app"), "#app");
|
|
56
56
|
```
|