bun-plugin-stx 0.2.29 → 0.2.35
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.
|
@@ -572,7 +572,7 @@ function getRouterScript() {
|
|
|
572
572
|
if(window.__stxRouter)return;
|
|
573
573
|
|
|
574
574
|
// \u2500\u2500 Configuration \u2500\u2500
|
|
575
|
-
var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px'};
|
|
575
|
+
var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px',interceptAllLinks:false};
|
|
576
576
|
var o=Object.assign({},defaults,window.__stxRouterConfig||{},window.STX_ROUTER_OPTIONS||{});
|
|
577
577
|
var containerSel=o.container;
|
|
578
578
|
|
|
@@ -1108,13 +1108,19 @@ else {
|
|
|
1108
1108
|
return true;
|
|
1109
1109
|
}
|
|
1110
1110
|
|
|
1111
|
-
// SPA click handling
|
|
1112
|
-
//
|
|
1113
|
-
//
|
|
1111
|
+
// SPA click handling. By default only [data-stx-link] elements get
|
|
1112
|
+
// SPA navigation; regular <a href> does native full page reload. Set
|
|
1113
|
+
// interceptAllLinks:true (window.__stxRouterConfig or build-time
|
|
1114
|
+
// config) to intercept any same-origin anchor \u2014 used by static-site
|
|
1115
|
+
// mode where every page is part of the same SPA shell.
|
|
1114
1116
|
document.addEventListener('click',function(e){
|
|
1115
1117
|
if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;
|
|
1116
1118
|
if(!e.target||!e.target.closest)return;
|
|
1117
1119
|
var link=e.target.closest('[data-stx-link]');
|
|
1120
|
+
if(!link&&o.interceptAllLinks){
|
|
1121
|
+
var anchor=e.target.closest('a[href]');
|
|
1122
|
+
if(anchor&&shouldIntercept(anchor))link=anchor;
|
|
1123
|
+
}
|
|
1118
1124
|
if(!link){return}
|
|
1119
1125
|
var href=link.getAttribute('href');
|
|
1120
1126
|
console.log('[router] click intercepted:',href,'container:',!!getContainer(),'defaultPrevented:',e.defaultPrevented);
|
|
@@ -1216,7 +1222,11 @@ else {
|
|
|
1216
1222
|
el.id='stx-router-progress';
|
|
1217
1223
|
el.setAttribute('role','progressbar');
|
|
1218
1224
|
el.setAttribute('aria-hidden','true');
|
|
1219
|
-
|
|
1225
|
+
// Append to <html>, not <body>: when the router swaps the body
|
|
1226
|
+
// (container:'body' for full-page static-site SPAs) the progress
|
|
1227
|
+
// element gets wiped along with it. <html> stays put across
|
|
1228
|
+
// swaps, so the bar survives multi-hop navigation.
|
|
1229
|
+
document.documentElement.appendChild(el);
|
|
1220
1230
|
progEl=el;
|
|
1221
1231
|
} else if(o.progress){
|
|
1222
1232
|
progEl=document.getElementById('stx-router-progress');
|
package/dist/serve.js
CHANGED
|
@@ -8956,7 +8956,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
8956
8956
|
pageMiddlewarePatterns.length = 0;
|
|
8957
8957
|
await Promise.all(files.map((f) => detectPageMiddleware(f)));
|
|
8958
8958
|
try {
|
|
8959
|
-
const { Router } = await import("./chunk-
|
|
8959
|
+
const { Router } = await import("./chunk-rvyh0t4b.js");
|
|
8960
8960
|
const pagesDir = patterns[0]?.replace(/\/$/, "") || "pages";
|
|
8961
8961
|
const router = new Router(process19.cwd(), { pagesDir });
|
|
8962
8962
|
console.log(`[stx] Generated ${router.routes.length} routes \u2192 .stx/routes.ts`);
|
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.35",
|
|
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",
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"typecheck": "bun tsc --noEmit"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@stacksjs/stx": "0.2.
|
|
75
|
+
"@stacksjs/stx": "0.2.35"
|
|
76
76
|
}
|
|
77
77
|
}
|