@real-router/core 0.80.0 → 0.82.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 (179) hide show
  1. package/README.md +68 -55
  2. package/dist/cjs/Router-CCmcEi-S.js +2 -0
  3. package/dist/cjs/Router-CCmcEi-S.js.map +1 -0
  4. package/dist/cjs/Router.d.ts +7 -6
  5. package/dist/cjs/Router.d.ts.map +1 -1
  6. package/dist/cjs/Router.js +1 -1
  7. package/dist/cjs/Router.js.map +1 -1
  8. package/dist/cjs/api/getPluginApi.d.ts.map +1 -1
  9. package/dist/cjs/api/getPluginApi.js +1 -1
  10. package/dist/cjs/api/getPluginApi.js.map +1 -1
  11. package/dist/cjs/api/getRoutesApi.d.ts.map +1 -1
  12. package/dist/cjs/api/getRoutesApi.js +1 -1
  13. package/dist/cjs/api/getRoutesApi.js.map +1 -1
  14. package/dist/cjs/api.js +2 -1
  15. package/dist/cjs/api.js.map +1 -1
  16. package/dist/cjs/buildParamMeta-0m11OIJS.js +2 -0
  17. package/dist/cjs/buildParamMeta-0m11OIJS.js.map +1 -0
  18. package/dist/cjs/channels/defaults.js +2 -0
  19. package/dist/cjs/channels/defaults.js.map +1 -0
  20. package/dist/cjs/channels/guard.js +2 -0
  21. package/dist/cjs/channels/guard.js.map +1 -0
  22. package/dist/cjs/channels/modeGate.js +2 -0
  23. package/dist/cjs/channels/modeGate.js.map +1 -0
  24. package/dist/cjs/constants.d.ts.map +1 -1
  25. package/dist/cjs/constants.js +1 -1
  26. package/dist/cjs/constants.js.map +1 -1
  27. package/dist/cjs/createRouter.d.ts +1 -1
  28. package/dist/cjs/createRouter.d.ts.map +1 -1
  29. package/dist/cjs/createRouter.js.map +1 -1
  30. package/dist/cjs/engine/builder/buildTree.js +1 -1
  31. package/dist/cjs/engine/builder/buildTree.js.map +1 -1
  32. package/dist/cjs/engine/path-matcher/SegmentMatcher.d.ts +14 -1
  33. package/dist/cjs/engine/path-matcher/SegmentMatcher.d.ts.map +1 -1
  34. package/dist/cjs/engine/path-matcher/SegmentMatcher.js +1 -1
  35. package/dist/cjs/engine/path-matcher/SegmentMatcher.js.map +1 -1
  36. package/dist/cjs/engine/path-matcher/registration/buildParts.js +1 -1
  37. package/dist/cjs/engine/path-matcher/registration/buildParts.js.map +1 -1
  38. package/dist/cjs/engine/path-matcher/registration/context.js +1 -1
  39. package/dist/cjs/engine/path-matcher/registration/context.js.map +1 -1
  40. package/dist/cjs/engine/path-matcher/registration/errors.js +1 -1
  41. package/dist/cjs/engine/path-matcher/registration/errors.js.map +1 -1
  42. package/dist/cjs/engine/path-matcher/registration/index.js +1 -1
  43. package/dist/cjs/engine/path-matcher/registration/index.js.map +1 -1
  44. package/dist/cjs/engine/path-matcher/registration/trieNodes.js.map +1 -1
  45. package/dist/cjs/engine/path-matcher/types.d.ts +3 -0
  46. package/dist/cjs/engine/path-matcher/types.d.ts.map +1 -1
  47. package/dist/cjs/engine/search-params/strategies/number.js +1 -1
  48. package/dist/cjs/engine/search-params/strategies/number.js.map +1 -1
  49. package/dist/cjs/engine/validation/routes.js +1 -1
  50. package/dist/cjs/engine/validation/routes.js.map +1 -1
  51. package/dist/cjs/helpers.js +1 -1
  52. package/dist/cjs/helpers.js.map +1 -1
  53. package/dist/cjs/index.d.ts +3 -3
  54. package/dist/cjs/index.js +2 -1
  55. package/dist/cjs/index.js.map +1 -1
  56. package/dist/cjs/internals.d.ts +30 -8
  57. package/dist/cjs/internals.d.ts.map +1 -1
  58. package/dist/cjs/internals.js +1 -1
  59. package/dist/cjs/internals.js.map +1 -1
  60. package/dist/cjs/limits.js +2 -0
  61. package/dist/cjs/limits.js.map +1 -0
  62. package/dist/cjs/namespaces/EventBusNamespace/EventBusNamespace.js.map +1 -1
  63. package/dist/cjs/namespaces/NavigationNamespace/NavigationNamespace.js +1 -1
  64. package/dist/cjs/namespaces/NavigationNamespace/NavigationNamespace.js.map +1 -1
  65. package/dist/cjs/namespaces/OptionsNamespace/OptionsNamespace.js.map +1 -1
  66. package/dist/cjs/namespaces/OptionsNamespace/constants.js +1 -1
  67. package/dist/cjs/namespaces/OptionsNamespace/constants.js.map +1 -1
  68. package/dist/cjs/namespaces/OptionsNamespace/helpers.js.map +1 -1
  69. package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.js +1 -1
  70. package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.js.map +1 -1
  71. package/dist/cjs/namespaces/RoutesNamespace/helpers.js +1 -1
  72. package/dist/cjs/namespaces/RoutesNamespace/helpers.js.map +1 -1
  73. package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts +8 -0
  74. package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts.map +1 -1
  75. package/dist/cjs/namespaces/RoutesNamespace/routesStore.js +1 -1
  76. package/dist/cjs/namespaces/RoutesNamespace/routesStore.js.map +1 -1
  77. package/dist/cjs/namespaces/RoutesNamespace/types.d.ts +24 -7
  78. package/dist/cjs/namespaces/RoutesNamespace/types.d.ts.map +1 -1
  79. package/dist/cjs/namespaces/StateNamespace/StateNamespace.js +1 -1
  80. package/dist/cjs/namespaces/StateNamespace/StateNamespace.js.map +1 -1
  81. package/dist/cjs/pipeline/buildURL.js +2 -0
  82. package/dist/cjs/pipeline/buildURL.js.map +1 -0
  83. package/dist/cjs/pipeline/canonicalize.js +2 -0
  84. package/dist/cjs/pipeline/canonicalize.js.map +1 -0
  85. package/dist/cjs/pipeline/materialize.js +2 -0
  86. package/dist/cjs/pipeline/materialize.js.map +1 -0
  87. package/dist/cjs/pipeline/port.d.ts +147 -0
  88. package/dist/cjs/pipeline/port.d.ts.map +1 -0
  89. package/dist/cjs/routerFSM.js +1 -1
  90. package/dist/cjs/routerFSM.js.map +1 -1
  91. package/dist/cjs/transitionPath.js +1 -1
  92. package/dist/cjs/transitionPath.js.map +1 -1
  93. package/dist/cjs/types/RouterValidator.d.ts +14 -0
  94. package/dist/cjs/types/RouterValidator.d.ts.map +1 -1
  95. package/dist/cjs/types/api.d.ts +20 -11
  96. package/dist/cjs/types/api.d.ts.map +1 -1
  97. package/dist/cjs/types/base.d.ts +63 -4
  98. package/dist/cjs/types/base.d.ts.map +1 -1
  99. package/dist/cjs/types/constants.d.ts +1 -0
  100. package/dist/cjs/types/constants.d.ts.map +1 -1
  101. package/dist/cjs/types/router.d.ts +112 -23
  102. package/dist/cjs/types/router.d.ts.map +1 -1
  103. package/dist/cjs/types/tree-changed.d.ts +1 -1
  104. package/dist/cjs/types/tree-changed.d.ts.map +1 -1
  105. package/dist/cjs/types.d.ts +20 -11
  106. package/dist/cjs/types.d.ts.map +1 -1
  107. package/dist/cjs/utils/event-emitter/EventEmitter.js.map +1 -0
  108. package/dist/cjs/utils/fsm/fsm.js.map +1 -0
  109. package/dist/cjs/utils/logger/RouterLogger.js.map +1 -0
  110. package/dist/cjs/utils/logger/constants.js.map +1 -0
  111. package/dist/cjs/validation.js +2 -1
  112. package/dist/cjs/validation.js.map +1 -1
  113. package/dist/cjs/wiring/wireNamespaces.js +1 -1
  114. package/dist/cjs/wiring/wireNamespaces.js.map +1 -1
  115. package/dist/esm/Router-DEpNuwBW.mjs +2 -0
  116. package/dist/esm/Router-DEpNuwBW.mjs.map +1 -0
  117. package/dist/esm/Router.d.mts +7 -6
  118. package/dist/esm/Router.d.mts.map +1 -1
  119. package/dist/esm/api/getPluginApi.d.mts.map +1 -1
  120. package/dist/esm/api/getRoutesApi.d.mts.map +1 -1
  121. package/dist/esm/api.mjs +1 -1
  122. package/dist/esm/api.mjs.map +1 -1
  123. package/dist/esm/buildParamMeta-D8td47fL.mjs +2 -0
  124. package/dist/esm/buildParamMeta-D8td47fL.mjs.map +1 -0
  125. package/dist/esm/constants.d.mts.map +1 -1
  126. package/dist/esm/createRouter.d.mts +1 -1
  127. package/dist/esm/createRouter.d.mts.map +1 -1
  128. package/dist/esm/engine/path-matcher/SegmentMatcher.d.mts +14 -1
  129. package/dist/esm/engine/path-matcher/SegmentMatcher.d.mts.map +1 -1
  130. package/dist/esm/engine/path-matcher/types.d.mts +3 -0
  131. package/dist/esm/engine/path-matcher/types.d.mts.map +1 -1
  132. package/dist/esm/index.d.mts +3 -3
  133. package/dist/esm/index.mjs +1 -1
  134. package/dist/esm/index.mjs.map +1 -1
  135. package/dist/esm/internals.d.mts +30 -8
  136. package/dist/esm/internals.d.mts.map +1 -1
  137. package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts +8 -0
  138. package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts.map +1 -1
  139. package/dist/esm/namespaces/RoutesNamespace/types.d.mts +24 -7
  140. package/dist/esm/namespaces/RoutesNamespace/types.d.mts.map +1 -1
  141. package/dist/esm/pipeline/port.d.mts +147 -0
  142. package/dist/esm/pipeline/port.d.mts.map +1 -0
  143. package/dist/esm/types/RouterValidator.d.mts +14 -0
  144. package/dist/esm/types/RouterValidator.d.mts.map +1 -1
  145. package/dist/esm/types/api.d.mts +20 -11
  146. package/dist/esm/types/api.d.mts.map +1 -1
  147. package/dist/esm/types/base.d.mts +63 -4
  148. package/dist/esm/types/base.d.mts.map +1 -1
  149. package/dist/esm/types/constants.d.mts +1 -0
  150. package/dist/esm/types/constants.d.mts.map +1 -1
  151. package/dist/esm/types/router.d.mts +112 -23
  152. package/dist/esm/types/router.d.mts.map +1 -1
  153. package/dist/esm/types/tree-changed.d.mts +1 -1
  154. package/dist/esm/types/tree-changed.d.mts.map +1 -1
  155. package/dist/esm/types.d.mts +20 -11
  156. package/dist/esm/types.d.mts.map +1 -1
  157. package/dist/esm/validation.mjs +1 -1
  158. package/dist/esm/validation.mjs.map +1 -1
  159. package/package.json +2 -2
  160. package/dist/cjs/Router-DGUed2F4.js +0 -2
  161. package/dist/cjs/Router-DGUed2F4.js.map +0 -1
  162. package/dist/cjs/buildParamMeta-DniluAIV.js +0 -2
  163. package/dist/cjs/buildParamMeta-DniluAIV.js.map +0 -1
  164. package/dist/cjs/foundation/event-emitter/EventEmitter.js.map +0 -1
  165. package/dist/cjs/foundation/fsm/fsm.js.map +0 -1
  166. package/dist/cjs/foundation/logger/RouterLogger.js.map +0 -1
  167. package/dist/cjs/foundation/logger/constants.js.map +0 -1
  168. package/dist/cjs/namespaces/StateNamespace/helpers.js +0 -2
  169. package/dist/cjs/namespaces/StateNamespace/helpers.js.map +0 -1
  170. package/dist/cjs/stateMetaStore.js +0 -2
  171. package/dist/cjs/stateMetaStore.js.map +0 -1
  172. package/dist/esm/Router-Bk6PfSE8.mjs +0 -2
  173. package/dist/esm/Router-Bk6PfSE8.mjs.map +0 -1
  174. package/dist/esm/buildParamMeta-bOLhLF9h.mjs +0 -2
  175. package/dist/esm/buildParamMeta-bOLhLF9h.mjs.map +0 -1
  176. /package/dist/cjs/{foundation → utils}/event-emitter/EventEmitter.js +0 -0
  177. /package/dist/cjs/{foundation → utils}/fsm/fsm.js +0 -0
  178. /package/dist/cjs/{foundation → utils}/logger/RouterLogger.js +0 -0
  179. /package/dist/cjs/{foundation → utils}/logger/constants.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildParamMeta-D8td47fL.mjs","names":["LT","QUESTION","SLASH"],"sources":["../../src/channels/guard.ts","../../src/internals.ts","../../src/engine/path-matcher/parseSegment.ts","../../src/engine/path-matcher/buildParamMeta.ts"],"sourcesContent":["// packages/core/src/channels/guard.ts\n\nimport type { Params } from \"../types\";\n\n/**\n * THE predicate of the always-on channel guard: the first key the caller put in\n * the PATH bag while the route declares it as a QUERY param, or `undefined`\n * when the bag is channel-correct.\n *\n * A DETECTOR, not a normaliser — the key is never moved. Moving it is what\n * `separateChannels` (stage ②) used to do — a function that no longer exists.\n * Channel-correctness is the producer's contract now, not a repair the pipeline\n * performs behind everyone's back.\n *\n * Scans `queryNames` (a route's declared query names — small, cached) rather\n * than the bag, so there is no `Object.keys` allocation, and short-circuits on\n * a route with no query declarations, which is the common case.\n *\n * `undefined` is absence on both sides (#1550 / #1551), so an\n * `undefined`-valued key is NOT a mis-channel: it is the documented removal\n * marker `persistent-params` relies on, and it never reaches a built state\n * anyway. A name that also occupies a path slot (`/items/:id?id`) is absent\n * from `queryNames` by construction (#843 / #1549 carve-out), so the collision\n * form is legitimately path-owned and passes.\n *\n * @internal\n */\nexport function findMisChanneledKey(\n params: Params | undefined,\n queryNames: readonly string[],\n): string | undefined {\n if (queryNames.length === 0 || params === undefined) {\n return undefined;\n }\n\n for (const key of queryNames) {\n if (!Object.hasOwn(params, key)) {\n continue;\n }\n\n let value: unknown;\n\n try {\n value = params[key];\n } catch {\n // A DIAGNOSTIC must never become the thing that throws. The bag may be\n // backed by accessors (a Proxy, a getter, a framework's reactive object),\n // and reading one here happens EARLIER than any consumer would have read\n // it — so an accessor that throws would surface from the guard instead of\n // from the code that actually needed the value, moving the origin of an\n // existing failure. Treat it as \"nothing to report\" and let the real\n // consumer hit the same accessor exactly as it did before.\n return undefined;\n }\n\n if (value !== undefined) {\n return key;\n }\n }\n\n return undefined;\n}\n\n/**\n * THE centralized channel check — the single place a mis-channelled bag is\n * refused, wherever it came from.\n *\n * Replaces the repair `separateChannels` (stage ②, since deleted) used to\n * perform at the `forwardState` seam. A key the route declares with `?`, sitting in the PATH\n * bag, is a producer's mistake — the producer named the route, so it knows the\n * declaration — and the router now says so instead of quietly moving the field\n * into the other object. Moving it was invisible: the caller kept believing\n * their bag was the one that shipped, and two producers of the SAME intent\n * could disagree about which channel a key ended up in.\n *\n * `source` names WHOSE bag is wrong, which is the whole diagnostic value at a\n * seam: the caller's argument, a `forwardState` interceptor's return, or the\n * output of a route's own `decodeParams`. It takes a THUNK as well as a string\n * because the seam sits on the navigation hot path — a source that has to be\n * composed (naming the route a chain forwarded from) must not build its string\n * on every call just to discard it on the 99.99% of calls that pass.\n *\n * @internal\n */\nexport function assertChannelCorrect(\n method: string,\n routeName: string,\n params: Params | undefined,\n queryNames: readonly string[],\n source?: string | (() => string),\n remedy?: string,\n): void {\n const key = findMisChanneledKey(params, queryNames);\n\n if (key !== undefined) {\n throw new TypeError(\n `[router.${method}] ${misChanneledKeyMessage(\n routeName,\n key,\n typeof source === \"function\" ? source() : source,\n remedy,\n )}`,\n );\n }\n}\n\n/**\n * The guard's actionable message. One builder for every position, so the\n * wording a user sees does not depend on which door they came through — the\n * facade's `TypeError`, the seam's, the decoder's, and `navigateToState`'s\n * `RouterError(WRONG_CHANNEL)`, which needs the wording WITHOUT the throw and is\n * why this is a separate function from {@link assertChannelCorrect}.\n *\n * @internal\n */\nexport function misChanneledKeyMessage(\n routeName: string,\n key: string,\n source = \"the `params` argument\",\n remedy = \"Pass it in `search` instead\",\n): string {\n return `Route \"${routeName}\" declares \\`${key}\\` as a query param, but it was given in ${source} — the path channel. ${remedy}; the two channels are separate since RFC-4 M2 and the router never moves a key between them.`;\n}\n","import { assertChannelCorrect } from \"./channels\";\n\nimport type { RouteTree } from \"./engine\";\nimport type { DependenciesStore } from \"./namespaces\";\nimport type { RoutesStore } from \"./namespaces/RoutesNamespace\";\nimport type { RouteResolver } from \"./pipeline\";\nimport type { Router as RouterClass } from \"./Router\";\nimport type {\n AnyOptions,\n DefaultDependencies,\n EventName,\n LoggerConfig,\n NavigationOptions,\n Options,\n Params,\n Plugin,\n Router as RouterInterface,\n RouterLogger,\n RouteTreeState,\n SearchParams,\n SerializedRouterState,\n SimpleState,\n State,\n TreeChangedEvent,\n Unsubscribe,\n EventMethodMap,\n PluginFactory,\n} from \"./types\";\nimport type { RouterValidator } from \"./types/RouterValidator\";\n\nexport interface RouterInternals<\n D extends DefaultDependencies = DefaultDependencies,\n> {\n readonly makeState: <\n P extends Params = Params,\n S extends SearchParams = SearchParams,\n >(\n name: string,\n params?: P,\n search?: S,\n path?: string,\n ) => State<P, S>;\n\n /**\n * Per-segment param-source map for a route name (`{ segment: { param: \"url\" |\n * \"query\" } }`), read from the live matcher — the ownership channel for\n * `getTransitionPath` (RFC-4 M2 / #1548, replaced the removed per-State\n * `stateMetaStore` WeakMap). `undefined` when the name is not in the tree.\n */\n readonly getMetaForState: (\n name: string,\n ) => Record<string, Record<string, \"url\" | \"query\">> | undefined;\n\n /**\n * The route's DECLARED query-param names — the same registry the URL build\n * prints from (#1556), minus path slots. Feeds the always-on channel guard\n * (#1572); read here rather than re-derived, so classification cannot drift.\n */\n readonly getQueryParams: (name: string) => readonly string[];\n\n readonly forwardState: <\n P extends Params = Params,\n S extends SearchParams = SearchParams,\n >(\n routeName: string,\n routeParams: P,\n routeSearch?: S,\n ) => SimpleState<P, S>;\n\n readonly buildStateResolved: (\n resolvedName: string,\n resolvedParams: Params,\n ) => RouteTreeState | undefined;\n\n readonly matchPath: <P extends Params = Params>(\n path: string,\n options?: AnyOptions,\n ) => State<P> | undefined;\n\n readonly getOptions: () => Options<D>;\n\n readonly addEventListener: <E extends EventName>(\n eventName: E,\n cb: Plugin[EventMethodMap[E]],\n ) => Unsubscribe;\n\n /**\n * Route-tree mutation channel — internal access for the `getRoutesApi`\n * wrapper. A dedicated bridge is required because the public\n * `addEventListener<E extends EventName>` structurally rejects\n * `\"TREE_CHANGED\"` (it is not in the public `EventName` union), is strict on\n * duplicates, and exposes neither `emit` nor `listenerCount`.\n */\n readonly treeChanged: {\n readonly emit: (event: TreeChangedEvent) => void;\n readonly subscribe: (\n handler: (event: TreeChangedEvent) => void,\n ) => Unsubscribe;\n readonly listenerCount: () => number;\n /**\n * True while a `TREE_CHANGED` emit is on the stack — `getRoutesApi` reads it\n * to reject reentrant route-CRUD from a `subscribeChanges` handler (#1032).\n */\n readonly isEmitting: () => boolean;\n };\n\n readonly buildPath: (\n route: string,\n params?: Params,\n search?: SearchParams,\n ) => string;\n\n /**\n * The navigation pipeline's read-model, for entry points that live on this\n * plugin-facing surface rather than in a namespace. Resolved LAZILY: the port\n * is created during wiring, and `registerInternals` runs before that, so the\n * accessor is a closure rather than a value — the same shape the interceptable\n * methods above already use.\n */\n readonly port: () => RouteResolver;\n\n readonly emitTransitionError: (error: Error) => void;\n\n /**\n * Emits `TRANSITION_SUCCESS` directly (no FSM transition) — used by\n * `getRoutesApi().replace()` to notify `router.subscribe` listeners when a\n * structural replace revalidates the active state (#950). Mirrors the success\n * emission `completeTransition` / `navigateToNotFound` perform.\n */\n readonly emitTransitionSuccess: (\n toState: State,\n fromState: State | undefined,\n opts?: NavigationOptions,\n ) => void;\n\n /**\n * Commits the not-found (`UNKNOWN_ROUTE`) state for `path` and emits\n * `TRANSITION_SUCCESS` — the `NavigationNamespace.navigateToNotFound`\n * primitive. `replace()` uses it when a structural replace drops the active\n * route, so subscribers are notified instead of the state silently clearing\n * (#950).\n */\n readonly navigateToNotFound: (path: string) => State;\n\n readonly start: (path: string) => Promise<State>;\n\n /**\n * Plugin-only navigation entry point — delegates to\n * `NavigationNamespace.navigateToState` (`getPluginApi(router).navigateToState`).\n * Hidden from `Router`/`Navigator` to keep the userland surface minimal;\n * see `core-types/src/api.ts` for usage docs.\n */\n readonly navigateToState: (\n state: State,\n options?: NavigationOptions,\n ) => Promise<State>;\n\n /* eslint-disable @typescript-eslint/no-explicit-any -- heterogeneous map: stores different InterceptorFn<M> types under different keys */\n readonly interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n readonly setRootPath: (rootPath: string) => void;\n readonly getRootPath: () => string;\n\n readonly getTree: () => RouteTree;\n\n readonly isDisposed: () => boolean;\n\n validator: RouterValidator | null;\n\n // Per-router logger instance (built from `options.logger` in the Router\n // constructor). The facade reads it as `getInternals(this).logger`; namespaces\n // receive it via their deps at wiring; plugins reach it through\n // `getPluginApi(router).logger`. Replaces the former process-global singleton\n // from the standalone `@real-router/logger` package (now folded into\n // `utils/logger`), whose `configure()` leaked across routers (#724).\n readonly logger: RouterLogger;\n\n // Dependencies (issue #172)\n readonly dependenciesGetStore: () => DependenciesStore<D>;\n\n // Clone support (issue #173, consolidated #964). One accessor for the\n // source-side snapshot a clone carries over besides the route store, so a new\n // clone-relevant subsystem is wired in a single place instead of being spread\n // across separate methods.\n readonly getCloneState: () => {\n options: Options<D>;\n dependencies: Record<string, unknown>;\n pluginFactories: PluginFactory<D>[];\n // Resolved logger config of the base router, so a clone can build its OWN\n // logger inheriting the base's level/callback. Frozen `options` do NOT carry\n // `logger` (stripped in the constructor), so `options` above can't convey it;\n // cloneRouter merges a per-request override (traceId) over this snapshot.\n loggerConfig: LoggerConfig;\n };\n\n // Consolidated route data store (issue #174 Phase 2)\n readonly routeGetStore: () => RoutesStore<D>;\n\n // Cross-namespace state (issue #174)\n readonly getStateName: () => string | undefined;\n readonly isTransitioning: () => boolean;\n readonly clearState: () => void;\n readonly setState: (state: State) => void;\n readonly routerExtensions: { keys: string[] }[];\n readonly contextClaimRecords: Set<string>;\n\n /**\n * One-shot hydration scratchpad populated by `hydrateRouter` immediately\n * before delegating to `router.start(parsed.path)` and cleared in the\n * matching `finally`. SSR loader plugins read this slot directly via\n * `getInternals(router).hydrationState` to short-circuit their own loader\n * call when the server-resolved namespace value is already present in the\n * parsed state (#596). `null` outside of an active `hydrateRouter`\n * invocation.\n */\n hydrationState: SerializedRouterState | null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- existential type: stores RouterInternals for all Dependencies types\nconst internals = new WeakMap<object, RouterInternals<any>>();\n\nexport function getInternals<D extends DefaultDependencies>(\n router: RouterInterface<D>,\n): RouterInternals<D> {\n const ctx = internals.get(router);\n\n if (!ctx) {\n throw new TypeError(\n \"[real-router] Invalid router instance — not found in internals registry\",\n );\n }\n\n return ctx as RouterInternals<D>;\n}\n\n/**\n * Channel guard, position P1 (#1572) — the caller's RAW `params` argument, at\n * the API boundary and BEFORE any interceptor runs, so what it reports is what\n * the CALLER wrote (a plugin's later injection is P2's population, not this one).\n *\n * THROWS. The warn-first step (#1572) announced the contract so every call site\n * could identify itself in the logs; this is the promotion it announced.\n *\n * A `TypeError`, synchronous, rather than a `RouterError` on a rejected promise:\n * this is an ARGUMENT-shape defect at the API boundary, caught before any\n * interceptor or transition exists — the same class as the `subscribe` /\n * `navigateToNotFound` / `start` guards beside it. Rejecting instead would let a\n * `.catch()` written for navigation failures swallow a programming error.\n *\n * P3 (`navigateToState`) keeps REJECTING — deliberately asymmetric, because it\n * takes a ready-made `State` from a popstate handler, where a new synchronous\n * throw would change an existing method's failure shape.\n *\n * The predicates (`buildPath` / `isActiveRoute` / `canNavigateTo`) are still NOT\n * instrumented: they run on every `<Link>` render, an answer there is read\n * immediately and corrupts nothing, and throwing inside a render in six adapters\n * is not a trade this guard is worth.\n *\n * ⚠ Not instrumented ≠ blind. `canNavigateTo` answers whether `navigate` WOULD\n * work, so it consults {@link findMisChanneledKey} directly and returns `false`\n * for a shape this function would have thrown on (#1576) — an answer, not a\n * throw, so the render-path trade above is untouched. `buildPath` /\n * `isActiveRoute` ask a different question and are unchanged.\n *\n * @internal\n */\nexport function throwOnMisChanneledKey<D extends DefaultDependencies>(\n ctx: RouterInternals<D>,\n method: string,\n routeName: string,\n params: Params | undefined,\n): void {\n assertChannelCorrect(\n method,\n routeName,\n params,\n ctx.getQueryParams(routeName),\n );\n}\n\nexport function registerInternals<D extends DefaultDependencies>(\n router: RouterClass<D>,\n ctx: RouterInternals<D>,\n): void {\n internals.set(router, ctx);\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument -- internal chain execution: type safety enforced at public API boundary (PluginApi.addInterceptor) */\nfunction executeInterceptorChain<T>(\n interceptors: ((next: (...args: any[]) => any, ...args: any[]) => any)[],\n original: (...args: any[]) => T,\n args: any[],\n): T {\n let chain = original as (...args: any[]) => any;\n\n for (const interceptor of interceptors) {\n const prev = chain;\n\n chain = (...chainArgs: any[]) => interceptor(prev, ...chainArgs);\n }\n\n return chain(...args) as T;\n}\n\n/**\n * Variadic interceptor wrapper — wraps a function of any arity, returning the\n * same callable type `T`. Use {@link createTernaryInterceptable} instead when\n * the wrapped method takes exactly three args and the caller needs the precise\n * `(a, b, c) => r` signature preserved (the variadic form widens args to\n * `any[]`).\n */\nexport function createInterceptable<T extends (...args: any[]) => any>(\n name: string,\n original: T,\n interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >,\n): T {\n return ((...args: any[]) => {\n const chain = interceptors.get(name);\n\n if (!chain || chain.length === 0) {\n return original(...args);\n }\n\n return executeInterceptorChain(chain, original, args);\n }) as T;\n}\n\n/**\n * Three-argument interceptor wrapper — preserves the exact\n * `(a: A, b: B, c: C) => R` signature that the variadic\n * {@link createInterceptable} widens to `any[]`. Backs both search-aware\n * interceptables — `buildPath(route, params, search)` and\n * `forwardState(name, params, search)` (RFC-4 M2 / #1548). Every first-party\n * plugin registers the full three-argument form; a shorter-arity interceptor\n * from a third party remains type-valid (TS allows fewer params, and `next(a,\n * b)` leaves the third arg `undefined`).\n */\nexport function createTernaryInterceptable<A, B, C, R>(\n name: string,\n original: (a: A, b: B, c: C) => R,\n interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >,\n): (a: A, b: B, c: C) => R {\n return (arg1: A, arg2: B, arg3: C) => {\n const chain = interceptors.get(name);\n\n if (!chain || chain.length === 0) {\n return original(arg1, arg2, arg3);\n }\n\n return executeInterceptorChain(chain, original, [arg1, arg2, arg3]);\n };\n}\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument */\n","/**\n * Canonical route-segment tokenizer.\n *\n * The single owner of \"where does a name / marker / constraint end\" for ONE\n * path segment (post-`/`-split). It replaces the five name-boundary compositions\n * of `PARAM_NAME_PATTERN` currently spread across `buildParamMeta` (L1),\n * `registration` (L2 build + L3 trie), and `route-tree`'s validation gate (L4),\n * so those layers can never disagree on a boundary (the gate↔backstop drift\n * class — #858 / #1050 / #1150 / #1311 / #1149 / #1324).\n *\n * A single left-to-right `charCodeAt` scan produces either a token tuple or a\n * typed error. Grammar — **3 tokens only** (`static | :param | *splat`); the\n * grammar has no optional `:x?` or `<re>` constraint forms. Any `<`/`>` or a\n * post-name `?` in the path is a *registration error* carrying a replacement\n * recipe (`optional-removed` / `constraint-removed`), not a token:\n * 1. Leading `:`/`*` → param/splat; otherwise `static` (a marker glued *after* a\n * static prefix ⇒ `fused-marker`; any `<`/`>` (a former constraint) ⇒\n * `constraint-removed`; a trailing `?` on a marker-less segment ⇒ `name-less`\n * — the modifier has no param name, #1241 / `/faq?`).\n * 2. name = any char except `<`/`?` (no `/` remains inside a segment); a name\n * ending in a bare `:`/`*` ⇒ `trailing-marker` (#1324). A *mid* marker stays\n * a name char — `:a:b` → name `a:b`, preserved.\n * 3. empty name ⇒ `name-less` (#858).\n * 4. a `<` after the name (a former `<re>` constraint) ⇒ `constraint-removed`.\n * 5. a post-name `?` (a former optional modifier, on `:param` or `*splat`) ⇒\n * `optional-removed`.\n *\n * @module parseSegment\n */\n\n/* eslint-disable unicorn/prefer-code-point, unicorn/prefer-includes-over-repeated-comparisons, sonarjs/cognitive-complexity -- charCodeAt code-unit scan + a single inlined branchy pass are this RFC's char-scan perf basis (§9); the same deliberate choices as registration/trie.ts hasNonAsciiSegment (#1285) and SegmentMatcher's inlined #traverseFrom. A `[LT,GT,QUESTION].includes(code)` boundary check would allocate an array literal per scanned char. Markers compared are ASCII (`:` `*` `<` `>` `?`, < 0x80). */\n\n/** A successfully tokenized segment (3-token grammar: `static | :param | *splat`). */\nexport type SegmentTokens =\n | { readonly kind: \"static\"; readonly text: string }\n | { readonly kind: \"param\"; readonly name: string }\n | { readonly kind: \"splat\"; readonly name: string };\n\n/** Grammar-shape rejections, each mirroring a registration guard. */\nexport type SegmentErrorCode =\n | \"name-less\" // #858 — a marker with no name\n | \"trailing-marker\" // #1324 — a param name ending in a bare `:`/`*`\n | \"fused-marker\" // #1050 — a marker glued after a static prefix\n | \"optional-removed\" // M1 — a `:x?`/`*x?` optional modifier (removed; two sibling routes)\n | \"constraint-removed\"; // M1 — a `<re>` constraint or stray `<`/`>` (removed; validate in a guard)\n\nexport interface SegmentError {\n readonly error: SegmentErrorCode;\n}\n\nconst COLON = 58; // :\nconst STAR = 42; // *\nconst LT = 60; // <\nconst GT = 62; // >\nconst QUESTION = 63; // ?\nconst SLASH = 47; // /\n\nconst isMarker = (code: number): boolean => code === COLON || code === STAR;\n\n/**\n * Splits a path into its `/`-delimited segments. A plain `/`-split (M1): the\n * 3-token grammar has no `<...>` constraint whose body could legally contain a\n * `/`, so no constraint-awareness is needed — a stray `<`/`>` is a\n * `constraint-removed` error, caught per segment by `parseSegment`. This is the\n * **segmentation** half of the path-grammar unification: `parseSegment` owns the\n * per-segment grammar, `splitPathSegments` owns where a segment begins and ends.\n *\n * @param path - a route path (query already stripped by the caller)\n * @returns the segments in order, including empty leading/trailing/`//` segments\n * (the caller skips empties, matching the current behaviour)\n */\nexport function splitPathSegments(path: string): string[] {\n const segments: string[] = [];\n let start = 0;\n\n for (let i = 0; i < path.length; i += 1) {\n if (path.charCodeAt(i) !== SLASH) {\n continue;\n }\n\n segments.push(path.slice(start, i));\n start = i + 1;\n }\n\n segments.push(path.slice(start));\n\n return segments;\n}\n\n/**\n * Tokenizes a single path segment (already split on `/`).\n *\n * @param segment - one `/`-delimited segment of a route path\n * @returns the segment's tokens, or a typed grammar error\n */\nexport function parseSegment(segment: string): SegmentTokens | SegmentError {\n const length = segment.length;\n\n if (length === 0) {\n return { kind: \"static\", text: \"\" };\n }\n\n // ---- static segment (no leading marker) -------------------------------\n if (!isMarker(segment.charCodeAt(0))) {\n for (let i = 0; i < length; i += 1) {\n const code = segment.charCodeAt(i);\n\n // A `<`/`>` (a former `<re>` constraint or a stray delimiter) is no longer\n // grammar — M1 removed constraints. Reject with the constraint recipe.\n if (code === LT || code === GT) {\n return { error: \"constraint-removed\" };\n }\n\n // A marker glued after a static prefix is extracted as a param by build/meta\n // but compiled as a static literal by the trie (#1050) — reject it as fused.\n // A marker ENDING the segment (a static ending in `:`/`*` — `/a:`, `/a*`, F2)\n // is NOT fused: caught by `i + 1 < length` being false. Every other following\n // char is fused — including a `?` (`a:?`): that shape never reaches the\n // tokenizer through a real path (a `?` after a bare marker is not a valid\n // `:name?` form, so the query mask strips it before `/`-segmentation), so a\n // direct call correctly reports fused-marker. (`a<`/`a>` already returned\n // `constraint-removed` above, so no `<`-follows exception is needed here.)\n if (isMarker(code) && i + 1 < length) {\n return { error: \"fused-marker\" };\n }\n }\n\n // A trailing `?` is a former optional modifier; on a marker-less segment (no\n // param name) it is a modifier-with-no-name — name-less (#858/#1241, `/faq?`),\n // NOT `optional-removed` (there is no param to route to two siblings). The\n // backstop rejects it by the SAME rule: its `endsWith(\"?\")` fork routes the\n // segment to `extractParamName` → this tokenizer. Owning the `?` here (not\n // only in the marker branch) is what lets the gate and backstop agree on it —\n // otherwise the gate reads `faq?` as a valid static (#1324 §4).\n if (segment.charCodeAt(length - 1) === QUESTION) {\n return { error: \"name-less\" };\n }\n\n return { kind: \"static\", text: segment };\n }\n\n const splat = segment.charCodeAt(0) === STAR;\n\n // ---- name: up to the first `<`/`>` (former constraint delimiter, reserved —\n // В1.3) or `?` (former optional). A segment holds no `/`. -----------------\n let cursor = 1;\n\n while (cursor < length) {\n const code = segment.charCodeAt(cursor);\n\n if (code === LT || code === GT || code === QUESTION) {\n break;\n }\n\n cursor += 1;\n }\n\n const name = segment.slice(1, cursor);\n\n if (name.length === 0) {\n return { error: \"name-less\" }; // #858\n }\n\n if (isMarker(name.charCodeAt(name.length - 1))) {\n return { error: \"trailing-marker\" }; // #1324\n }\n\n // ---- former constraint / optional modifiers (removed in M1) ------------\n // The name scan stops at the first `<`/`>` or `?`. Either is a form removed\n // in M1: a `<re>` constraint (also a stray `<`/`>` — В1.3), or a `:x?`/`*x?`\n // optional. Only `?` is the optional; `<`/`>` are the constraint recipe.\n // Reject with the matching replacement recipe rather than tokenize it.\n if (cursor < length) {\n return segment.charCodeAt(cursor) === QUESTION\n ? { error: \"optional-removed\" }\n : { error: \"constraint-removed\" }; // LT or GT\n }\n\n return splat ? { kind: \"splat\", name } : { kind: \"param\", name };\n}\n\n/**\n * Returns the first per-segment grammar error in a path, or `undefined` if every\n * segment tokenizes cleanly.\n *\n * The **validation-facing** entry over the tokenizer: `route-tree`'s\n * `validateRoutePath` calls this instead of re-running its own split+parse loop,\n * so the gate and the matcher's own grammar cannot drift (#1324) and the loop\n * stays single-sourced here — the tokenizer primitives (`parseSegment`,\n * `splitPathSegments`) need not leak into the package's public surface. An empty\n * segment tokenizes as `static` (never an error), so leading/trailing/`//`\n * empties are skipped naturally.\n *\n * @param path - a route path (query already stripped by the caller)\n * @returns the first `SegmentErrorCode` (scanned left to right), or `undefined`\n */\nexport function findSegmentGrammarError(\n path: string,\n): SegmentErrorCode | undefined {\n for (const segment of splitPathSegments(path)) {\n const token = parseSegment(segment);\n\n if (\"error\" in token) {\n return token.error;\n }\n }\n\n return undefined;\n}\n\n/** A removed-form (M1) match, describing the offending segment and — for an\n * optional — the two sibling paths that replace it (path without the optional\n * segment + path with the param made required). The route-tree gate uses this to\n * build a route-contextual replacement recipe; the matcher backstop uses only the\n * error code (a shorter, path-free recipe). */\nexport type RemovedForm =\n | {\n readonly code: \"optional-removed\";\n readonly segment: string;\n readonly withoutSegment: string;\n readonly requiredForm: string;\n }\n | { readonly code: \"constraint-removed\"; readonly segment: string };\n\n/**\n * The rich (route-tree gate) view over the tokenizer for a removed form: finds\n * the first `optional-removed` / `constraint-removed` segment and, for an\n * optional, computes its two replacement sibling paths from the ACTUAL path\n * (dropping the segment → without-form; dropping the trailing `?` → required\n * form). Returns `undefined` if no removed form is present (the gate then uses\n * `findSegmentGrammarError` for a surviving grammar rejection).\n *\n * @param path - a route path (query already stripped by the caller)\n */\nexport function describeRemovedForm(path: string): RemovedForm | undefined {\n const segments = splitPathSegments(path);\n\n for (let i = 0; i < segments.length; i += 1) {\n const token = parseSegment(segments[i]);\n\n if (!(\"error\" in token)) {\n continue;\n }\n\n // First error wins (mirrors `findSegmentGrammarError`): describe it ONLY if\n // it is a removed form, else return undefined so the caller falls to the\n // surviving-code message — this keeps the gate's reason in lockstep with the\n // matcher backstop's first-error verdict.\n if (token.error === \"optional-removed\") {\n const segment = segments[i];\n const required = [...segments];\n\n // Drop the `?` optional modifier AND everything after it (the tokenizer\n // stopped the name at the first `?`, so it is the modifier). Using the `?`\n // index — not a blind `slice(0, -1)` — keeps the required sibling VALID for\n // a reverse/compound form whose `?` is not the last char: `:b?<x>` → `:b`\n // (not `:b?<x`), `:id??` → `:id` (not `:id?`). #1516\n required[i] = segment.slice(0, segment.indexOf(\"?\"));\n\n return {\n code: \"optional-removed\",\n segment,\n withoutSegment: segments.filter((_, j) => j !== i).join(\"/\"),\n requiredForm: required.join(\"/\"),\n };\n }\n\n return token.error === \"constraint-removed\"\n ? { code: \"constraint-removed\", segment: segments[i] }\n : undefined;\n }\n\n return undefined;\n}\n","/**\n * Route Parameter Metadata Extraction.\n *\n * Extracts parameter metadata from route path patterns without requiring\n * a full path-parser instance. Replaces parser.urlParams/queryParams/spatParams.\n *\n * @module buildParamMeta\n */\n\nimport { parseSegment, splitPathSegments } from \"./parseSegment\";\n\nimport type { ParamMeta } from \"./types\";\n\n/**\n * A query-param NAME may not contain `<`/`>` (#1242 §5.1) — a constraint\n * delimiter leaked into the query via a reverse-order modifier typo (`/a/:b?<c>`\n * parses the `?` as the query start, making `<c>` the query name). Consumed by\n * the route-tree gate and the `registerTree` backstop; relocated here from the\n * deleted `constraint-grammar.ts` when M1 removed constraints (query-param name\n * validation is a query concern, and this module owns query extraction).\n */\nexport const INVALID_QUERY_NAME_RGX = /[<>]/u;\n\nconst QUESTION = 0x3f; // ?\nconst SLASH = 0x2f; // /\nconst LT = 0x3c; // <\n\n/**\n * Locates the query separator `?` in a route path — the FIRST `?` whose tail is\n * non-empty and does not begin with `/`, `?`, or `<` (M1 §3.3). The 3-token\n * grammar leaves `?` a single role (there is no optional modifier and no\n * constraint body to hide one), so no length-preserving mask is needed. The three\n * excluded tails keep a REMOVED form in the path part, where `parseSegment`\n * rejects it with a recipe instead of mis-reading it as a query declaration:\n * - end-of-string (`/:id?`) and `/` (`/:id?/edit`) → a bare `:x?` optional;\n * - `?` (`/:id??tab`) → the leading `?` is the optional, the later `?` the query;\n * - `<` (`/a/:b?<x>`) → a reverse-order `:b?<x>` (optional then a former constraint).\n *\n * @param path - a route path\n * @returns the index of the query separator, or -1 if there is none\n */\nfunction findQuerySeparator(path: string): number {\n for (let i = 0; i < path.length; i += 1) {\n if (path.codePointAt(i) !== QUESTION) {\n continue;\n }\n\n // `next` is the code point after the `?`, or the `-1` sentinel at end-of-string.\n // The `-1` sentinel is the SOLE end-of-string guard — the former separate\n // `next !== undefined` conjunct was dead (the ternary bounds the index, so\n // `codePointAt` never returns `undefined`; the `!` is a type assertion, not a\n // runtime branch, so it keeps the scan at 100% coverage). Mirrors `#scanPath`.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- ternary-bounded in-range index; codePointAt is defined\n const next = i + 1 < path.length ? path.codePointAt(i + 1)! : -1;\n\n if (next !== -1 && next !== SLASH && next !== QUESTION && next !== LT) {\n return i;\n }\n }\n\n return -1;\n}\n\n/**\n * Builds parameter metadata from a route path pattern.\n *\n * Extracts URL parameters, query parameters, and splat parameters\n * from the path pattern string.\n *\n * @param path - Route path pattern (e.g., \"/users/:id/posts/:postId?q\")\n * @returns Parameter metadata object\n *\n * @example\n * ```typescript\n * buildParamMeta(\"/users/:id\")\n * // → { urlParams: [\"id\"], queryParams: [], spatParams: [], paramTypeMap: { id: \"url\" } }\n *\n * buildParamMeta(\"/search?q&page\")\n * // → { urlParams: [], queryParams: [\"q\", \"page\"], spatParams: [],\n * // paramTypeMap: { q: \"query\", page: \"query\" } }\n *\n * buildParamMeta(\"/files/*path\")\n * // → { urlParams: [\"path\"], queryParams: [], spatParams: [\"path\"],\n * // paramTypeMap: { path: \"url\" } }\n * ```\n */\n// Shared frozen sentinels for the common no-params case — avoid a fresh empty\n// array/object per route (#1009). ParamMeta fields are Readonly*; match/build\n// only read them, and computeCaches' Object.freeze on the arrays/object is a\n// no-op on an already-frozen shared instance.\nconst EMPTY_PARAM_NAMES: readonly string[] = Object.freeze([]);\nconst EMPTY_PARAM_TYPE_MAP: Readonly<Record<string, \"url\" | \"query\">> =\n Object.freeze({});\n\n// Whole-meta shared sentinel for the fully-static case: every collection is a\n// #1009 sentinel AND pathPattern degenerates to the input path itself (no query\n// to strip), so the wrapper carries zero per-route information. The RETAINING\n// caller (route-tree's computeCaches) swaps a matching fresh result for this\n// instance — buildParamMeta itself keeps returning fresh objects so the\n// validation gate can read the real pathPattern of arbitrary input paths.\n// `pathPattern` is \"\" here; the one stored-meta reader (`registerNode`) falls\n// back to `node.path` on identity match.\nexport const EMPTY_PARAM_META: ParamMeta = Object.freeze({\n urlParams: EMPTY_PARAM_NAMES,\n queryParams: EMPTY_PARAM_NAMES,\n spatParams: EMPTY_PARAM_NAMES,\n paramTypeMap: EMPTY_PARAM_TYPE_MAP,\n pathPattern: \"\",\n});\n\n/**\n * Extracts URL/splat params from a path's segments into the given accumulators\n * via the canonical `parseSegment` tokenizer. Split out of `buildParamMeta` so\n * the builder stays under the cognitive-complexity budget. A malformed segment\n * (token errors) or a `static` segment contributes nothing — a malformed route is\n * rejected downstream before it compiles, so its meta is moot.\n */\nfunction collectUrlParams(\n path: string,\n urlParams: string[],\n spatParams: string[],\n paramTypeMap: Record<string, \"url\" | \"query\">,\n): void {\n for (const segment of splitPathSegments(path)) {\n if (segment.length === 0) {\n continue;\n }\n\n const token = parseSegment(segment);\n\n if (\"error\" in token || token.kind === \"static\") {\n continue;\n }\n\n urlParams.push(token.name);\n paramTypeMap[token.name] = \"url\";\n\n if (token.kind === \"splat\") {\n spatParams.push(token.name);\n }\n }\n}\n\nexport function buildParamMeta(path: string): ParamMeta {\n const urlParams: string[] = [];\n const queryParams: string[] = [];\n const spatParams: string[] = [];\n const paramTypeMap: Record<string, \"url\" | \"query\"> = {};\n\n // Locate the real query separator (M1 §3.3: first `?` whose tail is not a\n // former optional/reverse form).\n const separator = findQuerySeparator(path);\n\n if (separator !== -1) {\n const queryString = path.slice(separator + 1);\n const params = queryString.split(\"&\");\n\n for (const param of params) {\n const paramName = param.trim();\n\n if (paramName.length > 0) {\n queryParams.push(paramName);\n paramTypeMap[paramName] = \"query\";\n }\n }\n\n path = path.slice(0, separator);\n }\n\n collectUrlParams(path, urlParams, spatParams, paramTypeMap);\n\n return shareEmptyCollections(\n urlParams,\n queryParams,\n spatParams,\n paramTypeMap,\n path,\n );\n}\n\n// #1009: swap each freshly-built empty collection for a shared frozen sentinel\n// — factored out of buildParamMeta so the hot builder stays under the cognitive-\n// complexity budget. match/build only read these (Readonly*), and computeCaches'\n// Object.freeze is a no-op on an already-frozen shared instance.\nfunction shareEmptyCollections(\n urlParams: string[],\n queryParams: string[],\n spatParams: string[],\n paramTypeMap: Record<string, \"url\" | \"query\">,\n pathPattern: string,\n): ParamMeta {\n return {\n urlParams: urlParams.length === 0 ? EMPTY_PARAM_NAMES : urlParams,\n queryParams: queryParams.length === 0 ? EMPTY_PARAM_NAMES : queryParams,\n spatParams: spatParams.length === 0 ? EMPTY_PARAM_NAMES : spatParams,\n paramTypeMap:\n urlParams.length === 0 && queryParams.length === 0\n ? EMPTY_PARAM_TYPE_MAP\n : paramTypeMap,\n pathPattern,\n };\n}\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/constants.ts"],"mappings":";;KAWY;KAEA,YAAY,OAAO;KAMnB,aAAa,OAAO,eAAe;;;;;;cAOlC,YAAY;;;;;cAqBZ;cAEA,WAAW;;;;;cAsBX,QAAQ"}
1
+ {"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/constants.ts"],"mappings":";;KAWY;KAEA,YAAY,OAAO;KAMnB,aAAa,OAAO,eAAe;;;;;;cAOlC,YAAY;;;;;cAsBZ;cAEA,WAAW;;;;;cAsBX,QAAQ"}
@@ -17,7 +17,7 @@ import { Router } from "./Router.mjs";
17
17
  *
18
18
  * router.start('/');
19
19
  */
20
- declare const createRouter: <Dependencies extends DefaultDependencies = DefaultDependencies>(routes?: Route<Dependencies>[], options?: Partial<Options>, dependencies?: Dependencies) => Router<Dependencies>;
20
+ declare const createRouter: <Dependencies extends DefaultDependencies = DefaultDependencies>(routes?: Route<Dependencies>[], options?: Partial<Options<Dependencies>>, dependencies?: Dependencies) => Router<Dependencies>;
21
21
  //#endregion
22
22
  export { createRouter };
23
23
  //# sourceMappingURL=createRouter.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRouter.d.mts","names":[],"sources":["../../src/createRouter.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAsBa,eACX,qBAAqB,sBAAsB,qBAE3C,SAAQ,MAAM,iBACd,UAAS,QAAQ,UACjB,eAAc,iBACb,OAAO"}
1
+ {"version":3,"file":"createRouter.d.mts","names":[],"sources":["../../src/createRouter.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAsBa,eACX,qBAAqB,sBAAsB,qBAE3C,SAAQ,MAAM,iBACd,UAAS,QAAQ,QAAQ,gBACzB,eAAc,iBACb,OAAO"}
@@ -6,9 +6,22 @@ declare class SegmentMatcher {
6
6
  constructor(options: SegmentMatcherOptions);
7
7
  registerTree(node: MatcherInputNode): void;
8
8
  match(path: string): MatchResult | undefined;
9
- buildPath(name: string, params?: Record<string, unknown>, options?: BuildPathOptions): string;
9
+ buildPath(name: string, params?: Record<string, unknown>, search?: Record<string, unknown>, options?: BuildPathOptions): string;
10
10
  getSegmentsByName(name: string): readonly MatcherInputNode[] | undefined;
11
11
  getMetaByName(name: string): Readonly<Record<string, Record<string, "url" | "query">>> | undefined;
12
+ /**
13
+ * The route's declared query-param names — the SAME registry the query-string
14
+ * build reads (`#buildQueryStringForBuild`), so a consumer classifying keys
15
+ * into channels cannot drift from what this matcher actually prints (#1556).
16
+ *
17
+ * Unlike a walk over {@link getSegmentsByName}, this includes the ROOT node's
18
+ * `?`-declarations (`setRootPath("?a&b")` — how persistent-params declares its
19
+ * keys): the root is captured in `#rootQueryParams` at `registerTree` and is
20
+ * deliberately NOT part of `matchSegments`, so a segment walk silently misses
21
+ * it. Path-slot collisions (`/items/:id?id`) are NOT filtered here — the
22
+ * caller owns that policy (core subtracts its `urlParams`, #843 / #1549).
23
+ */
24
+ getDeclaredQueryParams(name: string): readonly string[] | undefined;
12
25
  hasRoute(name: string): boolean;
13
26
  }
14
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentMatcher.d.mts","names":[],"sources":["../../../../src/engine/path-matcher/SegmentMatcher.ts"],"mappings":";;cA6Da;;MACP,WAAW;EA2BH,YAAA,SAAS;EAiBrB,aAAa,MAAM;EAiBnB,MAAM,eAAe;EAqDrB,UACE,cACA,SAAS,yBACT,UAAU;EAmBZ,kBAAkB,wBAAwB;EAO1C,cACE,eACC,SAAS,eAAe;EAI3B,SAAS"}
1
+ {"version":3,"file":"SegmentMatcher.d.mts","names":[],"sources":["../../../../src/engine/path-matcher/SegmentMatcher.ts"],"mappings":";;cA0Ca;;MACP,WAAW;EA2BH,YAAA,SAAS;EAiBrB,aAAa,MAAM;EAkBnB,MAAM,eAAe;EAqDrB,UACE,cACA,SAAS,yBACT,SAAS,yBACT,UAAU;EAyBZ,kBAAkB,wBAAwB;EAO1C,cACE,eACC,SAAS,eAAe;;;;;;;;;;;;;EAgB3B,uBAAuB;EAIvB,SAAS"}
@@ -69,7 +69,10 @@ interface BuildPathOptions {
69
69
  }
70
70
  interface MatchResult {
71
71
  readonly segments: readonly MatcherInputNode[];
72
+ /** PATH params (query still folded in for A2 back-compat, RFC-4 M2 / #1548). */
72
73
  readonly params: Readonly<Record<string, unknown>>;
74
+ /** QUERY params — the query channel; frozen `{}` when no query string. */
75
+ readonly search: Readonly<Record<string, unknown>>;
73
76
  readonly meta: Readonly<Record<string, Record<string, "url" | "query">>>;
74
77
  }
75
78
  interface SegmentMatcherOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../src/engine/path-matcher/types.ts"],"mappings":";;;;;;;;;;;UAWiB;;;;;;WAMN;;;;;;WAOA;;;;;;WAOA;;;;;;WAOA,cAAc,SAAS;;;;;;WAOvB;;;;;;;;;;KAeC;UAMK;WACN;WACA;WACA;WACA;WACA,UAAU,oBAAoB;WAC9B,8BAA8B;WAC9B,WAAW;WACX,cAAc,SAAS;;;;;UAqCjB;WACN;WACA;;UA0BM;WACN,mBAAmB;WACnB,QAAQ,SAAS;WACjB,MAAM,SAAS,eAAe;;UAOxB;EACf;EACA;EACA;EACA,oBAAoB;EACpB,mBAAmB,wBAAwB;EAC3C,mBAAmB,QAAQ;;UAGZ;WACN;WACA;WACA;WACA,mBAAmB;WACnB,mBAAmB,wBAAwB;WAC3C,mBAAmB,QAAQ"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../src/engine/path-matcher/types.ts"],"mappings":";;;;;;;;;;;UAWiB;;;;;;WAMN;;;;;;WAOA;;;;;;WAOA;;;;;;WAOA,cAAc,SAAS;;;;;;WAOvB;;;;;;;;;;KAeC;UAMK;WACN;WACA;WACA;WACA;WACA,UAAU,oBAAoB;WAC9B,8BAA8B;WAC9B,WAAW;WACX,cAAc,SAAS;;;;;UAqCjB;WACN;WACA;;UA0BM;WACN,mBAAmB;;WAEnB,QAAQ,SAAS;;WAEjB,QAAQ,SAAS;WACjB,MAAM,SAAS,eAAe;;UAOxB;EACf;EACA;EACA;EACA,oBAAoB;EACpB,mBAAmB,wBAAwB;EAC3C,mBAAmB,QAAQ;;UAGZ;WACN;WACA;WACA;WACA,mBAAmB;WACnB,mBAAmB,wBAAwB;WAC3C,mBAAmB,QAAQ"}
@@ -1,8 +1,8 @@
1
1
  import { RouteTree } from "./engine/builder/types.mjs";
2
2
  import { QueryParamsMode, QueryParamsOptions, RouteParams, RouteTreeState } from "./types/route-node-types.mjs";
3
- import { Params, SerializedRouterState, SimpleState, State, StateMetaInput, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe } from "./types/base.mjs";
3
+ import { NavigationTarget, Params, ParamsSearch, SearchParamPrimitive, SearchParamValue, SearchParams, SerializedRouterState, SimpleState, State, TransitionMeta, TransitionPhase, TransitionReason, Unsubscribe } from "./types/base.mjs";
4
4
  import { LimitsConfig } from "./types/limits.mjs";
5
- import { DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, ForwardToCallback, GuardFn, GuardFnFactory, LeaveFn, LeaveState, Listener, LogCallback, LogLevel, LogLevelConfig, LoggerConfig, Navigator, Options, Plugin, PluginFactory, Route, RouteConfigUpdate, RouterLogger, SubscribeFn, SubscribeState, Subscription } from "./types/router.mjs";
5
+ import { AnyOptions, DefaultDependencies, DefaultParamsCallback, DefaultRouteCallback, DefaultSearchCallback, ForwardToCallback, GuardFn, GuardFnFactory, LeaveFn, LeaveState, Listener, LogCallback, LogLevel, LogLevelConfig, LoggerConfig, Navigator, Options, Plugin, PluginFactory, Route, RouteConfigUpdate, RouterLogger, SubscribeFn, SubscribeState, Subscription } from "./types/router.mjs";
6
6
  import { ErrorCodeKeys, ErrorCodeToValueMap, ErrorCodeValues, EventMethodMap, EventName, EventToNameMap, EventToPluginMap, EventsKeys, PluginMethod } from "./types/constants.mjs";
7
7
  import { TreeChangedAdd, TreeChangedClear, TreeChangedEvent, TreeChangedRemove, TreeChangedReplace, TreeChangedUpdate, TreeStructuralPatch } from "./types/tree-changed.mjs";
8
8
  import { ContextNamespaceClaim, DependenciesApi, InterceptableMethodMap, InterceptorFn, LifecycleApi, PluginApi, RoutesApi } from "./types/api.mjs";
@@ -14,4 +14,4 @@ import { RouterError } from "./RouterError.mjs";
14
14
  import { createRouter } from "./createRouter.mjs";
15
15
  import { getNavigator } from "./getNavigator.mjs";
16
16
  import { resolveForwardChain } from "./namespaces/RoutesNamespace/forwardChain.mjs";
17
- export { type Constants, type ContextNamespaceClaim, type DefaultDependencies, type DefaultParamsCallback, type DefaultRouteCallback, type DependenciesApi, type ErrorCodeKeys, type ErrorCodeToValueMap, type ErrorCodeValues, type ErrorCodes, type EventMethodMap, type EventName, type EventToNameMap, type EventToPluginMap, type EventsKeys, type ForwardToCallback, type GuardFn, type GuardFnFactory, type InterceptableMethodMap, type InterceptorFn, type LeaveFn, type LeaveState, type LifecycleApi, type LimitsConfig, type Listener, type LogCallback, type LogLevel, type LogLevelConfig, type LoggerConfig, type NavigationOptions, type Navigator, type Options, type Params, type Plugin, type PluginApi, type PluginFactory, type PluginMethod, type QueryParamsMode, type QueryParamsOptions, type Route, type RouteConfigUpdate, type RouteParams, type RouteTree, type RouteTreeState, Router, RouterError, type RouterLogger, type RouterValidator, type RoutesApi, type SerializedRouterState, type SimpleState, type State, type StateContext, type StateMetaInput, type SubscribeFn, type SubscribeState, type Subscription, type TransitionMeta, type TransitionPhase, type TransitionReason, type TreeChangedAdd, type TreeChangedClear, type TreeChangedEvent, type TreeChangedRemove, type TreeChangedReplace, type TreeChangedUpdate, type TreeStructuralPatch, UNKNOWN_ROUTE, type Unsubscribe, constants, createRouter, errorCodes, events, getNavigator, resolveForwardChain };
17
+ export { type AnyOptions, type Constants, type ContextNamespaceClaim, type DefaultDependencies, type DefaultParamsCallback, type DefaultRouteCallback, type DefaultSearchCallback, type DependenciesApi, type ErrorCodeKeys, type ErrorCodeToValueMap, type ErrorCodeValues, type ErrorCodes, type EventMethodMap, type EventName, type EventToNameMap, type EventToPluginMap, type EventsKeys, type ForwardToCallback, type GuardFn, type GuardFnFactory, type InterceptableMethodMap, type InterceptorFn, type LeaveFn, type LeaveState, type LifecycleApi, type LimitsConfig, type Listener, type LogCallback, type LogLevel, type LogLevelConfig, type LoggerConfig, type NavigationOptions, type NavigationTarget, type Navigator, type Options, type Params, type ParamsSearch, type Plugin, type PluginApi, type PluginFactory, type PluginMethod, type QueryParamsMode, type QueryParamsOptions, type Route, type RouteConfigUpdate, type RouteParams, type RouteTree, type RouteTreeState, Router, RouterError, type RouterLogger, type RouterValidator, type RoutesApi, type SearchParamPrimitive, type SearchParamValue, type SearchParams, type SerializedRouterState, type SimpleState, type State, type StateContext, type SubscribeFn, type SubscribeState, type Subscription, type TransitionMeta, type TransitionPhase, type TransitionReason, type TreeChangedAdd, type TreeChangedClear, type TreeChangedEvent, type TreeChangedRemove, type TreeChangedReplace, type TreeChangedUpdate, type TreeStructuralPatch, UNKNOWN_ROUTE, type Unsubscribe, constants, createRouter, errorCodes, events, getNavigator, resolveForwardChain };
@@ -1,2 +1,2 @@
1
- import{C as e,E as t,T as n,g as r,n as i,t as a,w as o}from"./Router-Bk6PfSE8.mjs";const s=(e=[],t={},n={})=>new a(e,t,n),c=new WeakMap,l=e=>{let t=c.get(e);return t||(t=Object.freeze({navigate:e.navigate,getState:e.getState,isActiveRoute:e.isActiveRoute,canNavigateTo:e.canNavigateTo,subscribe:e.subscribe,subscribeLeave:e.subscribeLeave,isLeaveApproved:e.isLeaveApproved}),c.set(e,t)),t};export{a as Router,i as RouterError,e as UNKNOWN_ROUTE,o as constants,s as createRouter,n as errorCodes,t as events,l as getNavigator,r as resolveForwardChain};
1
+ import{A as e,D as t,O as n,g as r,k as i,n as a,t as o}from"./Router-DEpNuwBW.mjs";const s=(e=[],t={},n={})=>new o(e,t,n),c=new WeakMap,l=e=>{let t=c.get(e);return t||(t=Object.freeze({navigate:e.navigate,getState:e.getState,isActiveRoute:e.isActiveRoute,canNavigateTo:e.canNavigateTo,subscribe:e.subscribe,subscribeLeave:e.subscribeLeave,isLeaveApproved:e.isLeaveApproved}),c.set(e,t)),t};export{o as Router,a as RouterError,t as UNKNOWN_ROUTE,n as constants,s as createRouter,i as errorCodes,e as events,l as getNavigator,r as resolveForwardChain};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/createRouter.ts","../../src/getNavigator.ts"],"sourcesContent":["// packages/core/src/createRouter.ts\n\nimport { Router } from \"./Router\";\n\nimport type { DefaultDependencies, Options, Route } from \"./types\";\n\n/**\n * Creates a new router instance.\n *\n * @param routes - Array of route definitions\n * @param options - Router configuration options\n * @param dependencies - Dependencies to inject into the router\n * @returns A new Router instance\n *\n * @example\n * const router = createRouter([\n * { name: 'home', path: '/' },\n * { name: 'users', path: '/users' },\n * ]);\n *\n * router.start('/');\n */\nexport const createRouter = <\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n routes: Route<Dependencies>[] = [],\n options: Partial<Options> = {},\n dependencies: Dependencies = {} as Dependencies,\n): Router<Dependencies> => {\n return new Router<Dependencies>(routes, options, dependencies);\n};\n","import type { Navigator, DefaultDependencies, Router } from \"./types\";\n\nconst cache = new WeakMap<Router, Navigator>();\n\nexport const getNavigator = <\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n router: Router<Dependencies>,\n): Navigator => {\n let nav = cache.get(router);\n\n if (!nav) {\n nav = Object.freeze({\n navigate: router.navigate,\n getState: router.getState,\n isActiveRoute: router.isActiveRoute,\n canNavigateTo: router.canNavigateTo,\n subscribe: router.subscribe,\n subscribeLeave: router.subscribeLeave,\n isLeaveApproved: router.isLeaveApproved,\n } as Navigator);\n cache.set(router, nav);\n }\n\n return nav;\n};\n"],"mappings":"oFAsBA,MAAa,GAGX,EAAgC,CAAC,EACjC,EAA4B,CAAC,EAC7B,EAA6B,CAAC,IAEvB,IAAI,EAAqB,EAAQ,EAAS,CAAY,EC3BzD,EAAQ,IAAI,QAEL,EAGX,GACc,CACd,IAAI,EAAM,EAAM,IAAI,CAAM,EAe1B,OAbK,IACH,EAAM,OAAO,OAAO,CAClB,SAAU,EAAO,SACjB,SAAU,EAAO,SACjB,cAAe,EAAO,cACtB,cAAe,EAAO,cACtB,UAAW,EAAO,UAClB,eAAgB,EAAO,eACvB,gBAAiB,EAAO,eAC1B,CAAc,EACd,EAAM,IAAI,EAAQ,CAAG,GAGhB,CACT"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/createRouter.ts","../../src/getNavigator.ts"],"sourcesContent":["// packages/core/src/createRouter.ts\n\nimport { Router } from \"./Router\";\n\nimport type { DefaultDependencies, Options, Route } from \"./types\";\n\n/**\n * Creates a new router instance.\n *\n * @param routes - Array of route definitions\n * @param options - Router configuration options\n * @param dependencies - Dependencies to inject into the router\n * @returns A new Router instance\n *\n * @example\n * const router = createRouter([\n * { name: 'home', path: '/' },\n * { name: 'users', path: '/users' },\n * ]);\n *\n * router.start('/');\n */\nexport const createRouter = <\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n routes: Route<Dependencies>[] = [],\n options: Partial<Options<Dependencies>> = {},\n dependencies: Dependencies = {} as Dependencies,\n): Router<Dependencies> => {\n return new Router<Dependencies>(routes, options, dependencies);\n};\n","import type { Navigator, DefaultDependencies, Router } from \"./types\";\n\nconst cache = new WeakMap<Router, Navigator>();\n\nexport const getNavigator = <\n Dependencies extends DefaultDependencies = DefaultDependencies,\n>(\n router: Router<Dependencies>,\n): Navigator => {\n let nav = cache.get(router);\n\n if (!nav) {\n nav = Object.freeze({\n navigate: router.navigate,\n getState: router.getState,\n isActiveRoute: router.isActiveRoute,\n canNavigateTo: router.canNavigateTo,\n subscribe: router.subscribe,\n subscribeLeave: router.subscribeLeave,\n isLeaveApproved: router.isLeaveApproved,\n } as Navigator);\n cache.set(router, nav);\n }\n\n return nav;\n};\n"],"mappings":"oFAsBA,MAAa,GAGX,EAAgC,CAAC,EACjC,EAA0C,CAAC,EAC3C,EAA6B,CAAC,IAEvB,IAAI,EAAqB,EAAQ,EAAS,CAAY,EC3BzD,EAAQ,IAAI,QAEL,EAGX,GACc,CACd,IAAI,EAAM,EAAM,IAAI,CAAM,EAe1B,OAbK,IACH,EAAM,OAAO,OAAO,CAClB,SAAU,EAAO,SACjB,SAAU,EAAO,SACjB,cAAe,EAAO,cACtB,cAAe,EAAO,cACtB,UAAW,EAAO,UAClB,eAAgB,EAAO,eACvB,gBAAiB,EAAO,eAC1B,CAAc,EACd,EAAM,IAAI,EAAQ,CAAG,GAGhB,CACT"}
@@ -1,20 +1,34 @@
1
1
  import { RouteTree } from "./engine/builder/types.mjs";
2
2
  import { RouteTreeState } from "./types/route-node-types.mjs";
3
- import { Params, SerializedRouterState, SimpleState, State, Unsubscribe } from "./types/base.mjs";
4
- import { DefaultDependencies, LoggerConfig, Options, Plugin, PluginFactory, Router, RouterLogger } from "./types/router.mjs";
3
+ import { Params, SearchParams, SerializedRouterState, SimpleState, State, Unsubscribe } from "./types/base.mjs";
4
+ import { AnyOptions, DefaultDependencies, LoggerConfig, Options, Plugin, PluginFactory, Router, RouterLogger } from "./types/router.mjs";
5
5
  import { EventMethodMap, EventName } from "./types/constants.mjs";
6
6
  import { TreeChangedEvent } from "./types/tree-changed.mjs";
7
7
  import { NavigationOptions } from "./types.mjs";
8
8
  import { RouterValidator } from "./types/RouterValidator.mjs";
9
9
  import { DependenciesStore } from "./namespaces/DependenciesNamespace/dependenciesStore.mjs";
10
+ import { RouteResolver } from "./pipeline/port.mjs";
10
11
  import { RoutesStore } from "./namespaces/RoutesNamespace/routesStore.mjs";
11
12
  //#region src/internals.d.ts
12
13
  interface RouterInternals<D extends DefaultDependencies = DefaultDependencies> {
13
- readonly makeState: <P extends Params = Params>(name: string, params?: P, path?: string, meta?: Record<string, Record<string, "url" | "query">>) => State<P>;
14
- readonly forwardState: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
14
+ readonly makeState: <P extends Params = Params, S extends SearchParams = SearchParams>(name: string, params?: P, search?: S, path?: string) => State<P, S>;
15
+ /**
16
+ * Per-segment param-source map for a route name (`{ segment: { param: "url" |
17
+ * "query" } }`), read from the live matcher — the ownership channel for
18
+ * `getTransitionPath` (RFC-4 M2 / #1548, replaced the removed per-State
19
+ * `stateMetaStore` WeakMap). `undefined` when the name is not in the tree.
20
+ */
21
+ readonly getMetaForState: (name: string) => Record<string, Record<string, "url" | "query">> | undefined;
22
+ /**
23
+ * The route's DECLARED query-param names — the same registry the URL build
24
+ * prints from (#1556), minus path slots. Feeds the always-on channel guard
25
+ * (#1572); read here rather than re-derived, so classification cannot drift.
26
+ */
27
+ readonly getQueryParams: (name: string) => readonly string[];
28
+ readonly forwardState: <P extends Params = Params, S extends SearchParams = SearchParams>(routeName: string, routeParams: P, routeSearch?: S) => SimpleState<P, S>;
15
29
  readonly buildStateResolved: (resolvedName: string, resolvedParams: Params) => RouteTreeState | undefined;
16
- readonly matchPath: <P extends Params = Params>(path: string, options?: Options) => State<P> | undefined;
17
- readonly getOptions: () => Options;
30
+ readonly matchPath: <P extends Params = Params>(path: string, options?: AnyOptions) => State<P> | undefined;
31
+ readonly getOptions: () => Options<D>;
18
32
  readonly addEventListener: <E extends EventName>(eventName: E, cb: Plugin[EventMethodMap[E]]) => Unsubscribe;
19
33
  /**
20
34
  * Route-tree mutation channel — internal access for the `getRoutesApi`
@@ -33,7 +47,15 @@ interface RouterInternals<D extends DefaultDependencies = DefaultDependencies> {
33
47
  */
34
48
  readonly isEmitting: () => boolean;
35
49
  };
36
- readonly buildPath: (route: string, params?: Params) => string;
50
+ readonly buildPath: (route: string, params?: Params, search?: SearchParams) => string;
51
+ /**
52
+ * The navigation pipeline's read-model, for entry points that live on this
53
+ * plugin-facing surface rather than in a namespace. Resolved LAZILY: the port
54
+ * is created during wiring, and `registerInternals` runs before that, so the
55
+ * accessor is a closure rather than a value — the same shape the interceptable
56
+ * methods above already use.
57
+ */
58
+ readonly port: () => RouteResolver;
37
59
  readonly emitTransitionError: (error: Error) => void;
38
60
  /**
39
61
  * Emits `TRANSITION_SUCCESS` directly (no FSM transition) — used by
@@ -67,7 +89,7 @@ interface RouterInternals<D extends DefaultDependencies = DefaultDependencies> {
67
89
  readonly logger: RouterLogger;
68
90
  readonly dependenciesGetStore: () => DependenciesStore<D>;
69
91
  readonly getCloneState: () => {
70
- options: Options;
92
+ options: Options<D>;
71
93
  dependencies: Record<string, unknown>;
72
94
  pluginFactories: PluginFactory<D>[];
73
95
  loggerConfig: LoggerConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"internals.d.mts","names":[],"sources":["../../src/internals.ts"],"mappings":";;;;;;;;;;;UAyBiB,gBACf,UAAU,sBAAsB;WAEvB,YAAY,UAAU,SAAS,QACtC,cACA,SAAS,GACT,eACA,OAAO,eAAe,qCACnB,MAAM;WAEF,eAAe,UAAU,SAAS,QACzC,mBACA,aAAa,MACV,YAAY;WAER,qBACP,sBACA,gBAAgB,WACb;WAEI,YAAY,UAAU,SAAS,QACtC,cACA,UAAU,YACP,MAAM;WAEF,kBAAkB;WAElB,mBAAmB,UAAU,WACpC,WAAW,GACX,IAAI,OAAO,eAAe,QACvB;;;;;;;;WASI;aACE,OAAO,OAAO;aACd,YACP,UAAU,OAAO,8BACd;aACI;;;;;aAKA;;WAGF,YAAY,eAAe,SAAS;WAEpC,sBAAsB,OAAO;;;;;;;WAQ7B,wBACP,SAAS,OACT,WAAW,mBACX,OAAO;;;;;;;;WAUA,qBAAqB,iBAAiB;WAEtC,QAAQ,iBAAiB,QAAQ;;;;;;;WAQjC,kBACP,OAAO,OACP,UAAU,sBACP,QAAQ;WAGJ,cAAc,cAEnB,UAAU,wBAAwB;WAI7B,cAAc;WACd;WAEA,eAAe;WAEf;EAET,WAAW;WAQF,QAAQ;WAGR,4BAA4B,kBAAkB;WAM9C;IACP,SAAS;IACT,cAAc;IACd,iBAAiB,cAAc;IAK/B,cAAc;;WAIP,qBAAqB,YAAY;WAGjC;WACA;WACA;WACA,WAAW,OAAO;WAClB;IAAoB;;WACpB,qBAAqB;;;;;;;;;;EAW9B,gBAAgB;;iBAMF,aAAa,UAAU,qBACrC,QAAQ,OAAgB,KACvB,gBAAgB"}
1
+ {"version":3,"file":"internals.d.mts","names":[],"sources":["../../src/internals.ts"],"mappings":";;;;;;;;;;;;UA8BiB,gBACf,UAAU,sBAAsB;WAEvB,YACP,UAAU,SAAS,QACnB,UAAU,eAAe,cAEzB,cACA,SAAS,GACT,SAAS,GACT,kBACG,MAAM,GAAG;;;;;;;WAQL,kBACP,iBACG,eAAe;;;;;;WAOX,iBAAiB;WAEjB,eACP,UAAU,SAAS,QACnB,UAAU,eAAe,cAEzB,mBACA,aAAa,GACb,cAAc,MACX,YAAY,GAAG;WAEX,qBACP,sBACA,gBAAgB,WACb;WAEI,YAAY,UAAU,SAAS,QACtC,cACA,UAAU,eACP,MAAM;WAEF,kBAAkB,QAAQ;WAE1B,mBAAmB,UAAU,WACpC,WAAW,GACX,IAAI,OAAO,eAAe,QACvB;;;;;;;;WASI;aACE,OAAO,OAAO;aACd,YACP,UAAU,OAAO,8BACd;aACI;;;;;aAKA;;WAGF,YACP,eACA,SAAS,QACT,SAAS;;;;;;;;WAUF,YAAY;WAEZ,sBAAsB,OAAO;;;;;;;WAQ7B,wBACP,SAAS,OACT,WAAW,mBACX,OAAO;;;;;;;;WAUA,qBAAqB,iBAAiB;WAEtC,QAAQ,iBAAiB,QAAQ;;;;;;;WAQjC,kBACP,OAAO,OACP,UAAU,sBACP,QAAQ;WAGJ,cAAc,cAEnB,UAAU,wBAAwB;WAI7B,cAAc;WACd;WAEA,eAAe;WAEf;EAET,WAAW;WAQF,QAAQ;WAGR,4BAA4B,kBAAkB;WAM9C;IACP,SAAS,QAAQ;IACjB,cAAc;IACd,iBAAiB,cAAc;IAK/B,cAAc;;WAIP,qBAAqB,YAAY;WAGjC;WACA;WACA;WACA,WAAW,OAAO;WAClB;IAAoB;;WACpB,qBAAqB;;;;;;;;;;EAW9B,gBAAgB;;iBAMF,aAAa,UAAU,qBACrC,QAAQ,OAAgB,KACvB,gBAAgB"}
@@ -28,6 +28,14 @@ interface RoutesStore<Dependencies extends DefaultDependencies = DefaultDependen
28
28
  * stay frozen to a route's pre-mutation param shape (#723).
29
29
  */
30
30
  readonly urlParamsCache: Map<string, string[]>;
31
+ /**
32
+ * Per-route-name cache of declared query param names (`?a&b` across the
33
+ * route's segments), read by `RoutesNamespace.getQueryParams` — THE registry
34
+ * every channel mechanism classifies through and the URL build prints from
35
+ * (#1556). Same lifecycle as `urlParamsCache`: cleared on every `matcher`
36
+ * rebuild.
37
+ */
38
+ readonly queryParamsCache: Map<string, string[]>;
31
39
  resolvedForwardMap: Record<string, string>;
32
40
  routeCustomFields: Record<string, Record<string, unknown>>;
33
41
  rootPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"routesStore.d.mts","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/routesStore.ts"],"mappings":";;;;;;UAsCiB,YACf,qBAAqB,sBAAsB;;;;;;;;;;;;;WAclC,aAAa;WACb,QAAQ;EACjB,MAAM;EACN,SAAS;;;;;;;WAOA,gBAAgB;EACzB,oBAAoB;EACpB,mBAAmB,eAAe;EAClC;WACS,gBAAgB;EACzB,WAAW,mBAAmB;EAC9B,oBAAoB,wBAAwB;WACnC,oBAAoB,YAAY,eAAe;WAC/C,sBAAsB,YAAY,eAAe"}
1
+ {"version":3,"file":"routesStore.d.mts","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/routesStore.ts"],"mappings":";;;;;;UA2CiB,YACf,qBAAqB,sBAAsB;;;;;;;;;;;;;WAclC,aAAa;WACb,QAAQ;EACjB,MAAM;EACN,SAAS;;;;;;;WAOA,gBAAgB;;;;;;;;WAQhB,kBAAkB;EAC3B,oBAAoB;EACpB,mBAAmB,eAAe;EAClC;WACS,gBAAgB;EACzB,WAAW,mBAAmB;EAC9B,oBAAoB,wBAAwB;WACnC,oBAAoB,YAAY,eAAe;WAC/C,sBAAsB,YAAY,eAAe"}
@@ -1,5 +1,7 @@
1
- import { Params, SimpleState, State } from "../../types/base.mjs";
1
+ import { Params, ParamsSearch, SearchParams, State } from "../../types/base.mjs";
2
2
  import { DefaultDependencies, ForwardToCallback, GuardFn, GuardFnFactory, RouterLogger } from "../../types/router.mjs";
3
+ import { RouterValidator } from "../../types/RouterValidator.mjs";
4
+ import { RouteResolver } from "../../pipeline/port.mjs";
3
5
  //#region src/namespaces/RoutesNamespace/types.d.ts
4
6
  /**
5
7
  * Dependencies injected into RoutesNamespace.
@@ -10,6 +12,23 @@ import { DefaultDependencies, ForwardToCallback, GuardFn, GuardFnFactory, Router
10
12
  interface RoutesDependencies<Dependencies extends DefaultDependencies = DefaultDependencies> {
11
13
  /** Per-router logger instance (from `getInternals(router).logger`) */
12
14
  logger: RouterLogger;
15
+ /**
16
+ * The opt-in validator, resolved PER CALL — `null` until `validation-plugin`
17
+ * installs one, and `null` again after its teardown. The same shared closure
18
+ * EventBus / RouteLifecycle / Plugins receive; this namespace needs it for the
19
+ * one boundary on it where USER code hands back a value core then builds a
20
+ * state from (a route's `decodeParams`).
21
+ */
22
+ getValidator: () => RouterValidator | null;
23
+ /**
24
+ * The pipeline's read-model (`RouteResolver`), shared with NavigationNamespace
25
+ * — one instance per router, created in `wireNamespaces`. Entry points on this
26
+ * namespace compose their target state through `canonicalize` / `buildURL` /
27
+ * `materialize` and reach the router's stage ① seam and route config through
28
+ * this port rather than through the namespace's own dependency closures, so
29
+ * every producer reads ONE read-model (nav-pipeline Phase 2).
30
+ */
31
+ port: RouteResolver;
13
32
  /**
14
33
  * Register a canActivate handler for a route. `precompiledFn` installs an
15
34
  * already-compiled `GuardFn` (from {@link compileGuard}) without re-invoking
@@ -25,16 +44,12 @@ interface RoutesDependencies<Dependencies extends DefaultDependencies = DefaultD
25
44
  * validate every guard before swapping the store (#956).
26
45
  */
27
46
  compileGuard: (handler: GuardFnFactory<Dependencies>, methodName: string) => GuardFn;
28
- /** Create state object */
29
- makeState: <P extends Params = Params>(name: string, params?: P, path?: string, meta?: Record<string, Record<string, "url" | "query">>) => State<P>;
30
47
  /** Get current router state */
31
48
  getState: () => State | undefined;
32
49
  /** Compare two states for equality */
33
50
  areStatesEqual: (state1: State | undefined, state2: State | undefined, ignoreQueryParams?: boolean) => boolean;
34
51
  /** Get a dependency by name */
35
52
  getDependency: <K extends keyof Dependencies>(name: K) => Dependencies[K];
36
- /** Forward state through facade (allows plugin interception) */
37
- forwardState: <P extends Params = Params>(name: string, params: P) => SimpleState<P>;
38
53
  }
39
54
  /**
40
55
  * Configuration storage for routes.
@@ -42,11 +57,13 @@ interface RoutesDependencies<Dependencies extends DefaultDependencies = DefaultD
42
57
  */
43
58
  interface RouteConfig {
44
59
  /** Custom param decoders per route */
45
- decoders: Record<string, (params: Params) => Params>;
60
+ decoders: Record<string, (channels: ParamsSearch) => ParamsSearch>;
46
61
  /** Custom param encoders per route */
47
- encoders: Record<string, (params: Params) => Params>;
62
+ encoders: Record<string, (channels: ParamsSearch) => ParamsSearch>;
48
63
  /** Default params per route */
49
64
  defaultParams: Record<string, Params>;
65
+ /** Default search (query) params per route (RFC-4 M2 / #1548) */
66
+ defaultSearch: Record<string, SearchParams>;
50
67
  /** Forward mappings (source -> target) */
51
68
  forwardMap: Record<string, string>;
52
69
  /** Dynamic forward callbacks (source -> callback) */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/types.ts"],"mappings":";;;;;;;;;UAmBiB,mBACf,qBAAqB,sBAAsB;;EAG3C,QAAQ;;;;;;;EAQR,mBACE,cACA,SAAS,eAAe,eACxB,gBAAgB;;EAIlB,qBACE,cACA,SAAS,eAAe,eACxB,gBAAgB;;;;;;EAQlB,eACE,SAAS,eAAe,eACxB,uBACG;;EAGL,YAAY,UAAU,SAAS,QAC7B,cACA,SAAS,GACT,eACA,OAAO,eAAe,qCACnB,MAAM;;EAGX,gBAAgB;;EAGhB,iBACE,QAAQ,mBACR,QAAQ,mBACR;;EAIF,gBAAgB,gBAAgB,cAAc,MAAM,MAAM,aAAa;;EAGvE,eAAe,UAAU,SAAS,QAChC,cACA,QAAQ,MACL,YAAY;;;;;;UAOF;;EAEf,UAAU,gBAAgB,QAAQ,WAAW;;EAG7C,UAAU,gBAAgB,QAAQ,WAAW;;EAG7C,eAAe,eAAe;;EAG9B,YAAY;;EAIZ,cAAc,eAAe"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../src/namespaces/RoutesNamespace/types.ts"],"mappings":";;;;;;;;;;;UAsBiB,mBACf,qBAAqB,sBAAsB;;EAG3C,QAAQ;;;;;;;;EASR,oBAAoB;;;;;;;;;EAUpB,MAAM;;;;;;;EAQN,mBACE,cACA,SAAS,eAAe,eACxB,gBAAgB;;EAIlB,qBACE,cACA,SAAS,eAAe,eACxB,gBAAgB;;;;;;EAQlB,eACE,SAAS,eAAe,eACxB,uBACG;;EAOL,gBAAgB;;EAGhB,iBACE,QAAQ,mBACR,QAAQ,mBACR;;EAIF,gBAAgB,gBAAgB,cAAc,MAAM,MAAM,aAAa;;;;;;UAkBxD;;EAEf,UAAU,gBAAgB,UAAU,iBAAiB;;EAGrD,UAAU,gBAAgB,UAAU,iBAAiB;;EAGrD,eAAe,eAAe;;EAG9B,eAAe,eAAe;;EAG9B,YAAY;;EAIZ,cAAc,eAAe"}
@@ -0,0 +1,147 @@
1
+ import { Params, SearchParams } from "../types/base.mjs";
2
+ //#region src/pipeline/port.d.ts
3
+ /**
4
+ * The pipeline's read-model over the routes layer — a narrow port, not a new
5
+ * layer. The module stays pure and mock-testable; the router implements the
6
+ * port at wiring time (`wiring/wireNamespaces.ts`).
7
+ *
8
+ * ⚠ **Both ends are deliberately interceptable, and all four phases closed
9
+ * without changing that.** The signatures describe the pipeline's contract, not
10
+ * where the implementation goes:
11
+ *
12
+ * - `resolveForward` is wired to the `forwardState` SEAM (`Router.ts:259-324`),
13
+ * i.e. the interceptable chain PLUS the centralized channel ASSERTION. It
14
+ * used to be a channel-SEPARATION wrapper (stage ②) that repaired a
15
+ * mis-channelled bag behind the producer's back; `ba0f6b18b` deleted the
16
+ * stage outright, and the seam now REFUSES such a bag instead
17
+ * (`assertChannelCorrect`, `src/channels/guard.ts`). Channel-correctness is
18
+ * the producer's contract, not something the port quietly restores. Calling
19
+ * the namespace primitive directly would switch off both the interceptors and
20
+ * that check.
21
+ * - `buildPath` is wired to `ctx.buildPath`, the interceptable, because the
22
+ * navigate path builds `state.path` through it (measured: one `navigate()`
23
+ * runs BOTH the `forwardState` and the `buildPath` interceptor). Reaching for
24
+ * the engine's `matcher.buildPath` here would silently stop running
25
+ * `persistent-params`' `buildPath` interceptor on the navigate path — a
26
+ * behaviour change, not a refactor. Phases 2 and 4 closed without un-wiring
27
+ * it: ⑤a stays on the interceptable.
28
+ *
29
+ * Accessors arrived with their consumers, as designed — `queryNames` with the
30
+ * channel guard, `admitsUndeclaredQuery` with the mode gate (#1575),
31
+ * `pathNames` and the two sinks with the diagnostics (#1579 / #1584). One
32
+ * member the design (RFC §4.5) listed never arrived at all: `encode`. The route
33
+ * codecs stayed with the entry points that own their direction (`buildPath`
34
+ * calls `config.encoders`, `matchPath` calls `config.decoders`), so the port
35
+ * never grew a stage for them — which is the case for adding a member only
36
+ * together with its caller, since one added early is dead weight nothing
37
+ * detects (knip has no issue type for unused members of an interface).
38
+ */
39
+ interface RouteResolver {
40
+ /**
41
+ * Stage ① — resolve the `forwardTo` chain (layering the hops' defaults) and
42
+ * hand back channel-correct bags. Channel-correct by REFUSAL, not by repair:
43
+ * the seam asserts and throws (see the header). `search` flows THROUGH the
44
+ * interceptor zone, not past it: `search-schema` validates the query channel
45
+ * here on the URL→State direction.
46
+ */
47
+ resolveForward: (name: string, params: Params, search?: SearchParams) => {
48
+ name: string;
49
+ params: Params;
50
+ search?: SearchParams | undefined;
51
+ };
52
+ /**
53
+ * Stage ③ input — the route's per-channel defaults. Split by field, never
54
+ * inferred: `defaultParams` owns the path channel, `defaultSearch` the query
55
+ * channel (RFC-4 M2 / #1548).
56
+ *
57
+ * Two accessors rather than one returning `{ params, search }`: `navigate` is
58
+ * the hot path, and the combined form allocated one throwaway object per
59
+ * navigation. That allocation is the deterministic reason; the bench arm it
60
+ * was measured on also carried a per-call `getInternals`, and the harness's
61
+ * own A/A spread is wider than the delta, so no percentage is attributable to
62
+ * this accessor alone.
63
+ */
64
+ defaultParams: (name: string) => Params | undefined;
65
+ defaultSearch: (name: string) => SearchParams | undefined;
66
+ /**
67
+ * Stage ⑤a executor — builds the URL from already-merged channels. Kept in
68
+ * raw-channel form (not `Canonical`) so the port never has to know about the
69
+ * brand and stays mockable on its own; `buildURL` is the primitive that
70
+ * accepts nothing but a `Canonical`.
71
+ */
72
+ buildPath: (name: string, params: Params, search: SearchParams) => string;
73
+ /**
74
+ * The route's declared `?query` names — the ONE registry that classifies and
75
+ * prints (#1556), so a key enters the query channel iff the build shows it.
76
+ * A name that also occupies a path slot (`/items/:id?id`) is absent here by
77
+ * construction: it is legitimately path-owned (#843 / #1549).
78
+ */
79
+ queryNames: (name: string) => readonly string[];
80
+ /**
81
+ * The mode gate (#1575) — `true` exactly for `queryParamsMode: "loose"`, the
82
+ * one mode whose build prints undeclared query keys. Read as a boolean rather
83
+ * than leaking the mode itself into the pipeline: the pipeline's question is
84
+ * "may an undeclared key be canonical here?", not "which mode is this?".
85
+ */
86
+ admitsUndeclaredQuery: () => boolean;
87
+ /**
88
+ * The mode gate's opt-in diagnostic sink (#1575) — `undefined` unless
89
+ * `validation-plugin` is installed, so bare core drops silently and the
90
+ * pipeline pays nothing. Resolved per call, not captured: the plugin
91
+ * registers after wiring.
92
+ *
93
+ * ⚠ Like its sibling below, the absence has to be REAL: the router implements
94
+ * this as a GETTER returning `undefined` while `validator === null`, not as a
95
+ * closure that forwards into an optional-chained validator. A closure is
96
+ * always truthy, so the pipeline's `?.` read as taken and bare core still paid
97
+ * the `pathNames` existence lookup (#1584) once per dropped key with nothing
98
+ * to feed. The `| undefined` in the type is what lets the getter say so under
99
+ * `exactOptionalPropertyTypes`.
100
+ *
101
+ * Optional on the interface so a MOCK port (the property tests) stays a
102
+ * four-liner: the pipeline's contract is the drop, not the report.
103
+ */
104
+ reportDroppedQueryKey?: ((routeName: string, key: string) => void) | undefined;
105
+ /**
106
+ * The route's PATH slot names, or `undefined` when there is NO SUCH ROUTE —
107
+ * the other half of "is this key declared?". Needed only by the undeclared-key
108
+ * diagnostic (#1579), which asks whether a key is declared ANYWHERE;
109
+ * `queryNames` alone cannot answer that.
110
+ *
111
+ * ⚠ The `undefined` arm is load-bearing, not defensive (#1584). An empty array
112
+ * is what an EXISTING route with no path slots returns, so `[]` cannot say
113
+ * "no such route" — and the diagnostic, reading `[]` for both, reported every
114
+ * key in the caller's bag as "declared nowhere on route X" for a route X that
115
+ * has no declarations only because it has no existence. That blames the params
116
+ * for a typo in the ROUTE name, which is the most misleading direction
117
+ * available. The matcher already knows the difference (`getSegmentsByName`
118
+ * answers `undefined`); this member used to discard it.
119
+ *
120
+ * `queryNames` is deliberately NOT given the same arm: its three consumers —
121
+ * the diagnostic, the default merge and the mode gate — all want `[]` for a
122
+ * missing route, and only this one asks a question that presupposes existence.
123
+ */
124
+ pathNames: (name: string) => readonly string[] | undefined;
125
+ /**
126
+ * Opt-in sink for a key the route declares NOWHERE (#1579 — the params half
127
+ * of #1553). Absent unless `validation-plugin` is installed, and the absence
128
+ * is what keeps the scan off the hot path: core checks one `undefined` and
129
+ * skips the walk entirely.
130
+ *
131
+ * ⚠ The absence has to be REAL — the router implements this member as a
132
+ * GETTER returning `undefined` while `validator === null`, not as a closure
133
+ * that forwards into an optional-chained validator. A closure is always
134
+ * truthy, so the gate would read as taken and bare core would walk the
135
+ * caller's bag on every commit; the `| undefined` in the type is what lets
136
+ * the getter say so under `exactOptionalPropertyTypes`.
137
+ *
138
+ * A diagnostic, never a gate — core keeps the key in `state.params` as
139
+ * app-level data (wiki `Route.md`). Dropping it was measured and rejected: it
140
+ * retires a shipped capability, and "declared nowhere" cannot tell a typo from
141
+ * `navigate("users", { id })` on a parent whose CHILD declares `:id`.
142
+ */
143
+ reportUndeclaredParamKey?: ((routeName: string, key: string) => void) | undefined;
144
+ }
145
+ //#endregion
146
+ export { RouteResolver };
147
+ //# sourceMappingURL=port.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port.d.mts","names":[],"sources":["../../../src/pipeline/port.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAwCiB;;;;;;;;EAQf,iBACE,cACA,QAAQ,QACR,SAAS;IAET;IACA,QAAQ;IAIR,SAAS;;;;;;;;;;;;;;EAeX,gBAAgB,iBAAiB;EACjC,gBAAgB,iBAAiB;;;;;;;EAQjC,YAAY,cAAc,QAAQ,QAAQ,QAAQ;;;;;;;EAQlD,aAAa;;;;;;;EAQb;;;;;;;;;;;;;;;;;;EAmBA,0BACI,mBAAmB;;;;;;;;;;;;;;;;;;;;EAqBvB,YAAY;;;;;;;;;;;;;;;;;;;EAoBZ,6BACI,mBAAmB"}
@@ -93,6 +93,20 @@ interface RouterValidator {
93
93
  state: {
94
94
  validateMakeStateArgs: (name: unknown, params: unknown, path: unknown) => void;
95
95
  validateAreStatesEqualArgs: (s1: unknown, s2: unknown, ignoreQP: unknown) => void;
96
+ /**
97
+ * The mode gate's opt-in diagnostic (#1575). Core DROPS a query key the
98
+ * active `queryParamsMode` will not print — silently, by the same
99
+ * always-on-fixes / opt-in-diagnoses split the channel guard follows. This
100
+ * hook is what makes the drop visible in development.
101
+ *
102
+ * Called once per dropped key, from the gate itself, so the report cannot
103
+ * disagree with what was actually dropped. A `defaultSearch` declared for
104
+ * such a key surfaces through the same call — it is dead config in these
105
+ * modes, and that is the edge worth naming out loud.
106
+ */
107
+ reportDroppedQueryKey: (routeName: string, key: string) => void;
108
+ /** Opt-in diagnostic for a key the route declares NOWHERE (#1579). */
109
+ reportUndeclaredParamKey: (routeName: string, key: string) => void;
96
110
  };
97
111
  /**
98
112
  * Event bus validation methods
@@ -1 +1 @@
1
- {"version":3,"file":"RouterValidator.d.mts","names":[],"sources":["../../../src/types/RouterValidator.ts"],"mappings":";;;;;;;;;;UAUiB;;;;EAIf;IACE,wBAAwB;IACxB,wBAAwB;IACxB,4BACE,eACA,iBACA,iBACA;IAEF,+BAA+B;IAC/B,2BACE,eACA,iBACA;IAEF,uBAAuB;IACvB,iBACE,mBACA,eACA;IAEF,0BAA0B;IAC1B,+BAA+B,eAAe;IAC9C,mCAAmC,cAAc;IACjD,sBACE,cACA,kBACA;IAEF,uBAAuB,iBAAiB;IACxC,oBAAoB,eAAe;IACnC,uBAAuB,eAAe;IACtC,8BAA8B,mBAAmB;IACjD,0BAA0B;IAC1B,sBAAsB;IACtB,wBAAwB;;;;;EAM1B;IACE,kBAAkB,kBAAkB;IACpC,+BAA+B,oBAAoB;;;;;EAMrD;IACE,yBAAyB,eAAe;IACxC,4BACE,eACA,gBACA;IAEF,6BAA6B,eAAe;IAC5C,2BAA2B,cAAc;IACzC,0BAA0B,gBAAgB;IAC1C,oBAAoB;IACpB,gBAAgB,cAAc;IAC9B,qBAAqB,gBAAgB;IACrC,wBAAwB;;;;;EAM1B;IACE,sBAAsB,eAAe;IACrC,6BACE,kBACA;IAEF,qBAAqB;IACrB,0BAA0B;IAC1B,sBAAsB;IACtB,uBAAuB;IACvB,uBAAuB;IACvB,6BAA6B,iBAAiB;;;;;EAMhD;IACE,kBAAkB,kBAAkB;IACpC,uBAAuB,eAAe;IACtC,0BAA0B,eAAe;IACzC,gBAAgB,cAAc,cAAc;IAC5C,qBAAqB,cAAc;;;;;EAMrC;IACE,uBAAuB;IACvB,gCAAgC;IAChC,8BAA8B;IAC9B,4BAA4B,kBAAkB;IAC9C,iBAAiB,iBAAiB;IAClC,oBAAoB;;;;;EAMtB;IACE,wBACE,eACA,iBACA;IAEF,6BACE,aACA,aACA;;;;;EAOJ;IACE,uBAAuB,eAAe;IACtC,0BACE,eACA,mBACA"}
1
+ {"version":3,"file":"RouterValidator.d.mts","names":[],"sources":["../../../src/types/RouterValidator.ts"],"mappings":";;;;;;;;;;UAUiB;;;;EAIf;IACE,wBAAwB;IACxB,wBAAwB;IACxB,4BACE,eACA,iBACA,iBACA;IAEF,+BAA+B;IAC/B,2BACE,eACA,iBACA;IAEF,uBAAuB;IACvB,iBACE,mBACA,eACA;IAEF,0BAA0B;IAC1B,+BAA+B,eAAe;IAC9C,mCAAmC,cAAc;IACjD,sBACE,cACA,kBACA;IAEF,uBAAuB,iBAAiB;IACxC,oBAAoB,eAAe;IACnC,uBAAuB,eAAe;IACtC,8BAA8B,mBAAmB;IACjD,0BAA0B;IAC1B,sBAAsB;IACtB,wBAAwB;;;;;EAM1B;IACE,kBAAkB,kBAAkB;IACpC,+BAA+B,oBAAoB;;;;;EAMrD;IACE,yBAAyB,eAAe;IACxC,4BACE,eACA,gBACA;IAEF,6BAA6B,eAAe;IAC5C,2BAA2B,cAAc;IACzC,0BAA0B,gBAAgB;IAC1C,oBAAoB;IACpB,gBAAgB,cAAc;IAC9B,qBAAqB,gBAAgB;IACrC,wBAAwB;;;;;EAM1B;IACE,sBAAsB,eAAe;IACrC,6BACE,kBACA;IAEF,qBAAqB;IACrB,0BAA0B;IAC1B,sBAAsB;IACtB,uBAAuB;IACvB,uBAAuB;IACvB,6BAA6B,iBAAiB;;;;;EAMhD;IACE,kBAAkB,kBAAkB;IACpC,uBAAuB,eAAe;IACtC,0BAA0B,eAAe;IACzC,gBAAgB,cAAc,cAAc;IAC5C,qBAAqB,cAAc;;;;;EAMrC;IACE,uBAAuB;IACvB,gCAAgC;IAChC,8BAA8B;IAC9B,4BAA4B,kBAAkB;IAC9C,iBAAiB,iBAAiB;IAClC,oBAAoB;;;;;EAMtB;IACE,wBACE,eACA,iBACA;IAEF,6BACE,aACA,aACA;;;;;;;;;;;;IAaF,wBAAwB,mBAAmB;;IAG3C,2BAA2B,mBAAmB;;;;;EAMhD;IACE,uBAAuB,eAAe;IACtC,0BACE,eACA,mBACA"}