@tanstack/react-router 1.26.21 → 1.28.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.
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +9 -10
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +32 -24
- package/dist/cjs/path.cjs +17 -3
- package/dist/cjs/path.cjs.map +1 -1
- package/dist/cjs/path.d.cts +7 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +42 -45
- package/dist/cjs/routeInfo.d.cts +5 -7
- package/dist/cjs/router.cjs +7 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +2 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +5 -3
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +9 -10
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/link.d.ts +32 -24
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/path.d.ts +7 -1
- package/dist/esm/path.js +17 -3
- package/dist/esm/path.js.map +1 -1
- package/dist/esm/route.d.ts +42 -45
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/routeInfo.d.ts +5 -7
- package/dist/esm/router.d.ts +2 -1
- package/dist/esm/router.js +7 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/utils.d.ts +5 -3
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/Matches.tsx +2 -2
- package/src/fileRoute.ts +17 -36
- package/src/index.tsx +0 -1
- package/src/link.tsx +187 -82
- package/src/path.ts +23 -3
- package/src/route.ts +153 -186
- package/src/routeInfo.ts +5 -7
- package/src/router.ts +13 -6
- package/src/useParams.tsx +2 -2
- package/src/utils.ts +10 -6
package/dist/esm/path.d.ts
CHANGED
|
@@ -9,7 +9,13 @@ export declare function cleanPath(path: string): string;
|
|
|
9
9
|
export declare function trimPathLeft(path: string): string;
|
|
10
10
|
export declare function trimPathRight(path: string): string;
|
|
11
11
|
export declare function trimPath(path: string): string;
|
|
12
|
-
|
|
12
|
+
interface ResolvePathOptions {
|
|
13
|
+
basepath: string;
|
|
14
|
+
base: string;
|
|
15
|
+
to: string;
|
|
16
|
+
trailingSlash?: 'always' | 'never' | 'preserve';
|
|
17
|
+
}
|
|
18
|
+
export declare function resolvePath({ basepath, base, to, trailingSlash, }: ResolvePathOptions): string;
|
|
13
19
|
export declare function parsePathname(pathname?: string): Array<Segment>;
|
|
14
20
|
interface InterpolatePathOptions {
|
|
15
21
|
path?: string;
|
package/dist/esm/path.js
CHANGED
|
@@ -14,8 +14,13 @@ function trimPathRight(path) {
|
|
|
14
14
|
function trimPath(path) {
|
|
15
15
|
return trimPathRight(trimPathLeft(path));
|
|
16
16
|
}
|
|
17
|
-
function resolvePath(
|
|
18
|
-
|
|
17
|
+
function resolvePath({
|
|
18
|
+
basepath,
|
|
19
|
+
base,
|
|
20
|
+
to,
|
|
21
|
+
trailingSlash = "never"
|
|
22
|
+
}) {
|
|
23
|
+
var _a, _b;
|
|
19
24
|
base = base.replace(new RegExp(`^${basepath}`), "/");
|
|
20
25
|
to = to.replace(new RegExp(`^${basepath}`), "/");
|
|
21
26
|
let baseSegments = parsePathname(base);
|
|
@@ -39,8 +44,17 @@ function resolvePath(basepath, base, to) {
|
|
|
39
44
|
baseSegments.push(toSegment);
|
|
40
45
|
}
|
|
41
46
|
});
|
|
47
|
+
if (baseSegments.length > 1) {
|
|
48
|
+
if (((_b = last(baseSegments)) == null ? void 0 : _b.value) === "/") {
|
|
49
|
+
if (trailingSlash === "never") {
|
|
50
|
+
baseSegments.pop();
|
|
51
|
+
}
|
|
52
|
+
} else if (trailingSlash === "always") {
|
|
53
|
+
baseSegments.push({ type: "pathname", value: "/" });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
const joined = joinPaths([basepath, ...baseSegments.map((d) => d.value)]);
|
|
43
|
-
return cleanPath(
|
|
57
|
+
return cleanPath(joined);
|
|
44
58
|
}
|
|
45
59
|
function parsePathname(pathname) {
|
|
46
60
|
if (!pathname) {
|
package/dist/esm/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","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(paths.filter(Boolean).join('/'))\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\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\nexport function resolvePath(basepath: string, base: string, to: string) {\n base = base.replace(new RegExp(`^${basepath}`), '/')\n to = to.replace(new RegExp(`^${basepath}`), '/')\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 const joined = joinPaths([basepath, ...baseSegments.map((d) => d.value)])\n\n return cleanPath(trimPathRight(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: 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: any\n leaveWildcards?: boolean\n leaveParams?: boolean\n}\nexport function interpolatePath({\n path,\n params,\n leaveWildcards,\n leaveParams,\n}: InterpolatePathOptions) {\n const interpolatedPathSegments = parsePathname(path)\n\n return joinPaths(\n interpolatedPathSegments.map((segment) => {\n if (segment.type === 'wildcard') {\n const value = params._splat\n if (leaveWildcards) return `${segment.value}${value ?? ''}`\n return value\n }\n\n if (segment.type === 'param') {\n if (leaveParams) {\n const value = params[segment.value]\n return `${segment.value}${value ?? ''}`\n }\n return params![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 return basepath != '/' ? pathname.replace(basepath, '') : pathname\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 if (baseSegment?.value) {\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 return false\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)] = decodeURI(\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":[],"mappings":";AASO,SAAS,UAAU,OAAkC;AAC1D,SAAO,UAAU,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC;AAClD;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;AA4BgB,SAAA,YAAY,UAAkB,MAAc,IAAY;;AAC/D,SAAA,KAAK,QAAQ,IAAI,OAAO,IAAI,QAAQ,EAAE,GAAG,GAAG;AAC9C,OAAA,GAAG,QAAQ,IAAI,OAAO,IAAI,QAAQ,EAAE,GAAG,GAAG;AAE3C,MAAA,eAAe,cAAc,IAAI;AAC/B,QAAA,aAAa,cAAc,EAAE;AAEnC,MAAI,aAAa,SAAS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SAAS;AAC7B,cAAA,YAAY,UAAU,KAAK;AACtB,mBAAA;AAAA,UACT;AACA,cAAI,YAAY,MAAM,OAAO,CAAC,MAAM,KAAK;AACvC,mBAAO,aAAa,MAAM,UAAU,CAAC,CAAC,IAAI;AAAA,cACxC,YAAY;AAAA,YAAA;AAAA,UAEhB;AAAA,QACF;AAAA,MACF;AAEI,UAAA,CAAC,qBAAqB,oBAAoB;AAC5C,eAAO,IAAI,IAAI,UAAU,aAAa,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,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.js","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(paths.filter(Boolean).join('/'))\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\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}\nexport function resolvePath({\n basepath,\n base,\n to,\n trailingSlash = 'never',\n}: ResolvePathOptions) {\n base = base.replace(new RegExp(`^${basepath}`), '/')\n to = to.replace(new RegExp(`^${basepath}`), '/')\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: 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: any\n leaveWildcards?: boolean\n leaveParams?: boolean\n}\nexport function interpolatePath({\n path,\n params,\n leaveWildcards,\n leaveParams,\n}: InterpolatePathOptions) {\n const interpolatedPathSegments = parsePathname(path)\n\n return joinPaths(\n interpolatedPathSegments.map((segment) => {\n if (segment.type === 'wildcard') {\n const value = params._splat\n if (leaveWildcards) return `${segment.value}${value ?? ''}`\n return value\n }\n\n if (segment.type === 'param') {\n if (leaveParams) {\n const value = params[segment.value]\n return `${segment.value}${value ?? ''}`\n }\n return params![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 return basepath != '/' ? pathname.replace(basepath, '') : pathname\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 if (baseSegment?.value) {\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 return false\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)] = decodeURI(\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":[],"mappings":";AASO,SAAS,UAAU,OAAkC;AAC1D,SAAO,UAAU,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC;AAClD;AAEO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EA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,3 +1,4 @@
|
|
|
1
|
+
import type { UseNavigateResult } from './useNavigate.js';
|
|
1
2
|
import type * as React from 'react';
|
|
2
3
|
import type { RouteMatch } from './Matches.js';
|
|
3
4
|
import type { AnyRouteMatch } from './Matches.js';
|
|
@@ -30,9 +31,9 @@ export type RoutePathOptions<TCustomId, TPath> = {
|
|
|
30
31
|
export interface StaticDataRouteOption {
|
|
31
32
|
}
|
|
32
33
|
export type RoutePathOptionsIntersection<TCustomId, TPath> = UnionToIntersection<RoutePathOptions<TCustomId, TPath>>;
|
|
33
|
-
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends Record<string, any> = {}, TSearchSchemaUsed
|
|
34
|
+
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends Record<string, any> = {}, TSearchSchemaUsed = {}, TFullSearchSchemaInput = TSearchSchemaUsed, TFullSearchSchema = TSearchSchema, TParams = AnyPathParams, TAllParams = TParams, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext = RouteContext, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TAllContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn> & UpdatableRouteOptions<NoInfer<TAllParams>, NoInfer<TFullSearchSchema>, NoInfer<TLoaderData>>;
|
|
34
35
|
export type ParamsFallback<TPath extends string, TParams> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams;
|
|
35
|
-
export type FileBaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TPath extends string = string, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema = TSearchSchema, TParams
|
|
36
|
+
export type FileBaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TPath extends string = string, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends Record<string, any> = {}, TFullSearchSchema = TSearchSchema, TParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext = RouteContext, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TAllContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown> = {
|
|
36
37
|
validateSearch?: SearchSchemaValidator<TSearchSchemaInput, TSearchSchema>;
|
|
37
38
|
shouldReload?: boolean | ((match: LoaderFnContext<TAllParams, TFullSearchSchema, TAllContext, TRouteContext>) => any);
|
|
38
39
|
beforeLoad?: BeforeLoadFn<TFullSearchSchema, TParentRoute, TAllParams, TRouteContextReturn, TRouterContext>;
|
|
@@ -47,10 +48,10 @@ export type FileBaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TPath
|
|
|
47
48
|
stringifyParams?: never;
|
|
48
49
|
parseParams?: never;
|
|
49
50
|
});
|
|
50
|
-
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends Record<string, any> = {}, TSearchSchemaUsed
|
|
51
|
+
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends Record<string, any> = {}, TSearchSchemaUsed = {}, TFullSearchSchemaInput = TSearchSchemaUsed, TFullSearchSchema = TSearchSchema, TParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext = RouteContext, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TAllContext = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown> = RoutePathOptions<TCustomId, TPath> & FileBaseRouteOptions<TParentRoute, TPath, TSearchSchemaInput, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn> & {
|
|
51
52
|
getParentRoute: () => TParentRoute;
|
|
52
53
|
};
|
|
53
|
-
type BeforeLoadFn<TFullSearchSchema, TParentRoute extends AnyRoute, TAllParams, TRouteContextReturn extends RouteContext, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TContext = IsAny<TParentRoute['types']['allContext'], TRouterContext>> = (opts: {
|
|
54
|
+
type BeforeLoadFn<in out TFullSearchSchema, in out TParentRoute extends AnyRoute, in out TAllParams, TRouteContextReturn extends RouteContext, in out TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, in out TContext = IsAny<TParentRoute['types']['allContext'], TRouterContext>> = (opts: {
|
|
54
55
|
search: TFullSearchSchema;
|
|
55
56
|
abortController: AbortController;
|
|
56
57
|
preload: boolean;
|
|
@@ -61,7 +62,7 @@ type BeforeLoadFn<TFullSearchSchema, TParentRoute extends AnyRoute, TAllParams,
|
|
|
61
62
|
buildLocation: BuildLocationFn<TParentRoute>;
|
|
62
63
|
cause: 'preload' | 'enter' | 'stay';
|
|
63
64
|
}) => Promise<TRouteContextReturn> | TRouteContextReturn | void;
|
|
64
|
-
export type UpdatableRouteOptions<TAllParams
|
|
65
|
+
export type UpdatableRouteOptions<TAllParams, TFullSearchSchema, TLoaderData> = {
|
|
65
66
|
caseSensitive?: boolean;
|
|
66
67
|
wrapInSuspense?: boolean;
|
|
67
68
|
component?: RouteComponent;
|
|
@@ -133,13 +134,13 @@ export type SearchSchemaValidatorObj<TInput, TReturn> = {
|
|
|
133
134
|
parse?: SearchSchemaValidatorFn<TInput, TReturn>;
|
|
134
135
|
};
|
|
135
136
|
export type SearchSchemaValidatorFn<TInput, TReturn> = (searchObj: TInput) => TReturn;
|
|
136
|
-
export type RouteLoaderFn<TAllParams = {}, TLoaderDeps extends Record<string, any> = {}, TAllContext = AnyContext,
|
|
137
|
-
export interface LoaderFnContext<TAllParams = {}, TLoaderDeps = {}, TAllContext = AnyContext,
|
|
137
|
+
export type RouteLoaderFn<in out TAllParams = {}, in out TLoaderDeps extends Record<string, any> = {}, in out TAllContext = AnyContext, in out TRouteContext = AnyContext, TLoaderData = unknown> = (match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext, TRouteContext>) => Promise<TLoaderData> | TLoaderData;
|
|
138
|
+
export interface LoaderFnContext<in out TAllParams = {}, in out TLoaderDeps = {}, in out TAllContext = AnyContext, in out TRouteContext = AnyContext> {
|
|
138
139
|
abortController: AbortController;
|
|
139
140
|
preload: boolean;
|
|
140
141
|
params: TAllParams;
|
|
141
142
|
deps: TLoaderDeps;
|
|
142
|
-
context:
|
|
143
|
+
context: Assign<TAllContext, TRouteContext>;
|
|
143
144
|
location: ParsedLocation;
|
|
144
145
|
/**
|
|
145
146
|
* @deprecated Use `throw redirect({ to: '/somewhere' })` instead
|
|
@@ -163,12 +164,12 @@ export type InferFullSearchSchemaInput<TRoute> = TRoute extends {
|
|
|
163
164
|
fullSearchSchemaInput: infer TFullSearchSchemaInput;
|
|
164
165
|
};
|
|
165
166
|
} ? TFullSearchSchemaInput : {};
|
|
166
|
-
export type ResolveFullSearchSchema<TParentRoute extends AnyRoute, TSearchSchema> =
|
|
167
|
-
export type ResolveFullSearchSchemaInput<TParentRoute extends AnyRoute, TSearchSchemaUsed> =
|
|
168
|
-
export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any
|
|
167
|
+
export type ResolveFullSearchSchema<TParentRoute extends AnyRoute, TSearchSchema> = Assign<TParentRoute['id'] extends RootRouteId ? Omit<TParentRoute['types']['searchSchema'], keyof RootSearchSchema> : TParentRoute['types']['fullSearchSchema'], TSearchSchema>;
|
|
168
|
+
export type ResolveFullSearchSchemaInput<TParentRoute extends AnyRoute, TSearchSchemaUsed> = Assign<TParentRoute['id'] extends RootRouteId ? Omit<TParentRoute['types']['searchSchemaInput'], keyof RootSearchSchema> : TParentRoute['types']['fullSearchSchemaInput'], TSearchSchemaUsed>;
|
|
169
|
+
export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
169
170
|
}
|
|
170
171
|
export type MergeFromFromParent<T, U> = IsAny<T, U, T & U>;
|
|
171
|
-
export type ResolveAllParams<TParentRoute extends AnyRoute, TParams
|
|
172
|
+
export type ResolveAllParams<TParentRoute extends AnyRoute, TParams> = Record<never, string> extends TParentRoute['types']['allParams'] ? TParams : UnionToIntersection<TParentRoute['types']['allParams'] & TParams> & {};
|
|
172
173
|
export type RouteConstraints = {
|
|
173
174
|
TParentRoute: AnyRoute;
|
|
174
175
|
TPath: string;
|
|
@@ -186,8 +187,8 @@ export type RouteConstraints = {
|
|
|
186
187
|
TChildren: unknown;
|
|
187
188
|
TRouteTree: AnyRoute;
|
|
188
189
|
};
|
|
189
|
-
export declare function getRouteApi<TId extends RouteIds<RegisteredRouter['routeTree']>, TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>, TFullSearchSchema = TRoute['types']['fullSearchSchema'], TAllParams
|
|
190
|
-
export declare class RouteApi<TId extends RouteIds<RegisteredRouter['routeTree']>, TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>, TFullSearchSchema = TRoute['types']['fullSearchSchema'], TAllParams
|
|
190
|
+
export declare function getRouteApi<TId extends RouteIds<RegisteredRouter['routeTree']>, TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>, TFullSearchSchema = TRoute['types']['fullSearchSchema'], TAllParams = TRoute['types']['allParams'], TAllContext = TRoute['types']['allContext'], TLoaderDeps = TRoute['types']['loaderDeps'], TLoaderData = TRoute['types']['loaderData']>(id: TId): RouteApi<TId, TRoute, TFullSearchSchema, TAllParams, TAllContext, TLoaderDeps, TLoaderData>;
|
|
191
|
+
export declare class RouteApi<TId extends RouteIds<RegisteredRouter['routeTree']>, TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>, TFullSearchSchema = TRoute['types']['fullSearchSchema'], TAllParams = TRoute['types']['allParams'], TAllContext = TRoute['types']['allContext'], TLoaderDeps = TRoute['types']['loaderDeps'], TLoaderData = TRoute['types']['loaderData']> {
|
|
191
192
|
id: TId;
|
|
192
193
|
/**
|
|
193
194
|
* @deprecated Use the `getRouteApi` function instead.
|
|
@@ -198,14 +199,14 @@ export declare class RouteApi<TId extends RouteIds<RegisteredRouter['routeTree']
|
|
|
198
199
|
useMatch: <TRouteTree extends AnyRoute = AnyRoute, TRouteMatchState = RouteMatch<TRouteTree, TId, false>, TSelected = TRouteMatchState>(opts?: {
|
|
199
200
|
select?: ((match: TRouteMatchState) => TSelected) | undefined;
|
|
200
201
|
} | undefined) => TSelected;
|
|
201
|
-
useRouteContext: <TSelected = TAllContext
|
|
202
|
-
select?: ((s: TAllContext) => TSelected) | undefined;
|
|
202
|
+
useRouteContext: <TSelected = Expand<TAllContext>>(opts?: {
|
|
203
|
+
select?: ((s: Expand<TAllContext>) => TSelected) | undefined;
|
|
203
204
|
} | undefined) => TSelected;
|
|
204
|
-
useSearch: <TSelected = TFullSearchSchema
|
|
205
|
-
select?: ((s: TFullSearchSchema) => TSelected) | undefined;
|
|
205
|
+
useSearch: <TSelected = Expand<TFullSearchSchema>>(opts?: {
|
|
206
|
+
select?: ((s: Expand<TFullSearchSchema>) => TSelected) | undefined;
|
|
206
207
|
} | undefined) => TSelected;
|
|
207
|
-
useParams: <TSelected = TAllParams
|
|
208
|
-
select?: ((s: TAllParams) => TSelected) | undefined;
|
|
208
|
+
useParams: <TSelected = Expand<TAllParams>>(opts?: {
|
|
209
|
+
select?: ((s: Expand<TAllParams>) => TSelected) | undefined;
|
|
209
210
|
} | undefined) => TSelected;
|
|
210
211
|
useLoaderDeps: <TSelected = TLoaderDeps>(opts?: {
|
|
211
212
|
select?: ((s: TLoaderDeps) => TSelected) | undefined;
|
|
@@ -213,12 +214,10 @@ export declare class RouteApi<TId extends RouteIds<RegisteredRouter['routeTree']
|
|
|
213
214
|
useLoaderData: <TSelected = TLoaderData>(opts?: {
|
|
214
215
|
select?: ((s: TLoaderData) => TSelected) | undefined;
|
|
215
216
|
} | undefined) => TSelected;
|
|
216
|
-
useNavigate: () =>
|
|
217
|
+
useNavigate: () => UseNavigateResult<string>;
|
|
217
218
|
notFound: (opts?: NotFoundError) => NotFoundError;
|
|
218
219
|
}
|
|
219
|
-
export declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, in out TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {}, TSearchSchema extends RouteConstraints['TSearchSchema'] = {},
|
|
220
|
-
TRouteContextReturn
|
|
221
|
-
] extends [never] ? RouteContext : TRouteContextReturn, in out TAllContext = Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> {
|
|
220
|
+
export declare class Route<in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, in out TPath extends RouteConstraints['TPath'] = '/', in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends RouteConstraints['TCustomId'] = string, in out TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {}, in out TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, in out TSearchSchemaUsed = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, keyof SearchSchemaInput> : TSearchSchema, in out TFullSearchSchemaInput = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, in out TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, in out TParams = Record<ParsePathParams<TPath>, string>, in out TAllParams = ResolveAllParams<TParentRoute, TParams>, TRouteContextReturn extends RouteConstraints['TRouteContext'] = RouteContext, in out TRouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, in out TAllContext = Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>, in out TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, in out TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, in out TChildren extends RouteConstraints['TChildren'] = unknown> {
|
|
222
221
|
isRoot: TParentRoute extends Route<any> ? true : false;
|
|
223
222
|
options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>;
|
|
224
223
|
parentRoute: TParentRoute;
|
|
@@ -252,7 +251,6 @@ export declare class Route<TParentRoute extends RouteConstraints['TParentRoute']
|
|
|
252
251
|
routeContext: TRouteContext;
|
|
253
252
|
allContext: TAllContext;
|
|
254
253
|
children: TChildren;
|
|
255
|
-
routeTree: TRouteTree;
|
|
256
254
|
routerContext: TRouterContext;
|
|
257
255
|
loaderData: TLoaderData;
|
|
258
256
|
loaderDeps: TLoaderDeps;
|
|
@@ -260,23 +258,23 @@ export declare class Route<TParentRoute extends RouteConstraints['TParentRoute']
|
|
|
260
258
|
init: (opts: {
|
|
261
259
|
originalIndex: number;
|
|
262
260
|
}) => void;
|
|
263
|
-
addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TNewChildren
|
|
261
|
+
addChildren: <const TNewChildren extends readonly AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TNewChildren>;
|
|
264
262
|
updateLoader: <TNewLoaderData = unknown>(options: {
|
|
265
263
|
loader: RouteLoaderFn<TAllParams, TLoaderDeps, TAllContext, TRouteContext, TNewLoaderData>;
|
|
266
|
-
}) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TNewLoaderData, TChildren,
|
|
264
|
+
}) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TNewLoaderData, TChildren, unknown>;
|
|
267
265
|
update: (options: UpdatableRouteOptions<TAllParams, TFullSearchSchema, TLoaderData>) => this;
|
|
268
266
|
lazy: (lazyFn: () => Promise<LazyRoute<any>>) => this;
|
|
269
|
-
useMatch: <
|
|
267
|
+
useMatch: <TRouteTree extends AnyRoute = AnyRoute, TRouteMatchState = RouteMatch<TRouteTree, TId, false>, TSelected = TRouteMatchState>(opts?: {
|
|
270
268
|
select?: ((match: TRouteMatchState) => TSelected) | undefined;
|
|
271
269
|
} | undefined) => TSelected;
|
|
272
|
-
useRouteContext: <TSelected = TAllContext
|
|
273
|
-
select?: ((search: TAllContext) => TSelected) | undefined;
|
|
270
|
+
useRouteContext: <TSelected = Expand<TAllContext>>(opts?: {
|
|
271
|
+
select?: ((search: Expand<TAllContext>) => TSelected) | undefined;
|
|
274
272
|
} | undefined) => TSelected;
|
|
275
|
-
useSearch: <TSelected = TFullSearchSchema
|
|
276
|
-
select?: ((search: TFullSearchSchema) => TSelected) | undefined;
|
|
273
|
+
useSearch: <TSelected = Expand<TFullSearchSchema>>(opts?: {
|
|
274
|
+
select?: ((search: Expand<TFullSearchSchema>) => TSelected) | undefined;
|
|
277
275
|
} | undefined) => TSelected;
|
|
278
|
-
useParams: <TSelected = TAllParams
|
|
279
|
-
select?: ((search: TAllParams) => TSelected) | undefined;
|
|
276
|
+
useParams: <TSelected = Expand<TAllParams>>(opts?: {
|
|
277
|
+
select?: ((search: Expand<TAllParams>) => TSelected) | undefined;
|
|
280
278
|
} | undefined) => TSelected;
|
|
281
279
|
useLoaderDeps: <TSelected = TLoaderDeps>(opts?: {
|
|
282
280
|
select?: ((s: TLoaderDeps) => TSelected) | undefined;
|
|
@@ -284,13 +282,11 @@ export declare class Route<TParentRoute extends RouteConstraints['TParentRoute']
|
|
|
284
282
|
useLoaderData: <TSelected = TLoaderData>(opts?: {
|
|
285
283
|
select?: ((search: TLoaderData) => TSelected) | undefined;
|
|
286
284
|
} | undefined) => TSelected;
|
|
287
|
-
useNavigate: () =>
|
|
285
|
+
useNavigate: () => UseNavigateResult<string>;
|
|
288
286
|
}
|
|
289
|
-
export declare function createRoute<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {}, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TSearchSchemaUsed
|
|
290
|
-
TRouteContextReturn
|
|
291
|
-
] extends [never] ? RouteContext : TRouteContextReturn, TAllContext = Expand<Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute>(options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren, TRouteTree>;
|
|
287
|
+
export declare function createRoute<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TSearchSchemaInput extends RouteConstraints['TSearchSchema'] = {}, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TSearchSchemaUsed = TSearchSchemaInput extends SearchSchemaInput ? Omit<TSearchSchemaInput, keyof SearchSchemaInput> : TSearchSchema, TFullSearchSchemaInput = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams = Record<ParsePathParams<TPath>, string>, TAllParams = ResolveAllParams<TParentRoute, TParams>, TRouteContextReturn extends RouteConstraints['TRouteContext'] = RouteContext, TRouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TAllContext = Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, TChildren extends RouteConstraints['TChildren'] = unknown>(options: RouteOptions<TParentRoute, TCustomId, TPath, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>): Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren>;
|
|
292
288
|
export type AnyRootRoute = RootRoute<any, any, any, any, any, any, any, any>;
|
|
293
|
-
export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TSearchSchemaInput extends Record<string, any> = RootSearchSchema, TSearchSchema extends Record<string, any> = RootSearchSchema, TSearchSchemaUsed extends Record<string, any> = RootSearchSchema, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn>(options?: Omit<RouteOptions<
|
|
289
|
+
export declare function createRootRouteWithContext<TRouterContext extends {}>(): <TSearchSchemaInput extends Record<string, any> = RootSearchSchema, TSearchSchema extends Record<string, any> = RootSearchSchema, TSearchSchemaUsed extends Record<string, any> = RootSearchSchema, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn>(options?: Omit<RouteOptions<any, "__root__", "", TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TSearchSchemaUsed, TSearchSchema, {}, {}, TRouteContextReturn, TRouteContext, TRouterContext, Assign<TRouterContext, TRouteContext>, TLoaderDeps, TLoaderDataReturn, TLoaderData>, "path" | "id" | "stringifyParams" | "parseParams" | "getParentRoute" | "caseSensitive"> | undefined) => RootRoute<TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TRouteContextReturn, TRouteContext, TRouterContext, TLoaderDeps, TLoaderData, [TLoaderData] extends [never] ? undefined : TLoaderData>;
|
|
294
290
|
/**
|
|
295
291
|
* @deprecated Use the `createRootRouteWithContext` function instead.
|
|
296
292
|
*/
|
|
@@ -298,7 +294,9 @@ export declare const rootRouteWithContext: typeof createRootRouteWithContext;
|
|
|
298
294
|
export type RootSearchSchema = {
|
|
299
295
|
__TRootSearchSchema__: '__TRootSearchSchema__';
|
|
300
296
|
};
|
|
301
|
-
export declare class RootRoute<TSearchSchemaInput extends Record<string, any> = RootSearchSchema, TSearchSchema extends Record<string, any> = RootSearchSchema, TSearchSchemaUsed extends Record<string, any> = RootSearchSchema, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [
|
|
297
|
+
export declare class RootRoute<in out TSearchSchemaInput extends Record<string, any> = RootSearchSchema, in out TSearchSchema extends Record<string, any> = RootSearchSchema, in out TSearchSchemaUsed extends Record<string, any> = RootSearchSchema, TRouteContextReturn extends RouteContext = RouteContext, in out TRouteContext extends RouteContext = [TRouteContextReturn] extends [
|
|
298
|
+
never
|
|
299
|
+
] ? RouteContext : TRouteContextReturn, in out TRouterContext extends {} = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, in out TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn> extends Route<any, // TParentRoute
|
|
302
300
|
'/', // TPath
|
|
303
301
|
'/', // TFullPath
|
|
304
302
|
string, // TCustomId
|
|
@@ -313,12 +311,11 @@ TRouteContextReturn, // TRouteContextReturn
|
|
|
313
311
|
TRouteContext, // TRouteContext
|
|
314
312
|
Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
315
313
|
TRouterContext, // TRouterContext
|
|
316
|
-
TLoaderDeps, TLoaderDataReturn, TLoaderData, any
|
|
317
|
-
any> {
|
|
314
|
+
TLoaderDeps, TLoaderDataReturn, TLoaderData, any> {
|
|
318
315
|
/**
|
|
319
316
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
320
317
|
*/
|
|
321
|
-
constructor(options?: Omit<RouteOptions<
|
|
318
|
+
constructor(options?: Omit<RouteOptions<any, // TParentRoute
|
|
322
319
|
RootRouteId, // TCustomId
|
|
323
320
|
'', // TPath
|
|
324
321
|
TSearchSchemaInput, // TSearchSchemaInput
|
|
@@ -332,7 +329,7 @@ any> {
|
|
|
332
329
|
TRouterContext, Assign<TRouterContext, TRouteContext>, // TAllContext
|
|
333
330
|
TLoaderDeps, TLoaderDataReturn, TLoaderData>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
|
|
334
331
|
}
|
|
335
|
-
export declare function createRootRoute<TSearchSchemaInput extends Record<string, any> = RootSearchSchema, TSearchSchema extends Record<string, any> = RootSearchSchema, TSearchSchemaUsed extends Record<string, any> = RootSearchSchema, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TRouterContext extends {} = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn>(options?: Omit<RouteOptions<
|
|
332
|
+
export declare function createRootRoute<TSearchSchemaInput extends Record<string, any> = RootSearchSchema, TSearchSchema extends Record<string, any> = RootSearchSchema, TSearchSchemaUsed extends Record<string, any> = RootSearchSchema, TRouteContextReturn extends RouteContext = RouteContext, TRouteContext extends RouteContext = [TRouteContextReturn] extends [never] ? RouteContext : TRouteContextReturn, TRouterContext extends {} = {}, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn>(options?: Omit<RouteOptions<any, // TParentRoute
|
|
336
333
|
RootRouteId, // TCustomId
|
|
337
334
|
'', // TPath
|
|
338
335
|
TSearchSchemaInput, // TSearchSchemaInput
|
|
@@ -391,7 +388,7 @@ export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
|
|
|
391
388
|
export type RouteComponent<TProps = any> = SyncRouteComponent<TProps> & AsyncRouteComponent<TProps>;
|
|
392
389
|
export type ErrorRouteComponent = RouteComponent<ErrorComponentProps>;
|
|
393
390
|
export type NotFoundRouteComponent = SyncRouteComponent<NotFoundRouteProps>;
|
|
394
|
-
export declare class NotFoundRoute<TParentRoute extends AnyRootRoute, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TSearchSchemaUsed extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchemaInput extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TRouteContextReturn extends RouteConstraints['TRouteContext'] = AnyContext, TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext =
|
|
391
|
+
export declare class NotFoundRoute<TParentRoute extends AnyRootRoute, TSearchSchemaInput extends Record<string, any> = {}, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TSearchSchemaUsed extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchemaInput extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchemaInput<TParentRoute, TSearchSchemaUsed>, TFullSearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TRouteContextReturn extends RouteConstraints['TRouteContext'] = AnyContext, TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext = Assign<IsAny<TParentRoute['types']['allContext'], {}>, TRouteContext>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderDataReturn = unknown, TLoaderData = [TLoaderDataReturn] extends [never] ? undefined : TLoaderDataReturn, TChildren extends RouteConstraints['TChildren'] = unknown> extends Route<TParentRoute, '/404', '/404', '404', '404', TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, {}, {}, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren> {
|
|
395
392
|
constructor(options: Omit<RouteOptions<TParentRoute, string, string, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, {}, {}, TRouteContextReturn, TRouteContext, TRouterContext, TAllContext, TLoaderDeps, TLoaderDataReturn, TLoaderData>, 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'path' | 'id'>);
|
|
396
393
|
}
|
|
397
394
|
export {};
|