@tanstack/react-router 1.14.4 → 1.14.5
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/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +2 -2
- package/dist/esm/Matches.d.ts +2 -2
- package/dist/esm/Matches.js.map +1 -1
- package/package.json +1 -1
- package/src/Matches.tsx +15 -16
package/dist/cjs/Matches.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.cjs","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport {\n AnyRoute,\n ReactNode,\n RootSearchSchema,\n StaticDataRouteOption,\n UpdatableStaticRouteOption,\n rootRouteId,\n} from './route'\nimport {\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { RegisteredRouter, RouterState } from './router'\nimport { DeepOptional, Expand, NoInfer, StrictOrFrom, pick } from './utils'\nimport {\n CatchNotFound,\n DefaultGlobalNotFound,\n NotFoundError,\n isNotFound,\n} from './not-found'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: TReturnIntersection extends false\n ? RouteById<TRouteTree, TRouteId>['types']['allParams']\n : Expand<Partial<AllParams<TRouteTree>>>\n status: 'pending' | 'success' | 'error'\n isFetching: boolean\n showPending: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: Promise<void>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: TReturnIntersection extends false\n ? Exclude<\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n RootSearchSchema\n >\n : Expand<\n Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>\n >\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n preload: boolean\n invalid: boolean\n pendingPromise?: Promise<void>\n meta?: JSX.IntrinsicElements['meta'][]\n links?: JSX.IntrinsicElements['link'][]\n scripts?: JSX.IntrinsicElements['script'][]\n notFoundError?: NotFoundError\n staticData: StaticDataRouteOption\n}\n\nexport type AnyRouteMatch = RouteMatch<any, any>\n\nexport function Matches() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return getRenderedMatches(s)[0]?.id\n },\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={ErrorComponent}\n onCatch={() => {\n warning(\n false,\n `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`,\n )\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route = router.routesById[routeId]!\n\n const PendingComponent = (route.options.pendingComponent ??\n router.options.defaultPendingComponent) as any\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ??\n router.options.defaultErrorComponent ??\n ErrorComponent\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ??\n PendingComponent ??\n route.options.component?.preload ??\n route.options.pendingComponent?.preload ??\n (route.options.errorComponent as any)?.preload\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={routeErrorComponent}\n onCatch={(error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or doesn't handle global not founds, forward it up the tree\n if (!routeNotFoundComponent || (error.global && !route.isRoot))\n throw error\n\n return React.createElement(routeNotFoundComponent, {\n data: error.data,\n })\n }}\n >\n <MatchInner matchId={matchId!} pendingElement={pendingElement} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction MatchInner({\n matchId,\n pendingElement,\n}: {\n matchId: string\n pendingElement: any\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { match } = useRouterState({\n select: (s) => ({\n match: pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n 'notFoundError',\n ]),\n }),\n })\n\n // If a global not-found is found, and it's the root route, render the global not-found component.\n if (match.notFoundError) {\n if (routeId === rootRouteId && !route.options.notFoundComponent)\n return <DefaultGlobalNotFound />\n\n invariant(\n route.options.notFoundComponent,\n 'Route matched with notFoundError should have a notFoundComponent',\n )\n\n return <route.options.notFoundComponent data={match.notFoundError} />\n }\n\n if (match.status === 'error') {\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement\n }\n throw match.loadPromise\n }\n\n if (match.status === 'success') {\n let Comp = route.options.component ?? router.options.defaultComponent\n\n if (Comp) {\n return <Comp />\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const matchId = React.useContext(matchContext)\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = getRenderedMatches(s)\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (!childMatchId) {\n return null\n }\n\n return <Match matchId={childMatchId} />\n})\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = DeepOptional<\n ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n 'search' | 'params'\n> &\n MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n useRouterState({ select: (s) => [s.location, s.resolvedLocation] })\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &\n MatchRouteOptions & {\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 TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n }\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return !!params ? props.children : null\n}\n\nexport function getRenderedMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>(state: RouterState<TRouteTree>) {\n return state.pendingMatches?.some((d) => d.showPending)\n ? state.pendingMatches\n : state.matches\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TReturnIntersection extends boolean = false,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom, TReturnIntersection> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TSelected {\n const router = useRouter()\n const nearestMatchId = React.useContext(matchContext)\n\n const nearestMatchRouteId = getRenderedMatches(router.state).find(\n (d) => d.id === nearestMatchId,\n )?.routeId\n\n const matchRouteId = (() => {\n const matches = getRenderedMatches(router.state)\n const match = opts?.from\n ? matches.find((d) => d.routeId === opts?.from)\n : matches.find((d) => d.id === nearestMatchId)\n return match!.routeId\n })()\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatchRouteId == matchRouteId,\n `useMatch(\"${\n matchRouteId as string\n }\") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch(\"${\n matchRouteId as string\n }\", { strict: false })' or 'useRoute(\"${\n matchRouteId as string\n }\")' instead?`,\n )\n }\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = getRenderedMatches(state).find(\n (d) => d.id === nearestMatchId,\n )\n\n invariant(\n match,\n `Could not find ${\n opts?.from\n ? `an active match from \"${opts.from}\"`\n : 'a nearest match!'\n }`,\n )\n\n return opts?.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as any\n}\n\nexport function useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n return useRouterState({\n select: (state) => {\n const matches = getRenderedMatches(state)\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(matches.findIndex((d) => d.id === contextMatchId))\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useLoaderDeps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderDeps'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderDeps)\n : s?.loaderDeps\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderData)\n : s?.loaderData\n },\n })\n}\n\nexport function isServerSideError(error: unknown): error is {\n __isServerError: true\n data: Record<string, any>\n} {\n if (!(typeof error === 'object' && error && 'data' in error)) return false\n if (!('__isServerError' in error && error.__isServerError)) return false\n if (!(typeof error.data === 'object' && error.data)) return false\n\n return error.__isServerError === true\n}\n\nexport function defaultDeserializeError(serializedData: Record<string, any>) {\n if ('name' in serializedData && 'message' in serializedData) {\n const error = new Error(serializedData.message)\n error.name = serializedData.name\n return error\n }\n\n return serializedData.data\n}\n"],"names":["React","useRouter","useRouterState","jsx","CatchBoundary","ErrorComponent","Fragment","_a","route","CatchNotFound","isNotFound","pick","rootRouteId","DefaultGlobalNotFound","Outlet"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCa,MAAA,eAAeA,iBAAM,cAAkC,MAAS;AAgDtE,SAAS,UAAU;AACxB,QAAM,SAASC,UAAAA;AACf,QAAM,UAAUC,eAAAA,eAAe;AAAA,IAC7B,QAAQ,CAAC,MAAM;;AACb,cAAO,wBAAmB,CAAC,EAAE,CAAC,MAAvB,mBAA0B;AAAA,IACnC;AAAA,EAAA,CACD;AAED,SACGC,2BAAAA,IAAA,aAAa,UAAb,EAAsB,OAAO,SAC5B,UAAAA,2BAAA;AAAA,IAACC,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAA;;AAAM,4BAAO,MAAM,iBAAiB,UAA9B,mBAAqC;AAAA;AAAA,MACxD,gBAAgBC,cAAA;AAAA,MAChB,SAAS,MAAM;AACb;AAAA,UACE;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AAAA,MAEC,UAAU,UAAAF,2BAAA,IAAC,OAAM,EAAA,QAAkB,CAAA,IAAK;AAAA,IAAA;AAAA,EAE7C,EAAA,CAAA;AAEJ;AAEA,SAAS,aAAa,OAAY;AACzB,SAAAA,2BAAAA,IAAAG,WAAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAC3B;AAEgB,SAAA,MAAM,EAAE,WAAgC;;AACtD,QAAM,SAASL,UAAAA;AACf,QAAM,UAAUC,eAAAA,eAAe;AAAA,IAC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Q,IAAI,MAAM,eAAe,OAAO;AAC9C,UAAM,OAAO,eAAe;AACrB,WAAA;AAAA,EACT;AAEA,SAAO,eAAe;AACxB;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Matches.cjs","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport {\n AnyRoute,\n ReactNode,\n RootSearchSchema,\n StaticDataRouteOption,\n UpdatableStaticRouteOption,\n rootRouteId,\n} from './route'\nimport {\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { RegisteredRouter, RouterState } from './router'\nimport { DeepOptional, Expand, NoInfer, StrictOrFrom, pick } from './utils'\nimport {\n CatchNotFound,\n DefaultGlobalNotFound,\n NotFoundError,\n isNotFound,\n} from './not-found'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: TReturnIntersection extends false\n ? RouteById<TRouteTree, TRouteId>['types']['allParams']\n : Expand<Partial<AllParams<TRouteTree>>>\n status: 'pending' | 'success' | 'error'\n isFetching: boolean\n showPending: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: Promise<void>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: TReturnIntersection extends false\n ? Exclude<\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n RootSearchSchema\n >\n : Expand<\n Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>\n >\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n preload: boolean\n invalid: boolean\n pendingPromise?: Promise<void>\n meta?: JSX.IntrinsicElements['meta'][]\n links?: JSX.IntrinsicElements['link'][]\n scripts?: JSX.IntrinsicElements['script'][]\n notFoundError?: NotFoundError\n staticData: StaticDataRouteOption\n}\n\nexport type AnyRouteMatch = RouteMatch<any, any>\n\nexport function Matches() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return getRenderedMatches(s)[0]?.id\n },\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={ErrorComponent}\n onCatch={() => {\n warning(\n false,\n `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`,\n )\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route = router.routesById[routeId]!\n\n const PendingComponent = (route.options.pendingComponent ??\n router.options.defaultPendingComponent) as any\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ??\n router.options.defaultErrorComponent ??\n ErrorComponent\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ??\n PendingComponent ??\n route.options.component?.preload ??\n route.options.pendingComponent?.preload ??\n (route.options.errorComponent as any)?.preload\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={routeErrorComponent}\n onCatch={(error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or doesn't handle global not founds, forward it up the tree\n if (!routeNotFoundComponent || (error.global && !route.isRoot))\n throw error\n\n return React.createElement(routeNotFoundComponent, {\n data: error.data,\n })\n }}\n >\n <MatchInner matchId={matchId!} pendingElement={pendingElement} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction MatchInner({\n matchId,\n pendingElement,\n}: {\n matchId: string\n pendingElement: any\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { match } = useRouterState({\n select: (s) => ({\n match: pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n 'notFoundError',\n ]),\n }),\n })\n\n // If a global not-found is found, and it's the root route, render the global not-found component.\n if (match.notFoundError) {\n if (routeId === rootRouteId && !route.options.notFoundComponent)\n return <DefaultGlobalNotFound />\n\n invariant(\n route.options.notFoundComponent,\n 'Route matched with notFoundError should have a notFoundComponent',\n )\n\n return <route.options.notFoundComponent data={match.notFoundError} />\n }\n\n if (match.status === 'error') {\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement\n }\n throw match.loadPromise\n }\n\n if (match.status === 'success') {\n let Comp = route.options.component ?? router.options.defaultComponent\n\n if (Comp) {\n return <Comp />\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const matchId = React.useContext(matchContext)\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = getRenderedMatches(s)\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (!childMatchId) {\n return null\n }\n\n return <Match matchId={childMatchId} />\n})\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = DeepOptional<\n ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n 'search' | 'params'\n> &\n MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n useRouterState({ select: (s) => [s.location, s.resolvedLocation] })\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouteTree, 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 TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return !!params ? props.children : null\n}\n\nexport function getRenderedMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>(state: RouterState<TRouteTree>) {\n return state.pendingMatches?.some((d) => d.showPending)\n ? state.pendingMatches\n : state.matches\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TReturnIntersection extends boolean = false,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom, TReturnIntersection> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TSelected {\n const router = useRouter()\n const nearestMatchId = React.useContext(matchContext)\n\n const nearestMatchRouteId = getRenderedMatches(router.state).find(\n (d) => d.id === nearestMatchId,\n )?.routeId\n\n const matchRouteId = (() => {\n const matches = getRenderedMatches(router.state)\n const match = opts?.from\n ? matches.find((d) => d.routeId === opts?.from)\n : matches.find((d) => d.id === nearestMatchId)\n return match!.routeId\n })()\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatchRouteId == matchRouteId,\n `useMatch(\"${\n matchRouteId as string\n }\") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch(\"${\n matchRouteId as string\n }\", { strict: false })' or 'useRoute(\"${\n matchRouteId as string\n }\")' instead?`,\n )\n }\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = getRenderedMatches(state).find(\n (d) => d.id === nearestMatchId,\n )\n\n invariant(\n match,\n `Could not find ${\n opts?.from\n ? `an active match from \"${opts.from}\"`\n : 'a nearest match!'\n }`,\n )\n\n return opts?.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as any\n}\n\nexport function useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n return useRouterState({\n select: (state) => {\n const matches = getRenderedMatches(state)\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(matches.findIndex((d) => d.id === contextMatchId))\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useLoaderDeps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderDeps'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderDeps)\n : s?.loaderDeps\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderData)\n : s?.loaderData\n },\n })\n}\n\nexport function isServerSideError(error: unknown): error is {\n __isServerError: true\n data: Record<string, any>\n} {\n if (!(typeof error === 'object' && error && 'data' in error)) return false\n if (!('__isServerError' in error && error.__isServerError)) return false\n if (!(typeof error.data === 'object' && error.data)) return false\n\n return error.__isServerError === true\n}\n\nexport function defaultDeserializeError(serializedData: Record<string, any>) {\n if ('name' in serializedData && 'message' in serializedData) {\n const error = new Error(serializedData.message)\n error.name = serializedData.name\n return error\n }\n\n return serializedData.data\n}\n"],"names":["React","useRouter","useRouterState","jsx","CatchBoundary","ErrorComponent","Fragment","_a","route","CatchNotFound","isNotFound","pick","rootRouteId","DefaultGlobalNotFound","Outlet"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCa,MAAA,eAAeA,iBAAM,cAAkC,MAAS;AAgDtE,SAAS,UAAU;AACxB,QAAM,SAASC,UAAAA;AACf,QAAM,UAAUC,eAAAA,eAAe;AAAA,IAC7B,QAAQ,CAAC,MAAM;;AACb,cAAO,wBAAmB,CAAC,EAAE,CAAC,MAAvB,mBAA0B;AAAA,IACnC;AAAA,EAAA,CACD;AAED,SACGC,2BAAAA,IAAA,aAAa,UAAb,EAAsB,OAAO,SAC5B,UAAAA,2BAAA;AAAA,IAACC,cAAA;AAAA,IAAA;AAAA,MACC,aAAa,MAAA;;AAAM,4BAAO,MAAM,iBAAiB,UAA9B,mBAAqC;AAAA;AAAA,MACxD,gBAAgBC,cAAA;AAAA,MAChB,SAAS,MAAM;AACb;AAAA,UACE;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AAAA,MAEC,UAAU,UAAAF,2BAAA,IAAC,OAAM,EAAA,QAAkB,CAAA,IAAK;AAAA,IAAA;AAAA,EAE7C,EAAA,CAAA;AAEJ;AAEA,SAAS,aAAa,OAAY;AACzB,SAAAA,2BAAAA,IAAAG,WAAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAC3B;AAEgB,SAAA,MAAM,EAAE,WAAgC;;AACtD,QAAM,SAASL,UAAAA;AACf,QAAM,UAAUC,eAAAA,eAAe;AAAA,IAC7B,QAAQ,CAAC;;AACP,cAAAK,MAAA,mBAAmB,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,OAAO,MAAlD,gBAAAA,IAAqD;AAAA;AAAA,EAAA,CACxD;AAED;AAAA,IACE;AAAA,IAC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+50,10 @@ export interface MatchRouteOptions {
|
|
|
50
50
|
}
|
|
51
51
|
export type UseMatchRouteOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> = DeepOptional<ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>, 'search' | 'params'> & MatchRouteOptions;
|
|
52
52
|
export declare function useMatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree']>(): <TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = "", TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
53
|
-
export type MakeMatchRouteOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> =
|
|
53
|
+
export type MakeMatchRouteOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> = UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
54
54
|
children?: ((params?: RouteByPath<TRouteTree, ResolveRelativePath<TFrom, NoInfer<TTo>>>['types']['allParams']) => ReactNode) | React.ReactNode;
|
|
55
55
|
};
|
|
56
|
-
export declare function MatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> =
|
|
56
|
+
export declare function MatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''>(props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): any;
|
|
57
57
|
export declare function getRenderedMatches<TRouteTree extends AnyRoute = RegisteredRouter['routeTree']>(state: RouterState<TRouteTree>): RouteMatch<TRouteTree, ParseRoute<TRouteTree>["id"], false>[];
|
|
58
58
|
export declare function useMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TReturnIntersection extends boolean = false, TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>, TSelected = TRouteMatchState>(opts: StrictOrFrom<TFrom, TReturnIntersection> & {
|
|
59
59
|
select?: (match: TRouteMatchState) => TSelected;
|
package/dist/esm/Matches.d.ts
CHANGED
|
@@ -50,10 +50,10 @@ export interface MatchRouteOptions {
|
|
|
50
50
|
}
|
|
51
51
|
export type UseMatchRouteOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> = DeepOptional<ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>, 'search' | 'params'> & MatchRouteOptions;
|
|
52
52
|
export declare function useMatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree']>(): <TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = "", TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
53
|
-
export type MakeMatchRouteOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> =
|
|
53
|
+
export type MakeMatchRouteOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> = UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
54
54
|
children?: ((params?: RouteByPath<TRouteTree, ResolveRelativePath<TFrom, NoInfer<TTo>>>['types']['allParams']) => ReactNode) | React.ReactNode;
|
|
55
55
|
};
|
|
56
|
-
export declare function MatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> =
|
|
56
|
+
export declare function MatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''>(props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): any;
|
|
57
57
|
export declare function getRenderedMatches<TRouteTree extends AnyRoute = RegisteredRouter['routeTree']>(state: RouterState<TRouteTree>): RouteMatch<TRouteTree, ParseRoute<TRouteTree>["id"], false>[];
|
|
58
58
|
export declare function useMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TReturnIntersection extends boolean = false, TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>, TSelected = TRouteMatchState>(opts: StrictOrFrom<TFrom, TReturnIntersection> & {
|
|
59
59
|
select?: (match: TRouteMatchState) => TSelected;
|
package/dist/esm/Matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport {\n AnyRoute,\n ReactNode,\n RootSearchSchema,\n StaticDataRouteOption,\n UpdatableStaticRouteOption,\n rootRouteId,\n} from './route'\nimport {\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { RegisteredRouter, RouterState } from './router'\nimport { DeepOptional, Expand, NoInfer, StrictOrFrom, pick } from './utils'\nimport {\n CatchNotFound,\n DefaultGlobalNotFound,\n NotFoundError,\n isNotFound,\n} from './not-found'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: TReturnIntersection extends false\n ? RouteById<TRouteTree, TRouteId>['types']['allParams']\n : Expand<Partial<AllParams<TRouteTree>>>\n status: 'pending' | 'success' | 'error'\n isFetching: boolean\n showPending: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: Promise<void>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: TReturnIntersection extends false\n ? Exclude<\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n RootSearchSchema\n >\n : Expand<\n Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>\n >\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n preload: boolean\n invalid: boolean\n pendingPromise?: Promise<void>\n meta?: JSX.IntrinsicElements['meta'][]\n links?: JSX.IntrinsicElements['link'][]\n scripts?: JSX.IntrinsicElements['script'][]\n notFoundError?: NotFoundError\n staticData: StaticDataRouteOption\n}\n\nexport type AnyRouteMatch = RouteMatch<any, any>\n\nexport function Matches() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return getRenderedMatches(s)[0]?.id\n },\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={ErrorComponent}\n onCatch={() => {\n warning(\n false,\n `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`,\n )\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route = router.routesById[routeId]!\n\n const PendingComponent = (route.options.pendingComponent ??\n router.options.defaultPendingComponent) as any\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ??\n router.options.defaultErrorComponent ??\n ErrorComponent\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ??\n PendingComponent ??\n route.options.component?.preload ??\n route.options.pendingComponent?.preload ??\n (route.options.errorComponent as any)?.preload\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={routeErrorComponent}\n onCatch={(error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or doesn't handle global not founds, forward it up the tree\n if (!routeNotFoundComponent || (error.global && !route.isRoot))\n throw error\n\n return React.createElement(routeNotFoundComponent, {\n data: error.data,\n })\n }}\n >\n <MatchInner matchId={matchId!} pendingElement={pendingElement} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction MatchInner({\n matchId,\n pendingElement,\n}: {\n matchId: string\n pendingElement: any\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { match } = useRouterState({\n select: (s) => ({\n match: pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n 'notFoundError',\n ]),\n }),\n })\n\n // If a global not-found is found, and it's the root route, render the global not-found component.\n if (match.notFoundError) {\n if (routeId === rootRouteId && !route.options.notFoundComponent)\n return <DefaultGlobalNotFound />\n\n invariant(\n route.options.notFoundComponent,\n 'Route matched with notFoundError should have a notFoundComponent',\n )\n\n return <route.options.notFoundComponent data={match.notFoundError} />\n }\n\n if (match.status === 'error') {\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement\n }\n throw match.loadPromise\n }\n\n if (match.status === 'success') {\n let Comp = route.options.component ?? router.options.defaultComponent\n\n if (Comp) {\n return <Comp />\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const matchId = React.useContext(matchContext)\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = getRenderedMatches(s)\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (!childMatchId) {\n return null\n }\n\n return <Match matchId={childMatchId} />\n})\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = DeepOptional<\n ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n 'search' | 'params'\n> &\n MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n useRouterState({ select: (s) => [s.location, s.resolvedLocation] })\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &\n MatchRouteOptions & {\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 TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n }\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return !!params ? props.children : null\n}\n\nexport function getRenderedMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>(state: RouterState<TRouteTree>) {\n return state.pendingMatches?.some((d) => d.showPending)\n ? state.pendingMatches\n : state.matches\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TReturnIntersection extends boolean = false,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom, TReturnIntersection> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TSelected {\n const router = useRouter()\n const nearestMatchId = React.useContext(matchContext)\n\n const nearestMatchRouteId = getRenderedMatches(router.state).find(\n (d) => d.id === nearestMatchId,\n )?.routeId\n\n const matchRouteId = (() => {\n const matches = getRenderedMatches(router.state)\n const match = opts?.from\n ? matches.find((d) => d.routeId === opts?.from)\n : matches.find((d) => d.id === nearestMatchId)\n return match!.routeId\n })()\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatchRouteId == matchRouteId,\n `useMatch(\"${\n matchRouteId as string\n }\") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch(\"${\n matchRouteId as string\n }\", { strict: false })' or 'useRoute(\"${\n matchRouteId as string\n }\")' instead?`,\n )\n }\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = getRenderedMatches(state).find(\n (d) => d.id === nearestMatchId,\n )\n\n invariant(\n match,\n `Could not find ${\n opts?.from\n ? `an active match from \"${opts.from}\"`\n : 'a nearest match!'\n }`,\n )\n\n return opts?.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as any\n}\n\nexport function useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n return useRouterState({\n select: (state) => {\n const matches = getRenderedMatches(state)\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(matches.findIndex((d) => d.id === contextMatchId))\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useLoaderDeps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderDeps'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderDeps)\n : s?.loaderDeps\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderData)\n : s?.loaderData\n },\n })\n}\n\nexport function isServerSideError(error: unknown): error is {\n __isServerError: true\n data: Record<string, any>\n} {\n if (!(typeof error === 'object' && error && 'data' in error)) return false\n if (!('__isServerError' in error && error.__isServerError)) return false\n if (!(typeof error.data === 'object' && error.data)) return false\n\n return error.__isServerError === true\n}\n\nexport function defaultDeserializeError(serializedData: Record<string, any>) {\n if ('name' in serializedData && 'message' in serializedData) {\n const error = new Error(serializedData.message)\n error.name = serializedData.name\n return error\n }\n\n return serializedData.data\n}\n"],"names":["_a","Outlet"],"mappings":";;;;;;;;;;AAiCa,MAAA,eAAe,MAAM,cAAkC,MAAS;AAgDtE,SAAS,UAAU;AACxB,QAAM,SAAS;AACf,QAAM,UAAU,eAAe;AAAA,IAC7B,QAAQ,CAAC,MAAM;;AACb,cAAO,wBAAmB,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AK,OAAO,uBAAG,UAAU,IACzB,uBAAG;AAAA,IACT;AAAA,EAAA,CACD;AACH;AAEO,SAAS,kBAAkB,OAGhC;AACA,MAAI,EAAE,OAAO,UAAU,YAAY,SAAS,UAAU;AAAe,WAAA;AACjE,MAAA,EAAE,qBAAqB,SAAS,MAAM;AAAyB,WAAA;AACnE,MAAI,EAAE,OAAO,MAAM,SAAS,YAAY,MAAM;AAAc,WAAA;AAE5D,SAAO,MAAM,oBAAoB;AACnC;AAEO,SAAS,wBAAwB,gBAAqC;AACvE,MAAA,UAAU,kBAAkB,aAAa,gBAAgB;AAC3D,UAAM,QAAQ,IAAI,MAAM,eAAe,OAAO;AAC9C,UAAM,OAAO,eAAe;AACrB,WAAA;AAAA,EACT;AAEA,SAAO,eAAe;AACxB;"}
|
|
1
|
+
{"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport {\n AnyRoute,\n ReactNode,\n RootSearchSchema,\n StaticDataRouteOption,\n UpdatableStaticRouteOption,\n rootRouteId,\n} from './route'\nimport {\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { RegisteredRouter, RouterState } from './router'\nimport { DeepOptional, Expand, NoInfer, StrictOrFrom, pick } from './utils'\nimport {\n CatchNotFound,\n DefaultGlobalNotFound,\n NotFoundError,\n isNotFound,\n} from './not-found'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: TReturnIntersection extends false\n ? RouteById<TRouteTree, TRouteId>['types']['allParams']\n : Expand<Partial<AllParams<TRouteTree>>>\n status: 'pending' | 'success' | 'error'\n isFetching: boolean\n showPending: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: Promise<void>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: TReturnIntersection extends false\n ? Exclude<\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n RootSearchSchema\n >\n : Expand<\n Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>\n >\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n preload: boolean\n invalid: boolean\n pendingPromise?: Promise<void>\n meta?: JSX.IntrinsicElements['meta'][]\n links?: JSX.IntrinsicElements['link'][]\n scripts?: JSX.IntrinsicElements['script'][]\n notFoundError?: NotFoundError\n staticData: StaticDataRouteOption\n}\n\nexport type AnyRouteMatch = RouteMatch<any, any>\n\nexport function Matches() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return getRenderedMatches(s)[0]?.id\n },\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={ErrorComponent}\n onCatch={() => {\n warning(\n false,\n `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`,\n )\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route = router.routesById[routeId]!\n\n const PendingComponent = (route.options.pendingComponent ??\n router.options.defaultPendingComponent) as any\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ??\n router.options.defaultErrorComponent ??\n ErrorComponent\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ??\n PendingComponent ??\n route.options.component?.preload ??\n route.options.pendingComponent?.preload ??\n (route.options.errorComponent as any)?.preload\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={routeErrorComponent}\n onCatch={(error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or doesn't handle global not founds, forward it up the tree\n if (!routeNotFoundComponent || (error.global && !route.isRoot))\n throw error\n\n return React.createElement(routeNotFoundComponent, {\n data: error.data,\n })\n }}\n >\n <MatchInner matchId={matchId!} pendingElement={pendingElement} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction MatchInner({\n matchId,\n pendingElement,\n}: {\n matchId: string\n pendingElement: any\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { match } = useRouterState({\n select: (s) => ({\n match: pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n 'notFoundError',\n ]),\n }),\n })\n\n // If a global not-found is found, and it's the root route, render the global not-found component.\n if (match.notFoundError) {\n if (routeId === rootRouteId && !route.options.notFoundComponent)\n return <DefaultGlobalNotFound />\n\n invariant(\n route.options.notFoundComponent,\n 'Route matched with notFoundError should have a notFoundComponent',\n )\n\n return <route.options.notFoundComponent data={match.notFoundError} />\n }\n\n if (match.status === 'error') {\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement\n }\n throw match.loadPromise\n }\n\n if (match.status === 'success') {\n let Comp = route.options.component ?? router.options.defaultComponent\n\n if (Comp) {\n return <Comp />\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const matchId = React.useContext(matchContext)\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = getRenderedMatches(s)\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (!childMatchId) {\n return null\n }\n\n return <Match matchId={childMatchId} />\n})\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = DeepOptional<\n ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n 'search' | 'params'\n> &\n MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n useRouterState({ select: (s) => [s.location, s.resolvedLocation] })\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouteTree, 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 TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return !!params ? props.children : null\n}\n\nexport function getRenderedMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>(state: RouterState<TRouteTree>) {\n return state.pendingMatches?.some((d) => d.showPending)\n ? state.pendingMatches\n : state.matches\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TReturnIntersection extends boolean = false,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom, TReturnIntersection> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TSelected {\n const router = useRouter()\n const nearestMatchId = React.useContext(matchContext)\n\n const nearestMatchRouteId = getRenderedMatches(router.state).find(\n (d) => d.id === nearestMatchId,\n )?.routeId\n\n const matchRouteId = (() => {\n const matches = getRenderedMatches(router.state)\n const match = opts?.from\n ? matches.find((d) => d.routeId === opts?.from)\n : matches.find((d) => d.id === nearestMatchId)\n return match!.routeId\n })()\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatchRouteId == matchRouteId,\n `useMatch(\"${\n matchRouteId as string\n }\") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch(\"${\n matchRouteId as string\n }\", { strict: false })' or 'useRoute(\"${\n matchRouteId as string\n }\")' instead?`,\n )\n }\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = getRenderedMatches(state).find(\n (d) => d.id === nearestMatchId,\n )\n\n invariant(\n match,\n `Could not find ${\n opts?.from\n ? `an active match from \"${opts.from}\"`\n : 'a nearest match!'\n }`,\n )\n\n return opts?.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as any\n}\n\nexport function useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n return useRouterState({\n select: (state) => {\n const matches = getRenderedMatches(state)\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = TRouteMatch[],\n>(opts?: {\n select?: (matches: TRouteMatch[]) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(matches.findIndex((d) => d.id === contextMatchId))\n return opts?.select\n ? opts.select(matches as TRouteMatch[])\n : (matches as T)\n },\n })\n}\n\nexport function useLoaderDeps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderDeps'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderDeps)\n : s?.loaderDeps\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s?.loaderData)\n : s?.loaderData\n },\n })\n}\n\nexport function isServerSideError(error: unknown): error is {\n __isServerError: true\n data: Record<string, any>\n} {\n if (!(typeof error === 'object' && error && 'data' in error)) return false\n if (!('__isServerError' in error && error.__isServerError)) return false\n if (!(typeof error.data === 'object' && error.data)) return false\n\n return error.__isServerError === true\n}\n\nexport function defaultDeserializeError(serializedData: Record<string, any>) {\n if ('name' in serializedData && 'message' in serializedData) {\n const error = new Error(serializedData.message)\n error.name = serializedData.name\n return error\n }\n\n return serializedData.data\n}\n"],"names":["_a","Outlet"],"mappings":";;;;;;;;;;AAiCa,MAAA,eAAe,MAAM,cAAkC,MAAS;AAgDtE,SAAS,UAAU;AACxB,QAAM,SAAS;AACf,QAAM,UAAU,eAAe;AAAA,IAC7B,QAAQ,CAAC,MAAM;;AACb,cAAO,wBAAmB,CAAC,EAAE,CAAC,MAAvB,mBAA0B;AAAA,IACnC;AAAA,EAAA,CACD;AAED,SACG,oBAAA,aAAa,UAAb,EAAsB,OAAO,SAC5B,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAa,MAAA;;AAAM,4BAAO,MAAM,iBAAiB,UAA9B,mBAAqC;AAAA;AAAA,MACxD,gBAAgB;AAAA,MAChB,SAAS,MAAM;AACb;AAAA,UACE;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AAAA,MAEC,UAAU,UAAA,oBAAC,OAAM,EAAA,QAAkB,CAAA,IAAK;AAAA,IAAA;AAAA,EAE7C,EAAA,CAAA;AAEJ;AAEA,SAAS,aAAa,OAAY;AACzB,SAAA,oBAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAC3B;AAEgB,SAAA,MAAM,EAAE,WAAgC;;AACtD,QAAM,SAAS;AACf,QAAM,UAAU,eAAe;AAAA,IA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329
329
|
export type MakeMatchRouteOptions<
|
|
330
330
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
331
|
-
TFrom extends RoutePaths<TRouteTree> =
|
|
331
|
+
TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,
|
|
332
332
|
TTo extends string = '',
|
|
333
|
-
TMaskFrom extends RoutePaths<TRouteTree> =
|
|
333
|
+
TMaskFrom extends RoutePaths<TRouteTree> = TFrom,
|
|
334
334
|
TMaskTo extends string = '',
|
|
335
|
-
> =
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
335
|
+
> = UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
336
|
+
// 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
|
|
337
|
+
children?:
|
|
338
|
+
| ((
|
|
339
|
+
params?: RouteByPath<
|
|
340
|
+
TRouteTree,
|
|
341
|
+
ResolveRelativePath<TFrom, NoInfer<TTo>>
|
|
342
|
+
>['types']['allParams'],
|
|
343
|
+
) => ReactNode)
|
|
344
|
+
| React.ReactNode
|
|
345
|
+
}
|
|
347
346
|
|
|
348
347
|
export function MatchRoute<
|
|
349
348
|
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
|
|
350
|
-
TFrom extends RoutePaths<TRouteTree> =
|
|
349
|
+
TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,
|
|
351
350
|
TTo extends string = '',
|
|
352
|
-
TMaskFrom extends RoutePaths<TRouteTree> =
|
|
351
|
+
TMaskFrom extends RoutePaths<TRouteTree> = TFrom,
|
|
353
352
|
TMaskTo extends string = '',
|
|
354
353
|
>(
|
|
355
354
|
props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,
|