@tanstack/router-core 1.121.0-alpha.1 → 1.121.0-alpha.14
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/RouterProvider.d.cts +2 -2
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +1 -1
- package/dist/cjs/redirect.cjs +7 -0
- package/dist/cjs/redirect.cjs.map +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +16 -6
- package/dist/cjs/router.cjs +172 -188
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +2 -5
- package/dist/cjs/utils.cjs +13 -3
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +1 -0
- package/dist/esm/RouterProvider.d.ts +2 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/link.d.ts +1 -1
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/redirect.js +7 -0
- package/dist/esm/redirect.js.map +1 -1
- package/dist/esm/route.d.ts +16 -6
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +2 -5
- package/dist/esm/router.js +172 -188
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js +13 -3
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/RouterProvider.ts +2 -6
- package/src/index.ts +1 -1
- package/src/link.ts +1 -1
- package/src/redirect.ts +8 -0
- package/src/route.ts +32 -22
- package/src/router.ts +245 -233
- package/src/utils.ts +25 -3
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RouteIds } from './routeInfo'
|
|
2
2
|
import type { AnyRouter } from './router'
|
|
3
3
|
|
|
4
|
+
export type Awaitable<T> = T | Promise<T>
|
|
4
5
|
export type NoInfer<T> = [T][T extends any ? 0 : never]
|
|
5
6
|
export type IsAny<TValue, TYesResult, TNoResult = TValue> = 1 extends 0 & TValue
|
|
6
7
|
? TYesResult
|
|
@@ -227,10 +228,18 @@ export function replaceEqualDeep<T>(prev: any, _next: T): T {
|
|
|
227
228
|
|
|
228
229
|
const array = isPlainArray(prev) && isPlainArray(next)
|
|
229
230
|
|
|
230
|
-
if (array || (
|
|
231
|
-
const prevItems = array
|
|
231
|
+
if (array || (isSimplePlainObject(prev) && isSimplePlainObject(next))) {
|
|
232
|
+
const prevItems = array
|
|
233
|
+
? prev
|
|
234
|
+
: (Object.keys(prev) as Array<unknown>).concat(
|
|
235
|
+
Object.getOwnPropertySymbols(prev),
|
|
236
|
+
)
|
|
232
237
|
const prevSize = prevItems.length
|
|
233
|
-
const nextItems = array
|
|
238
|
+
const nextItems = array
|
|
239
|
+
? next
|
|
240
|
+
: (Object.keys(next) as Array<unknown>).concat(
|
|
241
|
+
Object.getOwnPropertySymbols(next),
|
|
242
|
+
)
|
|
234
243
|
const nextSize = nextItems.length
|
|
235
244
|
const copy: any = array ? [] : {}
|
|
236
245
|
|
|
@@ -259,6 +268,19 @@ export function replaceEqualDeep<T>(prev: any, _next: T): T {
|
|
|
259
268
|
return next
|
|
260
269
|
}
|
|
261
270
|
|
|
271
|
+
/**
|
|
272
|
+
* A wrapper around `isPlainObject` with additional checks to ensure that it is not
|
|
273
|
+
* only a plain object, but also one that is "clone-friendly" (doesn't have any
|
|
274
|
+
* non-enumerable properties).
|
|
275
|
+
*/
|
|
276
|
+
function isSimplePlainObject(o: any) {
|
|
277
|
+
return (
|
|
278
|
+
// all the checks from isPlainObject are more likely to hit so we perform them first
|
|
279
|
+
isPlainObject(o) &&
|
|
280
|
+
Object.getOwnPropertyNames(o).length === Object.keys(o).length
|
|
281
|
+
)
|
|
282
|
+
}
|
|
283
|
+
|
|
262
284
|
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
263
285
|
export function isPlainObject(o: any) {
|
|
264
286
|
if (!hasObjectPrototype(o)) {
|