@tanstack/react-router 1.36.2 → 1.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { createBrowserHistory, createMemoryHistory } from '@tanstack/history'\nimport { Store } from '@tanstack/react-store'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { rootRouteId } from './root'\nimport { defaultParseSearch, defaultStringifySearch } from './searchParams'\nimport {\n createControlledPromise,\n deepEqual,\n functionalUpdate,\n last,\n pick,\n replaceEqualDeep,\n} from './utils'\nimport { getRouteMatch } from './RouterProvider'\nimport {\n cleanPath,\n interpolatePath,\n joinPaths,\n matchPathname,\n parsePathname,\n resolvePath,\n trimPath,\n trimPathLeft,\n trimPathRight,\n} from './path'\nimport { isRedirect, isResolvedRedirect } from './redirects'\nimport { isNotFound } from './not-found'\nimport type { Manifest } from './manifest'\nimport type * as React from 'react'\nimport type {\n HistoryLocation,\n HistoryState,\n RouterHistory,\n} from '@tanstack/history'\n\n//\n\nimport type {\n AnyContext,\n AnyRoute,\n AnySearchSchema,\n ErrorRouteComponent,\n LoaderFnContext,\n NotFoundRouteComponent,\n RouteMask,\n} from './route'\nimport type {\n FullSearchSchema,\n RouteById,\n RoutePaths,\n RoutesById,\n RoutesByPath,\n} from './routeInfo'\nimport type {\n ControlledPromise,\n NonNullableUpdater,\n PickAsRequired,\n Timeout,\n Updater,\n} from './utils'\nimport type { RouteComponent } from './route'\nimport type {\n AnyRouteMatch,\n MakeRouteMatch,\n MatchRouteOptions,\n RouteMatch,\n} from './Matches'\nimport type { ParsedLocation } from './location'\nimport type { SearchParser, SearchSerializer } from './searchParams'\nimport type {\n BuildLocationFn,\n CommitLocationOptions,\n InjectedHtmlEntry,\n NavigateFn,\n} from './RouterProvider'\n\nimport type { AnyRedirect, ResolvedRedirect } from './redirects'\n\nimport type { NotFoundError } from './not-found'\nimport type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'\nimport type { NoInfer } from '@tanstack/react-store'\nimport type { DeferredPromiseState } from './defer'\nimport type { ErrorInfo } from 'react'\n\n//\n\ndeclare global {\n interface Window {\n __TSR_DEHYDRATED__?: { data: string }\n __TSR_ROUTER_CONTEXT__?: React.Context<Router<any, any>>\n }\n}\n\nexport interface Register {\n // router: Router\n}\n\nexport type AnyRouter = Router<any, any, any, any>\n\nexport type RegisteredRouter = Register extends {\n router: infer TRouter extends AnyRouter\n}\n ? TRouter\n : AnyRouter\n\nexport type HydrationCtx = {\n router: DehydratedRouter\n payload: Record<string, any>\n}\n\nexport type RouterContextOptions<TRouteTree extends AnyRoute> =\n AnyContext extends TRouteTree['types']['routerContext']\n ? {\n context?: TRouteTree['types']['routerContext']\n }\n : {\n context: TRouteTree['types']['routerContext']\n }\n\nexport type TrailingSlashOption = 'always' | 'never' | 'preserve'\n\nexport interface RouterOptions<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDehydrated extends Record<string, any> = Record<string, any>,\n TSerializedError extends Record<string, any> = Record<string, any>,\n> {\n /**\n * The history object that will be used to manage the browser history.\n * If not provided, a new createBrowserHistory instance will be created and used.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)\n */\n history?: RouterHistory\n /**\n * A function that will be used to stringify search params when generating links.\n * Defaults to `defaultStringifySearch`.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)\n */\n stringifySearch?: SearchSerializer\n /**\n * A function that will be used to parse search params when parsing the current location.\n * Defaults to `defaultParseSearch`.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)\n */\n parseSearch?: SearchParser\n /**\n * Defaults to `false`\n * If `false`, routes will not be preloaded by default in any way.\n * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n */\n defaultPreload?: false | 'intent'\n /**\n * Defaults to 50\n * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)\n */\n defaultPreloadDelay?: number\n /**\n * Defaults to `Outlet`\n * The default `component` a route should use if no component is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)\n */\n defaultComponent?: RouteComponent\n /**\n * Defaults to `ErrorComponent`\n * The default `errorComponent` a route should use if no error component is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)\n */\n defaultErrorComponent?: ErrorRouteComponent\n /**\n * The default `pendingComponent` a route should use if no pending component is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)\n */\n defaultPendingComponent?: RouteComponent\n /**\n * Defaults to `1000`\n * The default `pendingMs` a route should use if no pendingMs is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)\n */\n defaultPendingMs?: number\n /**\n * Defaults to `500`\n * The default `pendingMinMs` a route should use if no pendingMinMs is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)\n */\n defaultPendingMinMs?: number\n /**\n * Defaults to `0`\n * The default `staleTime` a route should use if no staleTime is\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)\n */\n defaultStaleTime?: number\n /**\n * Defaults to `30_000` ms (30 seconds)\n * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n */\n defaultPreloadStaleTime?: number\n /**\n * Defaults to `routerOptions.defaultGcTime`, which defaults to 30 minutes.\n * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n */\n defaultPreloadGcTime?: number\n /**\n * The default `onCatch` handler for errors caught by the Router ErrorBoundary\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)\n */\n defaultOnCatch?: (error: Error, errorInfo: ErrorInfo) => void\n defaultViewTransition?: boolean\n /**\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)\n */\n notFoundMode?: 'root' | 'fuzzy'\n /**\n * Defaults to 30 minutes.\n * The default `gcTime` a route should use if no\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)\n */\n defaultGcTime?: number\n /**\n * Defaults to `false`\n * If `true`, all routes will be matched as case-sensitive.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-trees#case-sensitivity)\n */\n caseSensitive?: boolean\n /**\n * Required\n * The route tree that will be used to configure the router instance.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-trees)\n */\n routeTree?: TRouteTree\n /**\n * Defaults to `/`\n * The basepath for then entire router. This is useful for mounting a router instance at a subpath.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)\n */\n basepath?: string\n /**\n * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).\n * The root context that will be provided to all routes in the route tree.\n * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)\n */\n context?: TRouteTree['types']['routerContext']\n /**\n * A function that will be called when the router is dehydrated.\n * The return value of this function will be serialized and stored in the router's dehydrated state.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)\n */\n dehydrate?: () => TDehydrated\n /**\n * A function that will be called when the router is hydrated.\n * The return value of this function will be serialized and stored in the router's dehydrated state.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)\n */\n hydrate?: (dehydrated: TDehydrated) => void\n /**\n * An array of route masks that will be used to mask routes in the route tree.\n * Route masking is when you display a route at a different path than the one it is configured to match, like a modal popup that when shared will unmask to the modal's content instead of the modal's context.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)\n */\n routeMasks?: Array<RouteMask<TRouteTree>>\n /**\n * Defaults to `false`\n * If `true`, route masks will, by default, be removed when the page is reloaded.\n * This can be overridden on a per-mask basis by setting the `unmaskOnReload` option on the mask, or on a per-navigation basis by setting the `unmaskOnReload` option in the `Navigate` options.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)\n */\n unmaskOnReload?: boolean\n /**\n * A component that will be used to wrap the entire router.\n * This is useful for providing a context to the entire router.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)\n */\n Wrap?: (props: { children: any }) => React.JSX.Element\n /**\n * A component that will be used to wrap the inner contents of the router.\n * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)\n */\n InnerWrap?: (props: { children: any }) => React.JSX.Element\n /**\n * @deprecated\n * Use `notFoundComponent` instead.\n * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)\n */\n notFoundRoute?: AnyRoute\n /**\n * Defaults to `NotFound`\n * The default `notFoundComponent` a route should use if no notFound component is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)\n */\n defaultNotFoundComponent?: NotFoundRouteComponent\n /**\n * The transformer that will be used when sending data between the server and the client during SSR.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#transformer-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/ssr#data-transformers)\n */\n transformer?: RouterTransformer\n /**\n * The serializer object that will be used to determine how errors are serialized and deserialized between the server and the client.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#errorserializer-property)\n */\n errorSerializer?: RouterErrorSerializer<TSerializedError>\n /**\n * Defaults to `never`\n * Configures how trailing slashes are treated.\n * `'always'` will add a trailing slash if not present, `'never'` will remove the trailing slash if present and `'preserve'` will not modify the trailing slash.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)\n */\n trailingSlash?: TTrailingSlashOption\n}\n\nexport interface RouterTransformer {\n stringify: (obj: unknown) => string\n parse: (str: string) => unknown\n}\nexport interface RouterErrorSerializer<TSerializedError> {\n serialize: (err: unknown) => TSerializedError\n deserialize: (err: TSerializedError) => unknown\n}\n\nexport interface RouterState<\n TRouteTree extends AnyRoute = AnyRoute,\n TRouteMatch = MakeRouteMatch<TRouteTree>,\n> {\n status: 'pending' | 'idle'\n isLoading: boolean\n isTransitioning: boolean\n matches: Array<TRouteMatch>\n pendingMatches?: Array<TRouteMatch>\n cachedMatches: Array<TRouteMatch>\n location: ParsedLocation<FullSearchSchema<TRouteTree>>\n resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>\n statusCode: number\n redirect?: ResolvedRedirect\n}\n\nexport type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void\n\nexport interface BuildNextOptions {\n to?: string | number | null\n params?: true | Updater<unknown>\n search?: true | Updater<unknown>\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<HistoryState>\n mask?: {\n to?: string | number | null\n params?: true | Updater<unknown>\n search?: true | Updater<unknown>\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<HistoryState>\n unmaskOnReload?: boolean\n }\n from?: string\n fromSearch?: unknown\n _fromLocation?: ParsedLocation\n}\n\nexport interface DehydratedRouterState {\n dehydratedMatches: Array<DehydratedRouteMatch>\n}\n\nexport type DehydratedRouteMatch = Pick<\n MakeRouteMatch,\n 'id' | 'status' | 'updatedAt' | 'loaderData'\n>\n\nexport interface DehydratedRouter {\n state: DehydratedRouterState\n manifest?: Manifest\n}\n\nexport type RouterConstructorOptions<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDehydrated extends Record<string, any>,\n TSerializedError extends Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n 'context'\n> &\n RouterContextOptions<TRouteTree>\n\nexport const componentTypes = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n 'notFoundComponent',\n] as const\n\nexport type RouterEvents = {\n onBeforeNavigate: {\n type: 'onBeforeNavigate'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onBeforeLoad: {\n type: 'onBeforeLoad'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onLoad: {\n type: 'onLoad'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onResolved: {\n type: 'onResolved'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n}\n\nexport type RouterEvent = RouterEvents[keyof RouterEvents]\n\nexport type RouterListener<TRouterEvent extends RouterEvent> = {\n eventType: TRouterEvent['type']\n fn: ListenerFn<TRouterEvent>\n}\n\nexport function createRouter<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDehydrated extends Record<string, any> = Record<string, any>,\n TSerializedError extends Record<string, any> = Record<string, any>,\n>(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n) {\n return new Router<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >(options)\n}\n\nexport class Router<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption,\n in out TDehydrated extends Record<string, any> = Record<string, any>,\n in out TSerializedError extends Record<string, any> = Record<string, any>,\n> {\n // Option-independent properties\n tempLocationKey: string | undefined = `${Math.round(\n Math.random() * 10000000,\n )}`\n resetNextScroll = true\n shouldViewTransition?: boolean = undefined\n latestLoadPromise: Promise<void> = Promise.resolve()\n subscribers = new Set<RouterListener<RouterEvent>>()\n dehydratedData?: TDehydrated\n viewTransitionPromise?: ControlledPromise<true>\n manifest?: Manifest\n\n // Must build in constructor\n __store!: Store<RouterState<TRouteTree>>\n options!: PickAsRequired<\n Omit<\n RouterOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n 'transformer'\n > & {\n transformer: RouterTransformer\n },\n 'stringifySearch' | 'parseSearch' | 'context'\n >\n history!: RouterHistory\n latestLocation!: ParsedLocation<FullSearchSchema<TRouteTree>>\n basepath!: string\n routeTree!: TRouteTree\n routesById!: RoutesById<TRouteTree>\n routesByPath!: RoutesByPath<TRouteTree>\n flatRoutes!: Array<AnyRoute>\n\n /**\n * @deprecated Use the `createRouter` function instead\n */\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n ) {\n this.update({\n defaultPreloadDelay: 50,\n defaultPendingMs: 1000,\n defaultPendingMinMs: 500,\n context: undefined!,\n ...options,\n stringifySearch: options.stringifySearch ?? defaultStringifySearch,\n parseSearch: options.parseSearch ?? defaultParseSearch,\n transformer: options.transformer ?? JSON,\n })\n\n if (typeof document !== 'undefined') {\n ;(window as any).__TSR__ROUTER__ = this\n }\n }\n\n isServer = typeof document === 'undefined'\n\n // These are default implementations that can optionally be overridden\n // by the router provider once rendered. We provide these so that the\n // router can be used in a non-react environment if necessary\n startReactTransition: (fn: () => void) => void = (fn) => fn()\n\n update = (\n newOptions: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n ) => {\n if (newOptions.notFoundRoute) {\n console.warn(\n 'The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.',\n )\n }\n\n const previousOptions = this.options\n this.options = {\n ...this.options,\n ...newOptions,\n }\n\n if (\n !this.basepath ||\n (newOptions.basepath && newOptions.basepath !== previousOptions.basepath)\n ) {\n if (\n newOptions.basepath === undefined ||\n newOptions.basepath === '' ||\n newOptions.basepath === '/'\n ) {\n this.basepath = '/'\n } else {\n this.basepath = `/${trimPath(newOptions.basepath)}`\n }\n }\n\n if (\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n !this.history ||\n (this.options.history && this.options.history !== this.history)\n ) {\n this.history =\n this.options.history ??\n (typeof document !== 'undefined'\n ? createBrowserHistory()\n : createMemoryHistory({\n initialEntries: [this.options.basepath || '/'],\n }))\n this.latestLocation = this.parseLocation()\n }\n\n if (this.options.routeTree !== this.routeTree) {\n this.routeTree = this.options.routeTree as TRouteTree\n this.buildRouteTree()\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!this.__store) {\n this.__store = new Store(getInitialRouterState(this.latestLocation), {\n onUpdate: () => {\n this.__store.state = {\n ...this.state,\n cachedMatches: this.state.cachedMatches.filter(\n (d) => !['redirected'].includes(d.status),\n ),\n }\n },\n })\n }\n }\n\n get state() {\n return this.__store.state\n }\n\n buildRouteTree = () => {\n this.routesById = {} as RoutesById<TRouteTree>\n this.routesByPath = {} as RoutesByPath<TRouteTree>\n\n const notFoundRoute = this.options.notFoundRoute\n if (notFoundRoute) {\n notFoundRoute.init({ originalIndex: 99999999999 })\n ;(this.routesById as any)[notFoundRoute.id] = notFoundRoute\n }\n\n const recurseRoutes = (childRoutes: Array<AnyRoute>) => {\n childRoutes.forEach((childRoute, i) => {\n childRoute.init({ originalIndex: i })\n\n const existingRoute = (this.routesById as any)[childRoute.id]\n\n invariant(\n !existingRoute,\n `Duplicate routes found with id: ${String(childRoute.id)}`,\n )\n ;(this.routesById as any)[childRoute.id] = childRoute\n\n if (!childRoute.isRoot && childRoute.path) {\n const trimmedFullPath = trimPathRight(childRoute.fullPath)\n if (\n !(this.routesByPath as any)[trimmedFullPath] ||\n childRoute.fullPath.endsWith('/')\n ) {\n ;(this.routesByPath as any)[trimmedFullPath] = childRoute\n }\n }\n\n const children = childRoute.children\n\n if (children?.length) {\n recurseRoutes(children)\n }\n })\n }\n\n recurseRoutes([this.routeTree])\n\n const scoredRoutes: Array<{\n child: AnyRoute\n trimmed: string\n parsed: ReturnType<typeof parsePathname>\n index: number\n scores: Array<number>\n }> = []\n\n const routes: Array<AnyRoute> = Object.values(this.routesById)\n\n routes.forEach((d, i) => {\n if (d.isRoot || !d.path) {\n return\n }\n\n const trimmed = trimPathLeft(d.fullPath)\n const parsed = parsePathname(trimmed)\n\n while (parsed.length > 1 && parsed[0]?.value === '/') {\n parsed.shift()\n }\n\n const scores = parsed.map((segment) => {\n if (segment.value === '/') {\n return 0.75\n }\n\n if (segment.type === 'param') {\n return 0.5\n }\n\n if (segment.type === 'wildcard') {\n return 0.25\n }\n\n return 1\n })\n\n scoredRoutes.push({ child: d, trimmed, parsed, index: i, scores })\n })\n\n this.flatRoutes = scoredRoutes\n .sort((a, b) => {\n const minLength = Math.min(a.scores.length, b.scores.length)\n\n // Sort by min available score\n for (let i = 0; i < minLength; i++) {\n if (a.scores[i] !== b.scores[i]) {\n return b.scores[i]! - a.scores[i]!\n }\n }\n\n // Sort by length of score\n if (a.scores.length !== b.scores.length) {\n return b.scores.length - a.scores.length\n }\n\n // Sort by min available parsed value\n for (let i = 0; i < minLength; i++) {\n if (a.parsed[i]!.value !== b.parsed[i]!.value) {\n return a.parsed[i]!.value > b.parsed[i]!.value ? 1 : -1\n }\n }\n\n // Sort by original index\n return a.index - b.index\n })\n .map((d, i) => {\n d.child.rank = i\n return d.child\n })\n }\n\n subscribe = <TType extends keyof RouterEvents>(\n eventType: TType,\n fn: ListenerFn<RouterEvents[TType]>,\n ) => {\n const listener: RouterListener<any> = {\n eventType,\n fn,\n }\n\n this.subscribers.add(listener)\n\n return () => {\n this.subscribers.delete(listener)\n }\n }\n\n emit = (routerEvent: RouterEvent) => {\n this.subscribers.forEach((listener) => {\n if (listener.eventType === routerEvent.type) {\n listener.fn(routerEvent)\n }\n })\n }\n\n checkLatest = (promise: Promise<void>): void => {\n if (this.latestLoadPromise !== promise) {\n throw this.latestLoadPromise\n }\n }\n\n parseLocation = (\n previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>,\n ): ParsedLocation<FullSearchSchema<TRouteTree>> => {\n const parse = ({\n pathname,\n search,\n hash,\n state,\n }: HistoryLocation): ParsedLocation<FullSearchSchema<TRouteTree>> => {\n const parsedSearch = this.options.parseSearch(search)\n const searchStr = this.options.stringifySearch(parsedSearch)\n\n return {\n pathname: pathname,\n searchStr,\n search: replaceEqualDeep(previousLocation?.search, parsedSearch) as any,\n hash: hash.split('#').reverse()[0] ?? '',\n href: `${pathname}${searchStr}${hash}`,\n state: replaceEqualDeep(previousLocation?.state, state),\n }\n }\n\n const location = parse(this.history.location)\n\n const { __tempLocation, __tempKey } = location.state\n\n if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {\n // Sync up the location keys\n const parsedTempLocation = parse(__tempLocation) as any\n parsedTempLocation.state.key = location.state.key\n\n delete parsedTempLocation.state.__tempLocation\n\n return {\n ...parsedTempLocation,\n maskedLocation: location,\n }\n }\n\n return location\n }\n\n resolvePathWithBase = (from: string, path: string) => {\n const resolvedPath = resolvePath({\n basepath: this.basepath,\n base: from,\n to: cleanPath(path),\n trailingSlash: this.options.trailingSlash,\n })\n return resolvedPath\n }\n\n get looseRoutesById() {\n return this.routesById as Record<string, AnyRoute>\n }\n\n matchRoutes = (\n pathname: string,\n locationSearch: AnySearchSchema,\n opts?: { preload?: boolean; throwOnError?: boolean },\n ): Array<AnyRouteMatch> => {\n let routeParams: Record<string, string> = {}\n\n const foundRoute = this.flatRoutes.find((route) => {\n const matchedParams = matchPathname(\n this.basepath,\n trimPathRight(pathname),\n {\n to: route.fullPath,\n caseSensitive:\n route.options.caseSensitive ?? this.options.caseSensitive,\n fuzzy: true,\n },\n )\n\n if (matchedParams) {\n routeParams = matchedParams\n return true\n }\n\n return false\n })\n\n let routeCursor: AnyRoute =\n foundRoute || (this.routesById as any)[rootRouteId]\n\n const matchedRoutes: Array<AnyRoute> = [routeCursor]\n\n let isGlobalNotFound = false\n\n // Check to see if the route needs a 404 entry\n if (\n // If we found a route, and it's not an index route and we have left over path\n foundRoute\n ? foundRoute.path !== '/' && routeParams['**']\n : // Or if we didn't find a route and we have left over path\n trimPathRight(pathname)\n ) {\n // If the user has defined an (old) 404 route, use it\n if (this.options.notFoundRoute) {\n matchedRoutes.push(this.options.notFoundRoute)\n } else {\n // If there is no routes found during path matching\n isGlobalNotFound = true\n }\n }\n\n while (routeCursor.parentRoute) {\n routeCursor = routeCursor.parentRoute\n matchedRoutes.unshift(routeCursor)\n }\n\n const globalNotFoundRouteId = (() => {\n if (!isGlobalNotFound) {\n return undefined\n }\n\n if (this.options.notFoundMode !== 'root') {\n for (let i = matchedRoutes.length - 1; i >= 0; i--) {\n const route = matchedRoutes[i]!\n if (route.children) {\n return route.id\n }\n }\n }\n\n return rootRouteId\n })()\n\n // Existing matches are matches that are already loaded along with\n // pending matches that are still loading\n\n const parseErrors = matchedRoutes.map((route) => {\n let parsedParamsError\n\n if (route.options.parseParams) {\n try {\n const parsedParams = route.options.parseParams(routeParams)\n // Add the parsed params to the accumulated params bag\n Object.assign(routeParams, parsedParams)\n } catch (err: any) {\n parsedParamsError = new PathParamError(err.message, {\n cause: err,\n })\n\n if (opts?.throwOnError) {\n throw parsedParamsError\n }\n\n return parsedParamsError\n }\n }\n\n return\n })\n\n const matches: Array<AnyRouteMatch> = []\n\n matchedRoutes.forEach((route, index) => {\n // Take each matched route and resolve + validate its search params\n // This has to happen serially because each route's search params\n // can depend on the parent route's search params\n // It must also happen before we create the match so that we can\n // pass the search params to the route's potential key function\n // which is used to uniquely identify the route match in state\n\n const parentMatch = matches[index - 1]\n\n const [preMatchSearch, searchError]: [Record<string, any>, any] = (() => {\n // Validate the search params and stabilize them\n const parentSearch = parentMatch?.search ?? locationSearch\n\n try {\n const validator =\n typeof route.options.validateSearch === 'object'\n ? route.options.validateSearch.parse\n : route.options.validateSearch\n\n const search = validator?.(parentSearch) ?? {}\n\n return [\n {\n ...parentSearch,\n ...search,\n },\n undefined,\n ]\n } catch (err: any) {\n const searchParamError = new SearchParamError(err.message, {\n cause: err,\n })\n\n if (opts?.throwOnError) {\n throw searchParamError\n }\n\n return [parentSearch, searchParamError]\n }\n })()\n\n // This is where we need to call route.options.loaderDeps() to get any additional\n // deps that the route's loader function might need to run. We need to do this\n // before we create the match so that we can pass the deps to the route's\n // potential key function which is used to uniquely identify the route match in state\n\n const loaderDeps =\n route.options.loaderDeps?.({\n search: preMatchSearch,\n }) ?? ''\n\n const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : ''\n\n const interpolatedPath = interpolatePath({\n path: route.fullPath,\n params: routeParams,\n })\n\n const matchId =\n interpolatePath({\n path: route.id,\n params: routeParams,\n leaveWildcards: true,\n }) + loaderDepsHash\n\n // Waste not, want not. If we already have a match for this route,\n // reuse it. This is important for layout routes, which might stick\n // around between navigation actions that only change leaf routes.\n const existingMatch = getRouteMatch(this.state, matchId)\n\n const cause = this.state.matches.find((d) => d.id === matchId)\n ? 'stay'\n : 'enter'\n\n let match: AnyRouteMatch\n\n if (existingMatch) {\n match = {\n ...existingMatch,\n cause,\n params: routeParams,\n }\n } else {\n const status =\n route.options.loader || route.options.beforeLoad\n ? 'pending'\n : 'success'\n\n const loadPromise = createControlledPromise<void>()\n\n // If it's already a success, resolve the load promise\n if (status === 'success') {\n loadPromise.resolve()\n }\n\n match = {\n id: matchId,\n routeId: route.id,\n params: routeParams,\n pathname: joinPaths([this.basepath, interpolatedPath]),\n updatedAt: Date.now(),\n search: {} as any,\n searchError: undefined,\n status: 'pending',\n isFetching: false,\n error: undefined,\n paramsError: parseErrors[index],\n loaderPromise: Promise.resolve(),\n loadPromise,\n routeContext: undefined!,\n context: undefined!,\n abortController: new AbortController(),\n fetchCount: 0,\n cause,\n loaderDeps,\n invalid: false,\n preload: false,\n links: route.options.links?.(),\n scripts: route.options.scripts?.(),\n staticData: route.options.staticData || {},\n }\n }\n\n // If it's already a success, update the meta and headers\n // These may get updated again if the match is refreshed\n // due to being stale\n if (match.status === 'success') {\n match.meta = route.options.meta?.({\n matches,\n params: match.params,\n loaderData: match.loaderData,\n })\n\n match.headers = route.options.headers?.({\n loaderData: match.loaderData,\n })\n }\n\n if (!opts?.preload) {\n // If we have a global not found, mark the right match as global not found\n match.globalNotFound = globalNotFoundRouteId === route.id\n }\n\n // Regardless of whether we're reusing an existing match or creating\n // a new one, we need to update the match's search params\n match.search = replaceEqualDeep(match.search, preMatchSearch)\n // And also update the searchError if there is one\n match.searchError = searchError\n\n matches.push(match)\n })\n\n return matches as any\n }\n\n cancelMatch = (id: string) => {\n getRouteMatch(this.state, id)?.abortController.abort()\n }\n\n cancelMatches = () => {\n this.state.pendingMatches?.forEach((match) => {\n this.cancelMatch(match.id)\n })\n }\n\n buildLocation: BuildLocationFn<TRouteTree> = (opts) => {\n const build = (\n dest: BuildNextOptions & {\n unmaskOnReload?: boolean\n } = {},\n matches?: Array<MakeRouteMatch<TRouteTree>>,\n ): ParsedLocation => {\n // if the router is loading the previous location is what\n // we should use because the old matches are still around\n // and the latest location has already been updated.\n // If the router is not loading we should always use the\n // latest location because resolvedLocation can lag behind\n // and the new matches could already render\n const currentLocation = this.state.isLoading\n ? this.state.resolvedLocation\n : this.latestLocation\n\n const location = dest._fromLocation ?? currentLocation\n\n let fromPath = location.pathname\n let fromSearch = dest.fromSearch || location.search\n\n const fromMatches = this.matchRoutes(location.pathname, fromSearch)\n\n const fromMatch =\n dest.from != null\n ? fromMatches.find((d) =>\n matchPathname(this.basepath, trimPathRight(d.pathname), {\n to: dest.from,\n caseSensitive: false,\n fuzzy: false,\n }),\n )\n : undefined\n\n fromPath = fromMatch?.pathname || fromPath\n\n invariant(\n dest.from == null || fromMatch != null,\n 'Could not find match for from: ' + dest.from,\n )\n\n fromSearch = last(fromMatches)?.search || this.latestLocation.search\n\n const stayingMatches = matches?.filter((d) =>\n fromMatches.find((e) => e.routeId === d.routeId),\n )\n\n const fromRouteByFromPathRouteId =\n this.routesById[\n stayingMatches?.find((d) => d.pathname === fromPath)?.routeId\n ]\n\n let pathname = dest.to\n ? this.resolvePathWithBase(fromPath, `${dest.to}`)\n : this.resolvePathWithBase(\n fromPath,\n fromRouteByFromPathRouteId?.to ?? fromPath,\n )\n\n const prevParams = { ...last(fromMatches)?.params }\n\n let nextParams =\n (dest.params ?? true) === true\n ? prevParams\n : { ...prevParams, ...functionalUpdate(dest.params, prevParams) }\n\n if (Object.keys(nextParams).length > 0) {\n matches\n ?.map((d) => this.looseRoutesById[d.routeId]!.options.stringifyParams)\n .filter(Boolean)\n .forEach((fn) => {\n nextParams = { ...nextParams!, ...fn!(nextParams) }\n })\n }\n\n // encode all path params so the generated href is valid and stable\n Object.keys(nextParams).forEach((key) => {\n if (['*', '_splat'].includes(key)) {\n // the splat/catch-all routes shouldn't have the '/' encoded out\n nextParams[key] = encodeURI(nextParams[key])\n } else {\n nextParams[key] = encodeURIComponent(nextParams[key])\n }\n })\n\n pathname = interpolatePath({\n path: pathname,\n params: nextParams ?? {},\n leaveWildcards: false,\n leaveParams: opts.leaveParams,\n })\n\n const preSearchFilters =\n stayingMatches\n ?.map(\n (match) =>\n this.looseRoutesById[match.routeId]!.options.preSearchFilters ??\n [],\n )\n .flat()\n .filter(Boolean) ?? []\n\n const postSearchFilters =\n stayingMatches\n ?.map(\n (match) =>\n this.looseRoutesById[match.routeId]!.options.postSearchFilters ??\n [],\n )\n .flat()\n .filter(Boolean) ?? []\n\n // Pre filters first\n const preFilteredSearch = preSearchFilters.length\n ? preSearchFilters.reduce((prev, next) => next(prev), fromSearch)\n : fromSearch\n\n // Then the link/navigate function\n const destSearch =\n dest.search === true\n ? preFilteredSearch // Preserve resolvedFrom true\n : dest.search\n ? functionalUpdate(dest.search, preFilteredSearch) // Updater\n : preSearchFilters.length\n ? preFilteredSearch // Preserve resolvedFrom filters\n : {}\n\n // Then post filters\n const postFilteredSearch = postSearchFilters.length\n ? postSearchFilters.reduce((prev, next) => next(prev), destSearch)\n : destSearch\n\n const search = replaceEqualDeep(fromSearch, postFilteredSearch)\n\n const searchStr = this.options.stringifySearch(search)\n\n const hash =\n dest.hash === true\n ? this.latestLocation.hash\n : dest.hash\n ? functionalUpdate(dest.hash, this.latestLocation.hash)\n : undefined\n\n const hashStr = hash ? `#${hash}` : ''\n\n let nextState =\n dest.state === true\n ? this.latestLocation.state\n : dest.state\n ? functionalUpdate(dest.state, this.latestLocation.state)\n : {}\n\n nextState = replaceEqualDeep(this.latestLocation.state, nextState)\n\n return {\n pathname,\n search,\n searchStr,\n state: nextState as any,\n hash: hash ?? '',\n href: `${pathname}${searchStr}${hashStr}`,\n unmaskOnReload: dest.unmaskOnReload,\n }\n }\n\n const buildWithMatches = (\n dest: BuildNextOptions = {},\n maskedDest?: BuildNextOptions,\n ) => {\n const next = build(dest)\n let maskedNext = maskedDest ? build(maskedDest) : undefined\n\n if (!maskedNext) {\n let params = {}\n\n const foundMask = this.options.routeMasks?.find((d) => {\n const match = matchPathname(this.basepath, next.pathname, {\n to: d.from,\n caseSensitive: false,\n fuzzy: false,\n })\n\n if (match) {\n params = match\n return true\n }\n\n return false\n })\n\n if (foundMask) {\n const { from, ...maskProps } = foundMask\n maskedDest = {\n ...pick(opts, ['from']),\n ...maskProps,\n params,\n }\n maskedNext = build(maskedDest)\n }\n }\n\n const nextMatches = this.matchRoutes(next.pathname, next.search)\n const maskedMatches = maskedNext\n ? this.matchRoutes(maskedNext.pathname, maskedNext.search)\n : undefined\n const maskedFinal = maskedNext\n ? build(maskedDest, maskedMatches)\n : undefined\n\n const final = build(dest, nextMatches)\n\n if (maskedFinal) {\n final.maskedLocation = maskedFinal\n }\n\n return final\n }\n\n if (opts.mask) {\n return buildWithMatches(opts, {\n ...pick(opts, ['from']),\n ...opts.mask,\n })\n }\n\n return buildWithMatches(opts)\n }\n\n commitLocation = async ({\n startTransition,\n viewTransition,\n ...next\n }: ParsedLocation & CommitLocationOptions) => {\n const isSameState = () => {\n // `state.key` is ignored but may still be provided when navigating,\n // temporarily add the previous key to the next state so it doesn't affect\n // the comparison\n\n next.state.key = this.latestLocation.state.key\n const isEqual = deepEqual(next.state, this.latestLocation.state)\n delete next.state.key\n return isEqual\n }\n\n const isSameUrl = this.latestLocation.href === next.href\n\n // Don't commit to history if nothing changed\n if (isSameUrl && isSameState()) {\n this.load()\n } else {\n // eslint-disable-next-line prefer-const\n let { maskedLocation, ...nextHistory } = next\n\n if (maskedLocation) {\n nextHistory = {\n ...maskedLocation,\n state: {\n ...maskedLocation.state,\n __tempKey: undefined,\n __tempLocation: {\n ...nextHistory,\n search: nextHistory.searchStr,\n state: {\n ...nextHistory.state,\n __tempKey: undefined!,\n __tempLocation: undefined!,\n key: undefined!,\n },\n },\n },\n }\n\n if (\n nextHistory.unmaskOnReload ??\n this.options.unmaskOnReload ??\n false\n ) {\n nextHistory.state.__tempKey = this.tempLocationKey\n }\n }\n\n this.shouldViewTransition = viewTransition\n\n this.history[next.replace ? 'replace' : 'push'](\n nextHistory.href,\n nextHistory.state,\n )\n }\n\n this.resetNextScroll = next.resetScroll ?? true\n\n return this.latestLoadPromise\n }\n\n buildAndCommitLocation = ({\n replace,\n resetScroll,\n startTransition,\n viewTransition,\n ...rest\n }: BuildNextOptions & CommitLocationOptions = {}) => {\n const location = this.buildLocation(rest as any)\n return this.commitLocation({\n ...location,\n startTransition,\n viewTransition,\n replace,\n resetScroll,\n })\n }\n\n navigate: NavigateFn = ({ from, to, __isRedirect, ...rest }) => {\n // If this link simply reloads the current route,\n // make sure it has a new key so it will trigger a data refresh\n\n // If this `to` is a valid external URL, return\n // null for LinkUtils\n const toString = String(to)\n // const fromString = from !== undefined ? String(from) : from\n let isExternal\n\n try {\n new URL(`${toString}`)\n isExternal = true\n } catch (e) {}\n\n invariant(\n !isExternal,\n 'Attempting to navigate to external url with this.navigate!',\n )\n\n return this.buildAndCommitLocation({\n ...rest,\n from,\n to,\n // to: toString,\n })\n }\n\n load = async (): Promise<void> => {\n this.latestLocation = this.parseLocation(this.latestLocation)\n\n if (this.state.location === this.latestLocation) {\n return\n }\n\n const promise = createControlledPromise<void>()\n this.latestLoadPromise = promise\n let redirect: ResolvedRedirect | undefined\n let notFound: NotFoundError | undefined\n\n this.startReactTransition(async () => {\n try {\n const next = this.latestLocation\n const prevLocation = this.state.resolvedLocation\n const pathDidChange = prevLocation.href !== next.href\n\n // Cancel any pending matches\n this.cancelMatches()\n\n let pendingMatches!: Array<AnyRouteMatch>\n\n this.__store.batch(() => {\n // this call breaks a route context of destination route after a redirect\n // we should be fine not eagerly calling this since we call it later\n // this.cleanCache()\n\n // Match the routes\n pendingMatches = this.matchRoutes(next.pathname, next.search)\n\n // Ingest the new matches\n this.__store.setState((s) => ({\n ...s,\n status: 'pending',\n isLoading: true,\n location: next,\n pendingMatches,\n // If a cached moved to pendingMatches, remove it from cachedMatches\n cachedMatches: s.cachedMatches.filter((d) => {\n return !pendingMatches.find((e) => e.id === d.id)\n }),\n }))\n })\n\n if (!this.state.redirect) {\n this.emit({\n type: 'onBeforeNavigate',\n fromLocation: prevLocation,\n toLocation: next,\n pathChanged: pathDidChange,\n })\n }\n\n this.emit({\n type: 'onBeforeLoad',\n fromLocation: prevLocation,\n toLocation: next,\n pathChanged: pathDidChange,\n })\n\n await this.loadMatches({\n matches: pendingMatches,\n location: next,\n checkLatest: () => this.checkLatest(promise),\n onReady: async () => {\n await this.startViewTransition(async () => {\n // this.viewTransitionPromise = createControlledPromise<true>()\n\n // Commit the pending matches. If a previous match was\n // removed, place it in the cachedMatches\n let exitingMatches!: Array<AnyRouteMatch>\n let enteringMatches!: Array<AnyRouteMatch>\n let stayingMatches!: Array<AnyRouteMatch>\n\n this.__store.batch(() => {\n this.__store.setState((s) => {\n const previousMatches = s.matches\n const newMatches = s.pendingMatches || s.matches\n\n exitingMatches = previousMatches.filter(\n (match) => !newMatches.find((d) => d.id === match.id),\n )\n enteringMatches = newMatches.filter(\n (match) => !previousMatches.find((d) => d.id === match.id),\n )\n stayingMatches = previousMatches.filter((match) =>\n newMatches.find((d) => d.id === match.id),\n )\n\n return {\n ...s,\n isLoading: false,\n matches: newMatches,\n pendingMatches: undefined,\n cachedMatches: [\n ...s.cachedMatches,\n ...exitingMatches.filter((d) => d.status !== 'error'),\n ],\n }\n })\n this.cleanCache()\n })\n\n //\n ;(\n [\n [exitingMatches, 'onLeave'],\n [enteringMatches, 'onEnter'],\n [stayingMatches, 'onStay'],\n ] as const\n ).forEach(([matches, hook]) => {\n matches.forEach((match) => {\n this.looseRoutesById[match.routeId]!.options[hook]?.(match)\n })\n })\n })\n },\n })\n } catch (err) {\n if (isResolvedRedirect(err)) {\n redirect = err\n if (!this.isServer) {\n this.navigate({ ...err, replace: true, __isRedirect: true })\n this.load()\n }\n } else if (isNotFound(err)) {\n notFound = err\n }\n\n this.__store.setState((s) => ({\n ...s,\n statusCode: redirect\n ? redirect.statusCode\n : notFound\n ? 404\n : s.matches.some((d) => d.status === 'error')\n ? 500\n : 200,\n redirect,\n }))\n }\n\n promise.resolve()\n })\n\n return this.latestLoadPromise\n }\n\n startViewTransition = async (fn: () => Promise<void>) => {\n // Determine if we should start a view transition from the navigation\n // or from the router default\n const shouldViewTransition =\n this.shouldViewTransition ?? this.options.defaultViewTransition\n\n // Reset the view transition flag\n delete this.shouldViewTransition\n // Attempt to start a view transition (or just apply the changes if we can't)\n ;(shouldViewTransition && typeof document !== 'undefined'\n ? document\n : undefined\n )\n // @ts-expect-error\n ?.startViewTransition?.(fn) || fn()\n }\n\n loadMatches = async ({\n checkLatest,\n location,\n matches,\n preload,\n onReady,\n }: {\n checkLatest: () => void\n location: ParsedLocation\n matches: Array<AnyRouteMatch>\n preload?: boolean\n onReady?: () => Promise<void>\n }): Promise<Array<MakeRouteMatch>> => {\n let firstBadMatchIndex: number | undefined\n let rendered = false\n\n const triggerOnReady = async () => {\n if (!rendered) {\n rendered = true\n await onReady?.()\n }\n }\n\n if (!this.isServer && !this.state.matches.length) {\n triggerOnReady()\n }\n\n const updateMatch = (\n id: string,\n updater: (match: AnyRouteMatch) => AnyRouteMatch,\n opts?: { remove?: boolean },\n ) => {\n let updated!: AnyRouteMatch\n const isPending = this.state.pendingMatches?.find((d) => d.id === id)\n const isMatched = this.state.matches.find((d) => d.id === id)\n\n const matchesKey = isPending\n ? 'pendingMatches'\n : isMatched\n ? 'matches'\n : 'cachedMatches'\n\n this.__store.setState((s) => ({\n ...s,\n [matchesKey]: opts?.remove\n ? s[matchesKey]?.filter((d) => d.id !== id)\n : s[matchesKey]?.map((d) =>\n d.id === id ? (updated = updater(d)) : d,\n ),\n }))\n\n return updated\n }\n\n const handleRedirectAndNotFound = (match: AnyRouteMatch, err: any) => {\n if (isResolvedRedirect(err)) throw err\n\n if (isRedirect(err) || isNotFound(err)) {\n // if (!rendered) {\n updateMatch(match.id, (prev) => ({\n ...prev,\n status: isRedirect(err)\n ? 'redirected'\n : isNotFound(err)\n ? 'notFound'\n : 'error',\n isFetching: false,\n error: err,\n }))\n // }\n\n if (!(err as any).routeId) {\n ;(err as any).routeId = match.routeId\n }\n\n if (isRedirect(err)) {\n rendered = true\n err = this.resolveRedirect(err)\n throw err\n } else if (isNotFound(err)) {\n this.handleNotFound(matches, err)\n throw err\n }\n }\n }\n\n try {\n await new Promise<void>((resolveAll, rejectAll) => {\n ;(async () => {\n try {\n // Check each match middleware to see if the route can be accessed\n // eslint-disable-next-line prefer-const\n for (let [index, match] of matches.entries()) {\n const parentMatch = matches[index - 1]\n const route = this.looseRoutesById[match.routeId]!\n const abortController = new AbortController()\n let loadPromise = match.loadPromise\n\n const pendingMs =\n route.options.pendingMs ?? this.options.defaultPendingMs\n\n const shouldPending = !!(\n onReady &&\n !this.isServer &&\n !preload &&\n (route.options.loader || route.options.beforeLoad) &&\n typeof pendingMs === 'number' &&\n pendingMs !== Infinity &&\n (route.options.pendingComponent ??\n this.options.defaultPendingComponent)\n )\n\n if (shouldPending) {\n // If we might show a pending component, we need to wait for the\n // pending promise to resolve before we start showing that state\n setTimeout(() => {\n try {\n checkLatest()\n // Update the match and prematurely resolve the loadMatches promise so that\n // the pending component can start rendering\n triggerOnReady()\n } catch {}\n }, pendingMs)\n }\n\n if (match.isFetching) {\n continue\n }\n\n const previousResolve = loadPromise.resolve\n // Create a new one\n loadPromise = createControlledPromise<void>(\n // Resolve the old when we we resolve the new one\n previousResolve,\n )\n\n // Otherwise, load the route\n matches[index] = match = updateMatch(match.id, (prev) => ({\n ...prev,\n isFetching: 'beforeLoad',\n loadPromise,\n }))\n\n const handleSerialError = (err: any, routerCode: string) => {\n // If the error is a promise, it means we're outdated and\n // should abort the current async operation\n if (err instanceof Promise) {\n throw err\n }\n\n err.routerCode = routerCode\n firstBadMatchIndex = firstBadMatchIndex ?? index\n handleRedirectAndNotFound(match, err)\n\n try {\n route.options.onError?.(err)\n } catch (errorHandlerErr) {\n err = errorHandlerErr\n handleRedirectAndNotFound(match, err)\n }\n\n matches[index] = match = updateMatch(match.id, () => ({\n ...match,\n error: err,\n status: 'error',\n updatedAt: Date.now(),\n abortController: new AbortController(),\n }))\n }\n\n if (match.paramsError) {\n handleSerialError(match.paramsError, 'PARSE_PARAMS')\n }\n\n if (match.searchError) {\n handleSerialError(match.searchError, 'VALIDATE_SEARCH')\n }\n\n try {\n const parentContext =\n parentMatch?.context ?? this.options.context ?? {}\n\n // Make sure the match has parent context set before going further\n matches[index] = match = updateMatch(match.id, () => ({\n ...match,\n routeContext: replaceEqualDeep(\n match.routeContext,\n parentContext,\n ),\n abortController,\n }))\n\n const beforeLoadContext =\n (await route.options.beforeLoad?.({\n search: match.search,\n abortController,\n params: match.params,\n preload: !!preload,\n context: parentContext,\n location,\n navigate: (opts: any) =>\n this.navigate({ ...opts, _fromLocation: location }),\n buildLocation: this.buildLocation,\n cause: preload ? 'preload' : match.cause,\n })) ?? ({} as any)\n\n checkLatest()\n\n if (\n isRedirect(beforeLoadContext) ||\n isNotFound(beforeLoadContext)\n ) {\n handleSerialError(beforeLoadContext, 'BEFORE_LOAD')\n }\n\n const context = {\n ...parentContext,\n ...beforeLoadContext,\n }\n\n matches[index] = match = {\n ...match,\n routeContext: replaceEqualDeep(\n match.routeContext,\n beforeLoadContext,\n ),\n context: replaceEqualDeep(match.context, context),\n abortController,\n }\n updateMatch(match.id, () => match)\n } catch (err) {\n handleSerialError(err, 'BEFORE_LOAD')\n break\n }\n }\n\n checkLatest()\n\n const validResolvedMatches = matches.slice(0, firstBadMatchIndex)\n const matchPromises: Array<Promise<any>> = []\n\n validResolvedMatches.forEach((match, index) => {\n const createValidateResolvedMatchPromise = async () => {\n const parentMatchPromise = matchPromises[index - 1]\n const route = this.looseRoutesById[match.routeId]!\n\n const loaderContext: LoaderFnContext = {\n params: match.params,\n deps: match.loaderDeps,\n preload: !!preload,\n parentMatchPromise,\n abortController: match.abortController,\n context: match.context,\n location,\n navigate: (opts) =>\n this.navigate({ ...opts, _fromLocation: location }),\n cause: preload ? 'preload' : match.cause,\n route,\n }\n\n const fetch = async () => {\n const existing = getRouteMatch(this.state, match.id)!\n let lazyPromise = Promise.resolve()\n let componentsPromise = Promise.resolve() as Promise<any>\n let loaderPromise = existing.loaderPromise\n\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 const potentialPendingMinPromise = async () => {\n const latestMatch = getRouteMatch(this.state, match.id)\n\n if (latestMatch?.minPendingPromise) {\n await latestMatch.minPendingPromise\n\n checkLatest()\n\n updateMatch(latestMatch.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }\n }\n\n try {\n if (match.isFetching === 'beforeLoad') {\n // If the user doesn't want the route to reload, just\n // resolve with the existing loader data\n\n // if (match.fetchCount && match.status === 'success') {\n // resolve()\n // }\n\n // Otherwise, load the route\n matches[index] = match = updateMatch(\n match.id,\n (prev) => ({\n ...prev,\n isFetching: 'loader',\n fetchCount: match.fetchCount + 1,\n }),\n )\n\n lazyPromise =\n route.lazyFn?.().then((lazyRoute) => {\n Object.assign(route.options, lazyRoute.options)\n }) || Promise.resolve()\n\n // If for some reason lazy resolves more lazy components...\n // We'll wait for that before pre attempt to preload any\n // components themselves.\n componentsPromise = lazyPromise.then(() =>\n Promise.all(\n componentTypes.map(async (type) => {\n const component = route.options[type]\n\n if ((component as any)?.preload) {\n await (component as any).preload()\n }\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 await lazyPromise\n\n checkLatest()\n\n // Kick off the loader!\n loaderPromise = route.options.loader?.(loaderContext)\n\n matches[index] = match = updateMatch(\n match.id,\n (prev) => ({\n ...prev,\n loaderPromise,\n }),\n )\n }\n\n const loaderData = await loaderPromise\n checkLatest()\n\n handleRedirectAndNotFound(match, loaderData)\n\n await potentialPendingMinPromise()\n checkLatest()\n\n const meta = route.options.meta?.({\n matches,\n params: match.params,\n loaderData,\n })\n\n const headers = route.options.headers?.({\n loaderData,\n })\n\n matches[index] = match = updateMatch(match.id, (prev) => ({\n ...prev,\n error: undefined,\n status: 'success',\n isFetching: false,\n updatedAt: Date.now(),\n loaderData,\n meta,\n headers,\n }))\n } catch (e) {\n checkLatest()\n let error = e\n\n await potentialPendingMinPromise()\n checkLatest()\n\n handleRedirectAndNotFound(match, e)\n\n try {\n route.options.onError?.(e)\n } catch (onErrorError) {\n error = onErrorError\n handleRedirectAndNotFound(match, onErrorError)\n }\n\n matches[index] = match = updateMatch(match.id, (prev) => ({\n ...prev,\n error,\n status: 'error',\n isFetching: false,\n }))\n }\n\n // Last but not least, wait for the the component\n // to be preloaded before we resolve the match\n await componentsPromise\n\n checkLatest()\n\n match.loadPromise.resolve()\n }\n\n // This is where all of the stale-while-revalidate magic happens\n const age = Date.now() - match.updatedAt\n\n const staleAge = preload\n ? route.options.preloadStaleTime ??\n this.options.defaultPreloadStaleTime ??\n 30_000 // 30 seconds for preloads by default\n : route.options.staleTime ??\n this.options.defaultStaleTime ??\n 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(loaderContext)\n : shouldReloadOption\n\n matches[index] = match = {\n ...match,\n preload:\n !!preload &&\n !this.state.matches.find((d) => d.id === match.id),\n }\n\n const fetchWithRedirectAndNotFound = async () => {\n try {\n await fetch()\n } catch (err) {\n checkLatest()\n handleRedirectAndNotFound(match, err)\n }\n }\n\n // If the route is successful and still fresh, just resolve\n if (\n match.status === 'success' &&\n (match.invalid || (shouldReload ?? age > staleAge))\n ) {\n ;(async () => {\n try {\n await fetchWithRedirectAndNotFound()\n } catch (err) {}\n })()\n return\n }\n\n if (match.status !== 'success') {\n await fetchWithRedirectAndNotFound()\n }\n\n return\n }\n\n matchPromises.push(createValidateResolvedMatchPromise())\n })\n\n await Promise.all(matchPromises)\n\n checkLatest()\n\n resolveAll()\n } catch (err) {\n rejectAll(err)\n }\n })()\n })\n await triggerOnReady()\n } catch (err) {\n if (isRedirect(err) || isNotFound(err)) {\n if (isNotFound(err) && !preload) {\n await triggerOnReady()\n }\n throw err\n }\n }\n\n return matches\n }\n\n invalidate = () => {\n const invalidate = (d: MakeRouteMatch<TRouteTree>) => ({\n ...d,\n invalid: true,\n ...(d.status === 'error' ? ({ status: 'pending' } as const) : {}),\n })\n\n this.__store.setState((s) => ({\n ...s,\n matches: s.matches.map(invalidate),\n cachedMatches: s.cachedMatches.map(invalidate),\n pendingMatches: s.pendingMatches?.map(invalidate),\n }))\n\n return this.load()\n }\n\n resolveRedirect = (err: AnyRedirect): ResolvedRedirect => {\n const redirect = err as ResolvedRedirect\n\n if (!redirect.href) {\n redirect.href = this.buildLocation(redirect as any).href\n }\n\n return redirect\n }\n\n cleanCache = () => {\n // This is where all of the garbage collection magic happens\n this.__store.setState((s) => {\n return {\n ...s,\n cachedMatches: s.cachedMatches.filter((d) => {\n const route = this.looseRoutesById[d.routeId]!\n\n if (!route.options.loader) {\n return false\n }\n\n // If the route was preloaded, use the preloadGcTime\n // otherwise, use the gcTime\n const gcTime =\n (d.preload\n ? route.options.preloadGcTime ?? this.options.defaultPreloadGcTime\n : route.options.gcTime ?? this.options.defaultGcTime) ??\n 5 * 60 * 1000\n\n return d.status !== 'error' && Date.now() - d.updatedAt < gcTime\n }),\n }\n })\n }\n\n preloadRoute = async <\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n >(\n opts: NavigateOptions<\n Router<TRouteTree, TTrailingSlashOption, TDehydrated, TSerializedError>,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n >,\n ): Promise<Array<AnyRouteMatch> | undefined> => {\n const next = this.buildLocation(opts as any)\n\n let matches = this.matchRoutes(next.pathname, next.search, {\n throwOnError: true,\n preload: true,\n })\n\n const loadedMatchIds = Object.fromEntries(\n [\n ...this.state.matches,\n ...(this.state.pendingMatches ?? []),\n ...this.state.cachedMatches,\n ].map((d) => [d.id, true]),\n )\n\n this.__store.batch(() => {\n matches.forEach((match) => {\n if (!loadedMatchIds[match.id]) {\n this.__store.setState((s) => ({\n ...s,\n cachedMatches: [...(s.cachedMatches as any), match],\n }))\n }\n })\n })\n\n // If the preload leaf match is the same as the current or pending leaf match,\n // do not preload as it could cause a mutation of the current route.\n // The user should specify proper loaderDeps (which are used to uniquely identify a route)\n // to trigger preloads for routes with the same pathname, but different deps\n\n const leafMatch = last(matches)\n const currentLeafMatch = last(this.state.matches)\n const pendingLeafMatch = last(this.state.pendingMatches ?? [])\n\n if (\n leafMatch &&\n (currentLeafMatch?.id === leafMatch.id ||\n pendingLeafMatch?.id === leafMatch.id)\n ) {\n return undefined\n }\n\n try {\n matches = await this.loadMatches({\n matches,\n location: next,\n preload: true,\n checkLatest: () => undefined,\n })\n\n return matches\n } catch (err) {\n if (isRedirect(err)) {\n return await this.preloadRoute({\n ...(err as any),\n _fromLocation: next,\n })\n }\n // Preload errors are not fatal, but we should still log them\n console.error(err)\n return undefined\n }\n }\n\n matchRoute = <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n location: ToOptions<\n Router<TRouteTree, TTrailingSlashOption, TDehydrated, TSerializedError>,\n TFrom,\n TTo\n >,\n opts?: MatchRouteOptions,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const matchLocation = {\n ...location,\n to: location.to\n ? this.resolvePathWithBase((location.from || '') as string, location.to)\n : undefined,\n params: location.params || {},\n leaveParams: true,\n }\n const next = this.buildLocation(matchLocation as any)\n\n if (opts?.pending && this.state.status !== 'pending') {\n return false\n }\n\n const baseLocation = opts?.pending\n ? this.latestLocation\n : this.state.resolvedLocation\n\n const match = matchPathname(this.basepath, baseLocation.pathname, {\n ...opts,\n to: next.pathname,\n }) as any\n\n if (!match) {\n return false\n }\n if (location.params) {\n if (!deepEqual(match, location.params, true)) {\n return false\n }\n }\n\n if (match && (opts?.includeSearch ?? true)) {\n return deepEqual(baseLocation.search, next.search, true) ? match : false\n }\n\n return match\n }\n\n // We use a token -> weak map to keep track of deferred promises\n // that are registered on the server and need to be resolved\n registeredDeferredsIds = new Map<string, {}>()\n registeredDeferreds = new WeakMap<{}, DeferredPromiseState<any>>()\n\n getDeferred = (uid: string) => {\n const token = this.registeredDeferredsIds.get(uid)\n\n if (!token) {\n return undefined\n }\n\n return this.registeredDeferreds.get(token)\n }\n\n dehydrate = (): DehydratedRouter => {\n const pickError =\n this.options.errorSerializer?.serialize ?? defaultSerializeError\n\n return {\n state: {\n dehydratedMatches: this.state.matches.map((d) => ({\n ...pick(d, ['id', 'status', 'updatedAt', 'loaderData']),\n // If an error occurs server-side during SSRing,\n // send a small subset of the error to the client\n error: d.error\n ? {\n data: pickError(d.error),\n __isServerError: true,\n }\n : undefined,\n })),\n },\n manifest: this.manifest,\n }\n }\n\n hydrate = async (__do_not_use_server_ctx?: string) => {\n let _ctx = __do_not_use_server_ctx\n // Client hydrates from window\n if (typeof document !== 'undefined') {\n _ctx = window.__TSR_DEHYDRATED__?.data\n }\n\n invariant(\n _ctx,\n 'Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Please file an issue!',\n )\n\n const ctx = this.options.transformer.parse(_ctx) as HydrationCtx\n this.dehydratedData = ctx.payload as any\n this.options.hydrate?.(ctx.payload as any)\n const dehydratedState = ctx.router.state\n\n const matches = this.matchRoutes(\n this.state.location.pathname,\n this.state.location.search,\n ).map((match, i, allMatches) => {\n const dehydratedMatch = dehydratedState.dehydratedMatches.find(\n (d) => d.id === match.id,\n )\n\n invariant(\n dehydratedMatch,\n `Could not find a client-side match for dehydrated match with id: ${match.id}!`,\n )\n\n const route = this.looseRoutesById[match.routeId]!\n\n const assets =\n dehydratedMatch.status === 'notFound' ||\n dehydratedMatch.status === 'redirected'\n ? {}\n : {\n meta: route.options.meta?.({\n matches: allMatches,\n params: match.params,\n loaderData: dehydratedMatch.loaderData,\n }),\n links: route.options.links?.(),\n scripts: route.options.scripts?.(),\n }\n\n return {\n ...match,\n ...dehydratedMatch,\n ...assets,\n }\n })\n\n this.__store.setState((s) => {\n return {\n ...s,\n matches: matches as any,\n }\n })\n\n this.manifest = ctx.router.manifest\n }\n\n handleNotFound = (matches: Array<AnyRouteMatch>, err: NotFoundError) => {\n const matchesByRouteId = Object.fromEntries(\n matches.map((match) => [match.routeId, match]),\n ) as Record<string, AnyRouteMatch>\n\n // Start at the route that errored or default to the root route\n let routeCursor =\n (err.global\n ? this.looseRoutesById[rootRouteId]\n : this.looseRoutesById[err.routeId]) ||\n this.looseRoutesById[rootRouteId]!\n\n // Go up the tree until we find a route with a notFoundComponent or we hit the root\n while (\n !routeCursor.options.notFoundComponent &&\n !this.options.defaultNotFoundComponent &&\n routeCursor.id !== rootRouteId\n ) {\n routeCursor = routeCursor.parentRoute\n\n invariant(\n routeCursor,\n 'Found invalid route tree while trying to find not-found handler.',\n )\n }\n\n const match = matchesByRouteId[routeCursor.id]\n\n invariant(match, 'Could not find match for route: ' + routeCursor.id)\n\n // Assign the error to the match\n Object.assign(match, {\n status: 'notFound',\n error: err,\n isFetching: false,\n } as AnyRouteMatch)\n }\n\n hasNotFoundMatch = () => {\n return this.__store.state.matches.some(\n (d) => d.status === 'notFound' || d.globalNotFound,\n )\n }\n\n // resolveMatchPromise = (matchId: string, key: string, value: any) => {\n // state.matches\n // .find((d) => d.id === matchId)\n // ?.__promisesByKey[key]?.resolve(value)\n // }\n}\n\n// A function that takes an import() argument which is a function and returns a new function that will\n// proxy arguments from the caller to the imported function, retaining all type\n// information along the way\nexport function lazyFn<\n T extends Record<string, (...args: Array<any>) => any>,\n TKey extends keyof T = 'default',\n>(fn: () => Promise<T>, key?: TKey) {\n return async (\n ...args: Parameters<T[TKey]>\n ): Promise<Awaited<ReturnType<T[TKey]>>> => {\n const imported = await fn()\n return imported[key || 'default'](...args)\n }\n}\n\nexport class SearchParamError extends Error {}\n\nexport class PathParamError extends Error {}\n\nexport function getInitialRouterState(\n location: ParsedLocation,\n): RouterState<any> {\n return {\n isLoading: false,\n isTransitioning: false,\n status: 'idle',\n resolvedLocation: { ...location },\n location,\n matches: [],\n pendingMatches: [],\n cachedMatches: [],\n statusCode: 200,\n }\n}\n\nexport function defaultSerializeError(err: unknown) {\n if (err instanceof Error) {\n const obj = {\n name: err.name,\n message: err.message,\n }\n\n if (process.env.NODE_ENV === 'development') {\n ;(obj as any).stack = err.stack\n }\n\n return obj\n }\n\n return {\n data: err,\n }\n}\n"],"names":["_a","_b","_c","match"],"mappings":";;;;;;;;;;AA+ZO,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAoCO,SAAS,aAMd,SAMA;AACO,SAAA,IAAI,OAKT,OAAO;AACX;AAEO,MAAM,OAKX;AAAA;AAAA;AAAA;AAAA,EAwCA,YACE,SAMA;AA7CF,SAAA,kBAAsC,GAAG,KAAK;AAAA,MAC5C,KAAK,WAAW;AAAA,IACjB,CAAA;AACiB,SAAA,kBAAA;AACe,SAAA,uBAAA;AACjC,SAAA,oBAAmC,QAAQ;AAC3C,SAAA,kCAAkB;AAwDlB,SAAA,WAAW,OAAO,aAAa;AAKkB,SAAA,uBAAA,CAAC,OAAO,GAAG;AAE5D,SAAA,SAAS,CACP,eAMG;AACH,UAAI,WAAW,eAAe;AACpB,gBAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAEJ;AAEA,YAAM,kBAAkB,KAAK;AAC7B,WAAK,UAAU;AAAA,QACb,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MAAA;AAIH,UAAA,CAAC,KAAK,YACL,WAAW,YAAY,WAAW,aAAa,gBAAgB,UAChE;AAEE,YAAA,WAAW,aAAa,UACxB,WAAW,aAAa,MACxB,WAAW,aAAa,KACxB;AACA,eAAK,WAAW;AAAA,QAAA,OACX;AACL,eAAK,WAAW,IAAI,SAAS,WAAW,QAAQ,CAAC;AAAA,QACnD;AAAA,MACF;AAEA;AAAA;AAAA,QAEE,CAAC,KAAK,WACL,KAAK,QAAQ,WAAW,KAAK,QAAQ,YAAY,KAAK;AAAA,QACvD;AACK,aAAA,UACH,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,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { createBrowserHistory, createMemoryHistory } from '@tanstack/history'\nimport { Store } from '@tanstack/react-store'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { rootRouteId } from './root'\nimport { defaultParseSearch, defaultStringifySearch } from './searchParams'\nimport {\n createControlledPromise,\n deepEqual,\n functionalUpdate,\n last,\n pick,\n replaceEqualDeep,\n} from './utils'\nimport { getRouteMatch } from './RouterProvider'\nimport {\n cleanPath,\n interpolatePath,\n joinPaths,\n matchPathname,\n parsePathname,\n resolvePath,\n trimPath,\n trimPathLeft,\n trimPathRight,\n} from './path'\nimport { isRedirect, isResolvedRedirect } from './redirects'\nimport { isNotFound } from './not-found'\nimport type { Manifest } from './manifest'\nimport type * as React from 'react'\nimport type {\n HistoryLocation,\n HistoryState,\n RouterHistory,\n} from '@tanstack/history'\n\n//\n\nimport type {\n AnyContext,\n AnyRoute,\n AnySearchSchema,\n ErrorRouteComponent,\n LoaderFnContext,\n NotFoundRouteComponent,\n RouteMask,\n} from './route'\nimport type {\n FullSearchSchema,\n RouteById,\n RoutePaths,\n RoutesById,\n RoutesByPath,\n} from './routeInfo'\nimport type {\n ControlledPromise,\n NonNullableUpdater,\n PickAsRequired,\n Timeout,\n Updater,\n} from './utils'\nimport type { RouteComponent } from './route'\nimport type {\n AnyRouteMatch,\n MakeRouteMatch,\n MatchRouteOptions,\n RouteMatch,\n} from './Matches'\nimport type { ParsedLocation } from './location'\nimport type { SearchParser, SearchSerializer } from './searchParams'\nimport type {\n BuildLocationFn,\n CommitLocationOptions,\n InjectedHtmlEntry,\n NavigateFn,\n} from './RouterProvider'\n\nimport type { AnyRedirect, ResolvedRedirect } from './redirects'\n\nimport type { NotFoundError } from './not-found'\nimport type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'\nimport type { NoInfer } from '@tanstack/react-store'\nimport type { DeferredPromiseState } from './defer'\nimport type { ErrorInfo } from 'react'\n\n//\n\ndeclare global {\n interface Window {\n __TSR_DEHYDRATED__?: { data: string }\n __TSR_ROUTER_CONTEXT__?: React.Context<Router<any, any>>\n }\n}\n\nexport interface Register {\n // router: Router\n}\n\nexport type AnyRouter = Router<any, any, any, any>\n\nexport type RegisteredRouter = Register extends {\n router: infer TRouter extends AnyRouter\n}\n ? TRouter\n : AnyRouter\n\nexport type HydrationCtx = {\n router: DehydratedRouter\n payload: Record<string, any>\n}\n\nexport type RouterContextOptions<TRouteTree extends AnyRoute> =\n AnyContext extends TRouteTree['types']['routerContext']\n ? {\n context?: TRouteTree['types']['routerContext']\n }\n : {\n context: TRouteTree['types']['routerContext']\n }\n\nexport type TrailingSlashOption = 'always' | 'never' | 'preserve'\n\nexport interface RouterOptions<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDehydrated extends Record<string, any> = Record<string, any>,\n TSerializedError extends Record<string, any> = Record<string, any>,\n> {\n /**\n * The history object that will be used to manage the browser history.\n * If not provided, a new createBrowserHistory instance will be created and used.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)\n */\n history?: RouterHistory\n /**\n * A function that will be used to stringify search params when generating links.\n * Defaults to `defaultStringifySearch`.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)\n */\n stringifySearch?: SearchSerializer\n /**\n * A function that will be used to parse search params when parsing the current location.\n * Defaults to `defaultParseSearch`.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)\n */\n parseSearch?: SearchParser\n /**\n * Defaults to `false`\n * If `false`, routes will not be preloaded by default in any way.\n * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n */\n defaultPreload?: false | 'intent'\n /**\n * Defaults to 50\n * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)\n */\n defaultPreloadDelay?: number\n /**\n * Defaults to `Outlet`\n * The default `component` a route should use if no component is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)\n */\n defaultComponent?: RouteComponent\n /**\n * Defaults to `ErrorComponent`\n * The default `errorComponent` a route should use if no error component is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)\n */\n defaultErrorComponent?: ErrorRouteComponent\n /**\n * The default `pendingComponent` a route should use if no pending component is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)\n */\n defaultPendingComponent?: RouteComponent\n /**\n * Defaults to `1000`\n * The default `pendingMs` a route should use if no pendingMs is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)\n */\n defaultPendingMs?: number\n /**\n * Defaults to `500`\n * The default `pendingMinMs` a route should use if no pendingMinMs is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)\n */\n defaultPendingMinMs?: number\n /**\n * Defaults to `0`\n * The default `staleTime` a route should use if no staleTime is\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)\n */\n defaultStaleTime?: number\n /**\n * Defaults to `30_000` ms (30 seconds)\n * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n */\n defaultPreloadStaleTime?: number\n /**\n * Defaults to `routerOptions.defaultGcTime`, which defaults to 30 minutes.\n * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n */\n defaultPreloadGcTime?: number\n /**\n * The default `onCatch` handler for errors caught by the Router ErrorBoundary\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)\n */\n defaultOnCatch?: (error: Error, errorInfo: ErrorInfo) => void\n defaultViewTransition?: boolean\n /**\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)\n */\n notFoundMode?: 'root' | 'fuzzy'\n /**\n * Defaults to 30 minutes.\n * The default `gcTime` a route should use if no\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)\n */\n defaultGcTime?: number\n /**\n * Defaults to `false`\n * If `true`, all routes will be matched as case-sensitive.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-trees#case-sensitivity)\n */\n caseSensitive?: boolean\n /**\n * Required\n * The route tree that will be used to configure the router instance.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-trees)\n */\n routeTree?: TRouteTree\n /**\n * Defaults to `/`\n * The basepath for then entire router. This is useful for mounting a router instance at a subpath.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)\n */\n basepath?: string\n /**\n * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).\n * The root context that will be provided to all routes in the route tree.\n * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)\n */\n context?: TRouteTree['types']['routerContext']\n /**\n * A function that will be called when the router is dehydrated.\n * The return value of this function will be serialized and stored in the router's dehydrated state.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)\n */\n dehydrate?: () => TDehydrated\n /**\n * A function that will be called when the router is hydrated.\n * The return value of this function will be serialized and stored in the router's dehydrated state.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)\n */\n hydrate?: (dehydrated: TDehydrated) => void\n /**\n * An array of route masks that will be used to mask routes in the route tree.\n * Route masking is when you display a route at a different path than the one it is configured to match, like a modal popup that when shared will unmask to the modal's content instead of the modal's context.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)\n */\n routeMasks?: Array<RouteMask<TRouteTree>>\n /**\n * Defaults to `false`\n * If `true`, route masks will, by default, be removed when the page is reloaded.\n * This can be overridden on a per-mask basis by setting the `unmaskOnReload` option on the mask, or on a per-navigation basis by setting the `unmaskOnReload` option in the `Navigate` options.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)\n */\n unmaskOnReload?: boolean\n /**\n * A component that will be used to wrap the entire router.\n * This is useful for providing a context to the entire router.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)\n */\n Wrap?: (props: { children: any }) => React.JSX.Element\n /**\n * A component that will be used to wrap the inner contents of the router.\n * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)\n */\n InnerWrap?: (props: { children: any }) => React.JSX.Element\n /**\n * @deprecated\n * Use `notFoundComponent` instead.\n * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)\n */\n notFoundRoute?: AnyRoute\n /**\n * Defaults to `NotFound`\n * The default `notFoundComponent` a route should use if no notFound component is provided.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)\n */\n defaultNotFoundComponent?: NotFoundRouteComponent\n /**\n * The transformer that will be used when sending data between the server and the client during SSR.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#transformer-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/ssr#data-transformers)\n */\n transformer?: RouterTransformer\n /**\n * The serializer object that will be used to determine how errors are serialized and deserialized between the server and the client.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#errorserializer-property)\n */\n errorSerializer?: RouterErrorSerializer<TSerializedError>\n /**\n * Defaults to `never`\n * Configures how trailing slashes are treated.\n * `'always'` will add a trailing slash if not present, `'never'` will remove the trailing slash if present and `'preserve'` will not modify the trailing slash.\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)\n */\n trailingSlash?: TTrailingSlashOption\n}\n\nexport interface RouterTransformer {\n stringify: (obj: unknown) => string\n parse: (str: string) => unknown\n}\nexport interface RouterErrorSerializer<TSerializedError> {\n serialize: (err: unknown) => TSerializedError\n deserialize: (err: TSerializedError) => unknown\n}\n\nexport interface RouterState<\n TRouteTree extends AnyRoute = AnyRoute,\n TRouteMatch = MakeRouteMatch<TRouteTree>,\n> {\n status: 'pending' | 'idle'\n isLoading: boolean\n isTransitioning: boolean\n matches: Array<TRouteMatch>\n pendingMatches?: Array<TRouteMatch>\n cachedMatches: Array<TRouteMatch>\n location: ParsedLocation<FullSearchSchema<TRouteTree>>\n resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>\n statusCode: number\n redirect?: ResolvedRedirect\n}\n\nexport type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void\n\nexport interface BuildNextOptions {\n to?: string | number | null\n params?: true | Updater<unknown>\n search?: true | Updater<unknown>\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<HistoryState>\n mask?: {\n to?: string | number | null\n params?: true | Updater<unknown>\n search?: true | Updater<unknown>\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<HistoryState>\n unmaskOnReload?: boolean\n }\n from?: string\n fromSearch?: unknown\n _fromLocation?: ParsedLocation\n}\n\nexport interface DehydratedRouterState {\n dehydratedMatches: Array<DehydratedRouteMatch>\n}\n\nexport type DehydratedRouteMatch = Pick<\n MakeRouteMatch,\n 'id' | 'status' | 'updatedAt' | 'loaderData'\n>\n\nexport interface DehydratedRouter {\n state: DehydratedRouterState\n manifest?: Manifest\n}\n\nexport type RouterConstructorOptions<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDehydrated extends Record<string, any>,\n TSerializedError extends Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n 'context'\n> &\n RouterContextOptions<TRouteTree>\n\nexport const componentTypes = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n 'notFoundComponent',\n] as const\n\nexport type RouterEvents = {\n onBeforeNavigate: {\n type: 'onBeforeNavigate'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onBeforeLoad: {\n type: 'onBeforeLoad'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onLoad: {\n type: 'onLoad'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onResolved: {\n type: 'onResolved'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n}\n\nexport type RouterEvent = RouterEvents[keyof RouterEvents]\n\nexport type RouterListener<TRouterEvent extends RouterEvent> = {\n eventType: TRouterEvent['type']\n fn: ListenerFn<TRouterEvent>\n}\n\nexport function createRouter<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDehydrated extends Record<string, any> = Record<string, any>,\n TSerializedError extends Record<string, any> = Record<string, any>,\n>(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n) {\n return new Router<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >(options)\n}\n\nexport class Router<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption,\n in out TDehydrated extends Record<string, any> = Record<string, any>,\n in out TSerializedError extends Record<string, any> = Record<string, any>,\n> {\n // Option-independent properties\n tempLocationKey: string | undefined = `${Math.round(\n Math.random() * 10000000,\n )}`\n resetNextScroll = true\n shouldViewTransition?: boolean = undefined\n latestLoadPromise: Promise<void> = Promise.resolve()\n subscribers = new Set<RouterListener<RouterEvent>>()\n dehydratedData?: TDehydrated\n viewTransitionPromise?: ControlledPromise<true>\n manifest?: Manifest\n\n // Must build in constructor\n __store!: Store<RouterState<TRouteTree>>\n options!: PickAsRequired<\n Omit<\n RouterOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n 'transformer'\n > & {\n transformer: RouterTransformer\n },\n 'stringifySearch' | 'parseSearch' | 'context'\n >\n history!: RouterHistory\n latestLocation!: ParsedLocation<FullSearchSchema<TRouteTree>>\n basepath!: string\n routeTree!: TRouteTree\n routesById!: RoutesById<TRouteTree>\n routesByPath!: RoutesByPath<TRouteTree>\n flatRoutes!: Array<AnyRoute>\n\n /**\n * @deprecated Use the `createRouter` function instead\n */\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n ) {\n this.update({\n defaultPreloadDelay: 50,\n defaultPendingMs: 1000,\n defaultPendingMinMs: 500,\n context: undefined!,\n ...options,\n stringifySearch: options.stringifySearch ?? defaultStringifySearch,\n parseSearch: options.parseSearch ?? defaultParseSearch,\n transformer: options.transformer ?? JSON,\n })\n\n if (typeof document !== 'undefined') {\n ;(window as any).__TSR__ROUTER__ = this\n }\n }\n\n isServer = typeof document === 'undefined'\n\n // These are default implementations that can optionally be overridden\n // by the router provider once rendered. We provide these so that the\n // router can be used in a non-react environment if necessary\n startReactTransition: (fn: () => void) => void = (fn) => fn()\n\n update = (\n newOptions: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDehydrated,\n TSerializedError\n >,\n ) => {\n if (newOptions.notFoundRoute) {\n console.warn(\n 'The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.',\n )\n }\n\n const previousOptions = this.options\n this.options = {\n ...this.options,\n ...newOptions,\n }\n\n if (\n !this.basepath ||\n (newOptions.basepath && newOptions.basepath !== previousOptions.basepath)\n ) {\n if (\n newOptions.basepath === undefined ||\n newOptions.basepath === '' ||\n newOptions.basepath === '/'\n ) {\n this.basepath = '/'\n } else {\n this.basepath = `/${trimPath(newOptions.basepath)}`\n }\n }\n\n if (\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n !this.history ||\n (this.options.history && this.options.history !== this.history)\n ) {\n this.history =\n this.options.history ??\n (typeof document !== 'undefined'\n ? createBrowserHistory()\n : createMemoryHistory({\n initialEntries: [this.options.basepath || '/'],\n }))\n this.latestLocation = this.parseLocation()\n }\n\n if (this.options.routeTree !== this.routeTree) {\n this.routeTree = this.options.routeTree as TRouteTree\n this.buildRouteTree()\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!this.__store) {\n this.__store = new Store(getInitialRouterState(this.latestLocation), {\n onUpdate: () => {\n this.__store.state = {\n ...this.state,\n cachedMatches: this.state.cachedMatches.filter(\n (d) => !['redirected'].includes(d.status),\n ),\n }\n },\n })\n }\n }\n\n get state() {\n return this.__store.state\n }\n\n buildRouteTree = () => {\n this.routesById = {} as RoutesById<TRouteTree>\n this.routesByPath = {} as RoutesByPath<TRouteTree>\n\n const notFoundRoute = this.options.notFoundRoute\n if (notFoundRoute) {\n notFoundRoute.init({ originalIndex: 99999999999 })\n ;(this.routesById as any)[notFoundRoute.id] = notFoundRoute\n }\n\n const recurseRoutes = (childRoutes: Array<AnyRoute>) => {\n childRoutes.forEach((childRoute, i) => {\n childRoute.init({ originalIndex: i })\n\n const existingRoute = (this.routesById as any)[childRoute.id]\n\n invariant(\n !existingRoute,\n `Duplicate routes found with id: ${String(childRoute.id)}`,\n )\n ;(this.routesById as any)[childRoute.id] = childRoute\n\n if (!childRoute.isRoot && childRoute.path) {\n const trimmedFullPath = trimPathRight(childRoute.fullPath)\n if (\n !(this.routesByPath as any)[trimmedFullPath] ||\n childRoute.fullPath.endsWith('/')\n ) {\n ;(this.routesByPath as any)[trimmedFullPath] = childRoute\n }\n }\n\n const children = childRoute.children\n\n if (children?.length) {\n recurseRoutes(children)\n }\n })\n }\n\n recurseRoutes([this.routeTree])\n\n const scoredRoutes: Array<{\n child: AnyRoute\n trimmed: string\n parsed: ReturnType<typeof parsePathname>\n index: number\n scores: Array<number>\n }> = []\n\n const routes: Array<AnyRoute> = Object.values(this.routesById)\n\n routes.forEach((d, i) => {\n if (d.isRoot || !d.path) {\n return\n }\n\n const trimmed = trimPathLeft(d.fullPath)\n const parsed = parsePathname(trimmed)\n\n while (parsed.length > 1 && parsed[0]?.value === '/') {\n parsed.shift()\n }\n\n const scores = parsed.map((segment) => {\n if (segment.value === '/') {\n return 0.75\n }\n\n if (segment.type === 'param') {\n return 0.5\n }\n\n if (segment.type === 'wildcard') {\n return 0.25\n }\n\n return 1\n })\n\n scoredRoutes.push({ child: d, trimmed, parsed, index: i, scores })\n })\n\n this.flatRoutes = scoredRoutes\n .sort((a, b) => {\n const minLength = Math.min(a.scores.length, b.scores.length)\n\n // Sort by min available score\n for (let i = 0; i < minLength; i++) {\n if (a.scores[i] !== b.scores[i]) {\n return b.scores[i]! - a.scores[i]!\n }\n }\n\n // Sort by length of score\n if (a.scores.length !== b.scores.length) {\n return b.scores.length - a.scores.length\n }\n\n // Sort by min available parsed value\n for (let i = 0; i < minLength; i++) {\n if (a.parsed[i]!.value !== b.parsed[i]!.value) {\n return a.parsed[i]!.value > b.parsed[i]!.value ? 1 : -1\n }\n }\n\n // Sort by original index\n return a.index - b.index\n })\n .map((d, i) => {\n d.child.rank = i\n return d.child\n })\n }\n\n subscribe = <TType extends keyof RouterEvents>(\n eventType: TType,\n fn: ListenerFn<RouterEvents[TType]>,\n ) => {\n const listener: RouterListener<any> = {\n eventType,\n fn,\n }\n\n this.subscribers.add(listener)\n\n return () => {\n this.subscribers.delete(listener)\n }\n }\n\n emit = (routerEvent: RouterEvent) => {\n this.subscribers.forEach((listener) => {\n if (listener.eventType === routerEvent.type) {\n listener.fn(routerEvent)\n }\n })\n }\n\n checkLatest = (promise: Promise<void>): void => {\n if (this.latestLoadPromise !== promise) {\n throw this.latestLoadPromise\n }\n }\n\n parseLocation = (\n previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>,\n ): ParsedLocation<FullSearchSchema<TRouteTree>> => {\n const parse = ({\n pathname,\n search,\n hash,\n state,\n }: HistoryLocation): ParsedLocation<FullSearchSchema<TRouteTree>> => {\n const parsedSearch = this.options.parseSearch(search)\n const searchStr = this.options.stringifySearch(parsedSearch)\n\n return {\n pathname: pathname,\n searchStr,\n search: replaceEqualDeep(previousLocation?.search, parsedSearch) as any,\n hash: hash.split('#').reverse()[0] ?? '',\n href: `${pathname}${searchStr}${hash}`,\n state: replaceEqualDeep(previousLocation?.state, state),\n }\n }\n\n const location = parse(this.history.location)\n\n const { __tempLocation, __tempKey } = location.state\n\n if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {\n // Sync up the location keys\n const parsedTempLocation = parse(__tempLocation) as any\n parsedTempLocation.state.key = location.state.key\n\n delete parsedTempLocation.state.__tempLocation\n\n return {\n ...parsedTempLocation,\n maskedLocation: location,\n }\n }\n\n return location\n }\n\n resolvePathWithBase = (from: string, path: string) => {\n const resolvedPath = resolvePath({\n basepath: this.basepath,\n base: from,\n to: cleanPath(path),\n trailingSlash: this.options.trailingSlash,\n })\n return resolvedPath\n }\n\n get looseRoutesById() {\n return this.routesById as Record<string, AnyRoute>\n }\n\n matchRoutes = (\n pathname: string,\n locationSearch: AnySearchSchema,\n opts?: { preload?: boolean; throwOnError?: boolean },\n ): Array<AnyRouteMatch> => {\n let routeParams: Record<string, string> = {}\n\n const foundRoute = this.flatRoutes.find((route) => {\n const matchedParams = matchPathname(\n this.basepath,\n trimPathRight(pathname),\n {\n to: route.fullPath,\n caseSensitive:\n route.options.caseSensitive ?? this.options.caseSensitive,\n fuzzy: true,\n },\n )\n\n if (matchedParams) {\n routeParams = matchedParams\n return true\n }\n\n return false\n })\n\n let routeCursor: AnyRoute =\n foundRoute || (this.routesById as any)[rootRouteId]\n\n const matchedRoutes: Array<AnyRoute> = [routeCursor]\n\n let isGlobalNotFound = false\n\n // Check to see if the route needs a 404 entry\n if (\n // If we found a route, and it's not an index route and we have left over path\n foundRoute\n ? foundRoute.path !== '/' && routeParams['**']\n : // Or if we didn't find a route and we have left over path\n trimPathRight(pathname)\n ) {\n // If the user has defined an (old) 404 route, use it\n if (this.options.notFoundRoute) {\n matchedRoutes.push(this.options.notFoundRoute)\n } else {\n // If there is no routes found during path matching\n isGlobalNotFound = true\n }\n }\n\n while (routeCursor.parentRoute) {\n routeCursor = routeCursor.parentRoute\n matchedRoutes.unshift(routeCursor)\n }\n\n const globalNotFoundRouteId = (() => {\n if (!isGlobalNotFound) {\n return undefined\n }\n\n if (this.options.notFoundMode !== 'root') {\n for (let i = matchedRoutes.length - 1; i >= 0; i--) {\n const route = matchedRoutes[i]!\n if (route.children) {\n return route.id\n }\n }\n }\n\n return rootRouteId\n })()\n\n // Existing matches are matches that are already loaded along with\n // pending matches that are still loading\n\n const parseErrors = matchedRoutes.map((route) => {\n let parsedParamsError\n\n if (route.options.parseParams) {\n try {\n const parsedParams = route.options.parseParams(routeParams)\n // Add the parsed params to the accumulated params bag\n Object.assign(routeParams, parsedParams)\n } catch (err: any) {\n parsedParamsError = new PathParamError(err.message, {\n cause: err,\n })\n\n if (opts?.throwOnError) {\n throw parsedParamsError\n }\n\n return parsedParamsError\n }\n }\n\n return\n })\n\n const matches: Array<AnyRouteMatch> = []\n\n matchedRoutes.forEach((route, index) => {\n // Take each matched route and resolve + validate its search params\n // This has to happen serially because each route's search params\n // can depend on the parent route's search params\n // It must also happen before we create the match so that we can\n // pass the search params to the route's potential key function\n // which is used to uniquely identify the route match in state\n\n const parentMatch = matches[index - 1]\n\n const [preMatchSearch, searchError]: [Record<string, any>, any] = (() => {\n // Validate the search params and stabilize them\n const parentSearch = parentMatch?.search ?? locationSearch\n\n try {\n const validator =\n typeof route.options.validateSearch === 'object'\n ? route.options.validateSearch.parse\n : route.options.validateSearch\n\n const search = validator?.(parentSearch) ?? {}\n\n return [\n {\n ...parentSearch,\n ...search,\n },\n undefined,\n ]\n } catch (err: any) {\n const searchParamError = new SearchParamError(err.message, {\n cause: err,\n })\n\n if (opts?.throwOnError) {\n throw searchParamError\n }\n\n return [parentSearch, searchParamError]\n }\n })()\n\n // This is where we need to call route.options.loaderDeps() to get any additional\n // deps that the route's loader function might need to run. We need to do this\n // before we create the match so that we can pass the deps to the route's\n // potential key function which is used to uniquely identify the route match in state\n\n const loaderDeps =\n route.options.loaderDeps?.({\n search: preMatchSearch,\n }) ?? ''\n\n const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : ''\n\n const interpolatedPath = interpolatePath({\n path: route.fullPath,\n params: routeParams,\n })\n\n const matchId =\n interpolatePath({\n path: route.id,\n params: routeParams,\n leaveWildcards: true,\n }) + loaderDepsHash\n\n // Waste not, want not. If we already have a match for this route,\n // reuse it. This is important for layout routes, which might stick\n // around between navigation actions that only change leaf routes.\n const existingMatch = getRouteMatch(this.state, matchId)\n\n const cause = this.state.matches.find((d) => d.id === matchId)\n ? 'stay'\n : 'enter'\n\n let match: AnyRouteMatch\n\n if (existingMatch) {\n match = {\n ...existingMatch,\n cause,\n params: routeParams,\n }\n } else {\n const status =\n route.options.loader || route.options.beforeLoad\n ? 'pending'\n : 'success'\n\n const loadPromise = createControlledPromise<void>()\n\n // If it's already a success, resolve the load promise\n if (status === 'success') {\n loadPromise.resolve()\n }\n\n match = {\n id: matchId,\n routeId: route.id,\n params: routeParams,\n pathname: joinPaths([this.basepath, interpolatedPath]),\n updatedAt: Date.now(),\n search: {} as any,\n searchError: undefined,\n status: 'pending',\n isFetching: false,\n error: undefined,\n paramsError: parseErrors[index],\n loaderPromise: Promise.resolve(),\n loadPromise,\n routeContext: undefined!,\n context: undefined!,\n abortController: new AbortController(),\n fetchCount: 0,\n cause,\n loaderDeps,\n invalid: false,\n preload: false,\n links: route.options.links?.(),\n scripts: route.options.scripts?.(),\n staticData: route.options.staticData || {},\n }\n }\n\n // If it's already a success, update the meta and headers\n // These may get updated again if the match is refreshed\n // due to being stale\n if (match.status === 'success') {\n match.meta = route.options.meta?.({\n matches,\n params: match.params,\n loaderData: match.loaderData,\n })\n\n match.headers = route.options.headers?.({\n loaderData: match.loaderData,\n })\n }\n\n if (!opts?.preload) {\n // If we have a global not found, mark the right match as global not found\n match.globalNotFound = globalNotFoundRouteId === route.id\n }\n\n // Regardless of whether we're reusing an existing match or creating\n // a new one, we need to update the match's search params\n match.search = replaceEqualDeep(match.search, preMatchSearch)\n // And also update the searchError if there is one\n match.searchError = searchError\n\n matches.push(match)\n })\n\n return matches as any\n }\n\n cancelMatch = (id: string) => {\n getRouteMatch(this.state, id)?.abortController.abort()\n }\n\n cancelMatches = () => {\n this.state.pendingMatches?.forEach((match) => {\n this.cancelMatch(match.id)\n })\n }\n\n buildLocation: BuildLocationFn<TRouteTree> = (opts) => {\n const build = (\n dest: BuildNextOptions & {\n unmaskOnReload?: boolean\n } = {},\n matches?: Array<MakeRouteMatch<TRouteTree>>,\n ): ParsedLocation => {\n // if the router is loading the previous location is what\n // we should use because the old matches are still around\n // and the latest location has already been updated.\n // If the router is not loading we should always use the\n // latest location because resolvedLocation can lag behind\n // and the new matches could already render\n const currentLocation = this.state.isLoading\n ? this.state.resolvedLocation\n : this.latestLocation\n\n const location = dest._fromLocation ?? currentLocation\n\n let fromPath = location.pathname\n let fromSearch = dest.fromSearch || location.search\n\n const fromMatches = this.matchRoutes(location.pathname, fromSearch)\n\n const fromMatch =\n dest.from != null\n ? fromMatches.find((d) =>\n matchPathname(this.basepath, trimPathRight(d.pathname), {\n to: dest.from,\n caseSensitive: false,\n fuzzy: false,\n }),\n )\n : undefined\n\n fromPath = fromMatch?.pathname || fromPath\n\n invariant(\n dest.from == null || fromMatch != null,\n 'Could not find match for from: ' + dest.from,\n )\n\n fromSearch = last(fromMatches)?.search || this.latestLocation.search\n\n const stayingMatches = matches?.filter((d) =>\n fromMatches.find((e) => e.routeId === d.routeId),\n )\n\n const fromRouteByFromPathRouteId =\n this.routesById[\n stayingMatches?.find((d) => d.pathname === fromPath)?.routeId\n ]\n\n let pathname = dest.to\n ? this.resolvePathWithBase(fromPath, `${dest.to}`)\n : this.resolvePathWithBase(\n fromPath,\n fromRouteByFromPathRouteId?.to ?? fromPath,\n )\n\n const prevParams = { ...last(fromMatches)?.params }\n\n let nextParams =\n (dest.params ?? true) === true\n ? prevParams\n : { ...prevParams, ...functionalUpdate(dest.params, prevParams) }\n\n if (Object.keys(nextParams).length > 0) {\n matches\n ?.map((d) => this.looseRoutesById[d.routeId]!.options.stringifyParams)\n .filter(Boolean)\n .forEach((fn) => {\n nextParams = { ...nextParams!, ...fn!(nextParams) }\n })\n }\n\n // encode all path params so the generated href is valid and stable\n Object.keys(nextParams).forEach((key) => {\n if (['*', '_splat'].includes(key)) {\n // the splat/catch-all routes shouldn't have the '/' encoded out\n nextParams[key] = encodeURI(nextParams[key])\n } else {\n nextParams[key] = encodeURIComponent(nextParams[key])\n }\n })\n\n pathname = interpolatePath({\n path: pathname,\n params: nextParams ?? {},\n leaveWildcards: false,\n leaveParams: opts.leaveParams,\n })\n\n const preSearchFilters =\n stayingMatches\n ?.map(\n (match) =>\n this.looseRoutesById[match.routeId]!.options.preSearchFilters ??\n [],\n )\n .flat()\n .filter(Boolean) ?? []\n\n const postSearchFilters =\n stayingMatches\n ?.map(\n (match) =>\n this.looseRoutesById[match.routeId]!.options.postSearchFilters ??\n [],\n )\n .flat()\n .filter(Boolean) ?? []\n\n // Pre filters first\n const preFilteredSearch = preSearchFilters.length\n ? preSearchFilters.reduce((prev, next) => next(prev), fromSearch)\n : fromSearch\n\n // Then the link/navigate function\n const destSearch =\n dest.search === true\n ? preFilteredSearch // Preserve resolvedFrom true\n : dest.search\n ? functionalUpdate(dest.search, preFilteredSearch) // Updater\n : preSearchFilters.length\n ? preFilteredSearch // Preserve resolvedFrom filters\n : {}\n\n // Then post filters\n const postFilteredSearch = postSearchFilters.length\n ? postSearchFilters.reduce((prev, next) => next(prev), destSearch)\n : destSearch\n\n const search = replaceEqualDeep(fromSearch, postFilteredSearch)\n\n const searchStr = this.options.stringifySearch(search)\n\n const hash =\n dest.hash === true\n ? this.latestLocation.hash\n : dest.hash\n ? functionalUpdate(dest.hash, this.latestLocation.hash)\n : undefined\n\n const hashStr = hash ? `#${hash}` : ''\n\n let nextState =\n dest.state === true\n ? this.latestLocation.state\n : dest.state\n ? functionalUpdate(dest.state, this.latestLocation.state)\n : {}\n\n nextState = replaceEqualDeep(this.latestLocation.state, nextState)\n\n return {\n pathname,\n search,\n searchStr,\n state: nextState as any,\n hash: hash ?? '',\n href: `${pathname}${searchStr}${hashStr}`,\n unmaskOnReload: dest.unmaskOnReload,\n }\n }\n\n const buildWithMatches = (\n dest: BuildNextOptions = {},\n maskedDest?: BuildNextOptions,\n ) => {\n const next = build(dest)\n let maskedNext = maskedDest ? build(maskedDest) : undefined\n\n if (!maskedNext) {\n let params = {}\n\n const foundMask = this.options.routeMasks?.find((d) => {\n const match = matchPathname(this.basepath, next.pathname, {\n to: d.from,\n caseSensitive: false,\n fuzzy: false,\n })\n\n if (match) {\n params = match\n return true\n }\n\n return false\n })\n\n if (foundMask) {\n const { from, ...maskProps } = foundMask\n maskedDest = {\n ...pick(opts, ['from']),\n ...maskProps,\n params,\n }\n maskedNext = build(maskedDest)\n }\n }\n\n const nextMatches = this.matchRoutes(next.pathname, next.search)\n const maskedMatches = maskedNext\n ? this.matchRoutes(maskedNext.pathname, maskedNext.search)\n : undefined\n const maskedFinal = maskedNext\n ? build(maskedDest, maskedMatches)\n : undefined\n\n const final = build(dest, nextMatches)\n\n if (maskedFinal) {\n final.maskedLocation = maskedFinal\n }\n\n return final\n }\n\n if (opts.mask) {\n return buildWithMatches(opts, {\n ...pick(opts, ['from']),\n ...opts.mask,\n })\n }\n\n return buildWithMatches(opts)\n }\n\n commitLocation = async ({\n startTransition,\n viewTransition,\n ...next\n }: ParsedLocation & CommitLocationOptions) => {\n const isSameState = () => {\n // `state.key` is ignored but may still be provided when navigating,\n // temporarily add the previous key to the next state so it doesn't affect\n // the comparison\n\n next.state.key = this.latestLocation.state.key\n const isEqual = deepEqual(next.state, this.latestLocation.state)\n delete next.state.key\n return isEqual\n }\n\n const isSameUrl = this.latestLocation.href === next.href\n\n // Don't commit to history if nothing changed\n if (isSameUrl && isSameState()) {\n this.load()\n } else {\n // eslint-disable-next-line prefer-const\n let { maskedLocation, ...nextHistory } = next\n\n if (maskedLocation) {\n nextHistory = {\n ...maskedLocation,\n state: {\n ...maskedLocation.state,\n __tempKey: undefined,\n __tempLocation: {\n ...nextHistory,\n search: nextHistory.searchStr,\n state: {\n ...nextHistory.state,\n __tempKey: undefined!,\n __tempLocation: undefined!,\n key: undefined!,\n },\n },\n },\n }\n\n if (\n nextHistory.unmaskOnReload ??\n this.options.unmaskOnReload ??\n false\n ) {\n nextHistory.state.__tempKey = this.tempLocationKey\n }\n }\n\n this.shouldViewTransition = viewTransition\n\n this.history[next.replace ? 'replace' : 'push'](\n nextHistory.href,\n nextHistory.state,\n )\n }\n\n this.resetNextScroll = next.resetScroll ?? true\n\n return this.latestLoadPromise\n }\n\n buildAndCommitLocation = ({\n replace,\n resetScroll,\n startTransition,\n viewTransition,\n ...rest\n }: BuildNextOptions & CommitLocationOptions = {}) => {\n const location = this.buildLocation(rest as any)\n return this.commitLocation({\n ...location,\n startTransition,\n viewTransition,\n replace,\n resetScroll,\n })\n }\n\n navigate: NavigateFn = ({ from, to, __isRedirect, ...rest }) => {\n // If this link simply reloads the current route,\n // make sure it has a new key so it will trigger a data refresh\n\n // If this `to` is a valid external URL, return\n // null for LinkUtils\n const toString = String(to)\n // const fromString = from !== undefined ? String(from) : from\n let isExternal\n\n try {\n new URL(`${toString}`)\n isExternal = true\n } catch (e) {}\n\n invariant(\n !isExternal,\n 'Attempting to navigate to external url with this.navigate!',\n )\n\n return this.buildAndCommitLocation({\n ...rest,\n from,\n to,\n // to: toString,\n })\n }\n\n load = async (): Promise<void> => {\n this.latestLocation = this.parseLocation(this.latestLocation)\n\n if (this.state.location === this.latestLocation) {\n return\n }\n\n const promise = createControlledPromise<void>()\n this.latestLoadPromise = promise\n let redirect: ResolvedRedirect | undefined\n let notFound: NotFoundError | undefined\n\n this.startReactTransition(async () => {\n try {\n const next = this.latestLocation\n const prevLocation = this.state.resolvedLocation\n const pathDidChange = prevLocation.href !== next.href\n\n // Cancel any pending matches\n this.cancelMatches()\n\n let pendingMatches!: Array<AnyRouteMatch>\n\n this.__store.batch(() => {\n // this call breaks a route context of destination route after a redirect\n // we should be fine not eagerly calling this since we call it later\n // this.cleanCache()\n\n // Match the routes\n pendingMatches = this.matchRoutes(next.pathname, next.search)\n\n // Ingest the new matches\n this.__store.setState((s) => ({\n ...s,\n status: 'pending',\n isLoading: true,\n location: next,\n pendingMatches,\n // If a cached moved to pendingMatches, remove it from cachedMatches\n cachedMatches: s.cachedMatches.filter((d) => {\n return !pendingMatches.find((e) => e.id === d.id)\n }),\n }))\n })\n\n if (!this.state.redirect) {\n this.emit({\n type: 'onBeforeNavigate',\n fromLocation: prevLocation,\n toLocation: next,\n pathChanged: pathDidChange,\n })\n }\n\n this.emit({\n type: 'onBeforeLoad',\n fromLocation: prevLocation,\n toLocation: next,\n pathChanged: pathDidChange,\n })\n\n await this.loadMatches({\n matches: pendingMatches,\n location: next,\n checkLatest: () => this.checkLatest(promise),\n onReady: async () => {\n await this.startViewTransition(async () => {\n // this.viewTransitionPromise = createControlledPromise<true>()\n\n // Commit the pending matches. If a previous match was\n // removed, place it in the cachedMatches\n let exitingMatches!: Array<AnyRouteMatch>\n let enteringMatches!: Array<AnyRouteMatch>\n let stayingMatches!: Array<AnyRouteMatch>\n\n this.__store.batch(() => {\n this.__store.setState((s) => {\n const previousMatches = s.matches\n const newMatches = s.pendingMatches || s.matches\n\n exitingMatches = previousMatches.filter(\n (match) => !newMatches.find((d) => d.id === match.id),\n )\n enteringMatches = newMatches.filter(\n (match) => !previousMatches.find((d) => d.id === match.id),\n )\n stayingMatches = previousMatches.filter((match) =>\n newMatches.find((d) => d.id === match.id),\n )\n\n return {\n ...s,\n isLoading: false,\n matches: newMatches,\n pendingMatches: undefined,\n cachedMatches: [\n ...s.cachedMatches,\n ...exitingMatches.filter((d) => d.status !== 'error'),\n ],\n }\n })\n this.cleanCache()\n })\n\n //\n ;(\n [\n [exitingMatches, 'onLeave'],\n [enteringMatches, 'onEnter'],\n [stayingMatches, 'onStay'],\n ] as const\n ).forEach(([matches, hook]) => {\n matches.forEach((match) => {\n this.looseRoutesById[match.routeId]!.options[hook]?.(match)\n })\n })\n })\n },\n })\n } catch (err) {\n if (isResolvedRedirect(err)) {\n redirect = err\n if (!this.isServer) {\n this.navigate({ ...err, replace: true, __isRedirect: true })\n // this.load()\n }\n } else if (isNotFound(err)) {\n notFound = err\n }\n\n this.__store.setState((s) => ({\n ...s,\n statusCode: redirect\n ? redirect.statusCode\n : notFound\n ? 404\n : s.matches.some((d) => d.status === 'error')\n ? 500\n : 200,\n redirect,\n }))\n }\n\n promise.resolve()\n })\n\n return this.latestLoadPromise\n }\n\n startViewTransition = async (fn: () => Promise<void>) => {\n // Determine if we should start a view transition from the navigation\n // or from the router default\n const shouldViewTransition =\n this.shouldViewTransition ?? this.options.defaultViewTransition\n\n // Reset the view transition flag\n delete this.shouldViewTransition\n // Attempt to start a view transition (or just apply the changes if we can't)\n ;(shouldViewTransition && typeof document !== 'undefined'\n ? document\n : undefined\n )\n // @ts-expect-error\n ?.startViewTransition?.(fn) || fn()\n }\n\n loadMatches = async ({\n checkLatest,\n location,\n matches,\n preload,\n onReady,\n }: {\n checkLatest: () => void\n location: ParsedLocation\n matches: Array<AnyRouteMatch>\n preload?: boolean\n onReady?: () => Promise<void>\n }): Promise<Array<MakeRouteMatch>> => {\n let firstBadMatchIndex: number | undefined\n let rendered = false\n\n const triggerOnReady = async () => {\n if (!rendered) {\n rendered = true\n await onReady?.()\n }\n }\n\n if (!this.isServer && !this.state.matches.length) {\n triggerOnReady()\n }\n\n const updateMatch = (\n id: string,\n updater: (match: AnyRouteMatch) => AnyRouteMatch,\n opts?: { remove?: boolean },\n ) => {\n let updated!: AnyRouteMatch\n const isPending = this.state.pendingMatches?.find((d) => d.id === id)\n const isMatched = this.state.matches.find((d) => d.id === id)\n\n const matchesKey = isPending\n ? 'pendingMatches'\n : isMatched\n ? 'matches'\n : 'cachedMatches'\n\n this.__store.setState((s) => ({\n ...s,\n [matchesKey]: opts?.remove\n ? s[matchesKey]?.filter((d) => d.id !== id)\n : s[matchesKey]?.map((d) =>\n d.id === id ? (updated = updater(d)) : d,\n ),\n }))\n\n return updated\n }\n\n const handleRedirectAndNotFound = (match: AnyRouteMatch, err: any) => {\n if (isResolvedRedirect(err)) throw err\n\n if (isRedirect(err) || isNotFound(err)) {\n // if (!rendered) {\n updateMatch(match.id, (prev) => ({\n ...prev,\n status: isRedirect(err)\n ? 'redirected'\n : isNotFound(err)\n ? 'notFound'\n : 'error',\n isFetching: false,\n error: err,\n }))\n // }\n\n if (!(err as any).routeId) {\n ;(err as any).routeId = match.routeId\n }\n\n if (isRedirect(err)) {\n rendered = true\n err = this.resolveRedirect({ ...err, _fromLocation: location })\n throw err\n } else if (isNotFound(err)) {\n this.handleNotFound(matches, err)\n throw err\n }\n }\n }\n\n try {\n await new Promise<void>((resolveAll, rejectAll) => {\n ;(async () => {\n try {\n // Check each match middleware to see if the route can be accessed\n // eslint-disable-next-line prefer-const\n for (let [index, match] of matches.entries()) {\n const parentMatch = matches[index - 1]\n const route = this.looseRoutesById[match.routeId]!\n const abortController = new AbortController()\n let loadPromise = match.loadPromise\n\n const pendingMs =\n route.options.pendingMs ?? this.options.defaultPendingMs\n\n const shouldPending = !!(\n onReady &&\n !this.isServer &&\n !preload &&\n (route.options.loader || route.options.beforeLoad) &&\n typeof pendingMs === 'number' &&\n pendingMs !== Infinity &&\n (route.options.pendingComponent ??\n this.options.defaultPendingComponent)\n )\n\n if (shouldPending) {\n // If we might show a pending component, we need to wait for the\n // pending promise to resolve before we start showing that state\n setTimeout(() => {\n try {\n checkLatest()\n // Update the match and prematurely resolve the loadMatches promise so that\n // the pending component can start rendering\n triggerOnReady()\n } catch {}\n }, pendingMs)\n }\n\n if (match.isFetching) {\n continue\n }\n\n const previousResolve = loadPromise.resolve\n // Create a new one\n loadPromise = createControlledPromise<void>(\n // Resolve the old when we we resolve the new one\n previousResolve,\n )\n\n // Otherwise, load the route\n matches[index] = match = updateMatch(match.id, (prev) => ({\n ...prev,\n isFetching: 'beforeLoad',\n loadPromise,\n }))\n\n const handleSerialError = (err: any, routerCode: string) => {\n // If the error is a promise, it means we're outdated and\n // should abort the current async operation\n if (err instanceof Promise) {\n throw err\n }\n\n err.routerCode = routerCode\n firstBadMatchIndex = firstBadMatchIndex ?? index\n handleRedirectAndNotFound(match, err)\n\n try {\n route.options.onError?.(err)\n } catch (errorHandlerErr) {\n err = errorHandlerErr\n handleRedirectAndNotFound(match, err)\n }\n\n matches[index] = match = updateMatch(match.id, () => ({\n ...match,\n error: err,\n status: 'error',\n updatedAt: Date.now(),\n abortController: new AbortController(),\n }))\n }\n\n if (match.paramsError) {\n handleSerialError(match.paramsError, 'PARSE_PARAMS')\n }\n\n if (match.searchError) {\n handleSerialError(match.searchError, 'VALIDATE_SEARCH')\n }\n\n try {\n const parentContext =\n parentMatch?.context ?? this.options.context ?? {}\n\n // Make sure the match has parent context set before going further\n matches[index] = match = {\n ...match,\n routeContext: replaceEqualDeep(\n match.routeContext,\n parentContext,\n ),\n context: replaceEqualDeep(match.context, parentContext),\n abortController,\n }\n\n const beforeLoadFnContext = {\n search: match.search,\n abortController,\n params: match.params,\n preload: !!preload,\n context: match.routeContext,\n location,\n navigate: (opts: any) =>\n this.navigate({ ...opts, _fromLocation: location }),\n buildLocation: this.buildLocation,\n cause: preload ? 'preload' : match.cause,\n }\n\n const beforeLoadContext = route.options.beforeLoad\n ? (await route.options.beforeLoad(beforeLoadFnContext)) ?? {}\n : {}\n\n checkLatest()\n\n if (\n isRedirect(beforeLoadContext) ||\n isNotFound(beforeLoadContext)\n ) {\n handleSerialError(beforeLoadContext, 'BEFORE_LOAD')\n }\n\n const context = {\n ...parentContext,\n ...beforeLoadContext,\n }\n\n matches[index] = match = {\n ...match,\n routeContext: replaceEqualDeep(\n match.routeContext,\n beforeLoadContext,\n ),\n context: replaceEqualDeep(match.context, context),\n abortController,\n }\n updateMatch(match.id, () => match)\n } catch (err) {\n handleSerialError(err, 'BEFORE_LOAD')\n break\n }\n }\n\n checkLatest()\n\n const validResolvedMatches = matches.slice(0, firstBadMatchIndex)\n const matchPromises: Array<Promise<any>> = []\n\n validResolvedMatches.forEach((match, index) => {\n const createValidateResolvedMatchPromise = async () => {\n const parentMatchPromise = matchPromises[index - 1]\n const route = this.looseRoutesById[match.routeId]!\n\n const loaderContext: LoaderFnContext = {\n params: match.params,\n deps: match.loaderDeps,\n preload: !!preload,\n parentMatchPromise,\n abortController: match.abortController,\n context: match.context,\n location,\n navigate: (opts) =>\n this.navigate({ ...opts, _fromLocation: location }),\n cause: preload ? 'preload' : match.cause,\n route,\n }\n\n const fetchAndResolveInLoaderLifetime = async () => {\n const existing = getRouteMatch(this.state, match.id)!\n let lazyPromise = Promise.resolve()\n let componentsPromise = Promise.resolve() as Promise<any>\n let loaderPromise = existing.loaderPromise\n\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 const potentialPendingMinPromise = async () => {\n const latestMatch = getRouteMatch(this.state, match.id)\n\n if (latestMatch?.minPendingPromise) {\n await latestMatch.minPendingPromise\n\n checkLatest()\n\n updateMatch(latestMatch.id, (prev) => ({\n ...prev,\n minPendingPromise: undefined,\n }))\n }\n }\n\n try {\n if (match.isFetching === 'beforeLoad') {\n // If the user doesn't want the route to reload, just\n // resolve with the existing loader data\n\n // if (match.fetchCount && match.status === 'success') {\n // resolve()\n // }\n\n // Otherwise, load the route\n matches[index] = match = updateMatch(\n match.id,\n (prev) => ({\n ...prev,\n isFetching: 'loader',\n fetchCount: match.fetchCount + 1,\n }),\n )\n\n lazyPromise =\n route.lazyFn?.().then((lazyRoute) => {\n Object.assign(route.options, lazyRoute.options)\n }) || Promise.resolve()\n\n // If for some reason lazy resolves more lazy components...\n // We'll wait for that before pre attempt to preload any\n // components themselves.\n componentsPromise = lazyPromise.then(() =>\n Promise.all(\n componentTypes.map(async (type) => {\n const component = route.options[type]\n\n if ((component as any)?.preload) {\n await (component as any).preload()\n }\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 await lazyPromise\n\n checkLatest()\n\n // Kick off the loader!\n loaderPromise = route.options.loader?.(loaderContext)\n\n matches[index] = match = updateMatch(\n match.id,\n (prev) => ({\n ...prev,\n loaderPromise,\n }),\n )\n }\n\n const loaderData = await loaderPromise\n checkLatest()\n\n handleRedirectAndNotFound(match, loaderData)\n\n await potentialPendingMinPromise()\n checkLatest()\n\n const meta = route.options.meta?.({\n matches,\n params: match.params,\n loaderData,\n })\n\n const headers = route.options.headers?.({\n loaderData,\n })\n\n matches[index] = match = updateMatch(match.id, (prev) => ({\n ...prev,\n error: undefined,\n status: 'success',\n isFetching: false,\n updatedAt: Date.now(),\n loaderData,\n meta,\n headers,\n }))\n } catch (e) {\n checkLatest()\n let error = e\n\n await potentialPendingMinPromise()\n checkLatest()\n\n handleRedirectAndNotFound(match, e)\n\n try {\n route.options.onError?.(e)\n } catch (onErrorError) {\n error = onErrorError\n handleRedirectAndNotFound(match, onErrorError)\n }\n\n matches[index] = match = updateMatch(match.id, (prev) => ({\n ...prev,\n error,\n status: 'error',\n isFetching: false,\n }))\n }\n\n // Last but not least, wait for the the component\n // to be preloaded before we resolve the match\n await componentsPromise\n\n checkLatest()\n\n match.loadPromise.resolve()\n }\n\n // This is where all of the stale-while-revalidate magic happens\n const age = Date.now() - match.updatedAt\n\n const staleAge = preload\n ? route.options.preloadStaleTime ??\n this.options.defaultPreloadStaleTime ??\n 30_000 // 30 seconds for preloads by default\n : route.options.staleTime ??\n this.options.defaultStaleTime ??\n 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(loaderContext)\n : shouldReloadOption\n\n matches[index] = match = {\n ...match,\n preload:\n !!preload &&\n !this.state.matches.find((d) => d.id === match.id),\n }\n\n const fetchWithRedirectAndNotFound = async () => {\n try {\n await fetchAndResolveInLoaderLifetime()\n } catch (err) {\n checkLatest()\n handleRedirectAndNotFound(match, err)\n }\n }\n\n // If the route is successful and still fresh, just resolve\n if (\n match.status === 'success' &&\n (match.invalid || (shouldReload ?? age > staleAge))\n ) {\n ;(async () => {\n try {\n await fetchWithRedirectAndNotFound()\n } catch (err) {}\n })()\n return\n }\n\n if (match.status !== 'success') {\n await fetchWithRedirectAndNotFound()\n }\n\n return\n }\n\n matchPromises.push(createValidateResolvedMatchPromise())\n })\n\n await Promise.all(matchPromises)\n\n checkLatest()\n\n resolveAll()\n } catch (err) {\n rejectAll(err)\n }\n })()\n })\n await triggerOnReady()\n } catch (err) {\n if (isRedirect(err) || isNotFound(err)) {\n if (isNotFound(err) && !preload) {\n await triggerOnReady()\n }\n throw err\n }\n }\n\n return matches\n }\n\n invalidate = () => {\n const invalidate = (d: MakeRouteMatch<TRouteTree>) => ({\n ...d,\n invalid: true,\n ...(d.status === 'error' ? ({ status: 'pending' } as const) : {}),\n })\n\n this.__store.setState((s) => ({\n ...s,\n matches: s.matches.map(invalidate),\n cachedMatches: s.cachedMatches.map(invalidate),\n pendingMatches: s.pendingMatches?.map(invalidate),\n }))\n\n return this.load()\n }\n\n resolveRedirect = (err: AnyRedirect): ResolvedRedirect => {\n const redirect = err as ResolvedRedirect\n\n if (!redirect.href) {\n redirect.href = this.buildLocation(redirect as any).href\n }\n\n return redirect\n }\n\n cleanCache = () => {\n // This is where all of the garbage collection magic happens\n this.__store.setState((s) => {\n return {\n ...s,\n cachedMatches: s.cachedMatches.filter((d) => {\n const route = this.looseRoutesById[d.routeId]!\n\n if (!route.options.loader) {\n return false\n }\n\n // If the route was preloaded, use the preloadGcTime\n // otherwise, use the gcTime\n const gcTime =\n (d.preload\n ? route.options.preloadGcTime ?? this.options.defaultPreloadGcTime\n : route.options.gcTime ?? this.options.defaultGcTime) ??\n 5 * 60 * 1000\n\n return d.status !== 'error' && Date.now() - d.updatedAt < gcTime\n }),\n }\n })\n }\n\n preloadRoute = async <\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n >(\n opts: NavigateOptions<\n Router<TRouteTree, TTrailingSlashOption, TDehydrated, TSerializedError>,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n >,\n ): Promise<Array<AnyRouteMatch> | undefined> => {\n const next = this.buildLocation(opts as any)\n\n let matches = this.matchRoutes(next.pathname, next.search, {\n throwOnError: true,\n preload: true,\n })\n\n const loadedMatchIds = Object.fromEntries(\n [\n ...this.state.matches,\n ...(this.state.pendingMatches ?? []),\n ...this.state.cachedMatches,\n ].map((d) => [d.id, true]),\n )\n\n this.__store.batch(() => {\n matches.forEach((match) => {\n if (!loadedMatchIds[match.id]) {\n this.__store.setState((s) => ({\n ...s,\n cachedMatches: [...(s.cachedMatches as any), match],\n }))\n }\n })\n })\n\n // If the preload leaf match is the same as the current or pending leaf match,\n // do not preload as it could cause a mutation of the current route.\n // The user should specify proper loaderDeps (which are used to uniquely identify a route)\n // to trigger preloads for routes with the same pathname, but different deps\n\n const leafMatch = last(matches)\n const currentLeafMatch = last(this.state.matches)\n const pendingLeafMatch = last(this.state.pendingMatches ?? [])\n\n if (\n leafMatch &&\n (currentLeafMatch?.id === leafMatch.id ||\n pendingLeafMatch?.id === leafMatch.id)\n ) {\n return undefined\n }\n\n try {\n matches = await this.loadMatches({\n matches,\n location: next,\n preload: true,\n checkLatest: () => undefined,\n })\n\n return matches\n } catch (err) {\n if (isRedirect(err)) {\n return await this.preloadRoute({\n ...(err as any),\n _fromLocation: next,\n })\n }\n // Preload errors are not fatal, but we should still log them\n console.error(err)\n return undefined\n }\n }\n\n matchRoute = <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n location: ToOptions<\n Router<TRouteTree, TTrailingSlashOption, TDehydrated, TSerializedError>,\n TFrom,\n TTo\n >,\n opts?: MatchRouteOptions,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const matchLocation = {\n ...location,\n to: location.to\n ? this.resolvePathWithBase((location.from || '') as string, location.to)\n : undefined,\n params: location.params || {},\n leaveParams: true,\n }\n const next = this.buildLocation(matchLocation as any)\n\n if (opts?.pending && this.state.status !== 'pending') {\n return false\n }\n\n const pending =\n opts?.pending === undefined ? !this.state.isLoading : opts.pending\n\n const baseLocation = pending\n ? this.latestLocation\n : this.state.resolvedLocation\n\n const match = matchPathname(this.basepath, baseLocation.pathname, {\n ...opts,\n to: next.pathname,\n }) as any\n\n if (!match) {\n return false\n }\n if (location.params) {\n if (!deepEqual(match, location.params, true)) {\n return false\n }\n }\n\n if (match && (opts?.includeSearch ?? true)) {\n return deepEqual(baseLocation.search, next.search, true) ? match : false\n }\n\n return match\n }\n\n // We use a token -> weak map to keep track of deferred promises\n // that are registered on the server and need to be resolved\n registeredDeferredsIds = new Map<string, {}>()\n registeredDeferreds = new WeakMap<{}, DeferredPromiseState<any>>()\n\n getDeferred = (uid: string) => {\n const token = this.registeredDeferredsIds.get(uid)\n\n if (!token) {\n return undefined\n }\n\n return this.registeredDeferreds.get(token)\n }\n\n dehydrate = (): DehydratedRouter => {\n const pickError =\n this.options.errorSerializer?.serialize ?? defaultSerializeError\n\n return {\n state: {\n dehydratedMatches: this.state.matches.map((d) => ({\n ...pick(d, ['id', 'status', 'updatedAt', 'loaderData']),\n // If an error occurs server-side during SSRing,\n // send a small subset of the error to the client\n error: d.error\n ? {\n data: pickError(d.error),\n __isServerError: true,\n }\n : undefined,\n })),\n },\n manifest: this.manifest,\n }\n }\n\n hydrate = async (__do_not_use_server_ctx?: string) => {\n let _ctx = __do_not_use_server_ctx\n // Client hydrates from window\n if (typeof document !== 'undefined') {\n _ctx = window.__TSR_DEHYDRATED__?.data\n }\n\n invariant(\n _ctx,\n 'Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Please file an issue!',\n )\n\n const ctx = this.options.transformer.parse(_ctx) as HydrationCtx\n this.dehydratedData = ctx.payload as any\n this.options.hydrate?.(ctx.payload as any)\n const dehydratedState = ctx.router.state\n\n const matches = this.matchRoutes(\n this.state.location.pathname,\n this.state.location.search,\n ).map((match, i, allMatches) => {\n const dehydratedMatch = dehydratedState.dehydratedMatches.find(\n (d) => d.id === match.id,\n )\n\n invariant(\n dehydratedMatch,\n `Could not find a client-side match for dehydrated match with id: ${match.id}!`,\n )\n\n const route = this.looseRoutesById[match.routeId]!\n\n const assets =\n dehydratedMatch.status === 'notFound' ||\n dehydratedMatch.status === 'redirected'\n ? {}\n : {\n meta: route.options.meta?.({\n matches: allMatches,\n params: match.params,\n loaderData: dehydratedMatch.loaderData,\n }),\n links: route.options.links?.(),\n scripts: route.options.scripts?.(),\n }\n\n return {\n ...match,\n ...dehydratedMatch,\n ...assets,\n }\n })\n\n this.__store.setState((s) => {\n return {\n ...s,\n matches: matches as any,\n }\n })\n\n this.manifest = ctx.router.manifest\n }\n\n handleNotFound = (matches: Array<AnyRouteMatch>, err: NotFoundError) => {\n const matchesByRouteId = Object.fromEntries(\n matches.map((match) => [match.routeId, match]),\n ) as Record<string, AnyRouteMatch>\n\n // Start at the route that errored or default to the root route\n let routeCursor =\n (err.global\n ? this.looseRoutesById[rootRouteId]\n : this.looseRoutesById[err.routeId]) ||\n this.looseRoutesById[rootRouteId]!\n\n // Go up the tree until we find a route with a notFoundComponent or we hit the root\n while (\n !routeCursor.options.notFoundComponent &&\n !this.options.defaultNotFoundComponent &&\n routeCursor.id !== rootRouteId\n ) {\n routeCursor = routeCursor.parentRoute\n\n invariant(\n routeCursor,\n 'Found invalid route tree while trying to find not-found handler.',\n )\n }\n\n const match = matchesByRouteId[routeCursor.id]\n\n invariant(match, 'Could not find match for route: ' + routeCursor.id)\n\n // Assign the error to the match\n Object.assign(match, {\n status: 'notFound',\n error: err,\n isFetching: false,\n } as AnyRouteMatch)\n }\n\n hasNotFoundMatch = () => {\n return this.__store.state.matches.some(\n (d) => d.status === 'notFound' || d.globalNotFound,\n )\n }\n\n // resolveMatchPromise = (matchId: string, key: string, value: any) => {\n // state.matches\n // .find((d) => d.id === matchId)\n // ?.__promisesByKey[key]?.resolve(value)\n // }\n}\n\n// A function that takes an import() argument which is a function and returns a new function that will\n// proxy arguments from the caller to the imported function, retaining all type\n// information along the way\nexport function lazyFn<\n T extends Record<string, (...args: Array<any>) => any>,\n TKey extends keyof T = 'default',\n>(fn: () => Promise<T>, key?: TKey) {\n return async (\n ...args: Parameters<T[TKey]>\n ): Promise<Awaited<ReturnType<T[TKey]>>> => {\n const imported = await fn()\n return imported[key || 'default'](...args)\n }\n}\n\nexport class SearchParamError extends Error {}\n\nexport class PathParamError extends Error {}\n\nexport function getInitialRouterState(\n location: ParsedLocation,\n): RouterState<any> {\n return {\n isLoading: false,\n isTransitioning: false,\n status: 'idle',\n resolvedLocation: { ...location },\n location,\n matches: [],\n pendingMatches: [],\n cachedMatches: [],\n statusCode: 200,\n }\n}\n\nexport function defaultSerializeError(err: unknown) {\n if (err instanceof Error) {\n const obj = {\n name: err.name,\n message: err.message,\n }\n\n if (process.env.NODE_ENV === 'development') {\n ;(obj as any).stack = err.stack\n }\n\n return obj\n }\n\n return {\n data: err,\n }\n}\n"],"names":["_a","_b","_c","match"],"mappings":";;;;;;;;;;AA+ZO,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAoCO,SAAS,aAMd,SAMA;AACO,SAAA,IAAI,OAKT,OAAO;AACX;AAEO,MAAM,OAKX;AAAA;AAAA;AAAA;AAAA,EAwCA,YACE,SAMA;AA7CF,SAAA,kBAAsC,GAAG,KAAK;AAAA,MAC5C,KAAK,WAAW;AAAA,IACjB,CAAA;AACiB,SAAA,kBAAA;AACe,SAAA,uBAAA;AACjC,SAAA,oBAAmC,QAAQ;AAC3C,SAAA,kCAAkB;AAwDlB,SAAA,WAAW,OAAO,aAAa;AAKkB,SAAA,uBAAA,CAAC,OAAO,GAAG;AAE5D,SAAA,SAAS,CACP,eAMG;AACH,UAAI,WAAW,eAAe;AACpB,gBAAA;AAAA,UACN;AAAA,QAAA;AAAA,MAEJ;AAEA,YAAM,kBAAkB,KAAK;AAC7B,WAAK,UAAU;AAAA,QACb,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MAAA;AAIH,UAAA,CAAC,KAAK,YACL,WAAW,YAAY,WAAW,aAAa,gBAAgB,UAChE;AAEE,YAAA,WAAW,aAAa,UACxB,WAAW,aAAa,MACxB,WAAW,aAAa,KACxB;AACA,eAAK,WAAW;AAAA,QAAA,OACX;AACL,eAAK,WAAW,IAAI,SAAS,WAAW,QAAQ,CAAC;AAAA,QACnD;AAAA,MACF;AAEA;AAAA;AAAA,QAEE,CAAC,KAAK,WACL,KAAK,QAAQ,WAAW,KAAK,QAAQ,YAAY,KAAK;AAAA,QACvD;AAC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AEO,WAAA;AAAA,EACT;AAEO,SAAA;AAAA,IACL,MAAM;AAAA,EAAA;AAEV;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.36.2",
3
+ "version": "1.38.1",
4
4
  "description": "",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@ export function Transitioner() {
29
29
 
30
30
  // Subscribe to location changes
31
31
  // and try to load the new location
32
- useLayoutEffect(() => {
32
+ React.useEffect(() => {
33
33
  const unsub = router.history.subscribe(router.load)
34
34
 
35
35
  const nextLocation = router.buildLocation({