bun-plugin-stx 0.2.383 → 0.2.385
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.
|
@@ -839,8 +839,14 @@ function routerSource() {
|
|
|
839
839
|
log('[router] build skew: page is',loadedBuild,'server is',incoming,'\u2014 full navigation');
|
|
840
840
|
location.href=url;
|
|
841
841
|
}
|
|
842
|
+
// A link marked data-stx-transition="none" swaps without the cross-fade. A
|
|
843
|
+
// tab bar is the case: iOS switches tabs instantly, and the fade read as a
|
|
844
|
+
// quarter-second lag on every tap in a phone app. Set by the click that
|
|
845
|
+
// started the navigation, so programmatic and history navigations keep it.
|
|
846
|
+
var instantNext=false;
|
|
847
|
+
var instantNav=false;
|
|
842
848
|
function runViewTransition(callback){
|
|
843
|
-
if(
|
|
849
|
+
if(instantNav||!o.viewTransitions||!document.startViewTransition)return false;
|
|
844
850
|
try{
|
|
845
851
|
var transition=document.startViewTransition(callback);
|
|
846
852
|
var onAbort=function(err){log('[router] view transition aborted:',err&&err.message?err.message:err)};
|
|
@@ -867,19 +873,28 @@ function routerSource() {
|
|
|
867
873
|
progEl.style.opacity=progVal>0?'1':'0';
|
|
868
874
|
progEl.style.transform='scaleX('+(progVal/100)+')';
|
|
869
875
|
}
|
|
876
|
+
// Shown only for a navigation that is actually waiting. A page served from
|
|
877
|
+
// the prefetch cache swaps in a few milliseconds, and drawing then fading a
|
|
878
|
+
// bar for it made every instant navigation look like a load.
|
|
879
|
+
var progDelay=null;
|
|
870
880
|
function startProgress(){
|
|
871
881
|
if(!o.progress||!progEl)return;
|
|
872
882
|
if(progTimer){clearInterval(progTimer);progTimer=null}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
883
|
+
if(progDelay)clearTimeout(progDelay);
|
|
884
|
+
progDelay=setTimeout(function(){
|
|
885
|
+
progDelay=null;
|
|
886
|
+
setProgress(8);
|
|
887
|
+
progTimer=setInterval(function(){
|
|
888
|
+
if(progVal>=90)return;
|
|
889
|
+
// Asymptotic trickle \u2014 fast at first, slower near 90%
|
|
890
|
+
var inc=Math.max(0.4,(90-progVal)*0.08);
|
|
891
|
+
setProgress(progVal+inc);
|
|
892
|
+
},160);
|
|
893
|
+
},150);
|
|
880
894
|
}
|
|
881
895
|
function finishProgress(){
|
|
882
896
|
if(!o.progress||!progEl)return;
|
|
897
|
+
if(progDelay){clearTimeout(progDelay);progDelay=null;return}
|
|
883
898
|
if(progTimer){clearInterval(progTimer);progTimer=null}
|
|
884
899
|
setProgress(100);
|
|
885
900
|
// Fade out, then reset. Delays chosen so the "full" state is briefly
|
|
@@ -1156,19 +1171,13 @@ function routerSource() {
|
|
|
1156
1171
|
* Column-anchored: a declaration nested inside a function is indented, and
|
|
1157
1172
|
* is not in scope at the end of the block anyway.
|
|
1158
1173
|
*/
|
|
1159
|
-
var
|
|
1174
|
+
var TLD=/^(?:export\\s+)?(?:async\\s+)?(?:function\\s*\\*?|class|const|let|var)\\s+([$\\w]+)/gm;
|
|
1160
1175
|
function republishTopLevel(src){
|
|
1161
|
-
var
|
|
1162
|
-
|
|
1163
|
-
while((m=
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
if(!names.length)return '';
|
|
1167
|
-
var out='\\n;';
|
|
1168
|
-
for(var i=0;i<names.length;i++){
|
|
1169
|
-
out+='try{if(typeof '+names[i]+'==="function")window.'+names[i]+'='+names[i]+'}catch(e){}';
|
|
1170
|
-
}
|
|
1171
|
-
return out;
|
|
1176
|
+
var n=[],m,o='',i;
|
|
1177
|
+
TLD.lastIndex=0;
|
|
1178
|
+
while((m=TLD.exec(src))!==null)if(n.indexOf(m[1])<0)n.push(m[1]);
|
|
1179
|
+
for(i=0;i<n.length;i++)o+='try{typeof '+n[i]+'=="function"&&(window.'+n[i]+'='+n[i]+')}catch(e){}';
|
|
1180
|
+
return o?'\\n;'+o:'';
|
|
1172
1181
|
}
|
|
1173
1182
|
function runsAlways(declared, code){
|
|
1174
1183
|
if(declared==='always')return true;
|
|
@@ -1481,6 +1490,8 @@ function routerSource() {
|
|
|
1481
1490
|
if(pushState!==false&&t.href===location.href&&!t.hash&&!force)return Promise.resolve(false);
|
|
1482
1491
|
|
|
1483
1492
|
isNavigating=true;
|
|
1493
|
+
instantNav=instantNext;
|
|
1494
|
+
instantNext=false;
|
|
1484
1495
|
document.body.classList.add(o.loadingClass);
|
|
1485
1496
|
startProgress();
|
|
1486
1497
|
|
|
@@ -2016,6 +2027,7 @@ else {
|
|
|
2016
2027
|
}catch(err){reject(err)}
|
|
2017
2028
|
}
|
|
2018
2029
|
if(runViewTransition(completeFragSwap)){}
|
|
2030
|
+
else if(instantNav){completeFragSwap()}
|
|
2019
2031
|
else{currentContent.style.transition='opacity 0.12s ease-out';currentContent.style.opacity='0';setTimeout(function(){completeFragSwap();currentContent.style.opacity='1';setTimeout(function(){currentContent.style.transition=''},150)},120)}
|
|
2020
2032
|
});
|
|
2021
2033
|
}
|
|
@@ -2466,6 +2478,10 @@ else {
|
|
|
2466
2478
|
}
|
|
2467
2479
|
if(runViewTransition(completeSwap)){
|
|
2468
2480
|
}
|
|
2481
|
+
else if(instantNav){
|
|
2482
|
+
// A tab: swap at once, no fade either way.
|
|
2483
|
+
completeSwap();
|
|
2484
|
+
}
|
|
2469
2485
|
else {
|
|
2470
2486
|
// Fallback fade for browsers without View Transitions API
|
|
2471
2487
|
currentContent.style.transition='opacity 0.12s ease-out';
|
|
@@ -2584,6 +2600,7 @@ else {
|
|
|
2584
2600
|
e.preventDefault();
|
|
2585
2601
|
e.stopPropagation();
|
|
2586
2602
|
log('[router] navigating to:',href);
|
|
2603
|
+
instantNext=link.getAttribute('data-stx-transition')==='none';
|
|
2587
2604
|
navigate(withCurrentLocale(href));
|
|
2588
2605
|
});
|
|
2589
2606
|
|
package/dist/serve.js
CHANGED
|
@@ -9800,7 +9800,7 @@ function __stxOverlay(errs){
|
|
|
9800
9800
|
rebuildDiscoveredPagePaths(kept);
|
|
9801
9801
|
await indexPageMiddleware(kept);
|
|
9802
9802
|
try {
|
|
9803
|
-
const { Router } = await import("./chunk-
|
|
9803
|
+
const { Router } = await import("./chunk-kpbk9rbk.js");
|
|
9804
9804
|
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
9805
9805
|
const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName(), exclude: options.exclude });
|
|
9806
9806
|
if (!options.quiet)
|
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.385",
|
|
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.385",
|
|
78
|
+
"stx-router": "0.2.385"
|
|
79
79
|
}
|
|
80
80
|
}
|