{"version":3,"file":"Match.cjs","names":[],"sources":["../../src/Match.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport {\n  createControlledPromise,\n  getLocationChangeInfo,\n  invariant,\n  isNotFound,\n  isRedirect,\n  rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport { ClientOnly } from './ClientOnly'\nimport { useLayoutEffect } from './utils'\nimport type {\n  AnyRoute,\n  AnyRouteMatch,\n  ParsedLocation,\n  RootRouteOptions,\n} from '@tanstack/router-core'\n\ntype OutletMatchSelection = [\n  routeId: string | undefined,\n  parentGlobalNotFound: boolean,\n]\n\nconst matchViewFieldsEqual = (a: AnyRouteMatch, b: AnyRouteMatch) =>\n  a.routeId === b.routeId && a._displayPending === b._displayPending\n\nconst outletMatchSelectionEqual = (\n  a: OutletMatchSelection,\n  b: OutletMatchSelection,\n) => a[0] === b[0] && a[1] === b[1]\n\nexport const Match = React.memo(function MatchImpl({\n  matchId,\n}: {\n  matchId: string\n}) {\n  const router = useRouter()\n\n  if (isServer ?? router.isServer) {\n    const match = router.stores.matchStores.get(matchId)?.get()\n    if (!match) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error(\n          `Invariant failed: Could not find match for matchId \"${matchId}\". Please file an issue!`,\n        )\n      }\n\n      invariant()\n    }\n\n    const routeId = match.routeId as string\n    const parentRouteId = (router.routesById[routeId] as AnyRoute).parentRoute\n      ?.id\n\n    return (\n      <MatchView\n        router={router}\n        matchId={matchId}\n        resetKey={router.stores.loadedAt.get()}\n        matchState={{\n          routeId,\n          ssr: match.ssr,\n          _displayPending: match._displayPending,\n          parentRouteId,\n        }}\n      />\n    )\n  }\n\n  // Subscribe directly to the match store from the pool.\n  // The matchId prop is stable for this component's lifetime (set by Outlet),\n  // and reconcileMatchPool reuses stores for the same matchId.\n\n  const matchStore = router.stores.matchStores.get(matchId)\n  if (!matchStore) {\n    if (process.env.NODE_ENV !== 'production') {\n      throw new Error(\n        `Invariant failed: Could not find match for matchId \"${matchId}\". Please file an issue!`,\n      )\n    }\n\n    invariant()\n  }\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const resetKey = useStore(router.stores.loadedAt, (loadedAt) => loadedAt)\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const match = useStore(matchStore, (value) => value, matchViewFieldsEqual)\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const matchState = React.useMemo(() => {\n    const routeId = match.routeId as string\n    const parentRouteId = (router.routesById[routeId] as AnyRoute).parentRoute\n      ?.id\n\n    return {\n      routeId,\n      ssr: match.ssr,\n      _displayPending: match._displayPending,\n      parentRouteId: parentRouteId as string | undefined,\n    } satisfies MatchViewState\n  }, [match._displayPending, match.routeId, match.ssr, router.routesById])\n\n  return (\n    <MatchView\n      router={router}\n      matchId={matchId}\n      resetKey={resetKey}\n      matchState={matchState}\n    />\n  )\n})\n\ntype MatchViewState = {\n  routeId: string\n  ssr: boolean | 'data-only' | undefined\n  _displayPending: boolean | undefined\n  parentRouteId: string | undefined\n}\n\nfunction MatchView({\n  router,\n  matchId,\n  resetKey,\n  matchState,\n}: {\n  router: ReturnType<typeof useRouter>\n  matchId: string\n  resetKey: number\n  matchState: MatchViewState\n}) {\n  const route: AnyRoute = router.routesById[matchState.routeId]\n\n  const PendingComponent =\n    route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n  const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n  const routeErrorComponent =\n    route.options.errorComponent ?? router.options.defaultErrorComponent\n\n  const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n  const routeNotFoundComponent = route.isRoot\n    ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n      (route.options.notFoundComponent ??\n      router.options.notFoundRoute?.options.component)\n    : route.options.notFoundComponent\n\n  const resolvedNoSsr =\n    matchState.ssr === false || matchState.ssr === 'data-only'\n  const ResolvedSuspenseBoundary =\n    // If we're on the root route, allow forcefully wrapping in suspense\n    (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) &&\n    (route.options.wrapInSuspense ??\n      PendingComponent ??\n      ((route.options.errorComponent as any)?.preload || resolvedNoSsr))\n      ? React.Suspense\n      : SafeFragment\n\n  const ResolvedCatchBoundary = routeErrorComponent\n    ? CatchBoundary\n    : SafeFragment\n\n  const ResolvedNotFoundBoundary = routeNotFoundComponent\n    ? CatchNotFound\n    : SafeFragment\n\n  const ShellComponent = route.isRoot\n    ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)\n    : SafeFragment\n  return (\n    <ShellComponent>\n      <matchContext.Provider value={matchId}>\n        <ResolvedSuspenseBoundary fallback={pendingElement}>\n          <ResolvedCatchBoundary\n            getResetKey={() => resetKey}\n            errorComponent={routeErrorComponent || ErrorComponent}\n            onCatch={(error, errorInfo) => {\n              // Forward not found errors (we don't want to show the error component for these)\n              if (isNotFound(error)) {\n                error.routeId ??= matchState.routeId as any\n                throw error\n              }\n              if (process.env.NODE_ENV !== 'production') {\n                console.warn(`Warning: Error in route match: ${matchId}`)\n              }\n              routeOnCatch?.(error, errorInfo)\n            }}\n          >\n            <ResolvedNotFoundBoundary\n              fallback={(error) => {\n                error.routeId ??= matchState.routeId as any\n\n                // If the current not found handler doesn't exist or it has a\n                // route ID which doesn't match the current route, rethrow the error\n                if (\n                  !routeNotFoundComponent ||\n                  (error.routeId && error.routeId !== matchState.routeId) ||\n                  (!error.routeId && !route.isRoot)\n                )\n                  throw error\n\n                return React.createElement(routeNotFoundComponent, error as any)\n              }}\n            >\n              {resolvedNoSsr || matchState._displayPending ? (\n                <ClientOnly fallback={pendingElement}>\n                  <MatchInner matchId={matchId} />\n                </ClientOnly>\n              ) : (\n                <MatchInner matchId={matchId} />\n              )}\n            </ResolvedNotFoundBoundary>\n          </ResolvedCatchBoundary>\n        </ResolvedSuspenseBoundary>\n      </matchContext.Provider>\n      {matchState.parentRouteId === rootRouteId ? (\n        <>\n          <OnRendered />\n          {router.options.scrollRestoration && (isServer ?? router.isServer) ? (\n            <ScrollRestoration />\n          ) : null}\n        </>\n      ) : null}\n    </ShellComponent>\n  )\n}\n\n// On Rendered can't happen above the root layout because it needs to run after\n// the route subtree has committed below the root layout. Keeping it here lets\n// us fire onRendered even after a hydration mismatch above the root layout\n// (like bad head/link tags, which is common).\nfunction OnRendered() {\n  const router = useRouter()\n\n  if (isServer ?? router.isServer) {\n    return null\n  }\n\n  // Track the resolvedLocation as of the last render so that onRendered can\n  // report the correct fromLocation. By the time this effect fires,\n  // resolvedLocation has already been updated to the new location by\n  // Transitioner, so we cannot use router.stores.resolvedLocation.get()\n  // directly as the fromLocation.\n  // @ts-expect-error -- init to `undefined` but don't write `undefined` to shave bytes\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const prevResolvedLocationRef = React.useRef<\n    ParsedLocation<any> | undefined\n  >()\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const renderedLocationKey = useStore(\n    router.stores.resolvedLocation,\n    (resolvedLocation) => resolvedLocation?.state.__TSR_key,\n  )\n\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  useLayoutEffect(() => {\n    const currentResolvedLocation = router.stores.resolvedLocation.get()\n    const previousResolvedLocation = prevResolvedLocationRef.current\n\n    if (\n      currentResolvedLocation &&\n      (!previousResolvedLocation ||\n        previousResolvedLocation.href !== currentResolvedLocation.href)\n    ) {\n      router.emit({\n        type: 'onRendered',\n        ...getLocationChangeInfo(\n          router.stores.location.get(),\n          previousResolvedLocation ?? currentResolvedLocation,\n        ),\n      })\n    }\n    prevResolvedLocationRef.current = currentResolvedLocation\n  }, [renderedLocationKey, router])\n\n  return null\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n  matchId,\n}: {\n  matchId: string\n}): any {\n  const router = useRouter()\n\n  const getMatchPromise = (\n    match: {\n      id: string\n      _nonReactive: {\n        displayPendingPromise?: Promise<void>\n        minPendingPromise?: Promise<void>\n        loadPromise?: Promise<void>\n      }\n    },\n    key: 'displayPendingPromise' | 'minPendingPromise' | 'loadPromise',\n  ) => {\n    return (\n      router.getMatch(match.id)?._nonReactive[key] ?? match._nonReactive[key]\n    )\n  }\n\n  if (isServer ?? router.isServer) {\n    const match = router.stores.matchStores.get(matchId)?.get()\n    if (!match) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error(\n          `Invariant failed: Could not find match for matchId \"${matchId}\". Please file an issue!`,\n        )\n      }\n\n      invariant()\n    }\n\n    const routeId = match.routeId as string\n    const route = router.routesById[routeId] as AnyRoute\n    const remountFn =\n      (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n      router.options.defaultRemountDeps\n    const remountDeps = remountFn?.({\n      routeId,\n      loaderDeps: match.loaderDeps,\n      params: match._strictParams,\n      search: match._strictSearch,\n    })\n    const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n    const Comp = route.options.component ?? router.options.defaultComponent\n    const out = Comp ? <Comp key={key} /> : <Outlet />\n\n    if (match._displayPending) {\n      throw getMatchPromise(match, 'displayPendingPromise')\n    }\n\n    if (match._forcePending) {\n      throw getMatchPromise(match, 'minPendingPromise')\n    }\n\n    if (match.status === 'pending') {\n      throw getMatchPromise(match, 'loadPromise')\n    }\n\n    if (match.status === 'notFound') {\n      if (!isNotFound(match.error)) {\n        if (process.env.NODE_ENV !== 'production') {\n          throw new Error('Invariant failed: Expected a notFound error')\n        }\n\n        invariant()\n      }\n      return renderRouteNotFound(router, route, match.error)\n    }\n\n    if (match.status === 'redirected') {\n      if (!isRedirect(match.error)) {\n        if (process.env.NODE_ENV !== 'production') {\n          throw new Error('Invariant failed: Expected a redirect error')\n        }\n\n        invariant()\n      }\n      throw getMatchPromise(match, 'loadPromise')\n    }\n\n    if (match.status === 'error') {\n      const RouteErrorComponent =\n        (route.options.errorComponent ??\n          router.options.defaultErrorComponent) ||\n        ErrorComponent\n      return (\n        <RouteErrorComponent\n          error={match.error as any}\n          reset={undefined as any}\n          info={{\n            componentStack: '',\n          }}\n        />\n      )\n    }\n\n    return out\n  }\n\n  const matchStore = router.stores.matchStores.get(matchId)\n  if (!matchStore) {\n    if (process.env.NODE_ENV !== 'production') {\n      throw new Error(\n        `Invariant failed: Could not find match for matchId \"${matchId}\". Please file an issue!`,\n      )\n    }\n\n    invariant()\n  }\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const match = useStore(matchStore, (value) => value)\n  const routeId = match.routeId as string\n  const route = router.routesById[routeId] as AnyRoute\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const key = React.useMemo(() => {\n    const remountFn =\n      (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n      router.options.defaultRemountDeps\n    const remountDeps = remountFn?.({\n      routeId,\n      loaderDeps: match.loaderDeps,\n      params: match._strictParams,\n      search: match._strictSearch,\n    })\n    return remountDeps ? JSON.stringify(remountDeps) : undefined\n  }, [\n    routeId,\n    match.loaderDeps,\n    match._strictParams,\n    match._strictSearch,\n    router.options.defaultRemountDeps,\n    router.routesById,\n  ])\n\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const out = React.useMemo(() => {\n    const Comp = route.options.component ?? router.options.defaultComponent\n    if (Comp) {\n      return <Comp key={key} />\n    }\n    return <Outlet />\n  }, [key, route.options.component, router.options.defaultComponent])\n\n  if (match._displayPending) {\n    throw getMatchPromise(match, 'displayPendingPromise')\n  }\n\n  if (match._forcePending) {\n    throw getMatchPromise(match, 'minPendingPromise')\n  }\n\n  // see also hydrate() in packages/router-core/src/ssr/ssr-client.ts\n  if (match.status === 'pending') {\n    // We're pending, and if we have a minPendingMs, we need to wait for it\n    const pendingMinMs =\n      route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n    if (pendingMinMs) {\n      const routerMatch = router.getMatch(match.id)\n      if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {\n        // Create a promise that will resolve after the minPendingMs\n        if (!(isServer ?? router.isServer)) {\n          const minPendingPromise = createControlledPromise<void>()\n\n          routerMatch._nonReactive.minPendingPromise = minPendingPromise\n\n          setTimeout(() => {\n            minPendingPromise.resolve()\n            // We've handled the minPendingPromise, so we can delete it\n            routerMatch._nonReactive.minPendingPromise = undefined\n          }, pendingMinMs)\n        }\n      }\n    }\n    throw getMatchPromise(match, 'loadPromise')\n  }\n\n  if (match.status === 'notFound') {\n    if (!isNotFound(match.error)) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error('Invariant failed: Expected a notFound error')\n      }\n\n      invariant()\n    }\n    return renderRouteNotFound(router, route, match.error)\n  }\n\n  if (match.status === 'redirected') {\n    // A match can be observed as redirected during an in-flight transition,\n    // especially when pending UI is already rendering. Suspend on the match's\n    // load promise so React can abandon this stale render and continue the\n    // redirect transition.\n    if (!isRedirect(match.error)) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error('Invariant failed: Expected a redirect error')\n      }\n\n      invariant()\n    }\n\n    throw getMatchPromise(match, 'loadPromise')\n  }\n\n  if (match.status === 'error') {\n    // If we're on the server, we need to use React's new and super\n    // wonky api for throwing errors from a server side render inside\n    // of a suspense boundary. This is the only way to get\n    // renderToPipeableStream to not hang indefinitely.\n    // We'll serialize the error and rethrow it on the client.\n    if (isServer ?? router.isServer) {\n      const RouteErrorComponent =\n        (route.options.errorComponent ??\n          router.options.defaultErrorComponent) ||\n        ErrorComponent\n      return (\n        <RouteErrorComponent\n          error={match.error as any}\n          reset={undefined as any}\n          info={{\n            componentStack: '',\n          }}\n        />\n      )\n    }\n\n    throw match.error\n  }\n\n  return out\n})\n\n/**\n * Render the next child match in the route tree. Typically used inside\n * a route component to render nested routes.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent\n */\nexport const Outlet = React.memo(function OutletImpl() {\n  const router = useRouter()\n  const matchId = React.useContext(matchContext)\n\n  let routeId: string | undefined\n  let parentGlobalNotFound = false\n  let childMatchId: string | undefined\n\n  if (isServer ?? router.isServer) {\n    const matches = router.stores.matches.get()\n    const parentIndex = matchId\n      ? matches.findIndex((match) => match.id === matchId)\n      : -1\n    const parentMatch = parentIndex >= 0 ? matches[parentIndex] : undefined\n    routeId = parentMatch?.routeId as string | undefined\n    parentGlobalNotFound = parentMatch?.globalNotFound ?? false\n    childMatchId =\n      parentIndex >= 0 ? (matches[parentIndex + 1]?.id as string) : undefined\n  } else {\n    // Subscribe directly to the match store from the pool instead of\n    // the two-level byId → matchStore pattern.\n    const parentMatchStore = matchId\n      ? router.stores.matchStores.get(matchId)\n      : undefined\n\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    ;[routeId, parentGlobalNotFound] = useStore(\n      parentMatchStore,\n      (match): OutletMatchSelection => [\n        match?.routeId as string | undefined,\n        match?.globalNotFound ?? false,\n      ],\n      outletMatchSelectionEqual,\n    )\n\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    childMatchId = useStore(router.stores.matchesId, (ids) => {\n      const index = ids.findIndex((id) => id === matchId)\n      return ids[index + 1]\n    })\n  }\n\n  const route = routeId ? router.routesById[routeId] : undefined\n\n  const pendingElement = router.options.defaultPendingComponent ? (\n    <router.options.defaultPendingComponent />\n  ) : null\n\n  if (parentGlobalNotFound) {\n    if (!route) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error(\n          'Invariant failed: Could not resolve route for Outlet render',\n        )\n      }\n\n      invariant()\n    }\n    return renderRouteNotFound(router, route, undefined)\n  }\n\n  if (!childMatchId) {\n    return null\n  }\n\n  const nextMatch = <Match matchId={childMatchId} />\n\n  if (routeId === rootRouteId) {\n    return (\n      <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n    )\n  }\n\n  return nextMatch\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,IAAM,wBAAwB,GAAkB,MAC9C,EAAE,YAA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