@tanstack/router-core 1.121.16 → 1.121.18
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/package.json +2 -2
- package/src/redirect.ts +3 -0
- package/src/router.ts +15 -1
- package/dist/cjs/Matches.cjs +0 -13
- package/dist/cjs/Matches.cjs.map +0 -1
- package/dist/cjs/Matches.d.cts +0 -109
- package/dist/cjs/RouterProvider.d.cts +0 -26
- package/dist/cjs/defer.cjs +0 -25
- package/dist/cjs/defer.cjs.map +0 -1
- package/dist/cjs/defer.d.cts +0 -20
- package/dist/cjs/fileRoute.d.cts +0 -23
- package/dist/cjs/history.d.cts +0 -8
- package/dist/cjs/index.cjs +0 -79
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -41
- package/dist/cjs/link.cjs +0 -5
- package/dist/cjs/link.cjs.map +0 -1
- package/dist/cjs/link.d.cts +0 -212
- package/dist/cjs/location.d.cts +0 -12
- package/dist/cjs/manifest.d.cts +0 -24
- package/dist/cjs/not-found.cjs +0 -13
- package/dist/cjs/not-found.cjs.map +0 -1
- package/dist/cjs/not-found.d.cts +0 -20
- package/dist/cjs/path.cjs +0 -412
- package/dist/cjs/path.cjs.map +0 -1
- package/dist/cjs/path.d.cts +0 -56
- package/dist/cjs/qss.cjs +0 -36
- package/dist/cjs/qss.cjs.map +0 -1
- package/dist/cjs/qss.d.cts +0 -31
- package/dist/cjs/redirect.cjs +0 -39
- package/dist/cjs/redirect.cjs.map +0 -1
- package/dist/cjs/redirect.d.cts +0 -41
- package/dist/cjs/root.cjs +0 -5
- package/dist/cjs/root.cjs.map +0 -1
- package/dist/cjs/root.d.cts +0 -2
- package/dist/cjs/route.cjs +0 -119
- package/dist/cjs/route.cjs.map +0 -1
- package/dist/cjs/route.d.cts +0 -432
- package/dist/cjs/routeInfo.d.cts +0 -54
- package/dist/cjs/router.cjs +0 -1792
- package/dist/cjs/router.cjs.map +0 -1
- package/dist/cjs/router.d.cts +0 -627
- package/dist/cjs/scroll-restoration.cjs +0 -207
- package/dist/cjs/scroll-restoration.cjs.map +0 -1
- package/dist/cjs/scroll-restoration.d.cts +0 -38
- package/dist/cjs/searchMiddleware.cjs +0 -42
- package/dist/cjs/searchMiddleware.cjs.map +0 -1
- package/dist/cjs/searchMiddleware.d.cts +0 -5
- package/dist/cjs/searchParams.cjs +0 -61
- package/dist/cjs/searchParams.cjs.map +0 -1
- package/dist/cjs/searchParams.d.cts +0 -7
- package/dist/cjs/serializer.d.cts +0 -22
- package/dist/cjs/structuralSharing.d.cts +0 -4
- package/dist/cjs/typePrimitives.d.cts +0 -65
- package/dist/cjs/useLoaderData.d.cts +0 -5
- package/dist/cjs/useLoaderDeps.d.cts +0 -5
- package/dist/cjs/useNavigate.d.cts +0 -3
- package/dist/cjs/useParams.d.cts +0 -5
- package/dist/cjs/useRouteContext.d.cts +0 -9
- package/dist/cjs/useSearch.d.cts +0 -5
- package/dist/cjs/utils.cjs +0 -165
- package/dist/cjs/utils.cjs.map +0 -1
- package/dist/cjs/utils.d.cts +0 -94
- package/dist/cjs/validators.d.cts +0 -51
- package/dist/esm/Matches.d.ts +0 -109
- package/dist/esm/Matches.js +0 -13
- package/dist/esm/Matches.js.map +0 -1
- package/dist/esm/RouterProvider.d.ts +0 -26
- package/dist/esm/defer.d.ts +0 -20
- package/dist/esm/defer.js +0 -25
- package/dist/esm/defer.js.map +0 -1
- package/dist/esm/fileRoute.d.ts +0 -23
- package/dist/esm/history.d.ts +0 -8
- package/dist/esm/index.d.ts +0 -41
- package/dist/esm/index.js +0 -79
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/link.d.ts +0 -212
- package/dist/esm/link.js +0 -5
- package/dist/esm/link.js.map +0 -1
- package/dist/esm/location.d.ts +0 -12
- package/dist/esm/manifest.d.ts +0 -24
- package/dist/esm/not-found.d.ts +0 -20
- package/dist/esm/not-found.js +0 -13
- package/dist/esm/not-found.js.map +0 -1
- package/dist/esm/path.d.ts +0 -56
- package/dist/esm/path.js +0 -412
- package/dist/esm/path.js.map +0 -1
- package/dist/esm/qss.d.ts +0 -31
- package/dist/esm/qss.js +0 -36
- package/dist/esm/qss.js.map +0 -1
- package/dist/esm/redirect.d.ts +0 -41
- package/dist/esm/redirect.js +0 -39
- package/dist/esm/redirect.js.map +0 -1
- package/dist/esm/root.d.ts +0 -2
- package/dist/esm/root.js +0 -5
- package/dist/esm/root.js.map +0 -1
- package/dist/esm/route.d.ts +0 -432
- package/dist/esm/route.js +0 -119
- package/dist/esm/route.js.map +0 -1
- package/dist/esm/routeInfo.d.ts +0 -54
- package/dist/esm/router.d.ts +0 -627
- package/dist/esm/router.js +0 -1792
- package/dist/esm/router.js.map +0 -1
- package/dist/esm/scroll-restoration.d.ts +0 -38
- package/dist/esm/scroll-restoration.js +0 -207
- package/dist/esm/scroll-restoration.js.map +0 -1
- package/dist/esm/searchMiddleware.d.ts +0 -5
- package/dist/esm/searchMiddleware.js +0 -42
- package/dist/esm/searchMiddleware.js.map +0 -1
- package/dist/esm/searchParams.d.ts +0 -7
- package/dist/esm/searchParams.js +0 -61
- package/dist/esm/searchParams.js.map +0 -1
- package/dist/esm/serializer.d.ts +0 -22
- package/dist/esm/structuralSharing.d.ts +0 -4
- package/dist/esm/typePrimitives.d.ts +0 -65
- package/dist/esm/useLoaderData.d.ts +0 -5
- package/dist/esm/useLoaderDeps.d.ts +0 -5
- package/dist/esm/useNavigate.d.ts +0 -3
- package/dist/esm/useParams.d.ts +0 -5
- package/dist/esm/useRouteContext.d.ts +0 -9
- package/dist/esm/useSearch.d.ts +0 -5
- package/dist/esm/utils.d.ts +0 -94
- package/dist/esm/utils.js +0 -165
- package/dist/esm/utils.js.map +0 -1
- package/dist/esm/validators.d.ts +0 -51
package/dist/cjs/utils.cjs
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function last(arr) {
|
|
4
|
-
return arr[arr.length - 1];
|
|
5
|
-
}
|
|
6
|
-
function isFunction(d) {
|
|
7
|
-
return typeof d === "function";
|
|
8
|
-
}
|
|
9
|
-
function functionalUpdate(updater, previous) {
|
|
10
|
-
if (isFunction(updater)) {
|
|
11
|
-
return updater(previous);
|
|
12
|
-
}
|
|
13
|
-
return updater;
|
|
14
|
-
}
|
|
15
|
-
function pick(parent, keys) {
|
|
16
|
-
return keys.reduce((obj, key) => {
|
|
17
|
-
obj[key] = parent[key];
|
|
18
|
-
return obj;
|
|
19
|
-
}, {});
|
|
20
|
-
}
|
|
21
|
-
function replaceEqualDeep(prev, _next) {
|
|
22
|
-
if (prev === _next) {
|
|
23
|
-
return prev;
|
|
24
|
-
}
|
|
25
|
-
const next = _next;
|
|
26
|
-
const array = isPlainArray(prev) && isPlainArray(next);
|
|
27
|
-
if (array || isSimplePlainObject(prev) && isSimplePlainObject(next)) {
|
|
28
|
-
const prevItems = array ? prev : Object.keys(prev).concat(
|
|
29
|
-
Object.getOwnPropertySymbols(prev)
|
|
30
|
-
);
|
|
31
|
-
const prevSize = prevItems.length;
|
|
32
|
-
const nextItems = array ? next : Object.keys(next).concat(
|
|
33
|
-
Object.getOwnPropertySymbols(next)
|
|
34
|
-
);
|
|
35
|
-
const nextSize = nextItems.length;
|
|
36
|
-
const copy = array ? [] : {};
|
|
37
|
-
let equalItems = 0;
|
|
38
|
-
for (let i = 0; i < nextSize; i++) {
|
|
39
|
-
const key = array ? i : nextItems[i];
|
|
40
|
-
if ((!array && prevItems.includes(key) || array) && prev[key] === void 0 && next[key] === void 0) {
|
|
41
|
-
copy[key] = void 0;
|
|
42
|
-
equalItems++;
|
|
43
|
-
} else {
|
|
44
|
-
copy[key] = replaceEqualDeep(prev[key], next[key]);
|
|
45
|
-
if (copy[key] === prev[key] && prev[key] !== void 0) {
|
|
46
|
-
equalItems++;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return prevSize === nextSize && equalItems === prevSize ? prev : copy;
|
|
51
|
-
}
|
|
52
|
-
return next;
|
|
53
|
-
}
|
|
54
|
-
function isSimplePlainObject(o) {
|
|
55
|
-
return (
|
|
56
|
-
// all the checks from isPlainObject are more likely to hit so we perform them first
|
|
57
|
-
isPlainObject(o) && Object.getOwnPropertyNames(o).length === Object.keys(o).length
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
function isPlainObject(o) {
|
|
61
|
-
if (!hasObjectPrototype(o)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
const ctor = o.constructor;
|
|
65
|
-
if (typeof ctor === "undefined") {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
const prot = ctor.prototype;
|
|
69
|
-
if (!hasObjectPrototype(prot)) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
function hasObjectPrototype(o) {
|
|
78
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
79
|
-
}
|
|
80
|
-
function isPlainArray(value) {
|
|
81
|
-
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
82
|
-
}
|
|
83
|
-
function getObjectKeys(obj, ignoreUndefined) {
|
|
84
|
-
let keys = Object.keys(obj);
|
|
85
|
-
if (ignoreUndefined) {
|
|
86
|
-
keys = keys.filter((key) => obj[key] !== void 0);
|
|
87
|
-
}
|
|
88
|
-
return keys;
|
|
89
|
-
}
|
|
90
|
-
function deepEqual(a, b, opts) {
|
|
91
|
-
if (a === b) {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
if (typeof a !== typeof b) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
98
|
-
const ignoreUndefined = (opts == null ? void 0 : opts.ignoreUndefined) ?? true;
|
|
99
|
-
const aKeys = getObjectKeys(a, ignoreUndefined);
|
|
100
|
-
const bKeys = getObjectKeys(b, ignoreUndefined);
|
|
101
|
-
if (!(opts == null ? void 0 : opts.partial) && aKeys.length !== bKeys.length) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
return bKeys.every((key) => deepEqual(a[key], b[key], opts));
|
|
105
|
-
}
|
|
106
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
107
|
-
if (a.length !== b.length) {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
return !a.some((item, index) => !deepEqual(item, b[index], opts));
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
function createControlledPromise(onResolve) {
|
|
115
|
-
let resolveLoadPromise;
|
|
116
|
-
let rejectLoadPromise;
|
|
117
|
-
const controlledPromise = new Promise((resolve, reject) => {
|
|
118
|
-
resolveLoadPromise = resolve;
|
|
119
|
-
rejectLoadPromise = reject;
|
|
120
|
-
});
|
|
121
|
-
controlledPromise.status = "pending";
|
|
122
|
-
controlledPromise.resolve = (value) => {
|
|
123
|
-
controlledPromise.status = "resolved";
|
|
124
|
-
controlledPromise.value = value;
|
|
125
|
-
resolveLoadPromise(value);
|
|
126
|
-
onResolve == null ? void 0 : onResolve(value);
|
|
127
|
-
};
|
|
128
|
-
controlledPromise.reject = (e) => {
|
|
129
|
-
controlledPromise.status = "rejected";
|
|
130
|
-
rejectLoadPromise(e);
|
|
131
|
-
};
|
|
132
|
-
return controlledPromise;
|
|
133
|
-
}
|
|
134
|
-
function escapeJSON(jsonString) {
|
|
135
|
-
return jsonString.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/"/g, '\\"');
|
|
136
|
-
}
|
|
137
|
-
function shallow(objA, objB) {
|
|
138
|
-
if (Object.is(objA, objB)) {
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
const keysA = Object.keys(objA);
|
|
145
|
-
if (keysA.length !== Object.keys(objB).length) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
for (const item of keysA) {
|
|
149
|
-
if (!Object.prototype.hasOwnProperty.call(objB, item) || !Object.is(objA[item], objB[item])) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
exports.createControlledPromise = createControlledPromise;
|
|
156
|
-
exports.deepEqual = deepEqual;
|
|
157
|
-
exports.escapeJSON = escapeJSON;
|
|
158
|
-
exports.functionalUpdate = functionalUpdate;
|
|
159
|
-
exports.isPlainArray = isPlainArray;
|
|
160
|
-
exports.isPlainObject = isPlainObject;
|
|
161
|
-
exports.last = last;
|
|
162
|
-
exports.pick = pick;
|
|
163
|
-
exports.replaceEqualDeep = replaceEqualDeep;
|
|
164
|
-
exports.shallow = shallow;
|
|
165
|
-
//# sourceMappingURL=utils.cjs.map
|
package/dist/cjs/utils.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["import type { RouteIds } from './routeInfo'\nimport type { AnyRouter } from './router'\n\nexport type Awaitable<T> = T | Promise<T>\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\nexport type IsAny<TValue, TYesResult, TNoResult = TValue> = 1 extends 0 & TValue\n ? TYesResult\n : TNoResult\n\nexport type PickAsRequired<TValue, TKey extends keyof TValue> = Omit<\n TValue,\n TKey\n> &\n Required<Pick<TValue, TKey>>\n\nexport type PickRequired<T> = {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K]\n}\n\nexport type PickOptional<T> = {\n [K in keyof T as undefined extends T[K] ? K : never]: T[K]\n}\n\n// from https://stackoverflow.com/a/76458160\nexport type WithoutEmpty<T> = T extends any ? ({} extends T ? never : T) : never\n\nexport type Expand<T> = T extends object\n ? T extends infer O\n ? O extends Function\n ? O\n : { [K in keyof O]: O[K] }\n : never\n : T\n\nexport type DeepPartial<T> = T extends object\n ? {\n [P in keyof T]?: DeepPartial<T[P]>\n }\n : T\n\nexport type MakeDifferenceOptional<TLeft, TRight> = keyof TLeft &\n keyof TRight extends never\n ? TRight\n : Omit<TRight, keyof TLeft & keyof TRight> & {\n [K in keyof TLeft & keyof TRight]?: TRight[K]\n }\n\n// from https://stackoverflow.com/a/53955431\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type IsUnion<T, U extends T = T> = (\n T extends any ? (U extends T ? false : true) : never\n) extends false\n ? false\n : true\n\nexport type IsNonEmptyObject<T> = T extends object\n ? keyof T extends never\n ? false\n : true\n : false\n\nexport type Assign<TLeft, TRight> = TLeft extends any\n ? TRight extends any\n ? IsNonEmptyObject<TLeft> extends false\n ? TRight\n : IsNonEmptyObject<TRight> extends false\n ? TLeft\n : keyof TLeft & keyof TRight extends never\n ? TLeft & TRight\n : Omit<TLeft, keyof TRight> & TRight\n : never\n : never\n\nexport type IntersectAssign<TLeft, TRight> = TLeft extends any\n ? TRight extends any\n ? IsNonEmptyObject<TLeft> extends false\n ? TRight\n : IsNonEmptyObject<TRight> extends false\n ? TLeft\n : TRight & TLeft\n : never\n : never\n\nexport type Timeout = ReturnType<typeof setTimeout>\n\nexport type Updater<TPrevious, TResult = TPrevious> =\n | TResult\n | ((prev?: TPrevious) => TResult)\n\nexport type NonNullableUpdater<TPrevious, TResult = TPrevious> =\n | TResult\n | ((prev: TPrevious) => TResult)\n\nexport type ExtractObjects<TUnion> = TUnion extends MergeAllPrimitive\n ? never\n : TUnion\n\nexport type PartialMergeAllObject<TUnion> =\n ExtractObjects<TUnion> extends infer TObj\n ? [TObj] extends [never]\n ? never\n : {\n [TKey in TObj extends any ? keyof TObj : never]?: TObj extends any\n ? TKey extends keyof TObj\n ? TObj[TKey]\n : never\n : never\n }\n : never\n\nexport type MergeAllPrimitive =\n | ReadonlyArray<any>\n | number\n | string\n | bigint\n | boolean\n | symbol\n | undefined\n | null\n\nexport type ExtractPrimitives<TUnion> = TUnion extends MergeAllPrimitive\n ? TUnion\n : TUnion extends object\n ? never\n : TUnion\n\nexport type PartialMergeAll<TUnion> =\n | ExtractPrimitives<TUnion>\n | PartialMergeAllObject<TUnion>\n\nexport type Constrain<T, TConstraint, TDefault = TConstraint> =\n | (T extends TConstraint ? T : never)\n | TDefault\n\nexport type ConstrainLiteral<T, TConstraint, TDefault = TConstraint> =\n | (T & TConstraint)\n | TDefault\n\n/**\n * To be added to router types\n */\nexport type UnionToIntersection<T> = (\n T extends any ? (arg: T) => any : never\n) extends (arg: infer T) => any\n ? T\n : never\n\n/**\n * Merges everything in a union into one object.\n * This mapped type is homomorphic which means it preserves stuff! :)\n */\nexport type MergeAllObjects<\n TUnion,\n TIntersected = UnionToIntersection<ExtractObjects<TUnion>>,\n> = [keyof TIntersected] extends [never]\n ? never\n : {\n [TKey in keyof TIntersected]: TUnion extends any\n ? TUnion[TKey & keyof TUnion]\n : never\n }\n\nexport type MergeAll<TUnion> =\n | MergeAllObjects<TUnion>\n | ExtractPrimitives<TUnion>\n\nexport type ValidateJSON<T> = ((...args: Array<any>) => any) extends T\n ? unknown extends T\n ? never\n : 'Function is not serializable'\n : { [K in keyof T]: ValidateJSON<T[K]> }\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 function last<T>(arr: Array<T>) {\n return arr[arr.length - 1]\n}\n\nfunction isFunction(d: any): d is Function {\n return typeof d === 'function'\n}\n\nexport function functionalUpdate<TPrevious, TResult = TPrevious>(\n updater: Updater<TPrevious, TResult> | NonNullableUpdater<TPrevious, TResult>,\n previous: TPrevious,\n): TResult {\n if (isFunction(updater)) {\n return updater(previous)\n }\n\n return updater\n}\n\nexport function pick<TValue, TKey extends keyof TValue>(\n parent: TValue,\n keys: Array<TKey>,\n): Pick<TValue, TKey> {\n return keys.reduce((obj: any, key: TKey) => {\n obj[key] = parent[key]\n return obj\n }, {} as any)\n}\n\n/**\n * This function returns `prev` if `_next` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between immutable JSON values for example.\n * Do not use this with signals\n */\nexport function replaceEqualDeep<T>(prev: any, _next: T): T {\n if (prev === _next) {\n return prev\n }\n\n const next = _next as any\n\n const array = isPlainArray(prev) && isPlainArray(next)\n\n if (array || (isSimplePlainObject(prev) && isSimplePlainObject(next))) {\n const prevItems = array\n ? prev\n : (Object.keys(prev) as Array<unknown>).concat(\n Object.getOwnPropertySymbols(prev),\n )\n const prevSize = prevItems.length\n const nextItems = array\n ? next\n : (Object.keys(next) as Array<unknown>).concat(\n Object.getOwnPropertySymbols(next),\n )\n const nextSize = nextItems.length\n const copy: any = array ? [] : {}\n\n let equalItems = 0\n\n for (let i = 0; i < nextSize; i++) {\n const key = array ? i : (nextItems[i] as any)\n if (\n ((!array && prevItems.includes(key)) || array) &&\n prev[key] === undefined &&\n next[key] === undefined\n ) {\n copy[key] = undefined\n equalItems++\n } else {\n copy[key] = replaceEqualDeep(prev[key], next[key])\n if (copy[key] === prev[key] && prev[key] !== undefined) {\n equalItems++\n }\n }\n }\n\n return prevSize === nextSize && equalItems === prevSize ? prev : copy\n }\n\n return next\n}\n\n/**\n * A wrapper around `isPlainObject` with additional checks to ensure that it is not\n * only a plain object, but also one that is \"clone-friendly\" (doesn't have any\n * non-enumerable properties).\n */\nfunction isSimplePlainObject(o: any) {\n return (\n // all the checks from isPlainObject are more likely to hit so we perform them first\n isPlainObject(o) &&\n Object.getOwnPropertyNames(o).length === Object.keys(o).length\n )\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any) {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has modified constructor\n const ctor = o.constructor\n if (typeof ctor === 'undefined') {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any) {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function isPlainArray(value: unknown): value is Array<unknown> {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\nfunction getObjectKeys(obj: any, ignoreUndefined: boolean) {\n let keys = Object.keys(obj)\n if (ignoreUndefined) {\n keys = keys.filter((key) => obj[key] !== undefined)\n }\n return keys\n}\n\nexport function deepEqual(\n a: any,\n b: any,\n opts?: { partial?: boolean; ignoreUndefined?: boolean },\n): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n const ignoreUndefined = opts?.ignoreUndefined ?? true\n const aKeys = getObjectKeys(a, ignoreUndefined)\n const bKeys = getObjectKeys(b, ignoreUndefined)\n\n if (!opts?.partial && aKeys.length !== bKeys.length) {\n return false\n }\n\n return bKeys.every((key) => deepEqual(a[key], b[key], opts))\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) {\n return false\n }\n return !a.some((item, index) => !deepEqual(item, b[index], opts))\n }\n\n return false\n}\n\nexport type StringLiteral<T> = T extends string\n ? string extends T\n ? string\n : T\n : never\n\nexport type ThrowOrOptional<T, TThrow extends boolean> = TThrow extends true\n ? T\n : T | undefined\n\nexport type StrictOrFrom<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean = true,\n> = TStrict extends false\n ? {\n from?: never\n strict: TStrict\n }\n : {\n from: ConstrainLiteral<TFrom, RouteIds<TRouter['routeTree']>>\n strict?: TStrict\n }\n\nexport type ThrowConstraint<\n TStrict extends boolean,\n TThrow extends boolean,\n> = TStrict extends false ? (TThrow extends true ? never : TThrow) : TThrow\n\nexport type ControlledPromise<T> = Promise<T> & {\n resolve: (value: T) => void\n reject: (value: any) => void\n status: 'pending' | 'resolved' | 'rejected'\n value?: T\n}\n\nexport function createControlledPromise<T>(onResolve?: (value: T) => void) {\n let resolveLoadPromise!: (value: T) => void\n let rejectLoadPromise!: (value: any) => void\n\n const controlledPromise = new Promise<T>((resolve, reject) => {\n resolveLoadPromise = resolve\n rejectLoadPromise = reject\n }) as ControlledPromise<T>\n\n controlledPromise.status = 'pending'\n\n controlledPromise.resolve = (value: T) => {\n controlledPromise.status = 'resolved'\n controlledPromise.value = value\n resolveLoadPromise(value)\n onResolve?.(value)\n }\n\n controlledPromise.reject = (e) => {\n controlledPromise.status = 'rejected'\n rejectLoadPromise(e)\n }\n\n return controlledPromise\n}\n\n/**\n *\n * @deprecated use `jsesc` instead\n */\nexport function escapeJSON(jsonString: string) {\n return jsonString\n .replace(/\\\\/g, '\\\\\\\\') // Escape backslashes\n .replace(/'/g, \"\\\\'\") // Escape single quotes\n .replace(/\"/g, '\\\\\"') // Escape double quotes\n}\n\nexport function shallow<T>(objA: T, objB: T) {\n if (Object.is(objA, objB)) {\n return true\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false\n }\n\n const keysA = Object.keys(objA)\n if (keysA.length !== Object.keys(objB).length) {\n return false\n }\n\n for (const item of keysA) {\n if (\n !Object.prototype.hasOwnProperty.call(objB, item) ||\n !Object.is(objA[item as keyof T], objB[item as keyof T])\n ) {\n return false\n }\n }\n return true\n}\n"],"names":[],"mappings":"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"}
|
package/dist/cjs/utils.d.cts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { RouteIds } from './routeInfo.cjs';
|
|
2
|
-
import { AnyRouter } from './router.cjs';
|
|
3
|
-
export type Awaitable<T> = T | Promise<T>;
|
|
4
|
-
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
5
|
-
export type IsAny<TValue, TYesResult, TNoResult = TValue> = 1 extends 0 & TValue ? TYesResult : TNoResult;
|
|
6
|
-
export type PickAsRequired<TValue, TKey extends keyof TValue> = Omit<TValue, TKey> & Required<Pick<TValue, TKey>>;
|
|
7
|
-
export type PickRequired<T> = {
|
|
8
|
-
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
|
9
|
-
};
|
|
10
|
-
export type PickOptional<T> = {
|
|
11
|
-
[K in keyof T as undefined extends T[K] ? K : never]: T[K];
|
|
12
|
-
};
|
|
13
|
-
export type WithoutEmpty<T> = T extends any ? ({} extends T ? never : T) : never;
|
|
14
|
-
export type Expand<T> = T extends object ? T extends infer O ? O extends Function ? O : {
|
|
15
|
-
[K in keyof O]: O[K];
|
|
16
|
-
} : never : T;
|
|
17
|
-
export type DeepPartial<T> = T extends object ? {
|
|
18
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
19
|
-
} : T;
|
|
20
|
-
export type MakeDifferenceOptional<TLeft, TRight> = keyof TLeft & keyof TRight extends never ? TRight : Omit<TRight, keyof TLeft & keyof TRight> & {
|
|
21
|
-
[K in keyof TLeft & keyof TRight]?: TRight[K];
|
|
22
|
-
};
|
|
23
|
-
export type IsUnion<T, U extends T = T> = (T extends any ? (U extends T ? false : true) : never) extends false ? false : true;
|
|
24
|
-
export type IsNonEmptyObject<T> = T extends object ? keyof T extends never ? false : true : false;
|
|
25
|
-
export type Assign<TLeft, TRight> = TLeft extends any ? TRight extends any ? IsNonEmptyObject<TLeft> extends false ? TRight : IsNonEmptyObject<TRight> extends false ? TLeft : keyof TLeft & keyof TRight extends never ? TLeft & TRight : Omit<TLeft, keyof TRight> & TRight : never : never;
|
|
26
|
-
export type IntersectAssign<TLeft, TRight> = TLeft extends any ? TRight extends any ? IsNonEmptyObject<TLeft> extends false ? TRight : IsNonEmptyObject<TRight> extends false ? TLeft : TRight & TLeft : never : never;
|
|
27
|
-
export type Timeout = ReturnType<typeof setTimeout>;
|
|
28
|
-
export type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
|
|
29
|
-
export type NonNullableUpdater<TPrevious, TResult = TPrevious> = TResult | ((prev: TPrevious) => TResult);
|
|
30
|
-
export type ExtractObjects<TUnion> = TUnion extends MergeAllPrimitive ? never : TUnion;
|
|
31
|
-
export type PartialMergeAllObject<TUnion> = ExtractObjects<TUnion> extends infer TObj ? [TObj] extends [never] ? never : {
|
|
32
|
-
[TKey in TObj extends any ? keyof TObj : never]?: TObj extends any ? TKey extends keyof TObj ? TObj[TKey] : never : never;
|
|
33
|
-
} : never;
|
|
34
|
-
export type MergeAllPrimitive = ReadonlyArray<any> | number | string | bigint | boolean | symbol | undefined | null;
|
|
35
|
-
export type ExtractPrimitives<TUnion> = TUnion extends MergeAllPrimitive ? TUnion : TUnion extends object ? never : TUnion;
|
|
36
|
-
export type PartialMergeAll<TUnion> = ExtractPrimitives<TUnion> | PartialMergeAllObject<TUnion>;
|
|
37
|
-
export type Constrain<T, TConstraint, TDefault = TConstraint> = (T extends TConstraint ? T : never) | TDefault;
|
|
38
|
-
export type ConstrainLiteral<T, TConstraint, TDefault = TConstraint> = (T & TConstraint) | TDefault;
|
|
39
|
-
/**
|
|
40
|
-
* To be added to router types
|
|
41
|
-
*/
|
|
42
|
-
export type UnionToIntersection<T> = (T extends any ? (arg: T) => any : never) extends (arg: infer T) => any ? T : never;
|
|
43
|
-
/**
|
|
44
|
-
* Merges everything in a union into one object.
|
|
45
|
-
* This mapped type is homomorphic which means it preserves stuff! :)
|
|
46
|
-
*/
|
|
47
|
-
export type MergeAllObjects<TUnion, TIntersected = UnionToIntersection<ExtractObjects<TUnion>>> = [keyof TIntersected] extends [never] ? never : {
|
|
48
|
-
[TKey in keyof TIntersected]: TUnion extends any ? TUnion[TKey & keyof TUnion] : never;
|
|
49
|
-
};
|
|
50
|
-
export type MergeAll<TUnion> = MergeAllObjects<TUnion> | ExtractPrimitives<TUnion>;
|
|
51
|
-
export type ValidateJSON<T> = ((...args: Array<any>) => any) extends T ? unknown extends T ? never : 'Function is not serializable' : {
|
|
52
|
-
[K in keyof T]: ValidateJSON<T[K]>;
|
|
53
|
-
};
|
|
54
|
-
export type LooseReturnType<T> = T extends (...args: Array<any>) => infer TReturn ? TReturn : never;
|
|
55
|
-
export type LooseAsyncReturnType<T> = T extends (...args: Array<any>) => infer TReturn ? TReturn extends Promise<infer TReturn> ? TReturn : TReturn : never;
|
|
56
|
-
export declare function last<T>(arr: Array<T>): T | undefined;
|
|
57
|
-
export declare function functionalUpdate<TPrevious, TResult = TPrevious>(updater: Updater<TPrevious, TResult> | NonNullableUpdater<TPrevious, TResult>, previous: TPrevious): TResult;
|
|
58
|
-
export declare function pick<TValue, TKey extends keyof TValue>(parent: TValue, keys: Array<TKey>): Pick<TValue, TKey>;
|
|
59
|
-
/**
|
|
60
|
-
* This function returns `prev` if `_next` is deeply equal.
|
|
61
|
-
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
62
|
-
* This can be used for structural sharing between immutable JSON values for example.
|
|
63
|
-
* Do not use this with signals
|
|
64
|
-
*/
|
|
65
|
-
export declare function replaceEqualDeep<T>(prev: any, _next: T): T;
|
|
66
|
-
export declare function isPlainObject(o: any): boolean;
|
|
67
|
-
export declare function isPlainArray(value: unknown): value is Array<unknown>;
|
|
68
|
-
export declare function deepEqual(a: any, b: any, opts?: {
|
|
69
|
-
partial?: boolean;
|
|
70
|
-
ignoreUndefined?: boolean;
|
|
71
|
-
}): boolean;
|
|
72
|
-
export type StringLiteral<T> = T extends string ? string extends T ? string : T : never;
|
|
73
|
-
export type ThrowOrOptional<T, TThrow extends boolean> = TThrow extends true ? T : T | undefined;
|
|
74
|
-
export type StrictOrFrom<TRouter extends AnyRouter, TFrom, TStrict extends boolean = true> = TStrict extends false ? {
|
|
75
|
-
from?: never;
|
|
76
|
-
strict: TStrict;
|
|
77
|
-
} : {
|
|
78
|
-
from: ConstrainLiteral<TFrom, RouteIds<TRouter['routeTree']>>;
|
|
79
|
-
strict?: TStrict;
|
|
80
|
-
};
|
|
81
|
-
export type ThrowConstraint<TStrict extends boolean, TThrow extends boolean> = TStrict extends false ? (TThrow extends true ? never : TThrow) : TThrow;
|
|
82
|
-
export type ControlledPromise<T> = Promise<T> & {
|
|
83
|
-
resolve: (value: T) => void;
|
|
84
|
-
reject: (value: any) => void;
|
|
85
|
-
status: 'pending' | 'resolved' | 'rejected';
|
|
86
|
-
value?: T;
|
|
87
|
-
};
|
|
88
|
-
export declare function createControlledPromise<T>(onResolve?: (value: T) => void): ControlledPromise<T>;
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
* @deprecated use `jsesc` instead
|
|
92
|
-
*/
|
|
93
|
-
export declare function escapeJSON(jsonString: string): string;
|
|
94
|
-
export declare function shallow<T>(objA: T, objB: T): boolean;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { SearchSchemaInput } from './route.cjs';
|
|
2
|
-
export interface StandardSchemaValidatorProps<TInput, TOutput> {
|
|
3
|
-
readonly types?: StandardSchemaValidatorTypes<TInput, TOutput> | undefined;
|
|
4
|
-
readonly validate: AnyStandardSchemaValidate;
|
|
5
|
-
}
|
|
6
|
-
export interface StandardSchemaValidator<TInput, TOutput> {
|
|
7
|
-
readonly '~standard': StandardSchemaValidatorProps<TInput, TOutput>;
|
|
8
|
-
}
|
|
9
|
-
export type AnyStandardSchemaValidator = StandardSchemaValidator<any, any>;
|
|
10
|
-
export interface StandardSchemaValidatorTypes<TInput, TOutput> {
|
|
11
|
-
readonly input: TInput;
|
|
12
|
-
readonly output: TOutput;
|
|
13
|
-
}
|
|
14
|
-
export interface AnyStandardSchemaValidateSuccess {
|
|
15
|
-
readonly value: any;
|
|
16
|
-
readonly issues?: undefined;
|
|
17
|
-
}
|
|
18
|
-
export interface AnyStandardSchemaValidateFailure {
|
|
19
|
-
readonly issues: ReadonlyArray<AnyStandardSchemaValidateIssue>;
|
|
20
|
-
}
|
|
21
|
-
export interface AnyStandardSchemaValidateIssue {
|
|
22
|
-
readonly message: string;
|
|
23
|
-
}
|
|
24
|
-
export interface AnyStandardSchemaValidateInput {
|
|
25
|
-
readonly value: any;
|
|
26
|
-
}
|
|
27
|
-
export type AnyStandardSchemaValidate = (value: unknown) => (AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure) | Promise<AnyStandardSchemaValidateSuccess | AnyStandardSchemaValidateFailure>;
|
|
28
|
-
export interface ValidatorObj<TInput, TOutput> {
|
|
29
|
-
parse: ValidatorFn<TInput, TOutput>;
|
|
30
|
-
}
|
|
31
|
-
export type AnyValidatorObj = ValidatorObj<any, any>;
|
|
32
|
-
export interface ValidatorAdapter<TInput, TOutput> {
|
|
33
|
-
types: {
|
|
34
|
-
input: TInput;
|
|
35
|
-
output: TOutput;
|
|
36
|
-
};
|
|
37
|
-
parse: (input: unknown) => TOutput;
|
|
38
|
-
}
|
|
39
|
-
export type AnyValidatorAdapter = ValidatorAdapter<any, any>;
|
|
40
|
-
export type AnyValidatorFn = ValidatorFn<any, any>;
|
|
41
|
-
export type ValidatorFn<TInput, TOutput> = (input: TInput) => TOutput;
|
|
42
|
-
export type Validator<TInput, TOutput> = ValidatorObj<TInput, TOutput> | ValidatorFn<TInput, TOutput> | ValidatorAdapter<TInput, TOutput> | StandardSchemaValidator<TInput, TOutput> | undefined;
|
|
43
|
-
export type AnyValidator = Validator<any, any>;
|
|
44
|
-
export type AnySchema = {};
|
|
45
|
-
export type DefaultValidator = Validator<Record<string, unknown>, AnySchema>;
|
|
46
|
-
export type ResolveSearchValidatorInputFn<TValidator> = TValidator extends (input: infer TSchemaInput) => any ? TSchemaInput extends SearchSchemaInput ? Omit<TSchemaInput, keyof SearchSchemaInput> : ResolveValidatorOutputFn<TValidator> : AnySchema;
|
|
47
|
-
export type ResolveSearchValidatorInput<TValidator> = TValidator extends AnyStandardSchemaValidator ? NonNullable<TValidator['~standard']['types']>['input'] : TValidator extends AnyValidatorAdapter ? TValidator['types']['input'] : TValidator extends AnyValidatorObj ? ResolveSearchValidatorInputFn<TValidator['parse']> : ResolveSearchValidatorInputFn<TValidator>;
|
|
48
|
-
export type ResolveValidatorInputFn<TValidator> = TValidator extends (input: infer TInput) => any ? TInput : undefined;
|
|
49
|
-
export type ResolveValidatorInput<TValidator> = TValidator extends AnyStandardSchemaValidator ? NonNullable<TValidator['~standard']['types']>['input'] : TValidator extends AnyValidatorAdapter ? TValidator['types']['input'] : TValidator extends AnyValidatorObj ? ResolveValidatorInputFn<TValidator['parse']> : ResolveValidatorInputFn<TValidator>;
|
|
50
|
-
export type ResolveValidatorOutputFn<TValidator> = TValidator extends (...args: any) => infer TSchema ? TSchema : AnySchema;
|
|
51
|
-
export type ResolveValidatorOutput<TValidator> = unknown extends TValidator ? TValidator : TValidator extends AnyStandardSchemaValidator ? NonNullable<TValidator['~standard']['types']>['output'] : TValidator extends AnyValidatorAdapter ? TValidator['types']['output'] : TValidator extends AnyValidatorObj ? ResolveValidatorOutputFn<TValidator['parse']> : ResolveValidatorOutputFn<TValidator>;
|
package/dist/esm/Matches.d.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { AnyRoute, StaticDataRouteOption } from './route.js';
|
|
2
|
-
import { AllContext, AllLoaderData, AllParams, FullSearchSchema, ParseRoute, RouteById, RouteIds } from './routeInfo.js';
|
|
3
|
-
import { AnyRouter, RegisteredRouter } from './router.js';
|
|
4
|
-
import { Constrain, ControlledPromise } from './utils.js';
|
|
5
|
-
export type AnyMatchAndValue = {
|
|
6
|
-
match: any;
|
|
7
|
-
value: any;
|
|
8
|
-
};
|
|
9
|
-
export type FindValueByIndex<TKey, TValue extends ReadonlyArray<any>> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never;
|
|
10
|
-
export type FindValueByKey<TKey, TValue> = TValue extends ReadonlyArray<any> ? FindValueByIndex<TKey, TValue> : TValue[TKey & keyof TValue];
|
|
11
|
-
export type CreateMatchAndValue<TMatch, TValue> = TValue extends any ? {
|
|
12
|
-
match: TMatch;
|
|
13
|
-
value: TValue;
|
|
14
|
-
} : never;
|
|
15
|
-
export type NextMatchAndValue<TKey, TMatchAndValue extends AnyMatchAndValue> = TMatchAndValue extends any ? CreateMatchAndValue<TMatchAndValue['match'], FindValueByKey<TKey, TMatchAndValue['value']>> : never;
|
|
16
|
-
export type IsMatchKeyOf<TValue> = TValue extends ReadonlyArray<any> ? number extends TValue['length'] ? `${number}` : keyof TValue & `${number}` : TValue extends object ? keyof TValue & string : never;
|
|
17
|
-
export type IsMatchPath<TParentPath extends string, TMatchAndValue extends AnyMatchAndValue> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`;
|
|
18
|
-
export type IsMatchResult<TKey, TMatchAndValue extends AnyMatchAndValue> = TMatchAndValue extends any ? TKey extends keyof TMatchAndValue['value'] ? TMatchAndValue['match'] : never : never;
|
|
19
|
-
export type IsMatchParse<TPath, TMatchAndValue extends AnyMatchAndValue, TParentPath extends string = ''> = TPath extends `${string}.${string}` ? TPath extends `${infer TFirst}.${infer TRest}` ? IsMatchParse<TRest, NextMatchAndValue<TFirst, TMatchAndValue>, `${TParentPath}${TFirst}.`> : never : {
|
|
20
|
-
path: IsMatchPath<TParentPath, TMatchAndValue>;
|
|
21
|
-
result: IsMatchResult<TPath, TMatchAndValue>;
|
|
22
|
-
};
|
|
23
|
-
export type IsMatch<TMatch, TPath> = IsMatchParse<TPath, TMatch extends any ? {
|
|
24
|
-
match: TMatch;
|
|
25
|
-
value: TMatch;
|
|
26
|
-
} : never>;
|
|
27
|
-
/**
|
|
28
|
-
* Narrows matches based on a path
|
|
29
|
-
* @experimental
|
|
30
|
-
*/
|
|
31
|
-
export declare const isMatch: <TMatch, TPath extends string>(match: TMatch, path: Constrain<TPath, IsMatch<TMatch, TPath>["path"]>) => match is IsMatch<TMatch, TPath>["result"];
|
|
32
|
-
export interface DefaultRouteMatchExtensions {
|
|
33
|
-
scripts?: unknown;
|
|
34
|
-
links?: unknown;
|
|
35
|
-
headScripts?: unknown;
|
|
36
|
-
meta?: unknown;
|
|
37
|
-
}
|
|
38
|
-
export interface RouteMatchExtensions extends DefaultRouteMatchExtensions {
|
|
39
|
-
}
|
|
40
|
-
export interface RouteMatch<out TRouteId, out TFullPath, out TAllParams, out TFullSearchSchema, out TLoaderData, out TAllContext, out TLoaderDeps> extends RouteMatchExtensions {
|
|
41
|
-
id: string;
|
|
42
|
-
routeId: TRouteId;
|
|
43
|
-
fullPath: TFullPath;
|
|
44
|
-
index: number;
|
|
45
|
-
pathname: string;
|
|
46
|
-
params: TAllParams;
|
|
47
|
-
_strictParams: TAllParams;
|
|
48
|
-
status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound';
|
|
49
|
-
isFetching: false | 'beforeLoad' | 'loader';
|
|
50
|
-
error: unknown;
|
|
51
|
-
paramsError: unknown;
|
|
52
|
-
searchError: unknown;
|
|
53
|
-
updatedAt: number;
|
|
54
|
-
loadPromise?: ControlledPromise<void>;
|
|
55
|
-
beforeLoadPromise?: ControlledPromise<void>;
|
|
56
|
-
loaderPromise?: ControlledPromise<void>;
|
|
57
|
-
loaderData?: TLoaderData;
|
|
58
|
-
__routeContext: Record<string, unknown>;
|
|
59
|
-
__beforeLoadContext: Record<string, unknown>;
|
|
60
|
-
context: TAllContext;
|
|
61
|
-
search: TFullSearchSchema;
|
|
62
|
-
_strictSearch: TFullSearchSchema;
|
|
63
|
-
fetchCount: number;
|
|
64
|
-
abortController: AbortController;
|
|
65
|
-
cause: 'preload' | 'enter' | 'stay';
|
|
66
|
-
loaderDeps: TLoaderDeps;
|
|
67
|
-
preload: boolean;
|
|
68
|
-
invalid: boolean;
|
|
69
|
-
headers?: Record<string, string>;
|
|
70
|
-
globalNotFound?: boolean;
|
|
71
|
-
staticData: StaticDataRouteOption;
|
|
72
|
-
minPendingPromise?: ControlledPromise<void>;
|
|
73
|
-
pendingTimeout?: ReturnType<typeof setTimeout>;
|
|
74
|
-
}
|
|
75
|
-
export type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<TRoute['types']['id'], TRoute['types']['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema'], TRoute['types']['loaderData'], TRoute['types']['allContext'], TRoute['types']['loaderDeps']>;
|
|
76
|
-
export type MakeRouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TRouteId = RouteIds<TRouteTree>, TStrict extends boolean = true> = RouteMatch<TRouteId, RouteById<TRouteTree, TRouteId>['types']['fullPath'], TStrict extends false ? AllParams<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['allParams'], TStrict extends false ? FullSearchSchema<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'], TStrict extends false ? AllLoaderData<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['loaderData'], TStrict extends false ? AllContext<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['allContext'], RouteById<TRouteTree, TRouteId>['types']['loaderDeps']>;
|
|
77
|
-
export type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>;
|
|
78
|
-
export type MakeRouteMatchUnion<TRouter extends AnyRouter = RegisteredRouter, TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>> = TRoute extends any ? RouteMatch<TRoute['id'], TRoute['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema'], TRoute['types']['loaderData'], TRoute['types']['allContext'], TRoute['types']['loaderDeps']> : never;
|
|
79
|
-
/**
|
|
80
|
-
* The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.
|
|
81
|
-
*
|
|
82
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)
|
|
83
|
-
*/
|
|
84
|
-
export interface MatchRouteOptions {
|
|
85
|
-
/**
|
|
86
|
-
* If `true`, will match against pending location instead of the current location.
|
|
87
|
-
*
|
|
88
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)
|
|
89
|
-
*/
|
|
90
|
-
pending?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* If `true`, will match against the current location with case sensitivity.
|
|
93
|
-
*
|
|
94
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)
|
|
95
|
-
*/
|
|
96
|
-
caseSensitive?: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.
|
|
99
|
-
*
|
|
100
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)
|
|
101
|
-
*/
|
|
102
|
-
includeSearch?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.
|
|
105
|
-
*
|
|
106
|
-
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)
|
|
107
|
-
*/
|
|
108
|
-
fuzzy?: boolean;
|
|
109
|
-
}
|
package/dist/esm/Matches.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const isMatch = (match, path) => {
|
|
2
|
-
const parts = path.split(".");
|
|
3
|
-
let part;
|
|
4
|
-
let value = match;
|
|
5
|
-
while ((part = parts.shift()) != null && value != null) {
|
|
6
|
-
value = value[part];
|
|
7
|
-
}
|
|
8
|
-
return value != null;
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
isMatch
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=Matches.js.map
|
package/dist/esm/Matches.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.js","sources":["../../src/Matches.ts"],"sourcesContent":["import type { AnyRoute, StaticDataRouteOption } from './route'\nimport type {\n AllContext,\n AllLoaderData,\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteIds,\n} from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { Constrain, ControlledPromise } from './utils'\n\nexport type AnyMatchAndValue = { match: any; value: any }\n\nexport type FindValueByIndex<\n TKey,\n TValue extends ReadonlyArray<any>,\n> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never\n\nexport type FindValueByKey<TKey, TValue> =\n TValue extends ReadonlyArray<any>\n ? FindValueByIndex<TKey, TValue>\n : TValue[TKey & keyof TValue]\n\nexport type CreateMatchAndValue<TMatch, TValue> = TValue extends any\n ? {\n match: TMatch\n value: TValue\n }\n : never\n\nexport type NextMatchAndValue<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? CreateMatchAndValue<\n TMatchAndValue['match'],\n FindValueByKey<TKey, TMatchAndValue['value']>\n >\n : never\n\nexport type IsMatchKeyOf<TValue> =\n TValue extends ReadonlyArray<any>\n ? number extends TValue['length']\n ? `${number}`\n : keyof TValue & `${number}`\n : TValue extends object\n ? keyof TValue & string\n : never\n\nexport type IsMatchPath<\n TParentPath extends string,\n TMatchAndValue extends AnyMatchAndValue,\n> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`\n\nexport type IsMatchResult<\n TKey,\n TMatchAndValue extends AnyMatchAndValue,\n> = TMatchAndValue extends any\n ? TKey extends keyof TMatchAndValue['value']\n ? TMatchAndValue['match']\n : never\n : never\n\nexport type IsMatchParse<\n TPath,\n TMatchAndValue extends AnyMatchAndValue,\n TParentPath extends string = '',\n> = TPath extends `${string}.${string}`\n ? TPath extends `${infer TFirst}.${infer TRest}`\n ? IsMatchParse<\n TRest,\n NextMatchAndValue<TFirst, TMatchAndValue>,\n `${TParentPath}${TFirst}.`\n >\n : never\n : {\n path: IsMatchPath<TParentPath, TMatchAndValue>\n result: IsMatchResult<TPath, TMatchAndValue>\n }\n\nexport type IsMatch<TMatch, TPath> = IsMatchParse<\n TPath,\n TMatch extends any ? { match: TMatch; value: TMatch } : never\n>\n\n/**\n * Narrows matches based on a path\n * @experimental\n */\nexport const isMatch = <TMatch, TPath extends string>(\n match: TMatch,\n path: Constrain<TPath, IsMatch<TMatch, TPath>['path']>,\n): match is IsMatch<TMatch, TPath>['result'] => {\n const parts = (path as string).split('.')\n let part\n let value: any = match\n\n while ((part = parts.shift()) != null && value != null) {\n value = value[part]\n }\n\n return value != null\n}\n\nexport interface DefaultRouteMatchExtensions {\n scripts?: unknown\n links?: unknown\n headScripts?: unknown\n meta?: unknown\n}\n\nexport interface RouteMatchExtensions extends DefaultRouteMatchExtensions {}\n\nexport interface RouteMatch<\n out TRouteId,\n out TFullPath,\n out TAllParams,\n out TFullSearchSchema,\n out TLoaderData,\n out TAllContext,\n out TLoaderDeps,\n> extends RouteMatchExtensions {\n id: string\n routeId: TRouteId\n fullPath: TFullPath\n index: number\n pathname: string\n params: TAllParams\n _strictParams: TAllParams\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: false | 'beforeLoad' | 'loader'\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: ControlledPromise<void>\n beforeLoadPromise?: ControlledPromise<void>\n loaderPromise?: ControlledPromise<void>\n loaderData?: TLoaderData\n __routeContext: Record<string, unknown>\n __beforeLoadContext: Record<string, unknown>\n context: TAllContext\n search: TFullSearchSchema\n _strictSearch: TFullSearchSchema\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: TLoaderDeps\n preload: boolean\n invalid: boolean\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n minPendingPromise?: ControlledPromise<void>\n pendingTimeout?: ReturnType<typeof setTimeout>\n}\n\nexport type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<\n TRoute['types']['id'],\n TRoute['types']['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n>\n\nexport type MakeRouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n> = RouteMatch<\n TRouteId,\n RouteById<TRouteTree, TRouteId>['types']['fullPath'],\n TStrict extends false\n ? AllParams<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allParams'],\n TStrict extends false\n ? FullSearchSchema<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n TStrict extends false\n ? AllLoaderData<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['loaderData'],\n TStrict extends false\n ? AllContext<TRouteTree>\n : RouteById<TRouteTree, TRouteId>['types']['allContext'],\n RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n>\n\nexport type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>\n\nexport type MakeRouteMatchUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,\n> = TRoute extends any\n ? RouteMatch<\n TRoute['id'],\n TRoute['fullPath'],\n TRoute['types']['allParams'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['loaderData'],\n TRoute['types']['allContext'],\n TRoute['types']['loaderDeps']\n >\n : never\n\n/**\n * The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)\n */\nexport interface MatchRouteOptions {\n /**\n * If `true`, will match against pending location instead of the current location.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)\n */\n pending?: boolean\n /**\n * If `true`, will match against the current location with case sensitivity.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)\n */\n caseSensitive?: boolean\n /**\n * If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)\n */\n includeSearch?: boolean\n /**\n * If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)\n */\n fuzzy?: boolean\n}\n"],"names":[],"mappings":"AA2Fa,MAAA,UAAU,CACrB,OACA,SAC8C;AACxC,QAAA,QAAS,KAAgB,MAAM,GAAG;AACpC,MAAA;AACJ,MAAI,QAAa;AAEjB,UAAQ,OAAO,MAAM,MAAY,MAAA,QAAQ,SAAS,MAAM;AACtD,YAAQ,MAAM,IAAI;AAAA,EAAA;AAGpB,SAAO,SAAS;AAClB;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { NavigateOptions, ToOptions } from './link.js';
|
|
2
|
-
import { ParsedLocation } from './location.js';
|
|
3
|
-
import { RoutePaths } from './routeInfo.js';
|
|
4
|
-
import { RegisteredRouter, ViewTransitionOptions } from './router.js';
|
|
5
|
-
export interface MatchLocation {
|
|
6
|
-
to?: string | number | null;
|
|
7
|
-
fuzzy?: boolean;
|
|
8
|
-
caseSensitive?: boolean;
|
|
9
|
-
from?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface CommitLocationOptions {
|
|
12
|
-
replace?: boolean;
|
|
13
|
-
resetScroll?: boolean;
|
|
14
|
-
hashScrollIntoView?: boolean | ScrollIntoViewOptions;
|
|
15
|
-
viewTransition?: boolean | ViewTransitionOptions;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated All navigations use React transitions under the hood now
|
|
18
|
-
**/
|
|
19
|
-
startTransition?: boolean;
|
|
20
|
-
ignoreBlocker?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export type NavigateFn = <TRouter extends RegisteredRouter, TTo extends string | undefined, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(opts: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void> | void;
|
|
23
|
-
export type BuildLocationFn = <TRouter extends RegisteredRouter, TTo extends string | undefined, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(opts: ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
24
|
-
leaveParams?: boolean;
|
|
25
|
-
_includeValidateSearch?: boolean;
|
|
26
|
-
}) => ParsedLocation;
|
package/dist/esm/defer.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defaultSerializeError } from './router.js';
|
|
2
|
-
export declare const TSR_DEFERRED_PROMISE: unique symbol;
|
|
3
|
-
export type DeferredPromiseState<T> = {
|
|
4
|
-
status: 'pending';
|
|
5
|
-
data?: T;
|
|
6
|
-
error?: unknown;
|
|
7
|
-
} | {
|
|
8
|
-
status: 'success';
|
|
9
|
-
data: T;
|
|
10
|
-
} | {
|
|
11
|
-
status: 'error';
|
|
12
|
-
data?: T;
|
|
13
|
-
error: unknown;
|
|
14
|
-
};
|
|
15
|
-
export type DeferredPromise<T> = Promise<T> & {
|
|
16
|
-
[TSR_DEFERRED_PROMISE]: DeferredPromiseState<T>;
|
|
17
|
-
};
|
|
18
|
-
export declare function defer<T>(_promise: Promise<T>, options?: {
|
|
19
|
-
serializeError?: typeof defaultSerializeError;
|
|
20
|
-
}): DeferredPromise<T>;
|
package/dist/esm/defer.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { defaultSerializeError } from "./router.js";
|
|
2
|
-
const TSR_DEFERRED_PROMISE = Symbol.for("TSR_DEFERRED_PROMISE");
|
|
3
|
-
function defer(_promise, options) {
|
|
4
|
-
const promise = _promise;
|
|
5
|
-
if (promise[TSR_DEFERRED_PROMISE]) {
|
|
6
|
-
return promise;
|
|
7
|
-
}
|
|
8
|
-
promise[TSR_DEFERRED_PROMISE] = { status: "pending" };
|
|
9
|
-
promise.then((data) => {
|
|
10
|
-
promise[TSR_DEFERRED_PROMISE].status = "success";
|
|
11
|
-
promise[TSR_DEFERRED_PROMISE].data = data;
|
|
12
|
-
}).catch((error) => {
|
|
13
|
-
promise[TSR_DEFERRED_PROMISE].status = "error";
|
|
14
|
-
promise[TSR_DEFERRED_PROMISE].error = {
|
|
15
|
-
data: ((options == null ? void 0 : options.serializeError) ?? defaultSerializeError)(error),
|
|
16
|
-
__isServerError: true
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
return promise;
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
TSR_DEFERRED_PROMISE,
|
|
23
|
-
defer
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=defer.js.map
|
package/dist/esm/defer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defer.js","sources":["../../src/defer.ts"],"sourcesContent":["import { defaultSerializeError } from './router'\n\nexport const TSR_DEFERRED_PROMISE = Symbol.for('TSR_DEFERRED_PROMISE')\n\nexport type DeferredPromiseState<T> =\n | {\n status: 'pending'\n data?: T\n error?: unknown\n }\n | {\n status: 'success'\n data: T\n }\n | {\n status: 'error'\n data?: T\n error: unknown\n }\n\nexport type DeferredPromise<T> = Promise<T> & {\n [TSR_DEFERRED_PROMISE]: DeferredPromiseState<T>\n}\n\nexport function defer<T>(\n _promise: Promise<T>,\n options?: {\n serializeError?: typeof defaultSerializeError\n },\n) {\n const promise = _promise as DeferredPromise<T>\n // this is already deferred promise\n if ((promise as any)[TSR_DEFERRED_PROMISE]) {\n return promise\n }\n promise[TSR_DEFERRED_PROMISE] = { status: 'pending' }\n\n promise\n .then((data) => {\n promise[TSR_DEFERRED_PROMISE].status = 'success'\n promise[TSR_DEFERRED_PROMISE].data = data\n })\n .catch((error) => {\n promise[TSR_DEFERRED_PROMISE].status = 'error'\n ;(promise[TSR_DEFERRED_PROMISE] as any).error = {\n data: (options?.serializeError ?? defaultSerializeError)(error),\n __isServerError: true,\n }\n })\n\n return promise\n}\n"],"names":[],"mappings":";AAEa,MAAA,uBAAuB,OAAO,IAAI,sBAAsB;AAsBrD,SAAA,MACd,UACA,SAGA;AACA,QAAM,UAAU;AAEX,MAAA,QAAgB,oBAAoB,GAAG;AACnC,WAAA;AAAA,EAAA;AAET,UAAQ,oBAAoB,IAAI,EAAE,QAAQ,UAAU;AAGjD,UAAA,KAAK,CAAC,SAAS;AACN,YAAA,oBAAoB,EAAE,SAAS;AAC/B,YAAA,oBAAoB,EAAE,OAAO;AAAA,EAAA,CACtC,EACA,MAAM,CAAC,UAAU;AACR,YAAA,oBAAoB,EAAE,SAAS;AACrC,YAAQ,oBAAoB,EAAU,QAAQ;AAAA,MAC9C,QAAO,mCAAS,mBAAkB,uBAAuB,KAAK;AAAA,MAC9D,iBAAiB;AAAA,IACnB;AAAA,EAAA,CACD;AAEI,SAAA;AACT;"}
|
package/dist/esm/fileRoute.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AnyContext, AnyPathParams, AnyRoute, FileBaseRouteOptions, ResolveParams, Route, RouteConstraints, UpdatableRouteOptions } from './route.js';
|
|
2
|
-
import { AnyValidator } from './validators.js';
|
|
3
|
-
export interface FileRouteTypes {
|
|
4
|
-
fileRoutesByFullPath: any;
|
|
5
|
-
fullPaths: any;
|
|
6
|
-
to: any;
|
|
7
|
-
fileRoutesByTo: any;
|
|
8
|
-
id: any;
|
|
9
|
-
fileRoutesById: any;
|
|
10
|
-
}
|
|
11
|
-
export type InferFileRouteTypes<TRouteTree extends AnyRoute> = unknown extends TRouteTree['types']['fileRouteTypes'] ? never : TRouteTree['types']['fileRouteTypes'] extends FileRouteTypes ? TRouteTree['types']['fileRouteTypes'] : never;
|
|
12
|
-
export interface FileRoutesByPath {
|
|
13
|
-
}
|
|
14
|
-
export interface FileRouteOptions<TFilePath extends string, TParentRoute extends AnyRoute, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath'], TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined> extends FileBaseRouteOptions<TParentRoute, TId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn>, UpdatableRouteOptions<TParentRoute, TId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, AnyContext, TRouteContextFn, TBeforeLoadFn> {
|
|
15
|
-
}
|
|
16
|
-
export type CreateFileRoute<TFilePath extends string, TParentRoute extends AnyRoute, TId extends RouteConstraints['TId'], TPath extends RouteConstraints['TPath'], TFullPath extends RouteConstraints['TFullPath']> = <TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined>(options?: FileRouteOptions<TFilePath, TParentRoute, TId, TPath, TFullPath, TSearchValidator, TParams, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn>) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, unknown, unknown>;
|
|
17
|
-
export type LazyRouteOptions = Pick<UpdatableRouteOptions<AnyRoute, string, string, AnyPathParams, AnyValidator, {}, AnyContext, AnyContext, AnyContext, AnyContext>, 'component' | 'errorComponent' | 'pendingComponent' | 'notFoundComponent'>;
|
|
18
|
-
export interface LazyRoute<in out TRoute extends AnyRoute> {
|
|
19
|
-
options: {
|
|
20
|
-
id: string;
|
|
21
|
-
} & LazyRouteOptions;
|
|
22
|
-
}
|
|
23
|
-
export type CreateLazyFileRoute<TRoute extends AnyRoute> = (opts: LazyRouteOptions) => LazyRoute<TRoute>;
|