@tanstack/react-router
Advanced tools
@@ -25,3 +25,6 @@ const require_runtime = require("./_virtual/_rolldown/runtime.cjs"); | ||
| loadPromise = importer().then((res) => { | ||
| if (!(_tanstack_router_core_isServer.isServer ?? typeof window === "undefined")) loadPromise = void 0; | ||
| if (!(_tanstack_router_core_isServer.isServer ?? typeof window === "undefined")) { | ||
| loadPromise = void 0; | ||
| lazyComp.preload = void 0; | ||
| } | ||
| comp = res[exportName ?? "default"]; | ||
@@ -28,0 +31,0 @@ }).catch((err) => { |
@@ -1,1 +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"} | ||
| {"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 // Resolved clients have no preload work; SSR can reuse the import.\n if (!(isServer ?? typeof window === 'undefined')) {\n loadPromise = undefined\n ;(lazyComp as any).preload = 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 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,cAAc;KAChD,cAAc,KAAA;KACb,SAAkB,UAAU,KAAA;IAC/B;IACA,OAAO,IAAI,cAAc;GAC3B,CAAC,EACA,OAAO,QAAQ;IACd,cAAc,KAAA;IAId,QAAQ;GACV,CAAC;EACL;EAEA,OAAO;CACT;CACA,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"} |
@@ -26,2 +26,3 @@ "use client"; | ||
| var outletMatchSelectionEqual = (a, b) => a[0] === b[0] && a[1] === b[1]; | ||
| var canWrapInSuspense = (router, route, ssr) => !route.isRoot || route.options.shellComponent || route.options.wrapInSuspense || ssr === false || ssr === "data-only" || !((_tanstack_router_core_isServer.isServer ?? router.isServer) || router.ssr); | ||
| var Match = react.memo(function MatchImpl({ routeId }) { | ||
@@ -45,3 +46,3 @@ const router = require_useRouter.useRouter(); | ||
| 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 ResolvedSuspenseBoundary = canWrapInSuspense(router, route, match.ssr) && (route.options.wrapInSuspense ?? pendingElement ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? react.Suspense : require_SafeFragment.SafeFragment; | ||
| const ResolvedCatchBoundary = routeErrorComponent ? require_CatchBoundary.CatchBoundary : require_SafeFragment.SafeFragment; | ||
@@ -109,2 +110,3 @@ const ResolvedNotFoundBoundary = routeNotFoundComponent ? require_not_found.CatchNotFound : require_SafeFragment.SafeFragment; | ||
| if (match.status === "pending") { | ||
| if (router.ssr && !canWrapInSuspense(router, route, match.ssr)) return out; | ||
| if (router._tx) throw router._tx[5]; | ||
@@ -111,0 +113,0 @@ return renderPending(router, route); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"Match.cjs","names":[],"sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport { isNotFound, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport { ClientOnly } from './ClientOnly'\nimport {\n nonRouteComponentContext,\n wrapInNonRouteComponentContext,\n} from './nonRouteComponentContext'\nimport type {\n AnyRoute,\n AnyRouteMatch,\n RootRouteOptions,\n} from '@tanstack/router-core'\n\nexport function renderPending(\n router: ReturnType<typeof useRouter>,\n route?: AnyRoute,\n) {\n const PendingComponent =\n route?.options.pendingComponent ?? router.options.defaultPendingComponent\n if (!PendingComponent) {\n return null\n }\n\n const pendingElement = <PendingComponent />\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(pendingElement, 'pendingComponent')\n : pendingElement\n}\n\ntype OutletMatchSelection = [\n parentGlobalNotFound: boolean,\n parentNotFoundError: unknown,\n]\n\nconst outletMatchSelectionEqual = (\n a: OutletMatchSelection,\n b: OutletMatchSelection,\n) => a[0] === b[0] && a[1] === b[1]\n\nexport const Match = React.memo(function MatchImpl({\n routeId,\n}: {\n routeId: string\n}) {\n const router = useRouter()\n\n if (isServer ?? router.isServer) {\n const match = router.stores.byRoute.get(routeId)!.get()!\n return <MatchView router={router} match={match} />\n }\n\n const matchStore = router.stores.getMatchStore(routeId)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const match = useStore(matchStore, (value) => value)\n return <MatchView router={router} match={match!} />\n})\n\nfunction MatchView({\n router,\n match,\n}: {\n router: ReturnType<typeof useRouter>\n match: AnyRouteMatch\n}) {\n const route: AnyRoute = router.routesById[match.routeId]\n\n const pendingElement = renderPending(router, route)\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the _notFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const resolvedNoSsr = match.ssr === false || match.ssr === 'data-only'\n const ResolvedSuspenseBoundary =\n (route.options.wrapInSuspense ??\n pendingElement ??\n ((route.options.errorComponent as any)?.preload || resolvedNoSsr))\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const ShellComponent = route.isRoot\n ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)\n : SafeFragment\n return (\n <ShellComponent>\n <matchContext.Provider value={match.routeId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => match}\n errorComponent={routeErrorComponent as any}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) {\n error.routeId ??= match.routeId\n throw error\n }\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Warning: Error in route match: ${match.id}`)\n }\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n error.routeId ??= match.routeId\n\n if (error.routeId !== match.routeId) {\n throw error\n }\n\n const notFoundElement = React.createElement(\n routeNotFoundComponent!,\n error as any,\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(\n notFoundElement,\n 'notFoundComponent',\n )\n : notFoundElement\n }}\n >\n {resolvedNoSsr ? (\n <ClientOnly fallback={pendingElement}>\n <MatchInner match={match} />\n </ClientOnly>\n ) : (\n <MatchInner match={match} />\n )}\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n {(isServer ?? router.isServer) &&\n route.parentRoute?.id === rootRouteId &&\n router.options.scrollRestoration ? (\n <ScrollRestoration />\n ) : null}\n </ShellComponent>\n )\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n match,\n}: {\n match: AnyRouteMatch\n}): any {\n const router = useRouter()\n const routeId = match.routeId\n const route = router.routesById[routeId] as AnyRoute\n const key = React.useMemo(() => {\n const remountFn =\n route.options.remountDeps ?? router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n return remountDeps ? JSON.stringify(remountDeps) : undefined\n }, [\n routeId,\n match.loaderDeps,\n match._strictParams,\n match._strictSearch,\n route.options.remountDeps,\n router.options.defaultRemountDeps,\n ])\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n return Comp ? <Comp key={key} /> : <Outlet />\n }, [key, route.options.component, router.options.defaultComponent])\n\n if (match.status === 'pending') {\n if (router._tx) {\n throw router._tx[5]\n }\n return renderPending(router, route)\n }\n\n if (match.status === 'notFound') {\n return renderRouteNotFound(router, route, match.error)\n }\n\n if (match.status === 'error') {\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route.options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n const errorElement = (\n <RouteErrorComponent\n error={match.error as any}\n reset={undefined as any}\n info={{\n componentStack: '',\n }}\n />\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(errorElement, 'errorComponent')\n : errorElement\n }\n throw match.error\n }\n\n return out\n})\n\n/**\n * Render the next child match in the route tree. Typically used inside\n * a route component to render nested routes.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent\n */\nexport const Outlet = React.memo(function OutletImpl() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const nonRouteComponent = React.useContext(nonRouteComponentContext!)\n if (nonRouteComponent) {\n console.warn(\n `Warning: An <Outlet /> was rendered inside a ${nonRouteComponent}. <Outlet /> should only be rendered inside a route component.`,\n )\n }\n }\n\n const router = useRouter()\n const routeId = React.useContext(matchContext)!\n\n let parentGlobalNotFound: boolean\n let parentNotFoundError: unknown\n let childRouteId: string | undefined\n\n if (isServer ?? router.isServer) {\n const matches = router.stores.matches.get()\n const parentIndex = matches.findIndex((match) => match.routeId === routeId)\n const parentMatch = matches[parentIndex]!\n parentGlobalNotFound = !!parentMatch._notFound\n parentNotFoundError = parentMatch.error\n childRouteId = matches[parentIndex + 1]?.routeId\n } else {\n const parentMatchStore = router.stores.getMatchStore(routeId)\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n ;[parentGlobalNotFound, parentNotFoundError] = useStore(\n parentMatchStore,\n (match): OutletMatchSelection => [!!match!._notFound, match!.error],\n outletMatchSelectionEqual,\n )\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n childRouteId = useStore(router.stores.ids, (ids) => {\n return ids[ids.indexOf(routeId) + 1]\n })\n }\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(\n router,\n router.routesById[routeId],\n parentNotFoundError,\n )\n }\n\n if (!childRouteId) {\n return null\n }\n\n const nextMatch = <Match routeId={childRouteId} />\n\n if (routeId === rootRouteId) {\n return (\n <React.Suspense fallback={renderPending(router)}>\n {nextMatch}\n </React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,SAAgB,cACd,QACA,OACA;CACA,MAAM,mBACJ,OAAO,QAAQ,oBAAoB,OAAO,QAAQ;CACpD,IAAI,CAAC,kBACH,OAAO;CAGT,MAAM,iBAAiB,iBAAA,GAAA,kBAAA,KAAC,kBAAD,CAAmB,CAAA;CAC1C,OAAA,QAAA,IAAA,aAAgC,eAC5B,iCAAA,+BAA+B,gBAAgB,kBAAkB,IACjE;AACN;AAOA,IAAM,6BACJ,GACA,MACG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;AAEjC,IAAa,QAAQ,MAAM,KAAK,SAAS,UAAU,EACjD,WAGC;CACD,MAAM,SAAS,kBAAA,UAAU;CAEzB,IAAI,+BAAA,YAAY,OAAO,UAErB,OAAO,iBAAA,GAAA,kBAAA,KAAC,WAAD;EAAmB;EAAe,OAD3B,OAAO,OAAO,QAAQ,IAAI,OAAO,EAAG,IACT;CAAQ,CAAA;CAMnD,OAAO,iBAAA,GAAA,kBAAA,KAAC,WAAD;EAAmB;EAAe,QAAA,GAAA,sBA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AO;EAG3D,CAAC,sBAAsB,wBAAA,GAAA,sBAAA,UACtB,mBACC,UAAgC,CAAC,CAAC,CAAC,MAAO,WAAW,MAAO,KAAK,GAClE,yBACF;EAGA,gBAAA,GAAA,sBAAA,UAAwB,OAAO,OAAO,MAAM,QAAQ;GAClD,OAAO,IAAI,IAAI,QAAQ,OAAO,IAAI;EACpC,CAAC;CACH;CAEA,IAAI,sBACF,OAAO,4BAAA,oBACL,QACA,OAAO,WAAW,UAClB,mBACF;CAGF,IAAI,CAAC,cACH,OAAO;CAGT,MAAM,YAAY,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAO,SAAS,aAAe,CAAA;CAEjD,IAAI,YAAY,sBAAA,aACd,OACE,iBAAA,GAAA,kBAAA,KAAC,MAAM,UAAP;EAAgB,UAAU,cAAc,MAAM;YAC3C;CACa,CAAA;CAIpB,OAAO;AACT,CAAC"} | ||
| {"version":3,"file":"Match.cjs","names":[],"sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport { isNotFound, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport { ClientOnly } from './ClientOnly'\nimport {\n nonRouteComponentContext,\n wrapInNonRouteComponentContext,\n} from './nonRouteComponentContext'\nimport type {\n AnyRoute,\n AnyRouteMatch,\n RootRouteOptions,\n} from '@tanstack/router-core'\n\nexport function renderPending(\n router: ReturnType<typeof useRouter>,\n route?: AnyRoute,\n) {\n const PendingComponent =\n route?.options.pendingComponent ?? router.options.defaultPendingComponent\n if (!PendingComponent) {\n return null\n }\n\n const pendingElement = <PendingComponent />\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(pendingElement, 'pendingComponent')\n : pendingElement\n}\n\ntype OutletMatchSelection = [\n parentGlobalNotFound: boolean,\n parentNotFoundError: unknown,\n]\n\nconst outletMatchSelectionEqual = (\n a: OutletMatchSelection,\n b: OutletMatchSelection,\n) => a[0] === b[0] && a[1] === b[1]\n\nconst canWrapInSuspense = (\n router: ReturnType<typeof useRouter>,\n route: AnyRoute,\n ssr: AnyRouteMatch['ssr'],\n) =>\n !route.isRoot ||\n (route.options as RootRouteOptions).shellComponent ||\n route.options.wrapInSuspense ||\n ssr === false ||\n ssr === 'data-only' ||\n !((isServer ?? router.isServer) || router.ssr)\n\nexport const Match = React.memo(function MatchImpl({\n routeId,\n}: {\n routeId: string\n}) {\n const router = useRouter()\n\n if (isServer ?? router.isServer) {\n const match = router.stores.byRoute.get(routeId)!.get()!\n return <MatchView router={router} match={match} />\n }\n\n const matchStore = router.stores.getMatchStore(routeId)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const match = useStore(matchStore, (value) => value)\n return <MatchView router={router} match={match!} />\n})\n\nfunction MatchView({\n router,\n match,\n}: {\n router: ReturnType<typeof useRouter>\n match: AnyRouteMatch\n}) {\n const route: AnyRoute = router.routesById[match.routeId]\n\n const pendingElement = renderPending(router, route)\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the _notFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const resolvedNoSsr = match.ssr === false || match.ssr === 'data-only'\n // A root component may render the document itself. Only place its Suspense\n // boundary in pure CSR, inside an explicit shell, or when explicitly opted in.\n const ResolvedSuspenseBoundary =\n canWrapInSuspense(router, route, match.ssr) &&\n (route.options.wrapInSuspense ??\n pendingElement ??\n ((route.options.errorComponent as any)?.preload || resolvedNoSsr))\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const ShellComponent = route.isRoot\n ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)\n : SafeFragment\n return (\n <ShellComponent>\n <matchContext.Provider value={match.routeId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => match}\n errorComponent={routeErrorComponent as any}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) {\n error.routeId ??= match.routeId\n throw error\n }\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Warning: Error in route match: ${match.id}`)\n }\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n error.routeId ??= match.routeId\n\n if (error.routeId !== match.routeId) {\n throw error\n }\n\n const notFoundElement = React.createElement(\n routeNotFoundComponent!,\n error as any,\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(\n notFoundElement,\n 'notFoundComponent',\n )\n : notFoundElement\n }}\n >\n {resolvedNoSsr ? (\n <ClientOnly fallback={pendingElement}>\n <MatchInner match={match} />\n </ClientOnly>\n ) : (\n <MatchInner match={match} />\n )}\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n {(isServer ?? router.isServer) &&\n route.parentRoute?.id === rootRouteId &&\n router.options.scrollRestoration ? (\n <ScrollRestoration />\n ) : null}\n </ShellComponent>\n )\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n match,\n}: {\n match: AnyRouteMatch\n}): any {\n const router = useRouter()\n const routeId = match.routeId\n const route = router.routesById[routeId] as AnyRoute\n const key = React.useMemo(() => {\n const remountFn =\n route.options.remountDeps ?? router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n return remountDeps ? JSON.stringify(remountDeps) : undefined\n }, [\n routeId,\n match.loaderDeps,\n match._strictParams,\n match._strictSearch,\n route.options.remountDeps,\n router.options.defaultRemountDeps,\n ])\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n return Comp ? <Comp key={key} /> : <Outlet />\n }, [key, route.options.component, router.options.defaultComponent])\n\n if (match.status === 'pending') {\n if (router.ssr && !canWrapInSuspense(router, route, match.ssr)) {\n // Replacing an SSR document root with pending UI would remove <html>.\n // Hydrated matches retain their prior data, so keep rendering it.\n return out\n }\n if (router._tx) {\n throw router._tx[5]\n }\n return renderPending(router, route)\n }\n\n if (match.status === 'notFound') {\n return renderRouteNotFound(router, route, match.error)\n }\n\n if (match.status === 'error') {\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route.options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n const errorElement = (\n <RouteErrorComponent\n error={match.error as any}\n reset={undefined as any}\n info={{\n componentStack: '',\n }}\n />\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(errorElement, 'errorComponent')\n : errorElement\n }\n throw match.error\n }\n\n return out\n})\n\n/**\n * Render the next child match in the route tree. Typically used inside\n * a route component to render nested routes.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent\n */\nexport const Outlet = React.memo(function OutletImpl() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const nonRouteComponent = React.useContext(nonRouteComponentContext!)\n if (nonRouteComponent) {\n console.warn(\n `Warning: An <Outlet /> was rendered inside a ${nonRouteComponent}. <Outlet /> should only be rendered inside a route component.`,\n )\n }\n }\n\n const router = useRouter()\n const routeId = React.useContext(matchContext)!\n\n let parentGlobalNotFound: boolean\n let parentNotFoundError: unknown\n let childRouteId: string | undefined\n\n if (isServer ?? router.isServer) {\n const matches = router.stores.matches.get()\n const parentIndex = matches.findIndex((match) => match.routeId === routeId)\n const parentMatch = matches[parentIndex]!\n parentGlobalNotFound = !!parentMatch._notFound\n parentNotFoundError = parentMatch.error\n childRouteId = matches[parentIndex + 1]?.routeId\n } else {\n const parentMatchStore = router.stores.getMatchStore(routeId)\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n ;[parentGlobalNotFound, parentNotFoundError] = useStore(\n parentMatchStore,\n (match): OutletMatchSelection => [!!match!._notFound, match!.error],\n outletMatchSelectionEqual,\n )\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n childRouteId = useStore(router.stores.ids, (ids) => {\n return ids[ids.indexOf(routeId) + 1]\n })\n }\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(\n router,\n router.routesById[routeId],\n parentNotFoundError,\n )\n }\n\n if (!childRouteId) {\n return null\n }\n\n const nextMatch = <Match routeId={childRouteId} />\n\n if (routeId === rootRouteId) {\n return (\n <React.Suspense fallback={renderPending(router)}>\n {nextMatch}\n </React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,SAAgB,cACd,QACA,OACA;CACA,MAAM,mBACJ,OAAO,QAAQ,oBAAoB,OAAO,QAAQ;CACpD,IAAI,CAAC,kBACH,OAAO;CAGT,MAAM,iBAAiB,iBAAA,GAAA,kBAAA,KAAC,kBAAD,CAAmB,CAAA;CAC1C,OAAA,QAAA,IAAA,aAAgC,eAC5B,iCAAA,+BAA+B,gBAAgB,kBAAkB,IACjE;AACN;AAOA,IAAM,6BACJ,GACA,MACG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;AAEjC,IAAM,qBACJ,QACA,OACA,QAEA,CAAC,MAAM,UACN,MAAM,QAA6B,kBACpC,MAAM,QAAQ,kBACd,QAAQ,SACR,QAAQ,eACR,GAAG,+BAAA,YAAY,OAAO,aAAa,OAAO;AAE5C,IAAa,QAAQ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,MAAM,SAAS,kBAAA,UAAU;CACzB,MAAM,UAAU,MAAM,WAAW,qBAAA,YAAY;CAE7C,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,IAAI,+BAAA,YAAY,OAAO,UAAU;EAC/B,MAAM,UAAU,OAAO,OAAO,QAAQ,IAAI;EAC1C,MAAM,cAAc,QAAQ,WAAW,UAAU,MAAM,YAAY,OAAO;EAC1E,MAAM,cAAc,QAAQ;EAC5B,uBAAuB,CAAC,CAAC,YAAY;EACrC,sBAAsB,YAAY;EAClC,eAAe,QAAQ,cAAc,IAAI;CAC3C,OAAO;EACL,MAAM,mBAAmB,OAAO,OAAO,cAAc,OAAO;EAG3D,CAAC,sBAAsB,wBAAA,GAAA,sBAAA,UACtB,mBACC,UAAgC,CAAC,CAAC,CAAC,MAAO,WAAW,MAAO,KAAK,GAClE,yBACF;EAGA,gBAAA,GAAA,sBAAA,UAAwB,OAAO,OAAO,MAAM,QAAQ;GAClD,OAAO,IAAI,IAAI,QAAQ,OAAO,IAAI;EACpC,CAAC;CACH;CAEA,IAAI,sBACF,OAAO,4BAAA,oBACL,QACA,OAAO,WAAW,UAClB,mBACF;CAGF,IAAI,CAAC,cACH,OAAO;CAGT,MAAM,YAAY,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAO,SAAS,aAAe,CAAA;CAEjD,IAAI,YAAY,sBAAA,aACd,OACE,iBAAA,GAAA,kBAAA,KAAC,MAAM,UAAP;EAAgB,UAAU,cAAc,MAAM;YAC3C;CACa,CAAA;CAIpB,OAAO;AACT,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"route.cjs","names":[],"sources":["../../src/route.tsx"],"sourcesContent":["import {\n BaseRootRoute,\n BaseRoute,\n BaseRouteApi,\n notFound,\n} from '@tanstack/router-core'\nimport React from 'react'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport { useRouteContext } from './useRouteContext'\nimport { useRouter } from './useRouter'\nimport { Link } from './link'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n ConstrainLiteral,\n ErrorComponentProps,\n NotFoundError,\n NotFoundRouteProps,\n Register,\n RegisteredRouter,\n ResolveFullPath,\n ResolveId,\n ResolveParams,\n RootRoute as RootRouteCore,\n RootRouteId,\n RootRouteOptions,\n RouteConstraints,\n Route as RouteCore,\n RouteIds,\n RouteMask,\n RouteOptions,\n RouteTypesById,\n RouterCore,\n ToMaskOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseSearchRoute } from './useSearch'\nimport type { UseRouteContextRoute } from './useRouteContext'\nimport type { LinkComponentRoute } from './link'\n\ndeclare module '@tanstack/router-core' {\n export interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent\n errorComponent?: false | null | undefined | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n }\n\n export interface RootRouteOptionsExtensions {\n shellComponent?: ({\n children,\n }: {\n children: React.ReactNode\n }) => React.ReactNode\n }\n\n export interface RouteExtensions<\n in out TId extends string,\n in out TFullPath extends string,\n > {\n useMatch: UseMatchRoute<TId>\n useRouteContext: UseRouteContextRoute<TId>\n useSearch: UseSearchRoute<TId>\n useParams: UseParamsRoute<TId>\n useLoaderDeps: UseLoaderDepsRoute<TId>\n useLoaderData: UseLoaderDataRoute<TId>\n useNavigate: () => UseNavigateResult<TFullPath>\n Link: LinkComponentRoute<TFullPath>\n }\n}\n\n/**\n * Returns a route-specific API that exposes type-safe hooks pre-bound\n * to a single route ID. Useful for consuming a route's APIs from files\n * where the route object isn't directly imported (e.g. code-split files).\n *\n * @param id Route ID string literal for the target route.\n * @returns A `RouteApi` instance bound to the given route ID.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/getRouteApiFunction\n */\nexport function getRouteApi<\n const TId,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return new RouteApi<TId, TRouter>({ id })\n}\n\nexport class RouteApi<\n TId,\n TRouter extends AnyRouter = RegisteredRouter,\n> extends BaseRouteApi<TId, TRouter> {\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n super({ id })\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<\n RouteTypesById<TRouter, TId>['fullPath']\n > => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.id as string].fullPath })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n\n Link: LinkComponentRoute<RouteTypesById<TRouter, TId>['fullPath']> =\n React.forwardRef((props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n const router = useRouter()\n const fullPath = router.routesById[this.id as string].fullPath\n return <Link ref={ref} from={fullPath as never} {...props} />\n }) as unknown as LinkComponentRoute<\n RouteTypesById<TRouter, TId>['fullPath']\n >\n}\n\nexport class Route<\n in out TRegister = unknown,\n in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n in out TPath extends RouteConstraints['TPath'] = '/',\n in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n in out TCustomId extends RouteConstraints['TCustomId'] = string,\n in out TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n in out TSSR = unknown,\n in out TServerMiddlewares = unknown,\n in out THandlers = undefined,\n>\n extends BaseRoute<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n implements\n RouteCore<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n{\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts?) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.fullPath })\n }\n\n Link: LinkComponentRoute<TFullPath> = React.forwardRef(\n (props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n return <Link ref={ref} from={this.fullPath as never} {...props} />\n },\n ) as unknown as LinkComponentRoute<TFullPath>\n}\n\n/**\n * Creates a non-root Route instance for code-based routing.\n *\n * Use this to define a route that will be composed into a route tree\n * (typically via a parent route's `addChildren`). If you're using file-based\n * routing, prefer `createFileRoute`.\n *\n * @param options Route options (path, component, loader, context, etc.).\n * @returns A Route instance to be attached to the route tree.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouteFunction\n */\nexport function createRoute<\n TRegister = unknown,\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n>(\n options: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares\n >,\n): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n> {\n return new Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n >(\n // TODO: Help us TypeChris, you're our only hope!\n options as any,\n )\n}\n\nexport type AnyRootRoute = RootRoute<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>\n\n/**\n * Creates a root route factory that requires a router context type.\n *\n * Use when your root route expects `context` to be provided to `createRouter`.\n * The returned function behaves like `createRootRoute` but enforces a context type.\n *\n * @returns A factory function to configure and return a root route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction\n */\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRegister = Register,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n >(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares\n >,\n ) => {\n return createRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares\n >(options)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TRegister = unknown,\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n in out TSSR = unknown,\n in out TServerMiddlewares = unknown,\n in out THandlers = undefined,\n>\n extends BaseRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n implements\n RootRouteCore<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n{\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<RootRouteId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<RootRouteId> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<RootRouteId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<RootRouteId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<RootRouteId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<RootRouteId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<'/'> => {\n return useNavigate({ from: this.fullPath })\n }\n\n Link: LinkComponentRoute<'/'> = React.forwardRef(\n (props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n return <Link ref={ref} from={this.fullPath} {...props} />\n },\n ) as unknown as LinkComponentRoute<'/'>\n}\n\n/**\n * Creates a root Route instance used to build your route tree.\n *\n * Typically paired with `createRouter({ routeTree })`. If you need to require\n * a typed router context, use `createRootRouteWithContext` instead.\n *\n * @param options Root route options (component, error, pending, etc.).\n * @returns A root route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteFunction\n */\nexport function createRootRoute<\n TRegister = Register,\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n THandlers = undefined,\n>(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n): RootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n> {\n return new RootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n >(options)\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<RouterCore<TRouteTree, 'never', boolean>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport interface DefaultRouteTypes<TProps> {\n component:\n | ((props: TProps) => any)\n | React.LazyExoticComponent<(props: TProps) => any>\n}\nexport interface RouteTypes<TProps> extends DefaultRouteTypes<TProps> {}\n\nexport type AsyncRouteComponent<TProps> = RouteTypes<TProps>['component'] & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent = AsyncRouteComponent<{}>\n\nexport type ErrorRouteComponent = AsyncRouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = RouteTypes<NotFoundRouteProps>['component']\n\nexport class NotFoundRoute<\n TRegister,\n TParentRoute extends AnyRootRoute,\n TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n> extends Route<\n TRegister,\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TRegister,\n TParentRoute,\n string,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares\n >,\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'path'\n | 'id'\n | 'params'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0FA,SAAgB,YAGd,IAA2D;CAC3D,OAAO,IAAI,SAAuB,EAAE,GAAG,CAAC;AAC1C;AAEA,IAAa,WAAb,cAGU,sBAAA,aAA2B;;;;CAInC,YAAY,EAAE,MAAmB;EAC/B,MAAM,EAAE,GAAG,CAAC;mBAGkB,SAAS;GACvC,OAAO,iBAAA,SAAS;IACd,QAAQ,MAAM;IACd,MAAM,KAAK;IACX,mBAAmB,MAAM;GAC3B,CAAQ;EACV;0BAE8C,SAAS;GACrD,OAAO,wBAAA,gBAAgB;IAAE,GAAI;IAAc,MAAM,KAAK;GAAG,CAAC;EAC5D;oBAEkC,SAAS;GAEzC,OAAO,kBAAA,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK;GACb,CAAQ;EACV;oBAEkC,SAAS;GAEzC,OAAO,kBAAA,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK;GACb,CAAQ;EACV;wBAE0C,SAAS;GACjD,OAAO,sBAAA,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK;IAAI,QAAQ;GAAM,CAAQ;EACvE;wBAE0C,SAAS;GACjD,OAAO,sBAAA,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK;IAAI,QAA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;;;;;;;;;AAYA,SAAgB,gBAYd,SAyBA;CACA,OAAO,IAAI,UAaT,OAAO;AACX;AAEA,SAAgB,gBAKd,MAGuB;CACvB,OAAO;AACT;AAmBA,IAAa,gBAAb,cAYU,MAiBR;CACA,YACE,SAyBA;EACA,MAAM;GACJ,GAAI;GACJ,IAAI;EACN,CAAC;CACH;AACF"} | ||
| {"version":3,"file":"route.cjs","names":[],"sources":["../../src/route.tsx"],"sourcesContent":["import {\n BaseRootRoute,\n BaseRoute,\n BaseRouteApi,\n notFound,\n} from '@tanstack/router-core'\nimport React from 'react'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport { useRouteContext } from './useRouteContext'\nimport { useRouter } from './useRouter'\nimport { Link } from './link'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n ConstrainLiteral,\n ErrorComponentProps,\n NotFoundError,\n NotFoundRouteProps,\n Register,\n RegisteredRouter,\n ResolveFullPath,\n ResolveId,\n ResolveParams,\n RootRoute as RootRouteCore,\n RootRouteId,\n RootRouteOptions,\n RouteConstraints,\n Route as RouteCore,\n RouteIds,\n RouteMask,\n RouteOptions,\n RouteTypesById,\n RouterCore,\n ToMaskOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseSearchRoute } from './useSearch'\nimport type { UseRouteContextRoute } from './useRouteContext'\nimport type { LinkComponentRoute } from './link'\n\ndeclare module '@tanstack/router-core' {\n export interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent\n errorComponent?: false | null | undefined | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n }\n\n export interface RootRouteOptionsExtensions {\n shellComponent?: ({\n children,\n }: {\n children: React.ReactNode\n }) => React.ReactNode\n }\n\n export interface RouteExtensions<\n in out TId extends string,\n in out TFullPath extends string,\n > {\n useMatch: UseMatchRoute<TId>\n useRouteContext: UseRouteContextRoute<TId>\n useSearch: UseSearchRoute<TId>\n useParams: UseParamsRoute<TId>\n useLoaderDeps: UseLoaderDepsRoute<TId>\n useLoaderData: UseLoaderDataRoute<TId>\n useNavigate: () => UseNavigateResult<TFullPath>\n Link: LinkComponentRoute<TFullPath>\n }\n}\n\n/**\n * Returns a route-specific API that exposes type-safe hooks pre-bound\n * to a single route ID. Useful for consuming a route's APIs from files\n * where the route object isn't directly imported (e.g. code-split files).\n *\n * @param id Route ID string literal for the target route.\n * @returns A `RouteApi` instance bound to the given route ID.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/getRouteApiFunction\n */\nexport function getRouteApi<\n const TId,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return new RouteApi<TId, TRouter>({ id })\n}\n\nexport class RouteApi<\n TId,\n TRouter extends AnyRouter = RegisteredRouter,\n> extends BaseRouteApi<TId, TRouter> {\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n super({ id })\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<\n RouteTypesById<TRouter, TId>['fullPath']\n > => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.id as string].fullPath })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n\n Link: LinkComponentRoute<RouteTypesById<TRouter, TId>['fullPath']> =\n React.forwardRef((props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n const router = useRouter()\n const fullPath = router.routesById[this.id as string].fullPath\n return <Link ref={ref} from={fullPath as never} {...props} />\n }) as unknown as LinkComponentRoute<\n RouteTypesById<TRouter, TId>['fullPath']\n >\n}\n\nexport class Route<\n in out TRegister = unknown,\n in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n in out TPath extends RouteConstraints['TPath'] = '/',\n in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n in out TCustomId extends RouteConstraints['TCustomId'] = string,\n in out TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n in out TSSR = unknown,\n in out TServerMiddlewares = unknown,\n in out THandlers = undefined,\n>\n extends BaseRoute<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n implements\n RouteCore<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n{\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts?) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.fullPath })\n }\n\n Link: LinkComponentRoute<TFullPath> = React.forwardRef(\n (props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n return <Link ref={ref} from={this.fullPath as never} {...props} />\n },\n ) as unknown as LinkComponentRoute<TFullPath>\n}\n\n/**\n * Creates a non-root Route instance for code-based routing.\n *\n * Use this to define a route that will be composed into a route tree\n * (typically via a parent route's `addChildren`). If you're using file-based\n * routing, prefer `createFileRoute`.\n *\n * @param options Route options (path, component, loader, context, etc.).\n * @returns A Route instance to be attached to the route tree.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouteFunction\n */\nexport function createRoute<\n TRegister = unknown,\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n>(\n options: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares\n >,\n): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n> {\n return new Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n >(\n // TODO: Help us TypeChris, you're our only hope!\n options as any,\n )\n}\n\nexport type AnyRootRoute = RootRoute<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>\n\n/**\n * Creates a root route factory that requires a router context type.\n *\n * Use when your root route expects `context` to be provided to `createRouter`.\n * The returned function behaves like `createRootRoute` but enforces a context type.\n *\n * @returns A factory function to configure and return a root route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction\n */\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRegister = Register,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n >(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares\n >,\n ) => {\n return createRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares\n >(options)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TRegister = unknown,\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n in out TSSR = unknown,\n in out TServerMiddlewares = unknown,\n in out THandlers = undefined,\n>\n extends BaseRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n implements\n RootRouteCore<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n{\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<RootRouteId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<RootRouteId> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<RootRouteId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<RootRouteId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<RootRouteId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<RootRouteId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<'/'> => {\n return useNavigate({ from: this.fullPath })\n }\n\n Link: LinkComponentRoute<'/'> = React.forwardRef(\n (props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n return <Link ref={ref} from={this.fullPath} {...props} />\n },\n ) as unknown as LinkComponentRoute<'/'>\n}\n\n/**\n * Creates a root Route instance used to build your route tree.\n *\n * Typically paired with `createRouter({ routeTree })`. If you need to require\n * a typed router context, use `createRootRouteWithContext` instead.\n *\n * @param options Root route options (component, error, pending, etc.).\n * @returns A root route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteFunction\n */\nexport function createRootRoute<\n TRegister = Register,\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n THandlers = undefined,\n>(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n): RootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n> {\n return new RootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n >(options)\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<RouterCore<TRouteTree, 'never', boolean>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport interface DefaultRouteTypes<TProps> {\n component:\n | ((props: TProps) => any)\n | React.LazyExoticComponent<(props: TProps) => any>\n}\nexport interface RouteTypes<TProps> extends DefaultRouteTypes<TProps> {}\n\nexport type AsyncRouteComponent<TProps> = RouteTypes<TProps>['component'] & {\n preload?: () => Promise<void> | undefined\n}\n\nexport type RouteComponent = AsyncRouteComponent<{}>\n\nexport type ErrorRouteComponent = AsyncRouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = RouteTypes<NotFoundRouteProps>['component']\n\nexport class NotFoundRoute<\n TRegister,\n TParentRoute extends AnyRootRoute,\n TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n> extends Route<\n TRegister,\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TRegister,\n TParentRoute,\n string,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares\n >,\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'path'\n | 'id'\n | 'params'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0FA,SAAgB,YAGd,IAA2D;CAC3D,OAAO,IAAI,SAAuB,EAAE,GAAG,CAAC;AAC1C;AAEA,IAAa,WAAb,cAGU,sBAAA,aAA2B;;;;CAInC,YAAY,EAAE,MAAmB;EAC/B,MAAM,EAAE,GAAG,CAAC;mBAGkB,SAAS;GACvC,OAAO,iBAAA,SAAS;IACd,QAAQ,MAAM;IACd,MAAM,KAAK;IACX,mBAAmB,MAAM;GAC3B,CAAQ;EACV;0BAE8C,SAAS;GACrD,OA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MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK;GACb,CAAQ;EACV;wBAEkD,SAAS;GACzD,OAAO,sBAAA,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK;GAAG,CAAQ;EACxD;wBAEkD,SAAS;GACzD,OAAO,sBAAA,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK;GAAG,CAAQ;EACxD;2BAE4C;GAC1C,OAAO,oBAAA,YAAY,EAAE,MAAM,KAAK,SAAS,CAAC;EAC5C;cAEgC,MAAA,QAAM,YACnC,OAAO,QAA+C;GACrD,OAAO,iBAAA,GAAA,kBAAA,KAAC,aAAA,MAAD;IAAW;IAAK,MAAM,KAAK;IAAU,GAAI;GAAQ,CAAA;EAC1D,CACF;CAhDA;AAiDF;;;;;;;;;;;AAYA,SAAgB,gBAYd,SAyBA;CACA,OAAO,IAAI,UAaT,OAAO;AACX;AAEA,SAAgB,gBAKd,MAGuB;CACvB,OAAO;AACT;AAmBA,IAAa,gBAAb,cAYU,MAiBR;CACA,YACE,SAyBA;EACA,MAAM;GACJ,GAAI;GACJ,IAAI;EACN,CAAC;CACH;AACF"} |
@@ -135,3 +135,3 @@ 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'; | ||
| export type AsyncRouteComponent<TProps> = RouteTypes<TProps>['component'] & { | ||
| preload?: () => Promise<void>; | ||
| preload?: () => Promise<void> | undefined; | ||
| }; | ||
@@ -138,0 +138,0 @@ export type RouteComponent = AsyncRouteComponent<{}>; |
@@ -23,3 +23,6 @@ import { reactUse } from "./utils.js"; | ||
| loadPromise = importer().then((res) => { | ||
| if (!(isServer ?? typeof window === "undefined")) loadPromise = void 0; | ||
| if (!(isServer ?? typeof window === "undefined")) { | ||
| loadPromise = void 0; | ||
| lazyComp.preload = void 0; | ||
| } | ||
| comp = res[exportName ?? "default"]; | ||
@@ -26,0 +29,0 @@ }).catch((err) => { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"lazyRouteComponent.js","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,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,IACE,sBAAsB,KAAK,KAC3B,EAAE,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,UACF,SAAS,KAAK,CAAC;OAEf,MAAM,KAAK;EAIf,OAAO,QAAM,cAAc,MAAM,KAAK;CACxC;CAEC,SAAkB,UAAU;CAE7B,OAAO;AACT"} | ||
| {"version":3,"file":"lazyRouteComponent.js","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 // Resolved clients have no preload work; SSR can reuse the import.\n if (!(isServer ?? typeof window === 'undefined')) {\n loadPromise = undefined\n ;(lazyComp as any).preload = 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 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,YAAY,OAAO,WAAW,cAAc;KAChD,cAAc,KAAA;KACb,SAAkB,UAAU,KAAA;IAC/B;IACA,OAAO,IAAI,cAAc;GAC3B,CAAC,EACA,OAAO,QAAQ;IACd,cAAc,KAAA;IAId,QAAQ;GACV,CAAC;EACL;EAEA,OAAO;CACT;CACA,MAAM,WAAW,SAAS,KAAK,OAAY;EACzC,IAAI,OAAO;GAIT,IACE,sBAAsB,KAAK,KAC3B,EAAE,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,UACF,SAAS,KAAK,CAAC;OAEf,MAAM,KAAK;EAIf,OAAO,QAAM,cAAc,MAAM,KAAK;CACxC;CAEC,SAAkB,UAAU;CAE7B,OAAO;AACT"} |
@@ -24,2 +24,3 @@ "use client"; | ||
| var outletMatchSelectionEqual = (a, b) => a[0] === b[0] && a[1] === b[1]; | ||
| var canWrapInSuspense = (router, route, ssr) => !route.isRoot || route.options.shellComponent || route.options.wrapInSuspense || ssr === false || ssr === "data-only" || !((isServer ?? router.isServer) || router.ssr); | ||
| var Match = React$1.memo(function MatchImpl({ routeId }) { | ||
@@ -43,3 +44,3 @@ const router = useRouter(); | ||
| const resolvedNoSsr = match.ssr === false || match.ssr === "data-only"; | ||
| const ResolvedSuspenseBoundary = route.options.wrapInSuspense ?? pendingElement ?? (route.options.errorComponent?.preload || resolvedNoSsr) ? React$1.Suspense : SafeFragment; | ||
| const ResolvedSuspenseBoundary = canWrapInSuspense(router, route, match.ssr) && (route.options.wrapInSuspense ?? pendingElement ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? React$1.Suspense : SafeFragment; | ||
| const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment; | ||
@@ -107,2 +108,3 @@ const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment; | ||
| if (match.status === "pending") { | ||
| if (router.ssr && !canWrapInSuspense(router, route, match.ssr)) return out; | ||
| if (router._tx) throw router._tx[5]; | ||
@@ -109,0 +111,0 @@ return renderPending(router, route); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"Match.js","names":[],"sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport { isNotFound, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport { ClientOnly } from './ClientOnly'\nimport {\n nonRouteComponentContext,\n wrapInNonRouteComponentContext,\n} from './nonRouteComponentContext'\nimport type {\n AnyRoute,\n AnyRouteMatch,\n RootRouteOptions,\n} from '@tanstack/router-core'\n\nexport function renderPending(\n router: ReturnType<typeof useRouter>,\n route?: AnyRoute,\n) {\n const PendingComponent =\n route?.options.pendingComponent ?? router.options.defaultPendingComponent\n if (!PendingComponent) {\n return null\n }\n\n const pendingElement = <PendingComponent />\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(pendingElement, 'pendingComponent')\n : pendingElement\n}\n\ntype OutletMatchSelection = [\n parentGlobalNotFound: boolean,\n parentNotFoundError: unknown,\n]\n\nconst outletMatchSelectionEqual = (\n a: OutletMatchSelection,\n b: OutletMatchSelection,\n) => a[0] === b[0] && a[1] === b[1]\n\nexport const Match = React.memo(function MatchImpl({\n routeId,\n}: {\n routeId: string\n}) {\n const router = useRouter()\n\n if (isServer ?? router.isServer) {\n const match = router.stores.byRoute.get(routeId)!.get()!\n return <MatchView router={router} match={match} />\n }\n\n const matchStore = router.stores.getMatchStore(routeId)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const match = useStore(matchStore, (value) => value)\n return <MatchView router={router} match={match!} />\n})\n\nfunction MatchView({\n router,\n match,\n}: {\n router: ReturnType<typeof useRouter>\n match: AnyRouteMatch\n}) {\n const route: AnyRoute = router.routesById[match.routeId]\n\n const pendingElement = renderPending(router, route)\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the _notFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const resolvedNoSsr = match.ssr === false || match.ssr === 'data-only'\n const ResolvedSuspenseBoundary =\n (route.options.wrapInSuspense ??\n pendingElement ??\n ((route.options.errorComponent as any)?.preload || resolvedNoSsr))\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const ShellComponent = route.isRoot\n ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)\n : SafeFragment\n return (\n <ShellComponent>\n <matchContext.Provider value={match.routeId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => match}\n errorComponent={routeErrorComponent as any}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) {\n error.routeId ??= match.routeId\n throw error\n }\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Warning: Error in route match: ${match.id}`)\n }\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n error.routeId ??= match.routeId\n\n if (error.routeId !== match.routeId) {\n throw error\n }\n\n const notFoundElement = React.createElement(\n routeNotFoundComponent!,\n error as any,\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(\n notFoundElement,\n 'notFoundComponent',\n )\n : notFoundElement\n }}\n >\n {resolvedNoSsr ? (\n <ClientOnly fallback={pendingElement}>\n <MatchInner match={match} />\n </ClientOnly>\n ) : (\n <MatchInner match={match} />\n )}\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n {(isServer ?? router.isServer) &&\n route.parentRoute?.id === rootRouteId &&\n router.options.scrollRestoration ? (\n <ScrollRestoration />\n ) : null}\n </ShellComponent>\n )\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n match,\n}: {\n match: AnyRouteMatch\n}): any {\n const router = useRouter()\n const routeId = match.routeId\n const route = router.routesById[routeId] as AnyRoute\n const key = React.useMemo(() => {\n const remountFn =\n route.options.remountDeps ?? router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n return remountDeps ? JSON.stringify(remountDeps) : undefined\n }, [\n routeId,\n match.loaderDeps,\n match._strictParams,\n match._strictSearch,\n route.options.remountDeps,\n router.options.defaultRemountDeps,\n ])\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n return Comp ? <Comp key={key} /> : <Outlet />\n }, [key, route.options.component, router.options.defaultComponent])\n\n if (match.status === 'pending') {\n if (router._tx) {\n throw router._tx[5]\n }\n return renderPending(router, route)\n }\n\n if (match.status === 'notFound') {\n return renderRouteNotFound(router, route, match.error)\n }\n\n if (match.status === 'error') {\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route.options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n const errorElement = (\n <RouteErrorComponent\n error={match.error as any}\n reset={undefined as any}\n info={{\n componentStack: '',\n }}\n />\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(errorElement, 'errorComponent')\n : errorElement\n }\n throw match.error\n }\n\n return out\n})\n\n/**\n * Render the next child match in the route tree. Typically used inside\n * a route component to render nested routes.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent\n */\nexport const Outlet = React.memo(function OutletImpl() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const nonRouteComponent = React.useContext(nonRouteComponentContext!)\n if (nonRouteComponent) {\n console.warn(\n `Warning: An <Outlet /> was rendered inside a ${nonRouteComponent}. <Outlet /> should only be rendered inside a route component.`,\n )\n }\n }\n\n const router = useRouter()\n const routeId = React.useContext(matchContext)!\n\n let parentGlobalNotFound: boolean\n let parentNotFoundError: unknown\n let childRouteId: string | undefined\n\n if (isServer ?? router.isServer) {\n const matches = router.stores.matches.get()\n const parentIndex = matches.findIndex((match) => match.routeId === routeId)\n const parentMatch = matches[parentIndex]!\n parentGlobalNotFound = !!parentMatch._notFound\n parentNotFoundError = parentMatch.error\n childRouteId = matches[parentIndex + 1]?.routeId\n } else {\n const parentMatchStore = router.stores.getMatchStore(routeId)\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n ;[parentGlobalNotFound, parentNotFoundError] = useStore(\n parentMatchStore,\n (match): OutletMatchSelection => [!!match!._notFound, match!.error],\n outletMatchSelectionEqual,\n )\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n childRouteId = useStore(router.stores.ids, (ids) => {\n return ids[ids.indexOf(routeId) + 1]\n })\n }\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(\n router,\n router.routesById[routeId],\n parentNotFoundError,\n )\n }\n\n if (!childRouteId) {\n return null\n }\n\n const nextMatch = <Match routeId={childRouteId} />\n\n if (routeId === rootRouteId) {\n return (\n <React.Suspense fallback={renderPending(router)}>\n {nextMatch}\n </React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,SAAgB,cACd,QACA,OACA;CACA,MAAM,mBACJ,OAAO,QAAQ,oBAAoB,OAAO,QAAQ;CACpD,IAAI,CAAC,kBACH,OAAO;CAGT,MAAM,iBAAiB,oBAAC,kBAAD,CAAmB,CAAA;CAC1C,OAAA,QAAA,IAAA,aAAgC,eAC5B,+BAA+B,gBAAgB,kBAAkB,IACjE;AACN;AAOA,IAAM,6BACJ,GACA,MACG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;AAEjC,IAAa,QAAQ,QAAM,KAAK,SAAS,UAAU,EACjD,WAGC;CACD,MAAM,SAAS,UAAU;CAEzB,IAAI,YAAY,OAAO,UAErB,OAAO,oBAAC,WAAD;EAAmB;EAAe,OAD3B,OAAO,OAAO,QAAQ,IAAI,OAAO,EAAG,IACT;CAAQ,CAAA;CAMnD,OAAO,oBAAC,WAAD;EAAmB;EAAe,OAD3B,SAFK,OAAO,OAAO,cAAc,OAExB,IAAa,UAAU,KACL;CAAS,CAAA;AACpD,CAAC;AAED,SAAS,UAAU,EACjB,QACA,SAIC;CACD,MAAM,QAAkB,OAAO,WAAW,MAAM;CAEhD,MAAM,iBAAiB,cAAc,QAAQ,KAAK;CAElD,MAAM,sBACJ,MAAM,QAAQ,kBAAkB,OAAO,QAAQ;CAEjD,MAAM,eAAe,MAAM,QAAQ,WAAW,OAAO,QAAQ;CAE7D,MAAM,yBAAyB,MAAM,SAEhC,MAAM,QAAQ,qBACf,OAAO,QAAQ,eAAe,QAAQ,YACtC,MAAM,QAAQ;CAElB,MAAM,gBAAgB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kBAAkB,+DACpE;CAEJ;CAEA,MAAM,SAAS,UAAU;CACzB,MAAM,UAAU,QAAM,WAAW,YAAY;CAE7C,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,IAAI,YAAY,OAAO,UAAU;EAC/B,MAAM,UAAU,OAAO,OAAO,QAAQ,IAAI;EAC1C,MAAM,cAAc,QAAQ,WAAW,UAAU,MAAM,YAAY,OAAO;EAC1E,MAAM,cAAc,QAAQ;EAC5B,uBAAuB,CAAC,CAAC,YAAY;EACrC,sBAAsB,YAAY;EAClC,eAAe,QAAQ,cAAc,IAAI;CAC3C,OAAO;EACL,MAAM,mBAAmB,OAAO,OAAO,cAAc,OAAO;EAG3D,CAAC,sBAAsB,uBAAuB,SAC7C,mBACC,UAAgC,CAAC,CAAC,CAAC,MAAO,WAAW,MAAO,KAAK,GAClE,yBACF;EAGA,eAAe,SAAS,OAAO,OAAO,MAAM,QAAQ;GAClD,OAAO,IAAI,IAAI,QAAQ,OAAO,IAAI;EACpC,CAAC;CACH;CAEA,IAAI,sBACF,OAAO,oBACL,QACA,OAAO,WAAW,UAClB,mBACF;CAGF,IAAI,CAAC,cACH,OAAO;CAGT,MAAM,YAAY,oBAAC,OAAD,EAAO,SAAS,aAAe,CAAA;CAEjD,IAAI,YAAY,aACd,OACE,oBAAC,QAAM,UAAP;EAAgB,UAAU,cAAc,MAAM;YAC3C;CACa,CAAA;CAIpB,OAAO;AACT,CAAC"} | ||
| {"version":3,"file":"Match.js","names":[],"sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport { isNotFound, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport { ClientOnly } from './ClientOnly'\nimport {\n nonRouteComponentContext,\n wrapInNonRouteComponentContext,\n} from './nonRouteComponentContext'\nimport type {\n AnyRoute,\n AnyRouteMatch,\n RootRouteOptions,\n} from '@tanstack/router-core'\n\nexport function renderPending(\n router: ReturnType<typeof useRouter>,\n route?: AnyRoute,\n) {\n const PendingComponent =\n route?.options.pendingComponent ?? router.options.defaultPendingComponent\n if (!PendingComponent) {\n return null\n }\n\n const pendingElement = <PendingComponent />\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(pendingElement, 'pendingComponent')\n : pendingElement\n}\n\ntype OutletMatchSelection = [\n parentGlobalNotFound: boolean,\n parentNotFoundError: unknown,\n]\n\nconst outletMatchSelectionEqual = (\n a: OutletMatchSelection,\n b: OutletMatchSelection,\n) => a[0] === b[0] && a[1] === b[1]\n\nconst canWrapInSuspense = (\n router: ReturnType<typeof useRouter>,\n route: AnyRoute,\n ssr: AnyRouteMatch['ssr'],\n) =>\n !route.isRoot ||\n (route.options as RootRouteOptions).shellComponent ||\n route.options.wrapInSuspense ||\n ssr === false ||\n ssr === 'data-only' ||\n !((isServer ?? router.isServer) || router.ssr)\n\nexport const Match = React.memo(function MatchImpl({\n routeId,\n}: {\n routeId: string\n}) {\n const router = useRouter()\n\n if (isServer ?? router.isServer) {\n const match = router.stores.byRoute.get(routeId)!.get()!\n return <MatchView router={router} match={match} />\n }\n\n const matchStore = router.stores.getMatchStore(routeId)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const match = useStore(matchStore, (value) => value)\n return <MatchView router={router} match={match!} />\n})\n\nfunction MatchView({\n router,\n match,\n}: {\n router: ReturnType<typeof useRouter>\n match: AnyRouteMatch\n}) {\n const route: AnyRoute = router.routesById[match.routeId]\n\n const pendingElement = renderPending(router, route)\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the _notFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const resolvedNoSsr = match.ssr === false || match.ssr === 'data-only'\n // A root component may render the document itself. Only place its Suspense\n // boundary in pure CSR, inside an explicit shell, or when explicitly opted in.\n const ResolvedSuspenseBoundary =\n canWrapInSuspense(router, route, match.ssr) &&\n (route.options.wrapInSuspense ??\n pendingElement ??\n ((route.options.errorComponent as any)?.preload || resolvedNoSsr))\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const ShellComponent = route.isRoot\n ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)\n : SafeFragment\n return (\n <ShellComponent>\n <matchContext.Provider value={match.routeId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => match}\n errorComponent={routeErrorComponent as any}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) {\n error.routeId ??= match.routeId\n throw error\n }\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Warning: Error in route match: ${match.id}`)\n }\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n error.routeId ??= match.routeId\n\n if (error.routeId !== match.routeId) {\n throw error\n }\n\n const notFoundElement = React.createElement(\n routeNotFoundComponent!,\n error as any,\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(\n notFoundElement,\n 'notFoundComponent',\n )\n : notFoundElement\n }}\n >\n {resolvedNoSsr ? (\n <ClientOnly fallback={pendingElement}>\n <MatchInner match={match} />\n </ClientOnly>\n ) : (\n <MatchInner match={match} />\n )}\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n {(isServer ?? router.isServer) &&\n route.parentRoute?.id === rootRouteId &&\n router.options.scrollRestoration ? (\n <ScrollRestoration />\n ) : null}\n </ShellComponent>\n )\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n match,\n}: {\n match: AnyRouteMatch\n}): any {\n const router = useRouter()\n const routeId = match.routeId\n const route = router.routesById[routeId] as AnyRoute\n const key = React.useMemo(() => {\n const remountFn =\n route.options.remountDeps ?? router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n return remountDeps ? JSON.stringify(remountDeps) : undefined\n }, [\n routeId,\n match.loaderDeps,\n match._strictParams,\n match._strictSearch,\n route.options.remountDeps,\n router.options.defaultRemountDeps,\n ])\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n return Comp ? <Comp key={key} /> : <Outlet />\n }, [key, route.options.component, router.options.defaultComponent])\n\n if (match.status === 'pending') {\n if (router.ssr && !canWrapInSuspense(router, route, match.ssr)) {\n // Replacing an SSR document root with pending UI would remove <html>.\n // Hydrated matches retain their prior data, so keep rendering it.\n return out\n }\n if (router._tx) {\n throw router._tx[5]\n }\n return renderPending(router, route)\n }\n\n if (match.status === 'notFound') {\n return renderRouteNotFound(router, route, match.error)\n }\n\n if (match.status === 'error') {\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route.options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n const errorElement = (\n <RouteErrorComponent\n error={match.error as any}\n reset={undefined as any}\n info={{\n componentStack: '',\n }}\n />\n )\n return process.env.NODE_ENV !== 'production'\n ? wrapInNonRouteComponentContext(errorElement, 'errorComponent')\n : errorElement\n }\n throw match.error\n }\n\n return out\n})\n\n/**\n * Render the next child match in the route tree. Typically used inside\n * a route component to render nested routes.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent\n */\nexport const Outlet = React.memo(function OutletImpl() {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const nonRouteComponent = React.useContext(nonRouteComponentContext!)\n if (nonRouteComponent) {\n console.warn(\n `Warning: An <Outlet /> was rendered inside a ${nonRouteComponent}. <Outlet /> should only be rendered inside a route component.`,\n )\n }\n }\n\n const router = useRouter()\n const routeId = React.useContext(matchContext)!\n\n let parentGlobalNotFound: boolean\n let parentNotFoundError: unknown\n let childRouteId: string | undefined\n\n if (isServer ?? router.isServer) {\n const matches = router.stores.matches.get()\n const parentIndex = matches.findIndex((match) => match.routeId === routeId)\n const parentMatch = matches[parentIndex]!\n parentGlobalNotFound = !!parentMatch._notFound\n parentNotFoundError = parentMatch.error\n childRouteId = matches[parentIndex + 1]?.routeId\n } else {\n const parentMatchStore = router.stores.getMatchStore(routeId)\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n ;[parentGlobalNotFound, parentNotFoundError] = useStore(\n parentMatchStore,\n (match): OutletMatchSelection => [!!match!._notFound, match!.error],\n outletMatchSelectionEqual,\n )\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n childRouteId = useStore(router.stores.ids, (ids) => {\n return ids[ids.indexOf(routeId) + 1]\n })\n }\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(\n router,\n router.routesById[routeId],\n parentNotFoundError,\n )\n }\n\n if (!childRouteId) {\n return null\n }\n\n const nextMatch = <Match routeId={childRouteId} />\n\n if (routeId === rootRouteId) {\n return (\n <React.Suspense fallback={renderPending(router)}>\n {nextMatch}\n </React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,SAAgB,cACd,QACA,OACA;CACA,MAAM,mBACJ,OAAO,QAAQ,oBAAoB,OAAO,QAAQ;CACpD,IAAI,CAAC,kBACH,OAAO;CAGT,MAAM,iBAAiB,oBAAC,kBAAD,CAAmB,CAAA;CAC1C,OAAA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,OAAO,QAAQ,IAAI;EAC1C,MAAM,cAAc,QAAQ,WAAW,UAAU,MAAM,YAAY,OAAO;EAC1E,MAAM,cAAc,QAAQ;EAC5B,uBAAuB,CAAC,CAAC,YAAY;EACrC,sBAAsB,YAAY;EAClC,eAAe,QAAQ,cAAc,IAAI;CAC3C,OAAO;EACL,MAAM,mBAAmB,OAAO,OAAO,cAAc,OAAO;EAG3D,CAAC,sBAAsB,uBAAuB,SAC7C,mBACC,UAAgC,CAAC,CAAC,CAAC,MAAO,WAAW,MAAO,KAAK,GAClE,yBACF;EAGA,eAAe,SAAS,OAAO,OAAO,MAAM,QAAQ;GAClD,OAAO,IAAI,IAAI,QAAQ,OAAO,IAAI;EACpC,CAAC;CACH;CAEA,IAAI,sBACF,OAAO,oBACL,QACA,OAAO,WAAW,UAClB,mBACF;CAGF,IAAI,CAAC,cACH,OAAO;CAGT,MAAM,YAAY,oBAAC,OAAD,EAAO,SAAS,aAAe,CAAA;CAEjD,IAAI,YAAY,aACd,OACE,oBAAC,QAAM,UAAP;EAAgB,UAAU,cAAc,MAAM;YAC3C;CACa,CAAA;CAIpB,OAAO;AACT,CAAC"} |
@@ -135,3 +135,3 @@ 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'; | ||
| export type AsyncRouteComponent<TProps> = RouteTypes<TProps>['component'] & { | ||
| preload?: () => Promise<void>; | ||
| preload?: () => Promise<void> | undefined; | ||
| }; | ||
@@ -138,0 +138,0 @@ export type RouteComponent = AsyncRouteComponent<{}>; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"route.js","names":[],"sources":["../../src/route.tsx"],"sourcesContent":["import {\n BaseRootRoute,\n BaseRoute,\n BaseRouteApi,\n notFound,\n} from '@tanstack/router-core'\nimport React from 'react'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport { useRouteContext } from './useRouteContext'\nimport { useRouter } from './useRouter'\nimport { Link } from './link'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n ConstrainLiteral,\n ErrorComponentProps,\n NotFoundError,\n NotFoundRouteProps,\n Register,\n RegisteredRouter,\n ResolveFullPath,\n ResolveId,\n ResolveParams,\n RootRoute as RootRouteCore,\n RootRouteId,\n RootRouteOptions,\n RouteConstraints,\n Route as RouteCore,\n RouteIds,\n RouteMask,\n RouteOptions,\n RouteTypesById,\n RouterCore,\n ToMaskOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseSearchRoute } from './useSearch'\nimport type { UseRouteContextRoute } from './useRouteContext'\nimport type { LinkComponentRoute } from './link'\n\ndeclare module '@tanstack/router-core' {\n export interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent\n errorComponent?: false | null | undefined | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n }\n\n export interface RootRouteOptionsExtensions {\n shellComponent?: ({\n children,\n }: {\n children: React.ReactNode\n }) => React.ReactNode\n }\n\n export interface RouteExtensions<\n in out TId extends string,\n in out TFullPath extends string,\n > {\n useMatch: UseMatchRoute<TId>\n useRouteContext: UseRouteContextRoute<TId>\n useSearch: UseSearchRoute<TId>\n useParams: UseParamsRoute<TId>\n useLoaderDeps: UseLoaderDepsRoute<TId>\n useLoaderData: UseLoaderDataRoute<TId>\n useNavigate: () => UseNavigateResult<TFullPath>\n Link: LinkComponentRoute<TFullPath>\n }\n}\n\n/**\n * Returns a route-specific API that exposes type-safe hooks pre-bound\n * to a single route ID. Useful for consuming a route's APIs from files\n * where the route object isn't directly imported (e.g. code-split files).\n *\n * @param id Route ID string literal for the target route.\n * @returns A `RouteApi` instance bound to the given route ID.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/getRouteApiFunction\n */\nexport function getRouteApi<\n const TId,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return new RouteApi<TId, TRouter>({ id })\n}\n\nexport class RouteApi<\n TId,\n TRouter extends AnyRouter = RegisteredRouter,\n> extends BaseRouteApi<TId, TRouter> {\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n super({ id })\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<\n RouteTypesById<TRouter, TId>['fullPath']\n > => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.id as string].fullPath })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n\n Link: LinkComponentRoute<RouteTypesById<TRouter, TId>['fullPath']> =\n React.forwardRef((props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n const router = useRouter()\n const fullPath = router.routesById[this.id as string].fullPath\n return <Link ref={ref} from={fullPath as never} {...props} />\n }) as unknown as LinkComponentRoute<\n RouteTypesById<TRouter, TId>['fullPath']\n >\n}\n\nexport class Route<\n in out TRegister = unknown,\n in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n in out TPath extends RouteConstraints['TPath'] = '/',\n in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n in out TCustomId extends RouteConstraints['TCustomId'] = string,\n in out TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n in out TSSR = unknown,\n in out TServerMiddlewares = unknown,\n in out THandlers = undefined,\n>\n extends BaseRoute<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n implements\n RouteCore<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n{\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts?) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.fullPath })\n }\n\n Link: LinkComponentRoute<TFullPath> = React.forwardRef(\n (props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n return <Link ref={ref} from={this.fullPath as never} {...props} />\n },\n ) as unknown as LinkComponentRoute<TFullPath>\n}\n\n/**\n * Creates a non-root Route instance for code-based routing.\n *\n * Use this to define a route that will be composed into a route tree\n * (typically via a parent route's `addChildren`). If you're using file-based\n * routing, prefer `createFileRoute`.\n *\n * @param options Route options (path, component, loader, context, etc.).\n * @returns A Route instance to be attached to the route tree.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouteFunction\n */\nexport function createRoute<\n TRegister = unknown,\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n>(\n options: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares\n >,\n): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n> {\n return new Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n >(\n // TODO: Help us TypeChris, you're our only hope!\n options as any,\n )\n}\n\nexport type AnyRootRoute = RootRoute<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>\n\n/**\n * Creates a root route factory that requires a router context type.\n *\n * Use when your root route expects `context` to be provided to `createRouter`.\n * The returned function behaves like `createRootRoute` but enforces a context type.\n *\n * @returns A factory function to configure and return a root route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction\n */\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRegister = Register,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n >(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares\n >,\n ) => {\n return createRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares\n >(options)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TRegister = unknown,\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n in out TSSR = unknown,\n in out TServerMiddlewares = unknown,\n in out THandlers = undefined,\n>\n extends BaseRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n implements\n RootRouteCore<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n{\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<RootRouteId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<RootRouteId> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<RootRouteId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<RootRouteId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<RootRouteId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<RootRouteId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<'/'> => {\n return useNavigate({ from: this.fullPath })\n }\n\n Link: LinkComponentRoute<'/'> = React.forwardRef(\n (props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n return <Link ref={ref} from={this.fullPath} {...props} />\n },\n ) as unknown as LinkComponentRoute<'/'>\n}\n\n/**\n * Creates a root Route instance used to build your route tree.\n *\n * Typically paired with `createRouter({ routeTree })`. If you need to require\n * a typed router context, use `createRootRouteWithContext` instead.\n *\n * @param options Root route options (component, error, pending, etc.).\n * @returns A root route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteFunction\n */\nexport function createRootRoute<\n TRegister = Register,\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n THandlers = undefined,\n>(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n): RootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n> {\n return new RootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n >(options)\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<RouterCore<TRouteTree, 'never', boolean>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport interface DefaultRouteTypes<TProps> {\n component:\n | ((props: TProps) => any)\n | React.LazyExoticComponent<(props: TProps) => any>\n}\nexport interface RouteTypes<TProps> extends DefaultRouteTypes<TProps> {}\n\nexport type AsyncRouteComponent<TProps> = RouteTypes<TProps>['component'] & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent = AsyncRouteComponent<{}>\n\nexport type ErrorRouteComponent = AsyncRouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = RouteTypes<NotFoundRouteProps>['component']\n\nexport class NotFoundRoute<\n TRegister,\n TParentRoute extends AnyRootRoute,\n TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n> extends Route<\n TRegister,\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TRegister,\n TParentRoute,\n string,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares\n >,\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'path'\n | 'id'\n | 'params'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0FA,SAAgB,YAGd,IAA2D;CAC3D,OAAO,IAAI,SAAuB,EAAE,GAAG,CAAC;AAC1C;AAEA,IAAa,WAAb,cAGU,aAA2B;;;;CAInC,YAAY,EAAE,MAAmB;EAC/B,MAAM,EAAE,GAAG,CAAC;mBAGkB,SAAS;GACvC,OAAO,SAAS;IACd,QAAQ,MAAM;IACd,MAAM,KAAK;IACX,mBAAmB,MAAM;GAC3B,CAAQ;EACV;0BAE8C,SAAS;GACrD,OAAO,gBAAgB;IAAE,GAAI;IAAc,MAAM,KAAK;GAAG,CAAC;EAC5D;oBAEkC,SAAS;GAEzC,OAAO,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK;GACb,CAAQ;EACV;oBAEkC,SAAS;GAEzC,OAAO,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK;GACb,CAAQ;EACV;wBAE0C,SAAS;G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AGuB;CACvB,OAAO;AACT;AAmBA,IAAa,gBAAb,cAYU,MAiBR;CACA,YACE,SAyBA;EACA,MAAM;GACJ,GAAI;GACJ,IAAI;EACN,CAAC;CACH;AACF"} | ||
| {"version":3,"file":"route.js","names":[],"sources":["../../src/route.tsx"],"sourcesContent":["import {\n BaseRootRoute,\n BaseRoute,\n BaseRouteApi,\n notFound,\n} from '@tanstack/router-core'\nimport React from 'react'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport { useRouteContext } from './useRouteContext'\nimport { useRouter } from './useRouter'\nimport { Link } from './link'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n ConstrainLiteral,\n ErrorComponentProps,\n NotFoundError,\n NotFoundRouteProps,\n Register,\n RegisteredRouter,\n ResolveFullPath,\n ResolveId,\n ResolveParams,\n RootRoute as RootRouteCore,\n RootRouteId,\n RootRouteOptions,\n RouteConstraints,\n Route as RouteCore,\n RouteIds,\n RouteMask,\n RouteOptions,\n RouteTypesById,\n RouterCore,\n ToMaskOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseSearchRoute } from './useSearch'\nimport type { UseRouteContextRoute } from './useRouteContext'\nimport type { LinkComponentRoute } from './link'\n\ndeclare module '@tanstack/router-core' {\n export interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent\n errorComponent?: false | null | undefined | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n }\n\n export interface RootRouteOptionsExtensions {\n shellComponent?: ({\n children,\n }: {\n children: React.ReactNode\n }) => React.ReactNode\n }\n\n export interface RouteExtensions<\n in out TId extends string,\n in out TFullPath extends string,\n > {\n useMatch: UseMatchRoute<TId>\n useRouteContext: UseRouteContextRoute<TId>\n useSearch: UseSearchRoute<TId>\n useParams: UseParamsRoute<TId>\n useLoaderDeps: UseLoaderDepsRoute<TId>\n useLoaderData: UseLoaderDataRoute<TId>\n useNavigate: () => UseNavigateResult<TFullPath>\n Link: LinkComponentRoute<TFullPath>\n }\n}\n\n/**\n * Returns a route-specific API that exposes type-safe hooks pre-bound\n * to a single route ID. Useful for consuming a route's APIs from files\n * where the route object isn't directly imported (e.g. code-split files).\n *\n * @param id Route ID string literal for the target route.\n * @returns A `RouteApi` instance bound to the given route ID.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/getRouteApiFunction\n */\nexport function getRouteApi<\n const TId,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return new RouteApi<TId, TRouter>({ id })\n}\n\nexport class RouteApi<\n TId,\n TRouter extends AnyRouter = RegisteredRouter,\n> extends BaseRouteApi<TId, TRouter> {\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n super({ id })\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<\n RouteTypesById<TRouter, TId>['fullPath']\n > => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.id as string].fullPath })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n\n Link: LinkComponentRoute<RouteTypesById<TRouter, TId>['fullPath']> =\n React.forwardRef((props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n const router = useRouter()\n const fullPath = router.routesById[this.id as string].fullPath\n return <Link ref={ref} from={fullPath as never} {...props} />\n }) as unknown as LinkComponentRoute<\n RouteTypesById<TRouter, TId>['fullPath']\n >\n}\n\nexport class Route<\n in out TRegister = unknown,\n in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n in out TPath extends RouteConstraints['TPath'] = '/',\n in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n in out TCustomId extends RouteConstraints['TCustomId'] = string,\n in out TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n in out TSSR = unknown,\n in out TServerMiddlewares = unknown,\n in out THandlers = undefined,\n>\n extends BaseRoute<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n implements\n RouteCore<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n{\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts?) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.fullPath })\n }\n\n Link: LinkComponentRoute<TFullPath> = React.forwardRef(\n (props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n return <Link ref={ref} from={this.fullPath as never} {...props} />\n },\n ) as unknown as LinkComponentRoute<TFullPath>\n}\n\n/**\n * Creates a non-root Route instance for code-based routing.\n *\n * Use this to define a route that will be composed into a route tree\n * (typically via a parent route's `addChildren`). If you're using file-based\n * routing, prefer `createFileRoute`.\n *\n * @param options Route options (path, component, loader, context, etc.).\n * @returns A Route instance to be attached to the route tree.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouteFunction\n */\nexport function createRoute<\n TRegister = unknown,\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n>(\n options: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares\n >,\n): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n> {\n return new Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n >(\n // TODO: Help us TypeChris, you're our only hope!\n options as any,\n )\n}\n\nexport type AnyRootRoute = RootRoute<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>\n\n/**\n * Creates a root route factory that requires a router context type.\n *\n * Use when your root route expects `context` to be provided to `createRouter`.\n * The returned function behaves like `createRootRoute` but enforces a context type.\n *\n * @returns A factory function to configure and return a root route.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction\n */\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRegister = Register,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n >(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares\n >,\n ) => {\n return createRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares\n >(options)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TRegister = unknown,\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n in out TSSR = unknown,\n in out TServerMiddlewares = unknown,\n in out THandlers = undefined,\n>\n extends BaseRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n implements\n RootRouteCore<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes,\n TSSR,\n TServerMiddlewares,\n THandlers\n >\n{\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) {\n super(options)\n }\n\n useMatch: UseMatchRoute<RootRouteId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<RootRouteId> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.id })\n }\n\n useSearch: UseSearchRoute<RootRouteId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<RootRouteId> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<RootRouteId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<RootRouteId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<'/'> => {\n return useNavigate({ from: this.fullPath })\n }\n\n Link: LinkComponentRoute<'/'> = React.forwardRef(\n (props, ref: React.ForwardedRef<HTMLAnchorElement>) => {\n return <Link ref={ref} from={this.fullPath} {...props} />\n },\n ) as unknown as LinkComponentRoute<'/'>\n}\n\n/**\n * Creates a root Route instance used to build your route tree.\n *\n * Typically paired with `createRouter({ routeTree })`. If you need to require\n * a typed router context, use `createRootRouteWithContext` instead.\n *\n * @param options Root route options (component, error, pending, etc.).\n * @returns A root route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteFunction\n */\nexport function createRootRoute<\n TRegister = Register,\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n THandlers = undefined,\n>(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n): RootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n> {\n return new RootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n >(options)\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<RouterCore<TRouteTree, 'never', boolean>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport interface DefaultRouteTypes<TProps> {\n component:\n | ((props: TProps) => any)\n | React.LazyExoticComponent<(props: TProps) => any>\n}\nexport interface RouteTypes<TProps> extends DefaultRouteTypes<TProps> {}\n\nexport type AsyncRouteComponent<TProps> = RouteTypes<TProps>['component'] & {\n preload?: () => Promise<void> | undefined\n}\n\nexport type RouteComponent = AsyncRouteComponent<{}>\n\nexport type ErrorRouteComponent = AsyncRouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = RouteTypes<NotFoundRouteProps>['component']\n\nexport class NotFoundRoute<\n TRegister,\n TParentRoute extends AnyRootRoute,\n TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n> extends Route<\n TRegister,\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TSSR,\n TServerMiddlewares\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TRegister,\n TParentRoute,\n string,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares\n >,\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'path'\n | 'id'\n | 'params'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0FA,SAAgB,YAGd,IAA2D;CAC3D,OAAO,IAAI,SAAuB,EAAE,GAAG,CAAC;AAC1C;AAEA,IAAa,WAAb,cAGU,aAA2B;;;;CAInC,YAAY,EAAE,MAAmB;EAC/B,MAAM,EAAE,GAAG,CAAC;mBAGkB,SAAS;GACvC,OAAO,SAAS;IACd,QAAQ,MAAM;IACd,MAAM,KAAK;IACX,mBAAmB,MAAM;GAC3B,CAAQ;EACV;0BAE8C,SAAS;GACrD,OAAO,gBAAgB;IAAE,GAAI;IAAc,MAAM,KAAK;GAAG,CAAC;EAC5D;oBAEkC,SAAS;GAEzC,OAAO,UAAU;IACf,QAAQ,MAAM;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AAD;IAAW;IAAK,MAAM,KAAK;IAAU,GAAI;GAAQ,CAAA;EAC1D,CACF;CAhDA;AAiDF;;;;;;;;;;;AAYA,SAAgB,gBAYd,SAyBA;CACA,OAAO,IAAI,UAaT,OAAO;AACX;AAEA,SAAgB,gBAKd,MAGuB;CACvB,OAAO;AACT;AAmBA,IAAa,gBAAb,cAYU,MAiBR;CACA,YACE,SAyBA;EACA,MAAM;GACJ,GAAI;GACJ,IAAI;EACN,CAAC;CACH;AACF"} |
+2
-2
| { | ||
| "name": "@tanstack/react-router", | ||
| "version": "1.170.27", | ||
| "version": "1.170.28", | ||
| "description": "Modern and scalable routing for React applications", | ||
@@ -81,3 +81,3 @@ "author": "Tanner Linsley", | ||
| "@tanstack/history": "1.162.1", | ||
| "@tanstack/router-core": "1.171.22" | ||
| "@tanstack/router-core": "1.171.23" | ||
| }, | ||
@@ -84,0 +84,0 @@ "devDependencies": { |
@@ -34,5 +34,6 @@ import * as React from 'react' | ||
| .then((res) => { | ||
| // Keep browser preload behavior unchanged; SSR can reuse the import. | ||
| // Resolved clients have no preload work; SSR can reuse the import. | ||
| if (!(isServer ?? typeof window === 'undefined')) { | ||
| loadPromise = undefined | ||
| ;(lazyComp as any).preload = undefined | ||
| } | ||
@@ -52,3 +53,2 @@ comp = res[exportName ?? 'default'] | ||
| } | ||
| const lazyComp = function Lazy(props: any) { | ||
@@ -55,0 +55,0 @@ if (error) { |
+22
-2
@@ -51,2 +51,14 @@ 'use client' | ||
| const canWrapInSuspense = ( | ||
| router: ReturnType<typeof useRouter>, | ||
| route: AnyRoute, | ||
| ssr: AnyRouteMatch['ssr'], | ||
| ) => | ||
| !route.isRoot || | ||
| (route.options as RootRouteOptions).shellComponent || | ||
| route.options.wrapInSuspense || | ||
| ssr === false || | ||
| ssr === 'data-only' || | ||
| !((isServer ?? router.isServer) || router.ssr) | ||
| export const Match = React.memo(function MatchImpl({ | ||
@@ -93,6 +105,9 @@ routeId, | ||
| const resolvedNoSsr = match.ssr === false || match.ssr === 'data-only' | ||
| // A root component may render the document itself. Only place its Suspense | ||
| // boundary in pure CSR, inside an explicit shell, or when explicitly opted in. | ||
| const ResolvedSuspenseBoundary = | ||
| canWrapInSuspense(router, route, match.ssr) && | ||
| (route.options.wrapInSuspense ?? | ||
| pendingElement ?? | ||
| ((route.options.errorComponent as any)?.preload || resolvedNoSsr)) | ||
| pendingElement ?? | ||
| ((route.options.errorComponent as any)?.preload || resolvedNoSsr)) | ||
| ? React.Suspense | ||
@@ -203,2 +218,7 @@ : SafeFragment | ||
| if (match.status === 'pending') { | ||
| if (router.ssr && !canWrapInSuspense(router, route, match.ssr)) { | ||
| // Replacing an SSR document root with pending UI would remove <html>. | ||
| // Hydrated matches retain their prior data, so keep rendering it. | ||
| return out | ||
| } | ||
| if (router._tx) { | ||
@@ -205,0 +225,0 @@ throw router._tx[5] |
+1
-1
@@ -667,3 +667,3 @@ import { | ||
| export type AsyncRouteComponent<TProps> = RouteTypes<TProps>['component'] & { | ||
| preload?: () => Promise<void> | ||
| preload?: () => Promise<void> | undefined | ||
| } | ||
@@ -670,0 +670,0 @@ |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
1072758
0.37%13911
0.22%+ Added
- Removed