@xmachines/docs 1.0.0-beta.17 → 1.0.0-beta.19

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.
Files changed (184) hide show
  1. package/api/@xmachines/play/README.md +1 -1
  2. package/api/@xmachines/play/classes/PlayError.md +4 -4
  3. package/api/@xmachines/play/type-aliases/PlayEvent.md +3 -3
  4. package/api/@xmachines/play-actor/README.md +2 -2
  5. package/api/@xmachines/play-actor/classes/AbstractActor.md +4 -4
  6. package/api/@xmachines/play-actor/interfaces/PlaySpec.md +2 -2
  7. package/api/@xmachines/play-actor/interfaces/Routable.md +3 -3
  8. package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +3 -3
  9. package/api/@xmachines/play-actor/interfaces/Viewable.md +2 -2
  10. package/api/@xmachines/play-dom/classes/PlayRenderer.md +4 -4
  11. package/api/@xmachines/play-dom/functions/connectRenderer.md +1 -1
  12. package/api/@xmachines/play-dom/functions/renderSpec.md +1 -1
  13. package/api/@xmachines/play-dom/interfaces/ConnectRendererOptions.md +7 -7
  14. package/api/@xmachines/play-dom/interfaces/DomRenderContext.md +7 -7
  15. package/api/@xmachines/play-dom/interfaces/PlayDomOptions.md +3 -3
  16. package/api/@xmachines/play-dom/type-aliases/DomComponentRenderer.md +1 -1
  17. package/api/@xmachines/play-dom/type-aliases/DomRegistry.md +1 -1
  18. package/api/@xmachines/play-react/README.md +8 -2
  19. package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +9 -5
  20. package/api/@xmachines/play-react/functions/useActor.md +1 -1
  21. package/api/@xmachines/play-react/functions/useBoundProp.md +43 -0
  22. package/api/@xmachines/play-react/functions/useSignalEffect.md +1 -1
  23. package/api/@xmachines/play-react/functions/useStateBinding.md +1 -1
  24. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +4 -4
  25. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +3 -3
  26. package/api/@xmachines/play-react/interfaces/PlayRendererProps.md +6 -6
  27. package/api/@xmachines/play-react/type-aliases/PlayActor.md +1 -1
  28. package/api/@xmachines/play-react/variables/PlayRenderer.md +1 -1
  29. package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +23 -23
  30. package/api/@xmachines/play-react-router/classes/RouteMap.md +4 -4
  31. package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +1 -1
  32. package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +1 -1
  33. package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +9 -9
  34. package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +5 -5
  35. package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +3 -3
  36. package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +4 -4
  37. package/api/@xmachines/play-router/README.md +103 -47
  38. package/api/@xmachines/play-router/classes/BaseRouteMap.md +4 -4
  39. package/api/@xmachines/play-router/classes/RouterBridgeBase.md +21 -21
  40. package/api/@xmachines/play-router/functions/buildRouteTree.md +1 -1
  41. package/api/@xmachines/play-router/functions/connectRouter.md +1 -1
  42. package/api/@xmachines/play-router/functions/createBrowserHistory.md +1 -1
  43. package/api/@xmachines/play-router/functions/createRouteMap.md +1 -1
  44. package/api/@xmachines/play-router/functions/createRouter.md +1 -1
  45. package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +1 -1
  46. package/api/@xmachines/play-router/functions/extractMachineRoutes.md +6 -42
  47. package/api/@xmachines/play-router/functions/findRouteById.md +1 -1
  48. package/api/@xmachines/play-router/functions/findRouteByPath.md +1 -1
  49. package/api/@xmachines/play-router/functions/getNavigableRoutes.md +1 -1
  50. package/api/@xmachines/play-router/functions/getRoutableRoutes.md +1 -1
  51. package/api/@xmachines/play-router/functions/getTransitionReachableRoutes.md +38 -0
  52. package/api/@xmachines/play-router/functions/isRouteReachable.md +38 -0
  53. package/api/@xmachines/play-router/functions/machineToGraph.md +19 -0
  54. package/api/@xmachines/play-router/functions/routeExists.md +1 -1
  55. package/api/@xmachines/play-router/functions/sanitizePathname.md +40 -0
  56. package/api/@xmachines/play-router/functions/validateRouteFormat.md +9 -8
  57. package/api/@xmachines/play-router/functions/validateStateExists.md +8 -8
  58. package/api/@xmachines/play-router/interfaces/BaseRouteMapping.md +3 -3
  59. package/api/@xmachines/play-router/interfaces/BrowserHistory.md +14 -14
  60. package/api/@xmachines/play-router/interfaces/BrowserWindow.md +14 -14
  61. package/api/@xmachines/play-router/interfaces/ConnectRouterOptions.md +4 -4
  62. package/api/@xmachines/play-router/interfaces/MachineEdgeData.md +15 -0
  63. package/api/@xmachines/play-router/interfaces/MachineNodeData.md +17 -0
  64. package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +7 -7
  65. package/api/@xmachines/play-router/interfaces/RouteInfo.md +8 -8
  66. package/api/@xmachines/play-router/interfaces/RouteMap.md +4 -4
  67. package/api/@xmachines/play-router/interfaces/RouteNode.md +12 -12
  68. package/api/@xmachines/play-router/interfaces/RouteObject.md +2 -2
  69. package/api/@xmachines/play-router/interfaces/RouteTree.md +7 -6
  70. package/api/@xmachines/play-router/interfaces/RouteWatcherHandle.md +3 -3
  71. package/api/@xmachines/play-router/interfaces/RouterBridge.md +4 -4
  72. package/api/@xmachines/play-router/interfaces/VanillaRouter.md +4 -4
  73. package/api/@xmachines/play-router/type-aliases/MachineGraph.md +20 -0
  74. package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +1 -1
  75. package/api/@xmachines/play-signals/README.md +8 -2
  76. package/api/@xmachines/play-signals/functions/watchSignal.md +8 -1
  77. package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +2 -2
  78. package/api/@xmachines/play-signals/interfaces/SignalComputed.md +2 -2
  79. package/api/@xmachines/play-signals/interfaces/SignalOptions.md +2 -2
  80. package/api/@xmachines/play-signals/interfaces/SignalState.md +3 -3
  81. package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +4 -4
  82. package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +1 -1
  83. package/api/@xmachines/play-solid/README.md +1 -1
  84. package/api/@xmachines/play-solid/functions/useActor.md +1 -1
  85. package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +6 -6
  86. package/api/@xmachines/play-solid/type-aliases/PlayActor.md +1 -1
  87. package/api/@xmachines/play-solid/variables/PlayRenderer.md +1 -1
  88. package/api/@xmachines/play-solid-router/README.md +55 -31
  89. package/api/@xmachines/play-solid-router/classes/RouteMap.md +4 -4
  90. package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +24 -24
  91. package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +1 -1
  92. package/api/@xmachines/play-solid-router/functions/createRouteMap.md +1 -1
  93. package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +16 -16
  94. package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +9 -9
  95. package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
  96. package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +3 -3
  97. package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +4 -4
  98. package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +1 -1
  99. package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +4 -4
  100. package/api/@xmachines/play-tanstack-react-router/README.md +1 -4
  101. package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +4 -4
  102. package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +23 -23
  103. package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +1 -1
  104. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +1 -1
  105. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +1 -1
  106. package/api/@xmachines/play-tanstack-react-router/functions/extractMachineRoutes.md +28 -0
  107. package/api/@xmachines/play-tanstack-react-router/functions/extractParams.md +1 -1
  108. package/api/@xmachines/play-tanstack-react-router/functions/extractQueryParams.md +1 -1
  109. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +9 -9
  110. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +5 -5
  111. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +3 -3
  112. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +3 -3
  113. package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +4 -4
  114. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +1 -1
  115. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +4 -4
  116. package/api/@xmachines/play-tanstack-solid-router/README.md +1 -1
  117. package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +4 -4
  118. package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +26 -25
  119. package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +1 -1
  120. package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +1 -1
  121. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +9 -9
  122. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +5 -5
  123. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +3 -3
  124. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +4 -4
  125. package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +1 -1
  126. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +1 -1
  127. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +4 -4
  128. package/api/@xmachines/play-vue/README.md +4 -1
  129. package/api/@xmachines/play-vue/functions/defineRegistry.md +5 -5
  130. package/api/@xmachines/play-vue/functions/useActor.md +1 -1
  131. package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +5 -5
  132. package/api/@xmachines/play-vue/type-aliases/ComponentEntry.md +16 -0
  133. package/api/@xmachines/play-vue/type-aliases/ComponentsMap.md +15 -0
  134. package/api/@xmachines/play-vue/type-aliases/DefineRegistryOptions.md +21 -0
  135. package/api/@xmachines/play-vue/type-aliases/PlayActor.md +1 -1
  136. package/api/@xmachines/play-vue/variables/PlayRenderer.md +1 -1
  137. package/api/@xmachines/play-vue-router/README.md +55 -30
  138. package/api/@xmachines/play-vue-router/classes/RouteMap.md +7 -7
  139. package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +7 -7
  140. package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +27 -32
  141. package/api/@xmachines/play-vue-router/functions/createRouteMap.md +1 -1
  142. package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +9 -9
  143. package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +4 -4
  144. package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +4 -4
  145. package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +1 -1
  146. package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +1 -1
  147. package/api/@xmachines/play-xstate/README.md +6 -6
  148. package/api/@xmachines/play-xstate/classes/PlayerActor.md +12 -12
  149. package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +1 -1
  150. package/api/@xmachines/play-xstate/functions/composeGuards.md +1 -1
  151. package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +1 -1
  152. package/api/@xmachines/play-xstate/functions/contextFieldMatches.md +36 -0
  153. package/api/@xmachines/play-xstate/functions/definePlayer.md +2 -2
  154. package/api/@xmachines/play-xstate/functions/deriveRoute.md +2 -2
  155. package/api/@xmachines/play-xstate/functions/eventMatches.md +1 -1
  156. package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +1 -1
  157. package/api/@xmachines/play-xstate/functions/hasContext.md +1 -1
  158. package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +1 -1
  159. package/api/@xmachines/play-xstate/functions/negateGuard.md +1 -1
  160. package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +3 -3
  161. package/api/@xmachines/play-xstate/interfaces/PlayerFactoryResumeOptions.md +2 -2
  162. package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +6 -6
  163. package/api/@xmachines/play-xstate/interfaces/RouteContext.md +5 -5
  164. package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +1 -1
  165. package/api/@xmachines/play-xstate/type-aliases/Guard.md +1 -1
  166. package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +1 -1
  167. package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +1 -1
  168. package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +4 -4
  169. package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +4 -4
  170. package/api/@xmachines/shared/functions/defineXmVitestConfig.md +2 -2
  171. package/api/@xmachines/shared/functions/xmAliases.md +1 -1
  172. package/api/README.md +1 -1
  173. package/api/_media/play.md +447 -0
  174. package/api/llms.txt +1 -1
  175. package/examples/multi-router-integration.md +1 -1
  176. package/examples/routing-patterns.md +1 -1
  177. package/guides/README.md +2 -1
  178. package/guides/installation.md +30 -35
  179. package/package.json +2 -2
  180. package/api/@xmachines/play-router/functions/crawlMachine.md +0 -92
  181. package/api/@xmachines/play-router/functions/extractRoute.md +0 -45
  182. package/api/@xmachines/play-router/interfaces/StateVisit.md +0 -15
  183. package/api/@xmachines/play-tanstack-react-router/variables/extractMachineRoutes.md +0 -64
  184. package/api/@xmachines/play-xstate/functions/stateMatches.md +0 -25
@@ -4,11 +4,11 @@
4
4
 
5
5
  **Route tree extraction from XState v5 state machines with routing patterns**
6
6
 
7
- BFS graph crawling and bidirectional route lookup enabling Actor Authority over navigation.
7
+ Graph-based route extraction and bidirectional lookup enabling Actor Authority over navigation.
8
8
 
9
9
  ## Overview
10
10
 
11
- `@xmachines/play-router` extracts route trees from XState state machines by crawling the state graph using breadth-first traversal. It extracts `meta.route` paths from state machines and builds hierarchical route trees with bidirectional state ID ↔ path mapping.
11
+ `@xmachines/play-router` extracts route trees from XState state machines using `@statelyai/graph` a typed, JSON-serializable graph library. It converts machines to a directed `Graph` with hierarchy, transition edges, and route metadata, then builds hierarchical `RouteTree` structures with bidirectional state ID ↔ path mapping.
12
12
 
13
13
  It also exports `RouterBridgeBase`, the shared base class used by framework adapters to implement `RouterBridge` with consistent actor↔router synchronization behavior.
14
14
 
@@ -16,7 +16,7 @@ It also exports `RouterBridgeBase`, the shared base class used by framework adap
16
16
 
17
17
  The low-level `connectRouter()` path now uses the same router-to-actor event builder and route-map match helper as `RouterBridgeBase`, so pathname sanitization, state-id normalization, param extraction, and query extraction stay aligned across vanilla and framework adapters.
18
18
 
19
- Per [RFC Play v1](https://gitlab.com/xmachin-es/rfc/-/blob/main/src/play-v1.md), this package implements:
19
+ Per [Play RFC](../../_media/play.md), this package implements:
20
20
 
21
21
  - **Actor Authority (INV-01):** Routes derive from machine definitions, not external configuration
22
22
 
@@ -50,13 +50,13 @@ Install the polyfill:
50
50
  npm install urlpattern-polyfill
51
51
  ```
52
52
 
53
- `urlpattern-polyfill` is declared as an optional peer dependency. Package managers will not install it automatically — it is the consumer's responsibility to load it when needed.
53
+ `urlpattern-polyfill` is declared as an optional peer dependency. Package managers will not install it automatically — consumers must install and load it when their runtime lacks native URLPattern support (Node.js < 24, older browsers).
54
54
 
55
55
  ## Quick Start
56
56
 
57
57
  ```typescript
58
58
  import { createMachine } from "xstate";
59
- import { extractMachineRoutes } from "@xmachines/play-router";
59
+ import { extractMachineRoutes, findRouteByPath } from "@xmachines/play-router";
60
60
 
61
61
  // Route pattern (recommended)
62
62
  const machine = createMachine({
@@ -88,11 +88,11 @@ const machine = createMachine({
88
88
  const tree = extractMachineRoutes(machine);
89
89
 
90
90
  // Bidirectional lookup
91
- console.log(tree.byPath.get("/dashboard/overview")); // RouteNode
92
- console.log(tree.byId.get("overview")); // RouteNode
91
+ console.log(findRouteByPath(tree, "/overview")); // RouteNode
92
+ console.log(tree.byStateId.get("overview")); // RouteNode
93
93
 
94
94
  // Pattern matching for dynamic routes
95
- const settingsRoute = tree.byPath.get("/settings/profile");
95
+ const settingsRoute = findRouteByPath(tree, "/settings/profile");
96
96
  console.log(settingsRoute?.id); // "settings"
97
97
  ```
98
98
 
@@ -210,9 +210,10 @@ const tree = extractMachineRoutes(machine: AnyStateMachine): RouteTree;
210
210
 
211
211
  **Returns:** `RouteTree` with:
212
212
 
213
- - `routes: RouteNode[]` - Array of route nodes
214
- - `byPath: Map<string, RouteNode>` - URL path → route node
215
- - `byId: Map<string, RouteNode>` - State ID → route node
213
+ - `byPath: Map<string, RouteNode>` URL path route node
214
+ - `byStateId: Map<string, RouteNode>` State ID → route node
215
+ - `root: RouteNode` synthetic root node
216
+ - `graph: MachineGraph` — `@statelyai/graph` Graph for hierarchy queries, reachability checks, and transition-aware navigation
216
217
 
217
218
  **Throws:** Error if routes are invalid (malformed paths, missing state IDs, duplicates)
218
219
 
@@ -224,47 +225,77 @@ import { extractMachineRoutes } from "@xmachines/play-router";
224
225
  const tree = extractMachineRoutes(authMachine);
225
226
 
226
227
  // Query routes
227
- const loginRoute = tree.byId.get("login");
228
+ const loginRoute = tree.byStateId.get("login");
228
229
  console.log(loginRoute?.path); // "/login"
229
230
 
230
231
  const dashboardRoute = tree.byPath.get("/dashboard");
231
232
  console.log(dashboardRoute?.id); // "dashboard"
232
233
  ```
233
234
 
234
- ### crawlMachine()
235
+ ### machineToGraph()
235
236
 
236
- Low-level BFS traversal of state machine graph:
237
+ Converts an XState v5 machine to a typed `@statelyai/graph` `Graph`:
237
238
 
238
239
  ```typescript
239
- const visits = crawlMachine(machine: AnyStateMachine): StateVisit[];
240
- ```
240
+ import { machineToGraph } from "@xmachines/play-router";
241
+ import { getChildren, getSuccessors, hasPath } from "@statelyai/graph";
241
242
 
242
- **Returns:** Array of state visits in breadth-first order with:
243
+ const graph = machineToGraph(machine);
243
244
 
244
- - `path: string[]` - State path (e.g., ["dashboard", "settings"])
245
- - `parent: StateNode | null` - Parent state node
246
- - `node: StateNode` - Current state node
245
+ // Hierarchy queries
246
+ const children = getChildren(graph, "myMachine");
247
+ const successors = getSuccessors(graph, "myMachine.home"); // transition-reachable states
247
248
 
248
- **Example:**
249
+ // Reachability
250
+ const reachable = hasPath(graph, "myMachine.home", "myMachine.dashboard");
251
+ ```
252
+
253
+ The graph is also available on any `RouteTree` returned by `extractMachineRoutes()`:
249
254
 
250
255
  ```typescript
251
- import { crawlMachine } from "@xmachines/play-router";
256
+ const tree = extractMachineRoutes(machine);
252
257
 
253
- const visits = crawlMachine(machine);
254
- visits.forEach((visit) => {
255
- console.log("State:", visit.path.join("."));
256
- console.log("Parent:", visit.parent?.id ?? "root");
257
- });
258
+ // Use @statelyai/graph algorithms directly on the graph
259
+ const successors = getSuccessors(tree.graph!, "myMachine.home");
258
260
  ```
259
261
 
262
+ **Node data** (`MachineNodeData`):
263
+
264
+ - `stateId: string` — XState state ID (e.g., `"myMachine.dashboard.overview"`)
265
+ - `type` — `"atomic" | "compound" | "parallel" | "final" | "history"`
266
+ - `meta?: Record<string, unknown>` — original state meta object
267
+ - `route?: string` — extracted route path from `meta.route`
268
+
269
+ **Edge data** (`MachineEdgeData`):
270
+
271
+ - `eventType: string` — event type triggering this transition
272
+ - `guardType?: string` — guard name/description (if transition is guarded)
273
+
260
274
  ### Query Utilities
261
275
 
262
276
  ```typescript
263
- // Get child routes from state
264
- const children = getNavigableRoutes(tree, "dashboard");
277
+ import {
278
+ getNavigableRoutes,
279
+ getRoutableRoutes,
280
+ routeExists,
281
+ getTransitionReachableRoutes,
282
+ isRouteReachable,
283
+ } from "@xmachines/play-router";
284
+
285
+ // Child routes (hierarchical + transition-reachable)
286
+ const navigable = getNavigableRoutes(tree, "dashboard");
287
+
288
+ // All routable routes as flat array
289
+ const allRoutes = getRoutableRoutes(tree);
265
290
 
266
- // Check if route exists
291
+ // Check path exists
267
292
  const exists = routeExists(tree, "/profile/:userId");
293
+
294
+ // Transition-aware: which state IDs are reachable via transitions?
295
+ const reachableIds = getTransitionReachableRoutes(tree.graph!, "myMachine.home");
296
+
297
+ // Is there any path from state A to state B via transitions?
298
+ const canReach = isRouteReachable(tree.graph!, "myMachine.home", "myMachine.dashboard");
268
299
  ```
269
300
 
270
301
  ## Examples
@@ -272,7 +303,7 @@ const exists = routeExists(tree, "/profile/:userId");
272
303
  ### Route Detection
273
304
 
274
305
  ```typescript
275
- import { extractMachineRoutes } from "@xmachines/play-router";
306
+ import { extractMachineRoutes, findRouteByPath } from "@xmachines/play-router";
276
307
  import { createMachine } from "xstate";
277
308
 
278
309
  const machine = createMachine({
@@ -296,10 +327,10 @@ const machine = createMachine({
296
327
  const tree = extractMachineRoutes(machine);
297
328
 
298
329
  // Bidirectional mapping
299
- const profileById = tree.byId.get("profile");
330
+ const profileById = tree.byStateId.get("profile");
300
331
  console.log(profileById?.path); // "/profile/:userId"
301
332
 
302
- const profileByPath = tree.byPath.get("/profile/user123");
333
+ const profileByPath = findRouteByPath(tree, "/profile/user123");
303
334
  console.log(profileByPath?.id); // "profile"
304
335
  ```
305
336
 
@@ -343,14 +374,14 @@ const dashboardChildren = getNavigableRoutes(tree, "dashboard");
343
374
  console.log(dashboardChildren.map((r) => r.id)); // ["overview", "analytics"]
344
375
 
345
376
  // Route inheritance
346
- const analyticsRoute = tree.byId.get("analytics");
347
- console.log(analyticsRoute?.path); // "/dashboard/analytics" (inherited parent path)
377
+ const analyticsRoute = tree.byStateId.get("analytics");
378
+ console.log(analyticsRoute?.fullPath); // "/analytics" (absolute route)
348
379
  ```
349
380
 
350
381
  ### Pattern Matching
351
382
 
352
383
  ```typescript
353
- import { extractMachineRoutes } from "@xmachines/play-router";
384
+ import { extractMachineRoutes, findRouteByPath } from "@xmachines/play-router";
354
385
 
355
386
  const machine = createMachine({
356
387
  states: {
@@ -368,13 +399,13 @@ const machine = createMachine({
368
399
  const tree = extractMachineRoutes(machine);
369
400
 
370
401
  // Pattern matching for actual URLs
371
- const userRoute = tree.byPath.get("/user/user123");
402
+ const userRoute = findRouteByPath(tree, "/user/user123");
372
403
  console.log(userRoute?.id); // "user"
373
404
 
374
- const settingsDefault = tree.byPath.get("/settings");
405
+ const settingsDefault = findRouteByPath(tree, "/settings");
375
406
  console.log(settingsDefault?.id); // "settings" (optional param)
376
407
 
377
- const settingsProfile = tree.byPath.get("/settings/profile");
408
+ const settingsProfile = findRouteByPath(tree, "/settings/profile");
378
409
  console.log(settingsProfile?.id); // "settings" (with param)
379
410
  ```
380
411
 
@@ -420,7 +451,7 @@ states: {
420
451
  },
421
452
  relative: {
422
453
  id: "relative",
423
- meta: { route: "relative", view: { component: "Relative" } }, // No leading / → inherits parent
454
+ meta: { route: "relative", view: { component: "Relative" } }, // No leading / → inherits parent path prefix
424
455
  // Final path: "/parent/relative"
425
456
  },
426
457
  },
@@ -441,6 +472,25 @@ meta: {
441
472
 
442
473
  **Parameter substitution:** Values extracted from context or event params (handled by play-xstate adapter).
443
474
 
475
+ ## Security Utilities
476
+
477
+ ### `sanitizePathname()`
478
+
479
+ Normalize a raw pathname before route-map lookup. Used internally by `RouterBridgeBase.syncActorFromRouter()` and available to adapters that bypass the base class:
480
+
481
+ ```typescript
482
+ import { sanitizePathname } from "@xmachines/play-router";
483
+
484
+ // In a custom adapter's route-watch callback:
485
+ const clean = sanitizePathname(rawPath);
486
+ if (clean === null) return; // Reject malformed/oversized paths (> 2048 chars)
487
+ // Proceed with clean normalized path
488
+ ```
489
+
490
+ Returns `null` for paths exceeding 2048 characters. Strips query fragments, hash fragments, and collapses duplicate slashes.
491
+
492
+ ---
493
+
444
494
  ## Error Handling
445
495
 
446
496
  All runtime errors thrown by this package extend `PlayError` from `@xmachines/play` and
@@ -483,15 +533,17 @@ try {
483
533
  This package enables **Actor Authority (INV-01)**:
484
534
 
485
535
  1. **Routes derive from machine:** Business logic defines routes in state machine, not external config
486
- 2. **BFS traversal:** Systematic state discovery ensures all nested states visited
487
- 3. **Bidirectional mapping:** Fast lookup by path (browser URL) or by ID (state machine)
488
- 4. **Build-time validation:** Invalid routes throw errors during extraction, not runtime
536
+ 2. **Graph-based extraction:** `machineToGraph()` converts machines to typed `@statelyai/graph` `Graph` objects with hierarchy, transition edges, and route metadata
537
+ 3. **Bidirectional mapping:** Fast lookup by path (browser URL) or by state ID (state machine)
538
+ 4. **Transition-aware queries:** `getTransitionReachableRoutes()` and `isRouteReachable()` use graph algorithms for navigation reachability
539
+ 5. **Build-time validation:** Invalid routes throw errors during extraction, not runtime
489
540
 
490
541
  **Enhancements:**
491
542
 
492
- - `meta.route` detection via state metadata
543
+ - `meta.route` detection via state metadata — extracted into typed graph node data
493
544
  - Pattern matching for dynamic routes (`:param` and `:param?`)
494
545
  - State ID ↔ path bidirectional maps for `play.route` events
546
+ - `@statelyai/graph` integration — hierarchy queries, reachability checks, transition traversal
495
547
 
496
548
  ## Related Packages
497
549
 
@@ -518,6 +570,8 @@ For a copy, see <https://opensource.org/licenses/MIT>.
518
570
  - [BrowserHistory](interfaces/BrowserHistory.md)
519
571
  - [BrowserWindow](interfaces/BrowserWindow.md)
520
572
  - [ConnectRouterOptions](interfaces/ConnectRouterOptions.md)
573
+ - [MachineEdgeData](interfaces/MachineEdgeData.md)
574
+ - [MachineNodeData](interfaces/MachineNodeData.md)
521
575
  - [PlayRouteEvent](interfaces/PlayRouteEvent.md)
522
576
  - [RouteInfo](interfaces/RouteInfo.md)
523
577
  - [RouteMap](interfaces/RouteMap.md)
@@ -526,28 +580,30 @@ For a copy, see <https://opensource.org/licenses/MIT>.
526
580
  - [RouterBridge](interfaces/RouterBridge.md)
527
581
  - [RouteTree](interfaces/RouteTree.md)
528
582
  - [RouteWatcherHandle](interfaces/RouteWatcherHandle.md)
529
- - [StateVisit](interfaces/StateVisit.md)
530
583
  - [VanillaRouter](interfaces/VanillaRouter.md)
531
584
 
532
585
  ## Type Aliases
533
586
 
587
+ - [MachineGraph](type-aliases/MachineGraph.md)
534
588
  - [RouteMetadata](type-aliases/RouteMetadata.md)
535
589
 
536
590
  ## Functions
537
591
 
538
592
  - [buildRouteTree](functions/buildRouteTree.md)
539
593
  - [connectRouter](functions/connectRouter.md)
540
- - [crawlMachine](functions/crawlMachine.md)
541
594
  - [createBrowserHistory](functions/createBrowserHistory.md)
542
595
  - [createRouteMap](functions/createRouteMap.md)
543
596
  - [createRouter](functions/createRouter.md)
544
597
  - [detectDuplicateRoutes](functions/detectDuplicateRoutes.md)
545
598
  - [extractMachineRoutes](functions/extractMachineRoutes.md)
546
- - [extractRoute](functions/extractRoute.md)
547
599
  - [findRouteById](functions/findRouteById.md)
548
600
  - [findRouteByPath](functions/findRouteByPath.md)
549
601
  - [getNavigableRoutes](functions/getNavigableRoutes.md)
550
602
  - [getRoutableRoutes](functions/getRoutableRoutes.md)
603
+ - [getTransitionReachableRoutes](functions/getTransitionReachableRoutes.md)
604
+ - [isRouteReachable](functions/isRouteReachable.md)
605
+ - [machineToGraph](functions/machineToGraph.md)
551
606
  - [routeExists](functions/routeExists.md)
607
+ - [sanitizePathname](functions/sanitizePathname.md)
552
608
  - [validateRouteFormat](functions/validateRouteFormat.md)
553
609
  - [validateStateExists](functions/validateStateExists.md)
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Class: BaseRouteMap
4
4
 
5
- Defined in: [base-route-map.ts:106](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/base-route-map.ts#L106)
5
+ Defined in: [base-route-map.ts:106](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/base-route-map.ts#L106)
6
6
 
7
7
  Shared bidirectional route map base class.
8
8
 
@@ -57,7 +57,7 @@ map.getPathByStateId("missing"); // null
57
57
  new BaseRouteMap(mappings): BaseRouteMap;
58
58
  ```
59
59
 
60
- Defined in: [base-route-map.ts:125](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/base-route-map.ts#L125)
60
+ Defined in: [base-route-map.ts:125](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/base-route-map.ts#L125)
61
61
 
62
62
  Build a route map from an array of state ID ↔ path mappings.
63
63
 
@@ -83,7 +83,7 @@ buckets for efficient candidate selection.
83
83
  getPathByStateId(stateId): string | null;
84
84
  ```
85
85
 
86
- Defined in: [base-route-map.ts:210](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/base-route-map.ts#L210)
86
+ Defined in: [base-route-map.ts:210](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/base-route-map.ts#L210)
87
87
 
88
88
  Look up the path pattern registered for a state ID.
89
89
 
@@ -114,7 +114,7 @@ map.getPathByStateId("missing"); // null
114
114
  getStateIdByPath(path): string | null;
115
115
  ```
116
116
 
117
- Defined in: [base-route-map.ts:175](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/base-route-map.ts#L175)
117
+ Defined in: [base-route-map.ts:175](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/base-route-map.ts#L175)
118
118
 
119
119
  Resolve a URL path to its mapped state ID.
120
120
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Abstract Class: RouterBridgeBase
4
4
 
5
- Defined in: [router-bridge-base.ts:82](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L82)
5
+ Defined in: [router-bridge-base.ts:82](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L82)
6
6
 
7
7
  Abstract base class for all `@xmachines` router adapter bridges.
8
8
 
@@ -30,7 +30,7 @@ between frameworks.
30
30
  new RouterBridgeBase(actor, routeMap): RouterBridgeBase;
31
31
  ```
32
32
 
33
- Defined in: [router-bridge-base.ts:96](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L96)
33
+ Defined in: [router-bridge-base.ts:96](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L96)
34
34
 
35
35
  #### Parameters
36
36
 
@@ -49,15 +49,15 @@ Defined in: [router-bridge-base.ts:96](https://gitlab.com/xmachin-es/xmachines-j
49
49
 
50
50
  | Property | Modifier | Type | Default value | Description | Defined in |
51
51
  | --------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
52
- | <a id="property-actor"></a> `actor` | `readonly` | [`AbstractActor`](../../play-actor/classes/AbstractActor.md)\<[`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\> & [`Routable`](../../play-actor/interfaces/Routable.md) | `undefined` | A `Routable` actor exposing `currentRoute` and `send`. | [router-bridge-base.ts:97](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L97) |
53
- | <a id="property-hasconnectedonce"></a> `hasConnectedOnce` | `protected` | `boolean` | `false` | - | [router-bridge-base.ts:85](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L85) |
54
- | <a id="property-isconnected"></a> `isConnected` | `protected` | `boolean` | `false` | - | [router-bridge-base.ts:84](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L84) |
55
- | <a id="property-isprocessingnavigation"></a> `isProcessingNavigation` | `protected` | `boolean` | `false` | - | [router-bridge-base.ts:87](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L87) |
56
- | <a id="property-lastsyncedpath"></a> `lastSyncedPath` | `protected` | `string` \| `null` | `null` | - | [router-bridge-base.ts:86](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L86) |
57
- | <a id="property-routemap"></a> `routeMap` | `readonly` | `object` | `undefined` | Bidirectional route map for `stateId ↔ path` resolution. Provide `getStateIdByPath` and `getPathByStateId`. Framework adapters typically wrap the result of `createRouteMap()` or an equivalent. | [router-bridge-base.ts:98](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L98) |
58
- | `routeMap.getPathByStateId` | `public` | `string` \| `null` \| `undefined` | `undefined` | - | [router-bridge-base.ts:100](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L100) |
59
- | `routeMap.getStateIdByPath` | `public` | `string` \| `null` \| `undefined` | `undefined` | - | [router-bridge-base.ts:99](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L99) |
60
- | <a id="property-routewatcher"></a> `routeWatcher` | `protected` | [`RouteWatcherHandle`](../interfaces/RouteWatcherHandle.md) \| `null` | `null` | - | [router-bridge-base.ts:88](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L88) |
52
+ | <a id="property-actor"></a> `actor` | `readonly` | [`AbstractActor`](../../play-actor/classes/AbstractActor.md)\<[`AnyActorLogic`](https://www.jsdocs.io/package/xstate#AnyActorLogic), [`EventObject`](https://www.jsdocs.io/package/xstate#EventObject)\> & [`Routable`](../../play-actor/interfaces/Routable.md) | `undefined` | A `Routable` actor exposing `currentRoute` and `send`. | [router-bridge-base.ts:97](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L97) |
53
+ | <a id="property-hasconnectedonce"></a> `hasConnectedOnce` | `protected` | `boolean` | `false` | - | [router-bridge-base.ts:85](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L85) |
54
+ | <a id="property-isconnected"></a> `isConnected` | `protected` | `boolean` | `false` | - | [router-bridge-base.ts:84](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L84) |
55
+ | <a id="property-isprocessingnavigation"></a> `isProcessingNavigation` | `protected` | `boolean` | `false` | - | [router-bridge-base.ts:87](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L87) |
56
+ | <a id="property-lastsyncedpath"></a> `lastSyncedPath` | `protected` | `string` \| `null` | `null` | - | [router-bridge-base.ts:86](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L86) |
57
+ | <a id="property-routemap"></a> `routeMap` | `readonly` | `object` | `undefined` | Bidirectional route map for `stateId ↔ path` resolution. Provide `getStateIdByPath` and `getPathByStateId`. Framework adapters typically wrap the result of `createRouteMap()` or an equivalent. | [router-bridge-base.ts:98](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L98) |
58
+ | `routeMap.getPathByStateId` | `public` | `string` \| `null` \| `undefined` | `undefined` | - | [router-bridge-base.ts:100](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L100) |
59
+ | `routeMap.getStateIdByPath` | `public` | `string` \| `null` \| `undefined` | `undefined` | - | [router-bridge-base.ts:99](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L99) |
60
+ | <a id="property-routewatcher"></a> `routeWatcher` | `protected` | [`RouteWatcherHandle`](../interfaces/RouteWatcherHandle.md) \| `null` | `null` | - | [router-bridge-base.ts:88](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L88) |
61
61
 
62
62
  ## Methods
63
63
 
@@ -67,7 +67,7 @@ Defined in: [router-bridge-base.ts:96](https://gitlab.com/xmachin-es/xmachines-j
67
67
  connect(): void;
68
68
  ```
69
69
 
70
- Defined in: [router-bridge-base.ts:116](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L116)
70
+ Defined in: [router-bridge-base.ts:116](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L116)
71
71
 
72
72
  Connect the router bridge to the Actor.
73
73
 
@@ -90,7 +90,7 @@ starts watching router changes (framework-specific).
90
90
  disconnect(): void;
91
91
  ```
92
92
 
93
- Defined in: [router-bridge-base.ts:184](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L184)
93
+ Defined in: [router-bridge-base.ts:184](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L184)
94
94
 
95
95
  Disconnect the router bridge from the Actor.
96
96
 
@@ -112,7 +112,7 @@ Stops signal watching and unregisters framework-specific router listener.
112
112
  protected extractParams(pathname, stateId): Record<string, string>;
113
113
  ```
114
114
 
115
- Defined in: [router-bridge-base.ts:283](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L283)
115
+ Defined in: [router-bridge-base.ts:283](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L283)
116
116
 
117
117
  Extract path parameters from URL using the URLPattern API.
118
118
 
@@ -142,7 +142,7 @@ Extracted path parameters, or empty object if URLPattern is unavailable or no ma
142
142
  protected extractQuery(search): Record<string, string>;
143
143
  ```
144
144
 
145
- Defined in: [router-bridge-base.ts:310](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L310)
145
+ Defined in: [router-bridge-base.ts:310](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L310)
146
146
 
147
147
  Extract query parameters from URL search string.
148
148
 
@@ -166,7 +166,7 @@ Extracted query parameters or empty object
166
166
  protected getInitialRouterPath(): string | null | undefined;
167
167
  ```
168
168
 
169
- Defined in: [router-bridge-base.ts:357](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L357)
169
+ Defined in: [router-bridge-base.ts:357](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L357)
170
170
 
171
171
  Return the router's current pathname at connect() time.
172
172
 
@@ -198,7 +198,7 @@ bridges that have not yet implemented this hook.
198
198
  abstract protected navigateRouter(path): void;
199
199
  ```
200
200
 
201
- Defined in: [router-bridge-base.ts:322](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L322)
201
+ Defined in: [router-bridge-base.ts:322](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L322)
202
202
 
203
203
  Navigate the framework router to the given path.
204
204
 
@@ -223,7 +223,7 @@ Must trigger the framework router's navigation (e.g., router.navigate(path)).
223
223
  protected syncActorFromRouter(pathname, search?): void;
224
224
  ```
225
225
 
226
- Defined in: [router-bridge-base.ts:231](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L231)
226
+ Defined in: [router-bridge-base.ts:231](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L231)
227
227
 
228
228
  Sync actor state when router location changes.
229
229
 
@@ -249,7 +249,7 @@ Prevents circular updates via isProcessingNavigation flag.
249
249
  protected syncRouterFromActor(route): void;
250
250
  ```
251
251
 
252
- Defined in: [router-bridge-base.ts:211](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L211)
252
+ Defined in: [router-bridge-base.ts:211](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L211)
253
253
 
254
254
  Sync router location when actor route signal changes.
255
255
 
@@ -274,7 +274,7 @@ Prevents circular updates via isProcessingNavigation flag.
274
274
  abstract protected unwatchRouterChanges(): void;
275
275
  ```
276
276
 
277
- Defined in: [router-bridge-base.ts:337](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L337)
277
+ Defined in: [router-bridge-base.ts:337](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L337)
278
278
 
279
279
  Stop watching for router location changes.
280
280
 
@@ -292,7 +292,7 @@ Called by disconnect(). Should clean up the framework-specific subscription.
292
292
  abstract protected watchRouterChanges(): void;
293
293
  ```
294
294
 
295
- Defined in: [router-bridge-base.ts:330](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/router-bridge-base.ts#L330)
295
+ Defined in: [router-bridge-base.ts:330](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/router-bridge-base.ts#L330)
296
296
 
297
297
  Start watching for router location changes.
298
298
 
@@ -6,7 +6,7 @@
6
6
  function buildRouteTree(routes): RouteTree;
7
7
  ```
8
8
 
9
- Defined in: [build-tree.ts:13](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/build-tree.ts#L13)
9
+ Defined in: [build-tree.ts:13](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/build-tree.ts#L13)
10
10
 
11
11
  Build hierarchical route tree from flat route list
12
12
 
@@ -6,7 +6,7 @@
6
6
  function connectRouter(options): () => void;
7
7
  ```
8
8
 
9
- Defined in: [connect-router.ts:59](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/connect-router.ts#L59)
9
+ Defined in: [connect-router.ts:59](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/connect-router.ts#L59)
10
10
 
11
11
  Connect vanilla router to actor (pure browser integration).
12
12
 
@@ -6,7 +6,7 @@
6
6
  function createBrowserHistory(options): BrowserHistory;
7
7
  ```
8
8
 
9
- Defined in: [create-browser-history.ts:115](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/create-browser-history.ts#L115)
9
+ Defined in: [create-browser-history.ts:115](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/create-browser-history.ts#L115)
10
10
 
11
11
  Create browser history that wraps window.history
12
12
 
@@ -6,7 +6,7 @@
6
6
  function createRouteMap(routeTree): RouteMap;
7
7
  ```
8
8
 
9
- Defined in: [create-route-map.ts:121](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/create-route-map.ts#L121)
9
+ Defined in: [create-route-map.ts:121](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/create-route-map.ts#L121)
10
10
 
11
11
  Create a RouteMap from a RouteTree for efficient path lookups.
12
12
 
@@ -6,7 +6,7 @@
6
6
  function createRouter(options): VanillaRouter;
7
7
  ```
8
8
 
9
- Defined in: [create-router.ts:73](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/create-router.ts#L73)
9
+ Defined in: [create-router.ts:73](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/create-router.ts#L73)
10
10
 
11
11
  Create vanilla router for framework-agnostic routing.
12
12
 
@@ -6,7 +6,7 @@
6
6
  function detectDuplicateRoutes(routes): void;
7
7
  ```
8
8
 
9
- Defined in: [validate-routes.ts:51](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/validate-routes.ts#L51)
9
+ Defined in: [validate-routes.ts:51](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/validate-routes.ts#L51)
10
10
 
11
11
  Detect duplicate route paths
12
12
 
@@ -6,13 +6,14 @@
6
6
  function extractMachineRoutes(machine): RouteTree;
7
7
  ```
8
8
 
9
- Defined in: [extract-routes.ts:45](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.17/packages/play-router/src/extract-routes.ts#L45)
9
+ Defined in: [extract-routes.ts:93](https://gitlab.com/xmachin-es/xmachines-js/-/blob/v1.0.0-beta.19/packages/play-router/src/extract-routes.ts#L93)
10
10
 
11
11
  Extract complete route tree from state machine graph
12
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.
13
+ Converts the XState machine to a @statelyai/graph Graph via machineToGraph(),
14
+ then walks graph nodes to extract route metadata, validate route references,
15
+ and build a hierarchical RouteTree. The graph is attached to the returned
16
+ RouteTree for downstream transition-aware queries.
16
17
 
17
18
  ## Parameters
18
19
 
@@ -24,41 +25,4 @@ and builds hierarchical tree.
24
25
 
25
26
  [`RouteTree`](../interfaces/RouteTree.md)
26
27
 
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
- ```
28
+ Route tree with root, byStateId map, byPath map, and graph