bun-plugin-stx 0.2.411 → 0.2.412
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.
|
@@ -1113,7 +1113,7 @@ function routerSource() {
|
|
|
1113
1113
|
// whole fix \u2014 the click then goes to the network, where navigate does
|
|
1114
1114
|
// the reload properly.
|
|
1115
1115
|
function readPrefetchResponse(r,wantsFragment){
|
|
1116
|
-
if(r.redirected)return Promise.resolve(null);
|
|
1116
|
+
if(r.redirected||r.headers.get('X-STX-Location'))return Promise.resolve(null);
|
|
1117
1117
|
if(isBuildSkew(r.headers.get('X-STX-Build')||''))return Promise.resolve(null);
|
|
1118
1118
|
var isFrag=wantsFragment&&r.headers.get('X-STX-Fragment')==='true';
|
|
1119
1119
|
var layout=r.headers.get('X-STX-Layout')||'';
|
|
@@ -1642,6 +1642,18 @@ function routerSource() {
|
|
|
1642
1642
|
// swap() through pendingCtx, the same way pendingContainerAttrs is.
|
|
1643
1643
|
var navCtxNext=null;
|
|
1644
1644
|
var pendingCtx=null;
|
|
1645
|
+
// The page belongs to another origin: the server says so with
|
|
1646
|
+
// X-STX-Location (it cannot redirect a router fetch there, because a
|
|
1647
|
+
// cross-origin redirect of a request carrying X-STX-Router fails CORS), or
|
|
1648
|
+
// a plain fetch was redirected off-origin. Either way the browser goes
|
|
1649
|
+
// there itself; a fragment from another origin is never swapped in.
|
|
1650
|
+
function leaveOrigin(r){
|
|
1651
|
+
var away=r.headers.get('X-STX-Location');
|
|
1652
|
+
if(!away&&r.redirected&&r.url&&new URL(r.url,location.href).origin!==location.origin)away=r.url;
|
|
1653
|
+
if(!away)return false;
|
|
1654
|
+
location.href=away;
|
|
1655
|
+
return true;
|
|
1656
|
+
}
|
|
1645
1657
|
function routerFetch(url,headers){
|
|
1646
1658
|
var init={headers:headers};
|
|
1647
1659
|
if(navAbort)init.signal=navAbort.signal;
|
|
@@ -1733,10 +1745,11 @@ function routerSource() {
|
|
|
1733
1745
|
// Layout changed \u2014 fetch full page and do full document swap
|
|
1734
1746
|
log('[router] cache hit but layout changed \u2014 fetching full page');
|
|
1735
1747
|
return routerFetch(url,{'Accept':'text/html'}).then(function(r){
|
|
1748
|
+
if(leaveOrigin(r))return null;
|
|
1736
1749
|
if(!r.ok)throw httpError(r.status);
|
|
1737
1750
|
return r.text();
|
|
1738
1751
|
}).then(function(html){
|
|
1739
|
-
if(stale())return false;
|
|
1752
|
+
if(html===null||stale())return false;
|
|
1740
1753
|
log('[router] full page fetched from cache path, len:',html.length);
|
|
1741
1754
|
pendingLayoutDecl={layout:layoutCache[targetPath]||'',group:layoutGroupCache[targetPath]||''};
|
|
1742
1755
|
return swapWith(html,targetPath);
|
|
@@ -1761,6 +1774,7 @@ else {
|
|
|
1761
1774
|
var wantsFragment=shouldUseFragmentResponse();
|
|
1762
1775
|
return routerFetch(url,wantsFragment?{'X-STX-Router':'true','Accept':'text/html'}:{'Accept':'text/html'}).then(function(r){
|
|
1763
1776
|
if(stale())return null;
|
|
1777
|
+
if(leaveOrigin(r))return null;
|
|
1764
1778
|
if(!r.ok)throw httpError(r.status);
|
|
1765
1779
|
// A route guard answered with a redirect and fetch followed it
|
|
1766
1780
|
// transparently, so r.ok is the DESTINATION's 200 and this markup
|
|
@@ -1794,6 +1808,7 @@ else {
|
|
|
1794
1808
|
log('[router] layout change \u2014 fetching full page for document swap');
|
|
1795
1809
|
return routerFetch(url,{'Accept':'text/html'}).then(function(fullRes){
|
|
1796
1810
|
log('[router] full page fetched:',fullRes.status,'ok:',fullRes.ok);
|
|
1811
|
+
if(leaveOrigin(fullRes))return null;
|
|
1797
1812
|
if(!fullRes.ok)throw httpError(fullRes.status);
|
|
1798
1813
|
return fullRes.text().then(function(html){
|
|
1799
1814
|
log('[router] full page html length:',html.length);
|
package/dist/serve.js
CHANGED
|
@@ -9929,7 +9929,7 @@ function __stxOverlay(errs){
|
|
|
9929
9929
|
rebuildDiscoveredPagePaths(kept);
|
|
9930
9930
|
await indexPageMiddleware(kept);
|
|
9931
9931
|
try {
|
|
9932
|
-
const { Router } = await import("./chunk-
|
|
9932
|
+
const { Router } = await import("./chunk-g7br5ehx.js");
|
|
9933
9933
|
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
9934
9934
|
const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName(), exclude: options.exclude });
|
|
9935
9935
|
if (!options.quiet)
|
|
@@ -10604,8 +10604,11 @@ ${block}`;
|
|
|
10604
10604
|
req = new Request(original, { headers, method: req.method, body: req.body, redirect: req.redirect, duplex: "half" });
|
|
10605
10605
|
} else if (req.method === "GET" || req.method === "HEAD") {
|
|
10606
10606
|
const location = resolveDomainElsewhere(requestHost(req), original.pathname, original.search, domainRoutes, (pathname) => pathname.startsWith("/api/") || pathname.startsWith("/_stx/") || pathname.startsWith("/.well-known/") || isStaticAssetPath(pathname) || publicFileExists(pathname, publicDir));
|
|
10607
|
-
if (location)
|
|
10607
|
+
if (location) {
|
|
10608
|
+
if (req.headers.get(SPA_NAV_HEADER) === "true")
|
|
10609
|
+
return new Response(null, { status: 200, headers: { "X-STX-Location": location, "Cache-Control": "no-store", Vary: SPA_NAV_HEADER } });
|
|
10608
10610
|
return new Response(null, { status: 301, headers: { Location: location } });
|
|
10611
|
+
}
|
|
10609
10612
|
}
|
|
10610
10613
|
}
|
|
10611
10614
|
const url = new URL(req.url);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-plugin-stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.412",
|
|
5
5
|
"description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typecheck": "bun tsc --noEmit"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@stacksjs/stx": "0.2.
|
|
78
|
-
"stx-router": "0.2.
|
|
77
|
+
"@stacksjs/stx": "0.2.412",
|
|
78
|
+
"stx-router": "0.2.412"
|
|
79
79
|
}
|
|
80
80
|
}
|