@tanstack/solid-router 1.168.1 → 1.168.2
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 +9 -7
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +2 -4
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs +4 -5
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +12 -8
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/headContentUtils.d.cts +2 -1
- package/dist/cjs/renderRouteNotFound.cjs +4 -4
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +4 -3
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useRouter.cjs +3 -3
- package/dist/cjs/useRouter.cjs.map +1 -1
- package/dist/esm/Match.js +10 -6
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +2 -3
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/fileRoute.js +4 -3
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.d.ts +2 -1
- package/dist/esm/headContentUtils.js +13 -9
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +3 -2
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/useMatch.js +5 -3
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useRouter.js +3 -2
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/source/Match.jsx +16 -6
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +2 -3
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/fileRoute.js +4 -3
- package/dist/source/fileRoute.js.map +1 -1
- package/dist/source/headContentUtils.d.ts +2 -1
- package/dist/source/headContentUtils.jsx +15 -9
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/renderRouteNotFound.jsx +4 -3
- package/dist/source/renderRouteNotFound.jsx.map +1 -1
- package/dist/source/useMatch.jsx +8 -4
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useRouter.jsx +5 -2
- package/dist/source/useRouter.jsx.map +1 -1
- package/package.json +2 -4
- package/src/Match.tsx +24 -14
- package/src/Matches.tsx +3 -5
- package/src/fileRoute.ts +7 -8
- package/src/headContentUtils.tsx +8 -3
- package/src/renderRouteNotFound.tsx +6 -6
- package/src/useMatch.tsx +14 -10
- package/src/useRouter.tsx +7 -5
package/dist/esm/Match.js
CHANGED
|
@@ -5,12 +5,10 @@ import { SafeFragment } from "./SafeFragment.js";
|
|
|
5
5
|
import { CatchNotFound } from "./not-found.js";
|
|
6
6
|
import { renderRouteNotFound } from "./renderRouteNotFound.js";
|
|
7
7
|
import { ScrollRestoration } from "./scroll-restoration.js";
|
|
8
|
-
import { createControlledPromise, getLocationChangeInfo, isNotFound, isRedirect, rootRouteId } from "@tanstack/router-core";
|
|
8
|
+
import { createControlledPromise, getLocationChangeInfo, invariant, isNotFound, isRedirect, rootRouteId } from "@tanstack/router-core";
|
|
9
9
|
import { Dynamic, createComponent, memo, mergeProps } from "solid-js/web";
|
|
10
10
|
import * as Solid from "solid-js";
|
|
11
|
-
import warning from "tiny-warning";
|
|
12
11
|
import { isServer } from "@tanstack/router-core/isServer";
|
|
13
|
-
import invariant from "tiny-invariant";
|
|
14
12
|
//#region src/Match.tsx
|
|
15
13
|
var Match = (props) => {
|
|
16
14
|
const router = useRouter();
|
|
@@ -79,7 +77,7 @@ var Match = (props) => {
|
|
|
79
77
|
},
|
|
80
78
|
onCatch: (error) => {
|
|
81
79
|
if (isNotFound(error)) throw error;
|
|
82
|
-
|
|
80
|
+
if (process.env.NODE_ENV !== "production") console.warn(`Warning: Error in route match: ${currentMatchState().routeId}`);
|
|
83
81
|
routeOnCatch()?.(error);
|
|
84
82
|
},
|
|
85
83
|
get children() {
|
|
@@ -239,7 +237,10 @@ var MatchInner = () => {
|
|
|
239
237
|
return currentMatch().status === "notFound";
|
|
240
238
|
},
|
|
241
239
|
children: (_) => {
|
|
242
|
-
|
|
240
|
+
if (!isNotFound(currentMatch().error)) {
|
|
241
|
+
if (process.env.NODE_ENV !== "production") throw new Error("Invariant failed: Expected a notFound error");
|
|
242
|
+
invariant();
|
|
243
|
+
}
|
|
243
244
|
return createComponent(Solid.Show, {
|
|
244
245
|
get when() {
|
|
245
246
|
return currentMatchState().routeId;
|
|
@@ -254,7 +255,10 @@ var MatchInner = () => {
|
|
|
254
255
|
return currentMatch().status === "redirected";
|
|
255
256
|
},
|
|
256
257
|
children: (_) => {
|
|
257
|
-
|
|
258
|
+
if (!isRedirect(currentMatch().error)) {
|
|
259
|
+
if (process.env.NODE_ENV !== "production") throw new Error("Invariant failed: Expected a redirect error");
|
|
260
|
+
invariant();
|
|
261
|
+
}
|
|
258
262
|
const [loaderResult] = Solid.createResource(async () => {
|
|
259
263
|
await new Promise((r) => setTimeout(r, 0));
|
|
260
264
|
return router.getMatch(currentMatch().id)?._nonReactive.loadPromise;
|
package/dist/esm/Match.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.js","names":["Solid","invariant","warning","createControlledPromise","getLocationChangeInfo","isNotFound","isRedirect","rootRouteId","isServer","Dynamic","CatchBoundary","ErrorComponent","useRouter","CatchNotFound","nearestMatchContext","SafeFragment","renderRouteNotFound","ScrollRestoration","AnyRoute","RootRouteOptions","Match","props","matchId","router","match","createMemo","id","undefined","stores","activeMatchStoresById","get","state","rawMatchState","currentMatch","routeId","parentRouteId","routesById","parentRoute","ssr","_displayPending","hasPendingMatch","currentRouteId","Boolean","pendingRouteIds","nearestMatch","hasPending","_$createComponent","Show","when","children","currentMatchState","route","resolvePendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","resolvedNoSsr","ResolvedSuspenseBoundary","Suspense","ResolvedCatchBoundary","ResolvedNotFoundBoundary","ShellComponent","shellComponent","Provider","value","fallback","_$memo","getResetKey","loadedAt","error","Error","_$mergeProps","Switch","MatchInner","OnRendered","location","resolvedLocation","__TSR_key","createEffect","on","emit","type","useContext","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","key","JSON","stringify","status","_forcePending","componentKey","out","Comp","defaultComponent","Outlet","keyedOut","keyed","_key","_","displayPendingResult","createResource","getMatch","_nonReactive","displayPendingPromise","minPendingResult","minPendingPromise","pendingMinMs","defaultPendingMinMs","routerMatch","setTimeout","resolve","loaderResult","Promise","r","loadPromise","FallbackComponent","_routeId","RouteErrorComponent","info","componentStack","nearestParentMatch","parentMatch","parentGlobalNotFound","globalNotFound","childMatchId","childMatchIdByRouteId","childMatchStatus","shouldShowNotFound","resolvedRoute","childMatchIdAccessor","currentMatchId"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from 'solid-js/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nexport const Match = (props: { matchId: string }) => {\n const router = useRouter()\n\n const match = Solid.createMemo(() => {\n const id = props.matchId\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state\n })\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n const parentRouteId = (router.routesById[routeId] as AnyRoute)?.parentRoute\n ?.id\n\n return {\n matchId: currentMatch.id,\n routeId,\n ssr: currentMatch.ssr,\n _displayPending: currentMatch._displayPending,\n parentRouteId: parentRouteId as string | undefined,\n }\n })\n\n const hasPendingMatch = Solid.createMemo(() => {\n const currentRouteId = rawMatchState()?.routeId\n return currentRouteId\n ? Boolean(router.stores.pendingRouteIds.state[currentRouteId])\n : false\n })\n const nearestMatch = {\n matchId: () => rawMatchState()?.matchId,\n routeId: () => rawMatchState()?.routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route: () => AnyRoute = () =>\n router.routesById[currentMatchState().routeId]\n\n const resolvePendingComponent = () =>\n route().options.pendingComponent ??\n 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 resolvedNoSsr =\n currentMatchState().ssr === false ||\n currentMatchState().ssr === 'data-only'\n\n const ResolvedSuspenseBoundary = () => Solid.Suspense\n\n const ResolvedCatchBoundary = () =>\n routeErrorComponent() ? CatchBoundary : SafeFragment\n\n const ResolvedNotFoundBoundary = () =>\n routeNotFoundComponent() ? CatchNotFound : SafeFragment\n\n const ShellComponent = route().isRoot\n ? ((route().options as RootRouteOptions).shellComponent ??\n SafeFragment)\n : SafeFragment\n\n return (\n <ShellComponent>\n <nearestMatchContext.Provider value={nearestMatch}>\n <Dynamic\n component={ResolvedSuspenseBoundary()}\n fallback={\n // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch\n (isServer ?? router.isServer) && resolvedNoSsr ? undefined : (\n <Dynamic component={resolvePendingComponent()} />\n )\n }\n >\n <Dynamic\n component={ResolvedCatchBoundary()}\n getResetKey={() => router.stores.loadedAt.state}\n errorComponent={routeErrorComponent() || ErrorComponent}\n onCatch={(error: Error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(\n false,\n `Error in route match: ${currentMatchState().routeId}`,\n )\n routeOnCatch()?.(error)\n }}\n >\n <Dynamic\n component={ResolvedNotFoundBoundary()}\n fallback={(error: any) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent() ||\n (error.routeId &&\n error.routeId !== currentMatchState().routeId) ||\n (!error.routeId && !route().isRoot)\n )\n throw error\n\n return (\n <Dynamic\n component={routeNotFoundComponent()}\n {...error}\n />\n )\n }}\n >\n <Solid.Switch>\n <Solid.Match when={resolvedNoSsr}>\n <Solid.Show\n when={!(isServer ?? router.isServer)}\n fallback={\n <Dynamic component={resolvePendingComponent()} />\n }\n >\n <MatchInner />\n </Solid.Show>\n </Solid.Match>\n <Solid.Match when={!resolvedNoSsr}>\n <MatchInner />\n </Solid.Match>\n </Solid.Switch>\n </Dynamic>\n </Dynamic>\n </Dynamic>\n </nearestMatchContext.Provider>\n\n {currentMatchState().parentRouteId === rootRouteId ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </ShellComponent>\n )\n }}\n </Solid.Show>\n )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\nfunction OnRendered() {\n const router = useRouter()\n\n const location = Solid.createMemo(\n () => router.stores.resolvedLocation.state?.state.__TSR_key,\n )\n Solid.createEffect(\n Solid.on([location], () => {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(\n router.stores.location.state,\n router.stores.resolvedLocation.state,\n ),\n })\n }),\n )\n return null\n}\n\nexport const MatchInner = (): any => {\n const router = useRouter()\n const match = Solid.useContext(nearestMatchContext).match\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: currentMatch.loaderDeps,\n params: currentMatch._strictParams,\n search: currentMatch._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: currentMatch.id,\n status: currentMatch.status,\n error: currentMatch.error,\n _forcePending: currentMatch._forcePending ?? false,\n _displayPending: currentMatch._displayPending ?? false,\n },\n }\n })\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route = () => router.routesById[currentMatchState().routeId]!\n\n const currentMatch = () => currentMatchState().match\n\n const componentKey = () =>\n currentMatchState().key ?? currentMatchState().match.id\n\n const out = () => {\n const Comp =\n route().options.component ?? router.options.defaultComponent\n if (Comp) {\n return <Comp />\n }\n return <Outlet />\n }\n\n const keyedOut = () => (\n <Solid.Show when={componentKey()} keyed>\n {(_key) => out()}\n </Solid.Show>\n )\n\n return (\n <Solid.Switch>\n <Solid.Match when={currentMatch()._displayPending}>\n {(_) => {\n const [displayPendingResult] = Solid.createResource(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .displayPendingPromise,\n )\n\n return <>{displayPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch()._forcePending}>\n {(_) => {\n const [minPendingResult] = Solid.createResource(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .minPendingPromise,\n )\n\n return <>{minPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'pending'}>\n {(_) => {\n const pendingMinMs =\n route().options.pendingMinMs ??\n router.options.defaultPendingMinMs\n\n if (pendingMinMs) {\n const routerMatch = router.getMatch(currentMatch().id)\n if (\n routerMatch &&\n !routerMatch._nonReactive.minPendingPromise\n ) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise =\n minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n }\n\n const [loaderResult] = Solid.createResource(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(currentMatch().id)?._nonReactive\n .loadPromise\n })\n\n const FallbackComponent =\n route().options.pendingComponent ??\n router.options.defaultPendingComponent\n\n return (\n <>\n {FallbackComponent && pendingMinMs > 0 ? (\n <Dynamic component={FallbackComponent} />\n ) : null}\n {loaderResult()}\n </>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'notFound'}>\n {(_) => {\n invariant(\n isNotFound(currentMatch().error),\n 'Expected a notFound error',\n )\n\n // Use Show with keyed to ensure re-render when routeId changes\n return (\n <Solid.Show when={currentMatchState().routeId} keyed>\n {(_routeId) =>\n renderRouteNotFound(router, route(), currentMatch().error)\n }\n </Solid.Show>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'redirected'}>\n {(_) => {\n invariant(\n isRedirect(currentMatch().error),\n 'Expected a redirect error',\n )\n\n const [loaderResult] = Solid.createResource(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(currentMatch().id)?._nonReactive\n .loadPromise\n })\n\n return <>{loaderResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'error'}>\n {(_) => {\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route().options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n\n return (\n <RouteErrorComponent\n error={currentMatch().error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw currentMatch().error\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'success'}>\n {keyedOut()}\n </Solid.Match>\n </Solid.Switch>\n )\n }}\n </Solid.Show>\n )\n}\n\nexport const Outlet = () => {\n const router = useRouter()\n const nearestParentMatch = Solid.useContext(nearestMatchContext)\n const parentMatch = nearestParentMatch.match\n const routeId = nearestParentMatch.routeId\n const route = Solid.createMemo(() =>\n routeId() ? router.routesById[routeId()!] : undefined,\n )\n\n const parentGlobalNotFound = Solid.createMemo(\n () => parentMatch()?.globalNotFound ?? false,\n )\n\n const childMatchId = Solid.createMemo(() => {\n const currentRouteId = routeId()\n return currentRouteId\n ? router.stores.childMatchIdByRouteId.state[currentRouteId]\n : undefined\n })\n\n const childMatchStatus = Solid.createMemo(() => {\n const id = childMatchId()\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state.status\n })\n\n // Only show not-found if we're not in a redirected state\n const shouldShowNotFound = () =>\n childMatchStatus() !== 'redirected' && parentGlobalNotFound()\n\n return (\n <Solid.Show\n when={!shouldShowNotFound() && childMatchId()}\n fallback={\n <Solid.Show when={shouldShowNotFound() && route()}>\n {(resolvedRoute) =>\n renderRouteNotFound(router, resolvedRoute(), undefined)\n }\n </Solid.Show>\n }\n >\n {(childMatchIdAccessor) => {\n const currentMatchId = Solid.createMemo(() => childMatchIdAccessor())\n\n return (\n <Solid.Show\n when={routeId() === rootRouteId}\n fallback={<Match matchId={currentMatchId()} />}\n >\n <Solid.Suspense\n fallback={\n <Dynamic component={router.options.defaultPendingComponent} />\n }\n >\n <Match matchId={currentMatchId()} />\n </Solid.Suspense>\n </Solid.Show>\n )\n }}\n </Solid.Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAaoB,SAASC,UAA+B;CACnD,MAAME,SAASX,WAAW;CAE1B,MAAMY,QAAQxB,MAAMyB,iBAAiB;EACnC,MAAMC,KAAKL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E,oBAAoB,CAAA,EAAA,IAAI7F,OAAO;;IAAAF,WAC7CgG,kBACAjI,oBAAoBO,QAAQ0H,eAAe,EAAEtH,KAAAA,EAAS;IAAC,CAAA;;EAAAsB,WAK3DiG,yBAAyB;GACzB,MAAMC,iBAAiBnJ,MAAMyB,iBAAiByH,sBAAsB,CAAC;AAErE,UAAApG,gBACG9C,MAAM+C,MAAI;IAAA,IACTC,OAAI;AAAA,YAAEd,SAAS,KAAK3B;;IAAW,IAC/BqE,WAAQ;AAAA,YAAA9B,gBAAG1B,OAAK,EAAA,IAACE,UAAO;AAAA,aAAE6H,gBAAgB;QAAA,CAAA;;IAAA,IAAAlG,WAAA;AAAA,YAAAH,gBAEzC9C,MAAMqE,UAAQ;MAAA,IACbO,WAAQ;AAAA,cAAA9B,gBACLrC,SAAO,EAAA,IAACyD,YAAS;AAAA,eAAE3C,OAAO8B,QAAQE;UAAuB,CAAA;;MAAA,IAAAN,WAAA;AAAA,cAAAH,gBAG3D1B,OAAK,EAAA,IAACE,UAAO;AAAA,eAAE6H,gBAAgB;UAAA,CAAA;;MAAA,CAAA;;IAAA,CAAA;;EAIvC,CAAA"}
|
|
1
|
+
{"version":3,"file":"Match.js","names":["Solid","createControlledPromise","getLocationChangeInfo","invariant","isNotFound","isRedirect","rootRouteId","isServer","Dynamic","CatchBoundary","ErrorComponent","useRouter","CatchNotFound","nearestMatchContext","SafeFragment","renderRouteNotFound","ScrollRestoration","AnyRoute","RootRouteOptions","Match","props","matchId","router","match","createMemo","id","undefined","stores","activeMatchStoresById","get","state","rawMatchState","currentMatch","routeId","parentRouteId","routesById","parentRoute","ssr","_displayPending","hasPendingMatch","currentRouteId","Boolean","pendingRouteIds","nearestMatch","hasPending","_$createComponent","Show","when","children","currentMatchState","route","resolvePendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","resolvedNoSsr","ResolvedSuspenseBoundary","Suspense","ResolvedCatchBoundary","ResolvedNotFoundBoundary","ShellComponent","shellComponent","Provider","value","fallback","_$memo","getResetKey","loadedAt","error","Error","process","env","NODE_ENV","console","warn","_$mergeProps","Switch","MatchInner","OnRendered","location","resolvedLocation","__TSR_key","createEffect","on","emit","type","useContext","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","key","JSON","stringify","status","_forcePending","componentKey","out","Comp","defaultComponent","Outlet","keyedOut","keyed","_key","_","displayPendingResult","createResource","getMatch","_nonReactive","displayPendingPromise","minPendingResult","minPendingPromise","pendingMinMs","defaultPendingMinMs","routerMatch","setTimeout","resolve","loaderResult","Promise","r","loadPromise","FallbackComponent","_routeId","RouteErrorComponent","info","componentStack","nearestParentMatch","parentMatch","parentGlobalNotFound","globalNotFound","childMatchId","childMatchIdByRouteId","childMatchStatus","shouldShowNotFound","resolvedRoute","childMatchIdAccessor","currentMatchId"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n invariant,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from 'solid-js/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nexport const Match = (props: { matchId: string }) => {\n const router = useRouter()\n\n const match = Solid.createMemo(() => {\n const id = props.matchId\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state\n })\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n const parentRouteId = (router.routesById[routeId] as AnyRoute)?.parentRoute\n ?.id\n\n return {\n matchId: currentMatch.id,\n routeId,\n ssr: currentMatch.ssr,\n _displayPending: currentMatch._displayPending,\n parentRouteId: parentRouteId as string | undefined,\n }\n })\n\n const hasPendingMatch = Solid.createMemo(() => {\n const currentRouteId = rawMatchState()?.routeId\n return currentRouteId\n ? Boolean(router.stores.pendingRouteIds.state[currentRouteId])\n : false\n })\n const nearestMatch = {\n matchId: () => rawMatchState()?.matchId,\n routeId: () => rawMatchState()?.routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route: () => AnyRoute = () =>\n router.routesById[currentMatchState().routeId]\n\n const resolvePendingComponent = () =>\n route().options.pendingComponent ??\n 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 resolvedNoSsr =\n currentMatchState().ssr === false ||\n currentMatchState().ssr === 'data-only'\n\n const ResolvedSuspenseBoundary = () => Solid.Suspense\n\n const ResolvedCatchBoundary = () =>\n routeErrorComponent() ? CatchBoundary : SafeFragment\n\n const ResolvedNotFoundBoundary = () =>\n routeNotFoundComponent() ? CatchNotFound : SafeFragment\n\n const ShellComponent = route().isRoot\n ? ((route().options as RootRouteOptions).shellComponent ??\n SafeFragment)\n : SafeFragment\n\n return (\n <ShellComponent>\n <nearestMatchContext.Provider value={nearestMatch}>\n <Dynamic\n component={ResolvedSuspenseBoundary()}\n fallback={\n // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch\n (isServer ?? router.isServer) && resolvedNoSsr ? undefined : (\n <Dynamic component={resolvePendingComponent()} />\n )\n }\n >\n <Dynamic\n component={ResolvedCatchBoundary()}\n getResetKey={() => router.stores.loadedAt.state}\n errorComponent={routeErrorComponent() || ErrorComponent}\n onCatch={(error: Error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Warning: Error in route match: ${currentMatchState().routeId}`,\n )\n }\n routeOnCatch()?.(error)\n }}\n >\n <Dynamic\n component={ResolvedNotFoundBoundary()}\n fallback={(error: any) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent() ||\n (error.routeId &&\n error.routeId !== currentMatchState().routeId) ||\n (!error.routeId && !route().isRoot)\n )\n throw error\n\n return (\n <Dynamic\n component={routeNotFoundComponent()}\n {...error}\n />\n )\n }}\n >\n <Solid.Switch>\n <Solid.Match when={resolvedNoSsr}>\n <Solid.Show\n when={!(isServer ?? router.isServer)}\n fallback={\n <Dynamic component={resolvePendingComponent()} />\n }\n >\n <MatchInner />\n </Solid.Show>\n </Solid.Match>\n <Solid.Match when={!resolvedNoSsr}>\n <MatchInner />\n </Solid.Match>\n </Solid.Switch>\n </Dynamic>\n </Dynamic>\n </Dynamic>\n </nearestMatchContext.Provider>\n\n {currentMatchState().parentRouteId === rootRouteId ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </ShellComponent>\n )\n }}\n </Solid.Show>\n )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\nfunction OnRendered() {\n const router = useRouter()\n\n const location = Solid.createMemo(\n () => router.stores.resolvedLocation.state?.state.__TSR_key,\n )\n Solid.createEffect(\n Solid.on([location], () => {\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(\n router.stores.location.state,\n router.stores.resolvedLocation.state,\n ),\n })\n }),\n )\n return null\n}\n\nexport const MatchInner = (): any => {\n const router = useRouter()\n const match = Solid.useContext(nearestMatchContext).match\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: currentMatch.loaderDeps,\n params: currentMatch._strictParams,\n search: currentMatch._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: currentMatch.id,\n status: currentMatch.status,\n error: currentMatch.error,\n _forcePending: currentMatch._forcePending ?? false,\n _displayPending: currentMatch._displayPending ?? false,\n },\n }\n })\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route = () => router.routesById[currentMatchState().routeId]!\n\n const currentMatch = () => currentMatchState().match\n\n const componentKey = () =>\n currentMatchState().key ?? currentMatchState().match.id\n\n const out = () => {\n const Comp =\n route().options.component ?? router.options.defaultComponent\n if (Comp) {\n return <Comp />\n }\n return <Outlet />\n }\n\n const keyedOut = () => (\n <Solid.Show when={componentKey()} keyed>\n {(_key) => out()}\n </Solid.Show>\n )\n\n return (\n <Solid.Switch>\n <Solid.Match when={currentMatch()._displayPending}>\n {(_) => {\n const [displayPendingResult] = Solid.createResource(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .displayPendingPromise,\n )\n\n return <>{displayPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch()._forcePending}>\n {(_) => {\n const [minPendingResult] = Solid.createResource(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .minPendingPromise,\n )\n\n return <>{minPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'pending'}>\n {(_) => {\n const pendingMinMs =\n route().options.pendingMinMs ??\n router.options.defaultPendingMinMs\n\n if (pendingMinMs) {\n const routerMatch = router.getMatch(currentMatch().id)\n if (\n routerMatch &&\n !routerMatch._nonReactive.minPendingPromise\n ) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise =\n minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n }\n\n const [loaderResult] = Solid.createResource(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(currentMatch().id)?._nonReactive\n .loadPromise\n })\n\n const FallbackComponent =\n route().options.pendingComponent ??\n router.options.defaultPendingComponent\n\n return (\n <>\n {FallbackComponent && pendingMinMs > 0 ? (\n <Dynamic component={FallbackComponent} />\n ) : null}\n {loaderResult()}\n </>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'notFound'}>\n {(_) => {\n if (!isNotFound(currentMatch().error)) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Invariant failed: Expected a notFound error',\n )\n }\n\n invariant()\n }\n\n // Use Show with keyed to ensure re-render when routeId changes\n return (\n <Solid.Show when={currentMatchState().routeId} keyed>\n {(_routeId) =>\n renderRouteNotFound(router, route(), currentMatch().error)\n }\n </Solid.Show>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'redirected'}>\n {(_) => {\n if (!isRedirect(currentMatch().error)) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Invariant failed: Expected a redirect error',\n )\n }\n\n invariant()\n }\n\n const [loaderResult] = Solid.createResource(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(currentMatch().id)?._nonReactive\n .loadPromise\n })\n\n return <>{loaderResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'error'}>\n {(_) => {\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route().options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n\n return (\n <RouteErrorComponent\n error={currentMatch().error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw currentMatch().error\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'success'}>\n {keyedOut()}\n </Solid.Match>\n </Solid.Switch>\n )\n }}\n </Solid.Show>\n )\n}\n\nexport const Outlet = () => {\n const router = useRouter()\n const nearestParentMatch = Solid.useContext(nearestMatchContext)\n const parentMatch = nearestParentMatch.match\n const routeId = nearestParentMatch.routeId\n const route = Solid.createMemo(() =>\n routeId() ? router.routesById[routeId()!] : undefined,\n )\n\n const parentGlobalNotFound = Solid.createMemo(\n () => parentMatch()?.globalNotFound ?? false,\n )\n\n const childMatchId = Solid.createMemo(() => {\n const currentRouteId = routeId()\n return currentRouteId\n ? router.stores.childMatchIdByRouteId.state[currentRouteId]\n : undefined\n })\n\n const childMatchStatus = Solid.createMemo(() => {\n const id = childMatchId()\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state.status\n })\n\n // Only show not-found if we're not in a redirected state\n const shouldShowNotFound = () =>\n childMatchStatus() !== 'redirected' && parentGlobalNotFound()\n\n return (\n <Solid.Show\n when={!shouldShowNotFound() && childMatchId()}\n fallback={\n <Solid.Show when={shouldShowNotFound() && route()}>\n {(resolvedRoute) =>\n renderRouteNotFound(router, resolvedRoute(), undefined)\n }\n </Solid.Show>\n }\n >\n {(childMatchIdAccessor) => {\n const currentMatchId = Solid.createMemo(() => childMatchIdAccessor())\n\n return (\n <Solid.Show\n when={routeId() === rootRouteId}\n fallback={<Match matchId={currentMatchId()} />}\n >\n <Solid.Suspense\n fallback={\n <Dynamic component={router.options.defaultPendingComponent} />\n }\n >\n <Match matchId={currentMatchId()} />\n </Solid.Suspense>\n </Solid.Show>\n )\n }}\n </Solid.Show>\n )\n}\n"],"mappings":";;;;;;;;;;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,GAAG,EAAEK,MAAM+E;GAC1D;CAGF,MAAMuC,2BACJD,kBAAkB,KAAK,gBAAgBJ,sBAAsB;AAE/D,QAAAlG,gBACG7C,MAAM8C,MAAI;EAAA,IACTC,OAAI;AAAA,UAAE6B,WAAA,CAAA,CAAA,CAACwE,oBAAoB,CAAA,EAAA,IAAIH,cAAc;;EAAA,IAC7CtE,WAAQ;AAAA,UAAA9B,gBACL7C,MAAM8C,MAAI;IAAA,IAACC,OAAI;AAAA,YAAE6B,WAAA,CAAA,CAAAwE,oBAAoB,CAAA,EAAA,IAAIlG,OAAO;;IAAAF,WAC7CqG,kBACAtI,oBAAoBO,QAAQ+H,eAAe,EAAE3H,KAAAA,EAAS;IAAC,CAAA;;EAAAsB,WAK3DsG,yBAAyB;GACzB,MAAMC,iBAAiBvJ,MAAMwB,iBAAiB8H,sBAAsB,CAAC;AAErE,UAAAzG,gBACG7C,MAAM8C,MAAI;IAAA,IACTC,OAAI;AAAA,YAAEd,SAAS,KAAK3B;;IAAW,IAC/BqE,WAAQ;AAAA,YAAA9B,gBAAG1B,OAAK,EAAA,IAACE,UAAO;AAAA,aAAEkI,gBAAgB;QAAA,CAAA;;IAAA,IAAAvG,WAAA;AAAA,YAAAH,gBAEzC7C,MAAMoE,UAAQ;MAAA,IACbO,WAAQ;AAAA,cAAA9B,gBACLrC,SAAO,EAAA,IAACyD,YAAS;AAAA,eAAE3C,OAAO8B,QAAQE;UAAuB,CAAA;;MAAA,IAAAN,WAAA;AAAA,cAAAH,gBAG3D1B,OAAK,EAAA,IAACE,UAAO;AAAA,eAAEkI,gBAAgB;UAAA,CAAA;;MAAA,CAAA;;IAAA,CAAA;;EAIvC,CAAA"}
|
package/dist/esm/Matches.js
CHANGED
|
@@ -7,7 +7,6 @@ import { Match } from "./Match.js";
|
|
|
7
7
|
import { replaceEqualDeep, rootRouteId } from "@tanstack/router-core";
|
|
8
8
|
import { createComponent, memo } from "solid-js/web";
|
|
9
9
|
import * as Solid from "solid-js";
|
|
10
|
-
import warning from "tiny-warning";
|
|
11
10
|
import { isServer } from "@tanstack/router-core/isServer";
|
|
12
11
|
//#region src/Matches.tsx
|
|
13
12
|
function Matches() {
|
|
@@ -59,8 +58,8 @@ function MatchesInner() {
|
|
|
59
58
|
errorComponent: ErrorComponent,
|
|
60
59
|
get onCatch() {
|
|
61
60
|
return process.env.NODE_ENV !== "production" ? (error) => {
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
console.warn(`Warning: The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
|
|
62
|
+
console.warn(`Warning: ${error.message || error.toString()}`);
|
|
64
63
|
} : void 0;
|
|
65
64
|
},
|
|
66
65
|
get children() {
|
package/dist/esm/Matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.js","names":["Solid","warning","replaceEqualDeep","rootRouteId","isServer","CatchBoundary","ErrorComponent","useRouter","Transitioner","nearestMatchContext","SafeFragment","Match","AnyRoute","AnyRouter","DeepPartial","Expand","MakeOptionalPathParams","MakeOptionalSearchParams","MakeRouteMatchUnion","MaskOptions","MatchRouteOptions","NoInfer","RegisteredRouter","ResolveRelativePath","ResolveRoute","RouteByPath","ToSubOptionsProps","RouteMatchExtensions","meta","Array","JSX","IntrinsicElements","links","scripts","styles","headScripts","Matches","router","ResolvedSuspense","document","ssr","Suspense","rootRoute","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","OptionalWrapper","InnerWrap","_$createComponent","children","fallback","MatchesInner","matchId","stores","firstMatchId","state","routeId","undefined","match","getMatchStoreByRouteId","hasPendingMatch","Boolean","pendingRouteIds","resetKey","loadedAt","nearestMatch","hasPending","matchComponent","Show","when","Provider","value","_$memo","disableGlobalCatchBoundary","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","error","message","toString","UseMatchRouteOptions","TFrom","TRouter","TTo","TMaskFrom","TMaskTo","useMatchRoute","opts","Accessor","createMemo","pending","caseSensitive","fuzzy","includeSearch","rest","matchRouteReactivity","matchRoute","MakeMatchRouteOptions","params","Element","MatchRoute","props","renderedChild","matchedParams","child","UseMatchesBaseOptions","select","matches","TSelected","UseMatchesResult","useMatches","prev","activeMatchesSnapshot","res","useParentMatches","contextMatchId","useContext","slice","findIndex","d","id","useChildMatches"],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport warning from 'tiny-warning'\nimport { replaceEqualDeep, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Match } from './Match'\nimport type {\n AnyRoute,\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Solid.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<Solid.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<Solid.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n const ResolvedSuspense =\n (isServer ?? router.isServer) ||\n (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : Solid.Suspense\n\n const rootRoute: () => AnyRoute = () => router.routesById[rootRouteId]\n const PendingComponent =\n rootRoute().options.pendingComponent ??\n router.options.defaultPendingComponent\n\n const OptionalWrapper = router.options.InnerWrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <ResolvedSuspense\n fallback={PendingComponent ? <PendingComponent /> : null}\n >\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n </OptionalWrapper>\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = () => router.stores.firstMatchId.state\n const routeId = () => (matchId() ? rootRouteId : undefined)\n const match = () =>\n routeId()\n ? router.stores.getMatchStoreByRouteId(rootRouteId).state\n : undefined\n const hasPendingMatch = () =>\n routeId()\n ? Boolean(router.stores.pendingRouteIds.state[rootRouteId])\n : false\n const resetKey = () => router.stores.loadedAt.state\n const nearestMatch = {\n matchId,\n routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n const matchComponent = () => {\n return (\n <Solid.Show when={matchId()}>\n <Match matchId={matchId()!} />\n </Solid.Show>\n )\n }\n\n return (\n <nearestMatchContext.Provider value={nearestMatch}>\n {router.options.disableGlobalCatchBoundary ? (\n matchComponent()\n ) : (\n <CatchBoundary\n getResetKey={() => resetKey()}\n errorComponent={ErrorComponent}\n onCatch={\n process.env.NODE_ENV !== 'production'\n ? (error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }\n : undefined\n }\n >\n {matchComponent()}\n </CatchBoundary>\n )}\n </nearestMatchContext.Provider>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n return <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): Solid.Accessor<\n false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>\n > => {\n return Solid.createMemo(() => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n router.stores.matchRouteReactivity.state\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n }\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => Solid.JSX.Element)\n | Solid.JSX.Element\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n const renderedChild = Solid.createMemo(() => {\n const matchedParams = params()\n const child = props.children\n\n if (typeof child === 'function') {\n return (child as any)(matchedParams)\n }\n\n return matchedParams ? child : null\n })\n\n return <>{renderedChild()}</>\n}\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const router = useRouter<TRouter>()\n return Solid.createMemo((prev: TSelected | undefined) => {\n const matches = router.stores.activeMatchesSnapshot.state as Array<\n MakeRouteMatchUnion<TRouter>\n >\n const res = opts?.select ? opts.select(matches) : matches\n if (prev === undefined) return res\n return replaceEqualDeep(prev, res) as any\n }) as Solid.Accessor<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId()),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId()) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,SAAgBoC,UAAU;CACxB,MAAMC,SAAS9B,WAAW;CAE1B,MAAM+B,oBACHlC,YAAYiC,OAAOjC,aACnB,OAAOmC,aAAa,eAAeF,OAAOG,MACvC9B,eACAV,MAAMyC;CAEZ,MAAMC,kBAAkCL,OAAOM,WAAWxC;CAC1D,MAAMyC,mBACJF,WAAW,CAAC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MAChB,GACAV,QAAQW,WAAWC,MAAMA,EAAEC,OAAOL,gBAAgB,CACpD,CAAC;AACD,SAAO5B,MAAMmB,SAASnB,KAAKmB,OAAOC,QAAQ,GAAGA;IAEhD,CAAQ;;AAGX,SAAgBc,gBAIdlC,MACsD;CACtD,MAAM4B,iBAAiBxH,MAAMyH,WAAWhH,oBAAoB,CAAC6C;AAE7D,QAAO6D,WAAW,EAChBJ,SAASC,YAAiD;AACxDA,YAAUA,QAAQU,MAChBV,QAAQW,WAAWC,MAAMA,EAAEC,OAAOL,gBAAgB,CAAC,GAAG,EACvD;AACD,SAAO5B,MAAMmB,SAASnB,KAAKmB,OAAOC,QAAQ,GAAGA;IAEhD,CAAQ"}
|
|
1
|
+
{"version":3,"file":"Matches.js","names":["Solid","replaceEqualDeep","rootRouteId","isServer","CatchBoundary","ErrorComponent","useRouter","Transitioner","nearestMatchContext","SafeFragment","Match","AnyRoute","AnyRouter","DeepPartial","Expand","MakeOptionalPathParams","MakeOptionalSearchParams","MakeRouteMatchUnion","MaskOptions","MatchRouteOptions","NoInfer","RegisteredRouter","ResolveRelativePath","ResolveRoute","RouteByPath","ToSubOptionsProps","RouteMatchExtensions","meta","Array","JSX","IntrinsicElements","links","scripts","styles","headScripts","Matches","router","ResolvedSuspense","document","ssr","Suspense","rootRoute","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","OptionalWrapper","InnerWrap","_$createComponent","children","fallback","MatchesInner","matchId","stores","firstMatchId","state","routeId","undefined","match","getMatchStoreByRouteId","hasPendingMatch","Boolean","pendingRouteIds","resetKey","loadedAt","nearestMatch","hasPending","matchComponent","Show","when","Provider","value","_$memo","disableGlobalCatchBoundary","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","error","console","warn","message","toString","UseMatchRouteOptions","TFrom","TRouter","TTo","TMaskFrom","TMaskTo","useMatchRoute","opts","Accessor","createMemo","pending","caseSensitive","fuzzy","includeSearch","rest","matchRouteReactivity","matchRoute","MakeMatchRouteOptions","params","Element","MatchRoute","props","renderedChild","matchedParams","child","UseMatchesBaseOptions","select","matches","TSelected","UseMatchesResult","useMatches","prev","activeMatchesSnapshot","res","useParentMatches","contextMatchId","useContext","slice","findIndex","d","id","useChildMatches"],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { replaceEqualDeep, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Match } from './Match'\nimport type {\n AnyRoute,\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Solid.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<Solid.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<Solid.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n const ResolvedSuspense =\n (isServer ?? router.isServer) ||\n (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : Solid.Suspense\n\n const rootRoute: () => AnyRoute = () => router.routesById[rootRouteId]\n const PendingComponent =\n rootRoute().options.pendingComponent ??\n router.options.defaultPendingComponent\n\n const OptionalWrapper = router.options.InnerWrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <ResolvedSuspense\n fallback={PendingComponent ? <PendingComponent /> : null}\n >\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n </OptionalWrapper>\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = () => router.stores.firstMatchId.state\n const routeId = () => (matchId() ? rootRouteId : undefined)\n const match = () =>\n routeId()\n ? router.stores.getMatchStoreByRouteId(rootRouteId).state\n : undefined\n const hasPendingMatch = () =>\n routeId()\n ? Boolean(router.stores.pendingRouteIds.state[rootRouteId])\n : false\n const resetKey = () => router.stores.loadedAt.state\n const nearestMatch = {\n matchId,\n routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n const matchComponent = () => {\n return (\n <Solid.Show when={matchId()}>\n <Match matchId={matchId()!} />\n </Solid.Show>\n )\n }\n\n return (\n <nearestMatchContext.Provider value={nearestMatch}>\n {router.options.disableGlobalCatchBoundary ? (\n matchComponent()\n ) : (\n <CatchBoundary\n getResetKey={() => resetKey()}\n errorComponent={ErrorComponent}\n onCatch={\n process.env.NODE_ENV !== 'production'\n ? (error) => {\n console.warn(\n `Warning: The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n console.warn(`Warning: ${error.message || error.toString()}`)\n }\n : undefined\n }\n >\n {matchComponent()}\n </CatchBoundary>\n )}\n </nearestMatchContext.Provider>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n return <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): Solid.Accessor<\n false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>\n > => {\n return Solid.createMemo(() => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n router.stores.matchRouteReactivity.state\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n }\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => Solid.JSX.Element)\n | Solid.JSX.Element\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n const renderedChild = Solid.createMemo(() => {\n const matchedParams = params()\n const child = props.children\n\n if (typeof child === 'function') {\n return (child as any)(matchedParams)\n }\n\n return matchedParams ? child : null\n })\n\n return <>{renderedChild()}</>\n}\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const router = useRouter<TRouter>()\n return Solid.createMemo((prev: TSelected | undefined) => {\n const matches = router.stores.activeMatchesSnapshot.state as Array<\n MakeRouteMatchUnion<TRouter>\n >\n const res = opts?.select ? opts.select(matches) : matches\n if (prev === undefined) return res\n return replaceEqualDeep(prev, res) as any\n }) as Solid.Accessor<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId()),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId()) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"mappings":";;;;;;;;;;;AAqCA,SAAgBmC,UAAU;CACxB,MAAMC,SAAS9B,WAAW;CAE1B,MAAM+B,oBACHlC,YAAYiC,OAAOjC,aACnB,OAAOmC,aAAa,eAAeF,OAAOG,MACvC9B,eACAT,MAAMwC;CAEZ,MAAMC,kBAAkCL,OAAOM,WAAWxC;CAC1D,MAAMyC,mBACJF,WAAW,CAACG,QAAQC,oBACpBT,OAAOQ,QAAQE;AAIjB,QAAAG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,OAAOL,gBAAgB,CACpD,CAAC;AACD,SAAO5B,MAAMmB,SAASnB,KAAKmB,OAAOC,QAAQ,GAAGA;IAEhD,CAAQ;;AAGX,SAAgBc,gBAIdlC,MACsD;CACtD,MAAM4B,iBAAiBzH,MAAM0H,WAAWlH,oBAAoB,CAAC6C;AAE7D,QAAO+D,WAAW,EAChBJ,SAASC,YAAiD;AACxDA,YAAUA,QAAQU,MAChBV,QAAQW,WAAWC,MAAMA,EAAEC,OAAOL,gBAAgB,CAAC,GAAG,EACvD;AACD,SAAO5B,MAAMmB,SAASnB,KAAKmB,OAAOC,QAAQ,GAAGA;IAEhD,CAAQ"}
|
package/dist/esm/fileRoute.js
CHANGED
|
@@ -7,7 +7,6 @@ import { useSearch } from "./useSearch.js";
|
|
|
7
7
|
import { useNavigate } from "./useNavigate.js";
|
|
8
8
|
import { useRouteContext } from "./useRouteContext.js";
|
|
9
9
|
import { createRoute } from "./route.js";
|
|
10
|
-
import warning from "tiny-warning";
|
|
11
10
|
//#region src/fileRoute.ts
|
|
12
11
|
function createFileRoute(path) {
|
|
13
12
|
if (typeof path === "object") return new FileRoute(path, { silent: true }).createRoute(path);
|
|
@@ -21,7 +20,9 @@ var FileRoute = class {
|
|
|
21
20
|
constructor(path, _opts) {
|
|
22
21
|
this.path = path;
|
|
23
22
|
this.createRoute = (options) => {
|
|
24
|
-
if (process.env.NODE_ENV !== "production")
|
|
23
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24
|
+
if (!this.silent) console.warn("Warning: FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.");
|
|
25
|
+
}
|
|
25
26
|
const route = createRoute(options);
|
|
26
27
|
route.isRoot = false;
|
|
27
28
|
return route;
|
|
@@ -35,7 +36,7 @@ Instead, place the loader function in the the main route file, inside the
|
|
|
35
36
|
`createFileRoute('/path/to/file)(options)` options.
|
|
36
37
|
*/
|
|
37
38
|
function FileRouteLoader(_path) {
|
|
38
|
-
if (process.env.NODE_ENV !== "production")
|
|
39
|
+
if (process.env.NODE_ENV !== "production") console.warn(`Warning: FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`);
|
|
39
40
|
return (loaderFn) => loaderFn;
|
|
40
41
|
}
|
|
41
42
|
var LazyRoute = class {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRoute.js","names":[],"sources":["../../src/fileRoute.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"fileRoute.js","names":[],"sources":["../../src/fileRoute.ts"],"sourcesContent":["import { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport { useRouteContext } from './useRouteContext'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n Register,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderEntry,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TRegister = Register,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown,\n TSSR,\n TMiddlewares,\n THandlers\n > => {\n if (process.env.NODE_ENV !== 'production') {\n if (!this.silent) {\n console.warn(\n 'Warning: FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n }\n }\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderEntry<\n Register,\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Warning: FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n }\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.options.id }) as any\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"mappings":";;;;;;;;;;AAqCA,SAAgB,gBAQd,MAC0E;AAC1E,KAAI,OAAO,SAAS,SAClB,QAAO,IAAI,UAA0D,MAAM,EACzE,QAAQ,M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AGN,SAAgB,oBAGd,IAA8D;AAC9D,KAAI,OAAO,OAAO,SAChB,QAAO,IAAI,UAAkB,GAAG;AAGlC,SAAQ,SAA2B,IAAI,UAAkB;EAAE;EAAI,GAAG;EAAM,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { RouterManagedTag } from '@tanstack/router-core';
|
|
2
|
+
import * as Solid from 'solid-js';
|
|
2
3
|
/**
|
|
3
4
|
* Build the list of head/link/meta/script tags to render for active matches.
|
|
4
5
|
* Used internally by `HeadContent`.
|
|
5
6
|
*/
|
|
6
|
-
export declare const useTags: () =>
|
|
7
|
+
export declare const useTags: () => Solid.Accessor<RouterManagedTag[]>;
|
|
7
8
|
export declare function uniqBy<T>(arr: Array<T>, fn: (item: T) => string): T[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRouter } from "./useRouter.js";
|
|
2
|
-
import { escapeHtml } from "@tanstack/router-core";
|
|
2
|
+
import { escapeHtml, replaceEqualDeep } from "@tanstack/router-core";
|
|
3
3
|
import * as Solid from "solid-js";
|
|
4
4
|
//#region src/headContentUtils.tsx
|
|
5
5
|
/**
|
|
@@ -109,14 +109,18 @@ var useTags = () => {
|
|
|
109
109
|
},
|
|
110
110
|
children
|
|
111
111
|
})));
|
|
112
|
-
return () =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
return Solid.createMemo((prev) => {
|
|
113
|
+
const next = uniqBy([
|
|
114
|
+
...meta(),
|
|
115
|
+
...preloadLinks(),
|
|
116
|
+
...links(),
|
|
117
|
+
...styles(),
|
|
118
|
+
...headScripts()
|
|
119
|
+
], (d) => {
|
|
120
|
+
return JSON.stringify(d);
|
|
121
|
+
});
|
|
122
|
+
if (prev === void 0) return next;
|
|
123
|
+
return replaceEqualDeep(prev, next);
|
|
120
124
|
});
|
|
121
125
|
};
|
|
122
126
|
function uniqBy(arr, fn) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headContentUtils.js","names":["Solid","escapeHtml","useRouter","RouterManagedTag","useTags","router","nonce","options","ssr","activeMatches","createMemo","stores","activeMatchesSnapshot","state","routeMeta","map","match","meta","filter","Boolean","Accessor","Array","resultMeta","metaByAttribute","Record","title","routeMetasArray","i","length","metas","j","m","tag","children","json","JSON","stringify","push","attrs","type","attribute","name","property","content","reverse","links","matches","constructed","flat","link","manifest","assets","routes","routeId","asset","preloadLinks","looseRoutesById","forEach","route","id","preloads","preload","rel","href","styles","style","headScripts","script","uniqBy","d","arr","T","fn","item","seen","Set","key","has","add"],"sources":["../../src/headContentUtils.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { escapeHtml } from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\n/**\n * Build the list of head/link/meta/script tags to render for active matches.\n * Used internally by `HeadContent`.\n */\nexport const useTags = () => {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n const activeMatches = Solid.createMemo(\n () => router.stores.activeMatchesSnapshot.state,\n )\n const routeMeta = Solid.createMemo(() =>\n activeMatches()\n .map((match) => match.meta!)\n .filter(Boolean),\n )\n\n const meta: Solid.Accessor<Array<RouterManagedTag>> = Solid.createMemo(() => {\n const resultMeta: Array<RouterManagedTag> = []\n const metaByAttribute: Record<string, true> = {}\n let title: RouterManagedTag | undefined\n const routeMetasArray = routeMeta()\n for (let i = routeMetasArray.length - 1; i >= 0; i--) {\n const metas = routeMetasArray[i]!\n for (let j = metas.length - 1; j >= 0; j--) {\n const m = metas[j]\n if (!m) continue\n\n if (m.title) {\n if (!title) {\n title = {\n tag: 'title',\n children: m.title,\n }\n }\n } else if ('script:ld+json' in m) {\n // Handle JSON-LD structured data\n // Content is HTML-escaped to prevent XSS when injected via innerHTML\n try {\n const json = JSON.stringify(m['script:ld+json'])\n resultMeta.push({\n tag: 'script',\n attrs: {\n type: 'application/ld+json',\n },\n children: escapeHtml(json),\n })\n } catch {\n // Skip invalid JSON-LD objects\n }\n } else {\n const attribute = m.name ?? m.property\n if (attribute) {\n if (metaByAttribute[attribute]) {\n continue\n } else {\n metaByAttribute[attribute] = true\n }\n }\n\n resultMeta.push({\n tag: 'meta',\n attrs: {\n ...m,\n nonce,\n },\n })\n }\n }\n }\n\n if (title) {\n resultMeta.push(title)\n }\n\n if (router.options.ssr?.nonce) {\n resultMeta.push({\n tag: 'meta',\n attrs: {\n property: 'csp-nonce',\n content: router.options.ssr.nonce,\n },\n })\n }\n resultMeta.reverse()\n\n return resultMeta\n })\n\n const links = Solid.createMemo(() => {\n const matches = activeMatches()\n const constructed = matches\n .map((match) => match.links!)\n .filter(Boolean)\n .flat(1)\n .map((link) => ({\n tag: 'link',\n attrs: {\n ...link,\n nonce,\n },\n })) satisfies Array<RouterManagedTag>\n\n const manifest = router.ssr?.manifest\n\n const assets = matches\n .map((match) => manifest?.routes[match.routeId]?.assets ?? [])\n .filter(Boolean)\n .flat(1)\n .filter((asset) => asset.tag === 'link')\n .map(\n (asset) =>\n ({\n tag: 'link',\n attrs: { ...asset.attrs, nonce },\n }) satisfies RouterManagedTag,\n )\n\n return [...constructed, ...assets]\n })\n\n const preloadLinks = Solid.createMemo(() => {\n const matches = activeMatches()\n const preloadLinks: Array<RouterManagedTag> = []\n\n matches\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n router.ssr?.manifest?.routes[route.id]?.preloads\n ?.filter(Boolean)\n .forEach((preload) => {\n preloadLinks.push({\n tag: 'link',\n attrs: {\n rel: 'modulepreload',\n href: preload,\n nonce,\n },\n })\n }),\n )\n\n return preloadLinks\n })\n\n const styles = Solid.createMemo(() =>\n (\n activeMatches()\n .map((match) => match.styles!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...style }) => ({\n tag: 'style',\n attrs: {\n ...style,\n nonce,\n },\n children,\n })),\n )\n\n const headScripts = Solid.createMemo(() =>\n (\n activeMatches()\n .map((match) => match.headScripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script',\n attrs: {\n ...script,\n nonce,\n },\n children,\n })),\n )\n\n return ()
|
|
1
|
+
{"version":3,"file":"headContentUtils.js","names":["Solid","escapeHtml","replaceEqualDeep","useRouter","RouterManagedTag","useTags","router","nonce","options","ssr","activeMatches","createMemo","stores","activeMatchesSnapshot","state","routeMeta","map","match","meta","filter","Boolean","Accessor","Array","resultMeta","metaByAttribute","Record","title","routeMetasArray","i","length","metas","j","m","tag","children","json","JSON","stringify","push","attrs","type","attribute","name","property","content","reverse","links","matches","constructed","flat","link","manifest","assets","routes","routeId","asset","preloadLinks","looseRoutesById","forEach","route","id","preloads","preload","rel","href","styles","style","headScripts","script","prev","next","uniqBy","d","undefined","arr","T","fn","item","seen","Set","key","has","add"],"sources":["../../src/headContentUtils.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { escapeHtml, replaceEqualDeep } from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\n/**\n * Build the list of head/link/meta/script tags to render for active matches.\n * Used internally by `HeadContent`.\n */\nexport const useTags = () => {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n const activeMatches = Solid.createMemo(\n () => router.stores.activeMatchesSnapshot.state,\n )\n const routeMeta = Solid.createMemo(() =>\n activeMatches()\n .map((match) => match.meta!)\n .filter(Boolean),\n )\n\n const meta: Solid.Accessor<Array<RouterManagedTag>> = Solid.createMemo(() => {\n const resultMeta: Array<RouterManagedTag> = []\n const metaByAttribute: Record<string, true> = {}\n let title: RouterManagedTag | undefined\n const routeMetasArray = routeMeta()\n for (let i = routeMetasArray.length - 1; i >= 0; i--) {\n const metas = routeMetasArray[i]!\n for (let j = metas.length - 1; j >= 0; j--) {\n const m = metas[j]\n if (!m) continue\n\n if (m.title) {\n if (!title) {\n title = {\n tag: 'title',\n children: m.title,\n }\n }\n } else if ('script:ld+json' in m) {\n // Handle JSON-LD structured data\n // Content is HTML-escaped to prevent XSS when injected via innerHTML\n try {\n const json = JSON.stringify(m['script:ld+json'])\n resultMeta.push({\n tag: 'script',\n attrs: {\n type: 'application/ld+json',\n },\n children: escapeHtml(json),\n })\n } catch {\n // Skip invalid JSON-LD objects\n }\n } else {\n const attribute = m.name ?? m.property\n if (attribute) {\n if (metaByAttribute[attribute]) {\n continue\n } else {\n metaByAttribute[attribute] = true\n }\n }\n\n resultMeta.push({\n tag: 'meta',\n attrs: {\n ...m,\n nonce,\n },\n })\n }\n }\n }\n\n if (title) {\n resultMeta.push(title)\n }\n\n if (router.options.ssr?.nonce) {\n resultMeta.push({\n tag: 'meta',\n attrs: {\n property: 'csp-nonce',\n content: router.options.ssr.nonce,\n },\n })\n }\n resultMeta.reverse()\n\n return resultMeta\n })\n\n const links = Solid.createMemo(() => {\n const matches = activeMatches()\n const constructed = matches\n .map((match) => match.links!)\n .filter(Boolean)\n .flat(1)\n .map((link) => ({\n tag: 'link',\n attrs: {\n ...link,\n nonce,\n },\n })) satisfies Array<RouterManagedTag>\n\n const manifest = router.ssr?.manifest\n\n const assets = matches\n .map((match) => manifest?.routes[match.routeId]?.assets ?? [])\n .filter(Boolean)\n .flat(1)\n .filter((asset) => asset.tag === 'link')\n .map(\n (asset) =>\n ({\n tag: 'link',\n attrs: { ...asset.attrs, nonce },\n }) satisfies RouterManagedTag,\n )\n\n return [...constructed, ...assets]\n })\n\n const preloadLinks = Solid.createMemo(() => {\n const matches = activeMatches()\n const preloadLinks: Array<RouterManagedTag> = []\n\n matches\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n router.ssr?.manifest?.routes[route.id]?.preloads\n ?.filter(Boolean)\n .forEach((preload) => {\n preloadLinks.push({\n tag: 'link',\n attrs: {\n rel: 'modulepreload',\n href: preload,\n nonce,\n },\n })\n }),\n )\n\n return preloadLinks\n })\n\n const styles = Solid.createMemo(() =>\n (\n activeMatches()\n .map((match) => match.styles!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...style }) => ({\n tag: 'style',\n attrs: {\n ...style,\n nonce,\n },\n children,\n })),\n )\n\n const headScripts = Solid.createMemo(() =>\n (\n activeMatches()\n .map((match) => match.headScripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script',\n attrs: {\n ...script,\n nonce,\n },\n children,\n })),\n )\n\n return Solid.createMemo((prev: Array<RouterManagedTag> | undefined) => {\n const next = uniqBy(\n [\n ...meta(),\n ...preloadLinks(),\n ...links(),\n ...styles(),\n ...headScripts(),\n ] as Array<RouterManagedTag>,\n (d) => {\n return JSON.stringify(d)\n },\n )\n if (prev === undefined) {\n return next\n }\n return replaceEqualDeep(prev, next)\n })\n}\n\nexport function uniqBy<T>(arr: Array<T>, fn: (item: T) => string) {\n const seen = new Set<string>()\n return arr.filter((item) => {\n const key = fn(item)\n if (seen.has(key)) {\n return false\n }\n seen.add(key)\n return true\n })\n}\n"],"mappings":";;;;;;;;AASA,IAAaK,gBAAgB;CAC3B,MAAMC,SAASH,WAAW;CAC1B,MAAMI,QAAQD,OAAOE,QAAQC,KAAKF;CAClC,MAAMG,gBAAgBV,MAAMW,iBACpBL,OAAOM,OAAOC,sBAAsBC,MAC3C;CACD,MAAMC,YAAYf,MAAMW,iBACtBD,eAAe,CACZM,KAAKC,UAAUA,MAAMC,KAAM,CAC3BC,OAAOC,QACZ,CAAC;CAED,MAAMF,OAAgDlB,MAAMW,iBAAiB;EAC3E,MAAMY,aAAsC,EAAE;EAC9C,MAAMC,kBAAwC,EAAE;EAChD,IAAIE;EACJ,MAAMC,kBAAkBZ,WAAW;AACnC,OAAK,IAAIa,IAAID,gBAAgBE,SAAS,GAAGD,KAAK,GAAGA,KAAK;GACpD,MAAME,QAAQH,gBAAgBC;AAC9B,QAAK,IAAIG,IAAID,MAAMD,SAAS,GAAGE,KAAK,GAAG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AE;IAE3B;AACD,MAAIH,SAASI,KAAAA,EACX,QAAOH;AAET,SAAOpE,iBAAiBmE,MAAMC,KAAK;GACnC;;AAGJ,SAAgBC,OAAUG,KAAeE,IAAyB;CAChE,MAAME,uBAAO,IAAIC,KAAa;AAC9B,QAAOL,IAAIvD,QAAQ0D,SAAS;EAC1B,MAAMG,MAAMJ,GAAGC,KAAK;AACpB,MAAIC,KAAKG,IAAID,IAAI,CACf,QAAO;AAETF,OAAKI,IAAIF,IAAI;AACb,SAAO;GACP"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DefaultGlobalNotFound } from "./not-found.js";
|
|
2
2
|
import { createComponent } from "solid-js/web";
|
|
3
|
-
import warning from "tiny-warning";
|
|
4
3
|
//#region src/renderRouteNotFound.tsx
|
|
5
4
|
/**
|
|
6
5
|
* Renders a not found component for a route when no matching route is found.
|
|
@@ -13,7 +12,9 @@ import warning from "tiny-warning";
|
|
|
13
12
|
function renderRouteNotFound(router, route, data) {
|
|
14
13
|
if (!route.options.notFoundComponent) {
|
|
15
14
|
if (router.options.defaultNotFoundComponent) return createComponent(router.options.defaultNotFoundComponent, data);
|
|
16
|
-
if (process.env.NODE_ENV
|
|
15
|
+
if (process.env.NODE_ENV !== "production") {
|
|
16
|
+
if (!route.options.notFoundComponent) console.warn(`Warning: A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`);
|
|
17
|
+
}
|
|
17
18
|
return createComponent(DefaultGlobalNotFound, {});
|
|
18
19
|
}
|
|
19
20
|
return createComponent(route.options.notFoundComponent, data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouteNotFound.js","names":["
|
|
1
|
+
{"version":3,"file":"renderRouteNotFound.js","names":["DefaultGlobalNotFound","AnyRoute","AnyRouter","renderRouteNotFound","router","route","data","options","notFoundComponent","defaultNotFoundComponent","_$createComponent","process","env","NODE_ENV","console","warn","id"],"sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\n\n/**\n * Renders a not found component for a route when no matching route is found.\n *\n * @param router - The router instance containing the route configuration\n * @param route - The route that triggered the not found state\n * @param data - Additional data to pass to the not found component\n * @returns The rendered not found component or a default fallback component\n */\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent {...data} />\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (!route.options.notFoundComponent) {\n console.warn(\n `Warning: A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`,\n )\n }\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent {...data} />\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgBG,oBACdC,QACAC,OACAC,MACA;AACA,KAAI,CAACD,MAAME,QAAQC,mBAAmB;AACpC,MAAIJ,OAAOG,QAAQE,yBACjB,QAAAC,gBAAQN,OAAOG,QAAQE,0BAA6BH,KAAI;AAG1D,MAAA,QAAA,IAAA,aAA6B;OACvB,CAACD,MAAME,QAAQC,kBACjBM,SAAQC,KACN,kEAAkEV,MAAMW,GAAE,oPAC3E;;AAIL,SAAAN,gBAAQV,uBAAqB,EAAA,CAAA;;AAG/B,QAAAU,gBAAQL,MAAME,QAAQC,mBAAsBF,KAAI"}
|
package/dist/esm/useMatch.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useRouter } from "./useRouter.js";
|
|
2
2
|
import { nearestMatchContext } from "./matchContext.js";
|
|
3
|
-
import { replaceEqualDeep } from "@tanstack/router-core";
|
|
3
|
+
import { invariant, replaceEqualDeep } from "@tanstack/router-core";
|
|
4
4
|
import * as Solid from "solid-js";
|
|
5
|
-
import invariant from "tiny-invariant";
|
|
6
5
|
//#region src/useMatch.tsx
|
|
7
6
|
function useMatch(opts) {
|
|
8
7
|
const router = useRouter();
|
|
@@ -13,7 +12,10 @@ function useMatch(opts) {
|
|
|
13
12
|
};
|
|
14
13
|
Solid.createEffect(() => {
|
|
15
14
|
if (match() !== void 0) return;
|
|
16
|
-
|
|
15
|
+
if (!(opts.from ? Boolean(router.stores.pendingRouteIds.state[opts.from]) : nearestMatch?.hasPending() ?? false) && !router.stores.isTransitioning.state && (opts.shouldThrow ?? true)) {
|
|
16
|
+
if (process.env.NODE_ENV !== "production") throw new Error(`Invariant failed: Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
|
|
17
|
+
invariant();
|
|
18
|
+
}
|
|
17
19
|
});
|
|
18
20
|
return Solid.createMemo((prev) => {
|
|
19
21
|
const selectedMatch = match();
|
package/dist/esm/useMatch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatch.js","names":["Solid","invariant","replaceEqualDeep","nearestMatchContext","useRouter","AnyRouter","MakeRouteMatch","MakeRouteMatchUnion","RegisteredRouter","StrictOrFrom","ThrowConstraint","ThrowOrOptional","UseMatchBaseOptions","select","match","TRouter","TFrom","TStrict","TSelected","shouldThrow","TThrow","UseMatchRoute","opts","Accessor","UseMatchResult","UseMatchOptions","useMatch","router","nearestMatch","from","undefined","useContext","stores","getMatchStoreByRouteId","state","createEffect","hasPendingMatch","Boolean","pendingRouteIds","hasPending","isTransitioning","createMemo","prev","selectedMatch","res"],"sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport
|
|
1
|
+
{"version":3,"file":"useMatch.js","names":["Solid","invariant","replaceEqualDeep","nearestMatchContext","useRouter","AnyRouter","MakeRouteMatch","MakeRouteMatchUnion","RegisteredRouter","StrictOrFrom","ThrowConstraint","ThrowOrOptional","UseMatchBaseOptions","select","match","TRouter","TFrom","TStrict","TSelected","shouldThrow","TThrow","UseMatchRoute","opts","Accessor","UseMatchResult","UseMatchOptions","useMatch","router","nearestMatch","from","undefined","useContext","stores","getMatchStoreByRouteId","state","createEffect","hasPendingMatch","Boolean","pendingRouteIds","hasPending","isTransitioning","process","env","NODE_ENV","Error","createMemo","prev","selectedMatch","res"],"sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { invariant, replaceEqualDeep } from '@tanstack/router-core'\nimport { nearestMatchContext } from './matchContext'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouter,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n RegisteredRouter,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n} from '@tanstack/router-core'\n\nexport interface UseMatchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => TSelected\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>,\n) => Solid.Accessor<UseMatchResult<TRouter, TFrom, true, TSelected>>\n\nexport type UseMatchOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\n\nexport type UseMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>\n : MakeRouteMatchUnion<TRouter>\n : TSelected\n\nexport function useMatch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n>(\n opts: UseMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Solid.Accessor<\n ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n const router = useRouter<TRouter>()\n const nearestMatch = opts.from\n ? undefined\n : Solid.useContext(nearestMatchContext)\n\n const match = () => {\n if (opts.from) {\n return router.stores.getMatchStoreByRouteId(opts.from).state\n }\n\n return nearestMatch?.match()\n }\n\n Solid.createEffect(() => {\n if (match() !== undefined) {\n return\n }\n\n const hasPendingMatch = opts.from\n ? Boolean(router.stores.pendingRouteIds.state[opts.from!])\n : (nearestMatch?.hasPending() ?? false)\n\n if (\n !hasPendingMatch &&\n !router.stores.isTransitioning.state &&\n (opts.shouldThrow ?? true)\n ) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n `Invariant failed: Could not find ${opts.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'}`,\n )\n }\n\n invariant()\n }\n })\n\n return Solid.createMemo((prev: TSelected | undefined) => {\n const selectedMatch = match()\n\n if (selectedMatch === undefined) return undefined\n const res = opts.select ? opts.select(selectedMatch as any) : selectedMatch\n if (prev === undefined) return res as TSelected\n return replaceEqualDeep(prev, res) as TSelected\n }) as any\n}\n"],"mappings":";;;;;AAsDA,SAAgB0B,SAOdJ,MASA;CACA,MAAMK,SAASvB,WAAoB;CACnC,MAAMwB,eAAeN,KAAKO,OACtBC,KAAAA,IACA9B,MAAM+B,WAAW5B,oBAAoB;CAEzC,MAAMW,cAAc;AAClB,MAAIQ,KAAKO,KACP,QAAOF,OAAOK,OAAOC,uBAAuBX,KAAKO,KAAK,CAACK;AAGzD,SAAON,cAAcd,OAAO;;AAG9Bd,OAAMmC,mBAAmB;AACvB,MAAIrB,OAAO,KAAKgB,KAAAA,EACd;AAOF,MACE,EALsBR,KAAKO,OACzBQ,QAAQV,OAAOK,OAAOM,gBAAgBJ,MAAMZ,KAAKO,MAAO,GACvDD,cAAcW,YAAY,IAAI,UAIjC,CAACZ,OAAOK,OAAOQ,gBAAgBN,UAC9BZ,KAAKH,eAAe,OACrB;AACA,OAAA,QAAA,IAAA,aAA6B,aAC3B,OAAM,IAAIyB,MACR,oCAAoCtB,KAAKO,OAAO,yBAAyBP,KAAKO,KAAI,KAAM,qBACzF;AAGH5B,cAAW;;GAEb;AAEF,QAAOD,MAAM6C,YAAYC,SAAgC;EACvD,MAAMC,gBAAgBjC,OAAO;AAE7B,MAAIiC,kBAAkBjB,KAAAA,EAAW,QAAOA,KAAAA;EACxC,MAAMkB,MAAM1B,KAAKT,SAASS,KAAKT,OAAOkC,cAAqB,GAAGA;AAC9D,MAAID,SAAShB,KAAAA,EAAW,QAAOkB;AAC/B,SAAO9C,iBAAiB4C,MAAME,IAAI;GAClC"}
|
package/dist/esm/useRouter.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { routerContext } from "./routerContext.js";
|
|
2
2
|
import * as Solid from "solid-js";
|
|
3
|
-
import warning from "tiny-warning";
|
|
4
3
|
//#region src/useRouter.tsx
|
|
5
4
|
function useRouter(opts) {
|
|
6
5
|
const value = Solid.useContext(routerContext);
|
|
7
|
-
|
|
6
|
+
if (process.env.NODE_ENV !== "production") {
|
|
7
|
+
if ((opts?.warn ?? true) && !value) console.warn("Warning: useRouter must be used inside a <RouterProvider> component!");
|
|
8
|
+
}
|
|
8
9
|
return value;
|
|
9
10
|
}
|
|
10
11
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.js","names":["Solid","
|
|
1
|
+
{"version":3,"file":"useRouter.js","names":["Solid","routerContext","AnyRouter","RegisteredRouter","useRouter","opts","warn","TRouter","value","useContext","process","env","NODE_ENV","console"],"sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { routerContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = Solid.useContext(routerContext as any)\n if (process.env.NODE_ENV !== 'production') {\n if ((opts?.warn ?? true) && !value) {\n console.warn(\n 'Warning: useRouter must be used inside a <RouterProvider> component!',\n )\n }\n }\n return value as any\n}\n"],"mappings":";;;AAIA,SAAgBI,UAAwDC,MAE5D;CACV,MAAMG,QAAQR,MAAMS,WAAWR,cAAqB;AACpD,KAAA,QAAA,IAAA,aAA6B;OACtBI,MAAMC,QAAQ,SAAS,CAACE,MAC3BK,SAAQP,KACN,uEACD;;AAGL,QAAOE"}
|