@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/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 || (isPlainObject(prev) && isPlainObject(next))) {
231
- const prevItems = array ? prev : Object.keys(prev)
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 ? next : Object.keys(next)
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)) {