@depup/tanstack__react-router 1.166.4-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/cjs/Asset.cjs +177 -0
- package/dist/cjs/Asset.cjs.map +1 -0
- package/dist/cjs/Asset.d.cts +5 -0
- package/dist/cjs/CatchBoundary.cjs +114 -0
- package/dist/cjs/CatchBoundary.cjs.map +1 -0
- package/dist/cjs/CatchBoundary.d.cts +12 -0
- package/dist/cjs/ClientOnly.cjs +21 -0
- package/dist/cjs/ClientOnly.cjs.map +1 -0
- package/dist/cjs/ClientOnly.d.cts +49 -0
- package/dist/cjs/HeadContent.cjs +15 -0
- package/dist/cjs/HeadContent.cjs.map +1 -0
- package/dist/cjs/HeadContent.d.cts +6 -0
- package/dist/cjs/HeadContent.dev.cjs +41 -0
- package/dist/cjs/HeadContent.dev.cjs.map +1 -0
- package/dist/cjs/HeadContent.dev.d.cts +10 -0
- package/dist/cjs/Match.cjs +255 -0
- package/dist/cjs/Match.cjs.map +1 -0
- package/dist/cjs/Match.d.cts +14 -0
- package/dist/cjs/Matches.cjs +138 -0
- package/dist/cjs/Matches.cjs.map +1 -0
- package/dist/cjs/Matches.d.cts +68 -0
- package/dist/cjs/RouterProvider.cjs +32 -0
- package/dist/cjs/RouterProvider.cjs.map +1 -0
- package/dist/cjs/RouterProvider.d.cts +23 -0
- package/dist/cjs/SafeFragment.cjs +8 -0
- package/dist/cjs/SafeFragment.cjs.map +1 -0
- package/dist/cjs/SafeFragment.d.cts +1 -0
- package/dist/cjs/ScriptOnce.cjs +22 -0
- package/dist/cjs/ScriptOnce.cjs.map +1 -0
- package/dist/cjs/ScriptOnce.d.cts +6 -0
- package/dist/cjs/Scripts.cjs +56 -0
- package/dist/cjs/Scripts.cjs.map +1 -0
- package/dist/cjs/Scripts.d.cts +5 -0
- package/dist/cjs/ScrollRestoration.cjs +38 -0
- package/dist/cjs/ScrollRestoration.cjs.map +1 -0
- package/dist/cjs/ScrollRestoration.d.cts +14 -0
- package/dist/cjs/Transitioner.cjs +119 -0
- package/dist/cjs/Transitioner.cjs.map +1 -0
- package/dist/cjs/Transitioner.d.cts +1 -0
- package/dist/cjs/awaited.cjs +51 -0
- package/dist/cjs/awaited.cjs.map +1 -0
- package/dist/cjs/awaited.d.cts +14 -0
- package/dist/cjs/fileRoute.cjs +109 -0
- package/dist/cjs/fileRoute.cjs.map +1 -0
- package/dist/cjs/fileRoute.d.cts +87 -0
- package/dist/cjs/headContentUtils.cjs +185 -0
- package/dist/cjs/headContentUtils.cjs.map +1 -0
- package/dist/cjs/headContentUtils.d.cts +7 -0
- package/dist/cjs/history.d.cts +8 -0
- package/dist/cjs/index.cjs +241 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +51 -0
- package/dist/cjs/index.dev.cjs +241 -0
- package/dist/cjs/index.dev.cjs.map +1 -0
- package/dist/cjs/index.dev.d.cts +2 -0
- package/dist/cjs/lazyRouteComponent.cjs +70 -0
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -0
- package/dist/cjs/lazyRouteComponent.d.cts +11 -0
- package/dist/cjs/link.cjs +573 -0
- package/dist/cjs/link.cjs.map +1 -0
- package/dist/cjs/link.d.cts +98 -0
- package/dist/cjs/matchContext.cjs +27 -0
- package/dist/cjs/matchContext.cjs.map +1 -0
- package/dist/cjs/matchContext.d.cts +3 -0
- package/dist/cjs/not-found.cjs +38 -0
- package/dist/cjs/not-found.cjs.map +1 -0
- package/dist/cjs/not-found.d.cts +9 -0
- package/dist/cjs/renderRouteNotFound.cjs +22 -0
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -0
- package/dist/cjs/renderRouteNotFound.d.cts +10 -0
- package/dist/cjs/route.cjs +198 -0
- package/dist/cjs/route.cjs.map +1 -0
- package/dist/cjs/route.d.cts +142 -0
- package/dist/cjs/router.cjs +22 -0
- package/dist/cjs/router.cjs.map +1 -0
- package/dist/cjs/router.d.cts +83 -0
- package/dist/cjs/routerContext.cjs +23 -0
- package/dist/cjs/routerContext.cjs.map +1 -0
- package/dist/cjs/routerContext.d.cts +3 -0
- package/dist/cjs/scroll-restoration.cjs +39 -0
- package/dist/cjs/scroll-restoration.cjs.map +1 -0
- package/dist/cjs/scroll-restoration.d.cts +1 -0
- package/dist/cjs/ssr/RouterClient.cjs +25 -0
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -0
- package/dist/cjs/ssr/RouterClient.d.cts +4 -0
- package/dist/cjs/ssr/RouterServer.cjs +9 -0
- package/dist/cjs/ssr/RouterServer.cjs.map +1 -0
- package/dist/cjs/ssr/RouterServer.d.cts +4 -0
- package/dist/cjs/ssr/client.cjs +12 -0
- package/dist/cjs/ssr/client.cjs.map +1 -0
- package/dist/cjs/ssr/client.d.cts +2 -0
- package/dist/cjs/ssr/defaultRenderHandler.cjs +15 -0
- package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -0
- package/dist/cjs/ssr/defaultRenderHandler.d.cts +1 -0
- package/dist/cjs/ssr/defaultStreamHandler.cjs +16 -0
- package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -0
- package/dist/cjs/ssr/defaultStreamHandler.d.cts +1 -0
- package/dist/cjs/ssr/renderRouterToStream.cjs +73 -0
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -0
- package/dist/cjs/ssr/renderRouterToStream.d.cts +8 -0
- package/dist/cjs/ssr/renderRouterToString.cjs +31 -0
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -0
- package/dist/cjs/ssr/renderRouterToString.d.cts +7 -0
- package/dist/cjs/ssr/serializer.d.cts +6 -0
- package/dist/cjs/ssr/server.cjs +20 -0
- package/dist/cjs/ssr/server.cjs.map +1 -0
- package/dist/cjs/ssr/server.d.cts +6 -0
- package/dist/cjs/structuralSharing.d.cts +8 -0
- package/dist/cjs/typePrimitives.d.cts +16 -0
- package/dist/cjs/useBlocker.cjs +171 -0
- package/dist/cjs/useBlocker.cjs.map +1 -0
- package/dist/cjs/useBlocker.d.cts +66 -0
- package/dist/cjs/useCanGoBack.cjs +8 -0
- package/dist/cjs/useCanGoBack.cjs.map +1 -0
- package/dist/cjs/useCanGoBack.d.cts +1 -0
- package/dist/cjs/useLoaderData.cjs +15 -0
- package/dist/cjs/useLoaderData.cjs.map +1 -0
- package/dist/cjs/useLoaderData.d.cts +19 -0
- package/dist/cjs/useLoaderDeps.cjs +14 -0
- package/dist/cjs/useLoaderDeps.cjs.map +1 -0
- package/dist/cjs/useLoaderDeps.d.cts +19 -0
- package/dist/cjs/useLocation.cjs +10 -0
- package/dist/cjs/useLocation.cjs.map +1 -0
- package/dist/cjs/useLocation.d.cts +18 -0
- package/dist/cjs/useMatch.cjs +47 -0
- package/dist/cjs/useMatch.cjs.map +1 -0
- package/dist/cjs/useMatch.d.cts +14 -0
- package/dist/cjs/useNavigate.cjs +49 -0
- package/dist/cjs/useNavigate.cjs.map +1 -0
- package/dist/cjs/useNavigate.d.cts +28 -0
- package/dist/cjs/useParams.cjs +17 -0
- package/dist/cjs/useParams.cjs.map +1 -0
- package/dist/cjs/useParams.d.cts +21 -0
- package/dist/cjs/useRouteContext.cjs +11 -0
- package/dist/cjs/useRouteContext.cjs.map +1 -0
- package/dist/cjs/useRouteContext.d.cts +3 -0
- package/dist/cjs/useRouter.cjs +32 -0
- package/dist/cjs/useRouter.cjs.map +1 -0
- package/dist/cjs/useRouter.d.cts +14 -0
- package/dist/cjs/useRouterState.cjs +38 -0
- package/dist/cjs/useRouterState.cjs.map +1 -0
- package/dist/cjs/useRouterState.d.cts +20 -0
- package/dist/cjs/useSearch.cjs +16 -0
- package/dist/cjs/useSearch.cjs.map +1 -0
- package/dist/cjs/useSearch.d.cts +21 -0
- package/dist/cjs/utils.cjs +62 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +54 -0
- package/dist/esm/Asset.d.ts +5 -0
- package/dist/esm/Asset.js +160 -0
- package/dist/esm/Asset.js.map +1 -0
- package/dist/esm/CatchBoundary.d.ts +12 -0
- package/dist/esm/CatchBoundary.js +97 -0
- package/dist/esm/CatchBoundary.js.map +1 -0
- package/dist/esm/ClientOnly.d.ts +49 -0
- package/dist/esm/ClientOnly.js +21 -0
- package/dist/esm/ClientOnly.js.map +1 -0
- package/dist/esm/HeadContent.d.ts +6 -0
- package/dist/esm/HeadContent.dev.d.ts +10 -0
- package/dist/esm/HeadContent.dev.js +25 -0
- package/dist/esm/HeadContent.dev.js.map +1 -0
- package/dist/esm/HeadContent.js +15 -0
- package/dist/esm/HeadContent.js.map +1 -0
- package/dist/esm/Match.d.ts +14 -0
- package/dist/esm/Match.js +238 -0
- package/dist/esm/Match.js.map +1 -0
- package/dist/esm/Matches.d.ts +68 -0
- package/dist/esm/Matches.js +121 -0
- package/dist/esm/Matches.js.map +1 -0
- package/dist/esm/RouterProvider.d.ts +23 -0
- package/dist/esm/RouterProvider.js +32 -0
- package/dist/esm/RouterProvider.js.map +1 -0
- package/dist/esm/SafeFragment.d.ts +1 -0
- package/dist/esm/SafeFragment.js +8 -0
- package/dist/esm/SafeFragment.js.map +1 -0
- package/dist/esm/ScriptOnce.d.ts +6 -0
- package/dist/esm/ScriptOnce.js +22 -0
- package/dist/esm/ScriptOnce.js.map +1 -0
- package/dist/esm/Scripts.d.ts +5 -0
- package/dist/esm/Scripts.js +56 -0
- package/dist/esm/Scripts.js.map +1 -0
- package/dist/esm/ScrollRestoration.d.ts +14 -0
- package/dist/esm/ScrollRestoration.js +38 -0
- package/dist/esm/ScrollRestoration.js.map +1 -0
- package/dist/esm/Transitioner.d.ts +1 -0
- package/dist/esm/Transitioner.js +102 -0
- package/dist/esm/Transitioner.js.map +1 -0
- package/dist/esm/awaited.d.ts +14 -0
- package/dist/esm/awaited.js +34 -0
- package/dist/esm/awaited.js.map +1 -0
- package/dist/esm/fileRoute.d.ts +87 -0
- package/dist/esm/fileRoute.js +109 -0
- package/dist/esm/fileRoute.js.map +1 -0
- package/dist/esm/headContentUtils.d.ts +7 -0
- package/dist/esm/headContentUtils.js +168 -0
- package/dist/esm/headContentUtils.js.map +1 -0
- package/dist/esm/history.d.ts +8 -0
- package/dist/esm/index.d.ts +51 -0
- package/dist/esm/index.dev.d.ts +2 -0
- package/dist/esm/index.dev.js +133 -0
- package/dist/esm/index.dev.js.map +1 -0
- package/dist/esm/index.js +133 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lazyRouteComponent.d.ts +11 -0
- package/dist/esm/lazyRouteComponent.js +53 -0
- package/dist/esm/lazyRouteComponent.js.map +1 -0
- package/dist/esm/link.d.ts +98 -0
- package/dist/esm/link.js +556 -0
- package/dist/esm/link.js.map +1 -0
- package/dist/esm/matchContext.d.ts +3 -0
- package/dist/esm/matchContext.js +10 -0
- package/dist/esm/matchContext.js.map +1 -0
- package/dist/esm/not-found.d.ts +9 -0
- package/dist/esm/not-found.js +38 -0
- package/dist/esm/not-found.js.map +1 -0
- package/dist/esm/renderRouteNotFound.d.ts +10 -0
- package/dist/esm/renderRouteNotFound.js +22 -0
- package/dist/esm/renderRouteNotFound.js.map +1 -0
- package/dist/esm/route.d.ts +142 -0
- package/dist/esm/route.js +198 -0
- package/dist/esm/route.js.map +1 -0
- package/dist/esm/router.d.ts +83 -0
- package/dist/esm/router.js +22 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/routerContext.d.ts +3 -0
- package/dist/esm/routerContext.js +6 -0
- package/dist/esm/routerContext.js.map +1 -0
- package/dist/esm/scroll-restoration.d.ts +1 -0
- package/dist/esm/scroll-restoration.js +39 -0
- package/dist/esm/scroll-restoration.js.map +1 -0
- package/dist/esm/ssr/RouterClient.d.ts +4 -0
- package/dist/esm/ssr/RouterClient.js +25 -0
- package/dist/esm/ssr/RouterClient.js.map +1 -0
- package/dist/esm/ssr/RouterServer.d.ts +4 -0
- package/dist/esm/ssr/RouterServer.js +9 -0
- package/dist/esm/ssr/RouterServer.js.map +1 -0
- package/dist/esm/ssr/client.d.ts +2 -0
- package/dist/esm/ssr/client.js +6 -0
- package/dist/esm/ssr/client.js.map +1 -0
- package/dist/esm/ssr/defaultRenderHandler.d.ts +1 -0
- package/dist/esm/ssr/defaultRenderHandler.js +15 -0
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -0
- package/dist/esm/ssr/defaultStreamHandler.d.ts +1 -0
- package/dist/esm/ssr/defaultStreamHandler.js +16 -0
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -0
- package/dist/esm/ssr/renderRouterToStream.d.ts +8 -0
- package/dist/esm/ssr/renderRouterToStream.js +73 -0
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -0
- package/dist/esm/ssr/renderRouterToString.d.ts +7 -0
- package/dist/esm/ssr/renderRouterToString.js +31 -0
- package/dist/esm/ssr/renderRouterToString.js.map +1 -0
- package/dist/esm/ssr/serializer.d.ts +6 -0
- package/dist/esm/ssr/server.d.ts +6 -0
- package/dist/esm/ssr/server.js +14 -0
- package/dist/esm/ssr/server.js.map +1 -0
- package/dist/esm/structuralSharing.d.ts +8 -0
- package/dist/esm/typePrimitives.d.ts +16 -0
- package/dist/esm/useBlocker.d.ts +66 -0
- package/dist/esm/useBlocker.js +154 -0
- package/dist/esm/useBlocker.js.map +1 -0
- package/dist/esm/useCanGoBack.d.ts +1 -0
- package/dist/esm/useCanGoBack.js +8 -0
- package/dist/esm/useCanGoBack.js.map +1 -0
- package/dist/esm/useLoaderData.d.ts +19 -0
- package/dist/esm/useLoaderData.js +15 -0
- package/dist/esm/useLoaderData.js.map +1 -0
- package/dist/esm/useLoaderDeps.d.ts +19 -0
- package/dist/esm/useLoaderDeps.js +14 -0
- package/dist/esm/useLoaderDeps.js.map +1 -0
- package/dist/esm/useLocation.d.ts +18 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/dist/esm/useMatch.d.ts +14 -0
- package/dist/esm/useMatch.js +30 -0
- package/dist/esm/useMatch.js.map +1 -0
- package/dist/esm/useNavigate.d.ts +28 -0
- package/dist/esm/useNavigate.js +32 -0
- package/dist/esm/useNavigate.js.map +1 -0
- package/dist/esm/useParams.d.ts +21 -0
- package/dist/esm/useParams.js +17 -0
- package/dist/esm/useParams.js.map +1 -0
- package/dist/esm/useRouteContext.d.ts +3 -0
- package/dist/esm/useRouteContext.js +11 -0
- package/dist/esm/useRouteContext.js.map +1 -0
- package/dist/esm/useRouter.d.ts +14 -0
- package/dist/esm/useRouter.js +15 -0
- package/dist/esm/useRouter.js.map +1 -0
- package/dist/esm/useRouterState.d.ts +20 -0
- package/dist/esm/useRouterState.js +38 -0
- package/dist/esm/useRouterState.js.map +1 -0
- package/dist/esm/useSearch.d.ts +21 -0
- package/dist/esm/useSearch.js +16 -0
- package/dist/esm/useSearch.js.map +1 -0
- package/dist/esm/utils.d.ts +54 -0
- package/dist/esm/utils.js +45 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/llms/index.d.ts +3 -0
- package/dist/llms/index.js +43 -0
- package/dist/llms/rules/api.d.ts +2 -0
- package/dist/llms/rules/api.js +4612 -0
- package/dist/llms/rules/guide.d.ts +2 -0
- package/dist/llms/rules/guide.js +10690 -0
- package/dist/llms/rules/installation.d.ts +2 -0
- package/dist/llms/rules/installation.js +1285 -0
- package/dist/llms/rules/routing.d.ts +2 -0
- package/dist/llms/rules/routing.js +1984 -0
- package/dist/llms/rules/setup-and-architecture.d.ts +2 -0
- package/dist/llms/rules/setup-and-architecture.js +920 -0
- package/package.json +142 -0
- package/src/Asset.tsx +219 -0
- package/src/CatchBoundary.tsx +120 -0
- package/src/ClientOnly.tsx +68 -0
- package/src/HeadContent.dev.tsx +46 -0
- package/src/HeadContent.tsx +22 -0
- package/src/Match.tsx +360 -0
- package/src/Matches.tsx +313 -0
- package/src/RouterProvider.tsx +92 -0
- package/src/SafeFragment.tsx +5 -0
- package/src/ScriptOnce.tsx +21 -0
- package/src/Scripts.tsx +80 -0
- package/src/ScrollRestoration.tsx +69 -0
- package/src/Transitioner.tsx +134 -0
- package/src/awaited.tsx +55 -0
- package/src/fileRoute.ts +313 -0
- package/src/headContentUtils.tsx +217 -0
- package/src/history.ts +9 -0
- package/src/index.dev.tsx +6 -0
- package/src/index.tsx +341 -0
- package/src/lazyRouteComponent.tsx +96 -0
- package/src/link.tsx +984 -0
- package/src/matchContext.tsx +8 -0
- package/src/not-found.tsx +43 -0
- package/src/renderRouteNotFound.tsx +35 -0
- package/src/route.tsx +740 -0
- package/src/router.ts +127 -0
- package/src/routerContext.tsx +4 -0
- package/src/scroll-restoration.tsx +45 -0
- package/src/ssr/RouterClient.tsx +22 -0
- package/src/ssr/RouterServer.tsx +9 -0
- package/src/ssr/client.ts +2 -0
- package/src/ssr/defaultRenderHandler.tsx +12 -0
- package/src/ssr/defaultStreamHandler.tsx +13 -0
- package/src/ssr/renderRouterToStream.tsx +90 -0
- package/src/ssr/renderRouterToString.tsx +36 -0
- package/src/ssr/serializer.ts +7 -0
- package/src/ssr/server.ts +6 -0
- package/src/structuralSharing.ts +47 -0
- package/src/typePrimitives.ts +84 -0
- package/src/useBlocker.tsx +320 -0
- package/src/useCanGoBack.ts +5 -0
- package/src/useLoaderData.tsx +91 -0
- package/src/useLoaderDeps.tsx +69 -0
- package/src/useLocation.tsx +52 -0
- package/src/useMatch.tsx +123 -0
- package/src/useNavigate.tsx +78 -0
- package/src/useParams.tsx +107 -0
- package/src/useRouteContext.ts +30 -0
- package/src/useRouter.tsx +25 -0
- package/src/useRouterState.tsx +86 -0
- package/src/useSearch.tsx +105 -0
- package/src/utils.ts +125 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const isServer = require("@tanstack/router-core/isServer");
|
|
5
|
+
const useRouter = require("./useRouter.cjs");
|
|
6
|
+
function ScriptOnce({ children }) {
|
|
7
|
+
const router = useRouter.useRouter();
|
|
8
|
+
if (!(isServer.isServer ?? router.isServer)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12
|
+
"script",
|
|
13
|
+
{
|
|
14
|
+
nonce: router.options.ssr?.nonce,
|
|
15
|
+
dangerouslySetInnerHTML: {
|
|
16
|
+
__html: children + ";document.currentScript.remove()"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
exports.ScriptOnce = ScriptOnce;
|
|
22
|
+
//# sourceMappingURL=ScriptOnce.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptOnce.cjs","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\n\n/**\n * Server-only helper to emit a script tag exactly once during SSR.\n */\nexport function ScriptOnce({ children }: { children: string }) {\n const router = useRouter()\n if (!(isServer ?? router.isServer)) {\n return null\n }\n\n return (\n <script\n nonce={router.options.ssr?.nonce}\n dangerouslySetInnerHTML={{\n __html: children + ';document.currentScript.remove()',\n }}\n />\n )\n}\n"],"names":["useRouter","isServer","jsx"],"mappings":";;;;;AAMO,SAAS,WAAW,EAAE,YAAkC;AAC7D,QAAM,SAASA,UAAAA,UAAA;AACf,MAAI,EAAEC,SAAAA,YAAY,OAAO,WAAW;AAClC,WAAO;AAAA,EACT;AAEA,SACEC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO,OAAO,QAAQ,KAAK;AAAA,MAC3B,yBAAyB;AAAA,QACvB,QAAQ,WAAW;AAAA,MAAA;AAAA,IACrB;AAAA,EAAA;AAGN;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 nonce = router.options.ssr?.nonce;
|
|
11
|
+
const assetScripts = useRouterState.useRouterState({
|
|
12
|
+
select: (state) => {
|
|
13
|
+
const assetScripts2 = [];
|
|
14
|
+
const manifest = router.ssr?.manifest;
|
|
15
|
+
if (!manifest) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
|
|
19
|
+
(route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
|
|
20
|
+
assetScripts2.push({
|
|
21
|
+
tag: "script",
|
|
22
|
+
attrs: { ...asset.attrs, nonce },
|
|
23
|
+
children: asset.children
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
return assetScripts2;
|
|
28
|
+
},
|
|
29
|
+
structuralSharing: true
|
|
30
|
+
});
|
|
31
|
+
const { scripts } = useRouterState.useRouterState({
|
|
32
|
+
select: (state) => ({
|
|
33
|
+
scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
34
|
+
tag: "script",
|
|
35
|
+
attrs: {
|
|
36
|
+
...script,
|
|
37
|
+
suppressHydrationWarning: true,
|
|
38
|
+
nonce
|
|
39
|
+
},
|
|
40
|
+
children
|
|
41
|
+
}))
|
|
42
|
+
}),
|
|
43
|
+
structuralSharing: true
|
|
44
|
+
});
|
|
45
|
+
let serverBufferedScript = void 0;
|
|
46
|
+
if (router.serverSsr) {
|
|
47
|
+
serverBufferedScript = router.serverSsr.takeBufferedScripts();
|
|
48
|
+
}
|
|
49
|
+
const allScripts = [...scripts, ...assetScripts];
|
|
50
|
+
if (serverBufferedScript) {
|
|
51
|
+
allScripts.unshift(serverBufferedScript);
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: allScripts.map((asset, i) => /* @__PURE__ */ React.createElement(Asset.Asset, { ...asset, key: `tsr-scripts-${asset.tag}-${i}` })) });
|
|
54
|
+
};
|
|
55
|
+
exports.Scripts = Scripts;
|
|
56
|
+
//# 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\n/**\n * Render body script tags collected from route matches and SSR manifests.\n * Should be placed near the end of the document body.\n */\nexport const Scripts = () => {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\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, nonce },\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 nonce,\n },\n children,\n })),\n }),\n structuralSharing: true as any,\n })\n\n let serverBufferedScript: RouterManagedTag | undefined = undefined\n\n if (router.serverSsr) {\n serverBufferedScript = router.serverSsr.takeBufferedScripts()\n }\n\n const allScripts = [...scripts, ...assetScripts] as Array<RouterManagedTag>\n\n if (serverBufferedScript) {\n allScripts.unshift(serverBufferedScript)\n }\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","Asset"],"mappings":";;;;;;;AASO,MAAM,UAAU,MAAM;AAC3B,QAAM,SAASA,UAAAA,UAAA;AACf,QAAM,QAAQ,OAAO,QAAQ,KAAK;AAClC,QAAM,eAAeC,eAAAA,eAAe;AAAA,IAClC,QAAQ,CAAC,UAAU;AACjB,YAAMC,gBAAwC,CAAA;AAC9C,YAAM,WAAW,OAAO,KAAK;AAE7B,UAAI,CAAC,UAAU;AACb,eAAO,CAAA;AAAA,MACT;AAEA,YAAM,QACH,IAAI,CAAC,UAAU,OAAO,gBAAgB,MAAM,OAAO,CAAE,EACrD;AAAA,QAAQ,CAAC,UACR,SAAS,OAAO,MAAM,EAAE,GAAG,QACvB,OAAO,CAAC,MAAM,EAAE,QAAQ,QAAQ,EACjC,QAAQ,CAAC,UAAU;AAClBA,wBAAa,KAAK;AAAA,YAChB,KAAK;AAAA,YACL,OAAO,EAAE,GAAG,MAAM,OAAO,MAAA;AAAA,YACzB,UAAU,MAAM;AAAA,UAAA,CACV;AAAA,QACV,CAAC;AAAA,MAAA;AAGP,aAAOA;AAAAA,IACT;AAAA,IACA,mBAAmB;AAAA,EAAA,CACpB;AAED,QAAM,EAAE,QAAA,IAAYD,8BAAe;AAAA,IACjC,QAAQ,CAAC,WAAW;AAAA,MAClB,SACE,MAAM,QACH,IAAI,CAAC,UAAU,MAAM,OAAQ,EAC7B,KAAK,CAAC,EACN,OAAO,OAAO,EACjB,IAAI,CAAC,EAAE,UAAU,GAAG,cAAc;AAAA,QAClC,KAAK;AAAA,QACL,OAAO;AAAA,UACL,GAAG;AAAA,UACH,0BAA0B;AAAA,UAC1B;AAAA,QAAA;AAAA,QAEF;AAAA,MAAA,EACA;AAAA,IAAA;AAAA,IAEJ,mBAAmB;AAAA,EAAA,CACpB;AAED,MAAI,uBAAqD;AAEzD,MAAI,OAAO,WAAW;AACpB,2BAAuB,OAAO,UAAU,oBAAA;AAAA,EAC1C;AAEA,QAAM,aAAa,CAAC,GAAG,SAAS,GAAG,YAAY;AAE/C,MAAI,sBAAsB;AACxB,eAAW,QAAQ,oBAAoB;AAAA,EACzC;AAEA,+DAEK,UAAA,WAAW,IAAI,CAAC,OAAO,0CACrBE,MAAAA,OAAA,EAAO,GAAG,OAAO,KAAK,eAAe,MAAM,GAAG,IAAI,CAAC,IAAI,CACzD,GACH;AAEJ;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
useScrollRestoration();
|
|
20
|
+
const router = useRouter.useRouter();
|
|
21
|
+
const getKey = options.getKey || routerCore.defaultGetScrollRestorationKey;
|
|
22
|
+
let elementSelector = "";
|
|
23
|
+
if (options.id) {
|
|
24
|
+
elementSelector = `[data-scroll-restoration-id="${options.id}"]`;
|
|
25
|
+
} else {
|
|
26
|
+
const element = options.getElement?.();
|
|
27
|
+
if (!element) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
elementSelector = element instanceof Window ? "window" : routerCore.getCssSelector(element);
|
|
31
|
+
}
|
|
32
|
+
const restoreKey = getKey(router.latestLocation);
|
|
33
|
+
const byKey = routerCore.scrollRestorationCache?.state[restoreKey];
|
|
34
|
+
return byKey?.[elementSelector];
|
|
35
|
+
}
|
|
36
|
+
exports.ScrollRestoration = ScrollRestoration;
|
|
37
|
+
exports.useElementScrollRestoration = useElementScrollRestoration;
|
|
38
|
+
//# 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 the `scrollRestoration` router 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,UAAA;AACfC,aAAAA,uBAAuB,QAAQ,IAAI;AACrC;AAKO,SAAS,kBAAkB,QAAkC;AAClE,uBAAA;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAQ;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAO;AACT;AAEO,SAAS,4BACd,SAYoC;AACpC,uBAAA;AAEA,QAAM,SAASD,UAAAA,UAAA;AACf,QAAM,SAAS,QAAQ,UAAUE,WAAAA;AAEjC,MAAI,kBAAkB;AAEtB,MAAI,QAAQ,IAAI;AACd,sBAAkB,gCAAgC,QAAQ,EAAE;AAAA,EAC9D,OAAO;AACL,UAAM,UAAU,QAAQ,aAAA;AACxB,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AACA,sBACE,mBAAmB,SAAS,WAAWC,WAAAA,eAAe,OAAO;AAAA,EACjE;AAEA,QAAM,aAAa,OAAO,OAAO,cAAc;AAC/C,QAAM,QAAQC,WAAAA,wBAAwB,MAAM,UAAU;AACtD,SAAO,QAAQ,eAAe;AAChC;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ParsedLocation, ScrollRestorationEntry, ScrollRestorationOptions } from '@tanstack/router-core';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use the `scrollRestoration` router 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,119 @@
|
|
|
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 [isTransitioning, setIsTransitioning] = React__namespace.useState(false);
|
|
29
|
+
const { hasPendingMatches, isLoading } = useRouterState.useRouterState({
|
|
30
|
+
select: (s) => ({
|
|
31
|
+
isLoading: s.isLoading,
|
|
32
|
+
hasPendingMatches: s.matches.some((d) => d.status === "pending")
|
|
33
|
+
}),
|
|
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
|
+
router.startTransition = (fn) => {
|
|
42
|
+
setIsTransitioning(true);
|
|
43
|
+
React__namespace.startTransition(() => {
|
|
44
|
+
fn();
|
|
45
|
+
setIsTransitioning(false);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
React__namespace.useEffect(() => {
|
|
49
|
+
const unsub = router.history.subscribe(router.load);
|
|
50
|
+
const nextLocation = router.buildLocation({
|
|
51
|
+
to: router.latestLocation.pathname,
|
|
52
|
+
search: true,
|
|
53
|
+
params: true,
|
|
54
|
+
hash: true,
|
|
55
|
+
state: true,
|
|
56
|
+
_includeValidateSearch: true
|
|
57
|
+
});
|
|
58
|
+
if (routerCore.trimPathRight(router.latestLocation.publicHref) !== routerCore.trimPathRight(nextLocation.publicHref)) {
|
|
59
|
+
router.commitLocation({ ...nextLocation, replace: true });
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
unsub();
|
|
63
|
+
};
|
|
64
|
+
}, [router, router.history]);
|
|
65
|
+
utils.useLayoutEffect(() => {
|
|
66
|
+
if (
|
|
67
|
+
// if we are hydrating from SSR, loading is triggered in ssr-client
|
|
68
|
+
typeof window !== "undefined" && router.ssr || mountLoadForRouter.current.router === router && mountLoadForRouter.current.mounted
|
|
69
|
+
) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
mountLoadForRouter.current = { router, mounted: true };
|
|
73
|
+
const tryLoad = async () => {
|
|
74
|
+
try {
|
|
75
|
+
await router.load();
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.error(err);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
tryLoad();
|
|
81
|
+
}, [router]);
|
|
82
|
+
utils.useLayoutEffect(() => {
|
|
83
|
+
if (previousIsLoading && !isLoading) {
|
|
84
|
+
router.emit({
|
|
85
|
+
type: "onLoad",
|
|
86
|
+
// When the new URL has committed, when the new matches have been loaded into state.matches
|
|
87
|
+
...routerCore.getLocationChangeInfo(router.state)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}, [previousIsLoading, router, isLoading]);
|
|
91
|
+
utils.useLayoutEffect(() => {
|
|
92
|
+
if (previousIsPagePending && !isPagePending) {
|
|
93
|
+
router.emit({
|
|
94
|
+
type: "onBeforeRouteMount",
|
|
95
|
+
...routerCore.getLocationChangeInfo(router.state)
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}, [isPagePending, previousIsPagePending, router]);
|
|
99
|
+
utils.useLayoutEffect(() => {
|
|
100
|
+
if (previousIsAnyPending && !isAnyPending) {
|
|
101
|
+
const changeInfo = routerCore.getLocationChangeInfo(router.state);
|
|
102
|
+
router.emit({
|
|
103
|
+
type: "onResolved",
|
|
104
|
+
...changeInfo
|
|
105
|
+
});
|
|
106
|
+
router.__store.setState((s) => ({
|
|
107
|
+
...s,
|
|
108
|
+
status: "idle",
|
|
109
|
+
resolvedLocation: s.location
|
|
110
|
+
}));
|
|
111
|
+
if (changeInfo.hrefChanged) {
|
|
112
|
+
routerCore.handleHashScroll(router);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, [isAnyPending, previousIsAnyPending, router]);
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
exports.Transitioner = Transitioner;
|
|
119
|
+
//# 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\n const [isTransitioning, setIsTransitioning] = React.useState(false)\n // Track pending state changes\n const { hasPendingMatches, isLoading } = useRouterState({\n select: (s) => ({\n isLoading: s.isLoading,\n hasPendingMatches: s.matches.some((d) => d.status === 'pending'),\n }),\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 router.startTransition = (fn: () => void) => {\n setIsTransitioning(true)\n React.startTransition(() => {\n fn()\n setIsTransitioning(false)\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 // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\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 // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\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 if (previousIsAnyPending && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s: typeof router.state) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n }, [isAnyPending, previousIsAnyPending, router])\n\n return null\n}\n"],"names":["useRouter","React","useRouterState","usePrevious","trimPathRight","useLayoutEffect","getLocationChangeInfo","handleHashScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAS,eAAe;AAC7B,QAAM,SAASA,UAAAA,UAAA;AACf,QAAM,qBAAqBC,iBAAM,OAAO,EAAE,QAAQ,SAAS,OAAO;AAElE,QAAM,CAAC,iBAAiB,kBAAkB,IAAIA,iBAAM,SAAS,KAAK;AAElE,QAAM,EAAE,mBAAmB,UAAA,IAAcC,8BAAe;AAAA,IACtD,QAAQ,CAAC,OAAO;AAAA,MACd,WAAW,EAAE;AAAA,MACb,mBAAmB,EAAE,QAAQ,KAAK,CAAC,MAAM,EAAE,WAAW,SAAS;AAAA,IAAA;AAAA,IAEjE,mBAAmB;AAAA,EAAA,CACpB;AAED,QAAM,oBAAoBC,MAAAA,YAAY,SAAS;AAE/C,QAAM,eAAe,aAAa,mBAAmB;AACrD,QAAM,uBAAuBA,MAAAA,YAAY,YAAY;AAErD,QAAM,gBAAgB,aAAa;AACnC,QAAM,wBAAwBA,MAAAA,YAAY,aAAa;AAEvD,SAAO,kBAAkB,CAAC,OAAmB;AAC3C,uBAAmB,IAAI;AACvBF,qBAAM,gBAAgB,MAAM;AAC1B,SAAA;AACA,yBAAmB,KAAK;AAAA,IAC1B,CAAC;AAAA,EACH;AAIAA,mBAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,OAAO,QAAQ,UAAU,OAAO,IAAI;AAElD,UAAM,eAAe,OAAO,cAAc;AAAA,MACxC,IAAI,OAAO,eAAe;AAAA,MAC1B,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,wBAAwB;AAAA,IAAA,CACzB;AAKD,QACEG,WAAAA,cAAc,OAAO,eAAe,UAAU,MAC9CA,yBAAc,aAAa,UAAU,GACrC;AACA,aAAO,eAAe,EAAE,GAAG,cAAc,SAAS,MAAM;AAAA,IAC1D;AAEA,WAAO,MAAM;AACX,YAAA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,OAAO,CAAC;AAG3BC,QAAAA,gBAAgB,MAAM;AACpB;AAAA;AAAA,MAEG,OAAO,WAAW,eAAe,OAAO,OACxC,mBAAmB,QAAQ,WAAW,UACrC,mBAAmB,QAAQ;AAAA,MAC7B;AACA;AAAA,IACF;AACA,uBAAmB,UAAU,EAAE,QAAQ,SAAS,KAAA;AAEhD,UAAM,UAAU,YAAY;AAC1B,UAAI;AACF,cAAM,OAAO,KAAA;AAAA,MACf,SAAS,KAAK;AACZ,gBAAQ,MAAM,GAAG;AAAA,MACnB;AAAA,IACF;AAEA,YAAA;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AAEXA,QAAAA,gBAAgB,MAAM;AAEpB,QAAI,qBAAqB,CAAC,WAAW;AACnC,aAAO,KAAK;AAAA,QACV,MAAM;AAAA;AAAA,QACN,GAAGC,WAAAA,sBAAsB,OAAO,KAAK;AAAA,MAAA,CACtC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,mBAAmB,QAAQ,SAAS,CAAC;AAEzCD,QAAAA,gBAAgB,MAAM;AAEpB,QAAI,yBAAyB,CAAC,eAAe;AAC3C,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,GAAGC,WAAAA,sBAAsB,OAAO,KAAK;AAAA,MAAA,CACtC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,eAAe,uBAAuB,MAAM,CAAC;AAEjDD,QAAAA,gBAAgB,MAAM;AACpB,QAAI,wBAAwB,CAAC,cAAc;AACzC,YAAM,aAAaC,WAAAA,sBAAsB,OAAO,KAAK;AACrD,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA,CACJ;AAED,aAAO,QAAQ,SAAS,CAAC,OAA4B;AAAA,QACnD,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,kBAAkB,EAAE;AAAA,MAAA,EACpB;AAEF,UAAI,WAAW,aAAa;AAC1BC,mBAAAA,iBAAiB,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,cAAc,sBAAsB,MAAM,CAAC;AAE/C,SAAO;AACT;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Transitioner(): null;
|
|
@@ -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 routerCore = require("@tanstack/router-core");
|
|
6
|
+
const utils = require("./utils.cjs");
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
+
if (e) {
|
|
10
|
+
for (const k in e) {
|
|
11
|
+
if (k !== "default") {
|
|
12
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: () => e[k]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
24
|
+
function useAwaited({ promise: _promise }) {
|
|
25
|
+
if (utils.reactUse) {
|
|
26
|
+
const data = utils.reactUse(_promise);
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
const promise = routerCore.defer(_promise);
|
|
30
|
+
if (promise[routerCore.TSR_DEFERRED_PROMISE].status === "pending") {
|
|
31
|
+
throw promise;
|
|
32
|
+
}
|
|
33
|
+
if (promise[routerCore.TSR_DEFERRED_PROMISE].status === "error") {
|
|
34
|
+
throw promise[routerCore.TSR_DEFERRED_PROMISE].error;
|
|
35
|
+
}
|
|
36
|
+
return promise[routerCore.TSR_DEFERRED_PROMISE].data;
|
|
37
|
+
}
|
|
38
|
+
function Await(props) {
|
|
39
|
+
const inner = /* @__PURE__ */ jsxRuntime.jsx(AwaitInner, { ...props });
|
|
40
|
+
if (props.fallback) {
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Suspense, { fallback: props.fallback, children: inner });
|
|
42
|
+
}
|
|
43
|
+
return inner;
|
|
44
|
+
}
|
|
45
|
+
function AwaitInner(props) {
|
|
46
|
+
const data = useAwaited(props);
|
|
47
|
+
return props.children(data);
|
|
48
|
+
}
|
|
49
|
+
exports.Await = Await;
|
|
50
|
+
exports.useAwaited = useAwaited;
|
|
51
|
+
//# 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 { reactUse } from './utils'\n\nexport type AwaitOptions<T> = {\n promise: Promise<T>\n}\n\n/** Suspend until a deferred promise resolves or rejects and return its data. */\nexport function useAwaited<T>({ promise: _promise }: AwaitOptions<T>): T {\n if (reactUse) {\n const data = reactUse(_promise)\n return data\n }\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\n}\n\n/**\n * Component that suspends on a deferred promise and renders its child with\n * the resolved value. Optionally provides a Suspense fallback.\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":["reactUse","defer","TSR_DEFERRED_PROMISE","jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAS,WAAc,EAAE,SAAS,YAAgC;AACvE,MAAIA,gBAAU;AACZ,UAAM,OAAOA,MAAAA,SAAS,QAAQ;AAC9B,WAAO;AAAA,EACT;AACA,QAAM,UAAUC,WAAAA,MAAM,QAAQ;AAE9B,MAAI,QAAQC,WAAAA,oBAAoB,EAAE,WAAW,WAAW;AACtD,UAAM;AAAA,EACR;AAEA,MAAI,QAAQA,WAAAA,oBAAoB,EAAE,WAAW,SAAS;AACpD,UAAM,QAAQA,WAAAA,oBAAoB,EAAE;AAAA,EACtC;AAEA,SAAO,QAAQA,WAAAA,oBAAoB,EAAE;AACvC;AAMO,SAAS,MACd,OAIA;AACA,QAAM,QAAQC,2BAAAA,IAAC,YAAA,EAAY,GAAG,MAAA,CAAO;AACrC,MAAI,MAAM,UAAU;AAClB,0CAAQC,iBAAM,UAAN,EAAe,UAAU,MAAM,UAAW,UAAA,OAAM;AAAA,EAC1D;AACA,SAAO;AACT;AAEA,SAAS,WACP,OAImB;AACnB,QAAM,OAAO,WAAW,KAAK;AAE7B,SAAO,MAAM,SAAS,IAAI;AAC5B;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type AwaitOptions<T> = {
|
|
3
|
+
promise: Promise<T>;
|
|
4
|
+
};
|
|
5
|
+
/** Suspend until a deferred promise resolves or rejects and return its data. */
|
|
6
|
+
export declare function useAwaited<T>({ promise: _promise }: AwaitOptions<T>): T;
|
|
7
|
+
/**
|
|
8
|
+
* Component that suspends on a deferred promise and renders its child with
|
|
9
|
+
* the resolved value. Optionally provides a Suspense fallback.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Await<T>(props: AwaitOptions<T> & {
|
|
12
|
+
fallback?: React.ReactNode;
|
|
13
|
+
children: (result: T) => React.ReactNode;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
const useRouteContext = require("./useRouteContext.cjs");
|
|
13
|
+
function createFileRoute(path) {
|
|
14
|
+
if (typeof path === "object") {
|
|
15
|
+
return new FileRoute(path, {
|
|
16
|
+
silent: true
|
|
17
|
+
}).createRoute(path);
|
|
18
|
+
}
|
|
19
|
+
return new FileRoute(path, {
|
|
20
|
+
silent: true
|
|
21
|
+
}).createRoute;
|
|
22
|
+
}
|
|
23
|
+
class FileRoute {
|
|
24
|
+
constructor(path, _opts) {
|
|
25
|
+
this.path = path;
|
|
26
|
+
this.createRoute = (options) => {
|
|
27
|
+
if (process.env.NODE_ENV !== "production") {
|
|
28
|
+
warning(
|
|
29
|
+
this.silent,
|
|
30
|
+
"FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const route$1 = route.createRoute(options);
|
|
34
|
+
route$1.isRoot = false;
|
|
35
|
+
return route$1;
|
|
36
|
+
};
|
|
37
|
+
this.silent = _opts?.silent;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function FileRouteLoader(_path) {
|
|
41
|
+
if (process.env.NODE_ENV !== "production") {
|
|
42
|
+
warning(
|
|
43
|
+
false,
|
|
44
|
+
`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`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return (loaderFn) => loaderFn;
|
|
48
|
+
}
|
|
49
|
+
class LazyRoute {
|
|
50
|
+
constructor(opts) {
|
|
51
|
+
this.useMatch = (opts2) => {
|
|
52
|
+
return useMatch.useMatch({
|
|
53
|
+
select: opts2?.select,
|
|
54
|
+
from: this.options.id,
|
|
55
|
+
structuralSharing: opts2?.structuralSharing
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
this.useRouteContext = (opts2) => {
|
|
59
|
+
return useRouteContext.useRouteContext({ ...opts2, from: this.options.id });
|
|
60
|
+
};
|
|
61
|
+
this.useSearch = (opts2) => {
|
|
62
|
+
return useSearch.useSearch({
|
|
63
|
+
select: opts2?.select,
|
|
64
|
+
structuralSharing: opts2?.structuralSharing,
|
|
65
|
+
from: this.options.id
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
this.useParams = (opts2) => {
|
|
69
|
+
return useParams.useParams({
|
|
70
|
+
select: opts2?.select,
|
|
71
|
+
structuralSharing: opts2?.structuralSharing,
|
|
72
|
+
from: this.options.id
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
this.useLoaderDeps = (opts2) => {
|
|
76
|
+
return useLoaderDeps.useLoaderDeps({ ...opts2, from: this.options.id });
|
|
77
|
+
};
|
|
78
|
+
this.useLoaderData = (opts2) => {
|
|
79
|
+
return useLoaderData.useLoaderData({ ...opts2, from: this.options.id });
|
|
80
|
+
};
|
|
81
|
+
this.useNavigate = () => {
|
|
82
|
+
const router = useRouter.useRouter();
|
|
83
|
+
return useNavigate.useNavigate({ from: router.routesById[this.options.id].fullPath });
|
|
84
|
+
};
|
|
85
|
+
this.options = opts;
|
|
86
|
+
this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function createLazyRoute(id) {
|
|
90
|
+
return (opts) => {
|
|
91
|
+
return new LazyRoute({
|
|
92
|
+
id,
|
|
93
|
+
...opts
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function createLazyFileRoute(id) {
|
|
98
|
+
if (typeof id === "object") {
|
|
99
|
+
return new LazyRoute(id);
|
|
100
|
+
}
|
|
101
|
+
return (opts) => new LazyRoute({ id, ...opts });
|
|
102
|
+
}
|
|
103
|
+
exports.FileRoute = FileRoute;
|
|
104
|
+
exports.FileRouteLoader = FileRouteLoader;
|
|
105
|
+
exports.LazyRoute = LazyRoute;
|
|
106
|
+
exports.createFileRoute = createFileRoute;
|
|
107
|
+
exports.createLazyFileRoute = createLazyFileRoute;
|
|
108
|
+
exports.createLazyRoute = createLazyRoute;
|
|
109
|
+
//# 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 { useRouteContext } from './useRouteContext'\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 Register,\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\n/**\n * Creates a file-based Route factory for a given path.\n *\n * Used by TanStack Router's file-based routing to associate a file with a\n * route. The returned function accepts standard route options. In normal usage\n * the `path` string is inserted and maintained by the `tsr` generator.\n *\n * @param path File path literal for the route (usually auto-generated).\n * @returns A function that accepts Route options and returns a Route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\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 RouteConstraints['TFullPath'] =\n 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 RouteConstraints['TFullPath'] =\n 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 TRegister = Register,\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 TSSR = unknown,\n const TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\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 TRegister,\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 TSSR,\n TMiddlewares,\n THandlers\n > => {\n if (process.env.NODE_ENV !== 'production') {\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 }\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 main route file via `createFileRoute`.\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 Register,\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 if (process.env.NODE_ENV !== 'production') {\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 }\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 useRouteContext({ ...(opts as any), from: this.options.id })\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\n/**\n * Creates a lazily-configurable code-based route stub by ID.\n *\n * Use this for code-splitting with code-based routes. The returned function\n * accepts only non-critical route options like `component`, `pendingComponent`,\n * `errorComponent`, and `notFoundComponent` which are applied when the route\n * is matched.\n *\n * @param id Route ID string literal to associate with the lazy route.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\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\n/**\n * Creates a lazily-configurable file-based route stub by file path.\n *\n * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).\n * The returned function accepts only non-critical route options like\n * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.\n *\n * @param id File path literal for the route file.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\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","useRouteContext","useSearch","useParams","useLoaderDeps","useLoaderData","useRouter","useNavigate"],"mappings":";;;;;;;;;;;;AAiDO,SAAS,gBAQd,MAC0E;AAC1E,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EACrB;AACA,SAAO,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EAAA,CACT,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAaZ,YAgDG;AACH,UAAI,QAAQ,IAAI,aAAa,cAAc;AACzC;AAAA,UACE,KAAK;AAAA,UACL;AAAA,QAAA;AAAA,MAEJ;AACA,YAAMA,UAAQC,MAAAA,YAAY,OAAc;AACtCD,cAAc,SAAS;AACzB,aAAOA;AAAAA,IACT;AA1EE,SAAK,SAAS,OAAO;AAAA,EACvB;AA0EF;AAMO,SAAS,gBAId,OAea;AACb,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC;AAAA,MACE;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO,CAAC,aAAa;AACvB;AAcO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAwC,CAACE,UAAS;AAChD,aAAOC,kBAAS;AAAA,QACd,QAAQD,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,mBAAmBA,OAAM;AAAA,MAAA,CACnB;AAAA,IACV;AAEA,SAAA,kBAAsD,CAACA,UAAS;AAC9D,aAAOE,gBAAAA,gBAAgB,EAAE,GAAIF,OAAc,MAAM,KAAK,QAAQ,IAAI;AAAA,IACpE;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAOG,oBAAU;AAAA,QACf,QAAQH,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAOI,oBAAU;AAAA,QACf,QAAQJ,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAOK,cAAAA,cAAc,EAAE,GAAGL,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAOM,cAAAA,cAAc,EAAE,GAAGN,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAASO,UAAAA,UAAA;AACf,aAAOC,YAAAA,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AA7CE,SAAK,UAAU;AACb,SAAa,WAAW,uBAAO,IAAI,YAAY;AAAA,EACnD;AA4CF;AAcO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AAaO,SAAS,oBAGd,IAA8D;AAC9D,MAAI,OAAO,OAAO,UAAU;AAC1B,WAAO,IAAI,UAAkB,EAAE;AAAA,EACjC;AAEA,SAAO,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;;;;;;;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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, Register, 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
|
+
/**
|
|
9
|
+
* Creates a file-based Route factory for a given path.
|
|
10
|
+
*
|
|
11
|
+
* Used by TanStack Router's file-based routing to associate a file with a
|
|
12
|
+
* route. The returned function accepts standard route options. In normal usage
|
|
13
|
+
* the `path` string is inserted and maintained by the `tsr` generator.
|
|
14
|
+
*
|
|
15
|
+
* @param path File path literal for the route (usually auto-generated).
|
|
16
|
+
* @returns A function that accepts Route options and returns a Route instance.
|
|
17
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
|
|
18
|
+
*/
|
|
19
|
+
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'];
|
|
20
|
+
/**
|
|
21
|
+
@deprecated It's no longer recommended to use the `FileRoute` class directly.
|
|
22
|
+
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
|
|
23
|
+
*/
|
|
24
|
+
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']> {
|
|
25
|
+
path?: TFilePath | undefined;
|
|
26
|
+
silent?: boolean;
|
|
27
|
+
constructor(path?: TFilePath | undefined, _opts?: {
|
|
28
|
+
silent: boolean;
|
|
29
|
+
});
|
|
30
|
+
createRoute: <TRegister = Register, TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown, TSSR = unknown, const TMiddlewares = unknown, THandlers = undefined>(options?: FileBaseRouteOptions<TRegister, TParentRoute, TId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn, AnyContext, TSSR, TMiddlewares, THandlers> & UpdatableRouteOptions<TParentRoute, TId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, AnyContext, TRouteContextFn, TBeforeLoadFn>) => Route<TRegister, TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, unknown, TSSR, TMiddlewares, THandlers>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
@deprecated It's recommended not to split loaders into separate files.
|
|
34
|
+
Instead, place the loader function in the main route file via `createFileRoute`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function FileRouteLoader<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(_path: TFilePath): <TLoaderFn>(loaderFn: Constrain<TLoaderFn, RouteLoaderFn<Register, TRoute['parentRoute'], TRoute['types']['id'], TRoute['types']['params'], TRoute['types']['loaderDeps'], TRoute['types']['routerContext'], TRoute['types']['routeContextFn'], TRoute['types']['beforeLoadFn']>>) => TLoaderFn;
|
|
37
|
+
declare module '@tanstack/router-core' {
|
|
38
|
+
interface LazyRoute<in out TRoute extends AnyRoute> {
|
|
39
|
+
useMatch: UseMatchRoute<TRoute['id']>;
|
|
40
|
+
useRouteContext: UseRouteContextRoute<TRoute['id']>;
|
|
41
|
+
useSearch: UseSearchRoute<TRoute['id']>;
|
|
42
|
+
useParams: UseParamsRoute<TRoute['id']>;
|
|
43
|
+
useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>;
|
|
44
|
+
useLoaderData: UseLoaderDataRoute<TRoute['id']>;
|
|
45
|
+
useNavigate: () => UseNavigateResult<TRoute['fullPath']>;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export declare class LazyRoute<TRoute extends AnyRoute> {
|
|
49
|
+
options: {
|
|
50
|
+
id: string;
|
|
51
|
+
} & LazyRouteOptions;
|
|
52
|
+
constructor(opts: {
|
|
53
|
+
id: string;
|
|
54
|
+
} & LazyRouteOptions);
|
|
55
|
+
useMatch: UseMatchRoute<TRoute['id']>;
|
|
56
|
+
useRouteContext: UseRouteContextRoute<TRoute['id']>;
|
|
57
|
+
useSearch: UseSearchRoute<TRoute['id']>;
|
|
58
|
+
useParams: UseParamsRoute<TRoute['id']>;
|
|
59
|
+
useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>;
|
|
60
|
+
useLoaderData: UseLoaderDataRoute<TRoute['id']>;
|
|
61
|
+
useNavigate: () => UseNavigateResult<TRoute["fullPath"]>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates a lazily-configurable code-based route stub by ID.
|
|
65
|
+
*
|
|
66
|
+
* Use this for code-splitting with code-based routes. The returned function
|
|
67
|
+
* accepts only non-critical route options like `component`, `pendingComponent`,
|
|
68
|
+
* `errorComponent`, and `notFoundComponent` which are applied when the route
|
|
69
|
+
* is matched.
|
|
70
|
+
*
|
|
71
|
+
* @param id Route ID string literal to associate with the lazy route.
|
|
72
|
+
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
73
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
|
|
74
|
+
*/
|
|
75
|
+
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>;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a lazily-configurable file-based route stub by file path.
|
|
78
|
+
*
|
|
79
|
+
* Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).
|
|
80
|
+
* The returned function accepts only non-critical route options like
|
|
81
|
+
* `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.
|
|
82
|
+
*
|
|
83
|
+
* @param id File path literal for the route file.
|
|
84
|
+
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
|
|
85
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
|
|
86
|
+
*/
|
|
87
|
+
export declare function createLazyFileRoute<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
|