@tanstack/react-router 1.45.13 → 1.45.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Match.cjs +14 -7
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Match.d.cts +5 -2
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +2 -2
- package/dist/esm/Match.d.ts +5 -2
- package/dist/esm/Match.js +14 -7
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/route.d.ts +2 -2
- package/dist/esm/route.js.map +1 -1
- package/package.json +1 -1
- package/src/Match.tsx +19 -9
- package/src/route.ts +2 -2
package/dist/cjs/Match.cjs
CHANGED
|
@@ -33,7 +33,9 @@ function _interopNamespaceDefault(e) {
|
|
|
33
33
|
return Object.freeze(n);
|
|
34
34
|
}
|
|
35
35
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
36
|
-
|
|
36
|
+
const Match = React__namespace.memo(function MatchImpl({
|
|
37
|
+
matchId
|
|
38
|
+
}) {
|
|
37
39
|
var _a, _b;
|
|
38
40
|
const router = useRouter.useRouter();
|
|
39
41
|
const routeId = useRouterState.useRouterState({
|
|
@@ -87,8 +89,10 @@ function Match({ matchId }) {
|
|
|
87
89
|
)
|
|
88
90
|
}
|
|
89
91
|
) }) });
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
+
});
|
|
93
|
+
const MatchInner = React__namespace.memo(function MatchInnerImpl({
|
|
94
|
+
matchId
|
|
95
|
+
}) {
|
|
92
96
|
var _a, _b;
|
|
93
97
|
const router = useRouter.useRouter();
|
|
94
98
|
const routeId = useRouterState.useRouterState({
|
|
@@ -115,6 +119,10 @@ function MatchInner({ matchId }) {
|
|
|
115
119
|
]);
|
|
116
120
|
}
|
|
117
121
|
});
|
|
122
|
+
const out = React__namespace.useMemo(() => {
|
|
123
|
+
const Comp = route.options.component ?? router.options.defaultComponent;
|
|
124
|
+
return Comp ? /* @__PURE__ */ jsxRuntime.jsx(Comp, {}, matchId) : /* @__PURE__ */ jsxRuntime.jsx(Outlet, {});
|
|
125
|
+
}, [matchId, route.options.component, router.options.defaultComponent]);
|
|
118
126
|
const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || CatchBoundary.ErrorComponent;
|
|
119
127
|
if (match.status === "notFound") {
|
|
120
128
|
let error;
|
|
@@ -172,14 +180,12 @@ function MatchInner({ matchId }) {
|
|
|
172
180
|
}
|
|
173
181
|
throw match.loadPromise;
|
|
174
182
|
}
|
|
175
|
-
const Comp = route.options.component ?? router.options.defaultComponent;
|
|
176
|
-
const out = Comp ? /* @__PURE__ */ jsxRuntime.jsx(Comp, {}) : /* @__PURE__ */ jsxRuntime.jsx(Outlet, {});
|
|
177
183
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
178
184
|
out,
|
|
179
185
|
router.AfterEachMatch ? /* @__PURE__ */ jsxRuntime.jsx(router.AfterEachMatch, { match, matchIndex }) : null
|
|
180
186
|
] });
|
|
181
|
-
}
|
|
182
|
-
const Outlet = React__namespace.memo(function
|
|
187
|
+
});
|
|
188
|
+
const Outlet = React__namespace.memo(function OutletImpl() {
|
|
183
189
|
const router = useRouter.useRouter();
|
|
184
190
|
const matchId = React__namespace.useContext(matchContext.matchContext);
|
|
185
191
|
const routeId = useRouterState.useRouterState({
|
|
@@ -224,5 +230,6 @@ const Outlet = React__namespace.memo(function Outlet2() {
|
|
|
224
230
|
return nextMatch;
|
|
225
231
|
});
|
|
226
232
|
exports.Match = Match;
|
|
233
|
+
exports.MatchInner = MatchInner;
|
|
227
234
|
exports.Outlet = Outlet;
|
|
228
235
|
//# sourceMappingURL=Match.cjs.map
|
package/dist/cjs/Match.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.cjs","sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { createControlledPromise, pick } from './utils'\nimport { CatchNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport { matchContext } from './matchContext'\nimport { defaultDeserializeError, isServerSideError } from './isServerSideError'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { rootRouteId } from './root'\nimport type { AnyRoute } from './route'\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\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 globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\n (route.options.errorComponent as any)?.preload)\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 resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n <MatchInner matchId={matchId} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\nfunction MatchInner({ matchId }: { matchId: string }): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const matchIndex = useRouterState({\n select: (s) => {\n return s.matches.findIndex((d) => d.id === matchId)\n },\n })\n\n const match = useRouterState({\n select: (s) => {\n const match = s.matches[matchIndex]!\n return pick(match, [\n 'id',\n 'status',\n 'error',\n 'loadPromise',\n 'minPendingPromise',\n ])\n },\n })\n\n // function useChangedDiff(value: any) {\n // const ref = React.useRef(value)\n // const changed = ref.current !== value\n // if (changed) {\n // console.log(\n // 'Changed:',\n // value,\n // Object.fromEntries(\n // Object.entries(value).filter(\n // ([key, val]) => val !== ref.current[key],\n // ),\n // ),\n // )\n // }\n // ref.current = value\n // }\n\n // useChangedDiff(match)\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n let error: unknown\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n\n error = deserializeError(match.error.data)\n } else {\n error = match.error\n }\n\n invariant(isNotFound(error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw match.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (router.isServer) {\n return (\n <RouteErrorComponent\n error={match.error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !match.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!router.isServer) {\n const minPendingPromise = createControlledPromise<void>()\n\n Promise.resolve().then(() => {\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise,\n }))\n })\n\n setTimeout(() => {\n minPendingPromise.resolve()\n\n // We've handled the minPendingPromise, so we can delete it\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }, pendingMinMs)\n }\n }\n\n throw match.loadPromise\n }\n\n const Comp = route.options.component ?? router.options.defaultComponent\n\n const out = Comp ? <Comp /> : <Outlet />\n\n return (\n <>\n {out}\n {router.AfterEachMatch ? (\n <router.AfterEachMatch match={match} matchIndex={matchIndex} />\n ) : null}\n </>\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { parentGlobalNotFound } = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (matchId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"names":["match"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBgB;;AACd;AACA;AAA+B;;AACd;AAAyC;AAAA;AAG1D;AAAA;AACE;AAC8C;AAG1C;AAEN;AAGA;AAEA;AAGA;AAEA;AAAqC;AAAA;AAGK;AAGpC;AAAA;AAAA;AAOA;AAEA;AAIA;AAIN;AAAgC;AACb;AAIjB;AAEI;AAAC;AAAA;AACoB;AACoB;AAGjC;AACI;AACR;AAAsB;AACxB;AAEA;AAAC;AAAA;AAKK;AAIM;AAED;AAAwD;AACjE;AAE8B;AAAA;AAChC;AAAA;AAKV;AACA;;AACE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEN;AAAkC;AAE9B;AAAkD;AACpD;AAGF;AAA6B;AAEnBA;AACN;AAAmB;AACjB;AACA;AACA;AACA;AACA;AACD;AACH;AAsBF;AAII;AACE;AACA;AACF;AAGQ;AAAiC;AAEzC;AAAc;AAGN;AAEH;AAAwC;AAG7C;AAGF;AAMA;AAAY;AAGV;AAMF;AAEI;AAAA;AAAC;AAAA;AACc;AACP;AACY;AAClB;AAAA;AAAA;AAKF;AACF;AAEM;AAAiC;AAEvC;AAAY;AACd;AAGE;AAEF;AAGI;AAEE;AACF;AAEQ;AACN;AAAwC;AACnC;AACH;AACA;AAGJ;AACE;AAGA;AAAwC;AACnC;AACgB;AACnB;AACW;AACjB;AAGF;AAAY;AAGd;AAEA;AAEA;AAEK;AAAA;AAGG;AAGV;AAEO;AACL;AACM;AACN;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEA;AAA0C;AAE5C;AACA;AACA;AAAA;AACE;AACmD;AAE9C;AAAA;AAC6B;AAAA;AAEtC;AAGF;AAAoC;;AAEhC;AACA;AACO;AAAoB;AAC7B;AAGF;AACS;AAA4C;AAGrD;AACS;AAAA;AAGT;AAEM;AAIN;AACE;AACuD;AAIlD;AACT;;;"}
|
|
1
|
+
{"version":3,"file":"Match.cjs","sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { createControlledPromise, pick } from './utils'\nimport { CatchNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport { matchContext } from './matchContext'\nimport { defaultDeserializeError, isServerSideError } from './isServerSideError'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { rootRouteId } from './root'\nimport type { AnyRoute } from './route'\n\nexport const Match = React.memo(function MatchImpl({\n matchId,\n}: {\n matchId: string\n}) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\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 globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\n (route.options.errorComponent as any)?.preload)\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 resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n <MatchInner matchId={matchId} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n})\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n matchId,\n}: {\n matchId: string\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const matchIndex = useRouterState({\n select: (s) => {\n return s.matches.findIndex((d) => d.id === matchId)\n },\n })\n\n const match = useRouterState({\n select: (s) => {\n const match = s.matches[matchIndex]!\n return pick(match, [\n 'id',\n 'status',\n 'error',\n 'loadPromise',\n 'minPendingPromise',\n ])\n },\n })\n\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n return Comp ? <Comp key={matchId} /> : <Outlet />\n }, [matchId, route.options.component, router.options.defaultComponent])\n\n // function useChangedDiff(value: any) {\n // const ref = React.useRef(value)\n // const changed = ref.current !== value\n // if (changed) {\n // console.log(\n // 'Changed:',\n // value,\n // Object.fromEntries(\n // Object.entries(value).filter(\n // ([key, val]) => val !== ref.current[key],\n // ),\n // ),\n // )\n // }\n // ref.current = value\n // }\n\n // useChangedDiff(match)\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n let error: unknown\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n\n error = deserializeError(match.error.data)\n } else {\n error = match.error\n }\n\n invariant(isNotFound(error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw match.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (router.isServer) {\n return (\n <RouteErrorComponent\n error={match.error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !match.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!router.isServer) {\n const minPendingPromise = createControlledPromise<void>()\n\n Promise.resolve().then(() => {\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise,\n }))\n })\n\n setTimeout(() => {\n minPendingPromise.resolve()\n\n // We've handled the minPendingPromise, so we can delete it\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }, pendingMinMs)\n }\n }\n\n throw match.loadPromise\n }\n\n return (\n <>\n {out}\n {router.AfterEachMatch ? (\n <router.AfterEachMatch match={match} matchIndex={matchIndex} />\n ) : null}\n </>\n )\n})\n\nexport const Outlet = React.memo(function OutletImpl() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { parentGlobalNotFound } = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (matchId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"names":["match"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO;AAA4C;AAEnD;;AAGE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAG1D;AAAA;AACE;AAC8C;AAG1C;AAEN;AAGA;AAEA;AAGA;AAEA;AAAqC;AAAA;AAGK;AAGpC;AAAA;AAAA;AAOA;AAEA;AAIA;AAIN;AAAgC;AACb;AAIjB;AAEI;AAAC;AAAA;AACoB;AACoB;AAGjC;AACI;AACR;AAAsB;AACxB;AAEA;AAAC;AAAA;AAKK;AAIM;AAED;AAAwD;AACjE;AAE8B;AAAA;AAChC;AAAA;AAKV;AAEO;AAAsD;AAE7D;;AAGE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEN;AAAkC;AAE9B;AAAkD;AACpD;AAGF;AAA6B;AAEnBA;AACN;AAAmB;AACjB;AACA;AACA;AACA;AACA;AACD;AACH;AAGI;AACJ;AACA;AAA+C;AAsBjD;AAII;AACE;AACA;AACF;AAGQ;AAAiC;AAEzC;AAAc;AAGN;AAEH;AAAwC;AAG7C;AAGF;AAMA;AAAY;AAGV;AAMF;AAEI;AAAA;AAAC;AAAA;AACc;AACP;AACY;AAClB;AAAA;AAAA;AAKF;AACF;AAEM;AAAiC;AAEvC;AAAY;AACd;AAGE;AAEF;AAGI;AAEE;AACF;AAEQ;AACN;AAAwC;AACnC;AACH;AACA;AAGJ;AACE;AAGA;AAAwC;AACnC;AACgB;AACnB;AACW;AACjB;AAGF;AAAY;AAGd;AAEK;AAAA;AAGG;AAGV;AAEO;AACL;AACM;AACN;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEA;AAA0C;AAE5C;AACA;AACA;AAAA;AACE;AACmD;AAE9C;AAAA;AAC6B;AAAA;AAEtC;AAGF;AAAoC;;AAEhC;AACA;AACO;AAAoB;AAC7B;AAGF;AACS;AAA4C;AAGrD;AACS;AAAA;AAGT;AAEM;AAIN;AACE;AACuD;AAIlD;AACT;;;;"}
|
package/dist/cjs/Match.d.cts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const Match: React.NamedExoticComponent<{
|
|
3
3
|
matchId: string;
|
|
4
|
-
}
|
|
4
|
+
}>;
|
|
5
|
+
export declare const MatchInner: React.NamedExoticComponent<{
|
|
6
|
+
matchId: string;
|
|
7
|
+
}>;
|
|
5
8
|
export declare const Outlet: React.NamedExoticComponent<object>;
|
package/dist/cjs/route.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { joinPaths, trimPathLeft } from './path'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { rootRouteId } from './root'\nimport type * as React from 'react'\nimport type { RootRouteId } from './root'\nimport type { UseNavigateResult } from './useNavigate'\nimport type { MakeRouteMatch, RouteMatch } from './Matches'\nimport type { NavigateOptions, ParsePathParams, ToSubOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { RouteById, RouteIds, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, Router } from './router'\nimport type { Assign, Expand, NoInfer, PickRequired } from './utils'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type { NotFoundError } from './not-found'\nimport type { LazyRoute } from './fileRoute'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnySearchSchema = {}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = AnyPathParams,\n TAllParams = TParams,\n TRouteContextReturn = RouteContext,\n TRouteContext = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n> = BaseRouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TParentAllContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n> &\n UpdatableRouteOptions<\n NoInfer<TCustomId>,\n NoInfer<TAllParams>,\n NoInfer<TFullSearchSchema>,\n NoInfer<TLoaderData>,\n NoInfer<TAllContext>,\n NoInfer<TRouteContext>,\n NoInfer<TLoaderDeps>\n >\n\nexport type ParseParamsFn<TPath extends string, TParams> = (\n rawParams: Record<ParsePathParams<TPath>, string>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : Record<ParsePathParams<TPath>, any>\n\nexport type StringifyParamsFn<TPath extends string, TParams> = (\n params: TParams,\n) => Record<ParsePathParams<TPath>, string>\n\nexport type ParamsOptions<TPath extends string, TParams> = {\n params?: {\n parse: ParseParamsFn<TPath, TParams>\n stringify: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\nexport interface FullSearchSchemaOption<TFullSearchSchema> {\n search: TFullSearchSchema\n}\n\nexport type FileBaseRouteOptions<\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = {},\n TAllParams = {},\n TRouteContextReturn = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n> = {\n validateSearch?:\n | ((input: TSearchSchemaInput) => TSearchSchema)\n | { parse: (input: TSearchSchemaInput) => TSearchSchema }\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<TAllParams, TFullSearchSchema, TAllContext>,\n ) => any)\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: (\n ctx: BeforeLoadContext<TFullSearchSchema, TAllParams, TParentAllContext>,\n ) => Promise<TRouteContextReturn> | TRouteContextReturn | void\n loaderDeps?: (opts: FullSearchSchemaOption<TFullSearchSchema>) => TLoaderDeps\n loader?: (\n ctx: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,\n ) => TLoaderDataReturn | Promise<TLoaderDataReturn>\n} & ParamsOptions<TPath, TParams>\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = {},\n TAllParams = {},\n TRouteContextReturn = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TParentAllContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface BeforeLoadContext<\n TFullSearchSchema,\n TAllParams,\n TParentAllContext,\n> extends FullSearchSchemaOption<TFullSearchSchema> {\n abortController: AbortController\n preload: boolean\n params: Expand<TAllParams>\n context: TParentAllContext\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n}\n\nexport type UpdatableRouteOptions<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps,\n TRouteMatch = RouteMatch<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n> = {\n // test?: (args: TAllContext) => void\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preloadStaleTime?: number\n preloadGcTime?: number\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: Array<SearchFilter<TFullSearchSchema>>\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: Array<SearchFilter<TFullSearchSchema>>\n onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (match: TRouteMatch) => void\n onStay?: (match: TRouteMatch) => void\n onLeave?: (match: TRouteMatch) => void\n meta?: (ctx: {\n matches: Array<TRouteMatch>\n match: TRouteMatch\n params: TAllParams\n loaderData: TLoaderData\n }) => Array<React.JSX.IntrinsicElements['meta']>\n links?: () => Array<React.JSX.IntrinsicElements['link']>\n scripts?: () => Array<React.JSX.IntrinsicElements['script']>\n headers?: (ctx: { loaderData: TLoaderData }) => Record<string, string>\n} & UpdatableStaticRouteOption\n\nexport type UpdatableStaticRouteOption =\n {} extends PickRequired<StaticDataRouteOption>\n ? {\n staticData?: StaticDataRouteOption\n }\n : {\n staticData: StaticDataRouteOption\n }\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\n// The parse type here allows a zod schema to be passed directly to the validator\nexport type SearchSchemaValidator<TInput, TReturn> =\n | SearchSchemaValidatorObj<TInput, TReturn>\n | SearchSchemaValidatorFn<TInput, TReturn>\n\nexport type SearchSchemaValidatorObj<TInput, TReturn> = {\n parse?: SearchSchemaValidatorFn<TInput, TReturn>\n}\n\nexport type SearchSchemaValidatorFn<TInput, TReturn> = (\n searchObj: TInput,\n) => TReturn\n\nexport type RouteLoaderFn<\n in out TAllParams = {},\n in out TLoaderDeps extends Record<string, any> = {},\n in out TAllContext = AnyContext,\n TLoaderData = undefined,\n> = (\n match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,\n) => TLoaderData | Promise<TLoaderData>\n\nexport interface LoaderFnContext<\n in out TAllParams = {},\n in out TLoaderDeps = {},\n in out TAllContext = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<TAllParams>\n deps: TLoaderDeps\n context: TAllContext\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void>\n parentMatchPromise?: Promise<void>\n cause: 'preload' | 'enter' | 'stay'\n route: Route\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n}\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema> =\n TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchSchema,\n> = Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchSchemaUsed,\n> = Assign<InferFullSearchSchemaInput<TParentRoute>, TSearchSchemaUsed>\n\nexport type ResolveRouteContext<TRouteContextReturn> = [\n TRouteContextReturn,\n] extends [never]\n ? RouteContext\n : TRouteContextReturn\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouteContext,\n> = Assign<InferAllContext<TParentRoute>, TRouteContext>\n\nexport type ResolveLoaderData<TLoaderDataReturn> = [TLoaderDataReturn] extends [\n never,\n]\n ? undefined\n : TLoaderDataReturn\n\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type AnyRouteWithContext<TContext> = Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n TContext,\n any,\n any,\n any,\n any\n>\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySearchSchema\n TFullSearchSchema: AnySearchSchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport function getRouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n>(id: TId) {\n return new RouteApi<\n TId,\n TRouter,\n TRoute,\n TFullSearchSchema,\n TAllParams,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >({ id })\n}\n\nexport class RouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n> {\n id: TId\n\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch = <\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (s: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (s: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (s: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (s: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n return useNavigate({ from: this.id })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class Route<\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 TSearchSchemaInput = Record<string, unknown>,\n in out TSearchSchema = {},\n in out TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n in out TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n in out TFullSearchSchema = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n in out TParams = Record<ParsePathParams<TPath>, string>,\n in out TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n in out TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n in out TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n in out TChildren = unknown,\n> {\n isRoot: TParentRoute extends Route<any> ? true : false\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >\n\n // Set up in this.init()\n parentRoute!: TParentRoute\n id!: TId\n // customId!: TCustomId\n path!: TPath\n fullPath!: TFullPath\n to!: TrimPathRight<TFullPath>\n\n // Optional\n children?: TChildren\n originalIndex?: number\n router?: AnyRouter\n rank!: number\n lazyFn?: () => Promise<LazyRoute<any>>\n _lazyPromise?: Promise<void>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) {\n this.options = (options as any) || {}\n\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n types!: {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: TSearchSchema\n searchSchemaInput: TSearchSchemaInput\n searchSchemaUsed: TSearchSchemaUsed\n fullSearchSchema: TFullSearchSchema\n fullSearchSchemaInput: TFullSearchSchemaInput\n params: TParams\n allParams: TAllParams\n routeContext: TRouteContext\n allContext: TAllContext\n children: TChildren\n loaderData: TLoaderData\n loaderDeps: TLoaderDeps\n }\n\n init = (opts: { originalIndex: number }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.parentRoute = this.options?.getParentRoute?.()\n\n if (isRoot) {\n this.path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this.path = path as TPath\n this.id = id as TId\n // this.customId = customId as TCustomId\n this.fullPath = fullPath as TFullPath\n this.to = fullPath as TrimPathRight<TFullPath>\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TNewChildren\n > {\n this.children = (\n Array.isArray(children) ? children : Object.values(children)\n ) as any\n return this as any\n }\n\n updateLoader = <TNewLoaderData = unknown>(options: {\n loader: RouteLoaderFn<TAllParams, TLoaderDeps, TAllContext, TNewLoaderData>\n }) => {\n Object.assign(this.options, options)\n return this as unknown as Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TNewLoaderData,\n TChildren\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TCustomId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy = (lazyFn: () => Promise<LazyRoute<any>>): this => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch = <\n TRouter extends AnyRouter = RegisteredRouter,\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (search: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (search: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (search: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (search: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.id })\n }\n}\n\nexport function createRoute<\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 TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TParams = Record<ParsePathParams<TPath>, string>,\n TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n) {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>\n\nexport type RootRouteOptions<\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n TRouterContext, // TParentAllContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn, // TLoaderDataReturn,\n TLoaderData // TLoaderData,\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TRouteContextReturn extends RouteContext = RouteContext,\n TRouteContext extends\n RouteContext = ResolveRouteContext<TRouteContextReturn>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n >(\n options?: RootRouteOptions<\n TSearchSchemaInput,\n TSearchSchema,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) => {\n return createRootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData\n >(options as any)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TSearchSchemaInput = {},\n in out TSearchSchema = {},\n in out TSearchSchemaUsed = {},\n TRouteContextReturn = RouteContext,\n in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n in out TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchemaUsed,\n TSearchSchemaUsed, // TFullSearchSchemaInput\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren // TChildren\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchSchemaInput,\n TSearchSchema,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) {\n super(options as any)\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): RootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TNewChildren\n > {\n return super.addChildren(children)\n }\n}\n\nexport function createRootRoute<\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n>(\n options?: Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchema,\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n TRouterContext,\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n >,\n) {\n return new RootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >(options)\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\ntype RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends RoutePaths<TRouteTree>,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToSubOptions<Router<TRouteTree, 'never'>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps = {\n error: Error\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n//\n\nexport type ReactNode = any\n\nexport type SyncRouteComponent<TProps> =\n | ((props: TProps) => ReactNode)\n | React.LazyExoticComponent<(props: TProps) => ReactNode>\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = {},\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TRouteContextReturn = AnyContext,\n TRouteContext = RouteContext,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n {},\n {},\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n {},\n {},\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\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"],"names":["useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useNavigate","notFound","options","rootRouteId","path","trimPathLeft","joinPaths"],"mappings":";;;;;;;;;;;;AA6dO,SAAS,YASd,IAAS;AACT,SAAO,IAAI,SAST,EAAE,GAAA,CAAI;AACV;AAEO,MAAM,SASX;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY,EAAE,MAAmB;AAIjC,SAAA,WAAW,CAIT,SAEe;AACR,aAAAA,SAAA,SAAS,EAAE,QAAQ,6BAAM,QAAQ,MAAM,KAAK,IAAI;AAAA,IAAA;AAGzD,SAAA,kBAAkB,CAAkC,SAEnC;AACf,aAAOA,kBAAS;AAAA,QACd,MAAM,KAAK;AAAA,QACX,QAAQ,CAAC,OAAY,6BAAM,UAAS,KAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAChE;AAAA,IAAA;AAGH,SAAA,YAAY,CAAwC,SAEnC;AACf,aAAOC,UAAAA,UAAU,EAAE,GAAG,MAAM,MAAM,KAAK,IAAI;AAAA,IAAA;AAG7C,SAAA,YAAY,CAAiC,SAE5B;AACf,aAAOC,UAAAA,UAAU,EAAE,GAAG,MAAM,MAAM,KAAK,IAAI;AAAA,IAAA;AAG7C,SAAA,gBAAgB,CAA0B,SAEzB;AACR,aAAAC,cAAA,cAAc,EAAE,GAAG,MAAM,MAAM,KAAK,IAAI,QAAQ,MAAA,CAAc;AAAA,IAAA;AAGvE,SAAA,gBAAgB,CAA0B,SAEzB;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AW,WAAmB;AAE9B,SAAA,SAAS,EAAC,mCAAS;AACxB;AAAA,MACE,GAAG,mCAAiB,QAAO,mCAAiB;AAAA,MAC5C;AAAA,IAAA;AAEA,SAAa,WAAW,OAAO,IAAI,YAAY;AAAA,EACnD;AAAA,EAgGA,YAKE,UAqBA;AACK,SAAA,WACH,MAAM,QAAQ,QAAQ,IAAI,WAAW,OAAO,OAAO,QAAQ;AAEtD,WAAA;AAAA,EACT;AAgGF;AAEO,SAAS,YAkCd,SAiBA;AACO,SAAA,IAAI,MAoBT,OAAO;AACX;AAwCO,SAAS,6BAAwD;AACtE,SAAO,CAcL,YAUG;AACH,WAAO,gBASL,OAAc;AAAA,EAAA;AAEpB;AAKO,MAAM,uBAAuB;AAE7B,MAAM,kBAWH,MAoBR;AAAA;AAAA;AAAA;AAAA,EAIA,YACE,SAUA;AACA,UAAM,OAAc;AAAA,EACtB;AAAA,EAEA,YAKE,UAYA;AACO,WAAA,MAAM,YAAY,QAAQ;AAAA,EACnC;AACF;AAEO,SAAS,gBAcd,SA0BA;AACO,SAAA,IAAI,UAUT,OAAO;AACX;AAkDO,SAAS,gBAKd,MAGuB;AAChB,SAAA;AACT;AAsCO,MAAM,sBAiBH,MAoBR;AAAA,EACA,YACE,SAyBA;AACM,UAAA;AAAA,MACJ,GAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EACH;AACF;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"route.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { joinPaths, trimPathLeft } from './path'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { rootRouteId } from './root'\nimport type * as React from 'react'\nimport type { RootRouteId } from './root'\nimport type { UseNavigateResult } from './useNavigate'\nimport type { MakeRouteMatch, RouteMatch } from './Matches'\nimport type { NavigateOptions, ParsePathParams, ToMaskOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { RouteById, RouteIds, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, Router } from './router'\nimport type { Assign, Expand, NoInfer, PickRequired } from './utils'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type { NotFoundError } from './not-found'\nimport type { LazyRoute } from './fileRoute'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnySearchSchema = {}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = AnyPathParams,\n TAllParams = TParams,\n TRouteContextReturn = RouteContext,\n TRouteContext = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n> = BaseRouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TParentAllContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n> &\n UpdatableRouteOptions<\n NoInfer<TCustomId>,\n NoInfer<TAllParams>,\n NoInfer<TFullSearchSchema>,\n NoInfer<TLoaderData>,\n NoInfer<TAllContext>,\n NoInfer<TRouteContext>,\n NoInfer<TLoaderDeps>\n >\n\nexport type ParseParamsFn<TPath extends string, TParams> = (\n rawParams: Record<ParsePathParams<TPath>, string>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : Record<ParsePathParams<TPath>, any>\n\nexport type StringifyParamsFn<TPath extends string, TParams> = (\n params: TParams,\n) => Record<ParsePathParams<TPath>, string>\n\nexport type ParamsOptions<TPath extends string, TParams> = {\n params?: {\n parse: ParseParamsFn<TPath, TParams>\n stringify: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\nexport interface FullSearchSchemaOption<TFullSearchSchema> {\n search: TFullSearchSchema\n}\n\nexport type FileBaseRouteOptions<\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = {},\n TAllParams = {},\n TRouteContextReturn = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n> = {\n validateSearch?:\n | ((input: TSearchSchemaInput) => TSearchSchema)\n | { parse: (input: TSearchSchemaInput) => TSearchSchema }\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<TAllParams, TFullSearchSchema, TAllContext>,\n ) => any)\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: (\n ctx: BeforeLoadContext<TFullSearchSchema, TAllParams, TParentAllContext>,\n ) => Promise<TRouteContextReturn> | TRouteContextReturn | void\n loaderDeps?: (opts: FullSearchSchemaOption<TFullSearchSchema>) => TLoaderDeps\n loader?: (\n ctx: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,\n ) => TLoaderDataReturn | Promise<TLoaderDataReturn>\n} & ParamsOptions<TPath, TParams>\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = {},\n TAllParams = {},\n TRouteContextReturn = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TParentAllContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface BeforeLoadContext<\n TFullSearchSchema,\n TAllParams,\n TParentAllContext,\n> extends FullSearchSchemaOption<TFullSearchSchema> {\n abortController: AbortController\n preload: boolean\n params: Expand<TAllParams>\n context: TParentAllContext\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n}\n\nexport type UpdatableRouteOptions<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps,\n TRouteMatch = RouteMatch<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n> = {\n // test?: (args: TAllContext) => void\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preloadStaleTime?: number\n preloadGcTime?: number\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: Array<SearchFilter<TFullSearchSchema>>\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: Array<SearchFilter<TFullSearchSchema>>\n onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (match: TRouteMatch) => void\n onStay?: (match: TRouteMatch) => void\n onLeave?: (match: TRouteMatch) => void\n meta?: (ctx: {\n matches: Array<TRouteMatch>\n match: TRouteMatch\n params: TAllParams\n loaderData: TLoaderData\n }) => Array<React.JSX.IntrinsicElements['meta']>\n links?: () => Array<React.JSX.IntrinsicElements['link']>\n scripts?: () => Array<React.JSX.IntrinsicElements['script']>\n headers?: (ctx: { loaderData: TLoaderData }) => Record<string, string>\n} & UpdatableStaticRouteOption\n\nexport type UpdatableStaticRouteOption =\n {} extends PickRequired<StaticDataRouteOption>\n ? {\n staticData?: StaticDataRouteOption\n }\n : {\n staticData: StaticDataRouteOption\n }\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\n// The parse type here allows a zod schema to be passed directly to the validator\nexport type SearchSchemaValidator<TInput, TReturn> =\n | SearchSchemaValidatorObj<TInput, TReturn>\n | SearchSchemaValidatorFn<TInput, TReturn>\n\nexport type SearchSchemaValidatorObj<TInput, TReturn> = {\n parse?: SearchSchemaValidatorFn<TInput, TReturn>\n}\n\nexport type SearchSchemaValidatorFn<TInput, TReturn> = (\n searchObj: TInput,\n) => TReturn\n\nexport type RouteLoaderFn<\n in out TAllParams = {},\n in out TLoaderDeps extends Record<string, any> = {},\n in out TAllContext = AnyContext,\n TLoaderData = undefined,\n> = (\n match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,\n) => TLoaderData | Promise<TLoaderData>\n\nexport interface LoaderFnContext<\n in out TAllParams = {},\n in out TLoaderDeps = {},\n in out TAllContext = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<TAllParams>\n deps: TLoaderDeps\n context: TAllContext\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void>\n parentMatchPromise?: Promise<void>\n cause: 'preload' | 'enter' | 'stay'\n route: Route\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n}\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema> =\n TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchSchema,\n> = Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchSchemaUsed,\n> = Assign<InferFullSearchSchemaInput<TParentRoute>, TSearchSchemaUsed>\n\nexport type ResolveRouteContext<TRouteContextReturn> = [\n TRouteContextReturn,\n] extends [never]\n ? RouteContext\n : TRouteContextReturn\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouteContext,\n> = Assign<InferAllContext<TParentRoute>, TRouteContext>\n\nexport type ResolveLoaderData<TLoaderDataReturn> = [TLoaderDataReturn] extends [\n never,\n]\n ? undefined\n : TLoaderDataReturn\n\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type AnyRouteWithContext<TContext> = Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n TContext,\n any,\n any,\n any,\n any\n>\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySearchSchema\n TFullSearchSchema: AnySearchSchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport function getRouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n>(id: TId) {\n return new RouteApi<\n TId,\n TRouter,\n TRoute,\n TFullSearchSchema,\n TAllParams,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >({ id })\n}\n\nexport class RouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n> {\n id: TId\n\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch = <\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (s: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (s: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (s: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (s: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n return useNavigate({ from: this.id })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class Route<\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 TSearchSchemaInput = Record<string, unknown>,\n in out TSearchSchema = {},\n in out TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n in out TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n in out TFullSearchSchema = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n in out TParams = Record<ParsePathParams<TPath>, string>,\n in out TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n in out TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n in out TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n in out TChildren = unknown,\n> {\n isRoot: TParentRoute extends Route<any> ? true : false\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >\n\n // Set up in this.init()\n parentRoute!: TParentRoute\n id!: TId\n // customId!: TCustomId\n path!: TPath\n fullPath!: TFullPath\n to!: TrimPathRight<TFullPath>\n\n // Optional\n children?: TChildren\n originalIndex?: number\n router?: AnyRouter\n rank!: number\n lazyFn?: () => Promise<LazyRoute<any>>\n _lazyPromise?: Promise<void>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) {\n this.options = (options as any) || {}\n\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n types!: {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: TSearchSchema\n searchSchemaInput: TSearchSchemaInput\n searchSchemaUsed: TSearchSchemaUsed\n fullSearchSchema: TFullSearchSchema\n fullSearchSchemaInput: TFullSearchSchemaInput\n params: TParams\n allParams: TAllParams\n routeContext: TRouteContext\n allContext: TAllContext\n children: TChildren\n loaderData: TLoaderData\n loaderDeps: TLoaderDeps\n }\n\n init = (opts: { originalIndex: number }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.parentRoute = this.options?.getParentRoute?.()\n\n if (isRoot) {\n this.path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this.path = path as TPath\n this.id = id as TId\n // this.customId = customId as TCustomId\n this.fullPath = fullPath as TFullPath\n this.to = fullPath as TrimPathRight<TFullPath>\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TNewChildren\n > {\n this.children = (\n Array.isArray(children) ? children : Object.values(children)\n ) as any\n return this as any\n }\n\n updateLoader = <TNewLoaderData = unknown>(options: {\n loader: RouteLoaderFn<TAllParams, TLoaderDeps, TAllContext, TNewLoaderData>\n }) => {\n Object.assign(this.options, options)\n return this as unknown as Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TNewLoaderData,\n TChildren\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TCustomId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy = (lazyFn: () => Promise<LazyRoute<any>>): this => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch = <\n TRouter extends AnyRouter = RegisteredRouter,\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (search: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (search: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (search: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (search: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.id })\n }\n}\n\nexport function createRoute<\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 TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TParams = Record<ParsePathParams<TPath>, string>,\n TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n) {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>\n\nexport type RootRouteOptions<\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n TRouterContext, // TParentAllContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn, // TLoaderDataReturn,\n TLoaderData // TLoaderData,\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TRouteContextReturn extends RouteContext = RouteContext,\n TRouteContext extends\n RouteContext = ResolveRouteContext<TRouteContextReturn>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n >(\n options?: RootRouteOptions<\n TSearchSchemaInput,\n TSearchSchema,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) => {\n return createRootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData\n >(options as any)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TSearchSchemaInput = {},\n in out TSearchSchema = {},\n in out TSearchSchemaUsed = {},\n TRouteContextReturn = RouteContext,\n in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n in out TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchemaUsed,\n TSearchSchemaUsed, // TFullSearchSchemaInput\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren // TChildren\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchSchemaInput,\n TSearchSchema,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) {\n super(options as any)\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): RootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TNewChildren\n > {\n return super.addChildren(children)\n }\n}\n\nexport function createRootRoute<\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n>(\n options?: Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchema,\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n TRouterContext,\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n >,\n) {\n return new RootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >(options)\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\ntype RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends RoutePaths<TRouteTree>,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps = {\n error: Error\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n//\n\nexport type ReactNode = any\n\nexport type SyncRouteComponent<TProps> =\n | ((props: TProps) => ReactNode)\n | React.LazyExoticComponent<(props: TProps) => ReactNode>\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = {},\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TRouteContextReturn = AnyContext,\n TRouteContext = RouteContext,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n {},\n {},\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n {},\n {},\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\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"],"names":["useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useNavigate","notFound","options","rootRouteId","path","trimPathLeft","joinPaths"],"mappings":";;;;;;;;;;;;AA6dO,SAAS,YASd,IAAS;AACT,SAAO,IAAI,SAST,EAAE,GAAA,CAAI;AACV;AAEO,MAAM,SASX;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY,EAAE,MAAmB;AAIjC,SAAA,WAAW,CAIT,SAEe;AACR,aAAAA,SAAA,SAAS,EAAE,QAAQ,6BAAM,QAAQ,MAAM,KAAK,IAAI;AAAA,IAAA;AAGzD,SAAA,kBAAkB,CAAkC,SAEnC;AACf,aAAOA,kBAAS;AAAA,QACd,MAAM,KAAK;AAAA,QACX,QAAQ,CAAC,OAAY,6BAAM,UAAS,KAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AA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;AAAA,IAAA,CACL;AAAA,EACH;AACF;;;;;;;;;;;"}
|
package/dist/cjs/route.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RootRouteId } from './root.cjs';
|
|
2
2
|
import { UseNavigateResult } from './useNavigate.cjs';
|
|
3
3
|
import { MakeRouteMatch, RouteMatch } from './Matches.cjs';
|
|
4
|
-
import { NavigateOptions, ParsePathParams,
|
|
4
|
+
import { NavigateOptions, ParsePathParams, ToMaskOptions } from './link.cjs';
|
|
5
5
|
import { ParsedLocation } from './location.cjs';
|
|
6
6
|
import { RouteById, RouteIds, RoutePaths } from './routeInfo.cjs';
|
|
7
7
|
import { AnyRouter, RegisteredRouter, Router } from './router.cjs';
|
|
@@ -385,7 +385,7 @@ export type RouteMask<TRouteTree extends AnyRoute> = {
|
|
|
385
385
|
};
|
|
386
386
|
export declare function createRouteMask<TRouteTree extends AnyRoute, TFrom extends RoutePaths<TRouteTree>, TTo extends string>(opts: {
|
|
387
387
|
routeTree: TRouteTree;
|
|
388
|
-
} &
|
|
388
|
+
} & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>): RouteMask<TRouteTree>;
|
|
389
389
|
/**
|
|
390
390
|
* @deprecated Use `ErrorComponentProps` instead.
|
|
391
391
|
*/
|
package/dist/esm/Match.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const Match: React.NamedExoticComponent<{
|
|
3
3
|
matchId: string;
|
|
4
|
-
}
|
|
4
|
+
}>;
|
|
5
|
+
export declare const MatchInner: React.NamedExoticComponent<{
|
|
6
|
+
matchId: string;
|
|
7
|
+
}>;
|
|
5
8
|
export declare const Outlet: React.NamedExoticComponent<object>;
|
package/dist/esm/Match.js
CHANGED
|
@@ -14,7 +14,9 @@ import { isServerSideError, defaultDeserializeError } from "./isServerSideError.
|
|
|
14
14
|
import { SafeFragment } from "./SafeFragment.js";
|
|
15
15
|
import { renderRouteNotFound } from "./renderRouteNotFound.js";
|
|
16
16
|
import { rootRouteId } from "./root.js";
|
|
17
|
-
|
|
17
|
+
const Match = React.memo(function MatchImpl({
|
|
18
|
+
matchId
|
|
19
|
+
}) {
|
|
18
20
|
var _a, _b;
|
|
19
21
|
const router = useRouter();
|
|
20
22
|
const routeId = useRouterState({
|
|
@@ -68,8 +70,10 @@ function Match({ matchId }) {
|
|
|
68
70
|
)
|
|
69
71
|
}
|
|
70
72
|
) }) });
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
+
});
|
|
74
|
+
const MatchInner = React.memo(function MatchInnerImpl({
|
|
75
|
+
matchId
|
|
76
|
+
}) {
|
|
73
77
|
var _a, _b;
|
|
74
78
|
const router = useRouter();
|
|
75
79
|
const routeId = useRouterState({
|
|
@@ -96,6 +100,10 @@ function MatchInner({ matchId }) {
|
|
|
96
100
|
]);
|
|
97
101
|
}
|
|
98
102
|
});
|
|
103
|
+
const out = React.useMemo(() => {
|
|
104
|
+
const Comp = route.options.component ?? router.options.defaultComponent;
|
|
105
|
+
return Comp ? /* @__PURE__ */ jsx(Comp, {}, matchId) : /* @__PURE__ */ jsx(Outlet, {});
|
|
106
|
+
}, [matchId, route.options.component, router.options.defaultComponent]);
|
|
99
107
|
const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
|
|
100
108
|
if (match.status === "notFound") {
|
|
101
109
|
let error;
|
|
@@ -153,14 +161,12 @@ function MatchInner({ matchId }) {
|
|
|
153
161
|
}
|
|
154
162
|
throw match.loadPromise;
|
|
155
163
|
}
|
|
156
|
-
const Comp = route.options.component ?? router.options.defaultComponent;
|
|
157
|
-
const out = Comp ? /* @__PURE__ */ jsx(Comp, {}) : /* @__PURE__ */ jsx(Outlet, {});
|
|
158
164
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
159
165
|
out,
|
|
160
166
|
router.AfterEachMatch ? /* @__PURE__ */ jsx(router.AfterEachMatch, { match, matchIndex }) : null
|
|
161
167
|
] });
|
|
162
|
-
}
|
|
163
|
-
const Outlet = React.memo(function
|
|
168
|
+
});
|
|
169
|
+
const Outlet = React.memo(function OutletImpl() {
|
|
164
170
|
const router = useRouter();
|
|
165
171
|
const matchId = React.useContext(matchContext);
|
|
166
172
|
const routeId = useRouterState({
|
|
@@ -206,6 +212,7 @@ const Outlet = React.memo(function Outlet2() {
|
|
|
206
212
|
});
|
|
207
213
|
export {
|
|
208
214
|
Match,
|
|
215
|
+
MatchInner,
|
|
209
216
|
Outlet
|
|
210
217
|
};
|
|
211
218
|
//# sourceMappingURL=Match.js.map
|
package/dist/esm/Match.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.js","sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { createControlledPromise, pick } from './utils'\nimport { CatchNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport { matchContext } from './matchContext'\nimport { defaultDeserializeError, isServerSideError } from './isServerSideError'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { rootRouteId } from './root'\nimport type { AnyRoute } from './route'\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\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 globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\n (route.options.errorComponent as any)?.preload)\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 resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n <MatchInner matchId={matchId} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\nfunction MatchInner({ matchId }: { matchId: string }): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const matchIndex = useRouterState({\n select: (s) => {\n return s.matches.findIndex((d) => d.id === matchId)\n },\n })\n\n const match = useRouterState({\n select: (s) => {\n const match = s.matches[matchIndex]!\n return pick(match, [\n 'id',\n 'status',\n 'error',\n 'loadPromise',\n 'minPendingPromise',\n ])\n },\n })\n\n // function useChangedDiff(value: any) {\n // const ref = React.useRef(value)\n // const changed = ref.current !== value\n // if (changed) {\n // console.log(\n // 'Changed:',\n // value,\n // Object.fromEntries(\n // Object.entries(value).filter(\n // ([key, val]) => val !== ref.current[key],\n // ),\n // ),\n // )\n // }\n // ref.current = value\n // }\n\n // useChangedDiff(match)\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n let error: unknown\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n\n error = deserializeError(match.error.data)\n } else {\n error = match.error\n }\n\n invariant(isNotFound(error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw match.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (router.isServer) {\n return (\n <RouteErrorComponent\n error={match.error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !match.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!router.isServer) {\n const minPendingPromise = createControlledPromise<void>()\n\n Promise.resolve().then(() => {\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise,\n }))\n })\n\n setTimeout(() => {\n minPendingPromise.resolve()\n\n // We've handled the minPendingPromise, so we can delete it\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }, pendingMinMs)\n }\n }\n\n throw match.loadPromise\n }\n\n const Comp = route.options.component ?? router.options.defaultComponent\n\n const out = Comp ? <Comp /> : <Outlet />\n\n return (\n <>\n {out}\n {router.AfterEachMatch ? (\n <router.AfterEachMatch match={match} matchIndex={matchIndex} />\n ) : null}\n </>\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { parentGlobalNotFound } = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (matchId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"names":["match"],"mappings":";;;;;;;;;;;;;;;;AAkBgB;;AACd;AACA;AAA+B;;AACd;AAAyC;AAAA;AAG1D;AAAA;AACE;AAC8C;AAG1C;AAEN;AAGA;AAEA;AAGA;AAEA;AAAqC;AAAA;AAGK;AAGpC;AAAA;AAAA;AAOA;AAEA;AAIA;AAIN;AAAgC;AACb;AAIjB;AAEI;AAAC;AAAA;AACoB;AACoB;AAGjC;AACI;AACR;AAAsB;AACxB;AAEA;AAAC;AAAA;AAKK;AAIM;AAED;AAAwD;AACjE;AAE8B;AAAA;AAChC;AAAA;AAKV;AACA;;AACE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEN;AAAkC;AAE9B;AAAkD;AACpD;AAGF;AAA6B;AAEnBA;AACN;AAAmB;AACjB;AACA;AACA;AACA;AACA;AACD;AACH;AAsBF;AAII;AACE;AACA;AACF;AAGQ;AAAiC;AAEzC;AAAc;AAGN;AAEH;AAAwC;AAG7C;AAGF;AAMA;AAAY;AAGV;AAMF;AAEI;AAAA;AAAC;AAAA;AACc;AACP;AACY;AAClB;AAAA;AAAA;AAKF;AACF;AAEM;AAAiC;AAEvC;AAAY;AACd;AAGE;AAEF;AAGI;AAEE;AACF;AAEQ;AACN;AAAwC;AACnC;AACH;AACA;AAGJ;AACE;AAGA;AAAwC;AACnC;AACgB;AACnB;AACW;AACjB;AAGF;AAAY;AAGd;AAEA;AAEA;AAEK;AAAA;AAGG;AAGV;AAEO;AACL;AACM;AACN;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEA;AAA0C;AAE5C;AACA;AACA;AAAA;AACE;AACmD;AAE9C;AAAA;AAC6B;AAAA;AAEtC;AAGF;AAAoC;;AAEhC;AACA;AACO;AAAoB;AAC7B;AAGF;AACS;AAA4C;AAGrD;AACS;AAAA;AAGT;AAEM;AAIN;AACE;AACuD;AAIlD;AACT;;;;;"}
|
|
1
|
+
{"version":3,"file":"Match.js","sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { createControlledPromise, pick } from './utils'\nimport { CatchNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport { matchContext } from './matchContext'\nimport { defaultDeserializeError, isServerSideError } from './isServerSideError'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { rootRouteId } from './root'\nimport type { AnyRoute } from './route'\n\nexport const Match = React.memo(function MatchImpl({\n matchId,\n}: {\n matchId: string\n}) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\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 globalNotFound option, with fallback to the notFoundRoute's component\n (route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n // If we're on the root route, allow forcefully wrapping in suspense\n (!route.isRoot || route.options.wrapInSuspense) &&\n (route.options.wrapInSuspense ??\n PendingComponent ??\n (route.options.errorComponent as any)?.preload)\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 resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent || ErrorComponent}\n onCatch={(error, errorInfo) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n routeOnCatch?.(error, errorInfo)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n <MatchInner matchId={matchId} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n})\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n matchId,\n}: {\n matchId: string\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const matchIndex = useRouterState({\n select: (s) => {\n return s.matches.findIndex((d) => d.id === matchId)\n },\n })\n\n const match = useRouterState({\n select: (s) => {\n const match = s.matches[matchIndex]!\n return pick(match, [\n 'id',\n 'status',\n 'error',\n 'loadPromise',\n 'minPendingPromise',\n ])\n },\n })\n\n const out = React.useMemo(() => {\n const Comp = route.options.component ?? router.options.defaultComponent\n return Comp ? <Comp key={matchId} /> : <Outlet />\n }, [matchId, route.options.component, router.options.defaultComponent])\n\n // function useChangedDiff(value: any) {\n // const ref = React.useRef(value)\n // const changed = ref.current !== value\n // if (changed) {\n // console.log(\n // 'Changed:',\n // value,\n // Object.fromEntries(\n // Object.entries(value).filter(\n // ([key, val]) => val !== ref.current[key],\n // ),\n // ),\n // )\n // }\n // ref.current = value\n // }\n\n // useChangedDiff(match)\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n let error: unknown\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n\n error = deserializeError(match.error.data)\n } else {\n error = match.error\n }\n\n invariant(isNotFound(error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n // warning(\n // false,\n // 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n // )\n throw match.loadPromise\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (router.isServer) {\n return (\n <RouteErrorComponent\n error={match.error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !match.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!router.isServer) {\n const minPendingPromise = createControlledPromise<void>()\n\n Promise.resolve().then(() => {\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise,\n }))\n })\n\n setTimeout(() => {\n minPendingPromise.resolve()\n\n // We've handled the minPendingPromise, so we can delete it\n router.updateMatch(match.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }, pendingMinMs)\n }\n }\n\n throw match.loadPromise\n }\n\n return (\n <>\n {out}\n {router.AfterEachMatch ? (\n <router.AfterEachMatch match={match} matchIndex={matchIndex} />\n ) : null}\n </>\n )\n})\n\nexport const Outlet = React.memo(function OutletImpl() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { parentGlobalNotFound } = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n const nextMatch = <Match matchId={childMatchId} />\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n if (matchId === rootRouteId) {\n return (\n <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n )\n }\n\n return nextMatch\n})\n"],"names":["match"],"mappings":";;;;;;;;;;;;;;;;AAkBO;AAA4C;AAEnD;;AAGE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAG1D;AAAA;AACE;AAC8C;AAG1C;AAEN;AAGA;AAEA;AAGA;AAEA;AAAqC;AAAA;AAGK;AAGpC;AAAA;AAAA;AAOA;AAEA;AAIA;AAIN;AAAgC;AACb;AAIjB;AAEI;AAAC;AAAA;AACoB;AACoB;AAGjC;AACI;AACR;AAAsB;AACxB;AAEA;AAAC;AAAA;AAKK;AAIM;AAED;AAAwD;AACjE;AAE8B;AAAA;AAChC;AAAA;AAKV;AAEO;AAAsD;AAE7D;;AAGE;AACA;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEN;AAAkC;AAE9B;AAAkD;AACpD;AAGF;AAA6B;AAEnBA;AACN;AAAmB;AACjB;AACA;AACA;AACA;AACA;AACD;AACH;AAGI;AACJ;AACA;AAA+C;AAsBjD;AAII;AACE;AACA;AACF;AAGQ;AAAiC;AAEzC;AAAc;AAGN;AAEH;AAAwC;AAG7C;AAGF;AAMA;AAAY;AAGV;AAMF;AAEI;AAAA;AAAC;AAAA;AACc;AACP;AACY;AAClB;AAAA;AAAA;AAKF;AACF;AAEM;AAAiC;AAEvC;AAAY;AACd;AAGE;AAEF;AAGI;AAEE;AACF;AAEQ;AACN;AAAwC;AACnC;AACH;AACA;AAGJ;AACE;AAGA;AAAwC;AACnC;AACgB;AACnB;AACW;AACjB;AAGF;AAAY;AAGd;AAEK;AAAA;AAGG;AAGV;AAEO;AACL;AACM;AACN;AAA+B;;AACd;AAAyC;AAAA;AAGpD;AAEA;AAA0C;AAE5C;AACA;AACA;AAAA;AACE;AACmD;AAE9C;AAAA;AAC6B;AAAA;AAEtC;AAGF;AAAoC;;AAEhC;AACA;AACO;AAAoB;AAC7B;AAGF;AACS;AAA4C;AAGrD;AACS;AAAA;AAGT;AAEM;AAIN;AACE;AACuD;AAIlD;AACT;;;;;;"}
|
package/dist/esm/route.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RootRouteId } from './root.js';
|
|
2
2
|
import { UseNavigateResult } from './useNavigate.js';
|
|
3
3
|
import { MakeRouteMatch, RouteMatch } from './Matches.js';
|
|
4
|
-
import { NavigateOptions, ParsePathParams,
|
|
4
|
+
import { NavigateOptions, ParsePathParams, ToMaskOptions } from './link.js';
|
|
5
5
|
import { ParsedLocation } from './location.js';
|
|
6
6
|
import { RouteById, RouteIds, RoutePaths } from './routeInfo.js';
|
|
7
7
|
import { AnyRouter, RegisteredRouter, Router } from './router.js';
|
|
@@ -385,7 +385,7 @@ export type RouteMask<TRouteTree extends AnyRoute> = {
|
|
|
385
385
|
};
|
|
386
386
|
export declare function createRouteMask<TRouteTree extends AnyRoute, TFrom extends RoutePaths<TRouteTree>, TTo extends string>(opts: {
|
|
387
387
|
routeTree: TRouteTree;
|
|
388
|
-
} &
|
|
388
|
+
} & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>): RouteMask<TRouteTree>;
|
|
389
389
|
/**
|
|
390
390
|
* @deprecated Use `ErrorComponentProps` instead.
|
|
391
391
|
*/
|
package/dist/esm/route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { joinPaths, trimPathLeft } from './path'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { rootRouteId } from './root'\nimport type * as React from 'react'\nimport type { RootRouteId } from './root'\nimport type { UseNavigateResult } from './useNavigate'\nimport type { MakeRouteMatch, RouteMatch } from './Matches'\nimport type { NavigateOptions, ParsePathParams, ToSubOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { RouteById, RouteIds, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, Router } from './router'\nimport type { Assign, Expand, NoInfer, PickRequired } from './utils'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type { NotFoundError } from './not-found'\nimport type { LazyRoute } from './fileRoute'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnySearchSchema = {}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = AnyPathParams,\n TAllParams = TParams,\n TRouteContextReturn = RouteContext,\n TRouteContext = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n> = BaseRouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TParentAllContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n> &\n UpdatableRouteOptions<\n NoInfer<TCustomId>,\n NoInfer<TAllParams>,\n NoInfer<TFullSearchSchema>,\n NoInfer<TLoaderData>,\n NoInfer<TAllContext>,\n NoInfer<TRouteContext>,\n NoInfer<TLoaderDeps>\n >\n\nexport type ParseParamsFn<TPath extends string, TParams> = (\n rawParams: Record<ParsePathParams<TPath>, string>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : Record<ParsePathParams<TPath>, any>\n\nexport type StringifyParamsFn<TPath extends string, TParams> = (\n params: TParams,\n) => Record<ParsePathParams<TPath>, string>\n\nexport type ParamsOptions<TPath extends string, TParams> = {\n params?: {\n parse: ParseParamsFn<TPath, TParams>\n stringify: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\nexport interface FullSearchSchemaOption<TFullSearchSchema> {\n search: TFullSearchSchema\n}\n\nexport type FileBaseRouteOptions<\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = {},\n TAllParams = {},\n TRouteContextReturn = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n> = {\n validateSearch?:\n | ((input: TSearchSchemaInput) => TSearchSchema)\n | { parse: (input: TSearchSchemaInput) => TSearchSchema }\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<TAllParams, TFullSearchSchema, TAllContext>,\n ) => any)\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: (\n ctx: BeforeLoadContext<TFullSearchSchema, TAllParams, TParentAllContext>,\n ) => Promise<TRouteContextReturn> | TRouteContextReturn | void\n loaderDeps?: (opts: FullSearchSchemaOption<TFullSearchSchema>) => TLoaderDeps\n loader?: (\n ctx: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,\n ) => TLoaderDataReturn | Promise<TLoaderDataReturn>\n} & ParamsOptions<TPath, TParams>\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = {},\n TAllParams = {},\n TRouteContextReturn = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TParentAllContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface BeforeLoadContext<\n TFullSearchSchema,\n TAllParams,\n TParentAllContext,\n> extends FullSearchSchemaOption<TFullSearchSchema> {\n abortController: AbortController\n preload: boolean\n params: Expand<TAllParams>\n context: TParentAllContext\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n}\n\nexport type UpdatableRouteOptions<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps,\n TRouteMatch = RouteMatch<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n> = {\n // test?: (args: TAllContext) => void\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preloadStaleTime?: number\n preloadGcTime?: number\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: Array<SearchFilter<TFullSearchSchema>>\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: Array<SearchFilter<TFullSearchSchema>>\n onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (match: TRouteMatch) => void\n onStay?: (match: TRouteMatch) => void\n onLeave?: (match: TRouteMatch) => void\n meta?: (ctx: {\n matches: Array<TRouteMatch>\n match: TRouteMatch\n params: TAllParams\n loaderData: TLoaderData\n }) => Array<React.JSX.IntrinsicElements['meta']>\n links?: () => Array<React.JSX.IntrinsicElements['link']>\n scripts?: () => Array<React.JSX.IntrinsicElements['script']>\n headers?: (ctx: { loaderData: TLoaderData }) => Record<string, string>\n} & UpdatableStaticRouteOption\n\nexport type UpdatableStaticRouteOption =\n {} extends PickRequired<StaticDataRouteOption>\n ? {\n staticData?: StaticDataRouteOption\n }\n : {\n staticData: StaticDataRouteOption\n }\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\n// The parse type here allows a zod schema to be passed directly to the validator\nexport type SearchSchemaValidator<TInput, TReturn> =\n | SearchSchemaValidatorObj<TInput, TReturn>\n | SearchSchemaValidatorFn<TInput, TReturn>\n\nexport type SearchSchemaValidatorObj<TInput, TReturn> = {\n parse?: SearchSchemaValidatorFn<TInput, TReturn>\n}\n\nexport type SearchSchemaValidatorFn<TInput, TReturn> = (\n searchObj: TInput,\n) => TReturn\n\nexport type RouteLoaderFn<\n in out TAllParams = {},\n in out TLoaderDeps extends Record<string, any> = {},\n in out TAllContext = AnyContext,\n TLoaderData = undefined,\n> = (\n match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,\n) => TLoaderData | Promise<TLoaderData>\n\nexport interface LoaderFnContext<\n in out TAllParams = {},\n in out TLoaderDeps = {},\n in out TAllContext = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<TAllParams>\n deps: TLoaderDeps\n context: TAllContext\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void>\n parentMatchPromise?: Promise<void>\n cause: 'preload' | 'enter' | 'stay'\n route: Route\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n}\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema> =\n TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchSchema,\n> = Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchSchemaUsed,\n> = Assign<InferFullSearchSchemaInput<TParentRoute>, TSearchSchemaUsed>\n\nexport type ResolveRouteContext<TRouteContextReturn> = [\n TRouteContextReturn,\n] extends [never]\n ? RouteContext\n : TRouteContextReturn\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouteContext,\n> = Assign<InferAllContext<TParentRoute>, TRouteContext>\n\nexport type ResolveLoaderData<TLoaderDataReturn> = [TLoaderDataReturn] extends [\n never,\n]\n ? undefined\n : TLoaderDataReturn\n\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type AnyRouteWithContext<TContext> = Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n TContext,\n any,\n any,\n any,\n any\n>\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySearchSchema\n TFullSearchSchema: AnySearchSchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport function getRouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n>(id: TId) {\n return new RouteApi<\n TId,\n TRouter,\n TRoute,\n TFullSearchSchema,\n TAllParams,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >({ id })\n}\n\nexport class RouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n> {\n id: TId\n\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch = <\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (s: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (s: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (s: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (s: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n return useNavigate({ from: this.id })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class Route<\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 TSearchSchemaInput = Record<string, unknown>,\n in out TSearchSchema = {},\n in out TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n in out TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n in out TFullSearchSchema = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n in out TParams = Record<ParsePathParams<TPath>, string>,\n in out TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n in out TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n in out TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n in out TChildren = unknown,\n> {\n isRoot: TParentRoute extends Route<any> ? true : false\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >\n\n // Set up in this.init()\n parentRoute!: TParentRoute\n id!: TId\n // customId!: TCustomId\n path!: TPath\n fullPath!: TFullPath\n to!: TrimPathRight<TFullPath>\n\n // Optional\n children?: TChildren\n originalIndex?: number\n router?: AnyRouter\n rank!: number\n lazyFn?: () => Promise<LazyRoute<any>>\n _lazyPromise?: Promise<void>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) {\n this.options = (options as any) || {}\n\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n types!: {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: TSearchSchema\n searchSchemaInput: TSearchSchemaInput\n searchSchemaUsed: TSearchSchemaUsed\n fullSearchSchema: TFullSearchSchema\n fullSearchSchemaInput: TFullSearchSchemaInput\n params: TParams\n allParams: TAllParams\n routeContext: TRouteContext\n allContext: TAllContext\n children: TChildren\n loaderData: TLoaderData\n loaderDeps: TLoaderDeps\n }\n\n init = (opts: { originalIndex: number }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.parentRoute = this.options?.getParentRoute?.()\n\n if (isRoot) {\n this.path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this.path = path as TPath\n this.id = id as TId\n // this.customId = customId as TCustomId\n this.fullPath = fullPath as TFullPath\n this.to = fullPath as TrimPathRight<TFullPath>\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TNewChildren\n > {\n this.children = (\n Array.isArray(children) ? children : Object.values(children)\n ) as any\n return this as any\n }\n\n updateLoader = <TNewLoaderData = unknown>(options: {\n loader: RouteLoaderFn<TAllParams, TLoaderDeps, TAllContext, TNewLoaderData>\n }) => {\n Object.assign(this.options, options)\n return this as unknown as Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TNewLoaderData,\n TChildren\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TCustomId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy = (lazyFn: () => Promise<LazyRoute<any>>): this => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch = <\n TRouter extends AnyRouter = RegisteredRouter,\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (search: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (search: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (search: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (search: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.id })\n }\n}\n\nexport function createRoute<\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 TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TParams = Record<ParsePathParams<TPath>, string>,\n TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n) {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>\n\nexport type RootRouteOptions<\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n TRouterContext, // TParentAllContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn, // TLoaderDataReturn,\n TLoaderData // TLoaderData,\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TRouteContextReturn extends RouteContext = RouteContext,\n TRouteContext extends\n RouteContext = ResolveRouteContext<TRouteContextReturn>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n >(\n options?: RootRouteOptions<\n TSearchSchemaInput,\n TSearchSchema,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) => {\n return createRootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData\n >(options as any)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TSearchSchemaInput = {},\n in out TSearchSchema = {},\n in out TSearchSchemaUsed = {},\n TRouteContextReturn = RouteContext,\n in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n in out TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchemaUsed,\n TSearchSchemaUsed, // TFullSearchSchemaInput\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren // TChildren\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchSchemaInput,\n TSearchSchema,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) {\n super(options as any)\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): RootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TNewChildren\n > {\n return super.addChildren(children)\n }\n}\n\nexport function createRootRoute<\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n>(\n options?: Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchema,\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n TRouterContext,\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n >,\n) {\n return new RootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >(options)\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\ntype RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends RoutePaths<TRouteTree>,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToSubOptions<Router<TRouteTree, 'never'>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps = {\n error: Error\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n//\n\nexport type ReactNode = any\n\nexport type SyncRouteComponent<TProps> =\n | ((props: TProps) => ReactNode)\n | React.LazyExoticComponent<(props: TProps) => ReactNode>\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = {},\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TRouteContextReturn = AnyContext,\n TRouteContext = RouteContext,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n {},\n {},\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n {},\n {},\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\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"],"names":["options"],"mappings":";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AAM,YAAY,QAAQ;AAAA,EACnC;AACF;AAEO,SAAS,gBAcd,SA0BA;AACO,SAAA,IAAI,UAUT,OAAO;AACX;AAkDO,SAAS,gBAKd,MAGuB;AAChB,SAAA;AACT;AAsCO,MAAM,sBAiBH,MAoBR;AAAA,EACA,YACE,SAyBA;AACM,UAAA;AAAA,MACJ,GAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EACH;AACF;"}
|
|
1
|
+
{"version":3,"file":"route.js","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { joinPaths, trimPathLeft } from './path'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { rootRouteId } from './root'\nimport type * as React from 'react'\nimport type { RootRouteId } from './root'\nimport type { UseNavigateResult } from './useNavigate'\nimport type { MakeRouteMatch, RouteMatch } from './Matches'\nimport type { NavigateOptions, ParsePathParams, ToMaskOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { RouteById, RouteIds, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, Router } from './router'\nimport type { Assign, Expand, NoInfer, PickRequired } from './utils'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type { NotFoundError } from './not-found'\nimport type { LazyRoute } from './fileRoute'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnySearchSchema = {}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = AnyPathParams,\n TAllParams = TParams,\n TRouteContextReturn = RouteContext,\n TRouteContext = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n> = BaseRouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TParentAllContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n> &\n UpdatableRouteOptions<\n NoInfer<TCustomId>,\n NoInfer<TAllParams>,\n NoInfer<TFullSearchSchema>,\n NoInfer<TLoaderData>,\n NoInfer<TAllContext>,\n NoInfer<TRouteContext>,\n NoInfer<TLoaderDeps>\n >\n\nexport type ParseParamsFn<TPath extends string, TParams> = (\n rawParams: Record<ParsePathParams<TPath>, string>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : Record<ParsePathParams<TPath>, any>\n\nexport type StringifyParamsFn<TPath extends string, TParams> = (\n params: TParams,\n) => Record<ParsePathParams<TPath>, string>\n\nexport type ParamsOptions<TPath extends string, TParams> = {\n params?: {\n parse: ParseParamsFn<TPath, TParams>\n stringify: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\nexport interface FullSearchSchemaOption<TFullSearchSchema> {\n search: TFullSearchSchema\n}\n\nexport type FileBaseRouteOptions<\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = {},\n TAllParams = {},\n TRouteContextReturn = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n> = {\n validateSearch?:\n | ((input: TSearchSchemaInput) => TSearchSchema)\n | { parse: (input: TSearchSchemaInput) => TSearchSchema }\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<TAllParams, TFullSearchSchema, TAllContext>,\n ) => any)\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: (\n ctx: BeforeLoadContext<TFullSearchSchema, TAllParams, TParentAllContext>,\n ) => Promise<TRouteContextReturn> | TRouteContextReturn | void\n loaderDeps?: (opts: FullSearchSchemaOption<TFullSearchSchema>) => TLoaderDeps\n loader?: (\n ctx: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,\n ) => TLoaderDataReturn | Promise<TLoaderDataReturn>\n} & ParamsOptions<TPath, TParams>\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TFullSearchSchema = TSearchSchema,\n TParams = {},\n TAllParams = {},\n TRouteContextReturn = RouteContext,\n TParentAllContext = AnyContext,\n TAllContext = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TParentAllContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface BeforeLoadContext<\n TFullSearchSchema,\n TAllParams,\n TParentAllContext,\n> extends FullSearchSchemaOption<TFullSearchSchema> {\n abortController: AbortController\n preload: boolean\n params: Expand<TAllParams>\n context: TParentAllContext\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n}\n\nexport type UpdatableRouteOptions<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps,\n TRouteMatch = RouteMatch<\n TRouteId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n> = {\n // test?: (args: TAllContext) => void\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preloadStaleTime?: number\n preloadGcTime?: number\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: Array<SearchFilter<TFullSearchSchema>>\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: Array<SearchFilter<TFullSearchSchema>>\n onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (match: TRouteMatch) => void\n onStay?: (match: TRouteMatch) => void\n onLeave?: (match: TRouteMatch) => void\n meta?: (ctx: {\n matches: Array<TRouteMatch>\n match: TRouteMatch\n params: TAllParams\n loaderData: TLoaderData\n }) => Array<React.JSX.IntrinsicElements['meta']>\n links?: () => Array<React.JSX.IntrinsicElements['link']>\n scripts?: () => Array<React.JSX.IntrinsicElements['script']>\n headers?: (ctx: { loaderData: TLoaderData }) => Record<string, string>\n} & UpdatableStaticRouteOption\n\nexport type UpdatableStaticRouteOption =\n {} extends PickRequired<StaticDataRouteOption>\n ? {\n staticData?: StaticDataRouteOption\n }\n : {\n staticData: StaticDataRouteOption\n }\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\n// The parse type here allows a zod schema to be passed directly to the validator\nexport type SearchSchemaValidator<TInput, TReturn> =\n | SearchSchemaValidatorObj<TInput, TReturn>\n | SearchSchemaValidatorFn<TInput, TReturn>\n\nexport type SearchSchemaValidatorObj<TInput, TReturn> = {\n parse?: SearchSchemaValidatorFn<TInput, TReturn>\n}\n\nexport type SearchSchemaValidatorFn<TInput, TReturn> = (\n searchObj: TInput,\n) => TReturn\n\nexport type RouteLoaderFn<\n in out TAllParams = {},\n in out TLoaderDeps extends Record<string, any> = {},\n in out TAllContext = AnyContext,\n TLoaderData = undefined,\n> = (\n match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext>,\n) => TLoaderData | Promise<TLoaderData>\n\nexport interface LoaderFnContext<\n in out TAllParams = {},\n in out TLoaderDeps = {},\n in out TAllContext = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<TAllParams>\n deps: TLoaderDeps\n context: TAllContext\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void>\n parentMatchPromise?: Promise<void>\n cause: 'preload' | 'enter' | 'stay'\n route: Route\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n}\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaUsed<TSearchSchemaInput, TSearchSchema> =\n TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : TSearchSchema\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchSchema,\n> = Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchSchemaUsed,\n> = Assign<InferFullSearchSchemaInput<TParentRoute>, TSearchSchemaUsed>\n\nexport type ResolveRouteContext<TRouteContextReturn> = [\n TRouteContextReturn,\n] extends [never]\n ? RouteContext\n : TRouteContextReturn\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouteContext,\n> = Assign<InferAllContext<TParentRoute>, TRouteContext>\n\nexport type ResolveLoaderData<TLoaderDataReturn> = [TLoaderDataReturn] extends [\n never,\n]\n ? undefined\n : TLoaderDataReturn\n\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type AnyRouteWithContext<TContext> = Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n TContext,\n any,\n any,\n any,\n any\n>\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySearchSchema\n TFullSearchSchema: AnySearchSchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport function getRouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n>(id: TId) {\n return new RouteApi<\n TId,\n TRouter,\n TRoute,\n TFullSearchSchema,\n TAllParams,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >({ id })\n}\n\nexport class RouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n> {\n id: TId\n\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch = <\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (s: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (s: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (s: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (s: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n return useNavigate({ from: this.id })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class Route<\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 TSearchSchemaInput = Record<string, unknown>,\n in out TSearchSchema = {},\n in out TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n in out TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n in out TFullSearchSchema = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n in out TParams = Record<ParsePathParams<TPath>, string>,\n in out TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n in out TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n in out TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n in out TChildren = unknown,\n> {\n isRoot: TParentRoute extends Route<any> ? true : false\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >\n\n // Set up in this.init()\n parentRoute!: TParentRoute\n id!: TId\n // customId!: TCustomId\n path!: TPath\n fullPath!: TFullPath\n to!: TrimPathRight<TFullPath>\n\n // Optional\n children?: TChildren\n originalIndex?: number\n router?: AnyRouter\n rank!: number\n lazyFn?: () => Promise<LazyRoute<any>>\n _lazyPromise?: Promise<void>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) {\n this.options = (options as any) || {}\n\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n types!: {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: TSearchSchema\n searchSchemaInput: TSearchSchemaInput\n searchSchemaUsed: TSearchSchemaUsed\n fullSearchSchema: TFullSearchSchema\n fullSearchSchemaInput: TFullSearchSchemaInput\n params: TParams\n allParams: TAllParams\n routeContext: TRouteContext\n allContext: TAllContext\n children: TChildren\n loaderData: TLoaderData\n loaderDeps: TLoaderDeps\n }\n\n init = (opts: { originalIndex: number }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.parentRoute = this.options?.getParentRoute?.()\n\n if (isRoot) {\n this.path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this.path = path as TPath\n this.id = id as TId\n // this.customId = customId as TCustomId\n this.fullPath = fullPath as TFullPath\n this.to = fullPath as TrimPathRight<TFullPath>\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TNewChildren\n > {\n this.children = (\n Array.isArray(children) ? children : Object.values(children)\n ) as any\n return this as any\n }\n\n updateLoader = <TNewLoaderData = unknown>(options: {\n loader: RouteLoaderFn<TAllParams, TLoaderDeps, TAllContext, TNewLoaderData>\n }) => {\n Object.assign(this.options, options)\n return this as unknown as Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TNewLoaderData,\n TChildren\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TCustomId,\n TAllParams,\n TFullSearchSchema,\n TLoaderData,\n TAllContext,\n TRouteContext,\n TLoaderDeps\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy = (lazyFn: () => Promise<LazyRoute<any>>): this => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch = <\n TRouter extends AnyRouter = RegisteredRouter,\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (search: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (search: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (search: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (search: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.id })\n }\n}\n\nexport function createRoute<\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 TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TParams = Record<ParsePathParams<TPath>, string>,\n TAllParams = ResolveAllParamsFromParent<TParentRoute, TParams>,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n) {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>\n\nexport type RootRouteOptions<\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n TRouterContext, // TParentAllContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn, // TLoaderDataReturn,\n TLoaderData // TLoaderData,\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TRouteContextReturn extends RouteContext = RouteContext,\n TRouteContext extends\n RouteContext = ResolveRouteContext<TRouteContextReturn>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n >(\n options?: RootRouteOptions<\n TSearchSchemaInput,\n TSearchSchema,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) => {\n return createRootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData\n >(options as any)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TSearchSchemaInput = {},\n in out TSearchSchema = {},\n in out TSearchSchemaUsed = {},\n TRouteContextReturn = RouteContext,\n in out TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n in out TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n in out TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchemaUsed,\n TSearchSchemaUsed, // TFullSearchSchemaInput\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren // TChildren\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchSchemaInput,\n TSearchSchema,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n ) {\n super(options as any)\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): RootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TNewChildren\n > {\n return super.addChildren(children)\n }\n}\n\nexport function createRootRoute<\n TSearchSchemaInput = {},\n TSearchSchema = {},\n TSearchSchemaUsed = ResolveSearchSchemaUsed<\n TSearchSchemaInput,\n TSearchSchema\n >,\n TRouteContextReturn = RouteContext,\n TRouteContext = ResolveRouteContext<TRouteContextReturn>,\n TRouterContext = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n>(\n options?: Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchemaInput, // TSearchSchemaInput\n TSearchSchema, // TSearchSchema\n TSearchSchema,\n {}, // TParams\n {}, // TAllParams\n TRouteContextReturn, // TRouteContextReturn\n TRouteContext, // TRouteContext\n TRouterContext,\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n >,\n) {\n return new RootRoute<\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TRouteContextReturn,\n TRouteContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >(options)\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\ntype RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends RoutePaths<TRouteTree>,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps = {\n error: Error\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n//\n\nexport type ReactNode = any\n\nexport type SyncRouteComponent<TProps> =\n | ((props: TProps) => ReactNode)\n | React.LazyExoticComponent<(props: TProps) => ReactNode>\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TSearchSchemaInput = Record<string, unknown>,\n TSearchSchema = {},\n TSearchSchemaUsed = {},\n TFullSearchSchemaInput = ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchSchemaUsed\n >,\n TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>,\n TRouteContextReturn = AnyContext,\n TRouteContext = RouteContext,\n TAllContext = ResolveAllContext<TParentRoute, TRouteContext>,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderDataReturn = {},\n TLoaderData = ResolveLoaderData<TLoaderDataReturn>,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchSchemaInput,\n TSearchSchema,\n TSearchSchemaUsed,\n TFullSearchSchemaInput,\n TFullSearchSchema,\n {},\n {},\n TRouteContextReturn,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n TSearchSchemaInput,\n TSearchSchema,\n TFullSearchSchema,\n {},\n {},\n TRouteContextReturn,\n TRouteContext,\n InferAllContext<TParentRoute>,\n TAllContext,\n TLoaderDeps,\n TLoaderDataReturn,\n TLoaderData\n >,\n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7B,MAAM,kBAWH,MAoBR;AAAA;AAAA;AAAA;AAAA,EAIA,YACE,SAUA;AACA,UAAM,OAAc;AAAA,EACtB;AAAA,EAEA,YAKE,UAYA;AACO,WAAA,MAAM,YAAY,QAAQ;AAAA,EACnC;AACF;AAEO,SAAS,gBAcd,SA0BA;AACO,SAAA,IAAI,UAUT,OAAO;AACX;AAkDO,SAAS,gBAKd,MAGuB;AAChB,SAAA;AACT;AAsCO,MAAM,sBAiBH,MAoBR;AAAA,EACA,YACE,SAyBA;AACM,UAAA;AAAA,MACJ,GAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EACH;AACF;"}
|
package/package.json
CHANGED
package/src/Match.tsx
CHANGED
|
@@ -16,7 +16,11 @@ import { renderRouteNotFound } from './renderRouteNotFound'
|
|
|
16
16
|
import { rootRouteId } from './root'
|
|
17
17
|
import type { AnyRoute } from './route'
|
|
18
18
|
|
|
19
|
-
export
|
|
19
|
+
export const Match = React.memo(function MatchImpl({
|
|
20
|
+
matchId,
|
|
21
|
+
}: {
|
|
22
|
+
matchId: string
|
|
23
|
+
}) {
|
|
20
24
|
const router = useRouter()
|
|
21
25
|
const routeId = useRouterState({
|
|
22
26
|
select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,
|
|
@@ -99,8 +103,13 @@ export function Match({ matchId }: { matchId: string }) {
|
|
|
99
103
|
</ResolvedSuspenseBoundary>
|
|
100
104
|
</matchContext.Provider>
|
|
101
105
|
)
|
|
102
|
-
}
|
|
103
|
-
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
export const MatchInner = React.memo(function MatchInnerImpl({
|
|
109
|
+
matchId,
|
|
110
|
+
}: {
|
|
111
|
+
matchId: string
|
|
112
|
+
}): any {
|
|
104
113
|
const router = useRouter()
|
|
105
114
|
const routeId = useRouterState({
|
|
106
115
|
select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,
|
|
@@ -127,6 +136,11 @@ function MatchInner({ matchId }: { matchId: string }): any {
|
|
|
127
136
|
},
|
|
128
137
|
})
|
|
129
138
|
|
|
139
|
+
const out = React.useMemo(() => {
|
|
140
|
+
const Comp = route.options.component ?? router.options.defaultComponent
|
|
141
|
+
return Comp ? <Comp key={matchId} /> : <Outlet />
|
|
142
|
+
}, [matchId, route.options.component, router.options.defaultComponent])
|
|
143
|
+
|
|
130
144
|
// function useChangedDiff(value: any) {
|
|
131
145
|
// const ref = React.useRef(value)
|
|
132
146
|
// const changed = ref.current !== value
|
|
@@ -236,10 +250,6 @@ function MatchInner({ matchId }: { matchId: string }): any {
|
|
|
236
250
|
throw match.loadPromise
|
|
237
251
|
}
|
|
238
252
|
|
|
239
|
-
const Comp = route.options.component ?? router.options.defaultComponent
|
|
240
|
-
|
|
241
|
-
const out = Comp ? <Comp /> : <Outlet />
|
|
242
|
-
|
|
243
253
|
return (
|
|
244
254
|
<>
|
|
245
255
|
{out}
|
|
@@ -248,9 +258,9 @@ function MatchInner({ matchId }: { matchId: string }): any {
|
|
|
248
258
|
) : null}
|
|
249
259
|
</>
|
|
250
260
|
)
|
|
251
|
-
}
|
|
261
|
+
})
|
|
252
262
|
|
|
253
|
-
export const Outlet = React.memo(function
|
|
263
|
+
export const Outlet = React.memo(function OutletImpl() {
|
|
254
264
|
const router = useRouter()
|
|
255
265
|
const matchId = React.useContext(matchContext)
|
|
256
266
|
const routeId = useRouterState({
|
package/src/route.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type * as React from 'react'
|
|
|
12
12
|
import type { RootRouteId } from './root'
|
|
13
13
|
import type { UseNavigateResult } from './useNavigate'
|
|
14
14
|
import type { MakeRouteMatch, RouteMatch } from './Matches'
|
|
15
|
-
import type { NavigateOptions, ParsePathParams,
|
|
15
|
+
import type { NavigateOptions, ParsePathParams, ToMaskOptions } from './link'
|
|
16
16
|
import type { ParsedLocation } from './location'
|
|
17
17
|
import type { RouteById, RouteIds, RoutePaths } from './routeInfo'
|
|
18
18
|
import type { AnyRouter, RegisteredRouter, Router } from './router'
|
|
@@ -1233,7 +1233,7 @@ export function createRouteMask<
|
|
|
1233
1233
|
>(
|
|
1234
1234
|
opts: {
|
|
1235
1235
|
routeTree: TRouteTree
|
|
1236
|
-
} &
|
|
1236
|
+
} & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>,
|
|
1237
1237
|
): RouteMask<TRouteTree> {
|
|
1238
1238
|
return opts as any
|
|
1239
1239
|
}
|