@tanstack/router-core 0.0.1-beta.21 → 0.0.1-beta.23
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/build/cjs/packages/router-core/src/path.js +1 -4
- package/build/cjs/packages/router-core/src/path.js.map +1 -1
- package/build/cjs/packages/router-core/src/routeConfig.js.map +1 -1
- package/build/cjs/packages/router-core/src/router.js +15 -2
- package/build/cjs/packages/router-core/src/router.js.map +1 -1
- package/build/cjs/packages/router-core/src/utils.js +0 -6
- package/build/cjs/packages/router-core/src/utils.js.map +1 -1
- package/build/esm/index.js +16 -12
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +132 -132
- package/build/types/index.d.ts +16 -6
- package/build/umd/index.development.js +16 -12
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/path.ts +0 -4
- package/src/routeConfig.ts +5 -1
- package/src/routeInfo.ts +4 -1
- package/src/router.ts +28 -5
- package/src/utils.ts +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../src/utils.ts"],"sourcesContent":["export type NoInfer<T> = [T][T extends any ? 0 : never]\nexport type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N\nexport type IsAnyBoolean<T> = 1 extends 0 & T ? true : false\nexport type IsKnown<T, Y, N> = unknown extends T ? N : Y\nexport type PickAsRequired<T, K extends keyof T> = Omit<T, K> &\n Required<Pick<T, K>>\nexport type PickAsPartial<T, K extends keyof T> = Omit<T, K> &\n Partial<Pick<T, K>>\nexport type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never\nexport type PickExtra<T, K> = Expand<{\n [TKey in keyof K as string extends TKey\n ? never\n : TKey extends keyof T\n ? never\n : TKey]: K[TKey]\n}>\nexport type PickRequired<T> = {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K]\n}\n\nexport type Expand<T> = T extends object\n ? T extends infer O\n ? { [K in keyof O]: O[K] }\n : never\n : T\n\
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../src/utils.ts"],"sourcesContent":["export type NoInfer<T> = [T][T extends any ? 0 : never]\nexport type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N\nexport type IsAnyBoolean<T> = 1 extends 0 & T ? true : false\nexport type IsKnown<T, Y, N> = unknown extends T ? N : Y\nexport type PickAsRequired<T, K extends keyof T> = Omit<T, K> &\n Required<Pick<T, K>>\nexport type PickAsPartial<T, K extends keyof T> = Omit<T, K> &\n Partial<Pick<T, K>>\nexport type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never\nexport type PickExtra<T, K> = Expand<{\n [TKey in keyof K as string extends TKey\n ? never\n : TKey extends keyof T\n ? never\n : TKey]: K[TKey]\n}>\nexport type PickRequired<T> = {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K]\n}\n\nexport type Expand<T> = T extends object\n ? T extends infer O\n ? { [K in keyof O]: O[K] }\n : never\n : T\n\nexport type UnionToIntersection<U> = (\n U extends any ? (k: U) => void : never\n) extends (k: infer I) => any\n ? I\n : never\n\nexport type Values<O> = O[ValueKeys<O>]\nexport type ValueKeys<O> = Extract<keyof O, PropertyKey>\n\nexport type DeepAwaited<T> = T extends Promise<infer A>\n ? DeepAwaited<A>\n : T extends Record<infer A, Promise<infer B>>\n ? { [K in A]: DeepAwaited<B> }\n : T\n\nexport type PathParamMask<TRoutePath extends string> =\n TRoutePath extends `${infer L}/:${infer C}/${infer R}`\n ? PathParamMask<`${L}/${string}/${R}`>\n : TRoutePath extends `${infer L}/:${infer C}`\n ? PathParamMask<`${L}/${string}`>\n : TRoutePath\n\nexport type Timeout = ReturnType<typeof setTimeout>\n\nexport type Updater<TPrevious, TResult = TPrevious> =\n | TResult\n | ((prev?: TPrevious) => TResult)\n\nexport type PickExtract<T, U> = {\n [K in keyof T as T[K] extends U ? K : never]: T[K]\n}\n\nexport type PickExclude<T, U> = {\n [K in keyof T as T[K] extends U ? never : K]: T[K]\n}\n\n/**\n * This function returns `a` if `b` 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 JSON values for example.\n */\nexport function replaceEqualDeep(prev: any, next: any) {\n if (prev === next) {\n return prev\n }\n\n const array = Array.isArray(prev) && Array.isArray(next)\n\n if (array || (isPlainObject(prev) && isPlainObject(next))) {\n const aSize = array ? prev.length : Object.keys(prev).length\n const bItems = array ? next : Object.keys(next)\n const bSize = bItems.length\n const copy: any = array ? [] : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key = array ? i : bItems[i]\n copy[key] = replaceEqualDeep(prev[key], next[key])\n if (copy[key] === prev[key]) {\n equalItems++\n }\n }\n\n return aSize === bSize && equalItems === aSize ? prev : copy\n }\n\n return next\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nfunction 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 last<T>(arr: T[]) {\n return arr[arr.length - 1]\n}\n\nexport function warning(cond: any, message: string): cond is true {\n if (cond) {\n if (typeof console !== 'undefined') console.warn(message)\n\n try {\n throw new Error(message)\n } catch {}\n }\n\n return true\n}\n\nfunction isFunction(d: any): d is Function {\n return typeof d === 'function'\n}\n\nexport function functionalUpdate<TResult>(\n updater: Updater<TResult>,\n previous: TResult,\n) {\n if (isFunction(updater)) {\n return updater(previous as TResult)\n }\n\n return updater\n}\n\nexport function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K> {\n return keys.reduce((obj: any, key: K) => {\n obj[key] = parent[key]\n return obj\n }, {} as any)\n}\n"],"names":["replaceEqualDeep","prev","next","array","Array","isArray","isPlainObject","aSize","length","Object","keys","bItems","bSize","copy","equalItems","i","key","o","hasObjectPrototype","ctor","constructor","prot","prototype","hasOwnProperty","toString","call","last","arr","warning","cond","message","console","warn","Error","isFunction","d","functionalUpdate","updater","previous","pick","parent","reduce","obj"],"mappings":";;;;;;;;;;;;;;AA8DA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA0BC,IAA1B,EAAqCC,IAArC,EAAgD;EACrD,IAAID,IAAI,KAAKC,IAAb,EAAmB;AACjB,IAAA,OAAOD,IAAP,CAAA;AACD,GAAA;;AAED,EAAA,MAAME,KAAK,GAAGC,KAAK,CAACC,OAAN,CAAcJ,IAAd,CAAA,IAAuBG,KAAK,CAACC,OAAN,CAAcH,IAAd,CAArC,CAAA;;EAEA,IAAIC,KAAK,IAAKG,aAAa,CAACL,IAAD,CAAb,IAAuBK,aAAa,CAACJ,IAAD,CAAlD,EAA2D;AACzD,IAAA,MAAMK,KAAK,GAAGJ,KAAK,GAAGF,IAAI,CAACO,MAAR,GAAiBC,MAAM,CAACC,IAAP,CAAYT,IAAZ,EAAkBO,MAAtD,CAAA;IACA,MAAMG,MAAM,GAAGR,KAAK,GAAGD,IAAH,GAAUO,MAAM,CAACC,IAAP,CAAYR,IAAZ,CAA9B,CAAA;AACA,IAAA,MAAMU,KAAK,GAAGD,MAAM,CAACH,MAArB,CAAA;AACA,IAAA,MAAMK,IAAS,GAAGV,KAAK,GAAG,EAAH,GAAQ,EAA/B,CAAA;IAEA,IAAIW,UAAU,GAAG,CAAjB,CAAA;;IAEA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,KAApB,EAA2BG,CAAC,EAA5B,EAAgC;MAC9B,MAAMC,GAAG,GAAGb,KAAK,GAAGY,CAAH,GAAOJ,MAAM,CAACI,C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GAAjB,EAA2B;AAChC,EAAA,OAAOA,GAAG,CAACA,GAAG,CAACnB,MAAJ,GAAa,CAAd,CAAV,CAAA;AACD,CAAA;AAEM,SAASoB,OAAT,CAAiBC,IAAjB,EAA4BC,OAA5B,EAA2D;AAChE,EAAA,IAAID,IAAJ,EAAU;IACR,IAAI,OAAOE,OAAP,KAAmB,WAAvB,EAAoCA,OAAO,CAACC,IAAR,CAAaF,OAAb,CAAA,CAAA;;IAEpC,IAAI;AACF,MAAA,MAAM,IAAIG,KAAJ,CAAUH,OAAV,CAAN,CAAA;KADF,CAEE,gBAAM,EAAE;AACX,GAAA;;AAED,EAAA,OAAO,IAAP,CAAA;AACD,CAAA;;AAED,SAASI,UAAT,CAAoBC,CAApB,EAA2C;EACzC,OAAO,OAAOA,CAAP,KAAa,UAApB,CAAA;AACD,CAAA;;AAEM,SAASC,gBAAT,CACLC,OADK,EAELC,QAFK,EAGL;AACA,EAAA,IAAIJ,UAAU,CAACG,OAAD,CAAd,EAAyB;IACvB,OAAOA,OAAO,CAACC,QAAD,CAAd,CAAA;AACD,GAAA;;AAED,EAAA,OAAOD,OAAP,CAAA;AACD,CAAA;AAEM,SAASE,IAAT,CAAoCC,MAApC,EAA+C9B,IAA/C,EAAsE;EAC3E,OAAOA,IAAI,CAAC+B,MAAL,CAAY,CAACC,GAAD,EAAW1B,GAAX,KAAsB;AACvC0B,IAAAA,GAAG,CAAC1B,GAAD,CAAH,GAAWwB,MAAM,CAACxB,GAAD,CAAjB,CAAA;AACA,IAAA,OAAO0B,GAAP,CAAA;GAFK,EAGJ,EAHI,CAAP,CAAA;AAID;;;;;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -832,12 +832,6 @@ function invariant(condition, message) {
|
|
|
832
832
|
throw new Error(value);
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
-
// type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
836
|
-
// k: infer I,
|
|
837
|
-
// ) => any
|
|
838
|
-
// ? I
|
|
839
|
-
// : never
|
|
840
|
-
|
|
841
835
|
/**
|
|
842
836
|
* This function returns `a` if `b` is deeply equal.
|
|
843
837
|
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
@@ -1059,10 +1053,7 @@ function matchPathname(currentPathname, matchLocation) {
|
|
|
1059
1053
|
|
|
1060
1054
|
if (matchLocation.to && !pathParams) {
|
|
1061
1055
|
return;
|
|
1062
|
-
}
|
|
1063
|
-
// return
|
|
1064
|
-
// }
|
|
1065
|
-
|
|
1056
|
+
}
|
|
1066
1057
|
|
|
1067
1058
|
return pathParams != null ? pathParams : {};
|
|
1068
1059
|
}
|
|
@@ -1672,6 +1663,7 @@ function createRouter(userOptions) {
|
|
|
1672
1663
|
options: originalOptions,
|
|
1673
1664
|
listeners: [],
|
|
1674
1665
|
// Resolved after construction
|
|
1666
|
+
context: {},
|
|
1675
1667
|
basepath: '',
|
|
1676
1668
|
routeTree: undefined,
|
|
1677
1669
|
routesById: {},
|
|
@@ -1816,7 +1808,19 @@ function createRouter(userOptions) {
|
|
|
1816
1808
|
|
|
1817
1809
|
const matches = router.matchRoutes(router.location.pathname, {
|
|
1818
1810
|
strictParseParams: true
|
|
1819
|
-
});
|
|
1811
|
+
}); // Check if each match middleware to see if the route can be accessed
|
|
1812
|
+
|
|
1813
|
+
try {
|
|
1814
|
+
await Promise.all(matches.map(match => match.options.beforeLoad == null ? void 0 : match.options.beforeLoad({
|
|
1815
|
+
context: router.context
|
|
1816
|
+
})));
|
|
1817
|
+
} catch (err) {
|
|
1818
|
+
if (err != null && err.then) {
|
|
1819
|
+
await new Promise(() => {});
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
throw err;
|
|
1823
|
+
}
|
|
1820
1824
|
|
|
1821
1825
|
if (typeof document !== 'undefined') {
|
|
1822
1826
|
router.state = _extends({}, router.state, {
|
|
@@ -1886,7 +1890,7 @@ function createRouter(userOptions) {
|
|
|
1886
1890
|
});
|
|
1887
1891
|
});
|
|
1888
1892
|
entering.forEach(d => {
|
|
1889
|
-
d.__.onExit = d.options.
|
|
1893
|
+
d.__.onExit = d.options.onLoaded == null ? void 0 : d.options.onLoaded({
|
|
1890
1894
|
params: d.params,
|
|
1891
1895
|
search: d.search
|
|
1892
1896
|
});
|