Separate JSON API backend (vm_api.py) + React+TanStack frontend scaffold

- vm_api.py: pure FastAPI JSON API on :8098 with CORS
- vm-api.service: systemd unit for API (replaces inline HTML vm_web.py for frontend)
- vm_web.py: kept intact as fallback; Apache now proxies /api/ -> :8098
- frontend/: Vite + React + TanStack Query scaffold
- Apache vhost updated: DocumentRoot -> frontend/dist, /api/ proxy, SPA fallback
- All original HTML pages still functional via :8099 during transition
This commit is contained in:
jp
2026-08-13 17:42:33 +01:00
parent 7570de5cb5
commit 0917366cdf
3960 changed files with 1043030 additions and 41 deletions
+150
View File
@@ -0,0 +1,150 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_ClientOnly = require("./ClientOnly.cjs");
const require_useRouter = require("./useRouter.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/Asset.tsx
var INLINE_CSS_HYDRATION_ATTR = "data-tsr-inline-css";
var noopScriptHandler = () => {};
function setScriptAttrs(script, attrs) {
if (!attrs) return;
for (const [key, value] of Object.entries(attrs)) if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
}
function Asset(asset) {
const { attrs, children, nonce, preventScriptHoist } = asset;
switch (asset.tag) {
case "title": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("title", {
...attrs,
suppressHydrationWarning: true,
children
});
case "meta": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
...attrs,
suppressHydrationWarning: true
});
case "link": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("link", {
...attrs,
precedence: attrs?.precedence ?? (attrs?.rel === "stylesheet" ? "default" : void 0),
nonce,
suppressHydrationWarning: true
});
case "style":
if (asset.inlineCss && (process.env.TSS_INLINE_CSS_ENABLED === "true" || process.env.TSS_INLINE_CSS_ENABLED === void 0 && _tanstack_router_core_isServer.isServer)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineCssStyle, {
attrs,
nonce,
children
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", {
...attrs,
dangerouslySetInnerHTML: { __html: children },
nonce
});
case "script": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Script, {
attrs,
preventScriptHoist,
children
});
default: return null;
}
}
function InlineCssStyle({ attrs, children, nonce }) {
const isInlineCssPlaceholder = children === void 0;
const [hydratedInlineCss] = react.useState(() => {
if (!isInlineCssPlaceholder || typeof document === "undefined") return;
return document.querySelector(`style[${INLINE_CSS_HYDRATION_ATTR}]`)?.textContent ?? void 0;
});
const html = isInlineCssPlaceholder ? hydratedInlineCss ?? "" : children ?? "";
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", {
...attrs,
[INLINE_CSS_HYDRATION_ATTR]: "",
dangerouslySetInnerHTML: { __html: html },
nonce,
suppressHydrationWarning: true
});
}
function Script({ attrs, children, preventScriptHoist }) {
const router = require_useRouter.useRouter();
const hydrated = require_ClientOnly.useHydrated();
const dataScript = typeof attrs?.type === "string" && attrs.type !== "" && attrs.type !== "text/javascript" && attrs.type !== "module";
if (process.env.NODE_ENV !== "production" && attrs?.src && typeof children === "string" && children.trim().length) console.warn("[TanStack Router] <Script> received both `src` and `children`. The `children` content will be ignored. Remove `children` or remove `src`.");
react.useEffect(() => {
if (dataScript) return;
if (attrs?.src) {
const normSrc = (() => {
try {
const base = document.baseURI || window.location.href;
return new URL(attrs.src, base).href;
} catch {
return attrs.src;
}
})();
for (const el of document.querySelectorAll("script[src]")) if (el.src === normSrc) return;
const script = document.createElement("script");
setScriptAttrs(script, attrs);
document.head.appendChild(script);
return () => script.remove();
}
if (typeof children === "string") {
const typeAttr = typeof attrs?.type === "string" ? attrs.type : "text/javascript";
const nonceAttr = typeof attrs?.nonce === "string" ? attrs.nonce : void 0;
for (const el of document.querySelectorAll("script:not([src])")) {
if (!(el instanceof HTMLScriptElement)) continue;
const sType = el.getAttribute("type") ?? "text/javascript";
const sNonce = el.getAttribute("nonce") ?? void 0;
if (el.textContent === children && sType === typeAttr && sNonce === nonceAttr) return;
}
const script = document.createElement("script");
script.textContent = children;
setScriptAttrs(script, attrs);
document.head.appendChild(script);
return () => script.remove();
}
}, [
attrs,
children,
dataScript
]);
if (_tanstack_router_core_isServer.isServer ?? router.isServer) {
if (attrs?.src) {
if (!preventScriptHoist) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("script", {
...attrs,
suppressHydrationWarning: true
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("script", {
...attrs,
onLoad: noopScriptHandler,
suppressHydrationWarning: true
});
}
if (typeof children === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("script", {
...attrs,
dangerouslySetInnerHTML: { __html: children },
suppressHydrationWarning: true
});
return null;
}
if (dataScript && typeof children === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("script", {
...attrs,
suppressHydrationWarning: true,
dangerouslySetInnerHTML: { __html: children }
});
if (!hydrated) {
if (attrs?.src) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("script", {
...attrs,
suppressHydrationWarning: true
});
if (typeof children === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("script", {
...attrs,
dangerouslySetInnerHTML: { __html: children },
suppressHydrationWarning: true
});
}
return null;
}
//#endregion
exports.Asset = Asset;
//# sourceMappingURL=Asset.cjs.map
File diff suppressed because one or more lines are too long
+6
View File
@@ -0,0 +1,6 @@
import { RouterManagedTag } from '@tanstack/router-core';
import * as React from 'react';
export declare function Asset(asset: RouterManagedTag & {
nonce?: string;
preventScriptHoist?: boolean;
}): React.ReactElement | null;
@@ -0,0 +1,94 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_nonRouteComponentContext = require("./nonRouteComponentContext.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/CatchBoundary.tsx
function CatchBoundary(props) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CatchBoundaryImpl, { ...props });
}
var CatchBoundaryImpl = class extends react.Component {
constructor(..._args) {
super(..._args);
this.state = { error: null };
this.reset = () => {
this.setState({ error: null });
};
}
static getDerivedStateFromProps(props, state) {
const resetKey = props.getResetKey();
if (state.error && state.resetKey !== resetKey) return {
resetKey,
error: null
};
return { resetKey };
}
static getDerivedStateFromError(error) {
return { error };
}
componentDidCatch(error, errorInfo) {
this.props.onCatch?.(error, errorInfo);
}
render() {
const error = this.state.error;
if (error) {
const element = react.createElement(this.props.errorComponent ?? ErrorComponent, {
error,
reset: this.reset
});
return process.env.NODE_ENV !== "production" ? require_nonRouteComponentContext.wrapInNonRouteComponentContext(element, "errorComponent") : element;
}
return this.props.children;
}
};
function ErrorComponent({ error }) {
const [show, setShow] = react.useState(process.env.NODE_ENV !== "production");
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
style: {
padding: ".5rem",
maxWidth: "100%"
},
children: [
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
style: {
display: "flex",
alignItems: "center",
gap: ".5rem"
},
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
style: { fontSize: "1rem" },
children: "Something went wrong!"
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
style: {
appearance: "none",
fontSize: ".6em",
border: "1px solid currentColor",
padding: ".1rem .2rem",
fontWeight: "bold",
borderRadius: ".25rem"
},
onClick: () => setShow((d) => !d),
children: show ? "Hide Error" : "Show Error"
})]
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { height: ".25rem" } }),
show ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
style: {
fontSize: ".7em",
border: "1px solid red",
borderRadius: ".25rem",
padding: ".3rem",
color: "red",
overflow: "auto"
},
children: error.message ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: error.message }) : null
}) }) : null
]
});
}
//#endregion
exports.CatchBoundary = CatchBoundary;
exports.ErrorComponent = ErrorComponent;
//# sourceMappingURL=CatchBoundary.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"CatchBoundary.cjs","names":[],"sources":["../../src/CatchBoundary.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { wrapInNonRouteComponentContext } from './nonRouteComponentContext'\nimport type { ErrorRouteComponent } from './route'\nimport type { ErrorInfo } from 'react'\n\nexport function CatchBoundary(props: {\n getResetKey: () => unknown\n children: React.ReactNode\n errorComponent?: ErrorRouteComponent\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n}) {\n return <CatchBoundaryImpl {...props} />\n}\n\nclass CatchBoundaryImpl extends React.Component<{\n getResetKey: () => unknown\n children: React.ReactNode\n errorComponent?: ErrorRouteComponent\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n}> {\n state = { error: null } as { error: Error | null; resetKey?: unknown }\n\n static getDerivedStateFromProps(\n props: { getResetKey: () => unknown },\n state: { resetKey?: unknown; error: Error | null },\n ) {\n const resetKey = props.getResetKey()\n\n if (state.error && state.resetKey !== resetKey) {\n return { resetKey, error: null }\n }\n\n return { resetKey }\n }\n static getDerivedStateFromError(error: Error) {\n return { error }\n }\n reset = () => {\n this.setState({ error: null })\n }\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n this.props.onCatch?.(error, errorInfo)\n }\n render() {\n const error = this.state.error\n if (error) {\n const element = React.createElement(\n this.props.errorComponent ?? ErrorComponent,\n {\n error,\n reset: this.reset,\n },\n )\n\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(element, 'errorComponent')\n : element\n }\n\n return this.props.children\n }\n}\n\nexport function ErrorComponent({ error }: { error: any }) {\n const [show, setShow] = React.useState(process.env.NODE_ENV !== 'production')\n\n return (\n <div style={{ padding: '.5rem', maxWidth: '100%' }}>\n <div style={{ display: 'flex', alignItems: 'center', gap: '.5rem' }}>\n <strong style={{ fontSize: '1rem' }}>Something went wrong!</strong>\n <button\n style={{\n appearance: 'none',\n fontSize: '.6em',\n border: '1px solid currentColor',\n padding: '.1rem .2rem',\n fontWeight: 'bold',\n borderRadius: '.25rem',\n }}\n onClick={() => setShow((d) => !d)}\n >\n {show ? 'Hide Error' : 'Show Error'}\n </button>\n </div>\n <div style={{ height: '.25rem' }} />\n {show ? (\n <div>\n <pre\n style={{\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.3rem',\n color: 'red',\n overflow: 'auto',\n }}\n >\n {error.message ? <code>{error.message}</code> : null}\n </pre>\n </div>\n ) : null}\n </div>\n )\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,cAAc,OAK3B;CACD,OAAO,iBAAA,GAAA,kBAAA,KAAC,mBAAD,EAAmB,GAAI,MAAQ,CAAA;AACxC;AAEA,IAAM,oBAAN,cAAgC,MAAM,UAKnC;;;eACO,EAAE,OAAO,KAAK;qBAiBR;GACZ,KAAK,SAAS,EAAE,OAAO,KAAK,CAAC;EAC/B;;CAjBA,OAAO,yBACL,OACA,OACA;EACA,MAAM,WAAW,MAAM,YAAY;EAEnC,IAAI,MAAM,SAAS,MAAM,aAAa,UACpC,OAAO;GAAE;GAAU,OAAO;EAAK;EAGjC,OAAO,EAAE,SAAS;CACpB;CACA,OAAO,yBAAyB,OAAc;EAC5C,OAAO,EAAE,MAAM;CACjB;CAIA,kBAAkB,OAAc,WAAsB;EACpD,KAAK,MAAM,UAAU,OAAO,SAAS;CACvC;CACA,SAAS;EACP,MAAM,QAAQ,KAAK,MAAM;EACzB,IAAI,OAAO;GACT,MAAM,UAAU,MAAM,cACpB,KAAK,MAAM,kBAAkB,gBAC7B;IACE;IACA,OAAO,KAAK;GACd,CACF;GAEA,OAAA,QAAA,IAAA,aAAgC,eAC5B,iCAAA,+BAA+B,SAAS,gBAAgB,IACxD;EACN;EAEA,OAAO,KAAK,MAAM;CACpB;AACF;AAEA,SAAgB,eAAe,EAAE,SAAyB;CACxD,MAAM,CAAC,MAAM,WAAW,MAAM,SAAA,QAAA,IAAA,aAAkC,YAAY;CAE5E,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;EAAK,OAAO;GAAE,SAAS;GAAS,UAAU;EAAO;YAAjD;GACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;IAAK,OAAO;KAAE,SAAS;KAAQ,YAAY;KAAU,KAAK;IAAQ;cAAlE,CACE,iBAAA,GAAA,kBAAA,KAAC,UAAD;KAAQ,OAAO,EAAE,UAAU,OAAO;eAAG;IAA6B,CAAA,GAClE,iBAAA,GAAA,kBAAA,KAAC,UAAD;KACE,OAAO;MACL,YAAY;MACZ,UAAU;MACV,QAAQ;MACR,SAAS;MACT,YAAY;MACZ,cAAc;KAChB;KACA,eAAe,SAAS,MAAM,CAAC,CAAC;eAE/B,OAAO,eAAe;IACjB,CAAA,CACL;;GACL,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAK,OAAO,EAAE,QAAQ,SAAS,EAAI,CAAA;GAClC,OACC,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;IACE,OAAO;KACL,UAAU;KACV,QAAQ;KACR,cAAc;KACd,SAAS;KACT,OAAO;KACP,UAAU;IACZ;cAEC,MAAM,UAAU,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAA,UAAO,MAAM,QAAc,CAAA,IAAI;GAC7C,CAAA,EACF,CAAA,IACH;EACD;;AAET"}
@@ -0,0 +1,12 @@
import { ErrorRouteComponent } from './route.cjs';
import { ErrorInfo } from 'react';
import * as React from 'react';
export declare function CatchBoundary(props: {
getResetKey: () => unknown;
children: React.ReactNode;
errorComponent?: ErrorRouteComponent;
onCatch?: (error: Error, errorInfo: ErrorInfo) => void;
}): import("react/jsx-runtime").JSX.Element;
export declare function ErrorComponent({ error }: {
error: any;
}): import("react/jsx-runtime").JSX.Element;
+56
View File
@@ -0,0 +1,56 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/ClientOnly.tsx
/**
* Render the children only after the JS has loaded client-side. Use an optional
* fallback component if the JS is not yet loaded.
*
* @example
* Render a Chart component if JS loads, renders a simple FakeChart
* component server-side or if there is no JS. The FakeChart can have only the
* UI without the behavior or be a loading spinner or skeleton.
*
* ```tsx
* return (
* <ClientOnly fallback={<FakeChart />}>
* <Chart />
* </ClientOnly>
* )
* ```
*/
function ClientOnly({ children, fallback = null }) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: useHydrated() ? children : fallback });
}
/**
* Return a boolean indicating if the JS has been hydrated already.
* When doing Server-Side Rendering, the result will always be false.
* When doing Client-Side Rendering, the result will always be false on the
* first render and true from then on. Even if a new component renders it will
* always start with true.
*
* @example
* ```tsx
* // Disable a button that needs JS to work.
* let hydrated = useHydrated()
* return (
* <button type="button" disabled={!hydrated} onClick={doSomethingCustom}>
* Click me
* </button>
* )
* ```
* @returns True if the JS has been hydrated already, false otherwise.
*/
function useHydrated() {
return react.default.useSyncExternalStore(subscribe, () => true, () => false);
}
function subscribe() {
return () => {};
}
//#endregion
exports.ClientOnly = ClientOnly;
exports.useHydrated = useHydrated;
//# sourceMappingURL=ClientOnly.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ClientOnly.cjs","names":[],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nexport interface ClientOnlyProps {\n /**\n * The children to render when the JS is loaded.\n */\n children: React.ReactNode\n /**\n * The fallback component to render if the JS is not yet loaded.\n */\n fallback?: React.ReactNode\n}\n\n/**\n * Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * <Chart />\n * </ClientOnly>\n * )\n * ```\n */\nexport function ClientOnly({ children, fallback = null }: ClientOnlyProps) {\n return <React.Fragment>{useHydrated() ? children : fallback}</React.Fragment>\n}\n\n/**\n * Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @example\n * ```tsx\n * // Disable a button that needs JS to work.\n * let hydrated = useHydrated()\n * return (\n * <button type=\"button\" disabled={!hydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * )\n * ```\n * @returns True if the JS has been hydrated already, false otherwise.\n */\nexport function useHydrated(): boolean {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n )\n}\n\nfunction subscribe() {\n return () => {\n // noop\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,WAAW,EAAE,UAAU,WAAW,QAAyB;CACzE,OAAO,iBAAA,GAAA,kBAAA,KAAC,MAAA,QAAM,UAAP,EAAA,UAAiB,YAAY,IAAI,WAAW,SAAyB,CAAA;AAC9E;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,cAAuB;CACrC,OAAO,MAAA,QAAM,qBACX,iBACM,YACA,KACR;AACF;AAEA,SAAS,YAAY;CACnB,aAAa,CAEb;AACF"}
+49
View File
@@ -0,0 +1,49 @@
import { default as React } from 'react';
export interface ClientOnlyProps {
/**
* The children to render when the JS is loaded.
*/
children: React.ReactNode;
/**
* The fallback component to render if the JS is not yet loaded.
*/
fallback?: React.ReactNode;
}
/**
* Render the children only after the JS has loaded client-side. Use an optional
* fallback component if the JS is not yet loaded.
*
* @example
* Render a Chart component if JS loads, renders a simple FakeChart
* component server-side or if there is no JS. The FakeChart can have only the
* UI without the behavior or be a loading spinner or skeleton.
*
* ```tsx
* return (
* <ClientOnly fallback={<FakeChart />}>
* <Chart />
* </ClientOnly>
* )
* ```
*/
export declare function ClientOnly({ children, fallback }: ClientOnlyProps): import("react/jsx-runtime").JSX.Element;
/**
* Return a boolean indicating if the JS has been hydrated already.
* When doing Server-Side Rendering, the result will always be false.
* When doing Client-Side Rendering, the result will always be false on the
* first render and true from then on. Even if a new component renders it will
* always start with true.
*
* @example
* ```tsx
* // Disable a button that needs JS to work.
* let hydrated = useHydrated()
* return (
* <button type="button" disabled={!hydrated} onClick={doSomethingCustom}>
* Click me
* </button>
* )
* ```
* @returns True if the JS has been hydrated already, false otherwise.
*/
export declare function useHydrated(): boolean;
+27
View File
@@ -0,0 +1,27 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_useRouter = require("./useRouter.cjs");
const require_Asset = require("./Asset.cjs");
const require_headContentUtils = require("./headContentUtils.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/HeadContent.tsx
/**
* Render route-managed head tags (title, meta, links, styles, head scripts).
* Place inside the document head of your app shell.
* @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management
*/
function HeadContent(props) {
const tags = require_headContentUtils.useTags(props.assetCrossOrigin);
const nonce = require_useRouter.useRouter().options.ssr?.nonce;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: tags.map((tag) => /* @__PURE__ */ (0, react.createElement)(require_Asset.Asset, {
...tag,
key: `tsr-meta-${JSON.stringify(tag)}`,
nonce
})) });
}
//#endregion
exports.HeadContent = HeadContent;
//# sourceMappingURL=HeadContent.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"HeadContent.cjs","names":[],"sources":["../../src/HeadContent.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\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 * Render route-managed head tags (title, meta, links, styles, head scripts).\n * Place inside the document head of your app shell.\n * @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management\n */\nexport function HeadContent(props: HeadContentProps) {\n const tags = useTags(props.assetCrossOrigin)\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n return (\n <>\n {tags.map((tag) => (\n <Asset {...tag} key={`tsr-meta-${JSON.stringify(tag)}`} nonce={nonce} />\n ))}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAgB,YAAY,OAAyB;CACnD,MAAM,OAAO,yBAAA,QAAQ,MAAM,gBAAgB;CAE3C,MAAM,QADS,kBAAA,UACD,EAAO,QAAQ,KAAK;CAClC,OACE,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAA,UACG,KAAK,KAAK,QACT,iBAAA,GAAA,MAAA,eAAC,cAAA,OAAD;EAAO,GAAI;EAAK,KAAK,YAAY,KAAK,UAAU,GAAG;EAAY;CAAQ,CAAA,CACxE,EACD,CAAA;AAEN"}
@@ -0,0 +1,10 @@
import { AssetCrossOriginConfig } from '@tanstack/router-core';
export interface HeadContentProps {
assetCrossOrigin?: AssetCrossOriginConfig;
}
/**
* Render route-managed head tags (title, meta, links, styles, head scripts).
* Place inside the document head of your app shell.
* @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management
*/
export declare function HeadContent(props: HeadContentProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_ClientOnly = require("./ClientOnly.cjs");
const require_useRouter = require("./useRouter.cjs");
const require_Asset = require("./Asset.cjs");
const require_headContentUtils = require("./headContentUtils.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/HeadContent.dev.tsx
/**
* Render route-managed head tags (title, meta, links, styles, head scripts).
* Place inside the document head of your app shell.
*
* Development version: filters out dev styles link after hydration and
* includes a fallback cleanup effect for hydration mismatch cases.
*
* @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management
*/
function HeadContent(props) {
const tags = require_headContentUtils.useTags(props.assetCrossOrigin);
const nonce = require_useRouter.useRouter().options.ssr?.nonce;
const hydrated = require_ClientOnly.useHydrated();
react.useEffect(() => {
if (hydrated) document.querySelectorAll(`link[${_tanstack_router_core.DEV_STYLES_ATTR}]`).forEach((el) => el.remove());
}, [hydrated]);
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: (hydrated ? tags.filter((tag) => tag.tag !== "link" || tag.attrs?.[_tanstack_router_core.DEV_STYLES_ATTR] !== true) : tags).map((tag) => /* @__PURE__ */ (0, react.createElement)(require_Asset.Asset, {
...tag,
key: `tsr-meta-${JSON.stringify(tag)}`,
nonce
})) });
}
//#endregion
exports.HeadContent = HeadContent;
//# sourceMappingURL=HeadContent.dev.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"HeadContent.dev.cjs","names":[],"sources":["../../src/HeadContent.dev.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { DEV_STYLES_ATTR } from '@tanstack/router-core'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useHydrated } from './ClientOnly'\nimport { useTags } from './headContentUtils'\nimport type { HeadContentProps } from './HeadContent'\n\n/**\n * Render route-managed head tags (title, meta, links, styles, head scripts).\n * Place inside the document head of your app shell.\n *\n * Development version: filters out dev styles link after hydration and\n * includes a fallback cleanup effect for hydration mismatch cases.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management\n */\nexport function HeadContent(props: HeadContentProps) {\n const tags = useTags(props.assetCrossOrigin)\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n const hydrated = useHydrated()\n\n // Fallback cleanup for hydration mismatch cases\n // Runs when hydration completes to remove any orphaned dev styles links from DOM\n React.useEffect(() => {\n if (hydrated) {\n document\n .querySelectorAll(`link[${DEV_STYLES_ATTR}]`)\n .forEach((el) => el.remove())\n }\n }, [hydrated])\n\n // Filter out dev styles after hydration\n const filteredTags = hydrated\n ? tags.filter(\n (tag) => tag.tag !== 'link' || tag.attrs?.[DEV_STYLES_ATTR] !== true,\n )\n : tags\n\n return (\n <>\n {filteredTags.map((tag) => (\n <Asset {...tag} key={`tsr-meta-${JSON.stringify(tag)}`} nonce={nonce} />\n ))}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,YAAY,OAAyB;CACnD,MAAM,OAAO,yBAAA,QAAQ,MAAM,gBAAgB;CAE3C,MAAM,QADS,kBAAA,UACD,EAAO,QAAQ,KAAK;CAClC,MAAM,WAAW,mBAAA,YAAY;CAI7B,MAAM,gBAAgB;EACpB,IAAI,UACF,SACG,iBAAiB,QAAQ,sBAAA,gBAAgB,EAAE,EAC3C,SAAS,OAAO,GAAG,OAAO,CAAC;CAElC,GAAG,CAAC,QAAQ,CAAC;CASb,OACE,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAA,WAPmB,WACjB,KAAK,QACF,QAAQ,IAAI,QAAQ,UAAU,IAAI,QAAQ,sBAAA,qBAAqB,IAClE,IACA,MAIc,KAAK,QACjB,iBAAA,GAAA,MAAA,eAAC,cAAA,OAAD;EAAO,GAAI;EAAK,KAAK,YAAY,KAAK,UAAU,GAAG;EAAY;CAAQ,CAAA,CACxE,EACD,CAAA;AAEN"}
@@ -0,0 +1,11 @@
import { HeadContentProps } from './HeadContent.cjs';
/**
* Render route-managed head tags (title, meta, links, styles, head scripts).
* Place inside the document head of your app shell.
*
* Development version: filters out dev styles link after hydration and
* includes a fallback cleanup effect for hydration mismatch cases.
*
* @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management
*/
export declare function HeadContent(props: HeadContentProps): import("react/jsx-runtime").JSX.Element;
+168
View File
@@ -0,0 +1,168 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_nonRouteComponentContext = require("./nonRouteComponentContext.cjs");
const require_CatchBoundary = require("./CatchBoundary.cjs");
const require_ClientOnly = require("./ClientOnly.cjs");
const require_matchContext = require("./matchContext.cjs");
const require_useRouter = require("./useRouter.cjs");
const require_not_found = require("./not-found.cjs");
const require_SafeFragment = require("./SafeFragment.cjs");
const require_renderRouteNotFound = require("./renderRouteNotFound.cjs");
const require_scroll_restoration = require("./scroll-restoration.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let react_jsx_runtime = require("react/jsx-runtime");
let _tanstack_react_store = require("@tanstack/react-store");
//#region src/Match.tsx
function renderPending(router, route) {
const PendingComponent = route?.options.pendingComponent ?? router.options.defaultPendingComponent;
if (!PendingComponent) return null;
const pendingElement = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PendingComponent, {});
return process.env.NODE_ENV !== "production" ? require_nonRouteComponentContext.wrapInNonRouteComponentContext(pendingElement, "pendingComponent") : pendingElement;
}
var outletMatchSelectionEqual = (a, b) => a[0] === b[0] && a[1] === b[1];
var Match = react.memo(function MatchImpl({ routeId }) {
const router = require_useRouter.useRouter();
if (_tanstack_router_core_isServer.isServer ?? router.isServer) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MatchView, {
router,
match: router.stores.byRoute.get(routeId).get()
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MatchView, {
router,
match: (0, _tanstack_react_store.useStore)(router.stores.getMatchStore(routeId), (value) => value)
});
});
function MatchView({ router, match }) {
const route = router.routesById[match.routeId];
const pendingElement = renderPending(router, route);
const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
const routeNotFoundComponent = route.isRoot ? route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component : route.options.notFoundComponent;
const resolvedNoSsr = match.ssr === false || match.ssr === "data-only";
const ResolvedSuspenseBoundary = route.options.wrapInSuspense ?? pendingElement ?? (route.options.errorComponent?.preload || resolvedNoSsr) ? react.Suspense : require_SafeFragment.SafeFragment;
const ResolvedCatchBoundary = routeErrorComponent ? require_CatchBoundary.CatchBoundary : require_SafeFragment.SafeFragment;
const ResolvedNotFoundBoundary = routeNotFoundComponent ? require_not_found.CatchNotFound : require_SafeFragment.SafeFragment;
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(route.isRoot ? route.options.shellComponent ?? require_SafeFragment.SafeFragment : require_SafeFragment.SafeFragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_matchContext.matchContext.Provider, {
value: match.routeId,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedSuspenseBoundary, {
fallback: pendingElement,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedCatchBoundary, {
getResetKey: () => match,
errorComponent: routeErrorComponent,
onCatch: (error, errorInfo) => {
if ((0, _tanstack_router_core.isNotFound)(error)) {
error.routeId ??= match.routeId;
throw error;
}
if (process.env.NODE_ENV !== "production") console.warn(`Warning: Error in route match: ${match.id}`);
routeOnCatch?.(error, errorInfo);
},
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedNotFoundBoundary, {
fallback: (error) => {
error.routeId ??= match.routeId;
if (error.routeId !== match.routeId) throw error;
const notFoundElement = react.createElement(routeNotFoundComponent, error);
return process.env.NODE_ENV !== "production" ? require_nonRouteComponentContext.wrapInNonRouteComponentContext(notFoundElement, "notFoundComponent") : notFoundElement;
},
children: resolvedNoSsr ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ClientOnly.ClientOnly, {
fallback: pendingElement,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MatchInner, { match })
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MatchInner, { match })
})
})
})
}), (_tanstack_router_core_isServer.isServer ?? router.isServer) && route.parentRoute?.id === _tanstack_router_core.rootRouteId && router.options.scrollRestoration ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_scroll_restoration.ScrollRestoration, {}) : null] });
}
var MatchInner = react.memo(function MatchInnerImpl({ match }) {
const router = require_useRouter.useRouter();
const routeId = match.routeId;
const route = router.routesById[routeId];
const key = react.useMemo(() => {
const remountDeps = (route.options.remountDeps ?? router.options.defaultRemountDeps)?.({
routeId,
loaderDeps: match.loaderDeps,
params: match._strictParams,
search: match._strictSearch
});
return remountDeps ? JSON.stringify(remountDeps) : void 0;
}, [
routeId,
match.loaderDeps,
match._strictParams,
match._strictSearch,
route.options.remountDeps,
router.options.defaultRemountDeps
]);
const out = react.useMemo(() => {
const Comp = route.options.component ?? router.options.defaultComponent;
return Comp ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Comp, {}, key) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Outlet, {});
}, [
key,
route.options.component,
router.options.defaultComponent
]);
if (match.status === "pending") {
if (router._tx) throw router._tx[5];
return renderPending(router, route);
}
if (match.status === "notFound") return require_renderRouteNotFound.renderRouteNotFound(router, route, match.error);
if (match.status === "error") {
if (_tanstack_router_core_isServer.isServer ?? router.isServer) {
const errorElement = /* @__PURE__ */ (0, react_jsx_runtime.jsx)((route.options.errorComponent ?? router.options.defaultErrorComponent) || require_CatchBoundary.ErrorComponent, {
error: match.error,
reset: void 0,
info: { componentStack: "" }
});
return process.env.NODE_ENV !== "production" ? require_nonRouteComponentContext.wrapInNonRouteComponentContext(errorElement, "errorComponent") : errorElement;
}
throw match.error;
}
return out;
});
/**
* Render the next child match in the route tree. Typically used inside
* a route component to render nested routes.
*
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent
*/
var Outlet = react.memo(function OutletImpl() {
if (process.env.NODE_ENV !== "production") {
const nonRouteComponent = react.useContext(require_nonRouteComponentContext.nonRouteComponentContext);
if (nonRouteComponent) console.warn(`Warning: An <Outlet /> was rendered inside a ${nonRouteComponent}. <Outlet /> should only be rendered inside a route component.`);
}
const router = require_useRouter.useRouter();
const routeId = react.useContext(require_matchContext.matchContext);
let parentGlobalNotFound;
let parentNotFoundError;
let childRouteId;
if (_tanstack_router_core_isServer.isServer ?? router.isServer) {
const matches = router.stores.matches.get();
const parentIndex = matches.findIndex((match) => match.routeId === routeId);
const parentMatch = matches[parentIndex];
parentGlobalNotFound = !!parentMatch._notFound;
parentNotFoundError = parentMatch.error;
childRouteId = matches[parentIndex + 1]?.routeId;
} else {
const parentMatchStore = router.stores.getMatchStore(routeId);
[parentGlobalNotFound, parentNotFoundError] = (0, _tanstack_react_store.useStore)(parentMatchStore, (match) => [!!match._notFound, match.error], outletMatchSelectionEqual);
childRouteId = (0, _tanstack_react_store.useStore)(router.stores.ids, (ids) => {
return ids[ids.indexOf(routeId) + 1];
});
}
if (parentGlobalNotFound) return require_renderRouteNotFound.renderRouteNotFound(router, router.routesById[routeId], parentNotFoundError);
if (!childRouteId) return null;
const nextMatch = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Match, { routeId: childRouteId });
if (routeId === _tanstack_router_core.rootRouteId) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, {
fallback: renderPending(router),
children: nextMatch
});
return nextMatch;
});
//#endregion
exports.Match = Match;
exports.Outlet = Outlet;
exports.renderPending = renderPending;
//# sourceMappingURL=Match.cjs.map
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
import { useRouter } from './useRouter.cjs';
import { AnyRoute, AnyRouteMatch } from '@tanstack/router-core';
import * as React from 'react';
export declare function renderPending(router: ReturnType<typeof useRouter>, route?: AnyRoute): import("react/jsx-runtime").JSX.Element | null;
export declare const Match: React.MemoExoticComponent<({ routeId, }: {
routeId: string;
}) => import("react/jsx-runtime").JSX.Element>;
export declare const MatchInner: React.MemoExoticComponent<({ match, }: {
match: AnyRouteMatch;
}) => any>;
/**
* Render the next child match in the route tree. Typically used inside
* a route component to render nested routes.
*
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent
*/
export declare const Outlet: React.MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element | null>;
+153
View File
@@ -0,0 +1,153 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_utils = require("./utils.cjs");
const require_CatchBoundary = require("./CatchBoundary.cjs");
const require_matchContext = require("./matchContext.cjs");
const require_useRouter = require("./useRouter.cjs");
const require_useMatch = require("./useMatch.cjs");
const require_Transitioner = require("./Transitioner.cjs");
const require_SafeFragment = require("./SafeFragment.cjs");
const require_Match = require("./Match.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let react_jsx_runtime = require("react/jsx-runtime");
let _tanstack_react_store = require("@tanstack/react-store");
//#region src/Matches.tsx
/**
* Internal component that renders the router's active match tree with
* suspense, error, and not-found boundaries. Rendered by `RouterProvider`.
*/
function Matches() {
const router = require_useRouter.useRouter();
const rootRoute = router.routesById[_tanstack_router_core.rootRouteId];
const pendingElement = require_Match.renderPending(router, rootRoute);
const ResolvedSuspense = (_tanstack_router_core_isServer.isServer ?? router.isServer) || router.ssr ? require_SafeFragment.SafeFragment : react.Suspense;
const inner = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [!(_tanstack_router_core_isServer.isServer ?? router.isServer) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Transitioner.Transitioner, { t: react.useState()[1] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedSuspense, {
fallback: pendingElement,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MatchesInner, {})
})] });
return router.options.InnerWrap ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(router.options.InnerWrap, { children: inner }) : inner;
}
function MatchesInner() {
const router = require_useRouter.useRouter();
const acknowledgement = router._rendered;
const matches = _tanstack_router_core_isServer.isServer ?? router.isServer ? router.stores.matches.get() : (0, _tanstack_react_store.useStore)(router.stores.matches, (value) => acknowledgement[0] ?? value);
const match = matches[0];
const routeId = match?.routeId;
require_utils.useLayoutEffect(() => {
if (acknowledgement[0] === matches) require_Transitioner.settleOwner(acknowledgement, true);
}, [acknowledgement, matches]);
const matchComponent = routeId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Match.Match, { routeId }) : null;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_matchContext.matchContext.Provider, {
value: routeId,
children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CatchBoundary.CatchBoundary, {
getResetKey: () => match,
onCatch: process.env.NODE_ENV !== "production" ? (error) => {
console.warn(`Warning: The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
console.warn(`Warning: ${error.message || error.toString()}`);
} : void 0,
children: matchComponent
})
});
}
/**
* Create a matcher function for testing locations against route definitions.
*
* The returned function accepts standard navigation options (`to`, `params`,
* `search`, etc.) and returns either `false` (no match) or the matched params
* object when the route matches the current or pending location.
*
* Useful for conditional rendering and active UI states because it subscribes
* the component to the router state used for matching. The returned function's
* identity changes when that state changes. For imperative checks in event
* handlers, get the router with `useRouter` and call `router.matchRoute(...)`
* to avoid that subscription.
*
* @returns A `matchRoute(options)` function that returns `false` or params.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchRouteHook
*/
function useMatchRoute() {
const router = require_useRouter.useRouter();
if (_tanstack_router_core_isServer.isServer ?? router.isServer) return (opts) => {
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
return router.matchRoute(rest, {
pending,
caseSensitive,
fuzzy,
includeSearch
});
};
return react.useCallback((opts) => {
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
return router.matchRoute(rest, {
pending,
caseSensitive,
fuzzy,
includeSearch
});
}, [
router,
(0, _tanstack_react_store.useStore)(router.stores.location, (location) => location.href),
(0, _tanstack_react_store.useStore)(router.stores.resolvedLocation, (location) => location?.href),
(0, _tanstack_react_store.useStore)(router.stores.status, (status) => status)
]);
}
/**
* Component that conditionally renders its children based on whether a route
* matches the provided `from`/`to` options. If `children` is a function, it
* receives the matched params object.
*
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/matchRouteComponent
*/
function MatchRoute(props) {
const params = useMatchRoute()(props);
if (typeof props.children === "function") return props.children(params);
return params ? props.children : null;
}
function useMatches(opts) {
const router = require_useRouter.useRouter();
if (_tanstack_router_core_isServer.isServer ?? router.isServer) {
const matches = router.stores.matches.get();
return opts?.select ? opts.select(matches) : matches;
}
return (0, _tanstack_react_store.useStore)(router.stores.matches, require_useMatch.useStructuralSharing(opts, router));
}
/**
* Read the presented route matches above the current match, or select a
* derived value from them.
*/
function useParentMatches(opts) {
const contextRouteId = react.useContext(require_matchContext.matchContext);
return useMatches({
select: (matches) => {
matches = matches.slice(0, matches.findIndex((d) => d.routeId === contextRouteId));
return opts?.select ? opts.select(matches) : matches;
},
structuralSharing: opts?.structuralSharing
});
}
/**
* Read the presented route matches below the current match, or select a
* derived value from them.
*/
function useChildMatches(opts) {
const contextRouteId = react.useContext(require_matchContext.matchContext);
return useMatches({
select: (matches) => {
matches = matches.slice(matches.findIndex((d) => d.routeId === contextRouteId) + 1);
return opts?.select ? opts.select(matches) : matches;
},
structuralSharing: opts?.structuralSharing
});
}
//#endregion
exports.MatchRoute = MatchRoute;
exports.Matches = Matches;
exports.useChildMatches = useChildMatches;
exports.useMatchRoute = useMatchRoute;
exports.useMatches = useMatches;
exports.useParentMatches = useParentMatches;
//# sourceMappingURL=Matches.cjs.map
File diff suppressed because one or more lines are too long
+61
View File
@@ -0,0 +1,61 @@
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.cjs';
import { AnyRouter, DeepPartial, Expand, MakeOptionalPathParams, MakeOptionalSearchParams, MakeRouteMatchUnion, MaskOptions, MatchRouteOptions, RegisteredRouter, ResolveRoute, ToSubOptionsProps } from '@tanstack/router-core';
import * as React from 'react';
declare module '@tanstack/router-core' {
interface RouteMatchExtensions {
meta?: Array<React.JSX.IntrinsicElements['meta'] | undefined>;
links?: Array<React.JSX.IntrinsicElements['link'] | undefined>;
scripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>;
styles?: Array<React.JSX.IntrinsicElements['style'] | undefined>;
headScripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>;
}
}
/**
* Internal component that renders the router's active match tree with
* suspense, error, and not-found boundaries. Rendered by `RouterProvider`.
*/
export declare function Matches(): import("react/jsx-runtime").JSX.Element;
export type UseMatchRouteOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = undefined, TMaskFrom extends string = TFrom, TMaskTo extends string = ''> = ToSubOptionsProps<TRouter, TFrom, TTo> & DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> & DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> & MaskOptions<TRouter, TMaskFrom, TMaskTo> & MatchRouteOptions;
/**
* Create a matcher function for testing locations against route definitions.
*
* The returned function accepts standard navigation options (`to`, `params`,
* `search`, etc.) and returns either `false` (no match) or the matched params
* object when the route matches the current or pending location.
*
* Useful for conditional rendering and active UI states because it subscribes
* the component to the router state used for matching. The returned function's
* identity changes when that state changes. For imperative checks in event
* handlers, get the router with `useRouter` and call `router.matchRoute(...)`
* to avoid that subscription.
*
* @returns A `matchRoute(options)` function that returns `false` or params.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchRouteHook
*/
export declare function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>(): <const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>;
export type MakeMatchRouteOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = undefined, TMaskFrom extends string = TFrom, TMaskTo extends string = ''> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
children?: ((params?: Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>) => React.ReactNode) | React.ReactNode;
};
/**
* Component that conditionally renders its children based on whether a route
* matches the provided `from`/`to` options. If `children` is a function, it
* receives the matched params object.
*
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/matchRouteComponent
*/
export declare function MatchRoute<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any;
export interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected, TStructuralSharing> {
select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
}
export type UseMatchesResult<TRouter extends AnyRouter, TSelected> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected;
export declare function useMatches<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>): UseMatchesResult<TRouter, TSelected>;
/**
* Read the presented route matches above the current match, or select a
* derived value from them.
*/
export declare function useParentMatches<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>): UseMatchesResult<TRouter, TSelected>;
/**
* Read the presented route matches below the current match, or select a
* derived value from them.
*/
export declare function useChildMatches<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseMatchesBaseOptions<TRouter, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>): UseMatchesResult<TRouter, TSelected>;
@@ -0,0 +1,50 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_routerContext = require("./routerContext.cjs");
const require_Matches = require("./Matches.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/RouterProvider.tsx
/**
* Low-level provider that places the router into React context and optionally
* updates router options from props. Most apps should use `RouterProvider`.
*/
function RouterContextProvider({ router, children, ...rest }) {
if ((0, _tanstack_router_core.hasKeys)(rest)) router.update({
...router.options,
...rest,
context: {
...router.options.context,
...rest.context
}
});
const provider = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_routerContext.routerContext.Provider, {
value: router,
children
});
if (router.options.Wrap) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(router.options.Wrap, { children: provider });
return provider;
}
/**
* Renders the current match presentation and provides the router to the React
* tree via context.
*
* Accepts the same options as `createRouter` via props to update the router
* instance after creation.
*
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
*/
function RouterProvider({ router, ...rest }) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouterContextProvider, {
router,
...rest,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Matches.Matches, {})
});
}
//#endregion
exports.RouterContextProvider = RouterContextProvider;
exports.RouterProvider = RouterProvider;
//# sourceMappingURL=RouterProvider.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"RouterProvider.cjs","names":[],"sources":["../../src/RouterProvider.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { hasKeys } from '@tanstack/router-core'\nimport { Matches } from './Matches'\nimport { routerContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n/**\n * Low-level provider that places the router into React context and optionally\n * updates router options from props. Most apps should use `RouterProvider`.\n */\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n if (hasKeys(rest)) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n })\n }\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\n/**\n * Renders the current match presentation and provides the router to the React\n * tree via context.\n *\n * Accepts the same options as `createRouter` via props to update the router\n * instance after creation.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\n */\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,sBAGd,EACA,QACA,UACA,GAAG,QAGF;CACD,KAAA,GAAA,sBAAA,SAAY,IAAI,GAEd,OAAO,OAAO;EACZ,GAAG,OAAO;EACV,GAAG;EACH,SAAS;GACP,GAAG,OAAO,QAAQ;GAClB,GAAG,KAAK;EACV;CACF,CAAC;CAGH,MAAM,WACJ,iBAAA,GAAA,kBAAA,KAAC,sBAAA,cAAc,UAAf;EAAwB,OAAO;EAC5B;CACqB,CAAA;CAG1B,IAAI,OAAO,QAAQ,MACjB,OAAO,iBAAA,GAAA,kBAAA,KAAC,OAAO,QAAQ,MAAhB,EAAA,UAAsB,SAA8B,CAAA;CAG7D,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,eAGd,EAAE,QAAQ,GAAG,QAA2C;CACxD,OACE,iBAAA,GAAA,kBAAA,KAAC,uBAAD;EAA+B;EAAQ,GAAI;YACzC,iBAAA,GAAA,kBAAA,KAAC,gBAAA,SAAD,CAAU,CAAA;CACW,CAAA;AAE3B"}
@@ -0,0 +1,23 @@
import { AnyRouter, RegisteredRouter, RouterOptions } from '@tanstack/router-core';
import * as React from 'react';
/**
* Low-level provider that places the router into React context and optionally
* updates router options from props. Most apps should use `RouterProvider`.
*/
export declare function RouterContextProvider<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>>({ router, children, ...rest }: RouterProps<TRouter, TDehydrated> & {
children: React.ReactNode;
}): import("react/jsx-runtime").JSX.Element;
/**
* Renders the current match presentation and provides the router to the React
* tree via context.
*
* Accepts the same options as `createRouter` via props to update the router
* instance after creation.
*
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
*/
export declare function RouterProvider<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>>({ router, ...rest }: RouterProps<TRouter, TDehydrated>): import("react/jsx-runtime").JSX.Element;
export type RouterProps<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>> = Omit<RouterOptions<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TRouter['history'], TDehydrated>, 'context'> & {
router: TRouter;
context?: Partial<RouterOptions<TRouter['routeTree'], NonNullable<TRouter['options']['trailingSlash']>, NonNullable<TRouter['options']['defaultStructuralSharing']>, TRouter['history'], TDehydrated>['context']>;
};
+12
View File
@@ -0,0 +1,12 @@
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/SafeFragment.tsx
function SafeFragment(props) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: props.children });
}
//#endregion
exports.SafeFragment = SafeFragment;
//# sourceMappingURL=SafeFragment.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"SafeFragment.cjs","names":[],"sources":["../../src/SafeFragment.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport function SafeFragment(props: any) {\n return <>{props.children}</>\n}\n"],"mappings":";;;;;AAEA,SAAgB,aAAa,OAAY;CACvC,OAAO,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAA,UAAG,MAAM,SAAW,CAAA;AAC7B"}
@@ -0,0 +1 @@
export declare function SafeFragment(props: any): import("react/jsx-runtime").JSX.Element;
+19
View File
@@ -0,0 +1,19 @@
const require_useRouter = require("./useRouter.cjs");
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/ScriptOnce.tsx
/**
* Server-only helper to emit a script tag exactly once during SSR.
*/
function ScriptOnce({ children }) {
const router = require_useRouter.useRouter();
if (!(_tanstack_router_core_isServer.isServer ?? router.isServer)) return null;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("script", {
nonce: router.options.ssr?.nonce,
dangerouslySetInnerHTML: { __html: children + ";document.currentScript.remove()" }
});
}
//#endregion
exports.ScriptOnce = ScriptOnce;
//# sourceMappingURL=ScriptOnce.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ScriptOnce.cjs","names":[],"sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import { isServer } from '@tanstack/router-core/isServer'\nimport { useRouter } from './useRouter'\n\n/**\n * Server-only helper to emit a script tag exactly once during SSR.\n */\nexport function ScriptOnce({ children }: { children: string }) {\n const router = useRouter()\n if (!(isServer ?? router.isServer)) {\n return null\n }\n\n return (\n <script\n nonce={router.options.ssr?.nonce}\n dangerouslySetInnerHTML={{\n __html: children + ';document.currentScript.remove()',\n }}\n />\n )\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,WAAW,EAAE,YAAkC;CAC7D,MAAM,SAAS,kBAAA,UAAU;CACzB,IAAI,EAAE,+BAAA,YAAY,OAAO,WACvB,OAAO;CAGT,OACE,iBAAA,GAAA,kBAAA,KAAC,UAAD;EACE,OAAO,OAAO,QAAQ,KAAK;EAC3B,yBAAyB,EACvB,QAAQ,WAAW,mCACrB;CACD,CAAA;AAEL"}
@@ -0,0 +1,6 @@
/**
* Server-only helper to emit a script tag exactly once during SSR.
*/
export declare function ScriptOnce({ children }: {
children: string;
}): import("react/jsx-runtime").JSX.Element | null;
+60
View File
@@ -0,0 +1,60 @@
const require_useRouter = require("./useRouter.cjs");
const require_Asset = require("./Asset.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let react_jsx_runtime = require("react/jsx-runtime");
let _tanstack_react_store = require("@tanstack/react-store");
//#region src/Scripts.tsx
/**
* Render body script tags collected from route matches and SSR manifests.
* Should be placed near the end of the document body.
*/
var Scripts = () => {
const router = require_useRouter.useRouter();
const nonce = router.options.ssr?.nonce;
const getScripts = (matches) => {
matches = (0, _tanstack_router_core._getAssetMatches)(matches);
const scripts = matches.flatMap((match) => match.scripts ?? []).filter(Boolean).map(({ children, ...script }) => ({
tag: "script",
attrs: {
...script,
suppressHydrationWarning: true,
nonce
},
children
}));
const manifest = router.ssr?.manifest;
if (!manifest) return scripts;
for (const match of matches) {
const manifestScripts = manifest.routes[match.routeId]?.scripts;
if (!manifestScripts) continue;
for (const asset of manifestScripts) scripts.push({
tag: "script",
attrs: {
...asset.attrs,
nonce
},
children: asset.children,
...typeof asset.attrs?.src === "string" ? { preventScriptHoist: true } : {}
});
}
return scripts;
};
if (_tanstack_router_core_isServer.isServer ?? router.isServer) return renderScripts(router, getScripts(router.stores.matches.get()));
return renderScripts(router, (0, _tanstack_react_store.useStore)(router.stores.matches, getScripts, _tanstack_router_core.deepEqual));
};
function renderScripts(router, scripts) {
if ((_tanstack_router_core_isServer.isServer ?? router.isServer) && router.serverSsr) {
const serverBufferedScript = router.serverSsr.takeBufferedScripts();
if (serverBufferedScript) scripts.unshift(serverBufferedScript);
}
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: scripts.map((asset, i) => /* @__PURE__ */ (0, react.createElement)(require_Asset.Asset, {
...asset,
key: `tsr-scripts-${asset.tag}-${i}`
})) });
}
//#endregion
exports.Scripts = Scripts;
//# sourceMappingURL=Scripts.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"Scripts.cjs","names":[],"sources":["../../src/Scripts.tsx"],"sourcesContent":["import { useStore } from '@tanstack/react-store'\nimport { _getAssetMatches, deepEqual } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\ntype ScriptRenderAsset = RouterManagedTag & {\n preventScriptHoist?: boolean\n}\n\n/**\n * Render body script tags collected from route matches and SSR manifests.\n * Should be placed near the end of the document body.\n */\nexport const Scripts = () => {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n\n const getScripts = (matches: Array<any>) => {\n matches = _getAssetMatches(matches)\n const scripts = matches\n .flatMap((match) => match.scripts ?? [])\n .filter(Boolean)\n .map(\n ({ children, ...script }) =>\n ({\n tag: 'script',\n attrs: {\n ...script,\n suppressHydrationWarning: true,\n nonce,\n },\n children,\n }) satisfies RouterManagedTag,\n ) as Array<ScriptRenderAsset>\n const manifest = router.ssr?.manifest\n\n if (!manifest) {\n return scripts\n }\n\n for (const match of matches) {\n const manifestScripts = manifest.routes[match.routeId]?.scripts\n\n if (!manifestScripts) {\n continue\n }\n\n for (const asset of manifestScripts) {\n scripts.push({\n tag: 'script',\n attrs: { ...asset.attrs, nonce },\n children: asset.children,\n ...(typeof asset.attrs?.src === 'string'\n ? { preventScriptHoist: true }\n : {}),\n })\n }\n }\n\n return scripts\n }\n\n if (isServer ?? router.isServer) {\n const activeMatches = router.stores.matches.get()\n const scripts = getScripts(activeMatches)\n return renderScripts(router, scripts)\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks -- condition is static\n const scripts = useStore(router.stores.matches, getScripts, deepEqual)\n\n return renderScripts(router, scripts)\n}\n\nfunction renderScripts(\n router: ReturnType<typeof useRouter>,\n scripts: Array<ScriptRenderAsset>,\n) {\n if ((isServer ?? router.isServer) && router.serverSsr) {\n const serverBufferedScript = router.serverSsr.takeBufferedScripts()\n if (serverBufferedScript) {\n scripts.unshift(serverBufferedScript)\n }\n }\n\n return (\n <>\n {scripts.map((asset, i) => (\n <Asset {...asset} key={`tsr-scripts-${asset.tag}-${i}`} />\n ))}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAeA,IAAa,gBAAgB;CAC3B,MAAM,SAAS,kBAAA,UAAU;CACzB,MAAM,QAAQ,OAAO,QAAQ,KAAK;CAElC,MAAM,cAAc,YAAwB;EAC1C,WAAA,GAAA,sBAAA,kBAA2B,OAAO;EAClC,MAAM,UAAU,QACb,SAAS,UAAU,MAAM,WAAW,CAAC,CAAC,EACtC,OAAO,OAAO,EACd,KACE,EAAE,UAAU,GAAG,cACb;GACC,KAAK;GACL,OAAO;IACL,GAAG;IACH,0BAA0B;IAC1B;GACF;GACA;EACF,EACJ;EACF,MAAM,WAAW,OAAO,KAAK;EAE7B,IAAI,CAAC,UACH,OAAO;EAGT,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,kBAAkB,SAAS,OAAO,MAAM,UAAU;GAExD,IAAI,CAAC,iBACH;GAGF,KAAK,MAAM,SAAS,iBAClB,QAAQ,KAAK;IACX,KAAK;IACL,OAAO;KAAE,GAAG,MAAM;KAAO;IAAM;IAC/B,UAAU,MAAM;IAChB,GAAI,OAAO,MAAM,OAAO,QAAQ,WAC5B,EAAE,oBAAoB,KAAK,IAC3B,CAAC;GACP,CAAC;EAEL;EAEA,OAAO;CACT;CAEA,IAAI,+BAAA,YAAY,OAAO,UAGrB,OAAO,cAAc,QADL,WADM,OAAO,OAAO,QAAQ,IACjB,CACE,CAAO;CAMtC,OAAO,cAAc,SAAA,GAAA,sBAAA,UAFI,OAAO,OAAO,SAAS,YAAY,sBAAA,SAE/B,CAAO;AACtC;AAEA,SAAS,cACP,QACA,SACA;CACA,KAAK,+BAAA,YAAY,OAAO,aAAa,OAAO,WAAW;EACrD,MAAM,uBAAuB,OAAO,UAAU,oBAAoB;EAClE,IAAI,sBACF,QAAQ,QAAQ,oBAAoB;CAExC;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAA,UACG,QAAQ,KAAK,OAAO,MACnB,iBAAA,GAAA,MAAA,eAAC,cAAA,OAAD;EAAO,GAAI;EAAO,KAAK,eAAe,MAAM,IAAI,GAAG;CAAM,CAAA,CAC1D,EACD,CAAA;AAEN"}
+5
View File
@@ -0,0 +1,5 @@
/**
* Render body script tags collected from route matches and SSR manifests.
* Should be placed near the end of the document body.
*/
export declare const Scripts: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
const require_useRouter = require("./useRouter.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
//#region src/ScrollRestoration.tsx
function useScrollRestoration() {
(0, _tanstack_router_core.setupScrollRestoration)(require_useRouter.useRouter(), true);
}
/**
* @deprecated Use the `scrollRestoration` router option instead.
*/
function ScrollRestoration(_props) {
useScrollRestoration();
if (process.env.NODE_ENV === "development") console.warn("The ScrollRestoration component is deprecated. Use createRouter's `scrollRestoration` option instead.");
return null;
}
function useElementScrollRestoration(options) {
useScrollRestoration();
return (0, _tanstack_router_core.getElementScrollRestorationEntry)(require_useRouter.useRouter(), options);
}
//#endregion
exports.ScrollRestoration = ScrollRestoration;
exports.useElementScrollRestoration = useElementScrollRestoration;
//# sourceMappingURL=ScrollRestoration.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ScrollRestoration.cjs","names":[],"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 the `scrollRestoration` router option instead.\n */\nexport function ScrollRestoration(_props: ScrollRestorationOptions) {\n useScrollRestoration()\n\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n \"The ScrollRestoration component is deprecated. Use createRouter's `scrollRestoration` option instead.\",\n )\n }\n\n return null\n}\n\nexport function useElementScrollRestoration(\n options: (\n | {\n id: string\n getElement?: () => Window | Element | undefined | null\n }\n | {\n id?: string\n getElement: () => Window | Element | undefined | null\n }\n ) & {\n getKey?: (location: ParsedLocation) => string\n },\n): ScrollRestorationEntry | undefined {\n useScrollRestoration()\n\n return getElementScrollRestorationEntry(useRouter(), options)\n}\n"],"mappings":";;;AAWA,SAAS,uBAAuB;CAE9B,CAAA,GAAA,sBAAA,wBADe,kBAAA,UACQ,GAAQ,IAAI;AACrC;;;;AAKA,SAAgB,kBAAkB,QAAkC;CAClE,qBAAqB;CAErB,IAAA,QAAA,IAAA,aAA6B,eAC3B,QAAQ,KACN,uGACF;CAGF,OAAO;AACT;AAEA,SAAgB,4BACd,SAYoC;CACpC,qBAAqB;CAErB,QAAA,GAAA,sBAAA,kCAAwC,kBAAA,UAAU,GAAG,OAAO;AAC9D"}
@@ -0,0 +1,14 @@
import { ParsedLocation, ScrollRestorationEntry, ScrollRestorationOptions } from '@tanstack/router-core';
/**
* @deprecated Use the `scrollRestoration` router option instead.
*/
export declare function ScrollRestoration(_props: ScrollRestorationOptions): null;
export declare function useElementScrollRestoration(options: ({
id: string;
getElement?: () => Window | Element | undefined | null;
} | {
id?: string;
getElement: () => Window | Element | undefined | null;
}) & {
getKey?: (location: ParsedLocation) => string;
}): ScrollRestorationEntry | undefined;
+70
View File
@@ -0,0 +1,70 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_utils = require("./utils.cjs");
const require_useRouter = require("./useRouter.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
//#region src/Transitioner.tsx
function settleOwner(owner, rendered) {
const settle = owner[1];
owner.length = 0;
settle?.(rendered);
}
function Transitioner({ t }) {
const router = require_useRouter.useRouter();
const acknowledgement = router._rendered ??= [];
const mounted = process.env.NODE_ENV !== "production" ? react.useRef(false) : void 0;
router.startTransition = (fn, expected) => new Promise((resolve, reject) => {
settleOwner(acknowledgement, false);
acknowledgement.push(expected, resolve);
t(router);
react.startTransition(() => {
try {
fn();
} catch (cause) {
if (acknowledgement[1] === resolve) acknowledgement.length = 0;
reject(cause);
}
});
});
if (process.env.NODE_ENV !== "production") router._cancelTransition = () => settleOwner(acknowledgement, false);
require_utils.useLayoutEffect(() => {
const unsub = router.history.subscribe(router.load);
if (mounted?.current) return unsub;
if (mounted) mounted.current = true;
router.updateLatestLocation();
const location = router.latestLocation;
const nextLocation = router.buildLocation({
to: location.pathname,
search: true,
params: true,
hash: true,
state: true,
_includeValidateSearch: true
});
if ((0, _tanstack_router_core.trimPathRight)(location.publicHref) !== (0, _tanstack_router_core.trimPathRight)(nextLocation.publicHref)) {
router.commitLocation({
...nextLocation,
replace: true,
ignoreBlocker: true
});
return unsub;
}
const resolvedLocation = router.stores.resolvedLocation.get();
if (resolvedLocation?.href === location.href && resolvedLocation.state.__TSR_key === location.state.__TSR_key) acknowledgement.push(router.stores.matches.get(), (rendered) => {
if (rendered) router.emit({
type: "onRendered",
...(0, _tanstack_router_core.getLocationChangeInfo)(resolvedLocation, resolvedLocation)
});
});
else if (!router._tx) router.load().catch(console.error);
return unsub;
}, [router, router.history]);
return null;
}
//#endregion
exports.Transitioner = Transitioner;
exports.settleOwner = settleOwner;
//# sourceMappingURL=Transitioner.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"Transitioner.cjs","names":[],"sources":["../../src/Transitioner.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { getLocationChangeInfo, trimPathRight } from '@tanstack/router-core'\nimport { useLayoutEffect } from './utils'\nimport { useRouter } from './useRouter'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport function settleOwner(\n owner: NonNullable<AnyRouter['_rendered']>,\n rendered: boolean,\n) {\n const settle = owner[1 /* settle */]\n owner.length = 0\n settle?.(rendered)\n}\n\nexport function Transitioner({\n t,\n}: {\n t: React.Dispatch<React.SetStateAction<AnyRouter | undefined>>\n}) {\n const router = useRouter()\n const acknowledgement = (router._rendered ??= [])\n const mounted =\n process.env.NODE_ENV !== 'production'\n ? // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useRef(false)\n : undefined\n\n router.startTransition = (fn, expected) =>\n new Promise((resolve, reject) => {\n settleOwner(acknowledgement, false)\n acknowledgement.push(expected, resolve)\n t(router)\n React.startTransition(() => {\n try {\n fn()\n } catch (cause) {\n if (acknowledgement[1 /* settle */] === resolve) {\n acknowledgement.length = 0\n }\n reject(cause)\n }\n })\n })\n if (process.env.NODE_ENV !== 'production') {\n ;(\n router as typeof router & { _cancelTransition?: () => void }\n )._cancelTransition = () => settleOwner(acknowledgement, false)\n }\n\n // Subscribe before canonicalizing so the initial URL has exactly one load.\n useLayoutEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n if (mounted?.current) {\n return unsub\n }\n if (mounted) {\n mounted.current = true\n }\n\n router.updateLatestLocation()\n const location = router.latestLocation\n const nextLocation = router.buildLocation({\n to: location.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) consistently with server\n // canonicalization.\n if (\n trimPathRight(location.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({\n ...nextLocation,\n replace: true,\n ignoreBlocker: true,\n })\n return unsub\n }\n\n const resolvedLocation = router.stores.resolvedLocation.get()\n if (\n resolvedLocation?.href === location.href &&\n resolvedLocation.state.__TSR_key === location.state.__TSR_key\n ) {\n acknowledgement.push(router.stores.matches.get(), (rendered) => {\n if (rendered) {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(resolvedLocation, resolvedLocation),\n })\n }\n })\n } else if (!router._tx) {\n router.load().catch(console.error)\n }\n\n return unsub\n // `mounted` exists only in development and is a stable ref when present.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [router, router.history])\n\n return null\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,YACd,OACA,UACA;CACA,MAAM,SAAS,MAAM;CACrB,MAAM,SAAS;CACf,SAAS,QAAQ;AACnB;AAEA,SAAgB,aAAa,EAC3B,KAGC;CACD,MAAM,SAAS,kBAAA,UAAU;CACzB,MAAM,kBAAmB,OAAO,cAAc,CAAC;CAC/C,MAAM,UAAA,QAAA,IAAA,aACqB,eAErB,MAAM,OAAO,KAAK,IAClB,KAAA;CAEN,OAAO,mBAAmB,IAAI,aAC5B,IAAI,SAAS,SAAS,WAAW;EAC/B,YAAY,iBAAiB,KAAK;EAClC,gBAAgB,KAAK,UAAU,OAAO;EACtC,EAAE,MAAM;EACR,MAAM,sBAAsB;GAC1B,IAAI;IACF,GAAG;GACL,SAAS,OAAO;IACd,IAAI,gBAAgB,OAAoB,SACtC,gBAAgB,SAAS;IAE3B,OAAO,KAAK;GACd;EACF,CAAC;CACH,CAAC;CACH,IAAA,QAAA,IAAA,aAA6B,cAC1B,OAEC,0BAA0B,YAAY,iBAAiB,KAAK;CAIhE,cAAA,sBAAsB;EACpB,MAAM,QAAQ,OAAO,QAAQ,UAAU,OAAO,IAAI;EAElD,IAAI,SAAS,SACX,OAAO;EAET,IAAI,SACF,QAAQ,UAAU;EAGpB,OAAO,qBAAqB;EAC5B,MAAM,WAAW,OAAO;EACxB,MAAM,eAAe,OAAO,cAAc;GACxC,IAAI,SAAS;GACb,QAAQ;GACR,QAAQ;GACR,MAAM;GACN,OAAO;GACP,wBAAwB;EAC1B,CAAC;EAKD,KAAA,GAAA,sBAAA,eACgB,SAAS,UAAU,OAAA,GAAA,sBAAA,eACnB,aAAa,UAAU,GACrC;GACA,OAAO,eAAe;IACpB,GAAG;IACH,SAAS;IACT,eAAe;GACjB,CAAC;GACD,OAAO;EACT;EAEA,MAAM,mBAAmB,OAAO,OAAO,iBAAiB,IAAI;EAC5D,IACE,kBAAkB,SAAS,SAAS,QACpC,iBAAiB,MAAM,cAAc,SAAS,MAAM,WAEpD,gBAAgB,KAAK,OAAO,OAAO,QAAQ,IAAI,IAAI,aAAa;GAC9D,IAAI,UACF,OAAO,KAAK;IACV,MAAM;IACN,IAAA,GAAA,sBAAA,uBAAyB,kBAAkB,gBAAgB;GAC7D,CAAC;EAEL,CAAC;OACI,IAAI,CAAC,OAAO,KACjB,OAAO,KAAK,EAAE,MAAM,QAAQ,KAAK;EAGnC,OAAO;CAGT,GAAG,CAAC,QAAQ,OAAO,OAAO,CAAC;CAE3B,OAAO;AACT"}
@@ -0,0 +1,6 @@
import { AnyRouter } from '@tanstack/router-core';
import * as React from 'react';
export declare function settleOwner(owner: NonNullable<AnyRouter['_rendered']>, rendered: boolean): void;
export declare function Transitioner({ t, }: {
t: React.Dispatch<React.SetStateAction<AnyRouter | undefined>>;
}): null;
@@ -0,0 +1,23 @@
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
exports.__toESM = __toESM;
+36
View File
@@ -0,0 +1,36 @@
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_utils = require("./utils.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/awaited.tsx
/** Suspend until a deferred promise resolves or rejects and return its data. */
function useAwaited({ promise: _promise }) {
if (require_utils.reactUse) return require_utils.reactUse(_promise);
const promise = (0, _tanstack_router_core.defer)(_promise);
if (promise[_tanstack_router_core.TSR_DEFERRED_PROMISE].status === "pending") throw promise;
if (promise[_tanstack_router_core.TSR_DEFERRED_PROMISE].status === "error") throw promise[_tanstack_router_core.TSR_DEFERRED_PROMISE].error;
return promise[_tanstack_router_core.TSR_DEFERRED_PROMISE].data;
}
/**
* Component that suspends on a deferred promise and renders its child with
* the resolved value. Optionally provides a Suspense fallback.
*/
function Await(props) {
const inner = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AwaitInner, { ...props });
if (props.fallback) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, {
fallback: props.fallback,
children: inner
});
return inner;
}
function AwaitInner(props) {
const data = useAwaited(props);
return props.children(data);
}
//#endregion
exports.Await = Await;
exports.useAwaited = useAwaited;
//# sourceMappingURL=awaited.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"awaited.cjs","names":[],"sources":["../../src/awaited.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { TSR_DEFERRED_PROMISE, defer } from '@tanstack/router-core'\nimport { reactUse } from './utils'\n\nexport type AwaitOptions<T> = {\n promise: Promise<T>\n}\n\n/** Suspend until a deferred promise resolves or rejects and return its data. */\nexport function useAwaited<T>({ promise: _promise }: AwaitOptions<T>): T {\n if (reactUse) {\n const data = reactUse(_promise)\n return data\n }\n const promise = defer(_promise)\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'pending') {\n throw promise\n }\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'error') {\n throw promise[TSR_DEFERRED_PROMISE].error\n }\n\n return promise[TSR_DEFERRED_PROMISE].data\n}\n\n/**\n * Component that suspends on a deferred promise and renders its child with\n * the resolved value. Optionally provides a Suspense fallback.\n */\nexport function Await<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n) {\n const inner = <AwaitInner {...props} />\n if (props.fallback) {\n return <React.Suspense fallback={props.fallback}>{inner}</React.Suspense>\n }\n return inner\n}\n\nfunction AwaitInner<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n): React.JSX.Element {\n const data = useAwaited(props)\n\n return props.children(data) as React.JSX.Element\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,WAAc,EAAE,SAAS,YAAgC;CACvE,IAAI,cAAA,UAEF,OADa,cAAA,SAAS,QACf;CAET,MAAM,WAAA,GAAA,sBAAA,OAAgB,QAAQ;CAE9B,IAAI,QAAQ,sBAAA,sBAAsB,WAAW,WAC3C,MAAM;CAGR,IAAI,QAAQ,sBAAA,sBAAsB,WAAW,SAC3C,MAAM,QAAQ,sBAAA,sBAAsB;CAGtC,OAAO,QAAQ,sBAAA,sBAAsB;AACvC;;;;;AAMA,SAAgB,MACd,OAIA;CACA,MAAM,QAAQ,iBAAA,GAAA,kBAAA,KAAC,YAAD,EAAY,GAAI,MAAQ,CAAA;CACtC,IAAI,MAAM,UACR,OAAO,iBAAA,GAAA,kBAAA,KAAC,MAAM,UAAP;EAAgB,UAAU,MAAM;YAAW;CAAsB,CAAA;CAE1E,OAAO;AACT;AAEA,SAAS,WACP,OAImB;CACnB,MAAM,OAAO,WAAW,KAAK;CAE7B,OAAO,MAAM,SAAS,IAAI;AAC5B"}
+14
View File
@@ -0,0 +1,14 @@
import * as React from 'react';
export type AwaitOptions<T> = {
promise: Promise<T>;
};
/** Suspend until a deferred promise resolves or rejects and return its data. */
export declare function useAwaited<T>({ promise: _promise }: AwaitOptions<T>): T;
/**
* Component that suspends on a deferred promise and renders its child with
* the resolved value. Optionally provides a Suspense fallback.
*/
export declare function Await<T>(props: AwaitOptions<T> & {
fallback?: React.ReactNode;
children: (result: T) => React.ReactNode;
}): import("react/jsx-runtime").JSX.Element;
+148
View File
@@ -0,0 +1,148 @@
const require_useRouter = require("./useRouter.cjs");
const require_useMatch = require("./useMatch.cjs");
const require_useLoaderData = require("./useLoaderData.cjs");
const require_useLoaderDeps = require("./useLoaderDeps.cjs");
const require_useParams = require("./useParams.cjs");
const require_useSearch = require("./useSearch.cjs");
const require_useNavigate = require("./useNavigate.cjs");
const require_useRouteContext = require("./useRouteContext.cjs");
const require_route = require("./route.cjs");
//#region src/fileRoute.ts
/**
* Creates a file-based Route factory for a given path.
*
* Used by TanStack Router's file-based routing to associate a file with a
* route. The returned function accepts standard route options. In normal usage
* the `path` string is inserted and maintained by the `tsr` generator.
*
* @param path File path literal for the route (usually auto-generated).
* @returns A function that accepts Route options and returns a Route instance.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
*/
function createFileRoute(path) {
return (options) => {
const route = require_route.createRoute(options);
route.isRoot = false;
return route;
};
}
/**
@deprecated It's no longer recommended to use the `FileRoute` class directly.
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
*/
var FileRoute = class {
constructor(path, _opts) {
this.path = path;
this.createRoute = (options) => {
if (process.env.NODE_ENV !== "production") {
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.");
}
const route = require_route.createRoute(options);
route.isRoot = false;
return route;
};
this.silent = _opts?.silent;
}
};
/**
@deprecated It's recommended not to split loaders into separate files.
Instead, place the loader function in the main route file via `createFileRoute`.
*/
function FileRouteLoader(_path) {
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 main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`);
return (loaderFn) => loaderFn;
}
var LazyRoute = class {
constructor(opts) {
this.useMatch = (opts) => {
return require_useMatch.useMatch({
select: opts?.select,
from: this.options.id,
structuralSharing: opts?.structuralSharing
});
};
this.useRouteContext = (opts) => {
return require_useRouteContext.useRouteContext({
...opts,
from: this.options.id
});
};
this.useSearch = (opts) => {
return require_useSearch.useSearch({
select: opts?.select,
structuralSharing: opts?.structuralSharing,
from: this.options.id
});
};
this.useParams = (opts) => {
return require_useParams.useParams({
select: opts?.select,
structuralSharing: opts?.structuralSharing,
from: this.options.id
});
};
this.useLoaderDeps = (opts) => {
return require_useLoaderDeps.useLoaderDeps({
...opts,
from: this.options.id
});
};
this.useLoaderData = (opts) => {
return require_useLoaderData.useLoaderData({
...opts,
from: this.options.id
});
};
this.useNavigate = () => {
return require_useNavigate.useNavigate({ from: require_useRouter.useRouter().routesById[this.options.id].fullPath });
};
this.options = opts;
}
};
/**
* Creates a lazily-configurable code-based route stub by ID.
*
* Use this for code-splitting with code-based routes. The returned function
* accepts only non-critical route options like `component`, `pendingComponent`,
* `errorComponent`, and `notFoundComponent` which are applied when the route
* is matched.
*
* @param id Route ID string literal to associate with the lazy route.
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
*/
function createLazyRoute(id) {
return (opts) => {
return new LazyRoute({
id,
...opts
});
};
}
/**
* Creates a lazily-configurable file-based route stub by file path.
*
* Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).
* The returned function accepts only non-critical route options like
* `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.
*
* @param id File path literal for the route file.
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
*/
function createLazyFileRoute(id) {
if (typeof id === "object") return new LazyRoute(id);
return (opts) => new LazyRoute({
id,
...opts
});
}
//#endregion
exports.FileRoute = FileRoute;
exports.FileRouteLoader = FileRouteLoader;
exports.LazyRoute = LazyRoute;
exports.createFileRoute = createFileRoute;
exports.createLazyFileRoute = createLazyFileRoute;
exports.createLazyRoute = createLazyRoute;
//# sourceMappingURL=fileRoute.cjs.map
File diff suppressed because one or more lines are too long
+87
View File
@@ -0,0 +1,87 @@
import { UseParamsRoute } from './useParams.cjs';
import { UseMatchRoute } from './useMatch.cjs';
import { UseSearchRoute } from './useSearch.cjs';
import { AnyContext, AnyRoute, AnyRouter, Constrain, ConstrainLiteral, FileBaseRouteOptions, FileRoutesByPath, LazyRouteOptions, Register, RegisteredRouter, ResolveParams, Route, RouteById, RouteConstraints, RouteIds, RouteLoaderEntry, UpdatableRouteOptions, UseNavigateResult } from '@tanstack/router-core';
import { UseLoaderDepsRoute } from './useLoaderDeps.cjs';
import { UseLoaderDataRoute } from './useLoaderData.cjs';
import { UseRouteContextRoute } from './useRouteContext.cjs';
/**
* Creates a file-based Route factory for a given path.
*
* Used by TanStack Router's file-based routing to associate a file with a
* route. The returned function accepts standard route options. In normal usage
* the `path` string is inserted and maintained by the `tsr` generator.
*
* @param path File path literal for the route (usually auto-generated).
* @returns A function that accepts Route options and returns a Route instance.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
*/
export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath']>(path?: TFilePath): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'];
/**
@deprecated It's no longer recommended to use the `FileRoute` class directly.
Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
*/
export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'], TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'], TFullPath extends RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath']> {
path?: TFilePath | undefined;
silent?: boolean;
constructor(path?: TFilePath | undefined, _opts?: {
silent: boolean;
});
createRoute: <TRegister = Register, TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown, TSSR = unknown, const TMiddlewares = unknown, THandlers = undefined>(options?: FileBaseRouteOptions<TRegister, TParentRoute, TId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn, AnyContext, TSSR, TMiddlewares, THandlers> & UpdatableRouteOptions<TParentRoute, TId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, AnyContext, TRouteContextFn, TBeforeLoadFn>) => Route<TRegister, TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, unknown, TSSR, TMiddlewares, THandlers>;
}
/**
@deprecated It's recommended not to split loaders into separate files.
Instead, place the loader function in the main route file via `createFileRoute`.
*/
export declare function FileRouteLoader<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(_path: TFilePath): <TLoaderFn>(loaderFn: Constrain<TLoaderFn, RouteLoaderEntry<Register, TRoute['parentRoute'], TRoute['types']['id'], TRoute['types']['params'], TRoute['types']['loaderDeps'], TRoute['types']['routerContext'], TRoute['types']['routeContextFn'], TRoute['types']['beforeLoadFn']>>) => TLoaderFn;
declare module '@tanstack/router-core' {
interface LazyRoute<in out TRoute extends AnyRoute> {
useMatch: UseMatchRoute<TRoute['id']>;
useRouteContext: UseRouteContextRoute<TRoute['id']>;
useSearch: UseSearchRoute<TRoute['id']>;
useParams: UseParamsRoute<TRoute['id']>;
useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>;
useLoaderData: UseLoaderDataRoute<TRoute['id']>;
useNavigate: () => UseNavigateResult<TRoute['fullPath']>;
}
}
export declare class LazyRoute<TRoute extends AnyRoute> {
options: {
id: string;
} & LazyRouteOptions;
constructor(opts: {
id: string;
} & LazyRouteOptions);
useMatch: UseMatchRoute<TRoute['id']>;
useRouteContext: UseRouteContextRoute<TRoute['id']>;
useSearch: UseSearchRoute<TRoute['id']>;
useParams: UseParamsRoute<TRoute['id']>;
useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>;
useLoaderData: UseLoaderDataRoute<TRoute['id']>;
useNavigate: () => UseNavigateResult<TRoute["fullPath"]>;
}
/**
* Creates a lazily-configurable code-based route stub by ID.
*
* Use this for code-splitting with code-based routes. The returned function
* accepts only non-critical route options like `component`, `pendingComponent`,
* `errorComponent`, and `notFoundComponent` which are applied when the route
* is matched.
*
* @param id Route ID string literal to associate with the lazy route.
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
*/
export declare function createLazyRoute<TRouter extends AnyRouter = RegisteredRouter, TId extends string = string, TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
/**
* Creates a lazily-configurable file-based route stub by file path.
*
* Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).
* The returned function accepts only non-critical route options like
* `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.
*
* @param id File path literal for the route file.
* @returns A function that accepts lazy route options and returns a `LazyRoute`.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
*/
export declare function createLazyFileRoute<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute>;
@@ -0,0 +1,146 @@
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_useRouter = require("./useRouter.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let _tanstack_react_store = require("@tanstack/react-store");
//#region src/headContentUtils.tsx
function buildTagsFromMatches(router, nonce, matches, assetCrossOrigin) {
matches = (0, _tanstack_router_core._getAssetMatches)(matches);
const routeMeta = matches.map((match) => match.meta).filter((meta) => meta !== void 0);
const resultMeta = [];
const metaByAttribute = {};
let title;
for (let i = routeMeta.length - 1; i >= 0; i--) {
const metas = routeMeta[i];
for (let j = metas.length - 1; j >= 0; j--) {
const m = metas[j];
if (!m) continue;
if (m.title) {
if (!title) title = {
tag: "title",
children: m.title
};
} else if ("script:ld+json" in m) try {
const json = JSON.stringify(m["script:ld+json"]);
resultMeta.push({
tag: "script",
attrs: { type: "application/ld+json" },
children: (0, _tanstack_router_core.escapeHtml)(json)
});
} catch {}
else {
const attribute = m.name ?? m.property;
if (attribute) if (metaByAttribute[attribute]) continue;
else metaByAttribute[attribute] = true;
resultMeta.push({
tag: "meta",
attrs: {
...m,
nonce
}
});
}
}
}
if (title) resultMeta.push(title);
if (nonce) resultMeta.push({
tag: "meta",
attrs: {
property: "csp-nonce",
content: nonce
}
});
resultMeta.reverse();
const constructedLinks = matches.flatMap((match) => match.links ?? []).filter((link) => link !== void 0).map((link) => ({
tag: "link",
attrs: {
...link,
nonce
}
}));
const manifest = router.ssr?.manifest;
const manifestCssTags = [];
if (manifest) {
matches.forEach((match) => {
(manifest.routes[match.routeId]?.css)?.forEach((link) => {
const resolvedLink = (0, _tanstack_router_core.resolveManifestCssLink)(link);
manifestCssTags.push({
tag: "link",
attrs: {
rel: "stylesheet",
...resolvedLink,
crossOrigin: (0, _tanstack_router_core.getAssetCrossOrigin)(assetCrossOrigin, "stylesheet") ?? resolvedLink.crossOrigin,
suppressHydrationWarning: true,
nonce
}
});
});
});
if (manifest.inlineStyle) manifestCssTags.push({
tag: "style",
attrs: {
...manifest.inlineStyle.attrs,
nonce
},
children: manifest.inlineStyle.children,
inlineCss: true
});
}
const preloadLinks = [];
if (manifest) matches.forEach((match) => {
manifest.routes[match.routeId]?.preloads?.forEach((preload) => {
preloadLinks.push({
tag: "link",
attrs: {
...(0, _tanstack_router_core.getScriptPreloadAttrs)(manifest, preload, assetCrossOrigin),
nonce
}
});
});
});
const styles = matches.flatMap((match) => match.styles ?? []).filter((style) => style !== void 0).map(({ children, ...attrs }) => ({
tag: "style",
attrs: {
...attrs,
nonce
},
children
}));
const headScripts = matches.flatMap((match) => match.headScripts ?? []).filter((script) => script !== void 0).map(({ children, ...script }) => ({
tag: "script",
attrs: {
...script,
nonce
},
children
}));
const tags = [];
(0, _tanstack_router_core.appendUniqueUserTags)(tags, resultMeta);
tags.push(...preloadLinks);
(0, _tanstack_router_core.appendUniqueUserTags)(tags, constructedLinks);
tags.push(...manifestCssTags);
(0, _tanstack_router_core.appendUniqueUserTags)(tags, styles);
(0, _tanstack_router_core.appendUniqueUserTags)(tags, headScripts);
return tags;
}
/**
* Build the head/link/meta/script tags from the renderable presented prefix.
* Used internally by `HeadContent`.
*/
var useTags = (assetCrossOrigin) => {
const router = require_useRouter.useRouter();
const nonce = router.options.ssr?.nonce;
if (_tanstack_router_core_isServer.isServer ?? router.isServer) return buildTagsFromMatches(router, nonce, router.stores.matches.get(), assetCrossOrigin);
const selectTags = react.useCallback((matches) => buildTagsFromMatches(router, nonce, matches, assetCrossOrigin), [
assetCrossOrigin,
nonce,
router
]);
return (0, _tanstack_react_store.useStore)(router.stores.matches, selectTags, _tanstack_router_core.deepEqual);
};
//#endregion
exports.useTags = useTags;
//# sourceMappingURL=headContentUtils.cjs.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,6 @@
import { AssetCrossOriginConfig, RouterManagedTag } from '@tanstack/router-core';
/**
* Build the head/link/meta/script tags from the renderable presented prefix.
* Used internally by `HeadContent`.
*/
export declare const useTags: (assetCrossOrigin?: AssetCrossOriginConfig) => RouterManagedTag[];
+8
View File
@@ -0,0 +1,8 @@
declare module '@tanstack/history' {
interface HistoryState {
__tempLocation?: HistoryLocation;
__tempKey?: string;
__hashScrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
}
}
export {};
+315
View File
@@ -0,0 +1,315 @@
"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_utils = require("./utils.cjs");
const require_awaited = require("./awaited.cjs");
const require_CatchBoundary = require("./CatchBoundary.cjs");
const require_ClientOnly = require("./ClientOnly.cjs");
const require_useRouter = require("./useRouter.cjs");
const require_useMatch = require("./useMatch.cjs");
const require_useLoaderData = require("./useLoaderData.cjs");
const require_useLoaderDeps = require("./useLoaderDeps.cjs");
const require_useParams = require("./useParams.cjs");
const require_useSearch = require("./useSearch.cjs");
const require_useNavigate = require("./useNavigate.cjs");
const require_useRouteContext = require("./useRouteContext.cjs");
const require_link = require("./link.cjs");
const require_route = require("./route.cjs");
const require_fileRoute = require("./fileRoute.cjs");
const require_lazyRouteComponent = require("./lazyRouteComponent.cjs");
const require_not_found = require("./not-found.cjs");
const require_ScriptOnce = require("./ScriptOnce.cjs");
const require_Match = require("./Match.cjs");
const require_Matches = require("./Matches.cjs");
const require_router = require("./router.cjs");
const require_RouterProvider = require("./RouterProvider.cjs");
const require_ScrollRestoration = require("./ScrollRestoration.cjs");
const require_useBlocker = require("./useBlocker.cjs");
const require_useRouterState = require("./useRouterState.cjs");
const require_useLocation = require("./useLocation.cjs");
const require_useCanGoBack = require("./useCanGoBack.cjs");
const require_Asset = require("./Asset.cjs");
const require_headContentUtils = require("./headContentUtils.cjs");
const require_HeadContent = require("./HeadContent.cjs");
const require_Scripts = require("./Scripts.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let _tanstack_history = require("@tanstack/history");
exports.Asset = require_Asset.Asset;
exports.Await = require_awaited.Await;
exports.Block = require_useBlocker.Block;
exports.CatchBoundary = require_CatchBoundary.CatchBoundary;
exports.CatchNotFound = require_not_found.CatchNotFound;
exports.ClientOnly = require_ClientOnly.ClientOnly;
Object.defineProperty(exports, "DEFAULT_PROTOCOL_ALLOWLIST", {
enumerable: true,
get: function() {
return _tanstack_router_core.DEFAULT_PROTOCOL_ALLOWLIST;
}
});
exports.DefaultGlobalNotFound = require_not_found.DefaultGlobalNotFound;
exports.ErrorComponent = require_CatchBoundary.ErrorComponent;
exports.FileRoute = require_fileRoute.FileRoute;
exports.FileRouteLoader = require_fileRoute.FileRouteLoader;
exports.HeadContent = require_HeadContent.HeadContent;
exports.LazyRoute = require_fileRoute.LazyRoute;
exports.Link = require_link.Link;
exports.Match = require_Match.Match;
exports.MatchRoute = require_Matches.MatchRoute;
exports.Matches = require_Matches.Matches;
exports.Navigate = require_useNavigate.Navigate;
exports.NotFoundRoute = require_route.NotFoundRoute;
exports.Outlet = require_Match.Outlet;
exports.RootRoute = require_route.RootRoute;
exports.Route = require_route.Route;
exports.RouteApi = require_route.RouteApi;
exports.Router = require_router.Router;
exports.RouterContextProvider = require_RouterProvider.RouterContextProvider;
exports.RouterProvider = require_RouterProvider.RouterProvider;
exports.ScriptOnce = require_ScriptOnce.ScriptOnce;
exports.Scripts = require_Scripts.Scripts;
exports.ScrollRestoration = require_ScrollRestoration.ScrollRestoration;
Object.defineProperty(exports, "SearchParamError", {
enumerable: true,
get: function() {
return _tanstack_router_core.SearchParamError;
}
});
Object.defineProperty(exports, "cleanPath", {
enumerable: true,
get: function() {
return _tanstack_router_core.cleanPath;
}
});
Object.defineProperty(exports, "composeRewrites", {
enumerable: true,
get: function() {
return _tanstack_router_core.composeRewrites;
}
});
Object.defineProperty(exports, "createBrowserHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createBrowserHistory;
}
});
Object.defineProperty(exports, "createControlledPromise", {
enumerable: true,
get: function() {
return _tanstack_router_core.createControlledPromise;
}
});
exports.createFileRoute = require_fileRoute.createFileRoute;
Object.defineProperty(exports, "createHashHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createHashHistory;
}
});
Object.defineProperty(exports, "createHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createHistory;
}
});
exports.createLazyFileRoute = require_fileRoute.createLazyFileRoute;
exports.createLazyRoute = require_fileRoute.createLazyRoute;
exports.createLink = require_link.createLink;
Object.defineProperty(exports, "createMemoryHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createMemoryHistory;
}
});
exports.createRootRoute = require_route.createRootRoute;
exports.createRootRouteWithContext = require_route.createRootRouteWithContext;
exports.createRoute = require_route.createRoute;
exports.createRouteMask = require_route.createRouteMask;
exports.createRouter = require_router.createRouter;
Object.defineProperty(exports, "createRouterConfig", {
enumerable: true,
get: function() {
return _tanstack_router_core.createRouterConfig;
}
});
Object.defineProperty(exports, "createSerializationAdapter", {
enumerable: true,
get: function() {
return _tanstack_router_core.createSerializationAdapter;
}
});
Object.defineProperty(exports, "deepEqual", {
enumerable: true,
get: function() {
return _tanstack_router_core.deepEqual;
}
});
Object.defineProperty(exports, "defaultParseSearch", {
enumerable: true,
get: function() {
return _tanstack_router_core.defaultParseSearch;
}
});
Object.defineProperty(exports, "defaultStringifySearch", {
enumerable: true,
get: function() {
return _tanstack_router_core.defaultStringifySearch;
}
});
Object.defineProperty(exports, "defer", {
enumerable: true,
get: function() {
return _tanstack_router_core.defer;
}
});
Object.defineProperty(exports, "functionalUpdate", {
enumerable: true,
get: function() {
return _tanstack_router_core.functionalUpdate;
}
});
exports.getRouteApi = require_route.getRouteApi;
Object.defineProperty(exports, "interpolatePath", {
enumerable: true,
get: function() {
return _tanstack_router_core.interpolatePath;
}
});
Object.defineProperty(exports, "isMatch", {
enumerable: true,
get: function() {
return _tanstack_router_core.isMatch;
}
});
Object.defineProperty(exports, "isNotFound", {
enumerable: true,
get: function() {
return _tanstack_router_core.isNotFound;
}
});
Object.defineProperty(exports, "isPlainArray", {
enumerable: true,
get: function() {
return _tanstack_router_core.isPlainArray;
}
});
Object.defineProperty(exports, "isPlainObject", {
enumerable: true,
get: function() {
return _tanstack_router_core.isPlainObject;
}
});
Object.defineProperty(exports, "isRedirect", {
enumerable: true,
get: function() {
return _tanstack_router_core.isRedirect;
}
});
Object.defineProperty(exports, "joinPaths", {
enumerable: true,
get: function() {
return _tanstack_router_core.joinPaths;
}
});
Object.defineProperty(exports, "lazyFn", {
enumerable: true,
get: function() {
return _tanstack_router_core.lazyFn;
}
});
exports.lazyRouteComponent = require_lazyRouteComponent.lazyRouteComponent;
exports.linkOptions = require_link.linkOptions;
Object.defineProperty(exports, "notFound", {
enumerable: true,
get: function() {
return _tanstack_router_core.notFound;
}
});
Object.defineProperty(exports, "parseSearchWith", {
enumerable: true,
get: function() {
return _tanstack_router_core.parseSearchWith;
}
});
exports.reactUse = require_utils.reactUse;
Object.defineProperty(exports, "redirect", {
enumerable: true,
get: function() {
return _tanstack_router_core.redirect;
}
});
Object.defineProperty(exports, "replaceEqualDeep", {
enumerable: true,
get: function() {
return _tanstack_router_core.replaceEqualDeep;
}
});
Object.defineProperty(exports, "resolvePath", {
enumerable: true,
get: function() {
return _tanstack_router_core.resolvePath;
}
});
Object.defineProperty(exports, "retainSearchParams", {
enumerable: true,
get: function() {
return _tanstack_router_core.retainSearchParams;
}
});
Object.defineProperty(exports, "rootRouteId", {
enumerable: true,
get: function() {
return _tanstack_router_core.rootRouteId;
}
});
exports.rootRouteWithContext = require_route.rootRouteWithContext;
Object.defineProperty(exports, "stringifySearchWith", {
enumerable: true,
get: function() {
return _tanstack_router_core.stringifySearchWith;
}
});
Object.defineProperty(exports, "stripSearchParams", {
enumerable: true,
get: function() {
return _tanstack_router_core.stripSearchParams;
}
});
Object.defineProperty(exports, "trimPath", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPath;
}
});
Object.defineProperty(exports, "trimPathLeft", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPathLeft;
}
});
Object.defineProperty(exports, "trimPathRight", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPathRight;
}
});
exports.useAwaited = require_awaited.useAwaited;
exports.useBlocker = require_useBlocker.useBlocker;
exports.useCanGoBack = require_useCanGoBack.useCanGoBack;
exports.useChildMatches = require_Matches.useChildMatches;
exports.useElementScrollRestoration = require_ScrollRestoration.useElementScrollRestoration;
exports.useHydrated = require_ClientOnly.useHydrated;
exports.useLayoutEffect = require_utils.useLayoutEffect;
exports.useLinkProps = require_link.useLinkProps;
exports.useLoaderData = require_useLoaderData.useLoaderData;
exports.useLoaderDeps = require_useLoaderDeps.useLoaderDeps;
exports.useLocation = require_useLocation.useLocation;
exports.useMatch = require_useMatch.useMatch;
exports.useMatchRoute = require_Matches.useMatchRoute;
exports.useMatches = require_Matches.useMatches;
exports.useNavigate = require_useNavigate.useNavigate;
exports.useParams = require_useParams.useParams;
exports.useParentMatches = require_Matches.useParentMatches;
exports.useRouteContext = require_useRouteContext.useRouteContext;
exports.useRouter = require_useRouter.useRouter;
exports.useRouterState = require_useRouterState.useRouterState;
exports.useSearch = require_useSearch.useSearch;
exports.useTags = require_headContentUtils.useTags;
+52
View File
@@ -0,0 +1,52 @@
export { defer, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
export type { AnyRoute, DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, SearchMiddleware, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, Register, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, FileRoutesByPath, RouteById, RootRouteOptions, CreateFileRoute, SerializationAdapter, AnySerializationAdapter, SerializableExtensions, } from '@tanstack/router-core';
export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
export { useAwaited, Await } from './awaited.cjs';
export type { AwaitOptions } from './awaited.cjs';
export { CatchBoundary, ErrorComponent } from './CatchBoundary.cjs';
export { ClientOnly, useHydrated } from './ClientOnly.cjs';
export { reactUse, useLayoutEffect } from './utils.cjs';
export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, } from './fileRoute.cjs';
export * from './history.cjs';
export { lazyRouteComponent } from './lazyRouteComponent.cjs';
export { useLinkProps, createLink, Link, linkOptions } from './link.cjs';
export type { InferDescendantToPaths, RelativeToPath, RelativeToParentPath, RelativeToCurrentPath, AbsoluteToPath, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, LinkOptions, MakeOptionalPathParams, FileRouteTypes, RouteContextParameter, BeforeLoadContextParameter, ResolveAllContext, ResolveAllParamsFromParent, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, RouteIds, NavigateFn, BuildLocationFn, FullSearchSchemaOption, MakeRemountDepsOptionsUnion, RemountDepsOptions, ResolveFullPath, AnyRouteWithContext, AnyRouterWithContext, CommitLocationOptions, MatchLocation, UseNavigateResult, AnyRedirect, Redirect, RedirectOptions, ResolvedRedirect, MakeRouteMatch, MakeRouteMatchUnion, RouteMatch, AnyRouteMatch, RouteContextFn, RouteContextOptions, BeforeLoadContextOptions, ContextOptions, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, LazyRouteOptions, AnyRouter, RegisteredRouter, RouterContextOptions, ControllablePromise, InjectedHtmlEntry, RouterOptions, RouterState, ListenerFn, BuildNextOptions, RouterConstructorOptions, RouterEvents, RouterEvent, RouterListener, RouteConstraints, RouteMask, MatchRouteOptions, CreateLazyFileRoute, } from '@tanstack/router-core';
export type { UseLinkPropsOptions, ActiveLinkOptions, LinkProps, LinkComponent, LinkComponentProps, CreateLinkProps, } from './link.cjs';
export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches.cjs';
export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches.cjs';
export { Match, Outlet } from './Match.cjs';
export { useMatch } from './useMatch.cjs';
export { useLoaderDeps } from './useLoaderDeps.cjs';
export { useLoaderData } from './useLoaderData.cjs';
export { redirect, isRedirect, createRouterConfig, DEFAULT_PROTOCOL_ALLOWLIST, } from '@tanstack/router-core';
export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.cjs';
export type { AnyRootRoute, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, DefaultRouteTypes, RouteTypes, } from './route.cjs';
export { createRouter, Router } from './router.cjs';
export { lazyFn, SearchParamError } from '@tanstack/router-core';
export { RouterProvider, RouterContextProvider } from './RouterProvider.cjs';
export type { RouterProps } from './RouterProvider.cjs';
export { useElementScrollRestoration, ScrollRestoration, } from './ScrollRestoration.cjs';
export type { UseBlockerOpts, ShouldBlockFn } from './useBlocker.cjs';
export { useBlocker, Block } from './useBlocker.cjs';
export { useNavigate, Navigate } from './useNavigate.cjs';
export { useParams } from './useParams.cjs';
export { useSearch } from './useSearch.cjs';
export { useRouteContext } from './useRouteContext.cjs';
export { useRouter } from './useRouter.cjs';
export { useRouterState } from './useRouterState.cjs';
export { useLocation } from './useLocation.cjs';
export { useCanGoBack } from './useCanGoBack.cjs';
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.cjs';
export { notFound, isNotFound } from '@tanstack/router-core';
export type { NotFoundError } from '@tanstack/router-core';
export type { ValidateLinkOptions, InferStructuralSharing, ValidateUseSearchOptions, ValidateUseParamsOptions, ValidateLinkOptionsArray, } from './typePrimitives.cjs';
export type { ValidateFromPath, ValidateToPath, ValidateSearch, ValidateParams, InferFrom, InferTo, InferMaskTo, InferMaskFrom, ValidateNavigateOptions, ValidateNavigateOptionsArray, ValidateRedirectOptions, ValidateRedirectOptionsArray, ValidateId, InferStrict, InferShouldThrow, InferSelected, ValidateUseSearchResult, ValidateUseParamsResult, SerializerExtensions, RegisteredSerializableInput, Serializable, } from '@tanstack/router-core';
export { ScriptOnce } from './ScriptOnce.cjs';
export { Asset } from './Asset.cjs';
export { HeadContent } from './HeadContent.cjs';
export { useTags } from './headContentUtils.cjs';
export { Scripts } from './Scripts.cjs';
export type * from './ssr/serializer.cjs';
export { composeRewrites } from '@tanstack/router-core';
export type { LocationRewrite, LocationRewriteFunction, } from '@tanstack/router-core';
+315
View File
@@ -0,0 +1,315 @@
"use client";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_utils = require("./utils.cjs");
const require_awaited = require("./awaited.cjs");
const require_CatchBoundary = require("./CatchBoundary.cjs");
const require_ClientOnly = require("./ClientOnly.cjs");
const require_useRouter = require("./useRouter.cjs");
const require_useMatch = require("./useMatch.cjs");
const require_useLoaderData = require("./useLoaderData.cjs");
const require_useLoaderDeps = require("./useLoaderDeps.cjs");
const require_useParams = require("./useParams.cjs");
const require_useSearch = require("./useSearch.cjs");
const require_useNavigate = require("./useNavigate.cjs");
const require_useRouteContext = require("./useRouteContext.cjs");
const require_link = require("./link.cjs");
const require_route = require("./route.cjs");
const require_fileRoute = require("./fileRoute.cjs");
const require_lazyRouteComponent = require("./lazyRouteComponent.cjs");
const require_not_found = require("./not-found.cjs");
const require_ScriptOnce = require("./ScriptOnce.cjs");
const require_Match = require("./Match.cjs");
const require_Matches = require("./Matches.cjs");
const require_router = require("./router.cjs");
const require_RouterProvider = require("./RouterProvider.cjs");
const require_ScrollRestoration = require("./ScrollRestoration.cjs");
const require_useBlocker = require("./useBlocker.cjs");
const require_useRouterState = require("./useRouterState.cjs");
const require_useLocation = require("./useLocation.cjs");
const require_useCanGoBack = require("./useCanGoBack.cjs");
const require_Asset = require("./Asset.cjs");
const require_headContentUtils = require("./headContentUtils.cjs");
const require_Scripts = require("./Scripts.cjs");
const require_HeadContent_dev = require("./HeadContent.dev.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let _tanstack_history = require("@tanstack/history");
exports.Asset = require_Asset.Asset;
exports.Await = require_awaited.Await;
exports.Block = require_useBlocker.Block;
exports.CatchBoundary = require_CatchBoundary.CatchBoundary;
exports.CatchNotFound = require_not_found.CatchNotFound;
exports.ClientOnly = require_ClientOnly.ClientOnly;
Object.defineProperty(exports, "DEFAULT_PROTOCOL_ALLOWLIST", {
enumerable: true,
get: function() {
return _tanstack_router_core.DEFAULT_PROTOCOL_ALLOWLIST;
}
});
exports.DefaultGlobalNotFound = require_not_found.DefaultGlobalNotFound;
exports.ErrorComponent = require_CatchBoundary.ErrorComponent;
exports.FileRoute = require_fileRoute.FileRoute;
exports.FileRouteLoader = require_fileRoute.FileRouteLoader;
exports.HeadContent = require_HeadContent_dev.HeadContent;
exports.LazyRoute = require_fileRoute.LazyRoute;
exports.Link = require_link.Link;
exports.Match = require_Match.Match;
exports.MatchRoute = require_Matches.MatchRoute;
exports.Matches = require_Matches.Matches;
exports.Navigate = require_useNavigate.Navigate;
exports.NotFoundRoute = require_route.NotFoundRoute;
exports.Outlet = require_Match.Outlet;
exports.RootRoute = require_route.RootRoute;
exports.Route = require_route.Route;
exports.RouteApi = require_route.RouteApi;
exports.Router = require_router.Router;
exports.RouterContextProvider = require_RouterProvider.RouterContextProvider;
exports.RouterProvider = require_RouterProvider.RouterProvider;
exports.ScriptOnce = require_ScriptOnce.ScriptOnce;
exports.Scripts = require_Scripts.Scripts;
exports.ScrollRestoration = require_ScrollRestoration.ScrollRestoration;
Object.defineProperty(exports, "SearchParamError", {
enumerable: true,
get: function() {
return _tanstack_router_core.SearchParamError;
}
});
Object.defineProperty(exports, "cleanPath", {
enumerable: true,
get: function() {
return _tanstack_router_core.cleanPath;
}
});
Object.defineProperty(exports, "composeRewrites", {
enumerable: true,
get: function() {
return _tanstack_router_core.composeRewrites;
}
});
Object.defineProperty(exports, "createBrowserHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createBrowserHistory;
}
});
Object.defineProperty(exports, "createControlledPromise", {
enumerable: true,
get: function() {
return _tanstack_router_core.createControlledPromise;
}
});
exports.createFileRoute = require_fileRoute.createFileRoute;
Object.defineProperty(exports, "createHashHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createHashHistory;
}
});
Object.defineProperty(exports, "createHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createHistory;
}
});
exports.createLazyFileRoute = require_fileRoute.createLazyFileRoute;
exports.createLazyRoute = require_fileRoute.createLazyRoute;
exports.createLink = require_link.createLink;
Object.defineProperty(exports, "createMemoryHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createMemoryHistory;
}
});
exports.createRootRoute = require_route.createRootRoute;
exports.createRootRouteWithContext = require_route.createRootRouteWithContext;
exports.createRoute = require_route.createRoute;
exports.createRouteMask = require_route.createRouteMask;
exports.createRouter = require_router.createRouter;
Object.defineProperty(exports, "createRouterConfig", {
enumerable: true,
get: function() {
return _tanstack_router_core.createRouterConfig;
}
});
Object.defineProperty(exports, "createSerializationAdapter", {
enumerable: true,
get: function() {
return _tanstack_router_core.createSerializationAdapter;
}
});
Object.defineProperty(exports, "deepEqual", {
enumerable: true,
get: function() {
return _tanstack_router_core.deepEqual;
}
});
Object.defineProperty(exports, "defaultParseSearch", {
enumerable: true,
get: function() {
return _tanstack_router_core.defaultParseSearch;
}
});
Object.defineProperty(exports, "defaultStringifySearch", {
enumerable: true,
get: function() {
return _tanstack_router_core.defaultStringifySearch;
}
});
Object.defineProperty(exports, "defer", {
enumerable: true,
get: function() {
return _tanstack_router_core.defer;
}
});
Object.defineProperty(exports, "functionalUpdate", {
enumerable: true,
get: function() {
return _tanstack_router_core.functionalUpdate;
}
});
exports.getRouteApi = require_route.getRouteApi;
Object.defineProperty(exports, "interpolatePath", {
enumerable: true,
get: function() {
return _tanstack_router_core.interpolatePath;
}
});
Object.defineProperty(exports, "isMatch", {
enumerable: true,
get: function() {
return _tanstack_router_core.isMatch;
}
});
Object.defineProperty(exports, "isNotFound", {
enumerable: true,
get: function() {
return _tanstack_router_core.isNotFound;
}
});
Object.defineProperty(exports, "isPlainArray", {
enumerable: true,
get: function() {
return _tanstack_router_core.isPlainArray;
}
});
Object.defineProperty(exports, "isPlainObject", {
enumerable: true,
get: function() {
return _tanstack_router_core.isPlainObject;
}
});
Object.defineProperty(exports, "isRedirect", {
enumerable: true,
get: function() {
return _tanstack_router_core.isRedirect;
}
});
Object.defineProperty(exports, "joinPaths", {
enumerable: true,
get: function() {
return _tanstack_router_core.joinPaths;
}
});
Object.defineProperty(exports, "lazyFn", {
enumerable: true,
get: function() {
return _tanstack_router_core.lazyFn;
}
});
exports.lazyRouteComponent = require_lazyRouteComponent.lazyRouteComponent;
exports.linkOptions = require_link.linkOptions;
Object.defineProperty(exports, "notFound", {
enumerable: true,
get: function() {
return _tanstack_router_core.notFound;
}
});
Object.defineProperty(exports, "parseSearchWith", {
enumerable: true,
get: function() {
return _tanstack_router_core.parseSearchWith;
}
});
exports.reactUse = require_utils.reactUse;
Object.defineProperty(exports, "redirect", {
enumerable: true,
get: function() {
return _tanstack_router_core.redirect;
}
});
Object.defineProperty(exports, "replaceEqualDeep", {
enumerable: true,
get: function() {
return _tanstack_router_core.replaceEqualDeep;
}
});
Object.defineProperty(exports, "resolvePath", {
enumerable: true,
get: function() {
return _tanstack_router_core.resolvePath;
}
});
Object.defineProperty(exports, "retainSearchParams", {
enumerable: true,
get: function() {
return _tanstack_router_core.retainSearchParams;
}
});
Object.defineProperty(exports, "rootRouteId", {
enumerable: true,
get: function() {
return _tanstack_router_core.rootRouteId;
}
});
exports.rootRouteWithContext = require_route.rootRouteWithContext;
Object.defineProperty(exports, "stringifySearchWith", {
enumerable: true,
get: function() {
return _tanstack_router_core.stringifySearchWith;
}
});
Object.defineProperty(exports, "stripSearchParams", {
enumerable: true,
get: function() {
return _tanstack_router_core.stripSearchParams;
}
});
Object.defineProperty(exports, "trimPath", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPath;
}
});
Object.defineProperty(exports, "trimPathLeft", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPathLeft;
}
});
Object.defineProperty(exports, "trimPathRight", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPathRight;
}
});
exports.useAwaited = require_awaited.useAwaited;
exports.useBlocker = require_useBlocker.useBlocker;
exports.useCanGoBack = require_useCanGoBack.useCanGoBack;
exports.useChildMatches = require_Matches.useChildMatches;
exports.useElementScrollRestoration = require_ScrollRestoration.useElementScrollRestoration;
exports.useHydrated = require_ClientOnly.useHydrated;
exports.useLayoutEffect = require_utils.useLayoutEffect;
exports.useLinkProps = require_link.useLinkProps;
exports.useLoaderData = require_useLoaderData.useLoaderData;
exports.useLoaderDeps = require_useLoaderDeps.useLoaderDeps;
exports.useLocation = require_useLocation.useLocation;
exports.useMatch = require_useMatch.useMatch;
exports.useMatchRoute = require_Matches.useMatchRoute;
exports.useMatches = require_Matches.useMatches;
exports.useNavigate = require_useNavigate.useNavigate;
exports.useParams = require_useParams.useParams;
exports.useParentMatches = require_Matches.useParentMatches;
exports.useRouteContext = require_useRouteContext.useRouteContext;
exports.useRouter = require_useRouter.useRouter;
exports.useRouterState = require_useRouterState.useRouterState;
exports.useSearch = require_useSearch.useSearch;
exports.useTags = require_headContentUtils.useTags;
@@ -0,0 +1,2 @@
export * from './index.cjs';
export { HeadContent } from './HeadContent.dev';
+314
View File
@@ -0,0 +1,314 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_utils = require("./utils.cjs");
const require_awaited = require("./awaited.cjs");
const require_CatchBoundary = require("./CatchBoundary.cjs");
const require_ClientOnly = require("./ClientOnly.cjs");
const require_useRouter = require("./useRouter.cjs");
const require_useMatch = require("./useMatch.cjs");
const require_useLoaderData = require("./useLoaderData.cjs");
const require_useLoaderDeps = require("./useLoaderDeps.cjs");
const require_useParams = require("./useParams.cjs");
const require_useSearch = require("./useSearch.cjs");
const require_useNavigate = require("./useNavigate.cjs");
const require_useRouteContext = require("./useRouteContext.cjs");
const require_link = require("./link.cjs");
const require_route = require("./route.cjs");
const require_fileRoute = require("./fileRoute.cjs");
const require_lazyRouteComponent = require("./lazyRouteComponent.cjs");
const require_not_found = require("./not-found.cjs");
const require_ScriptOnce = require("./ScriptOnce.cjs");
const require_Match = require("./Match.cjs");
const require_Matches = require("./Matches.cjs");
const require_router = require("./router.cjs");
const require_RouterProvider = require("./RouterProvider.cjs");
const require_ScrollRestoration = require("./ScrollRestoration.cjs");
const require_useBlocker = require("./useBlocker.cjs");
const require_useRouterState = require("./useRouterState.cjs");
const require_useLocation = require("./useLocation.cjs");
const require_useCanGoBack = require("./useCanGoBack.cjs");
const require_Asset = require("./Asset.cjs");
const require_headContentUtils = require("./headContentUtils.cjs");
const require_HeadContent = require("./HeadContent.cjs");
const require_Scripts = require("./Scripts.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let _tanstack_history = require("@tanstack/history");
exports.Asset = require_Asset.Asset;
exports.Await = require_awaited.Await;
exports.Block = require_useBlocker.Block;
exports.CatchBoundary = require_CatchBoundary.CatchBoundary;
exports.CatchNotFound = require_not_found.CatchNotFound;
exports.ClientOnly = require_ClientOnly.ClientOnly;
Object.defineProperty(exports, "DEFAULT_PROTOCOL_ALLOWLIST", {
enumerable: true,
get: function() {
return _tanstack_router_core.DEFAULT_PROTOCOL_ALLOWLIST;
}
});
exports.DefaultGlobalNotFound = require_not_found.DefaultGlobalNotFound;
exports.ErrorComponent = require_CatchBoundary.ErrorComponent;
exports.FileRoute = require_fileRoute.FileRoute;
exports.FileRouteLoader = require_fileRoute.FileRouteLoader;
exports.HeadContent = require_HeadContent.HeadContent;
exports.LazyRoute = require_fileRoute.LazyRoute;
exports.Link = require_link.Link;
exports.Match = require_Match.Match;
exports.MatchRoute = require_Matches.MatchRoute;
exports.Matches = require_Matches.Matches;
exports.Navigate = require_useNavigate.Navigate;
exports.NotFoundRoute = require_route.NotFoundRoute;
exports.Outlet = require_Match.Outlet;
exports.RootRoute = require_route.RootRoute;
exports.Route = require_route.Route;
exports.RouteApi = require_route.RouteApi;
exports.Router = require_router.Router;
exports.RouterContextProvider = require_RouterProvider.RouterContextProvider;
exports.RouterProvider = require_RouterProvider.RouterProvider;
exports.ScriptOnce = require_ScriptOnce.ScriptOnce;
exports.Scripts = require_Scripts.Scripts;
exports.ScrollRestoration = require_ScrollRestoration.ScrollRestoration;
Object.defineProperty(exports, "SearchParamError", {
enumerable: true,
get: function() {
return _tanstack_router_core.SearchParamError;
}
});
Object.defineProperty(exports, "cleanPath", {
enumerable: true,
get: function() {
return _tanstack_router_core.cleanPath;
}
});
Object.defineProperty(exports, "composeRewrites", {
enumerable: true,
get: function() {
return _tanstack_router_core.composeRewrites;
}
});
Object.defineProperty(exports, "createBrowserHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createBrowserHistory;
}
});
Object.defineProperty(exports, "createControlledPromise", {
enumerable: true,
get: function() {
return _tanstack_router_core.createControlledPromise;
}
});
exports.createFileRoute = require_fileRoute.createFileRoute;
Object.defineProperty(exports, "createHashHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createHashHistory;
}
});
Object.defineProperty(exports, "createHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createHistory;
}
});
exports.createLazyFileRoute = require_fileRoute.createLazyFileRoute;
exports.createLazyRoute = require_fileRoute.createLazyRoute;
exports.createLink = require_link.createLink;
Object.defineProperty(exports, "createMemoryHistory", {
enumerable: true,
get: function() {
return _tanstack_history.createMemoryHistory;
}
});
exports.createRootRoute = require_route.createRootRoute;
exports.createRootRouteWithContext = require_route.createRootRouteWithContext;
exports.createRoute = require_route.createRoute;
exports.createRouteMask = require_route.createRouteMask;
exports.createRouter = require_router.createRouter;
Object.defineProperty(exports, "createRouterConfig", {
enumerable: true,
get: function() {
return _tanstack_router_core.createRouterConfig;
}
});
Object.defineProperty(exports, "createSerializationAdapter", {
enumerable: true,
get: function() {
return _tanstack_router_core.createSerializationAdapter;
}
});
Object.defineProperty(exports, "deepEqual", {
enumerable: true,
get: function() {
return _tanstack_router_core.deepEqual;
}
});
Object.defineProperty(exports, "defaultParseSearch", {
enumerable: true,
get: function() {
return _tanstack_router_core.defaultParseSearch;
}
});
Object.defineProperty(exports, "defaultStringifySearch", {
enumerable: true,
get: function() {
return _tanstack_router_core.defaultStringifySearch;
}
});
Object.defineProperty(exports, "defer", {
enumerable: true,
get: function() {
return _tanstack_router_core.defer;
}
});
Object.defineProperty(exports, "functionalUpdate", {
enumerable: true,
get: function() {
return _tanstack_router_core.functionalUpdate;
}
});
exports.getRouteApi = require_route.getRouteApi;
Object.defineProperty(exports, "interpolatePath", {
enumerable: true,
get: function() {
return _tanstack_router_core.interpolatePath;
}
});
Object.defineProperty(exports, "isMatch", {
enumerable: true,
get: function() {
return _tanstack_router_core.isMatch;
}
});
Object.defineProperty(exports, "isNotFound", {
enumerable: true,
get: function() {
return _tanstack_router_core.isNotFound;
}
});
Object.defineProperty(exports, "isPlainArray", {
enumerable: true,
get: function() {
return _tanstack_router_core.isPlainArray;
}
});
Object.defineProperty(exports, "isPlainObject", {
enumerable: true,
get: function() {
return _tanstack_router_core.isPlainObject;
}
});
Object.defineProperty(exports, "isRedirect", {
enumerable: true,
get: function() {
return _tanstack_router_core.isRedirect;
}
});
Object.defineProperty(exports, "joinPaths", {
enumerable: true,
get: function() {
return _tanstack_router_core.joinPaths;
}
});
Object.defineProperty(exports, "lazyFn", {
enumerable: true,
get: function() {
return _tanstack_router_core.lazyFn;
}
});
exports.lazyRouteComponent = require_lazyRouteComponent.lazyRouteComponent;
exports.linkOptions = require_link.linkOptions;
Object.defineProperty(exports, "notFound", {
enumerable: true,
get: function() {
return _tanstack_router_core.notFound;
}
});
Object.defineProperty(exports, "parseSearchWith", {
enumerable: true,
get: function() {
return _tanstack_router_core.parseSearchWith;
}
});
exports.reactUse = require_utils.reactUse;
Object.defineProperty(exports, "redirect", {
enumerable: true,
get: function() {
return _tanstack_router_core.redirect;
}
});
Object.defineProperty(exports, "replaceEqualDeep", {
enumerable: true,
get: function() {
return _tanstack_router_core.replaceEqualDeep;
}
});
Object.defineProperty(exports, "resolvePath", {
enumerable: true,
get: function() {
return _tanstack_router_core.resolvePath;
}
});
Object.defineProperty(exports, "retainSearchParams", {
enumerable: true,
get: function() {
return _tanstack_router_core.retainSearchParams;
}
});
Object.defineProperty(exports, "rootRouteId", {
enumerable: true,
get: function() {
return _tanstack_router_core.rootRouteId;
}
});
exports.rootRouteWithContext = require_route.rootRouteWithContext;
Object.defineProperty(exports, "stringifySearchWith", {
enumerable: true,
get: function() {
return _tanstack_router_core.stringifySearchWith;
}
});
Object.defineProperty(exports, "stripSearchParams", {
enumerable: true,
get: function() {
return _tanstack_router_core.stripSearchParams;
}
});
Object.defineProperty(exports, "trimPath", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPath;
}
});
Object.defineProperty(exports, "trimPathLeft", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPathLeft;
}
});
Object.defineProperty(exports, "trimPathRight", {
enumerable: true,
get: function() {
return _tanstack_router_core.trimPathRight;
}
});
exports.useAwaited = require_awaited.useAwaited;
exports.useBlocker = require_useBlocker.useBlocker;
exports.useCanGoBack = require_useCanGoBack.useCanGoBack;
exports.useChildMatches = require_Matches.useChildMatches;
exports.useElementScrollRestoration = require_ScrollRestoration.useElementScrollRestoration;
exports.useHydrated = require_ClientOnly.useHydrated;
exports.useLayoutEffect = require_utils.useLayoutEffect;
exports.useLinkProps = require_link.useLinkProps;
exports.useLoaderData = require_useLoaderData.useLoaderData;
exports.useLoaderDeps = require_useLoaderDeps.useLoaderDeps;
exports.useLocation = require_useLocation.useLocation;
exports.useMatch = require_useMatch.useMatch;
exports.useMatchRoute = require_Matches.useMatchRoute;
exports.useMatches = require_Matches.useMatches;
exports.useNavigate = require_useNavigate.useNavigate;
exports.useParams = require_useParams.useParams;
exports.useParentMatches = require_Matches.useParentMatches;
exports.useRouteContext = require_useRouteContext.useRouteContext;
exports.useRouter = require_useRouter.useRouter;
exports.useRouterState = require_useRouterState.useRouterState;
exports.useSearch = require_useSearch.useSearch;
exports.useTags = require_headContentUtils.useTags;
@@ -0,0 +1,3 @@
export * from './index.cjs';
export { notFound, isNotFound, redirect, isRedirect, rootRouteId, } from '@tanstack/router-core';
export type { NotFoundError } from '@tanstack/router-core';
@@ -0,0 +1,56 @@
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_utils = require("./utils.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
//#region src/lazyRouteComponent.tsx
/**
* Wrap a dynamic import to create a route component that supports
* `.preload()` and friendly reload-on-module-missing behavior.
*
* @param importer Function returning a module promise
* @param exportName Named export to use (default: `default`)
* @returns A lazy route component compatible with TanStack Router
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/lazyRouteComponentFunction
*/
function lazyRouteComponent(importer, exportName) {
let loadPromise;
let comp;
let error;
const load = () => {
if (!loadPromise) {
error = void 0;
loadPromise = importer().then((res) => {
if (!(_tanstack_router_core_isServer.isServer ?? typeof window === "undefined")) loadPromise = void 0;
comp = res[exportName ?? "default"];
}).catch((err) => {
loadPromise = void 0;
error = err;
});
}
return loadPromise;
};
const lazyComp = function Lazy(props) {
if (error) {
if ((0, _tanstack_router_core.isModuleNotFoundError)(error) && !(_tanstack_router_core_isServer.isServer ?? typeof window === "undefined") && typeof sessionStorage !== "undefined") {
const storageKey = `tanstack_router_reload:${error.message}`;
if (!sessionStorage.getItem(storageKey)) {
sessionStorage.setItem(storageKey, "1");
window.location.reload();
throw new Promise(() => {});
}
}
throw error;
}
if (!comp) if (require_utils.reactUse) require_utils.reactUse(load());
else throw load();
return react.createElement(comp, props);
};
lazyComp.preload = load;
return lazyComp;
}
//#endregion
exports.lazyRouteComponent = lazyRouteComponent;
//# sourceMappingURL=lazyRouteComponent.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"lazyRouteComponent.cjs","names":[],"sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import * as React from 'react'\nimport { isModuleNotFoundError } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { reactUse } from './utils'\nimport type { AsyncRouteComponent } from './route'\n\n/**\n * Wrap a dynamic import to create a route component that supports\n * `.preload()` and friendly reload-on-module-missing behavior.\n *\n * @param importer Function returning a module promise\n * @param exportName Named export to use (default: `default`)\n * @returns A lazy route component compatible with TanStack Router\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/lazyRouteComponentFunction\n */\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default']\n let error: any\n\n const load = () => {\n if (!loadPromise) {\n error = undefined\n loadPromise = importer()\n .then((res) => {\n // Keep browser preload behavior unchanged; SSR can reuse the import.\n if (!(isServer ?? typeof window === 'undefined')) {\n loadPromise = undefined\n }\n comp = res[exportName ?? 'default']\n })\n .catch((err) => {\n loadPromise = undefined\n // We don't want an error thrown from preload in this case, because\n // there's nothing we want to do about module not found during preload.\n // Record the error, the rest is handled during the render path.\n error = err\n })\n }\n\n return loadPromise\n }\n\n const lazyComp = function Lazy(props: any) {\n if (error) {\n // A missing module can mean that a newer deployment replaced the URL.\n // Reload only for the error that is still current at render time, so a\n // successful retry cannot leave a stale reload request armed.\n if (\n isModuleNotFoundError(error) &&\n !(isServer ?? typeof window === 'undefined') &&\n typeof sessionStorage !== 'undefined'\n ) {\n const storageKey = `tanstack_router_reload:${error.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n window.location.reload()\n // Suspend forever while the document reloads.\n throw new Promise(() => {})\n }\n }\n throw error\n }\n\n if (!comp) {\n if (reactUse) {\n reactUse(load())\n } else {\n throw load()\n }\n }\n\n return React.createElement(comp, props)\n }\n\n ;(lazyComp as any).preload = load\n\n return lazyComp as any\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAgB,mBAId,UACA,YAGQ;CACR,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,aAAa;EACjB,IAAI,CAAC,aAAa;GAChB,QAAQ,KAAA;GACR,cAAc,SAAS,EACpB,MAAM,QAAQ;IAEb,IAAI,EAAE,+BAAA,YAAY,OAAO,WAAW,cAClC,cAAc,KAAA;IAEhB,OAAO,IAAI,cAAc;GAC3B,CAAC,EACA,OAAO,QAAQ;IACd,cAAc,KAAA;IAId,QAAQ;GACV,CAAC;EACL;EAEA,OAAO;CACT;CAEA,MAAM,WAAW,SAAS,KAAK,OAAY;EACzC,IAAI,OAAO;GAIT,KAAA,GAAA,sBAAA,uBACwB,KAAK,KAC3B,EAAE,+BAAA,YAAY,OAAO,WAAW,gBAChC,OAAO,mBAAmB,aAC1B;IACA,MAAM,aAAa,0BAA0B,MAAM;IACnD,IAAI,CAAC,eAAe,QAAQ,UAAU,GAAG;KACvC,eAAe,QAAQ,YAAY,GAAG;KACtC,OAAO,SAAS,OAAO;KAEvB,MAAM,IAAI,cAAc,CAAC,CAAC;IAC5B;GACF;GACA,MAAM;EACR;EAEA,IAAI,CAAC,MACH,IAAI,cAAA,UACF,cAAA,SAAS,KAAK,CAAC;OAEf,MAAM,KAAK;EAIf,OAAO,MAAM,cAAc,MAAM,KAAK;CACxC;CAEC,SAAkB,UAAU;CAE7B,OAAO;AACT"}
@@ -0,0 +1,11 @@
import { AsyncRouteComponent } from './route.cjs';
/**
* Wrap a dynamic import to create a route component that supports
* `.preload()` and friendly reload-on-module-missing behavior.
*
* @param importer Function returning a module promise
* @param exportName Named export to use (default: `default`)
* @returns A lazy route component compatible with TanStack Router
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/lazyRouteComponentFunction
*/
export declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey): T[TKey] extends (props: infer TProps) => any ? AsyncRouteComponent<TProps> : never;
+463
View File
@@ -0,0 +1,463 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_utils = require("./utils.cjs");
const require_ClientOnly = require("./ClientOnly.cjs");
const require_useRouter = require("./useRouter.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let react_jsx_runtime = require("react/jsx-runtime");
let _tanstack_react_store = require("@tanstack/react-store");
//#region src/link.tsx
function useValueStable(value) {
const ref = react.useRef(value);
if (!(0, _tanstack_router_core.deepEqual)(ref.current, value, { ignoreUndefined: false })) ref.current = value;
return ref.current;
}
function compareLinkState(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
}
function resolveExternalLink(hrefOption, to, protocolAllowlist) {
if (hrefOption?.external) {
if ((0, _tanstack_router_core.isDangerousProtocol)(hrefOption.href, protocolAllowlist)) {
if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${hrefOption.href}`);
return;
}
return hrefOption.href;
}
if (isSafeInternal(to)) return;
if (typeof to !== "string" || to.indexOf(":") === -1) return;
try {
new URL(to);
if ((0, _tanstack_router_core.isDangerousProtocol)(to, protocolAllowlist)) {
if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${to}`);
return;
}
return to;
} catch {}
}
function resolveIsActive(location, next, activeOptions, basepath, isHydrated, isExternal) {
if (isExternal) return false;
if (activeOptions?.exact) {
if (!(0, _tanstack_router_core.exactPathTest)(location.pathname, next.pathname, basepath)) return false;
} else {
const currentPathSplit = (0, _tanstack_router_core.removeTrailingSlash)(location.pathname, basepath);
const nextPathSplit = (0, _tanstack_router_core.removeTrailingSlash)(next.pathname, basepath);
if (!(currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/"))) return false;
}
if (activeOptions?.includeSearch ?? true) {
if (!(0, _tanstack_router_core.deepEqual)(location.search, next.search, {
partial: !activeOptions?.exact,
ignoreUndefined: !activeOptions?.explicitUndefined
})) return false;
}
if (activeOptions?.includeHash) return isHydrated && location.hash === next.hash;
return true;
}
/**
* Build anchor-like props for declarative navigation and preloading.
*
* Returns stable `href`, event handlers and accessibility props derived from
* router options and active state. Used internally by `Link` and custom links.
*
* Options cover `to`, `params`, `search`, `hash`, `state`, `preload`,
* `activeProps`, `inactiveProps`, and more.
*
* @returns React anchor props suitable for `<a>` or custom components.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLinkPropsHook
*/
function useLinkProps(options, forwardedRef) {
const router = require_useRouter.useRouter();
const innerRef = require_utils.useForwardedRef(forwardedRef);
const { activeProps, inactiveProps, activeOptions, to, preload: userPreload, preloadDelay: userPreloadDelay, preloadIntentProximity: _preloadIntentProximity, hashScrollIntoView, replace, startTransition, resetScroll, viewTransition, children, target, disabled, style, className, onClick, onBlur, onFocus, onMouseEnter, onMouseLeave, onTouchStart, ignoreBlocker, params: _params, search: _search, hash: _hash, state: _state, mask: _mask, reloadDocument: _reloadDocument, unsafeRelative: _unsafeRelative, from: _from, _fromLocation, ...propsSafeToSpread } = options;
if (_tanstack_router_core_isServer.isServer ?? router.isServer) {
const safeInternal = isSafeInternal(to);
if (typeof to === "string" && !safeInternal && to.indexOf(":") > -1) try {
new URL(to);
if ((0, _tanstack_router_core.isDangerousProtocol)(to, router.protocolAllowlist)) {
if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${to}`);
return {
...propsSafeToSpread,
ref: innerRef,
href: void 0,
...children && { children },
...target && { target },
...disabled && { disabled },
...style && { style },
...className && { className }
};
}
return {
...propsSafeToSpread,
ref: innerRef,
href: to,
...children && { children },
...target && { target },
...disabled && { disabled },
...style && { style },
...className && { className }
};
} catch {}
const next = router.buildLocation({
...options,
from: options.from
});
const hrefOption = getHrefOption(next.maskedLocation ? next.maskedLocation.publicHref : next.publicHref, next.maskedLocation ? next.maskedLocation.external : next.external, router.history, disabled);
const externalLink = (() => {
if (hrefOption?.external) {
if ((0, _tanstack_router_core.isDangerousProtocol)(hrefOption.href, router.protocolAllowlist)) {
if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${hrefOption.href}`);
return;
}
return hrefOption.href;
}
if (safeInternal) return void 0;
if (typeof to === "string" && to.indexOf(":") > -1) try {
new URL(to);
if ((0, _tanstack_router_core.isDangerousProtocol)(to, router.protocolAllowlist)) {
if (process.env.NODE_ENV !== "production") console.warn(`Blocked Link with dangerous protocol: ${to}`);
return;
}
return to;
} catch {}
})();
const isActive = (() => {
if (externalLink) return false;
const currentLocation = router.stores.location.get();
const exact = activeOptions?.exact ?? false;
if (exact) {
if (!(0, _tanstack_router_core.exactPathTest)(currentLocation.pathname, next.pathname, router.basepath)) return false;
} else {
const currentPathSplit = (0, _tanstack_router_core.removeTrailingSlash)(currentLocation.pathname, router.basepath);
const nextPathSplit = (0, _tanstack_router_core.removeTrailingSlash)(next.pathname, router.basepath);
if (!(currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/"))) return false;
}
if (activeOptions?.includeSearch ?? true) {
if (currentLocation.search !== next.search) {
const currentSearchEmpty = !currentLocation.search || typeof currentLocation.search === "object" && !(0, _tanstack_router_core.hasKeys)(currentLocation.search);
const nextSearchEmpty = !next.search || typeof next.search === "object" && !(0, _tanstack_router_core.hasKeys)(next.search);
if (!(currentSearchEmpty && nextSearchEmpty)) {
if (!(0, _tanstack_router_core.deepEqual)(currentLocation.search, next.search, {
partial: !exact,
ignoreUndefined: !activeOptions?.explicitUndefined
})) return false;
}
}
}
if (activeOptions?.includeHash) return false;
return true;
})();
if (externalLink) return {
...propsSafeToSpread,
ref: innerRef,
href: externalLink,
...children && { children },
...target && { target },
...disabled && { disabled },
...style && { style },
...className && { className }
};
const resolvedActiveProps = isActive ? (0, _tanstack_router_core.functionalUpdate)(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : (0, _tanstack_router_core.functionalUpdate)(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
const resolvedStyle = (() => {
const baseStyle = style;
const activeStyle = resolvedActiveProps.style;
const inactiveStyle = resolvedInactiveProps.style;
if (!baseStyle && !activeStyle && !inactiveStyle) return;
if (baseStyle && !activeStyle && !inactiveStyle) return baseStyle;
if (!baseStyle && activeStyle && !inactiveStyle) return activeStyle;
if (!baseStyle && !activeStyle && inactiveStyle) return inactiveStyle;
return {
...baseStyle,
...activeStyle,
...inactiveStyle
};
})();
const resolvedClassName = (() => {
const baseClassName = className;
const activeClassName = resolvedActiveProps.className;
const inactiveClassName = resolvedInactiveProps.className;
if (!baseClassName && !activeClassName && !inactiveClassName) return "";
let out = "";
if (baseClassName) out = baseClassName;
if (activeClassName) out = out ? `${out} ${activeClassName}` : activeClassName;
if (inactiveClassName) out = out ? `${out} ${inactiveClassName}` : inactiveClassName;
return out;
})();
return {
...propsSafeToSpread,
...resolvedActiveProps,
...resolvedInactiveProps,
href: hrefOption?.href,
ref: innerRef,
disabled: !!disabled,
target,
...resolvedStyle && { style: resolvedStyle },
...resolvedClassName && { className: resolvedClassName },
...disabled && STATIC_DISABLED_PROPS,
...isActive && STATIC_ACTIVE_PROPS
};
}
const isHydrated = require_ClientOnly.useHydrated();
const stableSearch = useValueStable(options.search);
const stableParams = useValueStable(options.params);
const stableActiveOptions = useValueStable(activeOptions);
const _options = react.useMemo(() => options, [
router,
options.from,
options._fromLocation,
options.hash,
options.to,
stableSearch,
stableParams,
options.state,
options.mask,
options.unsafeRelative
]);
const selectLinkState = react.useCallback((location) => {
const next = router.buildLocation({
_fromLocation: location,
..._options
});
const hrefOption = getHrefOption(next.maskedLocation ? next.maskedLocation.publicHref : next.publicHref, next.maskedLocation ? next.maskedLocation.external : next.external, router.history, disabled);
const externalLink = resolveExternalLink(hrefOption, to, router.protocolAllowlist);
return [
hrefOption?.href,
externalLink,
resolveIsActive(location, next, stableActiveOptions, router.basepath, isHydrated, externalLink !== void 0)
];
}, [
stableActiveOptions,
disabled,
isHydrated,
_options,
router,
to
]);
const [href, externalLink, isActive] = (0, _tanstack_react_store.useStore)(router.stores.location, selectLinkState, compareLinkState);
const resolvedActiveProps = isActive ? (0, _tanstack_router_core.functionalUpdate)(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : (0, _tanstack_router_core.functionalUpdate)(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
const resolvedClassName = [
className,
resolvedActiveProps.className,
resolvedInactiveProps.className
].filter(Boolean).join(" ");
const resolvedStyle = (style || resolvedActiveProps.style || resolvedInactiveProps.style) && {
...style,
...resolvedActiveProps.style,
...resolvedInactiveProps.style
};
const hasRenderFetched = react.useRef(false);
const preload = options.reloadDocument || externalLink || disabled ? false : userPreload ?? router.options.defaultPreload;
const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
const doPreload = react.useCallback(() => {
router.preloadRoute(_options).catch((err) => {
console.warn(err);
console.warn(_tanstack_router_core.preloadWarning);
});
}, [router, _options]);
const enqueuePreload = react.useCallback((e) => {
if (!e) {
cancelPreload(innerRef);
return;
}
if (!(e.isIntersecting ?? preload === "intent")) {
if (e.isIntersecting === false) cancelPreload(innerRef);
return;
}
if (!preloadDelay) {
doPreload();
return;
}
if (timeoutMap.has(innerRef)) return;
timeoutMap.set(innerRef, setTimeout(() => {
timeoutMap.delete(innerRef);
doPreload();
}, preloadDelay));
}, [
doPreload,
innerRef,
preload,
preloadDelay
]);
require_utils.useIntersectionObserver(innerRef, enqueuePreload, preload !== "viewport");
react.useEffect(() => {
if (hasRenderFetched.current) return;
if (preload === "render") {
doPreload();
hasRenderFetched.current = true;
}
}, [doPreload, preload]);
const handleClick = (e) => {
const elementTarget = e.currentTarget.getAttribute("target");
const effectiveTarget = target !== void 0 ? target : elementTarget;
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
e.preventDefault();
router.navigate({
..._options,
replace,
resetScroll,
hashScrollIntoView,
startTransition,
viewTransition,
ignoreBlocker
});
}
};
if (externalLink) return {
...propsSafeToSpread,
ref: innerRef,
href: externalLink,
...children && { children },
...target && { target },
...disabled && { disabled },
...style && { style },
...className && { className },
...onClick && { onClick },
...onBlur && { onBlur },
...onFocus && { onFocus },
...onMouseEnter && { onMouseEnter },
...onMouseLeave && { onMouseLeave },
...onTouchStart && { onTouchStart }
};
const handleTouchStart = () => {
if (preload !== "intent") return;
doPreload();
};
const handleLeave = () => {
if (preload === "intent") cancelPreload(innerRef);
};
return {
...propsSafeToSpread,
...resolvedActiveProps,
...resolvedInactiveProps,
href,
ref: innerRef,
onClick: composeHandlers([onClick, handleClick]),
onBlur: composeHandlers([onBlur, handleLeave]),
onFocus: composeHandlers([onFocus, enqueuePreload]),
onMouseEnter: composeHandlers([onMouseEnter, enqueuePreload]),
onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
disabled: !!disabled,
target,
...resolvedStyle && { style: resolvedStyle },
...resolvedClassName && { className: resolvedClassName },
...disabled && STATIC_DISABLED_PROPS,
...isActive && STATIC_ACTIVE_PROPS
};
}
var STATIC_EMPTY_OBJECT = {};
var STATIC_ACTIVE_OBJECT = { className: "active" };
var STATIC_DISABLED_PROPS = {
role: "link",
"aria-disabled": true
};
var STATIC_ACTIVE_PROPS = {
"data-status": "active",
"aria-current": "page"
};
var timeoutMap = /* @__PURE__ */ new WeakMap();
var cancelPreload = (eventTarget) => {
clearTimeout(timeoutMap.get(eventTarget));
timeoutMap.delete(eventTarget);
};
var composeHandlers = (handlers) => (e) => {
for (const handler of handlers) {
if (!handler) continue;
if (e.defaultPrevented) return;
handler(e);
}
};
function getHrefOption(publicHref, external, history, disabled) {
if (disabled) return void 0;
if (external) return {
href: publicHref,
external: true
};
return {
href: history.createHref(publicHref) || "/",
external: false
};
}
function isSafeInternal(to) {
if (typeof to !== "string") return false;
const zero = to.charCodeAt(0);
if (zero === 47) return to.charCodeAt(1) !== 47;
return zero === 46;
}
/**
* Creates a typed Link-like component that preserves TanStack Router's
* navigation semantics and type-safety while delegating rendering to the
* provided host component.
*
* Useful for integrating design system anchors/buttons while keeping
* router-aware props (eg. `to`, `params`, `search`, `preload`).
*
* @param Comp The host component to render (eg. a design-system Link/Button)
* @returns A router-aware component with the same API as `Link`.
* @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-link
*/
function createLink(Comp) {
return react.forwardRef(function CreatedLink(props, ref) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Link, {
...props,
_asChild: Comp,
ref
});
});
}
/**
* A strongly-typed anchor component for declarative navigation.
* Handles path, search, hash and state updates with optional route preloading
* and active-state styling.
*
* Props:
* - `preload`: Controls route preloading (eg. 'intent', 'render', 'viewport', true/false)
* - `preloadDelay`: Delay in ms before preloading on focus, hover, or viewport entry
* - `activeProps`/`inactiveProps`: Additional props merged when link is active/inactive
* - `resetScroll`/`hashScrollIntoView`: Control scroll behavior on navigation
* - `viewTransition`/`startTransition`: Use View Transitions/React transitions for navigation
* - `ignoreBlocker`: Bypass registered blockers
*
* @returns An anchor-like element that navigates without full page reloads.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkComponent
*/
var Link = react.forwardRef((props, ref) => {
const { _asChild, ...rest } = props;
const { type: _type, ...linkProps } = useLinkProps(rest, ref);
const children = typeof rest.children === "function" ? rest.children({ isActive: linkProps["data-status"] === "active" }) : rest.children;
if (!_asChild) {
const { disabled: _, ...rest } = linkProps;
return react.createElement("a", rest, children);
}
return react.createElement(_asChild, linkProps, children);
});
function isCtrlEvent(e) {
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
}
/**
* Validate and reuse navigation options for `Link`, `navigate` or `redirect`.
* Accepts a literal options object and returns it typed for later spreading.
* @example
* const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } })
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions
*/
var linkOptions = (options) => {
return options;
};
/**
* Type-check a literal object for use with `Link`, `navigate` or `redirect`.
* Use to validate and reuse navigation options across your app.
* @example
* const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } })
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions
*/
//#endregion
exports.Link = Link;
exports.createLink = createLink;
exports.linkOptions = linkOptions;
exports.useLinkProps = useLinkProps;
//# sourceMappingURL=link.cjs.map
File diff suppressed because one or more lines are too long
+97
View File
@@ -0,0 +1,97 @@
import { AnyRouter, Constrain, LinkOptions, RegisteredRouter, RoutePaths } from '@tanstack/router-core';
import { ReactNode } from 'react';
import { ValidateLinkOptions, ValidateLinkOptionsArray } from './typePrimitives.cjs';
import * as React from 'react';
/**
* Build anchor-like props for declarative navigation and preloading.
*
* Returns stable `href`, event handlers and accessibility props derived from
* router options and active state. Used internally by `Link` and custom links.
*
* Options cover `to`, `params`, `search`, `hash`, `state`, `preload`,
* `activeProps`, `inactiveProps`, and more.
*
* @returns React anchor props suitable for `<a>` or custom components.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useLinkPropsHook
*/
export declare function useLinkProps<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>, forwardedRef?: React.ForwardedRef<Element>): React.ComponentPropsWithRef<'a'>;
type UseLinkReactProps<TComp> = TComp extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[TComp] : TComp extends React.ComponentType<any> ? React.ComponentPropsWithoutRef<TComp> & React.RefAttributes<React.ComponentRef<TComp>> : never;
export type UseLinkPropsOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string | undefined = '.', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & UseLinkReactProps<'a'>;
export type ActiveLinkOptions<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & ActiveLinkOptionProps<TComp>;
type ActiveLinkProps<TComp> = Partial<LinkComponentReactProps<TComp> & {
[key: `data-${string}`]: unknown;
}>;
export interface ActiveLinkOptionProps<TComp = 'a'> {
/**
* A function that returns additional props for the `active` state of this link.
* These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
*/
activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>);
/**
* A function that returns additional props for the `inactive` state of this link.
* These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
*/
inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>);
}
export type LinkProps<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkPropsChildren;
export interface LinkPropsChildren {
children?: React.ReactNode | ((state: {
isActive: boolean;
}) => React.ReactNode);
}
type LinkComponentReactProps<TComp> = Omit<UseLinkReactProps<TComp>, keyof CreateLinkProps>;
export type LinkComponentProps<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkComponentReactProps<TComp> & LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
export type CreateLinkProps = LinkProps<any, any, string, string, string, string>;
export type LinkComponent<in out TComp, in out TDefaultFrom extends string = string> = <TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = TDefaultFrom, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => React.ReactElement;
export interface LinkComponentRoute<in out TDefaultFrom extends string = string> {
defaultFrom: TDefaultFrom;
<TRouter extends AnyRouter = RegisteredRouter, const TTo extends string | undefined = undefined, const TMaskTo extends string = ''>(props: LinkComponentProps<'a', TRouter, this['defaultFrom'], TTo, this['defaultFrom'], TMaskTo>): React.ReactElement;
}
/**
* Creates a typed Link-like component that preserves TanStack Router's
* navigation semantics and type-safety while delegating rendering to the
* provided host component.
*
* Useful for integrating design system anchors/buttons while keeping
* router-aware props (eg. `to`, `params`, `search`, `preload`).
*
* @param Comp The host component to render (eg. a design-system Link/Button)
* @returns A router-aware component with the same API as `Link`.
* @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-link
*/
export declare function createLink<const TComp>(Comp: Constrain<TComp, any, (props: CreateLinkProps) => ReactNode>): LinkComponent<TComp>;
/**
* A strongly-typed anchor component for declarative navigation.
* Handles path, search, hash and state updates with optional route preloading
* and active-state styling.
*
* Props:
* - `preload`: Controls route preloading (eg. 'intent', 'render', 'viewport', true/false)
* - `preloadDelay`: Delay in ms before preloading on focus, hover, or viewport entry
* - `activeProps`/`inactiveProps`: Additional props merged when link is active/inactive
* - `resetScroll`/`hashScrollIntoView`: Control scroll behavior on navigation
* - `viewTransition`/`startTransition`: Use View Transitions/React transitions for navigation
* - `ignoreBlocker`: Bypass registered blockers
*
* @returns An anchor-like element that navigates without full page reloads.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkComponent
*/
export declare const Link: LinkComponent<'a'>;
export type LinkOptionsFnOptions<TOptions, TComp, TRouter extends AnyRouter = RegisteredRouter> = TOptions extends ReadonlyArray<any> ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp> : ValidateLinkOptions<TRouter, TOptions, string, TComp>;
export type LinkOptionsFn<TComp> = <const TOptions, TRouter extends AnyRouter = RegisteredRouter>(options: LinkOptionsFnOptions<TOptions, TComp, TRouter>) => TOptions;
/**
* Validate and reuse navigation options for `Link`, `navigate` or `redirect`.
* Accepts a literal options object and returns it typed for later spreading.
* @example
* const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } })
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions
*/
export declare const linkOptions: LinkOptionsFn<'a'>;
export {};
/**
* Type-check a literal object for use with `Link`, `navigate` or `redirect`.
* Use to validate and reuse navigation options across your app.
* @example
* const opts = linkOptions({ to: '/dashboard', search: { tab: 'home' } })
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/linkOptions
*/
+12
View File
@@ -0,0 +1,12 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
//#region src/matchContext.tsx
var matchContext = react.createContext(void 0);
var dummyMatchContext = react.createContext(void 0);
//#endregion
exports.dummyMatchContext = dummyMatchContext;
exports.matchContext = matchContext;
//# sourceMappingURL=matchContext.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"matchContext.cjs","names":[],"sources":["../../src/matchContext.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\n// N.B. this only exists so we can conditionally call useContext on it when we are not interested in the nearest match\nexport const dummyMatchContext = React.createContext<string | undefined>(\n undefined,\n)\n"],"mappings":";;;;;AAIA,IAAa,eAAe,MAAM,cAAkC,KAAA,CAAS;AAG7E,IAAa,oBAAoB,MAAM,cACrC,KAAA,CACF"}
@@ -0,0 +1,3 @@
import * as React from 'react';
export declare const matchContext: React.Context<string | undefined>;
export declare const dummyMatchContext: React.Context<string | undefined>;
@@ -0,0 +1,18 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/nonRouteComponentContext.tsx
var nonRouteComponentContext = process.env.NODE_ENV !== "production" ? react.createContext(void 0) : void 0;
function wrapInNonRouteComponentContext(element, component) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(nonRouteComponentContext.Provider, {
value: component,
children: element
});
}
//#endregion
exports.nonRouteComponentContext = nonRouteComponentContext;
exports.wrapInNonRouteComponentContext = wrapInNonRouteComponentContext;
//# sourceMappingURL=nonRouteComponentContext.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"nonRouteComponentContext.cjs","names":[],"sources":["../../src/nonRouteComponentContext.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nexport type NonRouteComponent =\n | 'pendingComponent'\n | 'errorComponent'\n | 'notFoundComponent'\n\nexport const nonRouteComponentContext =\n process.env.NODE_ENV !== 'production'\n ? React.createContext<NonRouteComponent | undefined>(undefined)\n : undefined\n\nexport function wrapInNonRouteComponentContext(\n element: React.ReactElement,\n component: NonRouteComponent,\n): React.ReactElement {\n const Context = nonRouteComponentContext!\n return <Context.Provider value={component}>{element}</Context.Provider>\n}\n"],"mappings":";;;;;;AASA,IAAa,2BAAA,QAAA,IAAA,aACc,eACrB,MAAM,cAA6C,KAAA,CAAS,IAC5D,KAAA;AAEN,SAAgB,+BACd,SACA,WACoB;CAEpB,OAAO,iBAAA,GAAA,kBAAA,KAAC,yBAAQ,UAAT;EAAkB,OAAO;YAAY;CAA0B,CAAA;AACxE"}
@@ -0,0 +1,4 @@
import * as React from 'react';
export type NonRouteComponent = 'pendingComponent' | 'errorComponent' | 'notFoundComponent';
export declare const nonRouteComponentContext: React.Context<NonRouteComponent | undefined> | undefined;
export declare function wrapInNonRouteComponentContext(element: React.ReactElement, component: NonRouteComponent): React.ReactElement;
+49
View File
@@ -0,0 +1,49 @@
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_CatchBoundary = require("./CatchBoundary.cjs");
const require_useRouter = require("./useRouter.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let react_jsx_runtime = require("react/jsx-runtime");
let _tanstack_react_store = require("@tanstack/react-store");
//#region src/not-found.tsx
function CatchNotFound(props) {
const router = require_useRouter.useRouter();
if (_tanstack_router_core_isServer.isServer ?? router.isServer) {
const resetKey = `not-found-${router.stores.location.get().pathname}-${router.stores.status.get()}`;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CatchBoundary.CatchBoundary, {
getResetKey: () => resetKey,
onCatch: (error, errorInfo) => {
if ((0, _tanstack_router_core.isNotFound)(error)) props.onCatch?.(error, errorInfo);
else throw error;
},
errorComponent: ({ error }) => {
if ((0, _tanstack_router_core.isNotFound)(error)) return props.fallback?.(error);
else throw error;
},
children: props.children
});
}
const resetKey = `not-found-${(0, _tanstack_react_store.useStore)(router.stores.location, (location) => location.pathname)}-${(0, _tanstack_react_store.useStore)(router.stores.status, (status) => status)}`;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CatchBoundary.CatchBoundary, {
getResetKey: () => resetKey,
onCatch: (error, errorInfo) => {
if ((0, _tanstack_router_core.isNotFound)(error)) props.onCatch?.(error, errorInfo);
else throw error;
},
errorComponent: ({ error }) => {
if ((0, _tanstack_router_core.isNotFound)(error)) return props.fallback?.(error);
else throw error;
},
children: props.children
});
}
function DefaultGlobalNotFound() {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "Not Found" });
}
//#endregion
exports.CatchNotFound = CatchNotFound;
exports.DefaultGlobalNotFound = DefaultGlobalNotFound;
//# sourceMappingURL=not-found.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"not-found.cjs","names":[],"sources":["../../src/not-found.tsx"],"sourcesContent":["import * as React from 'react'\nimport { isNotFound } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { useStore } from '@tanstack/react-store'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport type { ErrorInfo } from 'react'\nimport type { NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => React.ReactElement\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n children: React.ReactNode\n}) {\n const router = useRouter()\n\n if (isServer ?? router.isServer) {\n const pathname = router.stores.location.get().pathname\n const status = router.stores.status.get()\n const resetKey = `not-found-${pathname}-${status}`\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey}\n onCatch={(error, errorInfo) => {\n if (isNotFound(error)) {\n props.onCatch?.(error, errorInfo)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n }\n\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n // eslint-disable-next-line react-hooks/rules-of-hooks -- condition is static\n const pathname = useStore(\n router.stores.location,\n (location) => location.pathname,\n )\n // eslint-disable-next-line react-hooks/rules-of-hooks -- condition is static\n const status = useStore(router.stores.status, (status) => status)\n const resetKey = `not-found-${pathname}-${status}`\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey}\n onCatch={(error, errorInfo) => {\n if (isNotFound(error)) {\n props.onCatch?.(error, errorInfo)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,cAAc,OAI3B;CACD,MAAM,SAAS,kBAAA,UAAU;CAEzB,IAAI,+BAAA,YAAY,OAAO,UAAU;EAG/B,MAAM,WAAW,aAFA,OAAO,OAAO,SAAS,IAAI,EAAE,SAEP,GADxB,OAAO,OAAO,OAAO,IACM;EAE1C,OACE,iBAAA,GAAA,kBAAA,KAAC,sBAAA,eAAD;GACE,mBAAmB;GACnB,UAAU,OAAO,cAAc;IAC7B,KAAA,GAAA,sBAAA,YAAe,KAAK,GAClB,MAAM,UAAU,OAAO,SAAS;SAEhC,MAAM;GAEV;GACA,iBAAiB,EAAE,YAAY;IAC7B,KAAA,GAAA,sBAAA,YAAe,KAAK,GAClB,OAAO,MAAM,WAAW,KAAK;SAE7B,MAAM;GAEV;aAEC,MAAM;EACM,CAAA;CAEnB;CAUA,MAAM,WAAW,cAAA,GAAA,sBAAA,UALf,OAAO,OAAO,WACb,aAAa,SAAS,QAIK,EAAS,IAAA,GAAA,sBAAA,UADf,OAAO,OAAO,SAAS,WAAW,MAChB;CAE1C,OACE,iBAAA,GAAA,kBAAA,KAAC,sBAAA,eAAD;EACE,mBAAmB;EACnB,UAAU,OAAO,cAAc;GAC7B,KAAA,GAAA,sBAAA,YAAe,KAAK,GAClB,MAAM,UAAU,OAAO,SAAS;QAEhC,MAAM;EAEV;EACA,iBAAiB,EAAE,YAAY;GAC7B,KAAA,GAAA,sBAAA,YAAe,KAAK,GAClB,OAAO,MAAM,WAAW,KAAK;QAE7B,MAAM;EAEV;YAEC,MAAM;CACM,CAAA;AAEnB;AAEA,SAAgB,wBAAwB;CACtC,OAAO,iBAAA,GAAA,kBAAA,KAAC,KAAD,EAAA,UAAG,YAAY,CAAA;AACxB"}
@@ -0,0 +1,9 @@
import { ErrorInfo } from 'react';
import { NotFoundError } from '@tanstack/router-core';
import * as React from 'react';
export declare function CatchNotFound(props: {
fallback?: (error: NotFoundError) => React.ReactElement;
onCatch?: (error: Error, errorInfo: ErrorInfo) => void;
children: React.ReactNode;
}): import("react/jsx-runtime").JSX.Element;
export declare function DefaultGlobalNotFound(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,33 @@
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_nonRouteComponentContext = require("./nonRouteComponentContext.cjs");
const require_not_found = require("./not-found.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/renderRouteNotFound.tsx
/**
* Renders a not found component for a route when no matching route is found.
*
* @param router - The router instance containing the route configuration
* @param route - The route that triggered the not found state
* @param data - Additional data to pass to the not found component
* @returns The rendered not found component or a default fallback component
*/
function renderRouteNotFound(router, route, data) {
if (!route.options.notFoundComponent) {
if (router.options.defaultNotFoundComponent) {
const notFoundElement = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(router.options.defaultNotFoundComponent, { ...data });
return process.env.NODE_ENV !== "production" ? require_nonRouteComponentContext.wrapInNonRouteComponentContext(notFoundElement, "notFoundComponent") : notFoundElement;
}
if (process.env.NODE_ENV !== "production") {
if (!route.options.notFoundComponent) console.warn(`Warning: A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`);
}
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_not_found.DefaultGlobalNotFound, {});
}
const notFoundElement = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(route.options.notFoundComponent, { ...data });
return process.env.NODE_ENV !== "production" ? require_nonRouteComponentContext.wrapInNonRouteComponentContext(notFoundElement, "notFoundComponent") : notFoundElement;
}
//#endregion
exports.renderRouteNotFound = renderRouteNotFound;
//# sourceMappingURL=renderRouteNotFound.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"renderRouteNotFound.cjs","names":[],"sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as React from 'react'\nimport { DefaultGlobalNotFound } from './not-found'\nimport { wrapInNonRouteComponentContext } from './nonRouteComponentContext'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\n\n/**\n * Renders a not found component for a route when no matching route is found.\n *\n * @param router - The router instance containing the route configuration\n * @param route - The route that triggered the not found state\n * @param data - Additional data to pass to the not found component\n * @returns The rendered not found component or a default fallback component\n */\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n const notFoundElement = (\n <router.options.defaultNotFoundComponent {...data} />\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(notFoundElement, 'notFoundComponent')\n : notFoundElement\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (!route.options.notFoundComponent) {\n console.warn(\n `Warning: A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`,\n )\n }\n }\n\n return <DefaultGlobalNotFound />\n }\n\n const notFoundElement = <route.options.notFoundComponent {...data} />\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(notFoundElement, 'notFoundComponent')\n : notFoundElement\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,SAAgB,oBACd,QACA,OACA,MACA;CACA,IAAI,CAAC,MAAM,QAAQ,mBAAmB;EACpC,IAAI,OAAO,QAAQ,0BAA0B;GAC3C,MAAM,kBACJ,iBAAA,GAAA,kBAAA,KAAC,OAAO,QAAQ,0BAAhB,EAAyC,GAAI,KAAO,CAAA;GAEtD,OAAA,QAAA,IAAA,aAAgC,eAC5B,iCAAA,+BAA+B,iBAAiB,mBAAmB,IACnE;EACN;EAEA,IAAA,QAAA,IAAA,aAA6B;OACvB,CAAC,MAAM,QAAQ,mBACjB,QAAQ,KACN,kEAAkE,MAAM,GAAG,mPAC7E;EAAA;EAIJ,OAAO,iBAAA,GAAA,kBAAA,KAAC,kBAAA,uBAAD,CAAwB,CAAA;CACjC;CAEA,MAAM,kBAAkB,iBAAA,GAAA,kBAAA,KAAC,MAAM,QAAQ,mBAAf,EAAiC,GAAI,KAAO,CAAA;CACpE,OAAA,QAAA,IAAA,aAAgC,eAC5B,iCAAA,+BAA+B,iBAAiB,mBAAmB,IACnE;AACN"}
@@ -0,0 +1,10 @@
import { AnyRoute, AnyRouter } from '@tanstack/router-core';
/**
* Renders a not found component for a route when no matching route is found.
*
* @param router - The router instance containing the route configuration
* @param route - The route that triggered the not found state
* @param data - Additional data to pass to the not found component
* @returns The rendered not found component or a default fallback component
*/
export declare function renderRouteNotFound(router: AnyRouter, route: AnyRoute, data: any): import("react/jsx-runtime").JSX.Element;
+276
View File
@@ -0,0 +1,276 @@
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
const require_useRouter = require("./useRouter.cjs");
const require_useMatch = require("./useMatch.cjs");
const require_useLoaderData = require("./useLoaderData.cjs");
const require_useLoaderDeps = require("./useLoaderDeps.cjs");
const require_useParams = require("./useParams.cjs");
const require_useSearch = require("./useSearch.cjs");
const require_useNavigate = require("./useNavigate.cjs");
const require_useRouteContext = require("./useRouteContext.cjs");
const require_link = require("./link.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/route.tsx
/**
* Returns a route-specific API that exposes type-safe hooks pre-bound
* to a single route ID. Useful for consuming a route's APIs from files
* where the route object isn't directly imported (e.g. code-split files).
*
* @param id Route ID string literal for the target route.
* @returns A `RouteApi` instance bound to the given route ID.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/getRouteApiFunction
*/
function getRouteApi(id) {
return new RouteApi({ id });
}
var RouteApi = class extends _tanstack_router_core.BaseRouteApi {
/**
* @deprecated Use the `getRouteApi` function instead.
*/
constructor({ id }) {
super({ id });
this.useMatch = (opts) => {
return require_useMatch.useMatch({
select: opts?.select,
from: this.id,
structuralSharing: opts?.structuralSharing
});
};
this.useRouteContext = (opts) => {
return require_useRouteContext.useRouteContext({
...opts,
from: this.id
});
};
this.useSearch = (opts) => {
return require_useSearch.useSearch({
select: opts?.select,
structuralSharing: opts?.structuralSharing,
from: this.id
});
};
this.useParams = (opts) => {
return require_useParams.useParams({
select: opts?.select,
structuralSharing: opts?.structuralSharing,
from: this.id
});
};
this.useLoaderDeps = (opts) => {
return require_useLoaderDeps.useLoaderDeps({
...opts,
from: this.id,
strict: false
});
};
this.useLoaderData = (opts) => {
return require_useLoaderData.useLoaderData({
...opts,
from: this.id,
strict: false
});
};
this.useNavigate = () => {
return require_useNavigate.useNavigate({ from: require_useRouter.useRouter().routesById[this.id].fullPath });
};
this.notFound = (opts) => {
return (0, _tanstack_router_core.notFound)({
routeId: this.id,
...opts
});
};
this.Link = react.default.forwardRef((props, ref) => {
const fullPath = require_useRouter.useRouter().routesById[this.id].fullPath;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_link.Link, {
ref,
from: fullPath,
...props
});
});
}
};
var Route = class extends _tanstack_router_core.BaseRoute {
/**
* @deprecated Use the `createRoute` function instead.
*/
constructor(options) {
super(options);
this.useMatch = (opts) => {
return require_useMatch.useMatch({
select: opts?.select,
from: this.id,
structuralSharing: opts?.structuralSharing
});
};
this.useRouteContext = (opts) => {
return require_useRouteContext.useRouteContext({
...opts,
from: this.id
});
};
this.useSearch = (opts) => {
return require_useSearch.useSearch({
select: opts?.select,
structuralSharing: opts?.structuralSharing,
from: this.id
});
};
this.useParams = (opts) => {
return require_useParams.useParams({
select: opts?.select,
structuralSharing: opts?.structuralSharing,
from: this.id
});
};
this.useLoaderDeps = (opts) => {
return require_useLoaderDeps.useLoaderDeps({
...opts,
from: this.id
});
};
this.useLoaderData = (opts) => {
return require_useLoaderData.useLoaderData({
...opts,
from: this.id
});
};
this.useNavigate = () => {
return require_useNavigate.useNavigate({ from: this.fullPath });
};
this.Link = react.default.forwardRef((props, ref) => {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_link.Link, {
ref,
from: this.fullPath,
...props
});
});
}
};
/**
* Creates a non-root Route instance for code-based routing.
*
* Use this to define a route that will be composed into a route tree
* (typically via a parent route's `addChildren`). If you're using file-based
* routing, prefer `createFileRoute`.
*
* @param options Route options (path, component, loader, context, etc.).
* @returns A Route instance to be attached to the route tree.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouteFunction
*/
function createRoute(options) {
return new Route(options);
}
/**
* Creates a root route factory that requires a router context type.
*
* Use when your root route expects `context` to be provided to `createRouter`.
* The returned function behaves like `createRootRoute` but enforces a context type.
*
* @returns A factory function to configure and return a root route.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction
*/
function createRootRouteWithContext() {
return (options) => {
return createRootRoute(options);
};
}
/**
* @deprecated Use the `createRootRouteWithContext` function instead.
*/
var rootRouteWithContext = createRootRouteWithContext;
var RootRoute = class extends _tanstack_router_core.BaseRootRoute {
/**
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
*/
constructor(options) {
super(options);
this.useMatch = (opts) => {
return require_useMatch.useMatch({
select: opts?.select,
from: this.id,
structuralSharing: opts?.structuralSharing
});
};
this.useRouteContext = (opts) => {
return require_useRouteContext.useRouteContext({
...opts,
from: this.id
});
};
this.useSearch = (opts) => {
return require_useSearch.useSearch({
select: opts?.select,
structuralSharing: opts?.structuralSharing,
from: this.id
});
};
this.useParams = (opts) => {
return require_useParams.useParams({
select: opts?.select,
structuralSharing: opts?.structuralSharing,
from: this.id
});
};
this.useLoaderDeps = (opts) => {
return require_useLoaderDeps.useLoaderDeps({
...opts,
from: this.id
});
};
this.useLoaderData = (opts) => {
return require_useLoaderData.useLoaderData({
...opts,
from: this.id
});
};
this.useNavigate = () => {
return require_useNavigate.useNavigate({ from: this.fullPath });
};
this.Link = react.default.forwardRef((props, ref) => {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_link.Link, {
ref,
from: this.fullPath,
...props
});
});
}
};
/**
* Creates a root Route instance used to build your route tree.
*
* Typically paired with `createRouter({ routeTree })`. If you need to require
* a typed router context, use `createRootRouteWithContext` instead.
*
* @param options Root route options (component, error, pending, etc.).
* @returns A root route instance.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteFunction
*/
function createRootRoute(options) {
return new RootRoute(options);
}
function createRouteMask(opts) {
return opts;
}
var NotFoundRoute = class extends Route {
constructor(options) {
super({
...options,
id: "404"
});
}
};
//#endregion
exports.NotFoundRoute = NotFoundRoute;
exports.RootRoute = RootRoute;
exports.Route = Route;
exports.RouteApi = RouteApi;
exports.createRootRoute = createRootRoute;
exports.createRootRouteWithContext = createRootRouteWithContext;
exports.createRoute = createRoute;
exports.createRouteMask = createRouteMask;
exports.getRouteApi = getRouteApi;
exports.rootRouteWithContext = rootRouteWithContext;
//# sourceMappingURL=route.cjs.map
File diff suppressed because one or more lines are too long
+142
View File
@@ -0,0 +1,142 @@
import { BaseRootRoute, BaseRoute, BaseRouteApi, AnyContext, AnyRoute, AnyRouter, ConstrainLiteral, ErrorComponentProps, NotFoundError, NotFoundRouteProps, Register, RegisteredRouter, ResolveFullPath, ResolveId, ResolveParams, RootRoute as RootRouteCore, RootRouteId, RootRouteOptions, RouteConstraints, Route as RouteCore, RouteIds, RouteMask, RouteOptions, RouteTypesById, RouterCore, ToMaskOptions, UseNavigateResult } from '@tanstack/router-core';
import { default as React } from 'react';
import { UseLoaderDataRoute } from './useLoaderData.cjs';
import { UseMatchRoute } from './useMatch.cjs';
import { UseLoaderDepsRoute } from './useLoaderDeps.cjs';
import { UseParamsRoute } from './useParams.cjs';
import { UseSearchRoute } from './useSearch.cjs';
import { UseRouteContextRoute } from './useRouteContext.cjs';
import { LinkComponentRoute } from './link.cjs';
declare module '@tanstack/router-core' {
interface UpdatableRouteOptionsExtensions {
component?: RouteComponent;
errorComponent?: false | null | undefined | ErrorRouteComponent;
notFoundComponent?: NotFoundRouteComponent;
pendingComponent?: RouteComponent;
}
interface RootRouteOptionsExtensions {
shellComponent?: ({ children, }: {
children: React.ReactNode;
}) => React.ReactNode;
}
interface RouteExtensions<in out TId extends string, in out TFullPath extends string> {
useMatch: UseMatchRoute<TId>;
useRouteContext: UseRouteContextRoute<TId>;
useSearch: UseSearchRoute<TId>;
useParams: UseParamsRoute<TId>;
useLoaderDeps: UseLoaderDepsRoute<TId>;
useLoaderData: UseLoaderDataRoute<TId>;
useNavigate: () => UseNavigateResult<TFullPath>;
Link: LinkComponentRoute<TFullPath>;
}
}
/**
* Returns a route-specific API that exposes type-safe hooks pre-bound
* to a single route ID. Useful for consuming a route's APIs from files
* where the route object isn't directly imported (e.g. code-split files).
*
* @param id Route ID string literal for the target route.
* @returns A `RouteApi` instance bound to the given route ID.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/getRouteApiFunction
*/
export declare function getRouteApi<const TId, TRouter extends AnyRouter = RegisteredRouter>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>): RouteApi<TId, TRouter>;
export declare class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> extends BaseRouteApi<TId, TRouter> {
/**
* @deprecated Use the `getRouteApi` function instead.
*/
constructor({ id }: {
id: TId;
});
useMatch: UseMatchRoute<TId>;
useRouteContext: UseRouteContextRoute<TId>;
useSearch: UseSearchRoute<TId>;
useParams: UseParamsRoute<TId>;
useLoaderDeps: UseLoaderDepsRoute<TId>;
useLoaderData: UseLoaderDataRoute<TId>;
useNavigate: () => UseNavigateResult<RouteTypesById<TRouter, TId>["fullPath"]>;
notFound: (opts?: NotFoundError) => NotFoundError;
Link: LinkComponentRoute<RouteTypesById<TRouter, TId>['fullPath']>;
}
export declare class Route<in out TRegister = unknown, in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, in out TPath extends RouteConstraints['TPath'] = '/', in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends RouteConstraints['TCustomId'] = string, in out TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchValidator = undefined, in out TParams = ResolveParams<TPath>, in out TRouterContext = AnyContext, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown, in out TSSR = unknown, in out TServerMiddlewares = unknown, in out THandlers = undefined> extends BaseRoute<TRegister, TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes, TSSR, TServerMiddlewares, THandlers> implements RouteCore<TRegister, TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes, TSSR, TServerMiddlewares, THandlers> {
/**
* @deprecated Use the `createRoute` function instead.
*/
constructor(options?: RouteOptions<TRegister, TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn, TSSR, TServerMiddlewares, THandlers>);
useMatch: UseMatchRoute<TId>;
useRouteContext: UseRouteContextRoute<TId>;
useSearch: UseSearchRoute<TId>;
useParams: UseParamsRoute<TId>;
useLoaderDeps: UseLoaderDepsRoute<TId>;
useLoaderData: UseLoaderDataRoute<TId>;
useNavigate: () => UseNavigateResult<TFullPath>;
Link: LinkComponentRoute<TFullPath>;
}
/**
* Creates a non-root Route instance for code-based routing.
*
* Use this to define a route that will be composed into a route tree
* (typically via a parent route's `addChildren`). If you're using file-based
* routing, prefer `createFileRoute`.
*
* @param options Route options (path, component, loader, context, etc.).
* @returns A Route instance to be attached to the route tree.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouteFunction
*/
export declare function createRoute<TRegister = unknown, TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown, TSSR = unknown, const TServerMiddlewares = unknown>(options: RouteOptions<TRegister, TParentRoute, TId, TCustomId, TFullPath, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn, TSSR, TServerMiddlewares>): Route<TRegister, TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TSSR, TServerMiddlewares>;
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any, any, any, any>;
/**
* Creates a root route factory that requires a router context type.
*
* Use when your root route expects `context` to be provided to `createRouter`.
* The returned function behaves like `createRootRoute` but enforces a context type.
*
* @returns A factory function to configure and return a root route.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction
*/
export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TRegister = Register, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TSSR = unknown, TServerMiddlewares = unknown>(options?: RootRouteOptions<TRegister, TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TSSR, TServerMiddlewares>) => RootRoute<TRegister, TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown, TSSR, TServerMiddlewares, undefined>;
/**
* @deprecated Use the `createRootRouteWithContext` function instead.
*/
export declare const rootRouteWithContext: typeof createRootRouteWithContext;
export declare class RootRoute<in out TRegister = unknown, in out TSearchValidator = undefined, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown, in out TSSR = unknown, in out TServerMiddlewares = unknown, in out THandlers = undefined> extends BaseRootRoute<TRegister, TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes, TSSR, TServerMiddlewares, THandlers> implements RootRouteCore<TRegister, TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes, TSSR, TServerMiddlewares, THandlers> {
/**
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
*/
constructor(options?: RootRouteOptions<TRegister, TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TSSR, TServerMiddlewares, THandlers>);
useMatch: UseMatchRoute<RootRouteId>;
useRouteContext: UseRouteContextRoute<RootRouteId>;
useSearch: UseSearchRoute<RootRouteId>;
useParams: UseParamsRoute<RootRouteId>;
useLoaderDeps: UseLoaderDepsRoute<RootRouteId>;
useLoaderData: UseLoaderDataRoute<RootRouteId>;
useNavigate: () => UseNavigateResult<"/">;
Link: LinkComponentRoute<'/'>;
}
/**
* Creates a root Route instance used to build your route tree.
*
* Typically paired with `createRouter({ routeTree })`. If you need to require
* a typed router context, use `createRootRouteWithContext` instead.
*
* @param options Root route options (component, error, pending, etc.).
* @returns A root route instance.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteFunction
*/
export declare function createRootRoute<TRegister = Register, TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TSSR = unknown, const TServerMiddlewares = unknown, THandlers = undefined>(options?: RootRouteOptions<TRegister, TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TSSR, TServerMiddlewares, THandlers>): RootRoute<TRegister, TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown, TSSR, TServerMiddlewares, THandlers>;
export declare function createRouteMask<TRouteTree extends AnyRoute, TFrom extends string, TTo extends string>(opts: {
routeTree: TRouteTree;
} & ToMaskOptions<RouterCore<TRouteTree, 'never', boolean>, TFrom, TTo>): RouteMask<TRouteTree>;
export interface DefaultRouteTypes<TProps> {
component: ((props: TProps) => any) | React.LazyExoticComponent<(props: TProps) => any>;
}
export interface RouteTypes<TProps> extends DefaultRouteTypes<TProps> {
}
export type AsyncRouteComponent<TProps> = RouteTypes<TProps>['component'] & {
preload?: () => Promise<void>;
};
export type RouteComponent = AsyncRouteComponent<{}>;
export type ErrorRouteComponent = AsyncRouteComponent<ErrorComponentProps>;
export type NotFoundRouteComponent = RouteTypes<NotFoundRouteProps>['component'];
export declare class NotFoundRoute<TRegister, TParentRoute extends AnyRootRoute, TRouterContext = AnyContext, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown, TSSR = unknown, TServerMiddlewares = unknown> extends Route<TRegister, TParentRoute, '/404', '/404', '404', '404', TSearchValidator, {}, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TSSR, TServerMiddlewares> {
constructor(options: Omit<RouteOptions<TRegister, TParentRoute, string, string, string, string, TSearchValidator, {}, TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn, TSSR, TServerMiddlewares>, 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id' | 'params'>);
}
+27
View File
@@ -0,0 +1,27 @@
const require_routerStores = require("./routerStores.cjs");
let _tanstack_router_core = require("@tanstack/router-core");
//#region src/router.ts
/**
* Creates a new Router instance for React.
*
* Pass the returned router to `RouterProvider` to enable routing.
* Notable options: `routeTree` (your route definitions) and `context`
* (required if the root route was created with `createRootRouteWithContext`).
*
* @param options Router options used to configure the router.
* @returns A Router instance to be provided to `RouterProvider`.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
*/
var createRouter = (options) => {
return new Router(options);
};
var Router = class extends _tanstack_router_core.RouterCore {
constructor(options) {
super(options, require_routerStores.getStoreFactory);
}
};
//#endregion
exports.Router = Router;
exports.createRouter = createRouter;
//# sourceMappingURL=router.cjs.map
File diff suppressed because one or more lines are too long
+83
View File
@@ -0,0 +1,83 @@
import { RouterCore, AnyRoute, CreateRouterFn, RouterConstructorOptions, TrailingSlashOption } from '@tanstack/router-core';
import { RouterHistory } from '@tanstack/history';
import { ErrorRouteComponent, NotFoundRouteComponent, RouteComponent } from './route.cjs';
declare module '@tanstack/router-core' {
interface RouterOptionsExtensions {
/**
* The default `component` a route should use if no component is provided.
*
* @default Outlet
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
*/
defaultComponent?: RouteComponent;
/**
* The default `errorComponent` a route should use if no error component is provided.
*
* @default ErrorComponent
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
*/
defaultErrorComponent?: ErrorRouteComponent;
/**
* The default `pendingComponent` a route should use if no pending component is provided.
*
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
*/
defaultPendingComponent?: RouteComponent;
/**
* The default `notFoundComponent` a route should use if no notFound component is provided.
*
* @default NotFound
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
*/
defaultNotFoundComponent?: NotFoundRouteComponent;
/**
* A component that will be used to wrap the entire router.
*
* This is useful for providing a context to the entire router.
*
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
*
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
*/
Wrap?: (props: {
children: any;
}) => React.JSX.Element;
/**
* A component that will be used to wrap the inner contents of the router.
*
* This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
*
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
*
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
*/
InnerWrap?: (props: {
children: any;
}) => React.JSX.Element;
/**
* The default `onCatch` handler for errors caught by the Router ErrorBoundary
*
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
*/
defaultOnCatch?: (error: Error, errorInfo: React.ErrorInfo) => void;
}
}
/**
* Creates a new Router instance for React.
*
* Pass the returned router to `RouterProvider` to enable routing.
* Notable options: `routeTree` (your route definitions) and `context`
* (required if the root route was created with `createRootRouteWithContext`).
*
* @param options Router options used to configure the router.
* @returns A Router instance to be provided to `RouterProvider`.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction
*/
export declare const createRouter: CreateRouterFn;
export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption = 'never', in out TDefaultStructuralSharingOption extends boolean = false, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>> extends RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated> {
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>);
}
@@ -0,0 +1,10 @@
"use client";
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
//#region src/routerContext.tsx
var routerContext = react.createContext(null);
//#endregion
exports.routerContext = routerContext;
//# sourceMappingURL=routerContext.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"routerContext.cjs","names":[],"sources":["../../src/routerContext.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport const routerContext = React.createContext<AnyRouter>(null!)\n"],"mappings":";;;;;AAKA,IAAa,gBAAgB,MAAM,cAAyB,IAAK"}
@@ -0,0 +1,3 @@
import { AnyRouter } from '@tanstack/router-core';
import * as React from 'react';
export declare const routerContext: React.Context<AnyRouter>;
+20
View File
@@ -0,0 +1,20 @@
let _tanstack_router_core = require("@tanstack/router-core");
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
let _tanstack_react_store = require("@tanstack/react-store");
//#region src/routerStores.ts
var getStoreFactory = (opts) => {
if (_tanstack_router_core_isServer.isServer ?? opts.isServer) return {
createMutableStore: _tanstack_router_core.createNonReactiveMutableStore,
createReadonlyStore: _tanstack_router_core.createNonReactiveReadonlyStore,
batch: (fn) => fn()
};
return {
createMutableStore: _tanstack_react_store.createAtom,
createReadonlyStore: _tanstack_react_store.createAtom,
batch: _tanstack_react_store.batch
};
};
//#endregion
exports.getStoreFactory = getStoreFactory;
//# sourceMappingURL=routerStores.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"routerStores.cjs","names":[],"sources":["../../src/routerStores.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/react-store'\nimport {\n createNonReactiveMutableStore,\n createNonReactiveReadonlyStore,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport type { Readable } from '@tanstack/react-store'\nimport type { GetStoreConfig } from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouterReadableStore<TValue> extends Readable<TValue> {}\n}\nexport const getStoreFactory: GetStoreConfig = (opts) => {\n if (isServer ?? opts.isServer) {\n return {\n createMutableStore: createNonReactiveMutableStore,\n createReadonlyStore: createNonReactiveReadonlyStore,\n batch: (fn) => fn(),\n }\n }\n return {\n createMutableStore: createAtom,\n createReadonlyStore: createAtom,\n batch: batch,\n }\n}\n"],"mappings":";;;;AAYA,IAAa,mBAAmC,SAAS;CACvD,IAAI,+BAAA,YAAY,KAAK,UACnB,OAAO;EACL,oBAAoB,sBAAA;EACpB,qBAAqB,sBAAA;EACrB,QAAQ,OAAO,GAAG;CACpB;CAEF,OAAO;EACL,oBAAoB,sBAAA;EACpB,qBAAqB,sBAAA;EACd,OAAA,sBAAA;CACT;AACF"}
@@ -0,0 +1,7 @@
import { Readable } from '@tanstack/react-store';
import { GetStoreConfig } from '@tanstack/router-core';
declare module '@tanstack/router-core' {
interface RouterReadableStore<TValue> extends Readable<TValue> {
}
}
export declare const getStoreFactory: GetStoreConfig;
@@ -0,0 +1,14 @@
const require_useRouter = require("./useRouter.cjs");
const require_ScriptOnce = require("./ScriptOnce.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
let _tanstack_router_core_scroll_restoration_script = require("@tanstack/router-core/scroll-restoration-script");
//#region src/scroll-restoration.tsx
function ScrollRestoration() {
const script = (0, _tanstack_router_core_scroll_restoration_script.getScrollRestorationScriptForRouter)(require_useRouter.useRouter());
if (!script) return null;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ScriptOnce.ScriptOnce, { children: script });
}
//#endregion
exports.ScrollRestoration = ScrollRestoration;
//# sourceMappingURL=scroll-restoration.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"scroll-restoration.cjs","names":[],"sources":["../../src/scroll-restoration.tsx"],"sourcesContent":["import { getScrollRestorationScriptForRouter } from '@tanstack/router-core/scroll-restoration-script'\nimport { useRouter } from './useRouter'\nimport { ScriptOnce } from './ScriptOnce'\n\nexport function ScrollRestoration() {\n const router = useRouter()\n const script = getScrollRestorationScriptForRouter(router)\n\n if (!script) {\n return null\n }\n\n return <ScriptOnce children={script} />\n}\n"],"mappings":";;;;;AAIA,SAAgB,oBAAoB;CAElC,MAAM,UAAA,GAAA,gDAAA,qCADS,kBAAA,UACoC,CAAM;CAEzD,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,iBAAA,GAAA,kBAAA,KAAC,mBAAA,YAAD,EAAY,UAAU,OAAS,CAAA;AACxC"}
@@ -0,0 +1 @@
export declare function ScrollRestoration(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,17 @@
const require_awaited = require("../awaited.cjs");
const require_RouterProvider = require("../RouterProvider.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
let _tanstack_router_core_ssr_client = require("@tanstack/router-core/ssr/client");
//#region src/ssr/RouterClient.tsx
var hydrationPromise;
function RouterClient(props) {
hydrationPromise ??= (0, _tanstack_router_core_ssr_client.hydrate)(props.router).finally(() => window.$_TSR.h());
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_awaited.Await, {
promise: hydrationPromise,
children: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RouterProvider.RouterProvider, { router: props.router })
});
}
//#endregion
exports.RouterClient = RouterClient;
//# sourceMappingURL=RouterClient.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"RouterClient.cjs","names":[],"sources":["../../../src/ssr/RouterClient.tsx"],"sourcesContent":["import { hydrate } from '@tanstack/router-core/ssr/client'\nimport { Await } from '../awaited'\nimport { RouterProvider } from '../RouterProvider'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nlet hydrationPromise: Promise<void> | undefined\n\nexport function RouterClient(props: { router: AnyRouter }) {\n hydrationPromise ??= hydrate(props.router).finally(() => window.$_TSR!.h())\n\n return (\n <Await\n promise={hydrationPromise}\n children={() => <RouterProvider router={props.router} />}\n />\n )\n}\n"],"mappings":";;;;;AAKA,IAAI;AAEJ,SAAgB,aAAa,OAA8B;CACzD,sBAAA,GAAA,iCAAA,SAA6B,MAAM,MAAM,EAAE,cAAc,OAAO,MAAO,EAAE,CAAC;CAE1E,OACE,iBAAA,GAAA,kBAAA,KAAC,gBAAA,OAAD;EACE,SAAS;EACT,gBAAgB,iBAAA,GAAA,kBAAA,KAAC,uBAAA,gBAAD,EAAgB,QAAQ,MAAM,OAAS,CAAA;CACxD,CAAA;AAEL"}
@@ -0,0 +1,4 @@
import { AnyRouter } from '@tanstack/router-core';
export declare function RouterClient(props: {
router: AnyRouter;
}): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
const require_RouterProvider = require("../RouterProvider.cjs");
let react = require("react");
react = require_runtime.__toESM(react, 1);
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/ssr/RouterServer.tsx
function RouterServer(props) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RouterProvider.RouterProvider, { router: props.router });
}
//#endregion
exports.RouterServer = RouterServer;
//# sourceMappingURL=RouterServer.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"RouterServer.cjs","names":[],"sources":["../../../src/ssr/RouterServer.tsx"],"sourcesContent":["import * as React from 'react'\nimport { RouterProvider } from '../RouterProvider'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport function RouterServer<TRouter extends AnyRouter>(props: {\n router: TRouter\n}) {\n return <RouterProvider router={props.router} />\n}\n"],"mappings":";;;;;;AAIA,SAAgB,aAAwC,OAErD;CACD,OAAO,iBAAA,GAAA,kBAAA,KAAC,uBAAA,gBAAD,EAAgB,QAAQ,MAAM,OAAS,CAAA;AAChD"}
@@ -0,0 +1,4 @@
import { AnyRouter } from '@tanstack/router-core';
export declare function RouterServer<TRouter extends AnyRouter>(props: {
router: TRouter;
}): import("react/jsx-runtime").JSX.Element;
+12
View File
@@ -0,0 +1,12 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_RouterClient = require("./RouterClient.cjs");
exports.RouterClient = require_RouterClient.RouterClient;
var _tanstack_router_core_ssr_client = require("@tanstack/router-core/ssr/client");
Object.keys(_tanstack_router_core_ssr_client).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function() {
return _tanstack_router_core_ssr_client[k];
}
});
});
@@ -0,0 +1,2 @@
export { RouterClient } from './RouterClient.cjs';
export * from '@tanstack/router-core/ssr/client';
@@ -0,0 +1,13 @@
const require_RouterServer = require("./RouterServer.cjs");
const require_renderRouterToString = require("./renderRouterToString.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/ssr/defaultRenderHandler.tsx
var defaultRenderHandler = (0, require("@tanstack/router-core/ssr/server").defineHandlerCallback)(({ router, responseHeaders }) => require_renderRouterToString.renderRouterToString({
router,
responseHeaders,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RouterServer.RouterServer, { router })
}));
//#endregion
exports.defaultRenderHandler = defaultRenderHandler;
//# sourceMappingURL=defaultRenderHandler.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"defaultRenderHandler.cjs","names":[],"sources":["../../../src/ssr/defaultRenderHandler.tsx"],"sourcesContent":["import { defineHandlerCallback } from '@tanstack/router-core/ssr/server'\nimport { renderRouterToString } from './renderRouterToString'\nimport { RouterServer } from './RouterServer'\n\nexport const defaultRenderHandler = defineHandlerCallback(\n ({ router, responseHeaders }) =>\n renderRouterToString({\n router,\n responseHeaders,\n children: <RouterServer router={router} />,\n }),\n)\n"],"mappings":";;;;AAIA,IAAa,wBAAA,6CAAA,EAAA,wBACV,EAAE,QAAQ,sBACT,6BAAA,qBAAqB;CACnB;CACA;CACA,UAAU,iBAAA,GAAA,kBAAA,KAAC,qBAAA,cAAD,EAAsB,OAAS,CAAA;AAC3C,CAAC,CACL"}
@@ -0,0 +1 @@
export declare const defaultRenderHandler: import('@tanstack/router-core/ssr/server').HandlerCallback<import('@tanstack/router-core').AnyRouter>;

Some files were not shown because too many files have changed in this diff Show More