@tanstack/react-router 1.53.0 → 1.56.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/cjs/Matches.cjs.map +1 -1
  2. package/dist/cjs/Matches.d.cts +2 -2
  3. package/dist/cjs/RouterProvider.cjs.map +1 -1
  4. package/dist/cjs/RouterProvider.d.cts +2 -2
  5. package/dist/cjs/fileRoute.cjs.map +1 -1
  6. package/dist/cjs/fileRoute.d.cts +10 -1
  7. package/dist/cjs/index.d.cts +3 -3
  8. package/dist/cjs/link.cjs.map +1 -1
  9. package/dist/cjs/link.d.cts +22 -21
  10. package/dist/cjs/path.cjs +1 -1
  11. package/dist/cjs/path.cjs.map +1 -1
  12. package/dist/cjs/redirects.cjs.map +1 -1
  13. package/dist/cjs/redirects.d.cts +2 -2
  14. package/dist/cjs/route.cjs +18 -2
  15. package/dist/cjs/route.cjs.map +1 -1
  16. package/dist/cjs/route.d.cts +8 -5
  17. package/dist/cjs/routeInfo.d.cts +32 -21
  18. package/dist/cjs/router.cjs +4 -1
  19. package/dist/cjs/router.cjs.map +1 -1
  20. package/dist/cjs/router.d.cts +2 -2
  21. package/dist/cjs/useLoaderData.cjs.map +1 -1
  22. package/dist/cjs/useLoaderData.d.cts +3 -3
  23. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  24. package/dist/cjs/useLoaderDeps.d.cts +2 -2
  25. package/dist/cjs/useMatch.cjs.map +1 -1
  26. package/dist/cjs/useMatch.d.cts +2 -2
  27. package/dist/cjs/useNavigate.cjs.map +1 -1
  28. package/dist/cjs/useNavigate.d.cts +2 -2
  29. package/dist/cjs/useParams.cjs.map +1 -1
  30. package/dist/cjs/useParams.d.cts +2 -2
  31. package/dist/cjs/useRouteContext.cjs.map +1 -1
  32. package/dist/cjs/useRouteContext.d.cts +2 -2
  33. package/dist/cjs/useSearch.cjs.map +1 -1
  34. package/dist/cjs/useSearch.d.cts +2 -2
  35. package/dist/esm/Matches.d.ts +2 -2
  36. package/dist/esm/Matches.js.map +1 -1
  37. package/dist/esm/RouterProvider.d.ts +2 -2
  38. package/dist/esm/RouterProvider.js.map +1 -1
  39. package/dist/esm/fileRoute.d.ts +10 -1
  40. package/dist/esm/fileRoute.js.map +1 -1
  41. package/dist/esm/index.d.ts +3 -3
  42. package/dist/esm/link.d.ts +22 -21
  43. package/dist/esm/link.js.map +1 -1
  44. package/dist/esm/path.js +1 -1
  45. package/dist/esm/path.js.map +1 -1
  46. package/dist/esm/redirects.d.ts +2 -2
  47. package/dist/esm/redirects.js.map +1 -1
  48. package/dist/esm/route.d.ts +8 -5
  49. package/dist/esm/route.js +18 -2
  50. package/dist/esm/route.js.map +1 -1
  51. package/dist/esm/routeInfo.d.ts +32 -21
  52. package/dist/esm/router.d.ts +2 -2
  53. package/dist/esm/router.js +4 -1
  54. package/dist/esm/router.js.map +1 -1
  55. package/dist/esm/useLoaderData.d.ts +3 -3
  56. package/dist/esm/useLoaderData.js.map +1 -1
  57. package/dist/esm/useLoaderDeps.d.ts +2 -2
  58. package/dist/esm/useLoaderDeps.js.map +1 -1
  59. package/dist/esm/useMatch.d.ts +2 -2
  60. package/dist/esm/useMatch.js.map +1 -1
  61. package/dist/esm/useNavigate.d.ts +2 -2
  62. package/dist/esm/useNavigate.js.map +1 -1
  63. package/dist/esm/useParams.d.ts +2 -2
  64. package/dist/esm/useParams.js.map +1 -1
  65. package/dist/esm/useRouteContext.d.ts +2 -2
  66. package/dist/esm/useRouteContext.js.map +1 -1
  67. package/dist/esm/useSearch.d.ts +2 -2
  68. package/dist/esm/useSearch.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/Matches.tsx +15 -22
  71. package/src/RouterProvider.tsx +4 -4
  72. package/src/fileRoute.ts +25 -1
  73. package/src/index.tsx +10 -1
  74. package/src/link.tsx +81 -76
  75. package/src/path.ts +1 -1
  76. package/src/redirects.ts +8 -8
  77. package/src/route.ts +98 -9
  78. package/src/routeInfo.ts +116 -38
  79. package/src/router.ts +9 -5
  80. package/src/useLoaderData.tsx +3 -3
  81. package/src/useLoaderDeps.tsx +3 -3
  82. package/src/useMatch.tsx +9 -3
  83. package/src/useNavigate.tsx +5 -5
  84. package/src/useParams.tsx +10 -3
  85. package/src/useRouteContext.ts +8 -3
  86. package/src/useSearch.tsx +11 -4
@@ -1 +1 @@
1
- {"version":3,"file":"path.cjs","sources":["../../src/path.ts"],"sourcesContent":["import { last } from './utils'\nimport type { MatchLocation } from './RouterProvider'\nimport type { AnyPathParams } from './route'\n\nexport interface Segment {\n type: 'pathname' | 'param' | 'wildcard'\n value: string\n}\n\nexport function joinPaths(paths: Array<string | undefined>) {\n return cleanPath(\n paths\n .filter((val) => {\n return val !== undefined\n })\n .join('/'),\n )\n}\n\nexport function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n\nexport function trimPathRight(path: string) {\n return path === '/' ? path : path.replace(/\\/{1,}$/, '')\n}\n\nexport function trimPath(path: string) {\n return trimPathRight(trimPathLeft(path))\n}\n\nexport function removeTrailingSlash(value: string, basepath: string): string {\n if (value.endsWith('/') && value !== '/' && value !== `${basepath}/`) {\n return value.slice(0, -1)\n }\n return value\n}\n\n// intended to only compare path name\n// see the usage in the isActive under useLinkProps\n// /sample/path1 = /sample/path1/\n// /sample/path1/some <> /sample/path1\nexport function exactPathTest(\n pathName1: string,\n pathName2: string,\n basepath: string,\n): boolean {\n return (\n removeTrailingSlash(pathName1, basepath) ===\n removeTrailingSlash(pathName2, basepath)\n )\n}\n\n// When resolving relative paths, we treat all paths as if they are trailing slash\n// documents. All trailing slashes are removed after the path is resolved.\n// Here are a few examples:\n//\n// /a/b/c + ./d = /a/b/c/d\n// /a/b/c + ../d = /a/b/d\n// /a/b/c + ./d/ = /a/b/c/d\n// /a/b/c + ../d/ = /a/b/d\n// /a/b/c + ./ = /a/b/c\n//\n// Absolute paths that start with `/` short circuit the resolution process to the root\n// path.\n//\n// Here are some examples:\n//\n// /a/b/c + /d = /d\n// /a/b/c + /d/ = /d\n// /a/b/c + / = /\n//\n// Non-.-prefixed paths are still treated as relative paths, resolved like `./`\n//\n// Here are some examples:\n//\n// /a/b/c + d = /a/b/c/d\n// /a/b/c + d/ = /a/b/c/d\n// /a/b/c + d/e = /a/b/c/d/e\ninterface ResolvePathOptions {\n basepath: string\n base: string\n to: string\n trailingSlash?: 'always' | 'never' | 'preserve'\n}\n\nexport function resolvePath({\n basepath,\n base,\n to,\n trailingSlash = 'never',\n}: ResolvePathOptions) {\n base = removeBasepath(basepath, base)\n to = removeBasepath(basepath, to)\n\n let baseSegments = parsePathname(base)\n const toSegments = parsePathname(to)\n\n if (baseSegments.length > 1 && last(baseSegments)?.value === '/') {\n baseSegments.pop()\n }\n\n toSegments.forEach((toSegment, index) => {\n if (toSegment.value === '/') {\n if (!index) {\n // Leading slash\n baseSegments = [toSegment]\n } else if (index === toSegments.length - 1) {\n // Trailing Slash\n baseSegments.push(toSegment)\n } else {\n // ignore inter-slashes\n }\n } else if (toSegment.value === '..') {\n baseSegments.pop()\n } else if (toSegment.value === '.') {\n // ignore\n } else {\n baseSegments.push(toSegment)\n }\n })\n\n if (baseSegments.length > 1) {\n if (last(baseSegments)?.value === '/') {\n if (trailingSlash === 'never') {\n baseSegments.pop()\n }\n } else if (trailingSlash === 'always') {\n baseSegments.push({ type: 'pathname', value: '/' })\n }\n }\n\n const joined = joinPaths([basepath, ...baseSegments.map((d) => d.value)])\n return cleanPath(joined)\n}\n\nexport function parsePathname(pathname?: string): Array<Segment> {\n if (!pathname) {\n return []\n }\n\n pathname = cleanPath(pathname)\n\n const segments: Array<Segment> = []\n\n if (pathname.slice(0, 1) === '/') {\n pathname = pathname.substring(1)\n segments.push({\n type: 'pathname',\n value: '/',\n })\n }\n\n if (!pathname) {\n return segments\n }\n\n // Remove empty segments and '.' segments\n const split = pathname.split('/').filter(Boolean)\n\n segments.push(\n ...split.map((part): Segment => {\n if (part === '$' || part === '*') {\n return {\n type: 'wildcard',\n value: part,\n }\n }\n\n if (part.charAt(0) === '$') {\n return {\n type: 'param',\n value: part,\n }\n }\n\n return {\n type: 'pathname',\n value: decodeURIComponent(part),\n }\n }),\n )\n\n if (pathname.slice(-1) === '/') {\n pathname = pathname.substring(1)\n segments.push({\n type: 'pathname',\n value: '/',\n })\n }\n\n return segments\n}\n\ninterface InterpolatePathOptions {\n path?: string\n params: Record<string, unknown>\n leaveWildcards?: boolean\n leaveParams?: boolean\n}\n\nexport function interpolatePath({\n path,\n params,\n leaveWildcards,\n leaveParams,\n}: InterpolatePathOptions) {\n const interpolatedPathSegments = parsePathname(path)\n const encodedParams: any = {}\n\n for (const [key, value] of Object.entries(params)) {\n const isValueString = typeof value === 'string'\n\n if (['*', '_splat'].includes(key)) {\n // the splat/catch-all routes shouldn't have the '/' encoded out\n encodedParams[key] = isValueString ? encodeURI(value) : value\n } else {\n encodedParams[key] = isValueString ? encodeURIComponent(value) : value\n }\n }\n\n return joinPaths(\n interpolatedPathSegments.map((segment) => {\n if (segment.type === 'wildcard') {\n const value = encodedParams._splat\n if (leaveWildcards) return `${segment.value}${value ?? ''}`\n return value\n }\n\n if (segment.type === 'param') {\n if (leaveParams) {\n const value = encodedParams[segment.value]\n return `${segment.value}${value ?? ''}`\n }\n return encodedParams![segment.value.substring(1)] ?? 'undefined'\n }\n\n return segment.value\n }),\n )\n}\n\nexport function matchPathname(\n basepath: string,\n currentPathname: string,\n matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>,\n): AnyPathParams | undefined {\n const pathParams = matchByPath(basepath, currentPathname, matchLocation)\n // const searchMatched = matchBySearch(location.search, matchLocation)\n\n if (matchLocation.to && !pathParams) {\n return\n }\n\n return pathParams ?? {}\n}\n\nexport function removeBasepath(basepath: string, pathname: string) {\n switch (true) {\n // default behaviour is to serve app from the root - pathname\n // left untouched\n case basepath === '/':\n return pathname\n\n // shortcut for removing the basepath from the equal pathname\n case pathname === basepath:\n return ''\n\n // in case pathname is shorter than basepath - there is\n // nothing to remove\n case pathname.length < basepath.length:\n return pathname\n\n // avoid matching partial segments - strict equality handled\n // earlier, otherwise, basepath separated from pathname with\n // separator, therefore lack of separator means partial\n // segment match (`/app` should not match `/application`)\n case pathname[basepath.length] !== '/':\n return pathname\n\n // remove the basepath from the pathname in case there is any\n case pathname.startsWith(basepath):\n return pathname.slice(basepath.length)\n\n // otherwise, return the pathname as is\n default:\n return pathname\n }\n}\n\nexport function matchByPath(\n basepath: string,\n from: string,\n matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>,\n): Record<string, string> | undefined {\n // Remove the base path from the pathname\n from = removeBasepath(basepath, from)\n // Default to to $ (wildcard)\n const to = removeBasepath(basepath, `${matchLocation.to ?? '$'}`)\n\n // Parse the from and to\n const baseSegments = parsePathname(from)\n const routeSegments = parsePathname(to)\n\n if (!from.startsWith('/')) {\n baseSegments.unshift({\n type: 'pathname',\n value: '/',\n })\n }\n\n if (!to.startsWith('/')) {\n routeSegments.unshift({\n type: 'pathname',\n value: '/',\n })\n }\n\n const params: Record<string, string> = {}\n\n const isMatch = (() => {\n for (\n let i = 0;\n i < Math.max(baseSegments.length, routeSegments.length);\n i++\n ) {\n const baseSegment = baseSegments[i]\n const routeSegment = routeSegments[i]\n\n const isLastBaseSegment = i >= baseSegments.length - 1\n const isLastRouteSegment = i >= routeSegments.length - 1\n\n if (routeSegment) {\n if (routeSegment.type === 'wildcard') {\n const _splat = decodeURI(\n joinPaths(baseSegments.slice(i).map((d) => d.value)),\n )\n // TODO: Deprecate *\n params['*'] = _splat\n params['_splat'] = _splat\n return true\n }\n\n if (routeSegment.type === 'pathname') {\n if (routeSegment.value === '/' && !baseSegment?.value) {\n return true\n }\n\n if (baseSegment) {\n if (matchLocation.caseSensitive) {\n if (routeSegment.value !== baseSegment.value) {\n return false\n }\n } else if (\n routeSegment.value.toLowerCase() !==\n baseSegment.value.toLowerCase()\n ) {\n return false\n }\n }\n }\n\n if (!baseSegment) {\n return false\n }\n\n if (routeSegment.type === 'param') {\n if (baseSegment.value === '/') {\n return false\n }\n if (baseSegment.value.charAt(0) !== '$') {\n params[routeSegment.value.substring(1)] = decodeURIComponent(\n baseSegment.value,\n )\n }\n }\n }\n\n if (!isLastBaseSegment && isLastRouteSegment) {\n params['**'] = joinPaths(baseSegments.slice(i + 1).map((d) => d.value))\n return !!matchLocation.fuzzy && routeSegment?.value !== '/'\n }\n }\n\n return true\n })()\n\n return isMatch ? params : undefined\n}\n"],"names":["last"],"mappings":";;;AASO,SAAS,UAAU,OAAkC;AACnD,SAAA;AAAA,IACL,MACG,OAAO,CAAC,QAAQ;AACf,aAAO,QAAQ;AAAA,IAAA,CAChB,EACA,KAAK,GAAG;AAAA,EAAA;AAEf;AAEO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,cAAc,MAAc;AAC1C,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,SAAS,MAAc;AAC9B,SAAA,cAAc,aAAa,IAAI,CAAC;AACzC;AAEgB,SAAA,oBAAoB,OAAe,UAA0B;AACvE,MAAA,MAAM,SAAS,GAAG,KAAK,UAAU,OAAO,UAAU,GAAG,QAAQ,KAAK;AAC7D,WAAA,MAAM,MAAM,GAAG,EAAE;AAAA,EAC1B;AACO,SAAA;AACT;AAMgB,SAAA,cACd,WACA,WACA,UACS;AACT,SACE,oBAAoB,WAAW,QAAQ,MACvC,oBAAoB,WAAW,QAAQ;AAE3C;AAmCO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAClB,GAAuB;;AACd,SAAA,eAAe,UAAU,IAAI;A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E,KAAK,CAAC;AACtE,eAAO,CAAC,CAAC,cAAc,UAAS,6CAAc,WAAU;AAAA,MAC1D;AAAA,IACF;AAEO,WAAA;AAAA,EAAA;AAGT,SAAO,UAAU,SAAS;AAC5B;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"path.cjs","sources":["../../src/path.ts"],"sourcesContent":["import { last } from './utils'\nimport type { MatchLocation } from './RouterProvider'\nimport type { AnyPathParams } from './route'\n\nexport interface Segment {\n type: 'pathname' | 'param' | 'wildcard'\n value: string\n}\n\nexport function joinPaths(paths: Array<string | undefined>) {\n return cleanPath(\n paths\n .filter((val) => {\n return val !== undefined\n })\n .join('/'),\n )\n}\n\nexport function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n\nexport function trimPathRight(path: string) {\n return path === '/' ? path : path.replace(/\\/{1,}$/, '')\n}\n\nexport function trimPath(path: string) {\n return trimPathRight(trimPathLeft(path))\n}\n\nexport function removeTrailingSlash(value: string, basepath: string): string {\n if (value.endsWith('/') && value !== '/' && value !== `${basepath}/`) {\n return value.slice(0, -1)\n }\n return value\n}\n\n// intended to only compare path name\n// see the usage in the isActive under useLinkProps\n// /sample/path1 = /sample/path1/\n// /sample/path1/some <> /sample/path1\nexport function exactPathTest(\n pathName1: string,\n pathName2: string,\n basepath: string,\n): boolean {\n return (\n removeTrailingSlash(pathName1, basepath) ===\n removeTrailingSlash(pathName2, basepath)\n )\n}\n\n// When resolving relative paths, we treat all paths as if they are trailing slash\n// documents. All trailing slashes are removed after the path is resolved.\n// Here are a few examples:\n//\n// /a/b/c + ./d = /a/b/c/d\n// /a/b/c + ../d = /a/b/d\n// /a/b/c + ./d/ = /a/b/c/d\n// /a/b/c + ../d/ = /a/b/d\n// /a/b/c + ./ = /a/b/c\n//\n// Absolute paths that start with `/` short circuit the resolution process to the root\n// path.\n//\n// Here are some examples:\n//\n// /a/b/c + /d = /d\n// /a/b/c + /d/ = /d\n// /a/b/c + / = /\n//\n// Non-.-prefixed paths are still treated as relative paths, resolved like `./`\n//\n// Here are some examples:\n//\n// /a/b/c + d = /a/b/c/d\n// /a/b/c + d/ = /a/b/c/d\n// /a/b/c + d/e = /a/b/c/d/e\ninterface ResolvePathOptions {\n basepath: string\n base: string\n to: string\n trailingSlash?: 'always' | 'never' | 'preserve'\n}\n\nexport function resolvePath({\n basepath,\n base,\n to,\n trailingSlash = 'never',\n}: ResolvePathOptions) {\n base = removeBasepath(basepath, base)\n to = removeBasepath(basepath, to)\n\n let baseSegments = parsePathname(base)\n const toSegments = parsePathname(to)\n\n if (baseSegments.length > 1 && last(baseSegments)?.value === '/') {\n baseSegments.pop()\n }\n\n toSegments.forEach((toSegment, index) => {\n if (toSegment.value === '/') {\n if (!index) {\n // Leading slash\n baseSegments = [toSegment]\n } else if (index === toSegments.length - 1) {\n // Trailing Slash\n baseSegments.push(toSegment)\n } else {\n // ignore inter-slashes\n }\n } else if (toSegment.value === '..') {\n baseSegments.pop()\n } else if (toSegment.value === '.') {\n // ignore\n } else {\n baseSegments.push(toSegment)\n }\n })\n\n if (baseSegments.length > 1) {\n if (last(baseSegments)?.value === '/') {\n if (trailingSlash === 'never') {\n baseSegments.pop()\n }\n } else if (trailingSlash === 'always') {\n baseSegments.push({ type: 'pathname', value: '/' })\n }\n }\n\n const joined = joinPaths([basepath, ...baseSegments.map((d) => d.value)])\n return cleanPath(joined)\n}\n\nexport function parsePathname(pathname?: string): Array<Segment> {\n if (!pathname) {\n return []\n }\n\n pathname = cleanPath(pathname)\n\n const segments: Array<Segment> = []\n\n if (pathname.slice(0, 1) === '/') {\n pathname = pathname.substring(1)\n segments.push({\n type: 'pathname',\n value: '/',\n })\n }\n\n if (!pathname) {\n return segments\n }\n\n // Remove empty segments and '.' segments\n const split = pathname.split('/').filter(Boolean)\n\n segments.push(\n ...split.map((part): Segment => {\n if (part === '$' || part === '*') {\n return {\n type: 'wildcard',\n value: part,\n }\n }\n\n if (part.charAt(0) === '$') {\n return {\n type: 'param',\n value: part,\n }\n }\n\n return {\n type: 'pathname',\n value: decodeURI(part),\n }\n }),\n )\n\n if (pathname.slice(-1) === '/') {\n pathname = pathname.substring(1)\n segments.push({\n type: 'pathname',\n value: '/',\n })\n }\n\n return segments\n}\n\ninterface InterpolatePathOptions {\n path?: string\n params: Record<string, unknown>\n leaveWildcards?: boolean\n leaveParams?: boolean\n}\n\nexport function interpolatePath({\n path,\n params,\n leaveWildcards,\n leaveParams,\n}: InterpolatePathOptions) {\n const interpolatedPathSegments = parsePathname(path)\n const encodedParams: any = {}\n\n for (const [key, value] of Object.entries(params)) {\n const isValueString = typeof value === 'string'\n\n if (['*', '_splat'].includes(key)) {\n // the splat/catch-all routes shouldn't have the '/' encoded out\n encodedParams[key] = isValueString ? encodeURI(value) : value\n } else {\n encodedParams[key] = isValueString ? encodeURIComponent(value) : value\n }\n }\n\n return joinPaths(\n interpolatedPathSegments.map((segment) => {\n if (segment.type === 'wildcard') {\n const value = encodedParams._splat\n if (leaveWildcards) return `${segment.value}${value ?? ''}`\n return value\n }\n\n if (segment.type === 'param') {\n if (leaveParams) {\n const value = encodedParams[segment.value]\n return `${segment.value}${value ?? ''}`\n }\n return encodedParams![segment.value.substring(1)] ?? 'undefined'\n }\n\n return segment.value\n }),\n )\n}\n\nexport function matchPathname(\n basepath: string,\n currentPathname: string,\n matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>,\n): AnyPathParams | undefined {\n const pathParams = matchByPath(basepath, currentPathname, matchLocation)\n // const searchMatched = matchBySearch(location.search, matchLocation)\n\n if (matchLocation.to && !pathParams) {\n return\n }\n\n return pathParams ?? {}\n}\n\nexport function removeBasepath(basepath: string, pathname: string) {\n switch (true) {\n // default behaviour is to serve app from the root - pathname\n // left untouched\n case basepath === '/':\n return pathname\n\n // shortcut for removing the basepath from the equal pathname\n case pathname === basepath:\n return ''\n\n // in case pathname is shorter than basepath - there is\n // nothing to remove\n case pathname.length < basepath.length:\n return pathname\n\n // avoid matching partial segments - strict equality handled\n // earlier, otherwise, basepath separated from pathname with\n // separator, therefore lack of separator means partial\n // segment match (`/app` should not match `/application`)\n case pathname[basepath.length] !== '/':\n return pathname\n\n // remove the basepath from the pathname in case there is any\n case pathname.startsWith(basepath):\n return pathname.slice(basepath.length)\n\n // otherwise, return the pathname as is\n default:\n return pathname\n }\n}\n\nexport function matchByPath(\n basepath: string,\n from: string,\n matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>,\n): Record<string, string> | undefined {\n // Remove the base path from the pathname\n from = removeBasepath(basepath, from)\n // Default to to $ (wildcard)\n const to = removeBasepath(basepath, `${matchLocation.to ?? '$'}`)\n\n // Parse the from and to\n const baseSegments = parsePathname(from)\n const routeSegments = parsePathname(to)\n\n if (!from.startsWith('/')) {\n baseSegments.unshift({\n type: 'pathname',\n value: '/',\n })\n }\n\n if (!to.startsWith('/')) {\n routeSegments.unshift({\n type: 'pathname',\n value: '/',\n })\n }\n\n const params: Record<string, string> = {}\n\n const isMatch = (() => {\n for (\n let i = 0;\n i < Math.max(baseSegments.length, routeSegments.length);\n i++\n ) {\n const baseSegment = baseSegments[i]\n const routeSegment = routeSegments[i]\n\n const isLastBaseSegment = i >= baseSegments.length - 1\n const isLastRouteSegment = i >= routeSegments.length - 1\n\n if (routeSegment) {\n if (routeSegment.type === 'wildcard') {\n const _splat = decodeURI(\n joinPaths(baseSegments.slice(i).map((d) => d.value)),\n )\n // TODO: Deprecate *\n params['*'] = _splat\n params['_splat'] = _splat\n return true\n }\n\n if (routeSegment.type === 'pathname') {\n if (routeSegment.value === '/' && !baseSegment?.value) {\n return true\n }\n\n if (baseSegment) {\n if (matchLocation.caseSensitive) {\n if (routeSegment.value !== baseSegment.value) {\n return false\n }\n } else if (\n routeSegment.value.toLowerCase() !==\n baseSegment.value.toLowerCase()\n ) {\n return false\n }\n }\n }\n\n if (!baseSegment) {\n return false\n }\n\n if (routeSegment.type === 'param') {\n if (baseSegment.value === '/') {\n return false\n }\n if (baseSegment.value.charAt(0) !== '$') {\n params[routeSegment.value.substring(1)] = decodeURIComponent(\n baseSegment.value,\n )\n }\n }\n }\n\n if (!isLastBaseSegment && isLastRouteSegment) {\n params['**'] = joinPaths(baseSegments.slice(i + 1).map((d) => d.value))\n return !!matchLocation.fuzzy && routeSegment?.value !== '/'\n }\n }\n\n return true\n })()\n\n return isMatch ? params : undefined\n}\n"],"names":["last"],"mappings":";;;AASO,SAAS,UAAU,OAAkC;AACnD,SAAA;AAAA,IACL,MACG,OAAO,CAAC,QAAQ;AACf,aAAO,QAAQ;AAAA,IAAA,CAChB,EACA,KAAK,GAAG;AAAA,EAAA;AAEf;AAEO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,cAAc,MAAc;AAC1C,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,SAAS,MAAc;AAC9B,SAAA,cAAc,aAAa,IAAI,CAAC;AACzC;AAEgB,SAAA,oBAAoB,OAAe,UAA0B;AACvE,MAAA,MAAM,SAAS,GAAG,KAAK,UAAU,OAAO,UAAU,GAAG,QAAQ,KAAK;AAC7D,WAAA,MAAM,MAAM,GAAG,EAAE;AAAA,EAC1B;AACO,SAAA;AACT;AAMgB,SAAA,cACd,WACA,WACA,UACS;AACT,SACE,oBAAoB,WAAW,QAAQ,MACvC,oBAAoB,WAAW,QAAQ;AAE3C;AAmCO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAClB,GAAuB;;AACd,SAAA,eAAe,UAAU,IAAI;AAC/B,OAAA,eAAe,UAAU,EAAE;AAE5B,MAAA,eAAe,cAAc,IAAI;AAC/B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MAC1D;AAAA,IACF;AAEO,WAAA;AAAA,EAAA;AAGT,SAAO,UAAU,SAAS;AAC5B;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"redirects.cjs","sources":["../../src/redirects.ts"],"sourcesContent":["import type { NavigateOptions } from './link'\nimport type { RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { PickAsRequired } from './utils'\n\nexport type AnyRedirect = Redirect<any, any, any, any, any>\n\nexport type Redirect<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n> = {\n /**\n * @deprecated Use `statusCode` instead\n **/\n href?: string\n code?: number\n statusCode?: number\n throw?: any\n headers?: HeadersInit\n} & NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type ResolvedRedirect<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n> = PickAsRequired<\n Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n 'code' | 'statusCode' | 'headers'\n> & {\n href: string\n}\n\nexport function redirect<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> {\n ;(opts as any).isRedirect = true\n opts.statusCode = opts.statusCode || opts.code || 307\n opts.headers = opts.headers || {}\n if (opts.throw) {\n throw opts\n }\n\n return opts\n}\n\nexport function isRedirect(obj: any): obj is AnyRedirect {\n return !!obj?.isRedirect\n}\n\nexport function isResolvedRedirect(obj: any): obj is ResolvedRedirect {\n return !!obj?.isRedirect && obj.href\n}\n"],"names":[],"mappings":";;AAqCO,SAAS,SAOd,MACmD;AACjD,OAAa,aAAa;AAC5B,OAAK,aAAa,KAAK,cAAc,KAAK,QAAQ;AAC7C,OAAA,UAAU,KAAK,WAAW,CAAA;AAC/B,MAAI,KAAK,OAAO;AACR,UAAA;AAAA,EACR;AAEO,SAAA;AACT;AAEO,SAAS,WAAW,KAA8B;AAChD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,mBAAmB,KAAmC;AACpE,SAAO,CAAC,EAAC,2BAAK,eAAc,IAAI;AAClC;;;;"}
1
+ {"version":3,"file":"redirects.cjs","sources":["../../src/redirects.ts"],"sourcesContent":["import type { NavigateOptions } from './link'\nimport type { RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { PickAsRequired } from './utils'\n\nexport type AnyRedirect = Redirect<any, any, any, any, any>\n\nexport type Redirect<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = '/',\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = {\n /**\n * @deprecated Use `statusCode` instead\n **/\n href?: string\n code?: number\n statusCode?: number\n throw?: any\n headers?: HeadersInit\n} & NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type ResolvedRedirect<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom,\n TMaskTo extends string = '',\n> = PickAsRequired<\n Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n 'code' | 'statusCode' | 'headers'\n> & {\n href: string\n}\n\nexport function redirect<\n TRouter extends RegisteredRouter,\n TTo extends string | undefined,\n TFrom extends string = string,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> {\n ;(opts as any).isRedirect = true\n opts.statusCode = opts.statusCode || opts.code || 307\n opts.headers = opts.headers || {}\n if (opts.throw) {\n throw opts\n }\n\n return opts\n}\n\nexport function isRedirect(obj: any): obj is AnyRedirect {\n return !!obj?.isRedirect\n}\n\nexport function isResolvedRedirect(obj: any): obj is ResolvedRedirect {\n return !!obj?.isRedirect && obj.href\n}\n"],"names":[],"mappings":";;AAqCO,SAAS,SAOd,MACmD;AACjD,OAAa,aAAa;AAC5B,OAAK,aAAa,KAAK,cAAc,KAAK,QAAQ;AAC7C,OAAA,UAAU,KAAK,WAAW,CAAA;AAC/B,MAAI,KAAK,OAAO;AACR,UAAA;AAAA,EACR;AAEO,SAAA;AACT;AAEO,SAAS,WAAW,KAA8B;AAChD,SAAA,CAAC,EAAC,2BAAK;AAChB;AAEO,SAAS,mBAAmB,KAAmC;AACpE,SAAO,CAAC,EAAC,2BAAK,eAAc,IAAI;AAClC;;;;"}
@@ -3,7 +3,7 @@ import { RoutePaths } from './routeInfo.cjs';
3
3
  import { AnyRouter, RegisteredRouter } from './router.cjs';
4
4
  import { PickAsRequired } from './utils.cjs';
5
5
  export type AnyRedirect = Redirect<any, any, any, any, any>;
6
- export type Redirect<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom, TMaskTo extends string = ''> = {
6
+ export type Redirect<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = '/', TTo extends string | undefined = '.', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = '.'> = {
7
7
  /**
8
8
  * @deprecated Use `statusCode` instead
9
9
  **/
@@ -16,6 +16,6 @@ export type Redirect<TRouter extends AnyRouter = RegisteredRouter, TFrom extends
16
16
  export type ResolvedRedirect<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouter['routeTree']> = TFrom, TMaskTo extends string = ''> = PickAsRequired<Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>, 'code' | 'statusCode' | 'headers'> & {
17
17
  href: string;
18
18
  };
19
- export declare function redirect<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
19
+ export declare function redirect<TRouter extends RegisteredRouter, TTo extends string | undefined, TFrom extends string = string, TMaskFrom extends string = TFrom, TMaskTo extends string = ''>(opts: Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
20
20
  export declare function isRedirect(obj: any): obj is AnyRedirect;
21
21
  export declare function isResolvedRedirect(obj: any): obj is ResolvedRedirect;
@@ -146,7 +146,15 @@ class Route {
146
146
  return this._fullPath;
147
147
  }
148
148
  addChildren(children) {
149
- this.children = Array.isArray(children) ? children : Object.values(children);
149
+ return this._addFileChildren(children);
150
+ }
151
+ _addFileChildren(children) {
152
+ if (Array.isArray(children)) {
153
+ this.children = children;
154
+ }
155
+ if (typeof children === "object" && children !== null) {
156
+ this.children = Object.values(children);
157
+ }
150
158
  return this;
151
159
  }
152
160
  }
@@ -167,7 +175,15 @@ class RootRoute extends Route {
167
175
  super(options);
168
176
  }
169
177
  addChildren(children) {
170
- return super.addChildren(children);
178
+ super.addChildren(children);
179
+ return this;
180
+ }
181
+ _addFileChildren(children) {
182
+ super._addFileChildren(children);
183
+ return this;
184
+ }
185
+ _addFileTypes() {
186
+ return this;
171
187
  }
172
188
  }
173
189
  function createRootRoute(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"route.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { joinPaths, trimPathLeft } from './path'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { rootRouteId } from './root'\nimport type * as React from 'react'\nimport type { RootRouteId } from './root'\nimport type { UseNavigateResult } from './useNavigate'\nimport type { MakeRouteMatch, MakeRouteMatchUnion, RouteMatch } from './Matches'\nimport type { NavigateOptions, ParsePathParams, ToMaskOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { RouteById, RouteIds, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, Router } from './router'\nimport type { Assign, Constrain, Expand, NoInfer, PickRequired } from './utils'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type { NotFoundError } from './not-found'\nimport type { LazyRoute } from './fileRoute'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnySearchSchema = {}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TFullPath extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = AnyPathParams,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = BaseRouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n> &\n UpdatableRouteOptions<\n NoInfer<TParentRoute>,\n NoInfer<TCustomId>,\n NoInfer<TFullPath>,\n NoInfer<TParams>,\n NoInfer<TSearchValidator>,\n NoInfer<TLoaderFn>,\n NoInfer<TLoaderDeps>,\n NoInfer<TRouterContext>,\n NoInfer<TRouteContextFn>,\n NoInfer<TBeforeLoadFn>\n >\n\nexport type ParseSplatParams<TPath extends string> = TPath extends `${string}$`\n ? '_splat'\n : TPath extends `${string}$/${string}`\n ? '_splat'\n : never\n\nexport interface SplatParams {\n _splat?: string\n}\n\nexport type ResolveParams<TPath extends string> =\n ParseSplatParams<TPath> extends never\n ? Record<ParsePathParams<TPath>, string>\n : Record<ParsePathParams<TPath>, string> & SplatParams\n\nexport type ParseParamsFn<TPath extends string, TParams> = (\n rawParams: ResolveParams<TPath>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : Record<ParsePathParams<TPath>, any>\n\nexport type StringifyParamsFn<TPath extends string, TParams> = (\n params: TParams,\n) => ResolveParams<TPath>\n\nexport type ParamsOptions<TPath extends string, TParams> = {\n params?: {\n parse: ParseParamsFn<TPath, TParams>\n stringify: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\nexport interface FullSearchSchemaOption<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n> {\n search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n}\n\nexport type RouteContextFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n> = (\n ctx: RouteContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext\n >,\n) => any\n\nexport type BeforeLoadFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> = (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n) => any\n\nexport type FileBaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = ParamsOptions<TPath, TParams> & {\n validateSearch?: Constrain<\n TSearchValidator,\n AnySearchValidator,\n DefaultSearchValidator\n >\n\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<\n TParentRoute,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any)\n\n context?: Constrain<\n TRouteContextFn,\n (\n ctx: RouteContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext\n >,\n ) => any\n >\n\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: Constrain<\n TBeforeLoadFn,\n (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n ) => any\n >\n\n loaderDeps?: (\n opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,\n ) => TLoaderDeps\n\n loader?: Constrain<\n TLoaderFn,\n (\n ctx: LoaderFnContext<\n TParentRoute,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any\n >\n}\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TParentRoute,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface ContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n> extends FullSearchSchemaOption<TParentRoute, TSearchValidator> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n matches: Array<MakeRouteMatchUnion>\n}\n\nexport interface RouteContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n> extends ContextOptions<TParentRoute, TSearchValidator, TParams> {\n context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>\n}\n\nexport interface BeforeLoadContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> extends ContextOptions<TParentRoute, TSearchValidator, TParams> {\n context: Expand<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>\n >\n}\n\nexport interface UpdatableRouteOptions<\n in out TParentRoute extends AnyRoute,\n in out TRouteId,\n in out TFullPath,\n in out TParams,\n in out TSearchValidator,\n in out TLoaderFn,\n in out TLoaderDeps,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n> extends UpdatableStaticRouteOption {\n // test?: (args: TAllContext) => void\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preload?: boolean\n preloadStaleTime?: number\n preloadGcTime?: number\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onStay?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onLeave?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n meta?: (ctx: {\n matches: Array<\n RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n >\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n params: ResolveAllParamsFromParent<TParentRoute, TParams>\n loaderData: ResolveLoaderData<TLoaderFn>\n }) => Array<React.JSX.IntrinsicElements['meta']>\n links?: () => Array<React.JSX.IntrinsicElements['link']>\n scripts?: () => Array<React.JSX.IntrinsicElements['script']>\n headers?: (ctx: {\n loaderData: ResolveLoaderData<TLoaderFn>\n }) => Record<string, string>\n}\n\ninterface RequiredStaticDataRouteOption {\n staticData: StaticDataRouteOption\n}\n\ninterface OptionalStaticDataRouteOption {\n staticData?: StaticDataRouteOption\n}\n\nexport type UpdatableStaticRouteOption = {} extends StaticDataRouteOption\n ? OptionalStaticDataRouteOption\n : RequiredStaticDataRouteOption\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\nexport interface SearchValidatorObj<TInput, TOutput> {\n parse: SearchValidatorFn<TInput, TOutput>\n}\n\nexport type AnySearchValidatorObj = SearchValidatorObj<any, any>\n\nexport interface SearchValidatorAdapter<TInput, TOutput> {\n types: {\n input: TInput\n output: TOutput\n }\n parse: (input: unknown) => TOutput\n}\n\nexport type AnySearchValidatorAdapter = SearchValidatorAdapter<any, any>\n\nexport type AnySearchValidatorFn = SearchValidatorFn<any, any>\n\nexport type SearchValidatorFn<TInput, TOutput> = (input: TInput) => TOutput\n\nexport type SearchValidator<TInput, TOutput> =\n | SearchValidatorObj<TInput, TOutput>\n | SearchValidatorFn<TInput, TOutput>\n | SearchValidatorAdapter<TInput, TOutput>\n | undefined\n\nexport type AnySearchValidator = SearchValidator<any, any>\n\nexport type DefaultSearchValidator = SearchValidator<\n Record<string, unknown>,\n AnySearchSchema\n>\n\nexport type RouteLoaderFn<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> = (\n match: LoaderFnContext<\n TParentRoute,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n) => any\n\nexport interface LoaderFnContext<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n deps: TLoaderDeps\n context: Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void>\n parentMatchPromise?: Promise<void>\n cause: 'preload' | 'enter' | 'stay'\n route: Route\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = unknown extends TRoute\n ? TRoute\n : TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n }\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaFnInput<TSearchValidator> =\n TSearchValidator extends (input: infer TSearchSchemaInput) => any\n ? TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : ResolveSearchSchemaFn<TSearchValidator>\n : AnySearchSchema\n\nexport type ResolveSearchSchemaInput<TSearchValidator> =\n TSearchValidator extends AnySearchValidatorAdapter\n ? TSearchValidator['types']['input']\n : TSearchValidator extends AnySearchValidatorObj\n ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>\n : ResolveSearchSchemaFnInput<TSearchValidator>\n\nexport type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (\n ...args: any\n) => infer TSearchSchema\n ? TSearchSchema\n : AnySearchSchema\n\nexport type ResolveSearchSchema<TSearchValidator> =\n unknown extends TSearchValidator\n ? TSearchValidator\n : TSearchValidator extends AnySearchValidatorAdapter\n ? TSearchValidator['types']['output']\n : TSearchValidator extends AnySearchValidatorObj\n ? ResolveSearchSchemaFn<TSearchValidator['parse']>\n : ResolveSearchSchemaFn<TSearchValidator>\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = unknown extends TParentRoute\n ? ResolveSearchSchema<TSearchValidator>\n : Assign<\n InferFullSearchSchema<TParentRoute>,\n ResolveSearchSchema<TSearchValidator>\n >\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = Assign<\n InferFullSearchSchemaInput<TParentRoute>,\n ResolveSearchSchemaInput<TSearchValidator>\n>\n\nexport type LooseReturnType<T> = T extends (\n ...args: Array<any>\n) => infer TReturn\n ? TReturn\n : never\n\nexport type LooseAsyncReturnType<T> = T extends (\n ...args: Array<any>\n) => infer TReturn\n ? TReturn extends Promise<infer TReturn>\n ? TReturn\n : TReturn\n : never\n\nexport type ContextReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseReturnType<TContextFn> extends never\n ? AnyContext\n : LooseReturnType<TContextFn>\n\nexport type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseAsyncReturnType<TContextFn> extends never\n ? AnyContext\n : LooseAsyncReturnType<TContextFn>\n\nexport type RouteContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n> = unknown extends TParentRoute\n ? TRouterContext\n : Assign<TRouterContext, InferAllContext<TParentRoute>>\n\nexport type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<\n ContextReturnType<TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\nexport type BeforeLoadContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n> = Assign<\n RouteContextParameter<TParentRoute, TRouterContext>,\n ContextReturnType<TRouteContextFn>\n>\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n> = Assign<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\n\nexport type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn\n ? TLoaderFn\n : LooseAsyncReturnType<TLoaderFn> extends never\n ? {}\n : LooseAsyncReturnType<TLoaderFn>\n\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type AnyRouteWithContext<TContext> = AnyRoute & {\n types: { allContext: TContext }\n}\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySearchSchema\n TFullSearchSchema: AnySearchSchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport function getRouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n>(id: TId) {\n return new RouteApi<\n TId,\n TRouter,\n TRoute,\n TFullSearchSchema,\n TAllParams,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >({ id })\n}\n\nexport class RouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n> {\n id: TId\n\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch = <\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (s: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (s: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (s: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (s: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n return useNavigate({ from: this.id })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class Route<\n in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n in out TPath extends RouteConstraints['TPath'] = '/',\n in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n in out TCustomId extends RouteConstraints['TCustomId'] = string,\n in out TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n> {\n isRoot: TParentRoute extends Route<any> ? true : false\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n\n // The following properties are set up in this.init()\n parentRoute!: TParentRoute\n private _id!: TId\n private _path!: TPath\n private _fullPath!: TFullPath\n private _to!: TrimPathRight<TFullPath>\n\n public get to() {\n /* invariant(\n this._to,\n `trying to access property 'to' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._to\n }\n\n public get id() {\n /* invariant(\n this._id,\n `trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._id\n }\n\n public get path() {\n /* invariant(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.isRoot || this._id || this._path,\n `trying to access property 'path' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._path\n }\n\n public get fullPath() {\n /* invariant(\n this._fullPath,\n `trying to access property 'fullPath' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._fullPath\n }\n\n // Optional\n children?: TChildren\n originalIndex?: number\n router?: AnyRouter\n rank!: number\n lazyFn?: () => Promise<LazyRoute<any>>\n _lazyPromise?: Promise<void>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) {\n this.options = (options as any) || {}\n\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n types!: {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: ResolveSearchSchema<TSearchValidator>\n searchSchemaInput: ResolveSearchSchemaInput<TSearchValidator>\n searchValidator: TSearchValidator\n fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>\n fullSearchSchemaInput: ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchValidator\n >\n params: TParams\n allParams: ResolveAllParamsFromParent<TParentRoute, TParams>\n routerContext: TRouterContext\n routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>\n routeContextFn: TRouteContextFn\n beforeLoadFn: TBeforeLoadFn\n allContext: ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n children: TChildren\n loaderData: ResolveLoaderData<TLoaderFn>\n loaderDeps: TLoaderDeps\n }\n\n init = (opts: { originalIndex: number }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.parentRoute = this.options.getParentRoute?.()\n\n if (isRoot) {\n this._path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this._path = path as TPath\n this._id = id as TId\n // this.customId = customId as TCustomId\n this._fullPath = fullPath as TFullPath\n this._to = fullPath as TrimPathRight<TFullPath>\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren\n > {\n this.children = (\n Array.isArray(children) ? children : Object.values(children)\n ) as any\n return this as any\n }\n\n updateLoader = <TNewLoaderFn>(options: {\n loader: Constrain<\n TNewLoaderFn,\n RouteLoaderFn<\n TParentRoute,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n }) => {\n Object.assign(this.options, options)\n return this as unknown as Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TNewLoaderFn,\n TChildren\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy = (lazyFn: () => Promise<LazyRoute<any>>): this => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch = <\n TRouter extends AnyRouter = RegisteredRouter,\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id })\n }\n\n useRouteContext = <\n TSelected = Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >,\n >(opts?: {\n select?: (\n search: Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >,\n ) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <\n TSelected = Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>,\n >(opts?: {\n select?: (\n search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>,\n ) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <\n TSelected = Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,\n >(opts?: {\n select?: (\n search: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,\n ) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = ResolveLoaderData<TLoaderFn>>(opts?: {\n select?: (search: ResolveLoaderData<TLoaderFn>) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.id })\n }\n}\n\nexport function createRoute<\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n) {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>\n\nexport type RootRouteOptions<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId,\n '', // TCustomId\n '', // TPath\n TSearchValidator,\n {}, // TParams\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n >(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) => {\n return createRootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options as any)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n TChildren = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren // TChildren\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options as any)\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren\n > {\n return super.addChildren(children)\n }\n}\n\nexport function createRootRoute<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n>(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n) {\n return new RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options)\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\ntype RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends RoutePaths<TRouteTree>,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps = {\n error: Error\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n//\n\nexport type ReactNode = any\n\nexport type SyncRouteComponent<TProps> =\n | ((props: TProps) => ReactNode)\n | React.LazyExoticComponent<(props: TProps) => ReactNode>\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'path'\n | 'id'\n | 'params'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"names":["useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useNavigate","notFound","options","rootRouteId","path","trimPathLeft","joinPaths"],"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,WACH,MAAM,QAAQ,QAAQ,IAAI,WAAW,OAAO,OAAO,QAAQ;AAEtD,WAAA;AAAA,EACT;AAkIF;AAEO,SAAS,YAqBd,SAaA;AACO,SAAA,IAAI,MAcT,OAAO;AACX;AAkCO,SAAS,6BAAwD;AACtE,SAAO,CAOL,YAQG;AACH,WAAO,gBAOL,OAAc;AAAA,EAAA;AAEpB;AAKO,MAAM,uBAAuB;AAE7B,MAAM,kBAQH,MAcR;AAAA;AAAA;AAAA;AAAA,EAIA,YACE,SAQA;AACA,UAAM,OAAc;AAAA,EACtB;AAAA,EAEA,YAKE,UASA;AACO,WAAA,MAAM,YAAY,QAAQ;AAAA,EACnC;AACF;AAEO,SAAS,gBAQd,SAQA;AACO,SAAA,IAAI,UAOT,OAAO;AACX;AAkDO,SAAS,gBAKd,MAGuB;AAChB,SAAA;AACT;AAsCO,MAAM,sBASH,MAcR;AAAA,EACA,YACE,SAqBA;AACM,UAAA;AAAA,MACJ,GAAI;AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EACH;AACF;;;;;;;;;;;"}
1
+ {"version":3,"file":"route.cjs","sources":["../../src/route.ts"],"sourcesContent":["import invariant from 'tiny-invariant'\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { joinPaths, trimPathLeft } from './path'\nimport { useParams } from './useParams'\nimport { useSearch } from './useSearch'\nimport { notFound } from './not-found'\nimport { useNavigate } from './useNavigate'\nimport { rootRouteId } from './root'\nimport type * as React from 'react'\nimport type { RootRouteId } from './root'\nimport type { UseNavigateResult } from './useNavigate'\nimport type { MakeRouteMatch, MakeRouteMatchUnion, RouteMatch } from './Matches'\nimport type { NavigateOptions, ParsePathParams, ToMaskOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { RouteById, RouteIds, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, Router } from './router'\nimport type { Assign, Constrain, Expand, NoInfer, PickRequired } from './utils'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type { NotFoundError } from './not-found'\nimport type { LazyRoute } from './fileRoute'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnySearchSchema = {}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TFullPath extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = AnyPathParams,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = BaseRouteOptions<\n TParentRoute,\n TCustomId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n> &\n UpdatableRouteOptions<\n NoInfer<TParentRoute>,\n NoInfer<TCustomId>,\n NoInfer<TFullPath>,\n NoInfer<TParams>,\n NoInfer<TSearchValidator>,\n NoInfer<TLoaderFn>,\n NoInfer<TLoaderDeps>,\n NoInfer<TRouterContext>,\n NoInfer<TRouteContextFn>,\n NoInfer<TBeforeLoadFn>\n >\n\nexport type ParseSplatParams<TPath extends string> = TPath extends `${string}$`\n ? '_splat'\n : TPath extends `${string}$/${string}`\n ? '_splat'\n : never\n\nexport interface SplatParams {\n _splat?: string\n}\n\nexport type ResolveParams<TPath extends string> =\n ParseSplatParams<TPath> extends never\n ? Record<ParsePathParams<TPath>, string>\n : Record<ParsePathParams<TPath>, string> & SplatParams\n\nexport type ParseParamsFn<TPath extends string, TParams> = (\n rawParams: ResolveParams<TPath>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : Record<ParsePathParams<TPath>, any>\n\nexport type StringifyParamsFn<TPath extends string, TParams> = (\n params: TParams,\n) => ResolveParams<TPath>\n\nexport type ParamsOptions<TPath extends string, TParams> = {\n params?: {\n parse: ParseParamsFn<TPath, TParams>\n stringify: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\nexport interface FullSearchSchemaOption<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n> {\n search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n}\n\nexport type RouteContextFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n> = (\n ctx: RouteContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext\n >,\n) => any\n\nexport type BeforeLoadFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> = (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n) => any\n\nexport type FileBaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = ParamsOptions<TPath, TParams> & {\n validateSearch?: Constrain<\n TSearchValidator,\n AnySearchValidator,\n DefaultSearchValidator\n >\n\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<\n TParentRoute,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any)\n\n context?: Constrain<\n TRouteContextFn,\n (\n ctx: RouteContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext\n >,\n ) => any\n >\n\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: Constrain<\n TBeforeLoadFn,\n (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n ) => any\n >\n\n loaderDeps?: (\n opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,\n ) => TLoaderDeps\n\n loader?: Constrain<\n TLoaderFn,\n (\n ctx: LoaderFnContext<\n TParentRoute,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any\n >\n}\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TParentRoute,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface ContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n> extends FullSearchSchemaOption<TParentRoute, TSearchValidator> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n matches: Array<MakeRouteMatchUnion>\n}\n\nexport interface RouteContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n> extends ContextOptions<TParentRoute, TSearchValidator, TParams> {\n context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>\n}\n\nexport interface BeforeLoadContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> extends ContextOptions<TParentRoute, TSearchValidator, TParams> {\n context: Expand<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>\n >\n}\n\nexport interface UpdatableRouteOptions<\n in out TParentRoute extends AnyRoute,\n in out TRouteId,\n in out TFullPath,\n in out TParams,\n in out TSearchValidator,\n in out TLoaderFn,\n in out TLoaderDeps,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n> extends UpdatableStaticRouteOption {\n // test?: (args: TAllContext) => void\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: RouteComponent\n errorComponent?: false | null | ErrorRouteComponent\n notFoundComponent?: NotFoundRouteComponent\n pendingComponent?: RouteComponent\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preload?: boolean\n preloadStaleTime?: number\n preloadGcTime?: number\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n onCatch?: (error: Error, errorInfo: React.ErrorInfo) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onStay?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onLeave?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n meta?: (ctx: {\n matches: Array<\n RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n >\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n params: ResolveAllParamsFromParent<TParentRoute, TParams>\n loaderData: ResolveLoaderData<TLoaderFn>\n }) => Array<React.JSX.IntrinsicElements['meta']>\n links?: () => Array<React.JSX.IntrinsicElements['link']>\n scripts?: () => Array<React.JSX.IntrinsicElements['script']>\n headers?: (ctx: {\n loaderData: ResolveLoaderData<TLoaderFn>\n }) => Record<string, string>\n}\n\ninterface RequiredStaticDataRouteOption {\n staticData: StaticDataRouteOption\n}\n\ninterface OptionalStaticDataRouteOption {\n staticData?: StaticDataRouteOption\n}\n\nexport type UpdatableStaticRouteOption = {} extends StaticDataRouteOption\n ? OptionalStaticDataRouteOption\n : RequiredStaticDataRouteOption\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\nexport interface SearchValidatorObj<TInput, TOutput> {\n parse: SearchValidatorFn<TInput, TOutput>\n}\n\nexport type AnySearchValidatorObj = SearchValidatorObj<any, any>\n\nexport interface SearchValidatorAdapter<TInput, TOutput> {\n types: {\n input: TInput\n output: TOutput\n }\n parse: (input: unknown) => TOutput\n}\n\nexport type AnySearchValidatorAdapter = SearchValidatorAdapter<any, any>\n\nexport type AnySearchValidatorFn = SearchValidatorFn<any, any>\n\nexport type SearchValidatorFn<TInput, TOutput> = (input: TInput) => TOutput\n\nexport type SearchValidator<TInput, TOutput> =\n | SearchValidatorObj<TInput, TOutput>\n | SearchValidatorFn<TInput, TOutput>\n | SearchValidatorAdapter<TInput, TOutput>\n | undefined\n\nexport type AnySearchValidator = SearchValidator<any, any>\n\nexport type DefaultSearchValidator = SearchValidator<\n Record<string, unknown>,\n AnySearchSchema\n>\n\nexport type RouteLoaderFn<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> = (\n match: LoaderFnContext<\n TParentRoute,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n) => any\n\nexport interface LoaderFnContext<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n deps: TLoaderDeps\n context: Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void>\n parentMatchPromise?: Promise<void>\n cause: 'preload' | 'enter' | 'stay'\n route: Route\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = unknown extends TRoute\n ? TRoute\n : TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n }\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaFnInput<TSearchValidator> =\n TSearchValidator extends (input: infer TSearchSchemaInput) => any\n ? TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : ResolveSearchSchemaFn<TSearchValidator>\n : AnySearchSchema\n\nexport type ResolveSearchSchemaInput<TSearchValidator> =\n TSearchValidator extends AnySearchValidatorAdapter\n ? TSearchValidator['types']['input']\n : TSearchValidator extends AnySearchValidatorObj\n ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>\n : ResolveSearchSchemaFnInput<TSearchValidator>\n\nexport type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (\n ...args: any\n) => infer TSearchSchema\n ? TSearchSchema\n : AnySearchSchema\n\nexport type ResolveSearchSchema<TSearchValidator> =\n unknown extends TSearchValidator\n ? TSearchValidator\n : TSearchValidator extends AnySearchValidatorAdapter\n ? TSearchValidator['types']['output']\n : TSearchValidator extends AnySearchValidatorObj\n ? ResolveSearchSchemaFn<TSearchValidator['parse']>\n : ResolveSearchSchemaFn<TSearchValidator>\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = unknown extends TParentRoute\n ? ResolveSearchSchema<TSearchValidator>\n : Assign<\n InferFullSearchSchema<TParentRoute>,\n ResolveSearchSchema<TSearchValidator>\n >\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = Assign<\n InferFullSearchSchemaInput<TParentRoute>,\n ResolveSearchSchemaInput<TSearchValidator>\n>\n\nexport type LooseReturnType<T> = T extends (\n ...args: Array<any>\n) => infer TReturn\n ? TReturn\n : never\n\nexport type LooseAsyncReturnType<T> = T extends (\n ...args: Array<any>\n) => infer TReturn\n ? TReturn extends Promise<infer TReturn>\n ? TReturn\n : TReturn\n : never\n\nexport type ContextReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseReturnType<TContextFn> extends never\n ? AnyContext\n : LooseReturnType<TContextFn>\n\nexport type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseAsyncReturnType<TContextFn> extends never\n ? AnyContext\n : LooseAsyncReturnType<TContextFn>\n\nexport type RouteContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n> = unknown extends TParentRoute\n ? TRouterContext\n : Assign<TRouterContext, InferAllContext<TParentRoute>>\n\nexport type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<\n ContextReturnType<TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\nexport type BeforeLoadContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n> = Assign<\n RouteContextParameter<TParentRoute, TRouterContext>,\n ContextReturnType<TRouteContextFn>\n>\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n> = Assign<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\n\nexport type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn\n ? TLoaderFn\n : LooseAsyncReturnType<TLoaderFn> extends never\n ? {}\n : LooseAsyncReturnType<TLoaderFn>\n\nexport interface AnyRoute\n extends Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport type AnyRouteWithContext<TContext> = AnyRoute & {\n types: { allContext: TContext }\n}\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySearchSchema\n TFullSearchSchema: AnySearchSchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport function getRouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n>(id: TId) {\n return new RouteApi<\n TId,\n TRouter,\n TRoute,\n TFullSearchSchema,\n TAllParams,\n TAllContext,\n TLoaderDeps,\n TLoaderData\n >({ id })\n}\n\nexport class RouteApi<\n TId extends RouteIds<RegisteredRouter['routeTree']>,\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n TFullSearchSchema = TRoute['types']['fullSearchSchema'],\n TAllParams = TRoute['types']['allParams'],\n TAllContext = TRoute['types']['allContext'],\n TLoaderDeps = TRoute['types']['loaderDeps'],\n TLoaderData = TRoute['types']['loaderData'],\n> {\n id: TId\n\n /**\n * @deprecated Use the `getRouteApi` function instead.\n */\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n useMatch = <\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ select: opts?.select, from: this.id })\n }\n\n useRouteContext = <TSelected = Expand<TAllContext>>(opts?: {\n select?: (s: Expand<TAllContext>) => TSelected\n }): TSelected => {\n return useMatch({\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <TSelected = Expand<TFullSearchSchema>>(opts?: {\n select?: (s: Expand<TFullSearchSchema>) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <TSelected = Expand<TAllParams>>(opts?: {\n select?: (s: Expand<TAllParams>) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id, strict: false } as any)\n }\n\n useLoaderData = <TSelected = TLoaderData>(opts?: {\n select?: (s: TLoaderData) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id, strict: false } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n return useNavigate({ from: this.id })\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class Route<\n in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n in out TPath extends RouteConstraints['TPath'] = '/',\n in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n in out TCustomId extends RouteConstraints['TCustomId'] = string,\n in out TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n> {\n isRoot: TParentRoute extends Route<any> ? true : false\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n\n // The following properties are set up in this.init()\n parentRoute!: TParentRoute\n private _id!: TId\n private _path!: TPath\n private _fullPath!: TFullPath\n private _to!: TrimPathRight<TFullPath>\n\n public get to() {\n /* invariant(\n this._to,\n `trying to access property 'to' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._to\n }\n\n public get id() {\n /* invariant(\n this._id,\n `trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._id\n }\n\n public get path() {\n /* invariant(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.isRoot || this._id || this._path,\n `trying to access property 'path' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._path\n }\n\n public get fullPath() {\n /* invariant(\n this._fullPath,\n `trying to access property 'fullPath' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`,\n )*/\n return this._fullPath\n }\n\n // Optional\n children?: TChildren\n originalIndex?: number\n router?: AnyRouter\n rank!: number\n lazyFn?: () => Promise<LazyRoute<any>>\n _lazyPromise?: Promise<void>\n\n /**\n * @deprecated Use the `createRoute` function instead.\n */\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) {\n this.options = (options as any) || {}\n\n this.isRoot = !options?.getParentRoute as any\n invariant(\n !((options as any)?.id && (options as any)?.path),\n `Route cannot have both an 'id' and a 'path' option.`,\n )\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n types!: {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: ResolveSearchSchema<TSearchValidator>\n searchSchemaInput: ResolveSearchSchemaInput<TSearchValidator>\n searchValidator: TSearchValidator\n fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>\n fullSearchSchemaInput: ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchValidator\n >\n params: TParams\n allParams: ResolveAllParamsFromParent<TParentRoute, TParams>\n routerContext: TRouterContext\n routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>\n routeContextFn: TRouteContextFn\n beforeLoadFn: TBeforeLoadFn\n allContext: ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n children: TChildren\n loaderData: ResolveLoaderData<TLoaderFn>\n loaderDeps: TLoaderDeps\n }\n\n init = (opts: { originalIndex: number }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n this.parentRoute = this.options.getParentRoute?.()\n\n if (isRoot) {\n this._path = rootRouteId as TPath\n } else {\n invariant(\n this.parentRoute,\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this._path = path as TPath\n this._id = id as TId\n // this.customId = customId as TCustomId\n this._fullPath = fullPath as TFullPath\n this._to = fullPath as TrimPathRight<TFullPath>\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren\n > {\n return this._addFileChildren(children)\n }\n\n _addFileChildren<const TNewChildren>(\n children: TNewChildren,\n ): Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren\n > {\n if (Array.isArray(children)) {\n this.children = children as TChildren\n }\n\n if (typeof children === 'object' && children !== null) {\n this.children = Object.values(children) as TChildren\n }\n\n return this as unknown as Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren\n >\n }\n\n updateLoader = <TNewLoaderFn>(options: {\n loader: Constrain<\n TNewLoaderFn,\n RouteLoaderFn<\n TParentRoute,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n }) => {\n Object.assign(this.options, options)\n return this as unknown as Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TNewLoaderFn,\n TChildren\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy = (lazyFn: () => Promise<LazyRoute<any>>): this => {\n this.lazyFn = lazyFn\n return this\n }\n\n useMatch = <\n TRouter extends AnyRouter = RegisteredRouter,\n TRouteTree extends AnyRoute = TRouter['routeTree'],\n TRouteMatch = MakeRouteMatch<TRouteTree, TId>,\n TSelected = TRouteMatch,\n >(opts?: {\n select?: (match: TRouteMatch) => TSelected\n }): TSelected => {\n return useMatch({ ...opts, from: this.id })\n }\n\n useRouteContext = <\n TSelected = Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >,\n >(opts?: {\n select?: (\n search: Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >,\n ) => TSelected\n }): TSelected => {\n return useMatch({\n ...opts,\n from: this.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n })\n }\n\n useSearch = <\n TSelected = Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>,\n >(opts?: {\n select?: (\n search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>,\n ) => TSelected\n }): TSelected => {\n return useSearch({ ...opts, from: this.id })\n }\n\n useParams = <\n TSelected = Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,\n >(opts?: {\n select?: (\n search: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,\n ) => TSelected\n }): TSelected => {\n return useParams({ ...opts, from: this.id })\n }\n\n useLoaderDeps = <TSelected = TLoaderDeps>(opts?: {\n select?: (s: TLoaderDeps) => TSelected\n }): TSelected => {\n return useLoaderDeps({ ...opts, from: this.id } as any)\n }\n\n useLoaderData = <TSelected = ResolveLoaderData<TLoaderFn>>(opts?: {\n select?: (search: ResolveLoaderData<TLoaderFn>) => TSelected\n }): TSelected => {\n return useLoaderData({ ...opts, from: this.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TFullPath> => {\n return useNavigate({ from: this.id })\n }\n}\n\nexport function createRoute<\n TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,\n TPath extends RouteConstraints['TPath'] = '/',\n TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints['TCustomId'] = string,\n TId extends RouteConstraints['TId'] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n>(\n options: RouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n) {\n return new Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n >(options)\n}\n\nexport type AnyRootRoute = RootRoute<any, any, any, any, any, any, any>\n\nexport type RootRouteOptions<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId,\n '', // TCustomId\n '', // TPath\n TSearchValidator,\n {}, // TParams\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n>\n\nexport function createRootRouteWithContext<TRouterContext extends {}>() {\n return <\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n >(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) => {\n return createRootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options as any)\n }\n}\n\n/**\n * @deprecated Use the `createRootRouteWithContext` function instead.\n */\nexport const rootRouteWithContext = createRootRouteWithContext\n\nexport class RootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends Route<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren // TChildren\n> {\n /**\n * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.\n */\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options as any)\n }\n\n addChildren<\n const TNewChildren extends\n | Record<string, AnyRoute>\n | ReadonlyArray<AnyRoute>,\n >(\n children: TNewChildren,\n ): RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n > {\n super.addChildren(children)\n return this as unknown as RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n >\n }\n\n _addFileChildren<const TNewChildren>(\n children: TNewChildren,\n ): RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n > {\n super._addFileChildren(children)\n return this as unknown as RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n >\n }\n\n _addFileTypes<TFileRouteTypes>(): RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n > {\n return this as any\n }\n}\n\nexport function createRootRoute<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n>(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n) {\n return new RootRoute<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >(options)\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\ntype RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends RoutePaths<TRouteTree> | string,\n TTo extends string,\n>(\n opts: {\n routeTree: TRouteTree\n } & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>,\n): RouteMask<TRouteTree> {\n return opts as any\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps = {\n error: Error\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n//\n\nexport type ReactNode = any\n\nexport type SyncRouteComponent<TProps> =\n | ((props: TProps) => ReactNode)\n | React.LazyExoticComponent<(props: TProps) => ReactNode>\n\nexport type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport type RouteComponent<TProps = any> = AsyncRouteComponent<TProps>\n\nexport type ErrorRouteComponent = RouteComponent<ErrorComponentProps>\n\nexport type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>\n\nexport class NotFoundRoute<\n TParentRoute extends AnyRootRoute,\n TRouterContext = AnyContext,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n> extends Route<\n TParentRoute,\n '/404',\n '/404',\n '404',\n '404',\n TSearchValidator,\n {},\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n> {\n constructor(\n options: Omit<\n RouteOptions<\n TParentRoute,\n string,\n string,\n string,\n TSearchValidator,\n {},\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'path'\n | 'id'\n | 'params'\n >,\n ) {\n super({\n ...(options as any),\n id: '404',\n })\n }\n}\n"],"names":["useMatch","useSearch","useParams","useLoaderDeps","useLoaderData","useNavigate","notFound","options","rootRouteId","path","trimPathLeft","joinPaths"],"mappings":";;;;;;;;;;;;AAgvBO,SAAS,YASd,IAAS;AACT,SAAO,IAAI,SAST,EAAE,GAAA,CAAI;AACV;AAEO,MAAM,SASX;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY,EAAE,MAAmB;AAIjC,SAAA,WAAW,CAIT,SAEe;AACR,aAAAA,SAAA,SAAS,EAAE,QAAQ,6BAAM,QAAQ,MAAM,KAAK,IAAI;AAAA,IAAA;AAGzD,SAAA,kBAAkB,CAAkC,SAEnC;AACf,aAAOA,kBAAS;AAAA,QACd,MAAM,KAAK;AAAA,QACX,QAAQ,CAAC,OAAY,6BAAM,UAAS,KAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAChE;AAAA,IAAA;AAGH,SAAA,YAAY,CAAwC,SAEnC;AACf,aAAOC,UAAAA,UAAU,EAAE,GAAG,MAAM,MAAM,KAAK,IAAI;AAAA,IAAA;AAG7C,SAAA,YAAY,CAAiC,SAE5B;AACf,aAAOC,UAAAA,UAAU,EAAE,GAAG,MAAM,MAAM,KAAK,IAAI;AAAA,IAAA;AAG7C,SAAA,gBAAgB,CAA0B,SAEzB;AACR,aAAAC,cAAA,cAAc,EAAE,GAAG,MAAM,MAAM,KAAK,IAAI,QAAQ,MAAA,CAAc;AAAA,IAAA;AAGvE,SAAA,gBAAgB,CAA0B,SAEzB;AACR,aAAAC,cAAA,cAAc,EAAE,GAAG,MAAM,MAAM,KA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AAAA,MACJ,IAAI;AAAA,IAAA,CACL;AAAA,EACH;AACF;;;;;;;;;;;"}
@@ -333,6 +333,7 @@ export declare class Route<in out TParentRoute extends RouteConstraints['TParent
333
333
  originalIndex: number;
334
334
  }) => void;
335
335
  addChildren<const TNewChildren extends Record<string, AnyRoute> | ReadonlyArray<AnyRoute>>(children: TNewChildren): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren>;
336
+ _addFileChildren<const TNewChildren>(children: TNewChildren): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren>;
336
337
  updateLoader: <TNewLoaderFn>(options: {
337
338
  loader: Constrain<TNewLoaderFn, RouteLoaderFn<TParentRoute, TParams, TLoaderDeps, TRouterContext, TRouteContextFn, TBeforeLoadFn>>;
338
339
  }) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TNewLoaderFn, TChildren>;
@@ -365,12 +366,12 @@ RootRouteId, '', // TCustomId
365
366
  '', // TPath
366
367
  TSearchValidator, {}, // TParams
367
368
  TLoaderDeps, TLoaderFn, TRouterContext, TRouteContextFn, TBeforeLoadFn>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'params'>;
368
- export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>) => RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown>;
369
+ export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TSearchValidator = undefined, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>) => RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown>;
369
370
  /**
370
371
  * @deprecated Use the `createRootRouteWithContext` function instead.
371
372
  */
372
373
  export declare const rootRouteWithContext: typeof createRootRouteWithContext;
373
- export declare class RootRoute<in out TSearchValidator = undefined, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, TChildren = unknown> extends Route<any, // TParentRoute
374
+ export declare class RootRoute<in out TSearchValidator = undefined, in out TRouterContext = {}, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> extends Route<any, // TParentRoute
374
375
  '/', // TPath
375
376
  '/', // TFullPath
376
377
  string, // TCustomId
@@ -382,9 +383,11 @@ TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildre
382
383
  * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
383
384
  */
384
385
  constructor(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>);
385
- addChildren<const TNewChildren extends Record<string, AnyRoute> | ReadonlyArray<AnyRoute>>(children: TNewChildren): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren>;
386
+ addChildren<const TNewChildren extends Record<string, AnyRoute> | ReadonlyArray<AnyRoute>>(children: TNewChildren): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
387
+ _addFileChildren<const TNewChildren>(children: TNewChildren): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TNewChildren, TFileRouteTypes>;
388
+ _addFileTypes<TFileRouteTypes>(): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes>;
386
389
  }
387
- export declare function createRootRoute<TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown>;
390
+ export declare function createRootRoute<TSearchValidator = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: RootRouteOptions<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>): RootRoute<TSearchValidator, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown>;
388
391
  export type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
389
392
  type RoutePrefix<TPrefix extends string, TPath extends string> = string extends TPath ? RootRouteId : TPath extends string ? TPrefix extends RootRouteId ? TPath extends '/' ? '/' : `/${TrimPath<TPath>}` : `${TPrefix}/${TPath}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}` : never;
390
393
  export type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
@@ -400,7 +403,7 @@ export type RouteMask<TRouteTree extends AnyRoute> = {
400
403
  state?: any;
401
404
  unmaskOnReload?: boolean;
402
405
  };
403
- export declare function createRouteMask<TRouteTree extends AnyRoute, TFrom extends RoutePaths<TRouteTree>, TTo extends string>(opts: {
406
+ export declare function createRouteMask<TRouteTree extends AnyRoute, TFrom extends RoutePaths<TRouteTree> | string, TTo extends string>(opts: {
404
407
  routeTree: TRouteTree;
405
408
  } & ToMaskOptions<Router<TRouteTree, 'never'>, TFrom, TTo>): RouteMask<TRouteTree>;
406
409
  /**
@@ -1,3 +1,5 @@
1
+ import { InferFileRouteTypes } from './fileRoute.cjs';
2
+ import { AddTrailingSlash, RemoveTrailingSlashes } from './link.cjs';
1
3
  import { AnyRoute } from './route.cjs';
2
4
  import { AnyRouter, TrailingSlashOption } from './router.cjs';
3
5
  import { MergeUnion } from './utils.cjs';
@@ -7,19 +9,23 @@ export type ParseRoute<TRouteTree, TAcc = TRouteTree> = TRouteTree extends {
7
9
  };
8
10
  } ? unknown extends TChildren ? TAcc : TChildren extends ReadonlyArray<any> ? ParseRoute<TChildren[number], TAcc | TChildren[number]> : ParseRoute<TChildren[keyof TChildren], TAcc | TChildren[keyof TChildren]> : TAcc;
9
11
  export type ParseRouteWithoutBranches<TRouteTree> = ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute ? TRoute extends any ? unknown extends TRoute['types']['children'] ? TRoute : TRoute['types']['children'] extends ReadonlyArray<any> ? '/' extends TRoute['types']['children'][number]['path'] ? never : TRoute : '/' extends TRoute['types']['children'][keyof TRoute['types']['children']]['path'] ? never : TRoute : never : never;
10
- export type RoutesById<TRouteTree extends AnyRoute> = {
11
- [K in ParseRoute<TRouteTree> as K['id']]: K;
12
- };
13
- export type RouteById<TRouteTree extends AnyRoute, TId> = Extract<RoutesById<TRouteTree>[TId], AnyRoute>;
14
- export type RouteIds<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['id'];
12
+ export type CodeRoutesById<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? {
13
+ [K in TRoutes as K['id']]: K;
14
+ } : never;
15
+ export type RoutesById<TRouteTree extends AnyRoute> = InferFileRouteTypes<TRouteTree> extends never ? CodeRoutesById<TRouteTree> : InferFileRouteTypes<TRouteTree>['fileRoutesById'];
16
+ export type RouteById<TRouteTree extends AnyRoute, TId> = Extract<RoutesById<TRouteTree>[TId & keyof RoutesById<TRouteTree>], AnyRoute>;
17
+ export type CodeRouteIds<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? TRoutes['id'] : never;
18
+ export type RouteIds<TRouteTree extends AnyRoute> = InferFileRouteTypes<TRouteTree> extends never ? CodeRouteIds<TRouteTree> : InferFileRouteTypes<TRouteTree>['id'];
15
19
  export type ParentPath<TOption> = 'always' extends TOption ? '../' : 'never' extends TOption ? '..' : '../' | '..';
16
20
  export type CurrentPath<TOption> = 'always' extends TOption ? './' : 'never' extends TOption ? '.' : './' | '.';
17
- export type CatchAllPaths<TOption> = CurrentPath<TOption> | ParentPath<TOption> | '';
18
- export type RoutesByPath<TRouteTree extends AnyRoute> = {
19
- [K in ParseRoute<TRouteTree> as K['fullPath']]: K;
20
- };
21
- export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<RoutesByPath<TRouteTree>[TPath], AnyRoute>;
22
- export type RoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['fullPath'] | '/';
21
+ export type CatchAllPaths<TOption> = CurrentPath<TOption> | ParentPath<TOption>;
22
+ export type CodeRoutesByPath<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? {
23
+ [K in TRoutes as K['fullPath']]: K;
24
+ } : never;
25
+ export type RoutesByPath<TRouteTree extends AnyRoute> = InferFileRouteTypes<TRouteTree> extends never ? CodeRoutesByPath<TRouteTree> : InferFileRouteTypes<TRouteTree>['fileRoutesByFullPath'];
26
+ export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<RoutesByPath<TRouteTree>[TPath & keyof RoutesByPath<TRouteTree>], AnyRoute>;
27
+ export type CodeRoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? TRoutes['fullPath'] : never;
28
+ export type RoutePaths<TRouteTree extends AnyRoute> = (InferFileRouteTypes<TRouteTree> extends never ? CodeRoutePaths<TRouteTree> : InferFileRouteTypes<TRouteTree>['fullPaths']) | '/';
23
29
  export type RouteToPathAlwaysTrailingSlash<TRoute extends AnyRoute> = TRoute['path'] extends '/' ? TRoute['fullPath'] : TRoute['fullPath'] extends '/' ? TRoute['fullPath'] : `${TRoute['fullPath']}/`;
24
30
  export type RouteToPathNeverTrailingSlash<TRoute extends AnyRoute> = TRoute['path'] extends '/' ? TRoute['fullPath'] extends '/' ? TRoute['fullPath'] : TRoute['fullPath'] extends `${infer TRest}/` ? TRest : TRoute['fullPath'] : TRoute['fullPath'];
25
31
  export type RouteToPathPreserveTrailingSlash<TRoute extends AnyRoute> = RouteToPathNeverTrailingSlash<TRoute> | RouteToPathAlwaysTrailingSlash<TRoute>;
@@ -30,13 +36,18 @@ export type RouteToPathByTrailingSlashOption<TRoute extends AnyRoute> = {
30
36
  };
31
37
  export type TrailingSlashOptionByRouter<TRouter extends AnyRouter> = TrailingSlashOption extends TRouter['options']['trailingSlash'] ? 'never' : NonNullable<TRouter['options']['trailingSlash']>;
32
38
  export type RouteToByRouter<TRouter extends AnyRouter, TRoute extends AnyRoute> = RouteToPathByTrailingSlashOption<TRoute>[TrailingSlashOptionByRouter<TRouter>];
33
- export type RouteToPath<TRouter extends AnyRouter, TRouteTree extends AnyRoute> = ParseRouteWithoutBranches<TRouteTree> extends infer TRoute extends AnyRoute ? TRoute extends any ? RouteToByRouter<TRouter, TRoute> : never : never;
34
- export type RoutesByToPath<TRouter extends AnyRouter> = {
35
- [TRoute in ParseRouteWithoutBranches<TRouter['routeTree']> as RouteToByRouter<TRouter, TRoute>]: TRoute;
36
- };
37
- export type RouteByToPath<TRouter extends AnyRouter, TTo> = Extract<RoutesByToPath<TRouter>[TTo], AnyRoute>;
38
- export type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchema']>;
39
- export type FullSearchSchemaInput<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchemaInput']>;
40
- export type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allParams']>;
41
- export type AllContext<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allContext']>;
42
- export type AllLoaderData<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['loaderData']>;
39
+ export type CodeRouteToPath<TRouter extends AnyRouter, TRouteTree extends AnyRoute> = ParseRouteWithoutBranches<TRouteTree> extends infer TRoute extends AnyRoute ? TRoute extends any ? RouteToByRouter<TRouter, TRoute> : never : never;
40
+ export type FileRouteToPath<TRouter extends AnyRouter, TTo = InferFileRouteTypes<TRouter['routeTree']>['to'], TTrailingSlashOption = TrailingSlashOptionByRouter<TRouter>> = 'never' extends TTrailingSlashOption ? TTo : 'always' extends TTrailingSlashOption ? AddTrailingSlash<TTo> : TTo | AddTrailingSlash<TTo>;
41
+ export type RouteToPath<TRouter extends AnyRouter, TRouteTree extends AnyRoute> = InferFileRouteTypes<TRouter['routeTree']> extends never ? CodeRouteToPath<TRouter, TRouteTree> : FileRouteToPath<TRouter>;
42
+ export type CodeRoutesByToPath<TRouter extends AnyRouter> = ParseRouteWithoutBranches<TRouter['routeTree']> extends infer TRoutes extends AnyRoute ? {
43
+ [TRoute in TRoutes as RouteToByRouter<TRouter, TRoute>]: TRoute;
44
+ } : never;
45
+ export type RoutesByToPath<TRouter extends AnyRouter> = InferFileRouteTypes<TRouter['routeTree']> extends never ? CodeRoutesByToPath<TRouter> : InferFileRouteTypes<TRouter['routeTree']>['fileRoutesByTo'];
46
+ export type CodeRouteByToPath<TRouter extends AnyRouter, TTo> = Extract<RoutesByToPath<TRouter>[TTo & keyof RoutesByToPath<TRouter>], AnyRoute>;
47
+ export type FileRouteByToPath<TRouter extends AnyRouter, TTo> = 'never' extends TrailingSlashOptionByRouter<TRouter> ? CodeRouteByToPath<TRouter, TTo> : 'always' extends TrailingSlashOptionByRouter<TRouter> ? TTo extends '/' ? CodeRouteByToPath<TRouter, TTo> : TTo extends `${infer TPath}/` ? CodeRouteByToPath<TRouter, TPath> : never : CodeRouteByToPath<TRouter, TTo extends '/' ? TTo : RemoveTrailingSlashes<TTo>>;
48
+ export type RouteByToPath<TRouter extends AnyRouter, TTo> = InferFileRouteTypes<TRouter['routeTree']> extends never ? CodeRouteByToPath<TRouter, TTo> : FileRouteByToPath<TRouter, TTo>;
49
+ export type FullSearchSchema<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? MergeUnion<TRoutes['types']['fullSearchSchema']> : never;
50
+ export type FullSearchSchemaInput<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? MergeUnion<TRoutes['types']['fullSearchSchemaInput']> : never;
51
+ export type AllParams<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? MergeUnion<TRoutes['types']['allParams']> : never;
52
+ export type AllContext<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? MergeUnion<TRoutes['types']['allContext']> : never;
53
+ export type AllLoaderData<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree> extends infer TRoutes extends AnyRoute ? MergeUnion<TRoutes['types']['loaderData']> : never;
@@ -1051,7 +1051,10 @@ class Router {
1051
1051
  this.matchRoute = (location, opts) => {
1052
1052
  const matchLocation = {
1053
1053
  ...location,
1054
- to: location.to ? this.resolvePathWithBase(location.from || "", location.to) : void 0,
1054
+ to: location.to ? this.resolvePathWithBase(
1055
+ location.from || "",
1056
+ location.to
1057
+ ) : void 0,
1055
1058
  params: location.params || {},
1056
1059
  leaveParams: true
1057
1060
  };