@tanstack/react-router 0.0.1-beta.274 → 0.0.1-beta.275

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.
@@ -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 { useRouter, useRouterState } from './RouterProvider'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport { AnyRoute, ReactNode, rootRouteId } from './route'\nimport {\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { RegisteredRouter, RouterState } from './router'\nimport { NoInfer, StrictOrFrom, pick } from './utils'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = AnyRoute,\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: RouteById<TRouteTree, TRouteId>['types']['allParams']\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: FullSearchSchema<TRouteTree> &\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema']\n fetchCount: number\n shouldReloadDeps: any\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n}\n\nexport type AnyRouteMatch = RouteMatch<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 routeErrorComponent =\n route.options.errorComponent ??\n router.options.defaultErrorComponent ??\n ErrorComponent\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 return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={PendingComponent}>\n <ResolvedCatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={routeErrorComponent}\n onCatch={() => {\n warning(false, `Error in route match: ${matchId}`)\n }}\n >\n <MatchInner matchId={matchId!} pendingElement={PendingComponent} />\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 pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n ]),\n })\n\n if (match.status === 'error') {\n throw match.error\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement || null\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> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = ToOptions<AnyRoute, TFrom, TTo, TMaskFrom, TMaskTo> & MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\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, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\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\nfunction getRenderedMatches(state: RouterState) {\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 TStrict extends boolean = true,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TStrict extends true ? TSelected : TSelected | undefined {\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<T = RouteMatch[]>(opts?: {\n select?: (matches: RouteMatch[]) => T\n}): T {\n return useRouterState({\n select: (state) => {\n let matches = getRenderedMatches(state)\n return opts?.select ? opts.select(matches) : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<T = RouteMatch[]>(opts?: {\n select?: (matches: RouteMatch[]) => T\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 ? opts.select(matches) : (matches as T)\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\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): TStrict extends true ? TSelected : TSelected | undefined {\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"],"names":["matchContext","React","createContext","undefined","Matches","router","useRouter","matchId","useRouterState","select","s","getRenderedMatches","id","createElement","Provider","value","CatchBoundary","getResetKey","state","resolvedLocation","key","errorComponent","ErrorComponent","onCatch","warning","Match","SafeFragment","props","Fragment","children","routeId","find","d","invariant","route","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","defaultErrorComponent","ResolvedSuspenseBoundary","wrapInSuspense","component","preload","Suspense","ResolvedCatchBoundary","fallback","MatchInner","pendingElement","match","pick","status","error","showPending","loadPromise","Comp","defaultComponent","Outlet","memo","useContext","childMatchId","matches","index","findIndex","useMatchRoute","matchRoute","useCallback","opts","pending","caseSensitive","rest","MatchRoute","params","pendingMatches","some","useMatch","nearestMatchId","nearestMatchRouteId","matchRouteId","from","strict","matchSelection","useMatches","useParentMatches","contextMatchId","slice","useLoaderData","loaderData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,MAAMA,YAAY,gBAAGC,gBAAK,CAACC,aAAa,CAAqBC,SAAS,EAAC;AA+BvE,SAASC,OAAOA,GAAG;AACxB,EAAA,MAAMC,MAAM,GAAGC,wBAAS,EAAE,CAAA;EAC1B,MAAMC,OAAO,GAAGC,6BAAc,CAAC;IAC7BC,MAAM,EAAGC,CAAC,IAAK;MACb,OAAOC,kBAAkB,CAACD,CAAC,CAAC,CAAC,CAAC,CAAC,EAAEE,EAAE,CAAA;AACrC,KAAA;AACF,GAAC,CAAC,CAAA;AAEF,EAAA,oBACEX,gBAAA,CAAAY,aAAA,CAACb,YAAY,CAACc,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAER,OAAAA;AAAQ,GAAA,eACpCN,gBAAA,CAAAY,aAAA,CAACG,2BAAa,EAAA;IACZC,WAAW,EAAEA,MAAMZ,MAAM,CAACa,KAAK,CAACC,gBAAgB,CAACD,KAAK,EAAEE,GAAI;AAC5DC,IAAAA,cAAc,EAAEC,4BAAe;IAC/BC,O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CAAmBhB,IAElD,EAAK;AACJ,EAAA,MAAMiB,cAAc,GAAGrF,gBAAK,CAAC4D,UAAU,CAAC7D,YAAY,CAAC,CAAA;AAErD,EAAA,OAAOoF,UAAU,CAAC;IAChB3E,MAAM,EAAGsD,OAAO,IAAK;AACnBA,MAAAA,OAAO,GAAGA,OAAO,CAACwB,KAAK,CAACxB,OAAO,CAACE,SAAS,CAAEjC,CAAC,IAAKA,CAAC,CAACpB,EAAE,KAAK0E,cAAc,CAAC,CAAC,CAAA;MAC1E,OAAOjB,IAAI,EAAE5D,MAAM,GAAG4D,IAAI,CAAC5D,MAAM,CAACsD,OAAO,CAAC,GAAIA,OAAa,CAAA;AAC7D,KAAA;AACF,GAAC,CAAC,CAAA;AACJ,CAAA;AAEO,SAASyB,aAAaA,CAU3BnB,IAEC,EACyD;AAC1D,EAAA,OAAOQ,QAAQ,CAAC;AACd,IAAA,GAAGR,IAAI;IACP5D,MAAM,EAAGC,CAAC,IAAK;AACb,MAAA,OAAO,OAAO2D,IAAI,CAAC5D,MAAM,KAAK,UAAU,GACpC4D,IAAI,CAAC5D,MAAM,CAACC,CAAC,EAAE+E,UAAU,CAAC,GAC1B/E,CAAC,EAAE+E,UAAU,CAAA;AACnB,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;;;;;;;;;;"}
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 { useRouter, useRouterState } from './RouterProvider'\nimport { ResolveRelativePath, ToOptions } from './link'\nimport { AnyRoute, ReactNode, rootRouteId } from './route'\nimport {\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport { RegisteredRouter, RouterState } from './router'\nimport { NoInfer, StrictOrFrom, pick } from './utils'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = AnyRoute,\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: RouteById<TRouteTree, TRouteId>['types']['allParams']\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: FullSearchSchema<TRouteTree> &\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema']\n fetchCount: number\n shouldReloadDeps: any\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\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 routeErrorComponent =\n route.options.errorComponent ??\n router.options.defaultErrorComponent ??\n ErrorComponent\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 return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={PendingComponent}>\n <ResolvedCatchBoundary\n getResetKey={() => router.state.resolvedLocation.state?.key}\n errorComponent={routeErrorComponent}\n onCatch={() => {\n warning(false, `Error in route match: ${matchId}`)\n }}\n >\n <MatchInner matchId={matchId!} pendingElement={PendingComponent} />\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 pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n ]),\n })\n\n if (match.status === 'error') {\n throw match.error\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement || null\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> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = ToOptions<AnyRoute, TFrom, TTo, TMaskFrom, TMaskTo> & MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n const { matchRoute } = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\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, ...rest } = opts\n\n return matchRoute(rest as any, {\n pending,\n caseSensitive,\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\nfunction getRenderedMatches(state: RouterState) {\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 TStrict extends boolean = true,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TStrict extends true ? TSelected : TSelected | undefined {\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<T = RouteMatch[]>(opts?: {\n select?: (matches: RouteMatch[]) => T\n}): T {\n return useRouterState({\n select: (state) => {\n let matches = getRenderedMatches(state)\n return opts?.select ? opts.select(matches) : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<T = RouteMatch[]>(opts?: {\n select?: (matches: RouteMatch[]) => T\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 ? opts.select(matches) : (matches as T)\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\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): TStrict extends true ? TSelected : TSelected | undefined {\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"],"names":["matchContext","React","createContext","undefined","Matches","router","useRouter","matchId","useRouterState","select","s","getRenderedMatches","id","createElement","Provider","value","CatchBoundary","getResetKey","state","resolvedLocation","key","errorComponent","ErrorComponent","onCatch","warning","Match","SafeFragment","props","Fragment","children","routeId","find","d","invariant","route","routesById","PendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","defaultErrorComponent","ResolvedSuspenseBoundary","wrapInSuspense","component","preload","Suspense","ResolvedCatchBoundary","fallback","MatchInner","pendingElement","match","pick","status","error","showPending","loadPromise","Comp","defaultComponent","Outlet","memo","useContext","childMatchId","matches","index","findIndex","useMatchRoute","matchRoute","useCallback","opts","pending","caseSensitive","rest","MatchRoute","params","pendingMatches","some","useMatch","nearestMatchId","nearestMatchRouteId","matchRouteId","from","strict","mat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,EACyD;AAC1D,EAAA,OAAOQ,QAAQ,CAAC;AACd,IAAA,GAAGR,IAAI;IACP5D,MAAM,EAAGC,CAAC,IAAK;AACb,MAAA,OAAO,OAAO2D,IAAI,CAAC5D,MAAM,KAAK,UAAU,GACpC4D,IAAI,CAAC5D,MAAM,CAACC,CAAC,EAAE+E,UAAU,CAAC,GAC1B/E,CAAC,EAAE+E,UAAU,CAAA;AACnB,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import { ParsePathParams } from './link'\nimport {\n AnyRoute,\n ResolveFullPath,\n ResolveFullSearchSchema,\n MergeFromFromParent,\n RouteContext,\n AnyContext,\n RouteOptions,\n UpdatableRouteOptions,\n Route,\n AnyPathParams,\n RootRouteId,\n TrimPathLeft,\n RouteConstraints,\n} from './route'\nimport { Assign, Expand, IsAny } from './utils'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n S extends string,\n From extends string,\n To extends string,\n> = S extends `${infer Start}${From}${infer Rest}`\n ? `${Start}${To}${Replace<Rest, From, To>}`\n : S\n\nexport type TrimLeft<\n T extends string,\n S extends string,\n> = T extends `${S}${infer U}` ? U : T\n\nexport type TrimRight<\n T extends string,\n S extends string,\n> = T extends `${infer U}${S}` ? U : T\n\nexport type Trim<T extends string, S extends string> = TrimLeft<\n TrimRight<T, S>,\n S\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : Replace<\n TrimPathLeft<TFilePath>,\n TrimPathLeft<TParentRoute['types']['customId']>,\n ''\n >\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`\n ? string\n : ResolveFilePath<TParentRoute, TFilePath>\n\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = TFilePath,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n RemoveUnderScores<TPath>\n >,\n> {\n constructor(public path: TFilePath) {}\n\n createRoute = <\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = MergeFromFromParent<\n TParentRoute['types']['allParams'],\n TParams\n >,\n TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,\n TContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n >(\n options?: Omit<\n RouteOptions<\n TParentRoute,\n string,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TContext,\n TLoaderData\n >,\n 'getParentRoute' | 'path' | 'id'\n > &\n UpdatableRouteOptions<TFullSearchSchema>,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TContext,\n TRouterContext,\n TLoaderData,\n TChildren,\n TRouteTree\n > => {\n const route = new Route(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n"],"names":["FileRoute","constructor","path","createRoute","options","route","Route","isRoot"],"mappings":";;;;;;;;;;;;;;AAuEO,MAAMA,SAAS,CAYpB;EACAC,WAAWA,CAAQC,IAAe,EAAE;IAAA,IAAjBA,CAAAA,IAAe,GAAfA,IAAe,CAAA;AAAG,GAAA;EAErCC,WAAW,GAyBTC,OAe0C,IAiBvC;AACH,IAAA,MAAMC,OAAK,GAAG,IAAIC,WAAK,CAACF,OAAc,CAAC,CAAA;IACrCC,OAAK,CAASE,MAAM,GAAG,KAAK,CAAA;AAC9B,IAAA,OAAOF,OAAK,CAAA;GACb,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import { ParsePathParams } from './link'\nimport {\n AnyRoute,\n ResolveFullPath,\n ResolveFullSearchSchema,\n MergeFromFromParent,\n RouteContext,\n AnyContext,\n RouteOptions,\n UpdatableRouteOptions,\n Route,\n AnyPathParams,\n RootRouteId,\n TrimPathLeft,\n RouteConstraints,\n} from './route'\nimport { Assign, Expand, IsAny } from './utils'\n\nexport interface FileRoutesByPath {\n // '/': {\n // parentRoute: typeof rootRoute\n // }\n}\n\ntype Replace<\n S extends string,\n From extends string,\n To extends string,\n> = S extends `${infer Start}${From}${infer Rest}`\n ? `${Start}${To}${Replace<Rest, From, To>}`\n : S\n\nexport type TrimLeft<\n T extends string,\n S extends string,\n> = T extends `${S}${infer U}` ? U : T\n\nexport type TrimRight<\n T extends string,\n S extends string,\n> = T extends `${infer U}${S}` ? U : T\n\nexport type Trim<T extends string, S extends string> = TrimLeft<\n TrimRight<T, S>,\n S\n>\n\nexport type RemoveUnderScores<T extends string> = Replace<\n Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>,\n '/_',\n '/'\n>\n\nexport type ResolveFilePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = TParentRoute['id'] extends RootRouteId\n ? TrimPathLeft<TFilePath>\n : Replace<\n TrimPathLeft<TFilePath>,\n TrimPathLeft<TParentRoute['types']['customId']>,\n ''\n >\n\nexport type FileRoutePath<\n TParentRoute extends AnyRoute,\n TFilePath extends string,\n> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}`\n ? string\n : ResolveFilePath<TParentRoute, TFilePath>\n\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = TFilePath,\n TPath extends RouteConstraints['TPath'] = FileRoutePath<\n TParentRoute,\n TFilePath\n >,\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n RemoveUnderScores<TPath>\n >,\n> {\n constructor(public path: TFilePath) {}\n\n createRoute = <\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = MergeFromFromParent<\n TParentRoute['types']['allParams'],\n TParams\n >,\n TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,\n TContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n >(\n options?: Omit<\n RouteOptions<\n TParentRoute,\n string,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TContext,\n TLoaderDeps,\n TLoaderData\n >,\n 'getParentRoute' | 'path' | 'id'\n > &\n UpdatableRouteOptions<TFullSearchSchema>,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData,\n TChildren,\n TRouteTree\n > => {\n const route = new Route(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n"],"names":["FileRoute","constructor","path","createRoute","options","route","Route","isRoot"],"mappings":";;;;;;;;;;;;;;AAuEO,MAAMA,SAAS,CAYpB;EACAC,WAAWA,CAAQC,IAAe,EAAE;IAAA,IAAjBA,CAAAA,IAAe,GAAfA,IAAe,CAAA;AAAG,GAAA;EAErCC,WAAW,GA0BTC,OAgB0C,IAkBvC;AACH,IAAA,MAAMC,OAAK,GAAG,IAAIC,WAAK,CAACF,OAAc,CAAC,CAAA;IACrCC,OAAK,CAASE,MAAM,GAAG,KAAK,CAAA;AAC9B,IAAA,OAAOF,OAAK,CAAA;GACb,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"redirects.js","sources":["../../src/redirects.ts"],"sourcesContent":["import { NavigateOptions } from './link'\nimport { AnyRoute } from './route'\nimport { RoutePaths } from './routeInfo'\nimport { RegisteredRouter } from './router'\n\n// Detect if we're in the DOM\n\nexport type AnyRedirect = Redirect<any, any, any>\n\nexport type Redirect<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = {\n code?: number\n throw?: any\n} & NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport function redirect<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n opts: Redirect<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Redirect<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> {\n ;(opts as any).isRedirect = true\n if (opts.throw) {\n throw opts\n }\n return opts\n}\n\nexport function isRedirect(obj: any): obj is AnyRedirect {\n return !!obj?.isRedirect\n}\n"],"names":["redirect","opts","isRedirect","throw","obj"],"mappings":";;;;;;;;;;;;AAKA;;AAeO,SAASA,QAAQA,CAOtBC,IAA0D,EACJ;EACpDA,IAAI,CAASC,UAAU,GAAG,IAAI,CAAA;EAChC,IAAID,IAAI,CAACE,KAAK,EAAE;AACd,IAAA,MAAMF,IAAI,CAAA;AACZ,GAAA;AACA,EAAA,OAAOA,IAAI,CAAA;AACb,CAAA;AAEO,SAASC,UAAUA,CAACE,GAAQ,EAAsB;AACvD,EAAA,OAAO,CAAC,CAACA,GAAG,EAAEF,UAAU,CAAA;AAC1B;;;;;"}
1
+ {"version":3,"file":"redirects.js","sources":["../../src/redirects.ts"],"sourcesContent":["import { NavigateOptions } from './link'\nimport { AnyRoute } from './route'\nimport { RoutePaths } from './routeInfo'\nimport { RegisteredRouter } from './router'\n\n// Detect if we're in the DOM\n\nexport type AnyRedirect = Redirect<any, any, any, any, any>\n\nexport type Redirect<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = {\n code?: number\n throw?: any\n} & NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport function redirect<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n opts: Redirect<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Redirect<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> {\n ;(opts as any).isRedirect = true\n if (opts.throw) {\n throw opts\n }\n return opts\n}\n\nexport function isRedirect(obj: any): obj is AnyRedirect {\n return !!obj?.isRedirect\n}\n"],"names":["redirect","opts","isRedirect","throw","obj"],"mappings":";;;;;;;;;;;;AAKA;;AAeO,SAASA,QAAQA,CAOtBC,IAA0D,EACJ;EACpDA,IAAI,CAASC,UAAU,GAAG,IAAI,CAAA;EAChC,IAAID,IAAI,CAACE,KAAK,EAAE;AACd,IAAA,MAAMF,IAAI,CAAA;AACZ,GAAA;AACA,EAAA,OAAOA,IAAI,CAAA;AACb,CAAA;AAEO,SAASC,UAAUA,CAACE,GAAQ,EAAsB;AACvD,EAAA,OAAO,CAAC,CAACA,GAAG,EAAEF,UAAU,CAAA;AAC1B;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sources":["../../src/route.ts"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport { useLoaderData, useMatch } from './Matches'\nimport { AnyRouteMatch } from './Matches'\nimport { NavigateOptions, ParsePathParams, ToSubOptions } from './link'\nimport { ParsedLocation } from './location'\nimport { joinPaths, trimPath } from './path'\nimport { RouteById, RouteIds, RoutePaths } from './routeInfo'\nimport { AnyRouter, RegisteredRouter } from './router'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport {\n Assign,\n Expand,\n IsAny,\n NoInfer,\n PickRequired,\n UnionToIntersection,\n} from './utils'\nimport { BuildLocationFn, NavigateFn } from './RouterProvider'\n\nexport const rootRouteId = '__root__' as const\nexport type RootRouteId = typeof rootRouteId\nexport type AnyPathParams = {}\n\nexport type AnySearchSchema = {}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport interface RouteMeta {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> =\n UnionToIntersection<RoutePathOptions<TCustomId, TPath>>\n\nexport type MetaOptions = keyof PickRequired<RouteMeta> extends never\n ? {\n meta?: RouteMeta\n }\n : {\n meta: RouteMeta\n }\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchema extends Record<string, any> = {},\n TFullSearchSchema extends Record<string, any> = TSearchSchema,\n TParams extends AnyPathParams = AnyPathParams,\n TAllParams extends AnyPathParams = TParams,\n TRouteContext extends RouteContext = RouteContext,\n TAllContext extends Record<string, any> = AnyContext,\n TLoaderData extends any = unknown,\n> = BaseRouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TLoaderData\n> &\n UpdatableRouteOptions<NoInfer<TFullSearchSchema>>\n\nexport type ParamsFallback<\n TPath extends string,\n TParams,\n> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams\n\ntype Prefix<T extends string, U extends string> = U extends `${T}${infer _}`\n ? U\n : never\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchema extends Record<string, any> = {},\n TFullSearchSchema extends Record<string, any> = TSearchSchema,\n TParams extends AnyPathParams = {},\n TAllParams = ParamsFallback<TPath, TParams>,\n TRouteContext extends RouteContext = RouteContext,\n TAllContext extends Record<string, any> = AnyContext,\n TLoaderData extends any = unknown,\n> = RoutePathOptions<TCustomId, TPath> & {\n getParentRoute: () => TParentRoute\n validateSearch?: SearchSchemaValidator<TSearchSchema>\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<\n TAllParams,\n TFullSearchSchema,\n TAllContext,\n TRouteContext\n >,\n ) => any)\n} & (keyof PickRequired<RouteContext> extends never\n ? // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n {\n beforeLoad?: BeforeLoadFn<\n TFullSearchSchema,\n TParentRoute,\n TAllParams,\n TRouteContext\n >\n }\n : {\n beforeLoad: BeforeLoadFn<\n TFullSearchSchema,\n TParentRoute,\n TAllParams,\n TRouteContext\n >\n }) & {\n key?: (opts: { search: TFullSearchSchema; location: ParsedLocation }) => any\n loader?: RouteLoaderFn<\n TAllParams,\n TFullSearchSchema,\n NoInfer<TAllContext>,\n NoInfer<TRouteContext>,\n TLoaderData\n >\n } & (\n | {\n // Both or none\n parseParams?: (\n rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,\n ) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : 'parseParams must return an object'\n stringifyParams?: (\n params: NoInfer<ParamsFallback<TPath, TParams>>,\n ) => Record<ParsePathParams<TPath>, string>\n }\n | {\n stringifyParams?: never\n parseParams?: never\n }\n )\n\ntype BeforeLoadFn<\n TFullSearchSchema extends Record<string, any>,\n TParentRoute extends AnyRoute,\n TAllParams,\n TRouteContext,\n> = (opts: {\n search: TFullSearchSchema\n abortController: AbortController\n preload: boolean\n params: TAllParams\n context: TParentRoute['types']['allContext']\n location: ParsedLocation\n navigate: NavigateFn<AnyRoute>\n buildLocation: BuildLocationFn<AnyRoute>\n cause: 'preload' | 'enter' | 'stay'\n}) => Promise<TRouteContext> | TRouteContext | void\n\nexport type UpdatableRouteOptions<\n TFullSearchSchema extends Record<string, any>,\n> = MetaOptions & {\n // test?: (args: TAllContext) => void\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n pendingComponent?: RouteComponent\n pendingMs?: number\n pendingMinMs?: number\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: SearchFilter<TFullSearchSchema>[]\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: SearchFilter<TFullSearchSchema>[]\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (match: AnyRouteMatch) => void\n onStay?: (match: AnyRouteMatch) => void\n onLeave?: (match: AnyRouteMatch) => void\n}\n\nexport type ParseParamsOption<TPath extends string, TParams> = ParseParamsFn<\n TPath,\n TParams\n>\n\nexport type ParseParamsFn<TPath extends string, TParams> = (\n rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : 'parseParams must return an object'\n\nexport type ParseParamsObj<TPath extends string, TParams> = {\n parse?: ParseParamsFn<TPath, TParams>\n}\n\n// The parse type here allows a zod schema to be passed directly to the validator\nexport type SearchSchemaValidator<TReturn> =\n | SearchSchemaValidatorObj<TReturn>\n | SearchSchemaValidatorFn<TReturn>\n\nexport type SearchSchemaValidatorObj<TReturn> = {\n parse?: SearchSchemaValidatorFn<TReturn>\n}\n\nexport type SearchSchemaValidatorFn<TReturn> = (\n searchObj: Record<string, unknown>,\n) => TReturn\n\nexport type DefinedPathParamWarning =\n 'Path params cannot be redefined by child routes!'\n\nexport type ParentParams<TParentParams> = AnyPathParams extends TParentParams\n ? {}\n : {\n [Key in keyof TParentParams]?: DefinedPathParamWarning\n }\n\nexport type RouteLoaderFn<\n TAllParams = {},\n TFullSearchSchema extends Record<string, any> = {},\n TAllContext extends Record<string, any> = AnyContext,\n TRouteContext extends Record<string, any> = AnyContext,\n TLoaderData extends any = unknown,\n> = (\n match: LoaderFnContext<\n TAllParams,\n TFullSearchSchema,\n TAllContext,\n TRouteContext\n >,\n) => Promise<TLoaderData> | TLoaderData\n\nexport interface LoaderFnContext<\n TAllParams = {},\n TFullSearchSchema extends Record<string, any> = {},\n TAllContext extends Record<string, any> = AnyContext,\n TRouteContext extends Record<string, any> = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: TAllParams\n search: TFullSearchSchema\n context: Expand<Assign<TAllContext, TRouteContext>>\n location: ParsedLocation<TFullSearchSchema>\n navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>\n parentMatchPromise?: Promise<void>\n cause: 'preload' | 'enter' | 'stay'\n}\n\nexport type SearchFilter<T, U = T> = (prev: T) => U\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<\n Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>\n>\n\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type MergeFromFromParent<T, U> = IsAny<T, U, T & U>\n\nexport type ResolveAllParams<\n TParentRoute extends AnyRoute,\n TParams extends AnyPathParams,\n> = Record<never, string> extends TParentRoute['types']['allParams']\n ? TParams\n : Expand<\n UnionToIntersection<TParentRoute['types']['allParams'] & TParams> & {}\n >\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySearchSchema\n TFullSearchSchema: AnySearchSchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport class RouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,\n TFullSearchSchema extends Record<\n string,\n any\n > = TRoute['types']['fullSearchSchema'],\n TAllParams extends AnyPathParams = TRoute['types']['allParams'],\n TAllContext extends Record<string, any> = TRoute['types']['allContext'],\n TLoaderData extends any = TRoute['types']['loaderData'],\n> {\n id: TId\n\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch = <TSelected = TAllContext>(opts?: {\n select?: (search: TAllContext) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id }) as any\n }\n\n useRouteContext = <TSelected = TAllContext>(opts?: {\n select?: (search: TAllContext) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n } as any)\n }\n\n useSearch = <TSelected = TFullSearchSchema>(opts?: {\n select?: (search: TFullSearchSchema) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id } as any)\n }\n\n useParams = <TSelected = TAllParams>(opts?: {\n select?: (search: TAllParams) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (search: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any) as any\n }\n}\n\nexport class Route<\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = ResolveAllParams<\n TParentRoute,\n TParams\n >,\n TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,\n TAllContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n> {\n isRoot: TParentRoute extends Route<any> ? true : false\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TLoaderData\n >\n\n test!: Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >\n\n // Set up in this.init()\n parentRoute!: TParentRoute\n id!: TId\n // customId!: TCustomId\n path!: TPath\n fullPath!: TFullPath\n to!: TrimPathRight<TFullPath>\n\n // Optional\n children?: TChildren\n originalIndex?: number\n router?: AnyRouter\n rank!: number\n\n constructor(\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TLoaderData\n >,\n ) {\n this.options = (options as any) || {}\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n types!: {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: TSearchSchema\n fullSearchSchema: TFullSearchSchema\n params: TParams\n allParams: TAllParams\n routeContext: TRouteContext\n allContext: TAllContext\n children: TChildren\n routeTree: TRouteTree\n routerContext: TRouterContext\n loaderData: TLoaderData\n }\n\n init = (opts: { originalIndex: number }) => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TLoaderData\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>\n\n const isRoot = !options?.path && !options?.id\n\n this.parentRoute = this.options?.getParentRoute?.()\n\n if (isRoot) {\n this.path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPath(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n (this.parentRoute.id as any) === rootRouteId\n ? ''\n : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this.path = path as TPath\n this.id = id as TId\n // this.customId = customId as TCustomId\n this.fullPath = fullPath as TFullPath\n this.to = fullPath as TrimPathRight<TFullPath>\n }\n\n addChildren = <TNewChildren extends AnyRoute[]>(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TRouterContext,\n TNewChildren,\n TRouteTree\n > => {\n this.children = children as any\n return this as any\n }\n\n update = (options: UpdatableRouteOptions<TFullSearchSchema>) => {\n Object.assign(this.options, options)\n return this\n }\n\n useMatch = <TSelected = TAllContext>(opts?: {\n select?: (search: TAllContext) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id }) as any\n }\n\n useRouteContext = <TSelected = TAllContext>(opts?: {\n select?: (search: TAllContext) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n } as any)\n }\n\n useSearch = <TSelected = TFullSearchSchema>(opts?: {\n select?: (search: TFullSearchSchema) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id } as any)\n }\n\n useParams = <TSelected = TAllParams>(opts?: {\n select?: (search: TAllParams) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (search: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any) as any\n }\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any>\n\nexport function rootRouteWithContext<TRouterContext extends {}>() {\n return <\n TSearchSchema extends Record<string, any> = {},\n TRouteContext extends RouteContext = RouteContext,\n TLoaderData extends any = unknown,\n >(\n options?: Omit<\n RouteOptions<\n AnyRoute, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContext, // TRouteContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderData // TLoaderData\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n >,\n ): RootRoute<TSearchSchema, TRouteContext, TRouterContext> => {\n return new RootRoute(options) as any\n }\n}\n\nexport class RootRoute<\n TSearchSchema extends Record<string, any> = {},\n TRouteContext extends RouteContext = RouteContext,\n TRouterContext extends {} = {},\n TLoaderData extends any = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContext, // TRouteContext\n Expand<Assign<TRouterContext, TRouteContext>>, // TAllContext\n TRouterContext, // TRouterContext\n TLoaderData,\n any, // TChildren\n any // TRouteTree\n> {\n constructor(\n options?: Omit<\n RouteOptions<\n AnyRoute, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContext, // TRouteContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderData\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n >,\n ) {\n super(options as any)\n }\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\ntype RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends RoutePaths<TRouteTree>,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToSubOptions<TRouteTree, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport type ErrorRouteProps = {\n error: unknown\n info: { componentStack: string }\n}\n//\n\nexport type ReactNode = any\n\nexport type SyncRouteComponent<TProps> =\n | ((props: TProps) => ReactNode)\n | React.LazyExoticComponent<(props: TProps) => ReactNode>\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = SyncRouteComponent<TProps> &\n AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,\n TAllContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchSchema,\n TFullSearchSchema,\n {},\n {},\n TRouteContext,\n TAllContext,\n TRouterContext,\n TLoaderData,\n TChildren,\n TRouteTree\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n TSearchSchema,\n TFullSearchSchema,\n {},\n {},\n TRouteContext,\n TAllContext,\n TLoaderData\n >,\n 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"names":["rootRouteId","RouteApi","constructor","id","useMatch","opts","from","useRouteContext","select","d","context","useSearch","useParams","useLoaderData","Route","options","isRoot","getParentRoute","invariant","path","$$typeof","Symbol","for","init","originalIndex","parentRoute","trimPath","customId","joinPaths","fullPath","to","addChildren","children","update","Object","assign","rootRouteWithContext","RootRoute","createRouteMask","NotFoundRoute"],"mappings":";;;;;;;;;;;;;;;;;;AAqBO,MAAMA,WAAW,GAAG,WAAmB;;AAsM9C;;AA2HO,MAAMC,QAAQ,CAUnB;AAGAC,EAAAA,WAAWA,CAAC;AAAEC,IAAAA,EAAAA;AAAgB,GAAC,EAAE;IAC/B,IAAI,CAACA,EAAE,GAAGA,EAAS,CAAA;AACrB,GAAA;EAEAC,QAAQ,GAA6BC,IAEpC,IAAgB;AACf,IAAA,OAAOD,gBAAQ,CAAC;AAAE,MAAA,GAAGC,IAAI;MAAEC,IAAI,EAAE,IAAI,CAACH,EAAAA;AAAG,KAAC,CAAC,CAAA;GAC5C,CAAA;EAEDI,eAAe,GAA6BF,IAE3C,IAAgB;AACf,IAAA,OAAOD,gBAAQ,CAAC;AACd,MAAA,GAAGC,IAAI;MACPC,IAAI,EAAE,IAAI,CAACH,EAAE;AACbK,MAAAA,MAAM,EAAGC,CAAM,IAAMJ,IAAI,EAAEG,MAAM,GAAGH,IAAI,CAACG,MAAM,CAACC,CAAC,CAACC,OAAO,CAAC,GAAGD,CAAC,CAACC,OAAAA;AACjE,KAAQ,CAAC,CAAA;GACV,CAAA;EAEDC,SAAS,GAAmCN,IAE3C,IAAgB;AACf,IAAA,OAAOM,mBAAS,CAAC;AAAE,MAAA,GAAGN,IAAI;MAAEC,IAAI,EAAE,IAAI,CAACH,EAAAA;AAAG,KAAQ,CAAC,CAAA;GACpD,CAAA;EAEDS,SAAS,GAA4BP,IAEpC,IAAgB;AACf,IAAA,OAAOO,mBAAS,CAAC;AAAE,MAAA,GAAGP,IAAI;MAA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CAgBb;EACAZ,WAAWA,CACTa,OAmBC,EACD;IACA,KAAK,CAACA,OAAc,CAAC,CAAA;AACvB,GAAA;AACF,CAAA;AAkDO,SAASuB,eAAeA,CAK7BjC,IAEwC,EACjB;AACvB,EAAA,OAAOA,IAAI,CAAA;AACb,CAAA;;AAMA;;AAiBO,MAAMkC,aAAa,SAkBhBzB,KAAK,CAgBb;EACAZ,WAAWA,CACTa,OAcC,EACD;AACA,IAAA,KAAK,CAAC;AACJ,MAAA,GAAIA,OAAe;AACnBZ,MAAAA,EAAE,EAAE,KAAA;AACN,KAAC,CAAC,CAAA;AACJ,GAAA;AACF;;;;;;;;;;"}
1
+ {"version":3,"file":"route.js","sources":["../../src/route.ts"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport { useLoaderData, useMatch } from './Matches'\nimport { AnyRouteMatch } from './Matches'\nimport { NavigateOptions, ParsePathParams, ToSubOptions } from './link'\nimport { ParsedLocation } from './location'\nimport { joinPaths, trimPath } from './path'\nimport { RouteById, RouteIds, RoutePaths } from './routeInfo'\nimport { AnyRouter, RegisteredRouter } from './router'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport {\n Assign,\n Expand,\n IsAny,\n NoInfer,\n PickRequired,\n UnionToIntersection,\n} from './utils'\nimport { BuildLocationFn, NavigateFn } from './RouterProvider'\n\nexport const rootRouteId = '__root__' as const\nexport type RootRouteId = typeof rootRouteId\nexport type AnyPathParams = {}\n\nexport type AnySearchSchema = {}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport interface RouteMeta {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> =\n UnionToIntersection<RoutePathOptions<TCustomId, TPath>>\n\nexport type MetaOptions = keyof PickRequired<RouteMeta> extends never\n ? {\n meta?: RouteMeta\n }\n : {\n meta: RouteMeta\n }\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchema extends Record<string, any> = {},\n TFullSearchSchema extends Record<string, any> = TSearchSchema,\n TParams extends AnyPathParams = AnyPathParams,\n TAllParams extends AnyPathParams = TParams,\n TRouteContext extends RouteContext = RouteContext,\n TAllContext extends Record<string, any> = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n> = BaseRouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n> &\n UpdatableRouteOptions<NoInfer<TFullSearchSchema>>\n\nexport type ParamsFallback<\n TPath extends string,\n TParams,\n> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchSchema extends Record<string, any> = {},\n TFullSearchSchema extends Record<string, any> = TSearchSchema,\n TParams extends AnyPathParams = {},\n TAllParams = ParamsFallback<TPath, TParams>,\n TRouteContext extends RouteContext = RouteContext,\n TAllContext extends Record<string, any> = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n> = RoutePathOptions<TCustomId, TPath> & {\n getParentRoute: () => TParentRoute\n validateSearch?: SearchSchemaValidator<TSearchSchema>\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<\n TAllParams,\n TFullSearchSchema,\n TAllContext,\n TRouteContext\n >,\n ) => any)\n} & (keyof PickRequired<RouteContext> extends never\n ? // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n {\n beforeLoad?: BeforeLoadFn<\n TFullSearchSchema,\n TParentRoute,\n TAllParams,\n TRouteContext\n >\n }\n : {\n beforeLoad: BeforeLoadFn<\n TFullSearchSchema,\n TParentRoute,\n TAllParams,\n TRouteContext\n >\n }) & {\n loaderDeps?: (opts: { search: TFullSearchSchema }) => TLoaderDeps\n loader?: RouteLoaderFn<\n TAllParams,\n NoInfer<TLoaderDeps>,\n NoInfer<TAllContext>,\n NoInfer<TRouteContext>,\n TLoaderData\n >\n } & (\n | {\n // Both or none\n parseParams?: (\n rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,\n ) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : 'parseParams must return an object'\n stringifyParams?: (\n params: NoInfer<ParamsFallback<TPath, TParams>>,\n ) => Record<ParsePathParams<TPath>, string>\n }\n | {\n stringifyParams?: never\n parseParams?: never\n }\n )\n\ntype BeforeLoadFn<\n TFullSearchSchema extends Record<string, any>,\n TParentRoute extends AnyRoute,\n TAllParams,\n TRouteContext,\n> = (opts: {\n search: TFullSearchSchema\n abortController: AbortController\n preload: boolean\n params: TAllParams\n context: TParentRoute['types']['allContext']\n location: ParsedLocation\n navigate: NavigateFn<AnyRoute>\n buildLocation: BuildLocationFn<AnyRoute>\n cause: 'preload' | 'enter' | 'stay'\n}) => Promise<TRouteContext> | TRouteContext | void\n\nexport type UpdatableRouteOptions<\n TFullSearchSchema extends Record<string, any>,\n> = MetaOptions & {\n // test?: (args: TAllContext) => void\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n pendingComponent?: RouteComponent\n pendingMs?: number\n pendingMinMs?: number\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: SearchFilter<TFullSearchSchema>[]\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: SearchFilter<TFullSearchSchema>[]\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (match: AnyRouteMatch) => void\n onStay?: (match: AnyRouteMatch) => void\n onLeave?: (match: AnyRouteMatch) => void\n}\n\nexport type ParseParamsOption<TPath extends string, TParams> = ParseParamsFn<\n TPath,\n TParams\n>\n\nexport type ParseParamsFn<TPath extends string, TParams> = (\n rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : 'parseParams must return an object'\n\nexport type ParseParamsObj<TPath extends string, TParams> = {\n parse?: ParseParamsFn<TPath, TParams>\n}\n\n// The parse type here allows a zod schema to be passed directly to the validator\nexport type SearchSchemaValidator<TReturn> =\n | SearchSchemaValidatorObj<TReturn>\n | SearchSchemaValidatorFn<TReturn>\n\nexport type SearchSchemaValidatorObj<TReturn> = {\n parse?: SearchSchemaValidatorFn<TReturn>\n}\n\nexport type SearchSchemaValidatorFn<TReturn> = (\n searchObj: Record<string, unknown>,\n) => TReturn\n\nexport type DefinedPathParamWarning =\n 'Path params cannot be redefined by child routes!'\n\nexport type ParentParams<TParentParams> = AnyPathParams extends TParentParams\n ? {}\n : {\n [Key in keyof TParentParams]?: DefinedPathParamWarning\n }\n\nexport type RouteLoaderFn<\n TAllParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TAllContext extends Record<string, any> = AnyContext,\n TRouteContext extends Record<string, any> = AnyContext,\n TLoaderData extends any = unknown,\n> = (\n match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext, TRouteContext>,\n) => Promise<TLoaderData> | TLoaderData\n\nexport interface LoaderFnContext<\n TAllParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TAllContext extends Record<string, any> = AnyContext,\n TRouteContext extends Record<string, any> = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: TAllParams\n deps: TLoaderDeps\n context: Expand<Assign<TAllContext, TRouteContext>>\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>\n parentMatchPromise?: Promise<void>\n cause: 'preload' | 'enter' | 'stay'\n}\n\nexport type SearchFilter<T, U = T> = (prev: T) => U\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<\n Assign<InferFullSearchSchema<TParentRoute>, TSearchSchema>\n>\n\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type MergeFromFromParent<T, U> = IsAny<T, U, T & U>\n\nexport type ResolveAllParams<\n TParentRoute extends AnyRoute,\n TParams extends AnyPathParams,\n> = Record<never, string> extends TParentRoute['types']['allParams']\n ? TParams\n : Expand<\n UnionToIntersection<TParentRoute['types']['allParams'] & TParams> & {}\n >\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySearchSchema\n TFullSearchSchema: AnySearchSchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport class RouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,\n TFullSearchSchema extends Record<\n string,\n any\n > = TRoute['types']['fullSearchSchema'],\n TAllParams extends AnyPathParams = TRoute['types']['allParams'],\n TAllContext extends Record<string, any> = TRoute['types']['allContext'],\n TLoaderData extends any = TRoute['types']['loaderData'],\n> {\n id: TId\n\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch = <TSelected = TAllContext>(opts?: {\n select?: (search: TAllContext) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id }) as any\n }\n\n useRouteContext = <TSelected = TAllContext>(opts?: {\n select?: (search: TAllContext) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n } as any)\n }\n\n useSearch = <TSelected = TFullSearchSchema>(opts?: {\n select?: (search: TFullSearchSchema) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id } as any)\n }\n\n useParams = <TSelected = TAllParams>(opts?: {\n select?: (search: TAllParams) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (search: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any) as any\n }\n}\n\nexport class Route<\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TParams extends RouteConstraints['TParams'] = Expand<\n Record<ParsePathParams<TPath>, string>\n >,\n TAllParams extends RouteConstraints['TAllParams'] = ResolveAllParams<\n TParentRoute,\n TParams\n >,\n TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,\n TAllContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n> {\n isRoot: TParentRoute extends Route<any> ? true : false\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >\n\n test!: Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >\n\n // Set up in this.init()\n parentRoute!: TParentRoute\n id!: TId\n // customId!: TCustomId\n path!: TPath\n fullPath!: TFullPath\n to!: TrimPathRight<TFullPath>\n\n // Optional\n children?: TChildren\n originalIndex?: number\n router?: AnyRouter\n rank!: number\n\n constructor(\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >,\n ) {\n this.options = (options as any) || {}\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n types!: {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: TSearchSchema\n fullSearchSchema: TFullSearchSchema\n params: TParams\n allParams: TAllParams\n routeContext: TRouteContext\n allContext: TAllContext\n children: TChildren\n routeTree: TRouteTree\n routerContext: TRouterContext\n loaderData: TLoaderData\n loaderDeps: TLoaderDeps\n }\n\n init = (opts: { originalIndex: number }) => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as RouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>\n\n const isRoot = !options?.path && !options?.id\n\n this.parentRoute = this.options?.getParentRoute?.()\n\n if (isRoot) {\n this.path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPath(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n (this.parentRoute.id as any) === rootRouteId\n ? ''\n : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this.path = path as TPath\n this.id = id as TId\n // this.customId = customId as TCustomId\n this.fullPath = fullPath as TFullPath\n this.to = fullPath as TrimPathRight<TFullPath>\n }\n\n addChildren = <TNewChildren extends AnyRoute[]>(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchSchema,\n TFullSearchSchema,\n TParams,\n TAllParams,\n TRouteContext,\n TAllContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData,\n TNewChildren,\n TRouteTree\n > => {\n this.children = children as any\n return this as any\n }\n\n update = (options: UpdatableRouteOptions<TFullSearchSchema>) => {\n Object.assign(this.options, options)\n return this\n }\n\n useMatch = <TSelected = TAllContext>(opts?: {\n select?: (search: TAllContext) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id }) as any\n }\n\n useRouteContext = <TSelected = TAllContext>(opts?: {\n select?: (search: TAllContext) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n } as any)\n }\n\n useSearch = <TSelected = TFullSearchSchema>(opts?: {\n select?: (search: TFullSearchSchema) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id } as any)\n }\n\n useParams = <TSelected = TAllParams>(opts?: {\n select?: (search: TAllParams) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (search: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any) as any\n }\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any>\n\nexport function rootRouteWithContext<TRouterContext extends {}>() {\n return <\n TSearchSchema extends Record<string, any> = {},\n TRouteContext extends RouteContext = RouteContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n >(\n options?: Omit<\n RouteOptions<\n AnyRoute, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContext, // TRouteContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderData // TLoaderData,\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n >,\n ): RootRoute<TSearchSchema, TRouteContext, TRouterContext> => {\n return new RootRoute(options) as any\n }\n}\n\nexport class RootRoute<\n TSearchSchema extends Record<string, any> = {},\n TRouteContext extends RouteContext = RouteContext,\n TRouterContext extends {} = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContext, // TRouteContext\n Expand<Assign<TRouterContext, TRouteContext>>, // TAllContext\n TRouterContext, // TRouterContext\n TLoaderDeps,\n TLoaderData,\n any, // TChildren\n any // TRouteTree\n> {\n constructor(\n options?: Omit<\n RouteOptions<\n AnyRoute, // TParentRoute\n RootRouteId, // TCustomId\n '', // TPath\n TSearchSchema, // TSearchSchema\n TSearchSchema, // TFullSearchSchema\n {}, // TParams\n {}, // TAllParams\n TRouteContext, // TRouteContext\n Assign<TRouterContext, TRouteContext>, // TAllContext\n TLoaderDeps,\n TLoaderData\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n >,\n ) {\n super(options as any)\n }\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\ntype RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends RoutePaths<TRouteTree>,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToSubOptions<TRouteTree, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\nexport type ErrorRouteProps = {\n error: unknown\n info: { componentStack: string }\n}\n//\n\nexport type ReactNode = any\n\nexport type SyncRouteComponent<TProps> =\n | ((props: TProps) => ReactNode)\n | React.LazyExoticComponent<(props: TProps) => ReactNode>\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = SyncRouteComponent<TProps> &\n AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TSearchSchema extends RouteConstraints['TSearchSchema'] = {},\n TFullSearchSchema extends\n RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<\n TParentRoute,\n TSearchSchema\n >,\n TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext,\n TAllContext extends Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n > = Expand<\n Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>\n >,\n TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderData extends any = unknown,\n TChildren extends RouteConstraints['TChildren'] = unknown,\n TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchSchema,\n TFullSearchSchema,\n {},\n {},\n TRouteContext,\n TAllContext,\n TRouterContext,\n TLoaderDeps,\n TLoaderData,\n TChildren,\n TRouteTree\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n TSearchSchema,\n TFullSearchSchema,\n {},\n {},\n TRouteContext,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >,\n 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"names":["rootRouteId","RouteApi","constructor","id","useMatch","opts","from","useRouteContext","select","d","context","useSearch","useParams","useLoaderData","Route","options","isRoot","getParentRoute","invariant","path","$$typeof","Symbol","for","init","originalIndex","parentRoute","trimPath","customId","joinPaths","fullPath","to","addChildren","children","update","Object","assign","rootRouteWithContext","RootRoute","createRouteMask","NotFoundRoute"],"mappings":";;;;;;;;;;;;;;;;;;AAqBO,MAAMA,WAAW,GAAG,WAAmB;;AAqM9C;;AAwHO,MAAMC,QAAQ,CAUnB;AAGAC,EAAAA,WAAWA,CAAC;AAAEC,IAAAA,EAAAA;AAAgB,GAAC,EAAE;IAC/B,IAAI,CAACA,EAAE,GAAGA,EAAS,CAAA;AACrB,GAAA;EAEAC,QAAQ,GAA6BC,IAEpC,IAAgB;AACf,IAAA,OAAOD,gBAAQ,CAAC;AAAE,MAAA,GAAGC,IAAI;MAAEC,IAAI,EAAE,IAAI,CAACH,EAAAA;AAAG,KAAC,CAAC,CAAA;GAC5C,CAAA;EAEDI,eAAe,GAA6BF,IAE3C,IAAgB;AACf,IAAA,OAAOD,gBAAQ,CAAC;AACd,MAAA,GAAGC,IAAI;MACPC,IAAI,EAAE,IAAI,CAACH,EAAE;AACbK,MAAAA,MAAM,EAAGC,CAAM,IAAMJ,IAAI,EAAEG,MAAM,GAAGH,IAAI,CAACG,MAAM,CAACC,CAAC,CAACC,OAAO,CAAC,GAAGD,CAAC,CAACC,OAAAA;AACjE,KAAQ,CAAC,CAAA;GACV,CAAA;EAEDC,SAAS,GAAmCN,IAE3C,IAAgB;AACf,IAAA,OAAOM,mBAAS,CAAC;AAAE,MAAA,GAAGN,IAAI;MAAEC,IAAI,EAAE,IAAI,CAACH,EAAAA;AAAG,KAAQ,CAAC,C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D,IAAA,OAAO,IAAIsB,SAAS,CAACtB,OAAO,CAAC,CAAA;GAC9B,CAAA;AACH,CAAA;AAEO,MAAMsB,SAAS,SAMZvB,KAAK,CAiBb;EACAZ,WAAWA,CACTa,OAoBC,EACD;IACA,KAAK,CAACA,OAAc,CAAC,CAAA;AACvB,GAAA;AACF,CAAA;AAkDO,SAASuB,eAAeA,CAK7BjC,IAEwC,EACjB;AACvB,EAAA,OAAOA,IAAI,CAAA;AACb,CAAA;;AAMA;;AAiBO,MAAMkC,aAAa,SAmBhBzB,KAAK,CAiBb;EACAZ,WAAWA,CACTa,OAeC,EACD;AACA,IAAA,KAAK,CAAC;AACJ,MAAA,GAAIA,OAAe;AACnBZ,MAAAA,EAAE,EAAE,KAAA;AACN,KAAC,CAAC,CAAA;AACJ,GAAA;AACF;;;;;;;;;;"}
@@ -318,11 +318,18 @@ class Router {
318
318
  return [parentSearch, searchError];
319
319
  }
320
320
  })();
321
+
322
+ // This is where we need to call route.options.loaderDeps() to get any additional
323
+ // deps that the route's loader function might need to run. We need to do this
324
+ // before we create the match so that we can pass the deps to the route's
325
+ // potential key function which is used to uniquely identify the route match in state
326
+
327
+ const loaderDeps = route.options.loaderDeps?.({
328
+ search: preMatchSearch
329
+ }) ?? '';
330
+ const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : '';
321
331
  const interpolatedPath = path.interpolatePath(route.fullPath, routeParams);
322
- const matchId = path.interpolatePath(route.id, routeParams, true) + (route.options.key?.({
323
- search: preMatchSearch,
324
- location: this.state.location
325
- }) ?? '');
332
+ const matchId = path.interpolatePath(route.id, routeParams, true) + loaderDepsHash;
326
333
 
327
334
  // Waste not, want not. If we already have a match for this route,
328
335
  // reuse it. This is important for layout routes, which might stick
@@ -354,7 +361,8 @@ class Router {
354
361
  abortController: new AbortController(),
355
362
  shouldReloadDeps: undefined,
356
363
  fetchCount: 0,
357
- cause
364
+ cause,
365
+ loaderDeps
358
366
  };
359
367
 
360
368
  // Regardless of whether we're reusing an existing match or creating
@@ -678,7 +686,7 @@ class Router {
678
686
  } else {
679
687
  const loaderContext = {
680
688
  params: match.params,
681
- search: match.search,
689
+ deps: match.loaderDeps,
682
690
  preload: !!preload,
683
691
  parentMatchPromise,
684
692
  abortController: match.abortController,