@tanstack/react-router 1.121.20 → 1.121.24

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 (242) hide show
  1. package/dist/cjs/Asset.cjs +108 -0
  2. package/dist/cjs/Asset.cjs.map +1 -0
  3. package/dist/cjs/Asset.d.cts +3 -0
  4. package/dist/cjs/CatchBoundary.cjs +114 -0
  5. package/dist/cjs/CatchBoundary.cjs.map +1 -0
  6. package/dist/cjs/CatchBoundary.d.cts +12 -0
  7. package/dist/cjs/ClientOnly.cjs +20 -0
  8. package/dist/cjs/ClientOnly.cjs.map +1 -0
  9. package/dist/cjs/ClientOnly.d.cts +29 -0
  10. package/dist/cjs/HeadContent.cjs +155 -0
  11. package/dist/cjs/HeadContent.cjs.map +1 -0
  12. package/dist/cjs/HeadContent.d.cts +7 -0
  13. package/dist/cjs/Match.cjs +257 -0
  14. package/dist/cjs/Match.cjs.map +1 -0
  15. package/dist/cjs/Match.d.cts +8 -0
  16. package/dist/cjs/Matches.cjs +136 -0
  17. package/dist/cjs/Matches.cjs.map +1 -0
  18. package/dist/cjs/Matches.d.cts +26 -0
  19. package/dist/cjs/RouterProvider.cjs +33 -0
  20. package/dist/cjs/RouterProvider.cjs.map +1 -0
  21. package/dist/cjs/RouterProvider.d.cts +10 -0
  22. package/dist/cjs/SafeFragment.cjs +8 -0
  23. package/dist/cjs/SafeFragment.cjs.map +1 -0
  24. package/dist/cjs/SafeFragment.d.cts +1 -0
  25. package/dist/cjs/ScriptOnce.cjs +28 -0
  26. package/dist/cjs/ScriptOnce.cjs.map +1 -0
  27. package/dist/cjs/ScriptOnce.d.cts +5 -0
  28. package/dist/cjs/Scripts.cjs +51 -0
  29. package/dist/cjs/Scripts.cjs.map +1 -0
  30. package/dist/cjs/Scripts.d.cts +1 -0
  31. package/dist/cjs/ScrollRestoration.cjs +39 -0
  32. package/dist/cjs/ScrollRestoration.cjs.map +1 -0
  33. package/dist/cjs/ScrollRestoration.d.cts +14 -0
  34. package/dist/cjs/Transitioner.cjs +115 -0
  35. package/dist/cjs/Transitioner.cjs.map +1 -0
  36. package/dist/cjs/Transitioner.d.cts +1 -0
  37. package/dist/cjs/awaited.cjs +48 -0
  38. package/dist/cjs/awaited.cjs.map +1 -0
  39. package/dist/cjs/awaited.d.cts +10 -0
  40. package/dist/cjs/fileRoute.cjs +107 -0
  41. package/dist/cjs/fileRoute.cjs.map +1 -0
  42. package/dist/cjs/fileRoute.d.cts +54 -0
  43. package/dist/cjs/history.d.cts +8 -0
  44. package/dist/cjs/index.cjs +289 -0
  45. package/dist/cjs/index.cjs.map +1 -0
  46. package/dist/cjs/index.d.cts +55 -0
  47. package/dist/cjs/lazyRouteComponent.cjs +78 -0
  48. package/dist/cjs/lazyRouteComponent.cjs.map +1 -0
  49. package/dist/cjs/lazyRouteComponent.d.cts +2 -0
  50. package/dist/cjs/link.cjs +324 -0
  51. package/dist/cjs/link.cjs.map +1 -0
  52. package/dist/cjs/link.d.cts +48 -0
  53. package/dist/cjs/matchContext.cjs +27 -0
  54. package/dist/cjs/matchContext.cjs.map +1 -0
  55. package/dist/cjs/matchContext.d.cts +3 -0
  56. package/dist/cjs/not-found.cjs +40 -0
  57. package/dist/cjs/not-found.cjs.map +1 -0
  58. package/dist/cjs/not-found.d.cts +9 -0
  59. package/dist/cjs/renderRouteNotFound.cjs +22 -0
  60. package/dist/cjs/renderRouteNotFound.cjs.map +1 -0
  61. package/dist/cjs/renderRouteNotFound.d.cts +2 -0
  62. package/dist/cjs/route.cjs +205 -0
  63. package/dist/cjs/route.cjs.map +1 -0
  64. package/dist/cjs/route.d.cts +95 -0
  65. package/dist/cjs/router.cjs +22 -0
  66. package/dist/cjs/router.cjs.map +1 -0
  67. package/dist/cjs/router.d.cts +72 -0
  68. package/dist/cjs/routerContext.cjs +33 -0
  69. package/dist/cjs/routerContext.cjs.map +1 -0
  70. package/dist/cjs/routerContext.d.cts +8 -0
  71. package/dist/cjs/scroll-restoration.cjs +24 -0
  72. package/dist/cjs/scroll-restoration.cjs.map +1 -0
  73. package/dist/cjs/scroll-restoration.d.cts +1 -0
  74. package/dist/cjs/serializer.d.cts +6 -0
  75. package/dist/cjs/structuralSharing.d.cts +8 -0
  76. package/dist/cjs/typePrimitives.d.cts +16 -0
  77. package/dist/cjs/useBlocker.cjs +165 -0
  78. package/dist/cjs/useBlocker.cjs.map +1 -0
  79. package/dist/cjs/useBlocker.d.cts +66 -0
  80. package/dist/cjs/useCanGoBack.cjs +8 -0
  81. package/dist/cjs/useCanGoBack.cjs.map +1 -0
  82. package/dist/cjs/useCanGoBack.d.cts +1 -0
  83. package/dist/cjs/useLoaderData.cjs +15 -0
  84. package/dist/cjs/useLoaderData.cjs.map +1 -0
  85. package/dist/cjs/useLoaderData.d.cts +8 -0
  86. package/dist/cjs/useLoaderDeps.cjs +14 -0
  87. package/dist/cjs/useLoaderDeps.cjs.map +1 -0
  88. package/dist/cjs/useLoaderDeps.d.cts +8 -0
  89. package/dist/cjs/useLocation.cjs +10 -0
  90. package/dist/cjs/useLocation.cjs.map +1 -0
  91. package/dist/cjs/useLocation.d.cts +7 -0
  92. package/dist/cjs/useMatch.cjs +47 -0
  93. package/dist/cjs/useMatch.cjs.map +1 -0
  94. package/dist/cjs/useMatch.d.cts +10 -0
  95. package/dist/cjs/useNavigate.cjs +55 -0
  96. package/dist/cjs/useNavigate.cjs.map +1 -0
  97. package/dist/cjs/useNavigate.d.cts +5 -0
  98. package/dist/cjs/useParams.cjs +16 -0
  99. package/dist/cjs/useParams.cjs.map +1 -0
  100. package/dist/cjs/useParams.d.cts +9 -0
  101. package/dist/cjs/useRouteContext.cjs +11 -0
  102. package/dist/cjs/useRouteContext.cjs.map +1 -0
  103. package/dist/cjs/useRouteContext.d.cts +3 -0
  104. package/dist/cjs/useRouter.cjs +32 -0
  105. package/dist/cjs/useRouter.cjs.map +1 -0
  106. package/dist/cjs/useRouter.d.cts +4 -0
  107. package/dist/cjs/useRouterState.cjs +29 -0
  108. package/dist/cjs/useRouterState.cjs.map +1 -0
  109. package/dist/cjs/useRouterState.d.cts +8 -0
  110. package/dist/cjs/useSearch.cjs +16 -0
  111. package/dist/cjs/useSearch.cjs.map +1 -0
  112. package/dist/cjs/useSearch.d.cts +9 -0
  113. package/dist/cjs/utils.cjs +72 -0
  114. package/dist/cjs/utils.cjs.map +1 -0
  115. package/dist/cjs/utils.d.cts +49 -0
  116. package/dist/esm/Asset.d.ts +3 -0
  117. package/dist/esm/Asset.js +91 -0
  118. package/dist/esm/Asset.js.map +1 -0
  119. package/dist/esm/CatchBoundary.d.ts +12 -0
  120. package/dist/esm/CatchBoundary.js +97 -0
  121. package/dist/esm/CatchBoundary.js.map +1 -0
  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 +240 -0
  130. package/dist/esm/Match.js.map +1 -0
  131. package/dist/esm/Matches.d.ts +26 -0
  132. package/dist/esm/Matches.js +119 -0
  133. package/dist/esm/Matches.js.map +1 -0
  134. package/dist/esm/RouterProvider.d.ts +10 -0
  135. package/dist/esm/RouterProvider.js +33 -0
  136. package/dist/esm/RouterProvider.js.map +1 -0
  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 +10 -0
  153. package/dist/esm/awaited.js +31 -0
  154. package/dist/esm/awaited.js.map +1 -0
  155. package/dist/esm/fileRoute.d.ts +54 -0
  156. package/dist/esm/fileRoute.js +107 -0
  157. package/dist/esm/fileRoute.js.map +1 -0
  158. package/dist/esm/history.d.ts +8 -0
  159. package/dist/esm/index.d.ts +55 -0
  160. package/dist/esm/index.js +151 -0
  161. package/dist/esm/index.js.map +1 -0
  162. package/dist/esm/lazyRouteComponent.d.ts +2 -0
  163. package/dist/esm/lazyRouteComponent.js +61 -0
  164. package/dist/esm/lazyRouteComponent.js.map +1 -0
  165. package/dist/esm/link.d.ts +48 -0
  166. package/dist/esm/link.js +307 -0
  167. package/dist/esm/link.js.map +1 -0
  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 +9 -0
  172. package/dist/esm/not-found.js +40 -0
  173. package/dist/esm/not-found.js.map +1 -0
  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 +95 -0
  178. package/dist/esm/route.js +205 -0
  179. package/dist/esm/route.js.map +1 -0
  180. package/dist/esm/router.d.ts +72 -0
  181. package/dist/esm/router.js +22 -0
  182. package/dist/esm/router.js.map +1 -0
  183. package/dist/esm/routerContext.d.ts +8 -0
  184. package/dist/esm/routerContext.js +16 -0
  185. package/dist/esm/routerContext.js.map +1 -0
  186. package/dist/esm/scroll-restoration.d.ts +1 -0
  187. package/dist/esm/scroll-restoration.js +24 -0
  188. package/dist/esm/scroll-restoration.js.map +1 -0
  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 +66 -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 +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 +5 -0
  211. package/dist/esm/useNavigate.js +38 -0
  212. package/dist/esm/useNavigate.js.map +1 -0
  213. package/dist/esm/useParams.d.ts +9 -0
  214. package/dist/esm/useParams.js +16 -0
  215. package/dist/esm/useParams.js.map +1 -0
  216. package/dist/esm/useRouteContext.d.ts +3 -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 +15 -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 +29 -0
  224. package/dist/esm/useRouterState.js.map +1 -0
  225. package/dist/esm/useSearch.d.ts +9 -0
  226. package/dist/esm/useSearch.js +16 -0
  227. package/dist/esm/useSearch.js.map +1 -0
  228. package/dist/esm/utils.d.ts +49 -0
  229. package/dist/esm/utils.js +55 -0
  230. package/dist/esm/utils.js.map +1 -0
  231. package/dist/llms/index.d.ts +3 -0
  232. package/dist/llms/index.js +35 -0
  233. package/dist/llms/rules/api.d.ts +2 -0
  234. package/dist/llms/rules/api.js +4241 -0
  235. package/dist/llms/rules/guide.d.ts +2 -0
  236. package/dist/llms/rules/guide.js +6227 -0
  237. package/dist/llms/rules/routing.d.ts +2 -0
  238. package/dist/llms/rules/routing.js +1946 -0
  239. package/dist/llms/rules/setup-and-architecture.d.ts +2 -0
  240. package/dist/llms/rules/setup-and-architecture.js +932 -0
  241. package/package.json +3 -3
  242. package/src/Asset.tsx +95 -16
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const Asset = require("./Asset.cjs");
6
+ const useRouterState = require("./useRouterState.cjs");
7
+ const useRouter = require("./useRouter.cjs");
8
+ const Scripts = () => {
9
+ const router = useRouter.useRouter();
10
+ const assetScripts = useRouterState.useRouterState({
11
+ select: (state) => {
12
+ var _a;
13
+ const assetScripts2 = [];
14
+ const manifest = (_a = router.ssr) == null ? void 0 : _a.manifest;
15
+ if (!manifest) {
16
+ return [];
17
+ }
18
+ state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
19
+ (route) => {
20
+ var _a2, _b;
21
+ return (_b = (_a2 = manifest.routes[route.id]) == null ? void 0 : _a2.assets) == null ? void 0 : _b.filter((d) => d.tag === "script").forEach((asset) => {
22
+ assetScripts2.push({
23
+ tag: "script",
24
+ attrs: asset.attrs,
25
+ children: asset.children
26
+ });
27
+ });
28
+ }
29
+ );
30
+ return assetScripts2;
31
+ },
32
+ structuralSharing: true
33
+ });
34
+ const { scripts } = useRouterState.useRouterState({
35
+ select: (state) => ({
36
+ scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
37
+ tag: "script",
38
+ attrs: {
39
+ ...script,
40
+ suppressHydrationWarning: true
41
+ },
42
+ children
43
+ }))
44
+ }),
45
+ structuralSharing: true
46
+ });
47
+ const allScripts = [...scripts, ...assetScripts];
48
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: allScripts.map((asset, i) => /* @__PURE__ */ React.createElement(Asset.Asset, { ...asset, key: `tsr-scripts-${asset.tag}-${i}` })) });
49
+ };
50
+ exports.Scripts = Scripts;
51
+ //# sourceMappingURL=Scripts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Scripts.cjs","sources":["../../src/Scripts.tsx"],"sourcesContent":["import { Asset } from './Asset'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const Scripts = () => {\n const router = useRouter()\n\n const assetScripts = useRouterState({\n select: (state) => {\n const assetScripts: Array<RouterManagedTag> = []\n const manifest = router.ssr?.manifest\n\n if (!manifest) {\n return []\n }\n\n state.matches\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n manifest.routes[route.id]?.assets\n ?.filter((d) => d.tag === 'script')\n .forEach((asset) => {\n assetScripts.push({\n tag: 'script',\n attrs: asset.attrs,\n children: asset.children,\n } as any)\n }),\n )\n\n return assetScripts\n },\n structuralSharing: true as any,\n })\n\n const { scripts } = useRouterState({\n select: (state) => ({\n scripts: (\n state.matches\n .map((match) => match.scripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script',\n attrs: {\n ...script,\n suppressHydrationWarning: true,\n },\n children,\n })),\n }),\n structuralSharing: true as any,\n })\n\n const allScripts = [...scripts, ...assetScripts] as Array<RouterManagedTag>\n\n return (\n <>\n {allScripts.map((asset, i) => (\n <Asset {...asset} key={`tsr-scripts-${asset.tag}-${i}`} />\n ))}\n </>\n )\n}\n"],"names":["useRouter","useRouterState","assetScripts","_a","Asset"],"m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GACH;AAEJ;;"}
@@ -0,0 +1 @@
1
+ export declare const Scripts: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const routerCore = require("@tanstack/router-core");
4
+ const useRouter = require("./useRouter.cjs");
5
+ function useScrollRestoration() {
6
+ const router = useRouter.useRouter();
7
+ routerCore.setupScrollRestoration(router, true);
8
+ }
9
+ function ScrollRestoration(_props) {
10
+ useScrollRestoration();
11
+ if (process.env.NODE_ENV === "development") {
12
+ console.warn(
13
+ "The ScrollRestoration component is deprecated. Use createRouter's `scrollRestoration` option instead."
14
+ );
15
+ }
16
+ return null;
17
+ }
18
+ function useElementScrollRestoration(options) {
19
+ var _a, _b;
20
+ useScrollRestoration();
21
+ const router = useRouter.useRouter();
22
+ const getKey = options.getKey || routerCore.defaultGetScrollRestorationKey;
23
+ let elementSelector = "";
24
+ if (options.id) {
25
+ elementSelector = `[data-scroll-restoration-id="${options.id}"]`;
26
+ } else {
27
+ const element = (_a = options.getElement) == null ? void 0 : _a.call(options);
28
+ if (!element) {
29
+ return;
30
+ }
31
+ elementSelector = element instanceof Window ? "window" : routerCore.getCssSelector(element);
32
+ }
33
+ const restoreKey = getKey(router.latestLocation);
34
+ const byKey = (_b = routerCore.scrollRestorationCache) == null ? void 0 : _b.state[restoreKey];
35
+ return byKey == null ? void 0 : byKey[elementSelector];
36
+ }
37
+ exports.ScrollRestoration = ScrollRestoration;
38
+ exports.useElementScrollRestoration = useElementScrollRestoration;
39
+ //# sourceMappingURL=ScrollRestoration.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollRestoration.cjs","sources":["../../src/ScrollRestoration.tsx"],"sourcesContent":["import {\n defaultGetScrollRestorationKey,\n getCssSelector,\n scrollRestorationCache,\n setupScrollRestoration,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport type {\n ParsedLocation,\n ScrollRestorationEntry,\n ScrollRestorationOptions,\n} from '@tanstack/router-core'\n\nfunction useScrollRestoration() {\n const router = useRouter()\n setupScrollRestoration(router, true)\n}\n\n/**\n * @deprecated use createRouter's `scrollRestoration` option instead\n */\nexport function ScrollRestoration(_props: ScrollRestorationOptions) {\n useScrollRestoration()\n\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n \"The ScrollRestoration component is deprecated. Use createRouter's `scrollRestoration` option instead.\",\n )\n }\n\n return null\n}\n\nexport function useElementScrollRestoration(\n options: (\n | {\n id: string\n getElement?: () => Window | Element | undefined | null\n }\n | {\n id?: string\n getElement: () => Window | Element | undefined | null\n }\n ) & {\n getKey?: (location: ParsedLocation) => string\n },\n): ScrollRestorationEntry | undefined {\n useScrollRestoration()\n\n const router = useRouter()\n const getKey = options.getKey || defaultGetScrollRestorationKey\n\n let elementSelector = ''\n\n if (options.id) {\n elementSelector = `[data-scroll-restoration-id=\"${options.id}\"]`\n } else {\n const element = options.getElement?.()\n if (!element) {\n return\n }\n elementSelector =\n element instanceof Window ? 'window' : getCssSelector(element)\n }\n\n const restoreKey = getKey(router.latestLocation)\n const byKey = scrollRestorationCache?.state[restoreKey]\n return byKey?.[elementSelector]\n}\n"],"names":["useRouter","setupScrollRestoration","defaultGetScrollRestorationKey","getCssSelector","scrollRestorationCache"],"mappings":";;;;AAaA,SAAS,uBAAuB;AAC9B,QAAM,SAASA,UAAAA,UAAU;AACzBC,aAAA,uBAAuB,QAAQ,IAAI;AACrC;AAKO,SAAS,kBAAkB,QAAkC;AAC7C,uBAAA;AAEjB,MAAA,QAAQ,IAAI,aAAa,eAAe;AAClC,YAAA;AAAA,MACN;AAAA,IACF;AAAA,EAAA;AAGK,SAAA;AACT;AAEO,SAAS,4BACd,SAYoC;;AACf,uBAAA;AAErB,QAAM,SAASD,UAAAA,UAAU;AACnB,QAAA,SAAS,QAAQ,UAAUE,WAAA;AAEjC,MAAI,kBAAkB;AAEtB,MAAI,QAAQ,IAAI;AACI,sBAAA,gCAAgC,QAAQ,EAAE;AAAA,EAAA,OACvD;AACC,UAAA,WAAU,aAAQ,eAAR;AAChB,QAAI,CAAC,SAAS;AACZ;AAAA,IAAA;AAEF,sBACE,mBAAmB,SAAS,WAAWC,WAAAA,eAAe,OAAO;AAAA,EAAA;AAG3D,QAAA,aAAa,OAAO,OAAO,cAAc;AACzC,QAAA,SAAQC,gBAAAA,2BAAAA,mBAAwB,MAAM;AAC5C,SAAO,+BAAQ;AACjB;;;"}
@@ -0,0 +1,14 @@
1
+ import { ParsedLocation, ScrollRestorationEntry, ScrollRestorationOptions } from '@tanstack/router-core';
2
+ /**
3
+ * @deprecated use createRouter's `scrollRestoration` option instead
4
+ */
5
+ export declare function ScrollRestoration(_props: ScrollRestorationOptions): null;
6
+ export declare function useElementScrollRestoration(options: ({
7
+ id: string;
8
+ getElement?: () => Window | Element | undefined | null;
9
+ } | {
10
+ id?: string;
11
+ getElement: () => Window | Element | undefined | null;
12
+ }) & {
13
+ getKey?: (location: ParsedLocation) => string;
14
+ }): ScrollRestorationEntry | undefined;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ const routerCore = require("@tanstack/router-core");
5
+ const utils = require("./utils.cjs");
6
+ const useRouter = require("./useRouter.cjs");
7
+ const useRouterState = require("./useRouterState.cjs");
8
+ function _interopNamespaceDefault(e) {
9
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
+ if (e) {
11
+ for (const k in e) {
12
+ if (k !== "default") {
13
+ const d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: () => e[k]
17
+ });
18
+ }
19
+ }
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
25
+ function Transitioner() {
26
+ const router = useRouter.useRouter();
27
+ const mountLoadForRouter = React__namespace.useRef({ router, mounted: false });
28
+ const isLoading = useRouterState.useRouterState({
29
+ select: ({ isLoading: isLoading2 }) => isLoading2
30
+ });
31
+ const [isTransitioning, setIsTransitioning] = React__namespace.useState(false);
32
+ const hasPendingMatches = useRouterState.useRouterState({
33
+ select: (s) => s.matches.some((d) => d.status === "pending"),
34
+ structuralSharing: true
35
+ });
36
+ const previousIsLoading = utils.usePrevious(isLoading);
37
+ const isAnyPending = isLoading || isTransitioning || hasPendingMatches;
38
+ const previousIsAnyPending = utils.usePrevious(isAnyPending);
39
+ const isPagePending = isLoading || hasPendingMatches;
40
+ const previousIsPagePending = utils.usePrevious(isPagePending);
41
+ if (!router.isServer) {
42
+ router.startTransition = (fn) => {
43
+ setIsTransitioning(true);
44
+ React__namespace.startTransition(() => {
45
+ fn();
46
+ setIsTransitioning(false);
47
+ });
48
+ };
49
+ }
50
+ React__namespace.useEffect(() => {
51
+ const unsub = router.history.subscribe(router.load);
52
+ const nextLocation = router.buildLocation({
53
+ to: router.latestLocation.pathname,
54
+ search: true,
55
+ params: true,
56
+ hash: true,
57
+ state: true,
58
+ _includeValidateSearch: true
59
+ });
60
+ if (routerCore.trimPathRight(router.latestLocation.href) !== routerCore.trimPathRight(nextLocation.href)) {
61
+ router.commitLocation({ ...nextLocation, replace: true });
62
+ }
63
+ return () => {
64
+ unsub();
65
+ };
66
+ }, [router, router.history]);
67
+ utils.useLayoutEffect(() => {
68
+ if (typeof window !== "undefined" && router.clientSsr || mountLoadForRouter.current.router === router && mountLoadForRouter.current.mounted) {
69
+ return;
70
+ }
71
+ mountLoadForRouter.current = { router, mounted: true };
72
+ const tryLoad = async () => {
73
+ try {
74
+ await router.load();
75
+ } catch (err) {
76
+ console.error(err);
77
+ }
78
+ };
79
+ tryLoad();
80
+ }, [router]);
81
+ utils.useLayoutEffect(() => {
82
+ if (previousIsLoading && !isLoading) {
83
+ router.emit({
84
+ type: "onLoad",
85
+ // When the new URL has committed, when the new matches have been loaded into state.matches
86
+ ...routerCore.getLocationChangeInfo(router.state)
87
+ });
88
+ }
89
+ }, [previousIsLoading, router, isLoading]);
90
+ utils.useLayoutEffect(() => {
91
+ if (previousIsPagePending && !isPagePending) {
92
+ router.emit({
93
+ type: "onBeforeRouteMount",
94
+ ...routerCore.getLocationChangeInfo(router.state)
95
+ });
96
+ }
97
+ }, [isPagePending, previousIsPagePending, router]);
98
+ utils.useLayoutEffect(() => {
99
+ if (previousIsAnyPending && !isAnyPending) {
100
+ router.emit({
101
+ type: "onResolved",
102
+ ...routerCore.getLocationChangeInfo(router.state)
103
+ });
104
+ router.__store.setState((s) => ({
105
+ ...s,
106
+ status: "idle",
107
+ resolvedLocation: s.location
108
+ }));
109
+ routerCore.handleHashScroll(router);
110
+ }
111
+ }, [isAnyPending, previousIsAnyPending, router]);
112
+ return null;
113
+ }
114
+ exports.Transitioner = Transitioner;
115
+ //# sourceMappingURL=Transitioner.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transitioner.cjs","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as React from 'react'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useLayoutEffect, usePrevious } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\n\nexport function Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n const [isTransitioning, setIsTransitioning] = React.useState(false)\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n structuralSharing: true,\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = isLoading || isTransitioning || hasPendingMatches\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = isLoading || hasPendingMatches\n const previousIsPagePending = usePrevious(isPagePending)\n\n if (!router.isServer) {\n router.startTransition = (fn: () => void) => {\n setIsTransitioning(true)\n React.startTransition(() => {\n fn()\n setIsTransitioning(false)\n })\n }\n }\n\n // Subscribe to location changes\n // and try to load the new location\n React.useEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router, router.history])\n\n // Try to load the initial location\n useLayoutEffect(() => {\n if (\n (typeof window !== 'undefined' && router.clientSsr) ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n\n tryLoad()\n }, [router])\n\n useLayoutEffect(() => {\n // The router was loading and now it's not\n if (previousIsLoading && !isLoading) {\n router.emit({\n type: 'onLoad', // When the new URL has committed, when the new matches have been loaded into state.matches\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [previousIsLoading, router, isLoading])\n\n useLayoutEffect(() => {\n // emit onBeforeRouteMount\n if (previousIsPagePending && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [isPagePending, previousIsPagePending, router])\n\n useLayoutEffect(() => {\n // The router was pending and now it's not\n if (previousIsAnyPending && !isAnyPending) {\n router.emit({\n type: 'onResolved',\n ...getLocationChangeInfo(router.state),\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n handleHashScroll(router)\n }\n }, [isAnyPending, previousIsAnyPending, router])\n\n return null\n}\n"],"names":["useRouter","React","useRouterState","isLoading","usePrevious","trimPathRight","useLayoutEffect","getLocationChangeInfo","handleHashScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAS,eAAe;A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
1
+ export declare function Transitioner(): null;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const routerCore = require("@tanstack/router-core");
6
+ function _interopNamespaceDefault(e) {
7
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
+ if (e) {
9
+ for (const k in e) {
10
+ if (k !== "default") {
11
+ const d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: () => e[k]
15
+ });
16
+ }
17
+ }
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
23
+ function useAwaited({
24
+ promise: _promise
25
+ }) {
26
+ const promise = routerCore.defer(_promise);
27
+ if (promise[routerCore.TSR_DEFERRED_PROMISE].status === "pending") {
28
+ throw promise;
29
+ }
30
+ if (promise[routerCore.TSR_DEFERRED_PROMISE].status === "error") {
31
+ throw promise[routerCore.TSR_DEFERRED_PROMISE].error;
32
+ }
33
+ return [promise[routerCore.TSR_DEFERRED_PROMISE].data, promise];
34
+ }
35
+ function Await(props) {
36
+ const inner = /* @__PURE__ */ jsxRuntime.jsx(AwaitInner, { ...props });
37
+ if (props.fallback) {
38
+ return /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Suspense, { fallback: props.fallback, children: inner });
39
+ }
40
+ return inner;
41
+ }
42
+ function AwaitInner(props) {
43
+ const [data] = useAwaited(props);
44
+ return props.children(data);
45
+ }
46
+ exports.Await = Await;
47
+ exports.useAwaited = useAwaited;
48
+ //# sourceMappingURL=awaited.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awaited.cjs","sources":["../../src/awaited.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { TSR_DEFERRED_PROMISE, defer } from '@tanstack/router-core'\nimport type { DeferredPromise } from '@tanstack/router-core'\n\nexport type AwaitOptions<T> = {\n promise: Promise<T>\n}\n\nexport function useAwaited<T>({\n promise: _promise,\n}: AwaitOptions<T>): [T, DeferredPromise<T>] {\n const promise = defer(_promise)\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'pending') {\n throw promise\n }\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'error') {\n throw promise[TSR_DEFERRED_PROMISE].error\n }\n\n return [promise[TSR_DEFERRED_PROMISE].data, promise]\n}\n\nexport function Await<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n) {\n const inner = <AwaitInner {...props} />\n if (props.fallback) {\n return <React.Suspense fallback={props.fallback}>{inner}</React.Suspense>\n }\n return inner\n}\n\nfunction AwaitInner<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n): React.JSX.Element {\n const [data] = useAwaited(props)\n\n return props.children(data) as React.JSX.Element\n}\n"],"names":["defer","TSR_DEFERRED_PROMISE","jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASO,SAAS,WAAc;AAAA,EAC5B,SAAS;AACX,GAA6C;AACrC,QAAA,UAAUA,iBAAM,QAAQ;AAE9B,MAAI,QAAQC,WAAAA,oBAAoB,EAAE,WAAW,WAAW;AAChD,UAAA;AAAA,EAAA;AAGR,MAAI,QAAQA,WAAAA,oBAAoB,EAAE,WAAW,SAAS;AAC9C,UAAA,QAAQA,WAAoB,oBAAA,EAAE;AAAA,EAAA;AAGtC,SAAO,CAAC,QAAQA,WAAAA,oBAAoB,EAAE,MAAM,OAAO;AACrD;AAEO,SAAS,MACd,OAIA;AACA,QAAM,QAAQC,2BAAA,IAAC,YAAY,EAAA,GAAG,MAAO,CAAA;AACrC,MAAI,MAAM,UAAU;AAClB,0CAAQC,iBAAM,UAAN,EAAe,UAAU,MAAM,UAAW,UAAM,OAAA;AAAA,EAAA;AAEnD,SAAA;AACT;AAEA,SAAS,WACP,OAImB;AACnB,QAAM,CAAC,IAAI,IAAI,WAAW,KAAK;AAExB,SAAA,MAAM,SAAS,IAAI;AAC5B;;;"}
@@ -0,0 +1,10 @@
1
+ import { DeferredPromise } from '@tanstack/router-core';
2
+ import * as React from 'react';
3
+ export type AwaitOptions<T> = {
4
+ promise: Promise<T>;
5
+ };
6
+ export declare function useAwaited<T>({ promise: _promise, }: AwaitOptions<T>): [T, DeferredPromise<T>];
7
+ export declare function Await<T>(props: AwaitOptions<T> & {
8
+ fallback?: React.ReactNode;
9
+ children: (result: T) => React.ReactNode;
10
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const warning = require("tiny-warning");
4
+ const route = require("./route.cjs");
5
+ const useMatch = require("./useMatch.cjs");
6
+ const useLoaderDeps = require("./useLoaderDeps.cjs");
7
+ const useLoaderData = require("./useLoaderData.cjs");
8
+ const useSearch = require("./useSearch.cjs");
9
+ const useParams = require("./useParams.cjs");
10
+ const useNavigate = require("./useNavigate.cjs");
11
+ const useRouter = require("./useRouter.cjs");
12
+ function createFileRoute(path) {
13
+ if (typeof path === "object") {
14
+ return new FileRoute(path, {
15
+ silent: true
16
+ }).createRoute(path);
17
+ }
18
+ return new FileRoute(path, {
19
+ silent: true
20
+ }).createRoute;
21
+ }
22
+ class FileRoute {
23
+ constructor(path, _opts) {
24
+ this.path = path;
25
+ this.createRoute = (options) => {
26
+ warning(
27
+ this.silent,
28
+ "FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
29
+ );
30
+ const route$1 = route.createRoute(options);
31
+ route$1.isRoot = false;
32
+ return route$1;
33
+ };
34
+ this.silent = _opts == null ? void 0 : _opts.silent;
35
+ }
36
+ }
37
+ function FileRouteLoader(_path) {
38
+ warning(
39
+ false,
40
+ `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`
41
+ );
42
+ return (loaderFn) => loaderFn;
43
+ }
44
+ class LazyRoute {
45
+ constructor(opts) {
46
+ this.useMatch = (opts2) => {
47
+ return useMatch.useMatch({
48
+ select: opts2 == null ? void 0 : opts2.select,
49
+ from: this.options.id,
50
+ structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing
51
+ });
52
+ };
53
+ this.useRouteContext = (opts2) => {
54
+ return useMatch.useMatch({
55
+ from: this.options.id,
56
+ select: (d) => (opts2 == null ? void 0 : opts2.select) ? opts2.select(d.context) : d.context
57
+ });
58
+ };
59
+ this.useSearch = (opts2) => {
60
+ return useSearch.useSearch({
61
+ select: opts2 == null ? void 0 : opts2.select,
62
+ structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing,
63
+ from: this.options.id
64
+ });
65
+ };
66
+ this.useParams = (opts2) => {
67
+ return useParams.useParams({
68
+ select: opts2 == null ? void 0 : opts2.select,
69
+ structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing,
70
+ from: this.options.id
71
+ });
72
+ };
73
+ this.useLoaderDeps = (opts2) => {
74
+ return useLoaderDeps.useLoaderDeps({ ...opts2, from: this.options.id });
75
+ };
76
+ this.useLoaderData = (opts2) => {
77
+ return useLoaderData.useLoaderData({ ...opts2, from: this.options.id });
78
+ };
79
+ this.useNavigate = () => {
80
+ const router = useRouter.useRouter();
81
+ return useNavigate.useNavigate({ from: router.routesById[this.options.id].fullPath });
82
+ };
83
+ this.options = opts;
84
+ this.$$typeof = Symbol.for("react.memo");
85
+ }
86
+ }
87
+ function createLazyRoute(id) {
88
+ return (opts) => {
89
+ return new LazyRoute({
90
+ id,
91
+ ...opts
92
+ });
93
+ };
94
+ }
95
+ function createLazyFileRoute(id) {
96
+ if (typeof id === "object") {
97
+ return new LazyRoute(id);
98
+ }
99
+ return (opts) => new LazyRoute({ id, ...opts });
100
+ }
101
+ exports.FileRoute = FileRoute;
102
+ exports.FileRouteLoader = FileRouteLoader;
103
+ exports.LazyRoute = LazyRoute;
104
+ exports.createFileRoute = createFileRoute;
105
+ exports.createLazyFileRoute = createLazyFileRoute;
106
+ exports.createLazyRoute = createLazyRoute;
107
+ //# sourceMappingURL=fileRoute.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileRoute.cjs","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderFn,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n >(\n options?: FileBaseRouteOptions<\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderFn<\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useMatch({\n from: this.options.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\n\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"names":["route","createRoute","opts","useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useRouter","useNavigate"],"mappings":";;;;;;;;;;;AAoCO,SAAS,gBAQd,MAC0E;AACtE,MAAA,OAAO,SAAS,UAAU;AACrB,WAAA,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EAAA;AAEd,SAAA,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA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D,aAAAI,cAAAA,cAAc,EAAE,GAAGJ,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AACnD,aAAAK,cAAAA,cAAc,EAAE,GAAGL,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAASM,UAAAA,UAAU;AAClB,aAAAC,YAAA,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AAhDE,SAAK,UAAU;AACb,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EAAA;AAgDrD;AAEO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AAEO,SAAS,oBAGd,IAA8D;AAC1D,MAAA,OAAO,OAAO,UAAU;AACnB,WAAA,IAAI,UAAkB,EAAE;AAAA,EAAA;AAG1B,SAAA,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;;;;;;;"}
@@ -0,0 +1,54 @@
1
+ import { UseParamsRoute } from './useParams.cjs';
2
+ import { UseMatchRoute } from './useMatch.cjs';
3
+ import { UseSearchRoute } from './useSearch.cjs';
4
+ import { AnyContext, AnyRoute, AnyRouter, Constrain, ConstrainLiteral, FileBaseRouteOptions, FileRoutesByPath, LazyRouteOptions, RegisteredRouter, ResolveParams, Route, RouteById, RouteConstraints, RouteIds, RouteLoaderFn, UpdatableRouteOptions, UseNavigateResult } from '@tanstack/router-core';
5
+ import { UseLoaderDepsRoute } from './useLoaderDeps.cjs';
6
+ import { UseLoaderDataRoute } from './useLoaderData.cjs';
7
+ import { UseRouteContextRoute } from './useRouteContext.cjs';
8
+ export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath']>(path?: TFilePath): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'];
9
+ /**
10
+ @deprecated It's no longer recommended to use the `FileRoute` class directly.
11
+ Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
12
+ */
13
+ export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath']> {
14
+ path?: TFilePath | undefined;
15
+ silent?: boolean;
16
+ constructor(path?: TFilePath | undefined, _opts?: {
17
+ silent: boolean;
18
+ });
19
+ createRoute: <TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown>(options?: FileBaseRouteOptions<TParentRoute, TId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn> & UpdatableRouteOptions<TParentRoute, TId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, AnyContext, TRouteContextFn, TBeforeLoadFn>) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, unknown>;
20
+ }
21
+ /**
22
+ @deprecated It's recommended not to split loaders into separate files.
23
+ Instead, place the loader function in the the main route file, inside the
24
+ `createFileRoute('/path/to/file)(options)` options.
25
+ */
26
+ export declare function FileRouteLoader<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(_path: TFilePath): <TLoaderFn>(loaderFn: Constrain<TLoaderFn, RouteLoaderFn<TRoute['parentRoute'], TRoute['types']['id'], TRoute['types']['params'], TRoute['types']['loaderDeps'], TRoute['types']['routerContext'], TRoute['types']['routeContextFn'], TRoute['types']['beforeLoadFn']>>) => TLoaderFn;
27
+ declare module '@tanstack/router-core' {
28
+ interface LazyRoute<in out TRoute extends AnyRoute> {
29
+ useMatch: UseMatchRoute<TRoute['id']>;
30
+ useRouteContext: UseRouteContextRoute<TRoute['id']>;
31
+ useSearch: UseSearchRoute<TRoute['id']>;
32
+ useParams: UseParamsRoute<TRoute['id']>;
33
+ useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>;
34
+ useLoaderData: UseLoaderDataRoute<TRoute['id']>;
35
+ useNavigate: () => UseNavigateResult<TRoute['fullPath']>;
36
+ }
37
+ }
38
+ export declare class LazyRoute<TRoute extends AnyRoute> {
39
+ options: {
40
+ id: string;
41
+ } & LazyRouteOptions;
42
+ constructor(opts: {
43
+ id: string;
44
+ } & LazyRouteOptions);
45
+ useMatch: UseMatchRoute<TRoute['id']>;
46
+ useRouteContext: UseRouteContextRoute<TRoute['id']>;
47
+ useSearch: UseSearchRoute<TRoute['id']>;
48
+ useParams: UseParamsRoute<TRoute['id']>;
49
+ useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>;
50
+ useLoaderData: UseLoaderDataRoute<TRoute['id']>;
51
+ useNavigate: () => UseNavigateResult<TRoute["fullPath"]>;
52
+ }
53
+ export declare function createLazyRoute<TRouter extends AnyRouter = RegisteredRouter, TId extends string = string, TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
54
+ export declare function createLazyFileRoute<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
@@ -0,0 +1,8 @@
1
+ declare module '@tanstack/history' {
2
+ interface HistoryState {
3
+ __tempLocation?: HistoryLocation;
4
+ __tempKey?: string;
5
+ __hashScrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
6
+ }
7
+ }
8
+ export {};