@tanstack/solid-router 1.168.8 → 1.168.10
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 -3
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/link.cjs +3 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/not-found.cjs +9 -2
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +4 -1
- package/dist/esm/Match.js +10 -4
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/link.js +3 -1
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/not-found.d.ts +4 -1
- package/dist/esm/not-found.js +9 -3
- package/dist/esm/not-found.js.map +1 -1
- package/dist/source/Match.jsx +16 -8
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/link.jsx +2 -0
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/not-found.d.ts +4 -1
- package/dist/source/not-found.jsx +17 -4
- package/dist/source/not-found.jsx.map +1 -1
- package/package.json +2 -2
- package/src/Match.tsx +18 -7
- package/src/link.tsx +2 -0
- package/src/not-found.tsx +25 -5
package/dist/cjs/Match.cjs
CHANGED
|
@@ -78,7 +78,11 @@ var Match = (props) => {
|
|
|
78
78
|
return routeErrorComponent() || require_CatchBoundary.ErrorComponent;
|
|
79
79
|
},
|
|
80
80
|
onCatch: (error) => {
|
|
81
|
-
|
|
81
|
+
const notFoundError = require_not_found.getNotFound(error);
|
|
82
|
+
if (notFoundError) {
|
|
83
|
+
notFoundError.routeId ??= currentMatchState().routeId;
|
|
84
|
+
throw notFoundError;
|
|
85
|
+
}
|
|
82
86
|
if (process.env.NODE_ENV !== "production") console.warn(`Warning: Error in route match: ${currentMatchState().routeId}`);
|
|
83
87
|
routeOnCatch()?.(error);
|
|
84
88
|
},
|
|
@@ -88,10 +92,12 @@ var Match = (props) => {
|
|
|
88
92
|
return ResolvedNotFoundBoundary();
|
|
89
93
|
},
|
|
90
94
|
fallback: (error) => {
|
|
91
|
-
|
|
95
|
+
const notFoundError = require_not_found.getNotFound(error) ?? error;
|
|
96
|
+
notFoundError.routeId ??= currentMatchState().routeId;
|
|
97
|
+
if (!routeNotFoundComponent() || notFoundError.routeId && notFoundError.routeId !== currentMatchState().routeId || !notFoundError.routeId && !route().isRoot) throw notFoundError;
|
|
92
98
|
return (0, solid_js_web.createComponent)(solid_js_web.Dynamic, (0, solid_js_web.mergeProps)({ get component() {
|
|
93
99
|
return routeNotFoundComponent();
|
|
94
|
-
} },
|
|
100
|
+
} }, notFoundError));
|
|
95
101
|
},
|
|
96
102
|
get children() {
|
|
97
103
|
return (0, solid_js_web.createComponent)(solid_js.Switch, { get children() {
|
package/dist/cjs/Match.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.cjs","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","scrollRestoration","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 {router.options.scrollRestoration &&\n (isServer ?? router.isServer) ? (\n <ScrollRestoration />\n ) : null}\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 needs to run\n// after the app has committed below the root layout. Keeping it here lets us\n// fire onRendered even after a hydration mismatch above the root layout\n// (like bad head/link tags, 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":";;;;;;;;;;;;;;AAoBA,IAAamB,SAASC,UAA+B;CACnD,MAAME,SAASX,kBAAAA,WAAW;CAE1B,MAAMY,QAAQvB,SAAMwB,iBAAiB;EACnC,MAAMC,KAAKL,MAAMC;AACjB,MAAI,CAACI,GAAI,QAAOC,KAAAA;AAChB,SAAOJ,OAAOK,OAAOC,sBAAsBC,IAAI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AAW,IAC/BqE,WAAQ;AAAA,aAAA,GAAA,aAAA,iBAAGxD,OAAK,EAAA,IAACE,UAAO;AAAA,aAAEmI,gBAAgB;QAAA,CAAA;;IAAA,IAAAxG,WAAA;AAAA,aAAA,GAAA,aAAA,iBAEzChD,SAAMoE,UAAQ;MAAA,IACbO,WAAQ;AAAA,eAAA,GAAA,aAAA,iBACLnE,aAAAA,SAAO,EAAA,IAACyD,YAAS;AAAA,eAAE3C,OAAO8B,QAAQE;UAAuB,CAAA;;MAAA,IAAAN,WAAA;AAAA,eAAA,GAAA,aAAA,iBAG3D7B,OAAK,EAAA,IAACE,UAAO;AAAA,eAAEmI,gBAAgB;UAAA,CAAA;;MAAA,CAAA;;IAAA,CAAA;;EAIvC,CAAA"}
|
|
1
|
+
{"version":3,"file":"Match.cjs","names":["Solid","createControlledPromise","getLocationChangeInfo","invariant","isNotFound","isRedirect","rootRouteId","isServer","Dynamic","CatchBoundary","ErrorComponent","useRouter","CatchNotFound","getNotFound","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","notFoundError","process","env","NODE_ENV","console","warn","_$mergeProps","Switch","MatchInner","OnRendered","scrollRestoration","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, getNotFound } 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 const notFoundError = getNotFound(error)\n if (notFoundError) {\n notFoundError.routeId ??= currentMatchState()\n .routeId as any\n throw notFoundError\n }\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 const notFoundError = getNotFound(error) ?? error\n\n notFoundError.routeId ??= currentMatchState()\n .routeId as any\n\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 (notFoundError.routeId &&\n notFoundError.routeId !==\n currentMatchState().routeId) ||\n (!notFoundError.routeId && !route().isRoot)\n )\n throw notFoundError\n\n return (\n <Dynamic\n component={routeNotFoundComponent()}\n {...notFoundError}\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 {router.options.scrollRestoration &&\n (isServer ?? router.isServer) ? (\n <ScrollRestoration />\n ) : null}\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 needs to run\n// after the app has committed below the root layout. Keeping it here lets us\n// fire onRendered even after a hydration mismatch above the root layout\n// (like bad head/link tags, 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":";;;;;;;;;;;;;;AAoBA,IAAaoB,SAASC,UAA+B;CACnD,MAAME,SAASZ,kBAAAA,WAAW;CAE1B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,oBAAoB,CAAA,EAAA,IAAIpG,OAAO;;IAAAF,WAC7CuG,kBACAxI,4BAAAA,oBAAoBO,QAAQiI,eAAe,EAAE7H,KAAAA,EAAS;IAAC,CAAA;;EAAAsB,WAK3DwG,yBAAyB;GACzB,MAAMC,iBAAiB1J,SAAMyB,iBAAiBgI,sBAAsB,CAAC;AAErE,WAAA,GAAA,aAAA,iBACGzJ,SAAM+C,MAAI;IAAA,IACTC,OAAI;AAAA,YAAEd,SAAS,KAAK5B,sBAAAA;;IAAW,IAC/BsE,WAAQ;AAAA,aAAA,GAAA,aAAA,iBAAGxD,OAAK,EAAA,IAACE,UAAO;AAAA,aAAEoI,gBAAgB;QAAA,CAAA;;IAAA,IAAAzG,WAAA;AAAA,aAAA,GAAA,aAAA,iBAEzCjD,SAAMqE,UAAQ;MAAA,IACbO,WAAQ;AAAA,eAAA,GAAA,aAAA,iBACLpE,aAAAA,SAAO,EAAA,IAAC0D,YAAS;AAAA,eAAE3C,OAAO8B,QAAQE;UAAuB,CAAA;;MAAA,IAAAN,WAAA;AAAA,eAAA,GAAA,aAAA,iBAG3D7B,OAAK,EAAA,IAACE,UAAO;AAAA,eAAEoI,gBAAgB;UAAA,CAAA;;MAAA,CAAA;;IAAA,CAAA;;EAIvC,CAAA"}
|
package/dist/cjs/link.cjs
CHANGED
|
@@ -27,6 +27,7 @@ function useLinkProps(options) {
|
|
|
27
27
|
"to",
|
|
28
28
|
"preload",
|
|
29
29
|
"preloadDelay",
|
|
30
|
+
"preloadIntentProximity",
|
|
30
31
|
"hashScrollIntoView",
|
|
31
32
|
"replace",
|
|
32
33
|
"startTransition",
|
|
@@ -53,7 +54,8 @@ function useLinkProps(options) {
|
|
|
53
54
|
"state",
|
|
54
55
|
"mask",
|
|
55
56
|
"reloadDocument",
|
|
56
|
-
"unsafeRelative"
|
|
57
|
+
"unsafeRelative",
|
|
58
|
+
"from"
|
|
57
59
|
]);
|
|
58
60
|
const currentLocation = solid_js.createMemo(() => router.stores.location.state, void 0, { equals: (prev, next) => prev.href === next.href });
|
|
59
61
|
const _options = () => options;
|
package/dist/cjs/link.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","names":["Solid","mergeRefs","deepEqual","exactPathTest","functionalUpdate","isDangerousProtocol","preloadWarning","removeTrailingSlash","isServer","Dynamic","useRouter","useIntersectionObserver","useHydrated","AnyRouter","Constrain","LinkOptions","RegisteredRouter","RoutePaths","ValidateLinkOptions","ValidateLinkOptionsArray","timeoutMap","WeakMap","EventTarget","ReturnType","setTimeout","useLinkProps","TRouter","TFrom","options","UseLinkPropsOptions","TTo","TMaskFrom","TMaskTo","ComponentProps","router","isTransitioning","setIsTransitioning","createSignal","shouldHydrateHash","ssr","hasHydrated","hasRenderFetched","local","rest","splitProps","mergeProps","activeProps","STATIC_ACTIVE_PROPS_GET","inactiveProps","STATIC_INACTIVE_PROPS_GET","_","propsSafeToSpread","currentLocation","createMemo","stores","location","state","undefined","equals","prev","next","href","_options","_fromLocation","untrack","buildLocation","hrefOption","disabled","maskedLocation","publicHref","external","history","createHref","externalLink","_href","protocolAllowlist","process","env","NODE_ENV","console","warn","to","safeInternal","isSafeInternal","indexOf","URL","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","current","nextLocation","exact","testExact","pathname","basepath","currentPath","nextPath","pathIsFuzzyEqual","startsWith","length","includeSearch","searchTest","search","partial","ignoreUndefined","explicitUndefined","includeHash","currentHash","hash","doPreload","preloadRoute","_builtLocation","catch","err","preloadViewportIoCallback","entry","IntersectionObserverEntry","isIntersecting","ref","setRef","Element","rootMargin","createEffect","handleClick","e","MouseEvent","elementTarget","currentTarget","HTMLAnchorElement","SVGAElement","getAttribute","effectiveTarget","target","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","enqueueIntentPreload","FocusEvent","eventTarget","has","set","delete","handleTouchStart","TouchEvent","handleLeave","id","get","clearTimeout","simpleStyling","class","style","onClick","createComposedHandler","onBlur","onFocus","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onTouchStart","ResolvedLinkStateProps","Omit","JSX","CSSProperties","resolvedProps","active","base","STATIC_DISABLED_PROPS","STATIC_TRANSITIONING_ATTRIBUTES","STATIC_DEFAULT_ACTIVE_ATTRIBUTES","EMPTY_OBJECT","className","filter","Boolean","join","Object","keys","STATIC_ACTIVE_ATTRIBUTES","STATIC_ACTIVE_PROPS","role","callHandler","Event","event","TEvent","T","handler","EventHandlerUnion","getHandler","fallback","ActiveLinkOptions","ActiveLinkOptionProps","TComp","ActiveLinkProps","Partial","LinkComponentSolidProps","key","LinkProps","LinkPropsChildren","children","ValidComponent","CreateLinkProps","LinkComponentProps","LinkComponent","TDefaultFrom","props","LinkComponentRoute","defaultFrom","createLink","Comp","_$createComponent","Link","_$mergeProps","_asChild","linkProps","ch","svgLinkProps","_el$","_tmpl$","_el$2","firstChild","_$spread","_$insert","_el$3","_tmpl$2","component","metaKey","altKey","ctrlKey","shiftKey","zero","charCodeAt","LinkOptionsFnOptions","TOptions","ReadonlyArray","LinkOptionsFn","linkOptions"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport { mergeRefs } from '@solid-primitives/refs'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from 'solid-js/web'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useHydrated } from './ClientOnly'\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\nconst timeoutMap = new WeakMap<EventTarget, ReturnType<typeof setTimeout>>()\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)\n const shouldHydrateHash = !isServer && !!router.options.ssr\n const hasHydrated = useHydrated()\n\n let hasRenderFetched = false\n\n const [local, rest] = Solid.splitProps(\n Solid.mergeProps(\n {\n activeProps: STATIC_ACTIVE_PROPS_GET,\n inactiveProps: STATIC_INACTIVE_PROPS_GET,\n },\n options,\n ),\n [\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n ],\n )\n\n // const {\n // // custom props\n // activeProps = () => ({ class: 'active' }),\n // inactiveProps = () => ({}),\n // activeOptions,\n // to,\n // preload: userPreload,\n // preloadDelay: userPreloadDelay,\n // hashScrollIntoView,\n // replace,\n // startTransition,\n // resetScroll,\n // viewTransition,\n // // element props\n // children,\n // target,\n // disabled,\n // style,\n // class,\n // onClick,\n // onFocus,\n // onMouseEnter,\n // onMouseLeave,\n // onTouchStart,\n // ignoreBlocker,\n // ...rest\n // } = options\n\n const [_, propsSafeToSpread] = Solid.splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n ])\n\n const currentLocation = Solid.createMemo(\n () => router.stores.location.state,\n undefined,\n { equals: (prev, next) => prev.href === next.href },\n )\n\n const _options = () => options\n\n const next = Solid.createMemo(() => {\n // Rebuild when inherited search/hash or the current route context changes.\n const _fromLocation = currentLocation()\n const options = { _fromLocation, ..._options() } as any\n // untrack because router-core will also access stores, which are signals in solid\n return Solid.untrack(() => router.buildLocation(options))\n })\n\n const hrefOption = Solid.createMemo(() => {\n if (_options().disabled) return undefined\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const location = next().maskedLocation ?? next()\n const publicHref = location.publicHref\n const external = location.external\n\n if (external) {\n return { href: publicHref, external: true }\n }\n\n return {\n href: router.history.createHref(publicHref) || '/',\n external: false,\n }\n })\n\n const externalLink = Solid.createMemo(() => {\n const _href = hrefOption()\n if (_href?.external) {\n // Block dangerous protocols for external links\n if (isDangerousProtocol(_href.href, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${_href.href}`)\n }\n return undefined\n }\n return _href.href\n }\n const to = _options().to\n const safeInternal = isSafeInternal(to)\n if (safeInternal) return undefined\n if (typeof to !== 'string' || to.indexOf(':') === -1) return undefined\n try {\n new URL(to as any)\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(to, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${to}`)\n }\n return undefined\n }\n return to\n } catch {}\n return undefined\n })\n\n const preload = Solid.createMemo(() => {\n if (_options().reloadDocument || externalLink()) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = Solid.createMemo(() => {\n if (externalLink()) return false\n const activeOptions = local.activeOptions\n const current = currentLocation()\n const nextLocation = next()\n\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n current.pathname,\n nextLocation.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPath = removeTrailingSlash(current.pathname, router.basepath)\n const nextPath = removeTrailingSlash(\n nextLocation.pathname,\n router.basepath,\n )\n\n const pathIsFuzzyEqual =\n currentPath.startsWith(nextPath) &&\n (currentPath.length === nextPath.length ||\n currentPath[nextPath.length] === '/')\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(current.search, nextLocation.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n const currentHash =\n shouldHydrateHash && !hasHydrated() ? '' : current.hash\n return currentHash === nextLocation.hash\n }\n return true\n })\n\n const doPreload = () =>\n router\n .preloadRoute({ ..._options(), _builtLocation: next() } as any)\n .catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const [ref, setRef] = Solid.createSignal<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!local.disabled || !(preload() === 'viewport') },\n )\n\n Solid.createEffect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!local.disabled && preload() === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n if (externalLink()) {\n return Solid.mergeProps(\n propsSafeToSpread,\n {\n ref: mergeRefs(setRef, _options().ref),\n href: externalLink(),\n },\n Solid.splitProps(local, [\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n ).getAttribute('target')\n const effectiveTarget =\n local.target !== undefined ? local.target : elementTarget\n\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n setIsTransitioning(true)\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n setIsTransitioning(false)\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n router.navigate({\n ..._options(),\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n })\n }\n }\n\n const enqueueIntentPreload = (e: MouseEvent | FocusEvent) => {\n if (local.disabled || preload() !== 'intent') return\n\n if (!preloadDelay()) {\n doPreload()\n return\n }\n\n const eventTarget = e.currentTarget || e.target\n\n if (!eventTarget || timeoutMap.has(eventTarget)) return\n\n timeoutMap.set(\n eventTarget,\n setTimeout(() => {\n timeoutMap.delete(eventTarget)\n doPreload()\n }, preloadDelay()),\n )\n }\n\n const handleTouchStart = (_: TouchEvent) => {\n if (local.disabled || preload() !== 'intent') return\n doPreload()\n }\n\n const handleLeave = (e: MouseEvent | FocusEvent) => {\n if (local.disabled) return\n const eventTarget = e.currentTarget || e.target\n\n if (eventTarget) {\n const id = timeoutMap.get(eventTarget)\n clearTimeout(id)\n timeoutMap.delete(eventTarget)\n }\n }\n\n const simpleStyling = Solid.createMemo(\n () =>\n local.activeProps === STATIC_ACTIVE_PROPS_GET &&\n local.inactiveProps === STATIC_INACTIVE_PROPS_GET &&\n local.class === undefined &&\n local.style === undefined,\n )\n\n const onClick = createComposedHandler(() => local.onClick, handleClick)\n const onBlur = createComposedHandler(() => local.onBlur, handleLeave)\n const onFocus = createComposedHandler(\n () => local.onFocus,\n enqueueIntentPreload,\n )\n const onMouseEnter = createComposedHandler(\n () => local.onMouseEnter,\n enqueueIntentPreload,\n )\n const onMouseOver = createComposedHandler(\n () => local.onMouseOver,\n enqueueIntentPreload,\n )\n const onMouseLeave = createComposedHandler(\n () => local.onMouseLeave,\n handleLeave,\n )\n const onMouseOut = createComposedHandler(() => local.onMouseOut, handleLeave)\n const onTouchStart = createComposedHandler(\n () => local.onTouchStart,\n handleTouchStart,\n )\n\n type ResolvedLinkStateProps = Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n }\n\n const resolvedProps = Solid.createMemo(() => {\n const active = isActive()\n\n const base = {\n href: hrefOption()?.href,\n ref: mergeRefs(setRef, _options().ref),\n onClick,\n onBlur,\n onFocus,\n onMouseEnter,\n onMouseOver,\n onMouseLeave,\n onMouseOut,\n onTouchStart,\n disabled: !!local.disabled,\n target: local.target,\n ...(local.disabled && STATIC_DISABLED_PROPS),\n ...(isTransitioning() && STATIC_TRANSITIONING_ATTRIBUTES),\n }\n\n if (simpleStyling()) {\n return {\n ...base,\n ...(active && STATIC_DEFAULT_ACTIVE_ATTRIBUTES),\n }\n }\n\n const activeProps: ResolvedLinkStateProps = active\n ? (functionalUpdate(local.activeProps as any, {}) ?? EMPTY_OBJECT)\n : EMPTY_OBJECT\n const inactiveProps: ResolvedLinkStateProps = active\n ? EMPTY_OBJECT\n : functionalUpdate(local.inactiveProps, {})\n const style = {\n ...local.style,\n ...activeProps.style,\n ...inactiveProps.style,\n }\n const className = [local.class, activeProps.class, inactiveProps.class]\n .filter(Boolean)\n .join(' ')\n\n return {\n ...activeProps,\n ...inactiveProps,\n ...base,\n ...(Object.keys(style).length ? { style } : undefined),\n ...(className ? { class: className } : undefined),\n ...(active && STATIC_ACTIVE_ATTRIBUTES),\n } as ResolvedLinkStateProps\n })\n\n return Solid.mergeProps(propsSafeToSpread, resolvedProps) as any\n}\n\nconst STATIC_ACTIVE_PROPS = { class: 'active' }\nconst STATIC_ACTIVE_PROPS_GET = () => STATIC_ACTIVE_PROPS\nconst EMPTY_OBJECT = {}\nconst STATIC_INACTIVE_PROPS_GET = () => EMPTY_OBJECT\nconst STATIC_DEFAULT_ACTIVE_ATTRIBUTES = {\n class: 'active',\n 'data-status': 'active',\n 'aria-current': 'page',\n}\nconst STATIC_DISABLED_PROPS = {\n role: 'link',\n 'aria-disabled': true,\n}\nconst STATIC_ACTIVE_ATTRIBUTES = {\n 'data-status': 'active',\n 'aria-current': 'page',\n}\nconst STATIC_TRANSITIONING_ATTRIBUTES = {\n 'data-transitioning': 'transitioning',\n}\n\n/** Call a JSX.EventHandlerUnion with the event. */\nfunction callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.JSX.EventHandlerUnion<T, TEvent>,\n) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n return event.defaultPrevented\n}\n\nfunction createComposedHandler<T, TEvent extends Event>(\n getHandler: () => Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n fallback: (event: TEvent) => void,\n) {\n return (event: TEvent & { currentTarget: T; target: Element }) => {\n const handler = getHandler()\n if (!handler || !callHandler(event, handler)) fallback(event)\n }\n}\n\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n LinkComponentSolidProps<TComp> & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\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 | Solid.JSX.Element\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n : never\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentSolidProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Solid.JSX.Element\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = Solid.splitProps(\n props as typeof props & { _asChild: any },\n ['_asChild', 'children'],\n )\n\n const [_, linkProps] = Solid.splitProps(\n useLinkProps(rest as unknown as any),\n ['type'],\n )\n\n const children = Solid.createMemo(() => {\n const ch = local.children\n if (typeof ch === 'function') {\n return ch({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n get isTransitioning() {\n return (linkProps as any)['data-transitioning'] === 'transitioning'\n },\n })\n }\n\n return ch satisfies Solid.JSX.Element\n })\n\n if (local._asChild === 'svg') {\n const [_, svgLinkProps] = Solid.splitProps(linkProps, ['class'])\n return (\n <svg>\n <a {...svgLinkProps}>{children()}</a>\n </svg>\n )\n }\n\n if (!local._asChild) {\n return <a {...linkProps}>{children()}</a>\n }\n\n return (\n <Dynamic component={local._asChild as Solid.ValidComponent} {...linkProps}>\n {children()}\n </Dynamic>\n )\n}\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nfunction isSafeInternal(to: unknown) {\n if (typeof to !== 'string') return false\n const zero = to.charCodeAt(0)\n if (zero === 47) return to.charCodeAt(1) !== 47 // '/' but not '//'\n return zero === 46 // '.', '..', './', '../'\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,IAAMoB,6BAAa,IAAIC,SAAqD;AAE5E,SAAgBI,aAOdG,SAC2B;CAC3B,MAAMM,SAASxB,kBAAAA,WAAW;CAC1B,MAAM,CAACyB,iBAAiBC,sBAAsBpC,SAAMqC,aAAa,MAAM;CACvE,MAAMC,oBAAoB,CAAC9B,+BAAAA,YAAY,CAAC,CAAC0B,OAAON,QAAQW;CACxD,MAAMC,cAAc5B,mBAAAA,aAAa;CAEjC,IAAI6B,mBAAmB;CAEvB,MAAM,CAACC,OAAOC,QAAQ3C,SAAM4C,WAC1B5C,SAAM6C,WACJ;EACEC,aAAaC;EACbC,eAAeC;EAChB,EACDrB,QACD,EACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEJ,CAAC;CA8BD,MAAM,CAACsB,GAAGC,qBAAqBnD,SAAM4C,WAAWD,MAAM;EACpD;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAMS,kBAAkBpD,SAAMqD,iBACtBnB,OAAOoB,OAAOC,SAASC,OAC7BC,KAAAA,GACA,EAAEC,SAASC,MAAMC,SAASD,KAAKE,SAASD,KAAKC,MAC/C,CAAC;CAED,MAAMC,iBAAiBlC;CAEvB,MAAMgC,OAAO5D,SA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,OAEWH,cAAY,OAAA,KAAA;AAAAM,IAAAA,GAAAA,aAAAA,QAAAH,OAAGpB,SAAQ;AAAA,UAAAkB;MAAA;;AAKpC,KAAI,CAAC5L,MAAMwL,SACT,eAAA;EAAA,IAAAU,QAAAC,SAAA;AAAAH,GAAAA,GAAAA,aAAAA,QAAAE,OAAcT,WAAS,OAAA,KAAA;AAAAQ,GAAAA,GAAAA,aAAAA,QAAAC,OAAGxB,SAAQ;AAAA,SAAAwB;KAAA;AAGpC,SAAA,GAAA,aAAA,iBACGnO,aAAAA,UAAAA,GAAAA,aAAAA,YAAO,EAAA,IAACqO,YAAS;AAAA,SAAEpM,MAAMwL;IAAgC,EAAMC,WAAS,EAAA,IAAAf,WAAA;AAAA,SACtEA,UAAU;IAAA,CAAA,CAAA;;AAKjB,SAAS3E,YAAYT,GAAe;AAClC,QAAO,CAAC,EAAEA,EAAE+G,WAAW/G,EAAEgH,UAAUhH,EAAEiH,WAAWjH,EAAEkH;;AAGpD,SAAS/J,eAAeF,IAAa;AACnC,KAAI,OAAOA,OAAO,SAAU,QAAO;CACnC,MAAMkK,OAAOlK,GAAGmK,WAAW,EAAE;AAC7B,KAAID,SAAS,GAAI,QAAOlK,GAAGmK,WAAW,EAAE,KAAK;AAC7C,QAAOD,SAAS;;AAmBlB,IAAaM,eAAmC7N,YAAY;AAC1D,QAAOA"}
|
|
1
|
+
{"version":3,"file":"link.cjs","names":["Solid","mergeRefs","deepEqual","exactPathTest","functionalUpdate","isDangerousProtocol","preloadWarning","removeTrailingSlash","isServer","Dynamic","useRouter","useIntersectionObserver","useHydrated","AnyRouter","Constrain","LinkOptions","RegisteredRouter","RoutePaths","ValidateLinkOptions","ValidateLinkOptionsArray","timeoutMap","WeakMap","EventTarget","ReturnType","setTimeout","useLinkProps","TRouter","TFrom","options","UseLinkPropsOptions","TTo","TMaskFrom","TMaskTo","ComponentProps","router","isTransitioning","setIsTransitioning","createSignal","shouldHydrateHash","ssr","hasHydrated","hasRenderFetched","local","rest","splitProps","mergeProps","activeProps","STATIC_ACTIVE_PROPS_GET","inactiveProps","STATIC_INACTIVE_PROPS_GET","_","propsSafeToSpread","currentLocation","createMemo","stores","location","state","undefined","equals","prev","next","href","_options","_fromLocation","untrack","buildLocation","hrefOption","disabled","maskedLocation","publicHref","external","history","createHref","externalLink","_href","protocolAllowlist","process","env","NODE_ENV","console","warn","to","safeInternal","isSafeInternal","indexOf","URL","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","current","nextLocation","exact","testExact","pathname","basepath","currentPath","nextPath","pathIsFuzzyEqual","startsWith","length","includeSearch","searchTest","search","partial","ignoreUndefined","explicitUndefined","includeHash","currentHash","hash","doPreload","preloadRoute","_builtLocation","catch","err","preloadViewportIoCallback","entry","IntersectionObserverEntry","isIntersecting","ref","setRef","Element","rootMargin","createEffect","handleClick","e","MouseEvent","elementTarget","currentTarget","HTMLAnchorElement","SVGAElement","getAttribute","effectiveTarget","target","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","enqueueIntentPreload","FocusEvent","eventTarget","has","set","delete","handleTouchStart","TouchEvent","handleLeave","id","get","clearTimeout","simpleStyling","class","style","onClick","createComposedHandler","onBlur","onFocus","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onTouchStart","ResolvedLinkStateProps","Omit","JSX","CSSProperties","resolvedProps","active","base","STATIC_DISABLED_PROPS","STATIC_TRANSITIONING_ATTRIBUTES","STATIC_DEFAULT_ACTIVE_ATTRIBUTES","EMPTY_OBJECT","className","filter","Boolean","join","Object","keys","STATIC_ACTIVE_ATTRIBUTES","STATIC_ACTIVE_PROPS","role","callHandler","Event","event","TEvent","T","handler","EventHandlerUnion","getHandler","fallback","ActiveLinkOptions","ActiveLinkOptionProps","TComp","ActiveLinkProps","Partial","LinkComponentSolidProps","key","LinkProps","LinkPropsChildren","children","ValidComponent","CreateLinkProps","LinkComponentProps","LinkComponent","TDefaultFrom","props","LinkComponentRoute","defaultFrom","createLink","Comp","_$createComponent","Link","_$mergeProps","_asChild","linkProps","ch","svgLinkProps","_el$","_tmpl$","_el$2","firstChild","_$spread","_$insert","_el$3","_tmpl$2","component","metaKey","altKey","ctrlKey","shiftKey","zero","charCodeAt","LinkOptionsFnOptions","TOptions","ReadonlyArray","LinkOptionsFn","linkOptions"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport { mergeRefs } from '@solid-primitives/refs'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from 'solid-js/web'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useHydrated } from './ClientOnly'\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\nconst timeoutMap = new WeakMap<EventTarget, ReturnType<typeof setTimeout>>()\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)\n const shouldHydrateHash = !isServer && !!router.options.ssr\n const hasHydrated = useHydrated()\n\n let hasRenderFetched = false\n\n const [local, rest] = Solid.splitProps(\n Solid.mergeProps(\n {\n activeProps: STATIC_ACTIVE_PROPS_GET,\n inactiveProps: STATIC_INACTIVE_PROPS_GET,\n },\n options,\n ),\n [\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'preloadIntentProximity',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n ],\n )\n\n // const {\n // // custom props\n // activeProps = () => ({ class: 'active' }),\n // inactiveProps = () => ({}),\n // activeOptions,\n // to,\n // preload: userPreload,\n // preloadDelay: userPreloadDelay,\n // hashScrollIntoView,\n // replace,\n // startTransition,\n // resetScroll,\n // viewTransition,\n // // element props\n // children,\n // target,\n // disabled,\n // style,\n // class,\n // onClick,\n // onFocus,\n // onMouseEnter,\n // onMouseLeave,\n // onTouchStart,\n // ignoreBlocker,\n // ...rest\n // } = options\n\n const [_, propsSafeToSpread] = Solid.splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n 'from',\n ])\n\n const currentLocation = Solid.createMemo(\n () => router.stores.location.state,\n undefined,\n { equals: (prev, next) => prev.href === next.href },\n )\n\n const _options = () => options\n\n const next = Solid.createMemo(() => {\n // Rebuild when inherited search/hash or the current route context changes.\n const _fromLocation = currentLocation()\n const options = { _fromLocation, ..._options() } as any\n // untrack because router-core will also access stores, which are signals in solid\n return Solid.untrack(() => router.buildLocation(options))\n })\n\n const hrefOption = Solid.createMemo(() => {\n if (_options().disabled) return undefined\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const location = next().maskedLocation ?? next()\n const publicHref = location.publicHref\n const external = location.external\n\n if (external) {\n return { href: publicHref, external: true }\n }\n\n return {\n href: router.history.createHref(publicHref) || '/',\n external: false,\n }\n })\n\n const externalLink = Solid.createMemo(() => {\n const _href = hrefOption()\n if (_href?.external) {\n // Block dangerous protocols for external links\n if (isDangerousProtocol(_href.href, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${_href.href}`)\n }\n return undefined\n }\n return _href.href\n }\n const to = _options().to\n const safeInternal = isSafeInternal(to)\n if (safeInternal) return undefined\n if (typeof to !== 'string' || to.indexOf(':') === -1) return undefined\n try {\n new URL(to as any)\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(to, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${to}`)\n }\n return undefined\n }\n return to\n } catch {}\n return undefined\n })\n\n const preload = Solid.createMemo(() => {\n if (_options().reloadDocument || externalLink()) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = Solid.createMemo(() => {\n if (externalLink()) return false\n const activeOptions = local.activeOptions\n const current = currentLocation()\n const nextLocation = next()\n\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n current.pathname,\n nextLocation.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPath = removeTrailingSlash(current.pathname, router.basepath)\n const nextPath = removeTrailingSlash(\n nextLocation.pathname,\n router.basepath,\n )\n\n const pathIsFuzzyEqual =\n currentPath.startsWith(nextPath) &&\n (currentPath.length === nextPath.length ||\n currentPath[nextPath.length] === '/')\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(current.search, nextLocation.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n const currentHash =\n shouldHydrateHash && !hasHydrated() ? '' : current.hash\n return currentHash === nextLocation.hash\n }\n return true\n })\n\n const doPreload = () =>\n router\n .preloadRoute({ ..._options(), _builtLocation: next() } as any)\n .catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const [ref, setRef] = Solid.createSignal<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!local.disabled || !(preload() === 'viewport') },\n )\n\n Solid.createEffect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!local.disabled && preload() === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n if (externalLink()) {\n return Solid.mergeProps(\n propsSafeToSpread,\n {\n ref: mergeRefs(setRef, _options().ref),\n href: externalLink(),\n },\n Solid.splitProps(local, [\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n ).getAttribute('target')\n const effectiveTarget =\n local.target !== undefined ? local.target : elementTarget\n\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n setIsTransitioning(true)\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n setIsTransitioning(false)\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n router.navigate({\n ..._options(),\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n })\n }\n }\n\n const enqueueIntentPreload = (e: MouseEvent | FocusEvent) => {\n if (local.disabled || preload() !== 'intent') return\n\n if (!preloadDelay()) {\n doPreload()\n return\n }\n\n const eventTarget = e.currentTarget || e.target\n\n if (!eventTarget || timeoutMap.has(eventTarget)) return\n\n timeoutMap.set(\n eventTarget,\n setTimeout(() => {\n timeoutMap.delete(eventTarget)\n doPreload()\n }, preloadDelay()),\n )\n }\n\n const handleTouchStart = (_: TouchEvent) => {\n if (local.disabled || preload() !== 'intent') return\n doPreload()\n }\n\n const handleLeave = (e: MouseEvent | FocusEvent) => {\n if (local.disabled) return\n const eventTarget = e.currentTarget || e.target\n\n if (eventTarget) {\n const id = timeoutMap.get(eventTarget)\n clearTimeout(id)\n timeoutMap.delete(eventTarget)\n }\n }\n\n const simpleStyling = Solid.createMemo(\n () =>\n local.activeProps === STATIC_ACTIVE_PROPS_GET &&\n local.inactiveProps === STATIC_INACTIVE_PROPS_GET &&\n local.class === undefined &&\n local.style === undefined,\n )\n\n const onClick = createComposedHandler(() => local.onClick, handleClick)\n const onBlur = createComposedHandler(() => local.onBlur, handleLeave)\n const onFocus = createComposedHandler(\n () => local.onFocus,\n enqueueIntentPreload,\n )\n const onMouseEnter = createComposedHandler(\n () => local.onMouseEnter,\n enqueueIntentPreload,\n )\n const onMouseOver = createComposedHandler(\n () => local.onMouseOver,\n enqueueIntentPreload,\n )\n const onMouseLeave = createComposedHandler(\n () => local.onMouseLeave,\n handleLeave,\n )\n const onMouseOut = createComposedHandler(() => local.onMouseOut, handleLeave)\n const onTouchStart = createComposedHandler(\n () => local.onTouchStart,\n handleTouchStart,\n )\n\n type ResolvedLinkStateProps = Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n }\n\n const resolvedProps = Solid.createMemo(() => {\n const active = isActive()\n\n const base = {\n href: hrefOption()?.href,\n ref: mergeRefs(setRef, _options().ref),\n onClick,\n onBlur,\n onFocus,\n onMouseEnter,\n onMouseOver,\n onMouseLeave,\n onMouseOut,\n onTouchStart,\n disabled: !!local.disabled,\n target: local.target,\n ...(local.disabled && STATIC_DISABLED_PROPS),\n ...(isTransitioning() && STATIC_TRANSITIONING_ATTRIBUTES),\n }\n\n if (simpleStyling()) {\n return {\n ...base,\n ...(active && STATIC_DEFAULT_ACTIVE_ATTRIBUTES),\n }\n }\n\n const activeProps: ResolvedLinkStateProps = active\n ? (functionalUpdate(local.activeProps as any, {}) ?? EMPTY_OBJECT)\n : EMPTY_OBJECT\n const inactiveProps: ResolvedLinkStateProps = active\n ? EMPTY_OBJECT\n : functionalUpdate(local.inactiveProps, {})\n const style = {\n ...local.style,\n ...activeProps.style,\n ...inactiveProps.style,\n }\n const className = [local.class, activeProps.class, inactiveProps.class]\n .filter(Boolean)\n .join(' ')\n\n return {\n ...activeProps,\n ...inactiveProps,\n ...base,\n ...(Object.keys(style).length ? { style } : undefined),\n ...(className ? { class: className } : undefined),\n ...(active && STATIC_ACTIVE_ATTRIBUTES),\n } as ResolvedLinkStateProps\n })\n\n return Solid.mergeProps(propsSafeToSpread, resolvedProps) as any\n}\n\nconst STATIC_ACTIVE_PROPS = { class: 'active' }\nconst STATIC_ACTIVE_PROPS_GET = () => STATIC_ACTIVE_PROPS\nconst EMPTY_OBJECT = {}\nconst STATIC_INACTIVE_PROPS_GET = () => EMPTY_OBJECT\nconst STATIC_DEFAULT_ACTIVE_ATTRIBUTES = {\n class: 'active',\n 'data-status': 'active',\n 'aria-current': 'page',\n}\nconst STATIC_DISABLED_PROPS = {\n role: 'link',\n 'aria-disabled': true,\n}\nconst STATIC_ACTIVE_ATTRIBUTES = {\n 'data-status': 'active',\n 'aria-current': 'page',\n}\nconst STATIC_TRANSITIONING_ATTRIBUTES = {\n 'data-transitioning': 'transitioning',\n}\n\n/** Call a JSX.EventHandlerUnion with the event. */\nfunction callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.JSX.EventHandlerUnion<T, TEvent>,\n) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n return event.defaultPrevented\n}\n\nfunction createComposedHandler<T, TEvent extends Event>(\n getHandler: () => Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n fallback: (event: TEvent) => void,\n) {\n return (event: TEvent & { currentTarget: T; target: Element }) => {\n const handler = getHandler()\n if (!handler || !callHandler(event, handler)) fallback(event)\n }\n}\n\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n LinkComponentSolidProps<TComp> & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\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 | Solid.JSX.Element\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n : never\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentSolidProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Solid.JSX.Element\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = Solid.splitProps(\n props as typeof props & { _asChild: any },\n ['_asChild', 'children'],\n )\n\n const [_, linkProps] = Solid.splitProps(\n useLinkProps(rest as unknown as any),\n ['type'],\n )\n\n const children = Solid.createMemo(() => {\n const ch = local.children\n if (typeof ch === 'function') {\n return ch({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n get isTransitioning() {\n return (linkProps as any)['data-transitioning'] === 'transitioning'\n },\n })\n }\n\n return ch satisfies Solid.JSX.Element\n })\n\n if (local._asChild === 'svg') {\n const [_, svgLinkProps] = Solid.splitProps(linkProps, ['class'])\n return (\n <svg>\n <a {...svgLinkProps}>{children()}</a>\n </svg>\n )\n }\n\n if (!local._asChild) {\n return <a {...linkProps}>{children()}</a>\n }\n\n return (\n <Dynamic component={local._asChild as Solid.ValidComponent} {...linkProps}>\n {children()}\n </Dynamic>\n )\n}\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nfunction isSafeInternal(to: unknown) {\n if (typeof to !== 'string') return false\n const zero = to.charCodeAt(0)\n if (zero === 47) return to.charCodeAt(1) !== 47 // '/' but not '//'\n return zero === 46 // '.', '..', './', '../'\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,IAAMoB,6BAAa,IAAIC,SAAqD;AAE5E,SAAgBI,aAOdG,SAC2B;CAC3B,MA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A,SACtEA,UAAU;IAAA,CAAA,CAAA;;AAKjB,SAAS3E,YAAYT,GAAe;AAClC,QAAO,CAAC,EAAEA,EAAE+G,WAAW/G,EAAEgH,UAAUhH,EAAEiH,WAAWjH,EAAEkH;;AAGpD,SAAS/J,eAAeF,IAAa;AACnC,KAAI,OAAOA,OAAO,SAAU,QAAO;CACnC,MAAMkK,OAAOlK,GAAGmK,WAAW,EAAE;AAC7B,KAAID,SAAS,GAAI,QAAOlK,GAAGmK,WAAW,EAAE,KAAK;AAC7C,QAAOD,SAAS;;AAmBlB,IAAaM,eAAmC7N,YAAY;AAC1D,QAAOA"}
|
package/dist/cjs/not-found.cjs
CHANGED
|
@@ -7,6 +7,10 @@ let solid_js = require("solid-js");
|
|
|
7
7
|
solid_js = require_runtime.__toESM(solid_js);
|
|
8
8
|
//#region src/not-found.tsx
|
|
9
9
|
var _tmpl$ = /* @__PURE__ */ (0, solid_js_web.template)(`<p>Not Found`);
|
|
10
|
+
function getNotFound(error) {
|
|
11
|
+
if ((0, _tanstack_router_core.isNotFound)(error)) return error;
|
|
12
|
+
if ((0, _tanstack_router_core.isNotFound)(error?.cause)) return error.cause;
|
|
13
|
+
}
|
|
10
14
|
function CatchNotFound(props) {
|
|
11
15
|
const router = require_useRouter.useRouter();
|
|
12
16
|
const pathname = solid_js.createMemo(() => router.stores.location.state.pathname);
|
|
@@ -14,11 +18,13 @@ function CatchNotFound(props) {
|
|
|
14
18
|
return (0, solid_js_web.createComponent)(require_CatchBoundary.CatchBoundary, {
|
|
15
19
|
getResetKey: () => `not-found-${pathname()}-${status()}`,
|
|
16
20
|
onCatch: (error) => {
|
|
17
|
-
|
|
21
|
+
const notFoundError = getNotFound(error);
|
|
22
|
+
if (notFoundError) props.onCatch?.(notFoundError);
|
|
18
23
|
else throw error;
|
|
19
24
|
},
|
|
20
25
|
errorComponent: ({ error }) => {
|
|
21
|
-
|
|
26
|
+
const notFoundError = getNotFound(error);
|
|
27
|
+
if (notFoundError) return props.fallback?.(notFoundError);
|
|
22
28
|
else throw error;
|
|
23
29
|
},
|
|
24
30
|
get children() {
|
|
@@ -32,5 +38,6 @@ function DefaultGlobalNotFound() {
|
|
|
32
38
|
//#endregion
|
|
33
39
|
exports.CatchNotFound = CatchNotFound;
|
|
34
40
|
exports.DefaultGlobalNotFound = DefaultGlobalNotFound;
|
|
41
|
+
exports.getNotFound = getNotFound;
|
|
35
42
|
|
|
36
43
|
//# sourceMappingURL=not-found.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.cjs","names":["isNotFound","Solid","CatchBoundary","useRouter","NotFoundError","CatchNotFound","props","fallback","
|
|
1
|
+
{"version":3,"file":"not-found.cjs","names":["isNotFound","Solid","CatchBoundary","useRouter","NotFoundError","getNotFound","error","cause","undefined","CatchNotFound","props","fallback","JSX","Element","onCatch","children","router","pathname","createMemo","stores","location","state","status","_$createComponent","getResetKey","notFoundError","errorComponent","DefaultGlobalNotFound","_tmpl$"],"sources":["../../src/not-found.tsx"],"sourcesContent":["import { isNotFound } from '@tanstack/router-core'\nimport * as Solid from 'solid-js'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport type { NotFoundError } from '@tanstack/router-core'\n\n// Solid wraps non-Error throws in an Error and stores the original thrown value\n// on `cause`, so component-thrown `notFound()` needs one extra unwrapping step.\nexport function getNotFound(\n error: unknown,\n): (NotFoundError & { isNotFound: true }) | undefined {\n if (isNotFound(error)) {\n return error as NotFoundError & { isNotFound: true }\n }\n\n if (isNotFound((error as any)?.cause)) {\n return (error as any).cause as NotFoundError & { isNotFound: true }\n }\n\n return undefined\n}\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Solid.JSX.Element\n onCatch?: (error: NotFoundError) => void\n children: Solid.JSX.Element\n}) {\n const router = useRouter()\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const pathname = Solid.createMemo(() => router.stores.location.state.pathname)\n const status = Solid.createMemo(() => router.stores.status.state)\n\n return (\n <CatchBoundary\n getResetKey={() => `not-found-${pathname()}-${status()}`}\n onCatch={(error) => {\n const notFoundError = getNotFound(error)\n\n if (notFoundError) {\n props.onCatch?.(notFoundError)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }) => {\n const notFoundError = getNotFound(error)\n\n if (notFoundError) {\n return props.fallback?.(notFoundError)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgBK,YACdC,OACoD;AACpD,MAAA,GAAA,sBAAA,YAAeA,MAAM,CACnB,QAAOA;AAGT,MAAA,GAAA,sBAAA,YAAgBA,OAAeC,MAAM,CACnC,QAAQD,MAAcC;;AAM1B,SAAgBE,cAAcC,OAI3B;CACD,MAAMM,SAASb,kBAAAA,WAAW;CAE1B,MAAMc,WAAWhB,SAAMiB,iBAAiBF,OAAOG,OAAOC,SAASC,MAAMJ,SAAS;CAC9E,MAAMK,SAASrB,SAAMiB,iBAAiBF,OAAOG,OAAOG,OAAOD,MAAM;AAEjE,SAAA,GAAA,aAAA,iBACGnB,sBAAAA,eAAa;EACZsB,mBAAmB,aAAaP,UAAU,CAAA,GAAIK,QAAQ;EACtDR,UAAUR,UAAU;GAClB,MAAMmB,gBAAgBpB,YAAYC,MAAM;AAExC,OAAImB,cACFf,OAAMI,UAAUW,cAAc;OAE9B,OAAMnB;;EAGVoB,iBAAiB,EAAEpB,YAAY;GAC7B,MAAMmB,gBAAgBpB,YAAYC,MAAM;AAExC,OAAImB,cACF,QAAOf,MAAMC,WAAWc,cAAc;OAEtC,OAAMnB;;EAET,IAAAS,WAAA;AAAA,UAEAL,MAAMK;;EAAQ,CAAA;;AAKrB,SAAgBY,wBAAwB;AACtC,QAAAC,QAAA"}
|
package/dist/cjs/not-found.d.cts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { NotFoundError } from '@tanstack/router-core';
|
|
2
2
|
import * as Solid from 'solid-js';
|
|
3
|
+
export declare function getNotFound(error: unknown): (NotFoundError & {
|
|
4
|
+
isNotFound: true;
|
|
5
|
+
}) | undefined;
|
|
3
6
|
export declare function CatchNotFound(props: {
|
|
4
7
|
fallback?: (error: NotFoundError) => Solid.JSX.Element;
|
|
5
|
-
onCatch?: (error:
|
|
8
|
+
onCatch?: (error: NotFoundError) => void;
|
|
6
9
|
children: Solid.JSX.Element;
|
|
7
10
|
}): Solid.JSX.Element;
|
|
8
11
|
export declare function DefaultGlobalNotFound(): Solid.JSX.Element;
|
package/dist/esm/Match.js
CHANGED
|
@@ -2,7 +2,7 @@ import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
|
2
2
|
import { useRouter } from "./useRouter.js";
|
|
3
3
|
import { nearestMatchContext } from "./matchContext.js";
|
|
4
4
|
import { SafeFragment } from "./SafeFragment.js";
|
|
5
|
-
import { CatchNotFound } from "./not-found.js";
|
|
5
|
+
import { CatchNotFound, getNotFound } from "./not-found.js";
|
|
6
6
|
import { renderRouteNotFound } from "./renderRouteNotFound.js";
|
|
7
7
|
import { ScrollRestoration } from "./scroll-restoration.js";
|
|
8
8
|
import { createControlledPromise, getLocationChangeInfo, invariant, isNotFound, isRedirect, rootRouteId } from "@tanstack/router-core";
|
|
@@ -76,7 +76,11 @@ var Match = (props) => {
|
|
|
76
76
|
return routeErrorComponent() || ErrorComponent;
|
|
77
77
|
},
|
|
78
78
|
onCatch: (error) => {
|
|
79
|
-
|
|
79
|
+
const notFoundError = getNotFound(error);
|
|
80
|
+
if (notFoundError) {
|
|
81
|
+
notFoundError.routeId ??= currentMatchState().routeId;
|
|
82
|
+
throw notFoundError;
|
|
83
|
+
}
|
|
80
84
|
if (process.env.NODE_ENV !== "production") console.warn(`Warning: Error in route match: ${currentMatchState().routeId}`);
|
|
81
85
|
routeOnCatch()?.(error);
|
|
82
86
|
},
|
|
@@ -86,10 +90,12 @@ var Match = (props) => {
|
|
|
86
90
|
return ResolvedNotFoundBoundary();
|
|
87
91
|
},
|
|
88
92
|
fallback: (error) => {
|
|
89
|
-
|
|
93
|
+
const notFoundError = getNotFound(error) ?? error;
|
|
94
|
+
notFoundError.routeId ??= currentMatchState().routeId;
|
|
95
|
+
if (!routeNotFoundComponent() || notFoundError.routeId && notFoundError.routeId !== currentMatchState().routeId || !notFoundError.routeId && !route().isRoot) throw notFoundError;
|
|
90
96
|
return createComponent(Dynamic, mergeProps({ get component() {
|
|
91
97
|
return routeNotFoundComponent();
|
|
92
|
-
} },
|
|
98
|
+
} }, notFoundError));
|
|
93
99
|
},
|
|
94
100
|
get children() {
|
|
95
101
|
return createComponent(Solid.Switch, { get children() {
|