@xmachines/docs 1.0.0-beta.10
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/LICENSE +21 -0
- package/README.md +15 -0
- package/api/@xmachines/play/README.md +130 -0
- package/api/@xmachines/play/type-aliases/PlayEvent.md +81 -0
- package/api/@xmachines/play-actor/README.md +247 -0
- package/api/@xmachines/play-actor/classes/AbstractActor.md +520 -0
- package/api/@xmachines/play-actor/interfaces/Routable.md +29 -0
- package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +17 -0
- package/api/@xmachines/play-actor/interfaces/Viewable.md +12 -0
- package/api/@xmachines/play-catalog/README.md +331 -0
- package/api/@xmachines/play-catalog/functions/defineCatalog.md +98 -0
- package/api/@xmachines/play-catalog/functions/defineComponents.md +134 -0
- package/api/@xmachines/play-catalog/type-aliases/Catalog.md +48 -0
- package/api/@xmachines/play-catalog/type-aliases/ComponentsFor.md +20 -0
- package/api/@xmachines/play-catalog/type-aliases/InferComponentProps.md +65 -0
- package/api/@xmachines/play-catalog/type-aliases/NoExtraKeys.md +17 -0
- package/api/@xmachines/play-react/README.md +423 -0
- package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +613 -0
- package/api/@xmachines/play-react/functions/useSignalEffect.md +68 -0
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +15 -0
- package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +14 -0
- package/api/@xmachines/play-react/interfaces/PlayRendererProps.md +15 -0
- package/api/@xmachines/play-react/variables/PlayRenderer.md +64 -0
- package/api/@xmachines/play-react-router/README.md +198 -0
- package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +321 -0
- package/api/@xmachines/play-react-router/classes/RouteMap.md +137 -0
- package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +19 -0
- package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +35 -0
- package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +119 -0
- package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +14 -0
- package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +17 -0
- package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-react-router-demo/README.md +137 -0
- package/api/@xmachines/play-router/README.md +502 -0
- package/api/@xmachines/play-router/classes/BaseRouteMap.md +142 -0
- package/api/@xmachines/play-router/classes/RouterBridgeBase.md +300 -0
- package/api/@xmachines/play-router/functions/buildRouteTree.md +27 -0
- package/api/@xmachines/play-router/functions/connectRouter.md +67 -0
- package/api/@xmachines/play-router/functions/crawlMachine.md +92 -0
- package/api/@xmachines/play-router/functions/createBrowserHistory.md +47 -0
- package/api/@xmachines/play-router/functions/createRouteMap.md +53 -0
- package/api/@xmachines/play-router/functions/createRouter.md +76 -0
- package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +32 -0
- package/api/@xmachines/play-router/functions/extractMachineRoutes.md +64 -0
- package/api/@xmachines/play-router/functions/extractRoute.md +45 -0
- package/api/@xmachines/play-router/functions/findRouteById.md +37 -0
- package/api/@xmachines/play-router/functions/findRouteByPath.md +39 -0
- package/api/@xmachines/play-router/functions/getNavigableRoutes.md +35 -0
- package/api/@xmachines/play-router/functions/getRoutableRoutes.md +39 -0
- package/api/@xmachines/play-router/functions/routeExists.md +26 -0
- package/api/@xmachines/play-router/functions/validateRouteFormat.md +29 -0
- package/api/@xmachines/play-router/functions/validateStateExists.md +29 -0
- package/api/@xmachines/play-router/interfaces/BaseRouteMapping.md +27 -0
- package/api/@xmachines/play-router/interfaces/BrowserHistory.md +172 -0
- package/api/@xmachines/play-router/interfaces/BrowserWindow.md +69 -0
- package/api/@xmachines/play-router/interfaces/ConnectRouterOptions.md +13 -0
- package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +119 -0
- package/api/@xmachines/play-router/interfaces/RouteInfo.md +19 -0
- package/api/@xmachines/play-router/interfaces/RouteMap.md +56 -0
- package/api/@xmachines/play-router/interfaces/RouteNode.md +21 -0
- package/api/@xmachines/play-router/interfaces/RouteObject.md +21 -0
- package/api/@xmachines/play-router/interfaces/RouteTree.md +20 -0
- package/api/@xmachines/play-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-router/interfaces/StateVisit.md +15 -0
- package/api/@xmachines/play-router/interfaces/VanillaRouter.md +28 -0
- package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +11 -0
- package/api/@xmachines/play-router-demo/README.md +137 -0
- package/api/@xmachines/play-signals/README.md +176 -0
- package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +34 -0
- package/api/@xmachines/play-signals/interfaces/SignalComputed.md +49 -0
- package/api/@xmachines/play-signals/interfaces/SignalOptions.md +35 -0
- package/api/@xmachines/play-signals/interfaces/SignalState.md +68 -0
- package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +97 -0
- package/api/@xmachines/play-signals/namespaces/Signal/README.md +22 -0
- package/api/@xmachines/play-signals/namespaces/Signal/classes/Computed.md +52 -0
- package/api/@xmachines/play-signals/namespaces/Signal/classes/State.md +72 -0
- package/api/@xmachines/play-signals/namespaces/Signal/interfaces/Options.md +19 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/README.md +21 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/classes/Watcher.md +85 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/currentComputed.md +13 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSinks.md +19 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSources.md +19 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSinks.md +19 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSources.md +19 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/untrack.md +25 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/unwatched.md +9 -0
- package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/watched.md +9 -0
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isComputed.md +19 -0
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isState.md +19 -0
- package/api/@xmachines/play-signals/namespaces/Signal/variables/isWatcher.md +19 -0
- package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +32 -0
- package/api/@xmachines/play-solid/README.md +311 -0
- package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +15 -0
- package/api/@xmachines/play-solid/variables/PlayRenderer.md +70 -0
- package/api/@xmachines/play-solid-router/README.md +666 -0
- package/api/@xmachines/play-solid-router/classes/RouteMap.md +150 -0
- package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +347 -0
- package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +19 -0
- package/api/@xmachines/play-solid-router/functions/createRouteMap.md +32 -0
- package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +486 -0
- package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +119 -0
- package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +14 -0
- package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +14 -0
- package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +9 -0
- package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +51 -0
- package/api/@xmachines/play-solid-router-demo/README.md +127 -0
- package/api/@xmachines/play-tanstack-react-router/README.md +226 -0
- package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +137 -0
- package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +348 -0
- package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +19 -0
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +53 -0
- package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +35 -0
- package/api/@xmachines/play-tanstack-react-router/functions/extractParams.md +38 -0
- package/api/@xmachines/play-tanstack-react-router/functions/extractQueryParams.md +33 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +119 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +14 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +17 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +26 -0
- package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +9 -0
- package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +78 -0
- package/api/@xmachines/play-tanstack-react-router/variables/extractMachineRoutes.md +64 -0
- package/api/@xmachines/play-tanstack-react-router-demo/README.md +126 -0
- package/api/@xmachines/play-tanstack-solid-router/README.md +285 -0
- package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +150 -0
- package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +343 -0
- package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +19 -0
- package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +32 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +119 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +14 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +23 -0
- package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +9 -0
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +9 -0
- package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +78 -0
- package/api/@xmachines/play-tanstack-solid-router-demo/README.md +126 -0
- package/api/@xmachines/play-vue/README.md +292 -0
- package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +14 -0
- package/api/@xmachines/play-vue/variables/PlayRenderer.md +9 -0
- package/api/@xmachines/play-vue-router/README.md +604 -0
- package/api/@xmachines/play-vue-router/classes/RouteMap.md +209 -0
- package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +201 -0
- package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +360 -0
- package/api/@xmachines/play-vue-router/functions/createRouteMap.md +19 -0
- package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +119 -0
- package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +15 -0
- package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +104 -0
- package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +9 -0
- package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +67 -0
- package/api/@xmachines/play-vue-router-demo/README.md +133 -0
- package/api/@xmachines/play-xstate/README.md +512 -0
- package/api/@xmachines/play-xstate/classes/PlayerActor.md +527 -0
- package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +43 -0
- package/api/@xmachines/play-xstate/functions/composeGuards.md +79 -0
- package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +67 -0
- package/api/@xmachines/play-xstate/functions/definePlayer.md +127 -0
- package/api/@xmachines/play-xstate/functions/deriveRoute.md +109 -0
- package/api/@xmachines/play-xstate/functions/eventMatches.md +40 -0
- package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +54 -0
- package/api/@xmachines/play-xstate/functions/hasContext.md +42 -0
- package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +41 -0
- package/api/@xmachines/play-xstate/functions/mergeViewProps.md +26 -0
- package/api/@xmachines/play-xstate/functions/negateGuard.md +61 -0
- package/api/@xmachines/play-xstate/functions/stateMatches.md +25 -0
- package/api/@xmachines/play-xstate/functions/validateComponentBinding.md +39 -0
- package/api/@xmachines/play-xstate/functions/validateViewProps.md +80 -0
- package/api/@xmachines/play-xstate/interfaces/CatalogEntry.md +16 -0
- package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +24 -0
- package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +26 -0
- package/api/@xmachines/play-xstate/interfaces/RouteContext.md +22 -0
- package/api/@xmachines/play-xstate/type-aliases/Catalog.md +21 -0
- package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +14 -0
- package/api/@xmachines/play-xstate/type-aliases/Guard.md +34 -0
- package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +20 -0
- package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +29 -0
- package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +45 -0
- package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +51 -0
- package/api/@xmachines/play-xstate/type-aliases/ValidationResult.md +17 -0
- package/api/@xmachines/play-xstate/type-aliases/ViewMergeContext.md +35 -0
- package/api/@xmachines/shared/README.md +379 -0
- package/api/@xmachines/shared/functions/defineXmVitestConfig.md +29 -0
- package/api/@xmachines/shared/functions/xmAliases.md +24 -0
- package/api/README.md +25 -0
- package/api/llms.txt +26 -0
- package/examples/README.md +63 -0
- package/examples/basic-state-machine.md +70 -0
- package/examples/form-validation.md +167 -0
- package/examples/multi-router-integration.md +277 -0
- package/examples/routing-patterns.md +260 -0
- package/examples/traffic-light.md +99 -0
- package/guides/README.md +29 -0
- package/guides/getting-started.md +223 -0
- package/guides/installation.md +323 -0
- package/index.d.ts +3 -0
- package/index.js +4 -0
- package/package.json +54 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / composeGuardsOr
|
|
2
|
+
|
|
3
|
+
# Function: composeGuardsOr()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function composeGuardsOr<TContext, TEvent>(guards): ComposedGuard;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/guards/compose.ts:138](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/guards/compose.ts#L138)
|
|
10
|
+
|
|
11
|
+
Compose guards with OR logic using XState's or() helper
|
|
12
|
+
|
|
13
|
+
Combines multiple guard predicates using OR semantics—at least one guard must pass
|
|
14
|
+
for the composition to succeed. Uses XState's built-in `or()` helper for proper
|
|
15
|
+
type inference.
|
|
16
|
+
|
|
17
|
+
## Type Parameters
|
|
18
|
+
|
|
19
|
+
| Type Parameter | Default type | Description |
|
|
20
|
+
| -------------- | ------------ | -------------------------- |
|
|
21
|
+
| `TContext` | `any` | State machine context type |
|
|
22
|
+
| `TEvent` | `any` | Event type |
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
| Parameter | Type | Description |
|
|
27
|
+
| --------- | --------------------------------------------------------------------- | ---------------------------------------- |
|
|
28
|
+
| `guards` | [`GuardArray`](../type-aliases/GuardArray.md)\<`TContext`, `TEvent`\> | Array of guard predicates or guard names |
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
[`ComposedGuard`](../type-aliases/ComposedGuard.md)
|
|
33
|
+
|
|
34
|
+
XState or() guard composition
|
|
35
|
+
|
|
36
|
+
## Throws
|
|
37
|
+
|
|
38
|
+
If guards array is empty
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
|
|
42
|
+
OR composition with named guards
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { setup } from "xstate";
|
|
46
|
+
import { composeGuardsOr } from "@xmachines/play-xstate";
|
|
47
|
+
|
|
48
|
+
const machine = setup({
|
|
49
|
+
guards: {
|
|
50
|
+
isOwner: ({ context }) => context.role === "owner",
|
|
51
|
+
isAdmin: ({ context }) => context.role === "admin",
|
|
52
|
+
},
|
|
53
|
+
}).createMachine({
|
|
54
|
+
on: {
|
|
55
|
+
deleteResource: {
|
|
56
|
+
// Either guard can pass
|
|
57
|
+
guard: composeGuardsOr(["isOwner", "isAdmin"]),
|
|
58
|
+
actions: "delete",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## See
|
|
65
|
+
|
|
66
|
+
- [composeGuards](composeGuards.md) for AND composition
|
|
67
|
+
- [negateGuard](negateGuard.md) for NOT logic
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / definePlayer
|
|
2
|
+
|
|
3
|
+
# Function: definePlayer()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function definePlayer<TMachine, TCatalog>(config): PlayerFactory<TMachine>;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/define-player.ts:111](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/define-player.ts#L111)
|
|
10
|
+
|
|
11
|
+
Create a player factory from XState machine and catalog
|
|
12
|
+
|
|
13
|
+
Factory pattern that accepts an XState v5 machine and optional UI catalog,
|
|
14
|
+
returning a function that creates [PlayerActor](../classes/PlayerActor.md) instances. This enables
|
|
15
|
+
creating multiple actor instances from a single configuration, useful for
|
|
16
|
+
testing, multi-instance scenarios, or server-side rendering.
|
|
17
|
+
|
|
18
|
+
**Architectural Context:** Implements **Strict Separation (INV-02)** by accepting
|
|
19
|
+
the machine definition (pure business logic) separately from the catalog (UI vocabulary).
|
|
20
|
+
The machine references component names in `meta.view` without importing React/framework code.
|
|
21
|
+
|
|
22
|
+
## Type Parameters
|
|
23
|
+
|
|
24
|
+
| Type Parameter | Default type | Description |
|
|
25
|
+
| -------------------------------------- | ------------------------------- | ---------------------------------- |
|
|
26
|
+
| `TMachine` _extends_ `AnyStateMachine` | - | XState v5 state machine type |
|
|
27
|
+
| `TCatalog` | `Record`\<`string`, `unknown`\> | Optional UI component catalog type |
|
|
28
|
+
|
|
29
|
+
## Parameters
|
|
30
|
+
|
|
31
|
+
| Parameter | Type | Description |
|
|
32
|
+
| --------- | ------------------------------------------------------------------------- | --------------------------- |
|
|
33
|
+
| `config` | [`PlayerConfig`](../interfaces/PlayerConfig.md)\<`TMachine`, `TCatalog`\> | Player configuration object |
|
|
34
|
+
|
|
35
|
+
## Returns
|
|
36
|
+
|
|
37
|
+
[`PlayerFactory`](../type-aliases/PlayerFactory.md)\<`TMachine`\>
|
|
38
|
+
|
|
39
|
+
Factory function that creates actor instances with optional input context
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
|
|
43
|
+
Basic player factory without catalog
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { setup } from "xstate";
|
|
47
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
48
|
+
|
|
49
|
+
const machine = setup({}).createMachine({
|
|
50
|
+
initial: "idle",
|
|
51
|
+
states: {
|
|
52
|
+
idle: { meta: { route: "/" } },
|
|
53
|
+
active: { meta: { route: "/active" } },
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const createPlayer = definePlayer({ machine });
|
|
58
|
+
const actor = createPlayer();
|
|
59
|
+
actor.start();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Player factory with catalog and parameter-aware routing
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { setup } from "xstate";
|
|
66
|
+
import { defineCatalog } from "@xmachines/play-catalog";
|
|
67
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
68
|
+
import { z } from "zod";
|
|
69
|
+
|
|
70
|
+
const catalog = defineCatalog({
|
|
71
|
+
HomePage: z.object({}),
|
|
72
|
+
ProfilePage: z.object({ userId: z.string() }),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const machine = setup({
|
|
76
|
+
types: {
|
|
77
|
+
context: {} as { userId: string },
|
|
78
|
+
events: {} as { type: "play.route"; to: string; params?: Record<string, string> },
|
|
79
|
+
},
|
|
80
|
+
}).createMachine({
|
|
81
|
+
initial: "home",
|
|
82
|
+
context: { userId: "" },
|
|
83
|
+
states: {
|
|
84
|
+
home: {
|
|
85
|
+
route: {},
|
|
86
|
+
meta: {
|
|
87
|
+
route: "/",
|
|
88
|
+
view: { component: "HomePage" },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
profile: {
|
|
92
|
+
route: {},
|
|
93
|
+
meta: {
|
|
94
|
+
route: "/profile/:userId",
|
|
95
|
+
view: { component: "ProfilePage", userId: (ctx) => ctx.userId },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const createPlayer = definePlayer({ machine, catalog });
|
|
102
|
+
const actor = createPlayer({ userId: "user123" });
|
|
103
|
+
actor.start();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Multiple actor instances from single factory
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const createPlayer = definePlayer({ machine, catalog });
|
|
110
|
+
|
|
111
|
+
// Create actors for different users
|
|
112
|
+
const alice = createPlayer({ userId: "alice" });
|
|
113
|
+
const bob = createPlayer({ userId: "bob" });
|
|
114
|
+
|
|
115
|
+
alice.start();
|
|
116
|
+
bob.start();
|
|
117
|
+
|
|
118
|
+
// Independent state machines
|
|
119
|
+
console.log(alice.state.get() !== bob.state.get());
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## See
|
|
123
|
+
|
|
124
|
+
- [RFC Play v1](https://gitlab.com/xmachin-es/rfc/-/blob/main/src/play-v1.md)
|
|
125
|
+
- [PlayerActor](../classes/PlayerActor.md) for the concrete actor implementation
|
|
126
|
+
- [PlayerConfig](../interfaces/PlayerConfig.md) for configuration options
|
|
127
|
+
- [PlayerFactory](../type-aliases/PlayerFactory.md) for factory function signature
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / deriveRoute
|
|
2
|
+
|
|
3
|
+
# Function: deriveRoute()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function deriveRoute(stateMeta): string | null;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/routing/derive-route.ts:90](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/routing/derive-route.ts#L90)
|
|
10
|
+
|
|
11
|
+
Derive route from XState state metadata
|
|
12
|
+
|
|
13
|
+
Extracts route URL template from `meta.route` in the active state's metadata.
|
|
14
|
+
Supports both string routes (`"/about"`) and object routes with path property
|
|
15
|
+
(`{ path: "/about" }`). Returns null for states without route metadata (not
|
|
16
|
+
all states need to be routable).
|
|
17
|
+
|
|
18
|
+
**Architectural Context:** Implements **Actor Authority (INV-01)** by extracting
|
|
19
|
+
routing information from state machine definitions rather than external configuration.
|
|
20
|
+
The route is determined by the Actor's current state, not by infrastructure decisions.
|
|
21
|
+
|
|
22
|
+
## Parameters
|
|
23
|
+
|
|
24
|
+
| Parameter | Type | Description |
|
|
25
|
+
| ----------- | ------------------------------- | -------------------------------------- |
|
|
26
|
+
| `stateMeta` | `Record`\<`string`, `unknown`\> | State metadata from snapshot.getMeta() |
|
|
27
|
+
|
|
28
|
+
## Returns
|
|
29
|
+
|
|
30
|
+
`string` \| `null`
|
|
31
|
+
|
|
32
|
+
Route path template (may include :params) or null if no route found
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
Basic route extraction
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { deriveRoute } from "@xmachines/play-xstate";
|
|
40
|
+
import { setup } from "xstate";
|
|
41
|
+
|
|
42
|
+
const machine = setup({}).createMachine({
|
|
43
|
+
states: {
|
|
44
|
+
about: {
|
|
45
|
+
meta: { route: "/about", view: { component: "AboutPage" } },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const actor = createActor(machine);
|
|
51
|
+
actor.start();
|
|
52
|
+
const snapshot = actor.getSnapshot();
|
|
53
|
+
const meta = snapshot.getMeta();
|
|
54
|
+
|
|
55
|
+
const route = deriveRoute(meta);
|
|
56
|
+
console.log(route); // "/about"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Route with parameters
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const machine = setup({}).createMachine({
|
|
63
|
+
states: {
|
|
64
|
+
profile: {
|
|
65
|
+
meta: {
|
|
66
|
+
route: "/profile/:userId",
|
|
67
|
+
view: { component: "ProfilePage", userId: (ctx) => ctx.userId },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const route = deriveRoute(snapshot.getMeta());
|
|
74
|
+
console.log(route); // "/profile/:userId" (template, before substitution)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Route object format
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const machine = setup({}).createMachine({
|
|
81
|
+
states: {
|
|
82
|
+
dashboard: {
|
|
83
|
+
meta: {
|
|
84
|
+
route: { path: "/dashboard" },
|
|
85
|
+
view: { component: "Dashboard" },
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const route = deriveRoute(snapshot.getMeta());
|
|
92
|
+
console.log(route); // "/dashboard"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## See
|
|
96
|
+
|
|
97
|
+
- [RFC Play v1](https://gitlab.com/xmachin-es/rfc/-/blob/main/src/play-v1.md)
|
|
98
|
+
- [buildRouteUrl](buildRouteUrl.md) for URL construction with parameter substitution
|
|
99
|
+
- [isAbsoluteRoute](isAbsoluteRoute.md) for checking path absoluteness
|
|
100
|
+
|
|
101
|
+
## Remarks
|
|
102
|
+
|
|
103
|
+
This function checks `meta.route` for route definitions. States with `route: {}` config
|
|
104
|
+
are routable. Parameter substitution happens via [buildRouteUrl](buildRouteUrl.md), not in this
|
|
105
|
+
function (deriveRoute returns templates).
|
|
106
|
+
|
|
107
|
+
**Non-routable States:** States without `meta.route` return `null`. This is intentional—
|
|
108
|
+
not all states need routes. For example, intermediate loading states or substates may
|
|
109
|
+
not correspond to distinct URLs.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / eventMatches
|
|
2
|
+
|
|
3
|
+
# Function: eventMatches()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function eventMatches<TEvent>(eventType): Guard<unknown, TEvent>;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/guards/helpers.ts:49](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/guards/helpers.ts#L49)
|
|
10
|
+
|
|
11
|
+
Check if event type matches expected type
|
|
12
|
+
|
|
13
|
+
## Type Parameters
|
|
14
|
+
|
|
15
|
+
| Type Parameter | Default type |
|
|
16
|
+
| ---------------------------------------------------------------------- | --------------------------------------------------- |
|
|
17
|
+
| `TEvent` _extends_ [`PlayEvent`](../../play/type-aliases/PlayEvent.md) | [`PlayEvent`](../../play/type-aliases/PlayEvent.md) |
|
|
18
|
+
|
|
19
|
+
## Parameters
|
|
20
|
+
|
|
21
|
+
| Parameter | Type | Description |
|
|
22
|
+
| ----------- | -------- | ------------------- |
|
|
23
|
+
| `eventType` | `string` | Expected event type |
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
[`Guard`](../type-aliases/Guard.md)\<`unknown`, `TEvent`\>
|
|
28
|
+
|
|
29
|
+
Guard predicate checking event type
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const machine = setup({
|
|
35
|
+
guards: {
|
|
36
|
+
isSubmitEvent: eventMatches("submit"),
|
|
37
|
+
isBackOrForward: composeGuardsOr([eventMatches("back"), eventMatches("forward")]),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / formatPlayRouteTransitions
|
|
2
|
+
|
|
3
|
+
# Function: formatPlayRouteTransitions()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function formatPlayRouteTransitions<T>(machineConfig): T;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/routing/format-play-route-transitions.ts:65](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/routing/format-play-route-transitions.ts#L65)
|
|
10
|
+
|
|
11
|
+
Formats play.route transitions from declarative route configs
|
|
12
|
+
|
|
13
|
+
Crawls machine states looking for states with meta.route and generates
|
|
14
|
+
transitions that handle `play.route` events by matching event.to to state IDs.
|
|
15
|
+
|
|
16
|
+
Inspired by XState's internal formatRouteTransitions (stateUtils.ts line 391).
|
|
17
|
+
|
|
18
|
+
## Type Parameters
|
|
19
|
+
|
|
20
|
+
| Type Parameter |
|
|
21
|
+
| --------------------------------------------------------------------------- |
|
|
22
|
+
| `T` _extends_ [`RouteMachineConfig`](../type-aliases/RouteMachineConfig.md) |
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
| Parameter | Type | Description |
|
|
27
|
+
| --------------- | ---- | ------------------------------------------------------------------------------- |
|
|
28
|
+
| `machineConfig` | `T` | XState machine config (before createMachine). Must extend `RouteMachineConfig`. |
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
`T`
|
|
33
|
+
|
|
34
|
+
The same machine config with auto-generated `play.route` handlers merged in, preserving the original type `T`.
|
|
35
|
+
|
|
36
|
+
## Example
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const machineConfig = {
|
|
40
|
+
id: "myMachine",
|
|
41
|
+
states: {
|
|
42
|
+
home: { id: "home", meta: { route: "/home" } },
|
|
43
|
+
dashboard: { id: "dashboard", meta: { route: "/dashboard" } },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const machine = createMachine(formatPlayRouteTransitions(machineConfig));
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This automatically generates play.route handlers at the root level that:
|
|
51
|
+
|
|
52
|
+
- Match event.to against state IDs (e.g., event.to === "#home")
|
|
53
|
+
- Target the appropriate state
|
|
54
|
+
- Assign routeParams and queryParams from the event to context
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / hasContext
|
|
2
|
+
|
|
3
|
+
# Function: hasContext()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function hasContext<TContext>(path): Guard<TContext, PlayEvent>;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/guards/helpers.ts:23](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/guards/helpers.ts#L23)
|
|
10
|
+
|
|
11
|
+
Check if context has a truthy value at path
|
|
12
|
+
|
|
13
|
+
Per CONTEXT.md: Convenience helper for common guard pattern
|
|
14
|
+
|
|
15
|
+
## Type Parameters
|
|
16
|
+
|
|
17
|
+
| Type Parameter | Default type |
|
|
18
|
+
| -------------- | ------------------------------- |
|
|
19
|
+
| `TContext` | `Record`\<`string`, `unknown`\> |
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
| Parameter | Type | Description |
|
|
24
|
+
| --------- | -------- | -------------------------------------- |
|
|
25
|
+
| `path` | `string` | Dot-separated path to context property |
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
[`Guard`](../type-aliases/Guard.md)\<`TContext`, [`PlayEvent`](../../play/type-aliases/PlayEvent.md)\>
|
|
30
|
+
|
|
31
|
+
Guard predicate checking if property is truthy
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const machine = setup({
|
|
37
|
+
guards: {
|
|
38
|
+
hasUserId: hasContext("userId"),
|
|
39
|
+
hasEmail: hasContext("user.email"),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / isAbsoluteRoute
|
|
2
|
+
|
|
3
|
+
# Function: isAbsoluteRoute()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function isAbsoluteRoute(path): boolean;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/routing/derive-route.ts:150](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/routing/derive-route.ts#L150)
|
|
10
|
+
|
|
11
|
+
Check if route path is absolute
|
|
12
|
+
|
|
13
|
+
Determines whether a route path is absolute (starts with `/`) or relative.
|
|
14
|
+
Absolute paths don't inherit from parent routes, while relative paths can be
|
|
15
|
+
composed with parent paths for nested routing.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| --------- | -------- | ------------------- |
|
|
21
|
+
| `path` | `string` | Route path to check |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`boolean`
|
|
26
|
+
|
|
27
|
+
true if path starts with '/', false otherwise
|
|
28
|
+
|
|
29
|
+
## Example
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { isAbsoluteRoute } from "@xmachines/play-xstate";
|
|
33
|
+
|
|
34
|
+
console.log(isAbsoluteRoute("/dashboard")); // true
|
|
35
|
+
console.log(isAbsoluteRoute("settings")); // false
|
|
36
|
+
console.log(isAbsoluteRoute("./about")); // false
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## See
|
|
40
|
+
|
|
41
|
+
[deriveRoute](deriveRoute.md) for route extraction
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / mergeViewProps
|
|
2
|
+
|
|
3
|
+
# Function: mergeViewProps()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function mergeViewProps(view, context): Record<string, unknown>;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/catalog/validate-props.ts:115](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/catalog/validate-props.ts#L115)
|
|
10
|
+
|
|
11
|
+
Merge view metadata with context for props
|
|
12
|
+
|
|
13
|
+
Per CONTEXT.md: "Merge meta.view with relevant context data for component props"
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --------- | ------------------------------------------------------------------------------------- | ---------------------------- |
|
|
19
|
+
| `view` | [`ViewMetadata`](../../play-actor/interfaces/ViewMetadata.md) | View metadata from meta.view |
|
|
20
|
+
| `context` | \| [`ViewMergeContext`](../type-aliases/ViewMergeContext.md) \| `null` \| `undefined` | Machine context |
|
|
21
|
+
|
|
22
|
+
## Returns
|
|
23
|
+
|
|
24
|
+
`Record`\<`string`, `unknown`\>
|
|
25
|
+
|
|
26
|
+
Merged props object
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / negateGuard
|
|
2
|
+
|
|
3
|
+
# Function: negateGuard()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function negateGuard<TContext, TEvent>(guard): ComposedGuard;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/guards/compose.ts:198](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/guards/compose.ts#L198)
|
|
10
|
+
|
|
11
|
+
Negate a guard using XState's not() helper
|
|
12
|
+
|
|
13
|
+
Inverts a guard's result—if the guard passes, NOT fails; if guard fails, NOT passes.
|
|
14
|
+
Uses XState's built-in `not()` helper for proper serialization.
|
|
15
|
+
|
|
16
|
+
## Type Parameters
|
|
17
|
+
|
|
18
|
+
| Type Parameter | Default type | Description |
|
|
19
|
+
| -------------- | ------------ | -------------------------- |
|
|
20
|
+
| `TContext` | `any` | State machine context type |
|
|
21
|
+
| `TEvent` | `any` | Event type |
|
|
22
|
+
|
|
23
|
+
## Parameters
|
|
24
|
+
|
|
25
|
+
| Parameter | Type | Description |
|
|
26
|
+
| --------- | ----------------------------------------------------------------------- | --------------------------------------- |
|
|
27
|
+
| `guard` | `string` \| [`Guard`](../type-aliases/Guard.md)\<`TContext`, `TEvent`\> | Guard predicate or guard name to negate |
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
[`ComposedGuard`](../type-aliases/ComposedGuard.md)
|
|
32
|
+
|
|
33
|
+
XState not() guard negation
|
|
34
|
+
|
|
35
|
+
## Example
|
|
36
|
+
|
|
37
|
+
NOT composition with named guard
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { setup } from "xstate";
|
|
41
|
+
import { negateGuard } from "@xmachines/play-xstate";
|
|
42
|
+
|
|
43
|
+
const machine = setup({
|
|
44
|
+
guards: {
|
|
45
|
+
isGuest: ({ context }) => !context.userId,
|
|
46
|
+
},
|
|
47
|
+
}).createMachine({
|
|
48
|
+
on: {
|
|
49
|
+
accessDashboard: {
|
|
50
|
+
// Allow if NOT a guest (i.e., authenticated)
|
|
51
|
+
guard: negateGuard("isGuest"),
|
|
52
|
+
target: "dashboard",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## See
|
|
59
|
+
|
|
60
|
+
- [composeGuards](composeGuards.md) for AND composition
|
|
61
|
+
- [composeGuardsOr](composeGuardsOr.md) for OR composition
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / stateMatches
|
|
2
|
+
|
|
3
|
+
# Function: stateMatches()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function stateMatches<TContext>(stateValue): Guard<TContext, PlayEvent>;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/guards/helpers.ts:75](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/guards/helpers.ts#L75)
|
|
10
|
+
|
|
11
|
+
## Type Parameters
|
|
12
|
+
|
|
13
|
+
| Type Parameter | Default type |
|
|
14
|
+
| -------------- | ------------------------------- |
|
|
15
|
+
| `TContext` | `Record`\<`string`, `unknown`\> |
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type |
|
|
20
|
+
| ------------ | -------- |
|
|
21
|
+
| `stateValue` | `string` |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
[`Guard`](../type-aliases/Guard.md)\<`TContext`, [`PlayEvent`](../../play/type-aliases/PlayEvent.md)\>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-xstate](../README.md) / validateComponentBinding
|
|
2
|
+
|
|
3
|
+
# Function: validateComponentBinding()
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function validateComponentBinding(view, catalog): void;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-xstate/src/catalog/validate-binding.ts:22](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-xstate/src/catalog/validate-binding.ts#L22)
|
|
10
|
+
|
|
11
|
+
Validate component binding against catalog
|
|
12
|
+
|
|
13
|
+
Per CONTEXT.md:
|
|
14
|
+
|
|
15
|
+
- "Component references: String keys"
|
|
16
|
+
- "Mismatch detection: Both compile-time (TypeScript) and runtime validation"
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
| Parameter | Type | Description |
|
|
21
|
+
| --------- | ------------------------------------------------------------- | ---------------------------- |
|
|
22
|
+
| `view` | [`ViewMetadata`](../../play-actor/interfaces/ViewMetadata.md) | View metadata from meta.view |
|
|
23
|
+
| `catalog` | [`Catalog`](../type-aliases/Catalog.md) | Component catalog |
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
`void`
|
|
28
|
+
|
|
29
|
+
## Example
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const view = { component: "Dashboard", userId: "123" };
|
|
33
|
+
validateComponentBinding(view, catalog);
|
|
34
|
+
// Throws if 'Dashboard' not in catalog
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Throws
|
|
38
|
+
|
|
39
|
+
Error if component not found in catalog
|