UNPKG

@tanstack/solid-router

Version:

Modern and scalable routing for Solid applications

1 lines 3.77 kB
{"version":3,"file":"not-found.cjs","names":["<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>","getResetKey={() => `not-found-${pathname()}-${status()}`}","onCatch={(error) => {\n const notFoundError = getNotFound(error)\n\n if (notFoundError) {\n props.onCatch?.(notFoundError)\n } else {\n throw error\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 }}","<p>Not Found</p>"],"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'\nimport type { JSX } from '@solidjs/web'\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) => JSX.Element\n onCatch?: (error: NotFoundError) => void\n children: 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.get().pathname)\n const status = Solid.createMemo(() => router.stores.status.get())\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":";;;;;;;;;AASA,SAAgB,YACd,OACoD;CACpD,KAAA,GAAA,sBAAA,YAAe,KAAK,GAClB,OAAO;CAGT,KAAA,GAAA,sBAAA,YAAgB,OAAe,KAAK,GAClC,OAAQ,MAAc;AAI1B;AAEA,SAAgB,cAAc,OAI3B;CACD,MAAM,SAAS,kBAAA,UAAU;CAEzB,MAAM,WAAW,SAAM,iBAAiB,OAAO,OAAO,SAAS,IAAI,EAAE,QAAQ;CAC7E,MAAM,SAAS,SAAM,iBAAiB,OAAO,OAAO,OAAO,IAAI,CAAC;CAEhE,QAAA,GAAA,aAAA,iBACEA,sBAAAA,eAAAA;EACEC,mBAAmB,aAAa,SAAS,EAAE,GAAG,OAAO;EACrDC,UAAU,UAAU;GAClB,MAAM,gBAAgB,YAAY,KAAK;GAEvC,IAAI,eACF,MAAM,UAAU,aAAa;QAE7B,MAAM;EAEV;EACAC,iBAAiB,EAAE,YAAY;GAC7B,MAAM,gBAAgB,YAAY,KAAK;GAEvC,IAAI,eACF,OAAO,MAAM,WAAW,aAAa;QAErC,MAAM;EAEV;EAnBF,IAAA,WAAA;UAqBG,MAAM;EACM;;AAEnB;AAEA,SAAgB,wBAAwB;CACtC,OAAOC,OAAe;AACxB"}