@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,104 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-solid-router](../README.md) / RouterBridge
|
|
2
|
+
|
|
3
|
+
# Interface: RouterBridge
|
|
4
|
+
|
|
5
|
+
Defined in: packages/play-router/dist/types.d.ts:229
|
|
6
|
+
|
|
7
|
+
RouterBridge interface for runtime infrastructure adapters
|
|
8
|
+
|
|
9
|
+
Defines the lifecycle connection between Infrastructure (e.g., TanStack Router) and
|
|
10
|
+
the Actor. Infrastructure "bridges" to the Actor by observing its signals and
|
|
11
|
+
managing its own lifecycle accordingly.
|
|
12
|
+
|
|
13
|
+
**Architectural Context:** Implements **Passive Infrastructure (INV-04)** by establishing
|
|
14
|
+
a unidirectional observation pattern. Infrastructure connects to observe Actor signals
|
|
15
|
+
(currentRoute, currentView, state) and reflects changes without making state decisions.
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
|
|
19
|
+
TanStack Router bridge implementation
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import type { RouterBridge } from "@xmachines/play-router";
|
|
23
|
+
import { Signal } from "@xmachines/play-signals";
|
|
24
|
+
|
|
25
|
+
class TanStackRouterBridge implements RouterBridge {
|
|
26
|
+
private watcher: Signal.Watcher | null = null;
|
|
27
|
+
|
|
28
|
+
async connect(): Promise<void> {
|
|
29
|
+
// Start observing actor.currentRoute signal
|
|
30
|
+
this.watcher = new Signal.subtle.Watcher(() => {
|
|
31
|
+
const route = actor.currentRoute.get();
|
|
32
|
+
if (route) router.navigate(route);
|
|
33
|
+
});
|
|
34
|
+
this.watcher.watch(actor.currentRoute);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async disconnect(): Promise<void> {
|
|
38
|
+
// Stop observing, cleanup watchers
|
|
39
|
+
this.watcher?.unwatch(actor.currentRoute);
|
|
40
|
+
this.watcher = null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## See
|
|
46
|
+
|
|
47
|
+
[RFC Play v1 - Invariant INV-04](https://gitlab.com/xmachin-es/rfc/-/blob/main/src/play-v1.md)
|
|
48
|
+
|
|
49
|
+
## Methods
|
|
50
|
+
|
|
51
|
+
### connect()
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
connect(): void | Promise<void>;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Defined in: packages/play-router/dist/types.d.ts:245
|
|
58
|
+
|
|
59
|
+
Connect the router bridge to the Actor
|
|
60
|
+
|
|
61
|
+
Called when Infrastructure should begin observing Actor signals and
|
|
62
|
+
synchronizing its state (e.g., browser URL) with Actor state.
|
|
63
|
+
|
|
64
|
+
#### Returns
|
|
65
|
+
|
|
66
|
+
`void` \| `Promise`\<`void`\>
|
|
67
|
+
|
|
68
|
+
Promise that resolves when connection is established, or void for synchronous connection
|
|
69
|
+
|
|
70
|
+
#### Example
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const bridge: RouterBridge = createBridge(actor, router);
|
|
74
|
+
await bridge.connect();
|
|
75
|
+
// Bridge now observing actor.currentRoute signal
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### disconnect()
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
disconnect(): void | Promise<void>;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Defined in: packages/play-router/dist/types.d.ts:260
|
|
87
|
+
|
|
88
|
+
Disconnect the router bridge from the Actor
|
|
89
|
+
|
|
90
|
+
Called when Infrastructure should stop observing and clean up resources
|
|
91
|
+
(e.g., signal watchers, event listeners).
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`void` \| `Promise`\<`void`\>
|
|
96
|
+
|
|
97
|
+
Promise that resolves when disconnection is complete, or void for synchronous disconnection
|
|
98
|
+
|
|
99
|
+
#### Example
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
await bridge.disconnect();
|
|
103
|
+
// Bridge stopped observing, resources cleaned up
|
|
104
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-solid-router](../README.md) / RoutableActor
|
|
2
|
+
|
|
3
|
+
# Type Alias: RoutableActor
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type RoutableActor = AbstractActor<AnyActorLogic> & Routable & Viewable;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-solid-router/src/play-router-provider.tsx:7](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-solid-router/src/play-router-provider.tsx#L7)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-solid-router](../README.md) / SolidRouterHooks
|
|
2
|
+
|
|
3
|
+
# Type Alias: SolidRouterHooks
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type SolidRouterHooks = object;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/play-solid-router/src/play-router-provider.tsx:8](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-solid-router/src/play-router-provider.tsx#L8)
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### location
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
location: object;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Defined in: [packages/play-solid-router/src/play-router-provider.tsx:10](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-solid-router/src/play-router-provider.tsx#L10)
|
|
20
|
+
|
|
21
|
+
#### pathname
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
pathname: string;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### search
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
search: string;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### navigate
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
navigate: ((path) => void) | ((path, ...args) => unknown);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Defined in: [packages/play-solid-router/src/play-router-provider.tsx:9](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-solid-router/src/play-router-provider.tsx#L9)
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### params
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
params: Record<string, string | undefined>;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Defined in: [packages/play-solid-router/src/play-router-provider.tsx:11](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-solid-router/src/play-router-provider.tsx#L11)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
[Documentation](../../README.md) / @xmachines/play-solid-router-demo
|
|
2
|
+
|
|
3
|
+
# Solid Router Demo
|
|
4
|
+
|
|
5
|
+
Solid + `@solidjs/router` demonstration of the Play architecture using provider-based router integration.
|
|
6
|
+
|
|
7
|
+
## What This Demonstrates
|
|
8
|
+
|
|
9
|
+
- Shared auth machine reused without framework-specific business logic
|
|
10
|
+
- `PlayRouterProvider` renderer-based integration with Solid Router
|
|
11
|
+
- Shell-driven rendering via `PlayRenderer` with actor-authoritative navigation
|
|
12
|
+
- Canonical TC39 Signals lifecycle integration with Solid's fine-grained reactivity
|
|
13
|
+
- Non-browser invariant tests plus browser E2E coverage
|
|
14
|
+
|
|
15
|
+
## Running the Demo
|
|
16
|
+
|
|
17
|
+
From this directory (`packages/play-solid-router/examples/demo`):
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
npm run dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Open `http://localhost:5173`.
|
|
25
|
+
|
|
26
|
+
## Step-by-Step Code Flow
|
|
27
|
+
|
|
28
|
+
Use this order to understand the implementation:
|
|
29
|
+
|
|
30
|
+
1. `src/main.tsx` bootstraps the demo and mounts the `<App />` component.
|
|
31
|
+
2. `src/App.tsx` wires actor lifecycle, shared machine/catalog imports, and router integration.
|
|
32
|
+
3. A `routeMap` is created by extracting routes from the shared `authMachine`.
|
|
33
|
+
4. `PlayRouterProvider` forwards navigation intent from `@solidjs/router` to the actor, and reflects actor-approved routes back to the URL.
|
|
34
|
+
5. `Shell` (inside `src/App.tsx`) renders actor-projected views (`PlayRenderer`) and provides the shared UI shell.
|
|
35
|
+
6. `test/library-pattern.test.ts` and `test/browser/` verify invariants and runtime routing behavior.
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
// src/main.tsx (shape)
|
|
39
|
+
render(() => <App />, document.getElementById("root")!);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
// src/App.tsx (shape)
|
|
44
|
+
const createPlayer = definePlayer({ machine: authMachine, catalog });
|
|
45
|
+
const actor = createPlayer();
|
|
46
|
+
actor.start();
|
|
47
|
+
|
|
48
|
+
const routeMap = createRouteMap(authMachine);
|
|
49
|
+
|
|
50
|
+
<PlayRouterProvider
|
|
51
|
+
actor={actor}
|
|
52
|
+
routeMap={routeMap}
|
|
53
|
+
router={{ navigate, location, params }}
|
|
54
|
+
renderer={(currentActor, currentRouter) => (
|
|
55
|
+
<Shell actor={currentActor} router={currentRouter} />
|
|
56
|
+
)}
|
|
57
|
+
/>;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
// src/components/Nav.tsx (shape)
|
|
62
|
+
<button onClick={() => actor.send({ type: "auth.logout" })}>Logout</button>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Key Files
|
|
66
|
+
|
|
67
|
+
- `src/App.tsx` - Integration entry point wiring actor, provider, renderer, and shared machine/catalog imports.
|
|
68
|
+
- `src/main.tsx` - Vite bootstrap for the Solid app.
|
|
69
|
+
- `src/components/` - Demo views and controls that send events to the actor.
|
|
70
|
+
- `test/library-pattern.test.ts` - Node/Vitest invariant checks for architecture boundaries.
|
|
71
|
+
- `test/browser/startup.browser.test.ts` - Browser startup and mount coverage.
|
|
72
|
+
- `test/browser/auth-flow.browser.test.ts` - Browser auth and routing behavior coverage.
|
|
73
|
+
|
|
74
|
+
## State Machine & Architecture Details
|
|
75
|
+
|
|
76
|
+
The demo utilizes XMachines architectural invariants:
|
|
77
|
+
|
|
78
|
+
1. **Actor Authority:** When a user navigates to a protected route, the Solid Router updates the URL. The `PlayRouterProvider` intercepts this, translates it to a `play.route` event, and sends it to the actor. The actor evaluates guards (e.g., is the user logged in?) and transitions to the appropriate state.
|
|
79
|
+
2. **Passive Infrastructure:** Solid components hold no business state. They observe `actor.currentView` to know what to render, and `actor.currentRoute` to reflect the active path.
|
|
80
|
+
3. **Signal-Only Reactivity:** Instead of React-like re-renders, Solid uses `createEffect` internally within the `RouterBridge` to react precisely when signals update.
|
|
81
|
+
|
|
82
|
+
## Watcher Lifecycle and Cleanup Contract
|
|
83
|
+
|
|
84
|
+
This demo follows the canonical watcher lifecycle:
|
|
85
|
+
|
|
86
|
+
1. `notify`
|
|
87
|
+
2. `queueMicrotask`
|
|
88
|
+
3. `getPending()`
|
|
89
|
+
4. Read actor signals and update Solid-local render triggers
|
|
90
|
+
5. Re-arm with `watch()`/`watch(...signals)`
|
|
91
|
+
|
|
92
|
+
Watcher notifications are one-shot. Cleanup is explicit and lifecycle-bound: Solid teardown uses `onCleanup`, and provider/bridge teardown must call `disconnect`/`unwatch` paths rather than relying on GC-only cleanup. This is crucial to prevent memory leaks during component unmounting.
|
|
93
|
+
|
|
94
|
+
## Adapter Boundaries
|
|
95
|
+
|
|
96
|
+
Solid Router integration remains passive infrastructure. `RouterBridgeBase` stays the shared policy point; the Solid adapter only implements framework port behavior (calling `navigate()` and tracking `location.pathname`).
|
|
97
|
+
|
|
98
|
+
## Available Scripts
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run dev # Start Vite dev server (default: http://localhost:5173)
|
|
102
|
+
npm run build # Build production assets
|
|
103
|
+
npm run preview # Preview production build locally
|
|
104
|
+
npm run test # Run unit/integration tests via Vitest
|
|
105
|
+
npm run test:browser # Run browser-mode tests via vitest.browser.config.ts
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Verification
|
|
109
|
+
|
|
110
|
+
Use these checks from this directory:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm run test
|
|
114
|
+
npm run test:browser
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Manual sanity check:
|
|
118
|
+
|
|
119
|
+
1. Start the app with `npm run dev`.
|
|
120
|
+
2. Open `http://localhost:5173`.
|
|
121
|
+
3. Confirm login/logout transitions update both view and URL, and that accessing protected routes while logged out redirects properly.
|
|
122
|
+
|
|
123
|
+
## Learn More
|
|
124
|
+
|
|
125
|
+
- [Solid Router package README](../play-solid-router/README.md)
|
|
126
|
+
- [TanStack Solid Router demo README](../play-tanstack-solid-router-demo/README.md)
|
|
127
|
+
- [TanStack React Router demo README](../play-tanstack-react-router-demo/README.md)
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
[Documentation](../../README.md) / @xmachines/play-tanstack-react-router
|
|
2
|
+
|
|
3
|
+
# @xmachines/play-tanstack-react-router
|
|
4
|
+
|
|
5
|
+
**TanStack React Router adapter for XMachines Play using the RouterBridge pattern.**
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
`@xmachines/play-tanstack-react-router` connects a Play actor to TanStack Router through `TanStackReactRouterBridge`.
|
|
10
|
+
|
|
11
|
+
The bridge extends `RouterBridgeBase` from `@xmachines/play-router`, so adapter behavior stays consistent across frameworks:
|
|
12
|
+
|
|
13
|
+
- Actor route signal (`actor.currentRoute`) drives router navigation.
|
|
14
|
+
- Router history events send `play.route` intents back to the actor.
|
|
15
|
+
- Guarded state transitions remain actor-owned (Actor Authority).
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @tanstack/react-router react
|
|
21
|
+
npm install @xmachines/play-tanstack-react-router @xmachines/play-router @xmachines/play-react
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Current Exports
|
|
25
|
+
|
|
26
|
+
- `TanStackReactRouterBridge`
|
|
27
|
+
- `RouteMap`, `createRouteMapFromTree`, `RouteMapping` (type)
|
|
28
|
+
- `extractParams`, `extractQueryParams`
|
|
29
|
+
- `PlayRouterProvider` + `PlayRouterProviderProps`
|
|
30
|
+
- re-exports: `extractMachineRoutes`, `createRouteMap`, `RouterBridge`, `PlayRouteEvent`
|
|
31
|
+
|
|
32
|
+
Peer dependencies:
|
|
33
|
+
|
|
34
|
+
- `@tanstack/react-router` `^1.166.7`
|
|
35
|
+
- `react` `^18 || ^19`
|
|
36
|
+
- `xstate` `^5.0.0`
|
|
37
|
+
|
|
38
|
+
## URLPattern Support
|
|
39
|
+
|
|
40
|
+
This package uses the [URLPattern API](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) for route pattern matching via `@xmachines/play-router`.
|
|
41
|
+
|
|
42
|
+
URLPattern is available natively on Node.js 24+ and modern browsers (Chrome 95+, Firefox 117+, Safari 16.4+). On older environments, load a polyfill **before** importing this package — see [`@xmachines/play-router` installation](../play-router/README.md) for details.
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { createRouter } from "@tanstack/react-router";
|
|
48
|
+
import { definePlayer } from "@xmachines/play-xstate";
|
|
49
|
+
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
50
|
+
import {
|
|
51
|
+
TanStackReactRouterBridge,
|
|
52
|
+
createRouteMapFromTree,
|
|
53
|
+
} from "@xmachines/play-tanstack-react-router";
|
|
54
|
+
|
|
55
|
+
const routeTree = extractMachineRoutes(machine);
|
|
56
|
+
const routeMap = createRouteMapFromTree(routeTree);
|
|
57
|
+
|
|
58
|
+
const router = createRouter({ routeTree: tanstackRouteTree });
|
|
59
|
+
|
|
60
|
+
const actor = definePlayer({ machine, catalog })();
|
|
61
|
+
actor.start();
|
|
62
|
+
|
|
63
|
+
const bridge = new TanStackReactRouterBridge(router, actor, routeMap);
|
|
64
|
+
bridge.connect();
|
|
65
|
+
|
|
66
|
+
// later
|
|
67
|
+
bridge.disconnect();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### React convenience wrapper
|
|
71
|
+
|
|
72
|
+
Use `PlayRouterProvider` when you want bridge lifecycle wiring in a component:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { PlayRenderer } from "@xmachines/play-react";
|
|
76
|
+
|
|
77
|
+
<PlayRouterProvider
|
|
78
|
+
actor={actor}
|
|
79
|
+
router={router}
|
|
80
|
+
routeMap={routeMap}
|
|
81
|
+
renderer={(currentActor, currentRouter) => (
|
|
82
|
+
<PlayRenderer actor={currentActor} components={components} />
|
|
83
|
+
)}
|
|
84
|
+
/>;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## API
|
|
88
|
+
|
|
89
|
+
### `TanStackReactRouterBridge`
|
|
90
|
+
|
|
91
|
+
Primary adapter class.
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
class TanStackReactRouterBridge implements RouterBridge {
|
|
95
|
+
constructor(
|
|
96
|
+
router: TanStackRouterLike,
|
|
97
|
+
actor: AbstractActor<AnyActorLogic> & Routable,
|
|
98
|
+
routeMap: RouteMap,
|
|
99
|
+
);
|
|
100
|
+
connect(): void;
|
|
101
|
+
disconnect(): void;
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### `RouteMap` and `createRouteMapFromTree`
|
|
106
|
+
|
|
107
|
+
Map state IDs to URL paths and resolve URLs back to state IDs.
|
|
108
|
+
|
|
109
|
+
`RouteMap` extends `BaseRouteMap` from `@xmachines/play-router`, inheriting bucket-indexed
|
|
110
|
+
bidirectional route matching. No routing logic lives in the adapter itself.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
// RouteMap is a thin subclass of BaseRouteMap — no extra methods
|
|
114
|
+
class RouteMap extends BaseRouteMap {}
|
|
115
|
+
|
|
116
|
+
// Inherited API:
|
|
117
|
+
routeMap.getStateIdByPath(path: string): string | null
|
|
118
|
+
routeMap.getPathByStateId(stateId: string): string | null
|
|
119
|
+
|
|
120
|
+
// Factory from a machine route tree:
|
|
121
|
+
function createRouteMapFromTree(routeTree: RouteTree): RouteMap
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`getStateIdByPath` returns `null` (not `undefined`) for unmatched paths.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const routeMap = new RouteMap([
|
|
128
|
+
{ stateId: "home", path: "/" },
|
|
129
|
+
{ stateId: "profile", path: "/profile/:userId" },
|
|
130
|
+
{ stateId: "settings", path: "/settings/:section?" },
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
routeMap.getStateIdByPath("/profile/123"); // "profile"
|
|
134
|
+
routeMap.getPathByStateId("home"); // "/"
|
|
135
|
+
routeMap.getStateIdByPath("/unknown"); // null
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### `PlayRouterProvider`
|
|
139
|
+
|
|
140
|
+
React wrapper around `TanStackReactRouterBridge`.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
interface PlayRouterProviderProps {
|
|
144
|
+
actor: AbstractActor<AnyActorLogic> & Routable & Viewable;
|
|
145
|
+
router: TanStackRouterLike;
|
|
146
|
+
routeMap: RouteMap;
|
|
147
|
+
renderer: (
|
|
148
|
+
actor: AbstractActor<AnyActorLogic> & Routable & Viewable,
|
|
149
|
+
router: TanStackRouterLike,
|
|
150
|
+
) => ReactNode;
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Utilities and re-exports
|
|
155
|
+
|
|
156
|
+
- `extractParams`, `extractQueryParams`
|
|
157
|
+
- `extractMachineRoutes`, `createRouteMap` (re-exported from `@xmachines/play-router`)
|
|
158
|
+
- `RouterBridge`, `PlayRouteEvent` types
|
|
159
|
+
|
|
160
|
+
## Examples
|
|
161
|
+
|
|
162
|
+
- Multi-router integration guide: `docs/examples/multi-router-integration.md`
|
|
163
|
+
- Routing patterns guide: `docs/examples/routing-patterns.md`
|
|
164
|
+
|
|
165
|
+
## Architecture
|
|
166
|
+
|
|
167
|
+
Bridge-first flow:
|
|
168
|
+
|
|
169
|
+
1. `RouterBridgeBase.connect()` performs initial actor/router synchronization.
|
|
170
|
+
2. Actor route updates call TanStack navigation (`router.navigate({ to })`).
|
|
171
|
+
3. TanStack history updates are subscribed and translated to `play.route` events.
|
|
172
|
+
4. Actor guards accept or reject transitions; infrastructure reflects resulting state.
|
|
173
|
+
|
|
174
|
+
This keeps routing infrastructure passive while preserving business-logic control.
|
|
175
|
+
|
|
176
|
+
## Historical Note
|
|
177
|
+
|
|
178
|
+
`SignalSyncedHistory` and `createPlayRouter` are legacy migration-era APIs and are not part of the current quick-start path. Use `TanStackReactRouterBridge` + `RouteMap` for new integrations.
|
|
179
|
+
|
|
180
|
+
## Related Packages
|
|
181
|
+
|
|
182
|
+
- [@xmachines/play-router](../play-router/README.md)
|
|
183
|
+
- [@xmachines/play-xstate](../play-xstate/README.md)
|
|
184
|
+
- [@xmachines/play-react](../play-react/README.md)
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
Copyright (c) 2016 [Mikael Karon](mailto:mikael@karon.se). All rights reserved.
|
|
189
|
+
|
|
190
|
+
This work is licensed under the terms of the MIT license.
|
|
191
|
+
For a copy, see <https://opensource.org/licenses/MIT>.
|
|
192
|
+
|
|
193
|
+
@xmachines/play-tanstack-react-router
|
|
194
|
+
|
|
195
|
+
TanStack Router adapter for XMachines Play architecture.
|
|
196
|
+
Synchronizes browser URL with actor state through passive infrastructure.
|
|
197
|
+
|
|
198
|
+
## Classes
|
|
199
|
+
|
|
200
|
+
- [RouteMap](classes/RouteMap.md)
|
|
201
|
+
- [TanStackReactRouterBridge](classes/TanStackReactRouterBridge.md)
|
|
202
|
+
|
|
203
|
+
## Interfaces
|
|
204
|
+
|
|
205
|
+
- [PlayRouteEvent](interfaces/PlayRouteEvent.md)
|
|
206
|
+
- [PlayRouterProviderProps](interfaces/PlayRouterProviderProps.md)
|
|
207
|
+
- [RouteMapping](interfaces/RouteMapping.md)
|
|
208
|
+
- [RouteNavigateEvent](interfaces/RouteNavigateEvent.md)
|
|
209
|
+
- [RouterBridge](interfaces/RouterBridge.md)
|
|
210
|
+
|
|
211
|
+
## Type Aliases
|
|
212
|
+
|
|
213
|
+
- [TanStackRouterInstance](type-aliases/TanStackRouterInstance.md)
|
|
214
|
+
- [TanStackRouterLike](type-aliases/TanStackRouterLike.md)
|
|
215
|
+
|
|
216
|
+
## Variables
|
|
217
|
+
|
|
218
|
+
- [extractMachineRoutes](variables/extractMachineRoutes.md)
|
|
219
|
+
|
|
220
|
+
## Functions
|
|
221
|
+
|
|
222
|
+
- [createRouteMap](functions/createRouteMap.md)
|
|
223
|
+
- [createRouteMapFromTree](functions/createRouteMapFromTree.md)
|
|
224
|
+
- [extractParams](functions/extractParams.md)
|
|
225
|
+
- [extractQueryParams](functions/extractQueryParams.md)
|
|
226
|
+
- [PlayRouterProvider](functions/PlayRouterProvider.md)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-tanstack-react-router](../README.md) / RouteMap
|
|
2
|
+
|
|
3
|
+
# Class: RouteMap
|
|
4
|
+
|
|
5
|
+
Defined in: [play-tanstack-react-router/src/route-map.ts:54](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/route-map.ts#L54)
|
|
6
|
+
|
|
7
|
+
Bidirectional route mapper for TanStack React Router.
|
|
8
|
+
|
|
9
|
+
Extends [BaseRouteMap](../../play-router/classes/BaseRouteMap.md) — all matching logic lives there.
|
|
10
|
+
This class exists to provide a TanStack React Router-specific type name and to
|
|
11
|
+
allow future adapter-specific extensions without breaking the shared base.
|
|
12
|
+
|
|
13
|
+
**Inherited API:**
|
|
14
|
+
|
|
15
|
+
- `getStateIdByPath(path): string | null` — path → state ID
|
|
16
|
+
- `getPathByStateId(stateId): string | null` — state ID → path pattern
|
|
17
|
+
|
|
18
|
+
## Example
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
const routeMap = new RouteMap([
|
|
22
|
+
{ stateId: "home", path: "/" },
|
|
23
|
+
{ stateId: "profile", path: "/profile/:userId" },
|
|
24
|
+
{ stateId: "settings", path: "/settings/:section?" },
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
routeMap.getStateIdByPath("/profile/123"); // "profile"
|
|
28
|
+
routeMap.getPathByStateId("home"); // "/"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Extends
|
|
32
|
+
|
|
33
|
+
- [`BaseRouteMap`](../../play-router/classes/BaseRouteMap.md)
|
|
34
|
+
|
|
35
|
+
## Constructors
|
|
36
|
+
|
|
37
|
+
### Constructor
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
new RouteMap(mappings): RouteMap;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Defined in: play-router/dist/base-route-map.d.ts:81
|
|
44
|
+
|
|
45
|
+
Build a route map from an array of state ID ↔ path mappings.
|
|
46
|
+
|
|
47
|
+
Static paths (no `:param`) are indexed in an O(1) `Map`.
|
|
48
|
+
Parameterized paths are compiled to `RegExp` and grouped into first-segment
|
|
49
|
+
buckets for efficient candidate selection.
|
|
50
|
+
|
|
51
|
+
#### Parameters
|
|
52
|
+
|
|
53
|
+
| Parameter | Type | Description |
|
|
54
|
+
| ---------- | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `mappings` | [`BaseRouteMapping`](../../play-router/interfaces/BaseRouteMapping.md)[] | Array of `{ stateId, path }` entries. Order determines priority when multiple patterns could match the same path. |
|
|
56
|
+
|
|
57
|
+
#### Returns
|
|
58
|
+
|
|
59
|
+
`RouteMap`
|
|
60
|
+
|
|
61
|
+
#### Inherited from
|
|
62
|
+
|
|
63
|
+
[`BaseRouteMap`](../../play-router/classes/BaseRouteMap.md).[`constructor`](../../play-router/classes/BaseRouteMap.md#constructor)
|
|
64
|
+
|
|
65
|
+
## Methods
|
|
66
|
+
|
|
67
|
+
### getPathByStateId()
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
getPathByStateId(stateId): string | null;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Defined in: play-router/dist/base-route-map.d.ts:111
|
|
74
|
+
|
|
75
|
+
Look up the path pattern registered for a state ID.
|
|
76
|
+
|
|
77
|
+
#### Parameters
|
|
78
|
+
|
|
79
|
+
| Parameter | Type | Description |
|
|
80
|
+
| --------- | -------- | --------------------------------------------------------- |
|
|
81
|
+
| `stateId` | `string` | State machine state ID (e.g., `"profile"`, `"#settings"`) |
|
|
82
|
+
|
|
83
|
+
#### Returns
|
|
84
|
+
|
|
85
|
+
`string` \| `null`
|
|
86
|
+
|
|
87
|
+
The registered path pattern, or `null` if the state ID is unknown
|
|
88
|
+
|
|
89
|
+
#### Example
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
map.getPathByStateId("profile"); // "/profile/:userId"
|
|
93
|
+
map.getPathByStateId("missing"); // null
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Inherited from
|
|
97
|
+
|
|
98
|
+
[`BaseRouteMap`](../../play-router/classes/BaseRouteMap.md).[`getPathByStateId`](../../play-router/classes/BaseRouteMap.md#getpathbystateid)
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### getStateIdByPath()
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
getStateIdByPath(path): string | null;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Defined in: play-router/dist/base-route-map.d.ts:98
|
|
109
|
+
|
|
110
|
+
Resolve a URL path to its mapped state ID.
|
|
111
|
+
|
|
112
|
+
Strips query strings and hash fragments before matching. Tries an O(1) exact
|
|
113
|
+
lookup first, then falls back to bucket-indexed pattern matching. Results are
|
|
114
|
+
cached after the first pattern match.
|
|
115
|
+
|
|
116
|
+
#### Parameters
|
|
117
|
+
|
|
118
|
+
| Parameter | Type | Description |
|
|
119
|
+
| --------- | -------- | ------------------------------------------------------------------------------ |
|
|
120
|
+
| `path` | `string` | URL pathname, optionally including query/hash (e.g., `"/profile/123?ref=nav"`) |
|
|
121
|
+
|
|
122
|
+
#### Returns
|
|
123
|
+
|
|
124
|
+
`string` \| `null`
|
|
125
|
+
|
|
126
|
+
The mapped state ID, or `null` if no route matches
|
|
127
|
+
|
|
128
|
+
#### Example
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
map.getStateIdByPath("/profile/123"); // "profile"
|
|
132
|
+
map.getStateIdByPath("/unknown"); // null
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### Inherited from
|
|
136
|
+
|
|
137
|
+
[`BaseRouteMap`](../../play-router/classes/BaseRouteMap.md).[`getStateIdByPath`](../../play-router/classes/BaseRouteMap.md#getstateidbypath)
|