@xmachines/play-router 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +93 -76
  2. package/dist/base-route-map.d.ts +63 -57
  3. package/dist/base-route-map.d.ts.map +1 -1
  4. package/dist/base-route-map.js +65 -59
  5. package/dist/base-route-map.js.map +1 -1
  6. package/dist/build-tree.d.ts +13 -12
  7. package/dist/build-tree.d.ts.map +1 -1
  8. package/dist/build-tree.js +30 -28
  9. package/dist/build-tree.js.map +1 -1
  10. package/dist/create-route-map-from-tree.d.ts +15 -15
  11. package/dist/create-route-map-from-tree.js +15 -15
  12. package/dist/create-route-map.d.ts +18 -16
  13. package/dist/create-route-map.d.ts.map +1 -1
  14. package/dist/create-route-map.js +10 -9
  15. package/dist/create-route-map.js.map +1 -1
  16. package/dist/errors.d.ts +40 -38
  17. package/dist/errors.d.ts.map +1 -1
  18. package/dist/errors.js +40 -38
  19. package/dist/errors.js.map +1 -1
  20. package/dist/extract-routes.d.ts +8 -7
  21. package/dist/extract-routes.d.ts.map +1 -1
  22. package/dist/extract-routes.js +31 -27
  23. package/dist/extract-routes.js.map +1 -1
  24. package/dist/find-route.d.ts +18 -15
  25. package/dist/find-route.d.ts.map +1 -1
  26. package/dist/find-route.js +42 -38
  27. package/dist/find-route.js.map +1 -1
  28. package/dist/index.d.ts +6 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +11 -10
  31. package/dist/index.js.map +1 -1
  32. package/dist/machine-to-graph.d.ts +3 -2
  33. package/dist/machine-to-graph.d.ts.map +1 -1
  34. package/dist/machine-to-graph.js +20 -19
  35. package/dist/machine-to-graph.js.map +1 -1
  36. package/dist/query.d.ts +39 -37
  37. package/dist/query.d.ts.map +1 -1
  38. package/dist/query.js +62 -57
  39. package/dist/query.js.map +1 -1
  40. package/dist/router-bridge-base.d.ts +208 -190
  41. package/dist/router-bridge-base.d.ts.map +1 -1
  42. package/dist/router-bridge-base.js +235 -211
  43. package/dist/router-bridge-base.js.map +1 -1
  44. package/dist/router-sync.d.ts +41 -35
  45. package/dist/router-sync.d.ts.map +1 -1
  46. package/dist/router-sync.js +53 -45
  47. package/dist/router-sync.js.map +1 -1
  48. package/dist/types.d.ts +165 -147
  49. package/dist/types.d.ts.map +1 -1
  50. package/dist/url-pattern-utils.d.ts +53 -47
  51. package/dist/url-pattern-utils.d.ts.map +1 -1
  52. package/dist/url-pattern-utils.js +61 -55
  53. package/dist/url-pattern-utils.js.map +1 -1
  54. package/dist/validate-routes.d.ts +32 -31
  55. package/dist/validate-routes.d.ts.map +1 -1
  56. package/dist/validate-routes.js +30 -29
  57. package/dist/validate-routes.js.map +1 -1
  58. package/package.json +6 -5
package/dist/errors.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { PlayError } from "@xmachines/play";
2
2
  /**
3
- * Thrown when `RouterBridgeBase.syncActorFromRouter()` fails to process a router
4
- * location change and send the corresponding `play.route` event to the actor.
3
+ * The bridge throws this error when `RouterBridgeBase.syncActorFromRouter()`
4
+ * cannot process a location change of the router and send the `play.route` event to
5
+ * the actor.
5
6
  *
6
- * The `cause` property wraps the original error.
7
+ * The `cause` property holds the original error.
7
8
  *
8
9
  * **Error code:** `PLAY_ROUTER_SYNC_FAILED`
9
10
  *
@@ -24,17 +25,17 @@ export declare class RouterSyncError extends PlayError {
24
25
  constructor(message: string, options?: ErrorOptions);
25
26
  }
26
27
  /**
27
- * Thrown by `RouterBridgeBase.connect()` when a second bridge tries to connect
28
- * to an actor that already has an active bridge connection.
28
+ * `RouterBridgeBase.connect()` throws this error when a second bridge connects to an
29
+ * actor with an active bridge connection.
29
30
  *
30
- * One actor may only be connected to one router bridge at a time. Two bridges
31
- * sharing the same actor would both receive and process every router navigation
32
- * event, sending duplicate `play.route` events to the actor and producing
33
- * conflicting echo-suppression state via `lastSyncedPath`.
31
+ * One actor can hold one router bridge at a time. Two bridges of the same actor both
32
+ * receive and process every navigation event of the router. They therefore send two
33
+ * `play.route` events to the actor, and their `lastSyncedPath` values of the echo
34
+ * suppression contradict each other.
34
35
  *
35
- * **How to fix:** Call `bridge.disconnect()` on the first bridge before
36
- * connecting a second one, or ensure only one `connectRouter()` call is active
37
- * per actor at any given time.
36
+ * **The remedy:** call `bridge.disconnect()` on the first bridge before you connect
37
+ * the second one. You can also permit one active `connectRouter()` call for each
38
+ * actor at a time.
38
39
  *
39
40
  * **Error code:** `PLAY_ROUTER_DUPLICATE_BRIDGE`
40
41
  *
@@ -55,20 +56,20 @@ export declare class DuplicateBridgeError extends PlayError {
55
56
  constructor();
56
57
  }
57
58
  /**
58
- * Thrown by the `RouteMap` constructor when a parameterized route is registered but
59
- * the `URLPattern` API is not available in the current runtime environment and no
60
- * polyfill has been loaded.
59
+ * The `RouteMap` constructor throws this error when the caller registers a
60
+ * parameterized route, the current runtime has no `URLPattern` API, and no polyfill
61
+ * is loaded.
61
62
  *
62
- * **How to fix:** Load `urlpattern-polyfill` at your application entry point, before
63
- * any import of `@xmachines/play-router`:
63
+ * **The remedy:** load `urlpattern-polyfill` at the entry point of your application,
64
+ * before each import of `@xmachines/play-router`:
64
65
  *
65
66
  * ```typescript
66
- * // app entry point — must run first
67
+ * // the entry point of the application it must run first
67
68
  * import "urlpattern-polyfill";
68
69
  * ```
69
70
  *
70
- * URLPattern is natively available on Node.js ≥ 24 and modern browsers
71
- * (Chrome 95+, Firefox 117+, Safari 16.4+). Use the polyfill on older targets.
71
+ * URLPattern is native in Node.js ≥ 24 and in a modern browser (Chrome 95+,
72
+ * Firefox 117+, Safari 16.4+). Use the polyfill for an older target.
72
73
  *
73
74
  * **Error code:** `PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE`
74
75
  */
@@ -76,58 +77,59 @@ export declare class URLPatternUnavailableError extends PlayError {
76
77
  constructor();
77
78
  }
78
79
  /**
79
- * Thrown by `validateRouteFormat()` when a state declares `meta.route` with an
80
- * empty string path.
80
+ * `validateRouteFormat()` throws this error when a state declares a `meta.route`
81
+ * field with an empty string as its path.
81
82
  *
82
83
  * **Error code:** `PLAY_ROUTE_EMPTY_PATH`
83
84
  */
84
85
  export declare class EmptyRoutePathError extends PlayError {
85
- /** The state ID whose route path is empty. */
86
+ /** The state ID with the empty route path. */
86
87
  readonly stateId: string;
87
88
  constructor(stateId: string);
88
89
  }
89
90
  /**
90
- * Thrown by `validateStateExists()` when a route references a state ID that does
91
- * not exist in the machine graph.
91
+ * `validateStateExists()` throws this error when a route names a state ID that the
92
+ * machine graph does not hold.
92
93
  *
93
94
  * **Error code:** `PLAY_ROUTE_INVALID_STATE_ID`
94
95
  */
95
96
  export declare class InvalidStateIdError extends PlayError {
96
- /** The state ID that was referenced but not found. */
97
+ /** The state ID of the reference. The graph does not hold it. */
97
98
  readonly stateId: string;
98
99
  constructor(stateId: string);
99
100
  }
100
101
  /**
101
- * Thrown by `detectDuplicateRoutes()` when two or more states share the same URL path.
102
+ * `detectDuplicateRoutes()` throws this error when two states or more hold the same
103
+ * URL path.
102
104
  *
103
105
  * **Error code:** `PLAY_ROUTE_DUPLICATE_PATH`
104
106
  */
105
107
  export declare class DuplicateRoutePathError extends PlayError {
106
- /** Human-readable list of conflicting path → state-ID mappings. */
108
+ /** The list of the path → state-ID mappings of the conflict, for a person to read. */
107
109
  readonly duplicates: string[];
108
110
  constructor(duplicates: string[]);
109
111
  }
110
112
  /**
111
- * Thrown by `machineToGraph()` when an XState state node has an unrecognised
112
- * `.type` value.
113
+ * `machineToGraph()` throws this error when an XState state node has a `.type` value
114
+ * that the package does not know.
113
115
  *
114
116
  * **Error code:** `PLAY_ROUTE_UNKNOWN_STATE_TYPE`
115
117
  */
116
118
  export declare class UnknownStateTypeError extends PlayError {
117
- /** The unrecognised state type string. */
119
+ /** The string of the state type that the package does not know. */
118
120
  readonly stateType: string;
119
121
  /** The ID of the state node with the unknown type. */
120
122
  readonly nodeId: string;
121
123
  constructor(stateType: string, nodeId: string, validTypes: string[]);
122
124
  }
123
125
  /**
124
- * Thrown by the `RouteMap` constructor when a route pattern string cannot be compiled
125
- * by `URLPattern`. The `pattern` field contains the rejected string; `cause` wraps the
126
- * original `URLPattern` constructor error.
126
+ * The `RouteMap` constructor throws this error when `URLPattern` cannot compile the
127
+ * string of a route pattern. The `pattern` field holds the string in question, and
128
+ * `cause` holds the original error of the `URLPattern` constructor.
127
129
  *
128
- * Common causes:
129
- * - Unmatched parentheses or brackets in the pattern string
130
- * - Characters that are invalid in a URL pathname pattern
130
+ * The common causes:
131
+ * - A parenthesis or a bracket without its pair in the string of the pattern
132
+ * - A character that a URL pathname pattern does not permit
131
133
  *
132
134
  * **Error code:** `PLAY_ROUTE_MAP_INVALID_PATTERN`
133
135
  *
@@ -145,7 +147,7 @@ export declare class UnknownStateTypeError extends PlayError {
145
147
  * ```
146
148
  */
147
149
  export declare class InvalidRoutePatternError extends PlayError {
148
- /** The route pattern string that could not be compiled by URLPattern. */
150
+ /** The string of the route pattern. URLPattern could not compile it. */
149
151
  readonly pattern: string;
150
152
  constructor(pattern: string, options?: ErrorOptions);
151
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAInD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;;CAUlD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;;CASxD;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IACjD,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM;CAS3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C,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM;CAS3B;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IACjD,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM;CAS3B;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;IACrD,sFAAsF;IACtF,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;gBAElB,UAAU,EAAE,MAAM,EAAE;CAWhC;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,SAAS;IACnD,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE;CAWnE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;IACtD,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAUnD"}
package/dist/errors.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { PlayError } from "@xmachines/play";
2
2
  /**
3
- * Thrown when `RouterBridgeBase.syncActorFromRouter()` fails to process a router
4
- * location change and send the corresponding `play.route` event to the actor.
3
+ * The bridge throws this error when `RouterBridgeBase.syncActorFromRouter()`
4
+ * cannot process a location change of the router and send the `play.route` event to
5
+ * the actor.
5
6
  *
6
- * The `cause` property wraps the original error.
7
+ * The `cause` property holds the original error.
7
8
  *
8
9
  * **Error code:** `PLAY_ROUTER_SYNC_FAILED`
9
10
  *
@@ -27,17 +28,17 @@ export class RouterSyncError extends PlayError {
27
28
  }
28
29
  }
29
30
  /**
30
- * Thrown by `RouterBridgeBase.connect()` when a second bridge tries to connect
31
- * to an actor that already has an active bridge connection.
31
+ * `RouterBridgeBase.connect()` throws this error when a second bridge connects to an
32
+ * actor with an active bridge connection.
32
33
  *
33
- * One actor may only be connected to one router bridge at a time. Two bridges
34
- * sharing the same actor would both receive and process every router navigation
35
- * event, sending duplicate `play.route` events to the actor and producing
36
- * conflicting echo-suppression state via `lastSyncedPath`.
34
+ * One actor can hold one router bridge at a time. Two bridges of the same actor both
35
+ * receive and process every navigation event of the router. They therefore send two
36
+ * `play.route` events to the actor, and their `lastSyncedPath` values of the echo
37
+ * suppression contradict each other.
37
38
  *
38
- * **How to fix:** Call `bridge.disconnect()` on the first bridge before
39
- * connecting a second one, or ensure only one `connectRouter()` call is active
40
- * per actor at any given time.
39
+ * **The remedy:** call `bridge.disconnect()` on the first bridge before you connect
40
+ * the second one. You can also permit one active `connectRouter()` call for each
41
+ * actor at a time.
41
42
  *
42
43
  * **Error code:** `PLAY_ROUTER_DUPLICATE_BRIDGE`
43
44
  *
@@ -62,20 +63,20 @@ export class DuplicateBridgeError extends PlayError {
62
63
  }
63
64
  }
64
65
  /**
65
- * Thrown by the `RouteMap` constructor when a parameterized route is registered but
66
- * the `URLPattern` API is not available in the current runtime environment and no
67
- * polyfill has been loaded.
66
+ * The `RouteMap` constructor throws this error when the caller registers a
67
+ * parameterized route, the current runtime has no `URLPattern` API, and no polyfill
68
+ * is loaded.
68
69
  *
69
- * **How to fix:** Load `urlpattern-polyfill` at your application entry point, before
70
- * any import of `@xmachines/play-router`:
70
+ * **The remedy:** load `urlpattern-polyfill` at the entry point of your application,
71
+ * before each import of `@xmachines/play-router`:
71
72
  *
72
73
  * ```typescript
73
- * // app entry point — must run first
74
+ * // the entry point of the application it must run first
74
75
  * import "urlpattern-polyfill";
75
76
  * ```
76
77
  *
77
- * URLPattern is natively available on Node.js ≥ 24 and modern browsers
78
- * (Chrome 95+, Firefox 117+, Safari 16.4+). Use the polyfill on older targets.
78
+ * URLPattern is native in Node.js ≥ 24 and in a modern browser (Chrome 95+,
79
+ * Firefox 117+, Safari 16.4+). Use the polyfill for an older target.
79
80
  *
80
81
  * **Error code:** `PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE`
81
82
  */
@@ -86,13 +87,13 @@ export class URLPatternUnavailableError extends PlayError {
86
87
  }
87
88
  }
88
89
  /**
89
- * Thrown by `validateRouteFormat()` when a state declares `meta.route` with an
90
- * empty string path.
90
+ * `validateRouteFormat()` throws this error when a state declares a `meta.route`
91
+ * field with an empty string as its path.
91
92
  *
92
93
  * **Error code:** `PLAY_ROUTE_EMPTY_PATH`
93
94
  */
94
95
  export class EmptyRoutePathError extends PlayError {
95
- /** The state ID whose route path is empty. */
96
+ /** The state ID with the empty route path. */
96
97
  stateId;
97
98
  constructor(stateId) {
98
99
  super("RouteMap", "PLAY_ROUTE_EMPTY_PATH", `Empty route path in state "${stateId}": routes must have a non-empty path`);
@@ -101,13 +102,13 @@ export class EmptyRoutePathError extends PlayError {
101
102
  }
102
103
  }
103
104
  /**
104
- * Thrown by `validateStateExists()` when a route references a state ID that does
105
- * not exist in the machine graph.
105
+ * `validateStateExists()` throws this error when a route names a state ID that the
106
+ * machine graph does not hold.
106
107
  *
107
108
  * **Error code:** `PLAY_ROUTE_INVALID_STATE_ID`
108
109
  */
109
110
  export class InvalidStateIdError extends PlayError {
110
- /** The state ID that was referenced but not found. */
111
+ /** The state ID of the reference. The graph does not hold it. */
111
112
  stateId;
112
113
  constructor(stateId) {
113
114
  super("RouteMap", "PLAY_ROUTE_INVALID_STATE_ID", `Route references non-existent state ID: ${stateId}`);
@@ -116,12 +117,13 @@ export class InvalidStateIdError extends PlayError {
116
117
  }
117
118
  }
118
119
  /**
119
- * Thrown by `detectDuplicateRoutes()` when two or more states share the same URL path.
120
+ * `detectDuplicateRoutes()` throws this error when two states or more hold the same
121
+ * URL path.
120
122
  *
121
123
  * **Error code:** `PLAY_ROUTE_DUPLICATE_PATH`
122
124
  */
123
125
  export class DuplicateRoutePathError extends PlayError {
124
- /** Human-readable list of conflicting path → state-ID mappings. */
126
+ /** The list of the path → state-ID mappings of the conflict, for a person to read. */
125
127
  duplicates;
126
128
  constructor(duplicates) {
127
129
  super("RouteMap", "PLAY_ROUTE_DUPLICATE_PATH", `Duplicate route paths detected:\n${duplicates.join("\n")}\n\n` +
@@ -132,13 +134,13 @@ export class DuplicateRoutePathError extends PlayError {
132
134
  }
133
135
  }
134
136
  /**
135
- * Thrown by `machineToGraph()` when an XState state node has an unrecognised
136
- * `.type` value.
137
+ * `machineToGraph()` throws this error when an XState state node has a `.type` value
138
+ * that the package does not know.
137
139
  *
138
140
  * **Error code:** `PLAY_ROUTE_UNKNOWN_STATE_TYPE`
139
141
  */
140
142
  export class UnknownStateTypeError extends PlayError {
141
- /** The unrecognised state type string. */
143
+ /** The string of the state type that the package does not know. */
142
144
  stateType;
143
145
  /** The ID of the state node with the unknown type. */
144
146
  nodeId;
@@ -151,13 +153,13 @@ export class UnknownStateTypeError extends PlayError {
151
153
  }
152
154
  }
153
155
  /**
154
- * Thrown by the `RouteMap` constructor when a route pattern string cannot be compiled
155
- * by `URLPattern`. The `pattern` field contains the rejected string; `cause` wraps the
156
- * original `URLPattern` constructor error.
156
+ * The `RouteMap` constructor throws this error when `URLPattern` cannot compile the
157
+ * string of a route pattern. The `pattern` field holds the string in question, and
158
+ * `cause` holds the original error of the `URLPattern` constructor.
157
159
  *
158
- * Common causes:
159
- * - Unmatched parentheses or brackets in the pattern string
160
- * - Characters that are invalid in a URL pathname pattern
160
+ * The common causes:
161
+ * - A parenthesis or a bracket without its pair in the string of the pattern
162
+ * - A character that a URL pathname pattern does not permit
161
163
  *
162
164
  * **Error code:** `PLAY_ROUTE_MAP_INVALID_PATTERN`
163
165
  *
@@ -175,7 +177,7 @@ export class UnknownStateTypeError extends PlayError {
175
177
  * ```
176
178
  */
177
179
  export class InvalidRoutePatternError extends PlayError {
178
- /** The route pattern string that could not be compiled by URLPattern. */
180
+ /** The string of the route pattern. URLPattern could not compile it. */
179
181
  pattern;
180
182
  constructor(pattern, options) {
181
183
  super("RouteMap", "PLAY_ROUTE_MAP_INVALID_PATTERN", `Invalid route pattern: "${pattern}"`, options);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC7C,YAAY,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,kBAAkB,EAAE,yBAAyB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IAClD;QACC,KAAK,CACJ,kBAAkB,EAClB,8BAA8B,EAC9B,iEAAiE;YAChE,uEAAuE,CACxE,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACpC,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,0BAA2B,SAAQ,SAAS;IACxD;QACC,KAAK,CACJ,UAAU,EACV,uCAAuC,EACvC,6IAA6I,CAC7I,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC1C,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IACjD,8CAA8C;IACrC,OAAO,CAAS;IAEzB,YAAY,OAAe;QAC1B,KAAK,CACJ,UAAU,EACV,uBAAuB,EACvB,8BAA8B,OAAO,sCAAsC,CAC3E,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD;AAED;;;;;GAKG;AAC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D,OAAO,CAAS;IAEzB,YAAY,OAAe,EAAE,OAAsB;QAClD,KAAK,CACJ,UAAU,EACV,gCAAgC,EAChC,2BAA2B,OAAO,GAAG,EACrC,OAAO,CACP,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD"}
@@ -1,15 +1,16 @@
1
1
  import type { AnyStateMachine } from "xstate";
2
2
  import type { RouteTree } from "./types.js";
3
3
  /**
4
- * Extract complete route tree from state machine graph
4
+ * Reads the complete route tree from the graph of a state machine
5
5
  *
6
- * Converts the XState machine to a @statelyai/graph Graph via machineToGraph(),
7
- * then walks graph nodes to extract route metadata, validate route references,
8
- * and build a hierarchical RouteTree. The graph is attached to the returned
9
- * RouteTree for downstream transition-aware queries.
6
+ * The function converts the XState machine into a Graph of @statelyai/graph, with
7
+ * machineToGraph(). It then walks the graph nodes: it reads the route metadata of
8
+ * each node, it checks each route reference, and it builds a hierarchical RouteTree.
9
+ * The RouteTree of the return value also holds the graph, for a later query that
10
+ * needs the transitions.
10
11
  *
11
- * @param machine - XState v5 state machine
12
- * @returns Route tree with root, byStateId map, byPath map, and graph
12
+ * @param machine - The XState v5 state machine
13
+ * @returns The route tree, with its root, its byStateId map, its byPath map, and its graph
13
14
  */
14
15
  export declare const extractMachineRoutes: (machine: AnyStateMachine) => RouteTree;
15
16
  //# sourceMappingURL=extract-routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract-routes.d.ts","sourceRoot":"","sources":["../src/extract-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAA6C,MAAM,YAAY,CAAC;AA2EvF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,eAAe,KAAG,SAmB/D,CAAC"}
1
+ {"version":3,"file":"extract-routes.d.ts","sourceRoot":"","sources":["../src/extract-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAA6C,MAAM,YAAY,CAAC;AA6EvF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,eAAe,KAAG,SAoB/D,CAAC"}
@@ -2,14 +2,16 @@ import { machineToGraph } from "./machine-to-graph.js";
2
2
  import { validateRouteFormat, validateStateExists } from "./validate-routes.js";
3
3
  import { buildRouteTree } from "./build-tree.js";
4
4
  /**
5
- * Build statePath for a graph node by walking the parentId chain.
5
+ * Builds the statePath of a graph node, and it walks the chain of the parentId
6
+ * values.
6
7
  *
7
- * Produces an array of stateId segments from root to this node (excluding root),
8
- * matching the format expected by buildRouteTree's parent lookup.
8
+ * The function makes an array of the stateId segments, from the root to this node,
9
+ * and the array holds no root. This is the format of the parent lookup in
10
+ * buildRouteTree.
9
11
  *
10
- * @param graphNode - The node to build a path for
11
- * @param graphNodeMap - Map from node id to GraphNode for O(1) parent lookup
12
- * @returns Array of stateId segments (e.g. ["dashboard", "overview"])
12
+ * @param graphNode - The node of the path
13
+ * @param graphNodeMap - The map from a node id to a GraphNode, for a parent lookup in O(1)
14
+ * @returns The array of the stateId segments, for example ["dashboard", "overview"]
13
15
  */
14
16
  const buildStatePath = (graphNode, graphNodeMap) => {
15
17
  const path = [];
@@ -21,22 +23,22 @@ const buildStatePath = (graphNode, graphNodeMap) => {
21
23
  return path;
22
24
  };
23
25
  /**
24
- * Extract route info from a graph node's MachineNodeData.
25
- * Returns null if the node has no route (not routable).
26
+ * Reads the route information of the MachineNodeData object of a graph node.
27
+ * The function returns null when the node has no route.
26
28
  */
27
29
  const extractRouteFromNode = (graphNode, stateIds, graphNodeMap) => {
28
30
  const { stateId, route, meta } = graphNode.data;
29
- // Node has no route — not routable
31
+ // The node has no route
30
32
  if (!route)
31
33
  return null;
32
- // Validate format (must start with /)
34
+ // Check the format. The path must start with /
33
35
  validateRouteFormat(route, stateId);
34
- // Validate state exists in graph (redundant but guards against corruption)
36
+ // Check that the graph holds the state. This test is redundant, and it guards against a corruption
35
37
  validateStateExists(stateId, stateIds);
36
- // Build statePath from parentId chain (works for both explicit IDs and auto-generated)
38
+ // Build the statePath from the chain of the parentId values. This works for an explicit ID and also for a generated one
37
39
  const statePath = buildStatePath(graphNode, graphNodeMap);
38
40
  const pattern = route.includes(":") ? route : undefined;
39
- // Reconstruct original metadata shape from graph data
41
+ // Build the original shape of the metadata again, from the data of the graph
40
42
  const metadata = meta && typeof meta === "object" && "route" in meta
41
43
  ? meta["route"]
42
44
  : route;
@@ -53,30 +55,32 @@ const extractRouteFromNode = (graphNode, stateIds, graphNodeMap) => {
53
55
  return result;
54
56
  };
55
57
  /**
56
- * Extract complete route tree from state machine graph
58
+ * Reads the complete route tree from the graph of a state machine
57
59
  *
58
- * Converts the XState machine to a @statelyai/graph Graph via machineToGraph(),
59
- * then walks graph nodes to extract route metadata, validate route references,
60
- * and build a hierarchical RouteTree. The graph is attached to the returned
61
- * RouteTree for downstream transition-aware queries.
60
+ * The function converts the XState machine into a Graph of @statelyai/graph, with
61
+ * machineToGraph(). It then walks the graph nodes: it reads the route metadata of
62
+ * each node, it checks each route reference, and it builds a hierarchical RouteTree.
63
+ * The RouteTree of the return value also holds the graph, for a later query that
64
+ * needs the transitions.
62
65
  *
63
- * @param machine - XState v5 state machine
64
- * @returns Route tree with root, byStateId map, byPath map, and graph
66
+ * @param machine - The XState v5 state machine
67
+ * @returns The route tree, with its root, its byStateId map, its byPath map, and its graph
65
68
  */
66
69
  export const extractMachineRoutes = (machine) => {
67
- // 1. Convert machine to graph
70
+ // 1. Convert the machine into a graph
68
71
  const graph = machineToGraph(machine);
69
- // 2. Build state ID set for validation and node map for O(1) parent lookup
72
+ // 2. Build the set of the state IDs, for the check, and the node map, for a parent lookup in O(1)
70
73
  const stateIds = new Set(graph.nodes.map((n) => n.data.stateId));
71
74
  const graphNodeMap = new Map(graph.nodes.map((n) => [n.id, n]));
72
- // 3. Extract routes from graph nodes
75
+ // 3. Read the routes of the graph nodes
73
76
  const routes = graph.nodes
74
77
  .map((node) => extractRouteFromNode(node, stateIds, graphNodeMap))
75
78
  .filter((r) => r !== null);
76
- // 4. Build hierarchical tree and attach graph.
77
- // Duplicate-route detection happens inside buildRouteTree, AFTER relative
78
- // routes are resolved to full paths — raw route strings are not comparable
79
- // (two relative "settings" routes under different parents are distinct).
79
+ // 4. Build the hierarchical tree, and attach the graph.
80
+ // buildRouteTree finds each duplicate route, AFTER it resolved each relative route
81
+ // to a complete path. The raw route strings are not comparable, because two
82
+ // relative "settings" routes below two different parents are two different
83
+ // routes.
80
84
  const tree = buildRouteTree(routes);
81
85
  return { ...tree, graph };
82
86
  };
@@ -1 +1 @@
1
- {"version":3,"file":"extract-routes.js","sourceRoot":"","sources":["../src/extract-routes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAqB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,cAAc,GAAG,CACtB,SAAqC,EACrC,YAAqD,EAC1C,EAAE;IACb,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,OAAO,GAA2C,SAAS,CAAC;IAEhE,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC/E,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF;;;GAG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G;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAwB,EAAa,EAAE;IAC3E,sCAAsC;IACtC,MAAM,KAAK,GAAiB,cAAc,CAAC,OAAO,CAAC,CAAC;IAEpD,kGAAkG;IAClG,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE,wCAAwC;IACxC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK;SACxB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;SACjE,MAAM,CAAC,CAAC,CAAC,EAAkB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAE5C,wDAAwD;IACxD,mFAAmF;IACnF,4EAA4E;IAC5E,2EAA2E;IAC3E,UAAU;IACV,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC;AAC3B,CAAC,CAAC"}
@@ -1,13 +1,14 @@
1
1
  import type { RouteTree, RouteNode } from "./types.js";
2
2
  /**
3
- * Find route node by state ID
3
+ * Finds a route node by its state ID
4
4
  *
5
- * Looks up route node using the state's ID property. Used to get URL path
6
- * from state ID for browser URL sync after play.route transitions.
5
+ * The function looks the route node up by the ID property of the state. It gives you
6
+ * the URL path of a state ID, for the update of the browser URL after a `play.route`
7
+ * transition.
7
8
  *
8
- * @param tree - Route tree from extractMachineRoutes
9
- * @param id - State ID (e.g., 'dashboard', 'settings.profile')
10
- * @returns Route node if found, undefined otherwise
9
+ * @param tree - The route tree, from extractMachineRoutes
10
+ * @param id - The state ID, for example 'dashboard' or 'settings.profile'
11
+ * @returns The route node, or undefined when the function finds none
11
12
  *
12
13
  * @example
13
14
  * ```typescript
@@ -20,19 +21,21 @@ import type { RouteTree, RouteNode } from "./types.js";
20
21
  */
21
22
  export declare const findRouteById: (tree: RouteTree, id: string) => RouteNode | undefined;
22
23
  /**
23
- * Find route node by URL path
24
+ * Finds a route node by its URL path
24
25
  *
25
- * Looks up route node using the URL path. Used to get state ID from browser
26
- * URL for sending play.route events on navigation.
26
+ * The function looks the route node up by the URL path. It gives you the state ID of
27
+ * a browser URL, for the `play.route` event of a navigation.
27
28
  *
28
- * When multiple states share the same path (e.g., root and a state both at "/"),
29
- * prefers routable nodes (with meta.route) over non-routable nodes.
29
+ * When more than one state holds the same path, for example the root and a second
30
+ * state both at "/", the function prefers a node with a route, which means a node
31
+ * with a `meta.route` field, over a node without one.
30
32
  *
31
- * Supports pattern matching for dynamic routes (e.g., '/settings/:section?').
33
+ * The function also matches a pattern of a dynamic route, for example
34
+ * '/settings/:section?'.
32
35
  *
33
- * @param tree - Route tree from extractMachineRoutes
34
- * @param path - URL path (e.g., '/dashboard', '/settings/profile')
35
- * @returns Route node if found, undefined otherwise
36
+ * @param tree - The route tree, from extractMachineRoutes
37
+ * @param path - The URL path, for example '/dashboard' or '/settings/profile'
38
+ * @returns The route node, or undefined when the function finds none
36
39
  *
37
40
  * @example
38
41
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"find-route.d.ts","sourceRoot":"","sources":["../src/find-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAqCvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,EAAE,IAAI,MAAM,KAAG,SAAS,GAAG,SAEvE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,SAAS,EAAE,MAAM,MAAM,KAAG,SAAS,GAAG,SAyB3E,CAAC"}
1
+ {"version":3,"file":"find-route.d.ts","sourceRoot":"","sources":["../src/find-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAsCvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,EAAE,IAAI,MAAM,KAAG,SAAS,GAAG,SAEvE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,SAAS,EAAE,MAAM,MAAM,KAAG,SAAS,GAAG,SAyB3E,CAAC"}