@tanstack/router-core 1.141.1 → 1.141.4
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/dist/cjs/location.d.cts +3 -3
- package/dist/cjs/router.cjs +25 -23
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -0
- package/dist/cjs/ssr/client.d.cts +1 -0
- package/dist/cjs/ssr/ssr-client.cjs +0 -2
- package/dist/cjs/ssr/ssr-client.cjs.map +1 -1
- package/dist/cjs/ssr/ssr-client.d.cts +2 -30
- package/dist/cjs/ssr/ssr-server.cjs +3 -3
- package/dist/cjs/ssr/ssr-server.cjs.map +1 -1
- package/dist/cjs/ssr/ssr-server.d.cts +1 -1
- package/dist/cjs/ssr/tsrScript.cjs +1 -1
- package/dist/cjs/ssr/tsrScript.cjs.map +1 -1
- package/dist/cjs/ssr/types.d.cts +29 -0
- package/dist/esm/location.d.ts +3 -3
- package/dist/esm/router.d.ts +1 -0
- package/dist/esm/router.js +25 -23
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/ssr/client.d.ts +1 -0
- package/dist/esm/ssr/ssr-client.d.ts +2 -30
- package/dist/esm/ssr/ssr-client.js +0 -2
- package/dist/esm/ssr/ssr-client.js.map +1 -1
- package/dist/esm/ssr/ssr-server.d.ts +1 -1
- package/dist/esm/ssr/ssr-server.js +3 -3
- package/dist/esm/ssr/ssr-server.js.map +1 -1
- package/dist/esm/ssr/tsrScript.js +1 -1
- package/dist/esm/ssr/tsrScript.js.map +1 -1
- package/dist/esm/ssr/types.d.ts +29 -0
- package/package.json +1 -1
- package/src/location.ts +3 -3
- package/src/router.ts +27 -29
- package/src/ssr/client.ts +1 -0
- package/src/ssr/ssr-client.ts +3 -44
- package/src/ssr/ssr-server.ts +4 -5
- package/src/ssr/tsrScript.ts +9 -19
- package/src/ssr/types.ts +40 -0
package/dist/cjs/location.d.cts
CHANGED
|
@@ -37,14 +37,14 @@ export interface ParsedLocation<TSearchObj extends AnySchema = {}> {
|
|
|
37
37
|
unmaskOnReload?: boolean;
|
|
38
38
|
/**
|
|
39
39
|
* @private
|
|
40
|
-
* @description The public href of the location
|
|
40
|
+
* @description The public href of the location.
|
|
41
41
|
* If a rewrite is applied, the `href` property will be the rewritten URL.
|
|
42
42
|
*/
|
|
43
43
|
publicHref: string;
|
|
44
44
|
/**
|
|
45
45
|
* @private
|
|
46
|
-
* @description The full URL of the location
|
|
46
|
+
* @description The full URL of the location.
|
|
47
47
|
* @private
|
|
48
48
|
*/
|
|
49
|
-
url:
|
|
49
|
+
url: URL;
|
|
50
50
|
}
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -208,15 +208,14 @@ class RouterCore {
|
|
|
208
208
|
const searchStr = this.options.stringifySearch(parsedSearch);
|
|
209
209
|
url.search = searchStr;
|
|
210
210
|
const fullPath = url.href.replace(url.origin, "");
|
|
211
|
-
const { pathname, hash } = url;
|
|
212
211
|
return {
|
|
213
212
|
href: fullPath,
|
|
214
213
|
publicHref: href,
|
|
215
|
-
url
|
|
216
|
-
pathname: utils.decodePath(pathname),
|
|
214
|
+
url,
|
|
215
|
+
pathname: utils.decodePath(url.pathname),
|
|
217
216
|
searchStr,
|
|
218
217
|
search: utils.replaceEqualDeep(previousLocation?.search, parsedSearch),
|
|
219
|
-
hash: hash.split("#").reverse()[0] ?? "",
|
|
218
|
+
hash: url.hash.split("#").reverse()[0] ?? "",
|
|
220
219
|
state: utils.replaceEqualDeep(previousLocation?.state, state)
|
|
221
220
|
};
|
|
222
221
|
};
|
|
@@ -377,7 +376,7 @@ class RouterCore {
|
|
|
377
376
|
return {
|
|
378
377
|
publicHref: rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash,
|
|
379
378
|
href: fullPath,
|
|
380
|
-
url: rewrittenUrl
|
|
379
|
+
url: rewrittenUrl,
|
|
381
380
|
pathname: nextPathname,
|
|
382
381
|
search: nextSearch,
|
|
383
382
|
searchStr,
|
|
@@ -456,7 +455,16 @@ class RouterCore {
|
|
|
456
455
|
if (isSameUrl && isSameState()) {
|
|
457
456
|
this.load();
|
|
458
457
|
} else {
|
|
459
|
-
let {
|
|
458
|
+
let {
|
|
459
|
+
// eslint-disable-next-line prefer-const
|
|
460
|
+
maskedLocation,
|
|
461
|
+
// eslint-disable-next-line prefer-const
|
|
462
|
+
hashScrollIntoView,
|
|
463
|
+
// don't pass url into history since it is a URL instance that cannot be serialized
|
|
464
|
+
// eslint-disable-next-line prefer-const
|
|
465
|
+
url: _url,
|
|
466
|
+
...nextHistory
|
|
467
|
+
} = next;
|
|
460
468
|
if (maskedLocation) {
|
|
461
469
|
nextHistory = {
|
|
462
470
|
...maskedLocation,
|
|
@@ -544,7 +552,7 @@ class RouterCore {
|
|
|
544
552
|
if (reloadDocument) {
|
|
545
553
|
if (!href) {
|
|
546
554
|
const location = this.buildLocation({ to, ...rest });
|
|
547
|
-
href = location.url;
|
|
555
|
+
href = location.url.href;
|
|
548
556
|
}
|
|
549
557
|
if (!rest.ignoreBlocker) {
|
|
550
558
|
const historyWithBlockers = this.history;
|
|
@@ -589,18 +597,8 @@ class RouterCore {
|
|
|
589
597
|
state: true,
|
|
590
598
|
_includeValidateSearch: true
|
|
591
599
|
});
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
return encodeURI(decodeURI(url));
|
|
595
|
-
} catch {
|
|
596
|
-
return url;
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
if (path.trimPath(normalizeUrl(this.latestLocation.href)) !== path.trimPath(normalizeUrl(nextLocation.href))) {
|
|
600
|
-
let href = nextLocation.url;
|
|
601
|
-
if (this.origin && href.startsWith(this.origin)) {
|
|
602
|
-
href = href.replace(this.origin, "") || "/";
|
|
603
|
-
}
|
|
600
|
+
if (this.latestLocation.publicHref !== nextLocation.publicHref || nextLocation.url.origin !== this.origin) {
|
|
601
|
+
const href = this.getParsedLocationHref(nextLocation);
|
|
604
602
|
throw redirect.redirect({ href });
|
|
605
603
|
}
|
|
606
604
|
}
|
|
@@ -819,13 +817,17 @@ class RouterCore {
|
|
|
819
817
|
this.shouldViewTransition = false;
|
|
820
818
|
return this.load({ sync: opts?.sync });
|
|
821
819
|
};
|
|
820
|
+
this.getParsedLocationHref = (location) => {
|
|
821
|
+
let href = location.url.href;
|
|
822
|
+
if (this.origin && location.url.origin === this.origin) {
|
|
823
|
+
href = href.replace(this.origin, "") || "/";
|
|
824
|
+
}
|
|
825
|
+
return href;
|
|
826
|
+
};
|
|
822
827
|
this.resolveRedirect = (redirect2) => {
|
|
823
828
|
if (!redirect2.options.href) {
|
|
824
829
|
const location = this.buildLocation(redirect2.options);
|
|
825
|
-
|
|
826
|
-
if (this.origin && href.startsWith(this.origin)) {
|
|
827
|
-
href = href.replace(this.origin, "") || "/";
|
|
828
|
-
}
|
|
830
|
+
const href = this.getParsedLocationHref(location);
|
|
829
831
|
redirect2.options.href = location.href;
|
|
830
832
|
redirect2.headers.set("Location", href);
|
|
831
833
|
}
|