@real-router/core 0.79.0 → 0.80.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 (338) hide show
  1. package/dist/cjs/Router-DGUed2F4.js +2 -0
  2. package/dist/cjs/{Router-BRuC-daj.js.map → Router-DGUed2F4.js.map} +1 -1
  3. package/dist/cjs/{Router-BG5yNYUG.d.ts → Router.d.ts} +5 -4
  4. package/dist/cjs/Router.d.ts.map +1 -0
  5. package/dist/cjs/Router.js +2 -0
  6. package/dist/cjs/Router.js.map +1 -0
  7. package/dist/cjs/RouterError.d.ts +182 -0
  8. package/dist/cjs/RouterError.d.ts.map +1 -0
  9. package/dist/cjs/RouterError.js +2 -0
  10. package/dist/cjs/RouterError.js.map +1 -0
  11. package/dist/cjs/api/cloneRouter.d.ts +86 -0
  12. package/dist/cjs/api/cloneRouter.d.ts.map +1 -0
  13. package/dist/cjs/api/cloneRouter.js +2 -0
  14. package/dist/cjs/api/cloneRouter.js.map +1 -0
  15. package/dist/cjs/api/getDependenciesApi.d.ts +7 -0
  16. package/dist/cjs/api/getDependenciesApi.d.ts.map +1 -0
  17. package/dist/cjs/api/getDependenciesApi.js +2 -0
  18. package/dist/cjs/api/getDependenciesApi.js.map +1 -0
  19. package/dist/cjs/api/getLifecycleApi.d.ts +7 -0
  20. package/dist/cjs/api/getLifecycleApi.d.ts.map +1 -0
  21. package/dist/cjs/api/getLifecycleApi.js +2 -0
  22. package/dist/cjs/api/getLifecycleApi.js.map +1 -0
  23. package/dist/cjs/api/getPluginApi.d.ts +7 -0
  24. package/dist/cjs/api/getPluginApi.d.ts.map +1 -0
  25. package/dist/cjs/api/getPluginApi.js +2 -0
  26. package/dist/cjs/api/getPluginApi.js.map +1 -0
  27. package/dist/cjs/api/getRoutesApi.d.ts +7 -0
  28. package/dist/cjs/api/getRoutesApi.d.ts.map +1 -0
  29. package/dist/cjs/api/getRoutesApi.js +2 -0
  30. package/dist/cjs/api/getRoutesApi.js.map +1 -0
  31. package/dist/cjs/api/helpers.js +2 -0
  32. package/dist/cjs/api/helpers.js.map +1 -0
  33. package/dist/cjs/api/types.d.ts +9 -0
  34. package/dist/cjs/api/types.d.ts.map +1 -0
  35. package/dist/cjs/api.d.ts +8 -105
  36. package/dist/cjs/api.js +1 -2
  37. package/dist/cjs/api.js.map +1 -1
  38. package/dist/cjs/buildParamMeta-DniluAIV.js.map +1 -1
  39. package/dist/cjs/constants.d.ts +25 -0
  40. package/dist/cjs/constants.d.ts.map +1 -0
  41. package/dist/cjs/constants.js +2 -0
  42. package/dist/cjs/constants.js.map +1 -0
  43. package/dist/cjs/createRouter.d.ts +23 -0
  44. package/dist/cjs/createRouter.d.ts.map +1 -0
  45. package/dist/cjs/createRouter.js +2 -0
  46. package/dist/cjs/createRouter.js.map +1 -0
  47. package/dist/cjs/engine/builder/buildTree.js +2 -0
  48. package/dist/cjs/engine/builder/buildTree.js.map +1 -0
  49. package/dist/cjs/engine/builder/computeCaches.js +2 -0
  50. package/dist/cjs/engine/builder/computeCaches.js.map +1 -0
  51. package/dist/cjs/engine/builder/createRouteTree.js +2 -0
  52. package/dist/cjs/engine/builder/createRouteTree.js.map +1 -0
  53. package/dist/cjs/engine/builder/types.d.ts +48 -0
  54. package/dist/cjs/engine/builder/types.d.ts.map +1 -0
  55. package/dist/cjs/engine/createMatcher.d.ts +29 -0
  56. package/dist/cjs/engine/createMatcher.d.ts.map +1 -0
  57. package/dist/cjs/engine/createMatcher.js +2 -0
  58. package/dist/cjs/engine/createMatcher.js.map +1 -0
  59. package/dist/cjs/engine/operations/routeTreeToDefinitions.js +2 -0
  60. package/dist/cjs/engine/operations/routeTreeToDefinitions.js.map +1 -0
  61. package/dist/cjs/engine/path-matcher/SegmentMatcher.d.ts +16 -0
  62. package/dist/cjs/engine/path-matcher/SegmentMatcher.d.ts.map +1 -0
  63. package/dist/cjs/engine/path-matcher/SegmentMatcher.js +2 -0
  64. package/dist/cjs/engine/path-matcher/SegmentMatcher.js.map +1 -0
  65. package/dist/cjs/engine/path-matcher/buildParamMeta.js +2 -0
  66. package/dist/cjs/engine/path-matcher/buildParamMeta.js.map +1 -0
  67. package/dist/cjs/engine/path-matcher/encoding.js +2 -0
  68. package/dist/cjs/engine/path-matcher/encoding.js.map +1 -0
  69. package/dist/cjs/engine/path-matcher/parseSegment.js +2 -0
  70. package/dist/cjs/engine/path-matcher/parseSegment.js.map +1 -0
  71. package/dist/cjs/engine/path-matcher/pathUtils.js +2 -0
  72. package/dist/cjs/engine/path-matcher/pathUtils.js.map +1 -0
  73. package/dist/cjs/engine/path-matcher/percentEncoding.js +2 -0
  74. package/dist/cjs/engine/path-matcher/percentEncoding.js.map +1 -0
  75. package/dist/cjs/engine/path-matcher/registration/buildParts.js +2 -0
  76. package/dist/cjs/engine/path-matcher/registration/buildParts.js.map +1 -0
  77. package/dist/cjs/engine/path-matcher/registration/context.js +2 -0
  78. package/dist/cjs/engine/path-matcher/registration/context.js.map +1 -0
  79. package/dist/cjs/engine/path-matcher/registration/errors.js +2 -0
  80. package/dist/cjs/engine/path-matcher/registration/errors.js.map +1 -0
  81. package/dist/cjs/engine/path-matcher/registration/index.js +2 -0
  82. package/dist/cjs/engine/path-matcher/registration/index.js.map +1 -0
  83. package/dist/cjs/engine/path-matcher/registration/trie.js +2 -0
  84. package/dist/cjs/engine/path-matcher/registration/trie.js.map +1 -0
  85. package/dist/cjs/engine/path-matcher/registration/trieNodes.js +2 -0
  86. package/dist/cjs/engine/path-matcher/registration/trieNodes.js.map +1 -0
  87. package/dist/cjs/{types-DaXCTxi1.d.ts → engine/path-matcher/types.d.ts} +2 -47
  88. package/dist/cjs/engine/path-matcher/types.d.ts.map +1 -0
  89. package/dist/cjs/engine/search-params/decode.js +2 -0
  90. package/dist/cjs/engine/search-params/decode.js.map +1 -0
  91. package/dist/cjs/engine/search-params/encode.js +2 -0
  92. package/dist/cjs/engine/search-params/encode.js.map +1 -0
  93. package/dist/cjs/engine/search-params/searchParams.js +2 -0
  94. package/dist/cjs/engine/search-params/searchParams.js.map +1 -0
  95. package/dist/cjs/engine/search-params/strategies/array.js +2 -0
  96. package/dist/cjs/engine/search-params/strategies/array.js.map +1 -0
  97. package/dist/cjs/engine/search-params/strategies/boolean.js +2 -0
  98. package/dist/cjs/engine/search-params/strategies/boolean.js.map +1 -0
  99. package/dist/cjs/engine/search-params/strategies/index.js +2 -0
  100. package/dist/cjs/engine/search-params/strategies/index.js.map +1 -0
  101. package/dist/cjs/engine/search-params/strategies/null.js +2 -0
  102. package/dist/cjs/engine/search-params/strategies/null.js.map +1 -0
  103. package/dist/cjs/engine/search-params/strategies/number.js +2 -0
  104. package/dist/cjs/engine/search-params/strategies/number.js.map +1 -0
  105. package/dist/cjs/engine/search-params/types.d.ts +72 -0
  106. package/dist/cjs/engine/search-params/types.d.ts.map +1 -0
  107. package/dist/cjs/engine/search-params/utils.js +2 -0
  108. package/dist/cjs/engine/search-params/utils.js.map +1 -0
  109. package/dist/cjs/engine/validation/route-batch.d.ts +38 -0
  110. package/dist/cjs/engine/validation/route-batch.d.ts.map +1 -0
  111. package/dist/cjs/engine/validation/route-batch.js +2 -0
  112. package/dist/cjs/engine/validation/route-batch.js.map +1 -0
  113. package/dist/cjs/engine/validation/routes.js +2 -0
  114. package/dist/cjs/engine/validation/routes.js.map +1 -0
  115. package/dist/cjs/foundation/event-emitter/EventEmitter.js +2 -0
  116. package/dist/cjs/foundation/event-emitter/EventEmitter.js.map +1 -0
  117. package/dist/cjs/foundation/fsm/fsm.js +2 -0
  118. package/dist/cjs/foundation/fsm/fsm.js.map +1 -0
  119. package/dist/cjs/foundation/logger/RouterLogger.js +2 -0
  120. package/dist/cjs/foundation/logger/RouterLogger.js.map +1 -0
  121. package/dist/cjs/foundation/logger/constants.js +2 -0
  122. package/dist/cjs/foundation/logger/constants.js.map +1 -0
  123. package/dist/cjs/getNavigator.d.ts +6 -0
  124. package/dist/cjs/getNavigator.d.ts.map +1 -0
  125. package/dist/cjs/getNavigator.js +2 -0
  126. package/dist/cjs/getNavigator.js.map +1 -0
  127. package/dist/cjs/guards.js +2 -0
  128. package/dist/cjs/guards.js.map +1 -0
  129. package/dist/cjs/helpers.js +2 -0
  130. package/dist/cjs/helpers.js.map +1 -0
  131. package/dist/cjs/index.d.ts +17 -239
  132. package/dist/cjs/index.js +1 -2
  133. package/dist/cjs/internals.d.ts +98 -0
  134. package/dist/cjs/internals.d.ts.map +1 -0
  135. package/dist/cjs/internals.js +2 -0
  136. package/dist/cjs/internals.js.map +1 -0
  137. package/dist/cjs/namespaces/DependenciesNamespace/dependenciesStore.d.ts +10 -0
  138. package/dist/cjs/namespaces/DependenciesNamespace/dependenciesStore.d.ts.map +1 -0
  139. package/dist/cjs/namespaces/DependenciesNamespace/dependenciesStore.js +2 -0
  140. package/dist/cjs/namespaces/DependenciesNamespace/dependenciesStore.js.map +1 -0
  141. package/dist/cjs/namespaces/EventBusNamespace/EventBusNamespace.js +2 -0
  142. package/dist/cjs/namespaces/EventBusNamespace/EventBusNamespace.js.map +1 -0
  143. package/dist/cjs/namespaces/NavigationNamespace/NavigationNamespace.js +2 -0
  144. package/dist/cjs/namespaces/NavigationNamespace/NavigationNamespace.js.map +1 -0
  145. package/dist/cjs/namespaces/NavigationNamespace/constants.js +2 -0
  146. package/dist/cjs/namespaces/NavigationNamespace/constants.js.map +1 -0
  147. package/dist/cjs/namespaces/NavigationNamespace/transition/completeTransition.js +2 -0
  148. package/dist/cjs/namespaces/NavigationNamespace/transition/completeTransition.js.map +1 -0
  149. package/dist/cjs/namespaces/NavigationNamespace/transition/errorHandling.js +2 -0
  150. package/dist/cjs/namespaces/NavigationNamespace/transition/errorHandling.js.map +1 -0
  151. package/dist/cjs/namespaces/NavigationNamespace/transition/guardPhase.js +2 -0
  152. package/dist/cjs/namespaces/NavigationNamespace/transition/guardPhase.js.map +1 -0
  153. package/dist/cjs/namespaces/OptionsNamespace/OptionsNamespace.js +2 -0
  154. package/dist/cjs/namespaces/OptionsNamespace/OptionsNamespace.js.map +1 -0
  155. package/dist/cjs/namespaces/OptionsNamespace/constants.js +2 -0
  156. package/dist/cjs/namespaces/OptionsNamespace/constants.js.map +1 -0
  157. package/dist/cjs/namespaces/OptionsNamespace/helpers.js +2 -0
  158. package/dist/cjs/namespaces/OptionsNamespace/helpers.js.map +1 -0
  159. package/dist/cjs/namespaces/OptionsNamespace/validators.js +2 -0
  160. package/dist/cjs/namespaces/OptionsNamespace/validators.js.map +1 -0
  161. package/dist/cjs/namespaces/PluginsNamespace/PluginsNamespace.js +2 -0
  162. package/dist/cjs/namespaces/PluginsNamespace/PluginsNamespace.js.map +1 -0
  163. package/dist/cjs/namespaces/PluginsNamespace/constants.js +2 -0
  164. package/dist/cjs/namespaces/PluginsNamespace/constants.js.map +1 -0
  165. package/dist/cjs/namespaces/PluginsNamespace/validators.js +2 -0
  166. package/dist/cjs/namespaces/PluginsNamespace/validators.js.map +1 -0
  167. package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts +174 -0
  168. package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts.map +1 -0
  169. package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.js +2 -0
  170. package/dist/cjs/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.js.map +1 -0
  171. package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts +17 -0
  172. package/dist/cjs/namespaces/RouteLifecycleNamespace/types.d.ts.map +1 -0
  173. package/dist/cjs/namespaces/RouterLifecycleNamespace/RouterLifecycleNamespace.js +2 -0
  174. package/dist/cjs/namespaces/RouterLifecycleNamespace/RouterLifecycleNamespace.js.map +1 -0
  175. package/dist/cjs/namespaces/RouterLifecycleNamespace/constants.js +2 -0
  176. package/dist/cjs/namespaces/RouterLifecycleNamespace/constants.js.map +1 -0
  177. package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.js +2 -0
  178. package/dist/cjs/namespaces/RoutesNamespace/RoutesNamespace.js.map +1 -0
  179. package/dist/cjs/namespaces/RoutesNamespace/constants.js +2 -0
  180. package/dist/cjs/namespaces/RoutesNamespace/constants.js.map +1 -0
  181. package/dist/cjs/namespaces/RoutesNamespace/forwardChain.d.ts +5 -0
  182. package/dist/cjs/namespaces/RoutesNamespace/forwardChain.d.ts.map +1 -0
  183. package/dist/cjs/namespaces/RoutesNamespace/forwardChain.js +2 -0
  184. package/dist/cjs/namespaces/RoutesNamespace/forwardChain.js.map +1 -0
  185. package/dist/cjs/namespaces/RoutesNamespace/helpers.js +2 -0
  186. package/dist/cjs/namespaces/RoutesNamespace/helpers.js.map +1 -0
  187. package/dist/cjs/namespaces/RoutesNamespace/routeGuards.js +2 -0
  188. package/dist/cjs/namespaces/RoutesNamespace/routeGuards.js.map +1 -0
  189. package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts +42 -0
  190. package/dist/cjs/namespaces/RoutesNamespace/routesStore.d.ts.map +1 -0
  191. package/dist/cjs/namespaces/RoutesNamespace/routesStore.js +2 -0
  192. package/dist/cjs/namespaces/RoutesNamespace/routesStore.js.map +1 -0
  193. package/dist/cjs/namespaces/RoutesNamespace/types.d.ts +57 -0
  194. package/dist/cjs/namespaces/RoutesNamespace/types.d.ts.map +1 -0
  195. package/dist/cjs/namespaces/StateNamespace/StateNamespace.js +2 -0
  196. package/dist/cjs/namespaces/StateNamespace/StateNamespace.js.map +1 -0
  197. package/dist/cjs/namespaces/StateNamespace/helpers.js +2 -0
  198. package/dist/cjs/namespaces/StateNamespace/helpers.js.map +1 -0
  199. package/dist/cjs/routerFSM.js +2 -0
  200. package/dist/cjs/routerFSM.js.map +1 -0
  201. package/dist/cjs/stateMetaStore.js +2 -0
  202. package/dist/cjs/stateMetaStore.js.map +1 -0
  203. package/dist/cjs/transitionPath.js +2 -0
  204. package/dist/cjs/transitionPath.js.map +1 -0
  205. package/dist/cjs/{RouterValidator-CZ8kPkrI.d.ts → types/RouterValidator.d.ts} +2 -2
  206. package/dist/cjs/types/RouterValidator.d.ts.map +1 -0
  207. package/dist/cjs/types/api.d.ts +184 -0
  208. package/dist/cjs/types/api.d.ts.map +1 -0
  209. package/dist/cjs/types/base.d.ts +95 -0
  210. package/dist/cjs/types/base.d.ts.map +1 -0
  211. package/dist/cjs/types/constants.d.ts +72 -0
  212. package/dist/cjs/types/constants.d.ts.map +1 -0
  213. package/dist/cjs/types/internal.d.ts +9 -0
  214. package/dist/cjs/types/internal.d.ts.map +1 -0
  215. package/dist/cjs/types/limits.d.ts +45 -0
  216. package/dist/cjs/types/limits.d.ts.map +1 -0
  217. package/dist/cjs/types/route-node-types.d.ts +46 -0
  218. package/dist/cjs/types/route-node-types.d.ts.map +1 -0
  219. package/dist/cjs/types/router.d.ts +313 -0
  220. package/dist/cjs/types/router.d.ts.map +1 -0
  221. package/dist/cjs/types/tree-changed.d.ts +55 -0
  222. package/dist/cjs/types/tree-changed.d.ts.map +1 -0
  223. package/dist/cjs/types.d.ts +208 -2
  224. package/dist/cjs/types.d.ts.map +1 -0
  225. package/dist/cjs/validation.d.ts +6 -518
  226. package/dist/cjs/validation.js +1 -2
  227. package/dist/cjs/wiring/wireNamespaces.js +2 -0
  228. package/dist/cjs/wiring/wireNamespaces.js.map +1 -0
  229. package/dist/esm/Router-Bk6PfSE8.mjs +2 -0
  230. package/dist/esm/{Router-DikzugaD.mjs.map → Router-Bk6PfSE8.mjs.map} +1 -1
  231. package/dist/esm/{Router-Cy75qbgU.d.mts → Router.d.mts} +5 -4
  232. package/dist/esm/Router.d.mts.map +1 -0
  233. package/dist/esm/RouterError.d.mts +182 -0
  234. package/dist/esm/RouterError.d.mts.map +1 -0
  235. package/dist/esm/api/cloneRouter.d.mts +86 -0
  236. package/dist/esm/api/cloneRouter.d.mts.map +1 -0
  237. package/dist/esm/api/getDependenciesApi.d.mts +7 -0
  238. package/dist/esm/api/getDependenciesApi.d.mts.map +1 -0
  239. package/dist/esm/api/getLifecycleApi.d.mts +7 -0
  240. package/dist/esm/api/getLifecycleApi.d.mts.map +1 -0
  241. package/dist/esm/api/getPluginApi.d.mts +7 -0
  242. package/dist/esm/api/getPluginApi.d.mts.map +1 -0
  243. package/dist/esm/api/getRoutesApi.d.mts +7 -0
  244. package/dist/esm/api/getRoutesApi.d.mts.map +1 -0
  245. package/dist/esm/api/types.d.mts +9 -0
  246. package/dist/esm/api/types.d.mts.map +1 -0
  247. package/dist/esm/api.d.mts +8 -105
  248. package/dist/esm/api.mjs +1 -1
  249. package/dist/esm/api.mjs.map +1 -1
  250. package/dist/esm/buildParamMeta-bOLhLF9h.mjs.map +1 -1
  251. package/dist/esm/constants.d.mts +25 -0
  252. package/dist/esm/constants.d.mts.map +1 -0
  253. package/dist/esm/createRouter.d.mts +23 -0
  254. package/dist/esm/createRouter.d.mts.map +1 -0
  255. package/dist/esm/engine/builder/types.d.mts +48 -0
  256. package/dist/esm/engine/builder/types.d.mts.map +1 -0
  257. package/dist/esm/engine/createMatcher.d.mts +29 -0
  258. package/dist/esm/engine/createMatcher.d.mts.map +1 -0
  259. package/dist/esm/engine/path-matcher/SegmentMatcher.d.mts +16 -0
  260. package/dist/esm/engine/path-matcher/SegmentMatcher.d.mts.map +1 -0
  261. package/dist/esm/{types-DaXCTxi1.d.mts → engine/path-matcher/types.d.mts} +2 -47
  262. package/dist/esm/engine/path-matcher/types.d.mts.map +1 -0
  263. package/dist/esm/engine/search-params/types.d.mts +72 -0
  264. package/dist/esm/engine/search-params/types.d.mts.map +1 -0
  265. package/dist/esm/engine/validation/route-batch.d.mts +38 -0
  266. package/dist/esm/engine/validation/route-batch.d.mts.map +1 -0
  267. package/dist/esm/getNavigator.d.mts +6 -0
  268. package/dist/esm/getNavigator.d.mts.map +1 -0
  269. package/dist/esm/index.d.mts +17 -239
  270. package/dist/esm/index.mjs +1 -1
  271. package/dist/esm/internals.d.mts +98 -0
  272. package/dist/esm/internals.d.mts.map +1 -0
  273. package/dist/esm/namespaces/DependenciesNamespace/dependenciesStore.d.mts +10 -0
  274. package/dist/esm/namespaces/DependenciesNamespace/dependenciesStore.d.mts.map +1 -0
  275. package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts +174 -0
  276. package/dist/esm/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.mts.map +1 -0
  277. package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts +17 -0
  278. package/dist/esm/namespaces/RouteLifecycleNamespace/types.d.mts.map +1 -0
  279. package/dist/esm/namespaces/RoutesNamespace/forwardChain.d.mts +5 -0
  280. package/dist/esm/namespaces/RoutesNamespace/forwardChain.d.mts.map +1 -0
  281. package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts +42 -0
  282. package/dist/esm/namespaces/RoutesNamespace/routesStore.d.mts.map +1 -0
  283. package/dist/esm/namespaces/RoutesNamespace/types.d.mts +57 -0
  284. package/dist/esm/namespaces/RoutesNamespace/types.d.mts.map +1 -0
  285. package/dist/esm/{RouterValidator-CZ8kPkrI.d.mts → types/RouterValidator.d.mts} +2 -2
  286. package/dist/esm/types/RouterValidator.d.mts.map +1 -0
  287. package/dist/esm/types/api.d.mts +184 -0
  288. package/dist/esm/types/api.d.mts.map +1 -0
  289. package/dist/esm/types/base.d.mts +95 -0
  290. package/dist/esm/types/base.d.mts.map +1 -0
  291. package/dist/esm/types/constants.d.mts +72 -0
  292. package/dist/esm/types/constants.d.mts.map +1 -0
  293. package/dist/esm/types/internal.d.mts +9 -0
  294. package/dist/esm/types/internal.d.mts.map +1 -0
  295. package/dist/esm/types/limits.d.mts +45 -0
  296. package/dist/esm/types/limits.d.mts.map +1 -0
  297. package/dist/esm/types/route-node-types.d.mts +46 -0
  298. package/dist/esm/types/route-node-types.d.mts.map +1 -0
  299. package/dist/esm/types/router.d.mts +313 -0
  300. package/dist/esm/types/router.d.mts.map +1 -0
  301. package/dist/esm/types/tree-changed.d.mts +55 -0
  302. package/dist/esm/types/tree-changed.d.mts.map +1 -0
  303. package/dist/esm/types.d.mts +208 -2
  304. package/dist/esm/types.d.mts.map +1 -0
  305. package/dist/esm/validation.d.mts +6 -518
  306. package/package.json +5 -14
  307. package/dist/cjs/Router-BG5yNYUG.d.ts.map +0 -1
  308. package/dist/cjs/Router-BRuC-daj.js +0 -2
  309. package/dist/cjs/RouterValidator-CZ8kPkrI.d.ts.map +0 -1
  310. package/dist/cjs/api.d.ts.map +0 -1
  311. package/dist/cjs/cloneRouter-3AOUeQ8M.js +0 -2
  312. package/dist/cjs/cloneRouter-3AOUeQ8M.js.map +0 -1
  313. package/dist/cjs/index-CAnGQpnz.d.ts +0 -974
  314. package/dist/cjs/index-CAnGQpnz.d.ts.map +0 -1
  315. package/dist/cjs/index-DDrryY2U.d.ts +0 -309
  316. package/dist/cjs/index-DDrryY2U.d.ts.map +0 -1
  317. package/dist/cjs/index.d.ts.map +0 -1
  318. package/dist/cjs/types-DaXCTxi1.d.ts.map +0 -1
  319. package/dist/cjs/utils.d.ts +0 -2
  320. package/dist/cjs/utils.js +0 -2
  321. package/dist/cjs/utils.js.map +0 -1
  322. package/dist/cjs/validation.d.ts.map +0 -1
  323. package/dist/esm/Router-Cy75qbgU.d.mts.map +0 -1
  324. package/dist/esm/Router-DikzugaD.mjs +0 -2
  325. package/dist/esm/RouterValidator-CZ8kPkrI.d.mts.map +0 -1
  326. package/dist/esm/api.d.mts.map +0 -1
  327. package/dist/esm/cloneRouter-CAh5vA3l.mjs +0 -2
  328. package/dist/esm/cloneRouter-CAh5vA3l.mjs.map +0 -1
  329. package/dist/esm/index-CAnGQpnz.d.mts +0 -974
  330. package/dist/esm/index-CAnGQpnz.d.mts.map +0 -1
  331. package/dist/esm/index-DnSU6huX.d.mts +0 -309
  332. package/dist/esm/index-DnSU6huX.d.mts.map +0 -1
  333. package/dist/esm/index.d.mts.map +0 -1
  334. package/dist/esm/types-DaXCTxi1.d.mts.map +0 -1
  335. package/dist/esm/utils.d.mts +0 -2
  336. package/dist/esm/utils.mjs +0 -2
  337. package/dist/esm/utils.mjs.map +0 -1
  338. package/dist/esm/validation.d.mts.map +0 -1
@@ -1,974 +0,0 @@
1
- //#region src/types/route-node-types.d.ts
2
- /**
3
- * Route Node Type Definitions — Minimal Public API.
4
- *
5
- * This module exports ONLY the essential types used by real-router:
6
- * - QueryParamsMode, QueryParamsOptions
7
- * - RouteParams, RouteTreeState
8
- *
9
- * These types are copied from route-node to avoid circular dependencies.
10
- *
11
- * @module route-node-types
12
- */
13
- type ArrayFormat = "none" | "brackets" | "index" | "comma";
14
- type BooleanFormat = "none" | "auto" | "empty-true";
15
- type NullFormat = "default" | "hidden";
16
- type NumberFormat = "none" | "auto";
17
- /**
18
- * Options for query parameter parsing and building.
19
- */
20
- interface QueryParamsOptions {
21
- arrayFormat?: ArrayFormat;
22
- booleanFormat?: BooleanFormat;
23
- nullFormat?: NullFormat;
24
- numberFormat?: NumberFormat;
25
- }
26
- /**
27
- * Controls how query parameters are handled during matching.
28
- */
29
- type QueryParamsMode = "default" | "strict" | "loose";
30
- type ParamSource = "url" | "query";
31
- type ParamTypeMap = Record<string, ParamSource>;
32
- type RouteTreeStateMeta = Record<string, ParamTypeMap>;
33
- interface RouteParams {
34
- [key: string]: string | string[] | number | number[] | boolean | boolean[] | RouteParams | RouteParams[] | Record<string, string | number | boolean> | null | undefined;
35
- }
36
- /**
37
- * Complete state representation of a matched route.
38
- */
39
- interface RouteTreeState<P extends Record<string, unknown> = RouteParams> {
40
- name: string;
41
- params: P;
42
- meta: RouteTreeStateMeta;
43
- }
44
- //#endregion
45
- //#region src/types/base.d.ts
46
- /**
47
- * Detach function returned by subscription APIs.
48
- *
49
- * @description
50
- * Calling this function removes the associated listener. Returned by
51
- * `router.subscribe()`, `router.addEventListener()`, `router.subscribeLeave()`,
52
- * and plugin interceptors. Idempotent — calling more than once is safe and
53
- * has no additional effect after the first call.
54
- */
55
- type Unsubscribe = () => void;
56
- interface SimpleState<P extends Params = Params> {
57
- name: string;
58
- params: P;
59
- }
60
- type TransitionPhase = "deactivating" | "activating";
61
- type TransitionReason = "success" | "blocked" | "cancelled" | "error";
62
- interface TransitionMeta {
63
- phase: TransitionPhase;
64
- reason: TransitionReason;
65
- reload?: boolean;
66
- replace?: boolean;
67
- redirected?: boolean;
68
- from?: string;
69
- blocker?: string;
70
- segments: {
71
- deactivated: string[];
72
- activated: string[];
73
- intersection: string;
74
- };
75
- }
76
- /**
77
- * Empty interface extended by plugins via module augmentation to declare
78
- * typed `state.context.<namespace>` fields.
79
- *
80
- * @description
81
- * Plugins add typed context namespaces by augmenting this interface:
82
- *
83
- * ```typescript
84
- * declare module "@real-router/core/types" {
85
- * interface StateContext {
86
- * navigation: { direction: "forward" | "back" | "navigate" };
87
- * }
88
- * }
89
- * ```
90
- *
91
- * After augmentation, `state.context.navigation` becomes typed. The intersection
92
- * with `Record<string, unknown>` in {@link State.context} keeps the type open,
93
- * so plugins that don't augment can still write arbitrary namespaces.
94
- *
95
- * @see {@link State.context}
96
- * @see {@link ContextNamespaceClaim}
97
- */
98
- interface StateContext {}
99
- interface State<P extends Params = Params> {
100
- name: string;
101
- params: P;
102
- path: string;
103
- transition: TransitionMeta;
104
- /**
105
- * Plugin-extensible per-route data, attached by plugins via
106
- * `PluginApi.claimContextNamespace()` + `claim.write(state, value)`.
107
- *
108
- * @description
109
- * Required field — always present as at least `{}` on every State created by
110
- * the router (via `makeState`, `navigateToNotFound`, or `cloneRouter`).
111
- *
112
- * Typed extensions come from plugins augmenting {@link StateContext} through
113
- * module augmentation. The intersection with `Record<string, unknown>` allows
114
- * untyped namespaces (inline plugins, tests, or plugins that skip augmentation)
115
- * to write without compile errors.
116
- *
117
- * The `context` object itself is **not frozen** — this is intentional, so
118
- * plugins can attach data without cloning state. Core structural fields
119
- * (`name`, `params`, `path`, `transition`) remain immutable via shallow
120
- * `Object.freeze(state)`.
121
- *
122
- * @see {@link StateContext}
123
- */
124
- context: StateContext & Record<string, unknown>;
125
- }
126
- interface StateMetaInput<P extends Params = Params> {
127
- params: P;
128
- }
129
- /**
130
- * RouterError interface describing the public API of the RouterError class.
131
- * The actual class implementation is in the real-router package.
132
- * This interface enables structural typing compatibility between
133
- * core-types and real-router packages.
134
- */
135
- interface RouterError extends Error {
136
- [key: string]: unknown;
137
- readonly code: string;
138
- readonly segment: string | undefined;
139
- readonly path: string | undefined;
140
- setCode: (code: string) => void;
141
- setErrorInstance: (err: Error) => void;
142
- setAdditionalFields: (fields: Record<string, unknown>) => void;
143
- hasField: (key: string) => boolean;
144
- getField: (key: string) => unknown;
145
- toJSON: () => Record<string, unknown>;
146
- }
147
- /**
148
- * Configuration options that control navigation transition behavior.
149
- *
150
- * @description
151
- * NavigationOptions provides fine-grained control over how the router performs navigation
152
- * transitions. These options affect history management, transition lifecycle execution,
153
- * guard enforcement, and state comparison logic.
154
- *
155
- * All options are optional and have sensible defaults. Options can be combined to achieve
156
- * complex navigation behaviors. These options are available to guards and event listeners.
157
- *
158
- * @see {@link Router.navigate} for navigation method that accepts these options
159
- */
160
- interface NavigationOptions {
161
- /**
162
- * Replace the current history entry instead of pushing a new one.
163
- *
164
- * @description
165
- * When `true`, the navigation will replace the current entry in browser history instead
166
- * of adding a new entry. This is typically used by history plugins (browser plugin) to
167
- * control how navigation affects the browser's back/forward buttons.
168
- *
169
- * @default false
170
- *
171
- * @example
172
- * // Redirect after login - prevent back button to login page
173
- * router.navigate('dashboard', {}, { replace: true });
174
- *
175
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState}
176
- */
177
- replace?: boolean | undefined;
178
- /**
179
- * Marks a `replace()` state-revalidation emit — a core-set signal, NOT a
180
- * user-facing navigation option.
181
- *
182
- * @description
183
- * `getRoutesApi(router).replace(...)` revalidates the active state against the
184
- * new tree and emits `TRANSITION_SUCCESS` (#950). Core sets `revalidate: true`
185
- * on that emit so a plugin's `onTransitionSuccess(toState, fromState, opts)`
186
- * can distinguish a revalidation from a real navigation — both otherwise carry
187
- * `replace: true` and are indistinguishable (#1201). Passing it to
188
- * `router.navigate(...)` has no effect on the navigation itself.
189
- *
190
- * @default undefined
191
- */
192
- revalidate?: boolean | undefined;
193
- /**
194
- * Force reload of the current route even if states are equal.
195
- *
196
- * @description
197
- * When `true`, bypasses the "same state" check that normally prevents navigation when
198
- * the target state equals the current state. This forces a full transition lifecycle
199
- * execution, allowing route components to reload with the same parameters.
200
- *
201
- * Without `reload`:
202
- * - Navigation to current route throws SAME_STATES error
203
- * - No lifecycle hooks execute
204
- * - No events are fired
205
- *
206
- * With `reload`:
207
- * - Full transition executes (deactivate → activate)
208
- * - All lifecycle hooks run again
209
- * - TRANSITION_SUCCESS event fires with same state
210
- * - State object is recreated (new reference)
211
- *
212
- * @default false
213
- *
214
- * @example
215
- * // Refresh current page data
216
- * router.navigate(currentRoute.name, currentRoute.params, { reload: true });
217
- *
218
- * @example
219
- * // Force re-fetch on same route with different query params
220
- * // Note: query params are in path, not checked for equality
221
- * router.navigate('search', { term: 'react' }, { reload: true });
222
- *
223
- * @see {@link force} for alternative that forces transition
224
- * @see {@link Router.areStatesEqual} for state comparison logic
225
- */
226
- reload?: boolean | undefined;
227
- /**
228
- * Force navigation even if target state equals current state.
229
- *
230
- * @description
231
- * When `true`, bypasses the "same state" equality check but still executes the full
232
- * transition lifecycle. Similar to `reload` but can be used
233
- * for any forced navigation scenario.
234
- *
235
- * Difference from `reload`:
236
- * - `reload`: semantic meaning is "refresh current route"
237
- * - `force`: general-purpose bypass of equality check
238
- * - Both have identical implementation effect
239
- *
240
- * The equality check compares:
241
- * - state.name (route name)
242
- * - state.params (route parameters, shallow comparison)
243
- *
244
- * @default false
245
- *
246
- * @example
247
- * // Force transition for tracking even if params didn't change
248
- * router.navigate('analytics', { event: 'pageview' }, { force: true });
249
- *
250
- * @see {@link reload} for semantic equivalent (preferred for refresh scenarios)
251
- */
252
- force?: boolean | undefined;
253
- /**
254
- * Skip canDeactivate guards during transition.
255
- *
256
- * @description
257
- * When `true`, bypasses only the canDeactivate lifecycle hooks for segments being
258
- * deactivated. canActivate guards still execute normally. This allows
259
- * forcing navigation away from routes with confirmation dialogs or unsaved changes.
260
- *
261
- * Skipped vs executed:
262
- * ```
263
- * // Normal transition
264
- * deactivate(fromSegments) → activate(toSegments) → success
265
- *
266
- * // With forceDeactivate: true
267
- * [skip deactivate] → activate(toSegments) → success
268
- * ```
269
- *
270
- * ⚠️ Data loss risk: Bypassing canDeactivate means unsaved changes will be lost
271
- *
272
- * @default false
273
- *
274
- * @example
275
- * // Force logout even with unsaved changes
276
- * function forceLogout() {
277
- * router.navigate('login', {}, {
278
- * forceDeactivate: true,
279
- * replace: true
280
- * });
281
- * }
282
- *
283
- * @see {@link Router.clearCanDeactivate} for programmatically clearing guards
284
- */
285
- forceDeactivate?: boolean | undefined;
286
- /**
287
- * Internal flag indicating navigation is result of a redirect.
288
- *
289
- * @internal
290
- *
291
- * @description
292
- * Automatically set by the router when a navigation is triggered by a redirect.
293
- * Available on `state.transition` after successful navigation (not during guard execution).
294
- *
295
- * @default false (auto-set by router during redirects)
296
- *
297
- * @example
298
- * // Accessing redirect flag in TRANSITION_SUCCESS listener
299
- * router.addEventListener('TRANSITION_SUCCESS', (state) => {
300
- * if (state.transition?.redirected) {
301
- * console.log('This navigation is from a redirect');
302
- * }
303
- * });
304
- *
305
- * @see {@link Router.navigate} for redirect handling implementation
306
- * @see {@link NavigationOptions.redirected} for the input mechanism
307
- */
308
- redirected?: boolean | undefined;
309
- /**
310
- * Optional abort signal for cancelling the navigation.
311
- *
312
- * @description
313
- * When provided, this signal can be used to cancel the navigation operation.
314
- * If the signal is aborted, the navigation will be cancelled and any pending
315
- * guards or transitions will be interrupted.
316
- *
317
- * @default undefined
318
- */
319
- signal?: AbortSignal | undefined;
320
- }
321
- interface Params {
322
- [key: string]: string | string[] | number | number[] | boolean | boolean[] | Params | Params[] | Record<string, string | number | boolean> | null | undefined;
323
- }
324
- //#endregion
325
- //#region src/types/limits.d.ts
326
- /**
327
- * Configuration for router resource limits.
328
- * Controls maximum allowed values for various router operations to prevent resource exhaustion.
329
- */
330
- interface LimitsConfig {
331
- /**
332
- * Maximum number of route dependencies allowed.
333
- * Prevents circular dependency chains and excessive dependency graphs.
334
- *
335
- * @default 100
336
- */
337
- maxDependencies: number;
338
- /**
339
- * Maximum number of plugins that can be registered.
340
- * Limits plugin stack depth to prevent performance degradation.
341
- *
342
- * @default 50
343
- */
344
- maxPlugins: number;
345
- /**
346
- * Maximum number of event listeners per event type.
347
- * Prevents memory leaks from excessive listener registration.
348
- *
349
- * @default 10000
350
- */
351
- maxListeners: number;
352
- /**
353
- * Listener count at which a memory leak warning is logged per event type.
354
- * Set to 0 to disable the warning.
355
- *
356
- * @default 1000
357
- */
358
- warnListeners: number;
359
- /**
360
- * Maximum number of lifecycle handlers (canActivate/canDeactivate) per route.
361
- * Controls guard function stack to prevent excessive validation overhead.
362
- *
363
- * @default 200
364
- */
365
- maxLifecycleHandlers: number;
366
- }
367
- //#endregion
368
- //#region src/types/router.d.ts
369
- type LogLevel = "log" | "warn" | "error";
370
- type LogLevelConfig = "all" | "warn-error" | "error-only" | "none";
371
- type LogCallback = (level: LogLevel, context: string, message: string, ...args: unknown[]) => void;
372
- interface LoggerConfig {
373
- level: LogLevelConfig;
374
- callback?: LogCallback | undefined;
375
- callbackIgnoresLevel?: boolean;
376
- }
377
- /**
378
- * Per-router logging surface — the contract core writes through and plugins
379
- * consume.
380
- *
381
- * Core stores a concrete instance on `RouterInternals.logger` (built from
382
- * `options.logger` in the `Router` constructor); plugins and other consumers
383
- * reach that same per-instance logger via `getPluginApi(router).logger`. The
384
- * concrete `RouterLogger` class lives in core's `foundation/logger` — this
385
- * interface is the shared contract, so nothing outside core needs to import the
386
- * class (or depend on the former standalone `@real-router/logger` package).
387
- */
388
- interface RouterLogger {
389
- log: (context: string, message: string, ...args: unknown[]) => void;
390
- warn: (context: string, message: string, ...args: unknown[]) => void;
391
- error: (context: string, message: string, ...args: unknown[]) => void;
392
- }
393
- /**
394
- * Callback function for dynamically resolving the default route.
395
- * Receives a dependency getter function to access router dependencies.
396
- */
397
- type DefaultRouteCallback<Dependencies = object> = (getDependency: <K extends keyof Dependencies>(name: K) => Dependencies[K]) => string;
398
- /**
399
- * Callback function for dynamically resolving the forward target route.
400
- * Receives a dependency getter function and current route parameters.
401
- */
402
- type ForwardToCallback<Dependencies = object> = (getDependency: <K extends keyof Dependencies>(name: K) => Dependencies[K], params: Params) => string;
403
- /**
404
- * Callback function for dynamically resolving the default parameters.
405
- * Receives a dependency getter function to access router dependencies.
406
- */
407
- type DefaultParamsCallback<Dependencies = object> = (getDependency: <K extends keyof Dependencies>(name: K) => Dependencies[K]) => Params;
408
- /**
409
- * Router configuration options.
410
- *
411
- * Note: For input, use `Partial<Options>` as all fields have defaults.
412
- * After initialization, `getOptions()` returns resolved `Options` with all fields populated.
413
- */
414
- interface Options {
415
- /**
416
- * Default route to navigate to on start.
417
- * Empty string means no default route.
418
- *
419
- * @default ""
420
- */
421
- defaultRoute: string | DefaultRouteCallback;
422
- /**
423
- * Default parameters for the default route.
424
- *
425
- * @default {}
426
- */
427
- defaultParams: Params | DefaultParamsCallback;
428
- /**
429
- * How to handle trailing slashes in URLs.
430
- * - "strict": Route must match exactly
431
- * - "never": Always remove trailing slash
432
- * - "always": Always add trailing slash
433
- * - "preserve": Keep the source path's trailing-slash choice, even when
434
- * `rewritePathOnMatch: true` rewrites the rest of the path.
435
- *
436
- * @default "preserve"
437
- */
438
- trailingSlash: "strict" | "never" | "always" | "preserve";
439
- /**
440
- * Whether route matching is case-sensitive.
441
- *
442
- * When `false`, a mixed-case URL matches a lower-case route (`/Team` matches a
443
- * `/team` route). Dynamic param **values** keep their original case — only
444
- * static literal segments are compared case-insensitively.
445
- *
446
- * Default `true` (spec-correct: RFC 3986 §6.2.2.1 treats URL paths as
447
- * case-sensitive). Case-insensitive is an explicit **opt-in** for a narrow
448
- * niche — server-less / hash / static-hosted / legacy routing where no server
449
- * or edge layer can normalize the URL's case before it reaches the router. For
450
- * public SSR/edge apps, prefer a canonical-lowercase redirect at the server
451
- * instead (SEO / dedup). Note the divergence from React Router v7 / TanStack /
452
- * vue-router, which default to case-**insensitive**.
453
- *
454
- * @default true
455
- */
456
- caseSensitive: boolean;
457
- /**
458
- * How to encode URL parameters.
459
- * - "default": Standard encoding
460
- * - "uri": URI encoding (encodeURI)
461
- * - "uriComponent": Component encoding (encodeURIComponent)
462
- * - "none": No encoding
463
- *
464
- * @default "default"
465
- */
466
- urlParamsEncoding: "default" | "uri" | "uriComponent" | "none";
467
- /**
468
- * How to handle query parameters.
469
- *
470
- * @default "loose"
471
- */
472
- queryParamsMode: QueryParamsMode;
473
- /**
474
- * Query parameter parsing options.
475
- *
476
- * @default undefined
477
- */
478
- queryParams?: QueryParamsOptions;
479
- /**
480
- * Allow matching routes that don't exist.
481
- * When true, unknown routes navigate without error.
482
- *
483
- * @default true
484
- */
485
- allowNotFound: boolean;
486
- /**
487
- * Rewrite `state.path` on successful match to the canonical path built
488
- * from the matched route's pattern. Applies `forwardTo` aliases, encoders,
489
- * `defaultParams`, and `trailingSlash` normalization (`"never"` / `"always"`).
490
- * When `trailingSlash: "preserve"`, the source path's trailing-slash choice
491
- * is kept on the rewritten path.
492
- *
493
- * @default true
494
- */
495
- rewritePathOnMatch: boolean;
496
- /**
497
- * Logger configuration.
498
- *
499
- * @default undefined
500
- */
501
- logger?: Partial<LoggerConfig>;
502
- /**
503
- * Router resource limits configuration.
504
- * Controls maximum allowed values for various router operations.
505
- *
506
- * @default DEFAULT_LIMITS (from LimitsNamespace)
507
- */
508
- limits?: Partial<LimitsConfig>;
509
- }
510
- type GuardFn = (toState: State, fromState: State | undefined, signal?: AbortSignal) => boolean | Promise<boolean>;
511
- type DefaultDependencies = object;
512
- interface Plugin {
513
- onStart?: () => void;
514
- onStop?: () => void;
515
- onTransitionStart?: (toState: State, fromState?: State) => void;
516
- onTransitionLeaveApprove?: (toState: State, fromState?: State) => void;
517
- onTransitionCancel?: (toState: State, fromState?: State) => void;
518
- onTransitionError?: (toState: State | undefined, fromState: State | undefined, err: RouterError) => void;
519
- onTransitionSuccess?: (toState: State, fromState: State | undefined, opts: NavigationOptions) => void;
520
- teardown?: () => void;
521
- }
522
- interface SubscribeState {
523
- route: State;
524
- previousRoute?: State | undefined;
525
- }
526
- type SubscribeFn = (state: SubscribeState) => void;
527
- interface LeaveState {
528
- route: State;
529
- nextRoute: State;
530
- signal: AbortSignal;
531
- }
532
- type LeaveFn = (state: LeaveState) => void | Promise<void>;
533
- interface Listener {
534
- [key: string]: unknown;
535
- next: (val: unknown) => void;
536
- error?: (err: unknown) => void;
537
- complete?: () => void;
538
- }
539
- interface Subscription {
540
- unsubscribe: Unsubscribe;
541
- }
542
- /**
543
- * Navigator interface - a minimal, safe subset of Router methods.
544
- *
545
- * Provides only the essential navigation and state inspection methods.
546
- * Excludes lifecycle methods (start, stop), plugin management, and internal APIs.
547
- * Use this when you need to pass a limited router interface to components.
548
- *
549
- * For full router access, use the Router interface directly or the useRouter() hook.
550
- */
551
- interface Navigator {
552
- navigate: (routeName: string, routeParams?: Params, options?: NavigationOptions) => Promise<State>;
553
- getState: () => State | undefined;
554
- isActiveRoute: (name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean) => boolean;
555
- canNavigateTo: (name: string, params?: Params) => boolean;
556
- subscribe: (listener: SubscribeFn) => Unsubscribe;
557
- subscribeLeave: (listener: LeaveFn) => Unsubscribe;
558
- isLeaveApproved: () => boolean;
559
- }
560
- /**
561
- * Router interface — full public API for route navigation and lifecycle management.
562
- *
563
- * Generic parameter D constrains dependency injection types.
564
- * Factory types (PluginFactory, GuardFnFactory) self-reference this interface
565
- * within the same file to avoid circular dependencies.
566
- */
567
- interface Router<D extends DefaultDependencies = DefaultDependencies> {
568
- [key: string]: unknown;
569
- isActiveRoute: (name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean) => boolean;
570
- buildPath: (route: string, params?: Params) => string;
571
- getState: <P extends Params = Params>() => State<P> | undefined;
572
- getPreviousState: () => State | undefined;
573
- areStatesEqual: (state1: State | undefined, state2: State | undefined, ignoreQueryParams?: boolean) => boolean;
574
- shouldUpdateNode: (nodeName: string) => (toState: State, fromState?: State) => boolean;
575
- isActive: () => boolean;
576
- start: (startPath: string) => Promise<State>;
577
- stop: () => this;
578
- dispose: () => void;
579
- canNavigateTo: (name: string, params?: Params) => boolean;
580
- usePlugin: (...plugins: (PluginFactory<D> | false | null | undefined)[]) => Unsubscribe;
581
- subscribe: (listener: SubscribeFn) => Unsubscribe;
582
- subscribeLeave: (listener: LeaveFn) => Unsubscribe;
583
- isLeaveApproved: () => boolean;
584
- navigate: (routeName: string, routeParams?: Params, options?: NavigationOptions) => Promise<State>;
585
- navigateToDefault: (options?: NavigationOptions) => Promise<State>;
586
- navigateToNotFound: (path?: string) => State;
587
- }
588
- /**
589
- * Factory function for creating plugins.
590
- * Receives the router instance and a dependency getter.
591
- */
592
- type PluginFactory<Dependencies extends DefaultDependencies = DefaultDependencies> = (router: Router<Dependencies>, getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K]) => Plugin;
593
- /**
594
- * Factory function for creating guards.
595
- * Receives the router instance and a dependency getter.
596
- */
597
- type GuardFnFactory<Dependencies extends DefaultDependencies = DefaultDependencies> = (router: Router<Dependencies>, getDependency: <K extends keyof Dependencies>(key: K) => Dependencies[K]) => GuardFn;
598
- /**
599
- * Route configuration.
600
- */
601
- interface Route<Dependencies extends DefaultDependencies = DefaultDependencies> {
602
- [key: string]: unknown;
603
- /** Route name (dot-separated for nested routes). */
604
- name: string;
605
- /** URL path pattern for this route. */
606
- path: string;
607
- /** Factory function that returns a guard for route activation. */
608
- canActivate?: GuardFnFactory<Dependencies>;
609
- /** Factory function that returns a guard for route deactivation. */
610
- canDeactivate?: GuardFnFactory<Dependencies>;
611
- /**
612
- * Redirects navigation to another route.
613
- *
614
- * IMPORTANT: forwardTo creates a URL alias, not a transition chain.
615
- * Guards (canActivate) on the source route are NOT executed.
616
- * Only guards on the final destination are executed.
617
- *
618
- * This matches Vue Router and Angular Router behavior.
619
- */
620
- forwardTo?: string | ForwardToCallback<Dependencies>;
621
- /** Nested child routes. */
622
- children?: Route<Dependencies>[];
623
- /** Encodes state params to URL params. */
624
- encodeParams?: (stateParams: Params) => Params;
625
- /** Decodes URL params to state params. */
626
- decodeParams?: (pathParams: Params) => Params;
627
- /**
628
- * Default parameters for this route.
629
- *
630
- * These values are merged into state.params when creating route states.
631
- * Missing URL params are filled from defaultParams.
632
- */
633
- defaultParams?: Params;
634
- }
635
- /**
636
- * Configuration update options for `updateRoute()`.
637
- *
638
- * All properties are optional. For every field, `null` removes the
639
- * configuration, `undefined` (or omission) leaves it untouched, and any other
640
- * value sets it — values are shallow-merged into the route by patch key.
641
- *
642
- * Besides the structural and guard fields below, `update` also patches
643
- * **plugin-defined custom fields** (lifecycle hooks, `preload`, `searchSchema`,
644
- * …), symmetric with how `add`/`replace` register them. This interface is
645
- * **augmentable**: a plugin declares its updatable field via declaration
646
- * merging, mirroring its `Route` augmentation but with `| null` to allow removal:
647
- *
648
- * ```ts
649
- * declare module "@real-router/core" {
650
- * interface RouteConfigUpdate<Dependencies extends DefaultDependencies> {
651
- * onNavigate?: LifecycleHookFactory<Dependencies> | null;
652
- * }
653
- * }
654
- * ```
655
- *
656
- * Note: `name` / `path` / `children` are route identity and are NOT patchable —
657
- * use `remove` + `add` to restructure. The interface stays closed (no index
658
- * signature) so typos in structural field names remain compile errors.
659
- */
660
- interface RouteConfigUpdate<Dependencies extends DefaultDependencies = DefaultDependencies> {
661
- /** Set to null to remove forwardTo */
662
- forwardTo?: string | ForwardToCallback<Dependencies> | null;
663
- /** Set to null to remove defaultParams */
664
- defaultParams?: Params | null;
665
- /** Set to null to remove decoder */
666
- decodeParams?: ((params: Params) => Params) | null;
667
- /** Set to null to remove encoder */
668
- encodeParams?: ((params: Params) => Params) | null;
669
- /** Set to null to remove canActivate */
670
- canActivate?: GuardFnFactory<Dependencies> | null;
671
- /** Set to null to remove canDeactivate */
672
- canDeactivate?: GuardFnFactory<Dependencies> | null;
673
- }
674
- //#endregion
675
- //#region src/types/constants.d.ts
676
- /**
677
- * Plugin lifecycle method names
678
- */
679
- type PluginMethod = "onStart" | "onStop" | "onTransitionStart" | "onTransitionLeaveApprove" | "onTransitionCancel" | "onTransitionSuccess" | "onTransitionError";
680
- /**
681
- * Router event names
682
- */
683
- type EventName = "$start" | "$stop" | "$$start" | "$$leaveApprove" | "$$cancel" | "$$success" | "$$error";
684
- /**
685
- * Event type keys
686
- */
687
- type EventsKeys = "ROUTER_START" | "ROUTER_STOP" | "TRANSITION_START" | "TRANSITION_LEAVE_APPROVE" | "TRANSITION_CANCEL" | "TRANSITION_SUCCESS" | "TRANSITION_ERROR";
688
- /**
689
- * Error code values
690
- */
691
- type ErrorCodeValues = "NOT_STARTED" | "NO_START_PATH_OR_STATE" | "ALREADY_STARTED" | "ROUTE_NOT_FOUND" | "SAME_STATES" | "CANNOT_DEACTIVATE" | "CANNOT_ACTIVATE" | "TRANSITION_ERR" | "CANCELLED" | "DISPOSED" | "PLUGIN_CONFLICT" | "CONTEXT_NAMESPACE_ALREADY_CLAIMED";
692
- /**
693
- * Error code keys
694
- */
695
- type ErrorCodeKeys = "ROUTER_NOT_STARTED" | "NO_START_PATH_OR_STATE" | "ROUTER_ALREADY_STARTED" | "ROUTE_NOT_FOUND" | "SAME_STATES" | "CANNOT_DEACTIVATE" | "CANNOT_ACTIVATE" | "TRANSITION_ERR" | "TRANSITION_CANCELLED" | "ROUTER_DISPOSED" | "PLUGIN_CONFLICT" | "CONTEXT_NAMESPACE_ALREADY_CLAIMED" | "REENTRANT_NAVIGATION" | "REENTRANT_TREE_MUTATION";
696
- /**
697
- * Mapping of event keys to plugin methods
698
- */
699
- interface EventToPluginMap {
700
- readonly ROUTER_START: "onStart";
701
- readonly ROUTER_STOP: "onStop";
702
- readonly TRANSITION_START: "onTransitionStart";
703
- readonly TRANSITION_LEAVE_APPROVE: "onTransitionLeaveApprove";
704
- readonly TRANSITION_CANCEL: "onTransitionCancel";
705
- readonly TRANSITION_SUCCESS: "onTransitionSuccess";
706
- readonly TRANSITION_ERROR: "onTransitionError";
707
- }
708
- /**
709
- * Mapping of event keys to event names
710
- */
711
- interface EventToNameMap {
712
- ROUTER_START: "$start";
713
- ROUTER_STOP: "$stop";
714
- TRANSITION_START: "$$start";
715
- TRANSITION_LEAVE_APPROVE: "$$leaveApprove";
716
- TRANSITION_CANCEL: "$$cancel";
717
- TRANSITION_SUCCESS: "$$success";
718
- TRANSITION_ERROR: "$$error";
719
- }
720
- /**
721
- * Mapping of event names to plugin method names.
722
- * Type-level computation from EventToNameMap + EventToPluginMap.
723
- */
724
- type EventMethodMap = { [K in EventsKeys as EventToNameMap[K]]: EventToPluginMap[K] };
725
- /**
726
- * Mapping of error code keys to their values
727
- */
728
- interface ErrorCodeToValueMap {
729
- ROUTER_NOT_STARTED: "NOT_STARTED";
730
- NO_START_PATH_OR_STATE: "NO_START_PATH_OR_STATE";
731
- ROUTER_ALREADY_STARTED: "ALREADY_STARTED";
732
- ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND";
733
- SAME_STATES: "SAME_STATES";
734
- CANNOT_DEACTIVATE: "CANNOT_DEACTIVATE";
735
- CANNOT_ACTIVATE: "CANNOT_ACTIVATE";
736
- TRANSITION_ERR: "TRANSITION_ERR";
737
- TRANSITION_CANCELLED: "CANCELLED";
738
- ROUTER_DISPOSED: "DISPOSED";
739
- PLUGIN_CONFLICT: "PLUGIN_CONFLICT";
740
- CONTEXT_NAMESPACE_ALREADY_CLAIMED: "CONTEXT_NAMESPACE_ALREADY_CLAIMED";
741
- REENTRANT_NAVIGATION: "REENTRANT_NAVIGATION";
742
- REENTRANT_TREE_MUTATION: "REENTRANT_TREE_MUTATION";
743
- }
744
- //#endregion
745
- //#region src/types/tree-changed.d.ts
746
- /**
747
- * The subset of {@link RouteConfigUpdate} fields that count as **structural**
748
- * changes — the only ones that emit `TREE_CHANGED` from `update()`.
749
- *
750
- * Guard fields (`canActivate` / `canDeactivate`) are deliberately excluded:
751
- * guards are invoked-on-demand (fresh-read per navigation), not cached derived
752
- * state, so they need no observation channel.
753
- */
754
- type TreeStructuralPatch<Dependencies extends DefaultDependencies = DefaultDependencies> = Pick<RouteConfigUpdate<Dependencies>, "forwardTo" | "defaultParams" | "encodeParams" | "decodeParams">;
755
- interface TreeChangedAdd<Dependencies extends DefaultDependencies = DefaultDependencies> {
756
- readonly op: "add";
757
- /** Top-level routes that were added (deep-cloned + frozen; caller untouched). */
758
- readonly added: readonly Route<Dependencies>[];
759
- /** Parent route name when added via `add(routes, { parent })`. */
760
- readonly parent?: string;
761
- }
762
- interface TreeChangedRemove<Dependencies extends DefaultDependencies = DefaultDependencies> {
763
- readonly op: "remove";
764
- readonly name: string;
765
- /**
766
- * The removed route and all of its descendants, as a FLAT array (each entry's
767
- * `name` is the full dotted name). Collected before the mutation.
768
- */
769
- readonly removedSubtree: readonly Route<Dependencies>[];
770
- }
771
- interface TreeChangedUpdate<Dependencies extends DefaultDependencies = DefaultDependencies> {
772
- readonly op: "update";
773
- readonly name: string;
774
- /** Structural fields only (deep-cloned + frozen; caller's patch untouched). */
775
- readonly patch: Readonly<TreeStructuralPatch<Dependencies>>;
776
- }
777
- interface TreeChangedReplace<Dependencies extends DefaultDependencies = DefaultDependencies> {
778
- readonly op: "replace";
779
- /** FLAT by all names (including descendants) present before but not after. */
780
- readonly removed: readonly Route<Dependencies>[];
781
- /** FLAT by all names (including descendants) present after but not before. */
782
- readonly added: readonly Route<Dependencies>[];
783
- }
784
- interface TreeChangedClear<Dependencies extends DefaultDependencies = DefaultDependencies> {
785
- readonly op: "clear";
786
- /** Top-level routes (with nested children) that existed before the clear. */
787
- readonly removed: readonly Route<Dependencies>[];
788
- }
789
- /**
790
- * Discriminated union (by `op`) describing a single structural route-tree
791
- * mutation. Consumers should `switch (event.op)` with an exhaustive `default`
792
- * — do not rely on `Object.keys(event)`, array ordering, or absence of future
793
- * fields (see Invariant 11 in `.claude/rfc-tree-mutation-event.md`).
794
- */
795
- type TreeChangedEvent<Dependencies extends DefaultDependencies = DefaultDependencies> = TreeChangedAdd<Dependencies> | TreeChangedRemove<Dependencies> | TreeChangedUpdate<Dependencies> | TreeChangedReplace<Dependencies> | TreeChangedClear<Dependencies>;
796
- //#endregion
797
- //#region src/types/api.d.ts
798
- /**
799
- * Maps interceptable method names to their signatures.
800
- * Used by {@link PluginApi.addInterceptor} to provide type-safe interceptor registration.
801
- *
802
- * To add a new interceptable method:
803
- * 1. Add its signature here
804
- * 2. Wrap it with `createInterceptable()` / `createBinaryInterceptable()` in
805
- * the `registerInternals` block of the Router constructor
806
- * (`packages/core/src/Router.ts`)
807
- */
808
- interface InterceptableMethodMap {
809
- start: (path?: string) => Promise<State>;
810
- buildPath: (route: string, params?: Params) => string;
811
- forwardState: (routeName: string, routeParams: Params) => SimpleState;
812
- }
813
- /**
814
- * Type-safe interceptor callback.
815
- * Receives `next` (the next function in the chain) followed by the method's original parameters.
816
- */
817
- type InterceptorFn<M extends keyof InterceptableMethodMap> = (next: InterceptableMethodMap[M], ...args: Parameters<InterceptableMethodMap[M]>) => ReturnType<InterceptableMethodMap[M]>;
818
- /**
819
- * Writer object returned by {@link PluginApi.claimContextNamespace}. Holds
820
- * exclusive ownership of a single `state.context.<namespace>` key for the
821
- * lifetime of the owning plugin.
822
- *
823
- * @description
824
- * A plugin obtains a claim by calling `api.claimContextNamespace("ns")` at
825
- * registration, then publishes per-navigation data via {@link write} from a
826
- * lifecycle hook (typically `onTransitionSuccess`) or from an interceptor.
827
- * The plugin must call {@link release} in its `teardown()` so another plugin
828
- * can reclaim the same namespace.
829
- *
830
- * The core runtime enforces one invariant: a namespace can be held by at most
831
- * one claim at a time. Double-claiming throws `CONTEXT_NAMESPACE_ALREADY_CLAIMED`.
832
- *
833
- * @example
834
- * ```typescript
835
- * const navigationPlugin: PluginFactory = (router) => {
836
- * const api = getPluginApi(router);
837
- * const claim = api.claimContextNamespace("navigation");
838
- *
839
- * return {
840
- * onTransitionSuccess(toState, fromState) {
841
- * claim.write(toState, { direction: detectDirection(fromState, toState) });
842
- * },
843
- * teardown() {
844
- * claim.release();
845
- * },
846
- * };
847
- * };
848
- * ```
849
- *
850
- * @see {@link PluginApi.claimContextNamespace}
851
- * @see {@link State.context}
852
- */
853
- interface ContextNamespaceClaim<T = unknown> {
854
- write: (state: State, value: T) => void;
855
- release: () => void;
856
- }
857
- /**
858
- * Plugin API — for plugins and infrastructure packages.
859
- * Hides plugin-internal methods from public autocomplete.
860
- */
861
- interface PluginApi {
862
- makeState: <P extends Params = Params>(name: string, params?: P, path?: string, meta?: StateMetaInput) => State<P>;
863
- buildState: (routeName: string, routeParams: Params) => RouteTreeState | undefined;
864
- forwardState: <P extends Params = Params>(routeName: string, routeParams: P) => SimpleState<P>;
865
- matchPath: <P extends Params = Params>(path: string) => State<P> | undefined;
866
- /**
867
- * Navigate to a fully-built `State`, skipping the redundant
868
- * `forwardState`/`buildPath` round-trip in `buildNavigateState`.
869
- *
870
- * Plugin-only entry point for browser-initiated navigation: a plugin
871
- * receives a URL event, resolves it via `api.matchPath(url)`, then commits
872
- * the resulting `State` directly via `api.navigateToState(state, opts)`.
873
- *
874
- * Semantics vs `router.navigate(name, params, opts)`:
875
- * - `forwardState` is NOT re-applied (matchPath already ran it).
876
- * - `buildPath` is NOT re-run; `state.path` is used verbatim, preserving
877
- * `trailingSlash:"preserve"` source-URL output.
878
- * - `forwardState`/`buildPath` interceptors do NOT run on this path; the
879
- * URL the user navigated to is the source of truth.
880
- * - Pipeline: SAME_STATES check, FSM transition, guards, `subscribeLeave`,
881
- * `completeTransition`, plugin lifecycle hooks — all unchanged.
882
- *
883
- * Programmatic / userland navigation should keep using
884
- * `router.navigate(name, params, opts)` so interceptors apply.
885
- */
886
- navigateToState: (state: State, options?: NavigationOptions) => Promise<State>;
887
- setRootPath: (rootPath: string) => void;
888
- getRootPath: () => string;
889
- addEventListener: <E extends EventName>(eventName: E, cb: Plugin[EventMethodMap[E]]) => Unsubscribe;
890
- buildNavigationState: (name: string, params?: Params) => State | undefined;
891
- getOptions: () => Options;
892
- getTree: () => unknown;
893
- addInterceptor: <M extends keyof InterceptableMethodMap>(method: M, fn: InterceptorFn<M>) => Unsubscribe;
894
- extendRouter: (extensions: Record<string, unknown>) => Unsubscribe;
895
- /**
896
- * Emits a `$$error` event without going through the navigation pipeline.
897
- *
898
- * Used by plugins that detect an error outside a running transition (e.g.,
899
- * an unmatched URL on popstate in strict mode). The event reaches any
900
- * `onTransitionError` plugin hook and any `$$error` listener so developers
901
- * can observe errors raised by the plugin layer.
902
- *
903
- * The current router state is used as `fromState`; `toState` is `undefined`
904
- * because no transition was attempted. Safe to call at any FSM state —
905
- * delegates to `sendFailSafe` internally (direct emit when not READY).
906
- */
907
- emitTransitionError: (error: Error) => void;
908
- claimContextNamespace: {
909
- <K extends keyof StateContext & string>(namespace: K): ContextNamespaceClaim<StateContext[K]>;
910
- (namespace: string): ContextNamespaceClaim;
911
- };
912
- getRouteConfig: (name: string) => Record<string, unknown> | undefined;
913
- }
914
- /**
915
- * Routes API — for dynamic route mutation.
916
- */
917
- interface RoutesApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
918
- add: (routes: Route<Dependencies>[] | Route<Dependencies>, options?: {
919
- parent?: string;
920
- }) => void;
921
- remove: (name: string) => void;
922
- /**
923
- * Patch an existing route's configuration in place (no tree rebuild).
924
- *
925
- * Applies the structural/guard fields and any plugin-defined custom fields
926
- * (lifecycle hooks, `preload`, `searchSchema`, …) from the patch. Fields are
927
- * shallow-merged by key; `null` removes a field, `undefined` is a no-op.
928
- * `name`/`path`/`children` are immutable — use `remove` + `add` to
929
- * restructure. See {@link RouteConfigUpdate} for the full semantics and the
930
- * plugin augmentation pattern.
931
- */
932
- update: (name: string, updates: RouteConfigUpdate<Dependencies>) => void;
933
- clear: () => void;
934
- replace: (routes: Route<Dependencies>[] | Route<Dependencies>) => void;
935
- has: (name: string) => boolean;
936
- get: (name: string) => Route<Dependencies> | undefined;
937
- /**
938
- * Subscribe to structural route-tree mutations (`add` / `remove` / `update`
939
- * with structural fields / `replace` / `clear`). Fire-and-forget: the handler
940
- * cannot cancel the mutation, runs after the atomic commit, and sees the
941
- * post-mutation tree via `get()` / `has()`.
942
- *
943
- * Duplicate-registration semantics are **lenient** (mirrors
944
- * `router.subscribe`): each call registers an independent listener and
945
- * returns its own unsubscribe.
946
- *
947
- * @returns Unsubscribe function for this specific registration.
948
- */
949
- subscribeChanges: (handler: (event: TreeChangedEvent<Dependencies>) => void) => Unsubscribe;
950
- }
951
- /**
952
- * Dependencies API — CRUD for dependency injection.
953
- */
954
- interface DependenciesApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
955
- get: <K extends keyof Dependencies>(key: K) => Dependencies[K];
956
- getAll: () => Partial<Dependencies>;
957
- set: <K extends keyof Dependencies & string>(name: K, value: Dependencies[K]) => void;
958
- setAll: (deps: Dependencies) => void;
959
- remove: (name: keyof Dependencies) => void;
960
- reset: () => void;
961
- has: (name: keyof Dependencies) => boolean;
962
- }
963
- /**
964
- * Lifecycle API — guard registration (addActivateGuard, addDeactivateGuard, etc.)
965
- */
966
- interface LifecycleApi<Dependencies extends DefaultDependencies = DefaultDependencies> {
967
- addActivateGuard: (name: string, canActivateHandler: GuardFnFactory<Dependencies> | boolean) => void;
968
- addDeactivateGuard: (name: string, canDeactivateHandler: GuardFnFactory<Dependencies> | boolean) => void;
969
- removeActivateGuard: (name: string) => void;
970
- removeDeactivateGuard: (name: string) => void;
971
- }
972
- //#endregion
973
- export { State as $, LeaveFn as A, PluginFactory as B, PluginMethod as C, ForwardToCallback as D, DefaultRouteCallback as E, LogLevelConfig as F, SubscribeFn as G, RouteConfigUpdate as H, LoggerConfig as I, LimitsConfig as J, SubscribeState as K, Navigator as L, Listener as M, LogCallback as N, GuardFn as O, LogLevel as P, SimpleState as Q, Options as R, EventsKeys as S, DefaultParamsCallback as T, Router as U, Route as V, RouterLogger as W, Params as X, NavigationOptions as Y, RouterError as Z, ErrorCodeValues as _, LifecycleApi as a, Unsubscribe as at, EventToNameMap as b, TreeChangedAdd as c, RouteParams as ct, TreeChangedRemove as d, StateContext as et, TreeChangedReplace as f, ErrorCodeToValueMap as g, ErrorCodeKeys as h, InterceptorFn as i, TransitionReason as it, LeaveState as j, GuardFnFactory as k, TreeChangedClear as l, RouteTreeState as lt, TreeStructuralPatch as m, DependenciesApi as n, TransitionMeta as nt, PluginApi as o, QueryParamsMode as ot, TreeChangedUpdate as p, Subscription as q, InterceptableMethodMap as r, TransitionPhase as rt, RoutesApi as s, QueryParamsOptions as st, ContextNamespaceClaim as t, StateMetaInput as tt, TreeChangedEvent as u, EventMethodMap as v, DefaultDependencies as w, EventToPluginMap as x, EventName as y, Plugin as z };
974
- //# sourceMappingURL=index-CAnGQpnz.d.ts.map