@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,6 +1,6 @@
1
1
  import { Store } from '@tanstack/store';
2
2
  import { loadRouteChunk } from './load-matches.cjs';
3
- import { ParsePathnameCache } from './path.cjs';
3
+ import { ProcessedTree } from './new-process-route-tree.cjs';
4
4
  import { SearchParser, SearchSerializer } from './searchParams.cjs';
5
5
  import { AnyRedirect, ResolvedRedirect } from './redirect.cjs';
6
6
  import { HistoryLocation, HistoryState, ParsedHistoryState, RouterHistory } from '@tanstack/history';
@@ -458,7 +458,7 @@ export type InvalidateFn<TRouter extends AnyRouter> = (opts?: {
458
458
  forcePending?: boolean;
459
459
  }) => Promise<void>;
460
460
  export type ParseLocationFn<TRouteTree extends AnyRoute> = (locationToParse: HistoryLocation, previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>) => ParsedLocation<FullSearchSchema<TRouteTree>>;
461
- export type GetMatchRoutesFn = (pathname: string, routePathname: string | undefined) => {
461
+ export type GetMatchRoutesFn = (pathname: string) => {
462
462
  matchedRoutes: Array<AnyRoute>;
463
463
  routeParams: Record<string, string>;
464
464
  foundRoute: AnyRoute | undefined;
@@ -567,7 +567,7 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
567
567
  routeTree: TRouteTree;
568
568
  routesById: RoutesById<TRouteTree>;
569
569
  routesByPath: RoutesByPath<TRouteTree>;
570
- flatRoutes: Array<AnyRoute>;
570
+ processedTree: ProcessedTree<TRouteTree, any, any>;
571
571
  isServer: boolean;
572
572
  pathParamsDecodeCharMap?: Map<string, string>;
573
573
  /**
@@ -594,13 +594,12 @@ export declare class RouterCore<in out TRouteTree extends AnyRoute, in out TTrai
594
594
  * current router options, rewrite rules and search parser/stringifier.
595
595
  */
596
596
  parseLocation: ParseLocationFn<TRouteTree>;
597
+ resolvePathCache: import('./lru-cache.cjs').LRUCache<string, string>;
597
598
  /** Resolve a path against the router basepath and trailing-slash policy. */
598
599
  resolvePathWithBase: (from: string, path: string) => string;
599
600
  get looseRoutesById(): Record<string, AnyRoute>;
600
601
  matchRoutes: MatchRoutesFn;
601
602
  private matchRoutesInternal;
602
- /** a cache for `parsePathname` */
603
- private parsePathnameCache;
604
603
  getMatchedRoutes: GetMatchRoutesFn;
605
604
  cancelMatch: (id: string) => void;
606
605
  cancelMatches: () => void;
@@ -664,14 +663,10 @@ export declare function getInitialRouterState(location: ParsedLocation): RouterS
664
663
  * Build the matched route chain and extract params for a pathname.
665
664
  * Falls back to the root route if no specific route is found.
666
665
  */
667
- export declare function getMatchedRoutes<TRouteLike extends RouteLike>({ pathname, routePathname, caseSensitive, routesByPath, routesById, flatRoutes, parseCache, }: {
666
+ export declare function getMatchedRoutes<TRouteLike extends RouteLike>({ pathname, routesById, processedTree, }: {
668
667
  pathname: string;
669
- routePathname?: string;
670
- caseSensitive?: boolean;
671
- routesByPath: Record<string, TRouteLike>;
672
668
  routesById: Record<string, TRouteLike>;
673
- flatRoutes: Array<TRouteLike>;
674
- parseCache?: ParsePathnameCache;
669
+ processedTree: ProcessedTree<any, any, any>;
675
670
  }): {
676
671
  matchedRoutes: TRouteLike[];
677
672
  routeParams: Record<string, string>;
@@ -120,6 +120,8 @@ export interface MatchRouteOptions {
120
120
  * If `true`, will match against the current location with case sensitivity.
121
121
  *
122
122
  * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)
123
+ *
124
+ * @deprecated Declare case sensitivity in the route definition instead, or globally for all routes using the `caseSensitive` option on the router.
123
125
  */
124
126
  caseSensitive?: boolean;
125
127
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Matches.js","sources":["../../src/Matches.ts"],"sourcesContent":["import type { AnyRoute, StaticDataRouteOption } from './route'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteIds,\n} from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, SSROption } from './router'\nimport type { Constrain, ControlledPromise } from './utils'\n\nexport type AnyMatchAndValue = { match: any; value: any }\n\nexport type FindValueByIndex<\n TKey,\n TValue extends ReadonlyArray<any>,\n> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never\n\nexport type FindValueByKey<TKey, TValue> =\n TValue extends ReadonlyArray<any>\n ? FindValueByIndex<TKey, TValue>\n : TValue[TKey & keyof TValue]\n\nexport type CreateMatchAndValue<TMatch, TValue> = TValue extends any\n ? {\n match: TMatch\n value: TValue\n }\n : never\n\nexport type NextMatchAndValue<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? CreateMatchAndValue<\n TMatchAndValue['match'],\n FindValueByKey<TKey, TMatchAndValue['value']>\n >\n : never\n\nexport type IsMatchKeyOf<TValue> =\n TValue extends ReadonlyArray<any>\n ? number extends TValue['length']\n ? `${number}`\n : keyof TValue & `${number}`\n : TValue extends object\n ? keyof TValue & string\n : never\n\nexport type IsMatchPath<\n TParentPath extends string,\n TMatchAndValue extends AnyMatchAndValue,\n> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`\n\nexport type IsMatchResult<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? TKey extends keyof TMatchAndValue['value']\n ? TMatchAndValue['match']\n : never\n : never\n\nexport type IsMatchParse<\n TPath,\n TMatchAndValue extends AnyMatchAndValue,\n TParentPath extends string = '',\n> = TPath extends `${string}.${string}`\n ? TPath extends `${infer TFirst}.${infer TRest}`\n ? IsMatchParse<\n TRest,\n NextMatchAndValue<TFirst, TMatchAndValue>,\n `${TParentPath}${TFirst}.`\n >\n : never\n : {\n path: IsMatchPath<TParentPath, TMatchAndValue>\n result: IsMatchResult<TPath, TMatchAndValue>\n }\n\nexport type IsMatch<TMatch, TPath> = IsMatchParse<\n TPath,\n TMatch extends any ? { match: TMatch; value: TMatch } : never\n>\n\n/**\n * Narrows matches based on a path\n * @experimental\n */\nexport const isMatch = <TMatch, TPath extends string>(\n match: TMatch,\n path: Constrain<TPath, IsMatch<TMatch, TPath>['path']>,\n): match is IsMatch<TMatch, TPath>['result'] => {\n const parts = (path as string).split('.')\n let part\n let i = 0\n let value: any = match\n\n while ((part = parts[i++]) != null && value != null) {\n value = value[part]\n }\n\n return value != null\n}\n\nexport interface DefaultRouteMatchExtensions {\n scripts?: unknown\n links?: unknown\n headScripts?: unknown\n meta?: unknown\n styles?: unknown\n}\n\nexport interface RouteMatchExtensions extends DefaultRouteMatchExtensions {}\n\nexport interface RouteMatch<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n out TLoaderData,\n out TAllContext,\n out TLoaderDeps,\n> extends RouteMatchExtensions {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n params: TAllParams\n _strictParams: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n _nonReactive: {\n /** @internal */\n beforeLoadPromise?: ControlledPromise<void>\n /** @internal */\n loaderPromise?: ControlledPromise<void>\n /** @internal */\n pendingTimeout?: ReturnType<typeof setTimeout>\n loadPromise?: ControlledPromise<void>\n displayPendingPromise?: Promise<void>\n minPendingPromise?: ControlledPromise<void>\n dehydrated?: boolean\n /** @internal */\n error?: unknown\n }\n loaderData?: TLoaderData\n /** @internal */\n __routeContext?: Record<string, unknown>\n /** @internal */\n __beforeLoadContext?: Record<string, unknown>\n context: TAllContext\n search: TFullSearchSchema\n _strictSearch: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n /** This attribute is not reactive */\n ssr?: SSROption\n _forcePending?: boolean\n _displayPending?: boolean\n}\n\nexport interface PreValidationErrorHandlingRouteMatch<\n TRouteId,\n TFullPath,\n TAllParams,\n TFullSearchSchema,\n> {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n search:\n | { status: 'success'; value: TFullSearchSchema }\n | { status: 'error'; error: unknown }\n params:\n | { status: 'success'; value: TAllParams }\n | { status: 'error'; error: unknown }\n staticData: StaticDataRouteOption\n ssr?: boolean | 'data-only'\n}\n\nexport type MakePreValidationErrorHandlingRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? PreValidationErrorHandlingRouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema']\n >\n : never\n\nexport type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<\n TRoute['types']['id'],\n TRoute['types']['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n>\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n> = RouteMatch<\n TRouteId,\n RouteById<TRouteTree, TRouteId>['types']['fullPath'],\n TStrict extends false\n ? AllParams<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allParams'],\n TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n TStrict extends false\n ? AllLoaderData<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['loaderData'],\n TStrict extends false\n ? AllContext<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allContext'],\n RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport type MakeRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? RouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n >\n : never\n\n/**\n * The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)\n */\nexport interface MatchRouteOptions {\n /**\n * If `true`, will match against pending location instead of the current location.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)\n */\n pending?: boolean\n /**\n * If `true`, will match against the current location with case sensitivity.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)\n */\n caseSensitive?: boolean\n /**\n * If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)\n */\n includeSearch?: boolean\n /**\n * If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)\n */\n fuzzy?: boolean\n}\n"],"names":[],"mappings":"AA2FO,MAAM,UAAU,CACrB,OACA,SAC8C;AAC9C,QAAM,QAAS,KAAgB,MAAM,GAAG;AACxC,MAAI;AACJ,MAAI,IAAI;AACR,MAAI,QAAa;AAEjB,UAAQ,OAAO,MAAM,GAAG,MAAM,QAAQ,SAAS,MAAM;AACnD,YAAQ,MAAM,IAAI;AAAA,EACpB;AAEA,SAAO,SAAS;AAClB;"}
1
+ {"version":3,"file":"Matches.js","sources":["../../src/Matches.ts"],"sourcesContent":["import type { AnyRoute, StaticDataRouteOption } from './route'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteIds,\n} from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, SSROption } from './router'\nimport type { Constrain, ControlledPromise } from './utils'\n\nexport type AnyMatchAndValue = { match: any; value: any }\n\nexport type FindValueByIndex<\n TKey,\n TValue extends ReadonlyArray<any>,\n> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never\n\nexport type FindValueByKey<TKey, TValue> =\n TValue extends ReadonlyArray<any>\n ? FindValueByIndex<TKey, TValue>\n : TValue[TKey & keyof TValue]\n\nexport type CreateMatchAndValue<TMatch, TValue> = TValue extends any\n ? {\n match: TMatch\n value: TValue\n }\n : never\n\nexport type NextMatchAndValue<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? CreateMatchAndValue<\n TMatchAndValue['match'],\n FindValueByKey<TKey, TMatchAndValue['value']>\n >\n : never\n\nexport type IsMatchKeyOf<TValue> =\n TValue extends ReadonlyArray<any>\n ? number extends TValue['length']\n ? `${number}`\n : keyof TValue & `${number}`\n : TValue extends object\n ? keyof TValue & string\n : never\n\nexport type IsMatchPath<\n TParentPath extends string,\n TMatchAndValue extends AnyMatchAndValue,\n> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`\n\nexport type IsMatchResult<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? TKey extends keyof TMatchAndValue['value']\n ? TMatchAndValue['match']\n : never\n : never\n\nexport type IsMatchParse<\n TPath,\n TMatchAndValue extends AnyMatchAndValue,\n TParentPath extends string = '',\n> = TPath extends `${string}.${string}`\n ? TPath extends `${infer TFirst}.${infer TRest}`\n ? IsMatchParse<\n TRest,\n NextMatchAndValue<TFirst, TMatchAndValue>,\n `${TParentPath}${TFirst}.`\n >\n : never\n : {\n path: IsMatchPath<TParentPath, TMatchAndValue>\n result: IsMatchResult<TPath, TMatchAndValue>\n }\n\nexport type IsMatch<TMatch, TPath> = IsMatchParse<\n TPath,\n TMatch extends any ? { match: TMatch; value: TMatch } : never\n>\n\n/**\n * Narrows matches based on a path\n * @experimental\n */\nexport const isMatch = <TMatch, TPath extends string>(\n match: TMatch,\n path: Constrain<TPath, IsMatch<TMatch, TPath>['path']>,\n): match is IsMatch<TMatch, TPath>['result'] => {\n const parts = (path as string).split('.')\n let part\n let i = 0\n let value: any = match\n\n while ((part = parts[i++]) != null && value != null) {\n value = value[part]\n }\n\n return value != null\n}\n\nexport interface DefaultRouteMatchExtensions {\n scripts?: unknown\n links?: unknown\n headScripts?: unknown\n meta?: unknown\n styles?: unknown\n}\n\nexport interface RouteMatchExtensions extends DefaultRouteMatchExtensions {}\n\nexport interface RouteMatch<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n out TLoaderData,\n out TAllContext,\n out TLoaderDeps,\n> extends RouteMatchExtensions {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n params: TAllParams\n _strictParams: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n _nonReactive: {\n /** @internal */\n beforeLoadPromise?: ControlledPromise<void>\n /** @internal */\n loaderPromise?: ControlledPromise<void>\n /** @internal */\n pendingTimeout?: ReturnType<typeof setTimeout>\n loadPromise?: ControlledPromise<void>\n displayPendingPromise?: Promise<void>\n minPendingPromise?: ControlledPromise<void>\n dehydrated?: boolean\n /** @internal */\n error?: unknown\n }\n loaderData?: TLoaderData\n /** @internal */\n __routeContext?: Record<string, unknown>\n /** @internal */\n __beforeLoadContext?: Record<string, unknown>\n context: TAllContext\n search: TFullSearchSchema\n _strictSearch: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n /** This attribute is not reactive */\n ssr?: SSROption\n _forcePending?: boolean\n _displayPending?: boolean\n}\n\nexport interface PreValidationErrorHandlingRouteMatch<\n TRouteId,\n TFullPath,\n TAllParams,\n TFullSearchSchema,\n> {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n search:\n | { status: 'success'; value: TFullSearchSchema }\n | { status: 'error'; error: unknown }\n params:\n | { status: 'success'; value: TAllParams }\n | { status: 'error'; error: unknown }\n staticData: StaticDataRouteOption\n ssr?: boolean | 'data-only'\n}\n\nexport type MakePreValidationErrorHandlingRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? PreValidationErrorHandlingRouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema']\n >\n : never\n\nexport type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<\n TRoute['types']['id'],\n TRoute['types']['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n>\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n> = RouteMatch<\n TRouteId,\n RouteById<TRouteTree, TRouteId>['types']['fullPath'],\n TStrict extends false\n ? AllParams<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allParams'],\n TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n TStrict extends false\n ? AllLoaderData<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['loaderData'],\n TStrict extends false\n ? AllContext<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allContext'],\n RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport type MakeRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? RouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n >\n : never\n\n/**\n * The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)\n */\nexport interface MatchRouteOptions {\n /**\n * If `true`, will match against pending location instead of the current location.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)\n */\n pending?: boolean\n /**\n * If `true`, will match against the current location with case sensitivity.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)\n *\n * @deprecated Declare case sensitivity in the route definition instead, or globally for all routes using the `caseSensitive` option on the router.\n */\n caseSensitive?: boolean\n /**\n * If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)\n */\n includeSearch?: boolean\n /**\n * If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)\n */\n fuzzy?: boolean\n}\n"],"names":[],"mappings":"AA2FO,MAAM,UAAU,CACrB,OACA,SAC8C;AAC9C,QAAM,QAAS,KAAgB,MAAM,GAAG;AACxC,MAAI;AACJ,MAAI,IAAI;AACR,MAAI,QAAa;AAEjB,UAAQ,OAAO,MAAM,GAAG,MAAM,QAAQ,SAAS,MAAM;AACnD,YAAQ,MAAM,IAAI;AAAA,EACpB;AAEA,SAAO,SAAS;AAClB;"}
@@ -10,15 +10,12 @@ export type { ParsedLocation } from './location.js';
10
10
  export type { Manifest, RouterManagedTag } from './manifest.js';
11
11
  export { isMatch } from './Matches.js';
12
12
  export type { AnyMatchAndValue, FindValueByIndex, FindValueByKey, CreateMatchAndValue, NextMatchAndValue, IsMatchKeyOf, IsMatchPath, IsMatchResult, IsMatchParse, IsMatch, RouteMatch, RouteMatchExtensions, MakeRouteMatchUnion, MakeRouteMatch, AnyRouteMatch, MakeRouteMatchFromRoute, MatchRouteOptions, } from './Matches.js';
13
- export { joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, removeTrailingSlash, exactPathTest, resolvePath, parsePathname, interpolatePath, matchPathname, matchByPath, } from './path.js';
14
- export type { Segment } from './path.js';
13
+ export { joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, removeTrailingSlash, exactPathTest, resolvePath, interpolatePath, } from './path.js';
15
14
  export { encode, decode } from './qss.js';
16
15
  export { rootRouteId } from './root.js';
17
16
  export type { RootRouteId } from './root.js';
18
17
  export { BaseRoute, BaseRouteApi, BaseRootRoute } from './route.js';
19
18
  export type { AnyPathParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, SearchFilter, SearchMiddlewareContext, SearchMiddleware, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, InferAllParams, InferAllContext, MetaDescriptor, RouteLinkEntry, SearchValidator, AnySearchValidator, DefaultSearchValidator, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, ResolveParams, ParseParamsFn, StringifyParamsFn, ParamsOptions, UpdatableStaticRouteOption, ContextReturnType, ContextAsyncReturnType, ResolveRouteContext, ResolveLoaderData, RoutePrefix, TrimPath, TrimPathLeft, TrimPathRight, ResolveSearchSchemaFnInput, ResolveSearchSchemaInput, ResolveSearchSchemaFn, ResolveSearchSchema, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveAllContext, BeforeLoadContextParameter, RouteContextParameter, ResolveAllParamsFromParent, AnyRoute, Route, RouteTypes, FullSearchSchemaOption, RemountDepsOptions, MakeRemountDepsOptionsUnion, ResolveFullPath, AnyRouteWithContext, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, RouteContextFn, ContextOptions, RouteContextOptions, BeforeLoadContextOptions, RootRouteOptions, RootRouteOptionsExtensions, UpdatableRouteOptionsExtensions, RouteConstraints, RouteTypesById, RouteMask, RouteExtensions, RouteLazyFn, RouteAddChildrenFn, RouteAddFileChildrenFn, RouteAddFileTypesFn, ResolveOptionalParams, ResolveRequiredParams, RootRoute, FilebaseRouteOptionsInterface, } from './route.js';
20
- export { processRouteTree } from './process-route-tree.js';
21
- export type { ProcessRouteTreeResult } from './process-route-tree.js';
22
19
  export { defaultSerializeError, getLocationChangeInfo, RouterCore, lazyFn, SearchParamError, PathParamError, getInitialRouterState, getMatchedRoutes, trailingSlashOptions, } from './router.js';
23
20
  export type { ViewTransitionOptions, TrailingSlashOption, Register, AnyRouter, AnyRouterWithContext, RegisteredRouter, RouterState, BuildNextOptions, RouterListener, RouterEvent, ListenerFn, RouterEvents, MatchRoutesOpts, RouterOptionsExtensions, DefaultRemountDepsFn, PreloadRouteFn, MatchRouteFn, RouterContextOptions, RouterOptions, RouterConstructorOptions, UpdateFn, ParseLocationFn, InvalidateFn, ControllablePromise, InjectedHtmlEntry, EmitFn, LoadFn, GetMatchFn, SubscribeFn, UpdateMatchFn, CommitLocationFn, GetMatchRoutesFn, MatchRoutesFn, StartTransitionFn, LoadRouteChunkFn, ClearCacheFn, CreateRouterFn, SSROption, } from './router.js';
24
21
  export * from './config.js';
package/dist/esm/index.js CHANGED
@@ -2,11 +2,10 @@ import { TSR_DEFERRED_PROMISE, defer } from "./defer.js";
2
2
  import { preloadWarning } from "./link.js";
3
3
  import { componentTypes } from "./load-matches.js";
4
4
  import { isMatch } from "./Matches.js";
5
- import { cleanPath, exactPathTest, interpolatePath, joinPaths, matchByPath, matchPathname, parsePathname, removeTrailingSlash, resolvePath, trimPath, trimPathLeft, trimPathRight } from "./path.js";
5
+ import { cleanPath, exactPathTest, interpolatePath, joinPaths, removeTrailingSlash, resolvePath, trimPath, trimPathLeft, trimPathRight } from "./path.js";
6
6
  import { decode, encode } from "./qss.js";
7
7
  import { rootRouteId } from "./root.js";
8
8
  import { BaseRootRoute, BaseRoute, BaseRouteApi } from "./route.js";
9
- import { processRouteTree } from "./process-route-tree.js";
10
9
  import { PathParamError, RouterCore, SearchParamError, defaultSerializeError, getInitialRouterState, getLocationChangeInfo, getMatchedRoutes, lazyFn, trailingSlashOptions } from "./router.js";
11
10
  import { createRouterConfig } from "./config.js";
12
11
  import { retainSearchParams, stripSearchParams } from "./searchMiddleware.js";
@@ -64,14 +63,10 @@ export {
64
63
  lazyFn,
65
64
  makeSerovalPlugin,
66
65
  makeSsrSerovalPlugin,
67
- matchByPath,
68
- matchPathname,
69
66
  notFound,
70
- parsePathname,
71
67
  parseRedirect,
72
68
  parseSearchWith,
73
69
  preloadWarning,
74
- processRouteTree,
75
70
  redirect,
76
71
  removeTrailingSlash,
77
72
  replaceEqualDeep,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,6 @@
1
1
  export type LRUCache<TKey, TValue> = {
2
2
  get: (key: TKey) => TValue | undefined;
3
3
  set: (key: TKey, value: TValue) => void;
4
+ clear: () => void;
4
5
  };
5
6
  export declare function createLRUCache<TKey, TValue>(max: number): LRUCache<TKey, TValue>;
@@ -53,6 +53,11 @@ function createLRUCache(max) {
53
53
  if (!oldest) oldest = entry;
54
54
  cache.set(key, entry);
55
55
  }
56
+ },
57
+ clear() {
58
+ cache.clear();
59
+ oldest = void 0;
60
+ newest = void 0;
56
61
  }
57
62
  };
58
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lru-cache.js","sources":["../../src/lru-cache.ts"],"sourcesContent":["export type LRUCache<TKey, TValue> = {\n get: (key: TKey) => TValue | undefined\n set: (key: TKey, value: TValue) => void\n}\n\nexport function createLRUCache<TKey, TValue>(\n max: number,\n): LRUCache<TKey, TValue> {\n type Node = { prev?: Node; next?: Node; key: TKey; value: TValue }\n const cache = new Map<TKey, Node>()\n let oldest: Node | undefined\n let newest: Node | undefined\n\n const touch = (entry: Node) => {\n if (!entry.next) return\n if (!entry.prev) {\n entry.next.prev = undefined\n oldest = entry.next\n entry.next = undefined\n if (newest) {\n entry.prev = newest\n newest.next = entry\n }\n } else {\n entry.prev.next = entry.next\n entry.next.prev = entry.prev\n entry.next = undefined\n if (newest) {\n newest.next = entry\n entry.prev = newest\n }\n }\n newest = entry\n }\n\n return {\n get(key) {\n const entry = cache.get(key)\n if (!entry) return undefined\n touch(entry)\n return entry.value\n },\n set(key, value) {\n if (cache.size >= max && oldest) {\n const toDelete = oldest\n cache.delete(toDelete.key)\n if (toDelete.next) {\n oldest = toDelete.next\n toDelete.next.prev = undefined\n }\n if (toDelete === newest) {\n newest = undefined\n }\n }\n const existing = cache.get(key)\n if (existing) {\n existing.value = value\n touch(existing)\n } else {\n const entry: Node = { key, value, prev: newest }\n if (newest) newest.next = entry\n newest = entry\n if (!oldest) oldest = entry\n cache.set(key, entry)\n }\n },\n }\n}\n"],"names":[],"mappings":"AAKO,SAAS,eACd,KACwB;AAExB,QAAM,4BAAY,IAAA;AAClB,MAAI;AACJ,MAAI;AAEJ,QAAM,QAAQ,CAAC,UAAgB;AAC7B,QAAI,CAAC,MAAM,KAAM;AACjB,QAAI,CAAC,MAAM,MAAM;AACf,YAAM,KAAK,OAAO;AAClB,eAAS,MAAM;AACf,YAAM,OAAO;AACb,UAAI,QAAQ;AACV,cAAM,OAAO;AACb,eAAO,OAAO;AAAA,MAChB;AAAA,IACF,OAAO;AACL,YAAM,KAAK,OAAO,MAAM;AACxB,YAAM,KAAK,OAAO,MAAM;AACxB,YAAM,OAAO;AACb,UAAI,QAAQ;AACV,eAAO,OAAO;AACd,cAAM,OAAO;AAAA,MACf;AAAA,IACF;AACA,aAAS;AAAA,EACX;AAEA,SAAO;AAAA,IACL,IAAI,KAAK;AACP,YAAM,QAAQ,MAAM,IAAI,GAAG;AAC3B,UAAI,CAAC,MAAO,QAAO;AACnB,YAAM,KAAK;AACX,aAAO,MAAM;AAAA,IACf;AAAA,IACA,IAAI,KAAK,OAAO;AACd,UAAI,MAAM,QAAQ,OAAO,QAAQ;AAC/B,cAAM,WAAW;AACjB,cAAM,OAAO,SAAS,GAAG;AACzB,YAAI,SAAS,MAAM;AACjB,mBAAS,SAAS;AAClB,mBAAS,KAAK,OAAO;AAAA,QACvB;AACA,YAAI,aAAa,QAAQ;AACvB,mBAAS;AAAA,QACX;AAAA,MACF;AACA,YAAM,WAAW,MAAM,IAAI,GAAG;AAC9B,UAAI,UAAU;AACZ,iBAAS,QAAQ;AACjB,cAAM,QAAQ;AAAA,MAChB,OAAO;AACL,cAAM,QAAc,EAAE,KAAK,OAAO,MAAM,OAAA;AACxC,YAAI,eAAe,OAAO;AAC1B,iBAAS;AACT,YAAI,CAAC,OAAQ,UAAS;AACtB,cAAM,IAAI,KAAK,KAAK;AAAA,MACtB;AAAA,IACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"lru-cache.js","sources":["../../src/lru-cache.ts"],"sourcesContent":["export type LRUCache<TKey, TValue> = {\n get: (key: TKey) => TValue | undefined\n set: (key: TKey, value: TValue) => void\n clear: () => void\n}\n\nexport function createLRUCache<TKey, TValue>(\n max: number,\n): LRUCache<TKey, TValue> {\n type Node = { prev?: Node; next?: Node; key: TKey; value: TValue }\n const cache = new Map<TKey, Node>()\n let oldest: Node | undefined\n let newest: Node | undefined\n\n const touch = (entry: Node) => {\n if (!entry.next) return\n if (!entry.prev) {\n entry.next.prev = undefined\n oldest = entry.next\n entry.next = undefined\n if (newest) {\n entry.prev = newest\n newest.next = entry\n }\n } else {\n entry.prev.next = entry.next\n entry.next.prev = entry.prev\n entry.next = undefined\n if (newest) {\n newest.next = entry\n entry.prev = newest\n }\n }\n newest = entry\n }\n\n return {\n get(key) {\n const entry = cache.get(key)\n if (!entry) return undefined\n touch(entry)\n return entry.value\n },\n set(key, value) {\n if (cache.size >= max && oldest) {\n const toDelete = oldest\n cache.delete(toDelete.key)\n if (toDelete.next) {\n oldest = toDelete.next\n toDelete.next.prev = undefined\n }\n if (toDelete === newest) {\n newest = undefined\n }\n }\n const existing = cache.get(key)\n if (existing) {\n existing.value = value\n touch(existing)\n } else {\n const entry: Node = { key, value, prev: newest }\n if (newest) newest.next = entry\n newest = entry\n if (!oldest) oldest = entry\n cache.set(key, entry)\n }\n },\n clear() {\n cache.clear()\n oldest = undefined\n newest = undefined\n },\n }\n}\n"],"names":[],"mappings":"AAMO,SAAS,eACd,KACwB;AAExB,QAAM,4BAAY,IAAA;AAClB,MAAI;AACJ,MAAI;AAEJ,QAAM,QAAQ,CAAC,UAAgB;AAC7B,QAAI,CAAC,MAAM,KAAM;AACjB,QAAI,CAAC,MAAM,MAAM;AACf,YAAM,KAAK,OAAO;AAClB,eAAS,MAAM;AACf,YAAM,OAAO;AACb,UAAI,QAAQ;AACV,cAAM,OAAO;AACb,eAAO,OAAO;AAAA,MAChB;AAAA,IACF,OAAO;AACL,YAAM,KAAK,OAAO,MAAM;AACxB,YAAM,KAAK,OAAO,MAAM;AACxB,YAAM,OAAO;AACb,UAAI,QAAQ;AACV,eAAO,OAAO;AACd,cAAM,OAAO;AAAA,MACf;AAAA,IACF;AACA,aAAS;AAAA,EACX;AAEA,SAAO;AAAA,IACL,IAAI,KAAK;AACP,YAAM,QAAQ,MAAM,IAAI,GAAG;AAC3B,UAAI,CAAC,MAAO,QAAO;AACnB,YAAM,KAAK;AACX,aAAO,MAAM;AAAA,IACf;AAAA,IACA,IAAI,KAAK,OAAO;AACd,UAAI,MAAM,QAAQ,OAAO,QAAQ;AAC/B,cAAM,WAAW;AACjB,cAAM,OAAO,SAAS,GAAG;AACzB,YAAI,SAAS,MAAM;AACjB,mBAAS,SAAS;AAClB,mBAAS,KAAK,OAAO;AAAA,QACvB;AACA,YAAI,aAAa,QAAQ;AACvB,mBAAS;AAAA,QACX;AAAA,MACF;AACA,YAAM,WAAW,MAAM,IAAI,GAAG;AAC9B,UAAI,UAAU;AACZ,iBAAS,QAAQ;AACjB,cAAM,QAAQ;AAAA,MAChB,OAAO;AACL,cAAM,QAAc,EAAE,KAAK,OAAO,MAAM,OAAA;AACxC,YAAI,eAAe,OAAO;AAC1B,iBAAS;AACT,YAAI,CAAC,OAAQ,UAAS;AACtB,cAAM,IAAI,KAAK,KAAK;AAAA,MACtB;AAAA,IACF;AAAA,IACA,QAAQ;AACN,YAAM,MAAA;AACN,eAAS;AACT,eAAS;AAAA,IACX;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,177 @@
1
+ import { LRUCache } from './lru-cache.js';
2
+ export declare const SEGMENT_TYPE_PATHNAME = 0;
3
+ export declare const SEGMENT_TYPE_PARAM = 1;
4
+ export declare const SEGMENT_TYPE_WILDCARD = 2;
5
+ export declare const SEGMENT_TYPE_OPTIONAL_PARAM = 3;
6
+ export type SegmentKind = typeof SEGMENT_TYPE_PATHNAME | typeof SEGMENT_TYPE_PARAM | typeof SEGMENT_TYPE_WILDCARD | typeof SEGMENT_TYPE_OPTIONAL_PARAM;
7
+ type ParsedSegment = Uint16Array & {
8
+ /** segment type (0 = pathname, 1 = param, 2 = wildcard, 3 = optional param) */
9
+ 0: SegmentKind;
10
+ /** index of the end of the prefix */
11
+ 1: number;
12
+ /** index of the start of the value */
13
+ 2: number;
14
+ /** index of the end of the value */
15
+ 3: number;
16
+ /** index of the start of the suffix */
17
+ 4: number;
18
+ /** index of the end of the segment */
19
+ 5: number;
20
+ };
21
+ /**
22
+ * Populates the `output` array with the parsed representation of the given `segment` string.
23
+ *
24
+ * Usage:
25
+ * ```ts
26
+ * let output
27
+ * let cursor = 0
28
+ * while (cursor < path.length) {
29
+ * output = parseSegment(path, cursor, output)
30
+ * const end = output[5]
31
+ * cursor = end + 1
32
+ * ```
33
+ *
34
+ * `output` is stored outside to avoid allocations during repeated calls. It doesn't need to be typed
35
+ * or initialized, it will be done automatically.
36
+ */
37
+ export declare function parseSegment(
38
+ /** The full path string containing the segment. */
39
+ path: string,
40
+ /** The starting index of the segment within the path. */
41
+ start: number,
42
+ /** A Uint16Array (length: 6) to populate with the parsed segment data. */
43
+ output?: Uint16Array): ParsedSegment;
44
+ type StaticSegmentNode<T extends RouteLike> = SegmentNode<T> & {
45
+ kind: typeof SEGMENT_TYPE_PATHNAME;
46
+ };
47
+ type DynamicSegmentNode<T extends RouteLike> = SegmentNode<T> & {
48
+ kind: typeof SEGMENT_TYPE_PARAM | typeof SEGMENT_TYPE_WILDCARD | typeof SEGMENT_TYPE_OPTIONAL_PARAM;
49
+ prefix?: string;
50
+ suffix?: string;
51
+ caseSensitive: boolean;
52
+ };
53
+ type AnySegmentNode<T extends RouteLike> = StaticSegmentNode<T> | DynamicSegmentNode<T>;
54
+ type SegmentNode<T extends RouteLike> = {
55
+ kind: SegmentKind;
56
+ /** Static segments (highest priority) */
57
+ static: Map<string, StaticSegmentNode<T>> | null;
58
+ /** Case insensitive static segments (second highest priority) */
59
+ staticInsensitive: Map<string, StaticSegmentNode<T>> | null;
60
+ /** Dynamic segments ($param) */
61
+ dynamic: Array<DynamicSegmentNode<T>> | null;
62
+ /** Optional dynamic segments ({-$param}) */
63
+ optional: Array<DynamicSegmentNode<T>> | null;
64
+ /** Wildcard segments ($ - lowest priority) */
65
+ wildcard: Array<DynamicSegmentNode<T>> | null;
66
+ /** Terminal route (if this path can end here) */
67
+ route: T | null;
68
+ /** The full path for this segment node (will only be valid on leaf nodes) */
69
+ fullPath: string;
70
+ parent: AnySegmentNode<T> | null;
71
+ depth: number;
72
+ /** is it an index route (trailing / path), only valid for nodes with a `route` */
73
+ isIndex: boolean;
74
+ /** Same as `route`, but only present if both an "index route" and a "layout route" exist at this path */
75
+ notFound: T | null;
76
+ };
77
+ type RouteLike = {
78
+ path?: string;
79
+ children?: Array<RouteLike>;
80
+ parentRoute?: RouteLike;
81
+ isRoot?: boolean;
82
+ options?: {
83
+ caseSensitive?: boolean;
84
+ };
85
+ } & ({
86
+ fullPath: string;
87
+ from?: never;
88
+ } | {
89
+ fullPath?: never;
90
+ from: string;
91
+ });
92
+ export type ProcessedTree<TTree extends Extract<RouteLike, {
93
+ fullPath: string;
94
+ }>, TFlat extends Extract<RouteLike, {
95
+ from: string;
96
+ }>, TSingle extends Extract<RouteLike, {
97
+ from: string;
98
+ }>> = {
99
+ /** a representation of the `routeTree` as a segment tree */
100
+ segmentTree: AnySegmentNode<TTree>;
101
+ /** a mini route tree generated from the flat `routeMasks` list */
102
+ masksTree: AnySegmentNode<TFlat> | null;
103
+ /** @deprecated keep until v2 so that `router.matchRoute` can keep not caring about the actual route tree */
104
+ singleCache: Map<any, AnySegmentNode<TSingle>>;
105
+ /** a cache of route matches from the `segmentTree` */
106
+ matchCache: LRUCache<string, ReturnType<typeof findMatch<TTree>>>;
107
+ /** a cache of route matches from the `masksTree` */
108
+ flatCache: LRUCache<string, ReturnType<typeof findMatch<TFlat>>> | null;
109
+ };
110
+ export declare function processRouteMasks<TRouteLike extends Extract<RouteLike, {
111
+ from: string;
112
+ }>>(routeList: Array<TRouteLike>, processedTree: ProcessedTree<any, TRouteLike, any>): void;
113
+ /**
114
+ * Take an arbitrary list of routes, create a tree from them (if it hasn't been created already), and match a path against it.
115
+ */
116
+ export declare function findFlatMatch<T extends Extract<RouteLike, {
117
+ from: string;
118
+ }>>(
119
+ /** The path to match. */
120
+ path: string,
121
+ /** The `processedTree` returned by the initial `processRouteTree` call. */
122
+ processedTree: ProcessedTree<any, T, any>): {
123
+ route: T;
124
+ params: Record<string, string>;
125
+ } | null;
126
+ /**
127
+ * @deprecated keep until v2 so that `router.matchRoute` can keep not caring about the actual route tree
128
+ */
129
+ export declare function findSingleMatch(from: string, caseSensitive: boolean, fuzzy: boolean, path: string, processedTree: ProcessedTree<any, any, {
130
+ from: string;
131
+ }>): {
132
+ route: {
133
+ from: string;
134
+ };
135
+ params: Record<string, string>;
136
+ } | null;
137
+ export declare function findRouteMatch<T extends Extract<RouteLike, {
138
+ fullPath: string;
139
+ }>>(
140
+ /** The path to match against the route tree. */
141
+ path: string,
142
+ /** The `processedTree` returned by the initial `processRouteTree` call. */
143
+ processedTree: ProcessedTree<T, any, any>,
144
+ /** If `true`, allows fuzzy matching (partial matches), i.e. which node in the tree would have been an exact match if the `path` had been shorter? */
145
+ fuzzy?: boolean): {
146
+ route: T;
147
+ params: Record<string, string>;
148
+ } | null;
149
+ /** Trim trailing slashes (except preserving root '/'). */
150
+ export declare function trimPathRight(path: string): string;
151
+ /**
152
+ * Processes a route tree into a segment trie for efficient path matching.
153
+ * Also builds lookup maps for routes by ID and by trimmed full path.
154
+ */
155
+ export declare function processRouteTree<TRouteLike extends Extract<RouteLike, {
156
+ fullPath: string;
157
+ }> & {
158
+ id: string;
159
+ }>(
160
+ /** The root of the route tree to process. */
161
+ routeTree: TRouteLike,
162
+ /** Whether matching should be case sensitive by default (overridden by individual route options). */
163
+ caseSensitive?: boolean,
164
+ /** Optional callback invoked for each route during processing. */
165
+ initRoute?: (route: TRouteLike, index: number) => void): {
166
+ /** Should be considered a black box, needs to be provided to all matching functions in this module. */
167
+ processedTree: ProcessedTree<TRouteLike, any, any>;
168
+ /** A lookup map of routes by their unique IDs. */
169
+ routesById: Record<string, TRouteLike>;
170
+ /** A lookup map of routes by their trimmed full paths. */
171
+ routesByPath: Record<string, TRouteLike>;
172
+ };
173
+ declare function findMatch<T extends RouteLike>(path: string, segmentTree: AnySegmentNode<T>, fuzzy?: boolean): {
174
+ route: T;
175
+ params: Record<string, string>;
176
+ } | null;
177
+ export {};