@depup/tanstack__react-router 1.167.1-depup.0 → 1.167.3-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/README.md +2 -2
- package/dist/cjs/Asset.cjs +115 -174
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/CatchBoundary.cjs +92 -108
- package/dist/cjs/CatchBoundary.cjs.map +1 -1
- package/dist/cjs/ClientOnly.cjs +47 -13
- package/dist/cjs/ClientOnly.cjs.map +1 -1
- package/dist/cjs/HeadContent.cjs +23 -12
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.dev.cjs +33 -38
- package/dist/cjs/HeadContent.dev.cjs.map +1 -1
- package/dist/cjs/Match.cjs +190 -247
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +131 -118
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/RouterProvider.cjs +43 -27
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/SafeFragment.cjs +9 -5
- package/dist/cjs/SafeFragment.cjs.map +1 -1
- package/dist/cjs/ScriptOnce.cjs +17 -19
- package/dist/cjs/ScriptOnce.cjs.map +1 -1
- package/dist/cjs/Scripts.cjs +56 -54
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/ScrollRestoration.cjs +26 -30
- package/dist/cjs/ScrollRestoration.cjs.map +1 -1
- package/dist/cjs/Transitioner.cjs +109 -116
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/awaited.cjs +28 -43
- package/dist/cjs/awaited.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs +133 -95
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +144 -181
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/index.cjs +249 -178
- package/dist/cjs/index.dev.cjs +249 -178
- package/dist/cjs/lazyRouteComponent.cjs +52 -67
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
- package/dist/cjs/link.cjs +462 -556
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/matchContext.cjs +9 -25
- package/dist/cjs/matchContext.cjs.map +1 -1
- package/dist/cjs/not-found.cjs +25 -32
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/renderRouteNotFound.cjs +25 -19
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/route.cjs +258 -178
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/router.cjs +29 -16
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/routerContext.cjs +8 -22
- package/dist/cjs/routerContext.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.cjs +23 -36
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/ssr/RouterClient.cjs +16 -22
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
- package/dist/cjs/ssr/RouterServer.cjs +10 -6
- package/dist/cjs/ssr/RouterServer.cjs.map +1 -1
- package/dist/cjs/ssr/client.cjs +10 -10
- package/dist/cjs/ssr/defaultRenderHandler.cjs +13 -14
- package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -1
- package/dist/cjs/ssr/defaultStreamHandler.cjs +14 -15
- package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs +51 -71
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs +26 -29
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/ssr/server.cjs +18 -18
- package/dist/cjs/useBlocker.cjs +126 -162
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.cjs +6 -5
- package/dist/cjs/useCanGoBack.cjs.map +1 -1
- package/dist/cjs/useLoaderData.cjs +24 -12
- package/dist/cjs/useLoaderData.cjs.map +1 -1
- package/dist/cjs/useLoaderDeps.cjs +23 -11
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLocation.cjs +17 -7
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +25 -44
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useNavigate.cjs +53 -43
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useParams.cjs +27 -14
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useRouteContext.cjs +9 -8
- package/dist/cjs/useRouteContext.cjs.map +1 -1
- package/dist/cjs/useRouter.cjs +23 -29
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs +40 -35
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs +26 -13
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/utils.cjs +81 -51
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/Asset.js +112 -156
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/CatchBoundary.js +90 -92
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.js +45 -14
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.dev.js +31 -21
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +20 -11
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Match.js +181 -226
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +125 -103
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +41 -28
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/SafeFragment.js +8 -6
- package/dist/esm/SafeFragment.js.map +1 -1
- package/dist/esm/ScriptOnce.js +15 -18
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.js +55 -54
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/ScrollRestoration.js +25 -31
- package/dist/esm/ScrollRestoration.js.map +1 -1
- package/dist/esm/Transitioner.js +106 -98
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.js +26 -27
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.js +127 -96
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.js +141 -163
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +16 -117
- package/dist/esm/index.js +18 -118
- package/dist/esm/lazyRouteComponent.js +50 -50
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +459 -541
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.js +8 -10
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.js +22 -32
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +21 -18
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.js +249 -180
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +28 -17
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.js +7 -6
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.js +21 -35
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +14 -21
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/RouterServer.js +8 -6
- package/dist/esm/ssr/RouterServer.js.map +1 -1
- package/dist/esm/ssr/client.js +1 -4
- package/dist/esm/ssr/defaultRenderHandler.js +12 -13
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
- package/dist/esm/ssr/defaultStreamHandler.js +13 -14
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +48 -70
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +24 -29
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/ssr/server.js +3 -10
- package/dist/esm/useBlocker.js +124 -146
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.js +6 -5
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderData.js +24 -12
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +23 -11
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +17 -7
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +21 -26
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.js +50 -26
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.js +27 -14
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.js +9 -8
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.js +20 -12
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.js +38 -34
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +26 -13
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.js +80 -39
- package/dist/esm/utils.js.map +1 -1
- package/package.json +5 -5
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.dev.cjs.map +0 -1
- package/dist/cjs/ssr/client.cjs.map +0 -1
- package/dist/cjs/ssr/server.cjs.map +0 -1
- package/dist/esm/index.dev.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ssr/client.js.map +0 -1
- package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/ClientOnly.js
CHANGED
|
@@ -1,21 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
+
//#region src/ClientOnly.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Render the children only after the JS has loaded client-side. Use an optional
|
|
6
|
+
* fallback component if the JS is not yet loaded.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* Render a Chart component if JS loads, renders a simple FakeChart
|
|
10
|
+
* component server-side or if there is no JS. The FakeChart can have only the
|
|
11
|
+
* UI without the behavior or be a loading spinner or skeleton.
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* return (
|
|
15
|
+
* <ClientOnly fallback={<FakeChart />}>
|
|
16
|
+
* <Chart />
|
|
17
|
+
* </ClientOnly>
|
|
18
|
+
* )
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
3
21
|
function ClientOnly({ children, fallback = null }) {
|
|
4
|
-
|
|
22
|
+
return useHydrated() ? /* @__PURE__ */ jsx(React.Fragment, { children }) : /* @__PURE__ */ jsx(React.Fragment, { children: fallback });
|
|
5
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Return a boolean indicating if the JS has been hydrated already.
|
|
26
|
+
* When doing Server-Side Rendering, the result will always be false.
|
|
27
|
+
* When doing Client-Side Rendering, the result will always be false on the
|
|
28
|
+
* first render and true from then on. Even if a new component renders it will
|
|
29
|
+
* always start with true.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // Disable a button that needs JS to work.
|
|
34
|
+
* let hydrated = useHydrated()
|
|
35
|
+
* return (
|
|
36
|
+
* <button type="button" disabled={!hydrated} onClick={doSomethingCustom}>
|
|
37
|
+
* Click me
|
|
38
|
+
* </button>
|
|
39
|
+
* )
|
|
40
|
+
* ```
|
|
41
|
+
* @returns True if the JS has been hydrated already, false otherwise.
|
|
42
|
+
*/
|
|
6
43
|
function useHydrated() {
|
|
7
|
-
|
|
8
|
-
subscribe,
|
|
9
|
-
() => true,
|
|
10
|
-
() => false
|
|
11
|
-
);
|
|
44
|
+
return React.useSyncExternalStore(subscribe, () => true, () => false);
|
|
12
45
|
}
|
|
13
46
|
function subscribe() {
|
|
14
|
-
|
|
15
|
-
};
|
|
47
|
+
return () => {};
|
|
16
48
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=ClientOnly.js.map
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ClientOnly, useHydrated };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=ClientOnly.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientOnly.js","sources":["../../src/ClientOnly.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface ClientOnlyProps {\n /**\n * The children to render when the JS is loaded.\n */\n children: React.ReactNode\n /**\n * The fallback component to render if the JS is not yet loaded.\n */\n fallback?: React.ReactNode\n}\n\n/**\n * Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * <Chart />\n * </ClientOnly>\n * )\n * ```\n */\nexport function ClientOnly({ children, fallback = null }: ClientOnlyProps) {\n return useHydrated() ? (\n <React.Fragment>{children}</React.Fragment>\n ) : (\n <React.Fragment>{fallback}</React.Fragment>\n )\n}\n\n/**\n * Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @example\n * ```tsx\n * // Disable a button that needs JS to work.\n * let hydrated = useHydrated()\n * return (\n * <button type=\"button\" disabled={!hydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * )\n * ```\n * @returns True if the JS has been hydrated already, false otherwise.\n */\nexport function useHydrated(): boolean {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n )\n}\n\nfunction subscribe() {\n return () => {}\n}\n"],"
|
|
1
|
+
{"version":3,"file":"ClientOnly.js","names":[],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface ClientOnlyProps {\n /**\n * The children to render when the JS is loaded.\n */\n children: React.ReactNode\n /**\n * The fallback component to render if the JS is not yet loaded.\n */\n fallback?: React.ReactNode\n}\n\n/**\n * Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * <Chart />\n * </ClientOnly>\n * )\n * ```\n */\nexport function ClientOnly({ children, fallback = null }: ClientOnlyProps) {\n return useHydrated() ? (\n <React.Fragment>{children}</React.Fragment>\n ) : (\n <React.Fragment>{fallback}</React.Fragment>\n )\n}\n\n/**\n * Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @example\n * ```tsx\n * // Disable a button that needs JS to work.\n * let hydrated = useHydrated()\n * return (\n * <button type=\"button\" disabled={!hydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * )\n * ```\n * @returns True if the JS has been hydrated already, false otherwise.\n */\nexport function useHydrated(): boolean {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n )\n}\n\nfunction subscribe() {\n return () => {}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,WAAW,EAAE,UAAU,WAAW,QAAyB;AACzE,QAAO,aAAa,GAClB,oBAAC,MAAM,UAAP,EAAiB,UAA0B,CAAA,GAE3C,oBAAC,MAAM,UAAP,EAAA,UAAiB,UAA0B,CAAA;;;;;;;;;;;;;;;;;;;;;AAuB/C,SAAgB,cAAuB;AACrC,QAAO,MAAM,qBACX,iBACM,YACA,MACP;;AAGH,SAAS,YAAY;AACnB,cAAa"}
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { createElement } from "react";
|
|
4
|
-
import { Asset } from "./Asset.js";
|
|
5
|
-
import { useRouter } from "./useRouter.js";
|
|
6
1
|
import { useHydrated } from "./ClientOnly.js";
|
|
2
|
+
import { useRouter } from "./useRouter.js";
|
|
3
|
+
import { Asset } from "./Asset.js";
|
|
7
4
|
import { useTags } from "./headContentUtils.js";
|
|
8
|
-
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { createElement } from "react";
|
|
7
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region src/HeadContent.dev.tsx
|
|
9
|
+
var DEV_STYLES_ATTR = "data-tanstack-router-dev-styles";
|
|
10
|
+
/**
|
|
11
|
+
* Render route-managed head tags (title, meta, links, styles, head scripts).
|
|
12
|
+
* Place inside the document head of your app shell.
|
|
13
|
+
*
|
|
14
|
+
* Development version: filters out dev styles link after hydration and
|
|
15
|
+
* includes a fallback cleanup effect for hydration mismatch cases.
|
|
16
|
+
*
|
|
17
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management
|
|
18
|
+
*/
|
|
9
19
|
function HeadContent() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const tags = useTags();
|
|
21
|
+
const nonce = useRouter().options.ssr?.nonce;
|
|
22
|
+
const hydrated = useHydrated();
|
|
23
|
+
React$1.useEffect(() => {
|
|
24
|
+
if (hydrated) document.querySelectorAll(`link[${DEV_STYLES_ATTR}]`).forEach((el) => el.remove());
|
|
25
|
+
}, [hydrated]);
|
|
26
|
+
return /* @__PURE__ */ jsx(Fragment, { children: (hydrated ? tags.filter((tag) => !tag.attrs?.[DEV_STYLES_ATTR]) : tags).map((tag) => /* @__PURE__ */ createElement(Asset, {
|
|
27
|
+
...tag,
|
|
28
|
+
key: `tsr-meta-${JSON.stringify(tag)}`,
|
|
29
|
+
nonce
|
|
30
|
+
})) });
|
|
21
31
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=HeadContent.dev.js.map
|
|
32
|
+
//#endregion
|
|
33
|
+
export { HeadContent };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=HeadContent.dev.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadContent.dev.js","sources":["../../src/HeadContent.dev.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useHydrated } from './ClientOnly'\nimport { useTags } from './headContentUtils'\n\nconst DEV_STYLES_ATTR = 'data-tanstack-router-dev-styles'\n\n/**\n * Render route-managed head tags (title, meta, links, styles, head scripts).\n * Place inside the document head of your app shell.\n *\n * Development version: filters out dev styles link after hydration and\n * includes a fallback cleanup effect for hydration mismatch cases.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management\n */\nexport function HeadContent() {\n const tags = useTags()\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n const hydrated = useHydrated()\n\n // Fallback cleanup for hydration mismatch cases\n // Runs when hydration completes to remove any orphaned dev styles links from DOM\n React.useEffect(() => {\n if (hydrated) {\n document\n .querySelectorAll(`link[${DEV_STYLES_ATTR}]`)\n .forEach((el) => el.remove())\n }\n }, [hydrated])\n\n // Filter out dev styles after hydration\n const filteredTags = hydrated\n ? tags.filter((tag) => !tag.attrs?.[DEV_STYLES_ATTR])\n : tags\n\n return (\n <>\n {filteredTags.map((tag) => (\n <Asset {...tag} key={`tsr-meta-${JSON.stringify(tag)}`} nonce={nonce} />\n ))}\n </>\n )\n}\n"],"
|
|
1
|
+
{"version":3,"file":"HeadContent.dev.js","names":[],"sources":["../../src/HeadContent.dev.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useHydrated } from './ClientOnly'\nimport { useTags } from './headContentUtils'\n\nconst DEV_STYLES_ATTR = 'data-tanstack-router-dev-styles'\n\n/**\n * Render route-managed head tags (title, meta, links, styles, head scripts).\n * Place inside the document head of your app shell.\n *\n * Development version: filters out dev styles link after hydration and\n * includes a fallback cleanup effect for hydration mismatch cases.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management\n */\nexport function HeadContent() {\n const tags = useTags()\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n const hydrated = useHydrated()\n\n // Fallback cleanup for hydration mismatch cases\n // Runs when hydration completes to remove any orphaned dev styles links from DOM\n React.useEffect(() => {\n if (hydrated) {\n document\n .querySelectorAll(`link[${DEV_STYLES_ATTR}]`)\n .forEach((el) => el.remove())\n }\n }, [hydrated])\n\n // Filter out dev styles after hydration\n const filteredTags = hydrated\n ? tags.filter((tag) => !tag.attrs?.[DEV_STYLES_ATTR])\n : tags\n\n return (\n <>\n {filteredTags.map((tag) => (\n <Asset {...tag} key={`tsr-meta-${JSON.stringify(tag)}`} nonce={nonce} />\n ))}\n </>\n )\n}\n"],"mappings":";;;;;;;;AAMA,IAAM,kBAAkB;;;;;;;;;;AAWxB,SAAgB,cAAc;CAC5B,MAAM,OAAO,SAAS;CAEtB,MAAM,QADS,WAAW,CACL,QAAQ,KAAK;CAClC,MAAM,WAAW,aAAa;AAI9B,SAAM,gBAAgB;AACpB,MAAI,SACF,UACG,iBAAiB,QAAQ,gBAAgB,GAAG,CAC5C,SAAS,OAAO,GAAG,QAAQ,CAAC;IAEhC,CAAC,SAAS,CAAC;AAOd,QACE,oBAAA,UAAA,EAAA,WALmB,WACjB,KAAK,QAAQ,QAAQ,CAAC,IAAI,QAAQ,iBAAiB,GACnD,MAIc,KAAK,QACjB,8BAAC,OAAD;EAAO,GAAI;EAAK,KAAK,YAAY,KAAK,UAAU,IAAI;EAAW;EAAS,CAAA,CACxE,EACD,CAAA"}
|
package/dist/esm/HeadContent.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { createElement } from "react";
|
|
3
|
-
import { Asset } from "./Asset.js";
|
|
4
1
|
import { useRouter } from "./useRouter.js";
|
|
2
|
+
import { Asset } from "./Asset.js";
|
|
5
3
|
import { useTags } from "./headContentUtils.js";
|
|
4
|
+
import { createElement } from "react";
|
|
5
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/HeadContent.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Render route-managed head tags (title, meta, links, styles, head scripts).
|
|
9
|
+
* Place inside the document head of your app shell.
|
|
10
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management
|
|
11
|
+
*/
|
|
6
12
|
function HeadContent() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const tags = useTags();
|
|
14
|
+
const nonce = useRouter().options.ssr?.nonce;
|
|
15
|
+
return /* @__PURE__ */ jsx(Fragment, { children: tags.map((tag) => /* @__PURE__ */ createElement(Asset, {
|
|
16
|
+
...tag,
|
|
17
|
+
key: `tsr-meta-${JSON.stringify(tag)}`,
|
|
18
|
+
nonce
|
|
19
|
+
})) });
|
|
11
20
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=HeadContent.js.map
|
|
21
|
+
//#endregion
|
|
22
|
+
export { HeadContent };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=HeadContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadContent.js","sources":["../../src/HeadContent.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useTags } from './headContentUtils'\n\n/**\n * Render route-managed head tags (title, meta, links, styles, head scripts).\n * Place inside the document head of your app shell.\n * @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management\n */\nexport function HeadContent() {\n const tags = useTags()\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n return (\n <>\n {tags.map((tag) => (\n <Asset {...tag} key={`tsr-meta-${JSON.stringify(tag)}`} nonce={nonce} />\n ))}\n </>\n )\n}\n"],"
|
|
1
|
+
{"version":3,"file":"HeadContent.js","names":[],"sources":["../../src/HeadContent.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useTags } from './headContentUtils'\n\n/**\n * Render route-managed head tags (title, meta, links, styles, head scripts).\n * Place inside the document head of your app shell.\n * @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management\n */\nexport function HeadContent() {\n const tags = useTags()\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n return (\n <>\n {tags.map((tag) => (\n <Asset {...tag} key={`tsr-meta-${JSON.stringify(tag)}`} nonce={nonce} />\n ))}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,cAAc;CAC5B,MAAM,OAAO,SAAS;CAEtB,MAAM,QADS,WAAW,CACL,QAAQ,KAAK;AAClC,QACE,oBAAA,UAAA,EAAA,UACG,KAAK,KAAK,QACT,8BAAC,OAAD;EAAO,GAAI;EAAK,KAAK,YAAY,KAAK,UAAU,IAAI;EAAW;EAAS,CAAA,CACxE,EACD,CAAA"}
|
package/dist/esm/Match.js
CHANGED
|
@@ -1,237 +1,192 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import invariant from "tiny-invariant";
|
|
4
|
-
import warning from "tiny-warning";
|
|
5
|
-
import { isNotFound, rootRouteId, createControlledPromise, isRedirect, getLocationChangeInfo } from "@tanstack/router-core";
|
|
6
|
-
import { isServer } from "@tanstack/router-core/isServer";
|
|
7
1
|
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
8
|
-
import {
|
|
2
|
+
import { ClientOnly } from "./ClientOnly.js";
|
|
9
3
|
import { useRouter } from "./useRouter.js";
|
|
10
|
-
import {
|
|
4
|
+
import { useRouterState } from "./useRouterState.js";
|
|
11
5
|
import { matchContext } from "./matchContext.js";
|
|
6
|
+
import { CatchNotFound } from "./not-found.js";
|
|
12
7
|
import { SafeFragment } from "./SafeFragment.js";
|
|
13
8
|
import { renderRouteNotFound } from "./renderRouteNotFound.js";
|
|
14
9
|
import { ScrollRestoration } from "./scroll-restoration.js";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
children: resolvedNoSsr || matchState._displayPending ? /* @__PURE__ */ jsx(ClientOnly, { fallback: pendingElement, children: /* @__PURE__ */ jsx(MatchInner, { matchId }) }) : /* @__PURE__ */ jsx(MatchInner, { matchId })
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
) }) }),
|
|
79
|
-
matchState.parentRouteId === rootRouteId && router.options.scrollRestoration ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
-
/* @__PURE__ */ jsx(OnRendered, {}),
|
|
81
|
-
/* @__PURE__ */ jsx(ScrollRestoration, {})
|
|
82
|
-
] }) : null
|
|
83
|
-
] });
|
|
10
|
+
import { createControlledPromise, getLocationChangeInfo, isNotFound, isRedirect, rootRouteId } from "@tanstack/router-core";
|
|
11
|
+
import * as React$1 from "react";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import warning from "tiny-warning";
|
|
14
|
+
import invariant from "tiny-invariant";
|
|
15
|
+
import { isServer } from "@tanstack/router-core/isServer";
|
|
16
|
+
//#region src/Match.tsx
|
|
17
|
+
var Match = React$1.memo(function MatchImpl({ matchId }) {
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
const matchState = useRouterState({
|
|
20
|
+
select: (s) => {
|
|
21
|
+
const matchIndex = s.matches.findIndex((d) => d.id === matchId);
|
|
22
|
+
const match = s.matches[matchIndex];
|
|
23
|
+
invariant(match, `Could not find match for matchId "${matchId}". Please file an issue!`);
|
|
24
|
+
return {
|
|
25
|
+
routeId: match.routeId,
|
|
26
|
+
ssr: match.ssr,
|
|
27
|
+
_displayPending: match._displayPending,
|
|
28
|
+
resetKey: s.loadedAt,
|
|
29
|
+
parentRouteId: s.matches[matchIndex - 1]?.routeId
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
structuralSharing: true
|
|
33
|
+
});
|
|
34
|
+
const route = router.routesById[matchState.routeId];
|
|
35
|
+
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
36
|
+
const pendingElement = PendingComponent ? /* @__PURE__ */ jsx(PendingComponent, {}) : null;
|
|
37
|
+
const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
|
|
38
|
+
const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
|
|
39
|
+
const routeNotFoundComponent = route.isRoot ? route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component : route.options.notFoundComponent;
|
|
40
|
+
const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
|
|
41
|
+
const ResolvedSuspenseBoundary = (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? React$1.Suspense : SafeFragment;
|
|
42
|
+
const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
|
|
43
|
+
const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
|
|
44
|
+
return /* @__PURE__ */ jsxs(route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment, { children: [/* @__PURE__ */ jsx(matchContext.Provider, {
|
|
45
|
+
value: matchId,
|
|
46
|
+
children: /* @__PURE__ */ jsx(ResolvedSuspenseBoundary, {
|
|
47
|
+
fallback: pendingElement,
|
|
48
|
+
children: /* @__PURE__ */ jsx(ResolvedCatchBoundary, {
|
|
49
|
+
getResetKey: () => matchState.resetKey,
|
|
50
|
+
errorComponent: routeErrorComponent || ErrorComponent,
|
|
51
|
+
onCatch: (error, errorInfo) => {
|
|
52
|
+
if (isNotFound(error)) throw error;
|
|
53
|
+
warning(false, `Error in route match: ${matchId}`);
|
|
54
|
+
routeOnCatch?.(error, errorInfo);
|
|
55
|
+
},
|
|
56
|
+
children: /* @__PURE__ */ jsx(ResolvedNotFoundBoundary, {
|
|
57
|
+
fallback: (error) => {
|
|
58
|
+
if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot) throw error;
|
|
59
|
+
return React$1.createElement(routeNotFoundComponent, error);
|
|
60
|
+
},
|
|
61
|
+
children: resolvedNoSsr || matchState._displayPending ? /* @__PURE__ */ jsx(ClientOnly, {
|
|
62
|
+
fallback: pendingElement,
|
|
63
|
+
children: /* @__PURE__ */ jsx(MatchInner, { matchId })
|
|
64
|
+
}) : /* @__PURE__ */ jsx(MatchInner, { matchId })
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}), matchState.parentRouteId === rootRouteId && router.options.scrollRestoration ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(OnRendered, {}), /* @__PURE__ */ jsx(ScrollRestoration, {})] }) : null] });
|
|
84
69
|
});
|
|
85
70
|
function OnRendered() {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
prevLocationRef.current = router.latestLocation;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
router.latestLocation.state.__TSR_key
|
|
105
|
-
);
|
|
71
|
+
const router = useRouter();
|
|
72
|
+
const prevLocationRef = React$1.useRef(void 0);
|
|
73
|
+
return /* @__PURE__ */ jsx("script", {
|
|
74
|
+
suppressHydrationWarning: true,
|
|
75
|
+
ref: (el) => {
|
|
76
|
+
if (el && (prevLocationRef.current === void 0 || prevLocationRef.current.href !== router.latestLocation.href)) {
|
|
77
|
+
router.emit({
|
|
78
|
+
type: "onRendered",
|
|
79
|
+
...getLocationChangeInfo(router.state)
|
|
80
|
+
});
|
|
81
|
+
prevLocationRef.current = router.latestLocation;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, router.latestLocation.state.__TSR_key);
|
|
106
85
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return /* @__PURE__ */ jsx(
|
|
180
|
-
RouteErrorComponent,
|
|
181
|
-
{
|
|
182
|
-
error: match.error,
|
|
183
|
-
reset: void 0,
|
|
184
|
-
info: {
|
|
185
|
-
componentStack: ""
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
throw match.error;
|
|
191
|
-
}
|
|
192
|
-
return out;
|
|
86
|
+
var MatchInner = React$1.memo(function MatchInnerImpl({ matchId }) {
|
|
87
|
+
const router = useRouter();
|
|
88
|
+
const { match, key, routeId } = useRouterState({
|
|
89
|
+
select: (s) => {
|
|
90
|
+
const match = s.matches.find((d) => d.id === matchId);
|
|
91
|
+
const routeId = match.routeId;
|
|
92
|
+
const remountDeps = (router.routesById[routeId].options.remountDeps ?? router.options.defaultRemountDeps)?.({
|
|
93
|
+
routeId,
|
|
94
|
+
loaderDeps: match.loaderDeps,
|
|
95
|
+
params: match._strictParams,
|
|
96
|
+
search: match._strictSearch
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
key: remountDeps ? JSON.stringify(remountDeps) : void 0,
|
|
100
|
+
routeId,
|
|
101
|
+
match: {
|
|
102
|
+
id: match.id,
|
|
103
|
+
status: match.status,
|
|
104
|
+
error: match.error,
|
|
105
|
+
_forcePending: match._forcePending,
|
|
106
|
+
_displayPending: match._displayPending
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
structuralSharing: true
|
|
111
|
+
});
|
|
112
|
+
const route = router.routesById[routeId];
|
|
113
|
+
const out = React$1.useMemo(() => {
|
|
114
|
+
const Comp = route.options.component ?? router.options.defaultComponent;
|
|
115
|
+
if (Comp) return /* @__PURE__ */ jsx(Comp, {}, key);
|
|
116
|
+
return /* @__PURE__ */ jsx(Outlet, {});
|
|
117
|
+
}, [
|
|
118
|
+
key,
|
|
119
|
+
route.options.component,
|
|
120
|
+
router.options.defaultComponent
|
|
121
|
+
]);
|
|
122
|
+
if (match._displayPending) throw router.getMatch(match.id)?._nonReactive.displayPendingPromise;
|
|
123
|
+
if (match._forcePending) throw router.getMatch(match.id)?._nonReactive.minPendingPromise;
|
|
124
|
+
if (match.status === "pending") {
|
|
125
|
+
const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
|
|
126
|
+
if (pendingMinMs) {
|
|
127
|
+
const routerMatch = router.getMatch(match.id);
|
|
128
|
+
if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
|
|
129
|
+
if (!(isServer ?? router.isServer)) {
|
|
130
|
+
const minPendingPromise = createControlledPromise();
|
|
131
|
+
routerMatch._nonReactive.minPendingPromise = minPendingPromise;
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
minPendingPromise.resolve();
|
|
134
|
+
routerMatch._nonReactive.minPendingPromise = void 0;
|
|
135
|
+
}, pendingMinMs);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
throw router.getMatch(match.id)?._nonReactive.loadPromise;
|
|
140
|
+
}
|
|
141
|
+
if (match.status === "notFound") {
|
|
142
|
+
invariant(isNotFound(match.error), "Expected a notFound error");
|
|
143
|
+
return renderRouteNotFound(router, route, match.error);
|
|
144
|
+
}
|
|
145
|
+
if (match.status === "redirected") {
|
|
146
|
+
invariant(isRedirect(match.error), "Expected a redirect error");
|
|
147
|
+
throw router.getMatch(match.id)?._nonReactive.loadPromise;
|
|
148
|
+
}
|
|
149
|
+
if (match.status === "error") {
|
|
150
|
+
if (isServer ?? router.isServer) return /* @__PURE__ */ jsx((route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent, {
|
|
151
|
+
error: match.error,
|
|
152
|
+
reset: void 0,
|
|
153
|
+
info: { componentStack: "" }
|
|
154
|
+
});
|
|
155
|
+
throw match.error;
|
|
156
|
+
}
|
|
157
|
+
return out;
|
|
193
158
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (!childMatchId) {
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
const nextMatch = /* @__PURE__ */ jsx(Match, { matchId: childMatchId });
|
|
227
|
-
if (routeId === rootRouteId) {
|
|
228
|
-
return /* @__PURE__ */ jsx(React.Suspense, { fallback: pendingElement, children: nextMatch });
|
|
229
|
-
}
|
|
230
|
-
return nextMatch;
|
|
159
|
+
/**
|
|
160
|
+
* Render the next child match in the route tree. Typically used inside
|
|
161
|
+
* a route component to render nested routes.
|
|
162
|
+
*
|
|
163
|
+
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent
|
|
164
|
+
*/
|
|
165
|
+
var Outlet = React$1.memo(function OutletImpl() {
|
|
166
|
+
const router = useRouter();
|
|
167
|
+
const matchId = React$1.useContext(matchContext);
|
|
168
|
+
const routeId = useRouterState({ select: (s) => s.matches.find((d) => d.id === matchId)?.routeId });
|
|
169
|
+
const route = router.routesById[routeId];
|
|
170
|
+
const parentGlobalNotFound = useRouterState({ select: (s) => {
|
|
171
|
+
const parentMatch = s.matches.find((d) => d.id === matchId);
|
|
172
|
+
invariant(parentMatch, `Could not find parent match for matchId "${matchId}"`);
|
|
173
|
+
return parentMatch.globalNotFound;
|
|
174
|
+
} });
|
|
175
|
+
const childMatchId = useRouterState({ select: (s) => {
|
|
176
|
+
const matches = s.matches;
|
|
177
|
+
return matches[matches.findIndex((d) => d.id === matchId) + 1]?.id;
|
|
178
|
+
} });
|
|
179
|
+
const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ jsx(router.options.defaultPendingComponent, {}) : null;
|
|
180
|
+
if (parentGlobalNotFound) return renderRouteNotFound(router, route, void 0);
|
|
181
|
+
if (!childMatchId) return null;
|
|
182
|
+
const nextMatch = /* @__PURE__ */ jsx(Match, { matchId: childMatchId });
|
|
183
|
+
if (routeId === rootRouteId) return /* @__PURE__ */ jsx(React$1.Suspense, {
|
|
184
|
+
fallback: pendingElement,
|
|
185
|
+
children: nextMatch
|
|
186
|
+
});
|
|
187
|
+
return nextMatch;
|
|
231
188
|
});
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
};
|
|
237
|
-
//# sourceMappingURL=Match.js.map
|
|
189
|
+
//#endregion
|
|
190
|
+
export { Match, Outlet };
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=Match.js.map
|