@tanstack/solid-router 2.0.0-alpha.9 → 2.0.0-beta.10
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/dist/cjs/HeadContent.cjs +2 -2
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.d.cts +5 -1
- package/dist/cjs/HeadContent.dev.cjs +2 -2
- package/dist/cjs/HeadContent.dev.cjs.map +1 -1
- package/dist/cjs/HeadContent.dev.d.cts +2 -1
- package/dist/cjs/Match.cjs +19 -11
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +2 -4
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/ScrollRestoration.cjs +1 -11
- package/dist/cjs/ScrollRestoration.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs +4 -5
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +5 -2
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/headContentUtils.d.cts +2 -2
- package/dist/cjs/not-found.cjs +9 -2
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +4 -1
- package/dist/cjs/renderRouteNotFound.cjs +4 -4
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/router.cjs +0 -8
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/scroll-restoration.cjs +4 -17
- package/dist/cjs/scroll-restoration.cjs.map +1 -1
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useBlocker.d.cts +2 -2
- package/dist/cjs/useMatch.cjs +4 -3
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useRouter.cjs +3 -3
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/esm/HeadContent.d.ts +5 -1
- package/dist/esm/HeadContent.dev.d.ts +2 -1
- package/dist/esm/HeadContent.dev.js +2 -2
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +2 -2
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Match.js +21 -11
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +2 -3
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/ScrollRestoration.js +2 -12
- package/dist/esm/ScrollRestoration.js.map +1 -1
- package/dist/esm/fileRoute.js +4 -3
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.d.ts +2 -2
- package/dist/esm/headContentUtils.js +6 -3
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/not-found.d.ts +4 -1
- package/dist/esm/not-found.js +9 -3
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +3 -2
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/router.js +0 -8
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/scroll-restoration.js +4 -17
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/useBlocker.d.ts +2 -2
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useMatch.js +5 -3
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useRouter.js +3 -2
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/source/HeadContent.d.ts +5 -1
- package/dist/source/HeadContent.dev.d.ts +2 -1
- package/dist/source/HeadContent.dev.jsx +2 -2
- package/dist/source/HeadContent.dev.jsx.map +1 -1
- package/dist/source/HeadContent.jsx +2 -2
- package/dist/source/HeadContent.jsx.map +1 -1
- package/dist/source/Match.jsx +34 -15
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +2 -3
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/ScrollRestoration.jsx +2 -18
- package/dist/source/ScrollRestoration.jsx.map +1 -1
- package/dist/source/fileRoute.js +4 -3
- package/dist/source/fileRoute.js.map +1 -1
- package/dist/source/headContentUtils.d.ts +2 -2
- package/dist/source/headContentUtils.jsx +12 -4
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/not-found.d.ts +4 -1
- package/dist/source/not-found.jsx +17 -4
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/renderRouteNotFound.jsx +4 -3
- package/dist/source/renderRouteNotFound.jsx.map +1 -1
- package/dist/source/router.js +0 -11
- package/dist/source/router.js.map +1 -1
- package/dist/source/scroll-restoration.jsx +4 -24
- package/dist/source/scroll-restoration.jsx.map +1 -1
- package/dist/source/useBlocker.d.ts +2 -2
- package/dist/source/useMatch.jsx +7 -3
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useRouter.jsx +5 -2
- package/dist/source/useRouter.jsx.map +1 -1
- package/package.json +6 -7
- package/src/HeadContent.dev.tsx +3 -2
- package/src/HeadContent.tsx +7 -2
- package/src/Match.tsx +44 -16
- package/src/Matches.tsx +3 -5
- package/src/ScrollRestoration.tsx +2 -22
- package/src/fileRoute.ts +7 -8
- package/src/headContentUtils.tsx +22 -5
- package/src/not-found.tsx +25 -5
- package/src/renderRouteNotFound.tsx +6 -6
- package/src/router.ts +0 -9
- package/src/scroll-restoration.tsx +5 -36
- package/src/useBlocker.tsx +2 -2
- package/src/useMatch.tsx +9 -6
- package/src/useRouter.tsx +7 -5
package/dist/cjs/HeadContent.cjs
CHANGED
|
@@ -11,8 +11,8 @@ let solid_js = require("solid-js");
|
|
|
11
11
|
* to ensure it's part of the reactive tree and updates correctly during client-side navigation.
|
|
12
12
|
* The component uses portals internally to render content into the `<head>` element.
|
|
13
13
|
*/
|
|
14
|
-
function HeadContent() {
|
|
15
|
-
const tags = require_headContentUtils.useTags();
|
|
14
|
+
function HeadContent(props) {
|
|
15
|
+
const tags = require_headContentUtils.useTags(props.assetCrossOrigin);
|
|
16
16
|
const router = require_useRouter.useRouter();
|
|
17
17
|
const content = () => (0, _solidjs_web.createComponent)(solid_js.For, {
|
|
18
18
|
get each() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadContent.cjs","names":["For","Portal","isServer","Asset","useRouter","useTags","HeadContent","tags","router","content","_$createComponent","each","children","tag","t","attrs","mount","document","head"],"sources":["../../src/HeadContent.tsx"],"sourcesContent":["import { For } from 'solid-js'\nimport { Portal, isServer } from '@solidjs/web'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useTags } from './headContentUtils'\n\n/**\n * @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.\n * When using full document hydration (hydrating from `<html>`), this component should be rendered in the `<body>`\n * to ensure it's part of the reactive tree and updates correctly during client-side navigation.\n * The component uses portals internally to render content into the `<head>` element.\n */\nexport function HeadContent() {\n const tags = useTags()\n const router = useRouter()\n\n const content = () => (\n <For each={tags()}>\n {(tag) => {\n const t = tag() as any\n return <Asset tag={t.tag} attrs={t.attrs} children={t.children} />\n }}\n </For>\n )\n\n return (isServer ?? router.isServer) ? (\n content()\n ) : (\n <Portal mount={document.head}>{content()}</Portal>\n )\n}\n"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"HeadContent.cjs","names":["For","Portal","isServer","Asset","useRouter","useTags","AssetCrossOriginConfig","HeadContentProps","assetCrossOrigin","HeadContent","props","tags","router","content","_$createComponent","each","children","tag","t","attrs","mount","document","head"],"sources":["../../src/HeadContent.tsx"],"sourcesContent":["import { For } from 'solid-js'\nimport { Portal, isServer } from '@solidjs/web'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useTags } from './headContentUtils'\nimport type { AssetCrossOriginConfig } from '@tanstack/router-core'\n\nexport interface HeadContentProps {\n assetCrossOrigin?: AssetCrossOriginConfig\n}\n\n/**\n * @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.\n * When using full document hydration (hydrating from `<html>`), this component should be rendered in the `<body>`\n * to ensure it's part of the reactive tree and updates correctly during client-side navigation.\n * The component uses portals internally to render content into the `<head>` element.\n */\nexport function HeadContent(props: HeadContentProps) {\n const tags = useTags(props.assetCrossOrigin)\n const router = useRouter()\n\n const content = () => (\n <For each={tags()}>\n {(tag) => {\n const t = tag() as any\n return <Asset tag={t.tag} attrs={t.attrs} children={t.children} />\n }}\n </For>\n )\n\n return (isServer ?? router.isServer) ? (\n content()\n ) : (\n <Portal mount={document.head}>{content()}</Portal>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,SAAgBS,YAAYC,OAAyB;CACnD,MAAMC,OAAON,yBAAAA,QAAQK,MAAMF,iBAAiB;CAC5C,MAAMI,SAASR,kBAAAA,WAAW;CAE1B,MAAMS,iBAAAA,GAAAA,aAAAA,iBACHb,SAAAA,KAAG;EAAA,IAACe,OAAI;AAAA,UAAEJ,MAAM;;EAAAK,WACbC,QAAQ;GACR,MAAMC,IAAID,KAAK;AACf,WAAA,GAAA,aAAA,iBAAQd,cAAAA,OAAK;IAAA,IAACc,MAAG;AAAA,YAAEC,EAAED;;IAAG,IAAEE,QAAK;AAAA,YAAED,EAAEC;;IAAK,IAAEH,WAAQ;AAAA,YAAEE,EAAEF;;IAAQ,CAAA;;EAC/D,CAEJ;AAED,QAAQd,aAAAA,YAAYU,OAAOV,WACzBW,SAAS,IAAA,GAAA,aAAA,iBAERZ,aAAAA,QAAM;EAAA,IAACmB,QAAK;AAAA,UAAEC,SAASC;;EAAI,IAAAN,WAAA;AAAA,UAAGH,SAAS;;EAAA,CACzC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { AssetCrossOriginConfig } from '@tanstack/router-core';
|
|
2
|
+
export interface HeadContentProps {
|
|
3
|
+
assetCrossOrigin?: AssetCrossOriginConfig;
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.
|
|
3
7
|
* When using full document hydration (hydrating from `<html>`), this component should be rendered in the `<body>`
|
|
4
8
|
* to ensure it's part of the reactive tree and updates correctly during client-side navigation.
|
|
5
9
|
* The component uses portals internally to render content into the `<head>` element.
|
|
6
10
|
*/
|
|
7
|
-
export declare function HeadContent(): import("solid-js").JSX.Element;
|
|
11
|
+
export declare function HeadContent(props: HeadContentProps): import("solid-js").JSX.Element;
|
|
@@ -16,8 +16,8 @@ var DEV_STYLES_ATTR = "data-tanstack-router-dev-styles";
|
|
|
16
16
|
* Development version: filters out dev styles link after hydration and
|
|
17
17
|
* includes a fallback cleanup effect for hydration mismatch cases.
|
|
18
18
|
*/
|
|
19
|
-
function HeadContent() {
|
|
20
|
-
const tags = require_headContentUtils.useTags();
|
|
19
|
+
function HeadContent(props) {
|
|
20
|
+
const tags = require_headContentUtils.useTags(props.assetCrossOrigin);
|
|
21
21
|
const hydrated = require_ClientOnly.useHydrated();
|
|
22
22
|
const router = require_useRouter.useRouter();
|
|
23
23
|
(0, solid_js.createEffect)(() => [hydrated()], ([hydrated]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadContent.dev.cjs","names":["For","createEffect","createMemo","Portal","isServer","Asset","useHydrated","useRouter","useTags","DEV_STYLES_ATTR","HeadContent","tags","hydrated","router","const","document","querySelectorAll","forEach","el","remove","filteredTags","filter","tag","attrs","content","_$createComponent","each","children","t","mount","head"],"sources":["../../src/HeadContent.dev.tsx"],"sourcesContent":["import { For, createEffect, createMemo } from 'solid-js'\nimport { Portal, isServer } from '@solidjs/web'\nimport { Asset } from './Asset'\nimport { useHydrated } from './ClientOnly'\nimport { useRouter } from './useRouter'\nimport { useTags } from './headContentUtils'\n\nconst DEV_STYLES_ATTR = 'data-tanstack-router-dev-styles'\n\n/**\n * @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.\n * When using full document hydration (hydrating from `<html>`), this component should be rendered in the `<body>`\n * to ensure it's part of the reactive tree and updates correctly during client-side navigation.\n * The component uses portals internally to render content into the `<head>` element.\n *\n * Development version: filters out dev styles link after hydration and\n * includes a fallback cleanup effect for hydration mismatch cases.\n */\nexport function HeadContent() {\n const tags = useTags()\n const hydrated = useHydrated()\n const router = useRouter()\n\n // Fallback cleanup for hydration mismatch cases\n // Runs when hydration completes to remove any orphaned dev styles links from DOM\n createEffect(\n () => [hydrated()] as const,\n ([hydrated]) => {\n if (hydrated) {\n document\n .querySelectorAll(`link[${DEV_STYLES_ATTR}]`)\n .forEach((el) => el.remove())\n }\n },\n )\n\n // Filter out dev styles after hydration\n const filteredTags = createMemo(() => {\n if (hydrated()) {\n return tags().filter((tag) => !tag.attrs?.[DEV_STYLES_ATTR])\n }\n return tags()\n })\n\n const content = () => (\n <For each={filteredTags()}>\n {(tag) => {\n const t = tag() as any\n return <Asset tag={t.tag} attrs={t.attrs} children={t.children} />\n }}\n </For>\n )\n\n return (isServer ?? router.isServer) ? (\n content()\n ) : (\n <Portal mount={document.head}>{content()}</Portal>\n )\n}\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"HeadContent.dev.cjs","names":["For","createEffect","createMemo","Portal","isServer","Asset","useHydrated","useRouter","useTags","HeadContentProps","DEV_STYLES_ATTR","HeadContent","props","tags","assetCrossOrigin","hydrated","router","const","document","querySelectorAll","forEach","el","remove","filteredTags","filter","tag","attrs","content","_$createComponent","each","children","t","mount","head"],"sources":["../../src/HeadContent.dev.tsx"],"sourcesContent":["import { For, createEffect, createMemo } from 'solid-js'\nimport { Portal, isServer } from '@solidjs/web'\nimport { Asset } from './Asset'\nimport { useHydrated } from './ClientOnly'\nimport { useRouter } from './useRouter'\nimport { useTags } from './headContentUtils'\nimport type { HeadContentProps } from './HeadContent'\n\nconst DEV_STYLES_ATTR = 'data-tanstack-router-dev-styles'\n\n/**\n * @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.\n * When using full document hydration (hydrating from `<html>`), this component should be rendered in the `<body>`\n * to ensure it's part of the reactive tree and updates correctly during client-side navigation.\n * The component uses portals internally to render content into the `<head>` element.\n *\n * Development version: filters out dev styles link after hydration and\n * includes a fallback cleanup effect for hydration mismatch cases.\n */\nexport function HeadContent(props: HeadContentProps) {\n const tags = useTags(props.assetCrossOrigin)\n const hydrated = useHydrated()\n const router = useRouter()\n\n // Fallback cleanup for hydration mismatch cases\n // Runs when hydration completes to remove any orphaned dev styles links from DOM\n createEffect(\n () => [hydrated()] as const,\n ([hydrated]) => {\n if (hydrated) {\n document\n .querySelectorAll(`link[${DEV_STYLES_ATTR}]`)\n .forEach((el) => el.remove())\n }\n },\n )\n\n // Filter out dev styles after hydration\n const filteredTags = createMemo(() => {\n if (hydrated()) {\n return tags().filter((tag) => !tag.attrs?.[DEV_STYLES_ATTR])\n }\n return tags()\n })\n\n const content = () => (\n <For each={filteredTags()}>\n {(tag) => {\n const t = tag() as any\n return <Asset tag={t.tag} attrs={t.attrs} children={t.children} />\n }}\n </For>\n )\n\n return (isServer ?? router.isServer) ? (\n content()\n ) : (\n <Portal mount={document.head}>{content()}</Portal>\n )\n}\n"],"mappings":";;;;;;;;AAQA,IAAMU,kBAAkB;;;;;;;;;;AAWxB,SAAgBC,YAAYC,OAAyB;CACnD,MAAMC,OAAOL,yBAAAA,QAAQI,MAAME,iBAAiB;CAC5C,MAAMC,WAAWT,mBAAAA,aAAa;CAC9B,MAAMU,SAAST,kBAAAA,WAAW;AAI1BN,EAAAA,GAAAA,SAAAA,oBACQ,CAACc,UAAU,CAAC,GACjB,CAACA,cAAc;AACd,MAAIA,SACFG,UACGC,iBAAiB,QAAQT,gBAAe,GAAI,CAC5CU,SAASC,OAAOA,GAAGC,QAAQ,CAAC;GAGpC;CAGD,MAAMC,gBAAAA,GAAAA,SAAAA,kBAAgC;AACpC,MAAIR,UAAU,CACZ,QAAOF,MAAM,CAACW,QAAQC,QAAQ,CAACA,IAAIC,QAAQhB,iBAAiB;AAE9D,SAAOG,MAAM;GACb;CAEF,MAAMc,iBAAAA,GAAAA,aAAAA,iBACH3B,SAAAA,KAAG;EAAA,IAAC6B,OAAI;AAAA,UAAEN,cAAc;;EAAAO,WACrBL,QAAQ;GACR,MAAMM,IAAIN,KAAK;AACf,WAAA,GAAA,aAAA,iBAAQpB,cAAAA,OAAK;IAAA,IAACoB,MAAG;AAAA,YAAEM,EAAEN;;IAAG,IAAEC,QAAK;AAAA,YAAEK,EAAEL;;IAAK,IAAEI,WAAQ;AAAA,YAAEC,EAAED;;IAAQ,CAAA;;EAC/D,CAEJ;AAED,QAAQ1B,aAAAA,YAAYY,OAAOZ,WACzBuB,SAAS,IAAA,GAAA,aAAA,iBAERxB,aAAAA,QAAM;EAAA,IAAC6B,QAAK;AAAA,UAAEd,SAASe;;EAAI,IAAAH,WAAA;AAAA,UAAGH,SAAS;;EAAA,CACzC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HeadContentProps } from './HeadContent.cjs';
|
|
1
2
|
/**
|
|
2
3
|
* @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.
|
|
3
4
|
* When using full document hydration (hydrating from `<html>`), this component should be rendered in the `<body>`
|
|
@@ -7,4 +8,4 @@
|
|
|
7
8
|
* Development version: filters out dev styles link after hydration and
|
|
8
9
|
* includes a fallback cleanup effect for hydration mismatch cases.
|
|
9
10
|
*/
|
|
10
|
-
export declare function HeadContent(): import("solid-js").JSX.Element;
|
|
11
|
+
export declare function HeadContent(props: HeadContentProps): import("solid-js").JSX.Element;
|
package/dist/cjs/Match.cjs
CHANGED
|
@@ -10,11 +10,7 @@ let _tanstack_router_core = require("@tanstack/router-core");
|
|
|
10
10
|
let _solidjs_web = require("@solidjs/web");
|
|
11
11
|
let solid_js = require("solid-js");
|
|
12
12
|
solid_js = require_runtime.__toESM(solid_js);
|
|
13
|
-
let tiny_warning = require("tiny-warning");
|
|
14
|
-
tiny_warning = require_runtime.__toESM(tiny_warning);
|
|
15
13
|
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
|
|
16
|
-
let tiny_invariant = require("tiny-invariant");
|
|
17
|
-
tiny_invariant = require_runtime.__toESM(tiny_invariant);
|
|
18
14
|
//#region src/Match.tsx
|
|
19
15
|
var NearestMatchContext = require_matchContext.nearestMatchContext;
|
|
20
16
|
var Match = (props) => {
|
|
@@ -88,8 +84,12 @@ var Match = (props) => {
|
|
|
88
84
|
return routeErrorComponent() || require_CatchBoundary.ErrorComponent;
|
|
89
85
|
},
|
|
90
86
|
onCatch: (error) => {
|
|
91
|
-
|
|
92
|
-
(
|
|
87
|
+
const notFoundError = require_not_found.getNotFound(error);
|
|
88
|
+
if (notFoundError) {
|
|
89
|
+
notFoundError.routeId ??= currentMatchState().routeId;
|
|
90
|
+
throw notFoundError;
|
|
91
|
+
}
|
|
92
|
+
if (process.env.NODE_ENV !== "production") console.warn(`Warning: Error in route match: ${currentMatchState().routeId}`);
|
|
93
93
|
routeOnCatch()?.(error);
|
|
94
94
|
},
|
|
95
95
|
get children() {
|
|
@@ -98,10 +98,12 @@ var Match = (props) => {
|
|
|
98
98
|
return ResolvedNotFoundBoundary();
|
|
99
99
|
},
|
|
100
100
|
fallback: (error) => {
|
|
101
|
-
|
|
101
|
+
const notFoundError = require_not_found.getNotFound(error) ?? error;
|
|
102
|
+
notFoundError.routeId ??= currentMatchState().routeId;
|
|
103
|
+
if (!routeNotFoundComponent() || notFoundError.routeId && notFoundError.routeId !== currentMatchState().routeId || !notFoundError.routeId && !route().isRoot) throw notFoundError;
|
|
102
104
|
return (0, _solidjs_web.createComponent)(_solidjs_web.Dynamic, (0, _solidjs_web.mergeProps)({ get component() {
|
|
103
105
|
return routeNotFoundComponent();
|
|
104
|
-
} },
|
|
106
|
+
} }, notFoundError));
|
|
105
107
|
},
|
|
106
108
|
get children() {
|
|
107
109
|
return (0, _solidjs_web.createComponent)(solid_js.Switch, { get children() {
|
|
@@ -140,7 +142,7 @@ var Match = (props) => {
|
|
|
140
142
|
}
|
|
141
143
|
});
|
|
142
144
|
}
|
|
143
|
-
}), (0, _solidjs_web.memo)(() => (0, _solidjs_web.memo)(() => currentMatchState().parentRouteId === _tanstack_router_core.rootRouteId)() ? [(0, _solidjs_web.createComponent)(OnRendered, {}), (0, _solidjs_web.createComponent)(require_scroll_restoration.ScrollRestoration, {})] : null)];
|
|
145
|
+
}), (0, _solidjs_web.memo)(() => (0, _solidjs_web.memo)(() => currentMatchState().parentRouteId === _tanstack_router_core.rootRouteId)() ? [(0, _solidjs_web.createComponent)(OnRendered, {}), (0, _solidjs_web.memo)(() => (0, _solidjs_web.memo)(() => !!(router.options.scrollRestoration && (_tanstack_router_core_isServer.isServer ?? router.isServer)))() ? (0, _solidjs_web.createComponent)(require_scroll_restoration.ScrollRestoration, {}) : null)] : null)];
|
|
144
146
|
}
|
|
145
147
|
});
|
|
146
148
|
}
|
|
@@ -265,7 +267,10 @@ var MatchInner = () => {
|
|
|
265
267
|
},
|
|
266
268
|
children: (_) => {
|
|
267
269
|
const matchError = solid_js.untrack(() => currentMatch().error);
|
|
268
|
-
|
|
270
|
+
if (!(0, _tanstack_router_core.isNotFound)(matchError)) {
|
|
271
|
+
if (process.env.NODE_ENV !== "production") throw new Error("Invariant failed: Expected a notFound error");
|
|
272
|
+
(0, _tanstack_router_core.invariant)();
|
|
273
|
+
}
|
|
269
274
|
return (0, _solidjs_web.createComponent)(solid_js.Show, {
|
|
270
275
|
get when() {
|
|
271
276
|
return currentMatchState().routeId;
|
|
@@ -280,7 +285,10 @@ var MatchInner = () => {
|
|
|
280
285
|
return currentMatch().status === "redirected";
|
|
281
286
|
},
|
|
282
287
|
children: (_) => {
|
|
283
|
-
|
|
288
|
+
if (!(0, _tanstack_router_core.isRedirect)(solid_js.untrack(() => currentMatch().error))) {
|
|
289
|
+
if (process.env.NODE_ENV !== "production") throw new Error("Invariant failed: Expected a redirect error");
|
|
290
|
+
(0, _tanstack_router_core.invariant)();
|
|
291
|
+
}
|
|
284
292
|
return null;
|
|
285
293
|
}
|
|
286
294
|
}),
|
package/dist/cjs/Match.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.cjs","names":["Solid","invariant","warning","createControlledPromise","getLocationChangeInfo","isNotFound","isRedirect","rootRouteId","isServer","Dynamic","CatchBoundary","ErrorComponent","useRouter","CatchNotFound","nearestMatchContext","SafeFragment","renderRouteNotFound","ScrollRestoration","AnyRoute","RootRouteOptions","NearestMatchContext","Component","value","children","Match","props","matchId","router","match","createMemo","id","undefined","stores","activeMatchStoresById","get","state","rawMatchState","currentMatch","routeId","parentRouteId","routesById","parentRoute","ssr","_displayPending","hasPendingMatch","currentRouteId","Boolean","pendingRouteIds","nearestMatch","hasPending","_$createComponent","Show","when","currentMatchState","route","resolvePendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","resolvedNoSsr","ResolvedSuspenseBoundary","Loading","ResolvedCatchBoundary","ResolvedNotFoundBoundary","ShellComponent","shellComponent","fallback","_$memo","getResetKey","loadedAt","error","Error","_$mergeProps","Switch","MatchInner","OnRendered","lastOnRenderedKey","WeakMap","location","resolvedLocation","__TSR_key","locationState","resolvedLocationState","createEffect","const","currentLocationState","currentResolvedLocationState","set","emit","type","useContext","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","key","JSON","stringify","status","_forcePending","componentKey","Comp","defaultComponent","OutComponent","C","Outlet","RenderOut","keyedOut","keyed","_key","_","displayPendingResult","getMatch","_nonReactive","displayPendingPromise","minPendingResult","minPendingPromise","pendingMinMs","untrack","defaultPendingMinMs","routerMatch","setTimeout","resolve","loaderResult","Promise","r","loadPromise","FallbackComponent","matchError","_routeId","RouteErrorComponent","info","componentStack","nearestParentMatch","parentMatch","parentGlobalNotFound","globalNotFound","childMatchId","childMatchIdByRouteId","childRouteId","childRoute","childPendingComponent","childMatchStatus","shouldShowNotFound","resolvedRoute","childMatchIdAccessor","currentMatchId"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from '@solidjs/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nconst NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{\n value: any\n children?: any\n}>\n\nexport const Match = (props: { matchId: string }) => {\n const router = useRouter()\n\n const match = Solid.createMemo(() => {\n const id = props.matchId\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state\n })\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n const parentRouteId = (router.routesById[routeId] as AnyRoute)?.parentRoute\n ?.id\n\n return {\n matchId: currentMatch.id,\n routeId,\n ssr: currentMatch.ssr,\n _displayPending: currentMatch._displayPending,\n parentRouteId: parentRouteId as string | undefined,\n }\n })\n\n const hasPendingMatch = Solid.createMemo(() => {\n const currentRouteId = rawMatchState()?.routeId\n return currentRouteId\n ? Boolean(router.stores.pendingRouteIds.state[currentRouteId])\n : false\n })\n const nearestMatch = {\n matchId: () => rawMatchState()?.matchId,\n routeId: () => rawMatchState()?.routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route = Solid.createMemo(\n () => router.routesById[currentMatchState().routeId] as AnyRoute,\n )\n\n const resolvePendingComponent = Solid.createMemo(\n () =>\n route().options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n const routeErrorComponent = Solid.createMemo(\n () =>\n route().options.errorComponent ??\n router.options.defaultErrorComponent,\n )\n\n const routeOnCatch = Solid.createMemo(\n () => route().options.onCatch ?? router.options.defaultOnCatch,\n )\n\n const routeNotFoundComponent = Solid.createMemo(() =>\n route().isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route().options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route().options.notFoundComponent,\n )\n\n const resolvedNoSsr = Solid.createMemo(\n () =>\n currentMatchState().ssr === false ||\n currentMatchState().ssr === 'data-only',\n )\n\n const ResolvedSuspenseBoundary = Solid.createMemo(() =>\n resolvedNoSsr() ? SafeFragment : Solid.Loading,\n )\n\n const ResolvedCatchBoundary = Solid.createMemo(() =>\n routeErrorComponent() ? CatchBoundary : SafeFragment,\n )\n\n const ResolvedNotFoundBoundary = Solid.createMemo(() =>\n routeNotFoundComponent() ? CatchNotFound : SafeFragment,\n )\n\n const ShellComponent = Solid.createMemo(() =>\n route().isRoot\n ? ((route().options as RootRouteOptions).shellComponent ??\n SafeFragment)\n : SafeFragment,\n )\n\n return (\n <Dynamic component={ShellComponent()}>\n <NearestMatchContext value={nearestMatch}>\n <Dynamic\n component={ResolvedSuspenseBoundary()}\n fallback={\n // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch\n (isServer ?? router.isServer) &&\n resolvedNoSsr() ? undefined : (\n <Dynamic component={resolvePendingComponent()} />\n )\n }\n >\n <Dynamic\n component={ResolvedCatchBoundary()}\n getResetKey={() => router.stores.loadedAt.state}\n errorComponent={routeErrorComponent() || ErrorComponent}\n onCatch={(error: Error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(\n false,\n `Error in route match: ${currentMatchState().routeId}`,\n )\n routeOnCatch()?.(error)\n }}\n >\n <Dynamic\n component={ResolvedNotFoundBoundary()}\n fallback={(error: any) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent() ||\n (error.routeId &&\n error.routeId !== currentMatchState().routeId) ||\n (!error.routeId && !route().isRoot)\n )\n throw error\n\n return (\n <Dynamic\n component={routeNotFoundComponent()}\n {...error}\n />\n )\n }}\n >\n <Solid.Switch>\n <Solid.Match when={resolvedNoSsr()}>\n <Solid.Show\n when={!(isServer ?? router.isServer)}\n fallback={\n <Dynamic component={resolvePendingComponent()} />\n }\n >\n <MatchInner />\n </Solid.Show>\n </Solid.Match>\n <Solid.Match when={!resolvedNoSsr()}>\n <MatchInner />\n </Solid.Match>\n </Solid.Switch>\n </Dynamic>\n </Dynamic>\n </Dynamic>\n </NearestMatchContext>\n\n {currentMatchState().parentRouteId === rootRouteId ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </Dynamic>\n )\n }}\n </Solid.Show>\n )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\n//\n// In Solid, createEffect(source, fn) fires on initial mount as well as on\n// reactive changes. OnRendered can also remount when the first child route\n// changes (e.g. navigating from / to /posts). We deduplicate by tracking\n// the last emitted resolvedLocation key per router so each unique resolved\n// location only triggers one onRendered event regardless of remounts.\nconst lastOnRenderedKey = new WeakMap<object, string>()\n\nfunction OnRendered() {\n const router = useRouter()\n\n const location = Solid.createMemo(\n () => router.stores.resolvedLocation.state?.state.__TSR_key,\n )\n const locationState = Solid.createMemo(() => router.stores.location.state)\n const resolvedLocationState = Solid.createMemo(\n () => router.stores.resolvedLocation.state,\n )\n Solid.createEffect(\n () => [location(), locationState(), resolvedLocationState()] as const,\n ([location, currentLocationState, currentResolvedLocationState]) => {\n if (!location) return\n if (lastOnRenderedKey.get(router) === location) return\n lastOnRenderedKey.set(router, location)\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(\n currentLocationState,\n currentResolvedLocationState,\n ),\n })\n },\n )\n return null\n}\n\nexport const MatchInner = (): any => {\n const router = useRouter()\n const match = Solid.useContext(nearestMatchContext).match\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: currentMatch.loaderDeps,\n params: currentMatch._strictParams,\n search: currentMatch._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: currentMatch.id,\n status: currentMatch.status,\n error: currentMatch.error,\n _forcePending: currentMatch._forcePending ?? false,\n _displayPending: currentMatch._displayPending ?? false,\n },\n }\n })\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route = Solid.createMemo(\n () => router.routesById[currentMatchState().routeId]!,\n )\n\n const currentMatch = Solid.createMemo(() => currentMatchState().match)\n\n const componentKey = Solid.createMemo(\n () => currentMatchState().key ?? currentMatchState().match.id,\n )\n\n const Comp = Solid.createMemo(\n () => route().options.component ?? router.options.defaultComponent,\n )\n\n const OutComponent = Solid.createMemo(() => {\n const C = Comp()\n return C || Outlet\n })\n\n const RenderOut = () => <Dynamic component={OutComponent()} />\n\n const keyedOut = () => (\n <Solid.Show when={componentKey()} keyed>\n {(_key) => <RenderOut />}\n </Solid.Show>\n )\n\n return (\n <Solid.Switch>\n <Solid.Match when={currentMatch()._displayPending}>\n {(_) => {\n const displayPendingResult = Solid.createMemo(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .displayPendingPromise,\n )\n\n return <>{displayPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch()._forcePending}>\n {(_) => {\n const minPendingResult = Solid.createMemo(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .minPendingPromise,\n )\n\n return <>{minPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'pending'}>\n {(_) => {\n const pendingMinMs = Solid.untrack(\n () =>\n route().options.pendingMinMs ??\n router.options.defaultPendingMinMs,\n )\n\n if (pendingMinMs) {\n const routerMatch = Solid.untrack(() =>\n router.getMatch(currentMatch().id),\n )\n if (\n routerMatch &&\n !routerMatch._nonReactive.minPendingPromise\n ) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise =\n minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n }\n\n const loaderResult = Solid.createMemo(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(currentMatch().id)?._nonReactive\n .loadPromise\n })\n\n const FallbackComponent = Solid.untrack(\n () =>\n route().options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n return (\n <>\n {FallbackComponent && pendingMinMs > 0 ? (\n <Dynamic component={FallbackComponent} />\n ) : null}\n {loaderResult()}\n </>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'notFound'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n invariant(isNotFound(matchError), 'Expected a notFound error')\n\n // Use Show with keyed to ensure re-render when routeId changes\n return (\n <Solid.Show when={currentMatchState().routeId} keyed>\n {(_routeId) =>\n Solid.untrack(() =>\n renderRouteNotFound(router, route(), matchError),\n )\n }\n </Solid.Show>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'redirected'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n invariant(isRedirect(matchError), 'Expected a redirect error')\n\n return null\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'error'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route().options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n\n return (\n <RouteErrorComponent\n error={matchError}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw matchError\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'success'}>\n {keyedOut()}\n </Solid.Match>\n </Solid.Switch>\n )\n }}\n </Solid.Show>\n )\n}\n\nexport const Outlet = () => {\n const router = useRouter()\n const nearestParentMatch = Solid.useContext(nearestMatchContext)\n const parentMatch = nearestParentMatch.match\n const routeId = nearestParentMatch.routeId\n const route = Solid.createMemo(() =>\n routeId() ? router.routesById[routeId()!] : undefined,\n )\n\n const parentGlobalNotFound = Solid.createMemo(\n () => parentMatch()?.globalNotFound ?? false,\n )\n\n const childMatchId = Solid.createMemo(() => {\n const currentRouteId = routeId()\n return currentRouteId\n ? router.stores.childMatchIdByRouteId.state[currentRouteId]\n : undefined\n })\n\n const childRouteId = Solid.createMemo(() => {\n const id = childMatchId()\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state.routeId\n })\n\n const childRoute = Solid.createMemo(() => {\n const id = childRouteId()\n return id ? (router.routesById[id] as AnyRoute) : undefined\n })\n\n const childPendingComponent = Solid.createMemo(\n () =>\n childRoute()?.options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n const childMatchStatus = Solid.createMemo(() => {\n const id = childMatchId()\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state.status\n })\n\n // Only show not-found if we're not in a redirected state\n const shouldShowNotFound = () =>\n childMatchStatus() !== 'redirected' && parentGlobalNotFound()\n\n return (\n <Solid.Show\n when={!shouldShowNotFound() && childMatchId()}\n fallback={\n <Solid.Show when={shouldShowNotFound() && route()}>\n {(resolvedRoute) =>\n Solid.untrack(() =>\n renderRouteNotFound(router, resolvedRoute(), undefined),\n )\n }\n </Solid.Show>\n }\n >\n {(childMatchIdAccessor) => {\n const currentMatchId = Solid.createMemo(() => childMatchIdAccessor())\n\n return (\n <Solid.Show\n when={routeId() === rootRouteId}\n fallback={<Match matchId={currentMatchId()} />}\n >\n <Solid.Show when={childRouteId()} keyed>\n {(_routeId) => (\n <Solid.Loading\n fallback={\n childPendingComponent() ? (\n <Dynamic component={childPendingComponent()} />\n ) : null\n }\n >\n <Match matchId={currentMatchId()} />\n </Solid.Loading>\n )}\n </Solid.Show>\n </Solid.Show>\n )\n }}\n </Solid.Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,IAAMoB,sBAAsBN,qBAAAA;AAK5B,IAAaU,SAASC,UAA+B;CACnD,MAAME,SAASf,kBAAAA,WAAW;CAE1B,MAAMgB,QAAQ5B,SAAM6B,iBAAiB;EACnC,MAAMC,KAAKL,MAAMC;AACjB,MAAI,CAACI,GAAI,QAAOC,KAAAA;AAChB,SAAOJ,OAAOK,OAAOC,sBAAsBC,IAAIJ,GAAG,EAAEK;GACpD;CAEF,MAAMC,gBAAgBpC,SAAM6B,iBAAiB;EAC3C,MAAMQ,eAAeT,OAAO;AAC5B,MAAI,CAACS,aACH,QAAO;EAGT,MAAMC,UAAUD,aAAaC;EAC7B,MAAMC,gBAAiBZ,OAAOa,WAAWF,UAAuBG,aAC5DX;AAEJ,SAAO;GACLJ,SAASW,aAAaP;GACtBQ;GACAI,KAAKL,aAAaK;GAClBC,iBAAiBN,aAAaM;GACfJ;GAChB;GACD;CAQF,MAAMS,eAAe;EACnBtB,eAAeU,eAAe,EAAEV;EAChCY,eAAeF,eAAe,EAAEE;EAChCV;EACAqB,YAVsBjD,SAAM6B,iBAAiB;GAC7C,MAAMgB,iBAAiBT,eAAe,EAAEE;AACxC,UAAOO,iBACHC,QAAQnB,OAAOK,OAAOe,gBAAgBZ,MAAMU,gBAAgB,GAC5D;IACJ;EAMD;AAED,SAAA,GAAA,aAAA,iBACG7C,SAAMmD,MAAI;EAAA,IAACC,OAAI;AAAA,UAAEhB,eAAe;;EAAAb,WAC7B8B,sBAAsB;GACtB,MAAMC,QAAQtD,SAAM6B,iBACZF,OAAOa,WAAWa,mBAAmB,CAACf,SAC7C;GAED,MAAMiB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SAAM6B,iBAAiBmI,sBAAsB,CAAC;AAErE,WAAA,GAAA,aAAA,iBACGhK,SAAMmD,MAAI;IAAA,IACTC,OAAI;AAAA,YAAEd,SAAS,KAAK/B,sBAAAA;;IAAW,IAC/BsE,WAAQ;AAAA,aAAA,GAAA,aAAA,iBAAGrD,OAAK,EAAA,IAACE,UAAO;AAAA,aAAEuI,gBAAgB;QAAA,CAAA;;IAAA,IAAA1I,WAAA;AAAA,aAAA,GAAA,aAAA,iBAEzCvB,SAAMmD,MAAI;MAAA,IAACC,OAAI;AAAA,cAAEsG,cAAc;;MAAE/B,OAAK;MAAApG,WACnCyH,cAAAA,GAAAA,aAAAA,iBACChJ,SAAMwE,SAAO;OAAA,IACZK,WAAQ;AAAA,gBAAA,GAAA,aAAA,YACN,CAAA,CAAA+E,uBAAuB,CAAA,EAAA,IAAA,GAAA,aAAA,iBACpBnJ,aAAAA,SAAO,EAAA,IAAC4D,YAAS;AAAA,gBAAEuF,uBAAuB;WAAA,CAAA,GACzC;;OAAI,IAAArI,WAAA;AAAA,gBAAA,GAAA,aAAA,iBAGTC,OAAK,EAAA,IAACE,UAAO;AAAA,gBAAEuI,gBAAgB;WAAA,CAAA;;OAAA,CAAA;MAEnC,CAAA;;IAAA,CAAA;;EAIR,CAAA"}
|
|
1
|
+
{"version":3,"file":"Match.cjs","names":["Solid","createControlledPromise","getLocationChangeInfo","invariant","isNotFound","isRedirect","rootRouteId","isServer","Dynamic","CatchBoundary","ErrorComponent","useRouter","CatchNotFound","getNotFound","nearestMatchContext","SafeFragment","renderRouteNotFound","ScrollRestoration","AnyRoute","RootRouteOptions","NearestMatchContext","Component","value","children","Match","props","matchId","router","match","createMemo","id","undefined","stores","activeMatchStoresById","get","state","rawMatchState","currentMatch","routeId","parentRouteId","routesById","parentRoute","ssr","_displayPending","hasPendingMatch","currentRouteId","Boolean","pendingRouteIds","nearestMatch","hasPending","_$createComponent","Show","when","currentMatchState","route","resolvePendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","resolvedNoSsr","ResolvedSuspenseBoundary","Loading","ResolvedCatchBoundary","ResolvedNotFoundBoundary","ShellComponent","shellComponent","fallback","_$memo","getResetKey","loadedAt","error","Error","notFoundError","process","env","NODE_ENV","console","warn","_$mergeProps","Switch","MatchInner","OnRendered","scrollRestoration","lastOnRenderedKey","WeakMap","location","resolvedLocation","__TSR_key","locationState","resolvedLocationState","createEffect","const","currentLocationState","currentResolvedLocationState","set","emit","type","useContext","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","key","JSON","stringify","status","_forcePending","componentKey","Comp","defaultComponent","OutComponent","C","Outlet","RenderOut","keyedOut","keyed","_key","_","displayPendingResult","getMatch","_nonReactive","displayPendingPromise","minPendingResult","minPendingPromise","pendingMinMs","untrack","defaultPendingMinMs","routerMatch","setTimeout","resolve","loaderResult","Promise","r","loadPromise","FallbackComponent","matchError","_routeId","RouteErrorComponent","info","componentStack","nearestParentMatch","parentMatch","parentGlobalNotFound","globalNotFound","childMatchId","childMatchIdByRouteId","childRouteId","childRoute","childPendingComponent","childMatchStatus","shouldShowNotFound","resolvedRoute","childMatchIdAccessor","currentMatchId"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n invariant,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from '@solidjs/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound, getNotFound } from './not-found'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nconst NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{\n value: any\n children?: any\n}>\n\nexport const Match = (props: { matchId: string }) => {\n const router = useRouter()\n\n const match = Solid.createMemo(() => {\n const id = props.matchId\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state\n })\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n const parentRouteId = (router.routesById[routeId] as AnyRoute)?.parentRoute\n ?.id\n\n return {\n matchId: currentMatch.id,\n routeId,\n ssr: currentMatch.ssr,\n _displayPending: currentMatch._displayPending,\n parentRouteId: parentRouteId as string | undefined,\n }\n })\n\n const hasPendingMatch = Solid.createMemo(() => {\n const currentRouteId = rawMatchState()?.routeId\n return currentRouteId\n ? Boolean(router.stores.pendingRouteIds.state[currentRouteId])\n : false\n })\n const nearestMatch = {\n matchId: () => rawMatchState()?.matchId,\n routeId: () => rawMatchState()?.routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route = Solid.createMemo(\n () => router.routesById[currentMatchState().routeId] as AnyRoute,\n )\n\n const resolvePendingComponent = Solid.createMemo(\n () =>\n route().options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n const routeErrorComponent = Solid.createMemo(\n () =>\n route().options.errorComponent ??\n router.options.defaultErrorComponent,\n )\n\n const routeOnCatch = Solid.createMemo(\n () => route().options.onCatch ?? router.options.defaultOnCatch,\n )\n\n const routeNotFoundComponent = Solid.createMemo(() =>\n route().isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route().options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route().options.notFoundComponent,\n )\n\n const resolvedNoSsr = Solid.createMemo(\n () =>\n currentMatchState().ssr === false ||\n currentMatchState().ssr === 'data-only',\n )\n\n const ResolvedSuspenseBoundary = Solid.createMemo(() =>\n resolvedNoSsr() ? SafeFragment : Solid.Loading,\n )\n\n const ResolvedCatchBoundary = Solid.createMemo(() =>\n routeErrorComponent() ? CatchBoundary : SafeFragment,\n )\n\n const ResolvedNotFoundBoundary = Solid.createMemo(() =>\n routeNotFoundComponent() ? CatchNotFound : SafeFragment,\n )\n\n const ShellComponent = Solid.createMemo(() =>\n route().isRoot\n ? ((route().options as RootRouteOptions).shellComponent ??\n SafeFragment)\n : SafeFragment,\n )\n\n return (\n <Dynamic component={ShellComponent()}>\n <NearestMatchContext value={nearestMatch}>\n <Dynamic\n component={ResolvedSuspenseBoundary()}\n fallback={\n // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch\n (isServer ?? router.isServer) &&\n resolvedNoSsr() ? undefined : (\n <Dynamic component={resolvePendingComponent()} />\n )\n }\n >\n <Dynamic\n component={ResolvedCatchBoundary()}\n getResetKey={() => router.stores.loadedAt.state}\n errorComponent={routeErrorComponent() || ErrorComponent}\n onCatch={(error: Error) => {\n // Forward not found errors (we don't want to show the error component for these)\n const notFoundError = getNotFound(error)\n if (notFoundError) {\n notFoundError.routeId ??= currentMatchState()\n .routeId as any\n throw notFoundError\n }\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Warning: Error in route match: ${currentMatchState().routeId}`,\n )\n }\n routeOnCatch()?.(error)\n }}\n >\n <Dynamic\n component={ResolvedNotFoundBoundary()}\n fallback={(error: any) => {\n const notFoundError = getNotFound(error) ?? error\n\n notFoundError.routeId ??= currentMatchState()\n .routeId as any\n\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent() ||\n (notFoundError.routeId &&\n notFoundError.routeId !==\n currentMatchState().routeId) ||\n (!notFoundError.routeId && !route().isRoot)\n )\n throw notFoundError\n\n return (\n <Dynamic\n component={routeNotFoundComponent()}\n {...notFoundError}\n />\n )\n }}\n >\n <Solid.Switch>\n <Solid.Match when={resolvedNoSsr()}>\n <Solid.Show\n when={!(isServer ?? router.isServer)}\n fallback={\n <Dynamic component={resolvePendingComponent()} />\n }\n >\n <MatchInner />\n </Solid.Show>\n </Solid.Match>\n <Solid.Match when={!resolvedNoSsr()}>\n <MatchInner />\n </Solid.Match>\n </Solid.Switch>\n </Dynamic>\n </Dynamic>\n </Dynamic>\n </NearestMatchContext>\n\n {currentMatchState().parentRouteId === rootRouteId ? (\n <>\n <OnRendered />\n {router.options.scrollRestoration &&\n (isServer ?? router.isServer) ? (\n <ScrollRestoration />\n ) : null}\n </>\n ) : null}\n </Dynamic>\n )\n }}\n </Solid.Show>\n )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\n//\n// In Solid, createEffect(source, fn) fires on initial mount as well as on\n// reactive changes. OnRendered can also remount when the first child route\n// changes (e.g. navigating from / to /posts). We deduplicate by tracking\n// the last emitted resolvedLocation key per router so each unique resolved\n// location only triggers one onRendered event regardless of remounts.\nconst lastOnRenderedKey = new WeakMap<object, string>()\n\nfunction OnRendered() {\n const router = useRouter()\n\n const location = Solid.createMemo(\n () => router.stores.resolvedLocation.state?.state.__TSR_key,\n )\n const locationState = Solid.createMemo(() => router.stores.location.state)\n const resolvedLocationState = Solid.createMemo(\n () => router.stores.resolvedLocation.state,\n )\n Solid.createEffect(\n () => [location(), locationState(), resolvedLocationState()] as const,\n ([location, currentLocationState, currentResolvedLocationState]) => {\n if (!location) return\n if (lastOnRenderedKey.get(router) === location) return\n lastOnRenderedKey.set(router, location)\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(\n currentLocationState,\n currentResolvedLocationState,\n ),\n })\n },\n )\n return null\n}\n\nexport const MatchInner = (): any => {\n const router = useRouter()\n const match = Solid.useContext(nearestMatchContext).match\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: currentMatch.loaderDeps,\n params: currentMatch._strictParams,\n search: currentMatch._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: currentMatch.id,\n status: currentMatch.status,\n error: currentMatch.error,\n _forcePending: currentMatch._forcePending ?? false,\n _displayPending: currentMatch._displayPending ?? false,\n },\n }\n })\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route = Solid.createMemo(\n () => router.routesById[currentMatchState().routeId]!,\n )\n\n const currentMatch = Solid.createMemo(() => currentMatchState().match)\n\n const componentKey = Solid.createMemo(\n () => currentMatchState().key ?? currentMatchState().match.id,\n )\n\n const Comp = Solid.createMemo(\n () => route().options.component ?? router.options.defaultComponent,\n )\n\n const OutComponent = Solid.createMemo(() => {\n const C = Comp()\n return C || Outlet\n })\n\n const RenderOut = () => <Dynamic component={OutComponent()} />\n\n const keyedOut = () => (\n <Solid.Show when={componentKey()} keyed>\n {(_key) => <RenderOut />}\n </Solid.Show>\n )\n\n return (\n <Solid.Switch>\n <Solid.Match when={currentMatch()._displayPending}>\n {(_) => {\n const displayPendingResult = Solid.createMemo(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .displayPendingPromise,\n )\n\n return <>{displayPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch()._forcePending}>\n {(_) => {\n const minPendingResult = Solid.createMemo(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .minPendingPromise,\n )\n\n return <>{minPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'pending'}>\n {(_) => {\n const pendingMinMs = Solid.untrack(\n () =>\n route().options.pendingMinMs ??\n router.options.defaultPendingMinMs,\n )\n\n if (pendingMinMs) {\n const routerMatch = Solid.untrack(() =>\n router.getMatch(currentMatch().id),\n )\n if (\n routerMatch &&\n !routerMatch._nonReactive.minPendingPromise\n ) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise =\n minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n }\n\n const loaderResult = Solid.createMemo(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(currentMatch().id)?._nonReactive\n .loadPromise\n })\n\n const FallbackComponent = Solid.untrack(\n () =>\n route().options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n return (\n <>\n {FallbackComponent && pendingMinMs > 0 ? (\n <Dynamic component={FallbackComponent} />\n ) : null}\n {loaderResult()}\n </>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'notFound'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n if (!isNotFound(matchError)) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Invariant failed: Expected a notFound error',\n )\n }\n invariant()\n }\n\n // Use Show with keyed to ensure re-render when routeId changes\n return (\n <Solid.Show when={currentMatchState().routeId} keyed>\n {(_routeId) =>\n Solid.untrack(() =>\n renderRouteNotFound(router, route(), matchError),\n )\n }\n </Solid.Show>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'redirected'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n if (!isRedirect(matchError)) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Invariant failed: Expected a redirect error',\n )\n }\n invariant()\n }\n\n return null\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'error'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route().options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n\n return (\n <RouteErrorComponent\n error={matchError}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw matchError\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'success'}>\n {keyedOut()}\n </Solid.Match>\n </Solid.Switch>\n )\n }}\n </Solid.Show>\n )\n}\n\nexport const Outlet = () => {\n const router = useRouter()\n const nearestParentMatch = Solid.useContext(nearestMatchContext)\n const parentMatch = nearestParentMatch.match\n const routeId = nearestParentMatch.routeId\n const route = Solid.createMemo(() =>\n routeId() ? router.routesById[routeId()!] : undefined,\n )\n\n const parentGlobalNotFound = Solid.createMemo(\n () => parentMatch()?.globalNotFound ?? false,\n )\n\n const childMatchId = Solid.createMemo(() => {\n const currentRouteId = routeId()\n return currentRouteId\n ? router.stores.childMatchIdByRouteId.state[currentRouteId]\n : undefined\n })\n\n const childRouteId = Solid.createMemo(() => {\n const id = childMatchId()\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state.routeId\n })\n\n const childRoute = Solid.createMemo(() => {\n const id = childRouteId()\n return id ? (router.routesById[id] as AnyRoute) : undefined\n })\n\n const childPendingComponent = Solid.createMemo(\n () =>\n childRoute()?.options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n const childMatchStatus = Solid.createMemo(() => {\n const id = childMatchId()\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state.status\n })\n\n // Only show not-found if we're not in a redirected state\n const shouldShowNotFound = () =>\n childMatchStatus() !== 'redirected' && parentGlobalNotFound()\n\n return (\n <Solid.Show\n when={!shouldShowNotFound() && childMatchId()}\n fallback={\n <Solid.Show when={shouldShowNotFound() && route()}>\n {(resolvedRoute) =>\n Solid.untrack(() =>\n renderRouteNotFound(router, resolvedRoute(), undefined),\n )\n }\n </Solid.Show>\n }\n >\n {(childMatchIdAccessor) => {\n const currentMatchId = Solid.createMemo(() => childMatchIdAccessor())\n\n return (\n <Solid.Show\n when={routeId() === rootRouteId}\n fallback={<Match matchId={currentMatchId()} />}\n >\n <Solid.Show when={childRouteId()} keyed>\n {(_routeId) => (\n <Solid.Loading\n fallback={\n childPendingComponent() ? (\n <Dynamic component={childPendingComponent()} />\n ) : null\n }\n >\n <Match matchId={currentMatchId()} />\n </Solid.Loading>\n )}\n </Solid.Show>\n </Solid.Show>\n )\n }}\n </Solid.Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAMoB,sBAAsBN,qBAAAA;AAK5B,IAAaU,SAASC,UAA+B;CACnD,MAAME,SAAShB,kBAAAA,WAAW;CAE1B,MAAMiB,QAAQ5B,SAAM6B,iBAAiB;EACnC,MAAMC,KAAKL,MAAMC;AACjB,MAAI,CAACI,GAAI,QAAOC,KAAAA;AAChB,SAAOJ,OAAOK,OAAOC,sBAAsBC,IAAIJ,GAAG,EAAEK;GACpD;CAEF,MAAMC,gBAAgBpC,SAAM6B,iBAAiB;EAC3C,MAAMQ,eAAeT,OAAO;AAC5B,MAAI,CAACS,aACH,QAAO;EAGT,MAAMC,UAAUD,aAAaC;EAC7B,MAAMC,gBAAiBZ,OAAOa,WAAWF,UAAuBG,aAC5DX;AAEJ,SAAO;GACLJ,SAASW,aAAaP;GACtBQ;GACAI,KAAKL,aAAaK;GAClBC,iBAAiBN,aAAaM;GACfJ;GAChB;GACD;CAQF,MAAMS,eAAe;EACnBtB,eAAeU,eAAe,EAAEV;EAChCY,eAAeF,eAAe,EAAEE;EAChCV;EACAqB,YAVsBjD,SAAM6B,iBAAiB;GAC7C,MAAMgB,iBAAiBT,eAAe,EAAEE;AACxC,UAAOO,iBACHC,QAAQnB,OAAOK,OAAOe,gBAAgBZ,MAAMU,gBAAgB,GAC5D;IACJ;EAMD;AAED,SAAA,GAAA,aAAA,iBACG7C,SAAMmD,MAAI;EAAA,IAACC,OAAI;AAAA,UAAEhB,eAAe;;EAAAb,WAC7B8B,sBAAsB;GACtB,MA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AAE8I,gBAAgB;WAAA,CAAA;;OAAA,CAAA;MAEnC,CAAA;;IAAA,CAAA;;EAIR,CAAA"}
|
package/dist/cjs/Matches.cjs
CHANGED
|
@@ -9,8 +9,6 @@ let _tanstack_router_core = require("@tanstack/router-core");
|
|
|
9
9
|
let _solidjs_web = require("@solidjs/web");
|
|
10
10
|
let solid_js = require("solid-js");
|
|
11
11
|
solid_js = require_runtime.__toESM(solid_js);
|
|
12
|
-
let tiny_warning = require("tiny-warning");
|
|
13
|
-
tiny_warning = require_runtime.__toESM(tiny_warning);
|
|
14
12
|
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
|
|
15
13
|
//#region src/Matches.tsx
|
|
16
14
|
var NearestMatchContext = require_matchContext.nearestMatchContext;
|
|
@@ -67,8 +65,8 @@ function MatchesInner() {
|
|
|
67
65
|
errorComponent: require_CatchBoundary.ErrorComponent,
|
|
68
66
|
get onCatch() {
|
|
69
67
|
return process.env.NODE_ENV !== "production" ? (error) => {
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
console.warn(`Warning: The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
|
|
69
|
+
console.warn(`Warning: ${error.message || error.toString()}`);
|
|
72
70
|
} : void 0;
|
|
73
71
|
},
|
|
74
72
|
get children() {
|
package/dist/cjs/Matches.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.cjs","names":["Solid","warning","replaceEqualDeep","rootRouteId","isServer","CatchBoundary","ErrorComponent","useRouter","Transitioner","nearestMatchContext","SafeFragment","Match","AnyRoute","AnyRouter","DeepPartial","Expand","MakeOptionalPathParams","MakeOptionalSearchParams","MakeRouteMatchUnion","MaskOptions","MatchRouteOptions","NoInfer","RegisteredRouter","ResolveRelativePath","ResolveRoute","RouteByPath","ToSubOptionsProps","NearestMatchContext","Component","value","children","RouteMatchExtensions","meta","Array","JSX","IntrinsicElements","links","scripts","styles","headScripts","Matches","router","ResolvedSuspense","options","disableGlobalCatchBoundary","document","ssr","Loading","rootRoute","routesById","PendingComponent","pendingComponent","defaultPendingComponent","OptionalWrapper","InnerWrap","_$createComponent","fallback","MatchesInner","matchId","stores","firstMatchId","state","routeId","undefined","match","getMatchStoreByRouteId","hasPendingMatch","Boolean","pendingRouteIds","resetKey","loadedAt","nearestMatch","hasPending","matchContent","Show","when","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","error","message","toString","UseMatchRouteOptions","TFrom","TRouter","TTo","TMaskFrom","TMaskTo","useMatchRoute","opts","Accessor","createMemo","pending","caseSensitive","fuzzy","includeSearch","rest","matchRouteReactivity","matchRoute","MakeMatchRouteOptions","params","Element","MatchRoute","props","renderedChild","matchedParams","child","_$memo","UseMatchesBaseOptions","select","matches","TSelected","UseMatchesResult","useMatches","prev","activeMatchesSnapshot","res","useParentMatches","contextMatchId","useContext","slice","findIndex","d","id","useChildMatches"],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport warning from 'tiny-warning'\nimport { replaceEqualDeep, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Match } from './Match'\nimport type {\n AnyRoute,\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\nconst NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{\n value: any\n children: any\n}>\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Solid.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<Solid.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<Solid.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n // When disableGlobalCatchBoundary is true, we must NOT wrap with Solid.Loading\n // because Solid.Loading transforms STATUS_ERROR into STATUS_PENDING, which\n // prevents errors from propagating to an external Errored boundary.\n const ResolvedSuspense =\n router.options.disableGlobalCatchBoundary ||\n (isServer ?? router.isServer) ||\n (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : Solid.Loading\n\n const rootRoute: () => AnyRoute = () => router.routesById[rootRouteId]\n const PendingComponent =\n rootRoute().options.pendingComponent ??\n router.options.defaultPendingComponent\n\n const OptionalWrapper = router.options.InnerWrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <ResolvedSuspense\n fallback={PendingComponent ? <PendingComponent /> : null}\n >\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n </OptionalWrapper>\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = () => router.stores.firstMatchId.state\n const routeId = () => (matchId() ? rootRouteId : undefined)\n const match = () =>\n routeId()\n ? router.stores.getMatchStoreByRouteId(rootRouteId).state\n : undefined\n const hasPendingMatch = () =>\n routeId()\n ? Boolean(router.stores.pendingRouteIds.state[rootRouteId])\n : false\n const resetKey = () => router.stores.loadedAt.state\n const nearestMatch = {\n matchId,\n routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n const matchContent = () => (\n <Solid.Show when={matchId()}>\n <Match matchId={matchId()!} />\n </Solid.Show>\n )\n\n if (router.options.disableGlobalCatchBoundary) {\n // When disableGlobalCatchBoundary is true, render without any internal\n // error boundary so errors bubble up freely to an external Errored boundary.\n return (\n <NearestMatchContext value={nearestMatch}>\n {matchContent()}\n </NearestMatchContext>\n )\n }\n\n return (\n <NearestMatchContext value={nearestMatch}>\n <CatchBoundary\n getResetKey={() => resetKey()}\n errorComponent={ErrorComponent}\n onCatch={\n process.env.NODE_ENV !== 'production'\n ? (error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }\n : undefined\n }\n >\n {matchContent()}\n </CatchBoundary>\n </NearestMatchContext>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n return <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): Solid.Accessor<\n false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>\n > => {\n return Solid.createMemo(() => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n router.stores.matchRouteReactivity.state\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n }\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => Solid.JSX.Element)\n | Solid.JSX.Element\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n const renderedChild = Solid.createMemo(() => {\n const matchedParams = params()\n const child = props.children\n\n if (typeof child === 'function') {\n return (child as any)(matchedParams)\n }\n\n return matchedParams ? child : null\n })\n\n return <>{renderedChild()}</>\n}\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const router = useRouter<TRouter>()\n return Solid.createMemo((prev: TSelected | undefined) => {\n const matches = router.stores.activeMatchesSnapshot.state as Array<\n MakeRouteMatchUnion<TRouter>\n >\n const res = opts?.select ? opts.select(matches) : matches\n if (prev === undefined) return res\n return replaceEqualDeep(prev, res) as any\n }) as Solid.Accessor<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId()),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId()) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,IAAM2B,sBAAsBlB,qBAAAA;AAe5B,SAAgB+B,UAAU;CACxB,MAAMC,SAASlC,kBAAAA,WAAW;CAK1B,MAAMmC,mBACJD,OAAOE,QAAQC,+BACdxC,+BAAAA,YAAYqC,OAAOrC,aACnB,OAAOyC,aAAa,eAAeJ,OAAOK,MACvCpC,qBAAAA,eACAV,SAAM+C;CAEZ,MAAMC,kBAAkCP,OAAOQ,WAAW9C,sBAAAA;CAC1D,MAAM+C,mBACJF,WAAW,CAACL,QAAQQ,oBACpBV,OAAOE,QAAQS;AAIjB,SAAA,GAAA,aAAA,iBAFwBX,OAAOE,QAAQW,aAAa5C,qBAAAA,cAGlC,EAAA,IAAAoB,WAAA;AAAA,UAAA,GAAA,aAAA,iBACbY,kBAAgB;GAAA,IACfc,WAAQ;AAAA,WAAEN,oBAAAA,GAAAA,aAAAA,iBAAoBA,kBAAgB,EAAA,CAAA,GAAM;;GAAI,IAAApB,WAAA;AAAA,WAAA,EAAA,GAAA,aAAA,iBAEvDtB,qBAAAA,cAAY,EAAA,CAAA,GAAA,GAAA,aAAA,iBACZiD,cAAY,EAAA,CAAA,CAAA;;GAAA,CAAA;IAAA,CAAA;;AAMrB,SAASA,eAAe;CACtB,MAAMhB,SAASlC,kBAAAA,W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;CACtD,MAAM6B,iBAAiBzH,SAAM0H,WAAWjH,qBAAAA,oBAAoB,CAACiD;AAE7D,QAAO0D,WAAW,EAChBJ,SAASC,YAAiD;AACxDA,YAAUA,QAAQU,MAChBV,QAAQW,WAAWC,MAAMA,EAAEC,OAAOL,gBAAgB,CAAC,GAAG,EACvD;AACD,SAAO7B,MAAMoB,SAASpB,KAAKoB,OAAOC,QAAQ,GAAGA;IAEhD,CAAQ"}
|
|
1
|
+
{"version":3,"file":"Matches.cjs","names":["Solid","replaceEqualDeep","rootRouteId","isServer","CatchBoundary","ErrorComponent","useRouter","Transitioner","nearestMatchContext","SafeFragment","Match","AnyRoute","AnyRouter","DeepPartial","Expand","MakeOptionalPathParams","MakeOptionalSearchParams","MakeRouteMatchUnion","MaskOptions","MatchRouteOptions","NoInfer","RegisteredRouter","ResolveRelativePath","ResolveRoute","RouteByPath","ToSubOptionsProps","NearestMatchContext","Component","value","children","RouteMatchExtensions","meta","Array","JSX","IntrinsicElements","links","scripts","styles","headScripts","Matches","router","ResolvedSuspense","options","disableGlobalCatchBoundary","document","ssr","Loading","rootRoute","routesById","PendingComponent","pendingComponent","defaultPendingComponent","OptionalWrapper","InnerWrap","_$createComponent","fallback","MatchesInner","matchId","stores","firstMatchId","state","routeId","undefined","match","getMatchStoreByRouteId","hasPendingMatch","Boolean","pendingRouteIds","resetKey","loadedAt","nearestMatch","hasPending","matchContent","Show","when","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","error","console","warn","message","toString","UseMatchRouteOptions","TFrom","TRouter","TTo","TMaskFrom","TMaskTo","useMatchRoute","opts","Accessor","createMemo","pending","caseSensitive","fuzzy","includeSearch","rest","matchRouteReactivity","matchRoute","MakeMatchRouteOptions","params","Element","MatchRoute","props","renderedChild","matchedParams","child","_$memo","UseMatchesBaseOptions","select","matches","TSelected","UseMatchesResult","useMatches","prev","activeMatchesSnapshot","res","useParentMatches","contextMatchId","useContext","slice","findIndex","d","id","useChildMatches"],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { replaceEqualDeep, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Match } from './Match'\nimport type {\n AnyRoute,\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\nconst NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{\n value: any\n children: any\n}>\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Solid.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<Solid.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<Solid.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n // When disableGlobalCatchBoundary is true, we must NOT wrap with Solid.Loading\n // because Solid.Loading transforms STATUS_ERROR into STATUS_PENDING, which\n // prevents errors from propagating to an external Errored boundary.\n const ResolvedSuspense =\n router.options.disableGlobalCatchBoundary ||\n (isServer ?? router.isServer) ||\n (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : Solid.Loading\n\n const rootRoute: () => AnyRoute = () => router.routesById[rootRouteId]\n const PendingComponent =\n rootRoute().options.pendingComponent ??\n router.options.defaultPendingComponent\n\n const OptionalWrapper = router.options.InnerWrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <ResolvedSuspense\n fallback={PendingComponent ? <PendingComponent /> : null}\n >\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n </OptionalWrapper>\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = () => router.stores.firstMatchId.state\n const routeId = () => (matchId() ? rootRouteId : undefined)\n const match = () =>\n routeId()\n ? router.stores.getMatchStoreByRouteId(rootRouteId).state\n : undefined\n const hasPendingMatch = () =>\n routeId()\n ? Boolean(router.stores.pendingRouteIds.state[rootRouteId])\n : false\n const resetKey = () => router.stores.loadedAt.state\n const nearestMatch = {\n matchId,\n routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n const matchContent = () => (\n <Solid.Show when={matchId()}>\n <Match matchId={matchId()!} />\n </Solid.Show>\n )\n\n if (router.options.disableGlobalCatchBoundary) {\n // When disableGlobalCatchBoundary is true, render without any internal\n // error boundary so errors bubble up freely to an external Errored boundary.\n return (\n <NearestMatchContext value={nearestMatch}>\n {matchContent()}\n </NearestMatchContext>\n )\n }\n\n return (\n <NearestMatchContext value={nearestMatch}>\n <CatchBoundary\n getResetKey={() => resetKey()}\n errorComponent={ErrorComponent}\n onCatch={\n process.env.NODE_ENV !== 'production'\n ? (error) => {\n console.warn(\n `Warning: The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n console.warn(`Warning: ${error.message || error.toString()}`)\n }\n : undefined\n }\n >\n {matchContent()}\n </CatchBoundary>\n </NearestMatchContext>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n return <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): Solid.Accessor<\n false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>\n > => {\n return Solid.createMemo(() => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n router.stores.matchRouteReactivity.state\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n }\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => Solid.JSX.Element)\n | Solid.JSX.Element\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n const renderedChild = Solid.createMemo(() => {\n const matchedParams = params()\n const child = props.children\n\n if (typeof child === 'function') {\n return (child as any)(matchedParams)\n }\n\n return matchedParams ? child : null\n })\n\n return <>{renderedChild()}</>\n}\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const router = useRouter<TRouter>()\n return Solid.createMemo((prev: TSelected | undefined) => {\n const matches = router.stores.activeMatchesSnapshot.state as Array<\n MakeRouteMatchUnion<TRouter>\n >\n const res = opts?.select ? opts.select(matches) : matches\n if (prev === undefined) return res\n return replaceEqualDeep(prev, res) as any\n }) as Solid.Accessor<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId()),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId()) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,IAAM0B,sBAAsBlB,qBAAAA;AAe5B,SAAgB+B,UAAU;CACxB,MAAMC,SAASlC,kBAAAA,WAAW;CAK1B,MAAMmC,mBACJD,OAAOE,QAAQC,+BACdxC,+B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AASlC,kBAAAA,WAAoB;AACnC,QAAON,SAAM+F,YAAYuB,SAAgC;EACvD,MAAMJ,UAAU1E,OAAOkB,OAAO6D,sBAAsB3D;EAGpD,MAAM4D,MAAM3B,MAAMoB,SAASpB,KAAKoB,OAAOC,QAAQ,GAAGA;AAClD,MAAII,SAASxD,KAAAA,EAAW,QAAO0D;AAC/B,UAAA,GAAA,sBAAA,kBAAwBF,MAAME,IAAI;GAClC;;AAGJ,SAAgBC,iBAId5B,MACsD;CACtD,MAAM6B,iBAAiB1H,SAAM2H,WAAWnH,qBAAAA,oBAAoB,CAACiD;AAE7D,QAAO4D,WAAW,EAChBJ,SAASC,YAAiD;AACxDA,YAAUA,QAAQU,MAChB,GACAV,QAAQW,WAAWC,MAAMA,EAAEC,OAAOL,gBAAgB,CACpD,CAAC;AACD,SAAO7B,MAAMoB,SAASpB,KAAKoB,OAAOC,QAAQ,GAAGA;IAEhD,CAAQ;;AAGX,SAAgBc,gBAIdnC,MACsD;CACtD,MAAM6B,iBAAiB1H,SAAM2H,WAAWnH,qBAAAA,oBAAoB,CAACiD;AAE7D,QAAO4D,WAAW,EAChBJ,SAASC,YAAiD;AACxDA,YAAUA,QAAQU,MAChBV,QAAQW,WAAWC,MAAMA,EAAEC,OAAOL,gBAAgB,CAAC,GAAG,EACvD;AACD,SAAO7B,MAAMoB,SAASpB,KAAKoB,OAAOC,QAAQ,GAAGA;IAEhD,CAAQ"}
|
|
@@ -15,17 +15,7 @@ function ScrollRestoration(_props) {
|
|
|
15
15
|
}
|
|
16
16
|
function useElementScrollRestoration(options) {
|
|
17
17
|
useScrollRestoration();
|
|
18
|
-
|
|
19
|
-
const getKey = options.getKey || _tanstack_router_core.defaultGetScrollRestorationKey;
|
|
20
|
-
let elementSelector = "";
|
|
21
|
-
if (options.id) elementSelector = `[data-scroll-restoration-id="${options.id}"]`;
|
|
22
|
-
else {
|
|
23
|
-
const element = options.getElement?.();
|
|
24
|
-
if (!element) return;
|
|
25
|
-
elementSelector = element instanceof Window ? "window" : (0, _tanstack_router_core.getCssSelector)(element);
|
|
26
|
-
}
|
|
27
|
-
const restoreKey = getKey(router.latestLocation);
|
|
28
|
-
return (_tanstack_router_core.scrollRestorationCache?.state[restoreKey])?.[elementSelector];
|
|
18
|
+
return (0, _tanstack_router_core.getElementScrollRestorationEntry)(require_useRouter.useRouter(), options);
|
|
29
19
|
}
|
|
30
20
|
//#endregion
|
|
31
21
|
exports.ScrollRestoration = ScrollRestoration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollRestoration.cjs","names":["
|
|
1
|
+
{"version":3,"file":"ScrollRestoration.cjs","names":["getElementScrollRestorationEntry","setupScrollRestoration","useRouter","ParsedLocation","ScrollRestorationEntry","ScrollRestorationOptions","useScrollRestoration","router","ScrollRestoration","_props","process","env","NODE_ENV","console","warn","useElementScrollRestoration","options","id","getElement","Window","Element","getKey","location"],"sources":["../../src/ScrollRestoration.tsx"],"sourcesContent":["import {\n getElementScrollRestorationEntry,\n setupScrollRestoration,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport type {\n ParsedLocation,\n ScrollRestorationEntry,\n ScrollRestorationOptions,\n} from '@tanstack/router-core'\n\nfunction useScrollRestoration() {\n const router = useRouter()\n setupScrollRestoration(router, true)\n}\n\n/**\n * @deprecated use createRouter's `scrollRestoration` option instead\n */\nexport function ScrollRestoration(_props: ScrollRestorationOptions) {\n useScrollRestoration()\n\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n \"The ScrollRestoration component is deprecated. Use createRouter's `scrollRestoration` option instead.\",\n )\n }\n\n return null\n}\n\nexport function useElementScrollRestoration(\n options: (\n | {\n id: string\n getElement?: () => Window | Element | undefined | null\n }\n | {\n id?: string\n getElement: () => Window | Element | undefined | null\n }\n ) & {\n getKey?: (location: ParsedLocation) => string\n },\n): ScrollRestorationEntry | undefined {\n useScrollRestoration()\n\n return getElementScrollRestorationEntry(useRouter(), options)\n}\n"],"mappings":";;;;AAWA,SAASM,uBAAuB;AAE9BL,EAAAA,GAAAA,sBAAAA,wBADeC,kBAAAA,WAAW,EACK,KAAK;;;;;AAMtC,SAAgBM,kBAAkBC,QAAkC;AAClEH,uBAAsB;AAEtB,KAAA,QAAA,IAAA,aAA6B,cAC3BO,SAAQC,KACN,wGACD;AAGH,QAAO;;AAGT,SAAgBC,4BACdC,SAYoC;AACpCV,uBAAsB;AAEtB,SAAA,GAAA,sBAAA,kCAAwCJ,kBAAAA,WAAW,EAAEc,QAAQ"}
|
package/dist/cjs/fileRoute.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_useRouter = require("./useRouter.cjs");
|
|
3
2
|
const require_useMatch = require("./useMatch.cjs");
|
|
4
3
|
const require_useLoaderData = require("./useLoaderData.cjs");
|
|
@@ -8,8 +7,6 @@ const require_useSearch = require("./useSearch.cjs");
|
|
|
8
7
|
const require_useNavigate = require("./useNavigate.cjs");
|
|
9
8
|
const require_useRouteContext = require("./useRouteContext.cjs");
|
|
10
9
|
const require_route = require("./route.cjs");
|
|
11
|
-
let tiny_warning = require("tiny-warning");
|
|
12
|
-
tiny_warning = require_runtime.__toESM(tiny_warning);
|
|
13
10
|
//#region src/fileRoute.ts
|
|
14
11
|
function createFileRoute(path) {
|
|
15
12
|
if (typeof path === "object") return new FileRoute(path, { silent: true }).createRoute(path);
|
|
@@ -23,7 +20,9 @@ var FileRoute = class {
|
|
|
23
20
|
constructor(path, _opts) {
|
|
24
21
|
this.path = path;
|
|
25
22
|
this.createRoute = (options) => {
|
|
26
|
-
if (process.env.NODE_ENV !== "production")
|
|
23
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24
|
+
if (!this.silent) console.warn("Warning: FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.");
|
|
25
|
+
}
|
|
27
26
|
const route = require_route.createRoute(options);
|
|
28
27
|
route.isRoot = false;
|
|
29
28
|
return route;
|
|
@@ -37,7 +36,7 @@ Instead, place the loader function in the the main route file, inside the
|
|
|
37
36
|
`createFileRoute('/path/to/file)(options)` options.
|
|
38
37
|
*/
|
|
39
38
|
function FileRouteLoader(_path) {
|
|
40
|
-
if (process.env.NODE_ENV !== "production")
|
|
39
|
+
if (process.env.NODE_ENV !== "production") console.warn(`Warning: FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`);
|
|
41
40
|
return (loaderFn) => loaderFn;
|
|
42
41
|
}
|
|
43
42
|
var LazyRoute = class {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRoute.cjs","names":[],"sources":["../../src/fileRoute.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"fileRoute.cjs","names":[],"sources":["../../src/fileRoute.ts"],"sourcesContent":["import { 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 RouteLoaderEntry,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends 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 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 if (!this.silent) {\n console.warn(\n 'Warning: FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\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 the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderEntry<\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 console.warn(\n `Warning: 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 }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.options.id }) as any\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\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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AAQ;;2BAGN;AAEzD,UAAO,oBAAA,YAAY,EAAE,MADN,kBAAA,WAAW,CACQ,WAAW,KAAK,QAAQ,IAAI,UAAU,CAAC;;AAtCzE,OAAK,UAAU;;;AA0CnB,SAAgB,gBAId,IAA2D;AAC3D,SAAQ,SAA2B;AACjC,SAAO,IAAI,UAAkB;GACvB;GACJ,GAAG;GACJ,CAAC;;;AAGN,SAAgB,oBAGd,IAA8D;AAC9D,KAAI,OAAO,OAAO,SAChB,QAAO,IAAI,UAAkB,GAAG;AAGlC,SAAQ,SAA2B,IAAI,UAAkB;EAAE;EAAI,GAAG;EAAM,CAAC"}
|
|
@@ -8,7 +8,7 @@ solid_js = require_runtime.__toESM(solid_js);
|
|
|
8
8
|
* Build the list of head/link/meta/script tags to render for active matches.
|
|
9
9
|
* Used internally by `HeadContent`.
|
|
10
10
|
*/
|
|
11
|
-
var useTags = () => {
|
|
11
|
+
var useTags = (assetCrossOrigin) => {
|
|
12
12
|
const router = require_useRouter.useRouter();
|
|
13
13
|
const nonce = router.options.ssr?.nonce;
|
|
14
14
|
const getTagKey = (tag) => JSON.stringify(tag);
|
|
@@ -76,6 +76,7 @@ var useTags = () => {
|
|
|
76
76
|
tag: "link",
|
|
77
77
|
attrs: {
|
|
78
78
|
...asset.attrs,
|
|
79
|
+
crossOrigin: (0, _tanstack_router_core.getAssetCrossOrigin)(assetCrossOrigin, "stylesheet") ?? asset.attrs?.crossOrigin,
|
|
79
80
|
nonce
|
|
80
81
|
}
|
|
81
82
|
}));
|
|
@@ -85,11 +86,13 @@ var useTags = () => {
|
|
|
85
86
|
const matches = activeMatches();
|
|
86
87
|
const preloadLinks = [];
|
|
87
88
|
matches.map((match) => router.looseRoutesById[match.routeId]).forEach((route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
|
|
89
|
+
const preloadLink = (0, _tanstack_router_core.resolveManifestAssetLink)(preload);
|
|
88
90
|
preloadLinks.push({
|
|
89
91
|
tag: "link",
|
|
90
92
|
attrs: {
|
|
91
93
|
rel: "modulepreload",
|
|
92
|
-
href:
|
|
94
|
+
href: preloadLink.href,
|
|
95
|
+
crossOrigin: (0, _tanstack_router_core.getAssetCrossOrigin)(assetCrossOrigin, "modulepreload") ?? preloadLink.crossOrigin,
|
|
93
96
|
nonce
|
|
94
97
|
}
|
|
95
98
|
});
|