@xmachines/play-router 3.0.0 → 5.0.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 (85) hide show
  1. package/README.md +111 -116
  2. package/dist/base-route-map.d.ts +24 -13
  3. package/dist/base-route-map.d.ts.map +1 -1
  4. package/dist/base-route-map.js +116 -27
  5. package/dist/base-route-map.js.map +1 -1
  6. package/dist/build-tree.d.ts +16 -1
  7. package/dist/build-tree.d.ts.map +1 -1
  8. package/dist/build-tree.js +22 -4
  9. package/dist/build-tree.js.map +1 -1
  10. package/dist/create-route-map-from-tree.d.ts +13 -7
  11. package/dist/create-route-map-from-tree.d.ts.map +1 -1
  12. package/dist/create-route-map-from-tree.js +14 -6
  13. package/dist/create-route-map-from-tree.js.map +1 -1
  14. package/dist/errors.d.ts +2 -134
  15. package/dist/errors.d.ts.map +1 -1
  16. package/dist/errors.js +11 -151
  17. package/dist/errors.js.map +1 -1
  18. package/dist/find-route.d.ts +13 -1
  19. package/dist/find-route.d.ts.map +1 -1
  20. package/dist/find-route.js +33 -26
  21. package/dist/find-route.js.map +1 -1
  22. package/dist/index.d.ts +8 -18
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +6 -12
  25. package/dist/index.js.map +1 -1
  26. package/dist/provider-lifecycle.d.ts +18 -6
  27. package/dist/provider-lifecycle.d.ts.map +1 -1
  28. package/dist/provider-lifecycle.js +10 -5
  29. package/dist/provider-lifecycle.js.map +1 -1
  30. package/dist/router-bridge-base.d.ts +73 -38
  31. package/dist/router-bridge-base.d.ts.map +1 -1
  32. package/dist/router-bridge-base.js +304 -124
  33. package/dist/router-bridge-base.js.map +1 -1
  34. package/dist/router-sync.d.ts +3 -27
  35. package/dist/router-sync.d.ts.map +1 -1
  36. package/dist/router-sync.js +27 -45
  37. package/dist/router-sync.js.map +1 -1
  38. package/dist/types.d.ts +206 -102
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/xstate/create-route-map.d.ts +30 -0
  41. package/dist/xstate/create-route-map.d.ts.map +1 -0
  42. package/dist/{create-route-map.js → xstate/create-route-map.js} +11 -6
  43. package/dist/xstate/create-route-map.js.map +1 -0
  44. package/dist/{extract-routes.d.ts → xstate/extract-routes.d.ts} +4 -2
  45. package/dist/xstate/extract-routes.d.ts.map +1 -0
  46. package/dist/{extract-routes.js → xstate/extract-routes.js} +11 -6
  47. package/dist/xstate/extract-routes.js.map +1 -0
  48. package/dist/xstate/index.d.ts +35 -0
  49. package/dist/xstate/index.d.ts.map +1 -0
  50. package/dist/xstate/index.js +33 -0
  51. package/dist/xstate/index.js.map +1 -0
  52. package/dist/{machine-to-graph.d.ts → xstate/machine-to-graph.d.ts} +1 -1
  53. package/dist/xstate/machine-to-graph.d.ts.map +1 -0
  54. package/dist/{machine-to-graph.js → xstate/machine-to-graph.js} +2 -2
  55. package/dist/xstate/machine-to-graph.js.map +1 -0
  56. package/dist/xstate/machine-types.d.ts +42 -0
  57. package/dist/xstate/machine-types.d.ts.map +1 -0
  58. package/dist/xstate/machine-types.js +2 -0
  59. package/dist/xstate/machine-types.js.map +1 -0
  60. package/dist/{query.d.ts → xstate/query.d.ts} +6 -4
  61. package/dist/xstate/query.d.ts.map +1 -0
  62. package/dist/{query.js → xstate/query.js} +3 -2
  63. package/dist/xstate/query.js.map +1 -0
  64. package/package.json +30 -21
  65. package/dist/base-path.d.ts +0 -209
  66. package/dist/base-path.d.ts.map +0 -1
  67. package/dist/base-path.js +0 -418
  68. package/dist/base-path.js.map +0 -1
  69. package/dist/create-route-map.d.ts +0 -44
  70. package/dist/create-route-map.d.ts.map +0 -1
  71. package/dist/create-route-map.js.map +0 -1
  72. package/dist/extract-routes.d.ts.map +0 -1
  73. package/dist/extract-routes.js.map +0 -1
  74. package/dist/framework-params.d.ts +0 -144
  75. package/dist/framework-params.d.ts.map +0 -1
  76. package/dist/framework-params.js +0 -291
  77. package/dist/framework-params.js.map +0 -1
  78. package/dist/machine-to-graph.d.ts.map +0 -1
  79. package/dist/machine-to-graph.js.map +0 -1
  80. package/dist/query.d.ts.map +0 -1
  81. package/dist/query.js.map +0 -1
  82. package/dist/url-pattern-utils.d.ts +0 -93
  83. package/dist/url-pattern-utils.d.ts.map +0 -1
  84. package/dist/url-pattern-utils.js +0 -233
  85. package/dist/url-pattern-utils.js.map +0 -1
package/dist/errors.js CHANGED
@@ -1,4 +1,14 @@
1
- import { PlayError } from "@xmachines/play";
1
+ import { PlayError } from "@xmachines/play/errors";
2
+ // The errors of the URL language live in `@xmachines/play-url`, with the parser that
3
+ // raises them. They are re-exported here, so that a consumer of this package sorts every
4
+ // routing error from one import, exactly as before the split.
5
+ //
6
+ // The specifier is the `./errors` subpath, and not the root barrel. A consumer that
7
+ // imports `@xmachines/play-router/errors` to name a fault in a `catch` then loads the
8
+ // three classes alone: no pattern parser, no base path, and no `urlpattern-polyfill`. The
9
+ // root barrel of this package reaches the rest of `@xmachines/play-url` for the consumer
10
+ // that needs it.
11
+ export { InvalidRoutePatternError, InvalidBasePathError, MissingBasePathParamError, } from "@xmachines/play-url/errors";
2
12
  /**
3
13
  * The bridge throws this error when `RouterBridgeBase.syncActorFromRouter()`
4
14
  * cannot process a location change of the router and send the `play.route` event to
@@ -62,30 +72,6 @@ export class DuplicateBridgeError extends PlayError {
62
72
  this.name = "DuplicateBridgeError";
63
73
  }
64
74
  }
65
- /**
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.
69
- *
70
- * **The remedy:** load `urlpattern-polyfill` at the entry point of your application,
71
- * before each import of `@xmachines/play-router`:
72
- *
73
- * ```typescript
74
- * // the entry point of the application — it must run first
75
- * import "urlpattern-polyfill";
76
- * ```
77
- *
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.
80
- *
81
- * **Error code:** `PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE`
82
- */
83
- export class URLPatternUnavailableError extends PlayError {
84
- constructor() {
85
- super("RouteMap", "PLAY_ROUTE_MAP_URLPATTERN_UNAVAILABLE", "URLPattern is not available. Load a polyfill (e.g. urlpattern-polyfill) before using @xmachines/play-router on Node < 24 or older browsers.");
86
- this.name = "URLPatternUnavailableError";
87
- }
88
- }
89
75
  /**
90
76
  * `validateRouteFormat()` throws this error when a state declares a `meta.route`
91
77
  * field with an empty string as its path.
@@ -152,130 +138,4 @@ export class UnknownStateTypeError extends PlayError {
152
138
  this.nodeId = nodeId;
153
139
  }
154
140
  }
155
- /**
156
- * The library throws this error when `URLPattern` cannot compile the string of a route
157
- * pattern. The `pattern` field holds the string in question, and `cause` holds the
158
- * original error of the `URLPattern` constructor.
159
- *
160
- * Every compilation reports through this error, so `extractRouteParams` raises it for a
161
- * pattern that no `RouteMap` ever held, and not a bare `TypeError`.
162
- *
163
- * The common causes:
164
- * - A parenthesis or a bracket without its pair in the string of the pattern
165
- * - A character that a URL pathname pattern does not permit
166
- * - Two params of one pattern that land on the same URLPattern group. A name with a
167
- * hyphen compiles with an underscore, so `:cat-id` and `:cat_id` are one group. The
168
- * message names the two params and the group, and `cause` is absent: the library
169
- * refuses the pattern before URLPattern sees it.
170
- *
171
- * **Error code:** `PLAY_ROUTE_MAP_INVALID_PATTERN`
172
- *
173
- * @example
174
- * ```typescript
175
- * import { InvalidRoutePatternError } from "@xmachines/play-router/errors";
176
- *
177
- * try {
178
- * const routeMap = createRouteMap(machine);
179
- * } catch (err) {
180
- * if (err instanceof InvalidRoutePatternError) {
181
- * console.error(`Bad route pattern: "${err.pattern}"`, err.cause);
182
- * }
183
- * }
184
- * ```
185
- */
186
- export class InvalidRoutePatternError extends PlayError {
187
- /** The string of the route pattern. URLPattern could not compile it. */
188
- pattern;
189
- /**
190
- * @param pattern - The route pattern that URLPattern could not compile.
191
- * @param options - The standard `cause`, and an optional `reason` that says WHY. Give
192
- * a reason whenever the library knows it: the pattern alone shows a caller nothing
193
- * when the fault is a rewrite that the library made, and not the text they wrote.
194
- */
195
- constructor(pattern, options) {
196
- const reason = options?.reason;
197
- super("RouteMap", "PLAY_ROUTE_MAP_INVALID_PATTERN", reason
198
- ? `Invalid route pattern: "${pattern}". ${reason}`
199
- : `Invalid route pattern: "${pattern}"`, options);
200
- this.name = "InvalidRoutePatternError";
201
- this.pattern = pattern;
202
- }
203
- }
204
- /**
205
- * Thrown when a `basePath` option resolves to one concrete URL prefix never.
206
- *
207
- * A bridge writes a real browser URL from its prefix, so every segment must hold
208
- * exactly one value. A wildcard segment (`*`), an optional segment (`:section?`), a
209
- * nameless `:` segment, a query string, and a hash fragment each describe a SET of
210
- * prefixes instead, or no prefix at all. A `$param` segment is the route-param
211
- * syntax of TanStack Router: a base path writes a param as `:param`, and it takes
212
- * the value of that param from `basePathParams`.
213
- *
214
- * **How to fix it:** mount on the prefix itself, and let the machine own the rest.
215
- * For the splat route `/$machineId/play/$` of TanStack, the base path is
216
- * `"/:machineId/play"` with `basePathParams: { machineId }`.
217
- *
218
- * **Error code:** `PLAY_ROUTER_INVALID_BASE_PATH`
219
- *
220
- * @example
221
- * ```typescript
222
- * import { InvalidBasePathError } from "@xmachines/play-router/errors";
223
- *
224
- * try {
225
- * bridge.setBasePath("/:machineId/play/*");
226
- * } catch (err) {
227
- * if (err instanceof InvalidBasePathError) {
228
- * console.error(`Bad base path: "${err.basePath}"`, err.message);
229
- * }
230
- * }
231
- * ```
232
- */
233
- export class InvalidBasePathError extends PlayError {
234
- /** The `basePath` option of the refusal, exactly as the caller gave it. */
235
- basePath;
236
- constructor(basePath, reason) {
237
- super("resolveBasePath", "PLAY_ROUTER_INVALID_BASE_PATH", `Invalid basePath "${basePath}": ${reason}`);
238
- this.name = "InvalidBasePathError";
239
- this.basePath = basePath;
240
- }
241
- }
242
- /**
243
- * Thrown when a `:param` segment of a `basePath` has no value in `basePathParams`.
244
- *
245
- * A base path can be a pattern, so a host keeps one string that mirrors its own
246
- * route config. The bridge must still resolve that pattern to a concrete prefix,
247
- * because it writes a real browser URL, and it removes a literal prefix from every
248
- * inbound location. Every `:param` therefore needs a value.
249
- *
250
- * **How to fix it:** give the value that the host resolved already — a loader of
251
- * TanStack, or a `useParams()` call, holds it — as `basePathParams: { machineId }`.
252
- * An empty string counts as an absent value, because it would collapse the segment.
253
- *
254
- * **Error code:** `PLAY_ROUTER_MISSING_BASE_PATH_PARAM`
255
- *
256
- * @example
257
- * ```typescript
258
- * import { MissingBasePathParamError } from "@xmachines/play-router/errors";
259
- *
260
- * try {
261
- * connectRouter({ actor, router, routeMap, basePath: "/:machineId/play" });
262
- * } catch (err) {
263
- * if (err instanceof MissingBasePathParamError) {
264
- * console.error(`basePath needs a value for :${err.param}`);
265
- * }
266
- * }
267
- * ```
268
- */
269
- export class MissingBasePathParamError extends PlayError {
270
- /** The name of the `:param` segment without a value, and without its `:`. */
271
- param;
272
- /** The `basePath` option that declares the param. */
273
- basePath;
274
- constructor(param, basePath) {
275
- super("resolveBasePath", "PLAY_ROUTER_MISSING_BASE_PATH_PARAM", `basePath "${basePath}" declares ":${param}", but basePathParams has no value for it.`);
276
- this.name = "MissingBasePathParamError";
277
- this.param = param;
278
- this.basePath = basePath;
279
- }
280
- }
281
141
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;GAqBG;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,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ChB,+BAA+B,EAC/B,8BAA8B,SAAS,cAAc,MAAM,KAAK;YAC/D,oBAAoB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7C,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD"}
@@ -1,3 +1,4 @@
1
+ import type { CompileOptions } from "@xmachines/play-url";
1
2
  import type { RouteTree, RouteNode } from "./types.js";
2
3
  /**
3
4
  * Finds a route node by its state ID
@@ -35,13 +36,24 @@ export declare const findRouteById: (tree: RouteTree, id: string) => RouteNode |
35
36
  *
36
37
  * @param tree - The route tree, from extractMachineRoutes
37
38
  * @param path - The URL path, for example '/dashboard' or '/settings/profile'
39
+ * @param options - The caches that the pattern match reads. The default is the pair
40
+ * that `@xmachines/play-url` shares with every caller of the process. A server that
41
+ * serves many tenants passes a cache that the tenant owns, exactly as `RouteMap` and
42
+ * a bridge take one. A cache changes how often the work runs, and it changes no
43
+ * answer, so this argument is safe to leave out.
38
44
  * @returns The route node, or undefined when the function finds none
39
45
  *
40
46
  * @example
41
47
  * ```typescript
42
48
  * const tree = extractMachineRoutes(machine);
43
49
  * const node = findRouteByPath(tree, '/dashboard');
50
+ *
51
+ * // With a cache that one request owns and drops
52
+ * const node = findRouteByPath(tree, '/dashboard', {
53
+ * patternCache: createPatternCache(),
54
+ * compiledCache: createPatternCache(),
55
+ * });
44
56
  * ```
45
57
  */
46
- export declare const findRouteByPath: (tree: RouteTree, path: string) => RouteNode | undefined;
58
+ export declare const findRouteByPath: (tree: RouteTree, path: string, options?: CompileOptions) => RouteNode | undefined;
47
59
  //# sourceMappingURL=find-route.d.ts.map
@@ -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;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"}
1
+ {"version":3,"file":"find-route.d.ts","sourceRoot":"","sources":["../src/find-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAmCvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,EAAE,IAAI,MAAM,KAAG,SAAS,GAAG,SAEvE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,eAAe,GAC3B,MAAM,SAAS,EACf,MAAM,MAAM,EACZ,UAAU,cAAc,KACtB,SAAS,GAAG,SAyBd,CAAC"}
@@ -1,40 +1,36 @@
1
- import { getURLPatternCtor, getCompiledPattern } from "./url-pattern-utils.js";
2
- import { URLPatternUnavailableError, InvalidRoutePatternError } from "./errors.js";
1
+ import { getCompiledPattern, parsePattern } from "@xmachines/play-url";
3
2
  /**
4
3
  * Tells you if a URL path matches a route pattern, with URLPattern.
5
4
  *
6
- * For a static pattern, which holds no `:param`, the function makes a direct
7
- * equality test. Therefore an environment with static routes only needs URLPattern
8
- * never, and it needs no polyfill.
5
+ * For a static pattern, which holds no param, the function makes a direct equality
6
+ * test, and it compiles nothing.
9
7
  *
10
- * The function uses the compiled-pattern cache of the module level
11
- * (`getCompiledPattern`). A repeated lookup therefore compiles the same pattern
12
- * never again. The cache also normalizes a param name with a hyphen (`:cat-id`)
13
- * exactly like `RouteMap`: one match engine is below both.
8
+ * The function compiles through `getCompiledPattern`, so a repeated lookup compiles
9
+ * the same pattern never again. That call also normalizes a param name with a hyphen
10
+ * (`:cat-id`) exactly like `RouteMap`: one match engine is below both.
14
11
  *
15
- * The function throws a `URLPatternUnavailableError` when it tests a parameterized
16
- * pattern and `globalThis` holds no URLPattern.
17
- * It throws an `InvalidRoutePatternError` when URLPattern cannot compile the
18
- * pattern.
12
+ * It throws the `InvalidRoutePatternError` of `getCompiledPattern` when URLPattern
13
+ * cannot compile the pattern.
19
14
  *
20
15
  * This function is private. The public API of the package does not export it.
21
16
  *
22
17
  * @param path - The URL path, for example '/settings' or '/settings/billing'
23
18
  * @param pattern - The route pattern, for example '/settings/:section?'
19
+ * @param options - The caches to read. The default is the pair that
20
+ * `@xmachines/play-url` shares with every caller of the process.
24
21
  * @returns True when the path matches the pattern
25
22
  */
26
- function matchesPattern(path, pattern) {
27
- if (!pattern.includes(":"))
23
+ function matchesPattern(path, pattern, options) {
24
+ // The test reads the PARSE. `pattern.includes(":")` called `/docs/*` and `/a{/b}?/c`
25
+ // static, and the equality test below then answered `false` for every path that the
26
+ // pattern matches.
27
+ if (!parsePattern(pattern, options).parameterized)
28
28
  return path === pattern;
29
- const Ctor = getURLPatternCtor();
30
- if (!Ctor)
31
- throw new URLPatternUnavailableError();
32
- try {
33
- return getCompiledPattern(pattern, Ctor).test({ pathname: path });
34
- }
35
- catch (err) {
36
- throw new InvalidRoutePatternError(pattern, { cause: err });
37
- }
29
+ // `getCompiledPattern` reports an invalid pattern itself, and with the REASON when it
30
+ // knows one — two params that land on one URLPattern group, for example. A wrap here
31
+ // replaced that message with the generic one and pushed the explanation down to
32
+ // `cause`, which is the same defect that `RouteMap` guards against in its constructor.
33
+ return getCompiledPattern(pattern, options).test({ pathname: path });
38
34
  }
39
35
  /**
40
36
  * Finds a route node by its state ID
@@ -74,15 +70,26 @@ export const findRouteById = (tree, id) => {
74
70
  *
75
71
  * @param tree - The route tree, from extractMachineRoutes
76
72
  * @param path - The URL path, for example '/dashboard' or '/settings/profile'
73
+ * @param options - The caches that the pattern match reads. The default is the pair
74
+ * that `@xmachines/play-url` shares with every caller of the process. A server that
75
+ * serves many tenants passes a cache that the tenant owns, exactly as `RouteMap` and
76
+ * a bridge take one. A cache changes how often the work runs, and it changes no
77
+ * answer, so this argument is safe to leave out.
77
78
  * @returns The route node, or undefined when the function finds none
78
79
  *
79
80
  * @example
80
81
  * ```typescript
81
82
  * const tree = extractMachineRoutes(machine);
82
83
  * const node = findRouteByPath(tree, '/dashboard');
84
+ *
85
+ * // With a cache that one request owns and drops
86
+ * const node = findRouteByPath(tree, '/dashboard', {
87
+ * patternCache: createPatternCache(),
88
+ * compiledCache: createPatternCache(),
89
+ * });
83
90
  * ```
84
91
  */
85
- export const findRouteByPath = (tree, path) => {
92
+ export const findRouteByPath = (tree, path, options) => {
86
93
  // 1. Try the exact match first. This is the fast path of a static route
87
94
  const node = tree.byPath.get(path);
88
95
  if (node?.routable) {
@@ -97,7 +104,7 @@ export const findRouteByPath = (tree, path) => {
97
104
  continue; // Skip each node without a route
98
105
  }
99
106
  // Test the path against the pattern of this node
100
- if (matchesPattern(path, candidate.fullPath)) {
107
+ if (matchesPattern(path, candidate.fullPath, options)) {
101
108
  return candidate;
102
109
  }
103
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"find-route.js","sourceRoot":"","sources":["../src/find-route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAS,cAAc,CAAC,IAAY,EAAE,OAAe;IACpD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,KAAK,OAAO,CAAC;IACpD,MAAM,IAAI,G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AC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACzB,SAAS,CAAC,iCAAiC;QAC5C,CAAC;QAED,iDAAiD;QACjD,IAAI,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;YACvD,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC;IAED,yFAAyF;IACzF,OAAO,IAAI,CAAC;AACb,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,29 +1,19 @@
1
- import type { RouteMapping } from "./base-route-map.js";
2
1
  export { RouterBridgeBase } from "./router-bridge-base.js";
3
- export type { RouteWatcherHandle } from "./router-bridge-base.js";
4
- export { sanitizePathname, buildPlayRouteEvent, extractQuery, extractRouteParams, } from "./router-sync.js";
2
+ export type { RouteWatcherHandle, RouterBridgeOptions } from "./router-bridge-base.js";
3
+ export { buildPlayRouteEvent, extractQuery, extractRouteParams } from "./router-sync.js";
5
4
  export type { RouteMatch, BuildPlayRouteEventOptions } from "./router-sync.js";
6
5
  export { validateRouteFormat, validateStateExists, detectDuplicateRoutes, } from "./validate-routes.js";
7
6
  export type { ResolvedRoutePath } from "./validate-routes.js";
8
- export { buildRouteTree } from "./build-tree.js";
9
- export { extractMachineRoutes } from "./extract-routes.js";
10
- export { getNavigableRoutes, getRoutableRoutes, routeExists, getRouteMappings, getTransitionReachableRoutes, isRouteReachable, } from "./query.js";
11
- export { normalizeBasePath, resolveBasePath, stripBasePath, joinBasePath, NO_BASE_PATH, } from "./base-path.js";
12
- export type { BasePathOptions, ResolvedBasePath } from "./base-path.js";
13
- export { cleanFrameworkParams, getPatternParamNames, getRequiredPatternParamNames, pickOwnParams, resolveFrameworkParams, type FrameworkParamsSource, } from "./framework-params.js";
7
+ export { normalizeBasePath, resolveBasePath, stripBasePath, joinBasePath, NO_BASE_PATH, } from "@xmachines/play-url";
8
+ export type { BasePathOptions, ResolvedBasePath } from "@xmachines/play-url";
9
+ export { cleanFrameworkParams, createPatternCache, parsePattern, pickOwnParams, resolveFrameworkParams, sanitizePathname, splitLocation, type CompileOptions, type ParseOptions, type FrameworkParamsSource, type ParsedPattern, type PatternCache, type SplitLocation, type URLPatternLike, } from "@xmachines/play-url";
14
10
  export { isMountableBridge, mountKey, createRouterConnection, openProviderBridge, repointProviderBridge, } from "./provider-lifecycle.js";
15
11
  export type { OpenProviderBridgeArgs, PlayRouterBridgeConstructor, PlayRouterProviderBaseProps, RouterConnection, } from "./provider-lifecycle.js";
16
- export { machineToGraph } from "./machine-to-graph.js";
17
- export type { MachineGraph } from "./machine-to-graph.js";
18
- export type { RouteInfo, RouteNode, RouteTree, RouteObject, RouteMetadata, PlayRouteEvent, RoutableActor, PlayActor, RouterBridge, MountableRouterBridge, MachineNodeData, MachineEdgeData, WindowLike, LocationLike, } from "./types.js";
12
+ export type { RouteInfo, RouteNode, RouteTree, RouteObject, RouteMetadata, RouteData, RouteDataResolver, PlayRouteEvent, Routable, RoutableActor, RouterBridge, MountableRouterBridge, WindowLike, LocationLike, } from "./types.js";
19
13
  export { RouteMap, type RouteMapping } from "./base-route-map.js";
20
- /**
21
- * @deprecated Use {@link RouteMapping}. Will be removed in the next major.
22
- */
23
- export type BaseRouteMapping = RouteMapping;
24
- export { createRouteMap } from "./create-route-map.js";
25
- export type { RouteMapOptions } from "./create-route-map.js";
26
14
  export { createRouteMapFromTree } from "./create-route-map-from-tree.js";
27
15
  export { findRouteById, findRouteByPath } from "./find-route.js";
28
16
  export { DISPOSE } from "@xmachines/play";
17
+ export { buildRouteTree, ROOT_NODE_ID } from "./build-tree.js";
18
+ export type { RouteMapOptions } from "./types.js";
29
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,Y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,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EACN,iBAAiB,EACjB,QAAQ,EACR,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,GACrB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,gBAAgB,GAChB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,WAAW,EACX,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,UAAU,EACV,YAAY,GACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAGzE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMjE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI1C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,33 +1,24 @@
1
1
  // RouterBridgeBase — the public API of an adapter of the community
2
2
  export { RouterBridgeBase } from "./router-bridge-base.js";
3
3
  // The router sync utilities — play-dom-router uses them, and also each adapter that passes around syncActorFromRouter()
4
- export { sanitizePathname, buildPlayRouteEvent, extractQuery, extractRouteParams, } from "./router-sync.js";
4
+ export { buildPlayRouteEvent, extractQuery, extractRouteParams } from "./router-sync.js";
5
5
  // The route utilities
6
6
  export { validateRouteFormat, validateStateExists, detectDuplicateRoutes, } from "./validate-routes.js";
7
- export { buildRouteTree } from "./build-tree.js";
8
- export { extractMachineRoutes } from "./extract-routes.js";
9
- export { getNavigableRoutes, getRoutableRoutes, routeExists, getRouteMappings, getTransitionReachableRoutes, isRouteReachable, } from "./query.js";
10
7
  // The base-path mount — it lets a host own a part of the same router as a machine.
11
8
  // A consumer normally gives `basePath` to a bridge, to `connectRouter`, or to a
12
9
  // `PlayRouterProvider`. These primitives serve an adapter, and a host that builds its
13
10
  // own route table.
14
- export { normalizeBasePath, resolveBasePath, stripBasePath, joinBasePath, NO_BASE_PATH, } from "./base-path.js";
11
+ export { normalizeBasePath, resolveBasePath, stripBasePath, joinBasePath, NO_BASE_PATH, } from "@xmachines/play-url";
15
12
  // The params of a framework router, reconciled with the pattern of the machine. A
16
13
  // bridge whose framework parses the params itself calls this, and it keeps that parse.
17
- export { cleanFrameworkParams, getPatternParamNames, getRequiredPatternParamNames, pickOwnParams, resolveFrameworkParams, } from "./framework-params.js";
14
+ export { cleanFrameworkParams, createPatternCache, parsePattern, pickOwnParams, resolveFrameworkParams, sanitizePathname, splitLocation, } from "@xmachines/play-url";
18
15
  // The framework-free half of a PlayRouterProvider: the props, the constructor shape,
19
16
  // and the lifecycle of the bridge. A provider of a framework adds its own effects and
20
17
  // nothing else. This entry stays framework-agnostic — nothing here imports one.
21
18
  export { isMountableBridge, mountKey, createRouterConnection, openProviderBridge, repointProviderBridge, } from "./provider-lifecycle.js";
22
- // The graph adapter — it converts an XState machine into a Graph of @statelyai/graph
23
- export { machineToGraph } from "./machine-to-graph.js";
24
19
  // The shared base class of the route map for both directions.
25
- // This module exports RouteMapping directly. BaseRouteMapping stays as an alias, for
26
- // the compatibility.
27
20
  export { RouteMap } from "./base-route-map.js";
28
21
  // The factories: each one creates a RouteMap from a machine or from a route tree.
29
- // Every RouterBridgeBase adapter uses them, and it writes no factory of its own.
30
- export { createRouteMap } from "./create-route-map.js";
31
22
  export { createRouteMapFromTree } from "./create-route-map-from-tree.js";
32
23
  // The helpers of a route lookup. matchesPattern stays private inside find-route.ts
33
24
  export { findRouteById, findRouteByPath } from "./find-route.js";
@@ -36,4 +27,7 @@ export { findRouteById, findRouteByPath } from "./find-route.js";
36
27
  // entry. It names `asCleanup` nowhere: a consumer of this package RECEIVES a
37
28
  // release, and builds one only with @xmachines/play itself.
38
29
  export { DISPOSE } from "@xmachines/play";
30
+ // The tree builder and its options. `@xmachines/play-router/xstate` reads both: it walks
31
+ // a machine, and it hands the routes here to become a tree and then a route map.
32
+ export { buildRouteTree, ROOT_NODE_ID } from "./build-tree.js";
39
33
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,mEAAmE;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,wHAAwH;AACxH,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,sBAAsB;AACtB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,4BAA4B,EAC5B,gBAAgB,GAChB,MAAM,YAAY,CAAC;AAEpB,mFAAmF;AACnF,gFAAgF;AAChF,sFAAsF;AACtF,mBAAmB;AACnB,OAAO,EACN,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,GACZ,MAAM,gBAAgB,CAAC;AAExB,kFAAkF;AAClF,uFAAuF;AACvF,OAAO,EACN,oBAAoB,E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;AACvF,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,GAQb,MAAM,qBAAqB,CAAC;AAE7B,qFAAqF;AACrF,sFAAsF;AACtF,gFAAgF;AAChF,OAAO,EACN,iBAAiB,EACjB,QAAQ,EACR,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,GACrB,MAAM,yBAAyB,CAAC;AAyBjC,8DAA8D;AAC9D,OAAO,EAAE,QAAQ,EAAqB,MAAM,qBAAqB,CAAC;AAElE,kFAAkF;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,mFAAmF;AACnF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEjE,sFAAsF;AACtF,iFAAiF;AACjF,6EAA6E;AAC7E,4DAA4D;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,yFAAyF;AACzF,iFAAiF;AACjF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -17,9 +17,10 @@
17
17
  *
18
18
  * @see [Multi-router integration](../../docs/examples/multi-router-integration.md)
19
19
  */
20
+ import { type BasePathOptions, type CompileOptions } from "@xmachines/play-url";
21
+ import type { RouterBridgeOptions } from "./router-bridge-base.js";
20
22
  import { DISPOSE } from "@xmachines/play";
21
- import { type BasePathOptions } from "./base-path.js";
22
- import type { MountableRouterBridge, PlayActor, RouterBridge } from "./types.js";
23
+ import type { MountableRouterBridge, RoutableActor, RouterBridge } from "./types.js";
23
24
  import type { RouteMap } from "./base-route-map.js";
24
25
  /**
25
26
  * The props that every `PlayRouterProvider` of a framework shares.
@@ -31,7 +32,7 @@ import type { RouteMap } from "./base-route-map.js";
31
32
  * An adapter re-exports a two-parameter alias of this type, with `TRouter` bound to
32
33
  * the type of its router instance and `TNode` bound to its own node type.
33
34
  */
34
- export interface PlayRouterProviderBaseProps<TRouter, TActor extends PlayActor, TNode> {
35
+ export interface PlayRouterProviderBaseProps<TRouter, TActor extends RoutableActor, TNode> extends CompileOptions {
35
36
  /**
36
37
  * The actor to keep in step with the router. It must be a stable reference: give
37
38
  * the same actor instance on every render. An actor in the JSX, or a new actor on
@@ -91,13 +92,24 @@ export interface PlayRouterProviderBaseProps<TRouter, TActor extends PlayActor,
91
92
  /**
92
93
  * The constructor shape that a bridge class must satisfy for a provider factory: `(router, actor, routeMap, options?) → RouterBridge`.
93
94
  *
95
+ * `TActor` carries the actor type of the caller through to the constructor, so the spec
96
+ * type of that actor reaches the bridge whole. A bridge that reads no spec binds nothing
97
+ * and receives the default.
98
+ *
99
+ * The options are {@link RouterBridgeOptions}, because that is what
100
+ * {@link openProviderBridge} hands to the constructor: the base path AND the caches of a
101
+ * parse and a compilation. A `BasePathOptions` here named half of the value that travels,
102
+ * so a bridge author read the type and learned of no cache. A bridge that declares the
103
+ * narrower `BasePathOptions` still satisfies this type, and it reads the fields that it
104
+ * knows.
105
+ *
94
106
  * The return type is `RouterBridge`, the published contract of a bridge, so a
95
107
  * consumer bridge of its own keeps compiling. Every bridge on `RouterBridgeBase` also
96
108
  * satisfies `MountableRouterBridge`, and the provider finds that mount API at run
97
109
  * time: a bridge without it ignores `basePath`, exactly as it did before the option
98
110
  * existed.
99
111
  */
100
- export type PlayRouterBridgeConstructor<TRouter> = new (router: TRouter, actor: PlayActor, routeMap: RouteMap, options?: BasePathOptions) => RouterBridge;
112
+ export type PlayRouterBridgeConstructor<TRouter, TActor extends RoutableActor = RoutableActor> = new (router: TRouter, actor: TActor, routeMap: RouteMap, options?: RouterBridgeOptions) => RouterBridge;
101
113
  /**
102
114
  * Tells you whether a bridge can move its mount.
103
115
  *
@@ -118,7 +130,7 @@ export declare function isMountableBridge(bridge: RouterBridge | null | undefine
118
130
  */
119
131
  export declare function mountKey(basePath?: BasePathOptions["basePath"], basePathParams?: BasePathOptions["basePathParams"]): string;
120
132
  /** What {@link openProviderBridge} needs to build and connect a bridge. */
121
- export interface OpenProviderBridgeArgs<TRouter, TActor extends PlayActor> extends BasePathOptions {
133
+ export interface OpenProviderBridgeArgs<TRouter, TActor extends RoutableActor> extends RouterBridgeOptions {
122
134
  router: TRouter;
123
135
  actor: TActor;
124
136
  routeMap: RouteMap;
@@ -133,7 +145,7 @@ export interface OpenProviderBridgeArgs<TRouter, TActor extends PlayActor> exten
133
145
  *
134
146
  * @returns The bridge, and a `close` that disconnects it one time.
135
147
  */
136
- export declare function openProviderBridge<TRouter, TActor extends PlayActor>(BridgeCtor: PlayRouterBridgeConstructor<TRouter>, { router, actor, routeMap, basePath, basePathParams }: OpenProviderBridgeArgs<TRouter, TActor>): {
148
+ export declare function openProviderBridge<TRouter, TActor extends RoutableActor>(BridgeCtor: PlayRouterBridgeConstructor<TRouter, TActor>, { router, actor, routeMap, ...options }: OpenProviderBridgeArgs<TRouter, TActor>): {
137
149
  bridge: RouterBridge;
138
150
  close: () => void;
139
151
  };
@@ -1 +1 @@
1
- {"version":3,"file":"provider-lifecycle.d.ts","sourceRoot":"","sources":["../src/provider-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAa,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,WAAW,2BAA2B,CAAC,OAAO,EAAE,MAAM,SAAS,SAAS,EAAE,KAAK;IACpF;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,uGAAuG;IACvG,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,QAAQ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 +17,8 @@
17
17
  *
18
18
  * @see [Multi-router integration](../../docs/examples/multi-router-integration.md)
19
19
  */
20
+ import { normalizeBasePath } from "@xmachines/play-url";
20
21
  import { asCleanup, DISPOSE } from "@xmachines/play";
21
- import { normalizeBasePath } from "./base-path.js";
22
22
  /**
23
23
  * Tells you whether a bridge can move its mount.
24
24
  *
@@ -74,8 +74,13 @@ export function mountKey(basePath, basePathParams) {
74
74
  *
75
75
  * @returns The bridge, and a `close` that disconnects it one time.
76
76
  */
77
- export function openProviderBridge(BridgeCtor, { router, actor, routeMap, basePath, basePathParams }) {
78
- const bridge = new BridgeCtor(router, actor, routeMap, { basePath, basePathParams });
77
+ export function openProviderBridge(BridgeCtor, { router, actor, routeMap, ...options }) {
78
+ // The REST travels whole, rather than two named fields. A bridge takes a base path and
79
+ // the caches of a parse and a compilation, and a provider is the place a server builds
80
+ // one for each request — the case the caches exist for. A destructure of the two
81
+ // base-path fields dropped every cache in silence, so a provider of React, Solid, Vue
82
+ // or TanStack isolated nothing. A rest also carries whatever a later release adds.
83
+ const bridge = new BridgeCtor(router, actor, routeMap, options);
79
84
  // A bridge on the three-argument signature drops the options object, and
80
85
  // `PlayRouterBridgeConstructor` accepts one: it asks for the published `RouterBridge`,
81
86
  // so a consumer bridge that never heard of `basePath` still compiles. Such a bridge
@@ -93,8 +98,8 @@ export function openProviderBridge(BridgeCtor, { router, actor, routeMap, basePa
93
98
  // second refusal here would replace its error with an identical one from another
94
99
  // stack. For a bridge with no mount the normalization can still throw, and a prefix
95
100
  // that it refuses is a prefix all the same — the warning is the answer, not the throw.
96
- if (!isMountableBridge(bridge) && hasPrefix(basePath)) {
97
- console.warn(`[@xmachines/play-router] The provider received basePath "${basePath}", and ${BridgeCtor.name || "the bridge"} takes no mount: it has no setBasePath(), so the prefix is ignored and the bridge claims the whole router. Extend RouterBridgeBase, or drop the basePath prop.`);
101
+ if (!isMountableBridge(bridge) && hasPrefix(options.basePath)) {
102
+ console.warn(`[@xmachines/play-router] The provider received basePath "${options.basePath}", and ${BridgeCtor.name || "the bridge"} takes no mount: it has no setBasePath(), so the prefix is ignored and the bridge claims the whole router. Extend RouterBridgeBase, or drop the basePath prop.`);
98
103
  }
99
104
  void bridge.connect();
100
105
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"provider-lifecycle.js","sourceRoot":"","sources":["../src/provider-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAwB,MAAM,gBAAgB,CAAC;AAwFzE;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAChC,MAAuC;IAEvC,oFAAoF;IACpF,uFAAuF;IACvF,sCAAsC;IACtC,OAAO,MAAM,IAAI,IAAI,IAAI,OAAQ,MAAgC,CAAC,WAAW,KAAK,UAAU,CAAC;AAC9F,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CACvB,QAAsC,EACtC,cAAkD;IAElD,sFAAsF;IACtF,mFAAmF;IACnF,qFAAqF;IACrF,gEAAgE;IAChE,EAAE;IACF,qFAAqF;IACrF,oFAAoF;IACpF,2EAA2E;IAC3E,kFAAkF;IAClF,wDAAwD;IACxD,sFAAsF;IACtF,mFAAmF;IACnF,2EAA2E;IAC3E,mFAAmF;IACnF,qEAAqE;IACrE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;SAClD,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;SAC5D,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;S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