bun-plugin-stx 0.2.29 → 0.2.41
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
|
|
|
@@ -1039,6 +1039,13 @@ else {
|
|
|
1039
1039
|
var newTitle=doc.querySelector('title');
|
|
1040
1040
|
if(newTitle)document.title=newTitle.textContent;
|
|
1041
1041
|
|
|
1042
|
+
// Update <html lang> from the destination doc so screen readers,
|
|
1043
|
+
// CSS :lang() selectors, and any i18n picker that mirrors
|
|
1044
|
+
// document.documentElement.lang stay accurate after SPA hops.
|
|
1045
|
+
if(doc.documentElement&&doc.documentElement.lang){
|
|
1046
|
+
document.documentElement.lang=doc.documentElement.lang;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1042
1049
|
window.dispatchEvent(new CustomEvent('stx:navigate',{detail:{url:url}}));
|
|
1043
1050
|
|
|
1044
1051
|
// Execute page scripts FIRST \u2014 they define setup functions and set _latestSetup
|
|
@@ -1108,13 +1115,19 @@ else {
|
|
|
1108
1115
|
return true;
|
|
1109
1116
|
}
|
|
1110
1117
|
|
|
1111
|
-
// SPA click handling
|
|
1112
|
-
//
|
|
1113
|
-
//
|
|
1118
|
+
// SPA click handling. By default only [data-stx-link] elements get
|
|
1119
|
+
// SPA navigation; regular <a href> does native full page reload. Set
|
|
1120
|
+
// interceptAllLinks:true (window.__stxRouterConfig or build-time
|
|
1121
|
+
// config) to intercept any same-origin anchor \u2014 used by static-site
|
|
1122
|
+
// mode where every page is part of the same SPA shell.
|
|
1114
1123
|
document.addEventListener('click',function(e){
|
|
1115
1124
|
if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;
|
|
1116
1125
|
if(!e.target||!e.target.closest)return;
|
|
1117
1126
|
var link=e.target.closest('[data-stx-link]');
|
|
1127
|
+
if(!link&&o.interceptAllLinks){
|
|
1128
|
+
var anchor=e.target.closest('a[href]');
|
|
1129
|
+
if(anchor&&shouldIntercept(anchor))link=anchor;
|
|
1130
|
+
}
|
|
1118
1131
|
if(!link){return}
|
|
1119
1132
|
var href=link.getAttribute('href');
|
|
1120
1133
|
console.log('[router] click intercepted:',href,'container:',!!getContainer(),'defaultPrevented:',e.defaultPrevented);
|
|
@@ -1216,7 +1229,11 @@ else {
|
|
|
1216
1229
|
el.id='stx-router-progress';
|
|
1217
1230
|
el.setAttribute('role','progressbar');
|
|
1218
1231
|
el.setAttribute('aria-hidden','true');
|
|
1219
|
-
|
|
1232
|
+
// Append to <html>, not <body>: when the router swaps the body
|
|
1233
|
+
// (container:'body' for full-page static-site SPAs) the progress
|
|
1234
|
+
// element gets wiped along with it. <html> stays put across
|
|
1235
|
+
// swaps, so the bar survives multi-hop navigation.
|
|
1236
|
+
document.documentElement.appendChild(el);
|
|
1220
1237
|
progEl=el;
|
|
1221
1238
|
} else if(o.progress){
|
|
1222
1239
|
progEl=document.getElementById('stx-router-progress');
|
|
@@ -1226,7 +1243,7 @@ else {
|
|
|
1226
1243
|
function injectViewTransitionCSS(){
|
|
1227
1244
|
if(document.getElementById('stx-view-transitions'))return;
|
|
1228
1245
|
var s=document.createElement('style');s.id='stx-view-transitions';
|
|
1229
|
-
s.textContent='::view-transition-group(root){animation:none}::view-transition-old(root){animation:none}::view-transition-new(root){animation:none}
|
|
1246
|
+
s.textContent='::view-transition-group(root){animation:none}::view-transition-old(root){animation:none}::view-transition-new(root){animation:none}main,#app-content,[data-stx-content]{view-transition-name:stx-content}::view-transition-old(stx-content){animation:stx-fade-out .15s ease-out both}::view-transition-new(stx-content){animation:stx-fade-in .15s ease-in .1s both}@keyframes stx-fade-out{from{opacity:1}to{opacity:0}}@keyframes stx-fade-in{from{opacity:0}to{opacity:1}}::view-transition{background:transparent}::view-transition-group(stx-content){background:inherit;overflow:hidden}';
|
|
1230
1247
|
(document.head||document.documentElement).appendChild(s);
|
|
1231
1248
|
}
|
|
1232
1249
|
|
|
@@ -307,6 +307,11 @@ function stxPlugin(userOptions) {
|
|
|
307
307
|
console.error("Failed to build web components:", error);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
|
+
build.onResolve({ filter: /^\// }, (args) => {
|
|
311
|
+
if (args.path.startsWith("//"))
|
|
312
|
+
return null;
|
|
313
|
+
return { external: true, path: args.path };
|
|
314
|
+
});
|
|
310
315
|
build.onLoad({ filter: /\.md$/ }, async (args) => {
|
|
311
316
|
const filePath = args.path;
|
|
312
317
|
try {
|
package/dist/index.js
CHANGED
package/dist/preload.js
CHANGED
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-nyzhqegd.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.41",
|
|
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.41"
|
|
76
76
|
}
|
|
77
77
|
}
|