@tanstack/react-router 1.97.20 → 1.97.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.
Files changed (182) hide show
  1. package/dist/cjs/Match.cjs +4 -5
  2. package/dist/cjs/Match.cjs.map +1 -1
  3. package/dist/cjs/Matches.cjs +0 -10
  4. package/dist/cjs/Matches.cjs.map +1 -1
  5. package/dist/cjs/Matches.d.cts +3 -30
  6. package/dist/cjs/RouterProvider.cjs.map +1 -1
  7. package/dist/cjs/RouterProvider.d.cts +2 -2
  8. package/dist/cjs/Transitioner.cjs +2 -2
  9. package/dist/cjs/Transitioner.cjs.map +1 -1
  10. package/dist/cjs/awaited.cjs +6 -6
  11. package/dist/cjs/awaited.cjs.map +1 -1
  12. package/dist/cjs/awaited.d.cts +1 -1
  13. package/dist/cjs/fileRoute.cjs.map +1 -1
  14. package/dist/cjs/fileRoute.d.cts +2 -3
  15. package/dist/cjs/index.cjs +136 -42
  16. package/dist/cjs/index.cjs.map +1 -1
  17. package/dist/cjs/index.d.cts +12 -26
  18. package/dist/cjs/link.cjs +8 -9
  19. package/dist/cjs/link.cjs.map +1 -1
  20. package/dist/cjs/link.d.cts +2 -49
  21. package/dist/cjs/redirects.cjs.map +1 -1
  22. package/dist/cjs/redirects.d.cts +1 -1
  23. package/dist/cjs/route.cjs +14 -15
  24. package/dist/cjs/route.cjs.map +1 -1
  25. package/dist/cjs/route.d.cts +2 -149
  26. package/dist/cjs/routeInfo.d.cts +2 -3
  27. package/dist/cjs/router.cjs +52 -71
  28. package/dist/cjs/router.cjs.map +1 -1
  29. package/dist/cjs/router.d.cts +4 -19
  30. package/dist/cjs/routerContext.d.cts +1 -1
  31. package/dist/cjs/scroll-restoration.cjs +2 -2
  32. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  33. package/dist/cjs/scroll-restoration.d.cts +1 -1
  34. package/dist/cjs/structuralSharing.d.cts +1 -4
  35. package/dist/cjs/typePrimitives.d.cts +1 -1
  36. package/dist/cjs/useLoaderData.cjs.map +1 -1
  37. package/dist/cjs/useLoaderData.d.cts +2 -1
  38. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  39. package/dist/cjs/useLoaderDeps.d.cts +2 -1
  40. package/dist/cjs/useMatch.cjs.map +1 -1
  41. package/dist/cjs/useMatch.d.cts +2 -1
  42. package/dist/cjs/useParams.cjs.map +1 -1
  43. package/dist/cjs/useParams.d.cts +2 -1
  44. package/dist/cjs/useRouteContext.cjs.map +1 -1
  45. package/dist/cjs/useRouteContext.d.cts +2 -1
  46. package/dist/cjs/useRouterState.cjs +2 -2
  47. package/dist/cjs/useRouterState.cjs.map +1 -1
  48. package/dist/cjs/useSearch.cjs.map +1 -1
  49. package/dist/cjs/useSearch.d.cts +2 -1
  50. package/dist/cjs/utils.cjs +0 -152
  51. package/dist/cjs/utils.cjs.map +1 -1
  52. package/dist/cjs/utils.d.cts +1 -81
  53. package/dist/esm/Match.js +1 -2
  54. package/dist/esm/Match.js.map +1 -1
  55. package/dist/esm/Matches.d.ts +3 -30
  56. package/dist/esm/Matches.js +0 -10
  57. package/dist/esm/Matches.js.map +1 -1
  58. package/dist/esm/RouterProvider.d.ts +2 -2
  59. package/dist/esm/RouterProvider.js.map +1 -1
  60. package/dist/esm/Transitioner.js +1 -1
  61. package/dist/esm/Transitioner.js.map +1 -1
  62. package/dist/esm/awaited.d.ts +1 -1
  63. package/dist/esm/awaited.js +1 -1
  64. package/dist/esm/awaited.js.map +1 -1
  65. package/dist/esm/fileRoute.d.ts +2 -3
  66. package/dist/esm/fileRoute.js.map +1 -1
  67. package/dist/esm/index.d.ts +12 -26
  68. package/dist/esm/index.js +5 -10
  69. package/dist/esm/index.js.map +1 -1
  70. package/dist/esm/link.d.ts +2 -49
  71. package/dist/esm/link.js +2 -3
  72. package/dist/esm/link.js.map +1 -1
  73. package/dist/esm/redirects.d.ts +1 -1
  74. package/dist/esm/redirects.js.map +1 -1
  75. package/dist/esm/route.d.ts +2 -149
  76. package/dist/esm/route.js +1 -2
  77. package/dist/esm/route.js.map +1 -1
  78. package/dist/esm/routeInfo.d.ts +2 -3
  79. package/dist/esm/router.d.ts +4 -19
  80. package/dist/esm/router.js +2 -21
  81. package/dist/esm/router.js.map +1 -1
  82. package/dist/esm/routerContext.d.ts +1 -1
  83. package/dist/esm/scroll-restoration.d.ts +1 -1
  84. package/dist/esm/scroll-restoration.js +1 -1
  85. package/dist/esm/scroll-restoration.js.map +1 -1
  86. package/dist/esm/structuralSharing.d.ts +1 -4
  87. package/dist/esm/typePrimitives.d.ts +1 -1
  88. package/dist/esm/useLoaderData.d.ts +2 -1
  89. package/dist/esm/useLoaderData.js.map +1 -1
  90. package/dist/esm/useLoaderDeps.d.ts +2 -1
  91. package/dist/esm/useLoaderDeps.js.map +1 -1
  92. package/dist/esm/useMatch.d.ts +2 -1
  93. package/dist/esm/useMatch.js.map +1 -1
  94. package/dist/esm/useParams.d.ts +2 -1
  95. package/dist/esm/useParams.js.map +1 -1
  96. package/dist/esm/useRouteContext.d.ts +2 -1
  97. package/dist/esm/useRouteContext.js.map +1 -1
  98. package/dist/esm/useRouterState.js +1 -1
  99. package/dist/esm/useRouterState.js.map +1 -1
  100. package/dist/esm/useSearch.d.ts +2 -1
  101. package/dist/esm/useSearch.js.map +1 -1
  102. package/dist/esm/utils.d.ts +1 -81
  103. package/dist/esm/utils.js +0 -152
  104. package/dist/esm/utils.js.map +1 -1
  105. package/package.json +3 -2
  106. package/src/Match.tsx +5 -2
  107. package/src/Matches.tsx +8 -101
  108. package/src/RouterProvider.tsx +4 -2
  109. package/src/Transitioner.tsx +1 -1
  110. package/src/awaited.tsx +2 -2
  111. package/src/fileRoute.ts +6 -3
  112. package/src/index.tsx +128 -128
  113. package/src/link.tsx +27 -155
  114. package/src/redirects.ts +1 -1
  115. package/src/route.ts +41 -315
  116. package/src/routeInfo.ts +7 -3
  117. package/src/router.ts +33 -53
  118. package/src/scroll-restoration.tsx +2 -3
  119. package/src/structuralSharing.ts +5 -7
  120. package/src/typePrimitives.ts +1 -1
  121. package/src/useLoaderData.tsx +2 -1
  122. package/src/useLoaderDeps.tsx +2 -1
  123. package/src/useMatch.tsx +2 -1
  124. package/src/useParams.tsx +2 -1
  125. package/src/useRouteContext.ts +2 -1
  126. package/src/useRouterState.tsx +1 -1
  127. package/src/useSearch.tsx +2 -1
  128. package/src/utils.ts +1 -405
  129. package/dist/cjs/defer.cjs +0 -25
  130. package/dist/cjs/defer.cjs.map +0 -1
  131. package/dist/cjs/defer.d.cts +0 -20
  132. package/dist/cjs/location.d.cts +0 -12
  133. package/dist/cjs/manifest.d.cts +0 -24
  134. package/dist/cjs/path.cjs +0 -289
  135. package/dist/cjs/path.cjs.map +0 -1
  136. package/dist/cjs/path.d.cts +0 -34
  137. package/dist/cjs/qss.cjs +0 -51
  138. package/dist/cjs/qss.cjs.map +0 -1
  139. package/dist/cjs/qss.d.cts +0 -27
  140. package/dist/cjs/root.cjs +0 -5
  141. package/dist/cjs/root.cjs.map +0 -1
  142. package/dist/cjs/root.d.cts +0 -2
  143. package/dist/cjs/searchMiddleware.cjs +0 -42
  144. package/dist/cjs/searchMiddleware.cjs.map +0 -1
  145. package/dist/cjs/searchMiddleware.d.cts +0 -5
  146. package/dist/cjs/searchParams.cjs +0 -61
  147. package/dist/cjs/searchParams.cjs.map +0 -1
  148. package/dist/cjs/searchParams.d.cts +0 -7
  149. package/dist/cjs/serializer.d.cts +0 -15
  150. package/dist/cjs/validators.d.cts +0 -51
  151. package/dist/esm/defer.d.ts +0 -20
  152. package/dist/esm/defer.js +0 -25
  153. package/dist/esm/defer.js.map +0 -1
  154. package/dist/esm/location.d.ts +0 -12
  155. package/dist/esm/manifest.d.ts +0 -24
  156. package/dist/esm/path.d.ts +0 -34
  157. package/dist/esm/path.js +0 -289
  158. package/dist/esm/path.js.map +0 -1
  159. package/dist/esm/qss.d.ts +0 -27
  160. package/dist/esm/qss.js +0 -51
  161. package/dist/esm/qss.js.map +0 -1
  162. package/dist/esm/root.d.ts +0 -2
  163. package/dist/esm/root.js +0 -5
  164. package/dist/esm/root.js.map +0 -1
  165. package/dist/esm/searchMiddleware.d.ts +0 -5
  166. package/dist/esm/searchMiddleware.js +0 -42
  167. package/dist/esm/searchMiddleware.js.map +0 -1
  168. package/dist/esm/searchParams.d.ts +0 -7
  169. package/dist/esm/searchParams.js +0 -61
  170. package/dist/esm/searchParams.js.map +0 -1
  171. package/dist/esm/serializer.d.ts +0 -15
  172. package/dist/esm/validators.d.ts +0 -51
  173. package/src/defer.ts +0 -52
  174. package/src/location.ts +0 -13
  175. package/src/manifest.ts +0 -32
  176. package/src/path.ts +0 -427
  177. package/src/qss.ts +0 -91
  178. package/src/root.ts +0 -2
  179. package/src/searchMiddleware.ts +0 -54
  180. package/src/searchParams.ts +0 -77
  181. package/src/serializer.ts +0 -24
  182. package/src/validators.ts +0 -121
package/src/utils.ts CHANGED
@@ -1,327 +1,7 @@
1
1
  import * as React from 'react'
2
2
  import type { RouteIds } from './routeInfo'
3
3
  import type { AnyRouter } from './router'
4
-
5
- export type NoInfer<T> = [T][T extends any ? 0 : never]
6
- export type IsAny<TValue, TYesResult, TNoResult = TValue> = 1 extends 0 & TValue
7
- ? TYesResult
8
- : TNoResult
9
-
10
- export type PickAsRequired<TValue, TKey extends keyof TValue> = Omit<
11
- TValue,
12
- TKey
13
- > &
14
- Required<Pick<TValue, TKey>>
15
-
16
- export type PickRequired<T> = {
17
- [K in keyof T as undefined extends T[K] ? never : K]: T[K]
18
- }
19
-
20
- export type PickOptional<T> = {
21
- [K in keyof T as undefined extends T[K] ? K : never]: T[K]
22
- }
23
-
24
- // from https://stackoverflow.com/a/76458160
25
- export type WithoutEmpty<T> = T extends any ? ({} extends T ? never : T) : never
26
-
27
- // export type Expand<T> = T
28
- export type Expand<T> = T extends object
29
- ? T extends infer O
30
- ? O extends Function
31
- ? O
32
- : { [K in keyof O]: O[K] }
33
- : never
34
- : T
35
-
36
- export type DeepPartial<T> = T extends object
37
- ? {
38
- [P in keyof T]?: DeepPartial<T[P]>
39
- }
40
- : T
41
-
42
- export type MakeDifferenceOptional<TLeft, TRight> = Omit<
43
- TRight,
44
- keyof TLeft
45
- > & {
46
- [K in keyof TLeft & keyof TRight]?: TRight[K]
47
- }
48
-
49
- // from https://stackoverflow.com/a/53955431
50
- // eslint-disable-next-line @typescript-eslint/naming-convention
51
- export type IsUnion<T, U extends T = T> = (
52
- T extends any ? (U extends T ? false : true) : never
53
- ) extends false
54
- ? false
55
- : true
56
-
57
- export type IsNonEmptyObject<T> = T extends object
58
- ? keyof T extends never
59
- ? false
60
- : true
61
- : false
62
-
63
- export type Assign<TLeft, TRight> = TLeft extends any
64
- ? TRight extends any
65
- ? IsNonEmptyObject<TLeft> extends false
66
- ? TRight
67
- : IsNonEmptyObject<TRight> extends false
68
- ? TLeft
69
- : keyof TLeft & keyof TRight extends never
70
- ? TLeft & TRight
71
- : Omit<TLeft, keyof TRight> & TRight
72
- : never
73
- : never
74
-
75
- export type IntersectAssign<TLeft, TRight> = TLeft extends any
76
- ? TRight extends any
77
- ? IsNonEmptyObject<TLeft> extends false
78
- ? TRight
79
- : IsNonEmptyObject<TRight> extends false
80
- ? TLeft
81
- : TRight & TLeft
82
- : never
83
- : never
84
-
85
- export type Timeout = ReturnType<typeof setTimeout>
86
-
87
- export type Updater<TPrevious, TResult = TPrevious> =
88
- | TResult
89
- | ((prev?: TPrevious) => TResult)
90
-
91
- export type NonNullableUpdater<TPrevious, TResult = TPrevious> =
92
- | TResult
93
- | ((prev: TPrevious) => TResult)
94
-
95
- export type ExtractObjects<TUnion> = TUnion extends MergeAllPrimitive
96
- ? never
97
- : TUnion
98
-
99
- export type PartialMergeAllObject<TUnion> =
100
- ExtractObjects<TUnion> extends infer TObj
101
- ? {
102
- [TKey in TObj extends any ? keyof TObj : never]?: TObj extends any
103
- ? TKey extends keyof TObj
104
- ? TObj[TKey]
105
- : never
106
- : never
107
- }
108
- : never
109
-
110
- export type MergeAllPrimitive =
111
- | ReadonlyArray<any>
112
- | number
113
- | string
114
- | bigint
115
- | boolean
116
- | symbol
117
- | undefined
118
- | null
119
-
120
- export type ExtractPrimitives<TUnion> = TUnion extends MergeAllPrimitive
121
- ? TUnion
122
- : TUnion extends object
123
- ? never
124
- : TUnion
125
-
126
- export type PartialMergeAll<TUnion> =
127
- | ExtractPrimitives<TUnion>
128
- | PartialMergeAllObject<TUnion>
129
-
130
- export type Constrain<T, TConstraint, TDefault = TConstraint> =
131
- | (T extends TConstraint ? T : never)
132
- | TDefault
133
-
134
- export type ConstrainLiteral<T, TConstraint, TDefault = TConstraint> =
135
- | (T & TConstraint)
136
- | TDefault
137
-
138
- /**
139
- * To be added to router types
140
- */
141
- export type UnionToIntersection<T> = (
142
- T extends any ? (arg: T) => any : never
143
- ) extends (arg: infer T) => any
144
- ? T
145
- : never
146
-
147
- /**
148
- * Merges everything in a union into one object.
149
- * This mapped type is homomorphic which means it preserves stuff! :)
150
- */
151
- export type MergeAllObjects<
152
- TUnion,
153
- TIntersected = UnionToIntersection<ExtractObjects<TUnion>>,
154
- > = [keyof TIntersected] extends [never]
155
- ? never
156
- : {
157
- [TKey in keyof TIntersected]: TUnion extends any
158
- ? TUnion[TKey & keyof TUnion]
159
- : never
160
- }
161
-
162
- export type MergeAll<TUnion> =
163
- | MergeAllObjects<TUnion>
164
- | ExtractPrimitives<TUnion>
165
-
166
- export type ValidateJSON<T> = ((...args: Array<any>) => any) extends T
167
- ? unknown extends T
168
- ? never
169
- : 'Function is not serializable'
170
- : { [K in keyof T]: ValidateJSON<T[K]> }
171
-
172
- export function last<T>(arr: Array<T>) {
173
- return arr[arr.length - 1]
174
- }
175
-
176
- function isFunction(d: any): d is Function {
177
- return typeof d === 'function'
178
- }
179
-
180
- export function functionalUpdate<TPrevious, TResult = TPrevious>(
181
- updater: Updater<TPrevious, TResult> | NonNullableUpdater<TPrevious, TResult>,
182
- previous: TPrevious,
183
- ): TResult {
184
- if (isFunction(updater)) {
185
- return updater(previous)
186
- }
187
-
188
- return updater
189
- }
190
-
191
- export function pick<TValue, TKey extends keyof TValue>(
192
- parent: TValue,
193
- keys: Array<TKey>,
194
- ): Pick<TValue, TKey> {
195
- return keys.reduce((obj: any, key: TKey) => {
196
- obj[key] = parent[key]
197
- return obj
198
- }, {} as any)
199
- }
200
-
201
- /**
202
- * This function returns `prev` if `_next` is deeply equal.
203
- * If not, it will replace any deeply equal children of `b` with those of `a`.
204
- * This can be used for structural sharing between immutable JSON values for example.
205
- * Do not use this with signals
206
- */
207
- export function replaceEqualDeep<T>(prev: any, _next: T): T {
208
- if (prev === _next) {
209
- return prev
210
- }
211
-
212
- const next = _next as any
213
-
214
- const array = isPlainArray(prev) && isPlainArray(next)
215
-
216
- if (array || (isPlainObject(prev) && isPlainObject(next))) {
217
- const prevItems = array ? prev : Object.keys(prev)
218
- const prevSize = prevItems.length
219
- const nextItems = array ? next : Object.keys(next)
220
- const nextSize = nextItems.length
221
- const copy: any = array ? [] : {}
222
-
223
- let equalItems = 0
224
-
225
- for (let i = 0; i < nextSize; i++) {
226
- const key = array ? i : (nextItems[i] as any)
227
- if (
228
- ((!array && prevItems.includes(key)) || array) &&
229
- prev[key] === undefined &&
230
- next[key] === undefined
231
- ) {
232
- copy[key] = undefined
233
- equalItems++
234
- } else {
235
- copy[key] = replaceEqualDeep(prev[key], next[key])
236
- if (copy[key] === prev[key] && prev[key] !== undefined) {
237
- equalItems++
238
- }
239
- }
240
- }
241
-
242
- return prevSize === nextSize && equalItems === prevSize ? prev : copy
243
- }
244
-
245
- return next
246
- }
247
-
248
- // Copied from: https://github.com/jonschlinkert/is-plain-object
249
- export function isPlainObject(o: any) {
250
- if (!hasObjectPrototype(o)) {
251
- return false
252
- }
253
-
254
- // If has modified constructor
255
- const ctor = o.constructor
256
- if (typeof ctor === 'undefined') {
257
- return true
258
- }
259
-
260
- // If has modified prototype
261
- const prot = ctor.prototype
262
- if (!hasObjectPrototype(prot)) {
263
- return false
264
- }
265
-
266
- // If constructor does not have an Object-specific method
267
- if (!prot.hasOwnProperty('isPrototypeOf')) {
268
- return false
269
- }
270
-
271
- // Most likely a plain Object
272
- return true
273
- }
274
-
275
- function hasObjectPrototype(o: any) {
276
- return Object.prototype.toString.call(o) === '[object Object]'
277
- }
278
-
279
- export function isPlainArray(value: unknown): value is Array<unknown> {
280
- return Array.isArray(value) && value.length === Object.keys(value).length
281
- }
282
-
283
- function getObjectKeys(obj: any, ignoreUndefined: boolean) {
284
- let keys = Object.keys(obj)
285
- if (ignoreUndefined) {
286
- keys = keys.filter((key) => obj[key] !== undefined)
287
- }
288
- return keys
289
- }
290
-
291
- export function deepEqual(
292
- a: any,
293
- b: any,
294
- opts?: { partial?: boolean; ignoreUndefined?: boolean },
295
- ): boolean {
296
- if (a === b) {
297
- return true
298
- }
299
-
300
- if (typeof a !== typeof b) {
301
- return false
302
- }
303
-
304
- if (isPlainObject(a) && isPlainObject(b)) {
305
- const ignoreUndefined = opts?.ignoreUndefined ?? true
306
- const aKeys = getObjectKeys(a, ignoreUndefined)
307
- const bKeys = getObjectKeys(b, ignoreUndefined)
308
-
309
- if (!opts?.partial && aKeys.length !== bKeys.length) {
310
- return false
311
- }
312
-
313
- return bKeys.every((key) => deepEqual(a[key], b[key], opts))
314
- }
315
-
316
- if (Array.isArray(a) && Array.isArray(b)) {
317
- if (a.length !== b.length) {
318
- return false
319
- }
320
- return !a.some((item, index) => !deepEqual(item, b[index], opts))
321
- }
322
-
323
- return false
324
- }
4
+ import type { ConstrainLiteral } from '@tanstack/router-core'
325
5
 
326
6
  export function useStableCallback<T extends (...args: Array<any>) => any>(
327
7
  fn: T,
@@ -333,42 +13,6 @@ export function useStableCallback<T extends (...args: Array<any>) => any>(
333
13
  return ref.current as T
334
14
  }
335
15
 
336
- export function shallow<T>(objA: T, objB: T) {
337
- if (Object.is(objA, objB)) {
338
- return true
339
- }
340
-
341
- if (
342
- typeof objA !== 'object' ||
343
- objA === null ||
344
- typeof objB !== 'object' ||
345
- objB === null
346
- ) {
347
- return false
348
- }
349
-
350
- const keysA = Object.keys(objA)
351
- if (keysA.length !== Object.keys(objB).length) {
352
- return false
353
- }
354
-
355
- for (const item of keysA) {
356
- if (
357
- !Object.prototype.hasOwnProperty.call(objB, item) ||
358
- !Object.is(objA[item as keyof T], objB[item as keyof T])
359
- ) {
360
- return false
361
- }
362
- }
363
- return true
364
- }
365
-
366
- export type StringLiteral<T> = T extends string
367
- ? string extends T
368
- ? string
369
- : T
370
- : never
371
-
372
16
  export type StrictOrFrom<
373
17
  TRouter extends AnyRouter,
374
18
  TFrom,
@@ -383,57 +27,9 @@ export type StrictOrFrom<
383
27
  strict?: TStrict
384
28
  }
385
29
 
386
- export type ThrowOrOptional<T, TThrow extends boolean> = TThrow extends true
387
- ? T
388
- : T | undefined
389
-
390
30
  export const useLayoutEffect =
391
31
  typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect
392
32
 
393
- /**
394
- *
395
- * @deprecated use `jsesc` instead
396
- */
397
- export function escapeJSON(jsonString: string) {
398
- return jsonString
399
- .replace(/\\/g, '\\\\') // Escape backslashes
400
- .replace(/'/g, "\\'") // Escape single quotes
401
- .replace(/"/g, '\\"') // Escape double quotes
402
- }
403
-
404
- export type ControlledPromise<T> = Promise<T> & {
405
- resolve: (value: T) => void
406
- reject: (value: any) => void
407
- status: 'pending' | 'resolved' | 'rejected'
408
- value?: T
409
- }
410
-
411
- export function createControlledPromise<T>(onResolve?: (value: T) => void) {
412
- let resolveLoadPromise!: (value: T) => void
413
- let rejectLoadPromise!: (value: any) => void
414
-
415
- const controlledPromise = new Promise<T>((resolve, reject) => {
416
- resolveLoadPromise = resolve
417
- rejectLoadPromise = reject
418
- }) as ControlledPromise<T>
419
-
420
- controlledPromise.status = 'pending'
421
-
422
- controlledPromise.resolve = (value: T) => {
423
- controlledPromise.status = 'resolved'
424
- controlledPromise.value = value
425
- resolveLoadPromise(value)
426
- onResolve?.(value)
427
- }
428
-
429
- controlledPromise.reject = (e) => {
430
- controlledPromise.status = 'rejected'
431
- rejectLoadPromise(e)
432
- }
433
-
434
- return controlledPromise
435
- }
436
-
437
33
  /**
438
34
  * Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3
439
35
  */
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const router = require("./router.cjs");
4
- const TSR_DEFERRED_PROMISE = Symbol.for("TSR_DEFERRED_PROMISE");
5
- function defer(_promise, options) {
6
- const promise = _promise;
7
- if (promise[TSR_DEFERRED_PROMISE]) {
8
- return promise;
9
- }
10
- promise[TSR_DEFERRED_PROMISE] = { status: "pending" };
11
- promise.then((data) => {
12
- promise[TSR_DEFERRED_PROMISE].status = "success";
13
- promise[TSR_DEFERRED_PROMISE].data = data;
14
- }).catch((error) => {
15
- promise[TSR_DEFERRED_PROMISE].status = "error";
16
- promise[TSR_DEFERRED_PROMISE].error = {
17
- data: ((options == null ? void 0 : options.serializeError) ?? router.defaultSerializeError)(error),
18
- __isServerError: true
19
- };
20
- });
21
- return promise;
22
- }
23
- exports.TSR_DEFERRED_PROMISE = TSR_DEFERRED_PROMISE;
24
- exports.defer = defer;
25
- //# sourceMappingURL=defer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defer.cjs","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":["defaultSerializeError"],"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,mBAAkBA,OAAAA,uBAAuB,KAAK;AAAA,MAC9D,iBAAiB;AAAA,IACnB;AAAA,EAAA,CACD;AAEI,SAAA;AACT;;;"}
@@ -1,20 +0,0 @@
1
- import { defaultSerializeError } from './router.cjs';
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>;
@@ -1,12 +0,0 @@
1
- import { ParsedHistoryState } from '@tanstack/history';
2
- import { AnySchema } from './validators.cjs';
3
- export interface ParsedLocation<TSearchObj extends AnySchema = {}> {
4
- href: string;
5
- pathname: string;
6
- search: TSearchObj;
7
- searchStr: string;
8
- state: ParsedHistoryState;
9
- hash: string;
10
- maskedLocation?: ParsedLocation<TSearchObj>;
11
- unmaskOnReload?: boolean;
12
- }
@@ -1,24 +0,0 @@
1
- export type Manifest = {
2
- routes: Record<string, {
3
- filePath?: string;
4
- preloads?: Array<string>;
5
- assets?: Array<RouterManagedTag>;
6
- }>;
7
- };
8
- export type RouterManagedTag = {
9
- tag: 'title';
10
- attrs?: Record<string, any>;
11
- children: string;
12
- } | {
13
- tag: 'meta' | 'link';
14
- attrs?: Record<string, any>;
15
- children?: never;
16
- } | {
17
- tag: 'script';
18
- attrs?: Record<string, any>;
19
- children?: string;
20
- } | {
21
- tag: 'style';
22
- attrs?: Record<string, any>;
23
- children?: string;
24
- };