@benjavicente/router-core 1.168.9

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 (380) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/bin/intent.js +25 -0
  4. package/dist/cjs/Matches.cjs +17 -0
  5. package/dist/cjs/Matches.cjs.map +1 -0
  6. package/dist/cjs/Matches.d.cts +139 -0
  7. package/dist/cjs/RouterProvider.d.cts +27 -0
  8. package/dist/cjs/config.cjs +11 -0
  9. package/dist/cjs/config.cjs.map +1 -0
  10. package/dist/cjs/config.d.cts +17 -0
  11. package/dist/cjs/defer.cjs +41 -0
  12. package/dist/cjs/defer.cjs.map +1 -0
  13. package/dist/cjs/defer.d.cts +37 -0
  14. package/dist/cjs/fileRoute.d.cts +24 -0
  15. package/dist/cjs/global.d.cts +7 -0
  16. package/dist/cjs/hash-scroll.cjs +20 -0
  17. package/dist/cjs/hash-scroll.cjs.map +1 -0
  18. package/dist/cjs/hash-scroll.d.cts +7 -0
  19. package/dist/cjs/history.d.cts +8 -0
  20. package/dist/cjs/index.cjs +96 -0
  21. package/dist/cjs/index.d.cts +53 -0
  22. package/dist/cjs/invariant.cjs +8 -0
  23. package/dist/cjs/invariant.cjs.map +1 -0
  24. package/dist/cjs/invariant.d.cts +1 -0
  25. package/dist/cjs/isServer/client.cjs +7 -0
  26. package/dist/cjs/isServer/client.cjs.map +1 -0
  27. package/dist/cjs/isServer/client.d.cts +1 -0
  28. package/dist/cjs/isServer/development.cjs +7 -0
  29. package/dist/cjs/isServer/development.cjs.map +1 -0
  30. package/dist/cjs/isServer/development.d.cts +1 -0
  31. package/dist/cjs/isServer/server.cjs +7 -0
  32. package/dist/cjs/isServer/server.cjs.map +1 -0
  33. package/dist/cjs/isServer/server.d.cts +1 -0
  34. package/dist/cjs/link.cjs +6 -0
  35. package/dist/cjs/link.cjs.map +1 -0
  36. package/dist/cjs/link.d.cts +221 -0
  37. package/dist/cjs/load-matches.cjs +659 -0
  38. package/dist/cjs/load-matches.cjs.map +1 -0
  39. package/dist/cjs/load-matches.d.cts +18 -0
  40. package/dist/cjs/location.d.cts +50 -0
  41. package/dist/cjs/lru-cache.cjs +70 -0
  42. package/dist/cjs/lru-cache.cjs.map +1 -0
  43. package/dist/cjs/lru-cache.d.cts +6 -0
  44. package/dist/cjs/manifest.cjs +18 -0
  45. package/dist/cjs/manifest.cjs.map +1 -0
  46. package/dist/cjs/manifest.d.cts +35 -0
  47. package/dist/cjs/new-process-route-tree.cjs +754 -0
  48. package/dist/cjs/new-process-route-tree.cjs.map +1 -0
  49. package/dist/cjs/new-process-route-tree.d.cts +236 -0
  50. package/dist/cjs/not-found.cjs +26 -0
  51. package/dist/cjs/not-found.cjs.map +1 -0
  52. package/dist/cjs/not-found.d.cts +32 -0
  53. package/dist/cjs/path.cjs +252 -0
  54. package/dist/cjs/path.cjs.map +1 -0
  55. package/dist/cjs/path.d.cts +56 -0
  56. package/dist/cjs/qss.cjs +70 -0
  57. package/dist/cjs/qss.cjs.map +1 -0
  58. package/dist/cjs/qss.d.cts +33 -0
  59. package/dist/cjs/redirect.cjs +56 -0
  60. package/dist/cjs/redirect.cjs.map +1 -0
  61. package/dist/cjs/redirect.d.cts +77 -0
  62. package/dist/cjs/rewrite.cjs +68 -0
  63. package/dist/cjs/rewrite.cjs.map +1 -0
  64. package/dist/cjs/rewrite.d.cts +30 -0
  65. package/dist/cjs/root.cjs +7 -0
  66. package/dist/cjs/root.cjs.map +1 -0
  67. package/dist/cjs/root.d.cts +3 -0
  68. package/dist/cjs/route.cjs +100 -0
  69. package/dist/cjs/route.cjs.map +1 -0
  70. package/dist/cjs/route.d.cts +552 -0
  71. package/dist/cjs/routeInfo.d.cts +54 -0
  72. package/dist/cjs/router.cjs +1173 -0
  73. package/dist/cjs/router.cjs.map +1 -0
  74. package/dist/cjs/router.d.cts +734 -0
  75. package/dist/cjs/scroll-restoration-inline.cjs +6 -0
  76. package/dist/cjs/scroll-restoration-inline.cjs.map +1 -0
  77. package/dist/cjs/scroll-restoration-inline.d.cts +6 -0
  78. package/dist/cjs/scroll-restoration-script/client.cjs +9 -0
  79. package/dist/cjs/scroll-restoration-script/client.cjs.map +1 -0
  80. package/dist/cjs/scroll-restoration-script/client.d.cts +2 -0
  81. package/dist/cjs/scroll-restoration-script/server.cjs +30 -0
  82. package/dist/cjs/scroll-restoration-script/server.cjs.map +1 -0
  83. package/dist/cjs/scroll-restoration-script/server.d.cts +2 -0
  84. package/dist/cjs/scroll-restoration.cjs +191 -0
  85. package/dist/cjs/scroll-restoration.cjs.map +1 -0
  86. package/dist/cjs/scroll-restoration.d.cts +38 -0
  87. package/dist/cjs/searchMiddleware.cjs +55 -0
  88. package/dist/cjs/searchMiddleware.cjs.map +1 -0
  89. package/dist/cjs/searchMiddleware.d.cts +25 -0
  90. package/dist/cjs/searchParams.cjs +65 -0
  91. package/dist/cjs/searchParams.cjs.map +1 -0
  92. package/dist/cjs/searchParams.d.cts +31 -0
  93. package/dist/cjs/ssr/client.cjs +7 -0
  94. package/dist/cjs/ssr/client.d.cts +6 -0
  95. package/dist/cjs/ssr/constants.cjs +8 -0
  96. package/dist/cjs/ssr/constants.cjs.map +1 -0
  97. package/dist/cjs/ssr/constants.d.cts +3 -0
  98. package/dist/cjs/ssr/createRequestHandler.cjs +44 -0
  99. package/dist/cjs/ssr/createRequestHandler.cjs.map +1 -0
  100. package/dist/cjs/ssr/createRequestHandler.d.cts +9 -0
  101. package/dist/cjs/ssr/handlerCallback.cjs +8 -0
  102. package/dist/cjs/ssr/handlerCallback.cjs.map +1 -0
  103. package/dist/cjs/ssr/handlerCallback.d.cts +9 -0
  104. package/dist/cjs/ssr/headers.cjs +21 -0
  105. package/dist/cjs/ssr/headers.cjs.map +1 -0
  106. package/dist/cjs/ssr/headers.d.cts +3 -0
  107. package/dist/cjs/ssr/json.cjs +11 -0
  108. package/dist/cjs/ssr/json.cjs.map +1 -0
  109. package/dist/cjs/ssr/json.d.cts +10 -0
  110. package/dist/cjs/ssr/serializer/RawStream.cjs +287 -0
  111. package/dist/cjs/ssr/serializer/RawStream.cjs.map +1 -0
  112. package/dist/cjs/ssr/serializer/RawStream.d.cts +64 -0
  113. package/dist/cjs/ssr/serializer/ShallowErrorPlugin.cjs +32 -0
  114. package/dist/cjs/ssr/serializer/ShallowErrorPlugin.cjs.map +1 -0
  115. package/dist/cjs/ssr/serializer/ShallowErrorPlugin.d.cts +9 -0
  116. package/dist/cjs/ssr/serializer/seroval-plugins.cjs +13 -0
  117. package/dist/cjs/ssr/serializer/seroval-plugins.cjs.map +1 -0
  118. package/dist/cjs/ssr/serializer/seroval-plugins.d.cts +2 -0
  119. package/dist/cjs/ssr/serializer/transformer.cjs +53 -0
  120. package/dist/cjs/ssr/serializer/transformer.cjs.map +1 -0
  121. package/dist/cjs/ssr/serializer/transformer.d.cts +91 -0
  122. package/dist/cjs/ssr/server.cjs +13 -0
  123. package/dist/cjs/ssr/server.d.cts +6 -0
  124. package/dist/cjs/ssr/ssr-client.cjs +183 -0
  125. package/dist/cjs/ssr/ssr-client.cjs.map +1 -0
  126. package/dist/cjs/ssr/ssr-client.d.cts +10 -0
  127. package/dist/cjs/ssr/ssr-match-id.cjs +12 -0
  128. package/dist/cjs/ssr/ssr-match-id.cjs.map +1 -0
  129. package/dist/cjs/ssr/ssr-match-id.d.cts +2 -0
  130. package/dist/cjs/ssr/ssr-server.cjs +279 -0
  131. package/dist/cjs/ssr/ssr-server.cjs.map +1 -0
  132. package/dist/cjs/ssr/ssr-server.d.cts +42 -0
  133. package/dist/cjs/ssr/transformStreamWithRouter.cjs +327 -0
  134. package/dist/cjs/ssr/transformStreamWithRouter.cjs.map +1 -0
  135. package/dist/cjs/ssr/transformStreamWithRouter.d.cts +11 -0
  136. package/dist/cjs/ssr/tsrScript.cjs +6 -0
  137. package/dist/cjs/ssr/tsrScript.cjs.map +1 -0
  138. package/dist/cjs/ssr/tsrScript.d.cts +1 -0
  139. package/dist/cjs/ssr/types.d.cts +30 -0
  140. package/dist/cjs/stores.cjs +148 -0
  141. package/dist/cjs/stores.cjs.map +1 -0
  142. package/dist/cjs/stores.d.cts +70 -0
  143. package/dist/cjs/structuralSharing.d.cts +4 -0
  144. package/dist/cjs/typePrimitives.d.cts +65 -0
  145. package/dist/cjs/useLoaderData.d.cts +5 -0
  146. package/dist/cjs/useLoaderDeps.d.cts +5 -0
  147. package/dist/cjs/useNavigate.d.cts +3 -0
  148. package/dist/cjs/useParams.d.cts +5 -0
  149. package/dist/cjs/useRouteContext.d.cts +9 -0
  150. package/dist/cjs/useSearch.d.cts +5 -0
  151. package/dist/cjs/utils.cjs +339 -0
  152. package/dist/cjs/utils.cjs.map +1 -0
  153. package/dist/cjs/utils.d.cts +178 -0
  154. package/dist/cjs/validators.d.cts +51 -0
  155. package/dist/esm/Matches.d.ts +139 -0
  156. package/dist/esm/Matches.js +17 -0
  157. package/dist/esm/Matches.js.map +1 -0
  158. package/dist/esm/RouterProvider.d.ts +27 -0
  159. package/dist/esm/config.d.ts +17 -0
  160. package/dist/esm/config.js +11 -0
  161. package/dist/esm/config.js.map +1 -0
  162. package/dist/esm/defer.d.ts +37 -0
  163. package/dist/esm/defer.js +40 -0
  164. package/dist/esm/defer.js.map +1 -0
  165. package/dist/esm/fileRoute.d.ts +24 -0
  166. package/dist/esm/global.d.ts +7 -0
  167. package/dist/esm/hash-scroll.d.ts +7 -0
  168. package/dist/esm/hash-scroll.js +20 -0
  169. package/dist/esm/hash-scroll.js.map +1 -0
  170. package/dist/esm/history.d.ts +8 -0
  171. package/dist/esm/index.d.ts +53 -0
  172. package/dist/esm/index.js +24 -0
  173. package/dist/esm/invariant.d.ts +1 -0
  174. package/dist/esm/invariant.js +8 -0
  175. package/dist/esm/invariant.js.map +1 -0
  176. package/dist/esm/isServer/client.d.ts +1 -0
  177. package/dist/esm/isServer/client.js +6 -0
  178. package/dist/esm/isServer/client.js.map +1 -0
  179. package/dist/esm/isServer/development.d.ts +1 -0
  180. package/dist/esm/isServer/development.js +6 -0
  181. package/dist/esm/isServer/development.js.map +1 -0
  182. package/dist/esm/isServer/server.d.ts +1 -0
  183. package/dist/esm/isServer/server.js +6 -0
  184. package/dist/esm/isServer/server.js.map +1 -0
  185. package/dist/esm/link.d.ts +221 -0
  186. package/dist/esm/link.js +6 -0
  187. package/dist/esm/link.js.map +1 -0
  188. package/dist/esm/load-matches.d.ts +18 -0
  189. package/dist/esm/load-matches.js +657 -0
  190. package/dist/esm/load-matches.js.map +1 -0
  191. package/dist/esm/location.d.ts +50 -0
  192. package/dist/esm/lru-cache.d.ts +6 -0
  193. package/dist/esm/lru-cache.js +70 -0
  194. package/dist/esm/lru-cache.js.map +1 -0
  195. package/dist/esm/manifest.d.ts +35 -0
  196. package/dist/esm/manifest.js +17 -0
  197. package/dist/esm/manifest.js.map +1 -0
  198. package/dist/esm/new-process-route-tree.d.ts +236 -0
  199. package/dist/esm/new-process-route-tree.js +749 -0
  200. package/dist/esm/new-process-route-tree.js.map +1 -0
  201. package/dist/esm/not-found.d.ts +32 -0
  202. package/dist/esm/not-found.js +25 -0
  203. package/dist/esm/not-found.js.map +1 -0
  204. package/dist/esm/path.d.ts +56 -0
  205. package/dist/esm/path.js +243 -0
  206. package/dist/esm/path.js.map +1 -0
  207. package/dist/esm/qss.d.ts +33 -0
  208. package/dist/esm/qss.js +69 -0
  209. package/dist/esm/qss.js.map +1 -0
  210. package/dist/esm/redirect.d.ts +77 -0
  211. package/dist/esm/redirect.js +53 -0
  212. package/dist/esm/redirect.js.map +1 -0
  213. package/dist/esm/rewrite.d.ts +30 -0
  214. package/dist/esm/rewrite.js +65 -0
  215. package/dist/esm/rewrite.js.map +1 -0
  216. package/dist/esm/root.d.ts +3 -0
  217. package/dist/esm/root.js +7 -0
  218. package/dist/esm/root.js.map +1 -0
  219. package/dist/esm/route.d.ts +552 -0
  220. package/dist/esm/route.js +98 -0
  221. package/dist/esm/route.js.map +1 -0
  222. package/dist/esm/routeInfo.d.ts +54 -0
  223. package/dist/esm/router.d.ts +734 -0
  224. package/dist/esm/router.js +1165 -0
  225. package/dist/esm/router.js.map +1 -0
  226. package/dist/esm/scroll-restoration-inline.d.ts +6 -0
  227. package/dist/esm/scroll-restoration-inline.js +6 -0
  228. package/dist/esm/scroll-restoration-inline.js.map +1 -0
  229. package/dist/esm/scroll-restoration-script/client.d.ts +2 -0
  230. package/dist/esm/scroll-restoration-script/client.js +8 -0
  231. package/dist/esm/scroll-restoration-script/client.js.map +1 -0
  232. package/dist/esm/scroll-restoration-script/server.d.ts +2 -0
  233. package/dist/esm/scroll-restoration-script/server.js +29 -0
  234. package/dist/esm/scroll-restoration-script/server.js.map +1 -0
  235. package/dist/esm/scroll-restoration.d.ts +38 -0
  236. package/dist/esm/scroll-restoration.js +187 -0
  237. package/dist/esm/scroll-restoration.js.map +1 -0
  238. package/dist/esm/searchMiddleware.d.ts +25 -0
  239. package/dist/esm/searchMiddleware.js +54 -0
  240. package/dist/esm/searchMiddleware.js.map +1 -0
  241. package/dist/esm/searchParams.d.ts +31 -0
  242. package/dist/esm/searchParams.js +62 -0
  243. package/dist/esm/searchParams.js.map +1 -0
  244. package/dist/esm/ssr/client.d.ts +6 -0
  245. package/dist/esm/ssr/client.js +4 -0
  246. package/dist/esm/ssr/constants.d.ts +3 -0
  247. package/dist/esm/ssr/constants.js +7 -0
  248. package/dist/esm/ssr/constants.js.map +1 -0
  249. package/dist/esm/ssr/createRequestHandler.d.ts +9 -0
  250. package/dist/esm/ssr/createRequestHandler.js +44 -0
  251. package/dist/esm/ssr/createRequestHandler.js.map +1 -0
  252. package/dist/esm/ssr/handlerCallback.d.ts +9 -0
  253. package/dist/esm/ssr/handlerCallback.js +8 -0
  254. package/dist/esm/ssr/handlerCallback.js.map +1 -0
  255. package/dist/esm/ssr/headers.d.ts +3 -0
  256. package/dist/esm/ssr/headers.js +21 -0
  257. package/dist/esm/ssr/headers.js.map +1 -0
  258. package/dist/esm/ssr/json.d.ts +10 -0
  259. package/dist/esm/ssr/json.js +11 -0
  260. package/dist/esm/ssr/json.js.map +1 -0
  261. package/dist/esm/ssr/serializer/RawStream.d.ts +64 -0
  262. package/dist/esm/ssr/serializer/RawStream.js +282 -0
  263. package/dist/esm/ssr/serializer/RawStream.js.map +1 -0
  264. package/dist/esm/ssr/serializer/ShallowErrorPlugin.d.ts +9 -0
  265. package/dist/esm/ssr/serializer/ShallowErrorPlugin.js +33 -0
  266. package/dist/esm/ssr/serializer/ShallowErrorPlugin.js.map +1 -0
  267. package/dist/esm/ssr/serializer/seroval-plugins.d.ts +2 -0
  268. package/dist/esm/ssr/serializer/seroval-plugins.js +13 -0
  269. package/dist/esm/ssr/serializer/seroval-plugins.js.map +1 -0
  270. package/dist/esm/ssr/serializer/transformer.d.ts +91 -0
  271. package/dist/esm/ssr/serializer/transformer.js +51 -0
  272. package/dist/esm/ssr/serializer/transformer.js.map +1 -0
  273. package/dist/esm/ssr/server.d.ts +6 -0
  274. package/dist/esm/ssr/server.js +5 -0
  275. package/dist/esm/ssr/ssr-client.d.ts +10 -0
  276. package/dist/esm/ssr/ssr-client.js +183 -0
  277. package/dist/esm/ssr/ssr-client.js.map +1 -0
  278. package/dist/esm/ssr/ssr-match-id.d.ts +2 -0
  279. package/dist/esm/ssr/ssr-match-id.js +11 -0
  280. package/dist/esm/ssr/ssr-match-id.js.map +1 -0
  281. package/dist/esm/ssr/ssr-server.d.ts +42 -0
  282. package/dist/esm/ssr/ssr-server.js +277 -0
  283. package/dist/esm/ssr/ssr-server.js.map +1 -0
  284. package/dist/esm/ssr/transformStreamWithRouter.d.ts +11 -0
  285. package/dist/esm/ssr/transformStreamWithRouter.js +325 -0
  286. package/dist/esm/ssr/transformStreamWithRouter.js.map +1 -0
  287. package/dist/esm/ssr/tsrScript.d.ts +0 -0
  288. package/dist/esm/ssr/tsrScript.js +6 -0
  289. package/dist/esm/ssr/tsrScript.js.map +1 -0
  290. package/dist/esm/ssr/types.d.ts +30 -0
  291. package/dist/esm/stores.d.ts +70 -0
  292. package/dist/esm/stores.js +146 -0
  293. package/dist/esm/stores.js.map +1 -0
  294. package/dist/esm/structuralSharing.d.ts +4 -0
  295. package/dist/esm/typePrimitives.d.ts +65 -0
  296. package/dist/esm/useLoaderData.d.ts +5 -0
  297. package/dist/esm/useLoaderDeps.d.ts +5 -0
  298. package/dist/esm/useNavigate.d.ts +3 -0
  299. package/dist/esm/useParams.d.ts +5 -0
  300. package/dist/esm/useRouteContext.d.ts +9 -0
  301. package/dist/esm/useSearch.d.ts +5 -0
  302. package/dist/esm/utils.d.ts +178 -0
  303. package/dist/esm/utils.js +322 -0
  304. package/dist/esm/utils.js.map +1 -0
  305. package/dist/esm/validators.d.ts +51 -0
  306. package/package.json +200 -0
  307. package/skills/router-core/SKILL.md +139 -0
  308. package/skills/router-core/auth-and-guards/SKILL.md +458 -0
  309. package/skills/router-core/code-splitting/SKILL.md +322 -0
  310. package/skills/router-core/data-loading/SKILL.md +485 -0
  311. package/skills/router-core/navigation/SKILL.md +448 -0
  312. package/skills/router-core/not-found-and-errors/SKILL.md +435 -0
  313. package/skills/router-core/path-params/SKILL.md +382 -0
  314. package/skills/router-core/search-params/SKILL.md +349 -0
  315. package/skills/router-core/search-params/references/validation-patterns.md +379 -0
  316. package/skills/router-core/ssr/SKILL.md +437 -0
  317. package/skills/router-core/type-safety/SKILL.md +497 -0
  318. package/src/Matches.ts +291 -0
  319. package/src/RouterProvider.ts +47 -0
  320. package/src/config.ts +42 -0
  321. package/src/defer.ts +69 -0
  322. package/src/fileRoute.ts +164 -0
  323. package/src/global.ts +9 -0
  324. package/src/hash-scroll.ts +21 -0
  325. package/src/history.ts +9 -0
  326. package/src/index.ts +471 -0
  327. package/src/invariant.ts +3 -0
  328. package/src/isServer/client.ts +1 -0
  329. package/src/isServer/development.ts +2 -0
  330. package/src/isServer/server.ts +1 -0
  331. package/src/link.ts +704 -0
  332. package/src/load-matches.ts +1281 -0
  333. package/src/location.ts +51 -0
  334. package/src/lru-cache.ts +74 -0
  335. package/src/manifest.ts +68 -0
  336. package/src/new-process-route-tree.ts +1387 -0
  337. package/src/not-found.ts +41 -0
  338. package/src/path.ts +436 -0
  339. package/src/qss.ts +81 -0
  340. package/src/redirect.ts +179 -0
  341. package/src/rewrite.ts +93 -0
  342. package/src/root.ts +3 -0
  343. package/src/route.ts +2235 -0
  344. package/src/routeInfo.ts +235 -0
  345. package/src/router.ts +3207 -0
  346. package/src/scroll-restoration-inline.ts +81 -0
  347. package/src/scroll-restoration-script/client.ts +5 -0
  348. package/src/scroll-restoration-script/server.ts +64 -0
  349. package/src/scroll-restoration.ts +357 -0
  350. package/src/searchMiddleware.ts +76 -0
  351. package/src/searchParams.ts +90 -0
  352. package/src/ssr/client.ts +6 -0
  353. package/src/ssr/constants.ts +3 -0
  354. package/src/ssr/createRequestHandler.ts +98 -0
  355. package/src/ssr/handlerCallback.ts +15 -0
  356. package/src/ssr/headers.ts +40 -0
  357. package/src/ssr/json.ts +16 -0
  358. package/src/ssr/serializer/RawStream.ts +464 -0
  359. package/src/ssr/serializer/ShallowErrorPlugin.ts +43 -0
  360. package/src/ssr/serializer/seroval-plugins.ts +12 -0
  361. package/src/ssr/serializer/transformer.ts +312 -0
  362. package/src/ssr/server.ts +14 -0
  363. package/src/ssr/ssr-client.ts +313 -0
  364. package/src/ssr/ssr-match-id.ts +7 -0
  365. package/src/ssr/ssr-server.ts +425 -0
  366. package/src/ssr/transformStreamWithRouter.ts +493 -0
  367. package/src/ssr/tsrScript.ts +20 -0
  368. package/src/ssr/types.ts +41 -0
  369. package/src/stores.ts +342 -0
  370. package/src/structuralSharing.ts +7 -0
  371. package/src/typePrimitives.ts +181 -0
  372. package/src/useLoaderData.ts +20 -0
  373. package/src/useLoaderDeps.ts +13 -0
  374. package/src/useNavigate.ts +13 -0
  375. package/src/useParams.ts +20 -0
  376. package/src/useRouteContext.ts +39 -0
  377. package/src/useSearch.ts +20 -0
  378. package/src/utils.ts +708 -0
  379. package/src/validators.ts +121 -0
  380. package/src/vite-env.d.ts +4 -0
package/src/route.ts ADDED
@@ -0,0 +1,2235 @@
1
+ import { invariant } from './invariant'
2
+ import { joinPaths, trimPathLeft, trimPathRight } from './path'
3
+ import { notFound } from './not-found'
4
+ import { redirect } from './redirect'
5
+ import { rootRouteId } from './root'
6
+ import type { LazyRoute } from './fileRoute'
7
+ import type { NotFoundError } from './not-found'
8
+ import type { RedirectFnRoute } from './redirect'
9
+ import type { NavigateOptions, ParsePathParams } from './link'
10
+ import type { ParsedLocation } from './location'
11
+ import type {
12
+ AnyRouteMatch,
13
+ MakePreValidationErrorHandlingRouteMatchUnion,
14
+ MakeRouteMatchFromRoute,
15
+ MakeRouteMatchUnion,
16
+ RouteMatch,
17
+ } from './Matches'
18
+ import type { RootRouteId } from './root'
19
+ import type { ParseRoute, RouteById, RouteIds, RoutePaths } from './routeInfo'
20
+ import type { AnyRouter, Register, RegisteredRouter, SSROption } from './router'
21
+ import type { BuildLocationFn, NavigateFn } from './RouterProvider'
22
+ import type {
23
+ Assign,
24
+ Awaitable,
25
+ Constrain,
26
+ Expand,
27
+ IntersectAssign,
28
+ LooseAsyncReturnType,
29
+ LooseReturnType,
30
+ NoInfer,
31
+ } from './utils'
32
+ import type {
33
+ AnySchema,
34
+ AnyStandardSchemaValidator,
35
+ AnyValidator,
36
+ AnyValidatorAdapter,
37
+ AnyValidatorObj,
38
+ DefaultValidator,
39
+ ResolveSearchValidatorInput,
40
+ ResolveValidatorOutput,
41
+ StandardSchemaValidator,
42
+ ValidatorAdapter,
43
+ ValidatorFn,
44
+ ValidatorObj,
45
+ } from './validators'
46
+ import type { ValidateSerializableLifecycleResult } from './ssr/serializer/transformer'
47
+
48
+ export type AnyPathParams = {}
49
+
50
+ export type SearchSchemaInput = {
51
+ __TSearchSchemaInput__: 'TSearchSchemaInput'
52
+ }
53
+
54
+ export type AnyContext = {}
55
+
56
+ export interface RouteContext {}
57
+
58
+ export type PreloadableObj = { preload?: () => Promise<void> }
59
+
60
+ export type RoutePathOptions<TCustomId, TPath> =
61
+ | {
62
+ path: TPath
63
+ }
64
+ | {
65
+ id: TCustomId
66
+ }
67
+
68
+ export interface StaticDataRouteOption {}
69
+
70
+ export type RoutePathOptionsIntersection<TCustomId, TPath> = {
71
+ path: TPath
72
+ id: TCustomId
73
+ }
74
+
75
+ export type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult
76
+
77
+ export type SearchMiddlewareContext<TSearchSchema> = {
78
+ search: TSearchSchema
79
+ next: (newSearch: TSearchSchema) => TSearchSchema
80
+ }
81
+
82
+ export type SearchMiddleware<TSearchSchema> = (
83
+ ctx: SearchMiddlewareContext<TSearchSchema>,
84
+ ) => TSearchSchema
85
+
86
+ export type ResolveId<
87
+ TParentRoute,
88
+ TCustomId extends string,
89
+ TPath extends string,
90
+ > = TParentRoute extends { id: infer TParentId extends string }
91
+ ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>
92
+ : RootRouteId
93
+
94
+ export type InferFullSearchSchema<TRoute> = TRoute extends {
95
+ types: {
96
+ fullSearchSchema: infer TFullSearchSchema
97
+ }
98
+ }
99
+ ? TFullSearchSchema
100
+ : {}
101
+
102
+ export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
103
+ types: {
104
+ fullSearchSchemaInput: infer TFullSearchSchemaInput
105
+ }
106
+ }
107
+ ? TFullSearchSchemaInput
108
+ : {}
109
+
110
+ export type InferAllParams<TRoute> = TRoute extends {
111
+ types: {
112
+ allParams: infer TAllParams
113
+ }
114
+ }
115
+ ? TAllParams
116
+ : {}
117
+
118
+ export type InferAllContext<TRoute> = unknown extends TRoute
119
+ ? TRoute
120
+ : TRoute extends {
121
+ types: {
122
+ allContext: infer TAllContext
123
+ }
124
+ }
125
+ ? TAllContext
126
+ : {}
127
+
128
+ export type ResolveSearchSchemaFnInput<TSearchValidator> =
129
+ TSearchValidator extends (input: infer TSearchSchemaInput) => any
130
+ ? TSearchSchemaInput extends SearchSchemaInput
131
+ ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>
132
+ : ResolveSearchSchemaFn<TSearchValidator>
133
+ : AnySchema
134
+
135
+ export type ResolveSearchSchemaInput<TSearchValidator> =
136
+ TSearchValidator extends AnyStandardSchemaValidator
137
+ ? NonNullable<TSearchValidator['~standard']['types']>['input']
138
+ : TSearchValidator extends AnyValidatorAdapter
139
+ ? TSearchValidator['types']['input']
140
+ : TSearchValidator extends AnyValidatorObj
141
+ ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>
142
+ : ResolveSearchSchemaFnInput<TSearchValidator>
143
+
144
+ export type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (
145
+ ...args: any
146
+ ) => infer TSearchSchema
147
+ ? TSearchSchema
148
+ : AnySchema
149
+
150
+ export type ResolveSearchSchema<TSearchValidator> =
151
+ unknown extends TSearchValidator
152
+ ? TSearchValidator
153
+ : TSearchValidator extends AnyStandardSchemaValidator
154
+ ? NonNullable<TSearchValidator['~standard']['types']>['output']
155
+ : TSearchValidator extends AnyValidatorAdapter
156
+ ? TSearchValidator['types']['output']
157
+ : TSearchValidator extends AnyValidatorObj
158
+ ? ResolveSearchSchemaFn<TSearchValidator['parse']>
159
+ : ResolveSearchSchemaFn<TSearchValidator>
160
+
161
+ export type ResolveRequiredParams<TPath extends string, T> = {
162
+ [K in ParsePathParams<TPath>['required']]: T
163
+ }
164
+
165
+ export type ResolveOptionalParams<TPath extends string, T> = {
166
+ [K in ParsePathParams<TPath>['optional']]?: T | undefined
167
+ }
168
+
169
+ export type ResolveParams<
170
+ TPath extends string,
171
+ T = string,
172
+ > = ResolveRequiredParams<TPath, T> & ResolveOptionalParams<TPath, T>
173
+
174
+ export type ParseParamsFn<in out TPath extends string, in out TParams> = (
175
+ rawParams: Expand<ResolveParams<TPath>>,
176
+ ) => TParams extends ResolveParams<TPath, any>
177
+ ? TParams
178
+ : ResolveParams<TPath, any>
179
+
180
+ export type StringifyParamsFn<in out TPath extends string, in out TParams> = (
181
+ params: TParams,
182
+ ) => ResolveParams<TPath>
183
+
184
+ export type ParamsOptions<in out TPath extends string, in out TParams> = {
185
+ params?: {
186
+ parse?: ParseParamsFn<TPath, TParams>
187
+ stringify?: StringifyParamsFn<TPath, TParams>
188
+ }
189
+
190
+ /**
191
+ @deprecated Use params.parse instead
192
+ */
193
+ parseParams?: ParseParamsFn<TPath, TParams>
194
+
195
+ /**
196
+ @deprecated Use params.stringify instead
197
+ */
198
+ stringifyParams?: StringifyParamsFn<TPath, TParams>
199
+ }
200
+
201
+ interface RequiredStaticDataRouteOption {
202
+ staticData: StaticDataRouteOption
203
+ }
204
+
205
+ interface OptionalStaticDataRouteOption {
206
+ staticData?: StaticDataRouteOption
207
+ }
208
+
209
+ export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption
210
+ ? OptionalStaticDataRouteOption
211
+ : RequiredStaticDataRouteOption
212
+
213
+ export type MetaDescriptor =
214
+ | { charSet: 'utf-8' }
215
+ | { title: string }
216
+ | { name: string; content: string }
217
+ | { property: string; content: string }
218
+ | { httpEquiv: string; content: string }
219
+ | { 'script:ld+json': LdJsonObject }
220
+ | { tagName: 'meta' | 'link'; [name: string]: string }
221
+ | Record<string, unknown>
222
+
223
+ type LdJsonObject = { [Key in string]: LdJsonValue } & {
224
+ [Key in string]?: LdJsonValue | undefined
225
+ }
226
+ type LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>
227
+ type LdJsonPrimitive = string | number | boolean | null
228
+ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray
229
+
230
+ export type RouteLinkEntry = {}
231
+
232
+ export type SearchValidator<TInput, TOutput> =
233
+ | ValidatorObj<TInput, TOutput>
234
+ | ValidatorFn<TInput, TOutput>
235
+ | ValidatorAdapter<TInput, TOutput>
236
+ | StandardSchemaValidator<TInput, TOutput>
237
+ | undefined
238
+
239
+ export type AnySearchValidator = SearchValidator<any, any>
240
+
241
+ export type DefaultSearchValidator = SearchValidator<
242
+ Record<string, unknown>,
243
+ AnySchema
244
+ >
245
+
246
+ export type RoutePrefix<
247
+ TPrefix extends string,
248
+ TPath extends string,
249
+ > = string extends TPath
250
+ ? RootRouteId
251
+ : TPath extends string
252
+ ? TPrefix extends RootRouteId
253
+ ? TPath extends '/'
254
+ ? '/'
255
+ : `/${TrimPath<TPath>}`
256
+ : `${TPrefix}/${TPath}` extends '/'
257
+ ? '/'
258
+ : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`
259
+ : never
260
+
261
+ export type TrimPath<T extends string> = '' extends T
262
+ ? ''
263
+ : TrimPathRight<TrimPathLeft<T>>
264
+
265
+ export type TrimPathLeft<T extends string> =
266
+ T extends `${RootRouteId}/${infer U}`
267
+ ? TrimPathLeft<U>
268
+ : T extends `/${infer U}`
269
+ ? TrimPathLeft<U>
270
+ : T
271
+
272
+ export type TrimPathRight<T extends string> = T extends '/'
273
+ ? '/'
274
+ : T extends `${infer U}/`
275
+ ? TrimPathRight<U>
276
+ : T
277
+
278
+ export type ContextReturnType<TContextFn> = unknown extends TContextFn
279
+ ? TContextFn
280
+ : LooseReturnType<TContextFn> extends never
281
+ ? AnyContext
282
+ : LooseReturnType<TContextFn>
283
+
284
+ export type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn
285
+ ? TContextFn
286
+ : LooseAsyncReturnType<TContextFn> extends never
287
+ ? AnyContext
288
+ : LooseAsyncReturnType<TContextFn>
289
+
290
+ export type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<
291
+ ContextReturnType<TRouteContextFn>,
292
+ ContextAsyncReturnType<TBeforeLoadFn>
293
+ >
294
+
295
+ export type ResolveRouteLoaderFn<TLoaderFn> = TLoaderFn extends {
296
+ handler: infer THandler
297
+ }
298
+ ? THandler
299
+ : TLoaderFn
300
+
301
+ export type RouteLoaderObject<
302
+ TRegister,
303
+ TParentRoute extends AnyRoute = AnyRoute,
304
+ TId extends string = string,
305
+ TParams = {},
306
+ TLoaderDeps = {},
307
+ TRouterContext = {},
308
+ TRouteContextFn = AnyContext,
309
+ TBeforeLoadFn = AnyContext,
310
+ TServerMiddlewares = unknown,
311
+ THandlers = undefined,
312
+ > = {
313
+ handler: RouteLoaderFn<
314
+ TRegister,
315
+ TParentRoute,
316
+ TId,
317
+ TParams,
318
+ TLoaderDeps,
319
+ TRouterContext,
320
+ TRouteContextFn,
321
+ TBeforeLoadFn,
322
+ TServerMiddlewares,
323
+ THandlers
324
+ >
325
+ staleReloadMode?: LoaderStaleReloadMode
326
+ }
327
+
328
+ export type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn
329
+ ? TLoaderFn
330
+ : LooseAsyncReturnType<ResolveRouteLoaderFn<TLoaderFn>> extends never
331
+ ? undefined
332
+ : LooseAsyncReturnType<ResolveRouteLoaderFn<TLoaderFn>>
333
+
334
+ export type ResolveFullSearchSchema<
335
+ TParentRoute extends AnyRoute,
336
+ TSearchValidator,
337
+ > = unknown extends TParentRoute
338
+ ? ResolveValidatorOutput<TSearchValidator>
339
+ : IntersectAssign<
340
+ InferFullSearchSchema<TParentRoute>,
341
+ ResolveValidatorOutput<TSearchValidator>
342
+ >
343
+
344
+ export type ResolveFullSearchSchemaInput<
345
+ TParentRoute extends AnyRoute,
346
+ TSearchValidator,
347
+ > = IntersectAssign<
348
+ InferFullSearchSchemaInput<TParentRoute>,
349
+ ResolveSearchValidatorInput<TSearchValidator>
350
+ >
351
+
352
+ export type ResolveAllParamsFromParent<
353
+ TParentRoute extends AnyRoute,
354
+ TParams,
355
+ > = Assign<InferAllParams<TParentRoute>, TParams>
356
+
357
+ export type RouteContextParameter<
358
+ TParentRoute extends AnyRoute,
359
+ TRouterContext,
360
+ > = unknown extends TParentRoute
361
+ ? TRouterContext
362
+ : Assign<TRouterContext, InferAllContext<TParentRoute>>
363
+
364
+ export type BeforeLoadContextParameter<
365
+ TParentRoute extends AnyRoute,
366
+ TRouterContext,
367
+ TRouteContextFn,
368
+ > = Assign<
369
+ RouteContextParameter<TParentRoute, TRouterContext>,
370
+ ContextReturnType<TRouteContextFn>
371
+ >
372
+
373
+ export type ResolveAllContext<
374
+ TParentRoute extends AnyRoute,
375
+ TRouterContext,
376
+ TRouteContextFn,
377
+ TBeforeLoadFn,
378
+ > = Assign<
379
+ BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>,
380
+ ContextAsyncReturnType<TBeforeLoadFn>
381
+ >
382
+ export interface FullSearchSchemaOption<
383
+ in out TParentRoute extends AnyRoute,
384
+ in out TSearchValidator,
385
+ > {
386
+ search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
387
+ }
388
+
389
+ export interface RemountDepsOptions<
390
+ in out TRouteId,
391
+ in out TFullSearchSchema,
392
+ in out TAllParams,
393
+ in out TLoaderDeps,
394
+ > {
395
+ routeId: TRouteId
396
+ search: TFullSearchSchema
397
+ params: TAllParams
398
+ loaderDeps: TLoaderDeps
399
+ }
400
+
401
+ export type MakeRemountDepsOptionsUnion<
402
+ TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
403
+ > =
404
+ ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute
405
+ ? TRoute extends any
406
+ ? RemountDepsOptions<
407
+ TRoute['id'],
408
+ TRoute['types']['fullSearchSchema'],
409
+ TRoute['types']['allParams'],
410
+ TRoute['types']['loaderDeps']
411
+ >
412
+ : never
413
+ : never
414
+
415
+ export interface RouteTypes<
416
+ in out TRegister,
417
+ in out TParentRoute extends AnyRoute,
418
+ in out TPath extends string,
419
+ in out TFullPath extends string,
420
+ in out TCustomId extends string,
421
+ in out TId extends string,
422
+ in out TSearchValidator,
423
+ in out TParams,
424
+ in out TRouterContext,
425
+ in out TRouteContextFn,
426
+ in out TBeforeLoadFn,
427
+ in out TLoaderDeps,
428
+ in out TLoaderFn,
429
+ in out TChildren,
430
+ in out TFileRouteTypes,
431
+ in out TSSR,
432
+ in out TServerMiddlewares,
433
+ in out THandlers,
434
+ > {
435
+ parentRoute: TParentRoute
436
+ path: TPath
437
+ to: TrimPathRight<TFullPath>
438
+ fullPath: TFullPath
439
+ customId: TCustomId
440
+ id: TId
441
+ searchSchema: ResolveValidatorOutput<TSearchValidator>
442
+ searchSchemaInput: ResolveSearchValidatorInput<TSearchValidator>
443
+ searchValidator: TSearchValidator
444
+ fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>
445
+ fullSearchSchemaInput: ResolveFullSearchSchemaInput<
446
+ TParentRoute,
447
+ TSearchValidator
448
+ >
449
+ params: TParams
450
+ allParams: ResolveAllParamsFromParent<TParentRoute, TParams>
451
+ routerContext: TRouterContext
452
+ routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>
453
+ routeContextFn: TRouteContextFn
454
+ beforeLoadFn: TBeforeLoadFn
455
+ allContext: ResolveAllContext<
456
+ TParentRoute,
457
+ TRouterContext,
458
+ TRouteContextFn,
459
+ TBeforeLoadFn
460
+ >
461
+ children: TChildren
462
+ loaderData: ResolveLoaderData<TLoaderFn>
463
+ loaderDeps: TLoaderDeps
464
+ fileRouteTypes: TFileRouteTypes
465
+ ssr: ResolveSSR<TSSR>
466
+ allSsr: ResolveAllSSR<TParentRoute, TSSR>
467
+ }
468
+
469
+ export type ResolveSSR<TSSR> = TSSR extends (...args: ReadonlyArray<any>) => any
470
+ ? LooseReturnType<TSSR>
471
+ : TSSR
472
+
473
+ export type ResolveAllSSR<
474
+ TParentRoute extends AnyRoute,
475
+ TSSR,
476
+ > = unknown extends TParentRoute
477
+ ? ResolveSSR<TSSR>
478
+ : unknown extends TSSR
479
+ ? TParentRoute['types']['allSsr']
480
+ : ResolveSSR<TSSR>
481
+
482
+ export type ResolveFullPath<
483
+ TParentRoute extends AnyRoute,
484
+ TPath extends string,
485
+ TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,
486
+ > = TPrefixed extends RootRouteId ? '/' : TPrefixed
487
+
488
+ export interface RouteExtensions<in out TId, in out TFullPath> {
489
+ id: TId
490
+ fullPath: TFullPath
491
+ }
492
+
493
+ export type RouteLazyFn<TRoute extends AnyRoute> = (
494
+ lazyFn: () => Promise<LazyRoute<TRoute>>,
495
+ ) => TRoute
496
+
497
+ export type RouteAddChildrenFn<
498
+ in out TRegister,
499
+ in out TParentRoute extends AnyRoute,
500
+ in out TPath extends string,
501
+ in out TFullPath extends string,
502
+ in out TCustomId extends string,
503
+ in out TId extends string,
504
+ in out TSearchValidator,
505
+ in out TParams,
506
+ in out TRouterContext,
507
+ in out TRouteContextFn,
508
+ in out TBeforeLoadFn,
509
+ in out TLoaderDeps extends Record<string, any>,
510
+ in out TLoaderFn,
511
+ in out TFileRouteTypes,
512
+ in out TSSR,
513
+ in out TServerMiddlewares,
514
+ in out THandlers,
515
+ > = <const TNewChildren>(
516
+ children: Constrain<
517
+ TNewChildren,
518
+ ReadonlyArray<AnyRoute> | Record<string, AnyRoute>
519
+ >,
520
+ ) => Route<
521
+ TRegister,
522
+ TParentRoute,
523
+ TPath,
524
+ TFullPath,
525
+ TCustomId,
526
+ TId,
527
+ TSearchValidator,
528
+ TParams,
529
+ TRouterContext,
530
+ TRouteContextFn,
531
+ TBeforeLoadFn,
532
+ TLoaderDeps,
533
+ TLoaderFn,
534
+ TNewChildren,
535
+ TFileRouteTypes,
536
+ TSSR,
537
+ TServerMiddlewares,
538
+ THandlers
539
+ >
540
+
541
+ export type RouteAddFileChildrenFn<
542
+ in out TRegister,
543
+ in out TParentRoute extends AnyRoute,
544
+ in out TPath extends string,
545
+ in out TFullPath extends string,
546
+ in out TCustomId extends string,
547
+ in out TId extends string,
548
+ in out TSearchValidator,
549
+ in out TParams,
550
+ in out TRouterContext,
551
+ in out TRouteContextFn,
552
+ in out TBeforeLoadFn,
553
+ in out TLoaderDeps extends Record<string, any>,
554
+ in out TLoaderFn,
555
+ in out TFileRouteTypes,
556
+ in out TSSR,
557
+ in out TServerMiddlewares,
558
+ in out THandlers,
559
+ > = <const TNewChildren>(
560
+ children: TNewChildren,
561
+ ) => Route<
562
+ TRegister,
563
+ TParentRoute,
564
+ TPath,
565
+ TFullPath,
566
+ TCustomId,
567
+ TId,
568
+ TSearchValidator,
569
+ TParams,
570
+ TRouterContext,
571
+ TRouteContextFn,
572
+ TBeforeLoadFn,
573
+ TLoaderDeps,
574
+ TLoaderFn,
575
+ TNewChildren,
576
+ TFileRouteTypes,
577
+ TSSR,
578
+ TServerMiddlewares,
579
+ THandlers
580
+ >
581
+
582
+ export type RouteAddFileTypesFn<
583
+ TRegister,
584
+ TParentRoute extends AnyRoute,
585
+ TPath extends string,
586
+ TFullPath extends string,
587
+ TCustomId extends string,
588
+ TId extends string,
589
+ TSearchValidator,
590
+ TParams,
591
+ TRouterContext,
592
+ TRouteContextFn,
593
+ TBeforeLoadFn,
594
+ TLoaderDeps extends Record<string, any>,
595
+ TLoaderFn,
596
+ TChildren,
597
+ TSSR,
598
+ TServerMiddlewares,
599
+ THandlers,
600
+ > = <TNewFileRouteTypes>() => Route<
601
+ TRegister,
602
+ TParentRoute,
603
+ TPath,
604
+ TFullPath,
605
+ TCustomId,
606
+ TId,
607
+ TSearchValidator,
608
+ TParams,
609
+ TRouterContext,
610
+ TRouteContextFn,
611
+ TBeforeLoadFn,
612
+ TLoaderDeps,
613
+ TLoaderFn,
614
+ TChildren,
615
+ TNewFileRouteTypes,
616
+ TSSR,
617
+ TServerMiddlewares,
618
+ THandlers
619
+ >
620
+
621
+ export interface Route<
622
+ in out TRegister,
623
+ in out TParentRoute extends AnyRoute,
624
+ in out TPath extends string,
625
+ in out TFullPath extends string,
626
+ in out TCustomId extends string,
627
+ in out TId extends string,
628
+ in out TSearchValidator,
629
+ in out TParams,
630
+ in out TRouterContext,
631
+ in out TRouteContextFn,
632
+ in out TBeforeLoadFn,
633
+ in out TLoaderDeps extends Record<string, any>,
634
+ in out TLoaderFn,
635
+ in out TChildren,
636
+ in out TFileRouteTypes,
637
+ in out TSSR,
638
+ in out TServerMiddlewares,
639
+ in out THandlers,
640
+ > extends RouteExtensions<TId, TFullPath> {
641
+ path: TPath
642
+ parentRoute: TParentRoute
643
+ children?: TChildren
644
+ types: RouteTypes<
645
+ TRegister,
646
+ TParentRoute,
647
+ TPath,
648
+ TFullPath,
649
+ TCustomId,
650
+ TId,
651
+ TSearchValidator,
652
+ TParams,
653
+ TRouterContext,
654
+ TRouteContextFn,
655
+ TBeforeLoadFn,
656
+ TLoaderDeps,
657
+ TLoaderFn,
658
+ TChildren,
659
+ TFileRouteTypes,
660
+ TSSR,
661
+ TServerMiddlewares,
662
+ THandlers
663
+ >
664
+ options: RouteOptions<
665
+ TRegister,
666
+ TParentRoute,
667
+ TId,
668
+ TCustomId,
669
+ TFullPath,
670
+ TPath,
671
+ TSearchValidator,
672
+ TParams,
673
+ TLoaderDeps,
674
+ TLoaderFn,
675
+ TRouterContext,
676
+ TRouteContextFn,
677
+ TBeforeLoadFn,
678
+ TSSR,
679
+ TServerMiddlewares,
680
+ THandlers
681
+ >
682
+ isRoot: TParentRoute extends AnyRoute ? true : false
683
+ /** @internal */
684
+ _componentsPromise?: Promise<void>
685
+ /** @internal */
686
+ _componentsLoaded?: boolean
687
+ lazyFn?: () => Promise<
688
+ LazyRoute<
689
+ Route<
690
+ TRegister,
691
+ TParentRoute,
692
+ TPath,
693
+ TFullPath,
694
+ TCustomId,
695
+ TId,
696
+ TSearchValidator,
697
+ TParams,
698
+ TRouterContext,
699
+ TRouteContextFn,
700
+ TBeforeLoadFn,
701
+ TLoaderDeps,
702
+ TLoaderFn,
703
+ TChildren,
704
+ TFileRouteTypes,
705
+ TSSR,
706
+ TServerMiddlewares,
707
+ THandlers
708
+ >
709
+ >
710
+ >
711
+ /** @internal */
712
+ _lazyPromise?: Promise<void>
713
+ /** @internal */
714
+ _lazyLoaded?: boolean
715
+ rank: number
716
+ to: TrimPathRight<TFullPath>
717
+ init: (opts: { originalIndex: number }) => void
718
+ update: (
719
+ options: UpdatableRouteOptions<
720
+ TParentRoute,
721
+ TCustomId,
722
+ TFullPath,
723
+ TParams,
724
+ TSearchValidator,
725
+ TLoaderFn,
726
+ TLoaderDeps,
727
+ TRouterContext,
728
+ TRouteContextFn,
729
+ TBeforeLoadFn
730
+ >,
731
+ ) => this
732
+ lazy: RouteLazyFn<
733
+ Route<
734
+ TRegister,
735
+ TParentRoute,
736
+ TPath,
737
+ TFullPath,
738
+ TCustomId,
739
+ TId,
740
+ TSearchValidator,
741
+ TParams,
742
+ TRouterContext,
743
+ TRouteContextFn,
744
+ TBeforeLoadFn,
745
+ TLoaderDeps,
746
+ TLoaderFn,
747
+ TChildren,
748
+ TFileRouteTypes,
749
+ TSSR,
750
+ TServerMiddlewares,
751
+ THandlers
752
+ >
753
+ >
754
+ addChildren: RouteAddChildrenFn<
755
+ TRegister,
756
+ TParentRoute,
757
+ TPath,
758
+ TFullPath,
759
+ TCustomId,
760
+ TId,
761
+ TSearchValidator,
762
+ TParams,
763
+ TRouterContext,
764
+ TRouteContextFn,
765
+ TBeforeLoadFn,
766
+ TLoaderDeps,
767
+ TLoaderFn,
768
+ TFileRouteTypes,
769
+ TSSR,
770
+ TServerMiddlewares,
771
+ THandlers
772
+ >
773
+ _addFileChildren: RouteAddFileChildrenFn<
774
+ TRegister,
775
+ TParentRoute,
776
+ TPath,
777
+ TFullPath,
778
+ TCustomId,
779
+ TId,
780
+ TSearchValidator,
781
+ TParams,
782
+ TRouterContext,
783
+ TRouteContextFn,
784
+ TBeforeLoadFn,
785
+ TLoaderDeps,
786
+ TLoaderFn,
787
+ TFileRouteTypes,
788
+ TSSR,
789
+ TServerMiddlewares,
790
+ THandlers
791
+ >
792
+ _addFileTypes: RouteAddFileTypesFn<
793
+ TRegister,
794
+ TParentRoute,
795
+ TPath,
796
+ TFullPath,
797
+ TCustomId,
798
+ TId,
799
+ TSearchValidator,
800
+ TParams,
801
+ TRouterContext,
802
+ TRouteContextFn,
803
+ TBeforeLoadFn,
804
+ TLoaderDeps,
805
+ TLoaderFn,
806
+ TChildren,
807
+ TSSR,
808
+ TServerMiddlewares,
809
+ THandlers
810
+ >
811
+ /**
812
+ * Create a redirect with `from` automatically set to this route's path.
813
+ * Enables relative redirects like `Route.redirect({ to: './overview' })`.
814
+ * @param opts Redirect options (same as `redirect()` but without `from`)
815
+ * @returns A redirect Response that can be thrown from loaders/beforeLoad
816
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/redirectFunction
817
+ */
818
+ redirect: RedirectFnRoute<TFullPath>
819
+ }
820
+
821
+ export type AnyRoute = Route<
822
+ any,
823
+ any,
824
+ any,
825
+ any,
826
+ any,
827
+ any,
828
+ any,
829
+ any,
830
+ any,
831
+ any,
832
+ any,
833
+ any,
834
+ any,
835
+ any,
836
+ any,
837
+ any,
838
+ any,
839
+ any
840
+ >
841
+
842
+ export type AnyRouteWithContext<TContext> = AnyRoute & {
843
+ types: { allContext: TContext }
844
+ }
845
+
846
+ export type RouteOptions<
847
+ TRegister,
848
+ TParentRoute extends AnyRoute = AnyRoute,
849
+ TId extends string = string,
850
+ TCustomId extends string = string,
851
+ TFullPath extends string = string,
852
+ TPath extends string = string,
853
+ TSearchValidator = undefined,
854
+ TParams = AnyPathParams,
855
+ TLoaderDeps extends Record<string, any> = {},
856
+ TLoaderFn = undefined,
857
+ TRouterContext = {},
858
+ TRouteContextFn = AnyContext,
859
+ TBeforeLoadFn = AnyContext,
860
+ TSSR = unknown,
861
+ TServerMiddlewares = unknown,
862
+ THandlers = undefined,
863
+ > = BaseRouteOptions<
864
+ TRegister,
865
+ TParentRoute,
866
+ TId,
867
+ TCustomId,
868
+ TPath,
869
+ TSearchValidator,
870
+ TParams,
871
+ TLoaderDeps,
872
+ TLoaderFn,
873
+ TRouterContext,
874
+ TRouteContextFn,
875
+ TBeforeLoadFn,
876
+ TSSR,
877
+ TServerMiddlewares,
878
+ THandlers
879
+ > &
880
+ UpdatableRouteOptions<
881
+ NoInfer<TParentRoute>,
882
+ NoInfer<TCustomId>,
883
+ NoInfer<TFullPath>,
884
+ NoInfer<TParams>,
885
+ NoInfer<TSearchValidator>,
886
+ NoInfer<TLoaderFn>,
887
+ NoInfer<TLoaderDeps>,
888
+ NoInfer<TRouterContext>,
889
+ NoInfer<TRouteContextFn>,
890
+ NoInfer<TBeforeLoadFn>
891
+ >
892
+
893
+ export type RouteContextFn<
894
+ in out TParentRoute extends AnyRoute,
895
+ in out TSearchValidator,
896
+ in out TParams,
897
+ in out TRouterContext,
898
+ in out TRouteId,
899
+ > = (
900
+ ctx: RouteContextOptions<
901
+ TParentRoute,
902
+ TSearchValidator,
903
+ TParams,
904
+ TRouterContext,
905
+ TRouteId
906
+ >,
907
+ ) => any
908
+
909
+ export type FileBaseRouteOptions<
910
+ TRegister,
911
+ TParentRoute extends AnyRoute = AnyRoute,
912
+ TId extends string = string,
913
+ TPath extends string = string,
914
+ TSearchValidator = undefined,
915
+ TParams = {},
916
+ TLoaderDeps extends Record<string, any> = {},
917
+ TLoaderFn = undefined,
918
+ TRouterContext = {},
919
+ TRouteContextFn = AnyContext,
920
+ TBeforeLoadFn = AnyContext,
921
+ TRemountDepsFn = AnyContext,
922
+ TSSR = unknown,
923
+ TServerMiddlewares = unknown,
924
+ THandlers = undefined,
925
+ > = ParamsOptions<TPath, TParams> &
926
+ FilebaseRouteOptionsInterface<
927
+ TRegister,
928
+ TParentRoute,
929
+ TId,
930
+ TPath,
931
+ TSearchValidator,
932
+ TParams,
933
+ TLoaderDeps,
934
+ TLoaderFn,
935
+ TRouterContext,
936
+ TRouteContextFn,
937
+ TBeforeLoadFn,
938
+ TRemountDepsFn,
939
+ TSSR,
940
+ TServerMiddlewares,
941
+ THandlers
942
+ >
943
+
944
+ export interface FilebaseRouteOptionsInterface<
945
+ TRegister,
946
+ TParentRoute extends AnyRoute = AnyRoute,
947
+ TId extends string = string,
948
+ TPath extends string = string,
949
+ TSearchValidator = undefined,
950
+ TParams = {},
951
+ TLoaderDeps extends Record<string, any> = {},
952
+ TLoaderFn = undefined,
953
+ TRouterContext = {},
954
+ TRouteContextFn = AnyContext,
955
+ TBeforeLoadFn = AnyContext,
956
+ TRemountDepsFn = AnyContext,
957
+ TSSR = unknown,
958
+ TServerMiddlewares = unknown,
959
+ THandlers = undefined,
960
+ > {
961
+ validateSearch?: Constrain<TSearchValidator, AnyValidator, DefaultValidator>
962
+
963
+ shouldReload?:
964
+ | boolean
965
+ | ((
966
+ match: LoaderFnContext<
967
+ TRegister,
968
+ TParentRoute,
969
+ TId,
970
+ TParams,
971
+ TLoaderDeps,
972
+ TRouterContext,
973
+ TRouteContextFn,
974
+ TBeforeLoadFn,
975
+ TServerMiddlewares,
976
+ THandlers
977
+ >,
978
+ ) => any)
979
+
980
+ context?: Constrain<
981
+ TRouteContextFn,
982
+ (
983
+ ctx: RouteContextOptions<
984
+ TParentRoute,
985
+ TParams,
986
+ TRouterContext,
987
+ TLoaderDeps,
988
+ TId
989
+ >,
990
+ ) => any
991
+ >
992
+
993
+ ssr?: Constrain<
994
+ TSSR,
995
+ | undefined
996
+ | SSROption
997
+ | ((
998
+ ctx: SsrContextOptions<TParentRoute, TSearchValidator, TParams>,
999
+ ) => Awaitable<undefined | SSROption>)
1000
+ >
1001
+
1002
+ // This async function is called before a route is loaded.
1003
+ // If an error is thrown here, the route's loader will not be called.
1004
+ // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.
1005
+ // If thrown during a preload event, the error will be logged to the console.
1006
+ beforeLoad?: Constrain<
1007
+ TBeforeLoadFn,
1008
+ (
1009
+ ctx: BeforeLoadContextOptions<
1010
+ TRegister,
1011
+ TParentRoute,
1012
+ TSearchValidator,
1013
+ TParams,
1014
+ TRouterContext,
1015
+ TRouteContextFn,
1016
+ TId,
1017
+ TServerMiddlewares,
1018
+ THandlers
1019
+ >,
1020
+ ) => ValidateSerializableLifecycleResult<
1021
+ TRegister,
1022
+ TParentRoute,
1023
+ TSSR,
1024
+ TBeforeLoadFn
1025
+ >
1026
+ >
1027
+
1028
+ loaderDeps?: (
1029
+ opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,
1030
+ ) => TLoaderDeps
1031
+
1032
+ remountDeps?: Constrain<
1033
+ TRemountDepsFn,
1034
+ (
1035
+ opt: RemountDepsOptions<
1036
+ TId,
1037
+ ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
1038
+ Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,
1039
+ TLoaderDeps
1040
+ >,
1041
+ ) => any
1042
+ >
1043
+
1044
+ loader?: Constrain<
1045
+ TLoaderFn,
1046
+ | RouteLoaderFn<
1047
+ TRegister,
1048
+ TParentRoute,
1049
+ TId,
1050
+ TParams,
1051
+ TLoaderDeps,
1052
+ TRouterContext,
1053
+ TRouteContextFn,
1054
+ TBeforeLoadFn,
1055
+ TServerMiddlewares,
1056
+ THandlers
1057
+ >
1058
+ | RouteLoaderObject<
1059
+ TRegister,
1060
+ TParentRoute,
1061
+ TId,
1062
+ TParams,
1063
+ TLoaderDeps,
1064
+ TRouterContext,
1065
+ TRouteContextFn,
1066
+ TBeforeLoadFn,
1067
+ TServerMiddlewares,
1068
+ THandlers
1069
+ >
1070
+ >
1071
+ }
1072
+
1073
+ export type BaseRouteOptions<
1074
+ TRegister,
1075
+ TParentRoute extends AnyRoute = AnyRoute,
1076
+ TId extends string = string,
1077
+ TCustomId extends string = string,
1078
+ TPath extends string = string,
1079
+ TSearchValidator = undefined,
1080
+ TParams = {},
1081
+ TLoaderDeps extends Record<string, any> = {},
1082
+ TLoaderFn = undefined,
1083
+ TRouterContext = {},
1084
+ TRouteContextFn = AnyContext,
1085
+ TBeforeLoadFn = AnyContext,
1086
+ TSSR = unknown,
1087
+ TServerMiddlewares = unknown,
1088
+ THandlers = undefined,
1089
+ > = RoutePathOptions<TCustomId, TPath> &
1090
+ FileBaseRouteOptions<
1091
+ TRegister,
1092
+ TParentRoute,
1093
+ TId,
1094
+ TPath,
1095
+ TSearchValidator,
1096
+ TParams,
1097
+ TLoaderDeps,
1098
+ TLoaderFn,
1099
+ TRouterContext,
1100
+ TRouteContextFn,
1101
+ TBeforeLoadFn,
1102
+ AnyContext,
1103
+ TSSR,
1104
+ TServerMiddlewares,
1105
+ THandlers
1106
+ > & {
1107
+ getParentRoute: () => TParentRoute
1108
+ }
1109
+
1110
+ export interface ContextOptions<
1111
+ in out TParentRoute extends AnyRoute,
1112
+ in out TParams,
1113
+ in out TRouteId,
1114
+ > {
1115
+ abortController: AbortController
1116
+ preload: boolean
1117
+ params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>
1118
+ location: ParsedLocation
1119
+ /**
1120
+ * @deprecated Use `throw redirect({ to: '/somewhere' })` instead
1121
+ **/
1122
+ navigate: NavigateFn
1123
+ buildLocation: BuildLocationFn
1124
+ cause: 'preload' | 'enter' | 'stay'
1125
+ matches: Array<MakeRouteMatchUnion>
1126
+ routeId: TRouteId
1127
+ }
1128
+
1129
+ export interface RouteContextOptions<
1130
+ in out TParentRoute extends AnyRoute,
1131
+ in out TParams,
1132
+ in out TRouterContext,
1133
+ in out TLoaderDeps,
1134
+ in out TRouteId,
1135
+ > extends ContextOptions<TParentRoute, TParams, TRouteId> {
1136
+ deps: TLoaderDeps
1137
+ context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>
1138
+ }
1139
+
1140
+ export interface SsrContextOptions<
1141
+ in out TParentRoute extends AnyRoute,
1142
+ in out TSearchValidator,
1143
+ in out TParams,
1144
+ > {
1145
+ params:
1146
+ | {
1147
+ status: 'success'
1148
+ value: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>
1149
+ }
1150
+ | { status: 'error'; error: unknown }
1151
+ search:
1152
+ | {
1153
+ status: 'success'
1154
+ value: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
1155
+ }
1156
+ | { status: 'error'; error: unknown }
1157
+ location: ParsedLocation
1158
+ matches: Array<MakePreValidationErrorHandlingRouteMatchUnion>
1159
+ }
1160
+
1161
+ export interface DefaultBeforeLoadContextOptionsExtensions<
1162
+ in out TRegister,
1163
+ in out TParentRoute extends AnyRoute,
1164
+ in out TSearchValidator,
1165
+ in out TParams,
1166
+ in out TRouterContext,
1167
+ in out TRouteContextFn,
1168
+ in out TRouteId,
1169
+ in out TServerMiddlewares,
1170
+ in out THandlers,
1171
+ > {}
1172
+
1173
+ export interface BeforeLoadContextOptionsExtensions<
1174
+ in out TRegister,
1175
+ in out TParentRoute extends AnyRoute,
1176
+ in out TSearchValidator,
1177
+ in out TParams,
1178
+ in out TRouterContext,
1179
+ in out TRouteContextFn,
1180
+ in out TRouteId,
1181
+ in out TServerMiddlewares,
1182
+ in out THandlers,
1183
+ > extends DefaultBeforeLoadContextOptionsExtensions<
1184
+ TRegister,
1185
+ TParentRoute,
1186
+ TSearchValidator,
1187
+ TParams,
1188
+ TRouterContext,
1189
+ TRouteContextFn,
1190
+ TRouteId,
1191
+ TServerMiddlewares,
1192
+ THandlers
1193
+ > {}
1194
+
1195
+ export interface BeforeLoadContextOptions<
1196
+ in out TRegister,
1197
+ in out TParentRoute extends AnyRoute,
1198
+ in out TSearchValidator,
1199
+ in out TParams,
1200
+ in out TRouterContext,
1201
+ in out TRouteContextFn,
1202
+ in out TRouteId,
1203
+ in out TServerMiddlewares,
1204
+ in out THandlers,
1205
+ >
1206
+ extends
1207
+ ContextOptions<TParentRoute, TParams, TRouteId>,
1208
+ FullSearchSchemaOption<TParentRoute, TSearchValidator>,
1209
+ BeforeLoadContextOptionsExtensions<
1210
+ TRegister,
1211
+ TParentRoute,
1212
+ TSearchValidator,
1213
+ TParams,
1214
+ TRouterContext,
1215
+ TRouteContextFn,
1216
+ TRouteId,
1217
+ TServerMiddlewares,
1218
+ THandlers
1219
+ > {
1220
+ context: Expand<
1221
+ BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>
1222
+ >
1223
+ }
1224
+
1225
+ type AssetFnContextOptions<
1226
+ in out TRouteId,
1227
+ in out TFullPath,
1228
+ in out TParentRoute extends AnyRoute,
1229
+ in out TParams,
1230
+ in out TSearchValidator,
1231
+ in out TLoaderFn,
1232
+ in out TRouterContext,
1233
+ in out TRouteContextFn,
1234
+ in out TBeforeLoadFn,
1235
+ in out TLoaderDeps,
1236
+ > = {
1237
+ ssr?: {
1238
+ nonce?: string
1239
+ }
1240
+ matches: Array<
1241
+ RouteMatch<
1242
+ TRouteId,
1243
+ TFullPath,
1244
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
1245
+ ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
1246
+ ResolveLoaderData<TLoaderFn>,
1247
+ ResolveAllContext<
1248
+ TParentRoute,
1249
+ TRouterContext,
1250
+ TRouteContextFn,
1251
+ TBeforeLoadFn
1252
+ >,
1253
+ TLoaderDeps
1254
+ >
1255
+ >
1256
+ match: RouteMatch<
1257
+ TRouteId,
1258
+ TFullPath,
1259
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
1260
+ ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
1261
+ ResolveLoaderData<TLoaderFn>,
1262
+ ResolveAllContext<
1263
+ TParentRoute,
1264
+ TRouterContext,
1265
+ TRouteContextFn,
1266
+ TBeforeLoadFn
1267
+ >,
1268
+ TLoaderDeps
1269
+ >
1270
+ params: ResolveAllParamsFromParent<TParentRoute, TParams>
1271
+ loaderData?: ResolveLoaderData<TLoaderFn>
1272
+ }
1273
+
1274
+ export interface DefaultUpdatableRouteOptionsExtensions {
1275
+ component?: unknown
1276
+ errorComponent?: unknown
1277
+ notFoundComponent?: unknown
1278
+ pendingComponent?: unknown
1279
+ }
1280
+
1281
+ export interface UpdatableRouteOptionsExtensions extends DefaultUpdatableRouteOptionsExtensions {}
1282
+
1283
+ export interface UpdatableRouteOptions<
1284
+ in out TParentRoute extends AnyRoute,
1285
+ in out TRouteId,
1286
+ in out TFullPath,
1287
+ in out TParams,
1288
+ in out TSearchValidator,
1289
+ in out TLoaderFn,
1290
+ in out TLoaderDeps,
1291
+ in out TRouterContext,
1292
+ in out TRouteContextFn,
1293
+ in out TBeforeLoadFn,
1294
+ >
1295
+ extends UpdatableStaticRouteOption, UpdatableRouteOptionsExtensions {
1296
+ /**
1297
+ * Options to control route matching behavior with runtime code.
1298
+ *
1299
+ * @experimental 🚧 this feature is subject to change
1300
+ *
1301
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType
1302
+ */
1303
+ skipRouteOnParseError?: {
1304
+ /**
1305
+ * If `true`, skip this route during matching if `params.parse` fails.
1306
+ *
1307
+ * Without this option, a `/$param` route could match *any* value for `param`,
1308
+ * and only later during the route lifecycle would `params.parse` run and potentially
1309
+ * show the `errorComponent` if validation failed.
1310
+ *
1311
+ * With this option enabled, the route will only match if `params.parse` succeeds.
1312
+ * If it fails, the router will continue trying to match other routes, potentially
1313
+ * finding a different route that works, or ultimately showing the `notFoundComponent`.
1314
+ *
1315
+ * @default false
1316
+ */
1317
+ params?: boolean
1318
+ /**
1319
+ * In cases where multiple routes would need to run `params.parse` during matching
1320
+ * to determine which route to pick, this priority number can be used as a tie-breaker
1321
+ * for which route to try first. Higher number = higher priority.
1322
+ *
1323
+ * @default 0
1324
+ */
1325
+ priority?: number
1326
+ }
1327
+ /**
1328
+ * If true, this route will be matched as case-sensitive
1329
+ *
1330
+ * @default false
1331
+ */
1332
+ caseSensitive?: boolean
1333
+ /**
1334
+ * If true, this route will be forcefully wrapped in a suspense boundary
1335
+ */
1336
+ wrapInSuspense?: boolean
1337
+ // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
1338
+
1339
+ pendingMs?: number
1340
+ pendingMinMs?: number
1341
+ staleTime?: number
1342
+ gcTime?: number
1343
+ preload?: boolean
1344
+ preloadStaleTime?: number
1345
+ preloadGcTime?: number
1346
+ search?: {
1347
+ middlewares?: Array<
1348
+ SearchMiddleware<
1349
+ ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>
1350
+ >
1351
+ >
1352
+ }
1353
+ /**
1354
+ @deprecated Use search.middlewares instead
1355
+ */
1356
+ preSearchFilters?: Array<
1357
+ SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
1358
+ >
1359
+ /**
1360
+ @deprecated Use search.middlewares instead
1361
+ */
1362
+ postSearchFilters?: Array<
1363
+ SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>
1364
+ >
1365
+ onCatch?: (error: Error) => void
1366
+ onError?: (err: any) => void
1367
+ // These functions are called as route matches are loaded, stick around and leave the active
1368
+ // matches
1369
+ onEnter?: (
1370
+ match: RouteMatch<
1371
+ TRouteId,
1372
+ TFullPath,
1373
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
1374
+ ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
1375
+ ResolveLoaderData<TLoaderFn>,
1376
+ ResolveAllContext<
1377
+ TParentRoute,
1378
+ TRouterContext,
1379
+ TRouteContextFn,
1380
+ TBeforeLoadFn
1381
+ >,
1382
+ TLoaderDeps
1383
+ >,
1384
+ ) => void
1385
+ onStay?: (
1386
+ match: RouteMatch<
1387
+ TRouteId,
1388
+ TFullPath,
1389
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
1390
+ ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
1391
+ ResolveLoaderData<TLoaderFn>,
1392
+ ResolveAllContext<
1393
+ TParentRoute,
1394
+ TRouterContext,
1395
+ TRouteContextFn,
1396
+ TBeforeLoadFn
1397
+ >,
1398
+ TLoaderDeps
1399
+ >,
1400
+ ) => void
1401
+ onLeave?: (
1402
+ match: RouteMatch<
1403
+ TRouteId,
1404
+ TFullPath,
1405
+ ResolveAllParamsFromParent<TParentRoute, TParams>,
1406
+ ResolveFullSearchSchema<TParentRoute, TSearchValidator>,
1407
+ ResolveLoaderData<TLoaderFn>,
1408
+ ResolveAllContext<
1409
+ TParentRoute,
1410
+ TRouterContext,
1411
+ TRouteContextFn,
1412
+ TBeforeLoadFn
1413
+ >,
1414
+ TLoaderDeps
1415
+ >,
1416
+ ) => void
1417
+ headers?: (
1418
+ ctx: AssetFnContextOptions<
1419
+ TRouteId,
1420
+ TFullPath,
1421
+ TParentRoute,
1422
+ TParams,
1423
+ TSearchValidator,
1424
+ TLoaderFn,
1425
+ TRouterContext,
1426
+ TRouteContextFn,
1427
+ TBeforeLoadFn,
1428
+ TLoaderDeps
1429
+ >,
1430
+ ) => Awaitable<Record<string, string> | undefined>
1431
+ head?: (
1432
+ ctx: AssetFnContextOptions<
1433
+ TRouteId,
1434
+ TFullPath,
1435
+ TParentRoute,
1436
+ TParams,
1437
+ TSearchValidator,
1438
+ TLoaderFn,
1439
+ TRouterContext,
1440
+ TRouteContextFn,
1441
+ TBeforeLoadFn,
1442
+ TLoaderDeps
1443
+ >,
1444
+ ) => Awaitable<{
1445
+ links?: AnyRouteMatch['links']
1446
+ scripts?: AnyRouteMatch['headScripts']
1447
+ meta?: AnyRouteMatch['meta']
1448
+ styles?: AnyRouteMatch['styles']
1449
+ }>
1450
+ scripts?: (
1451
+ ctx: AssetFnContextOptions<
1452
+ TRouteId,
1453
+ TFullPath,
1454
+ TParentRoute,
1455
+ TParams,
1456
+ TSearchValidator,
1457
+ TLoaderFn,
1458
+ TRouterContext,
1459
+ TRouteContextFn,
1460
+ TBeforeLoadFn,
1461
+ TLoaderDeps
1462
+ >,
1463
+ ) => Awaitable<AnyRouteMatch['scripts']>
1464
+ codeSplitGroupings?: Array<
1465
+ Array<
1466
+ | 'loader'
1467
+ | 'component'
1468
+ | 'pendingComponent'
1469
+ | 'notFoundComponent'
1470
+ | 'errorComponent'
1471
+ >
1472
+ >
1473
+ }
1474
+
1475
+ export type RouteLoaderFn<
1476
+ in out TRegister,
1477
+ in out TParentRoute extends AnyRoute = AnyRoute,
1478
+ in out TId extends string = string,
1479
+ in out TParams = {},
1480
+ in out TLoaderDeps = {},
1481
+ in out TRouterContext = {},
1482
+ in out TRouteContextFn = AnyContext,
1483
+ in out TBeforeLoadFn = AnyContext,
1484
+ in out TServerMiddlewares = unknown,
1485
+ in out THandlers = undefined,
1486
+ > = (
1487
+ match: LoaderFnContext<
1488
+ TRegister,
1489
+ TParentRoute,
1490
+ TId,
1491
+ TParams,
1492
+ TLoaderDeps,
1493
+ TRouterContext,
1494
+ TRouteContextFn,
1495
+ TBeforeLoadFn,
1496
+ TServerMiddlewares,
1497
+ THandlers
1498
+ >,
1499
+ ) => any
1500
+
1501
+ export type LoaderStaleReloadMode = 'background' | 'blocking'
1502
+
1503
+ export type RouteLoaderEntry<
1504
+ TRegister,
1505
+ TParentRoute extends AnyRoute = AnyRoute,
1506
+ TId extends string = string,
1507
+ TParams = {},
1508
+ TLoaderDeps = {},
1509
+ TRouterContext = {},
1510
+ TRouteContextFn = AnyContext,
1511
+ TBeforeLoadFn = AnyContext,
1512
+ TServerMiddlewares = unknown,
1513
+ THandlers = undefined,
1514
+ > =
1515
+ | RouteLoaderFn<
1516
+ TRegister,
1517
+ TParentRoute,
1518
+ TId,
1519
+ TParams,
1520
+ TLoaderDeps,
1521
+ TRouterContext,
1522
+ TRouteContextFn,
1523
+ TBeforeLoadFn,
1524
+ TServerMiddlewares,
1525
+ THandlers
1526
+ >
1527
+ | RouteLoaderObject<
1528
+ TRegister,
1529
+ TParentRoute,
1530
+ TId,
1531
+ TParams,
1532
+ TLoaderDeps,
1533
+ TRouterContext,
1534
+ TRouteContextFn,
1535
+ TBeforeLoadFn,
1536
+ TServerMiddlewares,
1537
+ THandlers
1538
+ >
1539
+
1540
+ export interface LoaderFnContext<
1541
+ in out TRegister = unknown,
1542
+ in out TParentRoute extends AnyRoute = AnyRoute,
1543
+ in out TId extends string = string,
1544
+ in out TParams = {},
1545
+ in out TLoaderDeps = {},
1546
+ in out TRouterContext = {},
1547
+ in out TRouteContextFn = AnyContext,
1548
+ in out TBeforeLoadFn = AnyContext,
1549
+ in out TServerMiddlewares = unknown,
1550
+ in out THandlers = undefined,
1551
+ > extends LoaderFnContextExtensions<
1552
+ TRegister,
1553
+ TParentRoute,
1554
+ TId,
1555
+ TParams,
1556
+ TLoaderDeps,
1557
+ TRouterContext,
1558
+ TRouteContextFn,
1559
+ TBeforeLoadFn,
1560
+ TServerMiddlewares,
1561
+ THandlers
1562
+ > {
1563
+ abortController: AbortController
1564
+ preload: boolean
1565
+ params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>
1566
+ deps: TLoaderDeps
1567
+ context: Expand<
1568
+ ResolveAllContext<
1569
+ TParentRoute,
1570
+ TRouterContext,
1571
+ TRouteContextFn,
1572
+ TBeforeLoadFn
1573
+ >
1574
+ >
1575
+ location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps
1576
+ /**
1577
+ * @deprecated Use `throw redirect({ to: '/somewhere' })` instead
1578
+ **/
1579
+ navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void> | void
1580
+ // root route does not have a parent match
1581
+ parentMatchPromise: TId extends RootRouteId
1582
+ ? never
1583
+ : Promise<MakeRouteMatchFromRoute<TParentRoute>>
1584
+ cause: 'preload' | 'enter' | 'stay'
1585
+ route: AnyRoute
1586
+ }
1587
+
1588
+ export interface DefaultLoaderFnContextExtensions<
1589
+ in out TRegister = unknown,
1590
+ in out TParentRoute extends AnyRoute = AnyRoute,
1591
+ in out TId extends string = string,
1592
+ in out TParams = {},
1593
+ in out TLoaderDeps = {},
1594
+ in out TRouterContext = {},
1595
+ in out TRouteContextFn = AnyContext,
1596
+ in out TBeforeLoadFn = AnyContext,
1597
+ in out TServerMiddlewares = unknown,
1598
+ in out THandlers = undefined,
1599
+ > {}
1600
+
1601
+ export interface LoaderFnContextExtensions<
1602
+ in out TRegister = unknown,
1603
+ in out TParentRoute extends AnyRoute = AnyRoute,
1604
+ in out TId extends string = string,
1605
+ in out TParams = {},
1606
+ in out TLoaderDeps = {},
1607
+ in out TRouterContext = {},
1608
+ in out TRouteContextFn = AnyContext,
1609
+ in out TBeforeLoadFn = AnyContext,
1610
+ in out TServerMiddlewares = unknown,
1611
+ in out THandlers = undefined,
1612
+ > extends DefaultLoaderFnContextExtensions<
1613
+ TRegister,
1614
+ TParentRoute,
1615
+ TId,
1616
+ TParams,
1617
+ TLoaderDeps,
1618
+ TRouterContext,
1619
+ TRouteContextFn,
1620
+ TBeforeLoadFn,
1621
+ TServerMiddlewares,
1622
+ THandlers
1623
+ > {}
1624
+
1625
+ export interface DefaultRootRouteOptionsExtensions {
1626
+ shellComponent?: unknown
1627
+ }
1628
+
1629
+ export interface RootRouteOptionsExtensions extends DefaultRootRouteOptionsExtensions {}
1630
+
1631
+ export interface RootRouteOptions<
1632
+ TRegister = unknown,
1633
+ TSearchValidator = undefined,
1634
+ TRouterContext = {},
1635
+ TRouteContextFn = AnyContext,
1636
+ TBeforeLoadFn = AnyContext,
1637
+ TLoaderDeps extends Record<string, any> = {},
1638
+ TLoaderFn = undefined,
1639
+ TSSR = unknown,
1640
+ TServerMiddlewares = unknown,
1641
+ THandlers = undefined,
1642
+ >
1643
+ extends
1644
+ Omit<
1645
+ RouteOptions<
1646
+ TRegister,
1647
+ any, // TParentRoute
1648
+ RootRouteId, // TId
1649
+ RootRouteId, // TCustomId
1650
+ '', // TFullPath
1651
+ '', // TPath
1652
+ TSearchValidator,
1653
+ {}, // TParams
1654
+ TLoaderDeps,
1655
+ TLoaderFn,
1656
+ TRouterContext,
1657
+ TRouteContextFn,
1658
+ TBeforeLoadFn,
1659
+ TSSR,
1660
+ TServerMiddlewares,
1661
+ THandlers
1662
+ >,
1663
+ | 'path'
1664
+ | 'id'
1665
+ | 'getParentRoute'
1666
+ | 'caseSensitive'
1667
+ | 'parseParams'
1668
+ | 'stringifyParams'
1669
+ | 'params'
1670
+ >,
1671
+ RootRouteOptionsExtensions {}
1672
+
1673
+ export type RouteConstraints = {
1674
+ TParentRoute: AnyRoute
1675
+ TPath: string
1676
+ TFullPath: string
1677
+ TCustomId: string
1678
+ TId: string
1679
+ TSearchSchema: AnySchema
1680
+ TFullSearchSchema: AnySchema
1681
+ TParams: Record<string, any>
1682
+ TAllParams: Record<string, any>
1683
+ TParentContext: AnyContext
1684
+ TRouteContext: RouteContext
1685
+ TAllContext: AnyContext
1686
+ TRouterContext: AnyContext
1687
+ TChildren: unknown
1688
+ TRouteTree: AnyRoute
1689
+ }
1690
+
1691
+ export type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<
1692
+ TRouter['routeTree'],
1693
+ TId
1694
+ >['types']
1695
+
1696
+ export type RouteMask<TRouteTree extends AnyRoute> = {
1697
+ routeTree: TRouteTree
1698
+ from: RoutePaths<TRouteTree>
1699
+ to?: any
1700
+ params?: any
1701
+ search?: any
1702
+ hash?: any
1703
+ state?: any
1704
+ unmaskOnReload?: boolean
1705
+ }
1706
+
1707
+ /**
1708
+ * @deprecated Use `ErrorComponentProps` instead.
1709
+ */
1710
+ export type ErrorRouteProps = {
1711
+ error: unknown
1712
+ info?: { componentStack: string }
1713
+ reset: () => void
1714
+ }
1715
+
1716
+ export type ErrorComponentProps<TError = Error> = {
1717
+ error: TError
1718
+ info?: { componentStack: string }
1719
+ reset: () => void
1720
+ }
1721
+
1722
+ export type NotFoundRouteProps = {
1723
+ data?: unknown
1724
+ isNotFound: boolean
1725
+ routeId: RouteIds<RegisteredRouter['routeTree']>
1726
+ }
1727
+
1728
+ export class BaseRoute<
1729
+ in out TRegister = Register,
1730
+ in out TParentRoute extends AnyRoute = AnyRoute,
1731
+ in out TPath extends string = '/',
1732
+ in out TFullPath extends string = ResolveFullPath<TParentRoute, TPath>,
1733
+ in out TCustomId extends string = string,
1734
+ in out TId extends string = ResolveId<TParentRoute, TCustomId, TPath>,
1735
+ in out TSearchValidator = undefined,
1736
+ in out TParams = ResolveParams<TPath>,
1737
+ in out TRouterContext = AnyContext,
1738
+ in out TRouteContextFn = AnyContext,
1739
+ in out TBeforeLoadFn = AnyContext,
1740
+ in out TLoaderDeps extends Record<string, any> = {},
1741
+ in out TLoaderFn = undefined,
1742
+ in out TChildren = unknown,
1743
+ in out TFileRouteTypes = unknown,
1744
+ in out TSSR = unknown,
1745
+ in out TServerMiddlewares = unknown,
1746
+ in out THandlers = undefined,
1747
+ > {
1748
+ isRoot: TParentRoute extends AnyRoute ? true : false
1749
+ options: RouteOptions<
1750
+ TRegister,
1751
+ TParentRoute,
1752
+ TId,
1753
+ TCustomId,
1754
+ TFullPath,
1755
+ TPath,
1756
+ TSearchValidator,
1757
+ TParams,
1758
+ TLoaderDeps,
1759
+ TLoaderFn,
1760
+ TRouterContext,
1761
+ TRouteContextFn,
1762
+ TBeforeLoadFn,
1763
+ TSSR,
1764
+ TServerMiddlewares,
1765
+ THandlers
1766
+ >
1767
+
1768
+ // The following properties are set up in this.init()
1769
+ parentRoute!: TParentRoute
1770
+ private _id!: TId
1771
+ private _path!: TPath
1772
+ private _fullPath!: TFullPath
1773
+ private _to!: TrimPathRight<TFullPath>
1774
+
1775
+ public get to() {
1776
+ return this._to
1777
+ }
1778
+
1779
+ public get id() {
1780
+ return this._id
1781
+ }
1782
+
1783
+ public get path() {
1784
+ return this._path
1785
+ }
1786
+
1787
+ public get fullPath() {
1788
+ return this._fullPath
1789
+ }
1790
+
1791
+ // Optional
1792
+ children?: TChildren
1793
+ originalIndex?: number
1794
+ rank!: number
1795
+ lazyFn?: () => Promise<
1796
+ LazyRoute<
1797
+ Route<
1798
+ TRegister,
1799
+ TParentRoute,
1800
+ TPath,
1801
+ TFullPath,
1802
+ TCustomId,
1803
+ TId,
1804
+ TSearchValidator,
1805
+ TParams,
1806
+ TRouterContext,
1807
+ TRouteContextFn,
1808
+ TBeforeLoadFn,
1809
+ TLoaderDeps,
1810
+ TLoaderFn,
1811
+ TChildren,
1812
+ TFileRouteTypes,
1813
+ TSSR,
1814
+ TServerMiddlewares,
1815
+ THandlers
1816
+ >
1817
+ >
1818
+ >
1819
+ /** @internal */
1820
+ _lazyPromise?: Promise<void>
1821
+ /** @internal */
1822
+ _componentsPromise?: Promise<void>
1823
+
1824
+ constructor(
1825
+ options?: RouteOptions<
1826
+ TRegister,
1827
+ TParentRoute,
1828
+ TId,
1829
+ TCustomId,
1830
+ TFullPath,
1831
+ TPath,
1832
+ TSearchValidator,
1833
+ TParams,
1834
+ TLoaderDeps,
1835
+ TLoaderFn,
1836
+ TRouterContext,
1837
+ TRouteContextFn,
1838
+ TBeforeLoadFn,
1839
+ TSSR,
1840
+ TServerMiddlewares,
1841
+ THandlers
1842
+ >,
1843
+ ) {
1844
+ this.options = (options as any) || {}
1845
+ this.isRoot = !options?.getParentRoute as any
1846
+
1847
+ if ((options as any)?.id && (options as any)?.path) {
1848
+ throw new Error(`Route cannot have both an 'id' and a 'path' option.`)
1849
+ }
1850
+ }
1851
+
1852
+ types!: RouteTypes<
1853
+ TRegister,
1854
+ TParentRoute,
1855
+ TPath,
1856
+ TFullPath,
1857
+ TCustomId,
1858
+ TId,
1859
+ TSearchValidator,
1860
+ TParams,
1861
+ TRouterContext,
1862
+ TRouteContextFn,
1863
+ TBeforeLoadFn,
1864
+ TLoaderDeps,
1865
+ TLoaderFn,
1866
+ TChildren,
1867
+ TFileRouteTypes,
1868
+ TSSR,
1869
+ TServerMiddlewares,
1870
+ THandlers
1871
+ >
1872
+
1873
+ init = (opts: { originalIndex: number }): void => {
1874
+ this.originalIndex = opts.originalIndex
1875
+
1876
+ const options = this.options as
1877
+ | (RouteOptions<
1878
+ TRegister,
1879
+ TParentRoute,
1880
+ TId,
1881
+ TCustomId,
1882
+ TFullPath,
1883
+ TPath,
1884
+ TSearchValidator,
1885
+ TParams,
1886
+ TLoaderDeps,
1887
+ TLoaderFn,
1888
+ TRouterContext,
1889
+ TRouteContextFn,
1890
+ TBeforeLoadFn,
1891
+ TSSR,
1892
+ TServerMiddlewares
1893
+ > &
1894
+ RoutePathOptionsIntersection<TCustomId, TPath>)
1895
+ | undefined
1896
+
1897
+ const isRoot = !options?.path && !options?.id
1898
+
1899
+ this.parentRoute = this.options.getParentRoute?.()
1900
+
1901
+ if (isRoot) {
1902
+ this._path = rootRouteId as TPath
1903
+ } else if (!this.parentRoute) {
1904
+ if (process.env.NODE_ENV !== 'production') {
1905
+ throw new Error(
1906
+ `Invariant failed: Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,
1907
+ )
1908
+ }
1909
+
1910
+ invariant()
1911
+ }
1912
+
1913
+ let path: undefined | string = isRoot ? rootRouteId : options?.path
1914
+
1915
+ // If the path is anything other than an index path, trim it up
1916
+ if (path && path !== '/') {
1917
+ path = trimPathLeft(path)
1918
+ }
1919
+
1920
+ const customId = options?.id || path
1921
+
1922
+ // Strip the parentId prefix from the first level of children
1923
+ let id = isRoot
1924
+ ? rootRouteId
1925
+ : joinPaths([
1926
+ this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,
1927
+ customId,
1928
+ ])
1929
+
1930
+ if (path === rootRouteId) {
1931
+ path = '/'
1932
+ }
1933
+
1934
+ if (id !== rootRouteId) {
1935
+ id = joinPaths(['/', id])
1936
+ }
1937
+
1938
+ const fullPath =
1939
+ id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])
1940
+
1941
+ this._path = path as TPath
1942
+ this._id = id as TId
1943
+ this._fullPath = fullPath as TFullPath
1944
+ this._to = trimPathRight(fullPath) as TrimPathRight<TFullPath>
1945
+ }
1946
+
1947
+ addChildren: RouteAddChildrenFn<
1948
+ TRegister,
1949
+ TParentRoute,
1950
+ TPath,
1951
+ TFullPath,
1952
+ TCustomId,
1953
+ TId,
1954
+ TSearchValidator,
1955
+ TParams,
1956
+ TRouterContext,
1957
+ TRouteContextFn,
1958
+ TBeforeLoadFn,
1959
+ TLoaderDeps,
1960
+ TLoaderFn,
1961
+ TFileRouteTypes,
1962
+ TSSR,
1963
+ TServerMiddlewares,
1964
+ THandlers
1965
+ > = (children) => {
1966
+ return this._addFileChildren(children) as any
1967
+ }
1968
+
1969
+ _addFileChildren: RouteAddFileChildrenFn<
1970
+ TRegister,
1971
+ TParentRoute,
1972
+ TPath,
1973
+ TFullPath,
1974
+ TCustomId,
1975
+ TId,
1976
+ TSearchValidator,
1977
+ TParams,
1978
+ TRouterContext,
1979
+ TRouteContextFn,
1980
+ TBeforeLoadFn,
1981
+ TLoaderDeps,
1982
+ TLoaderFn,
1983
+ TFileRouteTypes,
1984
+ TSSR,
1985
+ TServerMiddlewares,
1986
+ THandlers
1987
+ > = (children) => {
1988
+ if (Array.isArray(children)) {
1989
+ this.children = children as TChildren
1990
+ }
1991
+
1992
+ if (typeof children === 'object' && children !== null) {
1993
+ this.children = Object.values(children) as TChildren
1994
+ }
1995
+
1996
+ return this as any
1997
+ }
1998
+
1999
+ _addFileTypes: RouteAddFileTypesFn<
2000
+ TRegister,
2001
+ TParentRoute,
2002
+ TPath,
2003
+ TFullPath,
2004
+ TCustomId,
2005
+ TId,
2006
+ TSearchValidator,
2007
+ TParams,
2008
+ TRouterContext,
2009
+ TRouteContextFn,
2010
+ TBeforeLoadFn,
2011
+ TLoaderDeps,
2012
+ TLoaderFn,
2013
+ TChildren,
2014
+ TSSR,
2015
+ TServerMiddlewares,
2016
+ THandlers
2017
+ > = () => {
2018
+ return this as any
2019
+ }
2020
+
2021
+ updateLoader = <TNewLoaderFn>(options: {
2022
+ loader: Constrain<
2023
+ TNewLoaderFn,
2024
+ RouteLoaderFn<
2025
+ TRegister,
2026
+ TParentRoute,
2027
+ TCustomId,
2028
+ TParams,
2029
+ TLoaderDeps,
2030
+ TRouterContext,
2031
+ TRouteContextFn,
2032
+ TBeforeLoadFn
2033
+ >
2034
+ >
2035
+ }) => {
2036
+ Object.assign(this.options, options)
2037
+ return this as unknown as BaseRoute<
2038
+ TRegister,
2039
+ TParentRoute,
2040
+ TPath,
2041
+ TFullPath,
2042
+ TCustomId,
2043
+ TId,
2044
+ TSearchValidator,
2045
+ TParams,
2046
+ TRouterContext,
2047
+ TRouteContextFn,
2048
+ TBeforeLoadFn,
2049
+ TLoaderDeps,
2050
+ TNewLoaderFn,
2051
+ TChildren,
2052
+ TFileRouteTypes,
2053
+ TSSR,
2054
+ TServerMiddlewares,
2055
+ THandlers
2056
+ >
2057
+ }
2058
+
2059
+ update = (
2060
+ options: UpdatableRouteOptions<
2061
+ TParentRoute,
2062
+ TCustomId,
2063
+ TFullPath,
2064
+ TParams,
2065
+ TSearchValidator,
2066
+ TLoaderFn,
2067
+ TLoaderDeps,
2068
+ TRouterContext,
2069
+ TRouteContextFn,
2070
+ TBeforeLoadFn
2071
+ >,
2072
+ ): this => {
2073
+ Object.assign(this.options, options)
2074
+ return this
2075
+ }
2076
+
2077
+ lazy: RouteLazyFn<
2078
+ Route<
2079
+ TRegister,
2080
+ TParentRoute,
2081
+ TPath,
2082
+ TFullPath,
2083
+ TCustomId,
2084
+ TId,
2085
+ TSearchValidator,
2086
+ TParams,
2087
+ TRouterContext,
2088
+ TRouteContextFn,
2089
+ TBeforeLoadFn,
2090
+ TLoaderDeps,
2091
+ TLoaderFn,
2092
+ TChildren,
2093
+ TFileRouteTypes,
2094
+ TSSR,
2095
+ TServerMiddlewares,
2096
+ THandlers
2097
+ >
2098
+ > = (lazyFn) => {
2099
+ this.lazyFn = lazyFn
2100
+ return this
2101
+ }
2102
+
2103
+ /**
2104
+ * Create a redirect with `from` automatically set to this route's fullPath.
2105
+ * Enables relative redirects like `Route.redirect({ to: './overview' })`.
2106
+ * @param opts Redirect options (same as `redirect()` but without `from`)
2107
+ * @returns A redirect Response that can be thrown from loaders/beforeLoad
2108
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/redirectFunction
2109
+ */
2110
+ redirect: RedirectFnRoute<TFullPath> = (opts) =>
2111
+ redirect({ from: this.fullPath, ...opts } as any)
2112
+ }
2113
+
2114
+ export class BaseRouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {
2115
+ id: TId
2116
+
2117
+ constructor({ id }: { id: TId }) {
2118
+ this.id = id
2119
+ }
2120
+
2121
+ notFound = (opts?: NotFoundError) => {
2122
+ return notFound({ routeId: this.id as string, ...opts })
2123
+ }
2124
+
2125
+ /**
2126
+ * Create a redirect with `from` automatically set to this route's path.
2127
+ * Enables relative redirects like `routeApi.redirect({ to: './overview' })`.
2128
+ * @param opts Redirect options (same as `redirect()` but without `from`)
2129
+ * @returns A redirect Response that can be thrown from loaders/beforeLoad
2130
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/redirectFunction
2131
+ */
2132
+ redirect: RedirectFnRoute<RouteTypesById<TRouter, TId>['fullPath']> = (
2133
+ opts,
2134
+ ) => redirect({ from: this.id as string, ...opts } as any)
2135
+ }
2136
+
2137
+ export interface RootRoute<
2138
+ in out TRegister,
2139
+ in out TSearchValidator = undefined,
2140
+ in out TRouterContext = {},
2141
+ in out TRouteContextFn = AnyContext,
2142
+ in out TBeforeLoadFn = AnyContext,
2143
+ in out TLoaderDeps extends Record<string, any> = {},
2144
+ in out TLoaderFn = undefined,
2145
+ in out TChildren = unknown,
2146
+ in out TFileRouteTypes = unknown,
2147
+ in out TSSR = unknown,
2148
+ in out TServerMiddlewares = unknown,
2149
+ in out THandlers = undefined,
2150
+ > extends Route<
2151
+ TRegister,
2152
+ any, // TParentRoute
2153
+ '/', // TPath
2154
+ '/', // TFullPath
2155
+ string, // TCustomId
2156
+ RootRouteId, // TId
2157
+ TSearchValidator, // TSearchValidator
2158
+ {}, // TParams
2159
+ TRouterContext,
2160
+ TRouteContextFn,
2161
+ TBeforeLoadFn,
2162
+ TLoaderDeps,
2163
+ TLoaderFn,
2164
+ TChildren, // TChildren
2165
+ TFileRouteTypes,
2166
+ TSSR,
2167
+ TServerMiddlewares,
2168
+ THandlers
2169
+ > {}
2170
+
2171
+ export class BaseRootRoute<
2172
+ in out TRegister = Register,
2173
+ in out TSearchValidator = undefined,
2174
+ in out TRouterContext = {},
2175
+ in out TRouteContextFn = AnyContext,
2176
+ in out TBeforeLoadFn = AnyContext,
2177
+ in out TLoaderDeps extends Record<string, any> = {},
2178
+ in out TLoaderFn = undefined,
2179
+ in out TChildren = unknown,
2180
+ in out TFileRouteTypes = unknown,
2181
+ in out TSSR = unknown,
2182
+ in out TServerMiddlewares = unknown,
2183
+ in out THandlers = undefined,
2184
+ > extends BaseRoute<
2185
+ TRegister,
2186
+ any, // TParentRoute
2187
+ '/', // TPath
2188
+ '/', // TFullPath
2189
+ string, // TCustomId
2190
+ RootRouteId, // TId
2191
+ TSearchValidator, // TSearchValidator
2192
+ {}, // TParams
2193
+ TRouterContext,
2194
+ TRouteContextFn,
2195
+ TBeforeLoadFn,
2196
+ TLoaderDeps,
2197
+ TLoaderFn,
2198
+ TChildren, // TChildren
2199
+ TFileRouteTypes,
2200
+ TSSR,
2201
+ TServerMiddlewares,
2202
+ THandlers
2203
+ > {
2204
+ constructor(
2205
+ options?: RootRouteOptions<
2206
+ TRegister,
2207
+ TSearchValidator,
2208
+ TRouterContext,
2209
+ TRouteContextFn,
2210
+ TBeforeLoadFn,
2211
+ TLoaderDeps,
2212
+ TLoaderFn,
2213
+ TSSR,
2214
+ TServerMiddlewares,
2215
+ THandlers
2216
+ >,
2217
+ ) {
2218
+ super(options as any)
2219
+ }
2220
+ }
2221
+
2222
+ //
2223
+
2224
+ export interface RouteLike {
2225
+ id: string
2226
+ isRoot?: boolean
2227
+ path?: string
2228
+ fullPath: string
2229
+ rank?: number
2230
+ parentRoute?: RouteLike
2231
+ children?: Array<RouteLike>
2232
+ options?: {
2233
+ caseSensitive?: boolean
2234
+ }
2235
+ }