@tanstack/react-router 1.20.0 → 1.20.3-alpha.1

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 (320) hide show
  1. package/README.md +31 -0
  2. package/dist/cjs/Asset.cjs +41 -0
  3. package/dist/cjs/Asset.cjs.map +1 -0
  4. package/dist/cjs/Asset.d.cts +2 -0
  5. package/dist/cjs/CatchBoundary.cjs +16 -12
  6. package/dist/cjs/CatchBoundary.cjs.map +1 -1
  7. package/dist/cjs/CatchBoundary.d.cts +8 -32
  8. package/dist/cjs/ClientOnly.cjs +20 -0
  9. package/dist/cjs/ClientOnly.cjs.map +1 -0
  10. package/dist/cjs/ClientOnly.d.cts +29 -0
  11. package/dist/cjs/HeadContent.cjs +155 -0
  12. package/dist/cjs/HeadContent.cjs.map +1 -0
  13. package/dist/cjs/HeadContent.d.cts +7 -0
  14. package/dist/cjs/Match.cjs +252 -0
  15. package/dist/cjs/Match.cjs.map +1 -0
  16. package/dist/cjs/Match.d.cts +8 -0
  17. package/dist/cjs/Matches.cjs +39 -287
  18. package/dist/cjs/Matches.cjs.map +1 -1
  19. package/dist/cjs/Matches.d.cts +23 -83
  20. package/dist/cjs/RouterProvider.cjs +17 -140
  21. package/dist/cjs/RouterProvider.cjs.map +1 -1
  22. package/dist/cjs/RouterProvider.d.cts +8 -27
  23. package/dist/cjs/SafeFragment.cjs +8 -0
  24. package/dist/cjs/SafeFragment.cjs.map +1 -0
  25. package/dist/cjs/SafeFragment.d.cts +1 -0
  26. package/dist/cjs/ScriptOnce.cjs +28 -0
  27. package/dist/cjs/ScriptOnce.cjs.map +1 -0
  28. package/dist/cjs/ScriptOnce.d.cts +5 -0
  29. package/dist/cjs/Scripts.cjs +51 -0
  30. package/dist/cjs/Scripts.cjs.map +1 -0
  31. package/dist/cjs/Scripts.d.cts +1 -0
  32. package/dist/cjs/ScrollRestoration.cjs +39 -0
  33. package/dist/cjs/ScrollRestoration.cjs.map +1 -0
  34. package/dist/cjs/ScrollRestoration.d.cts +14 -0
  35. package/dist/cjs/Transitioner.cjs +115 -0
  36. package/dist/cjs/Transitioner.cjs.map +1 -0
  37. package/dist/cjs/Transitioner.d.cts +1 -0
  38. package/dist/cjs/awaited.cjs +12 -65
  39. package/dist/cjs/awaited.cjs.map +1 -1
  40. package/dist/cjs/awaited.d.cts +4 -4
  41. package/dist/cjs/fileRoute.cjs +41 -15
  42. package/dist/cjs/fileRoute.cjs.map +1 -1
  43. package/dist/cjs/fileRoute.d.cts +33 -108
  44. package/dist/cjs/history.d.cts +1 -0
  45. package/dist/cjs/index.cjs +216 -73
  46. package/dist/cjs/index.cjs.map +1 -1
  47. package/dist/cjs/index.d.cts +52 -29
  48. package/dist/cjs/lazyRouteComponent.cjs +40 -29
  49. package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
  50. package/dist/cjs/lazyRouteComponent.d.cts +1 -1
  51. package/dist/cjs/link.cjs +212 -106
  52. package/dist/cjs/link.cjs.map +1 -1
  53. package/dist/cjs/link.d.cts +41 -86
  54. package/dist/cjs/matchContext.cjs +27 -0
  55. package/dist/cjs/matchContext.cjs.map +1 -0
  56. package/dist/cjs/matchContext.d.cts +3 -0
  57. package/dist/cjs/not-found.cjs +9 -15
  58. package/dist/cjs/not-found.cjs.map +1 -1
  59. package/dist/cjs/not-found.d.cts +5 -22
  60. package/dist/cjs/renderRouteNotFound.cjs +22 -0
  61. package/dist/cjs/renderRouteNotFound.cjs.map +1 -0
  62. package/dist/cjs/renderRouteNotFound.d.cts +2 -0
  63. package/dist/cjs/route.cjs +110 -79
  64. package/dist/cjs/route.cjs.map +1 -1
  65. package/dist/cjs/route.d.cts +64 -361
  66. package/dist/cjs/router.cjs +12 -1237
  67. package/dist/cjs/router.cjs.map +1 -1
  68. package/dist/cjs/router.d.cts +69 -237
  69. package/dist/cjs/routerContext.cjs +1 -1
  70. package/dist/cjs/routerContext.cjs.map +1 -1
  71. package/dist/cjs/routerContext.d.cts +7 -2
  72. package/dist/cjs/scroll-restoration.cjs +16 -177
  73. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  74. package/dist/cjs/scroll-restoration.d.cts +1 -18
  75. package/dist/cjs/serializer.d.cts +6 -0
  76. package/dist/cjs/structuralSharing.d.cts +8 -0
  77. package/dist/cjs/typePrimitives.d.cts +16 -0
  78. package/dist/cjs/useBlocker.cjs +138 -9
  79. package/dist/cjs/useBlocker.cjs.map +1 -1
  80. package/dist/cjs/useBlocker.d.cts +64 -7
  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 +15 -0
  85. package/dist/cjs/useLoaderData.cjs.map +1 -0
  86. package/dist/cjs/useLoaderData.d.cts +8 -0
  87. package/dist/cjs/useLoaderDeps.cjs +14 -0
  88. package/dist/cjs/useLoaderDeps.cjs.map +1 -0
  89. package/dist/cjs/useLoaderDeps.d.cts +8 -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 +47 -0
  94. package/dist/cjs/useMatch.cjs.map +1 -0
  95. package/dist/cjs/useMatch.d.cts +10 -0
  96. package/dist/cjs/useNavigate.cjs +18 -19
  97. package/dist/cjs/useNavigate.cjs.map +1 -1
  98. package/dist/cjs/useNavigate.d.cts +4 -8
  99. package/dist/cjs/useParams.cjs +8 -8
  100. package/dist/cjs/useParams.cjs.map +1 -1
  101. package/dist/cjs/useParams.d.cts +9 -8
  102. package/dist/cjs/useRouteContext.cjs +3 -3
  103. package/dist/cjs/useRouteContext.cjs.map +1 -1
  104. package/dist/cjs/useRouteContext.d.cts +3 -7
  105. package/dist/cjs/useRouter.cjs.map +1 -1
  106. package/dist/cjs/useRouter.d.cts +3 -4
  107. package/dist/cjs/useRouterState.cjs +18 -1
  108. package/dist/cjs/useRouterState.cjs.map +1 -1
  109. package/dist/cjs/useRouterState.d.cts +8 -6
  110. package/dist/cjs/useSearch.cjs +7 -4
  111. package/dist/cjs/useSearch.cjs.map +1 -1
  112. package/dist/cjs/useSearch.d.cts +9 -7
  113. package/dist/cjs/utils.cjs +40 -122
  114. package/dist/cjs/utils.cjs.map +1 -1
  115. package/dist/cjs/utils.d.cts +46 -50
  116. package/dist/esm/Asset.d.ts +2 -0
  117. package/dist/esm/Asset.js +41 -0
  118. package/dist/esm/Asset.js.map +1 -0
  119. package/dist/esm/CatchBoundary.d.ts +8 -32
  120. package/dist/esm/CatchBoundary.js +16 -12
  121. package/dist/esm/CatchBoundary.js.map +1 -1
  122. package/dist/esm/ClientOnly.d.ts +29 -0
  123. package/dist/esm/ClientOnly.js +20 -0
  124. package/dist/esm/ClientOnly.js.map +1 -0
  125. package/dist/esm/HeadContent.d.ts +7 -0
  126. package/dist/esm/HeadContent.js +139 -0
  127. package/dist/esm/HeadContent.js.map +1 -0
  128. package/dist/esm/Match.d.ts +8 -0
  129. package/dist/esm/Match.js +235 -0
  130. package/dist/esm/Match.js.map +1 -0
  131. package/dist/esm/Matches.d.ts +23 -83
  132. package/dist/esm/Matches.js +36 -284
  133. package/dist/esm/Matches.js.map +1 -1
  134. package/dist/esm/RouterProvider.d.ts +8 -27
  135. package/dist/esm/RouterProvider.js +20 -126
  136. package/dist/esm/RouterProvider.js.map +1 -1
  137. package/dist/esm/SafeFragment.d.ts +1 -0
  138. package/dist/esm/SafeFragment.js +8 -0
  139. package/dist/esm/SafeFragment.js.map +1 -0
  140. package/dist/esm/ScriptOnce.d.ts +5 -0
  141. package/dist/esm/ScriptOnce.js +28 -0
  142. package/dist/esm/ScriptOnce.js.map +1 -0
  143. package/dist/esm/Scripts.d.ts +1 -0
  144. package/dist/esm/Scripts.js +51 -0
  145. package/dist/esm/Scripts.js.map +1 -0
  146. package/dist/esm/ScrollRestoration.d.ts +14 -0
  147. package/dist/esm/ScrollRestoration.js +39 -0
  148. package/dist/esm/ScrollRestoration.js.map +1 -0
  149. package/dist/esm/Transitioner.d.ts +1 -0
  150. package/dist/esm/Transitioner.js +98 -0
  151. package/dist/esm/Transitioner.js.map +1 -0
  152. package/dist/esm/awaited.d.ts +4 -4
  153. package/dist/esm/awaited.js +12 -65
  154. package/dist/esm/awaited.js.map +1 -1
  155. package/dist/esm/fileRoute.d.ts +33 -108
  156. package/dist/esm/fileRoute.js +38 -12
  157. package/dist/esm/fileRoute.js.map +1 -1
  158. package/dist/esm/history.d.ts +1 -0
  159. package/dist/esm/index.d.ts +52 -29
  160. package/dist/esm/index.js +41 -29
  161. package/dist/esm/index.js.map +1 -1
  162. package/dist/esm/lazyRouteComponent.d.ts +1 -1
  163. package/dist/esm/lazyRouteComponent.js +40 -29
  164. package/dist/esm/lazyRouteComponent.js.map +1 -1
  165. package/dist/esm/link.d.ts +41 -86
  166. package/dist/esm/link.js +212 -106
  167. package/dist/esm/link.js.map +1 -1
  168. package/dist/esm/matchContext.d.ts +3 -0
  169. package/dist/esm/matchContext.js +10 -0
  170. package/dist/esm/matchContext.js.map +1 -0
  171. package/dist/esm/not-found.d.ts +5 -22
  172. package/dist/esm/not-found.js +9 -15
  173. package/dist/esm/not-found.js.map +1 -1
  174. package/dist/esm/renderRouteNotFound.d.ts +2 -0
  175. package/dist/esm/renderRouteNotFound.js +22 -0
  176. package/dist/esm/renderRouteNotFound.js.map +1 -0
  177. package/dist/esm/route.d.ts +64 -361
  178. package/dist/esm/route.js +103 -72
  179. package/dist/esm/route.js.map +1 -1
  180. package/dist/esm/router.d.ts +69 -237
  181. package/dist/esm/router.js +13 -1238
  182. package/dist/esm/router.js.map +1 -1
  183. package/dist/esm/routerContext.d.ts +7 -2
  184. package/dist/esm/routerContext.js +1 -1
  185. package/dist/esm/routerContext.js.map +1 -1
  186. package/dist/esm/scroll-restoration.d.ts +1 -18
  187. package/dist/esm/scroll-restoration.js +17 -161
  188. package/dist/esm/scroll-restoration.js.map +1 -1
  189. package/dist/esm/serializer.d.ts +6 -0
  190. package/dist/esm/structuralSharing.d.ts +8 -0
  191. package/dist/esm/typePrimitives.d.ts +16 -0
  192. package/dist/esm/useBlocker.d.ts +64 -7
  193. package/dist/esm/useBlocker.js +138 -9
  194. package/dist/esm/useBlocker.js.map +1 -1
  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 +8 -0
  199. package/dist/esm/useLoaderData.js +15 -0
  200. package/dist/esm/useLoaderData.js.map +1 -0
  201. package/dist/esm/useLoaderDeps.d.ts +8 -0
  202. package/dist/esm/useLoaderDeps.js +14 -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 +10 -0
  208. package/dist/esm/useMatch.js +30 -0
  209. package/dist/esm/useMatch.js.map +1 -0
  210. package/dist/esm/useNavigate.d.ts +4 -8
  211. package/dist/esm/useNavigate.js +18 -19
  212. package/dist/esm/useNavigate.js.map +1 -1
  213. package/dist/esm/useParams.d.ts +9 -8
  214. package/dist/esm/useParams.js +8 -8
  215. package/dist/esm/useParams.js.map +1 -1
  216. package/dist/esm/useRouteContext.d.ts +3 -7
  217. package/dist/esm/useRouteContext.js +2 -2
  218. package/dist/esm/useRouteContext.js.map +1 -1
  219. package/dist/esm/useRouter.d.ts +3 -4
  220. package/dist/esm/useRouter.js.map +1 -1
  221. package/dist/esm/useRouterState.d.ts +8 -6
  222. package/dist/esm/useRouterState.js +18 -1
  223. package/dist/esm/useRouterState.js.map +1 -1
  224. package/dist/esm/useSearch.d.ts +9 -7
  225. package/dist/esm/useSearch.js +6 -3
  226. package/dist/esm/useSearch.js.map +1 -1
  227. package/dist/esm/utils.d.ts +46 -50
  228. package/dist/esm/utils.js +41 -123
  229. package/dist/esm/utils.js.map +1 -1
  230. package/package.json +30 -31
  231. package/src/Asset.tsx +40 -0
  232. package/src/CatchBoundary.tsx +35 -19
  233. package/src/ClientOnly.tsx +68 -0
  234. package/src/HeadContent.tsx +174 -0
  235. package/src/Match.tsx +330 -0
  236. package/src/Matches.tsx +149 -558
  237. package/src/RouterProvider.tsx +58 -212
  238. package/src/SafeFragment.tsx +5 -0
  239. package/src/ScriptOnce.tsx +32 -0
  240. package/src/Scripts.tsx +65 -0
  241. package/src/ScrollRestoration.tsx +69 -0
  242. package/src/Transitioner.tsx +130 -0
  243. package/src/awaited.tsx +16 -87
  244. package/src/fileRoute.ts +145 -248
  245. package/src/history.ts +2 -1
  246. package/src/index.tsx +368 -30
  247. package/src/lazyRouteComponent.tsx +68 -54
  248. package/src/link.tsx +397 -522
  249. package/src/matchContext.tsx +8 -0
  250. package/src/not-found.tsx +13 -34
  251. package/src/renderRouteNotFound.tsx +27 -0
  252. package/src/route.tsx +572 -0
  253. package/src/router.ts +99 -2067
  254. package/src/routerContext.tsx +8 -2
  255. package/src/scroll-restoration.tsx +23 -224
  256. package/src/serializer.ts +7 -0
  257. package/src/structuralSharing.ts +47 -0
  258. package/src/typePrimitives.ts +84 -0
  259. package/src/useBlocker.tsx +297 -15
  260. package/src/useCanGoBack.ts +5 -0
  261. package/src/useLoaderData.tsx +80 -0
  262. package/src/useLoaderDeps.tsx +58 -0
  263. package/src/useLocation.tsx +41 -0
  264. package/src/useMatch.tsx +119 -0
  265. package/src/useNavigate.tsx +41 -61
  266. package/src/useParams.tsx +88 -23
  267. package/src/useRouteContext.ts +24 -18
  268. package/src/useRouter.tsx +4 -5
  269. package/src/useRouterState.tsx +52 -10
  270. package/src/useSearch.tsx +87 -24
  271. package/src/utils.ts +97 -312
  272. package/dist/cjs/createServerFn.cjs +0 -40
  273. package/dist/cjs/createServerFn.cjs.map +0 -1
  274. package/dist/cjs/createServerFn.d.cts +0 -44
  275. package/dist/cjs/defer.cjs +0 -30
  276. package/dist/cjs/defer.cjs.map +0 -1
  277. package/dist/cjs/defer.d.cts +0 -25
  278. package/dist/cjs/location.d.cts +0 -12
  279. package/dist/cjs/path.cjs +0 -213
  280. package/dist/cjs/path.cjs.map +0 -1
  281. package/dist/cjs/path.d.cts +0 -24
  282. package/dist/cjs/qss.cjs +0 -45
  283. package/dist/cjs/qss.cjs.map +0 -1
  284. package/dist/cjs/qss.d.cts +0 -2
  285. package/dist/cjs/redirects.cjs +0 -16
  286. package/dist/cjs/redirects.cjs.map +0 -1
  287. package/dist/cjs/redirects.d.cts +0 -18
  288. package/dist/cjs/routeInfo.d.cts +0 -33
  289. package/dist/cjs/searchParams.cjs +0 -63
  290. package/dist/cjs/searchParams.cjs.map +0 -1
  291. package/dist/cjs/searchParams.d.cts +0 -7
  292. package/dist/esm/createServerFn.d.ts +0 -44
  293. package/dist/esm/createServerFn.js +0 -40
  294. package/dist/esm/createServerFn.js.map +0 -1
  295. package/dist/esm/defer.d.ts +0 -25
  296. package/dist/esm/defer.js +0 -30
  297. package/dist/esm/defer.js.map +0 -1
  298. package/dist/esm/location.d.ts +0 -12
  299. package/dist/esm/path.d.ts +0 -24
  300. package/dist/esm/path.js +0 -213
  301. package/dist/esm/path.js.map +0 -1
  302. package/dist/esm/qss.d.ts +0 -2
  303. package/dist/esm/qss.js +0 -45
  304. package/dist/esm/qss.js.map +0 -1
  305. package/dist/esm/redirects.d.ts +0 -18
  306. package/dist/esm/redirects.js +0 -16
  307. package/dist/esm/redirects.js.map +0 -1
  308. package/dist/esm/routeInfo.d.ts +0 -33
  309. package/dist/esm/searchParams.d.ts +0 -7
  310. package/dist/esm/searchParams.js +0 -63
  311. package/dist/esm/searchParams.js.map +0 -1
  312. package/src/createServerFn.ts +0 -107
  313. package/src/defer.ts +0 -70
  314. package/src/location.ts +0 -13
  315. package/src/path.ts +0 -280
  316. package/src/qss.ts +0 -53
  317. package/src/redirects.ts +0 -56
  318. package/src/route.ts +0 -1356
  319. package/src/routeInfo.ts +0 -62
  320. package/src/searchParams.ts +0 -79
@@ -1,93 +1,48 @@
1
+ import { AnyRouter, Constrain, LinkOptions, RegisteredRouter, RoutePaths } from '@tanstack/router-core';
2
+ import { ReactNode } from 'react';
3
+ import { ValidateLinkOptions, ValidateLinkOptionsArray } from './typePrimitives.cjs';
1
4
  import * as React from 'react';
2
- import { Trim } from './fileRoute.cjs';
3
- import { AnyRoute, RootSearchSchema } from './route.cjs';
4
- import { RouteByPath, RoutePaths, RoutePathsAutoComplete } from './routeInfo.cjs';
5
- import { RegisteredRouter } from './router.cjs';
6
- import { Expand, IsUnion, MakeDifferenceOptional, NoInfer, NonNullableUpdater, PickRequired, Updater, WithoutEmpty } from './utils.cjs';
7
- import { HistoryState } from '@tanstack/history';
8
- export type CleanPath<T extends string> = T extends `${infer L}//${infer R}` ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`> : T extends `${infer L}//` ? `${CleanPath<L>}/` : T extends `//${infer L}` ? `/${CleanPath<L>}` : T;
9
- export type Split<S, TIncludeTrailingSlash = true> = S extends unknown ? string extends S ? string[] : S extends string ? CleanPath<S> extends '' ? [] : TIncludeTrailingSlash extends true ? CleanPath<S> extends `${infer T}/` ? [...Split<T>, '/'] : CleanPath<S> extends `/${infer U}` ? Split<U> : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : [S] : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : S extends string ? [S] : never : never : never;
10
- export type ParsePathParams<T extends string> = keyof {
11
- [K in Trim<Split<T>[number], '_'> as K extends `$${infer L}` ? L extends '' ? '_splat' : L : never]: K;
12
- };
13
- export type Join<T, Delimiter extends string = '/'> = T extends [] ? '' : T extends [infer L extends string] ? L : T extends [infer L extends string, ...infer Tail extends [...string[]]] ? CleanPath<`${L}${Delimiter}${Join<Tail>}`> : never;
14
- export type Last<T extends any[]> = T extends [...infer _, infer L] ? L : never;
15
- export type RemoveTrailingSlashes<T> = T extends `${infer R}/` ? RemoveTrailingSlashes<R> : T;
16
- export type RemoveLeadingSlashes<T> = T extends `/${infer R}` ? RemoveLeadingSlashes<R> : T;
17
- export type SearchPaths<TPaths, TSearchPath extends string> = TPaths extends `${TSearchPath}/${infer TRest}` ? TRest : never;
18
- export type SearchRelativePathAutoComplete<TTo extends string, TSearchPath extends string, TPaths, SearchedPaths = SearchPaths<TPaths, TSearchPath>> = SearchedPaths extends string ? `${TTo}/${SearchedPaths}` : never;
19
- export type RelativeToParentPathAutoComplete<TFrom extends string, TTo extends string, TPaths, TResolvedPath extends string = RemoveTrailingSlashes<ResolveRelativePath<TFrom, TTo>>> = SearchRelativePathAutoComplete<TTo, TResolvedPath, TPaths> | (TResolvedPath extends '' ? never : `${TTo}/../`);
20
- export type RelativeToCurrentPathAutoComplete<TFrom extends string, TTo extends string, TRestTo extends string, TPaths, TResolvedPath extends string = RemoveTrailingSlashes<`${RemoveTrailingSlashes<TFrom>}/${RemoveLeadingSlashes<TRestTo>}`>> = SearchRelativePathAutoComplete<TTo, TResolvedPath, TPaths>;
21
- export type AbsolutePathAutoComplete<TFrom extends string, TPaths> = (string extends TFrom ? './' : TFrom extends `/` ? never : SearchPaths<TPaths, RemoveTrailingSlashes<TFrom>> extends infer SearchedPaths ? SearchedPaths extends '' ? never : './' : never) | (string extends TFrom ? '../' : TFrom extends `/` ? never : '../') | TPaths;
22
- export type RelativeToPathAutoComplete<TRouteTree extends AnyRoute, TFrom extends string, TTo extends string, TPaths = RoutePaths<TRouteTree>> = TTo extends `..${string}` ? RelativeToParentPathAutoComplete<TFrom, RemoveTrailingSlashes<TTo>, TPaths> : TTo extends `./${infer TRestTTo}` ? RelativeToCurrentPathAutoComplete<TFrom, RemoveTrailingSlashes<TTo>, TRestTTo, TPaths> : AbsolutePathAutoComplete<TFrom, TPaths>;
23
- export type NavigateOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
24
- replace?: boolean;
25
- resetScroll?: boolean;
26
- startTransition?: boolean;
27
- };
28
- export type ToOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ToSubOptions<TRouteTree, TFrom, TTo> & {
29
- mask?: ToMaskOptions<TRouteTree, TMaskFrom, TMaskTo>;
30
- };
31
- export type ToMaskOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TMaskFrom extends RoutePaths<TRouteTree> | string = string, TMaskTo extends string = ''> = ToSubOptions<TRouteTree, TMaskFrom, TMaskTo> & {
32
- unmaskOnReload?: boolean;
33
- };
34
- export type ToSubOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = ''> = {
35
- to?: ToPathOption<TRouteTree, TFrom, TTo>;
36
- hash?: true | Updater<string>;
37
- state?: true | NonNullableUpdater<HistoryState>;
38
- from?: RoutePathsAutoComplete<TRouteTree, TFrom>;
39
- } & CheckPath<TRouteTree, {}, TFrom, TTo> & SearchParamOptions<TRouteTree, TFrom, TTo> & PathParamOptions<TRouteTree, TFrom, TTo>;
40
- type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
41
- type ParamVariant = 'PATH' | 'SEARCH';
42
- type ExcludeRootSearchSchema<T, Excluded = Exclude<T, RootSearchSchema>> = [
43
- Excluded
44
- ] extends [never] ? {} : Excluded;
45
- export type ResolveRoute<TRouteTree extends AnyRoute, TFrom, TTo, TPath = RemoveTrailingSlashes<string extends TTo ? TFrom : ResolveRelativePath<TFrom, TTo>>> = RouteByPath<TRouteTree, `${TPath & string}/`> extends never ? RouteByPath<TRouteTree, TPath> : RouteByPath<TRouteTree, `${TPath & string}/`>;
46
- type PostProcessParams<T, TParamVariant extends ParamVariant> = TParamVariant extends 'SEARCH' ? ExcludeRootSearchSchema<T> : T;
47
- export type ParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string, TParamVariant extends ParamVariant, TFromRouteType extends 'allParams' | 'fullSearchSchema' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema', TToRouteType extends 'allParams' | 'fullSearchSchemaInput' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput', TFromParams = PostProcessParams<RouteByPath<TRouteTree, TFrom>['types'][TFromRouteType], TParamVariant>, TToParams = PostProcessParams<ResolveRoute<TRouteTree, TFrom, TTo>['types'][TToRouteType], TParamVariant>, TRelativeToParams = TParamVariant extends 'SEARCH' ? TToParams : true extends IsUnion<TFromParams> ? TToParams : MakeDifferenceOptional<TFromParams, TToParams>, TReducer = ParamsReducer<TFromParams, TRelativeToParams>> = Expand<WithoutEmpty<PickRequired<TRelativeToParams>>> extends never ? Partial<MakeParamOption<TParamVariant, true | TReducer>> : TFromParams extends Expand<WithoutEmpty<PickRequired<TRelativeToParams>>> ? MakeParamOption<TParamVariant, true | TReducer> : MakeParamOption<TParamVariant, TReducer>;
48
- type MakeParamOption<TParamVariant extends ParamVariant, T> = TParamVariant extends 'PATH' ? MakePathParamOptions<T> : MakeSearchParamOptions<T>;
49
- type MakeSearchParamOptions<T> = {
50
- search: T;
51
- };
52
- type MakePathParamOptions<T> = {
53
- params: T;
54
- };
55
- export type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string> = ParamOptions<TRouteTree, TFrom, TTo, 'SEARCH'>;
56
- export type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string> = ParamOptions<TRouteTree, TFrom, TTo, 'PATH'>;
57
- export type ToPathOption<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = ''> = TTo | RelativeToPathAutoComplete<TRouteTree, NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
58
- export interface ActiveOptions {
59
- exact?: boolean;
60
- includeHash?: boolean;
61
- includeSearch?: boolean;
5
+ export declare function useLinkProps<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>, forwardedRef?: React.ForwardedRef<Element>): React.ComponentPropsWithRef<'a'>;
6
+ type UseLinkReactProps<TComp> = TComp extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[TComp] : React.PropsWithoutRef<TComp extends React.ComponentType<infer TProps> ? TProps : never> & React.RefAttributes<TComp extends React.FC<{
7
+ ref: infer TRef;
8
+ }> | React.Component<{
9
+ ref: infer TRef;
10
+ }> ? TRef : never>;
11
+ export type UseLinkPropsOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string | undefined = '.', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & UseLinkReactProps<'a'>;
12
+ export type ActiveLinkOptions<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & ActiveLinkOptionProps<TComp>;
13
+ type ActiveLinkProps<TComp> = Partial<LinkComponentReactProps<TComp> & {
14
+ [key: `data-${string}`]: unknown;
15
+ }>;
16
+ export interface ActiveLinkOptionProps<TComp = 'a'> {
17
+ /**
18
+ * A function that returns additional props for the `active` state of this link.
19
+ * These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
20
+ */
21
+ activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>);
22
+ /**
23
+ * A function that returns additional props for the `inactive` state of this link.
24
+ * These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
25
+ */
26
+ inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>);
62
27
  }
63
- export type LinkOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
64
- target?: HTMLAnchorElement['target'];
65
- activeOptions?: ActiveOptions;
66
- preload?: false | 'intent';
67
- preloadDelay?: number;
68
- disabled?: boolean;
69
- };
70
- export type CheckPath<TRouteTree extends AnyRoute, TPass, TFrom, TTo> = ResolveRoute<TRouteTree, TFrom, TTo> extends never ? string extends TFrom ? RemoveTrailingSlashes<TTo> extends '.' | '..' ? TPass : CheckPathError<TRouteTree> : CheckPathError<TRouteTree> : TPass;
71
- export type CheckPathError<TRouteTree extends AnyRoute> = {
72
- to: RoutePaths<TRouteTree>;
73
- };
74
- export type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string ? TTo extends string ? TTo extends '.' ? TFrom : TTo extends `./` ? Join<[TFrom, '/']> : TTo extends `./${infer TRest}` ? ResolveRelativePath<TFrom, TRest> : TTo extends `/${infer TRest}` ? TTo : Split<TTo> extends ['..', ...infer ToRest] ? Split<TFrom> extends [...infer FromRest, infer FromTail] ? ToRest extends ['/'] ? Join<['/', ...FromRest, '/']> : ResolveRelativePath<Join<FromRest>, Join<ToRest>> : never : Split<TTo> extends ['.', ...infer ToRest] ? ToRest extends ['/'] ? Join<[TFrom, '/']> : ResolveRelativePath<TFrom, Join<ToRest>> : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>> : never : never;
75
- export declare function useLinkProps<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''>(options: UseLinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
76
- export type UseLinkPropsOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ActiveLinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
77
- export type ActiveLinkOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = LinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
78
- activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
79
- inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
80
- };
81
- export type LinkProps<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ActiveLinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
28
+ export type LinkProps<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkPropsChildren;
29
+ export interface LinkPropsChildren {
82
30
  children?: React.ReactNode | ((state: {
83
31
  isActive: boolean;
32
+ isTransitioning: boolean;
84
33
  }) => React.ReactNode);
85
- };
86
- type LinkComponent<TComp> = <TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''>(props: React.PropsWithoutRef<LinkProps<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & (TComp extends React.FC<infer TProps> | React.Component<infer TProps> ? TProps : TComp extends keyof JSX.IntrinsicElements ? Omit<React.HTMLProps<TComp>, 'children' | 'preload'> : never)> & React.RefAttributes<TComp extends React.FC<{
87
- ref: infer TRef;
88
- }> | React.Component<{
89
- ref: infer TRef;
90
- }> ? TRef : TComp extends keyof JSX.IntrinsicElements ? React.ComponentRef<TComp> : never>) => React.ReactElement;
91
- export declare function createLink<const TComp>(Comp: TComp): LinkComponent<TComp>;
34
+ }
35
+ type LinkComponentReactProps<TComp> = Omit<UseLinkReactProps<TComp>, keyof CreateLinkProps>;
36
+ export type LinkComponentProps<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkComponentReactProps<TComp> & LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
37
+ export type CreateLinkProps = LinkProps<any, any, string, string, string, string>;
38
+ export type LinkComponent<in out TComp, in out TDefaultFrom extends string = string> = <TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = TDefaultFrom, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => React.ReactElement;
39
+ export interface LinkComponentRoute<in out TDefaultFrom extends string = string> {
40
+ defaultFrom: TDefaultFrom;
41
+ <TRouter extends AnyRouter = RegisteredRouter, const TTo extends string | undefined = undefined, const TMaskTo extends string = ''>(props: LinkComponentProps<'a', TRouter, this['defaultFrom'], TTo, this['defaultFrom'], TMaskTo>): React.ReactElement;
42
+ }
43
+ export declare function createLink<const TComp>(Comp: Constrain<TComp, any, (props: CreateLinkProps) => ReactNode>): LinkComponent<TComp>;
92
44
  export declare const Link: LinkComponent<'a'>;
45
+ export type LinkOptionsFnOptions<TOptions, TComp, TRouter extends AnyRouter = RegisteredRouter> = TOptions extends ReadonlyArray<any> ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp> : ValidateLinkOptions<TRouter, TOptions, string, TComp>;
46
+ export type LinkOptionsFn<TComp> = <const TOptions, TRouter extends AnyRouter = RegisteredRouter>(options: LinkOptionsFnOptions<TOptions, TComp, TRouter>) => TOptions;
47
+ export declare const linkOptions: LinkOptionsFn<'a'>;
93
48
  export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ function _interopNamespaceDefault(e) {
5
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
6
+ if (e) {
7
+ for (const k in e) {
8
+ if (k !== "default") {
9
+ const d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: () => e[k]
13
+ });
14
+ }
15
+ }
16
+ }
17
+ n.default = e;
18
+ return Object.freeze(n);
19
+ }
20
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
21
+ const matchContext = React__namespace.createContext(void 0);
22
+ const dummyMatchContext = React__namespace.createContext(
23
+ void 0
24
+ );
25
+ exports.dummyMatchContext = dummyMatchContext;
26
+ exports.matchContext = matchContext;
27
+ //# sourceMappingURL=matchContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchContext.cjs","sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\n// N.B. this only exists so we can conditionally call useContext on it when we are not interested in the nearest match\nexport const dummyMatchContext = React.createContext<string | undefined>(\n undefined,\n)\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEa,MAAA,eAAeA,iBAAM,cAAkC,MAAS;AAGtE,MAAM,oBAAoBA,iBAAM;AAAA,EACrC;AACF;;;"}
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ export declare const matchContext: React.Context<string | undefined>;
3
+ export declare const dummyMatchContext: React.Context<string | undefined>;
@@ -1,17 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
+ const routerCore = require("@tanstack/router-core");
4
5
  const CatchBoundary = require("./CatchBoundary.cjs");
5
6
  const useRouterState = require("./useRouterState.cjs");
6
- function notFound(options = {}) {
7
- options.isNotFound = true;
8
- if (options.throw)
9
- throw options;
10
- return options;
11
- }
12
- function isNotFound(obj) {
13
- return !!(obj == null ? void 0 : obj.isNotFound);
14
- }
15
7
  function CatchNotFound(props) {
16
8
  const resetKey = useRouterState.useRouterState({
17
9
  select: (s) => `not-found-${s.location.pathname}-${s.status}`
@@ -20,17 +12,21 @@ function CatchNotFound(props) {
20
12
  CatchBoundary.CatchBoundary,
21
13
  {
22
14
  getResetKey: () => resetKey,
23
- onCatch: (error) => {
15
+ onCatch: (error, errorInfo) => {
24
16
  var _a;
25
- if (isNotFound(error)) {
26
- (_a = props.onCatch) == null ? void 0 : _a.call(props, error);
17
+ if (routerCore.isNotFound(error)) {
18
+ (_a = props.onCatch) == null ? void 0 : _a.call(props, error, errorInfo);
27
19
  } else {
28
20
  throw error;
29
21
  }
30
22
  },
31
23
  errorComponent: ({ error }) => {
32
24
  var _a;
33
- return (_a = props.fallback) == null ? void 0 : _a.call(props, error);
25
+ if (routerCore.isNotFound(error)) {
26
+ return (_a = props.fallback) == null ? void 0 : _a.call(props, error);
27
+ } else {
28
+ throw error;
29
+ }
34
30
  },
35
31
  children: props.children
36
32
  }
@@ -41,6 +37,4 @@ function DefaultGlobalNotFound() {
41
37
  }
42
38
  exports.CatchNotFound = CatchNotFound;
43
39
  exports.DefaultGlobalNotFound = DefaultGlobalNotFound;
44
- exports.isNotFound = isNotFound;
45
- exports.notFound = notFound;
46
40
  //# sourceMappingURL=not-found.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import * as React from 'react'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { RegisteredRouter } from './router'\nimport { RouteIds } from './routeInfo'\n\nexport type NotFoundError = {\n /**\n @deprecated\n Use `routeId: rootRouteId` instead\n */\n global?: boolean\n /**\n @private\n Do not use this. It's used internally to indicate a path matching error\n */\n _global?: boolean\n data?: any\n throw?: boolean\n routeId?: RouteIds<RegisteredRouter['routeTree']>\n}\n\nexport function notFound(options: NotFoundError = {}) {\n ;(options as any).isNotFound = true\n if (options.throw) throw options\n return options\n}\n\nexport function isNotFound(obj: any): obj is NotFoundError {\n return !!obj?.isNotFound\n}\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => React.ReactElement\n onCatch?: (error: any) => void\n children: React.ReactNode\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey}\n onCatch={(error) => {\n if (isNotFound(error)) {\n props.onCatch?.(error)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }: { error: NotFoundError }) =>\n props.fallback?.(error)\n }\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"names":["useRouterState","jsx","CatchBoundary"],"mappings":";;;;;AAsBgB,SAAA,SAAS,UAAyB,IAAI;AAClD,UAAgB,aAAa;AAC/B,MAAI,QAAQ;AAAa,UAAA;AAClB,SAAA;AACT;AAEO,SAAS,WAAW,KAAgC;AAClD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,cAAc,OAI3B;AAED,QAAM,WAAWA,eAAAA,eAAe;AAAA,IAC9B,QAAQ,CAAC,MAAM,aAAa,EAAE,SAAS,QAAQ,IAAI,EAAE,MAAM;AAAA,EAAA,CAC5D;AAGC,SAAAC,2BAAA;AAAA,IAACC,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,SAAS,CAAC,UAAU;;AACd,YAAA,WAAW,KAAK,GAAG;AACrB,sBAAM,YAAN,+BAAgB;AAAA,QAAK,OAChB;AACC,gBAAA;AAAA,QACR;AAAA,MACF;AAAA,MACA,gBAAgB,CAAC,EAAE,YACjB;;AAAA,2BAAM,aAAN,+BAAiB;AAAA;AAAA,MAGlB,UAAM,MAAA;AAAA,IAAA;AAAA,EAAA;AAGb;AAEO,SAAS,wBAAwB;AAC/B,SAAAD,2BAAA,IAAC,OAAE,UAAS,YAAA,CAAA;AACrB;;;;;"}
1
+ {"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import * as React from 'react'\nimport { isNotFound } from '@tanstack/router-core'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type { ErrorInfo } from 'react'\nimport type { NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => React.ReactElement\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n children: React.ReactNode\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey}\n onCatch={(error, errorInfo) => {\n if (isNotFound(error)) {\n props.onCatch?.(error, errorInfo)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }: { error: Error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"names":["useRouterState","jsx","CatchBoundary","isNotFound"],"mappings":";;;;;;AAOO,SAAS,cAAc,OAI3B;AAED,QAAM,WAAWA,eAAAA,eAAe;AAAA,IAC9B,QAAQ,CAAC,MAAM,aAAa,EAAE,SAAS,QAAQ,IAAI,EAAE,MAAM;AAAA,EAAA,CAC5D;AAGC,SAAAC,2BAAA;AAAA,IAACC,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,SAAS,CAAC,OAAO,cAAc;;AACzB,YAAAC,WAAAA,WAAW,KAAK,GAAG;AACf,sBAAA,YAAA,+BAAU,OAAO;AAAA,QAAS,OAC3B;AACC,gBAAA;AAAA,QAAA;AAAA,MAEV;AAAA,MACA,gBAAgB,CAAC,EAAE,YAA8B;;AAC3C,YAAAA,WAAAA,WAAW,KAAK,GAAG;AACd,kBAAA,WAAM,aAAN,+BAAiB;AAAA,QAAK,OACxB;AACC,gBAAA;AAAA,QAAA;AAAA,MAEV;AAAA,MAEC,UAAM,MAAA;AAAA,IAAA;AAAA,EACT;AAEJ;AAEO,SAAS,wBAAwB;AAC/B,SAAAF,2BAAA,IAAC,OAAE,UAAS,YAAA,CAAA;AACrB;;;"}
@@ -1,26 +1,9 @@
1
+ import { ErrorInfo } from 'react';
2
+ import { NotFoundError } from '@tanstack/router-core';
1
3
  import * as React from 'react';
2
- import { RegisteredRouter } from './router.cjs';
3
- import { RouteIds } from './routeInfo.cjs';
4
- export type NotFoundError = {
5
- /**
6
- @deprecated
7
- Use `routeId: rootRouteId` instead
8
- */
9
- global?: boolean;
10
- /**
11
- @private
12
- Do not use this. It's used internally to indicate a path matching error
13
- */
14
- _global?: boolean;
15
- data?: any;
16
- throw?: boolean;
17
- routeId?: RouteIds<RegisteredRouter['routeTree']>;
18
- };
19
- export declare function notFound(options?: NotFoundError): NotFoundError;
20
- export declare function isNotFound(obj: any): obj is NotFoundError;
21
4
  export declare function CatchNotFound(props: {
22
5
  fallback?: (error: NotFoundError) => React.ReactElement;
23
- onCatch?: (error: any) => void;
6
+ onCatch?: (error: Error, errorInfo: ErrorInfo) => void;
24
7
  children: React.ReactNode;
25
- }): React.JSX.Element;
26
- export declare function DefaultGlobalNotFound(): React.JSX.Element;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ export declare function DefaultGlobalNotFound(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const warning = require("tiny-warning");
5
+ const notFound = require("./not-found.cjs");
6
+ function renderRouteNotFound(router, route, data) {
7
+ if (!route.options.notFoundComponent) {
8
+ if (router.options.defaultNotFoundComponent) {
9
+ return /* @__PURE__ */ jsxRuntime.jsx(router.options.defaultNotFoundComponent, { data });
10
+ }
11
+ if (process.env.NODE_ENV === "development") {
12
+ warning(
13
+ route.options.notFoundComponent,
14
+ `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>)`
15
+ );
16
+ }
17
+ return /* @__PURE__ */ jsxRuntime.jsx(notFound.DefaultGlobalNotFound, {});
18
+ }
19
+ return /* @__PURE__ */ jsxRuntime.jsx(route.options.notFoundComponent, { data });
20
+ }
21
+ exports.renderRouteNotFound = renderRouteNotFound;
22
+ //# sourceMappingURL=renderRouteNotFound.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderRouteNotFound.cjs","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\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":["jsx","DefaultGlobalNotFound"],"mappings":";;;;;AAKgB,SAAA,oBACd,QACA,OACA,MACA;AACI,MAAA,CAAC,MAAM,QAAQ,mBAAmB;AAChC,QAAA,OAAO,QAAQ,0BAA0B;AAC3C,aAAQA,2BAAAA,IAAA,OAAO,QAAQ,0BAAf,EAAwC,KAAY,CAAA;AAAA,IAAA;AAG1D,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC1C;AAAA,QACE,MAAM,QAAQ;AAAA,QACd,yDAAyD,MAAM,EAAE;AAAA,MACnE;AAAA,IAAA;AAGF,0CAAQC,SAAsB,uBAAA,EAAA;AAAA,EAAA;AAGhC,SAAQD,2BAAAA,IAAA,MAAM,QAAQ,mBAAd,EAAgC,KAAY,CAAA;AACtD;;"}
@@ -0,0 +1,2 @@
1
+ import { AnyRoute, AnyRouter } from '@tanstack/router-core';
2
+ export declare function renderRouteNotFound(router: AnyRouter, route: AnyRoute, data: any): import("react/jsx-runtime").JSX.Element;
@@ -1,130 +1,119 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const invariant = require("tiny-invariant");
4
- const Matches = require("./Matches.cjs");
5
- const path = require("./path.cjs");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const routerCore = require("@tanstack/router-core");
5
+ const React = require("react");
6
+ const useLoaderData = require("./useLoaderData.cjs");
7
+ const useLoaderDeps = require("./useLoaderDeps.cjs");
6
8
  const useParams = require("./useParams.cjs");
7
9
  const useSearch = require("./useSearch.cjs");
8
- const notFound = require("./not-found.cjs");
9
- const rootRouteId = "__root__";
10
+ const useNavigate = require("./useNavigate.cjs");
11
+ const useMatch = require("./useMatch.cjs");
12
+ const useRouter = require("./useRouter.cjs");
13
+ const link = require("./link.cjs");
10
14
  function getRouteApi(id) {
11
15
  return new RouteApi({ id });
12
16
  }
13
- class RouteApi {
17
+ class RouteApi extends routerCore.BaseRouteApi {
14
18
  /**
15
19
  * @deprecated Use the `getRouteApi` function instead.
16
20
  */
17
21
  constructor({ id }) {
22
+ super({ id });
18
23
  this.useMatch = (opts) => {
19
- return Matches.useMatch({ select: opts == null ? void 0 : opts.select, from: this.id });
24
+ return useMatch.useMatch({
25
+ select: opts == null ? void 0 : opts.select,
26
+ from: this.id,
27
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing
28
+ });
20
29
  };
21
30
  this.useRouteContext = (opts) => {
22
- return Matches.useMatch({
31
+ return useMatch.useMatch({
23
32
  from: this.id,
24
33
  select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
25
34
  });
26
35
  };
27
36
  this.useSearch = (opts) => {
28
- return useSearch.useSearch({ ...opts, from: this.id });
37
+ return useSearch.useSearch({
38
+ select: opts == null ? void 0 : opts.select,
39
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing,
40
+ from: this.id
41
+ });
29
42
  };
30
43
  this.useParams = (opts) => {
31
- return useParams.useParams({ ...opts, from: this.id });
44
+ return useParams.useParams({
45
+ select: opts == null ? void 0 : opts.select,
46
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing,
47
+ from: this.id
48
+ });
32
49
  };
33
50
  this.useLoaderDeps = (opts) => {
34
- return Matches.useLoaderDeps({ ...opts, from: this.id, strict: false });
51
+ return useLoaderDeps.useLoaderDeps({ ...opts, from: this.id, strict: false });
35
52
  };
36
53
  this.useLoaderData = (opts) => {
37
- return Matches.useLoaderData({ ...opts, from: this.id, strict: false });
54
+ return useLoaderData.useLoaderData({ ...opts, from: this.id, strict: false });
55
+ };
56
+ this.useNavigate = () => {
57
+ const router = useRouter.useRouter();
58
+ return useNavigate.useNavigate({ from: router.routesById[this.id].fullPath });
38
59
  };
39
60
  this.notFound = (opts) => {
40
- return notFound.notFound({ routeId: this.id, ...opts });
61
+ return routerCore.notFound({ routeId: this.id, ...opts });
41
62
  };
42
- this.id = id;
63
+ this.Link = React.forwardRef((props, ref) => {
64
+ const router = useRouter.useRouter();
65
+ const fullPath = router.routesById[this.id].fullPath;
66
+ return /* @__PURE__ */ jsxRuntime.jsx(link.Link, { ref, from: fullPath, ...props });
67
+ });
43
68
  }
44
69
  }
45
- class Route {
70
+ class Route extends routerCore.BaseRoute {
46
71
  /**
47
72
  * @deprecated Use the `createRoute` function instead.
48
73
  */
49
74
  constructor(options) {
50
- this.init = (opts) => {
51
- var _a, _b;
52
- this.originalIndex = opts.originalIndex;
53
- const options2 = this.options;
54
- const isRoot = !(options2 == null ? void 0 : options2.path) && !(options2 == null ? void 0 : options2.id);
55
- this.parentRoute = (_b = (_a = this.options) == null ? void 0 : _a.getParentRoute) == null ? void 0 : _b.call(_a);
56
- if (isRoot) {
57
- this.path = rootRouteId;
58
- } else {
59
- invariant(
60
- this.parentRoute,
61
- `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`
62
- );
63
- }
64
- let path$1 = isRoot ? rootRouteId : options2.path;
65
- if (path$1 && path$1 !== "/") {
66
- path$1 = path.trimPathLeft(path$1);
67
- }
68
- const customId = (options2 == null ? void 0 : options2.id) || path$1;
69
- let id = isRoot ? rootRouteId : path.joinPaths([
70
- this.parentRoute.id === rootRouteId ? "" : this.parentRoute.id,
71
- customId
72
- ]);
73
- if (path$1 === rootRouteId) {
74
- path$1 = "/";
75
- }
76
- if (id !== rootRouteId) {
77
- id = path.joinPaths(["/", id]);
78
- }
79
- const fullPath = id === rootRouteId ? "/" : path.joinPaths([this.parentRoute.fullPath, path$1]);
80
- this.path = path$1;
81
- this.id = id;
82
- this.fullPath = fullPath;
83
- this.to = fullPath;
84
- };
85
- this.addChildren = (children) => {
86
- this.children = children;
87
- return this;
88
- };
89
- this.updateLoader = (options2) => {
90
- Object.assign(this.options, options2);
91
- return this;
92
- };
93
- this.update = (options2) => {
94
- Object.assign(this.options, options2);
95
- return this;
96
- };
97
- this.lazy = (lazyFn) => {
98
- this.lazyFn = lazyFn;
99
- return this;
100
- };
75
+ super(options);
101
76
  this.useMatch = (opts) => {
102
- return Matches.useMatch({ ...opts, from: this.id });
77
+ return useMatch.useMatch({
78
+ select: opts == null ? void 0 : opts.select,
79
+ from: this.id,
80
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing
81
+ });
103
82
  };
104
83
  this.useRouteContext = (opts) => {
105
- return Matches.useMatch({
84
+ return useMatch.useMatch({
106
85
  ...opts,
107
86
  from: this.id,
108
87
  select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
109
88
  });
110
89
  };
111
90
  this.useSearch = (opts) => {
112
- return useSearch.useSearch({ ...opts, from: this.id });
91
+ return useSearch.useSearch({
92
+ select: opts == null ? void 0 : opts.select,
93
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing,
94
+ from: this.id
95
+ });
113
96
  };
114
97
  this.useParams = (opts) => {
115
- return useParams.useParams({ ...opts, from: this.id });
98
+ return useParams.useParams({
99
+ select: opts == null ? void 0 : opts.select,
100
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing,
101
+ from: this.id
102
+ });
116
103
  };
117
104
  this.useLoaderDeps = (opts) => {
118
- return Matches.useLoaderDeps({ ...opts, from: this.id });
105
+ return useLoaderDeps.useLoaderDeps({ ...opts, from: this.id });
119
106
  };
120
107
  this.useLoaderData = (opts) => {
121
- return Matches.useLoaderData({ ...opts, from: this.id });
108
+ return useLoaderData.useLoaderData({ ...opts, from: this.id });
109
+ };
110
+ this.useNavigate = () => {
111
+ return useNavigate.useNavigate({ from: this.fullPath });
122
112
  };
123
- this.options = options || {};
124
- this.isRoot = !(options == null ? void 0 : options.getParentRoute);
125
- invariant(
126
- !((options == null ? void 0 : options.id) && (options == null ? void 0 : options.path)),
127
- `Route cannot have both an 'id' and a 'path' option.`
113
+ this.Link = React.forwardRef(
114
+ (props, ref) => {
115
+ return /* @__PURE__ */ jsxRuntime.jsx(link.Link, { ref, from: this.fullPath, ...props });
116
+ }
128
117
  );
129
118
  this.$$typeof = Symbol.for("react.memo");
130
119
  }
@@ -138,12 +127,55 @@ function createRootRouteWithContext() {
138
127
  };
139
128
  }
140
129
  const rootRouteWithContext = createRootRouteWithContext;
141
- class RootRoute extends Route {
130
+ class RootRoute extends routerCore.BaseRootRoute {
142
131
  /**
143
132
  * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
144
133
  */
145
134
  constructor(options) {
146
135
  super(options);
136
+ this.useMatch = (opts) => {
137
+ return useMatch.useMatch({
138
+ select: opts == null ? void 0 : opts.select,
139
+ from: this.id,
140
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing
141
+ });
142
+ };
143
+ this.useRouteContext = (opts) => {
144
+ return useMatch.useMatch({
145
+ ...opts,
146
+ from: this.id,
147
+ select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
148
+ });
149
+ };
150
+ this.useSearch = (opts) => {
151
+ return useSearch.useSearch({
152
+ select: opts == null ? void 0 : opts.select,
153
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing,
154
+ from: this.id
155
+ });
156
+ };
157
+ this.useParams = (opts) => {
158
+ return useParams.useParams({
159
+ select: opts == null ? void 0 : opts.select,
160
+ structuralSharing: opts == null ? void 0 : opts.structuralSharing,
161
+ from: this.id
162
+ });
163
+ };
164
+ this.useLoaderDeps = (opts) => {
165
+ return useLoaderDeps.useLoaderDeps({ ...opts, from: this.id });
166
+ };
167
+ this.useLoaderData = (opts) => {
168
+ return useLoaderData.useLoaderData({ ...opts, from: this.id });
169
+ };
170
+ this.useNavigate = () => {
171
+ return useNavigate.useNavigate({ from: this.fullPath });
172
+ };
173
+ this.Link = React.forwardRef(
174
+ (props, ref) => {
175
+ return /* @__PURE__ */ jsxRuntime.jsx(link.Link, { ref, from: this.fullPath, ...props });
176
+ }
177
+ );
178
+ this.$$typeof = Symbol.for("react.memo");
147
179
  }
148
180
  }
149
181
  function createRootRoute(options) {
@@ -169,6 +201,5 @@ exports.createRootRouteWithContext = createRootRouteWithContext;
169
201
  exports.createRoute = createRoute;
170
202
  exports.createRouteMask = createRouteMask;
171
203
  exports.getRouteApi = getRouteApi;
172
- exports.rootRouteId = rootRouteId;
173
204
  exports.rootRouteWithContext = rootRouteWithContext;
174
205
  //# sourceMappingURL=route.cjs.map