bun-plugin-stx 0.2.383 → 0.2.384
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
|
|
@@ -1481,6 +1496,8 @@ function routerSource() {
|
|
|
1481
1496
|
if(pushState!==false&&t.href===location.href&&!t.hash&&!force)return Promise.resolve(false);
|
|
1482
1497
|
|
|
1483
1498
|
isNavigating=true;
|
|
1499
|
+
instantNav=instantNext;
|
|
1500
|
+
instantNext=false;
|
|
1484
1501
|
document.body.classList.add(o.loadingClass);
|
|
1485
1502
|
startProgress();
|
|
1486
1503
|
|
|
@@ -2016,6 +2033,7 @@ else {
|
|
|
2016
2033
|
}catch(err){reject(err)}
|
|
2017
2034
|
}
|
|
2018
2035
|
if(runViewTransition(completeFragSwap)){}
|
|
2036
|
+
else if(instantNav){completeFragSwap()}
|
|
2019
2037
|
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
2038
|
});
|
|
2021
2039
|
}
|
|
@@ -2466,6 +2484,10 @@ else {
|
|
|
2466
2484
|
}
|
|
2467
2485
|
if(runViewTransition(completeSwap)){
|
|
2468
2486
|
}
|
|
2487
|
+
else if(instantNav){
|
|
2488
|
+
// A tab: swap at once, no fade either way.
|
|
2489
|
+
completeSwap();
|
|
2490
|
+
}
|
|
2469
2491
|
else {
|
|
2470
2492
|
// Fallback fade for browsers without View Transitions API
|
|
2471
2493
|
currentContent.style.transition='opacity 0.12s ease-out';
|
|
@@ -2584,6 +2606,7 @@ else {
|
|
|
2584
2606
|
e.preventDefault();
|
|
2585
2607
|
e.stopPropagation();
|
|
2586
2608
|
log('[router] navigating to:',href);
|
|
2609
|
+
instantNext=link.getAttribute('data-stx-transition')==='none';
|
|
2587
2610
|
navigate(withCurrentLocale(href));
|
|
2588
2611
|
});
|
|
2589
2612
|
|
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-c7nhgech.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.384",
|
|
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.384",
|
|
78
|
+
"stx-router": "0.2.384"
|
|
79
79
|
}
|
|
80
80
|
}
|