@tanstack/router-core 1.171.7 → 1.171.8

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.
@@ -91,11 +91,10 @@ const syncMatchContext = (inner, matchId, index) => {
91
91
  };
92
92
  });
93
93
  };
94
- const handleSerialError = (inner, index, err, routerCode) => {
94
+ const handleSerialError = (inner, index, err) => {
95
95
  const { id: matchId, routeId } = inner.matches[index];
96
96
  const route = inner.router.looseRoutesById[routeId];
97
97
  if (err instanceof Promise) throw err;
98
- err.routerCode = routerCode;
99
98
  inner.firstBadMatchIndex ??= index;
100
99
  handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
101
100
  try {
@@ -195,8 +194,8 @@ const executeBeforeLoad = (inner, matchId, index, route) => {
195
194
  prevLoadPromise = void 0;
196
195
  });
197
196
  const { paramsError, searchError } = match;
198
- if (paramsError) handleSerialError(inner, index, paramsError, "PARSE_PARAMS");
199
- if (searchError) handleSerialError(inner, index, searchError, "VALIDATE_SEARCH");
197
+ if (paramsError) handleSerialError(inner, index, paramsError);
198
+ if (searchError) handleSerialError(inner, index, searchError);
200
199
  setupPendingTimeout(inner, matchId, route, match);
201
200
  const abortController = new AbortController();
202
201
  let isPending = false;
@@ -259,7 +258,7 @@ const executeBeforeLoad = (inner, matchId, index, route) => {
259
258
  }
260
259
  if (require_redirect.isRedirect(beforeLoadContext) || require_not_found.isNotFound(beforeLoadContext)) {
261
260
  pending();
262
- handleSerialError(inner, index, beforeLoadContext, "BEFORE_LOAD");
261
+ handleSerialError(inner, index, beforeLoadContext);
263
262
  }
264
263
  inner.router.batch(() => {
265
264
  pending();
@@ -276,12 +275,12 @@ const executeBeforeLoad = (inner, matchId, index, route) => {
276
275
  if (require_utils.isPromise(beforeLoadContext)) {
277
276
  pending();
278
277
  return beforeLoadContext.catch((err) => {
279
- handleSerialError(inner, index, err, "BEFORE_LOAD");
278
+ handleSerialError(inner, index, err);
280
279
  }).then(updateContext);
281
280
  }
282
281
  } catch (err) {
283
282
  pending();
284
- handleSerialError(inner, index, err, "BEFORE_LOAD");
283
+ handleSerialError(inner, index, err);
285
284
  }
286
285
  updateContext(beforeLoadContext);
287
286
  };
@@ -1 +1 @@
1
- {"version":3,"file":"load-matches.cjs","names":[],"sources":["../../src/load-matches.ts"],"sourcesContent":["import { isServer } from '@tanstack/router-core/isServer'\nimport { invariant } from './invariant'\nimport { createControlledPromise, isPromise } from './utils'\nimport { isNotFound } from './not-found'\nimport { rootRouteId } from './root'\nimport { isRedirect } from './redirect'\nimport type { NotFoundError } from './not-found'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyRoute,\n BeforeLoadContextOptions,\n LoaderFnContext,\n SsrContextOptions,\n} from './route'\nimport type { AnyRouteMatch, MakeRouteMatch } from './Matches'\nimport type { AnyRouter, SSROption, UpdateMatchFn } from './router'\n\n/**\n * An object of this shape is created when calling `loadMatches`.\n * It contains everything we need for all other functions in this file\n * to work. (It's basically the function's argument, plus a few mutable states)\n */\ntype InnerLoadContext = {\n /** the calling router instance */\n router: AnyRouter\n location: ParsedLocation\n /** mutable state, scoped to a `loadMatches` call */\n firstBadMatchIndex?: number\n /** mutable state, scoped to a `loadMatches` call */\n rendered?: boolean\n serialError?: unknown\n updateMatch: UpdateMatchFn\n matches: Array<AnyRouteMatch>\n preload?: boolean\n forceStaleReload?: boolean\n onReady?: () => Promise<void>\n sync?: boolean\n}\n\nconst triggerOnReady = (inner: InnerLoadContext): void | Promise<void> => {\n if (!inner.rendered) {\n inner.rendered = true\n return inner.onReady?.()\n }\n}\n\nconst hasForcePendingActiveMatch = (router: AnyRouter): boolean => {\n return router.stores.matchesId.get().some((matchId) => {\n return router.stores.matchStores.get(matchId)?.get()._forcePending\n })\n}\n\nconst resolvePreload = (inner: InnerLoadContext, matchId: string): boolean => {\n return !!(inner.preload && !inner.router.stores.matchStores.has(matchId))\n}\n\n/**\n * Builds the accumulated context from router options and all matches up to (and optionally including) the given index.\n * Merges __routeContext and __beforeLoadContext from each match.\n */\nconst buildMatchContext = (\n inner: InnerLoadContext,\n index: number,\n includeCurrentMatch: boolean = true,\n): Record<string, unknown> => {\n const context: Record<string, unknown> = {\n ...(inner.router.options.context ?? {}),\n }\n const end = includeCurrentMatch ? index : index - 1\n for (let i = 0; i <= end; i++) {\n const innerMatch = inner.matches[i]\n if (!innerMatch) continue\n const m = inner.router.getMatch(innerMatch.id)\n if (!m) continue\n Object.assign(context, m.__routeContext, m.__beforeLoadContext)\n }\n return context\n}\n\nconst getNotFoundBoundaryIndex = (\n inner: InnerLoadContext,\n err: NotFoundError,\n): number | undefined => {\n if (!inner.matches.length) {\n return undefined\n }\n\n const requestedRouteId = err.routeId\n const matchedRootIndex = inner.matches.findIndex(\n (m) => m.routeId === inner.router.routeTree.id,\n )\n const rootIndex = matchedRootIndex >= 0 ? matchedRootIndex : 0\n\n let startIndex = requestedRouteId\n ? inner.matches.findIndex((match) => match.routeId === requestedRouteId)\n : (inner.firstBadMatchIndex ?? inner.matches.length - 1)\n\n if (startIndex < 0) {\n startIndex = rootIndex\n }\n\n for (let i = startIndex; i >= 0; i--) {\n const match = inner.matches[i]!\n const route = inner.router.looseRoutesById[match.routeId]!\n if (route.options.notFoundComponent) {\n return i\n }\n }\n\n // If no boundary component is found, preserve explicit routeId targeting behavior,\n // otherwise default to root for untargeted notFounds.\n return requestedRouteId ? startIndex : rootIndex\n}\n\nconst handleRedirectAndNotFound = (\n inner: InnerLoadContext,\n match: AnyRouteMatch | undefined,\n err: unknown,\n): void => {\n if (!isRedirect(err) && !isNotFound(err)) return\n\n if (isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) {\n throw err\n }\n\n // in case of a redirecting match during preload, the match does not exist\n if (match) {\n match._nonReactive.beforeLoadPromise?.resolve()\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.beforeLoadPromise = undefined\n match._nonReactive.loaderPromise = undefined\n\n match._nonReactive.error = err\n\n inner.updateMatch(match.id, (prev) => ({\n ...prev,\n status: isRedirect(err)\n ? 'redirected'\n : isNotFound(err)\n ? 'notFound'\n : prev.status === 'pending'\n ? 'success'\n : prev.status,\n context: buildMatchContext(inner, match.index),\n isFetching: false,\n error: err,\n }))\n\n if (isNotFound(err) && !err.routeId) {\n // Stamp the throwing match's routeId so that the finalization step in\n // loadMatches knows where the notFound originated. The actual boundary\n // resolution (walking up to the nearest notFoundComponent) is deferred to\n // the finalization step, where firstBadMatchIndex is stable and\n // headMaxIndex can be capped correctly.\n err.routeId = match.routeId\n }\n\n match._nonReactive.loadPromise?.resolve()\n }\n\n if (isRedirect(err)) {\n inner.rendered = true\n err.options._fromLocation = inner.location\n err.redirectHandled = true\n err = inner.router.resolveRedirect(err)\n }\n\n throw err\n}\n\nconst shouldSkipLoader = (\n inner: InnerLoadContext,\n matchId: string,\n): boolean => {\n const match = inner.router.getMatch(matchId)\n if (!match) {\n return true\n }\n // upon hydration, we skip the loader if the match has been dehydrated on the server\n if (!(isServer ?? inner.router.isServer) && match._nonReactive.dehydrated) {\n return true\n }\n\n if ((isServer ?? inner.router.isServer) && match.ssr === false) {\n return true\n }\n\n return false\n}\n\nconst syncMatchContext = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n): void => {\n const nextContext = buildMatchContext(inner, index)\n\n inner.updateMatch(matchId, (prev) => {\n return {\n ...prev,\n context: nextContext,\n }\n })\n}\n\nconst handleSerialError = (\n inner: InnerLoadContext,\n index: number,\n err: any,\n routerCode: string,\n): void => {\n const { id: matchId, routeId } = inner.matches[index]!\n const route = inner.router.looseRoutesById[routeId]!\n\n // Much like suspense, we use a promise here to know if\n // we've been outdated by a new loadMatches call and\n // should abort the current async operation\n if (err instanceof Promise) {\n throw err\n }\n\n err.routerCode = routerCode\n inner.firstBadMatchIndex ??= index\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)\n\n try {\n route.options.onError?.(err)\n } catch (errorHandlerErr) {\n err = errorHandlerErr\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)\n }\n\n inner.updateMatch(matchId, (prev) => {\n prev._nonReactive.beforeLoadPromise?.resolve()\n prev._nonReactive.beforeLoadPromise = undefined\n prev._nonReactive.loadPromise?.resolve()\n\n return {\n ...prev,\n error: err,\n status: 'error',\n isFetching: false,\n updatedAt: Date.now(),\n abortController: new AbortController(),\n }\n })\n\n if (!inner.preload && !isRedirect(err) && !isNotFound(err)) {\n inner.serialError ??= err\n }\n}\n\nconst isBeforeLoadSsr = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n route: AnyRoute,\n): void | Promise<void> => {\n const existingMatch = inner.router.getMatch(matchId)!\n const parentMatchId = inner.matches[index - 1]?.id\n const parentMatch = parentMatchId\n ? inner.router.getMatch(parentMatchId)!\n : undefined\n\n // in SPA mode, only SSR the root route\n if (inner.router.isShell()) {\n existingMatch.ssr = route.id === rootRouteId\n return\n }\n\n if (parentMatch?.ssr === false) {\n existingMatch.ssr = false\n return\n }\n\n const parentOverride = (tempSsr: SSROption) => {\n if (tempSsr === true && parentMatch?.ssr === 'data-only') {\n return 'data-only'\n }\n return tempSsr\n }\n\n const defaultSsr = inner.router.options.defaultSsr ?? true\n\n if (route.options.ssr === undefined) {\n existingMatch.ssr = parentOverride(defaultSsr)\n return\n }\n\n if (typeof route.options.ssr !== 'function') {\n existingMatch.ssr = parentOverride(route.options.ssr)\n return\n }\n const { search, params } = existingMatch\n\n const ssrFnContext: SsrContextOptions<any, any, any> = {\n search: makeMaybe(search, existingMatch.searchError),\n params: makeMaybe(params, existingMatch.paramsError),\n location: inner.location,\n matches: inner.matches.map((match) => ({\n index: match.index,\n pathname: match.pathname,\n fullPath: match.fullPath,\n staticData: match.staticData,\n id: match.id,\n routeId: match.routeId,\n search: makeMaybe(match.search, match.searchError),\n params: makeMaybe(match.params, match.paramsError),\n ssr: match.ssr,\n })),\n }\n\n const tempSsr = route.options.ssr(ssrFnContext)\n if (isPromise(tempSsr)) {\n return tempSsr.then((ssr) => {\n existingMatch.ssr = parentOverride(ssr ?? defaultSsr)\n })\n }\n\n existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr)\n return\n}\n\nconst setupPendingTimeout = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n match: AnyRouteMatch,\n): void => {\n if (match._nonReactive.pendingTimeout !== undefined) return\n\n const pendingMs =\n route.options.pendingMs ?? inner.router.options.defaultPendingMs\n const shouldPending = !!(\n inner.onReady &&\n !(isServer ?? inner.router.isServer) &&\n !resolvePreload(inner, matchId) &&\n (route.options.loader ||\n route.options.beforeLoad ||\n routeNeedsPreload(route)) &&\n typeof pendingMs === 'number' &&\n pendingMs !== Infinity &&\n (route.options.pendingComponent ??\n (inner.router.options as any)?.defaultPendingComponent)\n )\n\n if (shouldPending) {\n const pendingTimeout = setTimeout(() => {\n // Update the match and prematurely resolve the loadMatches promise so that\n // the pending component can start rendering\n triggerOnReady(inner)\n }, pendingMs)\n match._nonReactive.pendingTimeout = pendingTimeout\n }\n}\n\nconst preBeforeLoadSetup = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n): void | Promise<void> => {\n const existingMatch = inner.router.getMatch(matchId)!\n\n // If we are in the middle of a load, either of these will be present\n // (not to be confused with `loadPromise`, which is always defined)\n if (\n !existingMatch._nonReactive.beforeLoadPromise &&\n !existingMatch._nonReactive.loaderPromise\n )\n return\n\n setupPendingTimeout(inner, matchId, route, existingMatch)\n\n const then = () => {\n const match = inner.router.getMatch(matchId)!\n if (\n match.preload &&\n (match.status === 'redirected' || match.status === 'notFound')\n ) {\n handleRedirectAndNotFound(inner, match, match.error)\n }\n }\n\n // Wait for the previous beforeLoad to resolve before we continue\n return existingMatch._nonReactive.beforeLoadPromise\n ? existingMatch._nonReactive.beforeLoadPromise.then(then)\n : then()\n}\n\nconst executeBeforeLoad = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n route: AnyRoute,\n): void | Promise<void> => {\n const match = inner.router.getMatch(matchId)!\n\n // explicitly capture the previous loadPromise\n let prevLoadPromise = match._nonReactive.loadPromise\n match._nonReactive.loadPromise = createControlledPromise<void>(() => {\n prevLoadPromise?.resolve()\n prevLoadPromise = undefined\n })\n\n const { paramsError, searchError } = match\n\n if (paramsError) {\n handleSerialError(inner, index, paramsError, 'PARSE_PARAMS')\n }\n\n if (searchError) {\n handleSerialError(inner, index, searchError, 'VALIDATE_SEARCH')\n }\n\n setupPendingTimeout(inner, matchId, route, match)\n\n const abortController = new AbortController()\n\n let isPending = false\n const pending = () => {\n if (isPending) return\n isPending = true\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: 'beforeLoad',\n fetchCount: prev.fetchCount + 1,\n abortController,\n // Note: We intentionally don't update context here.\n // Context should only be updated after beforeLoad resolves to avoid\n // components seeing incomplete context during async beforeLoad execution.\n }))\n }\n\n const resolve = () => {\n match._nonReactive.beforeLoadPromise?.resolve()\n match._nonReactive.beforeLoadPromise = undefined\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: false,\n }))\n }\n\n // if there is no `beforeLoad` option, just mark as pending and resolve\n // Context will be updated later in loadRouteMatch after loader completes\n if (!route.options.beforeLoad) {\n inner.router.batch(() => {\n pending()\n resolve()\n })\n return\n }\n\n match._nonReactive.beforeLoadPromise = createControlledPromise<void>()\n\n // Build context from all parent matches, excluding current match's __beforeLoadContext\n // (since we're about to execute beforeLoad for this match)\n const context = {\n ...buildMatchContext(inner, index, false),\n ...match.__routeContext,\n }\n const { search, params, cause } = match\n const preload = resolvePreload(inner, matchId)\n const beforeLoadFnContext: BeforeLoadContextOptions<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > = {\n search,\n abortController,\n params,\n preload,\n context,\n location: inner.location,\n navigate: (opts: any) =>\n inner.router.navigate({\n ...opts,\n _fromLocation: inner.location,\n }),\n buildLocation: inner.router.buildLocation,\n cause: preload ? 'preload' : cause,\n matches: inner.matches,\n routeId: route.id,\n ...inner.router.options.additionalContext,\n }\n\n const updateContext = (beforeLoadContext: any) => {\n if (beforeLoadContext === undefined) {\n inner.router.batch(() => {\n pending()\n resolve()\n })\n return\n }\n if (isRedirect(beforeLoadContext) || isNotFound(beforeLoadContext)) {\n pending()\n handleSerialError(inner, index, beforeLoadContext, 'BEFORE_LOAD')\n }\n\n inner.router.batch(() => {\n pending()\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n __beforeLoadContext: beforeLoadContext,\n }))\n resolve()\n })\n }\n\n let beforeLoadContext\n try {\n beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext)\n if (isPromise(beforeLoadContext)) {\n pending()\n return beforeLoadContext\n .catch((err) => {\n handleSerialError(inner, index, err, 'BEFORE_LOAD')\n })\n .then(updateContext)\n }\n } catch (err) {\n pending()\n handleSerialError(inner, index, err, 'BEFORE_LOAD')\n }\n\n updateContext(beforeLoadContext)\n return\n}\n\nconst handleBeforeLoad = (\n inner: InnerLoadContext,\n index: number,\n): void | Promise<void> => {\n const { id: matchId, routeId } = inner.matches[index]!\n const route = inner.router.looseRoutesById[routeId]!\n\n const serverSsr = () => {\n // on the server, determine whether SSR the current match or not\n if (isServer ?? inner.router.isServer) {\n const maybePromise = isBeforeLoadSsr(inner, matchId, index, route)\n if (isPromise(maybePromise)) return maybePromise.then(queueExecution)\n }\n return queueExecution()\n }\n\n const execute = () => executeBeforeLoad(inner, matchId, index, route)\n\n const queueExecution = () => {\n if (shouldSkipLoader(inner, matchId)) return\n const result = preBeforeLoadSetup(inner, matchId, route)\n return isPromise(result) ? result.then(execute) : execute()\n }\n\n return serverSsr()\n}\n\nconst executeHead = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n): void | Promise<\n Pick<\n AnyRouteMatch,\n 'meta' | 'links' | 'headScripts' | 'headers' | 'scripts' | 'styles'\n >\n> => {\n const match = inner.router.getMatch(matchId)\n // in case of a redirecting match during preload, the match does not exist\n if (!match) {\n return\n }\n if (!route.options.head && !route.options.scripts && !route.options.headers) {\n return\n }\n const assetContext = {\n ssr: inner.router.options.ssr,\n matches: inner.matches,\n match,\n params: match.params,\n loaderData: match.loaderData,\n }\n\n return Promise.all([\n route.options.head?.(assetContext),\n route.options.scripts?.(assetContext),\n route.options.headers?.(assetContext),\n ]).then(([headFnContent, scripts, headers]) => {\n const meta = headFnContent?.meta\n const links = headFnContent?.links\n const headScripts = headFnContent?.scripts\n const styles = headFnContent?.styles\n\n return {\n meta,\n links,\n headScripts,\n headers,\n scripts,\n styles,\n }\n })\n}\n\nconst getLoaderContext = (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n matchId: string,\n index: number,\n route: AnyRoute,\n): LoaderFnContext => {\n const parentMatchPromise = matchPromises[index - 1] as any\n const { params, loaderDeps, abortController, cause } =\n inner.router.getMatch(matchId)!\n\n const context = buildMatchContext(inner, index)\n\n const preload = resolvePreload(inner, matchId)\n\n return {\n params,\n deps: loaderDeps,\n preload: !!preload,\n parentMatchPromise,\n abortController,\n context,\n location: inner.location,\n navigate: (opts) =>\n inner.router.navigate({\n ...opts,\n _fromLocation: inner.location,\n }),\n cause: preload ? 'preload' : cause,\n route,\n ...inner.router.options.additionalContext,\n }\n}\n\nconst runLoader = async (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n matchId: string,\n index: number,\n route: AnyRoute,\n): Promise<void> => {\n try {\n // If the Matches component rendered\n // the pending component and needs to show it for\n // a minimum duration, we''ll wait for it to resolve\n // before committing to the match and resolving\n // the loadPromise\n\n const match = inner.router.getMatch(matchId)!\n\n // Actually run the loader and handle the result\n try {\n if (!(isServer ?? inner.router.isServer) || match.ssr === true) {\n loadRouteChunk(route)\n }\n\n // Kick off the loader!\n const routeLoader = route.options.loader\n const loader =\n typeof routeLoader === 'function' ? routeLoader : routeLoader?.handler\n const loaderResult = loader?.(\n getLoaderContext(inner, matchPromises, matchId, index, route),\n )\n const loaderResultIsPromise = !!loader && isPromise(loaderResult)\n\n const willLoadSomething = !!(\n loaderResultIsPromise ||\n route._lazyPromise ||\n route._componentsPromise ||\n route.options.head ||\n route.options.scripts ||\n route.options.headers ||\n match._nonReactive.minPendingPromise\n )\n\n if (willLoadSomething) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: 'loader',\n }))\n }\n\n if (loader) {\n const loaderData = loaderResultIsPromise\n ? await loaderResult\n : loaderResult\n\n handleRedirectAndNotFound(\n inner,\n inner.router.getMatch(matchId),\n loaderData,\n )\n if (loaderData !== undefined) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n loaderData,\n }))\n }\n }\n\n // Lazy option can modify the route options,\n // so we need to wait for it to resolve before\n // we can use the options\n if (route._lazyPromise) await route._lazyPromise\n const pendingPromise = match._nonReactive.minPendingPromise\n if (pendingPromise) await pendingPromise\n\n // Last but not least, wait for the components\n // to be preloaded before we resolve the match\n if (route._componentsPromise) await route._componentsPromise\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n error: undefined,\n context: buildMatchContext(inner, index),\n status: 'success',\n isFetching: false,\n updatedAt: Date.now(),\n }))\n } catch (e) {\n let error = e\n\n if ((error as any)?.name === 'AbortError') {\n if (match.abortController.signal.aborted) {\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loaderPromise = undefined\n return\n }\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n status: prev.status === 'pending' ? 'success' : prev.status,\n isFetching: false,\n context: buildMatchContext(inner, index),\n }))\n return\n }\n\n const pendingPromise = match._nonReactive.minPendingPromise\n if (pendingPromise) await pendingPromise\n\n if (isNotFound(e)) {\n await (route.options.notFoundComponent as any)?.preload?.()\n }\n\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e)\n\n try {\n route.options.onError?.(e)\n } catch (onErrorError) {\n error = onErrorError\n handleRedirectAndNotFound(\n inner,\n inner.router.getMatch(matchId),\n onErrorError,\n )\n }\n if (!isRedirect(error) && !isNotFound(error)) {\n await loadRouteChunk(route, ['errorComponent'])\n }\n\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n error,\n context: buildMatchContext(inner, index),\n status: 'error',\n isFetching: false,\n }))\n }\n } catch (err) {\n const match = inner.router.getMatch(matchId)\n // in case of a redirecting match during preload, the match does not exist\n if (match) {\n match._nonReactive.loaderPromise = undefined\n }\n handleRedirectAndNotFound(inner, match, err)\n }\n}\n\nconst loadRouteMatch = async (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n index: number,\n): Promise<AnyRouteMatch> => {\n async function handleLoader(\n preload: boolean,\n prevMatch: AnyRouteMatch,\n previousRouteMatchId: string | undefined,\n match: AnyRouteMatch,\n route: AnyRoute,\n ) {\n const age = Date.now() - prevMatch.updatedAt\n\n const staleAge = preload\n ? (route.options.preloadStaleTime ??\n inner.router.options.defaultPreloadStaleTime ??\n 30_000) // 30 seconds for preloads by default\n : (route.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0)\n\n const shouldReloadOption = route.options.shouldReload\n\n // Default to reloading the route all the time\n // Allow shouldReload to get the last say,\n // if provided.\n const shouldReload =\n typeof shouldReloadOption === 'function'\n ? shouldReloadOption(\n getLoaderContext(inner, matchPromises, matchId, index, route),\n )\n : shouldReloadOption\n\n // If the route is successful and still fresh, just resolve\n const { status, invalid } = match\n const staleMatchShouldReload =\n age >= staleAge &&\n (!!inner.forceStaleReload ||\n match.cause === 'enter' ||\n (previousRouteMatchId !== undefined &&\n previousRouteMatchId !== match.id))\n loaderShouldRunAsync =\n status === 'success' &&\n (invalid || (shouldReload ?? staleMatchShouldReload))\n if (preload && route.options.preload === false) {\n // Do nothing\n } else if (\n loaderShouldRunAsync &&\n !inner.sync &&\n shouldReloadInBackground\n ) {\n loaderIsRunningAsync = true\n ;(async () => {\n try {\n await runLoader(inner, matchPromises, matchId, index, route)\n const match = inner.router.getMatch(matchId)!\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loadPromise?.resolve()\n match._nonReactive.loaderPromise = undefined\n match._nonReactive.loadPromise = undefined\n } catch (err) {\n if (isRedirect(err)) {\n await inner.router.navigate(err.options)\n }\n }\n })()\n } else if (status !== 'success' || loaderShouldRunAsync) {\n await runLoader(inner, matchPromises, matchId, index, route)\n } else {\n syncMatchContext(inner, matchId, index)\n }\n }\n\n const { id: matchId, routeId } = inner.matches[index]!\n let loaderShouldRunAsync = false\n let loaderIsRunningAsync = false\n const route = inner.router.looseRoutesById[routeId]!\n const routeLoader = route.options.loader\n const shouldReloadInBackground =\n ((typeof routeLoader === 'function'\n ? undefined\n : routeLoader?.staleReloadMode) ??\n inner.router.options.defaultStaleReloadMode) !== 'blocking'\n\n if (shouldSkipLoader(inner, matchId)) {\n const match = inner.router.getMatch(matchId)\n if (!match) {\n return inner.matches[index]!\n }\n\n syncMatchContext(inner, matchId, index)\n\n if (isServer ?? inner.router.isServer) {\n return inner.router.getMatch(matchId)!\n }\n } else {\n const prevMatch = inner.router.getMatch(matchId)! // This is where all of the stale-while-revalidate magic happens\n const activeIdAtIndex = inner.router.stores.matchesId.get()[index]\n const activeAtIndex =\n (activeIdAtIndex &&\n inner.router.stores.matchStores.get(activeIdAtIndex)) ||\n null\n const previousRouteMatchId =\n activeAtIndex?.routeId === routeId\n ? activeIdAtIndex\n : inner.router.stores.matches.get().find((d) => d.routeId === routeId)\n ?.id\n const preload = resolvePreload(inner, matchId)\n\n // there is a loaderPromise, so we are in the middle of a load\n if (prevMatch._nonReactive.loaderPromise) {\n // do not block if we already have stale data we can show\n // but only if the ongoing load is not a preload since error handling is different for preloads\n // and we don't want to swallow errors\n if (\n prevMatch.status === 'success' &&\n !inner.sync &&\n !prevMatch.preload &&\n shouldReloadInBackground\n ) {\n return prevMatch\n }\n await prevMatch._nonReactive.loaderPromise\n const match = inner.router.getMatch(matchId)!\n const error = match._nonReactive.error || match.error\n if (error) {\n handleRedirectAndNotFound(inner, match, error)\n }\n\n if (match.status === 'pending') {\n await handleLoader(\n preload,\n prevMatch,\n previousRouteMatchId,\n match,\n route,\n )\n }\n } else {\n const nextPreload =\n preload && !inner.router.stores.matchStores.has(matchId)\n const match = inner.router.getMatch(matchId)!\n match._nonReactive.loaderPromise = createControlledPromise<void>()\n if (nextPreload !== match.preload) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n preload: nextPreload,\n }))\n }\n\n await handleLoader(preload, prevMatch, previousRouteMatchId, match, route)\n }\n }\n const match = inner.router.getMatch(matchId)!\n if (!loaderIsRunningAsync) {\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loadPromise?.resolve()\n match._nonReactive.loadPromise = undefined\n }\n\n clearTimeout(match._nonReactive.pendingTimeout)\n match._nonReactive.pendingTimeout = undefined\n if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = undefined\n match._nonReactive.dehydrated = undefined\n\n const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false\n if (nextIsFetching !== match.isFetching || match.invalid !== false) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: nextIsFetching,\n invalid: false,\n }))\n return inner.router.getMatch(matchId)!\n } else {\n return match\n }\n}\n\nexport async function loadMatches(arg: {\n router: AnyRouter\n location: ParsedLocation\n matches: Array<AnyRouteMatch>\n preload?: boolean\n forceStaleReload?: boolean\n onReady?: () => Promise<void>\n updateMatch: UpdateMatchFn\n sync?: boolean\n}): Promise<Array<MakeRouteMatch>> {\n const inner: InnerLoadContext = arg\n const matchPromises: Array<Promise<AnyRouteMatch>> = []\n\n // make sure the pending component is immediately rendered when hydrating a match that is not SSRed\n // the pending component was already rendered on the server and we want to keep it shown on the client until minPendingMs is reached\n if (\n !(isServer ?? inner.router.isServer) &&\n hasForcePendingActiveMatch(inner.router)\n ) {\n triggerOnReady(inner)\n }\n\n let beforeLoadNotFound: NotFoundError | undefined\n\n // Execute all beforeLoads one by one\n for (let i = 0; i < inner.matches.length; i++) {\n try {\n const beforeLoad = handleBeforeLoad(inner, i)\n if (isPromise(beforeLoad)) await beforeLoad\n } catch (err) {\n if (isRedirect(err)) {\n throw err\n }\n if (isNotFound(err)) {\n beforeLoadNotFound = err\n } else {\n if (!inner.preload) throw err\n }\n break\n }\n\n if (inner.serialError || inner.firstBadMatchIndex != null) {\n break\n }\n }\n\n // Execute loaders once, with max index adapted for beforeLoad notFound handling.\n const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length\n\n const boundaryIndex =\n beforeLoadNotFound && !inner.preload\n ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound)\n : undefined\n\n const maxIndexExclusive =\n beforeLoadNotFound && inner.preload\n ? 0\n : boundaryIndex !== undefined\n ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive)\n : baseMaxIndexExclusive\n\n let firstNotFound: NotFoundError | undefined\n let firstUnhandledRejection: unknown\n\n for (let i = 0; i < maxIndexExclusive; i++) {\n matchPromises.push(loadRouteMatch(inner, matchPromises, i))\n }\n\n try {\n await Promise.all(matchPromises)\n } catch {\n const settled = await Promise.allSettled(matchPromises)\n\n for (const result of settled) {\n if (result.status !== 'rejected') continue\n\n const reason = result.reason\n if (isRedirect(reason)) {\n throw reason\n }\n if (isNotFound(reason)) {\n firstNotFound ??= reason\n } else {\n firstUnhandledRejection ??= reason\n }\n }\n\n if (firstUnhandledRejection !== undefined) {\n throw firstUnhandledRejection\n }\n }\n\n const notFoundToThrow =\n firstNotFound ??\n (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : undefined)\n\n let headMaxIndex =\n inner.firstBadMatchIndex !== undefined\n ? inner.firstBadMatchIndex\n : inner.matches.length - 1\n\n if (!notFoundToThrow && beforeLoadNotFound && inner.preload) {\n return inner.matches\n }\n\n if (notFoundToThrow) {\n // Determine once which matched route will actually render the\n // notFoundComponent, then pass this precomputed index through the remaining\n // finalization steps.\n // This can differ from the throwing route when routeId targets an ancestor\n // boundary (or when bubbling resolves to a parent/root boundary).\n const renderedBoundaryIndex = getNotFoundBoundaryIndex(\n inner,\n notFoundToThrow,\n )\n\n if (renderedBoundaryIndex === undefined) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Invariant failed: Could not find match for notFound boundary',\n )\n }\n\n invariant()\n }\n const boundaryMatch = inner.matches[renderedBoundaryIndex]!\n\n const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId]!\n const defaultNotFoundComponent = (inner.router.options as any)\n ?.defaultNotFoundComponent\n\n // Ensure a notFoundComponent exists on the boundary route\n if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) {\n boundaryRoute.options.notFoundComponent = defaultNotFoundComponent\n }\n\n notFoundToThrow.routeId = boundaryMatch.routeId\n\n const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id\n\n inner.updateMatch(boundaryMatch.id, (prev) => ({\n ...prev,\n ...(boundaryIsRoot\n ? // For root boundary, use globalNotFound so the root component's\n // shell still renders and <Outlet> handles the not-found display,\n // instead of replacing the entire root shell via status='notFound'.\n { status: 'success' as const, globalNotFound: true, error: undefined }\n : // For non-root boundaries, set status:'notFound' so MatchInner\n // renders the notFoundComponent directly.\n { status: 'notFound' as const, error: notFoundToThrow }),\n isFetching: false,\n }))\n\n headMaxIndex = renderedBoundaryIndex\n\n // Ensure the rendering boundary route chunk (and its lazy components, including\n // lazy notFoundComponent) is loaded before we continue to head execution/render.\n await loadRouteChunk(boundaryRoute, ['notFoundComponent'])\n } else if (!inner.preload) {\n // Clear stale root global-not-found state on normal navigations that do not\n // throw notFound. This must live here (instead of only in runLoader success)\n // because the root loader may be skipped when data is still fresh.\n const rootMatch = inner.matches[0]!\n // `rootMatch` is the next match for this navigation. If it is not global\n // not-found, then any currently stored root global-not-found is stale.\n if (!rootMatch.globalNotFound) {\n // `currentRootMatch` is the current store state (from the previous\n // navigation/load). Update only when a stale flag is actually present.\n const currentRootMatch = inner.router.getMatch(rootMatch.id)\n if (currentRootMatch?.globalNotFound) {\n inner.updateMatch(rootMatch.id, (prev) => ({\n ...prev,\n globalNotFound: false,\n error: undefined,\n }))\n }\n }\n }\n\n // When a serial error occurred (e.g. beforeLoad threw a regular Error),\n // the erroring route's lazy chunk wasn't loaded because loaders were skipped.\n // We need to load it so the code-split errorComponent is available for rendering.\n if (inner.serialError && inner.firstBadMatchIndex !== undefined) {\n const errorRoute =\n inner.router.looseRoutesById[\n inner.matches[inner.firstBadMatchIndex]!.routeId\n ]!\n await loadRouteChunk(errorRoute, ['errorComponent'])\n }\n\n // serially execute heads once after loaders/notFound handling, ensuring\n // all head functions get a chance even if one throws.\n for (let i = 0; i <= headMaxIndex; i++) {\n const match = inner.matches[i]!\n const { id: matchId, routeId } = match\n const route = inner.router.looseRoutesById[routeId]!\n try {\n const headResult = executeHead(inner, matchId, route)\n if (headResult) {\n const head = await headResult\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n ...head,\n }))\n }\n } catch (err) {\n console.error(`Error executing head for route ${routeId}:`, err)\n }\n }\n\n const readyPromise = triggerOnReady(inner)\n if (isPromise(readyPromise)) {\n await readyPromise\n }\n\n if (notFoundToThrow) {\n throw notFoundToThrow\n }\n\n if (inner.serialError && !inner.preload && !inner.onReady) {\n throw inner.serialError\n }\n\n return inner.matches\n}\n\nexport type RouteComponentType =\n | 'component'\n | 'errorComponent'\n | 'pendingComponent'\n | 'notFoundComponent'\n\nfunction preloadRouteComponents(\n route: AnyRoute,\n componentTypesToLoad: Array<RouteComponentType>,\n): Promise<void> | undefined {\n const preloads = componentTypesToLoad\n .map((type) => (route.options[type] as any)?.preload?.())\n .filter(Boolean)\n\n if (preloads.length === 0) return undefined\n\n return Promise.all(preloads) as any as Promise<void>\n}\n\nexport function loadRouteChunk(\n route: AnyRoute,\n componentTypesToLoad: Array<RouteComponentType> = componentTypes,\n) {\n if (!route._lazyLoaded && route._lazyPromise === undefined) {\n if (route.lazyFn) {\n route._lazyPromise = route.lazyFn().then((lazyRoute) => {\n // explicitly don't copy over the lazy route's id\n const { id: _id, ...options } = lazyRoute.options\n Object.assign(route.options, options)\n route._lazyLoaded = true\n route._lazyPromise = undefined // gc promise, we won't need it anymore\n })\n } else {\n route._lazyLoaded = true\n }\n }\n\n const runAfterLazy = () =>\n route._componentsLoaded\n ? undefined\n : componentTypesToLoad === componentTypes\n ? (() => {\n if (route._componentsPromise === undefined) {\n const componentsPromise = preloadRouteComponents(\n route,\n componentTypes,\n )\n\n if (componentsPromise) {\n route._componentsPromise = componentsPromise.then(() => {\n route._componentsLoaded = true\n route._componentsPromise = undefined // gc promise, we won't need it anymore\n })\n } else {\n route._componentsLoaded = true\n }\n }\n\n return route._componentsPromise\n })()\n : preloadRouteComponents(route, componentTypesToLoad)\n\n return route._lazyPromise\n ? route._lazyPromise.then(runAfterLazy)\n : runAfterLazy()\n}\n\nfunction makeMaybe<TValue, TError>(\n value: TValue,\n error: TError,\n): { status: 'success'; value: TValue } | { status: 'error'; error: TError } {\n if (error) {\n return { status: 'error' as const, error }\n }\n return { status: 'success' as const, value }\n}\n\nexport function routeNeedsPreload(route: AnyRoute) {\n for (const componentType of componentTypes) {\n if ((route.options[componentType] as any)?.preload) {\n return true\n }\n }\n return false\n}\n\nexport const componentTypes: Array<RouteComponentType> = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n 'notFoundComponent',\n] as const\n"],"mappings":";;;;;;;AAuCA,MAAM,kBAAkB,UAAkD;CACxE,IAAI,CAAC,MAAM,UAAU;EACnB,MAAM,WAAW;EACjB,OAAO,MAAM,UAAU;CACzB;AACF;AAEA,MAAM,8BAA8B,WAA+B;CACjE,OAAO,OAAO,OAAO,UAAU,IAAI,EAAE,MAAM,YAAY;EACrD,OAAO,OAAO,OAAO,YAAY,IAAI,OAAO,GAAG,IAAI,EAAE;CACvD,CAAC;AACH;AAEA,MAAM,kBAAkB,OAAyB,YAA6B;CAC5E,OAAO,CAAC,EAAE,MAAM,WAAW,CAAC,MAAM,OAAO,OAAO,YAAY,IAAI,OAAO;AACzE;;;;;AAMA,MAAM,qBACJ,OACA,OACA,sBAA+B,SACH;CAC5B,MAAM,UAAmC,EACvC,GAAI,MAAM,OAAO,QAAQ,WAAW,CAAC,EACvC;CACA,MAAM,MAAM,sBAAsB,QAAQ,QAAQ;CA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,CAAC,MAAM,eAAe,MAAM,iBAAiB,KAAA,GAC/C,IAAI,MAAM,QACR,MAAM,eAAe,MAAM,OAAO,EAAE,MAAM,cAAc;EAEtD,MAAM,EAAE,IAAI,KAAK,GAAG,YAAY,UAAU;EAC1C,OAAO,OAAO,MAAM,SAAS,OAAO;EACpC,MAAM,cAAc;EACpB,MAAM,eAAe,KAAA;CACvB,CAAC;MAED,MAAM,cAAc;CAIxB,MAAM,qBACJ,MAAM,oBACF,KAAA,IACA,yBAAyB,wBAChB;EACL,IAAI,MAAM,uBAAuB,KAAA,GAAW;GAC1C,MAAM,oBAAoB,uBACxB,OACA,cACF;GAEA,IAAI,mBACF,MAAM,qBAAqB,kBAAkB,WAAW;IACtD,MAAM,oBAAoB;IAC1B,MAAM,qBAAqB,KAAA;GAC7B,CAAC;QAED,MAAM,oBAAoB;EAE9B;EAEA,OAAO,MAAM;CACf,GAAG,IACH,uBAAuB,OAAO,oBAAoB;CAE1D,OAAO,MAAM,eACT,MAAM,aAAa,KAAK,YAAY,IACpC,aAAa;AACnB;AAEA,SAAS,UACP,OACA,OAC2E;CAC3E,IAAI,OACF,OAAO;EAAE,QAAQ;EAAkB;CAAM;CAE3C,OAAO;EAAE,QAAQ;EAAoB;CAAM;AAC7C;AAEA,SAAgB,kBAAkB,OAAiB;CACjD,KAAK,MAAM,iBAAiB,gBAC1B,IAAK,MAAM,QAAQ,gBAAwB,SACzC,OAAO;CAGX,OAAO;AACT;AAEA,MAAa,iBAA4C;CACvD;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"load-matches.cjs","names":[],"sources":["../../src/load-matches.ts"],"sourcesContent":["import { isServer } from '@tanstack/router-core/isServer'\nimport { invariant } from './invariant'\nimport { createControlledPromise, isPromise } from './utils'\nimport { isNotFound } from './not-found'\nimport { rootRouteId } from './root'\nimport { isRedirect } from './redirect'\nimport type { NotFoundError } from './not-found'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyRoute,\n BeforeLoadContextOptions,\n LoaderFnContext,\n SsrContextOptions,\n} from './route'\nimport type { AnyRouteMatch, MakeRouteMatch } from './Matches'\nimport type { AnyRouter, SSROption, UpdateMatchFn } from './router'\n\n/**\n * An object of this shape is created when calling `loadMatches`.\n * It contains everything we need for all other functions in this file\n * to work. (It's basically the function's argument, plus a few mutable states)\n */\ntype InnerLoadContext = {\n /** the calling router instance */\n router: AnyRouter\n location: ParsedLocation\n /** mutable state, scoped to a `loadMatches` call */\n firstBadMatchIndex?: number\n /** mutable state, scoped to a `loadMatches` call */\n rendered?: boolean\n serialError?: unknown\n updateMatch: UpdateMatchFn\n matches: Array<AnyRouteMatch>\n preload?: boolean\n forceStaleReload?: boolean\n onReady?: () => Promise<void>\n sync?: boolean\n}\n\nconst triggerOnReady = (inner: InnerLoadContext): void | Promise<void> => {\n if (!inner.rendered) {\n inner.rendered = true\n return inner.onReady?.()\n }\n}\n\nconst hasForcePendingActiveMatch = (router: AnyRouter): boolean => {\n return router.stores.matchesId.get().some((matchId) => {\n return router.stores.matchStores.get(matchId)?.get()._forcePending\n })\n}\n\nconst resolvePreload = (inner: InnerLoadContext, matchId: string): boolean => {\n return !!(inner.preload && !inner.router.stores.matchStores.has(matchId))\n}\n\n/**\n * Builds the accumulated context from router options and all matches up to (and optionally including) the given index.\n * Merges __routeContext and __beforeLoadContext from each match.\n */\nconst buildMatchContext = (\n inner: InnerLoadContext,\n index: number,\n includeCurrentMatch: boolean = true,\n): Record<string, unknown> => {\n const context: Record<string, unknown> = {\n ...(inner.router.options.context ?? {}),\n }\n const end = includeCurrentMatch ? index : index - 1\n for (let i = 0; i <= end; i++) {\n const innerMatch = inner.matches[i]\n if (!innerMatch) continue\n const m = inner.router.getMatch(innerMatch.id)\n if (!m) continue\n Object.assign(context, m.__routeContext, m.__beforeLoadContext)\n }\n return context\n}\n\nconst getNotFoundBoundaryIndex = (\n inner: InnerLoadContext,\n err: NotFoundError,\n): number | undefined => {\n if (!inner.matches.length) {\n return undefined\n }\n\n const requestedRouteId = err.routeId\n const matchedRootIndex = inner.matches.findIndex(\n (m) => m.routeId === inner.router.routeTree.id,\n )\n const rootIndex = matchedRootIndex >= 0 ? matchedRootIndex : 0\n\n let startIndex = requestedRouteId\n ? inner.matches.findIndex((match) => match.routeId === requestedRouteId)\n : (inner.firstBadMatchIndex ?? inner.matches.length - 1)\n\n if (startIndex < 0) {\n startIndex = rootIndex\n }\n\n for (let i = startIndex; i >= 0; i--) {\n const match = inner.matches[i]!\n const route = inner.router.looseRoutesById[match.routeId]!\n if (route.options.notFoundComponent) {\n return i\n }\n }\n\n // If no boundary component is found, preserve explicit routeId targeting behavior,\n // otherwise default to root for untargeted notFounds.\n return requestedRouteId ? startIndex : rootIndex\n}\n\nconst handleRedirectAndNotFound = (\n inner: InnerLoadContext,\n match: AnyRouteMatch | undefined,\n err: unknown,\n): void => {\n if (!isRedirect(err) && !isNotFound(err)) return\n\n if (isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) {\n throw err\n }\n\n // in case of a redirecting match during preload, the match does not exist\n if (match) {\n match._nonReactive.beforeLoadPromise?.resolve()\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.beforeLoadPromise = undefined\n match._nonReactive.loaderPromise = undefined\n\n match._nonReactive.error = err\n\n inner.updateMatch(match.id, (prev) => ({\n ...prev,\n status: isRedirect(err)\n ? 'redirected'\n : isNotFound(err)\n ? 'notFound'\n : prev.status === 'pending'\n ? 'success'\n : prev.status,\n context: buildMatchContext(inner, match.index),\n isFetching: false,\n error: err,\n }))\n\n if (isNotFound(err) && !err.routeId) {\n // Stamp the throwing match's routeId so that the finalization step in\n // loadMatches knows where the notFound originated. The actual boundary\n // resolution (walking up to the nearest notFoundComponent) is deferred to\n // the finalization step, where firstBadMatchIndex is stable and\n // headMaxIndex can be capped correctly.\n err.routeId = match.routeId\n }\n\n match._nonReactive.loadPromise?.resolve()\n }\n\n if (isRedirect(err)) {\n inner.rendered = true\n err.options._fromLocation = inner.location\n err.redirectHandled = true\n err = inner.router.resolveRedirect(err)\n }\n\n throw err\n}\n\nconst shouldSkipLoader = (\n inner: InnerLoadContext,\n matchId: string,\n): boolean => {\n const match = inner.router.getMatch(matchId)\n if (!match) {\n return true\n }\n // upon hydration, we skip the loader if the match has been dehydrated on the server\n if (!(isServer ?? inner.router.isServer) && match._nonReactive.dehydrated) {\n return true\n }\n\n if ((isServer ?? inner.router.isServer) && match.ssr === false) {\n return true\n }\n\n return false\n}\n\nconst syncMatchContext = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n): void => {\n const nextContext = buildMatchContext(inner, index)\n\n inner.updateMatch(matchId, (prev) => {\n return {\n ...prev,\n context: nextContext,\n }\n })\n}\n\nconst handleSerialError = (\n inner: InnerLoadContext,\n index: number,\n err: any,\n): void => {\n const { id: matchId, routeId } = inner.matches[index]!\n const route = inner.router.looseRoutesById[routeId]!\n\n // Much like suspense, we use a promise here to know if\n // we've been outdated by a new loadMatches call and\n // should abort the current async operation\n if (err instanceof Promise) {\n throw err\n }\n\n inner.firstBadMatchIndex ??= index\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)\n\n try {\n route.options.onError?.(err)\n } catch (errorHandlerErr) {\n err = errorHandlerErr\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)\n }\n\n inner.updateMatch(matchId, (prev) => {\n prev._nonReactive.beforeLoadPromise?.resolve()\n prev._nonReactive.beforeLoadPromise = undefined\n prev._nonReactive.loadPromise?.resolve()\n\n return {\n ...prev,\n error: err,\n status: 'error',\n isFetching: false,\n updatedAt: Date.now(),\n abortController: new AbortController(),\n }\n })\n\n if (!inner.preload && !isRedirect(err) && !isNotFound(err)) {\n inner.serialError ??= err\n }\n}\n\nconst isBeforeLoadSsr = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n route: AnyRoute,\n): void | Promise<void> => {\n const existingMatch = inner.router.getMatch(matchId)!\n const parentMatchId = inner.matches[index - 1]?.id\n const parentMatch = parentMatchId\n ? inner.router.getMatch(parentMatchId)!\n : undefined\n\n // in SPA mode, only SSR the root route\n if (inner.router.isShell()) {\n existingMatch.ssr = route.id === rootRouteId\n return\n }\n\n if (parentMatch?.ssr === false) {\n existingMatch.ssr = false\n return\n }\n\n const parentOverride = (tempSsr: SSROption) => {\n if (tempSsr === true && parentMatch?.ssr === 'data-only') {\n return 'data-only'\n }\n return tempSsr\n }\n\n const defaultSsr = inner.router.options.defaultSsr ?? true\n\n if (route.options.ssr === undefined) {\n existingMatch.ssr = parentOverride(defaultSsr)\n return\n }\n\n if (typeof route.options.ssr !== 'function') {\n existingMatch.ssr = parentOverride(route.options.ssr)\n return\n }\n const { search, params } = existingMatch\n\n const ssrFnContext: SsrContextOptions<any, any, any> = {\n search: makeMaybe(search, existingMatch.searchError),\n params: makeMaybe(params, existingMatch.paramsError),\n location: inner.location,\n matches: inner.matches.map((match) => ({\n index: match.index,\n pathname: match.pathname,\n fullPath: match.fullPath,\n staticData: match.staticData,\n id: match.id,\n routeId: match.routeId,\n search: makeMaybe(match.search, match.searchError),\n params: makeMaybe(match.params, match.paramsError),\n ssr: match.ssr,\n })),\n }\n\n const tempSsr = route.options.ssr(ssrFnContext)\n if (isPromise(tempSsr)) {\n return tempSsr.then((ssr) => {\n existingMatch.ssr = parentOverride(ssr ?? defaultSsr)\n })\n }\n\n existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr)\n return\n}\n\nconst setupPendingTimeout = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n match: AnyRouteMatch,\n): void => {\n if (match._nonReactive.pendingTimeout !== undefined) return\n\n const pendingMs =\n route.options.pendingMs ?? inner.router.options.defaultPendingMs\n const shouldPending = !!(\n inner.onReady &&\n !(isServer ?? inner.router.isServer) &&\n !resolvePreload(inner, matchId) &&\n (route.options.loader ||\n route.options.beforeLoad ||\n routeNeedsPreload(route)) &&\n typeof pendingMs === 'number' &&\n pendingMs !== Infinity &&\n (route.options.pendingComponent ??\n (inner.router.options as any)?.defaultPendingComponent)\n )\n\n if (shouldPending) {\n const pendingTimeout = setTimeout(() => {\n // Update the match and prematurely resolve the loadMatches promise so that\n // the pending component can start rendering\n triggerOnReady(inner)\n }, pendingMs)\n match._nonReactive.pendingTimeout = pendingTimeout\n }\n}\n\nconst preBeforeLoadSetup = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n): void | Promise<void> => {\n const existingMatch = inner.router.getMatch(matchId)!\n\n // If we are in the middle of a load, either of these will be present\n // (not to be confused with `loadPromise`, which is always defined)\n if (\n !existingMatch._nonReactive.beforeLoadPromise &&\n !existingMatch._nonReactive.loaderPromise\n )\n return\n\n setupPendingTimeout(inner, matchId, route, existingMatch)\n\n const then = () => {\n const match = inner.router.getMatch(matchId)!\n if (\n match.preload &&\n (match.status === 'redirected' || match.status === 'notFound')\n ) {\n handleRedirectAndNotFound(inner, match, match.error)\n }\n }\n\n // Wait for the previous beforeLoad to resolve before we continue\n return existingMatch._nonReactive.beforeLoadPromise\n ? existingMatch._nonReactive.beforeLoadPromise.then(then)\n : then()\n}\n\nconst executeBeforeLoad = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n route: AnyRoute,\n): void | Promise<void> => {\n const match = inner.router.getMatch(matchId)!\n\n // explicitly capture the previous loadPromise\n let prevLoadPromise = match._nonReactive.loadPromise\n match._nonReactive.loadPromise = createControlledPromise<void>(() => {\n prevLoadPromise?.resolve()\n prevLoadPromise = undefined\n })\n\n const { paramsError, searchError } = match\n\n if (paramsError) {\n handleSerialError(inner, index, paramsError)\n }\n\n if (searchError) {\n handleSerialError(inner, index, searchError)\n }\n\n setupPendingTimeout(inner, matchId, route, match)\n\n const abortController = new AbortController()\n\n let isPending = false\n const pending = () => {\n if (isPending) return\n isPending = true\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: 'beforeLoad',\n fetchCount: prev.fetchCount + 1,\n abortController,\n // Note: We intentionally don't update context here.\n // Context should only be updated after beforeLoad resolves to avoid\n // components seeing incomplete context during async beforeLoad execution.\n }))\n }\n\n const resolve = () => {\n match._nonReactive.beforeLoadPromise?.resolve()\n match._nonReactive.beforeLoadPromise = undefined\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: false,\n }))\n }\n\n // if there is no `beforeLoad` option, just mark as pending and resolve\n // Context will be updated later in loadRouteMatch after loader completes\n if (!route.options.beforeLoad) {\n inner.router.batch(() => {\n pending()\n resolve()\n })\n return\n }\n\n match._nonReactive.beforeLoadPromise = createControlledPromise<void>()\n\n // Build context from all parent matches, excluding current match's __beforeLoadContext\n // (since we're about to execute beforeLoad for this match)\n const context = {\n ...buildMatchContext(inner, index, false),\n ...match.__routeContext,\n }\n const { search, params, cause } = match\n const preload = resolvePreload(inner, matchId)\n const beforeLoadFnContext: BeforeLoadContextOptions<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > = {\n search,\n abortController,\n params,\n preload,\n context,\n location: inner.location,\n navigate: (opts: any) =>\n inner.router.navigate({\n ...opts,\n _fromLocation: inner.location,\n }),\n buildLocation: inner.router.buildLocation,\n cause: preload ? 'preload' : cause,\n matches: inner.matches,\n routeId: route.id,\n ...inner.router.options.additionalContext,\n }\n\n const updateContext = (beforeLoadContext: any) => {\n if (beforeLoadContext === undefined) {\n inner.router.batch(() => {\n pending()\n resolve()\n })\n return\n }\n if (isRedirect(beforeLoadContext) || isNotFound(beforeLoadContext)) {\n pending()\n handleSerialError(inner, index, beforeLoadContext)\n }\n\n inner.router.batch(() => {\n pending()\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n __beforeLoadContext: beforeLoadContext,\n }))\n resolve()\n })\n }\n\n let beforeLoadContext\n try {\n beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext)\n if (isPromise(beforeLoadContext)) {\n pending()\n return beforeLoadContext\n .catch((err) => {\n handleSerialError(inner, index, err)\n })\n .then(updateContext)\n }\n } catch (err) {\n pending()\n handleSerialError(inner, index, err)\n }\n\n updateContext(beforeLoadContext)\n return\n}\n\nconst handleBeforeLoad = (\n inner: InnerLoadContext,\n index: number,\n): void | Promise<void> => {\n const { id: matchId, routeId } = inner.matches[index]!\n const route = inner.router.looseRoutesById[routeId]!\n\n const serverSsr = () => {\n // on the server, determine whether SSR the current match or not\n if (isServer ?? inner.router.isServer) {\n const maybePromise = isBeforeLoadSsr(inner, matchId, index, route)\n if (isPromise(maybePromise)) return maybePromise.then(queueExecution)\n }\n return queueExecution()\n }\n\n const execute = () => executeBeforeLoad(inner, matchId, index, route)\n\n const queueExecution = () => {\n if (shouldSkipLoader(inner, matchId)) return\n const result = preBeforeLoadSetup(inner, matchId, route)\n return isPromise(result) ? result.then(execute) : execute()\n }\n\n return serverSsr()\n}\n\nconst executeHead = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n): void | Promise<\n Pick<\n AnyRouteMatch,\n 'meta' | 'links' | 'headScripts' | 'headers' | 'scripts' | 'styles'\n >\n> => {\n const match = inner.router.getMatch(matchId)\n // in case of a redirecting match during preload, the match does not exist\n if (!match) {\n return\n }\n if (!route.options.head && !route.options.scripts && !route.options.headers) {\n return\n }\n const assetContext = {\n ssr: inner.router.options.ssr,\n matches: inner.matches,\n match,\n params: match.params,\n loaderData: match.loaderData,\n }\n\n return Promise.all([\n route.options.head?.(assetContext),\n route.options.scripts?.(assetContext),\n route.options.headers?.(assetContext),\n ]).then(([headFnContent, scripts, headers]) => {\n const meta = headFnContent?.meta\n const links = headFnContent?.links\n const headScripts = headFnContent?.scripts\n const styles = headFnContent?.styles\n\n return {\n meta,\n links,\n headScripts,\n headers,\n scripts,\n styles,\n }\n })\n}\n\nconst getLoaderContext = (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n matchId: string,\n index: number,\n route: AnyRoute,\n): LoaderFnContext => {\n const parentMatchPromise = matchPromises[index - 1] as any\n const { params, loaderDeps, abortController, cause } =\n inner.router.getMatch(matchId)!\n\n const context = buildMatchContext(inner, index)\n\n const preload = resolvePreload(inner, matchId)\n\n return {\n params,\n deps: loaderDeps,\n preload: !!preload,\n parentMatchPromise,\n abortController,\n context,\n location: inner.location,\n navigate: (opts) =>\n inner.router.navigate({\n ...opts,\n _fromLocation: inner.location,\n }),\n cause: preload ? 'preload' : cause,\n route,\n ...inner.router.options.additionalContext,\n }\n}\n\nconst runLoader = async (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n matchId: string,\n index: number,\n route: AnyRoute,\n): Promise<void> => {\n try {\n // If the Matches component rendered\n // the pending component and needs to show it for\n // a minimum duration, we''ll wait for it to resolve\n // before committing to the match and resolving\n // the loadPromise\n\n const match = inner.router.getMatch(matchId)!\n\n // Actually run the loader and handle the result\n try {\n if (!(isServer ?? inner.router.isServer) || match.ssr === true) {\n loadRouteChunk(route)\n }\n\n // Kick off the loader!\n const routeLoader = route.options.loader\n const loader =\n typeof routeLoader === 'function' ? routeLoader : routeLoader?.handler\n const loaderResult = loader?.(\n getLoaderContext(inner, matchPromises, matchId, index, route),\n )\n const loaderResultIsPromise = !!loader && isPromise(loaderResult)\n\n const willLoadSomething = !!(\n loaderResultIsPromise ||\n route._lazyPromise ||\n route._componentsPromise ||\n route.options.head ||\n route.options.scripts ||\n route.options.headers ||\n match._nonReactive.minPendingPromise\n )\n\n if (willLoadSomething) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: 'loader',\n }))\n }\n\n if (loader) {\n const loaderData = loaderResultIsPromise\n ? await loaderResult\n : loaderResult\n\n handleRedirectAndNotFound(\n inner,\n inner.router.getMatch(matchId),\n loaderData,\n )\n if (loaderData !== undefined) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n loaderData,\n }))\n }\n }\n\n // Lazy option can modify the route options,\n // so we need to wait for it to resolve before\n // we can use the options\n if (route._lazyPromise) await route._lazyPromise\n const pendingPromise = match._nonReactive.minPendingPromise\n if (pendingPromise) await pendingPromise\n\n // Last but not least, wait for the components\n // to be preloaded before we resolve the match\n if (route._componentsPromise) await route._componentsPromise\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n error: undefined,\n context: buildMatchContext(inner, index),\n status: 'success',\n isFetching: false,\n updatedAt: Date.now(),\n }))\n } catch (e) {\n let error = e\n\n if ((error as any)?.name === 'AbortError') {\n if (match.abortController.signal.aborted) {\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loaderPromise = undefined\n return\n }\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n status: prev.status === 'pending' ? 'success' : prev.status,\n isFetching: false,\n context: buildMatchContext(inner, index),\n }))\n return\n }\n\n const pendingPromise = match._nonReactive.minPendingPromise\n if (pendingPromise) await pendingPromise\n\n if (isNotFound(e)) {\n await (route.options.notFoundComponent as any)?.preload?.()\n }\n\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e)\n\n try {\n route.options.onError?.(e)\n } catch (onErrorError) {\n error = onErrorError\n handleRedirectAndNotFound(\n inner,\n inner.router.getMatch(matchId),\n onErrorError,\n )\n }\n if (!isRedirect(error) && !isNotFound(error)) {\n await loadRouteChunk(route, ['errorComponent'])\n }\n\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n error,\n context: buildMatchContext(inner, index),\n status: 'error',\n isFetching: false,\n }))\n }\n } catch (err) {\n const match = inner.router.getMatch(matchId)\n // in case of a redirecting match during preload, the match does not exist\n if (match) {\n match._nonReactive.loaderPromise = undefined\n }\n handleRedirectAndNotFound(inner, match, err)\n }\n}\n\nconst loadRouteMatch = async (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n index: number,\n): Promise<AnyRouteMatch> => {\n async function handleLoader(\n preload: boolean,\n prevMatch: AnyRouteMatch,\n previousRouteMatchId: string | undefined,\n match: AnyRouteMatch,\n route: AnyRoute,\n ) {\n const age = Date.now() - prevMatch.updatedAt\n\n const staleAge = preload\n ? (route.options.preloadStaleTime ??\n inner.router.options.defaultPreloadStaleTime ??\n 30_000) // 30 seconds for preloads by default\n : (route.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0)\n\n const shouldReloadOption = route.options.shouldReload\n\n // Default to reloading the route all the time\n // Allow shouldReload to get the last say,\n // if provided.\n const shouldReload =\n typeof shouldReloadOption === 'function'\n ? shouldReloadOption(\n getLoaderContext(inner, matchPromises, matchId, index, route),\n )\n : shouldReloadOption\n\n // If the route is successful and still fresh, just resolve\n const { status, invalid } = match\n const staleMatchShouldReload =\n age >= staleAge &&\n (!!inner.forceStaleReload ||\n match.cause === 'enter' ||\n (previousRouteMatchId !== undefined &&\n previousRouteMatchId !== match.id))\n loaderShouldRunAsync =\n status === 'success' &&\n (invalid || (shouldReload ?? staleMatchShouldReload))\n if (preload && route.options.preload === false) {\n // Do nothing\n } else if (\n loaderShouldRunAsync &&\n !inner.sync &&\n shouldReloadInBackground\n ) {\n loaderIsRunningAsync = true\n ;(async () => {\n try {\n await runLoader(inner, matchPromises, matchId, index, route)\n const match = inner.router.getMatch(matchId)!\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loadPromise?.resolve()\n match._nonReactive.loaderPromise = undefined\n match._nonReactive.loadPromise = undefined\n } catch (err) {\n if (isRedirect(err)) {\n await inner.router.navigate(err.options)\n }\n }\n })()\n } else if (status !== 'success' || loaderShouldRunAsync) {\n await runLoader(inner, matchPromises, matchId, index, route)\n } else {\n syncMatchContext(inner, matchId, index)\n }\n }\n\n const { id: matchId, routeId } = inner.matches[index]!\n let loaderShouldRunAsync = false\n let loaderIsRunningAsync = false\n const route = inner.router.looseRoutesById[routeId]!\n const routeLoader = route.options.loader\n const shouldReloadInBackground =\n ((typeof routeLoader === 'function'\n ? undefined\n : routeLoader?.staleReloadMode) ??\n inner.router.options.defaultStaleReloadMode) !== 'blocking'\n\n if (shouldSkipLoader(inner, matchId)) {\n const match = inner.router.getMatch(matchId)\n if (!match) {\n return inner.matches[index]!\n }\n\n syncMatchContext(inner, matchId, index)\n\n if (isServer ?? inner.router.isServer) {\n return inner.router.getMatch(matchId)!\n }\n } else {\n const prevMatch = inner.router.getMatch(matchId)! // This is where all of the stale-while-revalidate magic happens\n const activeIdAtIndex = inner.router.stores.matchesId.get()[index]\n const activeAtIndex =\n (activeIdAtIndex &&\n inner.router.stores.matchStores.get(activeIdAtIndex)) ||\n null\n const previousRouteMatchId =\n activeAtIndex?.routeId === routeId\n ? activeIdAtIndex\n : inner.router.stores.matches.get().find((d) => d.routeId === routeId)\n ?.id\n const preload = resolvePreload(inner, matchId)\n\n // there is a loaderPromise, so we are in the middle of a load\n if (prevMatch._nonReactive.loaderPromise) {\n // do not block if we already have stale data we can show\n // but only if the ongoing load is not a preload since error handling is different for preloads\n // and we don't want to swallow errors\n if (\n prevMatch.status === 'success' &&\n !inner.sync &&\n !prevMatch.preload &&\n shouldReloadInBackground\n ) {\n return prevMatch\n }\n await prevMatch._nonReactive.loaderPromise\n const match = inner.router.getMatch(matchId)!\n const error = match._nonReactive.error || match.error\n if (error) {\n handleRedirectAndNotFound(inner, match, error)\n }\n\n if (match.status === 'pending') {\n await handleLoader(\n preload,\n prevMatch,\n previousRouteMatchId,\n match,\n route,\n )\n }\n } else {\n const nextPreload =\n preload && !inner.router.stores.matchStores.has(matchId)\n const match = inner.router.getMatch(matchId)!\n match._nonReactive.loaderPromise = createControlledPromise<void>()\n if (nextPreload !== match.preload) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n preload: nextPreload,\n }))\n }\n\n await handleLoader(preload, prevMatch, previousRouteMatchId, match, route)\n }\n }\n const match = inner.router.getMatch(matchId)!\n if (!loaderIsRunningAsync) {\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loadPromise?.resolve()\n match._nonReactive.loadPromise = undefined\n }\n\n clearTimeout(match._nonReactive.pendingTimeout)\n match._nonReactive.pendingTimeout = undefined\n if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = undefined\n match._nonReactive.dehydrated = undefined\n\n const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false\n if (nextIsFetching !== match.isFetching || match.invalid !== false) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: nextIsFetching,\n invalid: false,\n }))\n return inner.router.getMatch(matchId)!\n } else {\n return match\n }\n}\n\nexport async function loadMatches(arg: {\n router: AnyRouter\n location: ParsedLocation\n matches: Array<AnyRouteMatch>\n preload?: boolean\n forceStaleReload?: boolean\n onReady?: () => Promise<void>\n updateMatch: UpdateMatchFn\n sync?: boolean\n}): Promise<Array<MakeRouteMatch>> {\n const inner: InnerLoadContext = arg\n const matchPromises: Array<Promise<AnyRouteMatch>> = []\n\n // make sure the pending component is immediately rendered when hydrating a match that is not SSRed\n // the pending component was already rendered on the server and we want to keep it shown on the client until minPendingMs is reached\n if (\n !(isServer ?? inner.router.isServer) &&\n hasForcePendingActiveMatch(inner.router)\n ) {\n triggerOnReady(inner)\n }\n\n let beforeLoadNotFound: NotFoundError | undefined\n\n // Execute all beforeLoads one by one\n for (let i = 0; i < inner.matches.length; i++) {\n try {\n const beforeLoad = handleBeforeLoad(inner, i)\n if (isPromise(beforeLoad)) await beforeLoad\n } catch (err) {\n if (isRedirect(err)) {\n throw err\n }\n if (isNotFound(err)) {\n beforeLoadNotFound = err\n } else {\n if (!inner.preload) throw err\n }\n break\n }\n\n if (inner.serialError || inner.firstBadMatchIndex != null) {\n break\n }\n }\n\n // Execute loaders once, with max index adapted for beforeLoad notFound handling.\n const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length\n\n const boundaryIndex =\n beforeLoadNotFound && !inner.preload\n ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound)\n : undefined\n\n const maxIndexExclusive =\n beforeLoadNotFound && inner.preload\n ? 0\n : boundaryIndex !== undefined\n ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive)\n : baseMaxIndexExclusive\n\n let firstNotFound: NotFoundError | undefined\n let firstUnhandledRejection: unknown\n\n for (let i = 0; i < maxIndexExclusive; i++) {\n matchPromises.push(loadRouteMatch(inner, matchPromises, i))\n }\n\n try {\n await Promise.all(matchPromises)\n } catch {\n const settled = await Promise.allSettled(matchPromises)\n\n for (const result of settled) {\n if (result.status !== 'rejected') continue\n\n const reason = result.reason\n if (isRedirect(reason)) {\n throw reason\n }\n if (isNotFound(reason)) {\n firstNotFound ??= reason\n } else {\n firstUnhandledRejection ??= reason\n }\n }\n\n if (firstUnhandledRejection !== undefined) {\n throw firstUnhandledRejection\n }\n }\n\n const notFoundToThrow =\n firstNotFound ??\n (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : undefined)\n\n let headMaxIndex =\n inner.firstBadMatchIndex !== undefined\n ? inner.firstBadMatchIndex\n : inner.matches.length - 1\n\n if (!notFoundToThrow && beforeLoadNotFound && inner.preload) {\n return inner.matches\n }\n\n if (notFoundToThrow) {\n // Determine once which matched route will actually render the\n // notFoundComponent, then pass this precomputed index through the remaining\n // finalization steps.\n // This can differ from the throwing route when routeId targets an ancestor\n // boundary (or when bubbling resolves to a parent/root boundary).\n const renderedBoundaryIndex = getNotFoundBoundaryIndex(\n inner,\n notFoundToThrow,\n )\n\n if (renderedBoundaryIndex === undefined) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Invariant failed: Could not find match for notFound boundary',\n )\n }\n\n invariant()\n }\n const boundaryMatch = inner.matches[renderedBoundaryIndex]!\n\n const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId]!\n const defaultNotFoundComponent = (inner.router.options as any)\n ?.defaultNotFoundComponent\n\n // Ensure a notFoundComponent exists on the boundary route\n if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) {\n boundaryRoute.options.notFoundComponent = defaultNotFoundComponent\n }\n\n notFoundToThrow.routeId = boundaryMatch.routeId\n\n const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id\n\n inner.updateMatch(boundaryMatch.id, (prev) => ({\n ...prev,\n ...(boundaryIsRoot\n ? // For root boundary, use globalNotFound so the root component's\n // shell still renders and <Outlet> handles the not-found display,\n // instead of replacing the entire root shell via status='notFound'.\n { status: 'success' as const, globalNotFound: true, error: undefined }\n : // For non-root boundaries, set status:'notFound' so MatchInner\n // renders the notFoundComponent directly.\n { status: 'notFound' as const, error: notFoundToThrow }),\n isFetching: false,\n }))\n\n headMaxIndex = renderedBoundaryIndex\n\n // Ensure the rendering boundary route chunk (and its lazy components, including\n // lazy notFoundComponent) is loaded before we continue to head execution/render.\n await loadRouteChunk(boundaryRoute, ['notFoundComponent'])\n } else if (!inner.preload) {\n // Clear stale root global-not-found state on normal navigations that do not\n // throw notFound. This must live here (instead of only in runLoader success)\n // because the root loader may be skipped when data is still fresh.\n const rootMatch = inner.matches[0]!\n // `rootMatch` is the next match for this navigation. If it is not global\n // not-found, then any currently stored root global-not-found is stale.\n if (!rootMatch.globalNotFound) {\n // `currentRootMatch` is the current store state (from the previous\n // navigation/load). Update only when a stale flag is actually present.\n const currentRootMatch = inner.router.getMatch(rootMatch.id)\n if (currentRootMatch?.globalNotFound) {\n inner.updateMatch(rootMatch.id, (prev) => ({\n ...prev,\n globalNotFound: false,\n error: undefined,\n }))\n }\n }\n }\n\n // When a serial error occurred (e.g. beforeLoad threw a regular Error),\n // the erroring route's lazy chunk wasn't loaded because loaders were skipped.\n // We need to load it so the code-split errorComponent is available for rendering.\n if (inner.serialError && inner.firstBadMatchIndex !== undefined) {\n const errorRoute =\n inner.router.looseRoutesById[\n inner.matches[inner.firstBadMatchIndex]!.routeId\n ]!\n await loadRouteChunk(errorRoute, ['errorComponent'])\n }\n\n // serially execute heads once after loaders/notFound handling, ensuring\n // all head functions get a chance even if one throws.\n for (let i = 0; i <= headMaxIndex; i++) {\n const match = inner.matches[i]!\n const { id: matchId, routeId } = match\n const route = inner.router.looseRoutesById[routeId]!\n try {\n const headResult = executeHead(inner, matchId, route)\n if (headResult) {\n const head = await headResult\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n ...head,\n }))\n }\n } catch (err) {\n console.error(`Error executing head for route ${routeId}:`, err)\n }\n }\n\n const readyPromise = triggerOnReady(inner)\n if (isPromise(readyPromise)) {\n await readyPromise\n }\n\n if (notFoundToThrow) {\n throw notFoundToThrow\n }\n\n if (inner.serialError && !inner.preload && !inner.onReady) {\n throw inner.serialError\n }\n\n return inner.matches\n}\n\nexport type RouteComponentType =\n | 'component'\n | 'errorComponent'\n | 'pendingComponent'\n | 'notFoundComponent'\n\nfunction preloadRouteComponents(\n route: AnyRoute,\n componentTypesToLoad: Array<RouteComponentType>,\n): Promise<void> | undefined {\n const preloads = componentTypesToLoad\n .map((type) => (route.options[type] as any)?.preload?.())\n .filter(Boolean)\n\n if (preloads.length === 0) return undefined\n\n return Promise.all(preloads) as any as Promise<void>\n}\n\nexport function loadRouteChunk(\n route: AnyRoute,\n componentTypesToLoad: Array<RouteComponentType> = componentTypes,\n) {\n if (!route._lazyLoaded && route._lazyPromise === undefined) {\n if (route.lazyFn) {\n route._lazyPromise = route.lazyFn().then((lazyRoute) => {\n // explicitly don't copy over the lazy route's id\n const { id: _id, ...options } = lazyRoute.options\n Object.assign(route.options, options)\n route._lazyLoaded = true\n route._lazyPromise = undefined // gc promise, we won't need it anymore\n })\n } else {\n route._lazyLoaded = true\n }\n }\n\n const runAfterLazy = () =>\n route._componentsLoaded\n ? undefined\n : componentTypesToLoad === componentTypes\n ? (() => {\n if (route._componentsPromise === undefined) {\n const componentsPromise = preloadRouteComponents(\n route,\n componentTypes,\n )\n\n if (componentsPromise) {\n route._componentsPromise = componentsPromise.then(() => {\n route._componentsLoaded = true\n route._componentsPromise = undefined // gc promise, we won't need it anymore\n })\n } else {\n route._componentsLoaded = true\n }\n }\n\n return route._componentsPromise\n })()\n : preloadRouteComponents(route, componentTypesToLoad)\n\n return route._lazyPromise\n ? route._lazyPromise.then(runAfterLazy)\n : runAfterLazy()\n}\n\nfunction makeMaybe<TValue, TError>(\n value: TValue,\n error: TError,\n): { status: 'success'; value: TValue } | { status: 'error'; error: TError } {\n if (error) {\n return { status: 'error' as const, error }\n }\n return { status: 'success' as const, value }\n}\n\nexport function routeNeedsPreload(route: AnyRoute) {\n for (const componentType of componentTypes) {\n if ((route.options[componentType] as any)?.preload) {\n return true\n }\n }\n return false\n}\n\nexport const componentTypes: Array<RouteComponentType> = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n 'notFoundComponent',\n] as const\n"],"mappings":";;;;;;;AAuCA,MAAM,kBAAkB,UAAkD;CACxE,IAAI,CAAC,MAAM,UAAU;EACnB,MAAM,WAAW;EACjB,OAAO,MAAM,UAAU;CACzB;AACF;AAEA,MAAM,8BAA8B,WAA+B;CACjE,OAAO,OAAO,OAAO,UAAU,IAAI,EAAE,MAAM,YAAY;EACrD,OAAO,OAAO,OAAO,YAAY,IAAI,OAAO,GAAG,IAAI,EAAE;CACvD,CAAC;AACH;AAEA,MAAM,kBAAkB,OAAyB,YAA6B;CAC5E,OAAO,CAAC,EAAE,MAAM,WAAW,CAAC,MAAM,OAAO,OAAO,YAAY,IAAI,OAAO;AACzE;;;;;AAMA,MAAM,qBACJ,OACA,OACA,sBAA+B,SACH;CAC5B,MAAM,UAAmC,EACvC,GAAI,MAAM,OAAO,QAAQ,WAAW,CAAC,EACvC;CACA,MAAM,MAAM,sBAAsB,QAAQ,QAAQ;CAClD,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK,KAAK;EAC7B,MAAM,aAAa,MAAM,QAAQ;EACjC,IAAI,CAAC,YAAY;EACjB,MAAM,IAAI,MAAM,OAAO,SAAS,WAAW,EAAE;EAC7C,IAAI,CAAC,GAAG;EACR,OAAO,OAAO,SAAS,EAAE,gBAAgB,EAAE,mBAAmB;CAChE;CACA,OAAO;AACT;AAEA,MAAM,4BACJ,OACA,QACuB;CACvB,IAAI,CAAC,MAAM,QAAQ,QACjB;CAGF,MAAM,mBAAmB,IAAI;CAC7B,MAAM,mBAAmB,MAAM,QAAQ,WACpC,MAAM,EAAE,YAAY,MAAM,OAAO,UAAU,EAC9C;CACA,MAAM,YAAY,oBAAoB,IAAI,mBAAmB;CAE7D,IAAI,aAAa,mBACb,MAAM,QAAQ,WAAW,UAAU,MAAM,YAAY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AAoB;CAE1D,OAAO,MAAM,eACT,MAAM,aAAa,KAAK,YAAY,IACpC,aAAa;AACnB;AAEA,SAAS,UACP,OACA,OAC2E;CAC3E,IAAI,OACF,OAAO;EAAE,QAAQ;EAAkB;CAAM;CAE3C,OAAO;EAAE,QAAQ;EAAoB;CAAM;AAC7C;AAEA,SAAgB,kBAAkB,OAAiB;CACjD,KAAK,MAAM,iBAAiB,gBAC1B,IAAK,MAAM,QAAQ,gBAAwB,SACzC,OAAO;CAGX,OAAO;AACT;AAEA,MAAa,iBAA4C;CACvD;CACA;CACA;CACA;AACF"}
@@ -91,11 +91,10 @@ const syncMatchContext = (inner, matchId, index) => {
91
91
  };
92
92
  });
93
93
  };
94
- const handleSerialError = (inner, index, err, routerCode) => {
94
+ const handleSerialError = (inner, index, err) => {
95
95
  const { id: matchId, routeId } = inner.matches[index];
96
96
  const route = inner.router.looseRoutesById[routeId];
97
97
  if (err instanceof Promise) throw err;
98
- err.routerCode = routerCode;
99
98
  inner.firstBadMatchIndex ??= index;
100
99
  handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
101
100
  try {
@@ -195,8 +194,8 @@ const executeBeforeLoad = (inner, matchId, index, route) => {
195
194
  prevLoadPromise = void 0;
196
195
  });
197
196
  const { paramsError, searchError } = match;
198
- if (paramsError) handleSerialError(inner, index, paramsError, "PARSE_PARAMS");
199
- if (searchError) handleSerialError(inner, index, searchError, "VALIDATE_SEARCH");
197
+ if (paramsError) handleSerialError(inner, index, paramsError);
198
+ if (searchError) handleSerialError(inner, index, searchError);
200
199
  setupPendingTimeout(inner, matchId, route, match);
201
200
  const abortController = new AbortController();
202
201
  let isPending = false;
@@ -259,7 +258,7 @@ const executeBeforeLoad = (inner, matchId, index, route) => {
259
258
  }
260
259
  if (isRedirect(beforeLoadContext) || isNotFound(beforeLoadContext)) {
261
260
  pending();
262
- handleSerialError(inner, index, beforeLoadContext, "BEFORE_LOAD");
261
+ handleSerialError(inner, index, beforeLoadContext);
263
262
  }
264
263
  inner.router.batch(() => {
265
264
  pending();
@@ -276,12 +275,12 @@ const executeBeforeLoad = (inner, matchId, index, route) => {
276
275
  if (isPromise(beforeLoadContext)) {
277
276
  pending();
278
277
  return beforeLoadContext.catch((err) => {
279
- handleSerialError(inner, index, err, "BEFORE_LOAD");
278
+ handleSerialError(inner, index, err);
280
279
  }).then(updateContext);
281
280
  }
282
281
  } catch (err) {
283
282
  pending();
284
- handleSerialError(inner, index, err, "BEFORE_LOAD");
283
+ handleSerialError(inner, index, err);
285
284
  }
286
285
  updateContext(beforeLoadContext);
287
286
  };
@@ -1 +1 @@
1
- {"version":3,"file":"load-matches.js","names":[],"sources":["../../src/load-matches.ts"],"sourcesContent":["import { isServer } from '@tanstack/router-core/isServer'\nimport { invariant } from './invariant'\nimport { createControlledPromise, isPromise } from './utils'\nimport { isNotFound } from './not-found'\nimport { rootRouteId } from './root'\nimport { isRedirect } from './redirect'\nimport type { NotFoundError } from './not-found'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyRoute,\n BeforeLoadContextOptions,\n LoaderFnContext,\n SsrContextOptions,\n} from './route'\nimport type { AnyRouteMatch, MakeRouteMatch } from './Matches'\nimport type { AnyRouter, SSROption, UpdateMatchFn } from './router'\n\n/**\n * An object of this shape is created when calling `loadMatches`.\n * It contains everything we need for all other functions in this file\n * to work. (It's basically the function's argument, plus a few mutable states)\n */\ntype InnerLoadContext = {\n /** the calling router instance */\n router: AnyRouter\n location: ParsedLocation\n /** mutable state, scoped to a `loadMatches` call */\n firstBadMatchIndex?: number\n /** mutable state, scoped to a `loadMatches` call */\n rendered?: boolean\n serialError?: unknown\n updateMatch: UpdateMatchFn\n matches: Array<AnyRouteMatch>\n preload?: boolean\n forceStaleReload?: boolean\n onReady?: () => Promise<void>\n sync?: boolean\n}\n\nconst triggerOnReady = (inner: InnerLoadContext): void | Promise<void> => {\n if (!inner.rendered) {\n inner.rendered = true\n return inner.onReady?.()\n }\n}\n\nconst hasForcePendingActiveMatch = (router: AnyRouter): boolean => {\n return router.stores.matchesId.get().some((matchId) => {\n return router.stores.matchStores.get(matchId)?.get()._forcePending\n })\n}\n\nconst resolvePreload = (inner: InnerLoadContext, matchId: string): boolean => {\n return !!(inner.preload && !inner.router.stores.matchStores.has(matchId))\n}\n\n/**\n * Builds the accumulated context from router options and all matches up to (and optionally including) the given index.\n * Merges __routeContext and __beforeLoadContext from each match.\n */\nconst buildMatchContext = (\n inner: InnerLoadContext,\n index: number,\n includeCurrentMatch: boolean = true,\n): Record<string, unknown> => {\n const context: Record<string, unknown> = {\n ...(inner.router.options.context ?? {}),\n }\n const end = includeCurrentMatch ? index : index - 1\n for (let i = 0; i <= end; i++) {\n const innerMatch = inner.matches[i]\n if (!innerMatch) continue\n const m = inner.router.getMatch(innerMatch.id)\n if (!m) continue\n Object.assign(context, m.__routeContext, m.__beforeLoadContext)\n }\n return context\n}\n\nconst getNotFoundBoundaryIndex = (\n inner: InnerLoadContext,\n err: NotFoundError,\n): number | undefined => {\n if (!inner.matches.length) {\n return undefined\n }\n\n const requestedRouteId = err.routeId\n const matchedRootIndex = inner.matches.findIndex(\n (m) => m.routeId === inner.router.routeTree.id,\n )\n const rootIndex = matchedRootIndex >= 0 ? matchedRootIndex : 0\n\n let startIndex = requestedRouteId\n ? inner.matches.findIndex((match) => match.routeId === requestedRouteId)\n : (inner.firstBadMatchIndex ?? inner.matches.length - 1)\n\n if (startIndex < 0) {\n startIndex = rootIndex\n }\n\n for (let i = startIndex; i >= 0; i--) {\n const match = inner.matches[i]!\n const route = inner.router.looseRoutesById[match.routeId]!\n if (route.options.notFoundComponent) {\n return i\n }\n }\n\n // If no boundary component is found, preserve explicit routeId targeting behavior,\n // otherwise default to root for untargeted notFounds.\n return requestedRouteId ? startIndex : rootIndex\n}\n\nconst handleRedirectAndNotFound = (\n inner: InnerLoadContext,\n match: AnyRouteMatch | undefined,\n err: unknown,\n): void => {\n if (!isRedirect(err) && !isNotFound(err)) return\n\n if (isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) {\n throw err\n }\n\n // in case of a redirecting match during preload, the match does not exist\n if (match) {\n match._nonReactive.beforeLoadPromise?.resolve()\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.beforeLoadPromise = undefined\n match._nonReactive.loaderPromise = undefined\n\n match._nonReactive.error = err\n\n inner.updateMatch(match.id, (prev) => ({\n ...prev,\n status: isRedirect(err)\n ? 'redirected'\n : isNotFound(err)\n ? 'notFound'\n : prev.status === 'pending'\n ? 'success'\n : prev.status,\n context: buildMatchContext(inner, match.index),\n isFetching: false,\n error: err,\n }))\n\n if (isNotFound(err) && !err.routeId) {\n // Stamp the throwing match's routeId so that the finalization step in\n // loadMatches knows where the notFound originated. The actual boundary\n // resolution (walking up to the nearest notFoundComponent) is deferred to\n // the finalization step, where firstBadMatchIndex is stable and\n // headMaxIndex can be capped correctly.\n err.routeId = match.routeId\n }\n\n match._nonReactive.loadPromise?.resolve()\n }\n\n if (isRedirect(err)) {\n inner.rendered = true\n err.options._fromLocation = inner.location\n err.redirectHandled = true\n err = inner.router.resolveRedirect(err)\n }\n\n throw err\n}\n\nconst shouldSkipLoader = (\n inner: InnerLoadContext,\n matchId: string,\n): boolean => {\n const match = inner.router.getMatch(matchId)\n if (!match) {\n return true\n }\n // upon hydration, we skip the loader if the match has been dehydrated on the server\n if (!(isServer ?? inner.router.isServer) && match._nonReactive.dehydrated) {\n return true\n }\n\n if ((isServer ?? inner.router.isServer) && match.ssr === false) {\n return true\n }\n\n return false\n}\n\nconst syncMatchContext = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n): void => {\n const nextContext = buildMatchContext(inner, index)\n\n inner.updateMatch(matchId, (prev) => {\n return {\n ...prev,\n context: nextContext,\n }\n })\n}\n\nconst handleSerialError = (\n inner: InnerLoadContext,\n index: number,\n err: any,\n routerCode: string,\n): void => {\n const { id: matchId, routeId } = inner.matches[index]!\n const route = inner.router.looseRoutesById[routeId]!\n\n // Much like suspense, we use a promise here to know if\n // we've been outdated by a new loadMatches call and\n // should abort the current async operation\n if (err instanceof Promise) {\n throw err\n }\n\n err.routerCode = routerCode\n inner.firstBadMatchIndex ??= index\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)\n\n try {\n route.options.onError?.(err)\n } catch (errorHandlerErr) {\n err = errorHandlerErr\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)\n }\n\n inner.updateMatch(matchId, (prev) => {\n prev._nonReactive.beforeLoadPromise?.resolve()\n prev._nonReactive.beforeLoadPromise = undefined\n prev._nonReactive.loadPromise?.resolve()\n\n return {\n ...prev,\n error: err,\n status: 'error',\n isFetching: false,\n updatedAt: Date.now(),\n abortController: new AbortController(),\n }\n })\n\n if (!inner.preload && !isRedirect(err) && !isNotFound(err)) {\n inner.serialError ??= err\n }\n}\n\nconst isBeforeLoadSsr = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n route: AnyRoute,\n): void | Promise<void> => {\n const existingMatch = inner.router.getMatch(matchId)!\n const parentMatchId = inner.matches[index - 1]?.id\n const parentMatch = parentMatchId\n ? inner.router.getMatch(parentMatchId)!\n : undefined\n\n // in SPA mode, only SSR the root route\n if (inner.router.isShell()) {\n existingMatch.ssr = route.id === rootRouteId\n return\n }\n\n if (parentMatch?.ssr === false) {\n existingMatch.ssr = false\n return\n }\n\n const parentOverride = (tempSsr: SSROption) => {\n if (tempSsr === true && parentMatch?.ssr === 'data-only') {\n return 'data-only'\n }\n return tempSsr\n }\n\n const defaultSsr = inner.router.options.defaultSsr ?? true\n\n if (route.options.ssr === undefined) {\n existingMatch.ssr = parentOverride(defaultSsr)\n return\n }\n\n if (typeof route.options.ssr !== 'function') {\n existingMatch.ssr = parentOverride(route.options.ssr)\n return\n }\n const { search, params } = existingMatch\n\n const ssrFnContext: SsrContextOptions<any, any, any> = {\n search: makeMaybe(search, existingMatch.searchError),\n params: makeMaybe(params, existingMatch.paramsError),\n location: inner.location,\n matches: inner.matches.map((match) => ({\n index: match.index,\n pathname: match.pathname,\n fullPath: match.fullPath,\n staticData: match.staticData,\n id: match.id,\n routeId: match.routeId,\n search: makeMaybe(match.search, match.searchError),\n params: makeMaybe(match.params, match.paramsError),\n ssr: match.ssr,\n })),\n }\n\n const tempSsr = route.options.ssr(ssrFnContext)\n if (isPromise(tempSsr)) {\n return tempSsr.then((ssr) => {\n existingMatch.ssr = parentOverride(ssr ?? defaultSsr)\n })\n }\n\n existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr)\n return\n}\n\nconst setupPendingTimeout = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n match: AnyRouteMatch,\n): void => {\n if (match._nonReactive.pendingTimeout !== undefined) return\n\n const pendingMs =\n route.options.pendingMs ?? inner.router.options.defaultPendingMs\n const shouldPending = !!(\n inner.onReady &&\n !(isServer ?? inner.router.isServer) &&\n !resolvePreload(inner, matchId) &&\n (route.options.loader ||\n route.options.beforeLoad ||\n routeNeedsPreload(route)) &&\n typeof pendingMs === 'number' &&\n pendingMs !== Infinity &&\n (route.options.pendingComponent ??\n (inner.router.options as any)?.defaultPendingComponent)\n )\n\n if (shouldPending) {\n const pendingTimeout = setTimeout(() => {\n // Update the match and prematurely resolve the loadMatches promise so that\n // the pending component can start rendering\n triggerOnReady(inner)\n }, pendingMs)\n match._nonReactive.pendingTimeout = pendingTimeout\n }\n}\n\nconst preBeforeLoadSetup = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n): void | Promise<void> => {\n const existingMatch = inner.router.getMatch(matchId)!\n\n // If we are in the middle of a load, either of these will be present\n // (not to be confused with `loadPromise`, which is always defined)\n if (\n !existingMatch._nonReactive.beforeLoadPromise &&\n !existingMatch._nonReactive.loaderPromise\n )\n return\n\n setupPendingTimeout(inner, matchId, route, existingMatch)\n\n const then = () => {\n const match = inner.router.getMatch(matchId)!\n if (\n match.preload &&\n (match.status === 'redirected' || match.status === 'notFound')\n ) {\n handleRedirectAndNotFound(inner, match, match.error)\n }\n }\n\n // Wait for the previous beforeLoad to resolve before we continue\n return existingMatch._nonReactive.beforeLoadPromise\n ? existingMatch._nonReactive.beforeLoadPromise.then(then)\n : then()\n}\n\nconst executeBeforeLoad = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n route: AnyRoute,\n): void | Promise<void> => {\n const match = inner.router.getMatch(matchId)!\n\n // explicitly capture the previous loadPromise\n let prevLoadPromise = match._nonReactive.loadPromise\n match._nonReactive.loadPromise = createControlledPromise<void>(() => {\n prevLoadPromise?.resolve()\n prevLoadPromise = undefined\n })\n\n const { paramsError, searchError } = match\n\n if (paramsError) {\n handleSerialError(inner, index, paramsError, 'PARSE_PARAMS')\n }\n\n if (searchError) {\n handleSerialError(inner, index, searchError, 'VALIDATE_SEARCH')\n }\n\n setupPendingTimeout(inner, matchId, route, match)\n\n const abortController = new AbortController()\n\n let isPending = false\n const pending = () => {\n if (isPending) return\n isPending = true\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: 'beforeLoad',\n fetchCount: prev.fetchCount + 1,\n abortController,\n // Note: We intentionally don't update context here.\n // Context should only be updated after beforeLoad resolves to avoid\n // components seeing incomplete context during async beforeLoad execution.\n }))\n }\n\n const resolve = () => {\n match._nonReactive.beforeLoadPromise?.resolve()\n match._nonReactive.beforeLoadPromise = undefined\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: false,\n }))\n }\n\n // if there is no `beforeLoad` option, just mark as pending and resolve\n // Context will be updated later in loadRouteMatch after loader completes\n if (!route.options.beforeLoad) {\n inner.router.batch(() => {\n pending()\n resolve()\n })\n return\n }\n\n match._nonReactive.beforeLoadPromise = createControlledPromise<void>()\n\n // Build context from all parent matches, excluding current match's __beforeLoadContext\n // (since we're about to execute beforeLoad for this match)\n const context = {\n ...buildMatchContext(inner, index, false),\n ...match.__routeContext,\n }\n const { search, params, cause } = match\n const preload = resolvePreload(inner, matchId)\n const beforeLoadFnContext: BeforeLoadContextOptions<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > = {\n search,\n abortController,\n params,\n preload,\n context,\n location: inner.location,\n navigate: (opts: any) =>\n inner.router.navigate({\n ...opts,\n _fromLocation: inner.location,\n }),\n buildLocation: inner.router.buildLocation,\n cause: preload ? 'preload' : cause,\n matches: inner.matches,\n routeId: route.id,\n ...inner.router.options.additionalContext,\n }\n\n const updateContext = (beforeLoadContext: any) => {\n if (beforeLoadContext === undefined) {\n inner.router.batch(() => {\n pending()\n resolve()\n })\n return\n }\n if (isRedirect(beforeLoadContext) || isNotFound(beforeLoadContext)) {\n pending()\n handleSerialError(inner, index, beforeLoadContext, 'BEFORE_LOAD')\n }\n\n inner.router.batch(() => {\n pending()\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n __beforeLoadContext: beforeLoadContext,\n }))\n resolve()\n })\n }\n\n let beforeLoadContext\n try {\n beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext)\n if (isPromise(beforeLoadContext)) {\n pending()\n return beforeLoadContext\n .catch((err) => {\n handleSerialError(inner, index, err, 'BEFORE_LOAD')\n })\n .then(updateContext)\n }\n } catch (err) {\n pending()\n handleSerialError(inner, index, err, 'BEFORE_LOAD')\n }\n\n updateContext(beforeLoadContext)\n return\n}\n\nconst handleBeforeLoad = (\n inner: InnerLoadContext,\n index: number,\n): void | Promise<void> => {\n const { id: matchId, routeId } = inner.matches[index]!\n const route = inner.router.looseRoutesById[routeId]!\n\n const serverSsr = () => {\n // on the server, determine whether SSR the current match or not\n if (isServer ?? inner.router.isServer) {\n const maybePromise = isBeforeLoadSsr(inner, matchId, index, route)\n if (isPromise(maybePromise)) return maybePromise.then(queueExecution)\n }\n return queueExecution()\n }\n\n const execute = () => executeBeforeLoad(inner, matchId, index, route)\n\n const queueExecution = () => {\n if (shouldSkipLoader(inner, matchId)) return\n const result = preBeforeLoadSetup(inner, matchId, route)\n return isPromise(result) ? result.then(execute) : execute()\n }\n\n return serverSsr()\n}\n\nconst executeHead = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n): void | Promise<\n Pick<\n AnyRouteMatch,\n 'meta' | 'links' | 'headScripts' | 'headers' | 'scripts' | 'styles'\n >\n> => {\n const match = inner.router.getMatch(matchId)\n // in case of a redirecting match during preload, the match does not exist\n if (!match) {\n return\n }\n if (!route.options.head && !route.options.scripts && !route.options.headers) {\n return\n }\n const assetContext = {\n ssr: inner.router.options.ssr,\n matches: inner.matches,\n match,\n params: match.params,\n loaderData: match.loaderData,\n }\n\n return Promise.all([\n route.options.head?.(assetContext),\n route.options.scripts?.(assetContext),\n route.options.headers?.(assetContext),\n ]).then(([headFnContent, scripts, headers]) => {\n const meta = headFnContent?.meta\n const links = headFnContent?.links\n const headScripts = headFnContent?.scripts\n const styles = headFnContent?.styles\n\n return {\n meta,\n links,\n headScripts,\n headers,\n scripts,\n styles,\n }\n })\n}\n\nconst getLoaderContext = (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n matchId: string,\n index: number,\n route: AnyRoute,\n): LoaderFnContext => {\n const parentMatchPromise = matchPromises[index - 1] as any\n const { params, loaderDeps, abortController, cause } =\n inner.router.getMatch(matchId)!\n\n const context = buildMatchContext(inner, index)\n\n const preload = resolvePreload(inner, matchId)\n\n return {\n params,\n deps: loaderDeps,\n preload: !!preload,\n parentMatchPromise,\n abortController,\n context,\n location: inner.location,\n navigate: (opts) =>\n inner.router.navigate({\n ...opts,\n _fromLocation: inner.location,\n }),\n cause: preload ? 'preload' : cause,\n route,\n ...inner.router.options.additionalContext,\n }\n}\n\nconst runLoader = async (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n matchId: string,\n index: number,\n route: AnyRoute,\n): Promise<void> => {\n try {\n // If the Matches component rendered\n // the pending component and needs to show it for\n // a minimum duration, we''ll wait for it to resolve\n // before committing to the match and resolving\n // the loadPromise\n\n const match = inner.router.getMatch(matchId)!\n\n // Actually run the loader and handle the result\n try {\n if (!(isServer ?? inner.router.isServer) || match.ssr === true) {\n loadRouteChunk(route)\n }\n\n // Kick off the loader!\n const routeLoader = route.options.loader\n const loader =\n typeof routeLoader === 'function' ? routeLoader : routeLoader?.handler\n const loaderResult = loader?.(\n getLoaderContext(inner, matchPromises, matchId, index, route),\n )\n const loaderResultIsPromise = !!loader && isPromise(loaderResult)\n\n const willLoadSomething = !!(\n loaderResultIsPromise ||\n route._lazyPromise ||\n route._componentsPromise ||\n route.options.head ||\n route.options.scripts ||\n route.options.headers ||\n match._nonReactive.minPendingPromise\n )\n\n if (willLoadSomething) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: 'loader',\n }))\n }\n\n if (loader) {\n const loaderData = loaderResultIsPromise\n ? await loaderResult\n : loaderResult\n\n handleRedirectAndNotFound(\n inner,\n inner.router.getMatch(matchId),\n loaderData,\n )\n if (loaderData !== undefined) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n loaderData,\n }))\n }\n }\n\n // Lazy option can modify the route options,\n // so we need to wait for it to resolve before\n // we can use the options\n if (route._lazyPromise) await route._lazyPromise\n const pendingPromise = match._nonReactive.minPendingPromise\n if (pendingPromise) await pendingPromise\n\n // Last but not least, wait for the components\n // to be preloaded before we resolve the match\n if (route._componentsPromise) await route._componentsPromise\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n error: undefined,\n context: buildMatchContext(inner, index),\n status: 'success',\n isFetching: false,\n updatedAt: Date.now(),\n }))\n } catch (e) {\n let error = e\n\n if ((error as any)?.name === 'AbortError') {\n if (match.abortController.signal.aborted) {\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loaderPromise = undefined\n return\n }\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n status: prev.status === 'pending' ? 'success' : prev.status,\n isFetching: false,\n context: buildMatchContext(inner, index),\n }))\n return\n }\n\n const pendingPromise = match._nonReactive.minPendingPromise\n if (pendingPromise) await pendingPromise\n\n if (isNotFound(e)) {\n await (route.options.notFoundComponent as any)?.preload?.()\n }\n\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e)\n\n try {\n route.options.onError?.(e)\n } catch (onErrorError) {\n error = onErrorError\n handleRedirectAndNotFound(\n inner,\n inner.router.getMatch(matchId),\n onErrorError,\n )\n }\n if (!isRedirect(error) && !isNotFound(error)) {\n await loadRouteChunk(route, ['errorComponent'])\n }\n\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n error,\n context: buildMatchContext(inner, index),\n status: 'error',\n isFetching: false,\n }))\n }\n } catch (err) {\n const match = inner.router.getMatch(matchId)\n // in case of a redirecting match during preload, the match does not exist\n if (match) {\n match._nonReactive.loaderPromise = undefined\n }\n handleRedirectAndNotFound(inner, match, err)\n }\n}\n\nconst loadRouteMatch = async (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n index: number,\n): Promise<AnyRouteMatch> => {\n async function handleLoader(\n preload: boolean,\n prevMatch: AnyRouteMatch,\n previousRouteMatchId: string | undefined,\n match: AnyRouteMatch,\n route: AnyRoute,\n ) {\n const age = Date.now() - prevMatch.updatedAt\n\n const staleAge = preload\n ? (route.options.preloadStaleTime ??\n inner.router.options.defaultPreloadStaleTime ??\n 30_000) // 30 seconds for preloads by default\n : (route.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0)\n\n const shouldReloadOption = route.options.shouldReload\n\n // Default to reloading the route all the time\n // Allow shouldReload to get the last say,\n // if provided.\n const shouldReload =\n typeof shouldReloadOption === 'function'\n ? shouldReloadOption(\n getLoaderContext(inner, matchPromises, matchId, index, route),\n )\n : shouldReloadOption\n\n // If the route is successful and still fresh, just resolve\n const { status, invalid } = match\n const staleMatchShouldReload =\n age >= staleAge &&\n (!!inner.forceStaleReload ||\n match.cause === 'enter' ||\n (previousRouteMatchId !== undefined &&\n previousRouteMatchId !== match.id))\n loaderShouldRunAsync =\n status === 'success' &&\n (invalid || (shouldReload ?? staleMatchShouldReload))\n if (preload && route.options.preload === false) {\n // Do nothing\n } else if (\n loaderShouldRunAsync &&\n !inner.sync &&\n shouldReloadInBackground\n ) {\n loaderIsRunningAsync = true\n ;(async () => {\n try {\n await runLoader(inner, matchPromises, matchId, index, route)\n const match = inner.router.getMatch(matchId)!\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loadPromise?.resolve()\n match._nonReactive.loaderPromise = undefined\n match._nonReactive.loadPromise = undefined\n } catch (err) {\n if (isRedirect(err)) {\n await inner.router.navigate(err.options)\n }\n }\n })()\n } else if (status !== 'success' || loaderShouldRunAsync) {\n await runLoader(inner, matchPromises, matchId, index, route)\n } else {\n syncMatchContext(inner, matchId, index)\n }\n }\n\n const { id: matchId, routeId } = inner.matches[index]!\n let loaderShouldRunAsync = false\n let loaderIsRunningAsync = false\n const route = inner.router.looseRoutesById[routeId]!\n const routeLoader = route.options.loader\n const shouldReloadInBackground =\n ((typeof routeLoader === 'function'\n ? undefined\n : routeLoader?.staleReloadMode) ??\n inner.router.options.defaultStaleReloadMode) !== 'blocking'\n\n if (shouldSkipLoader(inner, matchId)) {\n const match = inner.router.getMatch(matchId)\n if (!match) {\n return inner.matches[index]!\n }\n\n syncMatchContext(inner, matchId, index)\n\n if (isServer ?? inner.router.isServer) {\n return inner.router.getMatch(matchId)!\n }\n } else {\n const prevMatch = inner.router.getMatch(matchId)! // This is where all of the stale-while-revalidate magic happens\n const activeIdAtIndex = inner.router.stores.matchesId.get()[index]\n const activeAtIndex =\n (activeIdAtIndex &&\n inner.router.stores.matchStores.get(activeIdAtIndex)) ||\n null\n const previousRouteMatchId =\n activeAtIndex?.routeId === routeId\n ? activeIdAtIndex\n : inner.router.stores.matches.get().find((d) => d.routeId === routeId)\n ?.id\n const preload = resolvePreload(inner, matchId)\n\n // there is a loaderPromise, so we are in the middle of a load\n if (prevMatch._nonReactive.loaderPromise) {\n // do not block if we already have stale data we can show\n // but only if the ongoing load is not a preload since error handling is different for preloads\n // and we don't want to swallow errors\n if (\n prevMatch.status === 'success' &&\n !inner.sync &&\n !prevMatch.preload &&\n shouldReloadInBackground\n ) {\n return prevMatch\n }\n await prevMatch._nonReactive.loaderPromise\n const match = inner.router.getMatch(matchId)!\n const error = match._nonReactive.error || match.error\n if (error) {\n handleRedirectAndNotFound(inner, match, error)\n }\n\n if (match.status === 'pending') {\n await handleLoader(\n preload,\n prevMatch,\n previousRouteMatchId,\n match,\n route,\n )\n }\n } else {\n const nextPreload =\n preload && !inner.router.stores.matchStores.has(matchId)\n const match = inner.router.getMatch(matchId)!\n match._nonReactive.loaderPromise = createControlledPromise<void>()\n if (nextPreload !== match.preload) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n preload: nextPreload,\n }))\n }\n\n await handleLoader(preload, prevMatch, previousRouteMatchId, match, route)\n }\n }\n const match = inner.router.getMatch(matchId)!\n if (!loaderIsRunningAsync) {\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loadPromise?.resolve()\n match._nonReactive.loadPromise = undefined\n }\n\n clearTimeout(match._nonReactive.pendingTimeout)\n match._nonReactive.pendingTimeout = undefined\n if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = undefined\n match._nonReactive.dehydrated = undefined\n\n const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false\n if (nextIsFetching !== match.isFetching || match.invalid !== false) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: nextIsFetching,\n invalid: false,\n }))\n return inner.router.getMatch(matchId)!\n } else {\n return match\n }\n}\n\nexport async function loadMatches(arg: {\n router: AnyRouter\n location: ParsedLocation\n matches: Array<AnyRouteMatch>\n preload?: boolean\n forceStaleReload?: boolean\n onReady?: () => Promise<void>\n updateMatch: UpdateMatchFn\n sync?: boolean\n}): Promise<Array<MakeRouteMatch>> {\n const inner: InnerLoadContext = arg\n const matchPromises: Array<Promise<AnyRouteMatch>> = []\n\n // make sure the pending component is immediately rendered when hydrating a match that is not SSRed\n // the pending component was already rendered on the server and we want to keep it shown on the client until minPendingMs is reached\n if (\n !(isServer ?? inner.router.isServer) &&\n hasForcePendingActiveMatch(inner.router)\n ) {\n triggerOnReady(inner)\n }\n\n let beforeLoadNotFound: NotFoundError | undefined\n\n // Execute all beforeLoads one by one\n for (let i = 0; i < inner.matches.length; i++) {\n try {\n const beforeLoad = handleBeforeLoad(inner, i)\n if (isPromise(beforeLoad)) await beforeLoad\n } catch (err) {\n if (isRedirect(err)) {\n throw err\n }\n if (isNotFound(err)) {\n beforeLoadNotFound = err\n } else {\n if (!inner.preload) throw err\n }\n break\n }\n\n if (inner.serialError || inner.firstBadMatchIndex != null) {\n break\n }\n }\n\n // Execute loaders once, with max index adapted for beforeLoad notFound handling.\n const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length\n\n const boundaryIndex =\n beforeLoadNotFound && !inner.preload\n ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound)\n : undefined\n\n const maxIndexExclusive =\n beforeLoadNotFound && inner.preload\n ? 0\n : boundaryIndex !== undefined\n ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive)\n : baseMaxIndexExclusive\n\n let firstNotFound: NotFoundError | undefined\n let firstUnhandledRejection: unknown\n\n for (let i = 0; i < maxIndexExclusive; i++) {\n matchPromises.push(loadRouteMatch(inner, matchPromises, i))\n }\n\n try {\n await Promise.all(matchPromises)\n } catch {\n const settled = await Promise.allSettled(matchPromises)\n\n for (const result of settled) {\n if (result.status !== 'rejected') continue\n\n const reason = result.reason\n if (isRedirect(reason)) {\n throw reason\n }\n if (isNotFound(reason)) {\n firstNotFound ??= reason\n } else {\n firstUnhandledRejection ??= reason\n }\n }\n\n if (firstUnhandledRejection !== undefined) {\n throw firstUnhandledRejection\n }\n }\n\n const notFoundToThrow =\n firstNotFound ??\n (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : undefined)\n\n let headMaxIndex =\n inner.firstBadMatchIndex !== undefined\n ? inner.firstBadMatchIndex\n : inner.matches.length - 1\n\n if (!notFoundToThrow && beforeLoadNotFound && inner.preload) {\n return inner.matches\n }\n\n if (notFoundToThrow) {\n // Determine once which matched route will actually render the\n // notFoundComponent, then pass this precomputed index through the remaining\n // finalization steps.\n // This can differ from the throwing route when routeId targets an ancestor\n // boundary (or when bubbling resolves to a parent/root boundary).\n const renderedBoundaryIndex = getNotFoundBoundaryIndex(\n inner,\n notFoundToThrow,\n )\n\n if (renderedBoundaryIndex === undefined) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Invariant failed: Could not find match for notFound boundary',\n )\n }\n\n invariant()\n }\n const boundaryMatch = inner.matches[renderedBoundaryIndex]!\n\n const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId]!\n const defaultNotFoundComponent = (inner.router.options as any)\n ?.defaultNotFoundComponent\n\n // Ensure a notFoundComponent exists on the boundary route\n if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) {\n boundaryRoute.options.notFoundComponent = defaultNotFoundComponent\n }\n\n notFoundToThrow.routeId = boundaryMatch.routeId\n\n const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id\n\n inner.updateMatch(boundaryMatch.id, (prev) => ({\n ...prev,\n ...(boundaryIsRoot\n ? // For root boundary, use globalNotFound so the root component's\n // shell still renders and <Outlet> handles the not-found display,\n // instead of replacing the entire root shell via status='notFound'.\n { status: 'success' as const, globalNotFound: true, error: undefined }\n : // For non-root boundaries, set status:'notFound' so MatchInner\n // renders the notFoundComponent directly.\n { status: 'notFound' as const, error: notFoundToThrow }),\n isFetching: false,\n }))\n\n headMaxIndex = renderedBoundaryIndex\n\n // Ensure the rendering boundary route chunk (and its lazy components, including\n // lazy notFoundComponent) is loaded before we continue to head execution/render.\n await loadRouteChunk(boundaryRoute, ['notFoundComponent'])\n } else if (!inner.preload) {\n // Clear stale root global-not-found state on normal navigations that do not\n // throw notFound. This must live here (instead of only in runLoader success)\n // because the root loader may be skipped when data is still fresh.\n const rootMatch = inner.matches[0]!\n // `rootMatch` is the next match for this navigation. If it is not global\n // not-found, then any currently stored root global-not-found is stale.\n if (!rootMatch.globalNotFound) {\n // `currentRootMatch` is the current store state (from the previous\n // navigation/load). Update only when a stale flag is actually present.\n const currentRootMatch = inner.router.getMatch(rootMatch.id)\n if (currentRootMatch?.globalNotFound) {\n inner.updateMatch(rootMatch.id, (prev) => ({\n ...prev,\n globalNotFound: false,\n error: undefined,\n }))\n }\n }\n }\n\n // When a serial error occurred (e.g. beforeLoad threw a regular Error),\n // the erroring route's lazy chunk wasn't loaded because loaders were skipped.\n // We need to load it so the code-split errorComponent is available for rendering.\n if (inner.serialError && inner.firstBadMatchIndex !== undefined) {\n const errorRoute =\n inner.router.looseRoutesById[\n inner.matches[inner.firstBadMatchIndex]!.routeId\n ]!\n await loadRouteChunk(errorRoute, ['errorComponent'])\n }\n\n // serially execute heads once after loaders/notFound handling, ensuring\n // all head functions get a chance even if one throws.\n for (let i = 0; i <= headMaxIndex; i++) {\n const match = inner.matches[i]!\n const { id: matchId, routeId } = match\n const route = inner.router.looseRoutesById[routeId]!\n try {\n const headResult = executeHead(inner, matchId, route)\n if (headResult) {\n const head = await headResult\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n ...head,\n }))\n }\n } catch (err) {\n console.error(`Error executing head for route ${routeId}:`, err)\n }\n }\n\n const readyPromise = triggerOnReady(inner)\n if (isPromise(readyPromise)) {\n await readyPromise\n }\n\n if (notFoundToThrow) {\n throw notFoundToThrow\n }\n\n if (inner.serialError && !inner.preload && !inner.onReady) {\n throw inner.serialError\n }\n\n return inner.matches\n}\n\nexport type RouteComponentType =\n | 'component'\n | 'errorComponent'\n | 'pendingComponent'\n | 'notFoundComponent'\n\nfunction preloadRouteComponents(\n route: AnyRoute,\n componentTypesToLoad: Array<RouteComponentType>,\n): Promise<void> | undefined {\n const preloads = componentTypesToLoad\n .map((type) => (route.options[type] as any)?.preload?.())\n .filter(Boolean)\n\n if (preloads.length === 0) return undefined\n\n return Promise.all(preloads) as any as Promise<void>\n}\n\nexport function loadRouteChunk(\n route: AnyRoute,\n componentTypesToLoad: Array<RouteComponentType> = componentTypes,\n) {\n if (!route._lazyLoaded && route._lazyPromise === undefined) {\n if (route.lazyFn) {\n route._lazyPromise = route.lazyFn().then((lazyRoute) => {\n // explicitly don't copy over the lazy route's id\n const { id: _id, ...options } = lazyRoute.options\n Object.assign(route.options, options)\n route._lazyLoaded = true\n route._lazyPromise = undefined // gc promise, we won't need it anymore\n })\n } else {\n route._lazyLoaded = true\n }\n }\n\n const runAfterLazy = () =>\n route._componentsLoaded\n ? undefined\n : componentTypesToLoad === componentTypes\n ? (() => {\n if (route._componentsPromise === undefined) {\n const componentsPromise = preloadRouteComponents(\n route,\n componentTypes,\n )\n\n if (componentsPromise) {\n route._componentsPromise = componentsPromise.then(() => {\n route._componentsLoaded = true\n route._componentsPromise = undefined // gc promise, we won't need it anymore\n })\n } else {\n route._componentsLoaded = true\n }\n }\n\n return route._componentsPromise\n })()\n : preloadRouteComponents(route, componentTypesToLoad)\n\n return route._lazyPromise\n ? route._lazyPromise.then(runAfterLazy)\n : runAfterLazy()\n}\n\nfunction makeMaybe<TValue, TError>(\n value: TValue,\n error: TError,\n): { status: 'success'; value: TValue } | { status: 'error'; error: TError } {\n if (error) {\n return { status: 'error' as const, error }\n }\n return { status: 'success' as const, value }\n}\n\nexport function routeNeedsPreload(route: AnyRoute) {\n for (const componentType of componentTypes) {\n if ((route.options[componentType] as any)?.preload) {\n return true\n }\n }\n return false\n}\n\nexport const componentTypes: Array<RouteComponentType> = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n 'notFoundComponent',\n] as const\n"],"mappings":";;;;;;;AAuCA,MAAM,kBAAkB,UAAkD;CACxE,IAAI,CAAC,MAAM,UAAU;EACnB,MAAM,WAAW;EACjB,OAAO,MAAM,UAAU;CACzB;AACF;AAEA,MAAM,8BAA8B,WAA+B;CACjE,OAAO,OAAO,OAAO,UAAU,IAAI,EAAE,MAAM,YAAY;EACrD,OAAO,OAAO,OAAO,YAAY,IAAI,OAAO,GAAG,IAAI,EAAE;CACvD,CAAC;AACH;AAEA,MAAM,kBAAkB,OAAyB,YAA6B;CAC5E,OAAO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AiB,KAAA,GAC/C,IAAI,MAAM,QACR,MAAM,eAAe,MAAM,OAAO,EAAE,MAAM,cAAc;EAEtD,MAAM,EAAE,IAAI,KAAK,GAAG,YAAY,UAAU;EAC1C,OAAO,OAAO,MAAM,SAAS,OAAO;EACpC,MAAM,cAAc;EACpB,MAAM,eAAe,KAAA;CACvB,CAAC;MAED,MAAM,cAAc;CAIxB,MAAM,qBACJ,MAAM,oBACF,KAAA,IACA,yBAAyB,wBAChB;EACL,IAAI,MAAM,uBAAuB,KAAA,GAAW;GAC1C,MAAM,oBAAoB,uBACxB,OACA,cACF;GAEA,IAAI,mBACF,MAAM,qBAAqB,kBAAkB,WAAW;IACtD,MAAM,oBAAoB;IAC1B,MAAM,qBAAqB,KAAA;GAC7B,CAAC;QAED,MAAM,oBAAoB;EAE9B;EAEA,OAAO,MAAM;CACf,GAAG,IACH,uBAAuB,OAAO,oBAAoB;CAE1D,OAAO,MAAM,eACT,MAAM,aAAa,KAAK,YAAY,IACpC,aAAa;AACnB;AAEA,SAAS,UACP,OACA,OAC2E;CAC3E,IAAI,OACF,OAAO;EAAE,QAAQ;EAAkB;CAAM;CAE3C,OAAO;EAAE,QAAQ;EAAoB;CAAM;AAC7C;AAEA,SAAgB,kBAAkB,OAAiB;CACjD,KAAK,MAAM,iBAAiB,gBAC1B,IAAK,MAAM,QAAQ,gBAAwB,SACzC,OAAO;CAGX,OAAO;AACT;AAEA,MAAa,iBAA4C;CACvD;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"load-matches.js","names":[],"sources":["../../src/load-matches.ts"],"sourcesContent":["import { isServer } from '@tanstack/router-core/isServer'\nimport { invariant } from './invariant'\nimport { createControlledPromise, isPromise } from './utils'\nimport { isNotFound } from './not-found'\nimport { rootRouteId } from './root'\nimport { isRedirect } from './redirect'\nimport type { NotFoundError } from './not-found'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyRoute,\n BeforeLoadContextOptions,\n LoaderFnContext,\n SsrContextOptions,\n} from './route'\nimport type { AnyRouteMatch, MakeRouteMatch } from './Matches'\nimport type { AnyRouter, SSROption, UpdateMatchFn } from './router'\n\n/**\n * An object of this shape is created when calling `loadMatches`.\n * It contains everything we need for all other functions in this file\n * to work. (It's basically the function's argument, plus a few mutable states)\n */\ntype InnerLoadContext = {\n /** the calling router instance */\n router: AnyRouter\n location: ParsedLocation\n /** mutable state, scoped to a `loadMatches` call */\n firstBadMatchIndex?: number\n /** mutable state, scoped to a `loadMatches` call */\n rendered?: boolean\n serialError?: unknown\n updateMatch: UpdateMatchFn\n matches: Array<AnyRouteMatch>\n preload?: boolean\n forceStaleReload?: boolean\n onReady?: () => Promise<void>\n sync?: boolean\n}\n\nconst triggerOnReady = (inner: InnerLoadContext): void | Promise<void> => {\n if (!inner.rendered) {\n inner.rendered = true\n return inner.onReady?.()\n }\n}\n\nconst hasForcePendingActiveMatch = (router: AnyRouter): boolean => {\n return router.stores.matchesId.get().some((matchId) => {\n return router.stores.matchStores.get(matchId)?.get()._forcePending\n })\n}\n\nconst resolvePreload = (inner: InnerLoadContext, matchId: string): boolean => {\n return !!(inner.preload && !inner.router.stores.matchStores.has(matchId))\n}\n\n/**\n * Builds the accumulated context from router options and all matches up to (and optionally including) the given index.\n * Merges __routeContext and __beforeLoadContext from each match.\n */\nconst buildMatchContext = (\n inner: InnerLoadContext,\n index: number,\n includeCurrentMatch: boolean = true,\n): Record<string, unknown> => {\n const context: Record<string, unknown> = {\n ...(inner.router.options.context ?? {}),\n }\n const end = includeCurrentMatch ? index : index - 1\n for (let i = 0; i <= end; i++) {\n const innerMatch = inner.matches[i]\n if (!innerMatch) continue\n const m = inner.router.getMatch(innerMatch.id)\n if (!m) continue\n Object.assign(context, m.__routeContext, m.__beforeLoadContext)\n }\n return context\n}\n\nconst getNotFoundBoundaryIndex = (\n inner: InnerLoadContext,\n err: NotFoundError,\n): number | undefined => {\n if (!inner.matches.length) {\n return undefined\n }\n\n const requestedRouteId = err.routeId\n const matchedRootIndex = inner.matches.findIndex(\n (m) => m.routeId === inner.router.routeTree.id,\n )\n const rootIndex = matchedRootIndex >= 0 ? matchedRootIndex : 0\n\n let startIndex = requestedRouteId\n ? inner.matches.findIndex((match) => match.routeId === requestedRouteId)\n : (inner.firstBadMatchIndex ?? inner.matches.length - 1)\n\n if (startIndex < 0) {\n startIndex = rootIndex\n }\n\n for (let i = startIndex; i >= 0; i--) {\n const match = inner.matches[i]!\n const route = inner.router.looseRoutesById[match.routeId]!\n if (route.options.notFoundComponent) {\n return i\n }\n }\n\n // If no boundary component is found, preserve explicit routeId targeting behavior,\n // otherwise default to root for untargeted notFounds.\n return requestedRouteId ? startIndex : rootIndex\n}\n\nconst handleRedirectAndNotFound = (\n inner: InnerLoadContext,\n match: AnyRouteMatch | undefined,\n err: unknown,\n): void => {\n if (!isRedirect(err) && !isNotFound(err)) return\n\n if (isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) {\n throw err\n }\n\n // in case of a redirecting match during preload, the match does not exist\n if (match) {\n match._nonReactive.beforeLoadPromise?.resolve()\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.beforeLoadPromise = undefined\n match._nonReactive.loaderPromise = undefined\n\n match._nonReactive.error = err\n\n inner.updateMatch(match.id, (prev) => ({\n ...prev,\n status: isRedirect(err)\n ? 'redirected'\n : isNotFound(err)\n ? 'notFound'\n : prev.status === 'pending'\n ? 'success'\n : prev.status,\n context: buildMatchContext(inner, match.index),\n isFetching: false,\n error: err,\n }))\n\n if (isNotFound(err) && !err.routeId) {\n // Stamp the throwing match's routeId so that the finalization step in\n // loadMatches knows where the notFound originated. The actual boundary\n // resolution (walking up to the nearest notFoundComponent) is deferred to\n // the finalization step, where firstBadMatchIndex is stable and\n // headMaxIndex can be capped correctly.\n err.routeId = match.routeId\n }\n\n match._nonReactive.loadPromise?.resolve()\n }\n\n if (isRedirect(err)) {\n inner.rendered = true\n err.options._fromLocation = inner.location\n err.redirectHandled = true\n err = inner.router.resolveRedirect(err)\n }\n\n throw err\n}\n\nconst shouldSkipLoader = (\n inner: InnerLoadContext,\n matchId: string,\n): boolean => {\n const match = inner.router.getMatch(matchId)\n if (!match) {\n return true\n }\n // upon hydration, we skip the loader if the match has been dehydrated on the server\n if (!(isServer ?? inner.router.isServer) && match._nonReactive.dehydrated) {\n return true\n }\n\n if ((isServer ?? inner.router.isServer) && match.ssr === false) {\n return true\n }\n\n return false\n}\n\nconst syncMatchContext = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n): void => {\n const nextContext = buildMatchContext(inner, index)\n\n inner.updateMatch(matchId, (prev) => {\n return {\n ...prev,\n context: nextContext,\n }\n })\n}\n\nconst handleSerialError = (\n inner: InnerLoadContext,\n index: number,\n err: any,\n): void => {\n const { id: matchId, routeId } = inner.matches[index]!\n const route = inner.router.looseRoutesById[routeId]!\n\n // Much like suspense, we use a promise here to know if\n // we've been outdated by a new loadMatches call and\n // should abort the current async operation\n if (err instanceof Promise) {\n throw err\n }\n\n inner.firstBadMatchIndex ??= index\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)\n\n try {\n route.options.onError?.(err)\n } catch (errorHandlerErr) {\n err = errorHandlerErr\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)\n }\n\n inner.updateMatch(matchId, (prev) => {\n prev._nonReactive.beforeLoadPromise?.resolve()\n prev._nonReactive.beforeLoadPromise = undefined\n prev._nonReactive.loadPromise?.resolve()\n\n return {\n ...prev,\n error: err,\n status: 'error',\n isFetching: false,\n updatedAt: Date.now(),\n abortController: new AbortController(),\n }\n })\n\n if (!inner.preload && !isRedirect(err) && !isNotFound(err)) {\n inner.serialError ??= err\n }\n}\n\nconst isBeforeLoadSsr = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n route: AnyRoute,\n): void | Promise<void> => {\n const existingMatch = inner.router.getMatch(matchId)!\n const parentMatchId = inner.matches[index - 1]?.id\n const parentMatch = parentMatchId\n ? inner.router.getMatch(parentMatchId)!\n : undefined\n\n // in SPA mode, only SSR the root route\n if (inner.router.isShell()) {\n existingMatch.ssr = route.id === rootRouteId\n return\n }\n\n if (parentMatch?.ssr === false) {\n existingMatch.ssr = false\n return\n }\n\n const parentOverride = (tempSsr: SSROption) => {\n if (tempSsr === true && parentMatch?.ssr === 'data-only') {\n return 'data-only'\n }\n return tempSsr\n }\n\n const defaultSsr = inner.router.options.defaultSsr ?? true\n\n if (route.options.ssr === undefined) {\n existingMatch.ssr = parentOverride(defaultSsr)\n return\n }\n\n if (typeof route.options.ssr !== 'function') {\n existingMatch.ssr = parentOverride(route.options.ssr)\n return\n }\n const { search, params } = existingMatch\n\n const ssrFnContext: SsrContextOptions<any, any, any> = {\n search: makeMaybe(search, existingMatch.searchError),\n params: makeMaybe(params, existingMatch.paramsError),\n location: inner.location,\n matches: inner.matches.map((match) => ({\n index: match.index,\n pathname: match.pathname,\n fullPath: match.fullPath,\n staticData: match.staticData,\n id: match.id,\n routeId: match.routeId,\n search: makeMaybe(match.search, match.searchError),\n params: makeMaybe(match.params, match.paramsError),\n ssr: match.ssr,\n })),\n }\n\n const tempSsr = route.options.ssr(ssrFnContext)\n if (isPromise(tempSsr)) {\n return tempSsr.then((ssr) => {\n existingMatch.ssr = parentOverride(ssr ?? defaultSsr)\n })\n }\n\n existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr)\n return\n}\n\nconst setupPendingTimeout = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n match: AnyRouteMatch,\n): void => {\n if (match._nonReactive.pendingTimeout !== undefined) return\n\n const pendingMs =\n route.options.pendingMs ?? inner.router.options.defaultPendingMs\n const shouldPending = !!(\n inner.onReady &&\n !(isServer ?? inner.router.isServer) &&\n !resolvePreload(inner, matchId) &&\n (route.options.loader ||\n route.options.beforeLoad ||\n routeNeedsPreload(route)) &&\n typeof pendingMs === 'number' &&\n pendingMs !== Infinity &&\n (route.options.pendingComponent ??\n (inner.router.options as any)?.defaultPendingComponent)\n )\n\n if (shouldPending) {\n const pendingTimeout = setTimeout(() => {\n // Update the match and prematurely resolve the loadMatches promise so that\n // the pending component can start rendering\n triggerOnReady(inner)\n }, pendingMs)\n match._nonReactive.pendingTimeout = pendingTimeout\n }\n}\n\nconst preBeforeLoadSetup = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n): void | Promise<void> => {\n const existingMatch = inner.router.getMatch(matchId)!\n\n // If we are in the middle of a load, either of these will be present\n // (not to be confused with `loadPromise`, which is always defined)\n if (\n !existingMatch._nonReactive.beforeLoadPromise &&\n !existingMatch._nonReactive.loaderPromise\n )\n return\n\n setupPendingTimeout(inner, matchId, route, existingMatch)\n\n const then = () => {\n const match = inner.router.getMatch(matchId)!\n if (\n match.preload &&\n (match.status === 'redirected' || match.status === 'notFound')\n ) {\n handleRedirectAndNotFound(inner, match, match.error)\n }\n }\n\n // Wait for the previous beforeLoad to resolve before we continue\n return existingMatch._nonReactive.beforeLoadPromise\n ? existingMatch._nonReactive.beforeLoadPromise.then(then)\n : then()\n}\n\nconst executeBeforeLoad = (\n inner: InnerLoadContext,\n matchId: string,\n index: number,\n route: AnyRoute,\n): void | Promise<void> => {\n const match = inner.router.getMatch(matchId)!\n\n // explicitly capture the previous loadPromise\n let prevLoadPromise = match._nonReactive.loadPromise\n match._nonReactive.loadPromise = createControlledPromise<void>(() => {\n prevLoadPromise?.resolve()\n prevLoadPromise = undefined\n })\n\n const { paramsError, searchError } = match\n\n if (paramsError) {\n handleSerialError(inner, index, paramsError)\n }\n\n if (searchError) {\n handleSerialError(inner, index, searchError)\n }\n\n setupPendingTimeout(inner, matchId, route, match)\n\n const abortController = new AbortController()\n\n let isPending = false\n const pending = () => {\n if (isPending) return\n isPending = true\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: 'beforeLoad',\n fetchCount: prev.fetchCount + 1,\n abortController,\n // Note: We intentionally don't update context here.\n // Context should only be updated after beforeLoad resolves to avoid\n // components seeing incomplete context during async beforeLoad execution.\n }))\n }\n\n const resolve = () => {\n match._nonReactive.beforeLoadPromise?.resolve()\n match._nonReactive.beforeLoadPromise = undefined\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: false,\n }))\n }\n\n // if there is no `beforeLoad` option, just mark as pending and resolve\n // Context will be updated later in loadRouteMatch after loader completes\n if (!route.options.beforeLoad) {\n inner.router.batch(() => {\n pending()\n resolve()\n })\n return\n }\n\n match._nonReactive.beforeLoadPromise = createControlledPromise<void>()\n\n // Build context from all parent matches, excluding current match's __beforeLoadContext\n // (since we're about to execute beforeLoad for this match)\n const context = {\n ...buildMatchContext(inner, index, false),\n ...match.__routeContext,\n }\n const { search, params, cause } = match\n const preload = resolvePreload(inner, matchId)\n const beforeLoadFnContext: BeforeLoadContextOptions<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > = {\n search,\n abortController,\n params,\n preload,\n context,\n location: inner.location,\n navigate: (opts: any) =>\n inner.router.navigate({\n ...opts,\n _fromLocation: inner.location,\n }),\n buildLocation: inner.router.buildLocation,\n cause: preload ? 'preload' : cause,\n matches: inner.matches,\n routeId: route.id,\n ...inner.router.options.additionalContext,\n }\n\n const updateContext = (beforeLoadContext: any) => {\n if (beforeLoadContext === undefined) {\n inner.router.batch(() => {\n pending()\n resolve()\n })\n return\n }\n if (isRedirect(beforeLoadContext) || isNotFound(beforeLoadContext)) {\n pending()\n handleSerialError(inner, index, beforeLoadContext)\n }\n\n inner.router.batch(() => {\n pending()\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n __beforeLoadContext: beforeLoadContext,\n }))\n resolve()\n })\n }\n\n let beforeLoadContext\n try {\n beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext)\n if (isPromise(beforeLoadContext)) {\n pending()\n return beforeLoadContext\n .catch((err) => {\n handleSerialError(inner, index, err)\n })\n .then(updateContext)\n }\n } catch (err) {\n pending()\n handleSerialError(inner, index, err)\n }\n\n updateContext(beforeLoadContext)\n return\n}\n\nconst handleBeforeLoad = (\n inner: InnerLoadContext,\n index: number,\n): void | Promise<void> => {\n const { id: matchId, routeId } = inner.matches[index]!\n const route = inner.router.looseRoutesById[routeId]!\n\n const serverSsr = () => {\n // on the server, determine whether SSR the current match or not\n if (isServer ?? inner.router.isServer) {\n const maybePromise = isBeforeLoadSsr(inner, matchId, index, route)\n if (isPromise(maybePromise)) return maybePromise.then(queueExecution)\n }\n return queueExecution()\n }\n\n const execute = () => executeBeforeLoad(inner, matchId, index, route)\n\n const queueExecution = () => {\n if (shouldSkipLoader(inner, matchId)) return\n const result = preBeforeLoadSetup(inner, matchId, route)\n return isPromise(result) ? result.then(execute) : execute()\n }\n\n return serverSsr()\n}\n\nconst executeHead = (\n inner: InnerLoadContext,\n matchId: string,\n route: AnyRoute,\n): void | Promise<\n Pick<\n AnyRouteMatch,\n 'meta' | 'links' | 'headScripts' | 'headers' | 'scripts' | 'styles'\n >\n> => {\n const match = inner.router.getMatch(matchId)\n // in case of a redirecting match during preload, the match does not exist\n if (!match) {\n return\n }\n if (!route.options.head && !route.options.scripts && !route.options.headers) {\n return\n }\n const assetContext = {\n ssr: inner.router.options.ssr,\n matches: inner.matches,\n match,\n params: match.params,\n loaderData: match.loaderData,\n }\n\n return Promise.all([\n route.options.head?.(assetContext),\n route.options.scripts?.(assetContext),\n route.options.headers?.(assetContext),\n ]).then(([headFnContent, scripts, headers]) => {\n const meta = headFnContent?.meta\n const links = headFnContent?.links\n const headScripts = headFnContent?.scripts\n const styles = headFnContent?.styles\n\n return {\n meta,\n links,\n headScripts,\n headers,\n scripts,\n styles,\n }\n })\n}\n\nconst getLoaderContext = (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n matchId: string,\n index: number,\n route: AnyRoute,\n): LoaderFnContext => {\n const parentMatchPromise = matchPromises[index - 1] as any\n const { params, loaderDeps, abortController, cause } =\n inner.router.getMatch(matchId)!\n\n const context = buildMatchContext(inner, index)\n\n const preload = resolvePreload(inner, matchId)\n\n return {\n params,\n deps: loaderDeps,\n preload: !!preload,\n parentMatchPromise,\n abortController,\n context,\n location: inner.location,\n navigate: (opts) =>\n inner.router.navigate({\n ...opts,\n _fromLocation: inner.location,\n }),\n cause: preload ? 'preload' : cause,\n route,\n ...inner.router.options.additionalContext,\n }\n}\n\nconst runLoader = async (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n matchId: string,\n index: number,\n route: AnyRoute,\n): Promise<void> => {\n try {\n // If the Matches component rendered\n // the pending component and needs to show it for\n // a minimum duration, we''ll wait for it to resolve\n // before committing to the match and resolving\n // the loadPromise\n\n const match = inner.router.getMatch(matchId)!\n\n // Actually run the loader and handle the result\n try {\n if (!(isServer ?? inner.router.isServer) || match.ssr === true) {\n loadRouteChunk(route)\n }\n\n // Kick off the loader!\n const routeLoader = route.options.loader\n const loader =\n typeof routeLoader === 'function' ? routeLoader : routeLoader?.handler\n const loaderResult = loader?.(\n getLoaderContext(inner, matchPromises, matchId, index, route),\n )\n const loaderResultIsPromise = !!loader && isPromise(loaderResult)\n\n const willLoadSomething = !!(\n loaderResultIsPromise ||\n route._lazyPromise ||\n route._componentsPromise ||\n route.options.head ||\n route.options.scripts ||\n route.options.headers ||\n match._nonReactive.minPendingPromise\n )\n\n if (willLoadSomething) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: 'loader',\n }))\n }\n\n if (loader) {\n const loaderData = loaderResultIsPromise\n ? await loaderResult\n : loaderResult\n\n handleRedirectAndNotFound(\n inner,\n inner.router.getMatch(matchId),\n loaderData,\n )\n if (loaderData !== undefined) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n loaderData,\n }))\n }\n }\n\n // Lazy option can modify the route options,\n // so we need to wait for it to resolve before\n // we can use the options\n if (route._lazyPromise) await route._lazyPromise\n const pendingPromise = match._nonReactive.minPendingPromise\n if (pendingPromise) await pendingPromise\n\n // Last but not least, wait for the components\n // to be preloaded before we resolve the match\n if (route._componentsPromise) await route._componentsPromise\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n error: undefined,\n context: buildMatchContext(inner, index),\n status: 'success',\n isFetching: false,\n updatedAt: Date.now(),\n }))\n } catch (e) {\n let error = e\n\n if ((error as any)?.name === 'AbortError') {\n if (match.abortController.signal.aborted) {\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loaderPromise = undefined\n return\n }\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n status: prev.status === 'pending' ? 'success' : prev.status,\n isFetching: false,\n context: buildMatchContext(inner, index),\n }))\n return\n }\n\n const pendingPromise = match._nonReactive.minPendingPromise\n if (pendingPromise) await pendingPromise\n\n if (isNotFound(e)) {\n await (route.options.notFoundComponent as any)?.preload?.()\n }\n\n handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e)\n\n try {\n route.options.onError?.(e)\n } catch (onErrorError) {\n error = onErrorError\n handleRedirectAndNotFound(\n inner,\n inner.router.getMatch(matchId),\n onErrorError,\n )\n }\n if (!isRedirect(error) && !isNotFound(error)) {\n await loadRouteChunk(route, ['errorComponent'])\n }\n\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n error,\n context: buildMatchContext(inner, index),\n status: 'error',\n isFetching: false,\n }))\n }\n } catch (err) {\n const match = inner.router.getMatch(matchId)\n // in case of a redirecting match during preload, the match does not exist\n if (match) {\n match._nonReactive.loaderPromise = undefined\n }\n handleRedirectAndNotFound(inner, match, err)\n }\n}\n\nconst loadRouteMatch = async (\n inner: InnerLoadContext,\n matchPromises: Array<Promise<AnyRouteMatch>>,\n index: number,\n): Promise<AnyRouteMatch> => {\n async function handleLoader(\n preload: boolean,\n prevMatch: AnyRouteMatch,\n previousRouteMatchId: string | undefined,\n match: AnyRouteMatch,\n route: AnyRoute,\n ) {\n const age = Date.now() - prevMatch.updatedAt\n\n const staleAge = preload\n ? (route.options.preloadStaleTime ??\n inner.router.options.defaultPreloadStaleTime ??\n 30_000) // 30 seconds for preloads by default\n : (route.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0)\n\n const shouldReloadOption = route.options.shouldReload\n\n // Default to reloading the route all the time\n // Allow shouldReload to get the last say,\n // if provided.\n const shouldReload =\n typeof shouldReloadOption === 'function'\n ? shouldReloadOption(\n getLoaderContext(inner, matchPromises, matchId, index, route),\n )\n : shouldReloadOption\n\n // If the route is successful and still fresh, just resolve\n const { status, invalid } = match\n const staleMatchShouldReload =\n age >= staleAge &&\n (!!inner.forceStaleReload ||\n match.cause === 'enter' ||\n (previousRouteMatchId !== undefined &&\n previousRouteMatchId !== match.id))\n loaderShouldRunAsync =\n status === 'success' &&\n (invalid || (shouldReload ?? staleMatchShouldReload))\n if (preload && route.options.preload === false) {\n // Do nothing\n } else if (\n loaderShouldRunAsync &&\n !inner.sync &&\n shouldReloadInBackground\n ) {\n loaderIsRunningAsync = true\n ;(async () => {\n try {\n await runLoader(inner, matchPromises, matchId, index, route)\n const match = inner.router.getMatch(matchId)!\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loadPromise?.resolve()\n match._nonReactive.loaderPromise = undefined\n match._nonReactive.loadPromise = undefined\n } catch (err) {\n if (isRedirect(err)) {\n await inner.router.navigate(err.options)\n }\n }\n })()\n } else if (status !== 'success' || loaderShouldRunAsync) {\n await runLoader(inner, matchPromises, matchId, index, route)\n } else {\n syncMatchContext(inner, matchId, index)\n }\n }\n\n const { id: matchId, routeId } = inner.matches[index]!\n let loaderShouldRunAsync = false\n let loaderIsRunningAsync = false\n const route = inner.router.looseRoutesById[routeId]!\n const routeLoader = route.options.loader\n const shouldReloadInBackground =\n ((typeof routeLoader === 'function'\n ? undefined\n : routeLoader?.staleReloadMode) ??\n inner.router.options.defaultStaleReloadMode) !== 'blocking'\n\n if (shouldSkipLoader(inner, matchId)) {\n const match = inner.router.getMatch(matchId)\n if (!match) {\n return inner.matches[index]!\n }\n\n syncMatchContext(inner, matchId, index)\n\n if (isServer ?? inner.router.isServer) {\n return inner.router.getMatch(matchId)!\n }\n } else {\n const prevMatch = inner.router.getMatch(matchId)! // This is where all of the stale-while-revalidate magic happens\n const activeIdAtIndex = inner.router.stores.matchesId.get()[index]\n const activeAtIndex =\n (activeIdAtIndex &&\n inner.router.stores.matchStores.get(activeIdAtIndex)) ||\n null\n const previousRouteMatchId =\n activeAtIndex?.routeId === routeId\n ? activeIdAtIndex\n : inner.router.stores.matches.get().find((d) => d.routeId === routeId)\n ?.id\n const preload = resolvePreload(inner, matchId)\n\n // there is a loaderPromise, so we are in the middle of a load\n if (prevMatch._nonReactive.loaderPromise) {\n // do not block if we already have stale data we can show\n // but only if the ongoing load is not a preload since error handling is different for preloads\n // and we don't want to swallow errors\n if (\n prevMatch.status === 'success' &&\n !inner.sync &&\n !prevMatch.preload &&\n shouldReloadInBackground\n ) {\n return prevMatch\n }\n await prevMatch._nonReactive.loaderPromise\n const match = inner.router.getMatch(matchId)!\n const error = match._nonReactive.error || match.error\n if (error) {\n handleRedirectAndNotFound(inner, match, error)\n }\n\n if (match.status === 'pending') {\n await handleLoader(\n preload,\n prevMatch,\n previousRouteMatchId,\n match,\n route,\n )\n }\n } else {\n const nextPreload =\n preload && !inner.router.stores.matchStores.has(matchId)\n const match = inner.router.getMatch(matchId)!\n match._nonReactive.loaderPromise = createControlledPromise<void>()\n if (nextPreload !== match.preload) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n preload: nextPreload,\n }))\n }\n\n await handleLoader(preload, prevMatch, previousRouteMatchId, match, route)\n }\n }\n const match = inner.router.getMatch(matchId)!\n if (!loaderIsRunningAsync) {\n match._nonReactive.loaderPromise?.resolve()\n match._nonReactive.loadPromise?.resolve()\n match._nonReactive.loadPromise = undefined\n }\n\n clearTimeout(match._nonReactive.pendingTimeout)\n match._nonReactive.pendingTimeout = undefined\n if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = undefined\n match._nonReactive.dehydrated = undefined\n\n const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false\n if (nextIsFetching !== match.isFetching || match.invalid !== false) {\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n isFetching: nextIsFetching,\n invalid: false,\n }))\n return inner.router.getMatch(matchId)!\n } else {\n return match\n }\n}\n\nexport async function loadMatches(arg: {\n router: AnyRouter\n location: ParsedLocation\n matches: Array<AnyRouteMatch>\n preload?: boolean\n forceStaleReload?: boolean\n onReady?: () => Promise<void>\n updateMatch: UpdateMatchFn\n sync?: boolean\n}): Promise<Array<MakeRouteMatch>> {\n const inner: InnerLoadContext = arg\n const matchPromises: Array<Promise<AnyRouteMatch>> = []\n\n // make sure the pending component is immediately rendered when hydrating a match that is not SSRed\n // the pending component was already rendered on the server and we want to keep it shown on the client until minPendingMs is reached\n if (\n !(isServer ?? inner.router.isServer) &&\n hasForcePendingActiveMatch(inner.router)\n ) {\n triggerOnReady(inner)\n }\n\n let beforeLoadNotFound: NotFoundError | undefined\n\n // Execute all beforeLoads one by one\n for (let i = 0; i < inner.matches.length; i++) {\n try {\n const beforeLoad = handleBeforeLoad(inner, i)\n if (isPromise(beforeLoad)) await beforeLoad\n } catch (err) {\n if (isRedirect(err)) {\n throw err\n }\n if (isNotFound(err)) {\n beforeLoadNotFound = err\n } else {\n if (!inner.preload) throw err\n }\n break\n }\n\n if (inner.serialError || inner.firstBadMatchIndex != null) {\n break\n }\n }\n\n // Execute loaders once, with max index adapted for beforeLoad notFound handling.\n const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length\n\n const boundaryIndex =\n beforeLoadNotFound && !inner.preload\n ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound)\n : undefined\n\n const maxIndexExclusive =\n beforeLoadNotFound && inner.preload\n ? 0\n : boundaryIndex !== undefined\n ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive)\n : baseMaxIndexExclusive\n\n let firstNotFound: NotFoundError | undefined\n let firstUnhandledRejection: unknown\n\n for (let i = 0; i < maxIndexExclusive; i++) {\n matchPromises.push(loadRouteMatch(inner, matchPromises, i))\n }\n\n try {\n await Promise.all(matchPromises)\n } catch {\n const settled = await Promise.allSettled(matchPromises)\n\n for (const result of settled) {\n if (result.status !== 'rejected') continue\n\n const reason = result.reason\n if (isRedirect(reason)) {\n throw reason\n }\n if (isNotFound(reason)) {\n firstNotFound ??= reason\n } else {\n firstUnhandledRejection ??= reason\n }\n }\n\n if (firstUnhandledRejection !== undefined) {\n throw firstUnhandledRejection\n }\n }\n\n const notFoundToThrow =\n firstNotFound ??\n (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : undefined)\n\n let headMaxIndex =\n inner.firstBadMatchIndex !== undefined\n ? inner.firstBadMatchIndex\n : inner.matches.length - 1\n\n if (!notFoundToThrow && beforeLoadNotFound && inner.preload) {\n return inner.matches\n }\n\n if (notFoundToThrow) {\n // Determine once which matched route will actually render the\n // notFoundComponent, then pass this precomputed index through the remaining\n // finalization steps.\n // This can differ from the throwing route when routeId targets an ancestor\n // boundary (or when bubbling resolves to a parent/root boundary).\n const renderedBoundaryIndex = getNotFoundBoundaryIndex(\n inner,\n notFoundToThrow,\n )\n\n if (renderedBoundaryIndex === undefined) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Invariant failed: Could not find match for notFound boundary',\n )\n }\n\n invariant()\n }\n const boundaryMatch = inner.matches[renderedBoundaryIndex]!\n\n const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId]!\n const defaultNotFoundComponent = (inner.router.options as any)\n ?.defaultNotFoundComponent\n\n // Ensure a notFoundComponent exists on the boundary route\n if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) {\n boundaryRoute.options.notFoundComponent = defaultNotFoundComponent\n }\n\n notFoundToThrow.routeId = boundaryMatch.routeId\n\n const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id\n\n inner.updateMatch(boundaryMatch.id, (prev) => ({\n ...prev,\n ...(boundaryIsRoot\n ? // For root boundary, use globalNotFound so the root component's\n // shell still renders and <Outlet> handles the not-found display,\n // instead of replacing the entire root shell via status='notFound'.\n { status: 'success' as const, globalNotFound: true, error: undefined }\n : // For non-root boundaries, set status:'notFound' so MatchInner\n // renders the notFoundComponent directly.\n { status: 'notFound' as const, error: notFoundToThrow }),\n isFetching: false,\n }))\n\n headMaxIndex = renderedBoundaryIndex\n\n // Ensure the rendering boundary route chunk (and its lazy components, including\n // lazy notFoundComponent) is loaded before we continue to head execution/render.\n await loadRouteChunk(boundaryRoute, ['notFoundComponent'])\n } else if (!inner.preload) {\n // Clear stale root global-not-found state on normal navigations that do not\n // throw notFound. This must live here (instead of only in runLoader success)\n // because the root loader may be skipped when data is still fresh.\n const rootMatch = inner.matches[0]!\n // `rootMatch` is the next match for this navigation. If it is not global\n // not-found, then any currently stored root global-not-found is stale.\n if (!rootMatch.globalNotFound) {\n // `currentRootMatch` is the current store state (from the previous\n // navigation/load). Update only when a stale flag is actually present.\n const currentRootMatch = inner.router.getMatch(rootMatch.id)\n if (currentRootMatch?.globalNotFound) {\n inner.updateMatch(rootMatch.id, (prev) => ({\n ...prev,\n globalNotFound: false,\n error: undefined,\n }))\n }\n }\n }\n\n // When a serial error occurred (e.g. beforeLoad threw a regular Error),\n // the erroring route's lazy chunk wasn't loaded because loaders were skipped.\n // We need to load it so the code-split errorComponent is available for rendering.\n if (inner.serialError && inner.firstBadMatchIndex !== undefined) {\n const errorRoute =\n inner.router.looseRoutesById[\n inner.matches[inner.firstBadMatchIndex]!.routeId\n ]!\n await loadRouteChunk(errorRoute, ['errorComponent'])\n }\n\n // serially execute heads once after loaders/notFound handling, ensuring\n // all head functions get a chance even if one throws.\n for (let i = 0; i <= headMaxIndex; i++) {\n const match = inner.matches[i]!\n const { id: matchId, routeId } = match\n const route = inner.router.looseRoutesById[routeId]!\n try {\n const headResult = executeHead(inner, matchId, route)\n if (headResult) {\n const head = await headResult\n inner.updateMatch(matchId, (prev) => ({\n ...prev,\n ...head,\n }))\n }\n } catch (err) {\n console.error(`Error executing head for route ${routeId}:`, err)\n }\n }\n\n const readyPromise = triggerOnReady(inner)\n if (isPromise(readyPromise)) {\n await readyPromise\n }\n\n if (notFoundToThrow) {\n throw notFoundToThrow\n }\n\n if (inner.serialError && !inner.preload && !inner.onReady) {\n throw inner.serialError\n }\n\n return inner.matches\n}\n\nexport type RouteComponentType =\n | 'component'\n | 'errorComponent'\n | 'pendingComponent'\n | 'notFoundComponent'\n\nfunction preloadRouteComponents(\n route: AnyRoute,\n componentTypesToLoad: Array<RouteComponentType>,\n): Promise<void> | undefined {\n const preloads = componentTypesToLoad\n .map((type) => (route.options[type] as any)?.preload?.())\n .filter(Boolean)\n\n if (preloads.length === 0) return undefined\n\n return Promise.all(preloads) as any as Promise<void>\n}\n\nexport function loadRouteChunk(\n route: AnyRoute,\n componentTypesToLoad: Array<RouteComponentType> = componentTypes,\n) {\n if (!route._lazyLoaded && route._lazyPromise === undefined) {\n if (route.lazyFn) {\n route._lazyPromise = route.lazyFn().then((lazyRoute) => {\n // explicitly don't copy over the lazy route's id\n const { id: _id, ...options } = lazyRoute.options\n Object.assign(route.options, options)\n route._lazyLoaded = true\n route._lazyPromise = undefined // gc promise, we won't need it anymore\n })\n } else {\n route._lazyLoaded = true\n }\n }\n\n const runAfterLazy = () =>\n route._componentsLoaded\n ? undefined\n : componentTypesToLoad === componentTypes\n ? (() => {\n if (route._componentsPromise === undefined) {\n const componentsPromise = preloadRouteComponents(\n route,\n componentTypes,\n )\n\n if (componentsPromise) {\n route._componentsPromise = componentsPromise.then(() => {\n route._componentsLoaded = true\n route._componentsPromise = undefined // gc promise, we won't need it anymore\n })\n } else {\n route._componentsLoaded = true\n }\n }\n\n return route._componentsPromise\n })()\n : preloadRouteComponents(route, componentTypesToLoad)\n\n return route._lazyPromise\n ? route._lazyPromise.then(runAfterLazy)\n : runAfterLazy()\n}\n\nfunction makeMaybe<TValue, TError>(\n value: TValue,\n error: TError,\n): { status: 'success'; value: TValue } | { status: 'error'; error: TError } {\n if (error) {\n return { status: 'error' as const, error }\n }\n return { status: 'success' as const, value }\n}\n\nexport function routeNeedsPreload(route: AnyRoute) {\n for (const componentType of componentTypes) {\n if ((route.options[componentType] as any)?.preload) {\n return true\n }\n }\n return false\n}\n\nexport const componentTypes: Array<RouteComponentType> = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n 'notFoundComponent',\n] as const\n"],"mappings":";;;;;;;AAuCA,MAAM,kBAAkB,UAAkD;CACxE,IAAI,CAAC,MAAM,UAAU;EACnB,MAAM,WAAW;EACjB,OAAO,MAAM,UAAU;CACzB;AACF;AAEA,MAAM,8BAA8B,WAA+B;CACjE,OAAO,OAAO,OAAO,UAAU,IAAI,EAAE,MAAM,YAAY;EACrD,OAAO,OAAO,OAAO,YAAY,IAAI,OAAO,GAAG,IAAI,EAAE;CACvD,CAAC;AACH;AAEA,MAAM,kBAAkB,OAAyB,YAA6B;CAC5E,OAAO,CAAC,EAAE,MAAM,WAAW,CAAC,MAAM,OAAO,OAAO,YAAY,IAAI,OAAO;AACzE;;;;;AAMA,MAAM,qBACJ,OACA,OACA,sBAA+B,SACH;CAC5B,MAAM,UAAmC,EACvC,GAAI,MAAM,OAAO,QAAQ,WAAW,CAAC,EACvC;CACA,MAAM,MAAM,sBAAsB,QAAQ,QAAQ;CAClD,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK,KAAK;EAC7B,MAAM,aAAa,MAAM,QAAQ;EACjC,IAAI,CAAC,YAAY;EACjB,MAAM,IAAI,MAAM,OAAO,SAAS,WAAW,EAAE;EAC7C,IAAI,CAAC,GAAG;EACR,OAAO,OAAO,SAAS,EAAE,gBAAgB,EAAE,mBAAmB;CAChE;CACA,OAAO;AACT;AAEA,MAAM,4BACJ,OACA,QACuB;CACvB,IAAI,CAAC,MAAM,QAAQ,QACjB;CAGF,MAAM,mBAAmB,IAAI;CAC7B,MAAM,mBAAmB,MAAM,QAAQ,WACpC,MAAM,EAAE,YAAY,MAAM,OAAO,UAAU,EAC9C;CACA,MAAM,YAAY,oBAAoB,IAAI,mBAAmB;CAE7D,IAAI,aAAa,mBACb,MAAM,QAAQ,WAAW,UAAU,MAAM,YAAY,gBAAgB,IACpE,MAAM,sBAAsB,M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zC,OAAO;CAGX,OAAO;AACT;AAEA,MAAa,iBAA4C;CACvD;CACA;CACA;CACA;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
- "version": "1.171.7",
3
+ "version": "1.171.8",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -207,7 +207,6 @@ const handleSerialError = (
207
207
  inner: InnerLoadContext,
208
208
  index: number,
209
209
  err: any,
210
- routerCode: string,
211
210
  ): void => {
212
211
  const { id: matchId, routeId } = inner.matches[index]!
213
212
  const route = inner.router.looseRoutesById[routeId]!
@@ -219,7 +218,6 @@ const handleSerialError = (
219
218
  throw err
220
219
  }
221
220
 
222
- err.routerCode = routerCode
223
221
  inner.firstBadMatchIndex ??= index
224
222
  handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err)
225
223
 
@@ -405,11 +403,11 @@ const executeBeforeLoad = (
405
403
  const { paramsError, searchError } = match
406
404
 
407
405
  if (paramsError) {
408
- handleSerialError(inner, index, paramsError, 'PARSE_PARAMS')
406
+ handleSerialError(inner, index, paramsError)
409
407
  }
410
408
 
411
409
  if (searchError) {
412
- handleSerialError(inner, index, searchError, 'VALIDATE_SEARCH')
410
+ handleSerialError(inner, index, searchError)
413
411
  }
414
412
 
415
413
  setupPendingTimeout(inner, matchId, route, match)
@@ -499,7 +497,7 @@ const executeBeforeLoad = (
499
497
  }
500
498
  if (isRedirect(beforeLoadContext) || isNotFound(beforeLoadContext)) {
501
499
  pending()
502
- handleSerialError(inner, index, beforeLoadContext, 'BEFORE_LOAD')
500
+ handleSerialError(inner, index, beforeLoadContext)
503
501
  }
504
502
 
505
503
  inner.router.batch(() => {
@@ -519,13 +517,13 @@ const executeBeforeLoad = (
519
517
  pending()
520
518
  return beforeLoadContext
521
519
  .catch((err) => {
522
- handleSerialError(inner, index, err, 'BEFORE_LOAD')
520
+ handleSerialError(inner, index, err)
523
521
  })
524
522
  .then(updateContext)
525
523
  }
526
524
  } catch (err) {
527
525
  pending()
528
- handleSerialError(inner, index, err, 'BEFORE_LOAD')
526
+ handleSerialError(inner, index, err)
529
527
  }
530
528
 
531
529
  updateContext(beforeLoadContext)