@tanstack/solid-router 1.114.6 → 1.114.7
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 +3 -4
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/index.cjs +16 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +4 -3
- package/dist/cjs/not-found.cjs +3 -12
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +1 -19
- package/dist/cjs/route.cjs +1 -2
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +1 -2
- package/dist/cjs/router.cjs +16 -18
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -2
- package/dist/esm/Match.js +2 -3
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/not-found.d.ts +1 -19
- package/dist/esm/not-found.js +2 -11
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/route.d.ts +1 -2
- package/dist/esm/route.js +1 -2
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +1 -2
- package/dist/esm/router.js +1 -3
- package/dist/esm/router.js.map +1 -1
- package/dist/source/Match.jsx +2 -3
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/index.d.ts +4 -3
- package/dist/source/index.jsx +3 -2
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/not-found.d.ts +1 -19
- package/dist/source/not-found.jsx +1 -10
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/route.d.ts +1 -2
- package/dist/source/route.js +1 -2
- package/dist/source/route.js.map +1 -1
- package/dist/source/router.d.ts +1 -2
- package/dist/source/router.js +1 -3
- package/dist/source/router.js.map +1 -1
- package/package.json +2 -2
- package/src/Match.tsx +3 -2
- package/src/index.tsx +4 -8
- package/src/not-found.tsx +2 -28
- package/src/route.ts +7 -3
- package/src/router.ts +4 -3
- package/dist/cjs/redirects.cjs +0 -29
- package/dist/cjs/redirects.cjs.map +0 -1
- package/dist/cjs/redirects.d.cts +0 -4
- package/dist/esm/redirects.d.ts +0 -4
- package/dist/esm/redirects.js +0 -29
- package/dist/esm/redirects.js.map +0 -1
- package/dist/source/redirects.d.ts +0 -4
- package/dist/source/redirects.js +0 -25
- package/dist/source/redirects.js.map +0 -1
- package/src/redirects.ts +0 -41
package/dist/cjs/Match.cjs
CHANGED
|
@@ -9,7 +9,6 @@ const CatchBoundary = require("./CatchBoundary.cjs");
|
|
|
9
9
|
const useRouterState = require("./useRouterState.cjs");
|
|
10
10
|
const useRouter = require("./useRouter.cjs");
|
|
11
11
|
const notFound = require("./not-found.cjs");
|
|
12
|
-
const redirects = require("./redirects.cjs");
|
|
13
12
|
const matchContext = require("./matchContext.cjs");
|
|
14
13
|
const SafeFragment = require("./SafeFragment.cjs");
|
|
15
14
|
const renderRouteNotFound = require("./renderRouteNotFound.cjs");
|
|
@@ -95,7 +94,7 @@ const Match = (props) => {
|
|
|
95
94
|
},
|
|
96
95
|
onCatch: (error) => {
|
|
97
96
|
var _a;
|
|
98
|
-
if (
|
|
97
|
+
if (routerCore.isNotFound(error)) throw error;
|
|
99
98
|
warning(false, `Error in route match: ${props.matchId}`);
|
|
100
99
|
(_a = routeOnCatch()) == null ? void 0 : _a(error);
|
|
101
100
|
},
|
|
@@ -181,7 +180,7 @@ const MatchInner = (props) => {
|
|
|
181
180
|
return match().status === "notFound";
|
|
182
181
|
},
|
|
183
182
|
children: (_) => {
|
|
184
|
-
invariant(
|
|
183
|
+
invariant(routerCore.isNotFound(match().error), "Expected a notFound error");
|
|
185
184
|
return renderRouteNotFound.renderRouteNotFound(router, route(), match().error);
|
|
186
185
|
}
|
|
187
186
|
}), web.createComponent(Solid__namespace.Match, {
|
|
@@ -189,7 +188,7 @@ const MatchInner = (props) => {
|
|
|
189
188
|
return match().status === "redirected";
|
|
190
189
|
},
|
|
191
190
|
children: (_) => {
|
|
192
|
-
invariant(
|
|
191
|
+
invariant(routerCore.isRedirect(match().error), "Expected a redirect error");
|
|
193
192
|
const [loaderResult] = Solid__namespace.createResource(async () => {
|
|
194
193
|
var _a;
|
|
195
194
|
await new Promise((r) => setTimeout(r, 0));
|
package/dist/cjs/Match.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.cjs","sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n pick,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { Dynamic } from 'solid-js/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute } from '@tanstack/router-core'\n\nexport const Match = (props: { matchId: string }) => {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => {\n return s.matches.find((d) => d.id === props.matchId)?.routeId as string\n },\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${props.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 routeErrorComponent = () =>\n route().options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = () =>\n route().options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = () =>\n route().isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route().options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route().options.notFoundComponent\n\n 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 ? Solid.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = () =>\n routeErrorComponent() ? CatchBoundary : SafeFragment\n\n const ResolvedNotFoundBoundary = () =>\n routeNotFoundComponent() ? CatchNotFound : SafeFragment\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const parentRouteId = useRouterState({\n select: (s) => {\n const index = s.matches.findIndex((d) => d.id === props.matchId)\n return s.matches[index - 1]?.routeId as string\n },\n })\n\n return (\n <>\n <matchContext.Provider value={() => props.matchId}>\n <Dynamic\n component={ResolvedSuspenseBoundary()}\n fallback={<Dynamic component={PendingComponent()} />}\n >\n <Dynamic\n component={ResolvedCatchBoundary()}\n getResetKey={() => resetKey()}\n errorComponent={routeErrorComponent() || ErrorComponent}\n onCatch={(error: Error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${props.matchId}`)\n routeOnCatch()?.(error)\n }}\n >\n <Dynamic\n component={ResolvedNotFoundBoundary()}\n fallback={(error: any) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent() ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route().isRoot)\n )\n throw error\n\n return (\n <Dynamic component={routeNotFoundComponent()} {...error} />\n )\n }}\n >\n <MatchInner matchId={props.matchId} />\n </Dynamic>\n </Dynamic>\n </Dynamic>\n </matchContext.Provider>\n\n {parentRouteId() === rootRouteId ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </>\n )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\nfunction OnRendered() {\n const router = useRouter()\n\n const location = useRouterState({\n select: (s) => {\n return s.resolvedLocation?.state.key\n },\n })\n Solid.createEffect(\n Solid.on([location], () => {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(router.state),\n })\n }),\n )\n return null\n}\n\nexport const MatchInner = (props: { matchId: string }): any => {\n const router = useRouter()\n\n // { match, key, routeId } =\n const matchState: Solid.Accessor<any> = useRouterState({\n select: (s) => {\n const matchIndex = s.matches.findIndex((d) => d.id === props.matchId)\n const match = s.matches[matchIndex]!\n const routeId = match.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: pick(match, ['id', 'status', 'error']),\n }\n },\n })\n\n const route = () => router.routesById[matchState().routeId]!\n\n // function useChangedDiff(value: any) {\n // const ref = Solid.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 const match = () => matchState().match\n\n const out = () => {\n const Comp = route().options.component ?? router.options.defaultComponent\n if (Comp) {\n return <Comp />\n }\n return <Outlet />\n }\n\n return (\n <Solid.Switch>\n <Solid.Match when={match().status === 'notFound'}>\n {(_) => {\n invariant(isNotFound(match().error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route(), match().error)\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'redirected'}>\n {(_) => {\n invariant(isRedirect(match().error), 'Expected a redirect error')\n\n const [loaderResult] = Solid.createResource(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(match().id)?.loadPromise\n })\n\n return <>{loaderResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'error'}>\n {(_) => {\n if (router.isServer) {\n const RouteErrorComponent =\n (route().options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n\n return (\n <RouteErrorComponent\n error={match().error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw match().error\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'pending'}>\n {(_) => {\n const pendingMinMs =\n route().options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !router.getMatch(match().id)?.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 const [loaderResult] = Solid.createResource(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(match().id)?.loadPromise\n })\n\n return <>{loaderResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'success'}>{out()}</Solid.Match>\n </Solid.Switch>\n )\n}\n\nexport const Outlet = () => {\n const router = useRouter()\n const matchId = Solid.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 parentMatch.globalNotFound\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 const v = matches[index + 1]?.id\n return v\n },\n })\n\n return (\n <Solid.Switch>\n <Solid.Match when={parentGlobalNotFound()}>\n {renderRouteNotFound(router, route(), undefined)}\n </Solid.Match>\n <Solid.Match when={childMatchId()}>\n {(matchId) => {\n // const nextMatch = <Match matchId={matchId()} />\n\n return (\n <Solid.Show\n when={matchId() === rootRouteId}\n fallback={<Match matchId={matchId()} />}\n >\n <Solid.Suspense\n fallback={\n <Dynamic component={router.options.defaultPendingComponent} />\n }\n >\n <Match matchId={matchId()} />\n </Solid.Suspense>\n </Solid.Show>\n )\n }}\n </Solid.Match>\n </Solid.Switch>\n )\n}\n"],"names":["Match","props","router","useRouter","routeId","useRouterState","select","s","matches","find","d","id","matchId","invariant","route","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","ResolvedSuspenseBoundary","wrapInSuspense","preload","Solid","Suspense","SafeFragment","ResolvedCatchBoundary","CatchBoundary","ResolvedNotFoundBoundary","CatchNotFound","resetKey","loadedAt","parentRouteId","index","findIndex","_$createComponent","matchContext","Provider","value","children","Dynamic","fallback","getResetKey","ErrorComponent","error","isNotFound","warning","_$mergeProps","MatchInner","_$memo","rootRouteId","OnRendered","ScrollRestoration","location","resolvedLocation","state","key","createEffect","on","emit","type","getLocationChangeInfo","matchState","matchIndex","match","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","JSON","stringify","undefined","pick","out","Comp","defaultComponent","Outlet","Switch","when","status","_","renderRouteNotFound","isRedirect","loaderResult","createResource","Promise","r","setTimeout","getMatch","loadPromise","isServer","RouteErrorComponent","info","componentStack","pendingMinMs","defaultPendingMinMs","minPendingPromise","createControlledPromise","resolve","then","updateMatch","prev","useContext","parentGlobalNotFound","parentMatch","globalNotFound","childMatchId","v","Show"],"mappings":";;;;;;;;;;;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A,gBAEjDZ,iBAAMlC,OAAK;AAAA,QAAA,IAAC6F,OAAI;AAAA,iBAAE4B,aAAa;AAAA,QAAC;AAAA,QAAAvE,UAC7BtC,CAAAA,aAAY;AAGZkC,iBAAAA,IAAAA,gBACGZ,iBAAMyF,MAAI;AAAA,YAAA,IACT9B,OAAI;AAAA,qBAAEjF,SAAciD,MAAAA,WAAAA;AAAAA,YAAW;AAAA,YAAA,IAC/BT,WAAQ;AAAA,qBAAAN,IAAAA,gBAAG9C,OAAK;AAAA,gBAAA,IAACY,UAAO;AAAA,yBAAEA,SAAQ;AAAA,gBAAA;AAAA,cAAC,CAAA;AAAA,YAAA;AAAA,YAAA,IAAAsC,WAAA;AAAAJ,qBAAAA,IAAAA,gBAElCZ,iBAAMC,UAAQ;AAAA,gBAAA,IACbiB,WAAQ;AAAA,yBAAAN,IAAAA,gBACLK,IAAAA,SAAO;AAAA,oBAAA,IAACrB,YAAS;AAAA,6BAAE5B,OAAOe,QAAQE;AAAAA,oBAAAA;AAAAA,kBAAuB,CAAA;AAAA,gBAAA;AAAA,gBAAA,IAAA+B,WAAA;AAAA,yBAAAJ,IAAAA,gBAG3D9C,OAAK;AAAA,oBAAA,IAACY,UAAO;AAAA,6BAAEA,SAAQ;AAAA,oBAAA;AAAA,kBAAC,CAAA;AAAA,gBAAA;AAAA,cAAA,CAAA;AAAA,YAAA;AAAA,UAAA,CAAA;AAAA,QAAA;AAAA,MAIjC,CAAC,CAAA;AAAA,IAAA;AAAA,EAAA,CAAA;AAIT;;;;"}
|
|
1
|
+
{"version":3,"file":"Match.cjs","sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n pick,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { Dynamic } from 'solid-js/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute } from '@tanstack/router-core'\n\nexport const Match = (props: { matchId: string }) => {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => {\n return s.matches.find((d) => d.id === props.matchId)?.routeId as string\n },\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${props.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 routeErrorComponent = () =>\n route().options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = () =>\n route().options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = () =>\n route().isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route().options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route().options.notFoundComponent\n\n 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 ? Solid.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = () =>\n routeErrorComponent() ? CatchBoundary : SafeFragment\n\n const ResolvedNotFoundBoundary = () =>\n routeNotFoundComponent() ? CatchNotFound : SafeFragment\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const parentRouteId = useRouterState({\n select: (s) => {\n const index = s.matches.findIndex((d) => d.id === props.matchId)\n return s.matches[index - 1]?.routeId as string\n },\n })\n\n return (\n <>\n <matchContext.Provider value={() => props.matchId}>\n <Dynamic\n component={ResolvedSuspenseBoundary()}\n fallback={<Dynamic component={PendingComponent()} />}\n >\n <Dynamic\n component={ResolvedCatchBoundary()}\n getResetKey={() => resetKey()}\n errorComponent={routeErrorComponent() || ErrorComponent}\n onCatch={(error: Error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${props.matchId}`)\n routeOnCatch()?.(error)\n }}\n >\n <Dynamic\n component={ResolvedNotFoundBoundary()}\n fallback={(error: any) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent() ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route().isRoot)\n )\n throw error\n\n return (\n <Dynamic component={routeNotFoundComponent()} {...error} />\n )\n }}\n >\n <MatchInner matchId={props.matchId} />\n </Dynamic>\n </Dynamic>\n </Dynamic>\n </matchContext.Provider>\n\n {parentRouteId() === rootRouteId ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </>\n )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\nfunction OnRendered() {\n const router = useRouter()\n\n const location = useRouterState({\n select: (s) => {\n return s.resolvedLocation?.state.key\n },\n })\n Solid.createEffect(\n Solid.on([location], () => {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(router.state),\n })\n }),\n )\n return null\n}\n\nexport const MatchInner = (props: { matchId: string }): any => {\n const router = useRouter()\n\n // { match, key, routeId } =\n const matchState: Solid.Accessor<any> = useRouterState({\n select: (s) => {\n const matchIndex = s.matches.findIndex((d) => d.id === props.matchId)\n const match = s.matches[matchIndex]!\n const routeId = match.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: pick(match, ['id', 'status', 'error']),\n }\n },\n })\n\n const route = () => router.routesById[matchState().routeId]!\n\n // function useChangedDiff(value: any) {\n // const ref = Solid.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 const match = () => matchState().match\n\n const out = () => {\n const Comp = route().options.component ?? router.options.defaultComponent\n if (Comp) {\n return <Comp />\n }\n return <Outlet />\n }\n\n return (\n <Solid.Switch>\n <Solid.Match when={match().status === 'notFound'}>\n {(_) => {\n invariant(isNotFound(match().error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route(), match().error)\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'redirected'}>\n {(_) => {\n invariant(isRedirect(match().error), 'Expected a redirect error')\n\n const [loaderResult] = Solid.createResource(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(match().id)?.loadPromise\n })\n\n return <>{loaderResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'error'}>\n {(_) => {\n if (router.isServer) {\n const RouteErrorComponent =\n (route().options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n\n return (\n <RouteErrorComponent\n error={match().error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw match().error\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'pending'}>\n {(_) => {\n const pendingMinMs =\n route().options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !router.getMatch(match().id)?.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 const [loaderResult] = Solid.createResource(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(match().id)?.loadPromise\n })\n\n return <>{loaderResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'success'}>{out()}</Solid.Match>\n </Solid.Switch>\n )\n}\n\nexport const Outlet = () => {\n const router = useRouter()\n const matchId = Solid.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 parentMatch.globalNotFound\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 const v = matches[index + 1]?.id\n return v\n },\n })\n\n return (\n <Solid.Switch>\n <Solid.Match when={parentGlobalNotFound()}>\n {renderRouteNotFound(router, route(), undefined)}\n </Solid.Match>\n <Solid.Match when={childMatchId()}>\n {(matchId) => {\n // const nextMatch = <Match matchId={matchId()} />\n\n return (\n <Solid.Show\n when={matchId() === rootRouteId}\n fallback={<Match matchId={matchId()} />}\n >\n <Solid.Suspense\n fallback={\n <Dynamic component={router.options.defaultPendingComponent} />\n }\n >\n <Match matchId={matchId()} />\n </Solid.Suspense>\n </Solid.Show>\n )\n }}\n </Solid.Match>\n </Solid.Switch>\n )\n}\n"],"names":["Match","props","router","useRouter","routeId","useRouterState","select","s","matches","find","d","id","matchId","invariant","route","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","ResolvedSuspenseBoundary","wrapInSuspense","preload","Solid","Suspense","SafeFragment","ResolvedCatchBoundary","CatchBoundary","ResolvedNotFoundBoundary","CatchNotFound","resetKey","loadedAt","parentRouteId","index","findIndex","_$createComponent","matchContext","Provider","value","children","Dynamic","fallback","getResetKey","ErrorComponent","error","isNotFound","warning","_$mergeProps","MatchInner","_$memo","rootRouteId","OnRendered","ScrollRestoration","location","resolvedLocation","state","key","createEffect","on","emit","type","getLocationChangeInfo","matchState","matchIndex","match","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","JSON","stringify","undefined","pick","out","Comp","defaultComponent","Outlet","Switch","when","status","_","renderRouteNotFound","isRedirect","loaderResult","createResource","Promise","r","setTimeout","getMatch","loadPromise","isServer","RouteErrorComponent","info","componentStack","pendingMinMs","defaultPendingMinMs","minPendingPromise","createControlledPromise","resolve","then","updateMatch","prev","useContext","parentGlobalNotFound","parentMatch","globalNotFound","childMatchId","v","Show"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBaA,MAAAA,QAAQA,CAACC,UAA+B;AACnD,QAAMC,SAASC,UAAAA,UAAU;AACzB,QAAMC,UAAUC,eAAAA,eAAe;AAAA,IAC7BC,QAASC,CAAM,MAAA;;AACNA,cAAAA,OAAEC,QAAQC,KAAMC,CAAAA,MAAMA,EAAEC,OAAOV,MAAMW,OAAO,MAA5CL,mBAA+CH;AAAAA,IAAAA;AAAAA,EACxD,CACD;AAEDS,YACET,SACA,uCAAuCH,MAAMW,OAAO,0BACtD;AAEA,QAAME,QAAwBA,MAAMZ,OAAOa,WAAWX,SAAS;AAE/D,QAAMY,mBAAmBA,MACvBF,QAAQG,QAAQC,oBAAoBhB,OAAOe,QAAQE;AAErD,QAAMC,sBAAsBA,MAC1BN,QAAQG,QAAQI,kBAAkBnB,OAAOe,QAAQK;AAEnD,QAAMC,eAAeA,M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AAAA,oBAAA,IAACrB,YAAS;AAAA,6BAAE5B,OAAOe,QAAQE;AAAAA,oBAAAA;AAAAA,kBAAuB,CAAA;AAAA,gBAAA;AAAA,gBAAA,IAAA+B,WAAA;AAAA,yBAAAJ,IAAAA,gBAG3D9C,OAAK;AAAA,oBAAA,IAACY,UAAO;AAAA,6BAAEA,SAAQ;AAAA,oBAAA;AAAA,kBAAC,CAAA;AAAA,gBAAA;AAAA,cAAA,CAAA;AAAA,YAAA;AAAA,UAAA,CAAA;AAAA,QAAA;AAAA,MAIjC,CAAC,CAAA;AAAA,IAAA;AAAA,EAAA,CAAA;AAIT;;;;"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -15,7 +15,6 @@ const Match = require("./Match.cjs");
|
|
|
15
15
|
const useMatch = require("./useMatch.cjs");
|
|
16
16
|
const useLoaderDeps = require("./useLoaderDeps.cjs");
|
|
17
17
|
const useLoaderData = require("./useLoaderData.cjs");
|
|
18
|
-
const redirects = require("./redirects.cjs");
|
|
19
18
|
const route = require("./route.cjs");
|
|
20
19
|
const router = require("./router.cjs");
|
|
21
20
|
const RouterProvider = require("./RouterProvider.cjs");
|
|
@@ -94,6 +93,10 @@ Object.defineProperty(exports, "isMatch", {
|
|
|
94
93
|
enumerable: true,
|
|
95
94
|
get: () => routerCore.isMatch
|
|
96
95
|
});
|
|
96
|
+
Object.defineProperty(exports, "isNotFound", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: () => routerCore.isNotFound
|
|
99
|
+
});
|
|
97
100
|
Object.defineProperty(exports, "isPlainArray", {
|
|
98
101
|
enumerable: true,
|
|
99
102
|
get: () => routerCore.isPlainArray
|
|
@@ -102,6 +105,10 @@ Object.defineProperty(exports, "isPlainObject", {
|
|
|
102
105
|
enumerable: true,
|
|
103
106
|
get: () => routerCore.isPlainObject
|
|
104
107
|
});
|
|
108
|
+
Object.defineProperty(exports, "isRedirect", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: () => routerCore.isRedirect
|
|
111
|
+
});
|
|
105
112
|
Object.defineProperty(exports, "joinPaths", {
|
|
106
113
|
enumerable: true,
|
|
107
114
|
get: () => routerCore.joinPaths
|
|
@@ -114,6 +121,10 @@ Object.defineProperty(exports, "matchPathname", {
|
|
|
114
121
|
enumerable: true,
|
|
115
122
|
get: () => routerCore.matchPathname
|
|
116
123
|
});
|
|
124
|
+
Object.defineProperty(exports, "notFound", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: () => routerCore.notFound
|
|
127
|
+
});
|
|
117
128
|
Object.defineProperty(exports, "parsePathname", {
|
|
118
129
|
enumerable: true,
|
|
119
130
|
get: () => routerCore.parsePathname
|
|
@@ -126,6 +137,10 @@ Object.defineProperty(exports, "pick", {
|
|
|
126
137
|
enumerable: true,
|
|
127
138
|
get: () => routerCore.pick
|
|
128
139
|
});
|
|
140
|
+
Object.defineProperty(exports, "redirect", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: () => routerCore.redirect
|
|
143
|
+
});
|
|
129
144
|
Object.defineProperty(exports, "removeBasepath", {
|
|
130
145
|
enumerable: true,
|
|
131
146
|
get: () => routerCore.removeBasepath
|
|
@@ -213,8 +228,6 @@ exports.Outlet = Match.Outlet;
|
|
|
213
228
|
exports.useMatch = useMatch.useMatch;
|
|
214
229
|
exports.useLoaderDeps = useLoaderDeps.useLoaderDeps;
|
|
215
230
|
exports.useLoaderData = useLoaderData.useLoaderData;
|
|
216
|
-
exports.isRedirect = redirects.isRedirect;
|
|
217
|
-
exports.redirect = redirects.redirect;
|
|
218
231
|
exports.NotFoundRoute = route.NotFoundRoute;
|
|
219
232
|
exports.RootRoute = route.RootRoute;
|
|
220
233
|
exports.Route = route.Route;
|
|
@@ -251,8 +264,6 @@ exports.useCanGoBack = useCanGoBack.useCanGoBack;
|
|
|
251
264
|
exports.useLayoutEffect = utils.useLayoutEffect;
|
|
252
265
|
exports.CatchNotFound = notFound.CatchNotFound;
|
|
253
266
|
exports.DefaultGlobalNotFound = notFound.DefaultGlobalNotFound;
|
|
254
|
-
exports.isNotFound = notFound.isNotFound;
|
|
255
|
-
exports.notFound = notFound.notFound;
|
|
256
267
|
exports.ScriptOnce = ScriptOnce.ScriptOnce;
|
|
257
268
|
exports.Asset = Asset.Asset;
|
|
258
269
|
exports.HeadContent = HeadContent.HeadContent;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -20,7 +20,7 @@ export { Match, Outlet } from './Match.cjs';
|
|
|
20
20
|
export { useMatch } from './useMatch.cjs';
|
|
21
21
|
export { useLoaderDeps } from './useLoaderDeps.cjs';
|
|
22
22
|
export { useLoaderData } from './useLoaderData.cjs';
|
|
23
|
-
export { redirect, isRedirect } from '
|
|
23
|
+
export { redirect, isRedirect } from '@tanstack/router-core';
|
|
24
24
|
export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.cjs';
|
|
25
25
|
export type { AnyRootRoute, SolidNode, SyncRouteComponent, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, } from './route.cjs';
|
|
26
26
|
export { componentTypes, createRouter, Router, lazyFn, SearchParamError, PathParamError, getInitialRouterState, } from './router.cjs';
|
|
@@ -39,8 +39,9 @@ export { useRouterState } from './useRouterState.cjs';
|
|
|
39
39
|
export { useLocation } from './useLocation.cjs';
|
|
40
40
|
export { useCanGoBack } from './useCanGoBack.cjs';
|
|
41
41
|
export { useLayoutEffect } from './utils.cjs';
|
|
42
|
-
export {
|
|
43
|
-
export
|
|
42
|
+
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.cjs';
|
|
43
|
+
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
44
|
+
export type { NotFoundError } from '@tanstack/router-core';
|
|
44
45
|
export * from './typePrimitives.cjs';
|
|
45
46
|
export { ScriptOnce } from './ScriptOnce.cjs';
|
|
46
47
|
export { Asset } from './Asset.cjs';
|
package/dist/cjs/not-found.cjs
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const web = require("solid-js/web");
|
|
4
|
+
const routerCore = require("@tanstack/router-core");
|
|
4
5
|
const CatchBoundary = require("./CatchBoundary.cjs");
|
|
5
6
|
const useRouterState = require("./useRouterState.cjs");
|
|
6
7
|
var _tmpl$ = /* @__PURE__ */ web.template(`<p>Not Found`);
|
|
7
|
-
function notFound(options = {}) {
|
|
8
|
-
options.isNotFound = true;
|
|
9
|
-
if (options.throw) throw options;
|
|
10
|
-
return options;
|
|
11
|
-
}
|
|
12
|
-
function isNotFound(obj) {
|
|
13
|
-
return !!(obj == null ? void 0 : obj.isNotFound);
|
|
14
|
-
}
|
|
15
8
|
function CatchNotFound(props) {
|
|
16
9
|
const resetKey = useRouterState.useRouterState({
|
|
17
10
|
select: (s) => `not-found-${s.location.pathname}-${s.status}`
|
|
@@ -20,7 +13,7 @@ function CatchNotFound(props) {
|
|
|
20
13
|
getResetKey: () => resetKey(),
|
|
21
14
|
onCatch: (error) => {
|
|
22
15
|
var _a;
|
|
23
|
-
if (isNotFound(error)) {
|
|
16
|
+
if (routerCore.isNotFound(error)) {
|
|
24
17
|
(_a = props.onCatch) == null ? void 0 : _a.call(props, error);
|
|
25
18
|
} else {
|
|
26
19
|
throw error;
|
|
@@ -30,7 +23,7 @@ function CatchNotFound(props) {
|
|
|
30
23
|
error
|
|
31
24
|
}) => {
|
|
32
25
|
var _a;
|
|
33
|
-
if (isNotFound(error)) {
|
|
26
|
+
if (routerCore.isNotFound(error)) {
|
|
34
27
|
return (_a = props.fallback) == null ? void 0 : _a.call(props, error);
|
|
35
28
|
} else {
|
|
36
29
|
throw error;
|
|
@@ -46,6 +39,4 @@ function DefaultGlobalNotFound() {
|
|
|
46
39
|
}
|
|
47
40
|
exports.CatchNotFound = CatchNotFound;
|
|
48
41
|
exports.DefaultGlobalNotFound = DefaultGlobalNotFound;
|
|
49
|
-
exports.isNotFound = isNotFound;
|
|
50
|
-
exports.notFound = notFound;
|
|
51
42
|
//# sourceMappingURL=not-found.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type * as Solid from 'solid-js'\nimport type {
|
|
1
|
+
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.tsx"],"sourcesContent":["import { isNotFound } from '@tanstack/router-core'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type * as Solid from 'solid-js'\nimport type { NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Solid.JSX.Element\n onCatch?: (error: Error) => void\n children: Solid.JSX.Element\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n return (\n <CatchBoundary\n getResetKey={() => resetKey()}\n onCatch={(error) => {\n if (isNotFound(error)) {\n props.onCatch?.(error)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }: { error: Error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"names":["CatchNotFound","props","resetKey","useRouterState","select","s","location","pathname","status","_$createComponent","CatchBoundary","getResetKey","onCatch","error","isNotFound","errorComponent","fallback","children","DefaultGlobalNotFound","_tmpl$"],"mappings":";;;;;;;AAMO,SAASA,cAAcC,OAI3B;AAED,QAAMC,WAAWC,eAAAA,eAAe;AAAA,IAC9BC,QAASC,OAAM,aAAaA,EAAEC,SAASC,QAAQ,IAAIF,EAAEG,MAAM;AAAA,EAAA,CAC5D;AAED,SAAAC,IAAAA,gBACGC,cAAAA,eAAa;AAAA,IACZC,aAAaA,MAAMT,SAAS;AAAA,IAC5BU,SAAUC,CAAU,UAAA;;AACdC,UAAAA,WAAAA,WAAWD,KAAK,GAAG;AACrBZ,oBAAMW,YAANX,+BAAgBY;AAAAA,MAAK,OAChB;AACCA,cAAAA;AAAAA,MAAAA;AAAAA,IAEV;AAAA,IACAE,gBAAgBA,CAAC;AAAA,MAAEF;AAAAA,IAAAA,MAA8B;;AAC3CC,UAAAA,WAAAA,WAAWD,KAAK,GAAG;AACdZ,gBAAAA,WAAMe,aAANf,+BAAiBY;AAAAA,MAAK,OACxB;AACCA,cAAAA;AAAAA,MAAAA;AAAAA,IAEV;AAAA,IAAC,IAAAI,WAAA;AAAA,aAEAhB,MAAMgB;AAAAA,IAAAA;AAAAA,EAAQ,CAAA;AAGrB;AAEO,SAASC,wBAAwB;AACtC,SAAAC,OAAA;AACF;;;"}
|
package/dist/cjs/not-found.d.cts
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NotFoundError } from '@tanstack/router-core';
|
|
2
2
|
import type * as Solid from 'solid-js';
|
|
3
|
-
export type NotFoundError = {
|
|
4
|
-
/**
|
|
5
|
-
@deprecated
|
|
6
|
-
Use `routeId: rootRouteId` instead
|
|
7
|
-
*/
|
|
8
|
-
global?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
@private
|
|
11
|
-
Do not use this. It's used internally to indicate a path matching error
|
|
12
|
-
*/
|
|
13
|
-
_global?: boolean;
|
|
14
|
-
data?: any;
|
|
15
|
-
throw?: boolean;
|
|
16
|
-
routeId?: RouteIds<RegisteredRouter['routeTree']>;
|
|
17
|
-
headers?: HeadersInit;
|
|
18
|
-
};
|
|
19
|
-
export declare function notFound(options?: NotFoundError): NotFoundError;
|
|
20
|
-
export declare function isNotFound(obj: any): obj is NotFoundError;
|
|
21
3
|
export declare function CatchNotFound(props: {
|
|
22
4
|
fallback?: (error: NotFoundError) => Solid.JSX.Element;
|
|
23
5
|
onCatch?: (error: Error) => void;
|
package/dist/cjs/route.cjs
CHANGED
|
@@ -6,7 +6,6 @@ const useLoaderData = require("./useLoaderData.cjs");
|
|
|
6
6
|
const useLoaderDeps = require("./useLoaderDeps.cjs");
|
|
7
7
|
const useParams = require("./useParams.cjs");
|
|
8
8
|
const useSearch = require("./useSearch.cjs");
|
|
9
|
-
const notFound = require("./not-found.cjs");
|
|
10
9
|
const useNavigate = require("./useNavigate.cjs");
|
|
11
10
|
const useMatch = require("./useMatch.cjs");
|
|
12
11
|
const useRouter = require("./useRouter.cjs");
|
|
@@ -53,7 +52,7 @@ class RouteApi {
|
|
|
53
52
|
return useNavigate.useNavigate({ from: router.routesById[this.id].fullPath });
|
|
54
53
|
};
|
|
55
54
|
this.notFound = (opts) => {
|
|
56
|
-
return
|
|
55
|
+
return routerCore.notFound({ routeId: this.id, ...opts });
|
|
57
56
|
};
|
|
58
57
|
this.id = id;
|
|
59
58
|
}
|
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 { joinPaths, rootRouteId, trimPathLeft } from '@tanstack/router-core'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport { useRouter } from './useRouter'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n LazyRoute as CoreLazyRoute,\n Route as CoreRoute,\n ErrorComponentProps,\n NotFoundRouteProps,\n RegisteredRouter,\n ResolveFullPath,\n ResolveId,\n ResolveParams,\n RootRouteId,\n RootRouteOptions,\n RouteAddChildrenFn,\n RouteAddFileChildrenFn,\n RouteAddFileTypesFn,\n RouteConstraints,\n RouteIds,\n RouteLazyFn,\n RouteLoaderFn,\n RouteMask,\n RouteOptions,\n RoutePathOptionsIntersection,\n RouteTypes,\n RouteTypesById,\n Router,\n ToMaskOptions,\n TrimPathRight,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseSearchRoute } from './useSearch'\nimport type * as Solid from 'solid-js'\nimport type { NotFoundError } from './not-found'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\ndeclare module '@tanstack/router-core' {\n export interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n }\n\n export interface RouteExtensions<\n TId extends string,\n TFullPath extends string,\n > {\n useMatch: UseMatchRoute<TId>\n useRouteContext: UseRouteContextRoute<TId>\n useSearch: UseSearchRoute<TId>\n useParams: UseParamsRoute<TId>\n useLoaderDeps: UseLoaderDepsRoute<TId>\n useLoaderData: UseLoaderDataRoute<TId>\n useNavigate: () => UseNavigateResult<TFullPath>\n }\n}\n\nexport function getRouteApi<\n const TId,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return new RouteApi<TId, TRouter>({ id })\n}\n\nexport class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {\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: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts) => {\n return useMatch({\n from: this.id as any,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<\n RouteTypesById<TRouter, TId>['fullPath']\n > => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.id as string].fullPath })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\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 TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> implements\n CoreRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n{\n isRoot: TParentRoute extends AnyRoute ? true : false\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n\n // The following properties are set up in this.init()\n parentRoute!: TParentRoute\n private _id!: TId\n private _path!: TPath\n private _fullPath!: TFullPath\n private _to!: TrimPathRight<TFullPath>\n private _ssr!: boolean\n\n public get to() {\n /* invariant(\n this._to,\n `trying to access property 'to' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._to\n }\n\n public get id() {\n /* invariant(\n this._id,\n `trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._id\n }\n\n public get path() {\n /* invariant(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.isRoot || this._id || this._path,\n `trying to access property 'path' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._path\n }\n\n public get fullPath() {\n /* invariant(\n this._fullPath,\n `trying to access property 'fullPath' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._fullPath\n }\n\n public get ssr() {\n return this._ssr\n }\n\n // Optional\n children?: TChildren\n originalIndex?: number\n rank!: number\n lazyFn?: () => Promise<CoreLazyRoute>\n _lazyPromise?: Promise<void>\n _componentsPromise?: Promise<Array<void>>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\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 }\n\n types!: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n\n init = (opts: { originalIndex: number; defaultSsr?: boolean }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\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 this._ssr = options?.ssr ?? opts.defaultSsr ?? true\n }\n\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n return this._addFileChildren(children) as any\n }\n\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n if (Array.isArray(children)) {\n this.children = children as TChildren\n }\n\n if (typeof children === 'object' && children !== null) {\n this.children = Object.values(children) as TChildren\n }\n\n return this as any\n }\n\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n > = () => {\n return this as any\n }\n\n updateLoader = <TNewLoaderFn>(options: {\n loader: Constrain<\n TNewLoaderFn,\n RouteLoaderFn<\n TParentRoute,\n TCustomId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\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 TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TNewLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy: RouteLazyFn<this> = (lazyFn) => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts?) => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.fullPath })\n }\n}\n\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 TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n): CoreRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\n> {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n >(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) => {\n return createRootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\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 TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren, // TChildren\n TFileRouteTypes\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options as any)\n }\n}\n\nexport function createRootRoute<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n>(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n) {\n return new RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options)\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<Router<TRouteTree, 'never', false>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport type SolidNode = Solid.JSX.Element\n\nexport type SyncRouteComponent<TProps> = (props: TProps) => Solid.JSX.Element\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 TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\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","useRouter","useNavigate","notFound","options","rootRouteId","trimPathLeft","joinPaths"],"mappings":";;;;;;;;;;;;AA2EO,SAAS,YAGd,IAA2D;AAC3D,SAAO,IAAI,SAAuB,EAAE,IAAI;AAC1C;AAEO,MAAM,SAA4D;AAAA;AAAA;AAAA;AAAA,EAMvE,YAAY,EAAE,MAAmB;AAIjC,SAAA,WAA+B,CAAC,SAAS;AACvC,aAAOA,kBAAS;AAAA,QACd,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,kBAA6C,CAAC,SAAS;AACrD,aAAOA,kBAAS;AAAA,QACd,MAAM,KAAK;AAAA,QACX,QAAQ,CAAC,OAAO,6BAAM,UAAS,KAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAC3D;AAAA,IACH;AAEA,SAAA,YAAiC,CAAC,SAAS;AACzC,aAAOC,oBAAU;AAAA,QACf,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,YAAiC,CAAC,SAAS;AACzC,aAAOC,oBAAU;AAAA,QACf,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,gBAAyC,CAAC,SAAS;AAC1C,aAAAC,cAAA,cAAc,EAAE,GAAG,MAAM,MAAM,KAA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BAQd,SAQA;AACO,SAAA,IAAI,UAOT,OAAO;AACX;AAEO,SAAS,gBAKd,MAGuB;AAChB,SAAA;AACT;AAgBO,MAAM,sBASH,MAcR;AAAA,EACA,YACE,SAsBA;AACM,UAAA;AAAA,MACJ,GAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EAAA;AAEL;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"route.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport {\n joinPaths,\n notFound,\n rootRouteId,\n trimPathLeft,\n} from '@tanstack/router-core'\nimport { useLoaderData } from './useLoaderData'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { useNavigate } from './useNavigate'\nimport { useMatch } from './useMatch'\nimport { useRouter } from './useRouter'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n LazyRoute as CoreLazyRoute,\n Route as CoreRoute,\n ErrorComponentProps,\n NotFoundError,\n NotFoundRouteProps,\n RegisteredRouter,\n ResolveFullPath,\n ResolveId,\n ResolveParams,\n RootRouteId,\n RootRouteOptions,\n RouteAddChildrenFn,\n RouteAddFileChildrenFn,\n RouteAddFileTypesFn,\n RouteConstraints,\n RouteIds,\n RouteLazyFn,\n RouteLoaderFn,\n RouteMask,\n RouteOptions,\n RoutePathOptionsIntersection,\n RouteTypes,\n RouteTypesById,\n Router,\n ToMaskOptions,\n TrimPathRight,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseSearchRoute } from './useSearch'\nimport type * as Solid from 'solid-js'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\ndeclare module '@tanstack/router-core' {\n export interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n }\n\n export interface RouteExtensions<\n TId extends string,\n TFullPath extends string,\n > {\n useMatch: UseMatchRoute<TId>\n useRouteContext: UseRouteContextRoute<TId>\n useSearch: UseSearchRoute<TId>\n useParams: UseParamsRoute<TId>\n useLoaderDeps: UseLoaderDepsRoute<TId>\n useLoaderData: UseLoaderDataRoute<TId>\n useNavigate: () => UseNavigateResult<TFullPath>\n }\n}\n\nexport function getRouteApi<\n const TId,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return new RouteApi<TId, TRouter>({ id })\n}\n\nexport class RouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {\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: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts) => {\n return useMatch({\n from: this.id as any,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<\n RouteTypesById<TRouter, TId>['fullPath']\n > => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.id as string].fullPath })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\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 TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> implements\n CoreRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n{\n isRoot: TParentRoute extends AnyRoute ? true : false\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n\n // The following properties are set up in this.init()\n parentRoute!: TParentRoute\n private _id!: TId\n private _path!: TPath\n private _fullPath!: TFullPath\n private _to!: TrimPathRight<TFullPath>\n private _ssr!: boolean\n\n public get to() {\n /* invariant(\n this._to,\n `trying to access property 'to' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._to\n }\n\n public get id() {\n /* invariant(\n this._id,\n `trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._id\n }\n\n public get path() {\n /* invariant(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.isRoot || this._id || this._path,\n `trying to access property 'path' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._path\n }\n\n public get fullPath() {\n /* invariant(\n this._fullPath,\n `trying to access property 'fullPath' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._fullPath\n }\n\n public get ssr() {\n return this._ssr\n }\n\n // Optional\n children?: TChildren\n originalIndex?: number\n rank!: number\n lazyFn?: () => Promise<CoreLazyRoute>\n _lazyPromise?: Promise<void>\n _componentsPromise?: Promise<Array<void>>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\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 }\n\n types!: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n\n init = (opts: { originalIndex: number; defaultSsr?: boolean }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\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 this._ssr = options?.ssr ?? opts.defaultSsr ?? true\n }\n\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n return this._addFileChildren(children) as any\n }\n\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n if (Array.isArray(children)) {\n this.children = children as TChildren\n }\n\n if (typeof children === 'object' && children !== null) {\n this.children = Object.values(children) as TChildren\n }\n\n return this as any\n }\n\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n > = () => {\n return this as any\n }\n\n updateLoader = <TNewLoaderFn>(options: {\n loader: Constrain<\n TNewLoaderFn,\n RouteLoaderFn<\n TParentRoute,\n TCustomId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\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 TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TNewLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy: RouteLazyFn<this> = (lazyFn) => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch: UseMatchRoute<TId> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TId> = (opts?) => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TId> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TId> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TId> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TId> = (opts) => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.fullPath })\n }\n}\n\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 TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n): CoreRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown\n> {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n >(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) => {\n return createRootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\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 TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren, // TChildren\n TFileRouteTypes\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options as any)\n }\n}\n\nexport function createRootRoute<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n>(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n) {\n return new RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options)\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<Router<TRouteTree, 'never', false>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport type SolidNode = Solid.JSX.Element\n\nexport type SyncRouteComponent<TProps> = (props: TProps) => Solid.JSX.Element\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 TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\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","useRouter","useNavigate","notFound","options","rootRouteId","trimPathLeft","joinPaths"],"mappings":";;;;;;;;;;;AA+EO,SAAS,YAGd,IAA2D;AAC3D,SAAO,IAAI,SAAuB,EAAE,IAAI;AAC1C;AAEO,MAAM,SAA4D;AAAA;AAAA;AAAA;AAAA,EAMvE,YAAY,EAAE,MAAmB;AAIjC,SAAA,WAA+B,CAAC,SAAS;AACvC,aAAOA,kBAAS;AAAA,QACd,QAAQ,6BAAM;AAAA,QACd,MAAM,KAAK;AAAA,MAAA,CACL;AAAA,IACV;AAEA,SAAA,kBAA6C,CAAC,SAAS;AACrD,aAAOA,kBAAS;AAAA,QACd,MAAM,KAAK;AAAA,QACX,QAAQ,CAAC,OAAO,6BAAM,UAAS,KAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAC3D;AAAA,IACH;AAEA,SAAA,YAAiC,CAAC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AACf,WAAO,KAAK;AAAA,EAAA;AA4RhB;AAEO,SAAS,YAqBd,SA6BA;AACO,SAAA,IAAI,MAcT,OAAO;AACX;AAIO,SAAS,6BAAwD;AACtE,SAAO,CAOL,YAQG;AACH,WAAO,gBAOL,OAAc;AAAA,EAClB;AACF;AAKO,MAAM,uBAAuB;AAE7B,MAAM,kBASH,MAeR;AAAA;AAAA;AAAA;AAAA,EAIA,YACE,SAQA;AACA,UAAM,OAAc;AAAA,EAAA;AAExB;AAEO,SAAS,gBAQd,SAQA;AACO,SAAA,IAAI,UAOT,OAAO;AACX;AAEO,SAAS,gBAKd,MAGuB;AAChB,SAAA;AACT;AAgBO,MAAM,sBASH,MAcR;AAAA,EACA,YACE,SAsBA;AACM,UAAA;AAAA,MACJ,GAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EAAA;AAEL;;;;;;;;;;;"}
|
package/dist/cjs/route.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { AnyContext, AnyRoute, AnyRouter, Constrain, ConstrainLiteral, LazyRoute as CoreLazyRoute, Route as CoreRoute, ErrorComponentProps, NotFoundRouteProps, RegisteredRouter, ResolveFullPath, ResolveId, ResolveParams, RootRouteId, RootRouteOptions, RouteAddChildrenFn, RouteAddFileChildrenFn, RouteAddFileTypesFn, RouteConstraints, RouteIds, RouteLazyFn, RouteLoaderFn, RouteMask, RouteOptions, RouteTypes, RouteTypesById, Router, ToMaskOptions, TrimPathRight, UpdatableRouteOptions, UseNavigateResult } from '@tanstack/router-core';
|
|
1
|
+
import { AnyContext, AnyRoute, AnyRouter, Constrain, ConstrainLiteral, LazyRoute as CoreLazyRoute, Route as CoreRoute, ErrorComponentProps, NotFoundError, NotFoundRouteProps, RegisteredRouter, ResolveFullPath, ResolveId, ResolveParams, RootRouteId, RootRouteOptions, RouteAddChildrenFn, RouteAddFileChildrenFn, RouteAddFileTypesFn, RouteConstraints, RouteIds, RouteLazyFn, RouteLoaderFn, RouteMask, RouteOptions, RouteTypes, RouteTypesById, Router, ToMaskOptions, TrimPathRight, UpdatableRouteOptions, UseNavigateResult } from '@tanstack/router-core';
|
|
2
2
|
import { UseLoaderDataRoute } from './useLoaderData.cjs';
|
|
3
3
|
import { UseMatchRoute } from './useMatch.cjs';
|
|
4
4
|
import { UseLoaderDepsRoute } from './useLoaderDeps.cjs';
|
|
5
5
|
import { UseParamsRoute } from './useParams.cjs';
|
|
6
6
|
import { UseSearchRoute } from './useSearch.cjs';
|
|
7
|
-
import { NotFoundError } from './not-found.cjs';
|
|
8
7
|
import { UseRouteContextRoute } from './useRouteContext.cjs';
|
|
9
8
|
import type * as Solid from 'solid-js';
|
|
10
9
|
declare module '@tanstack/router-core' {
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -4,8 +4,6 @@ const history = require("@tanstack/history");
|
|
|
4
4
|
const solidStore = require("@tanstack/solid-store");
|
|
5
5
|
const invariant = require("tiny-invariant");
|
|
6
6
|
const routerCore = require("@tanstack/router-core");
|
|
7
|
-
const redirects = require("./redirects.cjs");
|
|
8
|
-
const notFound = require("./not-found.cjs");
|
|
9
7
|
const scrollRestoration = require("./scroll-restoration.cjs");
|
|
10
8
|
const componentTypes = [
|
|
11
9
|
"component",
|
|
@@ -647,7 +645,7 @@ class Router {
|
|
|
647
645
|
this.load = async (opts) => {
|
|
648
646
|
this.latestLocation = this.parseLocation(this.latestLocation);
|
|
649
647
|
let redirect;
|
|
650
|
-
let notFound
|
|
648
|
+
let notFound;
|
|
651
649
|
let loadPromise;
|
|
652
650
|
loadPromise = new Promise((resolve) => {
|
|
653
651
|
this.startTransition(async () => {
|
|
@@ -738,7 +736,7 @@ class Router {
|
|
|
738
736
|
}
|
|
739
737
|
});
|
|
740
738
|
} catch (err) {
|
|
741
|
-
if (
|
|
739
|
+
if (routerCore.isResolvedRedirect(err)) {
|
|
742
740
|
redirect = err;
|
|
743
741
|
if (!this.isServer) {
|
|
744
742
|
this.navigate({
|
|
@@ -747,12 +745,12 @@ class Router {
|
|
|
747
745
|
ignoreBlocker: true
|
|
748
746
|
});
|
|
749
747
|
}
|
|
750
|
-
} else if (
|
|
751
|
-
notFound
|
|
748
|
+
} else if (routerCore.isNotFound(err)) {
|
|
749
|
+
notFound = err;
|
|
752
750
|
}
|
|
753
751
|
this.__store.setState((s) => ({
|
|
754
752
|
...s,
|
|
755
|
-
statusCode: redirect ? redirect.statusCode : notFound
|
|
753
|
+
statusCode: redirect ? redirect.statusCode : notFound ? 404 : s.matches.some((d) => d.status === "error") ? 500 : 200,
|
|
756
754
|
redirect
|
|
757
755
|
}));
|
|
758
756
|
}
|
|
@@ -845,15 +843,15 @@ class Router {
|
|
|
845
843
|
}
|
|
846
844
|
const handleRedirectAndNotFound = (match, err) => {
|
|
847
845
|
var _a, _b, _c, _d;
|
|
848
|
-
if (
|
|
846
|
+
if (routerCore.isResolvedRedirect(err)) {
|
|
849
847
|
if (!err.reloadDocument) {
|
|
850
848
|
throw err;
|
|
851
849
|
}
|
|
852
850
|
}
|
|
853
|
-
if (
|
|
851
|
+
if (routerCore.isRedirect(err) || routerCore.isNotFound(err)) {
|
|
854
852
|
updateMatch(match.id, (prev) => ({
|
|
855
853
|
...prev,
|
|
856
|
-
status:
|
|
854
|
+
status: routerCore.isRedirect(err) ? "redirected" : routerCore.isNotFound(err) ? "notFound" : "error",
|
|
857
855
|
isFetching: false,
|
|
858
856
|
error: err,
|
|
859
857
|
beforeLoadPromise: void 0,
|
|
@@ -865,11 +863,11 @@ class Router {
|
|
|
865
863
|
(_a = match.beforeLoadPromise) == null ? void 0 : _a.resolve();
|
|
866
864
|
(_b = match.loaderPromise) == null ? void 0 : _b.resolve();
|
|
867
865
|
(_c = match.loadPromise) == null ? void 0 : _c.resolve();
|
|
868
|
-
if (
|
|
866
|
+
if (routerCore.isRedirect(err)) {
|
|
869
867
|
rendered = true;
|
|
870
868
|
err = this.resolveRedirect({ ...err, _fromLocation: location });
|
|
871
869
|
throw err;
|
|
872
|
-
} else if (
|
|
870
|
+
} else if (routerCore.isNotFound(err)) {
|
|
873
871
|
this._handleNotFound(matches, err, {
|
|
874
872
|
updateMatch
|
|
875
873
|
});
|
|
@@ -997,7 +995,7 @@ class Router {
|
|
|
997
995
|
matches
|
|
998
996
|
};
|
|
999
997
|
const beforeLoadContext = await ((_c = (_b = route.options).beforeLoad) == null ? void 0 : _c.call(_b, beforeLoadFnContext)) ?? {};
|
|
1000
|
-
if (
|
|
998
|
+
if (routerCore.isRedirect(beforeLoadContext) || routerCore.isNotFound(beforeLoadContext)) {
|
|
1001
999
|
handleSerialError(index, beforeLoadContext, "BEFORE_LOAD");
|
|
1002
1000
|
}
|
|
1003
1001
|
updateMatch(matchId, (prev) => {
|
|
@@ -1173,7 +1171,7 @@ class Router {
|
|
|
1173
1171
|
loaderPromise: void 0
|
|
1174
1172
|
}));
|
|
1175
1173
|
} catch (err) {
|
|
1176
|
-
if (
|
|
1174
|
+
if (routerCore.isResolvedRedirect(err)) {
|
|
1177
1175
|
await this.navigate(err);
|
|
1178
1176
|
}
|
|
1179
1177
|
}
|
|
@@ -1206,8 +1204,8 @@ class Router {
|
|
|
1206
1204
|
});
|
|
1207
1205
|
await triggerOnReady();
|
|
1208
1206
|
} catch (err) {
|
|
1209
|
-
if (
|
|
1210
|
-
if (
|
|
1207
|
+
if (routerCore.isRedirect(err) || routerCore.isNotFound(err)) {
|
|
1208
|
+
if (routerCore.isNotFound(err) && !allPreload) {
|
|
1211
1209
|
await triggerOnReady();
|
|
1212
1210
|
}
|
|
1213
1211
|
throw err;
|
|
@@ -1342,7 +1340,7 @@ class Router {
|
|
|
1342
1340
|
});
|
|
1343
1341
|
return matches;
|
|
1344
1342
|
} catch (err) {
|
|
1345
|
-
if (
|
|
1343
|
+
if (routerCore.isRedirect(err)) {
|
|
1346
1344
|
if (err.reloadDocument) {
|
|
1347
1345
|
return void 0;
|
|
1348
1346
|
}
|
|
@@ -1351,7 +1349,7 @@ class Router {
|
|
|
1351
1349
|
_fromLocation: next
|
|
1352
1350
|
});
|
|
1353
1351
|
}
|
|
1354
|
-
if (!
|
|
1352
|
+
if (!routerCore.isNotFound(err)) {
|
|
1355
1353
|
console.error(err);
|
|
1356
1354
|
}
|
|
1357
1355
|
return void 0;
|