@tanstack/router-core 0.0.1-beta.52 → 0.0.1-beta.54
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/build/cjs/history.js +1 -2
- package/build/cjs/history.js.map +1 -1
- package/build/cjs/router.js +1 -1
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +2 -3
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +150 -150
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +2 -3
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/history.ts +12 -2
- package/src/router.ts +8 -4
package/package.json
CHANGED
package/src/history.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// This implementation attempts to be more lightweight by
|
|
3
3
|
// making assumptions about the way TanStack Router works
|
|
4
4
|
|
|
5
|
+
import { match } from 'assert'
|
|
6
|
+
|
|
5
7
|
export interface RouterHistory {
|
|
6
8
|
location: RouterLocation
|
|
7
9
|
listen: (cb: () => void) => () => void
|
|
@@ -177,11 +179,19 @@ export function createMemoryHistory(
|
|
|
177
179
|
function parseLocation(href: string, state: any): RouterLocation {
|
|
178
180
|
let hashIndex = href.indexOf('#')
|
|
179
181
|
let searchIndex = href.indexOf('?')
|
|
180
|
-
const pathEnd = Math.min(hashIndex, searchIndex)
|
|
181
182
|
|
|
182
183
|
return {
|
|
183
184
|
href,
|
|
184
|
-
pathname:
|
|
185
|
+
pathname: href.substring(
|
|
186
|
+
0,
|
|
187
|
+
hashIndex > 0
|
|
188
|
+
? searchIndex > 0
|
|
189
|
+
? Math.min(hashIndex, searchIndex)
|
|
190
|
+
: hashIndex
|
|
191
|
+
: searchIndex > 0
|
|
192
|
+
? searchIndex
|
|
193
|
+
: href.length,
|
|
194
|
+
),
|
|
185
195
|
hash: hashIndex > -1 ? href.substring(hashIndex, searchIndex) : '',
|
|
186
196
|
search: searchIndex > -1 ? href.substring(searchIndex) : '',
|
|
187
197
|
state,
|
package/src/router.ts
CHANGED
|
@@ -820,7 +820,12 @@ export class Router<
|
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
822
|
|
|
823
|
-
invalidateRoute = async
|
|
823
|
+
invalidateRoute = async <
|
|
824
|
+
TFrom extends ValidFromPath<TAllRouteInfo> = '/',
|
|
825
|
+
TTo extends string = '.',
|
|
826
|
+
>(
|
|
827
|
+
opts: ToOptions<TAllRouteInfo, TFrom, TTo>,
|
|
828
|
+
) => {
|
|
824
829
|
const next = this.buildNext(opts)
|
|
825
830
|
const unloadedMatchIds = this.matchRoutes(next.pathname).map((d) => d.id)
|
|
826
831
|
|
|
@@ -865,8 +870,7 @@ export class Router<
|
|
|
865
870
|
// If this `to` is a valid external URL, return
|
|
866
871
|
// null for LinkUtils
|
|
867
872
|
const toString = String(to)
|
|
868
|
-
const fromString = String(from)
|
|
869
|
-
|
|
873
|
+
const fromString = typeof from === 'undefined' ? from : String(from)
|
|
870
874
|
let isExternal
|
|
871
875
|
|
|
872
876
|
try {
|
|
@@ -1010,7 +1014,7 @@ export class Router<
|
|
|
1010
1014
|
) {
|
|
1011
1015
|
e.preventDefault()
|
|
1012
1016
|
if (pathIsEqual && !search && !hash) {
|
|
1013
|
-
this.invalidateRoute(nextOpts)
|
|
1017
|
+
this.invalidateRoute(nextOpts as any)
|
|
1014
1018
|
}
|
|
1015
1019
|
|
|
1016
1020
|
// All is well? Navigate!
|