@tanstack/solid-router 1.108.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 (271) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -0
  3. package/dist/cjs/Asset.cjs +59 -0
  4. package/dist/cjs/Asset.cjs.map +1 -0
  5. package/dist/cjs/Asset.d.cts +2 -0
  6. package/dist/cjs/CatchBoundary.cjs +92 -0
  7. package/dist/cjs/CatchBoundary.cjs.map +1 -0
  8. package/dist/cjs/CatchBoundary.d.cts +11 -0
  9. package/dist/cjs/HeadContent.cjs +129 -0
  10. package/dist/cjs/HeadContent.cjs.map +1 -0
  11. package/dist/cjs/HeadContent.d.cts +8 -0
  12. package/dist/cjs/Match.cjs +340 -0
  13. package/dist/cjs/Match.cjs.map +1 -0
  14. package/dist/cjs/Match.d.cts +8 -0
  15. package/dist/cjs/Matches.cjs +151 -0
  16. package/dist/cjs/Matches.cjs.map +1 -0
  17. package/dist/cjs/Matches.d.cts +69 -0
  18. package/dist/cjs/RouterProvider.cjs +45 -0
  19. package/dist/cjs/RouterProvider.cjs.map +1 -0
  20. package/dist/cjs/RouterProvider.d.cts +35 -0
  21. package/dist/cjs/SafeFragment.cjs +8 -0
  22. package/dist/cjs/SafeFragment.cjs.map +1 -0
  23. package/dist/cjs/SafeFragment.d.cts +1 -0
  24. package/dist/cjs/ScriptOnce.cjs +23 -0
  25. package/dist/cjs/ScriptOnce.cjs.map +1 -0
  26. package/dist/cjs/ScriptOnce.d.cts +5 -0
  27. package/dist/cjs/Scripts.cjs +48 -0
  28. package/dist/cjs/Scripts.cjs.map +1 -0
  29. package/dist/cjs/Scripts.d.cts +1 -0
  30. package/dist/cjs/ScrollRestoration.cjs +37 -0
  31. package/dist/cjs/ScrollRestoration.cjs.map +1 -0
  32. package/dist/cjs/ScrollRestoration.d.cts +15 -0
  33. package/dist/cjs/Transitioner.cjs +132 -0
  34. package/dist/cjs/Transitioner.cjs.map +1 -0
  35. package/dist/cjs/Transitioner.d.cts +1 -0
  36. package/dist/cjs/awaited.cjs +53 -0
  37. package/dist/cjs/awaited.cjs.map +1 -0
  38. package/dist/cjs/awaited.d.cts +11 -0
  39. package/dist/cjs/fileRoute.cjs +90 -0
  40. package/dist/cjs/fileRoute.cjs.map +1 -0
  41. package/dist/cjs/fileRoute.d.cts +58 -0
  42. package/dist/cjs/history.d.cts +8 -0
  43. package/dist/cjs/index.cjs +260 -0
  44. package/dist/cjs/index.cjs.map +1 -0
  45. package/dist/cjs/index.d.cts +53 -0
  46. package/dist/cjs/lazyRouteComponent.cjs +74 -0
  47. package/dist/cjs/lazyRouteComponent.cjs.map +1 -0
  48. package/dist/cjs/lazyRouteComponent.d.cts +7 -0
  49. package/dist/cjs/link.cjs +279 -0
  50. package/dist/cjs/link.cjs.map +1 -0
  51. package/dist/cjs/link.d.cts +113 -0
  52. package/dist/cjs/matchContext.cjs +25 -0
  53. package/dist/cjs/matchContext.cjs.map +1 -0
  54. package/dist/cjs/matchContext.d.cts +3 -0
  55. package/dist/cjs/not-found.cjs +51 -0
  56. package/dist/cjs/not-found.cjs.map +1 -0
  57. package/dist/cjs/not-found.d.cts +27 -0
  58. package/dist/cjs/redirects.cjs +29 -0
  59. package/dist/cjs/redirects.cjs.map +1 -0
  60. package/dist/cjs/redirects.d.cts +21 -0
  61. package/dist/cjs/renderRouteNotFound.cjs +23 -0
  62. package/dist/cjs/renderRouteNotFound.cjs.map +1 -0
  63. package/dist/cjs/renderRouteNotFound.d.cts +3 -0
  64. package/dist/cjs/route.cjs +233 -0
  65. package/dist/cjs/route.cjs.map +1 -0
  66. package/dist/cjs/route.d.cts +297 -0
  67. package/dist/cjs/routeInfo.d.cts +53 -0
  68. package/dist/cjs/router.cjs +1687 -0
  69. package/dist/cjs/router.cjs.map +1 -0
  70. package/dist/cjs/router.d.cts +555 -0
  71. package/dist/cjs/routerContext.cjs +33 -0
  72. package/dist/cjs/routerContext.cjs.map +1 -0
  73. package/dist/cjs/routerContext.d.cts +8 -0
  74. package/dist/cjs/scroll-restoration.cjs +183 -0
  75. package/dist/cjs/scroll-restoration.cjs.map +1 -0
  76. package/dist/cjs/scroll-restoration.d.cts +29 -0
  77. package/dist/cjs/typePrimitives.d.cts +66 -0
  78. package/dist/cjs/useBlocker.cjs +165 -0
  79. package/dist/cjs/useBlocker.cjs.map +1 -0
  80. package/dist/cjs/useBlocker.d.cts +68 -0
  81. package/dist/cjs/useCanGoBack.cjs +8 -0
  82. package/dist/cjs/useCanGoBack.cjs.map +1 -0
  83. package/dist/cjs/useCanGoBack.d.cts +1 -0
  84. package/dist/cjs/useLoaderData.cjs +14 -0
  85. package/dist/cjs/useLoaderData.cjs.map +1 -0
  86. package/dist/cjs/useLoaderData.d.cts +13 -0
  87. package/dist/cjs/useLoaderDeps.cjs +17 -0
  88. package/dist/cjs/useLoaderDeps.cjs.map +1 -0
  89. package/dist/cjs/useLoaderDeps.d.cts +12 -0
  90. package/dist/cjs/useLocation.cjs +10 -0
  91. package/dist/cjs/useLocation.cjs.map +1 -0
  92. package/dist/cjs/useLocation.d.cts +7 -0
  93. package/dist/cjs/useMatch.cjs +39 -0
  94. package/dist/cjs/useMatch.cjs.map +1 -0
  95. package/dist/cjs/useMatch.d.cts +14 -0
  96. package/dist/cjs/useNavigate.cjs +45 -0
  97. package/dist/cjs/useNavigate.cjs.map +1 -0
  98. package/dist/cjs/useNavigate.d.cts +7 -0
  99. package/dist/cjs/useParams.cjs +15 -0
  100. package/dist/cjs/useParams.cjs.map +1 -0
  101. package/dist/cjs/useParams.d.cts +15 -0
  102. package/dist/cjs/useRouteContext.cjs +11 -0
  103. package/dist/cjs/useRouteContext.cjs.map +1 -0
  104. package/dist/cjs/useRouteContext.d.cts +13 -0
  105. package/dist/cjs/useRouter.cjs +29 -0
  106. package/dist/cjs/useRouter.cjs.map +1 -0
  107. package/dist/cjs/useRouter.d.cts +4 -0
  108. package/dist/cjs/useRouterState.cjs +16 -0
  109. package/dist/cjs/useRouterState.cjs.map +1 -0
  110. package/dist/cjs/useRouterState.d.cts +8 -0
  111. package/dist/cjs/useSearch.cjs +15 -0
  112. package/dist/cjs/useSearch.cjs.map +1 -0
  113. package/dist/cjs/useSearch.d.cts +15 -0
  114. package/dist/cjs/utils.cjs +58 -0
  115. package/dist/cjs/utils.cjs.map +1 -0
  116. package/dist/cjs/utils.d.cts +44 -0
  117. package/dist/esm/Asset.d.ts +2 -0
  118. package/dist/esm/Asset.js +59 -0
  119. package/dist/esm/Asset.js.map +1 -0
  120. package/dist/esm/CatchBoundary.d.ts +11 -0
  121. package/dist/esm/CatchBoundary.js +75 -0
  122. package/dist/esm/CatchBoundary.js.map +1 -0
  123. package/dist/esm/HeadContent.d.ts +8 -0
  124. package/dist/esm/HeadContent.js +112 -0
  125. package/dist/esm/HeadContent.js.map +1 -0
  126. package/dist/esm/Match.d.ts +8 -0
  127. package/dist/esm/Match.js +323 -0
  128. package/dist/esm/Match.js.map +1 -0
  129. package/dist/esm/Matches.d.ts +69 -0
  130. package/dist/esm/Matches.js +134 -0
  131. package/dist/esm/Matches.js.map +1 -0
  132. package/dist/esm/RouterProvider.d.ts +35 -0
  133. package/dist/esm/RouterProvider.js +45 -0
  134. package/dist/esm/RouterProvider.js.map +1 -0
  135. package/dist/esm/SafeFragment.d.ts +1 -0
  136. package/dist/esm/SafeFragment.js +8 -0
  137. package/dist/esm/SafeFragment.js.map +1 -0
  138. package/dist/esm/ScriptOnce.d.ts +5 -0
  139. package/dist/esm/ScriptOnce.js +23 -0
  140. package/dist/esm/ScriptOnce.js.map +1 -0
  141. package/dist/esm/Scripts.d.ts +1 -0
  142. package/dist/esm/Scripts.js +48 -0
  143. package/dist/esm/Scripts.js.map +1 -0
  144. package/dist/esm/ScrollRestoration.d.ts +15 -0
  145. package/dist/esm/ScrollRestoration.js +37 -0
  146. package/dist/esm/ScrollRestoration.js.map +1 -0
  147. package/dist/esm/Transitioner.d.ts +1 -0
  148. package/dist/esm/Transitioner.js +115 -0
  149. package/dist/esm/Transitioner.js.map +1 -0
  150. package/dist/esm/awaited.d.ts +11 -0
  151. package/dist/esm/awaited.js +36 -0
  152. package/dist/esm/awaited.js.map +1 -0
  153. package/dist/esm/fileRoute.d.ts +58 -0
  154. package/dist/esm/fileRoute.js +90 -0
  155. package/dist/esm/fileRoute.js.map +1 -0
  156. package/dist/esm/history.d.ts +8 -0
  157. package/dist/esm/index.d.ts +53 -0
  158. package/dist/esm/index.js +149 -0
  159. package/dist/esm/index.js.map +1 -0
  160. package/dist/esm/lazyRouteComponent.d.ts +7 -0
  161. package/dist/esm/lazyRouteComponent.js +74 -0
  162. package/dist/esm/lazyRouteComponent.js.map +1 -0
  163. package/dist/esm/link.d.ts +113 -0
  164. package/dist/esm/link.js +262 -0
  165. package/dist/esm/link.js.map +1 -0
  166. package/dist/esm/matchContext.d.ts +3 -0
  167. package/dist/esm/matchContext.js +8 -0
  168. package/dist/esm/matchContext.js.map +1 -0
  169. package/dist/esm/not-found.d.ts +27 -0
  170. package/dist/esm/not-found.js +51 -0
  171. package/dist/esm/not-found.js.map +1 -0
  172. package/dist/esm/redirects.d.ts +21 -0
  173. package/dist/esm/redirects.js +29 -0
  174. package/dist/esm/redirects.js.map +1 -0
  175. package/dist/esm/renderRouteNotFound.d.ts +3 -0
  176. package/dist/esm/renderRouteNotFound.js +23 -0
  177. package/dist/esm/renderRouteNotFound.js.map +1 -0
  178. package/dist/esm/route.d.ts +297 -0
  179. package/dist/esm/route.js +233 -0
  180. package/dist/esm/route.js.map +1 -0
  181. package/dist/esm/routeInfo.d.ts +53 -0
  182. package/dist/esm/router.d.ts +555 -0
  183. package/dist/esm/router.js +1687 -0
  184. package/dist/esm/router.js.map +1 -0
  185. package/dist/esm/routerContext.d.ts +8 -0
  186. package/dist/esm/routerContext.js +16 -0
  187. package/dist/esm/routerContext.js.map +1 -0
  188. package/dist/esm/scroll-restoration.d.ts +29 -0
  189. package/dist/esm/scroll-restoration.js +183 -0
  190. package/dist/esm/scroll-restoration.js.map +1 -0
  191. package/dist/esm/typePrimitives.d.ts +66 -0
  192. package/dist/esm/useBlocker.d.ts +68 -0
  193. package/dist/esm/useBlocker.js +148 -0
  194. package/dist/esm/useBlocker.js.map +1 -0
  195. package/dist/esm/useCanGoBack.d.ts +1 -0
  196. package/dist/esm/useCanGoBack.js +8 -0
  197. package/dist/esm/useCanGoBack.js.map +1 -0
  198. package/dist/esm/useLoaderData.d.ts +13 -0
  199. package/dist/esm/useLoaderData.js +14 -0
  200. package/dist/esm/useLoaderData.js.map +1 -0
  201. package/dist/esm/useLoaderDeps.d.ts +12 -0
  202. package/dist/esm/useLoaderDeps.js +17 -0
  203. package/dist/esm/useLoaderDeps.js.map +1 -0
  204. package/dist/esm/useLocation.d.ts +7 -0
  205. package/dist/esm/useLocation.js +10 -0
  206. package/dist/esm/useLocation.js.map +1 -0
  207. package/dist/esm/useMatch.d.ts +14 -0
  208. package/dist/esm/useMatch.js +22 -0
  209. package/dist/esm/useMatch.js.map +1 -0
  210. package/dist/esm/useNavigate.d.ts +7 -0
  211. package/dist/esm/useNavigate.js +28 -0
  212. package/dist/esm/useNavigate.js.map +1 -0
  213. package/dist/esm/useParams.d.ts +15 -0
  214. package/dist/esm/useParams.js +15 -0
  215. package/dist/esm/useParams.js.map +1 -0
  216. package/dist/esm/useRouteContext.d.ts +13 -0
  217. package/dist/esm/useRouteContext.js +11 -0
  218. package/dist/esm/useRouteContext.js.map +1 -0
  219. package/dist/esm/useRouter.d.ts +4 -0
  220. package/dist/esm/useRouter.js +12 -0
  221. package/dist/esm/useRouter.js.map +1 -0
  222. package/dist/esm/useRouterState.d.ts +8 -0
  223. package/dist/esm/useRouterState.js +16 -0
  224. package/dist/esm/useRouterState.js.map +1 -0
  225. package/dist/esm/useSearch.d.ts +15 -0
  226. package/dist/esm/useSearch.js +15 -0
  227. package/dist/esm/useSearch.js.map +1 -0
  228. package/dist/esm/utils.d.ts +44 -0
  229. package/dist/esm/utils.js +41 -0
  230. package/dist/esm/utils.js.map +1 -0
  231. package/package.json +75 -0
  232. package/src/Asset.tsx +23 -0
  233. package/src/CatchBoundary.tsx +78 -0
  234. package/src/HeadContent.tsx +146 -0
  235. package/src/Match.tsx +356 -0
  236. package/src/Matches.tsx +348 -0
  237. package/src/RouterProvider.tsx +130 -0
  238. package/src/SafeFragment.tsx +3 -0
  239. package/src/ScriptOnce.tsx +30 -0
  240. package/src/Scripts.tsx +65 -0
  241. package/src/ScrollRestoration.tsx +65 -0
  242. package/src/Transitioner.tsx +152 -0
  243. package/src/awaited.tsx +49 -0
  244. package/src/fileRoute.ts +274 -0
  245. package/src/history.ts +9 -0
  246. package/src/index.tsx +359 -0
  247. package/src/lazyRouteComponent.tsx +114 -0
  248. package/src/link.tsx +1002 -0
  249. package/src/matchContext.tsx +10 -0
  250. package/src/not-found.tsx +69 -0
  251. package/src/redirects.ts +71 -0
  252. package/src/renderRouteNotFound.tsx +27 -0
  253. package/src/route.ts +1477 -0
  254. package/src/routeInfo.ts +239 -0
  255. package/src/router.ts +3066 -0
  256. package/src/routerContext.tsx +26 -0
  257. package/src/scroll-restoration.tsx +337 -0
  258. package/src/typePrimitives.ts +195 -0
  259. package/src/useBlocker.tsx +298 -0
  260. package/src/useCanGoBack.ts +5 -0
  261. package/src/useLoaderData.tsx +64 -0
  262. package/src/useLoaderDeps.tsx +52 -0
  263. package/src/useLocation.tsx +26 -0
  264. package/src/useMatch.tsx +96 -0
  265. package/src/useNavigate.tsx +61 -0
  266. package/src/useParams.tsx +83 -0
  267. package/src/useRouteContext.ts +62 -0
  268. package/src/useRouter.tsx +15 -0
  269. package/src/useRouterState.tsx +32 -0
  270. package/src/useSearch.tsx +84 -0
  271. package/src/utils.ts +96 -0
@@ -0,0 +1,29 @@
1
+ function redirect(opts) {
2
+ opts.isRedirect = true;
3
+ opts.statusCode = opts.statusCode || opts.code || 307;
4
+ opts.headers = opts.headers || {};
5
+ if (!opts.reloadDocument) {
6
+ opts.reloadDocument = false;
7
+ try {
8
+ new URL(`${opts.href}`);
9
+ opts.reloadDocument = true;
10
+ } catch {
11
+ }
12
+ }
13
+ if (opts.throw) {
14
+ throw opts;
15
+ }
16
+ return opts;
17
+ }
18
+ function isRedirect(obj) {
19
+ return !!(obj == null ? void 0 : obj.isRedirect);
20
+ }
21
+ function isResolvedRedirect(obj) {
22
+ return !!(obj == null ? void 0 : obj.isRedirect) && obj.href;
23
+ }
24
+ export {
25
+ isRedirect,
26
+ isResolvedRedirect,
27
+ redirect
28
+ };
29
+ //# sourceMappingURL=redirects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirects.js","sources":["../../src/redirects.ts"],"sourcesContent":["import type { NavigateOptions } from './link'\nimport type { RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { PickAsRequired } from '@tanstack/router-core'\n\nexport type AnyRedirect = Redirect<any, any, any, any, any>\n\nexport type Redirect<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = '/',\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = {\n href?: string\n /**\n * @deprecated Use `statusCode` instead\n **/\n code?: number\n statusCode?: number\n throw?: any\n headers?: HeadersInit\n} & NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type ResolvedRedirect<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n> = PickAsRequired<\n Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n 'code' | 'statusCode' | 'headers'\n> & {\n href: string\n}\n\nexport function redirect<\n TRouter extends RegisteredRouter,\n const TTo extends string | undefined,\n const TFrom extends string = string,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> {\n ;(opts as any).isRedirect = true\n opts.statusCode = opts.statusCode || opts.code || 307\n opts.headers = opts.headers || {}\n if (!opts.reloadDocument) {\n opts.reloadDocument = false\n try {\n new URL(`${opts.href}`)\n opts.reloadDocument = true\n } catch {}\n }\n\n if (opts.throw) {\n throw opts\n }\n\n return opts\n}\n\nexport function isRedirect(obj: any): obj is AnyRedirect {\n return !!obj?.isRedirect\n}\n\nexport function isResolvedRedirect(obj: any): obj is ResolvedRedirect {\n return !!obj?.isRedirect && obj.href\n}\n"],"names":[],"mappings":"AAqCO,SAAS,SAOd,MACmD;AACjD,OAAa,aAAa;AAC5B,OAAK,aAAa,KAAK,cAAc,KAAK,QAAQ;AAC7C,OAAA,UAAU,KAAK,WAAW,CAAC;AAC5B,MAAA,CAAC,KAAK,gBAAgB;AACxB,SAAK,iBAAiB;AAClB,QAAA;AACF,UAAI,IAAI,GAAG,KAAK,IAAI,EAAE;AACtB,WAAK,iBAAiB;AAAA,IAAA,QAChB;AAAA,IAAA;AAAA,EAAC;AAGX,MAAI,KAAK,OAAO;AACR,UAAA;AAAA,EAAA;AAGD,SAAA;AACT;AAEO,SAAS,WAAW,KAA8B;AAChD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,mBAAmB,KAAmC;AACpE,SAAO,CAAC,EAAC,2BAAK,eAAc,IAAI;AAClC;"}
@@ -0,0 +1,3 @@
1
+ import { AnyRouter } from './router.js';
2
+ import { AnyRoute } from './route.js';
3
+ export declare function renderRouteNotFound(router: AnyRouter, route: AnyRoute, data: any): import("solid-js").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { createComponent } from "solid-js/web";
2
+ import warning from "tiny-warning";
3
+ import { DefaultGlobalNotFound } from "./not-found.js";
4
+ function renderRouteNotFound(router, route, data) {
5
+ if (!route.options.notFoundComponent) {
6
+ if (router.options.defaultNotFoundComponent) {
7
+ return createComponent(router.options.defaultNotFoundComponent, {
8
+ data
9
+ });
10
+ }
11
+ if (process.env.NODE_ENV === "development") {
12
+ warning(route.options.notFoundComponent, `A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`);
13
+ }
14
+ return createComponent(DefaultGlobalNotFound, {});
15
+ }
16
+ return createComponent(route.options.notFoundComponent, {
17
+ data
18
+ });
19
+ }
20
+ export {
21
+ renderRouteNotFound
22
+ };
23
+ //# sourceMappingURL=renderRouteNotFound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderRouteNotFound.js","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRouter } from './router'\nimport type { AnyRoute } from './route'\n\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent data={data} />\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`,\n )\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent data={data} />\n}\n"],"names":["renderRouteNotFound","router","route","data","options","notFoundComponent","defaultNotFoundComponent","_$createComponent","process","env","NODE_ENV","warning","id","DefaultGlobalNotFound"],"mappings":";;;AAKgBA,SAAAA,oBACdC,QACAC,OACAC,MACA;AACI,MAAA,CAACD,MAAME,QAAQC,mBAAmB;AAChCJ,QAAAA,OAAOG,QAAQE,0BAA0B;AAC3CC,aAAAA,gBAAQN,OAAOG,QAAQE,0BAAwB;AAAA,QAACH;AAAAA,MAAAA,CAAU;AAAA,IAAA;AAGxDK,QAAAA,QAAQC,IAAIC,aAAa,eAAe;AAC1CC,cACET,MAAME,QAAQC,mBACd,yDAAyDH,MAAMU,EAAE,uPACnE;AAAA,IAAA;AAGFL,WAAAA,gBAAQM,uBAAqB,EAAA;AAAA,EAAA;AAG/BN,SAAAA,gBAAQL,MAAME,QAAQC,mBAAiB;AAAA,IAACF;AAAAA,EAAAA,CAAU;AACpD;"}
@@ -0,0 +1,297 @@
1
+ import { AnyContext, AnyPathParams, AnySchema, AnyValidator, Assign, Constrain, ConstrainLiteral, ContextAsyncReturnType, ContextReturnType, DefaultValidator, ErrorComponentProps, Expand, InferAllContext, InferAllParams, InferFullSearchSchema, InferFullSearchSchemaInput, IntersectAssign, NoInfer, NotFoundRouteProps, ParamsOptions, ParsedLocation, ResolveId, ResolveLoaderData, ResolveParams, ResolveRouteContext, ResolveSearchValidatorInput, ResolveValidatorOutput, RootRouteId, RouteContext, RoutePathOptions, RoutePrefix, SearchFilter, SearchMiddleware, TrimPathRight, UpdatableStaticRouteOption } from '@tanstack/router-core';
2
+ import { UseLoaderDataRoute } from './useLoaderData.js';
3
+ import { UseMatchRoute } from './useMatch.js';
4
+ import { UseLoaderDepsRoute } from './useLoaderDeps.js';
5
+ import { UseParamsRoute } from './useParams.js';
6
+ import { UseSearchRoute } from './useSearch.js';
7
+ import { UseNavigateResult } from './useNavigate.js';
8
+ import { AnyRouteMatch, MakeRouteMatchFromRoute, MakeRouteMatchUnion, RouteMatch } from './Matches.js';
9
+ import { NavigateOptions, ToMaskOptions } from './link.js';
10
+ import { ParseRoute, RouteById, RouteIds, RoutePaths } from './routeInfo.js';
11
+ import { AnyRouter, RegisteredRouter, Router } from './router.js';
12
+ import { BuildLocationFn, NavigateFn } from './RouterProvider.js';
13
+ import { NotFoundError } from './not-found.js';
14
+ import { LazyRoute } from './fileRoute.js';
15
+ import { UseRouteContextRoute } from './useRouteContext.js';
16
+ import type * as Solid from 'solid-js';
17
+ export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TId extends string = string, TCustomId extends string = string, TFullPath extends string = string, TPath extends string = string, TSearchValidator = undefined, TParams = AnyPathParams, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext> = BaseRouteOptions<TParentRoute, TId, TCustomId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn> & UpdatableRouteOptions<NoInfer<TParentRoute>, NoInfer<TCustomId>, NoInfer<TFullPath>, NoInfer<TParams>, NoInfer<TSearchValidator>, NoInfer<TLoaderFn>, NoInfer<TLoaderDeps>, NoInfer<TRouterContext>, NoInfer<TRouteContextFn>, NoInfer<TBeforeLoadFn>>;
18
+ export interface FullSearchSchemaOption<in out TParentRoute extends AnyRoute, in out TSearchValidator> {
19
+ search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>;
20
+ }
21
+ export type RouteContextFn<in out TParentRoute extends AnyRoute, in out TSearchValidator, in out TParams, in out TRouterContext> = (ctx: RouteContextOptions<TParentRoute, TSearchValidator, TParams, TRouterContext>) => any;
22
+ export type BeforeLoadFn<in out TParentRoute extends AnyRoute, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn> = (ctx: BeforeLoadContextOptions<TParentRoute, TSearchValidator, TParams, TRouterContext, TRouteContextFn>) => any;
23
+ export type FileBaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TId extends string = string, TPath extends string = string, TSearchValidator = undefined, TParams = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TRemountDepsFn = AnyContext> = ParamsOptions<TPath, TParams> & {
24
+ validateSearch?: Constrain<TSearchValidator, AnyValidator, DefaultValidator>;
25
+ shouldReload?: boolean | ((match: LoaderFnContext<TParentRoute, TId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => any);
26
+ context?: Constrain<TRouteContextFn, (ctx: RouteContextOptions<TParentRoute, TParams, TRouterContext, TLoaderDeps>) => any>;
27
+ beforeLoad?: Constrain<TBeforeLoadFn, (ctx: BeforeLoadContextOptions<TParentRoute, TSearchValidator, TParams, TRouterContext, TRouteContextFn>) => any>;
28
+ loaderDeps?: (opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>) => TLoaderDeps;
29
+ remountDeps?: Constrain<TRemountDepsFn, (opt: RemountDepsOptions<TId, FullSearchSchemaOption<TParentRoute, TSearchValidator>, Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>, TLoaderDeps>) => any>;
30
+ loader?: Constrain<TLoaderFn, (ctx: LoaderFnContext<TParentRoute, TId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => any>;
31
+ };
32
+ export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TId extends string = string, TCustomId extends string = string, TPath extends string = string, TSearchValidator = undefined, TParams = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext> = RoutePathOptions<TCustomId, TPath> & FileBaseRouteOptions<TParentRoute, TId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn> & {
33
+ getParentRoute: () => TParentRoute;
34
+ };
35
+ export interface ContextOptions<in out TParentRoute extends AnyRoute, in out TParams> {
36
+ abortController: AbortController;
37
+ preload: boolean;
38
+ params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>;
39
+ location: ParsedLocation;
40
+ /**
41
+ * @deprecated Use `throw redirect({ to: '/somewhere' })` instead
42
+ **/
43
+ navigate: NavigateFn;
44
+ buildLocation: BuildLocationFn;
45
+ cause: 'preload' | 'enter' | 'stay';
46
+ matches: Array<MakeRouteMatchUnion>;
47
+ }
48
+ export interface RouteContextOptions<in out TParentRoute extends AnyRoute, in out TParams, in out TRouterContext, in out TLoaderDeps> extends ContextOptions<TParentRoute, TParams> {
49
+ deps: TLoaderDeps;
50
+ context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>;
51
+ }
52
+ export interface RemountDepsOptions<in out TRouteId, in out TFullSearchSchema, in out TAllParams, in out TLoaderDeps> {
53
+ routeId: TRouteId;
54
+ search: TFullSearchSchema;
55
+ params: TAllParams;
56
+ loaderDeps: TLoaderDeps;
57
+ }
58
+ export type MakeRemountDepsOptionsUnion<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TRoute extends AnyRoute = ParseRoute<TRouteTree>> = TRoute extends any ? RemountDepsOptions<TRoute['id'], TRoute['types']['fullSearchSchema'], TRoute['types']['allParams'], TRoute['types']['loaderDeps']> : never;
59
+ export interface BeforeLoadContextOptions<in out TParentRoute extends AnyRoute, in out TSearchValidator, in out TParams, in out TRouterContext, in out TRouteContextFn> extends ContextOptions<TParentRoute, TParams>, FullSearchSchemaOption<TParentRoute, TSearchValidator> {
60
+ context: Expand<BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>>;
61
+ }
62
+ type AssetFnContextOptions<in out TRouteId, in out TFullPath, in out TParentRoute extends AnyRoute, in out TParams, in out TSearchValidator, in out TLoaderFn, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn, in out TLoaderDeps> = {
63
+ matches: Array<RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>>;
64
+ match: RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>;
65
+ params: ResolveAllParamsFromParent<TParentRoute, TParams>;
66
+ loaderData: ResolveLoaderData<TLoaderFn>;
67
+ };
68
+ export interface UpdatableRouteOptions<in out TParentRoute extends AnyRoute, in out TRouteId, in out TFullPath, in out TParams, in out TSearchValidator, in out TLoaderFn, in out TLoaderDeps, in out TRouterContext, in out TRouteContextFn, in out TBeforeLoadFn> extends UpdatableStaticRouteOption {
69
+ caseSensitive?: boolean;
70
+ wrapInSuspense?: boolean;
71
+ component?: RouteComponent;
72
+ errorComponent?: false | null | ErrorRouteComponent;
73
+ notFoundComponent?: NotFoundRouteComponent;
74
+ pendingComponent?: RouteComponent;
75
+ pendingMs?: number;
76
+ pendingMinMs?: number;
77
+ staleTime?: number;
78
+ gcTime?: number;
79
+ preload?: boolean;
80
+ preloadStaleTime?: number;
81
+ preloadGcTime?: number;
82
+ search?: {
83
+ middlewares?: Array<SearchMiddleware<ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>>>;
84
+ };
85
+ /**
86
+ @deprecated Use search.middlewares instead
87
+ */
88
+ preSearchFilters?: Array<SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>>;
89
+ /**
90
+ @deprecated Use search.middlewares instead
91
+ */
92
+ postSearchFilters?: Array<SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>>;
93
+ onCatch?: (error: Error) => void;
94
+ onError?: (err: any) => void;
95
+ onEnter?: (match: RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>) => void;
96
+ onStay?: (match: RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>) => void;
97
+ onLeave?: (match: RouteMatch<TRouteId, TFullPath, ResolveAllParamsFromParent<TParentRoute, TParams>, ResolveFullSearchSchema<TParentRoute, TSearchValidator>, ResolveLoaderData<TLoaderFn>, ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>, TLoaderDeps>) => void;
98
+ headers?: (ctx: {
99
+ loaderData: ResolveLoaderData<TLoaderFn>;
100
+ }) => Record<string, string>;
101
+ head?: (ctx: AssetFnContextOptions<TRouteId, TFullPath, TParentRoute, TParams, TSearchValidator, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps>) => {
102
+ links?: AnyRouteMatch['links'];
103
+ scripts?: AnyRouteMatch['headScripts'];
104
+ meta?: AnyRouteMatch['meta'];
105
+ };
106
+ scripts?: (ctx: AssetFnContextOptions<TRouteId, TFullPath, TParentRoute, TParams, TSearchValidator, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps>) => AnyRouteMatch['scripts'];
107
+ ssr?: boolean;
108
+ codeSplitGroupings?: Array<Array<'loader' | 'component' | 'pendingComponent' | 'notFoundComponent' | 'errorComponent'>>;
109
+ }
110
+ export type RouteLoaderFn<in out TParentRoute extends AnyRoute = AnyRoute, in out TId extends string = string, in out TParams = {}, in out TLoaderDeps = {}, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext> = (match: LoaderFnContext<TParentRoute, TId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => any;
111
+ export interface LoaderFnContext<in out TParentRoute extends AnyRoute = AnyRoute, in out TId extends string = string, in out TParams = {}, in out TLoaderDeps = {}, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext> {
112
+ abortController: AbortController;
113
+ preload: boolean;
114
+ params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>;
115
+ deps: TLoaderDeps;
116
+ context: Expand<ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>>;
117
+ location: ParsedLocation;
118
+ /**
119
+ * @deprecated Use `throw redirect({ to: '/somewhere' })` instead
120
+ **/
121
+ navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void> | void;
122
+ parentMatchPromise: TId extends RootRouteId ? never : Promise<MakeRouteMatchFromRoute<TParentRoute>>;
123
+ cause: 'preload' | 'enter' | 'stay';
124
+ route: Route;
125
+ }
126
+ export type ResolveFullSearchSchema<TParentRoute extends AnyRoute, TSearchValidator> = unknown extends TParentRoute ? ResolveValidatorOutput<TSearchValidator> : IntersectAssign<InferFullSearchSchema<TParentRoute>, ResolveValidatorOutput<TSearchValidator>>;
127
+ export type ResolveFullSearchSchemaInput<TParentRoute extends AnyRoute, TSearchValidator> = IntersectAssign<InferFullSearchSchemaInput<TParentRoute>, ResolveSearchValidatorInput<TSearchValidator>>;
128
+ export type RouteContextParameter<TParentRoute extends AnyRoute, TRouterContext> = unknown extends TParentRoute ? TRouterContext : Assign<TRouterContext, InferAllContext<TParentRoute>>;
129
+ export type BeforeLoadContextParameter<TParentRoute extends AnyRoute, TRouterContext, TRouteContextFn> = Assign<RouteContextParameter<TParentRoute, TRouterContext>, ContextReturnType<TRouteContextFn>>;
130
+ export type ResolveAllContext<TParentRoute extends AnyRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn> = Assign<BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>, ContextAsyncReturnType<TBeforeLoadFn>>;
131
+ export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any> {
132
+ }
133
+ export type AnyRouteWithContext<TContext> = AnyRoute & {
134
+ types: {
135
+ allContext: TContext;
136
+ };
137
+ };
138
+ export type ResolveAllParamsFromParent<TParentRoute extends AnyRoute, TParams> = Assign<InferAllParams<TParentRoute>, TParams>;
139
+ export type RouteConstraints = {
140
+ TParentRoute: AnyRoute;
141
+ TPath: string;
142
+ TFullPath: string;
143
+ TCustomId: string;
144
+ TId: string;
145
+ TSearchSchema: AnySchema;
146
+ TFullSearchSchema: AnySchema;
147
+ TParams: Record<string, any>;
148
+ TAllParams: Record<string, any>;
149
+ TParentContext: AnyContext;
150
+ TRouteContext: RouteContext;
151
+ TAllContext: AnyContext;
152
+ TRouterContext: AnyContext;
153
+ TChildren: unknown;
154
+ TRouteTree: AnyRoute;
155
+ };
156
+ export type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<TRouter['routeTree'], TId>['types'];
157
+ export declare function getRouteApi<const TId, TRouter extends AnyRouter = RegisteredRouter>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>): RouteApi<TId, TRouter>;
158
+ export declare class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {
159
+ id: TId;
160
+ /**
161
+ * @deprecated Use the `getRouteApi` function instead.
162
+ */
163
+ constructor({ id }: {
164
+ id: TId;
165
+ });
166
+ useMatch: UseMatchRoute<TId>;
167
+ useRouteContext: UseRouteContextRoute<TId>;
168
+ useSearch: UseSearchRoute<TId>;
169
+ useParams: UseParamsRoute<TId>;
170
+ useLoaderDeps: UseLoaderDepsRoute<TId>;
171
+ useLoaderData: UseLoaderDataRoute<TId>;
172
+ useNavigate: () => UseNavigateResult<RouteTypesById<TRouter, TId>["fullPath"]>;
173
+ notFound: (opts?: NotFoundError) => NotFoundError;
174
+ }
175
+ export declare class Route<in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, in out TPath extends RouteConstraints['TPath'] = '/', in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends RouteConstraints['TCustomId'] = string, in out TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchValidator = undefined, in out TParams = ResolveParams<TPath>, in out TRouterContext = AnyContext, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown> {
176
+ isRoot: TParentRoute extends Route<any> ? true : false;
177
+ options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>;
178
+ parentRoute: TParentRoute;
179
+ private _id;
180
+ private _path;
181
+ private _fullPath;
182
+ private _to;
183
+ private _ssr;
184
+ get to(): TrimPathRight<TFullPath>;
185
+ get id(): TId;
186
+ get path(): TPath;
187
+ get fullPath(): TFullPath;
188
+ get ssr(): boolean;
189
+ children?: TChildren;
190
+ originalIndex?: number;
191
+ rank: number;
192
+ lazyFn?: () => Promise<LazyRoute<any>>;
193
+ _lazyPromise?: Promise<void>;
194
+ _componentsPromise?: Promise<Array<void>>;
195
+ /**
196
+ * @deprecated Use the `createRoute` function instead.
197
+ */
198
+ constructor(options?: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>);
199
+ types: {
200
+ parentRoute: TParentRoute;
201
+ path: TPath;
202
+ to: TrimPathRight<TFullPath>;
203
+ fullPath: TFullPath;
204
+ customId: TCustomId;
205
+ id: TId;
206
+ searchSchema: ResolveValidatorOutput<TSearchValidator>;
207
+ searchSchemaInput: ResolveSearchValidatorInput<TSearchValidator>;
208
+ searchValidator: TSearchValidator;
209
+ fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>;
210
+ fullSearchSchemaInput: ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>;
211
+ params: TParams;
212
+ allParams: ResolveAllParamsFromParent<TParentRoute, TParams>;
213
+ routerContext: TRouterContext;
214
+ routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>;
215
+ routeContextFn: TRouteContextFn;
216
+ beforeLoadFn: TBeforeLoadFn;
217
+ allContext: ResolveAllContext<TParentRoute, TRouterContext, TRouteContextFn, TBeforeLoadFn>;
218
+ children: TChildren;
219
+ loaderData: ResolveLoaderData<TLoaderFn>;
220
+ loaderDeps: TLoaderDeps;
221
+ };
222
+ init: (opts: {
223
+ originalIndex: number;
224
+ defaultSsr?: boolean;
225
+ }) => void;
226
+ addChildren<const TNewChildren>(children: Constrain<TNewChildren, ReadonlyArray<AnyRoute> | Record<string, AnyRoute>>): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren>;
227
+ _addFileChildren<const TNewChildren>(children: TNewChildren): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren>;
228
+ updateLoader: <TNewLoaderFn>(options: {
229
+ loader: Constrain<TNewLoaderFn, RouteLoaderFn<TParentRoute, TCustomId, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>>;
230
+ }) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TNewLoaderFn, TChildren>;
231
+ update: (options: UpdatableRouteOptions<TParentRoute, TCustomId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>) => this;
232
+ lazy: (lazyFn: () => Promise<LazyRoute<any>>) => this;
233
+ useMatch: UseMatchRoute<TId>;
234
+ useRouteContext: UseRouteContextRoute<TId>;
235
+ useSearch: UseSearchRoute<TId>;
236
+ useParams: UseParamsRoute<TId>;
237
+ useLoaderDeps: UseLoaderDepsRoute<TId>;
238
+ useLoaderData: UseLoaderDataRoute<TId>;
239
+ useNavigate: () => UseNavigateResult<TFullPath>;
240
+ }
241
+ export declare function createRoute<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown>(options: RouteOptions<TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn>): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren>;
242
+ export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>;
243
+ export type RootRouteOptions<TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined> = Omit<RouteOptions<any, // TParentRoute
244
+ RootRouteId, // TId
245
+ RootRouteId, // TCustomId
246
+ '', // TFullPath
247
+ '', // TPath
248
+ TSearchValidator, {}, // TParams
249
+ TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'params'>;
250
+ export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>) => RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown>;
251
+ /**
252
+ * @deprecated Use the `createRootRouteWithContext` function instead.
253
+ */
254
+ export declare const rootRouteWithContext: typeof createRootRouteWithContext;
255
+ export declare class RootRoute<in out TSearchValidator = undefined, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> extends Route<any, // TParentRoute
256
+ '/', // TPath
257
+ '/', // TFullPath
258
+ string, // TCustomId
259
+ RootRouteId, // TId
260
+ TSearchValidator, // TSearchValidator
261
+ {}, // TParams
262
+ TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren> {
263
+ /**
264
+ * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
265
+ */
266
+ constructor(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>);
267
+ addChildren<const TNewChildren>(children: Constrain<TNewChildren, ReadonlyArray<AnyRoute> | Record<string, AnyRoute>>): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
268
+ _addFileChildren<const TNewChildren>(children: TNewChildren): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
269
+ _addFileTypes<TFileRouteTypes>(): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>;
270
+ }
271
+ export declare function createRootRoute<TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown>;
272
+ export type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
273
+ export type RouteMask<TRouteTree extends AnyRoute> = {
274
+ routeTree: TRouteTree;
275
+ from: RoutePaths<TRouteTree>;
276
+ to?: any;
277
+ params?: any;
278
+ search?: any;
279
+ hash?: any;
280
+ state?: any;
281
+ unmaskOnReload?: boolean;
282
+ };
283
+ export declare function createRouteMask<TRouteTree extends AnyRoute, TFrom extends string, TTo extends string>(opts: {
284
+ routeTree: TRouteTree;
285
+ } & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>): RouteMask<TRouteTree>;
286
+ export type SolidNode = Solid.JSX.Element;
287
+ export type SyncRouteComponent<TProps> = (props: TProps) => Solid.JSX.Element;
288
+ export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
289
+ preload?: () => Promise<void>;
290
+ };
291
+ export type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>;
292
+ export type ErrorRouteComponent = RouteComponent<ErrorComponentProps>;
293
+ export type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>;
294
+ export declare class NotFoundRoute<TParentRoute extends AnyRootRoute, TRouterContext = AnyContext, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown> extends Route<TParentRoute, '/404', '/404', '404', '404', TSearchValidator, {}, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren> {
295
+ constructor(options: Omit<RouteOptions<TParentRoute, string, string, string, string, TSearchValidator, {}, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>, 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id' | 'params'>);
296
+ }
297
+ export {};
@@ -0,0 +1,233 @@
1
+ import invariant from "tiny-invariant";
2
+ import { rootRouteId, trimPathLeft, joinPaths } from "@tanstack/router-core";
3
+ import { useLoaderData } from "./useLoaderData.js";
4
+ import { useLoaderDeps } from "./useLoaderDeps.js";
5
+ import { useParams } from "./useParams.js";
6
+ import { useSearch } from "./useSearch.js";
7
+ import { notFound } from "./not-found.js";
8
+ import { useNavigate } from "./useNavigate.js";
9
+ import { useMatch } from "./useMatch.js";
10
+ function getRouteApi(id) {
11
+ return new RouteApi({ id });
12
+ }
13
+ class RouteApi {
14
+ /**
15
+ * @deprecated Use the `getRouteApi` function instead.
16
+ */
17
+ constructor({ id }) {
18
+ this.useMatch = (opts) => {
19
+ return useMatch({
20
+ select: opts == null ? void 0 : opts.select,
21
+ from: this.id
22
+ });
23
+ };
24
+ this.useRouteContext = (opts) => {
25
+ return useMatch({
26
+ from: this.id,
27
+ select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
28
+ });
29
+ };
30
+ this.useSearch = (opts) => {
31
+ return useSearch({
32
+ select: opts == null ? void 0 : opts.select,
33
+ from: this.id
34
+ });
35
+ };
36
+ this.useParams = (opts) => {
37
+ return useParams({
38
+ select: opts == null ? void 0 : opts.select,
39
+ from: this.id
40
+ });
41
+ };
42
+ this.useLoaderDeps = (opts) => {
43
+ return useLoaderDeps({ ...opts, from: this.id, strict: false });
44
+ };
45
+ this.useLoaderData = (opts) => {
46
+ return useLoaderData({ ...opts, from: this.id, strict: false });
47
+ };
48
+ this.useNavigate = () => {
49
+ return useNavigate({ from: this.id });
50
+ };
51
+ this.notFound = (opts) => {
52
+ return notFound({ routeId: this.id, ...opts });
53
+ };
54
+ this.id = id;
55
+ }
56
+ }
57
+ class Route {
58
+ /**
59
+ * @deprecated Use the `createRoute` function instead.
60
+ */
61
+ constructor(options) {
62
+ this.init = (opts) => {
63
+ var _a, _b;
64
+ this.originalIndex = opts.originalIndex;
65
+ const options2 = this.options;
66
+ const isRoot = !(options2 == null ? void 0 : options2.path) && !(options2 == null ? void 0 : options2.id);
67
+ this.parentRoute = (_b = (_a = this.options).getParentRoute) == null ? void 0 : _b.call(_a);
68
+ if (isRoot) {
69
+ this._path = rootRouteId;
70
+ } else {
71
+ invariant(
72
+ this.parentRoute,
73
+ `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`
74
+ );
75
+ }
76
+ let path = isRoot ? rootRouteId : options2.path;
77
+ if (path && path !== "/") {
78
+ path = trimPathLeft(path);
79
+ }
80
+ const customId = (options2 == null ? void 0 : options2.id) || path;
81
+ let id = isRoot ? rootRouteId : joinPaths([
82
+ this.parentRoute.id === rootRouteId ? "" : this.parentRoute.id,
83
+ customId
84
+ ]);
85
+ if (path === rootRouteId) {
86
+ path = "/";
87
+ }
88
+ if (id !== rootRouteId) {
89
+ id = joinPaths(["/", id]);
90
+ }
91
+ const fullPath = id === rootRouteId ? "/" : joinPaths([this.parentRoute.fullPath, path]);
92
+ this._path = path;
93
+ this._id = id;
94
+ this._fullPath = fullPath;
95
+ this._to = fullPath;
96
+ this._ssr = (options2 == null ? void 0 : options2.ssr) ?? opts.defaultSsr ?? true;
97
+ };
98
+ this.updateLoader = (options2) => {
99
+ Object.assign(this.options, options2);
100
+ return this;
101
+ };
102
+ this.update = (options2) => {
103
+ Object.assign(this.options, options2);
104
+ return this;
105
+ };
106
+ this.lazy = (lazyFn) => {
107
+ this.lazyFn = lazyFn;
108
+ return this;
109
+ };
110
+ this.useMatch = (opts) => {
111
+ return useMatch({
112
+ select: opts == null ? void 0 : opts.select,
113
+ from: this.id
114
+ });
115
+ };
116
+ this.useRouteContext = (opts) => {
117
+ return useMatch({
118
+ ...opts,
119
+ from: this.id,
120
+ select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
121
+ });
122
+ };
123
+ this.useSearch = (opts) => {
124
+ return useSearch({
125
+ select: opts == null ? void 0 : opts.select,
126
+ from: this.id
127
+ });
128
+ };
129
+ this.useParams = (opts) => {
130
+ return useParams({
131
+ select: opts == null ? void 0 : opts.select,
132
+ from: this.id
133
+ });
134
+ };
135
+ this.useLoaderDeps = (opts) => {
136
+ return useLoaderDeps({ ...opts, from: this.id });
137
+ };
138
+ this.useLoaderData = (opts) => {
139
+ return useLoaderData({ ...opts, from: this.id });
140
+ };
141
+ this.useNavigate = () => {
142
+ return useNavigate({ from: this.id });
143
+ };
144
+ this.options = options || {};
145
+ this.isRoot = !(options == null ? void 0 : options.getParentRoute);
146
+ invariant(
147
+ !((options == null ? void 0 : options.id) && (options == null ? void 0 : options.path)),
148
+ `Route cannot have both an 'id' and a 'path' option.`
149
+ );
150
+ }
151
+ get to() {
152
+ return this._to;
153
+ }
154
+ get id() {
155
+ return this._id;
156
+ }
157
+ get path() {
158
+ return this._path;
159
+ }
160
+ get fullPath() {
161
+ return this._fullPath;
162
+ }
163
+ get ssr() {
164
+ return this._ssr;
165
+ }
166
+ addChildren(children) {
167
+ return this._addFileChildren(children);
168
+ }
169
+ _addFileChildren(children) {
170
+ if (Array.isArray(children)) {
171
+ this.children = children;
172
+ }
173
+ if (typeof children === "object" && children !== null) {
174
+ this.children = Object.values(children);
175
+ }
176
+ return this;
177
+ }
178
+ }
179
+ function createRoute(options) {
180
+ return new Route(options);
181
+ }
182
+ function createRootRouteWithContext() {
183
+ return (options) => {
184
+ return createRootRoute(options);
185
+ };
186
+ }
187
+ const rootRouteWithContext = createRootRouteWithContext;
188
+ class RootRoute extends Route {
189
+ /**
190
+ * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
191
+ */
192
+ constructor(options) {
193
+ super(options);
194
+ }
195
+ addChildren(children) {
196
+ super.addChildren(children);
197
+ return this;
198
+ }
199
+ _addFileChildren(children) {
200
+ super._addFileChildren(children);
201
+ return this;
202
+ }
203
+ _addFileTypes() {
204
+ return this;
205
+ }
206
+ }
207
+ function createRootRoute(options) {
208
+ return new RootRoute(options);
209
+ }
210
+ function createRouteMask(opts) {
211
+ return opts;
212
+ }
213
+ class NotFoundRoute extends Route {
214
+ constructor(options) {
215
+ super({
216
+ ...options,
217
+ id: "404"
218
+ });
219
+ }
220
+ }
221
+ export {
222
+ NotFoundRoute,
223
+ RootRoute,
224
+ Route,
225
+ RouteApi,
226
+ createRootRoute,
227
+ createRootRouteWithContext,
228
+ createRoute,
229
+ createRouteMask,
230
+ getRouteApi,
231
+ rootRouteWithContext
232
+ };
233
+ //# sourceMappingURL=route.js.map