@tanstack/router-core 1.136.4 → 1.136.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cjs/Matches.cjs.map +1 -1
  2. package/dist/cjs/Matches.d.cts +2 -0
  3. package/dist/cjs/index.cjs +0 -5
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +1 -4
  6. package/dist/cjs/lru-cache.cjs +5 -0
  7. package/dist/cjs/lru-cache.cjs.map +1 -1
  8. package/dist/cjs/lru-cache.d.cts +1 -0
  9. package/dist/cjs/new-process-route-tree.cjs +655 -0
  10. package/dist/cjs/new-process-route-tree.cjs.map +1 -0
  11. package/dist/cjs/new-process-route-tree.d.cts +177 -0
  12. package/dist/cjs/path.cjs +133 -434
  13. package/dist/cjs/path.cjs.map +1 -1
  14. package/dist/cjs/path.d.cts +3 -39
  15. package/dist/cjs/router.cjs +47 -98
  16. package/dist/cjs/router.cjs.map +1 -1
  17. package/dist/cjs/router.d.cts +6 -11
  18. package/dist/esm/Matches.d.ts +2 -0
  19. package/dist/esm/Matches.js.map +1 -1
  20. package/dist/esm/index.d.ts +1 -4
  21. package/dist/esm/index.js +1 -6
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/lru-cache.d.ts +1 -0
  24. package/dist/esm/lru-cache.js +5 -0
  25. package/dist/esm/lru-cache.js.map +1 -1
  26. package/dist/esm/new-process-route-tree.d.ts +177 -0
  27. package/dist/esm/new-process-route-tree.js +655 -0
  28. package/dist/esm/new-process-route-tree.js.map +1 -0
  29. package/dist/esm/path.d.ts +3 -39
  30. package/dist/esm/path.js +133 -434
  31. package/dist/esm/path.js.map +1 -1
  32. package/dist/esm/router.d.ts +6 -11
  33. package/dist/esm/router.js +48 -99
  34. package/dist/esm/router.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/Matches.ts +2 -0
  37. package/src/index.ts +0 -6
  38. package/src/lru-cache.ts +6 -0
  39. package/src/new-process-route-tree.ts +1036 -0
  40. package/src/path.ts +168 -639
  41. package/src/router.ts +57 -126
  42. package/dist/cjs/process-route-tree.cjs +0 -144
  43. package/dist/cjs/process-route-tree.cjs.map +0 -1
  44. package/dist/cjs/process-route-tree.d.cts +0 -18
  45. package/dist/esm/process-route-tree.d.ts +0 -18
  46. package/dist/esm/process-route-tree.js +0 -144
  47. package/dist/esm/process-route-tree.js.map +0 -1
  48. package/src/process-route-tree.ts +0 -241
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { Store, batch } from '@tanstack/store'\nimport { createBrowserHistory, parseHref } from '@tanstack/history'\nimport {\n createControlledPromise,\n decodePath,\n deepEqual,\n findLast,\n functionalUpdate,\n last,\n replaceEqualDeep,\n} from './utils'\nimport { processRouteTree } from './process-route-tree'\nimport {\n cleanPath,\n interpolatePath,\n matchPathname,\n resolvePath,\n trimPath,\n trimPathRight,\n} from './path'\nimport { isNotFound } from './not-found'\nimport { setupScrollRestoration } from './scroll-restoration'\nimport { defaultParseSearch, defaultStringifySearch } from './searchParams'\nimport { rootRouteId } from './root'\nimport { isRedirect, redirect } from './redirect'\nimport { createLRUCache } from './lru-cache'\nimport { loadMatches, loadRouteChunk, routeNeedsPreload } from './load-matches'\nimport {\n composeRewrites,\n executeRewriteInput,\n executeRewriteOutput,\n rewriteBasepath,\n} from './rewrite'\nimport type { ParsePathnameCache } from './path'\nimport type { SearchParser, SearchSerializer } from './searchParams'\nimport type { AnyRedirect, ResolvedRedirect } from './redirect'\nimport type {\n HistoryLocation,\n HistoryState,\n ParsedHistoryState,\n RouterHistory,\n} from '@tanstack/history'\nimport type {\n Awaitable,\n Constrain,\n ControlledPromise,\n NoInfer,\n NonNullableUpdater,\n PickAsRequired,\n Updater,\n} from './utils'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouteWithContext,\n MakeRemountDepsOptionsUnion,\n RouteContextOptions,\n RouteLike,\n RouteMask,\n SearchMiddleware,\n} from './route'\nimport type {\n FullSearchSchema,\n RouteById,\n RoutePaths,\n RoutesById,\n RoutesByPath,\n} from './routeInfo'\nimport type {\n AnyRouteMatch,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n MatchRouteOptions,\n} from './Matches'\nimport type {\n BuildLocationFn,\n CommitLocationOptions,\n NavigateFn,\n} from './RouterProvider'\nimport type { Manifest } from './manifest'\nimport type { AnySchema, AnyValidator } from './validators'\nimport type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'\nimport type { NotFoundError } from './not-found'\nimport type {\n AnySerializationAdapter,\n ValidateSerializableInput,\n} from './ssr/serializer/transformer'\n// import type { AnyRouterConfig } from './config'\n\nexport type ControllablePromise<T = any> = Promise<T> & {\n resolve: (value: T) => void\n reject: (value?: any) => void\n}\n\nexport type InjectedHtmlEntry = Promise<string>\n\nexport interface Register {\n // Lots of things on here like...\n // router\n // config\n // ssr\n}\n\nexport type RegisteredSsr<TRegister = Register> = TRegister extends {\n ssr: infer TSSR\n}\n ? TSSR\n : false\n\nexport type RegisteredRouter<TRegister = Register> = TRegister extends {\n router: infer TRouter\n}\n ? TRouter\n : AnyRouter\n\nexport type RegisteredConfigType<TRegister, TKey> = TRegister extends {\n config: infer TConfig\n}\n ? TConfig extends {\n '~types': infer TTypes\n }\n ? TKey extends keyof TTypes\n ? TTypes[TKey]\n : unknown\n : unknown\n : unknown\n\nexport type DefaultRemountDepsFn<TRouteTree extends AnyRoute> = (\n opts: MakeRemountDepsOptionsUnion<TRouteTree>,\n) => any\n\nexport interface DefaultRouterOptionsExtensions {}\n\nexport interface RouterOptionsExtensions\n extends DefaultRouterOptionsExtensions {}\n\nexport type SSROption = boolean | 'data-only'\n\nexport interface RouterOptions<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean = false,\n TRouterHistory extends RouterHistory = RouterHistory,\n TDehydrated = undefined,\n> extends RouterOptionsExtensions {\n /**\n * The history object that will be used to manage the browser history.\n *\n * If not provided, a new createBrowserHistory instance will be created and used.\n *\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?: TRouterHistory\n /**\n * A function that will be used to stringify search params when generating links.\n *\n * @default 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 *\n * @default 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 * If `false`, routes will not be preloaded by default in any way.\n *\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 *\n * If `'viewport'`, routes will be preloaded by default when they are within the viewport.\n *\n * @default false\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' | 'viewport' | 'render'\n /**\n * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.\n *\n * @default 50\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 * The default `preloadIntentProximity` a route should use if no preloadIntentProximity is provided.\n *\n * @default 0\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadintentproximity-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-intent-proximity)\n */\n defaultPreloadIntentProximity?: number\n /**\n * The default `pendingMs` a route should use if no pendingMs is provided.\n *\n * @default 1000\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 * The default `pendingMinMs` a route should use if no pendingMinMs is provided.\n *\n * @default 500\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 * The default `staleTime` a route should use if no staleTime is provided. This is the time in milliseconds that a route will be considered fresh.\n *\n * @default 0\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 * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.\n *\n * @default 30_000 `(30 seconds)`\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 * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.\n *\n * @default 1_800_000 `(30 minutes)`\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 * If `true`, route navigations will called using `document.startViewTransition()`.\n *\n * If the browser does not support this api, this option will be ignored.\n *\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)\n */\n defaultViewTransition?: boolean | ViewTransitionOptions\n /**\n * The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating\n *\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)\n */\n defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions\n /**\n * @default 'fuzzy'\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)\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 * The default `gcTime` a route should use if no gcTime is provided.\n *\n * @default 1_800_000 `(30 minutes)`\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 * If `true`, all routes will be matched as case-sensitive.\n *\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)\n */\n caseSensitive?: boolean\n /**\n *\n * The route tree that will be used to configure the router instance.\n *\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/routing/route-trees)\n */\n routeTree?: TRouteTree\n /**\n * The basepath for then entire router. This is useful for mounting a router instance at a subpath.\n * ```\n * @default '/'\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)\n */\n basepath?: string\n /**\n * The root context that will be provided to all routes in the route tree.\n *\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 *\n * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).\n *\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?: InferRouterContext<TRouteTree>\n\n additionalContext?: any\n\n /**\n * A function that will be called when the router is dehydrated.\n *\n * The return value of this function will be serialized and stored in the router's dehydrated state.\n *\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?: () => Constrain<\n TDehydrated,\n ValidateSerializableInput<Register, TDehydrated>\n >\n /**\n * A function that will be called when the router is hydrated.\n *\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) => Awaitable<void>\n /**\n * An array of route masks that will be used to mask routes in the route tree.\n *\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 *\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 * If `true`, route masks will, by default, be removed when the page is reloaded.\n *\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 *\n * @default false\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 /**\n * Use `notFoundComponent` instead.\n *\n * @deprecated\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 * Configures how trailing slashes are treated.\n *\n * - `'always'` will add a trailing slash if not present\n * - `'never'` will remove the trailing slash if present\n * - `'preserve'` will not modify the trailing slash.\n *\n * @default 'never'\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)\n */\n trailingSlash?: TTrailingSlashOption\n /**\n * While usually automatic, sometimes it can be useful to force the router into a server-side state, e.g. when using the router in a non-browser environment that has access to a global.document object.\n *\n * @default typeof document !== 'undefined'\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)\n */\n isServer?: boolean\n\n /**\n * @default false\n */\n isShell?: boolean\n\n /**\n * @default false\n */\n isPrerendering?: boolean\n\n /**\n * The default `ssr` a route should use if no `ssr` is provided.\n *\n * @default true\n */\n defaultSsr?: SSROption\n\n search?: {\n /**\n * Configures how unknown search params (= not returned by any `validateSearch`) are treated.\n *\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)\n */\n strict?: boolean\n }\n\n /**\n * Configures whether structural sharing is enabled by default for fine-grained selectors.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstructuralsharing-property)\n */\n defaultStructuralSharing?: TDefaultStructuralSharingOption\n\n /**\n * Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)\n */\n pathParamsAllowedCharacters?: Array<\n ';' | ':' | '@' | '&' | '=' | '+' | '$' | ','\n >\n\n defaultRemountDeps?: DefaultRemountDepsFn<TRouteTree>\n\n /**\n * If `true`, scroll restoration will be enabled\n *\n * @default false\n */\n scrollRestoration?:\n | boolean\n | ((opts: { location: ParsedLocation }) => boolean)\n\n /**\n * A function that will be called to get the key for the scroll restoration cache.\n *\n * @default (location) => location.href\n */\n getScrollRestorationKey?: (location: ParsedLocation) => string\n /**\n * The default behavior for scroll restoration.\n *\n * @default 'auto'\n */\n scrollRestorationBehavior?: ScrollBehavior\n /**\n * An array of selectors that will be used to scroll to the top of the page in addition to `window`\n *\n * @default ['window']\n */\n scrollToTopSelectors?: Array<string | (() => Element | null | undefined)>\n\n /**\n * When `true`, disables the global catch boundary that normally wraps all route matches.\n * This allows unhandled errors to bubble up to top-level error handlers in the browser.\n *\n * Useful for testing tools (like Storybook Test Runner), error reporting services,\n * and debugging scenarios where you want errors to reach the browser's global error handlers.\n *\n * @default false\n */\n disableGlobalCatchBoundary?: boolean\n\n serializationAdapters?: ReadonlyArray<AnySerializationAdapter>\n /**\n * Configures how the router will rewrite the location between the actual href and the internal href of the router.\n *\n * @default undefined\n * @description You can provide a custom rewrite pair (in/out).\n * This is useful for shifting data from the origin to the path (for things like subdomain routing), or other advanced use cases.\n */\n rewrite?: LocationRewrite\n origin?: string\n ssr?: {\n nonce?: string\n }\n}\n\nexport type LocationRewrite = {\n /**\n * A function that will be called to rewrite the URL before it is interpreted by the router from the history instance.\n *\n * @default undefined\n */\n input?: LocationRewriteFunction\n /**\n * A function that will be called to rewrite the URL before it is committed to the actual history instance from the router.\n *\n * @default undefined\n */\n output?: LocationRewriteFunction\n}\n\n/**\n * A function that will be called to rewrite the URL.\n *\n * @param url The URL to rewrite.\n * @returns The rewritten URL (as a URL instance or full href string) or undefined if no rewrite is needed.\n */\nexport type LocationRewriteFunction = ({\n url,\n}: {\n url: URL\n}) => undefined | string | URL\n\nexport interface RouterState<\n in out TRouteTree extends AnyRoute = AnyRoute,\n in out TRouteMatch = MakeRouteMatchUnion,\n> {\n status: 'pending' | 'idle'\n loadedAt: number\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?: AnyRedirect\n}\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<ParsedHistoryState, 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<ParsedHistoryState, HistoryState>\n unmaskOnReload?: boolean\n }\n from?: string\n href?: string\n _fromLocation?: ParsedLocation\n unsafeRelative?: 'path'\n _isNavigate?: boolean\n}\n\ntype NavigationEventInfo = {\n fromLocation?: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n hrefChanged: boolean\n hashChanged: boolean\n}\n\nexport interface RouterEvents {\n onBeforeNavigate: {\n type: 'onBeforeNavigate'\n } & NavigationEventInfo\n onBeforeLoad: {\n type: 'onBeforeLoad'\n } & NavigationEventInfo\n onLoad: {\n type: 'onLoad'\n } & NavigationEventInfo\n onResolved: {\n type: 'onResolved'\n } & NavigationEventInfo\n onBeforeRouteMount: {\n type: 'onBeforeRouteMount'\n } & NavigationEventInfo\n onRendered: {\n type: 'onRendered'\n } & NavigationEventInfo\n}\n\nexport type RouterEvent = RouterEvents[keyof RouterEvents]\n\nexport type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void\n\nexport type RouterListener<TRouterEvent extends RouterEvent> = {\n eventType: TRouterEvent['type']\n fn: ListenerFn<TRouterEvent>\n}\n\nexport type SubscribeFn = <TType extends keyof RouterEvents>(\n eventType: TType,\n fn: ListenerFn<RouterEvents[TType]>,\n) => () => void\n\nexport interface MatchRoutesOpts {\n preload?: boolean\n throwOnError?: boolean\n _buildLocation?: boolean\n dest?: BuildNextOptions\n}\n\nexport type InferRouterContext<TRouteTree extends AnyRoute> =\n TRouteTree['types']['routerContext']\n\nexport type RouterContextOptions<TRouteTree extends AnyRoute> =\n AnyContext extends InferRouterContext<TRouteTree>\n ? {\n context?: InferRouterContext<TRouteTree>\n }\n : {\n context: InferRouterContext<TRouteTree>\n }\n\nexport type RouterConstructorOptions<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n TDehydrated extends Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n 'context' | 'serializationAdapters' | 'defaultSsr'\n> &\n RouterContextOptions<TRouteTree>\n\nexport type PreloadRouteFn<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n> = <\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<\n RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory\n >,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n >,\n) => Promise<Array<AnyRouteMatch> | undefined>\n\nexport type MatchRouteFn<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n> = <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string | undefined = undefined,\n TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n>(\n location: ToOptions<\n RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory\n >,\n TFrom,\n TTo\n >,\n opts?: MatchRouteOptions,\n) => false | RouteById<TRouteTree, TResolved>['types']['allParams']\n\nexport type UpdateFn<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n TDehydrated extends Record<string, any>,\n> = (\n newOptions: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n) => void\n\nexport type InvalidateFn<TRouter extends AnyRouter> = (opts?: {\n filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean\n sync?: boolean\n forcePending?: boolean\n}) => Promise<void>\n\nexport type ParseLocationFn<TRouteTree extends AnyRoute> = (\n locationToParse: HistoryLocation,\n previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>,\n) => ParsedLocation<FullSearchSchema<TRouteTree>>\n\nexport type GetMatchRoutesFn = (\n pathname: string,\n routePathname: string | undefined,\n) => {\n matchedRoutes: Array<AnyRoute>\n routeParams: Record<string, string>\n foundRoute: AnyRoute | undefined\n}\n\nexport type EmitFn = (routerEvent: RouterEvent) => void\n\nexport type LoadFn = (opts?: { sync?: boolean }) => Promise<void>\n\nexport type CommitLocationFn = ({\n viewTransition,\n ignoreBlocker,\n ...next\n}: ParsedLocation & CommitLocationOptions) => Promise<void>\n\nexport type StartTransitionFn = (fn: () => void) => void\n\nexport interface MatchRoutesFn {\n (\n pathname: string,\n locationSearch?: AnySchema,\n opts?: MatchRoutesOpts,\n ): Array<MakeRouteMatchUnion>\n /**\n * @deprecated use the following signature instead\n */\n (next: ParsedLocation, opts?: MatchRoutesOpts): Array<AnyRouteMatch>\n (\n pathnameOrNext: string | ParsedLocation,\n locationSearchOrOpts?: AnySchema | MatchRoutesOpts,\n opts?: MatchRoutesOpts,\n ): Array<AnyRouteMatch>\n}\n\nexport type GetMatchFn = (matchId: string) => AnyRouteMatch | undefined\n\nexport type UpdateMatchFn = (\n id: string,\n updater: (match: AnyRouteMatch) => AnyRouteMatch,\n) => void\n\nexport type LoadRouteChunkFn = (route: AnyRoute) => Promise<Array<void>>\n\nexport type ResolveRedirect = (err: AnyRedirect) => ResolvedRedirect\n\nexport type ClearCacheFn<TRouter extends AnyRouter> = (opts?: {\n filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean\n}) => void\n\nexport interface ServerSsr {\n injectedHtml: Array<InjectedHtmlEntry>\n injectHtml: (getHtml: () => string | Promise<string>) => Promise<void>\n injectScript: (\n getScript: () => string | Promise<string>,\n opts?: { logScript?: boolean },\n ) => Promise<void>\n isDehydrated: () => boolean\n onRenderFinished: (listener: () => void) => void\n dehydrate: () => Promise<void>\n takeBufferedScripts: () => string | undefined\n}\n\nexport type AnyRouterWithContext<TContext> = RouterCore<\n AnyRouteWithContext<TContext>,\n any,\n any,\n any,\n any\n>\n\nexport type AnyRouter = RouterCore<any, any, any, any, any>\n\nexport interface ViewTransitionOptions {\n types:\n | Array<string>\n | ((locationChangeInfo: {\n fromLocation?: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n hrefChanged: boolean\n hashChanged: boolean\n }) => Array<string> | false)\n}\n\n// TODO where is this used? can we remove this?\n/**\n * Convert an unknown error into a minimal, serializable object.\n * Includes name and message (and stack in development).\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\n/** Options for configuring trailing-slash behavior. */\nexport const trailingSlashOptions = {\n always: 'always',\n never: 'never',\n preserve: 'preserve',\n} as const\n\nexport type TrailingSlashOption =\n (typeof trailingSlashOptions)[keyof typeof trailingSlashOptions]\n\n/**\n * Compute whether path, href or hash changed between previous and current\n * resolved locations in router state.\n */\nexport function getLocationChangeInfo(routerState: {\n resolvedLocation?: ParsedLocation\n location: ParsedLocation\n}) {\n const fromLocation = routerState.resolvedLocation\n const toLocation = routerState.location\n const pathChanged = fromLocation?.pathname !== toLocation.pathname\n const hrefChanged = fromLocation?.href !== toLocation.href\n const hashChanged = fromLocation?.hash !== toLocation.hash\n return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged }\n}\n\nexport type CreateRouterFn = <\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption = 'never',\n TDefaultStructuralSharingOption extends boolean = false,\n TRouterHistory extends RouterHistory = RouterHistory,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>(\n options: undefined extends number\n ? 'strictNullChecks must be enabled in tsconfig.json'\n : RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n) => RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n>\n\n/**\n * Core, framework-agnostic router engine that powers TanStack Router.\n *\n * Provides navigation, matching, loading, preloading, caching and event APIs\n * used by framework adapters (React/Solid). Prefer framework helpers like\n * `createRouter` in app code.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType\n */\nexport class RouterCore<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption,\n in out TDefaultStructuralSharingOption extends boolean,\n in out TRouterHistory extends RouterHistory = RouterHistory,\n in out TDehydrated 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 | ViewTransitionOptions = undefined\n isViewTransitionTypesSupported?: boolean = undefined\n subscribers = new Set<RouterListener<RouterEvent>>()\n viewTransitionPromise?: ControlledPromise<true>\n isScrollRestoring = false\n isScrollRestorationSetup = false\n\n // Must build in constructor\n __store!: Store<RouterState<TRouteTree>>\n options!: PickAsRequired<\n RouterOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n 'stringifySearch' | 'parseSearch' | 'context'\n >\n history!: TRouterHistory\n rewrite?: LocationRewrite\n origin?: string\n latestLocation!: ParsedLocation<FullSearchSchema<TRouteTree>>\n pendingBuiltLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>\n basepath!: string\n routeTree!: TRouteTree\n routesById!: RoutesById<TRouteTree>\n routesByPath!: RoutesByPath<TRouteTree>\n flatRoutes!: Array<AnyRoute>\n isServer!: boolean\n pathParamsDecodeCharMap?: Map<string, string>\n\n /**\n * @deprecated Use the `createRouter` function instead\n */\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n ) {\n this.update({\n defaultPreloadDelay: 50,\n defaultPendingMs: 1000,\n defaultPendingMinMs: 500,\n context: undefined!,\n ...options,\n caseSensitive: options.caseSensitive ?? false,\n notFoundMode: options.notFoundMode ?? 'fuzzy',\n stringifySearch: options.stringifySearch ?? defaultStringifySearch,\n parseSearch: options.parseSearch ?? defaultParseSearch,\n })\n\n if (typeof document !== 'undefined') {\n self.__TSR_ROUTER__ = this\n }\n }\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 startTransition: StartTransitionFn = (fn) => fn()\n\n isShell() {\n return !!this.options.isShell\n }\n\n isPrerendering() {\n return !!this.options.isPrerendering\n }\n\n update: UpdateFn<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n > = (newOptions) => {\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/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.',\n )\n }\n\n const prevOptions = this.options\n const prevBasepath = this.basepath ?? prevOptions?.basepath ?? '/'\n const basepathWasUnset = this.basepath === undefined\n const prevRewriteOption = prevOptions?.rewrite\n\n this.options = {\n ...prevOptions,\n ...newOptions,\n }\n\n this.isServer = this.options.isServer ?? typeof document === 'undefined'\n\n this.pathParamsDecodeCharMap = this.options.pathParamsAllowedCharacters\n ? new Map(\n this.options.pathParamsAllowedCharacters.map((char) => [\n encodeURIComponent(char),\n char,\n ]),\n )\n : undefined\n\n if (\n !this.history ||\n (this.options.history && this.options.history !== this.history)\n ) {\n if (!this.options.history) {\n if (!this.isServer) {\n this.history = createBrowserHistory() as TRouterHistory\n }\n } else {\n this.history = this.options.history\n }\n }\n\n this.origin = this.options.origin\n if (!this.origin) {\n if (!this.isServer && window?.origin && window.origin !== 'null') {\n this.origin = window.origin\n } else {\n // fallback for the server, can be overridden by calling router.update({origin}) on the server\n this.origin = 'http://localhost'\n }\n }\n\n if (this.history) {\n this.updateLatestLocation()\n }\n\n if (this.options.routeTree !== this.routeTree) {\n this.routeTree = this.options.routeTree as TRouteTree\n this.buildRouteTree()\n }\n\n if (!this.__store && this.latestLocation) {\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 setupScrollRestoration(this)\n }\n\n let needsLocationUpdate = false\n const nextBasepath = this.options.basepath ?? '/'\n const nextRewriteOption = this.options.rewrite\n const basepathChanged = basepathWasUnset || prevBasepath !== nextBasepath\n const rewriteChanged = prevRewriteOption !== nextRewriteOption\n\n if (basepathChanged || rewriteChanged) {\n this.basepath = nextBasepath\n\n const rewrites: Array<LocationRewrite> = []\n if (trimPath(nextBasepath) !== '') {\n rewrites.push(\n rewriteBasepath({\n basepath: nextBasepath,\n }),\n )\n }\n if (nextRewriteOption) {\n rewrites.push(nextRewriteOption)\n }\n\n this.rewrite =\n rewrites.length === 0\n ? undefined\n : rewrites.length === 1\n ? rewrites[0]\n : composeRewrites(rewrites)\n\n if (this.history) {\n this.updateLatestLocation()\n }\n\n needsLocationUpdate = true\n }\n\n if (needsLocationUpdate && this.__store) {\n this.__store.state = {\n ...this.state,\n location: this.latestLocation,\n }\n }\n\n if (\n typeof window !== 'undefined' &&\n 'CSS' in window &&\n typeof window.CSS?.supports === 'function'\n ) {\n this.isViewTransitionTypesSupported = window.CSS.supports(\n 'selector(:active-view-transition-type(a)',\n )\n }\n }\n\n get state(): RouterState<TRouteTree> {\n return this.__store.state\n }\n\n updateLatestLocation = () => {\n this.latestLocation = this.parseLocation(\n this.history.location,\n this.latestLocation,\n )\n }\n\n buildRouteTree = () => {\n const { routesById, routesByPath, flatRoutes } = processRouteTree({\n routeTree: this.routeTree,\n initRoute: (route, i) => {\n route.init({\n originalIndex: i,\n })\n },\n })\n\n this.routesById = routesById as RoutesById<TRouteTree>\n this.routesByPath = routesByPath as RoutesByPath<TRouteTree>\n this.flatRoutes = flatRoutes as Array<AnyRoute>\n\n const notFoundRoute = this.options.notFoundRoute\n\n if (notFoundRoute) {\n notFoundRoute.init({\n originalIndex: 99999999999,\n })\n this.routesById[notFoundRoute.id] = notFoundRoute\n }\n }\n\n /**\n * Subscribe to router lifecycle events like `onBeforeNavigate`, `onLoad`,\n * `onResolved`, etc. Returns an unsubscribe function.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterEventsType\n */\n subscribe: SubscribeFn = (eventType, fn) => {\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: EmitFn = (routerEvent) => {\n this.subscribers.forEach((listener) => {\n if (listener.eventType === routerEvent.type) {\n listener.fn(routerEvent)\n }\n })\n }\n\n /**\n * Parse a HistoryLocation into a strongly-typed ParsedLocation using the\n * current router options, rewrite rules and search parser/stringifier.\n */\n parseLocation: ParseLocationFn<TRouteTree> = (\n locationToParse,\n previousLocation,\n ) => {\n const parse = ({\n href,\n state,\n }: HistoryLocation): ParsedLocation<FullSearchSchema<TRouteTree>> => {\n // Before we do any processing, we need to allow rewrites to modify the URL\n // build up the full URL by combining the href from history with the router's origin\n const fullUrl = new URL(href, this.origin)\n const url = executeRewriteInput(this.rewrite, fullUrl)\n\n const parsedSearch = this.options.parseSearch(url.search)\n const searchStr = this.options.stringifySearch(parsedSearch)\n // Make sure our final url uses the re-stringified pathname, search, and has for consistency\n // (We were already doing this, so just keeping it for now)\n url.search = searchStr\n\n const fullPath = url.href.replace(url.origin, '')\n\n const { pathname, hash } = url\n\n return {\n href: fullPath,\n publicHref: href,\n url: url.href,\n pathname: decodePath(pathname),\n searchStr,\n search: replaceEqualDeep(previousLocation?.search, parsedSearch) as any,\n hash: hash.split('#').reverse()[0] ?? '',\n state: replaceEqualDeep(previousLocation?.state, state),\n }\n }\n\n const location = parse(locationToParse)\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 // TODO: Remove in v2 - use __TSR_key instead\n parsedTempLocation.state.__TSR_key = location.state.__TSR_key\n\n delete parsedTempLocation.state.__tempLocation\n\n return {\n ...parsedTempLocation,\n maskedLocation: location,\n }\n }\n return location\n }\n\n /** Resolve a path against the router basepath and trailing-slash policy. */\n resolvePathWithBase = (from: string, path: string) => {\n const resolvedPath = resolvePath({\n base: from,\n to: cleanPath(path),\n trailingSlash: this.options.trailingSlash,\n parseCache: this.parsePathnameCache,\n })\n return resolvedPath\n }\n\n get looseRoutesById() {\n return this.routesById as Record<string, AnyRoute>\n }\n\n matchRoutes: MatchRoutesFn = (\n pathnameOrNext: string | ParsedLocation,\n locationSearchOrOpts?: AnySchema | MatchRoutesOpts,\n opts?: MatchRoutesOpts,\n ) => {\n if (typeof pathnameOrNext === 'string') {\n return this.matchRoutesInternal(\n {\n pathname: pathnameOrNext,\n search: locationSearchOrOpts,\n } as ParsedLocation,\n opts,\n )\n }\n\n return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts)\n }\n\n private matchRoutesInternal(\n next: ParsedLocation,\n opts?: MatchRoutesOpts,\n ): Array<AnyRouteMatch> {\n const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes(\n next.pathname,\n opts?.dest?.to as string,\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(next.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 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 const matches: Array<AnyRouteMatch> = []\n\n const getParentContext = (parentMatch?: AnyRouteMatch) => {\n const parentMatchId = parentMatch?.id\n\n const parentContext = !parentMatchId\n ? ((this.options.context as any) ?? undefined)\n : (parentMatch.context ?? this.options.context ?? undefined)\n\n return parentContext\n }\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, strictMatchSearch, searchError]: [\n Record<string, any>,\n Record<string, any>,\n any,\n ] = (() => {\n // Validate the search params and stabilize them\n const parentSearch = parentMatch?.search ?? next.search\n const parentStrictSearch = parentMatch?._strictSearch ?? undefined\n\n try {\n const strictSearch =\n validateSearch(route.options.validateSearch, { ...parentSearch }) ??\n undefined\n\n return [\n {\n ...parentSearch,\n ...strictSearch,\n },\n { ...parentStrictSearch, ...strictSearch },\n undefined,\n ]\n } catch (err: any) {\n let searchParamError = err\n if (!(err instanceof SearchParamError)) {\n searchParamError = new SearchParamError(err.message, {\n cause: err,\n })\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, usedParams } = interpolatePath({\n path: route.fullPath,\n params: routeParams,\n decodeCharMap: this.pathParamsDecodeCharMap,\n })\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\n // Existing matches are matches that are already loaded along with\n // pending matches that are still loading\n const matchId =\n // route.id for disambiguation\n route.id +\n // interpolatedPath for param changes\n interpolatedPath +\n // explicit deps\n loaderDepsHash\n\n const existingMatch = this.getMatch(matchId)\n\n const previousMatch = this.state.matches.find(\n (d) => d.routeId === route.id,\n )\n\n const strictParams = existingMatch?._strictParams ?? usedParams\n\n let paramsError: PathParamError | undefined = undefined\n\n if (!existingMatch) {\n const strictParseParams =\n route.options.params?.parse ?? route.options.parseParams\n\n if (strictParseParams) {\n try {\n Object.assign(\n strictParams,\n strictParseParams(strictParams as Record<string, string>),\n )\n } catch (err: any) {\n paramsError = new PathParamError(err.message, {\n cause: err,\n })\n\n if (opts?.throwOnError) {\n throw paramsError\n }\n }\n }\n }\n\n Object.assign(routeParams, strictParams)\n\n const cause = previousMatch ? 'stay' : 'enter'\n\n let match: AnyRouteMatch\n\n if (existingMatch) {\n match = {\n ...existingMatch,\n cause,\n params: previousMatch\n ? replaceEqualDeep(previousMatch.params, routeParams)\n : routeParams,\n _strictParams: strictParams,\n search: previousMatch\n ? replaceEqualDeep(previousMatch.search, preMatchSearch)\n : replaceEqualDeep(existingMatch.search, preMatchSearch),\n _strictSearch: strictMatchSearch,\n }\n } else {\n const status =\n route.options.loader ||\n route.options.beforeLoad ||\n route.lazyFn ||\n routeNeedsPreload(route)\n ? 'pending'\n : 'success'\n\n match = {\n id: matchId,\n index,\n routeId: route.id,\n params: previousMatch\n ? replaceEqualDeep(previousMatch.params, routeParams)\n : routeParams,\n _strictParams: strictParams,\n pathname: interpolatedPath,\n updatedAt: Date.now(),\n search: previousMatch\n ? replaceEqualDeep(previousMatch.search, preMatchSearch)\n : preMatchSearch,\n _strictSearch: strictMatchSearch,\n searchError: undefined,\n status,\n isFetching: false,\n error: undefined,\n paramsError,\n __routeContext: undefined,\n _nonReactive: {\n loadPromise: createControlledPromise(),\n },\n __beforeLoadContext: undefined,\n context: {},\n abortController: new AbortController(),\n fetchCount: 0,\n cause,\n loaderDeps: previousMatch\n ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps)\n : loaderDeps,\n invalid: false,\n preload: false,\n links: undefined,\n scripts: undefined,\n headScripts: undefined,\n meta: undefined,\n staticData: route.options.staticData || {},\n fullPath: route.fullPath,\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 // update the searchError if there is one\n match.searchError = searchError\n\n const parentContext = getParentContext(parentMatch)\n\n match.context = {\n ...parentContext,\n ...match.__routeContext,\n ...match.__beforeLoadContext,\n }\n\n matches.push(match)\n })\n\n matches.forEach((match, index) => {\n const route = this.looseRoutesById[match.routeId]!\n const existingMatch = this.getMatch(match.id)\n\n // only execute `context` if we are not calling from router.buildLocation\n\n if (!existingMatch && opts?._buildLocation !== true) {\n const parentMatch = matches[index - 1]\n const parentContext = getParentContext(parentMatch)\n\n // Update the match's context\n\n if (route.options.context) {\n const contextFnContext: RouteContextOptions<any, any, any, any> = {\n deps: match.loaderDeps,\n params: match.params,\n context: parentContext ?? {},\n location: next,\n navigate: (opts: any) =>\n this.navigate({ ...opts, _fromLocation: next }),\n buildLocation: this.buildLocation,\n cause: match.cause,\n abortController: match.abortController,\n preload: !!match.preload,\n matches,\n }\n // Get the route context\n match.__routeContext =\n route.options.context(contextFnContext) ?? undefined\n }\n\n match.context = {\n ...parentContext,\n ...match.__routeContext,\n ...match.__beforeLoadContext,\n }\n }\n })\n\n return matches\n }\n\n /** a cache for `parsePathname` */\n private parsePathnameCache: ParsePathnameCache = createLRUCache(1000)\n\n getMatchedRoutes: GetMatchRoutesFn = (\n pathname: string,\n routePathname: string | undefined,\n ) => {\n return getMatchedRoutes({\n pathname,\n routePathname,\n caseSensitive: this.options.caseSensitive,\n routesByPath: this.routesByPath,\n routesById: this.routesById,\n flatRoutes: this.flatRoutes,\n parseCache: this.parsePathnameCache,\n })\n }\n\n cancelMatch = (id: string) => {\n const match = this.getMatch(id)\n\n if (!match) return\n\n match.abortController.abort()\n clearTimeout(match._nonReactive.pendingTimeout)\n match._nonReactive.pendingTimeout = undefined\n }\n\n cancelMatches = () => {\n const currentPendingMatches = this.state.matches.filter(\n (match) => match.status === 'pending',\n )\n const currentLoadingMatches = this.state.matches.filter(\n (match) => match.isFetching === 'loader',\n )\n const matchesToCancelArray = new Set([\n ...(this.state.pendingMatches ?? []),\n ...currentPendingMatches,\n ...currentLoadingMatches,\n ])\n matchesToCancelArray.forEach((match) => {\n this.cancelMatch(match.id)\n })\n }\n\n /**\n * Build the next ParsedLocation from navigation options without committing.\n * Resolves `to`/`from`, params/search/hash/state, applies search validation\n * and middlewares, and returns a stable, stringified location object.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType#buildlocation-method\n */\n buildLocation: BuildLocationFn = (opts) => {\n const build = (\n dest: BuildNextOptions & {\n unmaskOnReload?: boolean\n } = {},\n ): ParsedLocation => {\n // We allow the caller to override the current location\n const currentLocation =\n dest._fromLocation || this.pendingBuiltLocation || this.latestLocation\n\n const allCurrentLocationMatches = this.matchRoutes(currentLocation, {\n _buildLocation: true,\n })\n\n // Now let's find the starting pathname\n // This should default to the current location if no from is provided\n const lastMatch = last(allCurrentLocationMatches)!\n\n // check that from path exists in the current route tree\n // do this check only on navigations during test or development\n if (\n dest.from &&\n process.env.NODE_ENV !== 'production' &&\n dest._isNavigate\n ) {\n const allFromMatches = this.getMatchedRoutes(\n dest.from,\n undefined,\n ).matchedRoutes\n\n const matchedFrom = findLast(allCurrentLocationMatches, (d) => {\n return comparePaths(d.fullPath, dest.from!)\n })\n\n const matchedCurrent = findLast(allFromMatches, (d) => {\n return comparePaths(d.fullPath, lastMatch.fullPath)\n })\n\n // for from to be invalid it shouldn't just be unmatched to currentLocation\n // but the currentLocation should also be unmatched to from\n if (!matchedFrom && !matchedCurrent) {\n console.warn(`Could not find match for from: ${dest.from}`)\n }\n }\n\n const defaultedFromPath =\n dest.unsafeRelative === 'path'\n ? currentLocation.pathname\n : (dest.from ?? lastMatch.fullPath)\n\n // ensure this includes the basePath if set\n const fromPath = this.resolvePathWithBase(defaultedFromPath, '.')\n\n // From search should always use the current location\n const fromSearch = lastMatch.search\n // Same with params. It can't hurt to provide as many as possible\n const fromParams = { ...lastMatch.params }\n\n // Resolve the next to\n // ensure this includes the basePath if set\n const nextTo = dest.to\n ? this.resolvePathWithBase(fromPath, `${dest.to}`)\n : this.resolvePathWithBase(fromPath, '.')\n\n // Resolve the next params\n const nextParams =\n dest.params === false || dest.params === null\n ? {}\n : (dest.params ?? true) === true\n ? fromParams\n : Object.assign(\n fromParams,\n functionalUpdate(dest.params as any, fromParams),\n )\n\n // Interpolate the path first to get the actual resolved path, then match against that\n const interpolatedNextTo = interpolatePath({\n path: nextTo,\n params: nextParams,\n parseCache: this.parsePathnameCache,\n }).interpolatedPath\n\n const destRoutes = this.matchRoutes(interpolatedNextTo, undefined, {\n _buildLocation: true,\n }).map((d) => this.looseRoutesById[d.routeId]!)\n\n // If there are any params, we need to stringify them\n if (Object.keys(nextParams).length > 0) {\n for (const route of destRoutes) {\n const fn =\n route.options.params?.stringify ?? route.options.stringifyParams\n if (fn) {\n Object.assign(nextParams, fn(nextParams))\n }\n }\n }\n\n const nextPathname = opts.leaveParams\n ? // Use the original template path for interpolation\n // This preserves the original parameter syntax including optional parameters\n nextTo\n : decodePath(\n interpolatePath({\n path: nextTo,\n params: nextParams,\n decodeCharMap: this.pathParamsDecodeCharMap,\n parseCache: this.parsePathnameCache,\n }).interpolatedPath,\n )\n\n // Resolve the next search\n let nextSearch = fromSearch\n if (opts._includeValidateSearch && this.options.search?.strict) {\n const validatedSearch = {}\n destRoutes.forEach((route) => {\n if (route.options.validateSearch) {\n try {\n Object.assign(\n validatedSearch,\n validateSearch(route.options.validateSearch, {\n ...validatedSearch,\n ...nextSearch,\n }),\n )\n } catch {\n // ignore errors here because they are already handled in matchRoutes\n }\n }\n })\n nextSearch = validatedSearch\n }\n\n nextSearch = applySearchMiddleware({\n search: nextSearch,\n dest,\n destRoutes,\n _includeValidateSearch: opts._includeValidateSearch,\n })\n\n // Replace the equal deep\n nextSearch = replaceEqualDeep(fromSearch, nextSearch)\n\n // Stringify the next search\n const searchStr = this.options.stringifySearch(nextSearch)\n\n // Resolve the next hash\n const hash =\n dest.hash === true\n ? currentLocation.hash\n : dest.hash\n ? functionalUpdate(dest.hash, currentLocation.hash)\n : undefined\n\n // Resolve the next hash string\n const hashStr = hash ? `#${hash}` : ''\n\n // Resolve the next state\n let nextState =\n dest.state === true\n ? currentLocation.state\n : dest.state\n ? functionalUpdate(dest.state, currentLocation.state)\n : {}\n\n // Replace the equal deep\n nextState = replaceEqualDeep(currentLocation.state, nextState)\n\n // Create the full path of the location\n const fullPath = `${nextPathname}${searchStr}${hashStr}`\n\n // Create the new href with full origin\n const url = new URL(fullPath, this.origin)\n\n // If a rewrite function is provided, use it to rewrite the URL\n const rewrittenUrl = executeRewriteOutput(this.rewrite, url)\n\n return {\n publicHref:\n rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash,\n href: fullPath,\n url: rewrittenUrl.href,\n pathname: nextPathname,\n search: nextSearch,\n searchStr,\n state: nextState as any,\n hash: hash ?? '',\n unmaskOnReload: dest.unmaskOnReload,\n }\n }\n\n const buildWithMatches = (\n dest: BuildNextOptions = {},\n maskedDest?: BuildNextOptions,\n ) => {\n const next = build(dest)\n\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(\n next.pathname,\n {\n to: d.from,\n caseSensitive: false,\n fuzzy: false,\n },\n this.parsePathnameCache,\n )\n\n if (match) {\n params = match\n return true\n }\n\n return false\n })\n\n if (foundMask) {\n const { from: _from, ...maskProps } = foundMask\n maskedDest = {\n from: opts.from,\n ...maskProps,\n params,\n }\n maskedNext = build(maskedDest)\n }\n }\n\n if (maskedNext) {\n next.maskedLocation = maskedNext\n }\n\n return next\n }\n\n if (opts.mask) {\n return buildWithMatches(opts, {\n from: opts.from,\n ...opts.mask,\n })\n }\n\n return buildWithMatches(opts)\n }\n\n commitLocationPromise: undefined | ControlledPromise<void>\n\n /**\n * Commit a previously built location to history (push/replace), optionally\n * using view transitions and scroll restoration options.\n */\n commitLocation: CommitLocationFn = ({\n viewTransition,\n ignoreBlocker,\n ...next\n }) => {\n const isSameState = () => {\n // the following props are ignored but may still be provided when navigating,\n // temporarily add the previous values to the next state so they don't affect\n // the comparison\n const ignoredProps = [\n 'key', // TODO: Remove in v2 - use __TSR_key instead\n '__TSR_key',\n '__TSR_index',\n '__hashScrollIntoViewOptions',\n ] as const\n ignoredProps.forEach((prop) => {\n ;(next.state as any)[prop] = this.latestLocation.state[prop]\n })\n const isEqual = deepEqual(next.state, this.latestLocation.state)\n ignoredProps.forEach((prop) => {\n delete next.state[prop]\n })\n return isEqual\n }\n\n const isSameUrl =\n trimPathRight(this.latestLocation.href) === trimPathRight(next.href)\n\n const previousCommitPromise = this.commitLocationPromise\n this.commitLocationPromise = createControlledPromise<void>(() => {\n previousCommitPromise?.resolve()\n })\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, hashScrollIntoView, ...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 __TSR_key: undefined!,\n key: undefined!, // TODO: Remove in v2 - use __TSR_key instead\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 nextHistory.state.__hashScrollIntoViewOptions =\n hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true\n\n this.shouldViewTransition = viewTransition\n\n this.history[next.replace ? 'replace' : 'push'](\n nextHistory.publicHref,\n nextHistory.state,\n { ignoreBlocker },\n )\n }\n\n this.resetNextScroll = next.resetScroll ?? true\n\n if (!this.history.subscribers.size) {\n this.load()\n }\n\n return this.commitLocationPromise\n }\n\n /** Convenience helper: build a location from options, then commit it. */\n buildAndCommitLocation = ({\n replace,\n resetScroll,\n hashScrollIntoView,\n viewTransition,\n ignoreBlocker,\n href,\n ...rest\n }: BuildNextOptions & CommitLocationOptions = {}) => {\n if (href) {\n const currentIndex = this.history.location.state.__TSR_index\n\n const parsed = parseHref(href, {\n __TSR_index: replace ? currentIndex : currentIndex + 1,\n })\n rest.to = parsed.pathname\n rest.search = this.options.parseSearch(parsed.search)\n // remove the leading `#` from the hash\n rest.hash = parsed.hash.slice(1)\n }\n\n const location = this.buildLocation({\n ...(rest as any),\n _includeValidateSearch: true,\n })\n\n this.pendingBuiltLocation = location as ParsedLocation<\n FullSearchSchema<TRouteTree>\n >\n\n const commitPromise = this.commitLocation({\n ...location,\n viewTransition,\n replace,\n resetScroll,\n hashScrollIntoView,\n ignoreBlocker,\n })\n\n // Clear pending location after commit starts\n // We do this on next microtask to allow synchronous navigate calls to chain\n Promise.resolve().then(() => {\n if (this.pendingBuiltLocation === location) {\n this.pendingBuiltLocation = undefined\n }\n })\n\n return commitPromise\n }\n\n /**\n * Imperatively navigate using standard `NavigateOptions`. When `reloadDocument`\n * or an absolute `href` is provided, performs a full document navigation.\n * Otherwise, builds and commits a client-side location.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType\n */\n navigate: NavigateFn = ({ to, reloadDocument, href, ...rest }) => {\n if (!reloadDocument && href) {\n try {\n new URL(`${href}`)\n reloadDocument = true\n } catch {}\n }\n\n if (reloadDocument) {\n if (!href) {\n const location = this.buildLocation({ to, ...rest } as any)\n href = location.url\n }\n if (rest.replace) {\n window.location.replace(href)\n } else {\n window.location.href = href\n }\n return Promise.resolve()\n }\n\n return this.buildAndCommitLocation({\n ...rest,\n href,\n to: to as string,\n _isNavigate: true,\n })\n }\n\n latestLoadPromise: undefined | Promise<void>\n\n beforeLoad = () => {\n // Cancel any pending matches\n this.cancelMatches()\n this.updateLatestLocation()\n\n if (this.isServer) {\n // for SPAs on the initial load, this is handled by the Transitioner\n const nextLocation = this.buildLocation({\n to: this.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Normalize URLs for comparison to handle encoding differences\n // Browser history always stores encoded URLs while buildLocation may produce decoded URLs\n const normalizeUrl = (url: string) => {\n try {\n return encodeURI(decodeURI(url))\n } catch {\n return url\n }\n }\n\n if (\n trimPath(normalizeUrl(this.latestLocation.href)) !==\n trimPath(normalizeUrl(nextLocation.href))\n ) {\n let href = nextLocation.url\n if (this.origin && href.startsWith(this.origin)) {\n href = href.replace(this.origin, '') || '/'\n }\n\n throw redirect({ href })\n }\n }\n\n // Match the routes\n const pendingMatches = this.matchRoutes(this.latestLocation)\n\n // Ingest the new matches\n this.__store.setState((s) => ({\n ...s,\n status: 'pending',\n statusCode: 200,\n isLoading: true,\n location: this.latestLocation,\n pendingMatches,\n // If a cached moved to pendingMatches, remove it from cachedMatches\n cachedMatches: s.cachedMatches.filter(\n (d) => !pendingMatches.some((e) => e.id === d.id),\n ),\n }))\n }\n\n load: LoadFn = async (opts?: { sync?: boolean }): Promise<void> => {\n let redirect: AnyRedirect | undefined\n let notFound: NotFoundError | undefined\n let loadPromise: Promise<void>\n\n // eslint-disable-next-line prefer-const\n loadPromise = new Promise<void>((resolve) => {\n this.startTransition(async () => {\n try {\n this.beforeLoad()\n const next = this.latestLocation\n const prevLocation = this.state.resolvedLocation\n\n if (!this.state.redirect) {\n this.emit({\n type: 'onBeforeNavigate',\n ...getLocationChangeInfo({\n resolvedLocation: prevLocation,\n location: next,\n }),\n })\n }\n\n this.emit({\n type: 'onBeforeLoad',\n ...getLocationChangeInfo({\n resolvedLocation: prevLocation,\n location: next,\n }),\n })\n\n await loadMatches({\n router: this,\n sync: opts?.sync,\n matches: this.state.pendingMatches as Array<AnyRouteMatch>,\n location: next,\n updateMatch: this.updateMatch,\n // eslint-disable-next-line @typescript-eslint/require-await\n onReady: async () => {\n // eslint-disable-next-line @typescript-eslint/require-await\n // Wrap batch in framework-specific transition wrapper (e.g., Solid's startTransition)\n this.startTransition(() => {\n 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 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.some((d) => d.id === match.id),\n )\n enteringMatches = newMatches.filter(\n (match) =>\n !previousMatches.some((d) => d.id === match.id),\n )\n stayingMatches = newMatches.filter((match) =>\n previousMatches.some((d) => d.id === match.id),\n )\n\n return {\n ...s,\n isLoading: false,\n loadedAt: Date.now(),\n matches: newMatches,\n pendingMatches: undefined,\n cachedMatches: [\n ...s.cachedMatches,\n ...exitingMatches.filter((d) => d.status !== 'error'),\n ],\n }\n })\n this.clearExpiredCache()\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]?.(\n match,\n )\n })\n })\n })\n })\n },\n })\n } catch (err) {\n if (isRedirect(err)) {\n redirect = err\n if (!this.isServer) {\n this.navigate({\n ...redirect.options,\n replace: true,\n ignoreBlocker: true,\n })\n }\n } else if (isNotFound(err)) {\n notFound = err\n }\n\n this.__store.setState((s) => ({\n ...s,\n statusCode: redirect\n ? redirect.status\n : notFound\n ? 404\n : s.matches.some((d) => d.status === 'error')\n ? 500\n : 200,\n redirect,\n }))\n }\n\n if (this.latestLoadPromise === loadPromise) {\n this.commitLocationPromise?.resolve()\n this.latestLoadPromise = undefined\n this.commitLocationPromise = undefined\n }\n\n resolve()\n })\n })\n\n this.latestLoadPromise = loadPromise\n\n await loadPromise\n\n while (\n (this.latestLoadPromise as any) &&\n loadPromise !== this.latestLoadPromise\n ) {\n await this.latestLoadPromise\n }\n\n let newStatusCode: number | undefined = undefined\n if (this.hasNotFoundMatch()) {\n newStatusCode = 404\n } else if (this.__store.state.matches.some((d) => d.status === 'error')) {\n newStatusCode = 500\n }\n if (newStatusCode !== undefined) {\n this.__store.setState((s) => ({\n ...s,\n statusCode: newStatusCode,\n }))\n }\n }\n\n startViewTransition = (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 if (\n shouldViewTransition &&\n typeof document !== 'undefined' &&\n 'startViewTransition' in document &&\n typeof document.startViewTransition === 'function'\n ) {\n // lib.dom.ts doesn't support viewTransition types variant yet.\n // TODO: Fix this when dom types are updated\n let startViewTransitionParams: any\n\n if (\n typeof shouldViewTransition === 'object' &&\n this.isViewTransitionTypesSupported\n ) {\n const next = this.latestLocation\n const prevLocation = this.state.resolvedLocation\n\n const resolvedViewTransitionTypes =\n typeof shouldViewTransition.types === 'function'\n ? shouldViewTransition.types(\n getLocationChangeInfo({\n resolvedLocation: prevLocation,\n location: next,\n }),\n )\n : shouldViewTransition.types\n\n if (resolvedViewTransitionTypes === false) {\n fn()\n return\n }\n\n startViewTransitionParams = {\n update: fn,\n types: resolvedViewTransitionTypes,\n }\n } else {\n startViewTransitionParams = fn\n }\n\n document.startViewTransition(startViewTransitionParams)\n } else {\n fn()\n }\n }\n\n updateMatch: UpdateMatchFn = (id, updater) => {\n this.startTransition(() => {\n const matchesKey = this.state.pendingMatches?.some((d) => d.id === id)\n ? 'pendingMatches'\n : this.state.matches.some((d) => d.id === id)\n ? 'matches'\n : this.state.cachedMatches.some((d) => d.id === id)\n ? 'cachedMatches'\n : ''\n\n if (matchesKey) {\n this.__store.setState((s) => ({\n ...s,\n [matchesKey]: s[matchesKey]?.map((d) =>\n d.id === id ? updater(d) : d,\n ),\n }))\n }\n })\n }\n\n getMatch: GetMatchFn = (matchId: string): AnyRouteMatch | undefined => {\n const findFn = (d: { id: string }) => d.id === matchId\n return (\n this.state.cachedMatches.find(findFn) ??\n this.state.pendingMatches?.find(findFn) ??\n this.state.matches.find(findFn)\n )\n }\n\n invalidate: InvalidateFn<\n RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >\n > = (opts) => {\n const invalidate = (d: MakeRouteMatch<TRouteTree>) => {\n if (opts?.filter?.(d as MakeRouteMatchUnion<this>) ?? true) {\n return {\n ...d,\n invalid: true,\n ...(opts?.forcePending || d.status === 'error'\n ? ({ status: 'pending', error: undefined } as const)\n : undefined),\n }\n }\n return d\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 this.shouldViewTransition = false\n return this.load({ sync: opts?.sync })\n }\n\n resolveRedirect = (redirect: AnyRedirect): AnyRedirect => {\n if (!redirect.options.href) {\n const location = this.buildLocation(redirect.options)\n let href = location.url\n if (this.origin && href.startsWith(this.origin)) {\n href = href.replace(this.origin, '') || '/'\n }\n redirect.options.href = location.href\n redirect.headers.set('Location', href)\n }\n if (!redirect.headers.get('Location')) {\n redirect.headers.set('Location', redirect.options.href)\n }\n return redirect\n }\n\n clearCache: ClearCacheFn<this> = (opts) => {\n const filter = opts?.filter\n if (filter !== undefined) {\n this.__store.setState((s) => {\n return {\n ...s,\n cachedMatches: s.cachedMatches.filter(\n (m) => !filter(m as MakeRouteMatchUnion<this>),\n ),\n }\n })\n } else {\n this.__store.setState((s) => {\n return {\n ...s,\n cachedMatches: [],\n }\n })\n }\n }\n\n clearExpiredCache = () => {\n // This is where all of the garbage collection magic happens\n const filter = (d: MakeRouteMatch<TRouteTree>) => {\n const route = this.looseRoutesById[d.routeId]!\n\n if (!route.options.loader) {\n return true\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 const isError = d.status === 'error'\n if (isError) return true\n\n const gcEligible = Date.now() - d.updatedAt >= gcTime\n return gcEligible\n }\n this.clearCache({ filter })\n }\n\n loadRouteChunk = loadRouteChunk\n\n preloadRoute: PreloadRouteFn<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory\n > = async (opts) => {\n const next = this.buildLocation(opts as any)\n\n let matches = this.matchRoutes(next, {\n throwOnError: true,\n preload: true,\n dest: opts,\n })\n\n const activeMatchIds = new Set(\n [...this.state.matches, ...(this.state.pendingMatches ?? [])].map(\n (d) => d.id,\n ),\n )\n\n const loadedMatchIds = new Set([\n ...activeMatchIds,\n ...this.state.cachedMatches.map((d) => d.id),\n ])\n\n // If the matches are already loaded, we need to add them to the cachedMatches\n batch(() => {\n matches.forEach((match) => {\n if (!loadedMatchIds.has(match.id)) {\n this.__store.setState((s) => ({\n ...s,\n cachedMatches: [...(s.cachedMatches as any), match],\n }))\n }\n })\n })\n\n try {\n matches = await loadMatches({\n router: this,\n matches,\n location: next,\n preload: true,\n updateMatch: (id, updater) => {\n // Don't update the match if it's currently loaded\n if (activeMatchIds.has(id)) {\n matches = matches.map((d) => (d.id === id ? updater(d) : d))\n } else {\n this.updateMatch(id, updater)\n }\n },\n })\n\n return matches\n } catch (err) {\n if (isRedirect(err)) {\n if (err.options.reloadDocument) {\n return undefined\n }\n\n return await this.preloadRoute({\n ...err.options,\n _fromLocation: next,\n })\n }\n if (!isNotFound(err)) {\n // Preload errors are not fatal, but we should still log them\n console.error(err)\n }\n return undefined\n }\n }\n\n matchRoute: MatchRouteFn<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory\n > = (location, opts) => {\n const matchLocation = {\n ...location,\n to: location.to\n ? this.resolvePathWithBase(\n (location.from || '') as string,\n location.to as string,\n )\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 || this.state.location\n\n const match = matchPathname(\n baseLocation.pathname,\n {\n ...opts,\n to: next.pathname,\n },\n this.parsePathnameCache,\n ) as any\n\n if (!match) {\n return false\n }\n if (location.params) {\n if (!deepEqual(match, location.params, { partial: true })) {\n return false\n }\n }\n\n if (match && (opts?.includeSearch ?? true)) {\n return deepEqual(baseLocation.search, next.search, { partial: true })\n ? match\n : false\n }\n\n return match\n }\n\n ssr?: {\n manifest: Manifest | undefined\n }\n\n serverSsr?: ServerSsr\n\n hasNotFoundMatch = () => {\n return this.__store.state.matches.some(\n (d) => d.status === 'notFound' || d.globalNotFound,\n )\n }\n}\n\n/** Error thrown when search parameter validation fails. */\nexport class SearchParamError extends Error {}\n\n/** Error thrown when path parameter parsing/validation fails. */\nexport class PathParamError extends Error {}\n\nconst normalize = (str: string) =>\n str.endsWith('/') && str.length > 1 ? str.slice(0, -1) : str\nfunction comparePaths(a: string, b: string) {\n return normalize(a) === normalize(b)\n}\n\n/**\n * Lazily import a module function and forward arguments to it, retaining\n * parameter and return types for the selected export key.\n */\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\n/** Create an initial RouterState from a parsed location. */\nexport function getInitialRouterState(\n location: ParsedLocation,\n): RouterState<any> {\n return {\n loadedAt: 0,\n isLoading: false,\n isTransitioning: false,\n status: 'idle',\n resolvedLocation: undefined,\n location,\n matches: [],\n pendingMatches: [],\n cachedMatches: [],\n statusCode: 200,\n }\n}\n\nfunction validateSearch(validateSearch: AnyValidator, input: unknown): unknown {\n if (validateSearch == null) return {}\n\n if ('~standard' in validateSearch) {\n const result = validateSearch['~standard'].validate(input)\n\n if (result instanceof Promise)\n throw new SearchParamError('Async validation not supported')\n\n if (result.issues)\n throw new SearchParamError(JSON.stringify(result.issues, undefined, 2), {\n cause: result,\n })\n\n return result.value\n }\n\n if ('parse' in validateSearch) {\n return validateSearch.parse(input)\n }\n\n if (typeof validateSearch === 'function') {\n return validateSearch(input)\n }\n\n return {}\n}\n\n/**\n * Build the matched route chain and extract params for a pathname.\n * Falls back to the root route if no specific route is found.\n */\nexport function getMatchedRoutes<TRouteLike extends RouteLike>({\n pathname,\n routePathname,\n caseSensitive,\n routesByPath,\n routesById,\n flatRoutes,\n parseCache,\n}: {\n pathname: string\n routePathname?: string\n caseSensitive?: boolean\n routesByPath: Record<string, TRouteLike>\n routesById: Record<string, TRouteLike>\n flatRoutes: Array<TRouteLike>\n parseCache?: ParsePathnameCache\n}) {\n let routeParams: Record<string, string> = {}\n const trimmedPath = trimPathRight(pathname)\n const getMatchedParams = (route: TRouteLike) => {\n const result = matchPathname(\n trimmedPath,\n {\n to: route.fullPath,\n caseSensitive: route.options?.caseSensitive ?? caseSensitive,\n // we need fuzzy matching for `notFoundMode: 'fuzzy'`\n fuzzy: true,\n },\n parseCache,\n )\n return result\n }\n\n let foundRoute: TRouteLike | undefined =\n routePathname !== undefined ? routesByPath[routePathname] : undefined\n if (foundRoute) {\n routeParams = getMatchedParams(foundRoute)!\n } else {\n // iterate over flatRoutes to find the best match\n // if we find a fuzzy matching route, keep looking for a perfect fit\n let fuzzyMatch:\n | { foundRoute: TRouteLike; routeParams: Record<string, string> }\n | undefined = undefined\n for (const route of flatRoutes) {\n const matchedParams = getMatchedParams(route)\n\n if (matchedParams) {\n if (\n route.path !== '/' &&\n (matchedParams as Record<string, string>)['**']\n ) {\n if (!fuzzyMatch) {\n fuzzyMatch = { foundRoute: route, routeParams: matchedParams }\n }\n } else {\n foundRoute = route\n routeParams = matchedParams\n break\n }\n }\n }\n // did not find a perfect fit, so take the fuzzy matching route if it exists\n if (!foundRoute && fuzzyMatch) {\n foundRoute = fuzzyMatch.foundRoute\n routeParams = fuzzyMatch.routeParams\n }\n }\n\n let routeCursor: TRouteLike = foundRoute || routesById[rootRouteId]!\n\n const matchedRoutes: Array<TRouteLike> = [routeCursor]\n\n while (routeCursor.parentRoute) {\n routeCursor = routeCursor.parentRoute as TRouteLike\n matchedRoutes.push(routeCursor)\n }\n matchedRoutes.reverse()\n\n return { matchedRoutes, routeParams, foundRoute }\n}\n\nfunction applySearchMiddleware({\n search,\n dest,\n destRoutes,\n _includeValidateSearch,\n}: {\n search: any\n dest: BuildNextOptions\n destRoutes: Array<AnyRoute>\n _includeValidateSearch: boolean | undefined\n}) {\n const allMiddlewares =\n destRoutes.reduce(\n (acc, route) => {\n const middlewares: Array<SearchMiddleware<any>> = []\n\n if ('search' in route.options) {\n if (route.options.search?.middlewares) {\n middlewares.push(...route.options.search.middlewares)\n }\n }\n // TODO remove preSearchFilters and postSearchFilters in v2\n else if (\n route.options.preSearchFilters ||\n route.options.postSearchFilters\n ) {\n const legacyMiddleware: SearchMiddleware<any> = ({\n search,\n next,\n }) => {\n let nextSearch = search\n\n if (\n 'preSearchFilters' in route.options &&\n route.options.preSearchFilters\n ) {\n nextSearch = route.options.preSearchFilters.reduce(\n (prev, next) => next(prev),\n search,\n )\n }\n\n const result = next(nextSearch)\n\n if (\n 'postSearchFilters' in route.options &&\n route.options.postSearchFilters\n ) {\n return route.options.postSearchFilters.reduce(\n (prev, next) => next(prev),\n result,\n )\n }\n\n return result\n }\n middlewares.push(legacyMiddleware)\n }\n\n if (_includeValidateSearch && route.options.validateSearch) {\n const validate: SearchMiddleware<any> = ({ search, next }) => {\n const result = next(search)\n try {\n const validatedSearch = {\n ...result,\n ...(validateSearch(route.options.validateSearch, result) ??\n undefined),\n }\n return validatedSearch\n } catch {\n // ignore errors here because they are already handled in matchRoutes\n return result\n }\n }\n\n middlewares.push(validate)\n }\n\n return acc.concat(middlewares)\n },\n [] as Array<SearchMiddleware<any>>,\n ) ?? []\n\n // the chain ends here since `next` is not called\n const final: SearchMiddleware<any> = ({ search }) => {\n if (!dest.search) {\n return {}\n }\n if (dest.search === true) {\n return search\n }\n return functionalUpdate(dest.search, search)\n }\n\n allMiddlewares.push(final)\n\n const applyNext = (index: number, currentSearch: any): any => {\n // no more middlewares left, return the current search\n if (index >= allMiddlewares.length) {\n return currentSearch\n }\n\n const middleware = allMiddlewares[index]!\n\n const next = (newSearch: any): any => {\n return applyNext(index + 1, newSearch)\n }\n\n return middleware({ search: currentSearch, next })\n }\n\n // Start applying middlewares\n return applyNext(0, search)\n}\n"],"names":["redirect","opts","validateSearch","search","next"],"mappings":";;;;;;;;;;;;;AAkxBO,SAAS,sBAAsB,KAAc;AAClD,MAAI,eAAe,OAAO;AACxB,UAAM,MAAM;AAAA,MACV,MAAM,IAAI;AAAA,MACV,SAAS,IAAI;AAAA,IAAA;AAGf,QAAI,QAAQ,IAAI,aAAa,eAAe;AACxC,UAAY,QAAQ,IAAI;AAAA,IAC5B;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,EAAA;AAEV;AAGO,MAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AACZ;AASO,SAAS,sBAAsB,aAGnC;AACD,QAAM,eAAe,YAAY;AACjC,QAAM,aAAa,YAAY;AAC/B,QAAM,cAAc,cAAc,aAAa,WAAW;AAC1D,QAAM,cAAc,cAAc,SAAS,WAAW;AACtD,QAAM,cAAc,cAAc,SAAS,WAAW;AACtD,SAAO,EAAE,cAAc,YAAY,aAAa,aAAa,YAAA;AAC/D;AAmCO,MAAM,WAMX;AAAA;AAAA;AAAA;AAAA,EAyCA,YACE,SAOA;AA/CF,SAAA,kBAAsC,GAAG,KAAK;AAAA,MAC5C,KAAK,WAAW;AAAA,IAAA,CACjB;AACD,SAAA,kBAAkB;AAClB,SAAA,uBAAyD;AACzD,SAAA,iCAA2C;AAC3C,SAAA,kCAAkB,IAAA;AAElB,SAAA,oBAAoB;AACpB,SAAA,2BAA2B;AA2D3B,SAAA,kBAAqC,CAAC,OAAO,GAAA;AAU7C,SAAA,SAMI,CAAC,eAAe;AAClB,UAAI,WAAW,eAAe;AAC5B,gBAAQ;AAAA,UACN;A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AM;AAC5B;"}
1
+ {"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { Store, batch } from '@tanstack/store'\nimport { createBrowserHistory, parseHref } from '@tanstack/history'\nimport {\n createControlledPromise,\n decodePath,\n deepEqual,\n findLast,\n functionalUpdate,\n last,\n replaceEqualDeep,\n} from './utils'\nimport {\n findFlatMatch,\n findRouteMatch,\n findSingleMatch,\n processRouteMasks,\n processRouteTree,\n} from './new-process-route-tree'\nimport {\n cleanPath,\n interpolatePath,\n resolvePath,\n trimPath,\n trimPathRight,\n} from './path'\nimport { createLRUCache } from './lru-cache'\nimport { isNotFound } from './not-found'\nimport { setupScrollRestoration } from './scroll-restoration'\nimport { defaultParseSearch, defaultStringifySearch } from './searchParams'\nimport { rootRouteId } from './root'\nimport { isRedirect, redirect } from './redirect'\nimport { loadMatches, loadRouteChunk, routeNeedsPreload } from './load-matches'\nimport {\n composeRewrites,\n executeRewriteInput,\n executeRewriteOutput,\n rewriteBasepath,\n} from './rewrite'\nimport type { ProcessedTree } from './new-process-route-tree'\nimport type { SearchParser, SearchSerializer } from './searchParams'\nimport type { AnyRedirect, ResolvedRedirect } from './redirect'\nimport type {\n HistoryLocation,\n HistoryState,\n ParsedHistoryState,\n RouterHistory,\n} from '@tanstack/history'\nimport type {\n Awaitable,\n Constrain,\n ControlledPromise,\n NoInfer,\n NonNullableUpdater,\n PickAsRequired,\n Updater,\n} from './utils'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouteWithContext,\n MakeRemountDepsOptionsUnion,\n RouteContextOptions,\n RouteLike,\n RouteMask,\n SearchMiddleware,\n} from './route'\nimport type {\n FullSearchSchema,\n RouteById,\n RoutePaths,\n RoutesById,\n RoutesByPath,\n} from './routeInfo'\nimport type {\n AnyRouteMatch,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n MatchRouteOptions,\n} from './Matches'\nimport type {\n BuildLocationFn,\n CommitLocationOptions,\n NavigateFn,\n} from './RouterProvider'\nimport type { Manifest } from './manifest'\nimport type { AnySchema, AnyValidator } from './validators'\nimport type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'\nimport type { NotFoundError } from './not-found'\nimport type {\n AnySerializationAdapter,\n ValidateSerializableInput,\n} from './ssr/serializer/transformer'\n// import type { AnyRouterConfig } from './config'\n\nexport type ControllablePromise<T = any> = Promise<T> & {\n resolve: (value: T) => void\n reject: (value?: any) => void\n}\n\nexport type InjectedHtmlEntry = Promise<string>\n\nexport interface Register {\n // Lots of things on here like...\n // router\n // config\n // ssr\n}\n\nexport type RegisteredSsr<TRegister = Register> = TRegister extends {\n ssr: infer TSSR\n}\n ? TSSR\n : false\n\nexport type RegisteredRouter<TRegister = Register> = TRegister extends {\n router: infer TRouter\n}\n ? TRouter\n : AnyRouter\n\nexport type RegisteredConfigType<TRegister, TKey> = TRegister extends {\n config: infer TConfig\n}\n ? TConfig extends {\n '~types': infer TTypes\n }\n ? TKey extends keyof TTypes\n ? TTypes[TKey]\n : unknown\n : unknown\n : unknown\n\nexport type DefaultRemountDepsFn<TRouteTree extends AnyRoute> = (\n opts: MakeRemountDepsOptionsUnion<TRouteTree>,\n) => any\n\nexport interface DefaultRouterOptionsExtensions {}\n\nexport interface RouterOptionsExtensions\n extends DefaultRouterOptionsExtensions {}\n\nexport type SSROption = boolean | 'data-only'\n\nexport interface RouterOptions<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean = false,\n TRouterHistory extends RouterHistory = RouterHistory,\n TDehydrated = undefined,\n> extends RouterOptionsExtensions {\n /**\n * The history object that will be used to manage the browser history.\n *\n * If not provided, a new createBrowserHistory instance will be created and used.\n *\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?: TRouterHistory\n /**\n * A function that will be used to stringify search params when generating links.\n *\n * @default 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 *\n * @default 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 * If `false`, routes will not be preloaded by default in any way.\n *\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 *\n * If `'viewport'`, routes will be preloaded by default when they are within the viewport.\n *\n * @default false\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' | 'viewport' | 'render'\n /**\n * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.\n *\n * @default 50\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 * The default `preloadIntentProximity` a route should use if no preloadIntentProximity is provided.\n *\n * @default 0\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadintentproximity-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-intent-proximity)\n */\n defaultPreloadIntentProximity?: number\n /**\n * The default `pendingMs` a route should use if no pendingMs is provided.\n *\n * @default 1000\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 * The default `pendingMinMs` a route should use if no pendingMinMs is provided.\n *\n * @default 500\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 * The default `staleTime` a route should use if no staleTime is provided. This is the time in milliseconds that a route will be considered fresh.\n *\n * @default 0\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 * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.\n *\n * @default 30_000 `(30 seconds)`\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 * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.\n *\n * @default 1_800_000 `(30 minutes)`\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 * If `true`, route navigations will called using `document.startViewTransition()`.\n *\n * If the browser does not support this api, this option will be ignored.\n *\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)\n */\n defaultViewTransition?: boolean | ViewTransitionOptions\n /**\n * The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating\n *\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)\n */\n defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions\n /**\n * @default 'fuzzy'\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)\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 * The default `gcTime` a route should use if no gcTime is provided.\n *\n * @default 1_800_000 `(30 minutes)`\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 * If `true`, all routes will be matched as case-sensitive.\n *\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)\n */\n caseSensitive?: boolean\n /**\n *\n * The route tree that will be used to configure the router instance.\n *\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/routing/route-trees)\n */\n routeTree?: TRouteTree\n /**\n * The basepath for then entire router. This is useful for mounting a router instance at a subpath.\n * ```\n * @default '/'\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)\n */\n basepath?: string\n /**\n * The root context that will be provided to all routes in the route tree.\n *\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 *\n * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).\n *\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?: InferRouterContext<TRouteTree>\n\n additionalContext?: any\n\n /**\n * A function that will be called when the router is dehydrated.\n *\n * The return value of this function will be serialized and stored in the router's dehydrated state.\n *\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?: () => Constrain<\n TDehydrated,\n ValidateSerializableInput<Register, TDehydrated>\n >\n /**\n * A function that will be called when the router is hydrated.\n *\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) => Awaitable<void>\n /**\n * An array of route masks that will be used to mask routes in the route tree.\n *\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 *\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 * If `true`, route masks will, by default, be removed when the page is reloaded.\n *\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 *\n * @default false\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 /**\n * Use `notFoundComponent` instead.\n *\n * @deprecated\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 * Configures how trailing slashes are treated.\n *\n * - `'always'` will add a trailing slash if not present\n * - `'never'` will remove the trailing slash if present\n * - `'preserve'` will not modify the trailing slash.\n *\n * @default 'never'\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)\n */\n trailingSlash?: TTrailingSlashOption\n /**\n * While usually automatic, sometimes it can be useful to force the router into a server-side state, e.g. when using the router in a non-browser environment that has access to a global.document object.\n *\n * @default typeof document !== 'undefined'\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)\n */\n isServer?: boolean\n\n /**\n * @default false\n */\n isShell?: boolean\n\n /**\n * @default false\n */\n isPrerendering?: boolean\n\n /**\n * The default `ssr` a route should use if no `ssr` is provided.\n *\n * @default true\n */\n defaultSsr?: SSROption\n\n search?: {\n /**\n * Configures how unknown search params (= not returned by any `validateSearch`) are treated.\n *\n * @default false\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)\n */\n strict?: boolean\n }\n\n /**\n * Configures whether structural sharing is enabled by default for fine-grained selectors.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstructuralsharing-property)\n */\n defaultStructuralSharing?: TDefaultStructuralSharingOption\n\n /**\n * Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)\n */\n pathParamsAllowedCharacters?: Array<\n ';' | ':' | '@' | '&' | '=' | '+' | '$' | ','\n >\n\n defaultRemountDeps?: DefaultRemountDepsFn<TRouteTree>\n\n /**\n * If `true`, scroll restoration will be enabled\n *\n * @default false\n */\n scrollRestoration?:\n | boolean\n | ((opts: { location: ParsedLocation }) => boolean)\n\n /**\n * A function that will be called to get the key for the scroll restoration cache.\n *\n * @default (location) => location.href\n */\n getScrollRestorationKey?: (location: ParsedLocation) => string\n /**\n * The default behavior for scroll restoration.\n *\n * @default 'auto'\n */\n scrollRestorationBehavior?: ScrollBehavior\n /**\n * An array of selectors that will be used to scroll to the top of the page in addition to `window`\n *\n * @default ['window']\n */\n scrollToTopSelectors?: Array<string | (() => Element | null | undefined)>\n\n /**\n * When `true`, disables the global catch boundary that normally wraps all route matches.\n * This allows unhandled errors to bubble up to top-level error handlers in the browser.\n *\n * Useful for testing tools (like Storybook Test Runner), error reporting services,\n * and debugging scenarios where you want errors to reach the browser's global error handlers.\n *\n * @default false\n */\n disableGlobalCatchBoundary?: boolean\n\n serializationAdapters?: ReadonlyArray<AnySerializationAdapter>\n /**\n * Configures how the router will rewrite the location between the actual href and the internal href of the router.\n *\n * @default undefined\n * @description You can provide a custom rewrite pair (in/out).\n * This is useful for shifting data from the origin to the path (for things like subdomain routing), or other advanced use cases.\n */\n rewrite?: LocationRewrite\n origin?: string\n ssr?: {\n nonce?: string\n }\n}\n\nexport type LocationRewrite = {\n /**\n * A function that will be called to rewrite the URL before it is interpreted by the router from the history instance.\n *\n * @default undefined\n */\n input?: LocationRewriteFunction\n /**\n * A function that will be called to rewrite the URL before it is committed to the actual history instance from the router.\n *\n * @default undefined\n */\n output?: LocationRewriteFunction\n}\n\n/**\n * A function that will be called to rewrite the URL.\n *\n * @param url The URL to rewrite.\n * @returns The rewritten URL (as a URL instance or full href string) or undefined if no rewrite is needed.\n */\nexport type LocationRewriteFunction = ({\n url,\n}: {\n url: URL\n}) => undefined | string | URL\n\nexport interface RouterState<\n in out TRouteTree extends AnyRoute = AnyRoute,\n in out TRouteMatch = MakeRouteMatchUnion,\n> {\n status: 'pending' | 'idle'\n loadedAt: number\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?: AnyRedirect\n}\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<ParsedHistoryState, 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<ParsedHistoryState, HistoryState>\n unmaskOnReload?: boolean\n }\n from?: string\n href?: string\n _fromLocation?: ParsedLocation\n unsafeRelative?: 'path'\n _isNavigate?: boolean\n}\n\ntype NavigationEventInfo = {\n fromLocation?: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n hrefChanged: boolean\n hashChanged: boolean\n}\n\nexport interface RouterEvents {\n onBeforeNavigate: {\n type: 'onBeforeNavigate'\n } & NavigationEventInfo\n onBeforeLoad: {\n type: 'onBeforeLoad'\n } & NavigationEventInfo\n onLoad: {\n type: 'onLoad'\n } & NavigationEventInfo\n onResolved: {\n type: 'onResolved'\n } & NavigationEventInfo\n onBeforeRouteMount: {\n type: 'onBeforeRouteMount'\n } & NavigationEventInfo\n onRendered: {\n type: 'onRendered'\n } & NavigationEventInfo\n}\n\nexport type RouterEvent = RouterEvents[keyof RouterEvents]\n\nexport type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void\n\nexport type RouterListener<TRouterEvent extends RouterEvent> = {\n eventType: TRouterEvent['type']\n fn: ListenerFn<TRouterEvent>\n}\n\nexport type SubscribeFn = <TType extends keyof RouterEvents>(\n eventType: TType,\n fn: ListenerFn<RouterEvents[TType]>,\n) => () => void\n\nexport interface MatchRoutesOpts {\n preload?: boolean\n throwOnError?: boolean\n _buildLocation?: boolean\n dest?: BuildNextOptions\n}\n\nexport type InferRouterContext<TRouteTree extends AnyRoute> =\n TRouteTree['types']['routerContext']\n\nexport type RouterContextOptions<TRouteTree extends AnyRoute> =\n AnyContext extends InferRouterContext<TRouteTree>\n ? {\n context?: InferRouterContext<TRouteTree>\n }\n : {\n context: InferRouterContext<TRouteTree>\n }\n\nexport type RouterConstructorOptions<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n TDehydrated extends Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n 'context' | 'serializationAdapters' | 'defaultSsr'\n> &\n RouterContextOptions<TRouteTree>\n\nexport type PreloadRouteFn<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n> = <\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<\n RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory\n >,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n >,\n) => Promise<Array<AnyRouteMatch> | undefined>\n\nexport type MatchRouteFn<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n> = <\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string | undefined = undefined,\n TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n>(\n location: ToOptions<\n RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory\n >,\n TFrom,\n TTo\n >,\n opts?: MatchRouteOptions,\n) => false | RouteById<TRouteTree, TResolved>['types']['allParams']\n\nexport type UpdateFn<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption,\n TDefaultStructuralSharingOption extends boolean,\n TRouterHistory extends RouterHistory,\n TDehydrated extends Record<string, any>,\n> = (\n newOptions: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n) => void\n\nexport type InvalidateFn<TRouter extends AnyRouter> = (opts?: {\n filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean\n sync?: boolean\n forcePending?: boolean\n}) => Promise<void>\n\nexport type ParseLocationFn<TRouteTree extends AnyRoute> = (\n locationToParse: HistoryLocation,\n previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>,\n) => ParsedLocation<FullSearchSchema<TRouteTree>>\n\nexport type GetMatchRoutesFn = (pathname: string) => {\n matchedRoutes: Array<AnyRoute>\n routeParams: Record<string, string>\n foundRoute: AnyRoute | undefined\n}\n\nexport type EmitFn = (routerEvent: RouterEvent) => void\n\nexport type LoadFn = (opts?: { sync?: boolean }) => Promise<void>\n\nexport type CommitLocationFn = ({\n viewTransition,\n ignoreBlocker,\n ...next\n}: ParsedLocation & CommitLocationOptions) => Promise<void>\n\nexport type StartTransitionFn = (fn: () => void) => void\n\nexport interface MatchRoutesFn {\n (\n pathname: string,\n locationSearch?: AnySchema,\n opts?: MatchRoutesOpts,\n ): Array<MakeRouteMatchUnion>\n /**\n * @deprecated use the following signature instead\n */\n (next: ParsedLocation, opts?: MatchRoutesOpts): Array<AnyRouteMatch>\n (\n pathnameOrNext: string | ParsedLocation,\n locationSearchOrOpts?: AnySchema | MatchRoutesOpts,\n opts?: MatchRoutesOpts,\n ): Array<AnyRouteMatch>\n}\n\nexport type GetMatchFn = (matchId: string) => AnyRouteMatch | undefined\n\nexport type UpdateMatchFn = (\n id: string,\n updater: (match: AnyRouteMatch) => AnyRouteMatch,\n) => void\n\nexport type LoadRouteChunkFn = (route: AnyRoute) => Promise<Array<void>>\n\nexport type ResolveRedirect = (err: AnyRedirect) => ResolvedRedirect\n\nexport type ClearCacheFn<TRouter extends AnyRouter> = (opts?: {\n filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean\n}) => void\n\nexport interface ServerSsr {\n injectedHtml: Array<InjectedHtmlEntry>\n injectHtml: (getHtml: () => string | Promise<string>) => Promise<void>\n injectScript: (\n getScript: () => string | Promise<string>,\n opts?: { logScript?: boolean },\n ) => Promise<void>\n isDehydrated: () => boolean\n onRenderFinished: (listener: () => void) => void\n dehydrate: () => Promise<void>\n takeBufferedScripts: () => string | undefined\n}\n\nexport type AnyRouterWithContext<TContext> = RouterCore<\n AnyRouteWithContext<TContext>,\n any,\n any,\n any,\n any\n>\n\nexport type AnyRouter = RouterCore<any, any, any, any, any>\n\nexport interface ViewTransitionOptions {\n types:\n | Array<string>\n | ((locationChangeInfo: {\n fromLocation?: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n hrefChanged: boolean\n hashChanged: boolean\n }) => Array<string> | false)\n}\n\n// TODO where is this used? can we remove this?\n/**\n * Convert an unknown error into a minimal, serializable object.\n * Includes name and message (and stack in development).\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\n/** Options for configuring trailing-slash behavior. */\nexport const trailingSlashOptions = {\n always: 'always',\n never: 'never',\n preserve: 'preserve',\n} as const\n\nexport type TrailingSlashOption =\n (typeof trailingSlashOptions)[keyof typeof trailingSlashOptions]\n\n/**\n * Compute whether path, href or hash changed between previous and current\n * resolved locations in router state.\n */\nexport function getLocationChangeInfo(routerState: {\n resolvedLocation?: ParsedLocation\n location: ParsedLocation\n}) {\n const fromLocation = routerState.resolvedLocation\n const toLocation = routerState.location\n const pathChanged = fromLocation?.pathname !== toLocation.pathname\n const hrefChanged = fromLocation?.href !== toLocation.href\n const hashChanged = fromLocation?.hash !== toLocation.hash\n return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged }\n}\n\nexport type CreateRouterFn = <\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption = 'never',\n TDefaultStructuralSharingOption extends boolean = false,\n TRouterHistory extends RouterHistory = RouterHistory,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>(\n options: undefined extends number\n ? 'strictNullChecks must be enabled in tsconfig.json'\n : RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n) => RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n>\n\n/**\n * Core, framework-agnostic router engine that powers TanStack Router.\n *\n * Provides navigation, matching, loading, preloading, caching and event APIs\n * used by framework adapters (React/Solid). Prefer framework helpers like\n * `createRouter` in app code.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType\n */\nexport class RouterCore<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption,\n in out TDefaultStructuralSharingOption extends boolean,\n in out TRouterHistory extends RouterHistory = RouterHistory,\n in out TDehydrated 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 | ViewTransitionOptions = undefined\n isViewTransitionTypesSupported?: boolean = undefined\n subscribers = new Set<RouterListener<RouterEvent>>()\n viewTransitionPromise?: ControlledPromise<true>\n isScrollRestoring = false\n isScrollRestorationSetup = false\n\n // Must build in constructor\n __store!: Store<RouterState<TRouteTree>>\n options!: PickAsRequired<\n RouterOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n 'stringifySearch' | 'parseSearch' | 'context'\n >\n history!: TRouterHistory\n rewrite?: LocationRewrite\n origin?: string\n latestLocation!: ParsedLocation<FullSearchSchema<TRouteTree>>\n pendingBuiltLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>\n basepath!: string\n routeTree!: TRouteTree\n routesById!: RoutesById<TRouteTree>\n routesByPath!: RoutesByPath<TRouteTree>\n processedTree!: ProcessedTree<TRouteTree, any, any>\n isServer!: boolean\n pathParamsDecodeCharMap?: Map<string, string>\n\n /**\n * @deprecated Use the `createRouter` function instead\n */\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n ) {\n this.update({\n defaultPreloadDelay: 50,\n defaultPendingMs: 1000,\n defaultPendingMinMs: 500,\n context: undefined!,\n ...options,\n caseSensitive: options.caseSensitive ?? false,\n notFoundMode: options.notFoundMode ?? 'fuzzy',\n stringifySearch: options.stringifySearch ?? defaultStringifySearch,\n parseSearch: options.parseSearch ?? defaultParseSearch,\n })\n\n if (typeof document !== 'undefined') {\n self.__TSR_ROUTER__ = this\n }\n }\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 startTransition: StartTransitionFn = (fn) => fn()\n\n isShell() {\n return !!this.options.isShell\n }\n\n isPrerendering() {\n return !!this.options.isPrerendering\n }\n\n update: UpdateFn<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n > = (newOptions) => {\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/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.',\n )\n }\n\n const prevOptions = this.options\n const prevBasepath = this.basepath ?? prevOptions?.basepath ?? '/'\n const basepathWasUnset = this.basepath === undefined\n const prevRewriteOption = prevOptions?.rewrite\n\n this.options = {\n ...prevOptions,\n ...newOptions,\n }\n\n this.isServer = this.options.isServer ?? typeof document === 'undefined'\n\n this.pathParamsDecodeCharMap = this.options.pathParamsAllowedCharacters\n ? new Map(\n this.options.pathParamsAllowedCharacters.map((char) => [\n encodeURIComponent(char),\n char,\n ]),\n )\n : undefined\n\n if (\n !this.history ||\n (this.options.history && this.options.history !== this.history)\n ) {\n if (!this.options.history) {\n if (!this.isServer) {\n this.history = createBrowserHistory() as TRouterHistory\n }\n } else {\n this.history = this.options.history\n }\n }\n\n this.origin = this.options.origin\n if (!this.origin) {\n if (!this.isServer && window?.origin && window.origin !== 'null') {\n this.origin = window.origin\n } else {\n // fallback for the server, can be overridden by calling router.update({origin}) on the server\n this.origin = 'http://localhost'\n }\n }\n\n if (this.history) {\n this.updateLatestLocation()\n }\n\n if (this.options.routeTree !== this.routeTree) {\n this.routeTree = this.options.routeTree as TRouteTree\n this.buildRouteTree()\n }\n\n if (!this.__store && this.latestLocation) {\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 setupScrollRestoration(this)\n }\n\n let needsLocationUpdate = false\n const nextBasepath = this.options.basepath ?? '/'\n const nextRewriteOption = this.options.rewrite\n const basepathChanged = basepathWasUnset || prevBasepath !== nextBasepath\n const rewriteChanged = prevRewriteOption !== nextRewriteOption\n\n if (basepathChanged || rewriteChanged) {\n this.basepath = nextBasepath\n\n const rewrites: Array<LocationRewrite> = []\n if (trimPath(nextBasepath) !== '') {\n rewrites.push(\n rewriteBasepath({\n basepath: nextBasepath,\n }),\n )\n }\n if (nextRewriteOption) {\n rewrites.push(nextRewriteOption)\n }\n\n this.rewrite =\n rewrites.length === 0\n ? undefined\n : rewrites.length === 1\n ? rewrites[0]\n : composeRewrites(rewrites)\n\n if (this.history) {\n this.updateLatestLocation()\n }\n\n needsLocationUpdate = true\n }\n\n if (needsLocationUpdate && this.__store) {\n this.__store.state = {\n ...this.state,\n location: this.latestLocation,\n }\n }\n\n if (\n typeof window !== 'undefined' &&\n 'CSS' in window &&\n typeof window.CSS?.supports === 'function'\n ) {\n this.isViewTransitionTypesSupported = window.CSS.supports(\n 'selector(:active-view-transition-type(a)',\n )\n }\n }\n\n get state(): RouterState<TRouteTree> {\n return this.__store.state\n }\n\n updateLatestLocation = () => {\n this.latestLocation = this.parseLocation(\n this.history.location,\n this.latestLocation,\n )\n }\n\n buildRouteTree = () => {\n const { routesById, routesByPath, processedTree } = processRouteTree(\n this.routeTree,\n this.options.caseSensitive,\n (route, i) => {\n route.init({\n originalIndex: i,\n })\n },\n )\n if (this.options.routeMasks) {\n processRouteMasks(this.options.routeMasks, processedTree)\n }\n\n this.routesById = routesById as RoutesById<TRouteTree>\n this.routesByPath = routesByPath as RoutesByPath<TRouteTree>\n this.processedTree = processedTree\n\n const notFoundRoute = this.options.notFoundRoute\n\n if (notFoundRoute) {\n notFoundRoute.init({\n originalIndex: 99999999999,\n })\n this.routesById[notFoundRoute.id] = notFoundRoute\n }\n }\n\n /**\n * Subscribe to router lifecycle events like `onBeforeNavigate`, `onLoad`,\n * `onResolved`, etc. Returns an unsubscribe function.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterEventsType\n */\n subscribe: SubscribeFn = (eventType, fn) => {\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: EmitFn = (routerEvent) => {\n this.subscribers.forEach((listener) => {\n if (listener.eventType === routerEvent.type) {\n listener.fn(routerEvent)\n }\n })\n }\n\n /**\n * Parse a HistoryLocation into a strongly-typed ParsedLocation using the\n * current router options, rewrite rules and search parser/stringifier.\n */\n parseLocation: ParseLocationFn<TRouteTree> = (\n locationToParse,\n previousLocation,\n ) => {\n const parse = ({\n href,\n state,\n }: HistoryLocation): ParsedLocation<FullSearchSchema<TRouteTree>> => {\n // Before we do any processing, we need to allow rewrites to modify the URL\n // build up the full URL by combining the href from history with the router's origin\n const fullUrl = new URL(href, this.origin)\n const url = executeRewriteInput(this.rewrite, fullUrl)\n\n const parsedSearch = this.options.parseSearch(url.search)\n const searchStr = this.options.stringifySearch(parsedSearch)\n // Make sure our final url uses the re-stringified pathname, search, and has for consistency\n // (We were already doing this, so just keeping it for now)\n url.search = searchStr\n\n const fullPath = url.href.replace(url.origin, '')\n\n const { pathname, hash } = url\n\n return {\n href: fullPath,\n publicHref: href,\n url: url.href,\n pathname: decodePath(pathname),\n searchStr,\n search: replaceEqualDeep(previousLocation?.search, parsedSearch) as any,\n hash: hash.split('#').reverse()[0] ?? '',\n state: replaceEqualDeep(previousLocation?.state, state),\n }\n }\n\n const location = parse(locationToParse)\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 // TODO: Remove in v2 - use __TSR_key instead\n parsedTempLocation.state.__TSR_key = location.state.__TSR_key\n\n delete parsedTempLocation.state.__tempLocation\n\n return {\n ...parsedTempLocation,\n maskedLocation: location,\n }\n }\n return location\n }\n\n resolvePathCache = createLRUCache<string, string>(1000)\n\n /** Resolve a path against the router basepath and trailing-slash policy. */\n resolvePathWithBase = (from: string, path: string) => {\n const resolvedPath = resolvePath({\n base: from,\n to: cleanPath(path),\n trailingSlash: this.options.trailingSlash,\n cache: this.resolvePathCache,\n })\n return resolvedPath\n }\n\n get looseRoutesById() {\n return this.routesById as Record<string, AnyRoute>\n }\n\n matchRoutes: MatchRoutesFn = (\n pathnameOrNext: string | ParsedLocation,\n locationSearchOrOpts?: AnySchema | MatchRoutesOpts,\n opts?: MatchRoutesOpts,\n ) => {\n if (typeof pathnameOrNext === 'string') {\n return this.matchRoutesInternal(\n {\n pathname: pathnameOrNext,\n search: locationSearchOrOpts,\n } as ParsedLocation,\n opts,\n )\n }\n\n return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts)\n }\n\n private matchRoutesInternal(\n next: ParsedLocation,\n opts?: MatchRoutesOpts,\n ): Array<AnyRouteMatch> {\n const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes(\n next.pathname,\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(next.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 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 const matches: Array<AnyRouteMatch> = []\n\n const getParentContext = (parentMatch?: AnyRouteMatch) => {\n const parentMatchId = parentMatch?.id\n\n const parentContext = !parentMatchId\n ? ((this.options.context as any) ?? undefined)\n : (parentMatch.context ?? this.options.context ?? undefined)\n\n return parentContext\n }\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, strictMatchSearch, searchError]: [\n Record<string, any>,\n Record<string, any>,\n any,\n ] = (() => {\n // Validate the search params and stabilize them\n const parentSearch = parentMatch?.search ?? next.search\n const parentStrictSearch = parentMatch?._strictSearch ?? undefined\n\n try {\n const strictSearch =\n validateSearch(route.options.validateSearch, { ...parentSearch }) ??\n undefined\n\n return [\n {\n ...parentSearch,\n ...strictSearch,\n },\n { ...parentStrictSearch, ...strictSearch },\n undefined,\n ]\n } catch (err: any) {\n let searchParamError = err\n if (!(err instanceof SearchParamError)) {\n searchParamError = new SearchParamError(err.message, {\n cause: err,\n })\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, usedParams } = interpolatePath({\n path: route.fullPath,\n params: routeParams,\n decodeCharMap: this.pathParamsDecodeCharMap,\n })\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\n // Existing matches are matches that are already loaded along with\n // pending matches that are still loading\n const matchId =\n // route.id for disambiguation\n route.id +\n // interpolatedPath for param changes\n interpolatedPath +\n // explicit deps\n loaderDepsHash\n\n const existingMatch = this.getMatch(matchId)\n\n const previousMatch = this.state.matches.find(\n (d) => d.routeId === route.id,\n )\n\n const strictParams = existingMatch?._strictParams ?? usedParams\n\n let paramsError: PathParamError | undefined = undefined\n\n if (!existingMatch) {\n const strictParseParams =\n route.options.params?.parse ?? route.options.parseParams\n\n if (strictParseParams) {\n try {\n Object.assign(\n strictParams,\n strictParseParams(strictParams as Record<string, string>),\n )\n } catch (err: any) {\n paramsError = new PathParamError(err.message, {\n cause: err,\n })\n\n if (opts?.throwOnError) {\n throw paramsError\n }\n }\n }\n }\n\n Object.assign(routeParams, strictParams)\n\n const cause = previousMatch ? 'stay' : 'enter'\n\n let match: AnyRouteMatch\n\n if (existingMatch) {\n match = {\n ...existingMatch,\n cause,\n params: previousMatch\n ? replaceEqualDeep(previousMatch.params, routeParams)\n : routeParams,\n _strictParams: strictParams,\n search: previousMatch\n ? replaceEqualDeep(previousMatch.search, preMatchSearch)\n : replaceEqualDeep(existingMatch.search, preMatchSearch),\n _strictSearch: strictMatchSearch,\n }\n } else {\n const status =\n route.options.loader ||\n route.options.beforeLoad ||\n route.lazyFn ||\n routeNeedsPreload(route)\n ? 'pending'\n : 'success'\n\n match = {\n id: matchId,\n index,\n routeId: route.id,\n params: previousMatch\n ? replaceEqualDeep(previousMatch.params, routeParams)\n : routeParams,\n _strictParams: strictParams,\n pathname: interpolatedPath,\n updatedAt: Date.now(),\n search: previousMatch\n ? replaceEqualDeep(previousMatch.search, preMatchSearch)\n : preMatchSearch,\n _strictSearch: strictMatchSearch,\n searchError: undefined,\n status,\n isFetching: false,\n error: undefined,\n paramsError,\n __routeContext: undefined,\n _nonReactive: {\n loadPromise: createControlledPromise(),\n },\n __beforeLoadContext: undefined,\n context: {},\n abortController: new AbortController(),\n fetchCount: 0,\n cause,\n loaderDeps: previousMatch\n ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps)\n : loaderDeps,\n invalid: false,\n preload: false,\n links: undefined,\n scripts: undefined,\n headScripts: undefined,\n meta: undefined,\n staticData: route.options.staticData || {},\n fullPath: route.fullPath,\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 // update the searchError if there is one\n match.searchError = searchError\n\n const parentContext = getParentContext(parentMatch)\n\n match.context = {\n ...parentContext,\n ...match.__routeContext,\n ...match.__beforeLoadContext,\n }\n\n matches.push(match)\n })\n\n matches.forEach((match, index) => {\n const route = this.looseRoutesById[match.routeId]!\n const existingMatch = this.getMatch(match.id)\n\n // only execute `context` if we are not calling from router.buildLocation\n\n if (!existingMatch && opts?._buildLocation !== true) {\n const parentMatch = matches[index - 1]\n const parentContext = getParentContext(parentMatch)\n\n // Update the match's context\n\n if (route.options.context) {\n const contextFnContext: RouteContextOptions<any, any, any, any> = {\n deps: match.loaderDeps,\n params: match.params,\n context: parentContext ?? {},\n location: next,\n navigate: (opts: any) =>\n this.navigate({ ...opts, _fromLocation: next }),\n buildLocation: this.buildLocation,\n cause: match.cause,\n abortController: match.abortController,\n preload: !!match.preload,\n matches,\n }\n // Get the route context\n match.__routeContext =\n route.options.context(contextFnContext) ?? undefined\n }\n\n match.context = {\n ...parentContext,\n ...match.__routeContext,\n ...match.__beforeLoadContext,\n }\n }\n })\n\n return matches\n }\n\n getMatchedRoutes: GetMatchRoutesFn = (pathname) => {\n return getMatchedRoutes({\n pathname,\n routesById: this.routesById,\n processedTree: this.processedTree,\n })\n }\n\n cancelMatch = (id: string) => {\n const match = this.getMatch(id)\n\n if (!match) return\n\n match.abortController.abort()\n clearTimeout(match._nonReactive.pendingTimeout)\n match._nonReactive.pendingTimeout = undefined\n }\n\n cancelMatches = () => {\n const currentPendingMatches = this.state.matches.filter(\n (match) => match.status === 'pending',\n )\n const currentLoadingMatches = this.state.matches.filter(\n (match) => match.isFetching === 'loader',\n )\n const matchesToCancelArray = new Set([\n ...(this.state.pendingMatches ?? []),\n ...currentPendingMatches,\n ...currentLoadingMatches,\n ])\n matchesToCancelArray.forEach((match) => {\n this.cancelMatch(match.id)\n })\n }\n\n /**\n * Build the next ParsedLocation from navigation options without committing.\n * Resolves `to`/`from`, params/search/hash/state, applies search validation\n * and middlewares, and returns a stable, stringified location object.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType#buildlocation-method\n */\n buildLocation: BuildLocationFn = (opts) => {\n const build = (\n dest: BuildNextOptions & {\n unmaskOnReload?: boolean\n } = {},\n ): ParsedLocation => {\n // We allow the caller to override the current location\n const currentLocation =\n dest._fromLocation || this.pendingBuiltLocation || this.latestLocation\n\n const allCurrentLocationMatches = this.matchRoutes(currentLocation, {\n _buildLocation: true,\n })\n\n // Now let's find the starting pathname\n // This should default to the current location if no from is provided\n const lastMatch = last(allCurrentLocationMatches)!\n\n // check that from path exists in the current route tree\n // do this check only on navigations during test or development\n if (\n dest.from &&\n process.env.NODE_ENV !== 'production' &&\n dest._isNavigate\n ) {\n const allFromMatches = this.getMatchedRoutes(dest.from).matchedRoutes\n\n const matchedFrom = findLast(allCurrentLocationMatches, (d) => {\n return comparePaths(d.fullPath, dest.from!)\n })\n\n const matchedCurrent = findLast(allFromMatches, (d) => {\n return comparePaths(d.fullPath, lastMatch.fullPath)\n })\n\n // for from to be invalid it shouldn't just be unmatched to currentLocation\n // but the currentLocation should also be unmatched to from\n if (!matchedFrom && !matchedCurrent) {\n console.warn(`Could not find match for from: ${dest.from}`)\n }\n }\n\n const defaultedFromPath =\n dest.unsafeRelative === 'path'\n ? currentLocation.pathname\n : (dest.from ?? lastMatch.fullPath)\n\n // ensure this includes the basePath if set\n const fromPath = this.resolvePathWithBase(defaultedFromPath, '.')\n\n // From search should always use the current location\n const fromSearch = lastMatch.search\n // Same with params. It can't hurt to provide as many as possible\n const fromParams = { ...lastMatch.params }\n\n // Resolve the next to\n // ensure this includes the basePath if set\n const nextTo = dest.to\n ? this.resolvePathWithBase(fromPath, `${dest.to}`)\n : this.resolvePathWithBase(fromPath, '.')\n\n // Resolve the next params\n const nextParams =\n dest.params === false || dest.params === null\n ? {}\n : (dest.params ?? true) === true\n ? fromParams\n : Object.assign(\n fromParams,\n functionalUpdate(dest.params as any, fromParams),\n )\n\n // Interpolate the path first to get the actual resolved path, then match against that\n const interpolatedNextTo = interpolatePath({\n path: nextTo,\n params: nextParams,\n }).interpolatedPath\n\n const destRoutes = this.matchRoutes(interpolatedNextTo, undefined, {\n _buildLocation: true,\n }).map((d) => this.looseRoutesById[d.routeId]!)\n\n // If there are any params, we need to stringify them\n if (Object.keys(nextParams).length > 0) {\n for (const route of destRoutes) {\n const fn =\n route.options.params?.stringify ?? route.options.stringifyParams\n if (fn) {\n Object.assign(nextParams, fn(nextParams))\n }\n }\n }\n\n const nextPathname = opts.leaveParams\n ? // Use the original template path for interpolation\n // This preserves the original parameter syntax including optional parameters\n nextTo\n : decodePath(\n interpolatePath({\n path: nextTo,\n params: nextParams,\n decodeCharMap: this.pathParamsDecodeCharMap,\n }).interpolatedPath,\n )\n\n // Resolve the next search\n let nextSearch = fromSearch\n if (opts._includeValidateSearch && this.options.search?.strict) {\n const validatedSearch = {}\n destRoutes.forEach((route) => {\n if (route.options.validateSearch) {\n try {\n Object.assign(\n validatedSearch,\n validateSearch(route.options.validateSearch, {\n ...validatedSearch,\n ...nextSearch,\n }),\n )\n } catch {\n // ignore errors here because they are already handled in matchRoutes\n }\n }\n })\n nextSearch = validatedSearch\n }\n\n nextSearch = applySearchMiddleware({\n search: nextSearch,\n dest,\n destRoutes,\n _includeValidateSearch: opts._includeValidateSearch,\n })\n\n // Replace the equal deep\n nextSearch = replaceEqualDeep(fromSearch, nextSearch)\n\n // Stringify the next search\n const searchStr = this.options.stringifySearch(nextSearch)\n\n // Resolve the next hash\n const hash =\n dest.hash === true\n ? currentLocation.hash\n : dest.hash\n ? functionalUpdate(dest.hash, currentLocation.hash)\n : undefined\n\n // Resolve the next hash string\n const hashStr = hash ? `#${hash}` : ''\n\n // Resolve the next state\n let nextState =\n dest.state === true\n ? currentLocation.state\n : dest.state\n ? functionalUpdate(dest.state, currentLocation.state)\n : {}\n\n // Replace the equal deep\n nextState = replaceEqualDeep(currentLocation.state, nextState)\n\n // Create the full path of the location\n const fullPath = `${nextPathname}${searchStr}${hashStr}`\n\n // Create the new href with full origin\n const url = new URL(fullPath, this.origin)\n\n // If a rewrite function is provided, use it to rewrite the URL\n const rewrittenUrl = executeRewriteOutput(this.rewrite, url)\n\n return {\n publicHref:\n rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash,\n href: fullPath,\n url: rewrittenUrl.href,\n pathname: nextPathname,\n search: nextSearch,\n searchStr,\n state: nextState as any,\n hash: hash ?? '',\n unmaskOnReload: dest.unmaskOnReload,\n }\n }\n\n const buildWithMatches = (\n dest: BuildNextOptions = {},\n maskedDest?: BuildNextOptions,\n ) => {\n const next = build(dest)\n\n let maskedNext = maskedDest ? build(maskedDest) : undefined\n\n if (!maskedNext) {\n const params = {}\n\n if (this.options.routeMasks) {\n const match = findFlatMatch<RouteMask<TRouteTree>>(\n next.pathname,\n this.processedTree,\n )\n if (match) {\n Object.assign(params, match.params) // Copy params, because they're cached\n const { from: _from, ...maskProps } = match.route\n maskedDest = {\n from: opts.from,\n ...maskProps,\n params,\n }\n maskedNext = build(maskedDest)\n }\n }\n }\n\n if (maskedNext) {\n next.maskedLocation = maskedNext\n }\n\n return next\n }\n\n if (opts.mask) {\n return buildWithMatches(opts, {\n from: opts.from,\n ...opts.mask,\n })\n }\n\n return buildWithMatches(opts)\n }\n\n commitLocationPromise: undefined | ControlledPromise<void>\n\n /**\n * Commit a previously built location to history (push/replace), optionally\n * using view transitions and scroll restoration options.\n */\n commitLocation: CommitLocationFn = ({\n viewTransition,\n ignoreBlocker,\n ...next\n }) => {\n const isSameState = () => {\n // the following props are ignored but may still be provided when navigating,\n // temporarily add the previous values to the next state so they don't affect\n // the comparison\n const ignoredProps = [\n 'key', // TODO: Remove in v2 - use __TSR_key instead\n '__TSR_key',\n '__TSR_index',\n '__hashScrollIntoViewOptions',\n ] as const\n ignoredProps.forEach((prop) => {\n ;(next.state as any)[prop] = this.latestLocation.state[prop]\n })\n const isEqual = deepEqual(next.state, this.latestLocation.state)\n ignoredProps.forEach((prop) => {\n delete next.state[prop]\n })\n return isEqual\n }\n\n const isSameUrl =\n trimPathRight(this.latestLocation.href) === trimPathRight(next.href)\n\n const previousCommitPromise = this.commitLocationPromise\n this.commitLocationPromise = createControlledPromise<void>(() => {\n previousCommitPromise?.resolve()\n })\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, hashScrollIntoView, ...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 __TSR_key: undefined!,\n key: undefined!, // TODO: Remove in v2 - use __TSR_key instead\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 nextHistory.state.__hashScrollIntoViewOptions =\n hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true\n\n this.shouldViewTransition = viewTransition\n\n this.history[next.replace ? 'replace' : 'push'](\n nextHistory.publicHref,\n nextHistory.state,\n { ignoreBlocker },\n )\n }\n\n this.resetNextScroll = next.resetScroll ?? true\n\n if (!this.history.subscribers.size) {\n this.load()\n }\n\n return this.commitLocationPromise\n }\n\n /** Convenience helper: build a location from options, then commit it. */\n buildAndCommitLocation = ({\n replace,\n resetScroll,\n hashScrollIntoView,\n viewTransition,\n ignoreBlocker,\n href,\n ...rest\n }: BuildNextOptions & CommitLocationOptions = {}) => {\n if (href) {\n const currentIndex = this.history.location.state.__TSR_index\n\n const parsed = parseHref(href, {\n __TSR_index: replace ? currentIndex : currentIndex + 1,\n })\n rest.to = parsed.pathname\n rest.search = this.options.parseSearch(parsed.search)\n // remove the leading `#` from the hash\n rest.hash = parsed.hash.slice(1)\n }\n\n const location = this.buildLocation({\n ...(rest as any),\n _includeValidateSearch: true,\n })\n\n this.pendingBuiltLocation = location as ParsedLocation<\n FullSearchSchema<TRouteTree>\n >\n\n const commitPromise = this.commitLocation({\n ...location,\n viewTransition,\n replace,\n resetScroll,\n hashScrollIntoView,\n ignoreBlocker,\n })\n\n // Clear pending location after commit starts\n // We do this on next microtask to allow synchronous navigate calls to chain\n Promise.resolve().then(() => {\n if (this.pendingBuiltLocation === location) {\n this.pendingBuiltLocation = undefined\n }\n })\n\n return commitPromise\n }\n\n /**\n * Imperatively navigate using standard `NavigateOptions`. When `reloadDocument`\n * or an absolute `href` is provided, performs a full document navigation.\n * Otherwise, builds and commits a client-side location.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType\n */\n navigate: NavigateFn = ({ to, reloadDocument, href, ...rest }) => {\n if (!reloadDocument && href) {\n try {\n new URL(`${href}`)\n reloadDocument = true\n } catch {}\n }\n\n if (reloadDocument) {\n if (!href) {\n const location = this.buildLocation({ to, ...rest } as any)\n href = location.url\n }\n if (rest.replace) {\n window.location.replace(href)\n } else {\n window.location.href = href\n }\n return Promise.resolve()\n }\n\n return this.buildAndCommitLocation({\n ...rest,\n href,\n to: to as string,\n _isNavigate: true,\n })\n }\n\n latestLoadPromise: undefined | Promise<void>\n\n beforeLoad = () => {\n // Cancel any pending matches\n this.cancelMatches()\n this.updateLatestLocation()\n\n if (this.isServer) {\n // for SPAs on the initial load, this is handled by the Transitioner\n const nextLocation = this.buildLocation({\n to: this.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Normalize URLs for comparison to handle encoding differences\n // Browser history always stores encoded URLs while buildLocation may produce decoded URLs\n const normalizeUrl = (url: string) => {\n try {\n return encodeURI(decodeURI(url))\n } catch {\n return url\n }\n }\n\n if (\n trimPath(normalizeUrl(this.latestLocation.href)) !==\n trimPath(normalizeUrl(nextLocation.href))\n ) {\n let href = nextLocation.url\n if (this.origin && href.startsWith(this.origin)) {\n href = href.replace(this.origin, '') || '/'\n }\n\n throw redirect({ href })\n }\n }\n\n // Match the routes\n const pendingMatches = this.matchRoutes(this.latestLocation)\n\n // Ingest the new matches\n this.__store.setState((s) => ({\n ...s,\n status: 'pending',\n statusCode: 200,\n isLoading: true,\n location: this.latestLocation,\n pendingMatches,\n // If a cached moved to pendingMatches, remove it from cachedMatches\n cachedMatches: s.cachedMatches.filter(\n (d) => !pendingMatches.some((e) => e.id === d.id),\n ),\n }))\n }\n\n load: LoadFn = async (opts?: { sync?: boolean }): Promise<void> => {\n let redirect: AnyRedirect | undefined\n let notFound: NotFoundError | undefined\n let loadPromise: Promise<void>\n\n // eslint-disable-next-line prefer-const\n loadPromise = new Promise<void>((resolve) => {\n this.startTransition(async () => {\n try {\n this.beforeLoad()\n const next = this.latestLocation\n const prevLocation = this.state.resolvedLocation\n\n if (!this.state.redirect) {\n this.emit({\n type: 'onBeforeNavigate',\n ...getLocationChangeInfo({\n resolvedLocation: prevLocation,\n location: next,\n }),\n })\n }\n\n this.emit({\n type: 'onBeforeLoad',\n ...getLocationChangeInfo({\n resolvedLocation: prevLocation,\n location: next,\n }),\n })\n\n await loadMatches({\n router: this,\n sync: opts?.sync,\n matches: this.state.pendingMatches as Array<AnyRouteMatch>,\n location: next,\n updateMatch: this.updateMatch,\n // eslint-disable-next-line @typescript-eslint/require-await\n onReady: async () => {\n // eslint-disable-next-line @typescript-eslint/require-await\n // Wrap batch in framework-specific transition wrapper (e.g., Solid's startTransition)\n this.startTransition(() => {\n 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 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.some((d) => d.id === match.id),\n )\n enteringMatches = newMatches.filter(\n (match) =>\n !previousMatches.some((d) => d.id === match.id),\n )\n stayingMatches = newMatches.filter((match) =>\n previousMatches.some((d) => d.id === match.id),\n )\n\n return {\n ...s,\n isLoading: false,\n loadedAt: Date.now(),\n matches: newMatches,\n pendingMatches: undefined,\n cachedMatches: [\n ...s.cachedMatches,\n ...exitingMatches.filter((d) => d.status !== 'error'),\n ],\n }\n })\n this.clearExpiredCache()\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]?.(\n match,\n )\n })\n })\n })\n })\n },\n })\n } catch (err) {\n if (isRedirect(err)) {\n redirect = err\n if (!this.isServer) {\n this.navigate({\n ...redirect.options,\n replace: true,\n ignoreBlocker: true,\n })\n }\n } else if (isNotFound(err)) {\n notFound = err\n }\n\n this.__store.setState((s) => ({\n ...s,\n statusCode: redirect\n ? redirect.status\n : notFound\n ? 404\n : s.matches.some((d) => d.status === 'error')\n ? 500\n : 200,\n redirect,\n }))\n }\n\n if (this.latestLoadPromise === loadPromise) {\n this.commitLocationPromise?.resolve()\n this.latestLoadPromise = undefined\n this.commitLocationPromise = undefined\n }\n\n resolve()\n })\n })\n\n this.latestLoadPromise = loadPromise\n\n await loadPromise\n\n while (\n (this.latestLoadPromise as any) &&\n loadPromise !== this.latestLoadPromise\n ) {\n await this.latestLoadPromise\n }\n\n let newStatusCode: number | undefined = undefined\n if (this.hasNotFoundMatch()) {\n newStatusCode = 404\n } else if (this.__store.state.matches.some((d) => d.status === 'error')) {\n newStatusCode = 500\n }\n if (newStatusCode !== undefined) {\n this.__store.setState((s) => ({\n ...s,\n statusCode: newStatusCode,\n }))\n }\n }\n\n startViewTransition = (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 if (\n shouldViewTransition &&\n typeof document !== 'undefined' &&\n 'startViewTransition' in document &&\n typeof document.startViewTransition === 'function'\n ) {\n // lib.dom.ts doesn't support viewTransition types variant yet.\n // TODO: Fix this when dom types are updated\n let startViewTransitionParams: any\n\n if (\n typeof shouldViewTransition === 'object' &&\n this.isViewTransitionTypesSupported\n ) {\n const next = this.latestLocation\n const prevLocation = this.state.resolvedLocation\n\n const resolvedViewTransitionTypes =\n typeof shouldViewTransition.types === 'function'\n ? shouldViewTransition.types(\n getLocationChangeInfo({\n resolvedLocation: prevLocation,\n location: next,\n }),\n )\n : shouldViewTransition.types\n\n if (resolvedViewTransitionTypes === false) {\n fn()\n return\n }\n\n startViewTransitionParams = {\n update: fn,\n types: resolvedViewTransitionTypes,\n }\n } else {\n startViewTransitionParams = fn\n }\n\n document.startViewTransition(startViewTransitionParams)\n } else {\n fn()\n }\n }\n\n updateMatch: UpdateMatchFn = (id, updater) => {\n this.startTransition(() => {\n const matchesKey = this.state.pendingMatches?.some((d) => d.id === id)\n ? 'pendingMatches'\n : this.state.matches.some((d) => d.id === id)\n ? 'matches'\n : this.state.cachedMatches.some((d) => d.id === id)\n ? 'cachedMatches'\n : ''\n\n if (matchesKey) {\n this.__store.setState((s) => ({\n ...s,\n [matchesKey]: s[matchesKey]?.map((d) =>\n d.id === id ? updater(d) : d,\n ),\n }))\n }\n })\n }\n\n getMatch: GetMatchFn = (matchId: string): AnyRouteMatch | undefined => {\n const findFn = (d: { id: string }) => d.id === matchId\n return (\n this.state.cachedMatches.find(findFn) ??\n this.state.pendingMatches?.find(findFn) ??\n this.state.matches.find(findFn)\n )\n }\n\n invalidate: InvalidateFn<\n RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >\n > = (opts) => {\n const invalidate = (d: MakeRouteMatch<TRouteTree>) => {\n if (opts?.filter?.(d as MakeRouteMatchUnion<this>) ?? true) {\n return {\n ...d,\n invalid: true,\n ...(opts?.forcePending || d.status === 'error'\n ? ({ status: 'pending', error: undefined } as const)\n : undefined),\n }\n }\n return d\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 this.shouldViewTransition = false\n return this.load({ sync: opts?.sync })\n }\n\n resolveRedirect = (redirect: AnyRedirect): AnyRedirect => {\n if (!redirect.options.href) {\n const location = this.buildLocation(redirect.options)\n let href = location.url\n if (this.origin && href.startsWith(this.origin)) {\n href = href.replace(this.origin, '') || '/'\n }\n redirect.options.href = location.href\n redirect.headers.set('Location', href)\n }\n if (!redirect.headers.get('Location')) {\n redirect.headers.set('Location', redirect.options.href)\n }\n return redirect\n }\n\n clearCache: ClearCacheFn<this> = (opts) => {\n const filter = opts?.filter\n if (filter !== undefined) {\n this.__store.setState((s) => {\n return {\n ...s,\n cachedMatches: s.cachedMatches.filter(\n (m) => !filter(m as MakeRouteMatchUnion<this>),\n ),\n }\n })\n } else {\n this.__store.setState((s) => {\n return {\n ...s,\n cachedMatches: [],\n }\n })\n }\n }\n\n clearExpiredCache = () => {\n // This is where all of the garbage collection magic happens\n const filter = (d: MakeRouteMatch<TRouteTree>) => {\n const route = this.looseRoutesById[d.routeId]!\n\n if (!route.options.loader) {\n return true\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 const isError = d.status === 'error'\n if (isError) return true\n\n const gcEligible = Date.now() - d.updatedAt >= gcTime\n return gcEligible\n }\n this.clearCache({ filter })\n }\n\n loadRouteChunk = loadRouteChunk\n\n preloadRoute: PreloadRouteFn<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory\n > = async (opts) => {\n const next = this.buildLocation(opts as any)\n\n let matches = this.matchRoutes(next, {\n throwOnError: true,\n preload: true,\n dest: opts,\n })\n\n const activeMatchIds = new Set(\n [...this.state.matches, ...(this.state.pendingMatches ?? [])].map(\n (d) => d.id,\n ),\n )\n\n const loadedMatchIds = new Set([\n ...activeMatchIds,\n ...this.state.cachedMatches.map((d) => d.id),\n ])\n\n // If the matches are already loaded, we need to add them to the cachedMatches\n batch(() => {\n matches.forEach((match) => {\n if (!loadedMatchIds.has(match.id)) {\n this.__store.setState((s) => ({\n ...s,\n cachedMatches: [...(s.cachedMatches as any), match],\n }))\n }\n })\n })\n\n try {\n matches = await loadMatches({\n router: this,\n matches,\n location: next,\n preload: true,\n updateMatch: (id, updater) => {\n // Don't update the match if it's currently loaded\n if (activeMatchIds.has(id)) {\n matches = matches.map((d) => (d.id === id ? updater(d) : d))\n } else {\n this.updateMatch(id, updater)\n }\n },\n })\n\n return matches\n } catch (err) {\n if (isRedirect(err)) {\n if (err.options.reloadDocument) {\n return undefined\n }\n\n return await this.preloadRoute({\n ...err.options,\n _fromLocation: next,\n })\n }\n if (!isNotFound(err)) {\n // Preload errors are not fatal, but we should still log them\n console.error(err)\n }\n return undefined\n }\n }\n\n matchRoute: MatchRouteFn<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory\n > = (location, opts) => {\n const matchLocation = {\n ...location,\n to: location.to\n ? this.resolvePathWithBase(\n (location.from || '') as string,\n location.to as string,\n )\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 || this.state.location\n\n const match = findSingleMatch(\n next.pathname,\n opts?.caseSensitive ?? false,\n opts?.fuzzy ?? false,\n baseLocation.pathname,\n this.processedTree,\n )\n\n if (!match) {\n return false\n }\n\n if (location.params) {\n if (!deepEqual(match.params, location.params, { partial: true })) {\n return false\n }\n }\n\n if (opts?.includeSearch ?? true) {\n return deepEqual(baseLocation.search, next.search, { partial: true })\n ? match.params\n : false\n }\n\n return match.params\n }\n\n ssr?: {\n manifest: Manifest | undefined\n }\n\n serverSsr?: ServerSsr\n\n hasNotFoundMatch = () => {\n return this.__store.state.matches.some(\n (d) => d.status === 'notFound' || d.globalNotFound,\n )\n }\n}\n\n/** Error thrown when search parameter validation fails. */\nexport class SearchParamError extends Error {}\n\n/** Error thrown when path parameter parsing/validation fails. */\nexport class PathParamError extends Error {}\n\nconst normalize = (str: string) =>\n str.endsWith('/') && str.length > 1 ? str.slice(0, -1) : str\nfunction comparePaths(a: string, b: string) {\n return normalize(a) === normalize(b)\n}\n\n/**\n * Lazily import a module function and forward arguments to it, retaining\n * parameter and return types for the selected export key.\n */\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\n/** Create an initial RouterState from a parsed location. */\nexport function getInitialRouterState(\n location: ParsedLocation,\n): RouterState<any> {\n return {\n loadedAt: 0,\n isLoading: false,\n isTransitioning: false,\n status: 'idle',\n resolvedLocation: undefined,\n location,\n matches: [],\n pendingMatches: [],\n cachedMatches: [],\n statusCode: 200,\n }\n}\n\nfunction validateSearch(validateSearch: AnyValidator, input: unknown): unknown {\n if (validateSearch == null) return {}\n\n if ('~standard' in validateSearch) {\n const result = validateSearch['~standard'].validate(input)\n\n if (result instanceof Promise)\n throw new SearchParamError('Async validation not supported')\n\n if (result.issues)\n throw new SearchParamError(JSON.stringify(result.issues, undefined, 2), {\n cause: result,\n })\n\n return result.value\n }\n\n if ('parse' in validateSearch) {\n return validateSearch.parse(input)\n }\n\n if (typeof validateSearch === 'function') {\n return validateSearch(input)\n }\n\n return {}\n}\n\n/**\n * Build the matched route chain and extract params for a pathname.\n * Falls back to the root route if no specific route is found.\n */\nexport function getMatchedRoutes<TRouteLike extends RouteLike>({\n pathname,\n routesById,\n processedTree,\n}: {\n pathname: string\n routesById: Record<string, TRouteLike>\n processedTree: ProcessedTree<any, any, any>\n}) {\n const routeParams: Record<string, string> = {}\n const trimmedPath = trimPathRight(pathname)\n\n let foundRoute: TRouteLike | undefined = undefined\n const match = findRouteMatch<TRouteLike>(trimmedPath, processedTree, true)\n if (match) {\n foundRoute = match.route\n Object.assign(routeParams, match.params) // Copy params, because they're cached\n }\n\n let routeCursor: TRouteLike = foundRoute || routesById[rootRouteId]!\n\n const matchedRoutes: Array<TRouteLike> = [routeCursor]\n\n while (routeCursor.parentRoute) {\n routeCursor = routeCursor.parentRoute as TRouteLike\n matchedRoutes.push(routeCursor)\n }\n matchedRoutes.reverse()\n\n return { matchedRoutes, routeParams, foundRoute }\n}\n\nfunction applySearchMiddleware({\n search,\n dest,\n destRoutes,\n _includeValidateSearch,\n}: {\n search: any\n dest: BuildNextOptions\n destRoutes: Array<AnyRoute>\n _includeValidateSearch: boolean | undefined\n}) {\n const allMiddlewares =\n destRoutes.reduce(\n (acc, route) => {\n const middlewares: Array<SearchMiddleware<any>> = []\n\n if ('search' in route.options) {\n if (route.options.search?.middlewares) {\n middlewares.push(...route.options.search.middlewares)\n }\n }\n // TODO remove preSearchFilters and postSearchFilters in v2\n else if (\n route.options.preSearchFilters ||\n route.options.postSearchFilters\n ) {\n const legacyMiddleware: SearchMiddleware<any> = ({\n search,\n next,\n }) => {\n let nextSearch = search\n\n if (\n 'preSearchFilters' in route.options &&\n route.options.preSearchFilters\n ) {\n nextSearch = route.options.preSearchFilters.reduce(\n (prev, next) => next(prev),\n search,\n )\n }\n\n const result = next(nextSearch)\n\n if (\n 'postSearchFilters' in route.options &&\n route.options.postSearchFilters\n ) {\n return route.options.postSearchFilters.reduce(\n (prev, next) => next(prev),\n result,\n )\n }\n\n return result\n }\n middlewares.push(legacyMiddleware)\n }\n\n if (_includeValidateSearch && route.options.validateSearch) {\n const validate: SearchMiddleware<any> = ({ search, next }) => {\n const result = next(search)\n try {\n const validatedSearch = {\n ...result,\n ...(validateSearch(route.options.validateSearch, result) ??\n undefined),\n }\n return validatedSearch\n } catch {\n // ignore errors here because they are already handled in matchRoutes\n return result\n }\n }\n\n middlewares.push(validate)\n }\n\n return acc.concat(middlewares)\n },\n [] as Array<SearchMiddleware<any>>,\n ) ?? []\n\n // the chain ends here since `next` is not called\n const final: SearchMiddleware<any> = ({ search }) => {\n if (!dest.search) {\n return {}\n }\n if (dest.search === true) {\n return search\n }\n return functionalUpdate(dest.search, search)\n }\n\n allMiddlewares.push(final)\n\n const applyNext = (index: number, currentSearch: any): any => {\n // no more middlewares left, return the current search\n if (index >= allMiddlewares.length) {\n return currentSearch\n }\n\n const middleware = allMiddlewares[index]!\n\n const next = (newSearch: any): any => {\n return applyNext(index + 1, newSearch)\n }\n\n return middleware({ search: currentSearch, next })\n }\n\n // Start applying middlewares\n return applyNext(0, search)\n}\n"],"names":["redirect","opts","validateSearch","search","next"],"mappings":";;;;;;;;;;;;;AAoxBO,SAAS,sBAAsB,KAAc;AAClD,MAAI,eAAe,OAAO;AACxB,UAAM,MAAM;AAAA,MACV,MAAM,IAAI;AAAA,MACV,SAAS,IAAI;AAAA,IAAA;AAGf,QAAI,QAAQ,IAAI,aAAa,eAAe;AACxC,UAAY,QAAQ,IAAI;AAAA,IAC5B;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,EAAA;AAEV;AAGO,MAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AACZ;AASO,SAAS,sBAAsB,aAGnC;AACD,QAAM,eAAe,YAAY;AACjC,QAAM,aAAa,YAAY;AAC/B,QAAM,cAAc,cAAc,aAAa,WAAW;AAC1D,QAAM,cAAc,cAAc,SAAS,WAAW;AACtD,QAAM,cAAc,cAAc,SAAS,WAAW;AACtD,SAAO,EAAE,cAAc,YAAY,aAAa,aAAa,YAAA;AAC/D;AAmCO,MAAM,WAMX;AAAA;AAAA;AAAA;AAAA,EAyCA,YACE,SAOA;AA/CF,SAAA,kBAAsC,GAAG,KAAK;AAAA,MAC5C,KAAK,WAAW;AAAA,IAAA,CACjB;AACD,SAAA,kBAAkB;AAClB,SAAA,uBAAyD;AACzD,SAAA,iCAA2C;AAC3C,SAAA,kCAAkB,IAAA;AAElB,SAAA,oBAAoB;AACpB,SAAA,2BAA2B;AA2D3B,SAAA,kBAAqC,CAAC,OAAO,GAAA;AAU7C,SAAA,SAMI,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,CAAC,KAAK,QAAQ;AAChB,aAAO,CAAA;AAAA,IACT;AACA,QAAI,KAAK,WAAW,MAAM;AACxB,aAAOA;AAAAA,IACT;AACA,WAAO,iBAAiB,KAAK,QAAQA,OAAM;AAAA,EAC7C;AAEA,iBAAe,KAAK,KAAK;AAEzB,QAAM,YAAY,CAAC,OAAe,kBAA4B;AAE5D,QAAI,SAAS,eAAe,QAAQ;AAClC,aAAO;AAAA,IACT;AAEA,UAAM,aAAa,eAAe,KAAK;AAEvC,UAAM,OAAO,CAAC,cAAwB;AACpC,aAAO,UAAU,QAAQ,GAAG,SAAS;AAAA,IACvC;AAEA,WAAO,WAAW,EAAE,QAAQ,eAAe,MAAM;AAAA,EACnD;AAGA,SAAO,UAAU,GAAG,MAAM;AAC5B;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
- "version": "1.136.4",
3
+ "version": "1.136.5",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/Matches.ts CHANGED
@@ -272,6 +272,8 @@ export interface MatchRouteOptions {
272
272
  * If `true`, will match against the current location with case sensitivity.
273
273
  *
274
274
  * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)
275
+ *
276
+ * @deprecated Declare case sensitivity in the route definition instead, or globally for all routes using the `caseSensitive` option on the router.
275
277
  */
276
278
  caseSensitive?: boolean
277
279
  /**