@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventBusNamespace.js","names":["RouterError","errorCodes","#fsm","#emitter","#abortController","#leaveListeners","#currentToState","#setupFSMActions","events","#dispatchDepth","routerEvents","#pendingToState","#pendingFromState","#pendingError","#pendingCancelReason","routerStates","#checkListenerThreshold","#getValidator","#emitPendingError"],"sources":["../../../../src/namespaces/EventBusNamespace/EventBusNamespace.ts"],"sourcesContent":["// packages/core/src/namespaces/EventBusNamespace/EventBusNamespace.ts\n\nimport { errorCodes, events } from \"../../constants\";\nimport { RouterError } from \"../../RouterError\";\nimport { routerEvents, routerStates } from \"../../routerFSM\";\n\nimport type { EventBusOptions } from \"./types\";\nimport type { EventEmitter } from \"../../foundation/event-emitter\";\nimport type { FSM } from \"../../foundation/fsm\";\nimport type { RouterEvent, RouterPayloads, RouterState } from \"../../routerFSM\";\nimport type {\n EventName,\n LeaveFn,\n LeaveState,\n NavigationOptions,\n Plugin,\n State,\n SubscribeFn,\n TreeChangedEvent,\n Unsubscribe,\n EventMethodMap,\n} from \"../../types\";\nimport type { RouterEventMap } from \"../../types/internal\";\nimport type { RouterValidator } from \"../../types/RouterValidator\";\n\n/**\n * Internal-only event key for route-tree mutations. Lives on the same\n * `EventEmitter` as the 7 transition events but never enters the public\n * `EventName` union — reachable only through\n * `getRoutesApi(router).subscribeChanges()`.\n */\nconst TREE_CHANGED = \"TREE_CHANGED\";\n\nfunction ensureError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value));\n}\n\nfunction settleLeavePromises(\n promises: Promise<void>[],\n firstSyncError: unknown,\n signal: AbortSignal,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n // #1197 — canonicalize the abort outcome: reject with a\n // `RouterError(TRANSITION_CANCELLED)` carrying the external reason, so the\n // no-guards leave path classifies identically to the guard path (no raw\n // reject, no spurious TRANSITION_ERROR). Internal sources\n // (supersede/stop/dispose) already abort with such a RouterError — thread it\n // through unchanged so the #943 reason is preserved.\n const onAbort = (): void => {\n const reason: unknown = signal.reason;\n\n reject(\n reason instanceof RouterError &&\n reason.code === errorCodes.TRANSITION_CANCELLED\n ? reason\n : new RouterError(errorCodes.TRANSITION_CANCELLED, { reason }),\n );\n };\n\n if (signal.aborted) {\n onAbort();\n\n return;\n }\n\n // Stryker disable next-line ObjectLiteral,BooleanLiteral: equivalent — `{ once: true }` is redundant: onAbort fires at most once (a signal aborts once) and the success path explicitly removeEventListener's it, so dropping `once` is unobservable. StringLiteral sibling stays live (the \"abort\" event name is killed).\n signal.addEventListener(\"abort\", onAbort, { once: true });\n\n void Promise.allSettled(promises).then((results) => {\n // Stryker disable next-line StringLiteral: equivalent — this cleanup name is redundant: onAbort is registered with `{ once: true }` and the per-navigation signal is discarded unaborted on success, so failing to remove the listener leaks nothing observable.\n signal.removeEventListener(\"abort\", onAbort);\n\n // Stryker disable next-line BlockStatement: equivalent — emptying the post-allSettled abort-race early-return falls through to resolve()/reject(), but the abort handler already settled the promise, so the extra settle is a no-op. CE sibling stays live (→true hangs the pipeline = killed via timeout).\n if (signal.aborted) {\n // Race lost to abort — the abort handler already rejected; do nothing\n return;\n }\n\n if (firstSyncError !== undefined) {\n reject(ensureError(firstSyncError));\n\n return;\n }\n\n const rejected = results.find(\n (result): result is PromiseRejectedResult =>\n result.status === \"rejected\",\n );\n\n if (rejected !== undefined) {\n reject(ensureError(rejected.reason));\n\n return;\n }\n\n resolve();\n });\n });\n}\n\nexport class EventBusNamespace {\n readonly #fsm: FSM<RouterState, RouterEvent, null, RouterPayloads>;\n readonly #emitter: EventEmitter<RouterEventMap>;\n // Effect of the FSM CANCEL action: aborts the in-flight navigation's\n // controller. Wired to NavigationNamespace.\n readonly #abortController: (reason?: unknown) => void;\n // Lazy accessor for the opt-in RouterValidator (wired by wireNamespaces).\n // Returns `null` until validation-plugin is registered — so the proactive\n // listener-count threshold (#1188) costs the no-plugin path nothing.\n #getValidator: (() => RouterValidator | null) | undefined;\n readonly #leaveListeners: LeaveFn[] = [];\n\n // Depth of the synchronous transition-dispatch window — elevated while a\n // transition event is being emitted (`emitTransition*`) or a `subscribeLeave`\n // listener batch runs. `isProcessing()` reads it so the navigation facade can\n // reject a synchronous reentrant navigate() from inside a transition listener\n // with REENTRANT_NAVIGATION (RFC navigation-cancellation-unification §4). A\n // counter (not a boolean) tolerates legitimately-nested transition emits. The\n // ceiling-bounded \"allow reentrant navigate, throw RecursionDepthError at\n // `maxEventDepth`\" behaviour (#935/#945) is gone: such a navigate now throws\n // REENTRANT_NAVIGATION at depth 1, before it can recurse. (The emitter's old\n // `maxEventDepth` depth-bound is gone too — re-entrant emits are coalesced to a\n // no-op at the emitter, #1033 — so no event can re-enter its own dispatch.)\n #dispatchDepth = 0;\n\n #currentToState: State | undefined;\n #pendingToState: State | undefined;\n #pendingFromState: State | undefined;\n #pendingError: unknown;\n // Abort reason for the pending CANCEL — read by handleCancel, set by sendCancel.\n #pendingCancelReason: unknown;\n\n constructor(options: EventBusOptions) {\n this.#fsm = options.routerFSM;\n this.#emitter = options.emitter;\n this.#abortController = options.abortController;\n this.#currentToState = undefined;\n this.#setupFSMActions();\n }\n\n static validateSubscribeListener(listener: unknown): void {\n if (typeof listener !== \"function\") {\n throw new TypeError(\n \"[router.subscribe] Expected a function. \" +\n \"For Observable pattern use observable(router) from @real-router/rx\",\n );\n }\n }\n\n /**\n * Validates the `subscribeLeave` listener. Unlike\n * {@link validateSubscribeListener}, the error carries **no**\n * `@real-router/rx` hint — rx exposes the Observable pattern for *success*\n * transitions (`observable(router)`, `state$`, `events$`), not for leave\n * events, so steering leave-listener misuse toward rx would mislead. The\n * asymmetry is intentional (mirrored in `core/CLAUDE.md`).\n */\n static validateSubscribeLeaveListener(listener: unknown): void {\n if (typeof listener !== \"function\") {\n throw new TypeError(\"[router.subscribeLeave] Expected a function\");\n }\n }\n\n emitRouterStart(): void {\n this.#emitter.emit(events.ROUTER_START);\n }\n\n emitRouterStop(): void {\n this.#emitter.emit(events.ROUTER_STOP);\n }\n\n emitTransitionStart(toState: State, fromState?: State): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_START, toState, fromState);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n emitTransitionSuccess(\n toState: State,\n fromState?: State,\n opts?: NavigationOptions,\n ): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_SUCCESS, toState, fromState, opts);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n emitTransitionError(\n toState?: State,\n fromState?: State,\n error?: RouterError,\n ): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_ERROR, toState, fromState, error);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n emitTransitionCancel(toState: State, fromState?: State): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_CANCEL, toState, fromState);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n emitTransitionLeaveApprove(toState: State, fromState?: State): void {\n this.#dispatchDepth++;\n try {\n this.#emitter.emit(events.TRANSITION_LEAVE_APPROVE, toState, fromState);\n } finally {\n this.#dispatchDepth--;\n }\n }\n\n /**\n * True while a transition event is being dispatched synchronously — an\n * `emitTransition*` call or a `subscribeLeave` listener batch is on the stack.\n * The navigation facade reads this to reject a synchronous reentrant\n * navigate() from inside a transition listener (RFC §4).\n */\n isProcessing(): boolean {\n return this.#dispatchDepth > 0;\n }\n\n /**\n * Emits the internal `TREE_CHANGED` event after a structural route-tree\n * mutation. Reuses the shared `EventEmitter` — so re-entrancy coalescing\n * (#1033) and per-listener error isolation (`onListenerError`) apply\n * automatically.\n */\n emitTreeChanged(event: TreeChangedEvent): void {\n this.#emitter.emit(TREE_CHANGED, event);\n }\n\n /**\n * True while a `TREE_CHANGED` event is being dispatched synchronously.\n * Delegates to the emitter's own in-flight tracking (#1034) — `getRoutesApi`\n * reads this to reject reentrant route-CRUD from a `subscribeChanges` handler\n * (#1032).\n */\n isEmittingTreeChanged(): boolean {\n return this.#emitter.isDispatching(TREE_CHANGED);\n }\n\n /**\n * Subscribes to `TREE_CHANGED`. **Lenient** duplicate semantics (mirrors\n * {@link subscribe}): each call wraps the handler in a fresh closure, so N\n * registrations of the same reference produce N independent subscriptions.\n */\n subscribeTreeChanged(\n handler: (event: TreeChangedEvent) => void,\n ): Unsubscribe {\n // Same disposed-state enforcement as subscribe()/subscribeLeave() (#946),\n // completing the guard across all three subscription primitives — extended\n // here to the internal route-tree channel (#982). A `subscribeChanges`\n // reference bound before dispose() (`const s = routes.subscribeChanges\n // .bind(routes)`) reaches this method via the getRoutesApi delegate, which\n // — unlike its add/remove/update siblings — does not itself check\n // isDisposed(). Without this guard, `emitter.on` would re-register a\n // TREE_CHANGED listener that can never fire (clearAll already ran, the FSM\n // is DISPOSED, the route tree is torn down, no future emit) — a silent\n // no-op, the internal-channel counterpart of the #946 hazard.\n if (this.isDisposed()) {\n throw new RouterError(errorCodes.ROUTER_DISPOSED);\n }\n\n return this.#emitter.on(TREE_CHANGED, (event: TreeChangedEvent) => {\n handler(event);\n });\n }\n\n /** Number of active `TREE_CHANGED` listeners (drives conditional emit). */\n treeChangedListenerCount(): number {\n return this.#emitter.listenerCount(TREE_CHANGED);\n }\n\n sendStart(): void {\n this.#fsm.send(routerEvents.START);\n }\n\n sendStop(): void {\n this.#fsm.send(routerEvents.STOP);\n }\n\n sendDispose(): void {\n this.#fsm.send(routerEvents.DISPOSE);\n }\n\n sendStarted(): void {\n this.#fsm.send(routerEvents.STARTED);\n }\n\n sendNavigate(toState: State, fromState?: State): void {\n this.#currentToState = toState;\n // Table-driven: the FSM action emits TRANSITION_START (#1169 D-full). A\n // NAVIGATE that the table rejects is a no-op — the FSM never leaves an\n // invalid state and no event fires.\n this.#fsm.send(routerEvents.NAVIGATE, { toState, fromState });\n }\n\n sendComplete(\n state: State,\n fromState?: State,\n opts: NavigationOptions = {},\n ): void {\n // Table-driven: the FSM action emits TRANSITION_SUCCESS (#1169 D-full).\n // COMPLETE from IDLE/DISPOSED (a listener stopped/disposed mid-transition)\n // is a table no-op — no resurrection, no phantom success emit.\n this.#fsm.send(routerEvents.COMPLETE, { toState: state, fromState, opts });\n\n // Nav committed — clear so a later stop()/dispose() cannot cancel a finished\n // navigation. Unconditional now that synchronous reentrant navigate is banned\n // (RFC §4): nothing can replace #currentToState during the emit above, so the\n // #308 reentrant-preserve guard is no longer needed.\n this.#currentToState = undefined;\n }\n\n sendLeaveApprove(toState: State, fromState?: State): void {\n // Table-driven: the FSM action emits TRANSITION_LEAVE_APPROVE (#1169 D-full).\n // LEAVE_APPROVE from IDLE/DISPOSED is a table no-op — no resurrection.\n this.#fsm.send(routerEvents.LEAVE_APPROVE, { toState, fromState });\n }\n\n sendFail(toState?: State, fromState?: State, error?: unknown): void {\n this.#pendingToState = toState;\n this.#pendingFromState = fromState;\n this.#pendingError = error;\n this.#fsm.send(routerEvents.FAIL);\n\n // Nav failed — clear (unconditional; synchronous reentrant navigate is\n // banned (RFC §4), so nothing replaces #currentToState during the emit).\n this.#currentToState = undefined;\n }\n\n /**\n * Surfaces a `TRANSITION_ERROR` for callers that do **not** know — or do not\n * control — the current FSM state: the plugin-facing `emitTransitionError`\n * primitive (`getPluginApi`), the dispose chain, and validator / same-state\n * rejections. It is the state-agnostic counterpart to {@link sendFail}.\n *\n * **What \"Safe\" means here.** The error event is never *dropped*, whatever the\n * FSM state — it does **not** mean the method catches every error. Errors\n * thrown *inside* a `TRANSITION_ERROR` listener are isolated by the\n * `EventEmitter`'s per-listener `onListenerError` sink, not by this method.\n *\n * **Why it branches on its own FSM state.** When the FSM is settled in `READY`\n * (no transition in flight) it routes through the FSM `FAIL` action via\n * {@link sendFail}, so the error rides the normal FSM-driven emit. Otherwise —\n * the router may be starting, mid-transition, or torn down — it emits\n * `TRANSITION_ERROR` directly: a fire-and-forget error report from an unknown\n * state must not drive a second FSM transition that could collide with an\n * in-flight one. Both branches guarantee the event reaches subscribers.\n */\n sendFailSafe(toState?: State, fromState?: State, error?: unknown): void {\n if (this.isReady()) {\n this.sendFail(toState, fromState, error);\n } else {\n this.emitTransitionError(toState, fromState, error as RouterError);\n }\n }\n\n sendCancel(toState: State, fromState?: State, reason?: unknown): void {\n this.#pendingToState = toState;\n this.#pendingFromState = fromState;\n this.#pendingCancelReason = reason;\n this.#fsm.send(routerEvents.CANCEL);\n\n // Nav cancelled — clear (unconditional; synchronous reentrant navigate is\n // banned (RFC §4), so nothing replaces #currentToState during the emit).\n this.#currentToState = undefined;\n }\n\n canBeginTransition(): boolean {\n return this.#fsm.canSend(routerEvents.NAVIGATE);\n }\n\n canStart(): boolean {\n return this.#fsm.canSend(routerEvents.START);\n }\n\n canCancel(): boolean {\n return this.#fsm.canSend(routerEvents.CANCEL);\n }\n\n isActive(): boolean {\n const fsmState = this.#fsm.getState();\n\n return fsmState !== routerStates.IDLE && fsmState !== routerStates.DISPOSED;\n }\n\n isDisposed(): boolean {\n return this.#fsm.getState() === routerStates.DISPOSED;\n }\n\n isTransitioning(): boolean {\n const state = this.#fsm.getState();\n\n return (\n state === routerStates.TRANSITION_STARTED ||\n state === routerStates.LEAVE_APPROVED\n );\n }\n\n isLeaveApproved(): boolean {\n return this.#fsm.getState() === routerStates.LEAVE_APPROVED;\n }\n\n isReady(): boolean {\n return this.#fsm.getState() === routerStates.READY;\n }\n\n isStarting(): boolean {\n return this.#fsm.getState() === routerStates.STARTING;\n }\n\n isIdle(): boolean {\n return this.#fsm.getState() === routerStates.IDLE;\n }\n\n /**\n * Plugin-author API for subscribing to internal router events.\n *\n * @remarks\n *\n * **Duplicate-registration semantics — strict (throws).** Passing the same\n * callback reference twice for the same event throws\n * `Error(\"Duplicate listener for ...\")` from the underlying `EventEmitter`.\n * This is loud-on-misuse by design: plugin code is expected to register\n * each callback once. The contract differs from {@link subscribe} /\n * {@link subscribeLeave}, which are end-user surfaces and silently accept\n * duplicates.\n */\n addEventListener<E extends EventName>(\n eventName: E,\n cb: Plugin[EventMethodMap[E]],\n ): Unsubscribe {\n this.#checkListenerThreshold(eventName, \"addEventListener\");\n\n return this.#emitter.on(\n eventName,\n cb as (...args: RouterEventMap[typeof eventName]) => void,\n );\n }\n\n /**\n * End-user / UI-binding API for subscribing to successful transitions.\n *\n * @remarks\n *\n * **Duplicate-registration semantics — independent.** Each call wraps\n * `listener` in a fresh closure and registers it as a distinct internal\n * slot. `router.subscribe(fn)` twice produces **two** active subscriptions;\n * `fn` fires twice per `TRANSITION_SUCCESS`. The returned `Unsubscribe` is\n * paired with its specific call — invoking it removes exactly that\n * registration.\n *\n * This contract differs from {@link addEventListener} (plugin API, throws\n * on duplicate). End-user code that wants idempotent registration must\n * gate itself, e.g. `if (!unsub) unsub = router.subscribe(fn);`.\n */\n subscribe(listener: SubscribeFn): Unsubscribe {\n // Enforce the disposed state HERE, not only on the facade. A reference\n // bound before dispose() (`const s = router.subscribe.bind(router)`)\n // bypasses the facade's #markDisposed swap and reaches this method\n // directly. Without this guard, `emitter.on` would silently re-register a\n // listener that can never fire (clearAll already ran, FSM is DISPOSED, no\n // future emit) — a silent no-op / stuck-UI hazard (#946).\n if (this.isDisposed()) {\n throw new RouterError(errorCodes.ROUTER_DISPOSED);\n }\n\n this.#checkListenerThreshold(events.TRANSITION_SUCCESS, \"subscribe\");\n\n // `subscribe` is fire-and-forget; the listener's return value is ignored at\n // the type level (`SubscribeFn` is `=> void`). A void-typed async listener\n // still returns a rejecting Promise at runtime, so return it to the emitter,\n // whose central isolation routes the rejection to the same `onListenerError`\n // sink a sync throw flows through — instead of leaking an `unhandledRejection`\n // (fatal under `--unhandled-rejections=strict`, the Node 22+ default). This\n // is #944, now folded into the emitter's central #1412 async isolation — the\n // former per-site `.catch` here is redundant (symmetric with `subscribeLeave`,\n // which isolates via `Promise.allSettled`).\n return this.#emitter.on(\n events.TRANSITION_SUCCESS,\n (toState: State, fromState?: State) => {\n // Return the listener's runtime value to the emitter so its central\n // isolation catches an async listener's rejection (#944/#1412). Read the\n // void-typed result into `unknown` first — a returned `void` expression\n // is forbidden, but returning the read `unknown` is fine.\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -- read the void-typed listener's runtime value so it can be returned for central async isolation (#944/#1412)\n const result: unknown = listener({\n route: toState,\n previousRoute: fromState,\n });\n\n return result;\n },\n );\n }\n\n /**\n * End-user / UI-binding API for subscribing to **approved** route departures\n * (`LEAVE_APPROVED` phase): all `canDeactivate` guards have passed, but the\n * departure is **tentative, not committed** — an activation (`canActivate`)\n * guard can still reject (or the target route be removed mid-transition),\n * leaving the user on the current route (#932). Treat the leave as tentative\n * for non-idempotent side-effects and use the payload `signal` (which aborts\n * with the failure reason, #943) to roll back when the navigation does not\n * commit. Async listeners block the activation phase.\n *\n * @remarks\n *\n * **Duplicate-registration semantics — independent.** Each call pushes\n * `listener` onto the internal array; `router.subscribeLeave(fn)` twice\n * produces two entries and `fn` fires twice per leave. Each returned\n * `Unsubscribe` is **idempotent** (a `removed` flag, #1349) and removes\n * exactly ONE entry — the first still matching the reference (`indexOf`\n * semantic). So a repeated call of one unsubscribe is a true no-op and does\n * **not** touch the other registration; N subscribes + M *distinct*\n * unsubscribes leave N − M entries. Which physical entry survives is\n * irrelevant — the reference is the same.\n *\n * Contract differs from {@link addEventListener} (throws on duplicate).\n * For idempotent *registration* (one active subscription), gate at the call site.\n */\n subscribeLeave(listener: LeaveFn): Unsubscribe {\n // Same disposed-state enforcement as subscribe() (#946): a pre-bound\n // reference would otherwise push onto #leaveListeners after dispose() and\n // silently never fire (FSM is DISPOSED, no LEAVE_APPROVE emit).\n if (this.isDisposed()) {\n throw new RouterError(errorCodes.ROUTER_DISPOSED);\n }\n\n this.#leaveListeners.push(listener);\n\n // Idempotency flag (#1349), mirroring extendRouter / addInterceptor (#1198).\n // Without it, a double call would `indexOf(listener)` again and splice a\n // DUPLICATE registration of the same fn — silently deactivating another\n // subscriber whose own unsubscribe was never called. The `Unsubscribe`\n // contract names subscribeLeave as idempotent. (Unlike addInterceptor, the\n // `idx !== -1` guard stays: `dispose()` empties `#leaveListeners` via\n // `clearAll`, so an unsubscribe called after dispose reaches this with\n // idx === -1.)\n let removed = false;\n\n return () => {\n if (removed) {\n return;\n }\n\n removed = true;\n\n const idx = this.#leaveListeners.indexOf(listener);\n\n if (idx !== -1) {\n this.#leaveListeners.splice(idx, 1);\n }\n };\n }\n\n hasLeaveListeners(): boolean {\n return this.#leaveListeners.length > 0;\n }\n\n /**\n * True when a plugin listener runs in a PRE-COMMIT transition window where a\n * synchronous `stop()`/`dispose()` can supersede the in-flight navigation\n * before it commits — i.e. `onTransitionStart` (TRANSITION_START) or\n * `onTransitionLeaveApprove` (TRANSITION_LEAVE_APPROVE). (`subscribeLeave` is\n * tracked separately via `hasLeaveListeners`; `onTransitionSuccess` fires\n * post-commit and cannot cancel.) Read into the pre-`startTransition` liveness\n * snapshot so the commit-gate (#1169) fires for these windows too.\n */\n hasPreCommitListeners(): boolean {\n return (\n this.#emitter.listenerCount(events.TRANSITION_START) > 0 ||\n this.#emitter.listenerCount(events.TRANSITION_LEAVE_APPROVE) > 0\n );\n }\n\n awaitLeaveListeners(\n toState: State,\n fromState: State | undefined,\n signal: AbortSignal,\n ): Promise<void> | undefined {\n if (fromState === undefined) {\n return undefined;\n }\n\n // Freeze the payload wrapper so listeners cannot mutate it (`payload.route`\n // is already deep-frozen via the State immutability invariant; this closes\n // the wrapper-mutation gap surfaced by audit `probe-05-payload-frozen`).\n const leaveState: LeaveState = Object.freeze({\n route: fromState,\n nextRoute: toState,\n signal,\n });\n\n let promises: Promise<void>[] | undefined;\n let firstSyncError: unknown;\n\n // Snapshot before iteration — a listener that reentrantly calls\n // `subscribeLeave(newFn)` or its own `unsubscribe()` must not affect the\n // current emit cycle. Symmetric with the EventEmitter snapshot invariant\n // (PR #666 / #659).\n const snapshot = [...this.#leaveListeners];\n\n // Elevated across the SYNC leave-listener dispatch: `isProcessing()` reads\n // it, so a sync subscribeLeave listener that calls navigate() is rejected\n // with REENTRANT_NAVIGATION at the facade (RFC §4). The `finally` restores it\n // before any async tail (returned promise) runs, so a DEFERRED navigate from\n // an async listener (after its first `await`) sees depth 0 and is allowed.\n this.#dispatchDepth++;\n\n try {\n for (const listener of snapshot) {\n try {\n const result = listener(leaveState);\n\n if (result !== undefined && typeof result.then === \"function\") {\n promises ??= [];\n promises.push(result);\n }\n } catch (error: unknown) {\n if (firstSyncError === undefined) {\n firstSyncError = error;\n }\n }\n }\n } finally {\n this.#dispatchDepth--;\n }\n\n if (promises === undefined) {\n if (firstSyncError !== undefined) {\n throw ensureError(firstSyncError);\n }\n\n return undefined;\n }\n\n return settleLeavePromises(promises, firstSyncError, signal);\n }\n\n clearAll(): void {\n this.#emitter.clearAll();\n this.#leaveListeners.length = 0;\n }\n\n setLimits(limits: { maxListeners: number; warnListeners: number }): void {\n this.#emitter.setLimits(limits);\n }\n\n /**\n * Injects the lazy validator accessor (wireNamespaces), mirroring\n * `PluginsNamespace` / `RouteLifecycleNamespace`. The closure reads the live\n * `RouterInternals.validator`, so a validation-plugin registered AFTER wiring\n * is still observed on the next `subscribe` / `addEventListener`.\n */\n setValidatorAccessor(getValidator: () => RouterValidator | null): void {\n this.#getValidator = getValidator;\n }\n\n // Single guarded entry point for routing a cancel into the FSM `CANCEL` action\n // — used by every source: stop/dispose (RouterLifecycle) pass no reason;\n // supersede / external `opts.signal` (via the wiring `cancelNavigation` dep)\n // pass the abort reason (#943). `canCancel()` makes it a no-op outside a\n // cancellable FSM state (#1034: was a second, unguarded `cancelNavigation` path).\n sendCancelIfPossible(fromState: State | undefined, reason?: unknown): void {\n const toState = this.#currentToState;\n\n if (!this.canCancel() || toState === undefined) {\n return;\n }\n\n this.sendCancel(toState, fromState, reason);\n }\n\n /**\n * Proactive listener-count threshold (#1188) — mirrors the plugins /\n * lifecycle / dependencies counters. Opt-in: the emitter's per-event count is\n * read ONLY when the validator is installed, so the bare-core hot path pays\n * nothing. `count` is the POST-add size (`listenerCount + 1`), matching\n * `RouteLifecycleNamespace`'s `count + 1`, so warn/error fire exactly when the\n * new listener reaches the threshold. Core keeps the emitter's bare-`Error`\n * hard cap; this only surfaces an actionable signal well before it.\n */\n #checkListenerThreshold(eventName: EventName, methodName: string): void {\n const validator = this.#getValidator?.();\n\n if (validator) {\n validator.eventBus.validateCountThresholds(\n this.#emitter.listenerCount(eventName) + 1,\n eventName,\n methodName,\n );\n }\n }\n\n #emitPendingError(): void {\n this.emitTransitionError(\n this.#pendingToState,\n this.#pendingFromState,\n this.#pendingError as RouterError | undefined,\n );\n\n // Clear the pending payload once this FAIL action has consumed it. `#pending*`\n // is only meaningful in the window between the sendFail()/sendFailSafe() that\n // sets it and this emit; keeping it afterwards pins a stale State/RouterError\n // on the instance and leaves an implicit \"valid only in this window\" coupling\n // (#949). Hygiene only — every consumer overwrites the fields before\n // re-reading (handleCancel reads what its own sendCancel just set), so there\n // is no observable behaviour change.\n this.#pendingToState = undefined;\n this.#pendingFromState = undefined;\n this.#pendingError = undefined;\n }\n\n #setupFSMActions(): void {\n const fsm = this.#fsm;\n\n fsm.on(routerStates.STARTING, routerEvents.STARTED, () => {\n this.emitRouterStart();\n });\n\n fsm.on(routerStates.READY, routerEvents.STOP, () => {\n this.emitRouterStop();\n });\n\n // NAVIGATE / LEAVE_APPROVE / COMPLETE emit their transition event as the FSM\n // action (payload = the transition states), so `send()` from an invalid\n // state (e.g. COMPLETE from IDLE after a listener's stop()/dispose()) is a\n // table no-op that emits nothing — the FSM table is the sole authority over\n // state, no `forceState` resurrection (#1169 D-full). NAVIGATE fires from\n // READY plus the TRANSITION_STARTED / LEAVE_APPROVED self-loops (supersede).\n const emitNavigate = (payload: RouterPayloads[\"NAVIGATE\"]): void => {\n this.emitTransitionStart(payload.toState, payload.fromState);\n };\n\n fsm.on(routerStates.READY, routerEvents.NAVIGATE, emitNavigate);\n fsm.on(\n routerStates.TRANSITION_STARTED,\n routerEvents.NAVIGATE,\n emitNavigate,\n );\n fsm.on(routerStates.LEAVE_APPROVED, routerEvents.NAVIGATE, emitNavigate);\n\n fsm.on(\n routerStates.TRANSITION_STARTED,\n routerEvents.LEAVE_APPROVE,\n (payload) => {\n this.emitTransitionLeaveApprove(payload.toState, payload.fromState);\n },\n );\n\n fsm.on(routerStates.LEAVE_APPROVED, routerEvents.COMPLETE, (payload) => {\n this.emitTransitionSuccess(\n payload.toState,\n payload.fromState,\n payload.opts,\n );\n });\n\n const handleCancel = () => {\n const toState = this.#pendingToState;\n const reason = this.#pendingCancelReason;\n\n this.#pendingCancelReason = undefined;\n\n // (RFC navigation-cancellation-unification §5): the FSM CANCEL\n // action OWNS the abort. Aborting the in-flight controller wakes the parked\n // async pipeline (#1018) and rejects navigate() — the post-race local\n // isActive() sees signal.aborted; `reason` surfaces as the leave signal's\n // reason (#943). Order: (i) abort (wake) then (ii) emit TRANSITION_CANCEL.\n // No cycle: onInternalAbort is wake-only, it does not re-enter cancel.\n this.#abortController(reason);\n\n /* v8 ignore next -- @preserve: #pendingToState guaranteed set by sendCancel before send() */\n if (toState === undefined) {\n return;\n }\n\n this.emitTransitionCancel(toState, this.#pendingFromState);\n };\n\n fsm.on(routerStates.TRANSITION_STARTED, routerEvents.CANCEL, handleCancel);\n fsm.on(routerStates.LEAVE_APPROVED, routerEvents.CANCEL, handleCancel);\n\n fsm.on(routerStates.LEAVE_APPROVED, routerEvents.FAIL, () => {\n this.#emitPendingError();\n });\n\n fsm.on(routerStates.STARTING, routerEvents.FAIL, () => {\n this.#emitPendingError();\n });\n\n fsm.on(routerStates.READY, routerEvents.FAIL, () => {\n this.#emitPendingError();\n });\n\n fsm.on(routerStates.TRANSITION_STARTED, routerEvents.FAIL, () => {\n this.#emitPendingError();\n });\n }\n}\n"],"mappings":"wGA+BM,EAAe,eAErB,SAAS,EAAY,EAAuB,CAC1C,OAAO,aAAiB,MAAQ,EAAY,MAAM,OAAO,CAAK,CAAC,CACjE,CAEA,SAAS,EACP,EACA,EACA,EACe,CACf,OAAO,IAAI,SAAe,EAAS,IAAW,CAO5C,IAAM,MAAsB,CAC1B,IAAM,EAAkB,EAAO,OAE/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CAAY,EAErE,EAAI,GAAGK,EAAAA,aAAa,eAAgBL,EAAAA,aAAa,SAAY,CAC3D,KAAKQ,GAAkB,CACzB,CAAC,EAED,EAAI,GAAGH,EAAAA,aAAa,SAAUL,EAAAA,aAAa,SAAY,CACrD,KAAKQ,GAAkB,CACzB,CAAC,EAED,EAAI,GAAGH,EAAAA,aAAa,MAAOL,EAAAA,aAAa,SAAY,CAClD,KAAKQ,GAAkB,CACzB,CAAC,EAED,EAAI,GAAGH,EAAAA,aAAa,mBAAoBL,EAAAA,aAAa,SAAY,CAC/D,KAAKQ,GAAkB,CACzB,CAAC,CACH,CACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../constants.js"),t=require("../../stateMetaStore.js"),n=require("../../transitionPath.js"),r=require("../../RouterError.js"),i=require("./constants.js"),a=require("./transition/completeTransition.js"),o=require("./transition/errorHandling.js"),s=require("./transition/guardPhase.js"),c=Object.freeze([e.constants.UNKNOWN_ROUTE]),l=Object.freeze({replace:!0});function u(t,n){return n?.name===e.constants.UNKNOWN_ROUTE&&!t.replace?{...t,replace:!0}:t}function d(e,t,n){return!!e&&!t.reload&&!t.force&&e.path===n.path}var f=class{lastSyncResolved=!1;lastSyncRejected=!1;#e;#t=null;#n=0;setDependencies(e){this.#e=e}navigate(e,t,n){this.lastSyncResolved=!1;let r=this.#e;if(!r.canNavigate())return this.lastSyncRejected=!0,i.CACHED_NOT_STARTED_REJECTION;let a;try{a=r.buildNavigateState(e,t)}catch(e){return Promise.reject(e)}return a?this.#r(a,n):(r.emitTransitionError(void 0,r.getState(),i.CACHED_ROUTE_NOT_FOUND_ERROR),this.lastSyncRejected=!0,i.CACHED_ROUTE_NOT_FOUND_REJECTION)}navigateToState(n,a){this.lastSyncResolved=!1;let o=this.#e;if(!o.canNavigate())return this.lastSyncRejected=!0,i.CACHED_NOT_STARTED_REJECTION;if(n.name!==e.constants.UNKNOWN_ROUTE&&!o.hasRoute(n.name)){let t=new r.RouterError(e.errorCodes.ROUTE_NOT_FOUND,{routeName:n.name});return o.emitTransitionError(void 0,o.getState(),t),Promise.reject(t)}let s={name:n.name,params:n.params,path:n.path,context:{...n.context}},c=t.getStateMetaParams(n);return c!==void 0&&t.setStateMetaParams(s,c),this.#r(s,a)}navigateToDefault(t){this.lastSyncResolved=!1;let n=this.#e;if(!n.getOptions().defaultRoute)return Promise.reject(new r.RouterError(e.errorCodes.ROUTE_NOT_FOUND,{routeName:`defaultRoute not configured`}));let i,a;try{({route:i,params:a}=n.resolveDefault())}catch(e){return Promise.reject(e)}return i?this.navigate(i,a,t):Promise.reject(new r.RouterError(e.errorCodes.ROUTE_NOT_FOUND,{routeName:`defaultRoute resolved to empty`}))}navigateToNotFound(t){if(!this.#e.isActive())throw new r.RouterError(e.errorCodes.ROUTER_DISPOSED);this.#c();let i=this.#e.getState(),a=i?n.nameToIDs(i.name).toReversed():[];Object.freeze(a);let o={deactivated:a,activated:c,intersection:``};Object.freeze(o);let s={phase:`activating`,...i&&{from:i.name},reason:`success`,replace:!0,segments:o};Object.freeze(s);let u={name:e.constants.UNKNOWN_ROUTE,params:e.EMPTY_PARAMS,path:t,transition:s,context:{}};return Object.freeze(u),this.#e.setState(u),this.#e.emitTransitionSuccess(u,i,l),u}abortCurrentController(t){this.#t?.abort(t??new r.RouterError(e.errorCodes.TRANSITION_CANCELLED)),this.#t=null}#r(t,o){let c=this.#e,l,f=!1,p=null;try{if(l=c.getState(),o=u(o,l),d(l,o,t))return c.emitTransitionError(t,l,i.CACHED_SAME_STATES_ERROR),this.lastSyncRejected=!0,i.CACHED_SAME_STATES_REJECTION;this.#c(o.signal);let m=++this.#n,h=o.signal!==void 0||c.hasLeaveListeners()||c.hasPreCommitListeners();c.startTransition(t,l),f=!0;let[g,_]=c.getLifecycleFunctions(),v=t.name===e.constants.UNKNOWN_ROUTE,y=n.getTransitionPath(t,l),{toDeactivate:b,toActivate:x,intersection:S}=y,C=l&&!o.forceDeactivate&&b.length>0,w=!v&&x.length>0,T=g.size>0||_.size>0,E=t;if(!T){let e=this.#o(E,l,m,o,y,g);if(e!==void 0)return e}if(T){p=new AbortController,this.#t=p;let n=()=>this.#n===m&&c.isActive(),i=p.signal,a=s.executeGuardPipeline(g,_,b,x,!!C,w,t,l,i,n,()=>{if(c.sendLeaveApprove(E,l),c.hasLeaveListeners())return c.awaitLeaveListeners(E,l,i)});if(a!==void 0)return this.#i(a,{toState:t,fromState:l,opts:o,toDeactivate:b,toActivate:x,intersection:S,canDeactivateFunctions:g},p,m);if(!n())throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED);this.#s(p,!1)}if(h&&(!c.isActive()||o.signal?.aborted===!0))throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED);let D=a.completeTransition(c,{toState:t,fromState:l,opts:o,toDeactivate:b,toActivate:x,intersection:S,canDeactivateFunctions:g});return this.lastSyncResolved=!0,Promise.resolve(D)}catch(e){return this.#a(e,p,f,t,l),Promise.reject(e)}}async#i(t,n,i,s){let c=this.#e,l=()=>this.#n===s&&!i.signal.aborted&&c.isActive(),u=n.opts.signal,d,f,p=!1,m,h=new Promise(e=>{if(i.signal.aborted){e();return}f=()=>{e()},i.signal.addEventListener(`abort`,f,{once:!0})});t.catch(()=>{});try{if(u){if(u.aborted)throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED,{reason:u.reason});d=()=>{c.cancelNavigation(u.reason)},u.addEventListener(`abort`,d,{once:!0})}if(await Promise.race([t,h]),!l())throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED);let i=a.completeTransition(c,n);return p=!0,i}catch(e){throw m=e,o.routeTransitionError(c,e,n.toState,n.fromState),e}finally{d&&u?.removeEventListener(`abort`,d),f&&i.signal.removeEventListener(`abort`,f),this.#s(i,!p,m)}}#a(e,t,n,r,i){t&&this.#s(t,!0,e),n&&r&&o.routeTransitionError(this.#e,e,r,i)}#o(e,t,n,r,i,a){let o=this.#e;if(o.sendLeaveApprove(e,t),o.hasLeaveListeners()){let s=new AbortController;this.#t=s;let c;try{c=o.awaitLeaveListeners(e,t,s.signal)}catch(e){throw this.#s(s,!0,e),e}if(c!==void 0)return this.#i(c,{toState:e,fromState:t,opts:r,toDeactivate:i.toDeactivate,toActivate:i.toActivate,intersection:i.intersection,canDeactivateFunctions:a},s,n);this.#s(s,!1);return}}#s(e,t,n){t&&e.abort(n),this.#t===e&&(this.#t=null)}#c(t){if(this.#e.isTransitioning()&&(this.#e.logger.warn(`router.navigate`,`Concurrent navigation detected on shared router instance. For SSR, use cloneRouter() to create isolated instance per request.`),this.#e.cancelNavigation()),t?.aborted)throw new r.RouterError(e.errorCodes.TRANSITION_CANCELLED,{reason:t.reason})}};exports.NavigationNamespace=f;
2
+ //# sourceMappingURL=NavigationNamespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationNamespace.js","names":["constants","#deps","CACHED_NOT_STARTED_REJECTION","CACHED_ROUTE_NOT_FOUND_ERROR","CACHED_ROUTE_NOT_FOUND_REJECTION","#executeNavigation","RouterError","errorCodes","getStateMetaParams","#abortPreviousNavigation","nameToIDs","EMPTY_PARAMS","#currentController","CACHED_SAME_STATES_ERROR","CACHED_SAME_STATES_REJECTION","#navigationId","getTransitionPath","#handleNoGuardsLeave","executeGuardPipeline","#finishAsyncNavigation","#cleanupController","completeTransition","#handleNavigateError"],"sources":["../../../../src/namespaces/NavigationNamespace/NavigationNamespace.ts"],"sourcesContent":["import {\n CACHED_NOT_STARTED_REJECTION,\n CACHED_ROUTE_NOT_FOUND_ERROR,\n CACHED_ROUTE_NOT_FOUND_REJECTION,\n CACHED_SAME_STATES_ERROR,\n CACHED_SAME_STATES_REJECTION,\n} from \"./constants\";\nimport { completeTransition } from \"./transition/completeTransition\";\nimport { routeTransitionError } from \"./transition/errorHandling\";\nimport { executeGuardPipeline } from \"./transition/guardPhase\";\nimport { EMPTY_PARAMS, errorCodes, constants } from \"../../constants\";\nimport { RouterError } from \"../../RouterError\";\nimport { getStateMetaParams, setStateMetaParams } from \"../../stateMetaStore\";\nimport { getTransitionPath, nameToIDs } from \"../../transitionPath\";\n\nimport type { NavigationContext, NavigationDependencies } from \"./types\";\nimport type { TransitionPath } from \"../../transitionPath\";\nimport type {\n GuardFn,\n NavigationOptions,\n Params,\n State,\n TransitionMeta,\n} from \"../../types\";\n\nconst FROZEN_ACTIVATED: string[] = Object.freeze([\n constants.UNKNOWN_ROUTE,\n]) as unknown as string[];\nconst FROZEN_REPLACE_OPTS: NavigationOptions = Object.freeze({ replace: true });\n\nfunction forceReplaceFromUnknown(\n opts: NavigationOptions,\n fromState: State | undefined,\n): NavigationOptions {\n return fromState?.name === constants.UNKNOWN_ROUTE && !opts.replace\n ? { ...opts, replace: true }\n : opts;\n}\n\nfunction isSameNavigation(\n fromState: State | undefined,\n opts: NavigationOptions,\n toState: State,\n): boolean {\n return (\n !!fromState &&\n !opts.reload &&\n !opts.force &&\n fromState.path === toState.path\n );\n}\n\n/**\n * Independent namespace for managing navigation.\n *\n * Handles navigate(), navigateToDefault(), navigateToNotFound(), and transition state.\n *\n * Performance: navigate() uses optimistic sync execution — guards run synchronously\n * until one returns a Promise, then switches to async. This eliminates Promise/AbortController\n * overhead for the common case (no guards or sync guards).\n */\nexport class NavigationNamespace {\n // Stryker disable next-line BooleanLiteral: equivalent — reset to false at the top of every navigate()/navigateToState()/navigateToDefault(), so the initializer value is never observed.\n lastSyncResolved = false;\n lastSyncRejected = false;\n #deps!: NavigationDependencies;\n #currentController: AbortController | null = null;\n #navigationId = 0;\n\n // =========================================================================\n // Dependency injection\n // =========================================================================\n\n setDependencies(deps: NavigationDependencies): void {\n this.#deps = deps;\n }\n\n // =========================================================================\n // Instance methods\n // =========================================================================\n\n navigate(\n name: string,\n params: Params,\n opts: NavigationOptions,\n ): Promise<State> {\n this.lastSyncResolved = false;\n const deps = this.#deps;\n\n // Fast-path sync rejections: cached error + cached Promise.reject\n // No allocations, no throw/catch overhead, facade skips .catch() suppression\n if (!deps.canNavigate()) {\n // Stryker disable next-line BooleanLiteral: equivalent — #721 optimization flag, not a correctness gate. Not flagging the cached (pre-suppressed) rejection routes the facade to the else-branch, which re-attaches a harmless .catch; no observable difference.\n this.lastSyncRejected = true;\n\n return CACHED_NOT_STARTED_REJECTION;\n }\n\n let toState: State | undefined;\n\n try {\n toState = deps.buildNavigateState(name, params);\n } catch (error) {\n /* v8 ignore next 3 -- @preserve: reachable only via validator-driven\n throws from buildNavigateState (validateStateBuilderArgs) — covered\n in @real-router/validation-plugin's suite, not in core. */\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- preserve original throw shape from user-provided buildNavigateState\n return Promise.reject(error);\n }\n\n if (!toState) {\n deps.emitTransitionError(\n undefined,\n deps.getState(),\n CACHED_ROUTE_NOT_FOUND_ERROR,\n );\n // Stryker disable next-line BooleanLiteral: equivalent — #721 optimization flag (see L95): the cached rejection is suppressed by the facade else-branch regardless of the flag.\n this.lastSyncRejected = true;\n\n return CACHED_ROUTE_NOT_FOUND_REJECTION;\n }\n\n return this.#executeNavigation(toState, opts);\n }\n\n /**\n * Navigate to a fully-built `State` directly, skipping `buildNavigateState`\n * (forwardState + buildPath + meta lookup). Used by URL plugins after they\n * have already produced a `State` from a browser-initiated event via\n * `api.matchPath(url)` — see issue #525.\n *\n * Semantics vs. `navigate(name, params, opts)`:\n * - `forwardState` is NOT re-applied. matchPath already runs it; reapplying\n * is redundant in the idempotent case and can race in the dynamic case.\n * - `buildPath` is NOT re-run. The caller's `state.path` is used as-is —\n * so `trailingSlash:\"preserve\"` matchedState paths flow through unchanged\n * (closes #525 Q2). `buildPath` interceptors do NOT run; the URL the\n * user navigated to is the source of truth for this code path.\n * - All other pipeline steps run unchanged: SAME_STATES check, FSM\n * transition, guards, `subscribeLeave`, `completeTransition`,\n * plugin lifecycle hooks.\n */\n navigateToState(state: State, opts: NavigationOptions): Promise<State> {\n this.lastSyncResolved = false;\n const deps = this.#deps;\n\n if (!deps.canNavigate()) {\n // Stryker disable next-line BooleanLiteral: equivalent — #721 optimization flag (see L95): the cached rejection is suppressed by the facade else-branch regardless of the flag.\n this.lastSyncRejected = true;\n\n return CACHED_NOT_STARTED_REJECTION;\n }\n\n // Reject states whose route no longer exists (e.g. the route tree was\n // mutated between matchPath and navigateToState). UNKNOWN_ROUTE is\n // structurally legal — it is the navigateToNotFound output shape.\n if (state.name !== constants.UNKNOWN_ROUTE && !deps.hasRoute(state.name)) {\n const err = new RouterError(errorCodes.ROUTE_NOT_FOUND, {\n routeName: state.name,\n });\n\n deps.emitTransitionError(undefined, deps.getState(), err);\n\n // This is a FRESH reject (carries `routeName`), not one of the\n // pre-suppressed CACHED_*_REJECTION singletons. `lastSyncRejected`\n // contractually means \"I returned a pre-suppressed cached rejection —\n // skip your .catch()\", so leaving it unset lets the facade attach its\n // own suppression. Setting it here leaked an unhandledRejection on\n // fire-and-forget calls (#721).\n return Promise.reject(err);\n }\n\n // States from `matchPath` are deeply frozen (`freezeStateInPlace`).\n // `completeTransition` mutates `toState.transition` and `context` is\n // intentionally extensible for plugin claim writes, so we hand the\n // pipeline a writable shell — same shape `makeState(skipFreeze=true)`\n // produces. `params` stays referentially shared (already frozen).\n // `transition` is omitted so completeTransition can assign it.\n const writableState = {\n name: state.name,\n params: state.params,\n path: state.path,\n context: { ...state.context },\n } as State;\n\n // Carry the route-meta binding (#1170). `matchPath` / `makeState` attach it\n // to the frozen source `state` via a WeakMap keyed by object reference, so\n // the fresh writable shell would otherwise be meta-less. Without it, two\n // consecutive popstate navigations make both `toState` AND `fromState`\n // meta-less, dropping `getTransitionPath` to FAST PATH 3 (full chains):\n // ancestor guards re-run and browser-back can block where `navigate()`\n // succeeds.\n const meta = getStateMetaParams(state);\n\n if (meta !== undefined) {\n setStateMetaParams(writableState, meta);\n }\n\n return this.#executeNavigation(writableState, opts);\n }\n\n navigateToDefault(opts: NavigationOptions): Promise<State> {\n // Reset the sync-resolution flag on entry, mirroring navigate() and\n // navigateToState(). start() leaves `lastSyncResolved = true`, and the\n // early reject paths below return before delegating to navigate(), so a\n // stale `true` would make the facade take the \"already resolved\" branch\n // and skip .catch() suppression — leaking an unhandledRejection on\n // fire-and-forget calls (#721).\n this.lastSyncResolved = false;\n const deps = this.#deps;\n const options = deps.getOptions();\n\n if (!options.defaultRoute) {\n return Promise.reject(\n new RouterError(errorCodes.ROUTE_NOT_FOUND, {\n routeName: \"defaultRoute not configured\",\n }),\n );\n }\n\n let route: string;\n let params: Params;\n\n try {\n ({ route, params } = deps.resolveDefault());\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- preserve original throw shape from user-provided resolveDefault callback\n return Promise.reject(error);\n }\n\n if (!route) {\n return Promise.reject(\n new RouterError(errorCodes.ROUTE_NOT_FOUND, {\n routeName: \"defaultRoute resolved to empty\",\n }),\n );\n }\n\n return this.navigate(route, params, opts);\n }\n\n navigateToNotFound(path: string): State {\n // #1186 — liveness gate. This internal commit primitive has no FSM\n // transition of its own, so without this check a `dispose()` that lands\n // while a start-interceptor is parked (FSM already DISPOSED) would let the\n // resuming pipeline commit an UNKNOWN_ROUTE state on the disposed router and\n // `start()` resolve. Symmetric with `navigateToState`'s `canNavigate()` gate\n // (the matched-route branch is already protected). `!isActive()` also covers\n // a merely-stopped (IDLE) router: the only reachable path to that is a direct\n // `router.navigateToNotFound()` on a stopped instance (internal callers run\n // during STARTING, which is active), so the ROUTER_DISPOSED code is slightly\n // broad there — fail-closed is deliberate (committing on a stopped router is\n // out of contract), and the disposed race is the case that matters.\n if (!this.#deps.isActive()) {\n throw new RouterError(errorCodes.ROUTER_DISPOSED);\n }\n\n this.#abortPreviousNavigation();\n\n const fromState = this.#deps.getState();\n const deactivated: string[] = fromState\n ? nameToIDs(fromState.name).toReversed()\n : [];\n\n Object.freeze(deactivated);\n\n const segments: TransitionMeta[\"segments\"] = {\n deactivated,\n activated: FROZEN_ACTIVATED,\n intersection: \"\",\n };\n\n Object.freeze(segments);\n\n const transitionMeta: TransitionMeta = {\n phase: \"activating\",\n ...(fromState && { from: fromState.name }),\n reason: \"success\",\n replace: true,\n segments,\n };\n\n Object.freeze(transitionMeta);\n\n const state: State = {\n name: constants.UNKNOWN_ROUTE,\n params: EMPTY_PARAMS,\n path,\n transition: transitionMeta,\n context: {},\n };\n\n Object.freeze(state);\n\n this.#deps.setState(state);\n this.#deps.emitTransitionSuccess(state, fromState, FROZEN_REPLACE_OPTS);\n\n return state;\n }\n\n /**\n * Aborts and releases the in-flight navigation's `AbortController` (waking the\n * parked async pipeline via `onInternalAbort`). This is the\n * **effect** of the FSM `CANCEL` action (`handleCancel` → injected\n * `deps.abortCurrentController`), not something cancellation sources call\n * directly — so \"FSM `CANCEL` ⟹ controller aborted\" holds in one place (RFC\n * navigation-cancellation-unification §5). `reason` (e.g. an external\n * `opts.signal`'s reason, #943) becomes the controller's `signal.reason`;\n * defaults to `TRANSITION_CANCELLED`.\n */\n abortCurrentController(reason?: unknown): void {\n this.#currentController?.abort(\n reason ?? new RouterError(errorCodes.TRANSITION_CANCELLED),\n );\n this.#currentController = null;\n }\n\n #executeNavigation(toState: State, opts: NavigationOptions): Promise<State> {\n const deps = this.#deps;\n let fromState: State | undefined;\n let transitionStarted = false;\n let controller: AbortController | null = null;\n\n try {\n fromState = deps.getState();\n opts = forceReplaceFromUnknown(opts, fromState);\n\n if (isSameNavigation(fromState, opts, toState)) {\n deps.emitTransitionError(toState, fromState, CACHED_SAME_STATES_ERROR);\n // Stryker disable next-line BooleanLiteral: equivalent — #721 optimization flag (see L95): the cached rejection is suppressed by the facade else-branch regardless of the flag.\n this.lastSyncRejected = true;\n\n return CACHED_SAME_STATES_REJECTION;\n }\n\n this.#abortPreviousNavigation(opts.signal);\n\n // Stryker disable next-line UpdateOperator: equivalent — `#navigationId` is only ever compared by identity (`!== myId`) to detect supersession; uniqueness per navigation is all that matters, so `--` (decreasing ids) is indistinguishable from `++`.\n const myId = ++this.#navigationId;\n\n // #1169 commit-gate — liveness snapshot captured BEFORE the pre-commit\n // listener windows. A listener's `stop()`/`dispose()` runs `clearAll()`,\n // which empties the listener lists, so the marker must be read now, not at\n // the commit site (that self-destruct was the QB/QE hole, RFC §5-bis).\n // `suspendable` is true only when a synchronous supersede is reachable — an\n // external `opts.signal`, `subscribeLeave` listeners, or a pre-commit\n // plugin listener (`onTransitionStart` / `onTransitionLeaveApprove`); the\n // pure synchronous navigate (none of these) is uncancellable and skips the\n // gate, keeping the #307 hot path perf-neutral.\n const suspendable =\n opts.signal !== undefined ||\n deps.hasLeaveListeners() ||\n deps.hasPreCommitListeners();\n\n deps.startTransition(toState, fromState);\n transitionStarted = true;\n\n // Post-`startTransition` supersession is now caught at the commit-gate\n // below (before `completeTransition`'s setState): a `stop()`/`dispose()`/\n // external-abort from the TRANSITION_START listener leaves the FSM in\n // IDLE/DISPOSED, which `!deps.isActive()` detects. (Async supersession is\n // additionally caught in `#finishAsyncNavigation` / the guard pipeline's\n // `isCurrentNav`; a reentrant navigate() is banned — REENTRANT_NAVIGATION.)\n\n const [canDeactivateFunctions, canActivateFunctions] =\n deps.getLifecycleFunctions();\n const isUnknownRoute = toState.name === constants.UNKNOWN_ROUTE;\n\n const transitionPath = getTransitionPath(toState, fromState);\n const { toDeactivate, toActivate, intersection } = transitionPath;\n\n const shouldDeactivate =\n fromState && !opts.forceDeactivate && toDeactivate.length > 0;\n const shouldActivate = !isUnknownRoute && toActivate.length > 0;\n const hasGuards =\n canDeactivateFunctions.size > 0 || canActivateFunctions.size > 0;\n\n const confirmedToState = toState;\n\n if (!hasGuards) {\n const asyncLeave = this.#handleNoGuardsLeave(\n confirmedToState,\n fromState,\n myId,\n opts,\n transitionPath,\n canDeactivateFunctions,\n );\n\n if (asyncLeave !== undefined) {\n return asyncLeave;\n }\n }\n\n // Stryker disable next-line ConditionalExpression: equivalent — running the guard pipeline on the no-guards path does not double-emit LEAVE_APPROVE (full suite green with `if (true)`); the BlockStatement mutant stays live (killed by guarded-route tests).\n // eslint-disable-next-line unicorn/prefer-else-if -- two exhaustive `if`s read clearer here than an else-if; merging cascades into no-negated-condition / no-unnecessary-condition in this hot guard-setup branch\n if (hasGuards) {\n controller = new AbortController();\n this.#currentController = controller;\n const isCurrentNav = () =>\n this.#navigationId === myId && deps.isActive();\n\n const signal = controller.signal;\n\n const emitLeaveApproveCallback = (): Promise<void> | undefined => {\n deps.sendLeaveApprove(confirmedToState, fromState);\n\n if (deps.hasLeaveListeners()) {\n return deps.awaitLeaveListeners(\n confirmedToState,\n fromState,\n signal,\n );\n }\n\n return undefined;\n };\n\n const guardCompletion = executeGuardPipeline(\n canDeactivateFunctions,\n canActivateFunctions,\n toDeactivate,\n toActivate,\n !!shouldDeactivate,\n shouldActivate,\n toState,\n fromState,\n signal,\n isCurrentNav,\n emitLeaveApproveCallback,\n );\n\n if (guardCompletion !== undefined) {\n return this.#finishAsyncNavigation(\n guardCompletion,\n {\n toState,\n fromState,\n opts,\n toDeactivate,\n toActivate,\n intersection,\n canDeactivateFunctions,\n },\n controller,\n myId,\n );\n }\n\n if (!isCurrentNav()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n this.#cleanupController(controller, false);\n }\n\n // #1169 commit-gate — refuse to commit a navigation cancelled or\n // terminated during a listener window, BEFORE `completeTransition`'s\n // setState. The FSM table (D-full) already prevents the forceState\n // resurrection; this prevents the state commit that precedes the emit.\n // Gated on `suspendable` so the pure sync hot path pays nothing. A\n // `stop()`/`dispose()` from the listener lands the FSM in IDLE/DISPOSED\n // (caught by `!isActive()`); an external `opts.signal` abort is caught\n // directly. No `#navigationId` check: a reentrant navigate() (the only\n // thing that could bump it synchronously) is banned (REENTRANT_NAVIGATION,\n // §4), so on this sync path `#navigationId === myId` always holds — async\n // supersede is caught in `#finishAsyncNavigation`'s `isCurrentNav`.\n if (suspendable && (!deps.isActive() || opts.signal?.aborted === true)) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n const finalState = completeTransition(deps, {\n toState,\n fromState,\n opts,\n toDeactivate,\n toActivate,\n intersection,\n canDeactivateFunctions,\n });\n\n // Mark sync-resolution only AFTER completeTransition returns. It emits\n // TRANSITION_SUCCESS; listener throws are all isolated via onListenerError\n // (the emitter re-throws nothing now that re-entrant emits are coalesced,\n // #1033, and reentrant navigate/CRUD are banned), so the emit itself does\n // not throw. Should completeTransition throw for any other reason, setting\n // the flag optimistically BEFORE it would leave the flag stale-true, so the\n // facade would read lastSyncResolved and skip its suppressing `.catch()` —\n // the rejection would then leak as a Node unhandledRejection. Post-emit\n // placement keeps the flag false on a throw, so control falls to catch and\n // the facade attaches its `.catch`.\n // Stryker disable next-line BooleanLiteral: equivalent — flipping to false routes the facade to the else-branch, which attaches a harmless .catch to an already-resolved promise; there is no rejection to suppress.\n this.lastSyncResolved = true;\n\n return Promise.resolve(finalState);\n } catch (error) {\n this.#handleNavigateError(\n error,\n controller,\n transitionStarted,\n toState,\n fromState,\n );\n\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- preserve original throw shape from guards or transition pipeline\n return Promise.reject(error);\n }\n }\n\n async #finishAsyncNavigation(\n guardCompletion: Promise<void>,\n nav: NavigationContext,\n controller: AbortController,\n myId: number,\n ): Promise<State> {\n const deps = this.#deps;\n const isActive = () =>\n this.#navigationId === myId &&\n !controller.signal.aborted &&\n deps.isActive();\n\n const externalSignal = nav.opts.signal;\n let onExternalAbort: (() => void) | undefined;\n let onInternalAbort: (() => void) | undefined;\n let succeeded = false;\n let failureReason: unknown;\n\n // #1018: race the guard completion against the controller's abort so a\n // non-cooperative guard whose Promise never settles (and ignores `signal`)\n // cannot wedge navigate() forever. `abortRace` RESOLVES on abort, so the\n // post-race `isActive()` check below throws TRANSITION_CANCELLED — the same\n // path that already handles a guard which swallows the abort and resolves\n // `true`. `stop()`/`dispose()`/supersede all abort the controller. Mirrors\n // the leave-path protection `settleLeavePromises` (#663/#673).\n const abortRace = new Promise<void>((resolve) => {\n if (controller.signal.aborted) {\n resolve();\n\n return;\n }\n\n onInternalAbort = () => {\n resolve();\n };\n\n controller.signal.addEventListener(\"abort\", onInternalAbort, {\n once: true,\n });\n });\n\n // Consume `guardCompletion` when the abort wins the race: a slow or\n // never-settling guard that settles later then has no awaiter, which would\n // surface as an unhandled rejection without this catch.\n guardCompletion.catch(() => {\n /* settlement consumed — the race already decided the navigation */\n });\n\n try {\n if (externalSignal) {\n if (externalSignal.aborted) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED, {\n reason: externalSignal.reason,\n });\n }\n\n // Bridge an external `{ signal }` abort onto the internal controller.\n // It is NOT scoped to `controller.signal` (the old `{ signal }` option)\n // because success no longer aborts the controller (#722) — the listener\n // is detached explicitly in `finally` instead.\n onExternalAbort = () => {\n // (#1030): route the external abort through the FSM. The\n // `CANCEL` action aborts the internal controller (waking THIS pipeline)\n // with the external `reason` (#943 — surfaces via the leave signal) AND\n // returns the FSM to READY, atomically. No direct `controller.abort`\n // here — \"FSM CANCEL ⟹ controller aborted\" lives in one place\n // (handleCancel). onExternalAbort only fires while the navigation is in\n // flight (the listener is removed in `finally` once it settles), so the\n // FSM is always cancellable here.\n deps.cancelNavigation(externalSignal.reason);\n };\n // Stryker disable next-line ObjectLiteral: equivalent — `{ once: true }` is redundant: the per-navigation signal aborts at most once and is discarded unaborted on success, and the `finally` block explicitly removeEventListener's it.\n externalSignal.addEventListener(\"abort\", onExternalAbort, {\n // Stryker disable next-line BooleanLiteral: equivalent — `once` redundant (see ObjectLiteral above); the listener is explicitly removed in `finally`.\n once: true,\n });\n }\n\n await Promise.race([guardCompletion, abortRace]);\n\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n const state = completeTransition(deps, nav);\n\n succeeded = true;\n\n return state;\n } catch (error) {\n failureReason = error;\n\n routeTransitionError(deps, error, nav.toState, nav.fromState);\n\n throw error;\n // NB: the `} finally {}` BlockStatement mutant SURVIVES but is EQUIVALENT —\n // emptying the finally only skips #cleanupController, which is unobservable\n // (defense-in-depth: on a CANCEL the FSM CANCEL action already aborted+nulled\n // the controller via abortCurrentController, RFC §5; the success-path\n // ref-release is proven unobservable — see #cleanupController's disable). It\n // cannot be inline-`Stryker disable`d: the catch `}` and finally `{` share one\n // line, so there is no comment position that targets the finally body. Left documented.\n } finally {\n // Stryker disable next-line ConditionalExpression,BlockStatement: equivalent — listener cleanup is redundant: the per-navigation signal is discarded on completion, so skipping the removeEventListener leaks nothing observable.\n if (onExternalAbort) {\n // Stryker disable next-line StringLiteral: equivalent — cleanup event name is redundant (listener is `{ once: true }` and the signal is discarded), so a wrong name removes nothing observable.\n externalSignal?.removeEventListener(\"abort\", onExternalAbort);\n }\n\n // Detach the abort-race listener before #cleanupController aborts the\n // controller below, so the cleanup abort cannot re-fire it. `undefined`\n // only when the controller was already aborted at setup (the early-resolve\n // branch above registered no listener).\n if (onInternalAbort) {\n controller.signal.removeEventListener(\"abort\", onInternalAbort);\n }\n\n // Success drops the controller without aborting (the subscribeLeave signal\n // must stay unaborted); cancel/error aborts it with the originating reason\n // so captured signals expose the real cause via `signal.reason` (#943).\n this.#cleanupController(controller, !succeeded, failureReason);\n }\n }\n\n #handleNavigateError(\n error: unknown,\n controller: AbortController | null,\n transitionStarted: boolean,\n toState: State | undefined,\n fromState: State | undefined,\n ): void {\n if (controller) {\n this.#cleanupController(controller, true, error);\n }\n\n if (transitionStarted && toState) {\n routeTransitionError(this.#deps, error, toState, fromState);\n }\n }\n\n #handleNoGuardsLeave(\n toState: State,\n fromState: State | undefined,\n myId: number,\n opts: NavigationOptions,\n transitionPath: TransitionPath,\n canDeactivateFunctions: Map<string, GuardFn>,\n ): Promise<State> | undefined {\n const deps = this.#deps;\n\n deps.sendLeaveApprove(toState, fromState);\n\n if (deps.hasLeaveListeners()) {\n const controller = new AbortController();\n\n // Track as the current navigation BEFORE listeners run so a reentrant\n // navigate() / stop() / dispose() from a sync listener aborts THIS leave\n // signal — parity with the guard path (#722). On success the controller is\n // released without aborting (see #cleanupController).\n this.#currentController = controller;\n\n let leaveResult: Promise<void> | undefined;\n\n try {\n leaveResult = deps.awaitLeaveListeners(\n toState,\n fromState,\n controller.signal,\n );\n } catch (error) {\n // A sync listener threw — the navigation fails; abort the leave signal\n // with the thrown value so a listener that captured the signal sees the\n // real cause via `signal.reason`, not a generic AbortError (#943).\n this.#cleanupController(controller, true, error);\n\n throw error;\n }\n\n if (leaveResult !== undefined) {\n return this.#finishAsyncNavigation(\n leaveResult,\n {\n toState,\n fromState,\n opts,\n toDeactivate: transitionPath.toDeactivate,\n toActivate: transitionPath.toActivate,\n intersection: transitionPath.intersection,\n canDeactivateFunctions,\n },\n controller,\n myId,\n );\n }\n\n // Sync listeners settled. A synchronous reentrant navigate() can no longer\n // supersede here (banned, RFC §4), so the leave always succeeds: release the\n // controller WITHOUT aborting (the subscribeLeave signal must stay live).\n this.#cleanupController(controller, false);\n\n return undefined;\n }\n\n // No leave listeners: nothing synchronous could have superseded this\n // navigation during the LEAVE_APPROVE emit (reentrant navigate is banned).\n return undefined;\n }\n\n /**\n * Release a navigation's AbortController. The same `controller.signal` is\n * handed to `subscribeLeave` listeners, so it must abort **only** when the\n * navigation is cancelled or errors — never on success (#722). On the success\n * path pass `cancelled = false`: the reference is dropped without aborting, so\n * a listener that captured the signal still sees `aborted === false`.\n *\n * On the failure/cancellation path (`cancelled = true`) pass the originating\n * `reason` so `signal.reason` carries router/error context (a `RouterError`,\n * or the value a sync leave listener threw) — consistent with the cancellation\n * abort `RouterError(TRANSITION_CANCELLED)`, not a generic `AbortError` (#943).\n * `abort()` is idempotent: a controller already aborted by a superseding\n * navigation keeps its first (also-meaningful) reason.\n */\n #cleanupController(\n controller: AbortController,\n cancelled: boolean,\n reason?: unknown,\n ): void {\n if (cancelled) {\n controller.abort(reason);\n }\n\n // Stryker disable next-line ConditionalExpression,EqualityOperator,BlockStatement: equivalent — controller identity-guard; cleanup correctness is enforced by #abortPreviousNavigation + the navigationId/isCurrentNav checks. Full suite stays green with `=== → !==` (nulls the wrong controller) and with the body removed (ref never nulled), so no mutant here is observable.\n if (this.#currentController === controller) {\n this.#currentController = null;\n }\n }\n\n #abortPreviousNavigation(externalSignal?: AbortSignal): void {\n if (this.#deps.isTransitioning()) {\n this.#deps.logger.warn(\n \"router.navigate\",\n \"Concurrent navigation detected on shared router instance. \" +\n \"For SSR, use cloneRouter() to create isolated instance per request.\",\n );\n // The FSM CANCEL action aborts the previous controller — no\n // direct controller.abort here (RFC navigation-cancellation-unification §5).\n this.#deps.cancelNavigation();\n }\n\n if (externalSignal?.aborted) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED, {\n reason: externalSignal.reason,\n });\n }\n }\n}\n"],"mappings":"iTAyBM,EAA6B,OAAO,OAAO,CAC/CA,EAAAA,UAAU,aACZ,CAAC,EACK,EAAyC,OAAO,OAAO,CAAE,QAAS,EAAK,CAAC,EAE9E,SAAS,EACP,EACA,EACmB,CACnB,OAAO,GAAW,OAASA,EAAAA,UAAU,eAAiB,CAAC,EAAK,QACxD,CAAE,GAAG,EAAM,QAAS,EAAK,EACzB,CACN,CAEA,SAAS,EACP,EACA,EACA,EACS,CACT,MACE,CAAC,CAAC,GACF,CAAC,EAAK,QACN,CAAC,EAAK,OACN,EAAU,OAAS,EAAQ,IAE/B,CAWA,IAAa,EAAb,KAAiC,CAE/B,iBAAmB,GACnB,iBAAmB,GACnB,GACA,GAA6C,KAC7C,GAAgB,EAMhB,gBAAgB,EAAoC,CAClD,KAAKC,GAAQ,CACf,CAMA,SACE,EACA,EACA,EACgB,CAChB,KAAK,iBAAmB,GACxB,IAAM,EAAO,KAAKA,GAIlB,GAAI,CAAC,EAAK,YAAY,EAIpB,MAFA,MAAK,iBAAmB,GAEjBC,EAAAA,6BAGT,IAAI,EAEJ,GAAI,CACF,EAAU,EAAK,mBAAmB,EAAM,CAAM,CAChD,OAAS,EAAO,CAKd,OAAO,QAAQ,OAAO,CAAK,CAC7B,CAcA,OAZK,EAYE,KAAKG,GAAmB,EAAS,CAAI,GAX1C,EAAK,oBACH,IAAA,GACA,EAAK,SAAS,EACdF,EAAAA,4BACF,EAEA,KAAK,i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,EAAY,CAAC,EAAW,CAAa,CAC/D,CACF,CAEA,GACE,EACA,EACA,EACA,EACA,EACM,CACF,GACF,KAAKA,GAAmB,EAAY,GAAM,CAAK,EAG7C,GAAqB,GACvB,EAAA,qBAAqB,KAAKnB,GAAO,EAAO,EAAS,CAAS,CAE9D,CAEA,GACE,EACA,EACA,EACA,EACA,EACA,EAC4B,CAC5B,IAAM,EAAO,KAAKA,GAIlB,GAFA,EAAK,iBAAiB,EAAS,CAAS,EAEpC,EAAK,kBAAkB,EAAG,CAC5B,IAAM,EAAa,IAAI,gBAMvB,KAAKW,GAAqB,EAE1B,IAAI,EAEJ,GAAI,CACF,EAAc,EAAK,oBACjB,EACA,EACA,EAAW,MACb,CACF,OAAS,EAAO,CAMd,MAFA,KAAKQ,GAAmB,EAAY,GAAM,CAAK,EAEzC,CACR,CAEA,GAAI,IAAgB,IAAA,GAClB,OAAO,KAAKD,GACV,EACA,CACE,UACA,YACA,OACA,aAAc,EAAe,aAC7B,WAAY,EAAe,WAC3B,aAAc,EAAe,aAC7B,wBACF,EACA,EACA,CACF,EAMF,KAAKC,GAAmB,EAAY,EAAK,EAEzC,MACF,CAKF,CAgBA,GACE,EACA,EACA,EACM,CACF,GACF,EAAW,MAAM,CAAM,EAIrB,KAAKR,KAAuB,IAC9B,KAAKA,GAAqB,KAE9B,CAEA,GAAyB,EAAoC,CAY3D,GAXI,KAAKX,GAAM,gBAAgB,IAC7B,KAAKA,GAAM,OAAO,KAChB,kBACA,+HAEF,EAGA,KAAKA,GAAM,iBAAiB,GAG1B,GAAgB,QAClB,MAAM,IAAIK,EAAAA,YAAYC,EAAAA,WAAW,qBAAsB,CACrD,OAAQ,EAAe,MACzB,CAAC,CAEL,CACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../constants.js"),t=require("../../RouterError.js"),n=new t.RouterError(e.errorCodes.ROUTER_NOT_STARTED),r=new t.RouterError(e.errorCodes.ROUTE_NOT_FOUND),i=new t.RouterError(e.errorCodes.SAME_STATES),a=Promise.reject(n),o=Promise.reject(r),s=Promise.reject(i);a.catch(()=>{}),o.catch(()=>{}),s.catch(()=>{}),exports.CACHED_NOT_STARTED_ERROR=n,exports.CACHED_NOT_STARTED_REJECTION=a,exports.CACHED_ROUTE_NOT_FOUND_ERROR=r,exports.CACHED_ROUTE_NOT_FOUND_REJECTION=o,exports.CACHED_SAME_STATES_ERROR=i,exports.CACHED_SAME_STATES_REJECTION=s;
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["RouterError","errorCodes"],"sources":["../../../../src/namespaces/NavigationNamespace/constants.ts"],"sourcesContent":["// packages/core/src/namespaces/NavigationNamespace/constants.ts\n\nimport { errorCodes } from \"../../constants\";\nimport { RouterError } from \"../../RouterError\";\n\nimport type { State } from \"../../types\";\n\n// =============================================================================\n// Cached Errors & Rejected Promises (Performance Optimization)\n// =============================================================================\n// Pre-create error instances and rejected promises for sync error paths\n// in navigate(). Eliminates per-call allocations:\n// - new RouterError() — object + stack trace capture (~500ns-2μs)\n// - Promise.reject() — promise allocation\n// - .catch(handler) — derived promise from suppression\n//\n// Trade-off: All error instances share the same stack trace (points here).\n// This is acceptable because:\n// 1. These errors indicate expected conditions, not internal bugs\n// 2. Error code and message are sufficient for debugging\n// 3. The facade skips .catch() suppression for cached promises (zero alloc)\n// =============================================================================\n\nexport const CACHED_NOT_STARTED_ERROR = new RouterError(\n errorCodes.ROUTER_NOT_STARTED,\n);\n\nexport const CACHED_ROUTE_NOT_FOUND_ERROR = new RouterError(\n errorCodes.ROUTE_NOT_FOUND,\n);\n\nexport const CACHED_SAME_STATES_ERROR = new RouterError(errorCodes.SAME_STATES);\n\n// Pre-suppressed rejected promises — .catch() at module load prevents\n// unhandled rejection warnings. The facade skips additional .catch() calls\n// via the lastSyncRejected flag (zero derived-promise allocation).\nexport const CACHED_NOT_STARTED_REJECTION: Promise<State> = Promise.reject(\n CACHED_NOT_STARTED_ERROR,\n);\n\nexport const CACHED_ROUTE_NOT_FOUND_REJECTION: Promise<State> = Promise.reject(\n CACHED_ROUTE_NOT_FOUND_ERROR,\n);\n\nexport const CACHED_SAME_STATES_REJECTION: Promise<State> = Promise.reject(\n CACHED_SAME_STATES_ERROR,\n);\n\n// Suppress once at module load — prevents unhandled rejection events.\n// Subsequent .catch() / await by user code still works correctly:\n// a rejected promise stays rejected forever, each .catch() creates\n// its own derived promise and fires its handler.\nCACHED_NOT_STARTED_REJECTION.catch(() => {}); // NOSONAR -- intentional suppression, not a promise chain\nCACHED_ROUTE_NOT_FOUND_REJECTION.catch(() => {}); // NOSONAR\nCACHED_SAME_STATES_REJECTION.catch(() => {}); // NOSONAR\n"],"mappings":"wEAuBa,EAA2B,IAAIA,EAAAA,YAC1CC,EAAAA,WAAW,kBACb,EAEa,EAA+B,IAAID,EAAAA,YAC9CC,EAAAA,WAAW,eACb,EAEa,EAA2B,IAAID,EAAAA,YAAYC,EAAAA,WAAW,WAAW,EAKjE,EAA+C,QAAQ,OAClE,CACF,EAEa,EAAmD,QAAQ,OACtE,CACF,EAEa,EAA+C,QAAQ,OAClE,CACF,EAMA,EAA6B,UAAY,CAAC,CAAC,EAC3C,EAAiC,UAAY,CAAC,CAAC,EAC/C,EAA6B,UAAY,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../../constants.js"),t=require("../../../RouterError.js");function n(e,t,n,r,i){Object.freeze(n),Object.freeze(r);let a={phase:`activating`,reason:`success`,segments:Object.freeze({deactivated:n,activated:r,intersection:i})};return e?.name!==void 0&&(a.from=e.name),t.reload!==void 0&&(a.reload=t.reload),t.replace!==void 0&&(a.replace=t.replace),t.redirected!==void 0&&(a.redirected=t.redirected),Object.freeze(a)}function r({signal:e,...t}){return t}function i(i,a){let{toState:o,fromState:s,opts:c,toDeactivate:l,toActivate:u,intersection:d}=a;if(o.name!==e.constants.UNKNOWN_ROUTE&&!i.hasRoute(o.name)){let n=new t.RouterError(e.errorCodes.ROUTE_NOT_FOUND,{routeName:o.name});throw i.sendTransitionFail(o,s,n),n}if(s)for(let e of l)!u.includes(e)&&a.canDeactivateFunctions.has(e)&&i.clearCanDeactivate(e);o.transition=n(s,c,l,u,d);let f=Object.freeze(o);i.setState(f);let p=c.signal===void 0?c:r(c);return i.sendTransitionDone(f,s,p),f}exports.completeTransition=i;
2
+ //# sourceMappingURL=completeTransition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completeTransition.js","names":["constants","RouterError","errorCodes"],"sources":["../../../../../src/namespaces/NavigationNamespace/transition/completeTransition.ts"],"sourcesContent":["import { errorCodes, constants } from \"../../../constants\";\nimport { RouterError } from \"../../../RouterError\";\n\nimport type { NavigationOptions, State, TransitionMeta } from \"../../../types\";\nimport type { NavigationDependencies, NavigationContext } from \"../types\";\n\ntype MutableTransitionMeta = {\n -readonly [K in keyof TransitionMeta]: TransitionMeta[K];\n};\n\nfunction buildTransitionMeta(\n fromState: State | undefined,\n opts: NavigationOptions,\n toDeactivate: string[],\n toActivate: string[],\n intersection: string,\n): TransitionMeta {\n Object.freeze(toDeactivate);\n Object.freeze(toActivate);\n\n const segments = Object.freeze({\n deactivated: toDeactivate,\n activated: toActivate,\n intersection,\n });\n\n const meta: MutableTransitionMeta = {\n phase: \"activating\",\n reason: \"success\",\n segments,\n };\n\n if (fromState?.name !== undefined) {\n meta.from = fromState.name;\n }\n\n if (opts.reload !== undefined) {\n meta.reload = opts.reload;\n }\n\n if (opts.replace !== undefined) {\n meta.replace = opts.replace;\n }\n\n if (opts.redirected !== undefined) {\n meta.redirected = opts.redirected;\n }\n\n return Object.freeze(meta);\n}\n\nfunction stripSignal({\n signal: _,\n ...rest\n}: NavigationOptions): NavigationOptions {\n return rest;\n}\n\nexport function completeTransition(\n deps: NavigationDependencies,\n nav: NavigationContext,\n): State {\n const { toState, fromState, opts, toDeactivate, toActivate, intersection } =\n nav;\n\n if (\n toState.name !== constants.UNKNOWN_ROUTE &&\n !deps.hasRoute(toState.name)\n ) {\n const err = new RouterError(errorCodes.ROUTE_NOT_FOUND, {\n routeName: toState.name,\n });\n\n deps.sendTransitionFail(toState, fromState, err);\n\n throw err;\n }\n\n if (fromState) {\n for (const name of toDeactivate) {\n if (!toActivate.includes(name) && nav.canDeactivateFunctions.has(name)) {\n deps.clearCanDeactivate(name);\n }\n }\n }\n\n (toState as { transition: TransitionMeta }).transition = buildTransitionMeta(\n fromState,\n opts,\n toDeactivate,\n toActivate,\n intersection,\n );\n\n const finalState = Object.freeze(toState);\n\n deps.setState(finalState);\n\n const transitionOpts = opts.signal === undefined ? opts : stripSignal(opts);\n\n deps.sendTransitionDone(finalState, fromState, transitionOpts);\n\n return finalState;\n}\n"],"mappings":"8EAUA,SAAS,EACP,EACA,EACA,EACA,EACA,EACgB,CAChB,OAAO,OAAO,CAAY,EAC1B,OAAO,OAAO,CAAU,EAQxB,IAAM,EAA8B,CAClC,MAAO,aACP,OAAQ,UACR,SATe,OAAO,OAAO,CAC7B,YAAa,EACb,UAAW,EACX,cACF,CAKS,CACT,EAkBA,OAhBI,GAAW,OAAS,IAAA,KACtB,EAAK,KAAO,EAAU,MAGpB,EAAK,SAAW,IAAA,KAClB,EAAK,OAAS,EAAK,QAGjB,EAAK,UAAY,IAAA,KACnB,EAAK,QAAU,EAAK,SAGlB,EAAK,aAAe,IAAA,KACtB,EAAK,WAAa,EAAK,YAGlB,OAAO,OAAO,CAAI,CAC3B,CAEA,SAAS,EAAY,CACnB,OAAQ,EACR,GAAG,GACoC,CACvC,OAAO,CACT,CAEA,SAAgB,EACd,EACA,EACO,CACP,GAAM,CAAE,UAAS,YAAW,OAAM,eAAc,aAAY,gBAC1D,EAEF,GACE,EAAQ,OAASA,EAAAA,UAAU,eAC3B,CAAC,EAAK,SAAS,EAAQ,IAAI,EAC3B,CACA,IAAM,EAAM,IAAIC,EAAAA,YAAYC,EAAAA,WAAW,gBAAiB,CACtD,UAAW,EAAQ,IACrB,CAAC,EAID,MAFA,EAAK,mBAAmB,EAAS,EAAW,CAAG,EAEzC,CACR,CAEA,GAAI,EACG,IAAA,IAAM,KAAQ,EACb,CAAC,EAAW,SAAS,CAAI,GAAK,EAAI,uBAAuB,IAAI,CAAI,GACnE,EAAK,mBAAmB,CAAI,EAKlC,EAA4C,WAAa,EACvD,EACA,EACA,EACA,EACA,CACF,EAEA,IAAM,EAAa,OAAO,OAAO,CAAO,EAExC,EAAK,SAAS,CAAU,EAExB,IAAM,EAAiB,EAAK,SAAW,IAAA,GAAY,EAAO,EAAY,CAAI,EAI1E,OAFA,EAAK,mBAAmB,EAAY,EAAW,CAAc,EAEtD,CACT"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../../constants.js"),t=require("../../../RouterError.js");function n(t,n,r,i){let a=n;a.code!==e.errorCodes.TRANSITION_CANCELLED&&a.code!==e.errorCodes.ROUTE_NOT_FOUND&&t.sendTransitionFail(r,i,a)}function r(n,r,a){if(n instanceof DOMException&&n.name===`AbortError`)throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED);if(n instanceof t.RouterError&&n.code===e.errorCodes.TRANSITION_CANCELLED)throw n;i(n,r,a)}function i(e,n,r){throw e instanceof t.RouterError?(e.setCode(n),e):new t.RouterError(n,o(e,r))}const a=new Set([`code`,`segment`,`path`,`then`]);function o(e,t){let n={segment:t};if(e instanceof Error)return{...n,message:e.message,stack:e.stack,...`cause`in e&&e.cause!==void 0&&{cause:e.cause}};if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))a.has(n)||(t[n]=r);return{...n,...t}}return n}exports.handleGuardError=r,exports.rethrowAsRouterError=i,exports.routeTransitionError=n,exports.wrapSyncError=o;
2
+ //# sourceMappingURL=errorHandling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorHandling.js","names":["errorCodes","RouterError"],"sources":["../../../../../src/namespaces/NavigationNamespace/transition/errorHandling.ts"],"sourcesContent":["// packages/core/src/namespaces/NavigationNamespace/transition/errorHandling.ts\n\nimport { errorCodes } from \"../../../constants\";\nimport { RouterError } from \"../../../RouterError\";\n\nimport type { State } from \"../../../types\";\nimport type { NavigationDependencies } from \"../types\";\n\nexport function routeTransitionError(\n deps: NavigationDependencies,\n error: unknown,\n toState: State,\n fromState: State | undefined,\n): void {\n const routerError = error as RouterError;\n\n if (\n routerError.code === errorCodes.TRANSITION_CANCELLED ||\n routerError.code === errorCodes.ROUTE_NOT_FOUND\n ) {\n return;\n }\n\n deps.sendTransitionFail(toState, fromState, routerError);\n}\n\nexport function handleGuardError(\n error: unknown,\n errorCode: string,\n segment: string,\n): never {\n if (error instanceof DOMException && error.name === \"AbortError\") {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n // A guard can also signal a quiet cancel by throwing\n // RouterError(TRANSITION_CANCELLED) directly — the same intent as a thrown\n // AbortError. Preserve it as-is instead of letting rethrowAsRouterError\n // overwrite the code with CANNOT_ACTIVATE / CANNOT_DEACTIVATE: that code\n // drives the downstream suppression (routeTransitionError early-returns,\n // fire-and-forget stays silent), so re-coding would surface the intended\n // quiet cancel as a reported transition error (#933).\n if (\n error instanceof RouterError &&\n error.code === errorCodes.TRANSITION_CANCELLED\n ) {\n throw error;\n }\n\n rethrowAsRouterError(error, errorCode, segment);\n}\n\n/**\n * Error metadata structure for transition errors.\n * Contains information extracted from caught exceptions.\n */\nexport interface SyncErrorMetadata {\n [key: string]: unknown;\n message?: string;\n stack?: string | undefined;\n cause?: unknown;\n segment?: string;\n}\n\n/**\n * Re-throws a caught error as a RouterError with the given error code.\n * If the error is already a RouterError, sets the code directly.\n * Otherwise wraps it with wrapSyncError metadata.\n */\nexport function rethrowAsRouterError(\n error: unknown,\n errorCode: string,\n segment: string,\n): never {\n if (error instanceof RouterError) {\n error.setCode(errorCode);\n\n throw error;\n }\n\n throw new RouterError(errorCode, wrapSyncError(error, segment));\n}\n\n// Own-enumerable keys that must never be copied from a thrown object onto the\n// RouterError metadata:\n// - `code` / `segment` / `path` are reserved — the RouterError constructor\n// throws a TypeError on them (#39).\n// - `then` would make the RouterError itself thenable, so a consumer that\n// awaits it (or passes it through Promise.resolve / returns it from an async\n// function) would have it assimilated as a Promise instead of treated as a\n// plain rejection reason (#947).\nconst reservedRouterErrorProps = new Set([\"code\", \"segment\", \"path\", \"then\"]);\n\n/**\n * Wraps a synchronously thrown value into structured error metadata.\n *\n * This helper extracts useful debugging information from various thrown values:\n * - Error instances: extracts message, stack, and cause (ES2022+)\n * - Plain objects: spreads properties into metadata\n * - Primitives (string, number, etc.): returns minimal metadata\n *\n * @param thrown - The value caught in a try-catch block\n * @param segment - Route segment name (for lifecycle hooks)\n * @returns Structured error metadata for RouterError\n */\nexport function wrapSyncError(\n thrown: unknown,\n segment: string,\n): SyncErrorMetadata {\n const base: SyncErrorMetadata = { segment };\n\n // Handle Error instances - extract all useful properties\n if (thrown instanceof Error) {\n return {\n ...base,\n message: thrown.message,\n stack: thrown.stack,\n // Error.cause requires ES2022+ - safely access if present\n ...(\"cause\" in thrown &&\n thrown.cause !== undefined && { cause: thrown.cause }),\n };\n }\n\n // Handle plain objects - spread properties into metadata, filtering reserved props\n if (thrown && typeof thrown === \"object\") {\n const filtered: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(thrown)) {\n // Skip reserved / hazardous keys: #39 (constructor TypeError on code/\n // segment/path) and #947 (`then` would make the error thenable).\n if (!reservedRouterErrorProps.has(key)) {\n filtered[key] = value;\n }\n }\n\n return { ...base, ...filtered };\n }\n\n // Primitives (string, number, boolean, null, undefined, symbol, bigint)\n // Return base metadata only - the primitive value isn't useful as metadata\n return base;\n}\n"],"mappings":"8EAQA,SAAgB,EACd,EACA,EACA,EACA,EACM,CACN,IAAM,EAAc,EAGlB,EAAY,OAASA,EAAAA,WAAW,sBAChC,EAAY,OAASA,EAAAA,WAAW,iBAKlC,EAAK,mBAAmB,EAAS,EAAW,CAAW,CACzD,CAEA,SAAgB,EACd,EACA,EACA,EACO,CACP,GAAI,aAAiB,cAAgB,EAAM,OAAS,aAClD,MAAM,IAAIC,EAAAA,YAAYD,EAAAA,WAAW,oBAAoB,EAUvD,GACE,aAAiBC,EAAAA,aACjB,EAAM,OAASD,EAAAA,WAAW,qBAE1B,MAAM,EAGR,EAAqB,EAAO,EAAW,CAAO,CAChD,CAmBA,SAAgB,EACd,EACA,EACA,EACO,CAOP,MANI,aAAiBC,EAAAA,aACnB,EAAM,QAAQ,CAAS,EAEjB,GAGF,IAAIA,EAAAA,YAAY,EAAW,EAAc,EAAO,CAAO,CAAC,CAChE,CAUA,MAAM,EAA2B,IAAI,IAAI,CAAC,OAAQ,UAAW,OAAQ,MAAM,CAAC,EAc5E,SAAgB,EACd,EACA,EACmB,CACnB,IAAM,EAA0B,CAAE,SAAQ,EAG1C,GAAI,aAAkB,MACpB,MAAO,CACL,GAAG,EACH,QAAS,EAAO,QAChB,MAAO,EAAO,MAEd,GAAI,UAAW,GACb,EAAO,QAAU,IAAA,IAAa,CAAE,MAAO,EAAO,KAAM,CACxD,EAIF,GAAI,GAAU,OAAO,GAAW,SAAU,CACxC,IAAM,EAAoC,CAAC,EAE3C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAM,EAGzC,EAAyB,IAAI,CAAG,IACnC,EAAS,GAAO,GAIpB,MAAO,CAAE,GAAG,EAAM,GAAG,CAAS,CAChC,CAIA,OAAO,CACT"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../../constants.js"),t=require("../../../RouterError.js"),n=require("./errorHandling.js");async function r(e,r,i){let a;try{a=await e}catch(e){n.handleGuardError(e,r,i);return}if(!a)throw new t.RouterError(r,{segment:i})}async function i(i,a,o,s,c,l,u,d,f,p){await r(f,o,p);for(let f=d;f<a.length;f++){if(!u())throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED);let d=a[f],p=i.get(d);if(!p)continue;let m=!1;try{m=p(s,c,l)}catch(e){n.handleGuardError(e,o,d)}if(m instanceof Promise){await r(m,o,d);continue}if(!m)throw new t.RouterError(o,{segment:d})}}async function a(n,r,i,a,o,s,l,u,d){if(await n,!u())throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED);let f=d();if(f!==void 0&&(await f,!u()))throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED);if(a){let n=c(r,i,e.errorCodes.CANNOT_ACTIVATE,o,s,l,u);if(n!==void 0&&await n,!u())throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED)}}function o(n,r,i,o,l,u,d,f,p,m,h){if(l){let t=c(n,i,e.errorCodes.CANNOT_DEACTIVATE,d,f,p,m);if(t!==void 0)return a(t,r,o,u,d,f,p,m,h)}if(!m())throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED);let g=h();if(g!==void 0)return s(g,u?r:void 0,o,d,f,p,m);if(u)return c(r,o,e.errorCodes.CANNOT_ACTIVATE,d,f,p,m)}async function s(n,r,i,a,o,s,l){if(await n,!l())throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED);if(r!==void 0){let n=c(r,i,e.errorCodes.CANNOT_ACTIVATE,a,o,s,l);if(n!==void 0&&await n,!l())throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED)}}function c(r,a,o,s,c,l,u){for(let[d,f]of a.entries()){if(!u())throw new t.RouterError(e.errorCodes.TRANSITION_CANCELLED);let p=r.get(f);if(!p)continue;let m=!1;try{m=p(s,c,l)}catch(e){n.handleGuardError(e,o,f)}if(m instanceof Promise)return i(r,a,o,s,c,l,u,d+1,m,f);if(!m)throw new t.RouterError(o,{segment:f})}}exports.executeGuardPipeline=o;
2
+ //# sourceMappingURL=guardPhase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardPhase.js","names":["RouterError","errorCodes"],"sources":["../../../../../src/namespaces/NavigationNamespace/transition/guardPhase.ts"],"sourcesContent":["import { handleGuardError } from \"./errorHandling\";\nimport { errorCodes } from \"../../../constants\";\nimport { RouterError } from \"../../../RouterError\";\n\nimport type { GuardFn, State } from \"../../../types\";\n\nasync function resolveAsyncGuard(\n promise: Promise<boolean>,\n errorCode: string,\n segment: string,\n): Promise<void> {\n let result: boolean;\n\n try {\n result = await promise;\n } catch (error: unknown) {\n handleGuardError(error, errorCode, segment);\n\n return; // unreachable — handleGuardError returns never\n }\n\n if (!result) {\n throw new RouterError(errorCode, { segment });\n }\n}\n\nasync function resolveRemainingGuards( // NOSONAR -- params kept flat to avoid object allocation on hot path\n guards: Map<string, GuardFn>,\n segments: string[],\n errorCode: string,\n toState: State,\n fromState: State | undefined,\n signal: AbortSignal | undefined,\n isActive: () => boolean,\n startIndex: number,\n firstResult: Promise<boolean>,\n firstSegment: string,\n): Promise<void> {\n await resolveAsyncGuard(firstResult, errorCode, firstSegment);\n\n for (let i = startIndex; i < segments.length; i++) {\n // Stryker disable next-line BlockStatement: equivalent — emptying the body drops the async-tail cancellation throw, but supersession is independently enforced by the navigationId/isCurrentNav checks in NavigationNamespace, so the navigation still rejects with TRANSITION_CANCELLED (full suite green). The ConditionalExpression sibling stays live (its →true variant always-cancels and is killed by async-guard tests).\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n const segment = segments[i];\n const guardFn = guards.get(segment);\n\n if (!guardFn) {\n continue;\n }\n\n // Stryker disable next-line BooleanLiteral: equivalent — guardResult is unconditionally reassigned by guardFn() on the next line, or the catch calls handleGuardError() (returns never), so the init value is never read.\n let guardResult: boolean | Promise<boolean> = false;\n\n try {\n guardResult = guardFn(toState, fromState, signal);\n } catch (error: unknown) {\n handleGuardError(error, errorCode, segment);\n }\n\n if (guardResult instanceof Promise) {\n await resolveAsyncGuard(guardResult, errorCode, segment);\n continue;\n }\n\n if (!guardResult) {\n throw new RouterError(errorCode, { segment });\n }\n }\n}\n\nasync function finishAsyncPipeline( // NOSONAR\n deactivateCompletion: Promise<void>,\n activateGuards: Map<string, GuardFn>,\n toActivate: string[],\n shouldActivate: boolean,\n toState: State,\n fromState: State | undefined,\n signal: AbortSignal,\n isActive: () => boolean,\n emitLeaveApprove: () => Promise<void> | undefined,\n): Promise<void> {\n await deactivateCompletion;\n\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n const leaveResult = emitLeaveApprove();\n\n if (leaveResult !== undefined) {\n await leaveResult;\n\n // Stryker disable next-line BlockStatement: equivalent — defensive-redundancy: this post-leave cancellation re-check is already enforced upstream (navigationId / isCurrentNav supersession in NavigationNamespace), so emptying the throw is unobservable. Mirrors the disabled L42/L115/L228 cancel-checks.\n /* v8 ignore next 3 -- @preserve: V8 cannot track cancellation check through async leave continuation after Promise.allSettled */\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n }\n\n if (shouldActivate) {\n const pending = runGuards(\n activateGuards,\n toActivate,\n errorCodes.CANNOT_ACTIVATE,\n toState,\n fromState,\n signal,\n isActive,\n );\n\n if (pending !== undefined) {\n await pending;\n }\n\n // Stryker disable next-line BlockStatement: equivalent — same async-tail cancellation throw as L42; dropping it is covered by the outer navigationId guard (full suite green). CE sibling stays live (→true killed by async-guard tests).\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n }\n}\n\nexport function executeGuardPipeline( // NOSONAR\n deactivateGuards: Map<string, GuardFn>,\n activateGuards: Map<string, GuardFn>,\n toDeactivate: string[],\n toActivate: string[],\n shouldDeactivate: boolean,\n shouldActivate: boolean,\n toState: State,\n fromState: State | undefined,\n signal: AbortSignal,\n isActive: () => boolean,\n emitLeaveApprove: () => Promise<void> | undefined,\n): Promise<void> | undefined {\n if (shouldDeactivate) {\n const pending = runGuards(\n deactivateGuards,\n toDeactivate,\n errorCodes.CANNOT_DEACTIVATE,\n toState,\n fromState,\n signal,\n isActive,\n );\n\n if (pending !== undefined) {\n return finishAsyncPipeline(\n pending,\n activateGuards,\n toActivate,\n shouldActivate,\n toState,\n fromState,\n signal,\n isActive,\n emitLeaveApprove,\n );\n }\n }\n\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n const leaveResult = emitLeaveApprove();\n\n if (leaveResult !== undefined) {\n return finishAfterAsyncLeave(\n leaveResult,\n /* v8 ignore next -- @preserve: false-branch unreachable — navigateToNotFound bypasses guards pipeline */\n shouldActivate ? activateGuards : undefined,\n toActivate,\n toState,\n fromState,\n signal,\n isActive,\n );\n }\n\n if (shouldActivate) {\n return runGuards(\n activateGuards,\n toActivate,\n errorCodes.CANNOT_ACTIVATE,\n toState,\n fromState,\n signal,\n isActive,\n );\n }\n\n return undefined;\n}\n\nasync function finishAfterAsyncLeave(\n leaveCompletion: Promise<void>,\n activateGuards: Map<string, GuardFn> | undefined,\n toActivate: string[],\n toState: State,\n fromState: State | undefined,\n signal: AbortSignal,\n isActive: () => boolean,\n): Promise<void> {\n await leaveCompletion;\n\n // Stryker disable next-line BlockStatement: equivalent — defensive-redundancy: same post-leave cancellation re-check as guardPhase's other `!isActive()` guards; supersession is enforced upstream (navigationId / isCurrentNav), so emptying the throw is unobservable.\n /* v8 ignore next 3 -- @preserve: unreachable after #663 — signal abort\n mid-leave rejects via settleLeavePromises, so `await leaveCompletion`\n throws directly instead of completing with a stale isActive() */\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n /* v8 ignore next -- @preserve: false-branch unreachable — navigateToNotFound bypasses guards pipeline */\n if (activateGuards !== undefined) {\n const pending = runGuards(\n activateGuards,\n toActivate,\n errorCodes.CANNOT_ACTIVATE,\n toState,\n fromState,\n signal,\n isActive,\n );\n\n if (pending !== undefined) {\n await pending;\n }\n\n // Stryker disable next-line BlockStatement: equivalent — same async-tail cancellation throw as L42; dropping it is covered by the outer navigationId guard (full suite green). CE sibling stays live (→true killed by async-guard tests).\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n }\n}\n\nfunction runGuards(\n guards: Map<string, GuardFn>,\n segments: string[],\n errorCode: string,\n toState: State,\n fromState: State | undefined,\n signal: AbortSignal | undefined,\n isActive: () => boolean,\n): Promise<void> | undefined {\n for (const [i, segment] of segments.entries()) {\n if (!isActive()) {\n throw new RouterError(errorCodes.TRANSITION_CANCELLED);\n }\n\n const guardFn = guards.get(segment);\n\n if (!guardFn) {\n continue;\n }\n\n // Stryker disable next-line BooleanLiteral: equivalent — guardResult is unconditionally reassigned by guardFn() on the next line, or the catch calls handleGuardError() (returns never), so the init value is never read.\n let guardResult: boolean | Promise<boolean> = false;\n\n try {\n guardResult = guardFn(toState, fromState, signal);\n } catch (error: unknown) {\n handleGuardError(error, errorCode, segment);\n }\n\n if (guardResult instanceof Promise) {\n return resolveRemainingGuards(\n guards,\n segments,\n errorCode,\n toState,\n fromState,\n signal,\n isActive,\n i + 1,\n guardResult,\n segment,\n );\n }\n\n if (!guardResult) {\n throw new RouterError(errorCode, { segment });\n }\n }\n\n return undefined;\n}\n"],"mappings":"8GAMA,eAAe,EACb,EACA,EACA,EACe,CACf,IAAI,EAEJ,GAAI,CACF,EAAS,MAAM,CACjB,OAAS,EAAgB,CACvB,EAAA,iBAAiB,EAAO,EAAW,CAAO,EAE1C,MACF,CAEA,GAAI,CAAC,EACH,MAAM,IAAIA,EAAAA,YAAY,EAAW,CAAE,SAAQ,CAAC,CAEhD,CAEA,eAAe,EACb,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACe,CACf,MAAM,EAAkB,EAAa,EAAW,CAAY,EAE5D,IAAK,IAAI,EAAI,EAAY,EAAI,EAAS,OAAQ,IAAK,CAEjD,GAAI,CAAC,EAAS,EACZ,MAAM,IAAIA,EAAAA,YAAYC,EAAAA,WAAW,oBAAoB,EAGvD,IAAM,EAAU,EAAS,GACnB,EAAU,EAAO,IAAI,CAAO,EAElC,GAAI,CAAC,EACH,SAIF,IAAI,EAA0C,GAE9C,GAAI,CACF,EAAc,EAAQ,EAAS,EAAW,CAAM,CAClD,OAAS,EAAgB,CACvB,EAAA,iBAAiB,EAAO,EAAW,CAAO,CAC5C,CAEA,GAAI,aAAuB,QAAS,CAClC,MAAM,EAAkB,EAAa,EAAW,CAAO,EACvD,QACF,CAEA,GA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AAYC,EAAAA,WAAW,oBAAoB,EAIvD,GAAI,IAAmB,IAAA,GAAW,CAChC,IAAM,EAAU,EACd,EACA,EACAA,EAAAA,WAAW,gBACX,EACA,EACA,EACA,CACF,EAOA,GALI,IAAY,IAAA,IACd,MAAM,EAIJ,CAAC,EAAS,EACZ,MAAM,IAAID,EAAAA,YAAYC,EAAAA,WAAW,oBAAoB,CAEzD,CACF,CAEA,SAAS,EACP,EACA,EACA,EACA,EACA,EACA,EACA,EAC2B,CAC3B,IAAK,GAAM,CAAC,EAAG,KAAY,EAAS,QAAQ,EAAG,CAC7C,GAAI,CAAC,EAAS,EACZ,MAAM,IAAID,EAAAA,YAAYC,EAAAA,WAAW,oBAAoB,EAGvD,IAAM,EAAU,EAAO,IAAI,CAAO,EAElC,GAAI,CAAC,EACH,SAIF,IAAI,EAA0C,GAE9C,GAAI,CACF,EAAc,EAAQ,EAAS,EAAW,CAAM,CAClD,OAAS,EAAgB,CACvB,EAAA,iBAAiB,EAAO,EAAW,CAAO,CAC5C,CAEA,GAAI,aAAuB,QACzB,OAAO,EACL,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EAAI,EACJ,EACA,CACF,EAGF,GAAI,CAAC,EACH,MAAM,IAAID,EAAAA,YAAY,EAAW,CAAE,SAAQ,CAAC,CAEhD,CAGF"}
@@ -0,0 +1,2 @@
1
+ const e=require("./constants.js"),t=require("./helpers.js"),n=require("./validators.js");var r=class{#e;constructor(n={}){this.#e=t.deepFreeze({...e.defaultOptions,...n})}static validateOptionsIsObject(e){n.validateOptionsIsObject(e)}get(){return this.#e}};exports.OptionsNamespace=r;
2
+ //# sourceMappingURL=OptionsNamespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsNamespace.js","names":["#options","deepFreeze","defaultOptions"],"sources":["../../../../src/namespaces/OptionsNamespace/OptionsNamespace.ts"],"sourcesContent":["// packages/core/src/namespaces/OptionsNamespace/OptionsNamespace.ts\n\nimport { defaultOptions } from \"./constants\";\nimport { deepFreeze } from \"./helpers\";\nimport { validateOptionsIsObject } from \"./validators\";\n\nimport type { Options } from \"../../types\";\n\nexport class OptionsNamespace {\n readonly #options: Readonly<Options>;\n\n constructor(initialOptions: Partial<Options> = {}) {\n this.#options = deepFreeze({\n ...defaultOptions,\n ...initialOptions,\n });\n }\n\n static validateOptionsIsObject(\n options: unknown,\n ): asserts options is Record<string, unknown> {\n validateOptionsIsObject(options);\n }\n\n get(): Readonly<Options> {\n return this.#options;\n }\n}\n"],"mappings":"yFAQA,IAAa,EAAb,KAA8B,CAC5B,GAEA,YAAY,EAAmC,CAAC,EAAG,CACjD,KAAKA,GAAWC,EAAAA,WAAW,CACzB,GAAGC,EAAAA,eACH,GAAG,CACL,CAAC,CACH,CAEA,OAAO,wBACL,EAC4C,CAC5C,EAAA,wBAAwB,CAAO,CACjC,CAEA,KAAyB,CACvB,OAAO,KAAKF,EACd,CACF"}
@@ -0,0 +1,2 @@
1
+ const e={defaultRoute:``,defaultParams:{},trailingSlash:`preserve`,caseSensitive:!0,queryParamsMode:`loose`,queryParams:require("../../engine/search-params/encode.js").DEFAULT_QUERY_PARAMS,urlParamsEncoding:`default`,allowNotFound:!0,rewritePathOnMatch:!0};exports.defaultOptions=e;
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["DEFAULT_QUERY_PARAMS"],"sources":["../../../../src/namespaces/OptionsNamespace/constants.ts"],"sourcesContent":["// packages/core/src/namespaces/OptionsNamespace/constants.ts\n\nimport { DEFAULT_QUERY_PARAMS } from \"../../engine\";\n\nimport type { Options } from \"../../types\";\n\n/**\n * Default options for the router.\n */\nexport const defaultOptions: Options = {\n defaultRoute: \"\",\n defaultParams: {},\n trailingSlash: \"preserve\",\n caseSensitive: true,\n queryParamsMode: \"loose\",\n queryParams: DEFAULT_QUERY_PARAMS,\n urlParamsEncoding: \"default\",\n allowNotFound: true,\n rewritePathOnMatch: true,\n} satisfies Options;\n"],"mappings":"AASA,MAAa,EAA0B,CACrC,aAAc,GACd,cAAe,CAAC,EAChB,cAAe,WACf,cAAe,GACf,gBAAiB,QACjB,0DAAaA,CAAAA,CAAAA,qBACb,kBAAmB,UACnB,cAAe,GACf,mBAAoB,EACtB"}
@@ -0,0 +1,2 @@
1
+ function e(t){Object.freeze(t);for(let n of Object.values(t))n&&typeof n==`object`&&n.constructor===Object&&e(n);return t}function t(e,t){return typeof e==`function`?e(t):e}exports.deepFreeze=e,exports.resolveOption=t;
2
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","names":[],"sources":["../../../../src/namespaces/OptionsNamespace/helpers.ts"],"sourcesContent":["// packages/core/src/namespaces/OptionsNamespace/helpers.ts\n\nimport type { Options, Params } from \"../../types\";\n\n/**\n * Recursively freezes an object and all nested objects.\n * Only freezes plain objects, not primitives or special objects.\n */\nexport function deepFreeze<T extends object>(obj: T): Readonly<T> {\n Object.freeze(obj);\n\n for (const value of Object.values(obj as Record<string, unknown>)) {\n if (value && typeof value === \"object\" && value.constructor === Object) {\n deepFreeze(value);\n }\n }\n\n return obj;\n}\n\n/**\n * Resolves an option value that can be static or a callback.\n * If the value is a function, calls it with getDependency and returns the result.\n * Otherwise, returns the value as-is.\n */\nexport function resolveOption(\n value: Options[\"defaultRoute\"],\n getDependency: (name: string) => unknown,\n): string;\n\nexport function resolveOption(\n value: Options[\"defaultParams\"],\n getDependency: (name: string) => unknown,\n): Params;\n\nexport function resolveOption(\n value: Options[\"defaultRoute\"] | Options[\"defaultParams\"],\n getDependency: (name: string) => unknown,\n): string | Params {\n if (typeof value === \"function\") {\n // Runtime getDependency is (name: string) => unknown, but DefaultRouteCallback<object>\n // expects <K extends keyof object>(name: K) => object[K] where keyof object = never.\n // Cast needed to bridge generic constraint mismatch.\n return value(getDependency as never);\n }\n\n return value;\n}\n"],"mappings":"AAQA,SAAgB,EAA6B,EAAqB,CAChE,OAAO,OAAO,CAAG,EAEjB,IAAK,IAAM,KAAS,OAAO,OAAO,CAA8B,EAC1D,GAAS,OAAO,GAAU,UAAY,EAAM,cAAgB,QAC9D,EAAW,CAAK,EAIpB,OAAO,CACT,CAiBA,SAAgB,EACd,EACA,EACiB,CAQjB,OAPI,OAAO,GAAU,WAIZ,EAAM,CAAsB,EAG9B,CACT"}
@@ -0,0 +1,2 @@
1
+ function e(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`[router.constructor] options must be a plain object`)}exports.validateOptionsIsObject=e;
2
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","names":[],"sources":["../../../../src/namespaces/OptionsNamespace/validators.ts"],"sourcesContent":["// packages/core/src/namespaces/OptionsNamespace/validators.ts\n\n/**\n * Minimal crash guard for options.\n * Full DX validation moved to @real-router/validation-plugin (retrospective pattern).\n */\nexport function validateOptionsIsObject(\n options: unknown,\n): asserts options is Record<string, unknown> {\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\n throw new TypeError(\"[router.constructor] options must be a plain object\");\n }\n}\n"],"mappings":"AAMA,SAAgB,EACd,EAC4C,CAC5C,GAAI,CAAC,GAAW,OAAO,GAAY,UAAY,MAAM,QAAQ,CAAO,EAClE,MAAU,UAAU,qDAAqD,CAE7E"}
@@ -0,0 +1,2 @@
1
+ const e=require("./constants.js"),t=require("./validators.js");var n=class n{#e=new Set;#t=new Set;#n;static validatePlugin(e){t.validatePlugin(e)}setDependencies(e){this.#n=e}count(){return this.#e.size}use(...t){if(this.#n.getValidator()?.plugins.validateCountThresholds(this.#e.size+t.length),t.length===1){let n=t[0],r=this.#i(n);this.#e.add(n);let i=!1,a=()=>{if(!i){i=!0,this.#e.delete(n),this.#t.delete(a);try{r()}catch(t){this.#n.logger.error(e.LOGGER_CONTEXT,`Error during cleanup:`,t)}}};return this.#t.add(a),a}let n=this.#r(t),r=[];try{for(let e of n){let t=this.#i(e);r.push({factory:e,cleanup:t})}}catch(t){for(let{cleanup:t}of r)try{t()}catch(t){this.#n.logger.error(e.LOGGER_CONTEXT,`Cleanup error:`,t)}throw t}for(let{factory:e}of r)this.#e.add(e);let i=!1,a=()=>{if(!i){i=!0,this.#t.delete(a);for(let{factory:e}of r)this.#e.delete(e);for(let{cleanup:t}of r)try{t()}catch(t){this.#n.logger.error(e.LOGGER_CONTEXT,`Error during cleanup:`,t)}}};return this.#t.add(a),a}getAll(){return[...this.#e]}has(e){return this.#e.has(e)}disposeAll(){for(let e of this.#t)e();this.#e.clear(),this.#t.clear()}#r(e){let t=new Set;for(let n of e)t.has(n)?this.#n.getValidator()?.plugins.warnBatchDuplicates(e):t.add(n);return t}#i(t){let r=this.#n.compileFactory(t);n.validatePlugin(r),this.#n.getValidator()?.plugins.validatePluginKeys(r),Object.freeze(r);let i=[];for(let t of e.EVENT_METHOD_NAMES)t in r&&(typeof r[t]==`function`?(i.push(this.#n.addEventListener(e.EVENTS_MAP[t],r[t])),t===`onStart`&&this.#n.canNavigate()&&this.#n.getValidator()?.plugins.warnPluginAfterStart(t)):this.#n.getValidator()?.plugins.warnPluginMethodType(t));return()=>{for(let e of i)e();typeof r.teardown==`function`&&r.teardown()}}};exports.PluginsNamespace=n;
2
+ //# sourceMappingURL=PluginsNamespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginsNamespace.js","names":["#plugins","#unsubscribes","#deps","#startPlugin","LOGGER_CONTEXT","#deduplicateBatch","EVENT_METHOD_NAMES","EVENTS_MAP"],"sources":["../../../../src/namespaces/PluginsNamespace/PluginsNamespace.ts"],"sourcesContent":["// packages/core/src/namespaces/PluginsNamespace/PluginsNamespace.ts\n\nimport { EVENTS_MAP, EVENT_METHOD_NAMES, LOGGER_CONTEXT } from \"./constants\";\nimport { validatePlugin } from \"./validators\";\n\nimport type { PluginsDependencies } from \"./types\";\nimport type {\n DefaultDependencies,\n Plugin,\n Unsubscribe,\n PluginFactory,\n} from \"../../types\";\n\n/**\n * Independent namespace for managing plugins.\n *\n * Static methods handle validation (called by facade).\n * Instance methods handle storage and business logic.\n */\nexport class PluginsNamespace<\n Dependencies extends DefaultDependencies = DefaultDependencies,\n> {\n readonly #plugins = new Set<PluginFactory<Dependencies>>();\n readonly #unsubscribes = new Set<Unsubscribe>();\n\n #deps!: PluginsDependencies<Dependencies>;\n\n // =========================================================================\n // Static validation methods (called by facade before instance methods)\n // Proxy to functions in validators.ts for separation of concerns\n // =========================================================================\n\n static validatePlugin(plugin: Plugin): void {\n validatePlugin(plugin);\n }\n\n // =========================================================================\n // Dependency injection\n // =========================================================================\n\n setDependencies(deps: PluginsDependencies<Dependencies>): void {\n this.#deps = deps;\n }\n\n // =========================================================================\n // Instance methods (trust input - already validated by facade)\n // =========================================================================\n\n /**\n * Returns the number of registered plugins.\n * Used by facade for limit validation.\n */\n /* v8 ignore next 3 -- @preserve: only called via validator interface (ctx.validator?.plugins.validatePluginLimit), not reachable without validation plugin */\n count(): number {\n return this.#plugins.size;\n }\n\n /**\n * Registers one or more plugin factories.\n * Returns unsubscribe function to remove all added plugins.\n * Input already validated by facade (limit, duplicates).\n *\n * @param factories - Already validated by facade\n */\n use(...factories: PluginFactory<Dependencies>[]): Unsubscribe {\n // Emit warnings for count thresholds (not validation, just warnings)\n this.#deps\n .getValidator()\n ?.plugins.validateCountThresholds(this.#plugins.size + factories.length);\n\n // Fast path for single plugin (common case)\n if (factories.length === 1) {\n const factory = factories[0];\n const cleanup = this.#startPlugin(factory);\n\n this.#plugins.add(factory);\n\n let unsubscribed = false;\n\n const unsubscribe: Unsubscribe = () => {\n if (unsubscribed) {\n return;\n }\n\n unsubscribed = true;\n this.#plugins.delete(factory);\n this.#unsubscribes.delete(unsubscribe);\n try {\n cleanup();\n } catch (error) {\n this.#deps.logger.error(\n LOGGER_CONTEXT,\n \"Error during cleanup:\",\n error,\n );\n }\n };\n\n this.#unsubscribes.add(unsubscribe);\n\n return unsubscribe;\n }\n\n // Deduplicate batch with warning (validation already done by facade)\n const seenInBatch = this.#deduplicateBatch(factories);\n\n // Track successfully initialized plugins for cleanup\n const initializedPlugins: {\n factory: PluginFactory<Dependencies>;\n cleanup: Unsubscribe;\n }[] = [];\n\n // Initialize deduplicated plugins sequentially\n try {\n for (const plugin of seenInBatch) {\n const cleanup = this.#startPlugin(plugin);\n\n initializedPlugins.push({ factory: plugin, cleanup });\n }\n } catch (error) {\n // Rollback on failure - cleanup all initialized plugins\n for (const { cleanup } of initializedPlugins) {\n try {\n cleanup();\n } catch (cleanupError) {\n this.#deps.logger.error(\n LOGGER_CONTEXT,\n \"Cleanup error:\",\n cleanupError,\n );\n }\n }\n\n throw error;\n }\n\n // Commit phase - add to registry\n for (const { factory } of initializedPlugins) {\n this.#plugins.add(factory);\n }\n\n // Return unsubscribe function\n let unsubscribed = false;\n\n const unsubscribe: Unsubscribe = () => {\n if (unsubscribed) {\n return;\n }\n\n unsubscribed = true;\n this.#unsubscribes.delete(unsubscribe);\n\n for (const { factory } of initializedPlugins) {\n this.#plugins.delete(factory);\n }\n\n for (const { cleanup } of initializedPlugins) {\n try {\n cleanup();\n } catch (error) {\n this.#deps.logger.error(\n LOGGER_CONTEXT,\n \"Error during cleanup:\",\n error,\n );\n }\n }\n };\n\n this.#unsubscribes.add(unsubscribe);\n\n return unsubscribe;\n }\n\n /**\n * Returns registered plugin factories.\n */\n getAll(): PluginFactory<Dependencies>[] {\n return [...this.#plugins];\n }\n\n /**\n * Checks if a plugin factory is registered.\n * Used internally by validation to avoid array allocation.\n */\n /* v8 ignore next 3 -- @preserve: only called via validator interface, not reachable without validation plugin */\n has(factory: PluginFactory<Dependencies>): boolean {\n return this.#plugins.has(factory);\n }\n\n /**\n * Disposes all registered plugins by running their teardown callbacks\n * and removing event listener subscriptions.\n * Active disposal is required because plugins have an active lifecycle\n * (event subscriptions, teardown hooks).\n * Named \"dispose\" (not \"clear\") because there is active cleanup to perform.\n */\n disposeAll(): void {\n for (const unsubscribe of this.#unsubscribes) {\n unsubscribe();\n }\n\n this.#plugins.clear();\n this.#unsubscribes.clear();\n }\n\n // =========================================================================\n // Private methods\n // =========================================================================\n\n /**\n * Deduplicates batch with warning for duplicates within batch.\n * Validation (existing duplicates) is done by facade.\n */\n #deduplicateBatch(\n plugins: PluginFactory<Dependencies>[],\n ): Set<PluginFactory<Dependencies>> {\n const seenInBatch = new Set<PluginFactory<Dependencies>>();\n\n for (const plugin of plugins) {\n if (seenInBatch.has(plugin)) {\n this.#deps.getValidator()?.plugins.warnBatchDuplicates(plugins);\n } else {\n seenInBatch.add(plugin);\n }\n }\n\n return seenInBatch;\n }\n\n #startPlugin(pluginFactory: PluginFactory<Dependencies>): Unsubscribe {\n const appliedPlugin = this.#deps.compileFactory(pluginFactory);\n\n PluginsNamespace.validatePlugin(appliedPlugin);\n this.#deps.getValidator()?.plugins.validatePluginKeys(appliedPlugin);\n\n Object.freeze(appliedPlugin);\n\n // Collect all unsubscribe functions\n const removeEventListeners: Unsubscribe[] = [];\n\n // Subscribe plugin methods to corresponding router events\n for (const methodName of EVENT_METHOD_NAMES) {\n if (methodName in appliedPlugin) {\n if (typeof appliedPlugin[methodName] === \"function\") {\n removeEventListeners.push(\n this.#deps.addEventListener(\n EVENTS_MAP[methodName],\n appliedPlugin[methodName],\n ),\n );\n\n if (methodName === \"onStart\" && this.#deps.canNavigate()) {\n this.#deps.getValidator()?.plugins.warnPluginAfterStart(methodName);\n }\n } else {\n this.#deps.getValidator()?.plugins.warnPluginMethodType(methodName);\n }\n }\n }\n\n // Return composite cleanup function\n return () => {\n for (const removeListener of removeEventListeners) {\n removeListener();\n }\n\n if (typeof appliedPlugin.teardown === \"function\") {\n appliedPlugin.teardown();\n }\n };\n }\n}\n"],"mappings":"+DAmBA,IAAa,EAAb,MAAa,CAEX,CACA,GAAoB,IAAI,IACxB,GAAyB,IAAI,IAE7B,GAOA,OAAO,eAAe,EAAsB,CAC1C,EAAA,eAAe,CAAM,CACvB,CAMA,gBAAgB,EAA+C,CAC7D,KAAKE,GAAQ,CACf,CAWA,OAAgB,CACd,OAAO,KAAKF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UCCESS]:e.events.TRANSITION_SUCCESS,[e.plugins.TRANSITION_START]:e.events.TRANSITION_START,[e.plugins.TRANSITION_LEAVE_APPROVE]:e.events.TRANSITION_LEAVE_APPROVE,[e.plugins.TRANSITION_ERROR]:e.events.TRANSITION_ERROR,[e.plugins.TRANSITION_CANCEL]:e.events.TRANSITION_CANCEL},n=Object.keys(t);exports.EVENTS_MAP=t,exports.EVENT_METHOD_NAMES=n,exports.LOGGER_CONTEXT=`router.usePlugin`;
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["PLUGINS_CONST","EVENTS_CONST"],"sources":["../../../../src/namespaces/PluginsNamespace/constants.ts"],"sourcesContent":["// packages/core/src/namespaces/PluginsNamespace/constants.ts\n\nimport {\n events as EVENTS_CONST,\n plugins as PLUGINS_CONST,\n} from \"../../constants\";\n\nimport type { EventName } from \"../../types\";\n\n/**\n * Maps plugin method names to router event names.\n */\nexport const EVENTS_MAP = {\n [PLUGINS_CONST.ROUTER_START]: EVENTS_CONST.ROUTER_START,\n [PLUGINS_CONST.ROUTER_STOP]: EVENTS_CONST.ROUTER_STOP,\n [PLUGINS_CONST.TRANSITION_SUCCESS]: EVENTS_CONST.TRANSITION_SUCCESS,\n [PLUGINS_CONST.TRANSITION_START]: EVENTS_CONST.TRANSITION_START,\n [PLUGINS_CONST.TRANSITION_LEAVE_APPROVE]:\n EVENTS_CONST.TRANSITION_LEAVE_APPROVE,\n [PLUGINS_CONST.TRANSITION_ERROR]: EVENTS_CONST.TRANSITION_ERROR,\n [PLUGINS_CONST.TRANSITION_CANCEL]: EVENTS_CONST.TRANSITION_CANCEL,\n} as const satisfies Record<\n (typeof PLUGINS_CONST)[keyof typeof PLUGINS_CONST],\n EventName\n>;\n\n/**\n * Plugin method names that correspond to router events.\n */\nexport const EVENT_METHOD_NAMES = Object.keys(\n EVENTS_MAP,\n) as (keyof typeof EVENTS_MAP)[];\n\nexport const LOGGER_CONTEXT = \"router.usePlugin\";\n"],"mappings":"sCAYa,EAAa,EACvBA,EAAAA,QAAc,cAAeC,EAAAA,OAAa,cAC1CD,EAAAA,QAAc,aAAcC,EAAAA,OAAa,aACzCD,EAAAA,QAAc,oBAAqBC,EAAAA,OAAa,oBAChDD,EAAAA,QAAc,kBAAmBC,EAAAA,OAAa,kBAC9CD,EAAAA,QAAc,0BACbC,EAAAA,OAAa,0BACdD,EAAAA,QAAc,kBAAmBC,EAAAA,OAAa,kBAC9CD,EAAAA,QAAc,mBAAoBC,EAAAA,OAAa,iBAClD,EAQa,EAAqB,OAAO,KACvC,CACF"}
@@ -0,0 +1,2 @@
1
+ function e(e){if(!(e&&typeof e==`object`)||Array.isArray(e))throw TypeError(`[router.usePlugin] Plugin factory must return an object, got ${typeof e}`);if(typeof e.then==`function`)throw TypeError(`[router.usePlugin] Async plugin factories are not supported. Factory returned a Promise instead of a plugin object.`)}exports.validatePlugin=e;
2
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","names":[],"sources":["../../../../src/namespaces/PluginsNamespace/validators.ts"],"sourcesContent":["// packages/core/src/namespaces/PluginsNamespace/validators.ts\n\n/**\n * Static validation functions for PluginsNamespace.\n * Called by Router facade before instance methods.\n */\n\nimport type { Plugin } from \"../../types\";\n\n/**\n * Validates that a plugin factory returned a valid plugin object.\n */\nexport function validatePlugin(plugin: Plugin): void {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!(plugin && typeof plugin === \"object\") || Array.isArray(plugin)) {\n throw new TypeError(\n `[router.usePlugin] Plugin factory must return an object, got ${typeof plugin}`,\n );\n }\n\n // Detect async factory (returns Promise)\n if (typeof (plugin as unknown as { then?: unknown }).then === \"function\") {\n throw new TypeError(\n `[router.usePlugin] Async plugin factories are not supported. ` +\n `Factory returned a Promise instead of a plugin object.`,\n );\n }\n}\n"],"mappings":"AAYA,SAAgB,EAAe,EAAsB,CAEnD,GAAI,EAAE,GAAU,OAAO,GAAW,WAAa,MAAM,QAAQ,CAAM,EACjE,MAAU,UACR,gEAAgE,OAAO,GACzE,EAIF,GAAI,OAAQ,EAAyC,MAAS,WAC5D,MAAU,UACR,qHAEF,CAEJ"}
@@ -0,0 +1,174 @@
1
+ import { State } from "../../types/base.js";
2
+ import { DefaultDependencies, GuardFn, GuardFnFactory } from "../../types/router.js";
3
+ import { RouteLifecycleDependencies } from "./types.js";
4
+ //#region src/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.d.ts
5
+ /**
6
+ * Origin lane for a guard clear. Every `clearCanActivate` / `clearCanDeactivate`
7
+ * caller names its lane — there is no origin-blind default — so a new call site
8
+ * cannot silently wipe both the route-config and the external guard (#1171):
9
+ *
10
+ * - `"definition"` — clear only the route-config guard (`update(name, {…: null})`, #952).
11
+ * - `"external"` — clear only the external, component-managed guard
12
+ * (`removeXGuard()` and post-leave auto-cleanup — the inverse of `addXGuard()`).
13
+ * - `"both"` — clear both (route removal / router teardown; the route is gone).
14
+ */
15
+ type GuardClearScope = "definition" | "external" | "both";
16
+ /**
17
+ * Source of truth for `canActivate` / `canDeactivate` guards.
18
+ *
19
+ * Storage is split by origin into four factory Maps (definition vs external,
20
+ * each ×activate/deactivate); a single compiled-function Map per kind backs
21
+ * navigation ("external wins" — when a route holds both a definition and an
22
+ * external guard, the compiled guard is the external one, regardless of
23
+ * registration order; #1174). `getFunctions()` returns a cached
24
+ * `[deactivate, activate]` tuple for the hot path (stable reference, no
25
+ * per-navigate allocation).
26
+ *
27
+ * All input validation is handled upstream by `getLifecycleApi` and
28
+ * `getRoutesApi` — this class has no static methods.
29
+ *
30
+ * **Ordering convention.** Every paired surface lists **deactivate before
31
+ * activate**: `getFunctions()` / `getFactories()` return `[deactivate,
32
+ * activate]`, `getFactoriesByOrigin()` returns that tuple per origin, and
33
+ * `canNavigateTo(toDeactivate, toActivate, …)` takes deactivate first. Keep
34
+ * any new paired surface consistent with this order.
35
+ */
36
+ declare class RouteLifecycleNamespace<Dependencies extends DefaultDependencies = DefaultDependencies> {
37
+ #private;
38
+ setDependencies(deps: RouteLifecycleDependencies<Dependencies>): void;
39
+ getHandlerCount(type: "activate" | "deactivate"): number;
40
+ /**
41
+ * Pre-flights the #961 handler-limit `RangeError` into the route-CRUD PREPARE
42
+ * phase (#1046). `#registerHandler`'s per-slot limit check throws AFTER the
43
+ * tree/config swap, so `add`/`replace`/`update` tore post-commit when the
44
+ * validator was installed and the per-type count was at `maxLifecycleHandlers`.
45
+ * Running the same check here — before any store mutation — restores atomicity
46
+ * (#951/#956/#698): a batch that would exceed the limit aborts before a single
47
+ * write.
48
+ *
49
+ * Only NEW slots count (an overwrite leaves the union count unchanged, mirroring
50
+ * `#registerHandler`). For `replace` (`clearsDefinition = true`) the definition
51
+ * guards are about to be cleared, so the projection runs against the surviving
52
+ * EXTERNAL guards only — exactly the post-clear state the install loop sees.
53
+ * Plugin-gated: a no-op without the validator (the limit is opt-in).
54
+ *
55
+ * @param activateNames - route names a `canActivate` would be registered for
56
+ * @param deactivateNames - route names a `canDeactivate` would be registered for
57
+ * @param clearsDefinition - true for `replace` (definition guards cleared first)
58
+ */
59
+ preflightHandlerLimit(activateNames: Iterable<string>, deactivateNames: Iterable<string>, clearsDefinition: boolean): void;
60
+ /**
61
+ * Adds a canActivate guard for a route.
62
+ *
63
+ * @param name - Route name (input-validated by facade)
64
+ * @param handler - Guard function or boolean (input-validated by facade)
65
+ * @param isFromDefinition - True when guard comes from route definition
66
+ * (lands in the definition Map; subject to `clearDefinitionGuards()`).
67
+ * False (default) when added via `getLifecycleApi().addActivateGuard(...)`
68
+ * (lands in the external Map; survives `replace()`).
69
+ *
70
+ * External wins at runtime (#1174): when a route holds both a definition and
71
+ * an external guard, the compiled function is the external one, regardless of
72
+ * registration order. Within one origin the most recent add overwrites. Origin
73
+ * determines which Map the factory is filed under (relevant for
74
+ * `clearDefinitionGuards()` and `cloneRouter` re-registration).
75
+ */
76
+ addCanActivate(name: string, handler: GuardFnFactory<Dependencies> | boolean, isFromDefinition?: boolean, precompiledFn?: GuardFn): void;
77
+ /**
78
+ * Adds a canDeactivate guard for a route.
79
+ *
80
+ * Symmetric counterpart to {@link addCanActivate}.
81
+ */
82
+ addCanDeactivate(name: string, handler: GuardFnFactory<Dependencies> | boolean, isFromDefinition?: boolean, precompiledFn?: GuardFn): void;
83
+ /**
84
+ * Removes a canActivate guard for a route. `scope` names the origin lane
85
+ * (see {@link GuardClearScope}) — there is no origin-blind default, so every
86
+ * caller commits to a lane and a new call site cannot silently clear both.
87
+ * Delegates to {@link #clearGuard} (mirrors the add side's `#registerHandler`).
88
+ *
89
+ * @param name - Route name (already validated by facade)
90
+ * @param scope - Which origin(s) to clear: `"definition"` / `"external"` / `"both"`
91
+ */
92
+ clearCanActivate(name: string, scope: GuardClearScope): void;
93
+ /**
94
+ * Removes a canDeactivate guard for a route. Symmetric counterpart to
95
+ * {@link clearCanActivate}.
96
+ *
97
+ * The `"external"` lane is what makes a route-config `canDeactivate` durable:
98
+ * post-leave auto-cleanup (`completeTransition`) and `removeDeactivateGuard()`
99
+ * unregister only the external, component-managed guard (router5 mount/unmount
100
+ * heritage), while a definition guard survives for re-entry — symmetric with
101
+ * definition `canActivate`, which lives as long as the route is in the tree
102
+ * (#1171). Clearing both by default made a config guard one-shot: the first
103
+ * permitted leave erased it, so re-entry was unguarded, `getRoutesApi().get()`
104
+ * lost the field, and a clone taken after the leave never received it
105
+ * (clone invariant #6).
106
+ *
107
+ * @param name - Route name (already validated by facade)
108
+ * @param scope - Which origin(s) to clear: `"definition"` / `"external"` / `"both"`
109
+ */
110
+ clearCanDeactivate(name: string, scope: GuardClearScope): void;
111
+ /**
112
+ * Clears all lifecycle handlers (canActivate and canDeactivate).
113
+ * Used by clearRoutes to reset all lifecycle state.
114
+ */
115
+ clearAll(): void;
116
+ /**
117
+ * Clears only lifecycle handlers that were registered from route definitions.
118
+ * Used by HMR `replace()` to remove definition-sourced guards without
119
+ * touching externally-added guards.
120
+ *
121
+ * For a slot where BOTH a definition and an external guard exist, the external
122
+ * factory survives — and the compiled function is RECOMPILED from it (#1192).
123
+ * Under external-wins (#1174) the compiled slot is already the external guard,
124
+ * so this recompile is idempotent — it re-derives the surviving external factory
125
+ * through the same choke point that keeps clearing correct (and stays robust if
126
+ * the compiled slot were ever out of sync). For a definition-only slot, the
127
+ * compiled function is dropped.
128
+ */
129
+ clearDefinitionGuards(): void;
130
+ /**
131
+ * Returns lifecycle factories as a flat `[deactivate, activate]` tuple of
132
+ * `Record<name, factory>` — the effective view where external wins over
133
+ * definition for the same slot. Used by `getRoutesApi` to enrich route
134
+ * objects with their current canActivate / canDeactivate factories and by
135
+ * the route-removal cleanup path.
136
+ *
137
+ * For cloneRouter (which needs to preserve origin on re-registration), use
138
+ * {@link getFactoriesByOrigin} instead.
139
+ */
140
+ getFactories(): [Record<string, GuardFnFactory<Dependencies>>, Record<string, GuardFnFactory<Dependencies>>];
141
+ /**
142
+ * Returns factories tagged by origin — definition and external as separate
143
+ * `[deactivate, activate]` tuples. Used by `cloneRouter` to re-register
144
+ * guards on the clone with their original origin flag preserved.
145
+ */
146
+ getFactoriesByOrigin(): {
147
+ definition: [Record<string, GuardFnFactory<Dependencies>>, Record<string, GuardFnFactory<Dependencies>>];
148
+ external: [Record<string, GuardFnFactory<Dependencies>>, Record<string, GuardFnFactory<Dependencies>>];
149
+ };
150
+ /**
151
+ * Returns compiled lifecycle functions for transition execution.
152
+ *
153
+ * @returns Tuple of [canDeactivateFunctions, canActivateFunctions] as Maps
154
+ */
155
+ getFunctions(): [Map<string, GuardFn>, Map<string, GuardFn>];
156
+ canNavigateTo(toDeactivate: string[], toActivate: string[], toState: State, fromState: State | undefined): boolean;
157
+ /**
158
+ * Compiles a guard factory to its `GuardFn` WITHOUT registering it — surfaces
159
+ * a throwing / non-function factory eagerly. The prepare-then-commit
160
+ * add/replace path (`adoptRouteArtifacts`) calls this for every pending guard
161
+ * BEFORE the store swap (#956), so a malformed factory aborts the mutation
162
+ * with the store untouched. The returned function is then installed via the
163
+ * `precompiledFn` argument of {@link addCanActivate} / {@link addCanDeactivate}
164
+ * — no re-compile, so a factory with compile-time side effects runs exactly
165
+ * once. Same boolean-shorthand handling + compile + non-function check as the
166
+ * inline `#registerHandler` path, so a route-config `canActivate: true`
167
+ * (boolean shorthand, runtime-reachable via the public route type) compiles to
168
+ * the cached `TRUE_GUARD`/`FALSE_GUARD` instead of throwing on a non-callable.
169
+ */
170
+ compileGuardFactory(handler: GuardFnFactory<Dependencies> | boolean, methodName: string): GuardFn;
171
+ }
172
+ //#endregion
173
+ export { GuardClearScope, RouteLifecycleNamespace };
174
+ //# sourceMappingURL=RouteLifecycleNamespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteLifecycleNamespace.d.ts","names":[],"sources":["../../../../src/namespaces/RouteLifecycleNamespace/RouteLifecycleNamespace.ts"],"mappings":";;;;;;;;;;;;;;KAuCY;;;;;;;;;;;;;;;;;;;;;cAsBC,wBACX,qBAAqB,sBAAsB;;EAuC3C,gBAAgB,MAAM,2BAA2B;EAIjD,gBAAgB;;;;;;;;;;;;;;;;;;;;EA8ChB,sBACE,eAAe,kBACf,iBAAiB,kBACjB;;;;;;;;;;;;;;;;;EAuEF,eACE,cACA,SAAS,eAAe,yBACxB,4BACA,gBAAgB;;;;;;EAiBlB,iBACE,cACA,SAAS,eAAe,yBACxB,4BACA,gBAAgB;;;;;;;;;;EAqBlB,iBAAiB,cAAc,OAAO;;;;;;;;;;;;;;;;;;EAqBtC,mBAAmB,cAAc,OAAO;;;;;EAQxC;;;;;;;;;;;;;;EAsBA;;;;;;;;;;;EA+BA,iBACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;;;;;;EA2BhC;IACE,aACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;IAEhC,WACE,eAAe,eAAe,gBAC9B,eAAe,eAAe;;;;;;;EAgClC,iBAAiB,YAAY,UAAU,YAAY;EAInD,cACE,wBACA,sBACA,SAAS,OACT,WAAW;;;;;;;;;;;;;;EA8Cb,oBACE,SAAS,eAAe,yBACxB,qBACC"}