@tanstack/router-core 0.0.1-beta.188 → 0.0.1-beta.189

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.188",
4
+ "version": "0.0.1-beta.189",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
package/src/history.ts CHANGED
@@ -15,7 +15,7 @@ export interface RouterHistory {
15
15
  }
16
16
 
17
17
  export interface HistoryLocation extends ParsedPath {
18
- state: LocationState
18
+ state: HistoryState
19
19
  }
20
20
 
21
21
  export interface ParsedPath {
@@ -25,7 +25,7 @@ export interface ParsedPath {
25
25
  hash: string
26
26
  }
27
27
 
28
- export interface LocationState {
28
+ export interface HistoryState {
29
29
  key: string
30
30
  __tempLocation?: HistoryLocation
31
31
  __tempKey?: string
@@ -161,7 +161,7 @@ function createHistory(opts: {
161
161
  }
162
162
  }
163
163
 
164
- function assignKey(state: LocationState) {
164
+ function assignKey(state: HistoryState) {
165
165
  state.key = createRandomKey()
166
166
  // if (state.__actualLocation) {
167
167
  // state.__actualLocation.state = {
@@ -242,7 +242,7 @@ export function createMemoryHistory(
242
242
  let index = opts.initialIndex ?? entries.length - 1
243
243
  let currentState = {
244
244
  key: createRandomKey(),
245
- } as LocationState
245
+ } as HistoryState
246
246
 
247
247
  const getLocation = () => parseLocation(entries[index]!, currentState)
248
248
 
@@ -269,7 +269,7 @@ export function createMemoryHistory(
269
269
  })
270
270
  }
271
271
 
272
- function parseLocation(href: string, state: LocationState): HistoryLocation {
272
+ function parseLocation(href: string, state: HistoryState): HistoryLocation {
273
273
  let hashIndex = href.indexOf('#')
274
274
  let searchIndex = href.indexOf('?')
275
275
 
package/src/link.ts CHANGED
@@ -1,19 +1,11 @@
1
1
  import { Trim } from './fileRoute'
2
- import { LocationState } from './history'
3
2
  import { AnyRoute } from './route'
4
- import {
5
- AllParams,
6
- FullSearchSchema,
7
- RouteByPath,
8
- RouteIds,
9
- RoutePaths,
10
- } from './routeInfo'
11
- import { ParsedLocation } from './router'
3
+ import { AllParams, RouteByPath, RouteIds, RoutePaths } from './routeInfo'
4
+ import { LocationState, ParsedLocation } from './router'
12
5
  import {
13
6
  Expand,
14
7
  NoInfer,
15
8
  NonNullableUpdater,
16
- PickAsRequired,
17
9
  PickRequired,
18
10
  UnionToIntersection,
19
11
  Updater,
package/src/route.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  import invariant from 'tiny-invariant'
2
- import { RouteById, RoutePaths } from './routeInfo'
2
+ import { RoutePaths } from './routeInfo'
3
3
  import { joinPaths, trimPath } from './path'
4
- import {
5
- AnyRouter,
6
- RouteMatch,
7
- AnyRouteMatch,
8
- RegisteredRouter,
9
- } from './router'
4
+ import { AnyRouter, RouteMatch, AnyRouteMatch } from './router'
10
5
  import {
11
6
  Expand,
12
7
  IsAny,
@@ -14,12 +9,7 @@ import {
14
9
  PickRequired,
15
10
  UnionToIntersection,
16
11
  } from './utils'
17
- import {
18
- ParsePathParams,
19
- ResolveRelativePath,
20
- ToMaskOptions,
21
- ToSubOptions,
22
- } from './link'
12
+ import { ParsePathParams, ToSubOptions } from './link'
23
13
 
24
14
  export const rootRouteId = '__root__' as const
25
15
  export type RootRouteId = typeof rootRouteId
@@ -53,6 +43,7 @@ export interface RegisterPendingRouteComponent<
53
43
  > {
54
44
  // PendingRouteComponent: unknown // This is registered by the framework
55
45
  }
46
+
56
47
  export interface RegisterRouteProps<
57
48
  TLoader = unknown,
58
49
  TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
package/src/router.ts CHANGED
@@ -57,7 +57,7 @@ import {
57
57
  createBrowserHistory,
58
58
  createMemoryHistory,
59
59
  HistoryLocation,
60
- LocationState,
60
+ HistoryState,
61
61
  RouterHistory,
62
62
  } from './history'
63
63
 
@@ -73,6 +73,8 @@ export interface Register {
73
73
  // router: Router
74
74
  }
75
75
 
76
+ export interface LocationState {}
77
+
76
78
  export type AnyRouter = Router<any, any>
77
79
 
78
80
  export type RegisteredRouter = Register extends {
@@ -86,7 +88,7 @@ export interface ParsedLocation<TSearchObj extends AnySearchSchema = {}> {
86
88
  pathname: string
87
89
  search: TSearchObj
88
90
  searchStr: string
89
- state: LocationState
91
+ state: HistoryState
90
92
  hash: string
91
93
  maskedLocation?: ParsedLocation<TSearchObj>
92
94
  unmaskOnReload?: boolean
@@ -184,10 +186,6 @@ export interface RouterOptions<
184
186
  basepath?: string
185
187
  createRoute?: (opts: { route: AnyRoute; router: AnyRouter }) => void
186
188
  context?: TRouteTree['types']['routerContext']
187
- Wrap?: React.ComponentType<{
188
- children: React.ReactNode
189
- dehydratedState?: TDehydrated
190
- }>
191
189
  dehydrate?: () => TDehydrated
192
190
  hydrate?: (dehydrated: TDehydrated) => void
193
191
  routeMasks?: RouteMask<TRouteTree>[]
@@ -1176,11 +1174,7 @@ export class Router<
1176
1174
  >({
1177
1175
  from,
1178
1176
  to = '' as any,
1179
- search,
1180
- hash,
1181
- replace,
1182
- params,
1183
- resetScroll,
1177
+ ...rest
1184
1178
  }: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>) => {
1185
1179
  // If this link simply reloads the current route,
1186
1180
  // make sure it has a new key so it will trigger a data refresh
@@ -1202,13 +1196,9 @@ export class Router<
1202
1196
  )
1203
1197
 
1204
1198
  return this.#buildAndCommitLocation({
1199
+ ...rest,
1205
1200
  from: fromString,
1206
1201
  to: toString,
1207
- search,
1208
- hash,
1209
- params,
1210
- replace,
1211
- resetScroll,
1212
1202
  })
1213
1203
  }
1214
1204
 
@@ -1260,51 +1250,39 @@ export class Router<
1260
1250
  buildLink = <
1261
1251
  TFrom extends RoutePaths<TRouteTree> = '/',
1262
1252
  TTo extends string = '',
1263
- >({
1264
- from,
1265
- to = '.' as any,
1266
- search,
1267
- params,
1268
- hash,
1269
- target,
1270
- replace,
1271
- activeOptions,
1272
- preload,
1273
- preloadDelay: userPreloadDelay,
1274
- disabled,
1275
- state,
1276
- mask,
1277
- resetScroll,
1278
- }: LinkOptions<TRouteTree, TFrom, TTo>): LinkInfo => {
1253
+ >(
1254
+ dest: LinkOptions<TRouteTree, TFrom, TTo>,
1255
+ ): LinkInfo => {
1279
1256
  // If this link simply reloads the current route,
1280
1257
  // make sure it has a new key so it will trigger a data refresh
1281
1258
 
1282
1259
  // If this `to` is a valid external URL, return
1283
1260
  // null for LinkUtils
1284
1261
 
1262
+ const {
1263
+ to,
1264
+ preload: userPreload,
1265
+ preloadDelay: userPreloadDelay,
1266
+ activeOptions,
1267
+ disabled,
1268
+ target,
1269
+ replace,
1270
+ resetScroll,
1271
+ } = dest
1272
+
1285
1273
  try {
1286
1274
  new URL(`${to}`)
1287
1275
  return {
1288
1276
  type: 'external',
1289
- href: to,
1277
+ href: to as any,
1290
1278
  }
1291
1279
  } catch (e) {}
1292
1280
 
1293
- const nextOpts = {
1294
- from,
1295
- to,
1296
- search,
1297
- params,
1298
- hash,
1299
- replace,
1300
- state,
1301
- mask,
1302
- resetScroll,
1303
- }
1281
+ const nextOpts = dest
1304
1282
 
1305
1283
  const next = this.buildLocation(nextOpts)
1306
1284
 
1307
- preload = preload ?? this.options.defaultPreload
1285
+ const preload = userPreload ?? this.options.defaultPreload
1308
1286
  const preloadDelay =
1309
1287
  userPreloadDelay ?? this.options.defaultPreloadDelay ?? 0
1310
1288
 
@@ -1635,10 +1613,7 @@ export class Router<
1635
1613
  search: replaceEqualDeep(previousLocation?.search, parsedSearch) as any,
1636
1614
  hash: hash.split('#').reverse()[0] ?? '',
1637
1615
  href: `${pathname}${search}${hash}`,
1638
- state: replaceEqualDeep(
1639
- previousLocation?.state,
1640
- state,
1641
- ) as LocationState,
1616
+ state: replaceEqualDeep(previousLocation?.state, state) as HistoryState,
1642
1617
  }
1643
1618
  }
1644
1619
 
@@ -1763,7 +1738,7 @@ export class Router<
1763
1738
  pathname,
1764
1739
  search,
1765
1740
  searchStr,
1766
- state: nextState,
1741
+ state: nextState as any,
1767
1742
  hash,
1768
1743
  href: this.history.createHref(`${pathname}${searchStr}${hashStr}`),
1769
1744
  unmaskOnReload: dest.unmaskOnReload,