@tanstack/router-core 0.0.1-beta.3 → 0.0.1-beta.5

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.3",
4
+ "version": "0.0.1-beta.5",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
package/src/qss.ts CHANGED
@@ -30,6 +30,7 @@ function toValue(mix) {
30
30
  var str = decodeURIComponent(mix)
31
31
  if (str === 'false') return false
32
32
  if (str === 'true') return true
33
+ if (str.charAt(0) === '0') return str
33
34
  return +str * 0 === 0 ? +str : str
34
35
  }
35
36
 
package/src/router.ts CHANGED
@@ -172,7 +172,6 @@ export interface RouterState {
172
172
  location: Location
173
173
  matches: RouteMatch[]
174
174
  lastUpdated: number
175
- loaderData: unknown
176
175
  currentAction?: ActionState
177
176
  latestAction?: ActionState
178
177
  actions: Record<string, Action>
@@ -366,7 +365,6 @@ export function createRouter<
366
365
  matches: [],
367
366
  actions: {},
368
367
  loaders: {},
369
- loaderData: {} as any,
370
368
  lastUpdated: Date.now(),
371
369
  isFetching: false,
372
370
  isPreloading: false,
@@ -409,11 +407,12 @@ export function createRouter<
409
407
  // to the current location. Otherwise, load the current location.
410
408
  if (next.href !== router.location.href) {
411
409
  router.__.commitLocation(next, true)
412
- } else {
413
- router.loadLocation()
414
410
  }
415
411
 
416
- const unsub = history.listen((event) => {
412
+ router.loadLocation()
413
+
414
+ const unsub = router.history.listen((event) => {
415
+ console.log(event.location)
417
416
  router.loadLocation(
418
417
  router.__.parseLocation(event.location, router.location),
419
418
  )
@@ -440,6 +439,15 @@ export function createRouter<
440
439
  },
441
440
 
442
441
  update: (opts) => {
442
+ const newHistory = opts?.history !== router.history
443
+ if (!router.location || newHistory) {
444
+ if (opts?.history) {
445
+ router.history = opts.history
446
+ }
447
+ router.location = router.__.parseLocation(router.history.location)
448
+ router.state.location = router.location
449
+ }
450
+
443
451
  Object.assign(router.options, opts)
444
452
 
445
453
  const { basepath, routeConfig } = router.options
@@ -487,7 +495,7 @@ export function createRouter<
487
495
  router.cancelMatches()
488
496
 
489
497
  // Match the routes
490
- const matches = router.matchRoutes(location.pathname, {
498
+ const matches = router.matchRoutes(router.location.pathname, {
491
499
  strictParseParams: true,
492
500
  })
493
501
 
@@ -1211,9 +1219,6 @@ export function createRouter<
1211
1219
  },
1212
1220
  }
1213
1221
 
1214
- router.location = router.__.parseLocation(history.location)
1215
- router.state.location = router.location
1216
-
1217
1222
  router.update(userOptions)
1218
1223
 
1219
1224
  // Allow frameworks to hook into the router creation