@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,17 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-tanstack-react-router](../README.md) / RouteMapping
|
|
2
|
+
|
|
3
|
+
# Interface: RouteMapping
|
|
4
|
+
|
|
5
|
+
Defined in: [play-tanstack-react-router/src/route-map.ts:22](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/route-map.ts#L22)
|
|
6
|
+
|
|
7
|
+
Mapping between state machine state ID and router path.
|
|
8
|
+
|
|
9
|
+
Structurally compatible with `BaseRouteMapping` from `@xmachines/play-router`.
|
|
10
|
+
Fields are `readonly` — entries are immutable once passed to `RouteMap`.
|
|
11
|
+
|
|
12
|
+
## Properties
|
|
13
|
+
|
|
14
|
+
| Property | Modifier | Type | Description | Defined in |
|
|
15
|
+
| --------------------------------------- | ---------- | -------- | -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
16
|
+
| <a id="property-path"></a> `path` | `readonly` | `string` | Router path with optional parameters (e.g., `"/settings/:section?"`) | [play-tanstack-react-router/src/route-map.ts:26](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/route-map.ts#L26) |
|
|
17
|
+
| <a id="property-stateid"></a> `stateId` | `readonly` | `string` | State ID from state machine (e.g., `"home"`, `"settings.profile"`) | [play-tanstack-react-router/src/route-map.ts:24](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/route-map.ts#L24) |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-tanstack-react-router](../README.md) / RouteNavigateEvent
|
|
2
|
+
|
|
3
|
+
# Interface: RouteNavigateEvent
|
|
4
|
+
|
|
5
|
+
Defined in: [play-tanstack-react-router/src/types.ts:21](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/types.ts#L21)
|
|
6
|
+
|
|
7
|
+
Event sent to actor when browser navigates.
|
|
8
|
+
|
|
9
|
+
Browser navigation (user clicks link, back/forward button, direct URL entry)
|
|
10
|
+
sends this event to the actor. The actor's guards determine if navigation
|
|
11
|
+
is allowed based on business logic.
|
|
12
|
+
|
|
13
|
+
Invariant: Passive Infrastructure - Router suggests, actor decides validity.
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
actor.send({ type: "route.navigate", path: "/dashboard" });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Properties
|
|
22
|
+
|
|
23
|
+
| Property | Modifier | Type | Description | Defined in |
|
|
24
|
+
| --------------------------------- | ---------- | ------------------ | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| <a id="property-path"></a> `path` | `readonly` | `string` | Target route path (may include parameters, e.g., /posts/123) | [play-tanstack-react-router/src/types.ts:25](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/types.ts#L25) |
|
|
26
|
+
| <a id="property-type"></a> `type` | `readonly` | `"route.navigate"` | Event type discriminant (extends XState event pattern) | [play-tanstack-react-router/src/types.ts:23](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/types.ts#L23) |
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-tanstack-react-router](../README.md) / RouterBridge
|
|
2
|
+
|
|
3
|
+
# Interface: RouterBridge
|
|
4
|
+
|
|
5
|
+
Defined in: 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: 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: 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-tanstack-react-router](../README.md) / TanStackRouterInstance
|
|
2
|
+
|
|
3
|
+
# Type Alias: TanStackRouterInstance
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type TanStackRouterInstance = ConstructorParameters<typeof TanStackReactRouterBridge>[0];
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [play-tanstack-react-router/src/play-router-provider.tsx:26](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/play-router-provider.tsx#L26)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-tanstack-react-router](../README.md) / TanStackRouterLike
|
|
2
|
+
|
|
3
|
+
# Type Alias: TanStackRouterLike
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type TanStackRouterLike = object;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:42](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L42)
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### history
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
history: object;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:45](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L45)
|
|
20
|
+
|
|
21
|
+
#### subscribe()
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
subscribe(handler): () => void;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
##### Parameters
|
|
28
|
+
|
|
29
|
+
| Parameter | Type |
|
|
30
|
+
| --------- | ------------------- |
|
|
31
|
+
| `handler` | (`event`) => `void` |
|
|
32
|
+
|
|
33
|
+
##### Returns
|
|
34
|
+
|
|
35
|
+
() => `void`
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### state?
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
optional state?: object;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:44](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L44)
|
|
46
|
+
|
|
47
|
+
#### location?
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
optional location?: object;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
##### location.pathname?
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
optional pathname?: string;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Methods
|
|
60
|
+
|
|
61
|
+
### navigate()
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
navigate(args): void;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Defined in: [play-tanstack-react-router/src/tanstack-router-bridge.ts:43](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/play-tanstack-react-router/src/tanstack-router-bridge.ts#L43)
|
|
68
|
+
|
|
69
|
+
#### Parameters
|
|
70
|
+
|
|
71
|
+
| Parameter | Type |
|
|
72
|
+
| --------- | --------------------- |
|
|
73
|
+
| `args` | \{ `to`: `string`; \} |
|
|
74
|
+
| `args.to` | `string` |
|
|
75
|
+
|
|
76
|
+
#### Returns
|
|
77
|
+
|
|
78
|
+
`void`
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[Documentation](../../../README.md) / [@xmachines/play-tanstack-react-router](../README.md) / extractMachineRoutes
|
|
2
|
+
|
|
3
|
+
# Variable: extractMachineRoutes
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
const extractMachineRoutes: (machine) => RouteTree;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Defined in: play-router/dist/extract-routes.d.ts:40
|
|
10
|
+
|
|
11
|
+
Extract complete route tree from state machine graph
|
|
12
|
+
|
|
13
|
+
Crawls machine starting from root, visits all state nodes (including nested
|
|
14
|
+
and parallel), extracts meta.route metadata, validates route references,
|
|
15
|
+
and builds hierarchical tree.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| --------- | ----------------- | ----------------------- |
|
|
21
|
+
| `machine` | `AnyStateMachine` | XState v5 state machine |
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
[`RouteTree`](../../play-router/interfaces/RouteTree.md)
|
|
26
|
+
|
|
27
|
+
Route tree with root, byStateId map, and byPath map
|
|
28
|
+
|
|
29
|
+
## Throws
|
|
30
|
+
|
|
31
|
+
If route references non-existent state
|
|
32
|
+
|
|
33
|
+
## Throws
|
|
34
|
+
|
|
35
|
+
If route path is malformed (doesn't start with /)
|
|
36
|
+
|
|
37
|
+
## Throws
|
|
38
|
+
|
|
39
|
+
If parallel states define conflicting routes
|
|
40
|
+
|
|
41
|
+
## Example
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { createMachine } from "xstate";
|
|
45
|
+
import { extractMachineRoutes } from "@xmachines/play-router";
|
|
46
|
+
|
|
47
|
+
const machine = createMachine({
|
|
48
|
+
initial: "home",
|
|
49
|
+
states: {
|
|
50
|
+
home: { id: "home", meta: { route: "/" } },
|
|
51
|
+
dashboard: {
|
|
52
|
+
id: "dashboard",
|
|
53
|
+
meta: { route: "/dashboard" },
|
|
54
|
+
initial: "overview",
|
|
55
|
+
states: {
|
|
56
|
+
overview: { id: "overview", meta: { route: "/overview" } },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const tree = extractMachineRoutes(machine);
|
|
63
|
+
console.log(tree.byPath.get("/dashboard/overview"));
|
|
64
|
+
```
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
[Documentation](../../README.md) / @xmachines/play-tanstack-react-router-demo
|
|
2
|
+
|
|
3
|
+
# TanStack React Router Demo
|
|
4
|
+
|
|
5
|
+
React + TanStack Router demonstration of Play's actor-authoritative routing and rendering model.
|
|
6
|
+
|
|
7
|
+
## What This Demonstrates
|
|
8
|
+
|
|
9
|
+
- Shared auth machine reused without framework-specific business logic
|
|
10
|
+
- `PlayRouterProvider` renderer-based integration with TanStack Router
|
|
11
|
+
- Shell-driven rendering via `PlayRenderer` with actor-authoritative navigation
|
|
12
|
+
- Non-browser invariant tests plus browser E2E coverage
|
|
13
|
+
|
|
14
|
+
## Running the Demo
|
|
15
|
+
|
|
16
|
+
From this directory (`packages/play-tanstack-react-router/examples/demo`):
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install
|
|
20
|
+
npm run dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Open `http://localhost:3000`.
|
|
24
|
+
|
|
25
|
+
## Step-by-Step Code Flow
|
|
26
|
+
|
|
27
|
+
This demo uses provider-based integration centered on `PlayRouterProvider` and a route map generated from the machine:
|
|
28
|
+
|
|
29
|
+
1. `src/main.tsx` mounts `<App />`.
|
|
30
|
+
2. `src/App.tsx` creates/starts the actor from shared machine + catalog.
|
|
31
|
+
3. `src/App.tsx` builds `routeMap` from `extractMachineRoutes(authMachine)` + `createRouteMapFromTree(routeTree)`.
|
|
32
|
+
4. `PlayRouterProvider` bridges TanStack Router to the actor and renders `Shell` via `renderer(actor, router)`.
|
|
33
|
+
5. `Shell` renders `PlayRenderer`, header/nav, and debug panel from actor state.
|
|
34
|
+
6. Tests in `test/` and `test/browser*/` validate invariant and runtime behavior.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
// src/App.tsx (shape)
|
|
38
|
+
const routeTree = extractMachineRoutes(authMachine);
|
|
39
|
+
const routeMap = createRouteMapFromTree(routeTree);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<PlayRouterProvider
|
|
43
|
+
actor={actor}
|
|
44
|
+
router={router}
|
|
45
|
+
routeMap={routeMap}
|
|
46
|
+
renderer={(currentActor, currentRouter) => (
|
|
47
|
+
<Shell actor={currentActor} router={currentRouter} />
|
|
48
|
+
)}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
// src/components/Login.tsx (shape)
|
|
55
|
+
<button onClick={() => actor.send({ type: "auth.login", username })}>Login</button>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Shared business logic comes from the common demo machine/catalog module (`authMachine` and `catalog`), so routing decisions remain machine-driven and framework-independent.
|
|
59
|
+
|
|
60
|
+
## Key Files
|
|
61
|
+
|
|
62
|
+
- `src/main.tsx` - React entry point that mounts `<App />`
|
|
63
|
+
- `src/App.tsx` - actor lifecycle, route-map creation, provider wiring, and `Shell` rendering
|
|
64
|
+
- `src/components/` - UI components that send actor events and render state-driven views
|
|
65
|
+
- `test/actor-authority.test.ts` - actor authority and guarded navigation behavior
|
|
66
|
+
- `test/strict-separation.test.ts` - machine/view infrastructure separation contracts
|
|
67
|
+
- `test/browser-e2e/auth-flow.browser.test.tsx` - canonical browser auth flow
|
|
68
|
+
- `test/browser/` - extended browser checks for URL sync, history behavior, and route event flow
|
|
69
|
+
|
|
70
|
+
## State Machine & Architecture Details
|
|
71
|
+
|
|
72
|
+
The demo utilizes XMachines architectural invariants:
|
|
73
|
+
|
|
74
|
+
1. **Actor Authority:** When a user navigates to a protected route, TanStack 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. `isAuthenticated`) and executes state transitions.
|
|
75
|
+
2. **Passive Infrastructure:** The router does not execute route loaders or guards for business logic. The actor dictates whether navigation is permitted.
|
|
76
|
+
3. **Signal-Only Reactivity:** The bridge leverages React's internal mechanisms combined with TanStack's `router.subscribe` to react precisely when signals update, without relying on `useEffect` synchronization inside the application codebase.
|
|
77
|
+
|
|
78
|
+
## Watcher Lifecycle and Cleanup Contract
|
|
79
|
+
|
|
80
|
+
This demo follows the canonical watcher lifecycle:
|
|
81
|
+
|
|
82
|
+
1. `notify`
|
|
83
|
+
2. `queueMicrotask`
|
|
84
|
+
3. `getPending()`
|
|
85
|
+
4. Read actor signals and trigger React state updates
|
|
86
|
+
5. Re-arm with `watch()`/`watch(...signals)`
|
|
87
|
+
|
|
88
|
+
Watcher notifications are one-shot. Cleanup is explicit and lifecycle-bound: the provider automatically triggers `bridge.disconnect()` when the component tree unmounts to prevent memory leaks and zombie subscriptions.
|
|
89
|
+
|
|
90
|
+
## Adapter Boundaries
|
|
91
|
+
|
|
92
|
+
The TanStack React adapter wraps TanStack's `router.navigate({ to })` and `router.subscribe` methods while delegating core synchronization policy to `RouterBridgeBase`.
|
|
93
|
+
|
|
94
|
+
## Available Scripts
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm run dev # Start Vite dev server (http://localhost:3000)
|
|
98
|
+
npm run build # Build production assets
|
|
99
|
+
npm run preview # Preview production build locally
|
|
100
|
+
npm run test # Run Vitest suite
|
|
101
|
+
npm run test:vitest # Explicit Vitest command alias
|
|
102
|
+
npm run test:browser # Browser-focused test run
|
|
103
|
+
npm run test:browser:e2e # E2E-specific browser suite
|
|
104
|
+
npm run test:e2e # Alias to test:browser
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Verification
|
|
108
|
+
|
|
109
|
+
Run the core invariant checks referenced by this demo docs:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npm run test:vitest -- test/actor-authority.test.ts test/strict-separation.test.ts
|
|
113
|
+
npm run test:browser
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Manual sanity flow:
|
|
117
|
+
|
|
118
|
+
1. Run `npm run dev` and open `http://localhost:3000`.
|
|
119
|
+
2. Attempt protected navigation while logged out and confirm guard-driven behavior.
|
|
120
|
+
3. Log in, then confirm route and view updates stay in sync.
|
|
121
|
+
|
|
122
|
+
## Learn More
|
|
123
|
+
|
|
124
|
+
- [TanStack React Router package README](../play-tanstack-react-router/README.md)
|
|
125
|
+
- [Solid Router demo README](../play-solid-router-demo/README.md)
|
|
126
|
+
- [TanStack Solid Router demo README](../play-tanstack-solid-router-demo/README.md)
|