bun-plugin-stx 0.2.393 → 0.2.395

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.
@@ -744,6 +744,10 @@ function routerSource() {
744
744
  // there. sessionStorage is per tab and dies with it, same as the history.
745
745
  var SCROLL_TOKEN='__stxScroll';
746
746
  var SCROLL_STORE='stx:scroll:';
747
+ // On every entry the router pushes, never on the one the app opened with
748
+ // (which carries a scroll token too): going back from a pushed entry stays
749
+ // in the app, from the first it leaves it (or, in a phone app, does nothing).
750
+ var PUSHED_MARK='__stxPushed';
747
751
  var scrollSeq=0;
748
752
  var pendingScroll=null;
749
753
  var restoreScroll=!!o.scrollRestoration;
@@ -1527,9 +1531,18 @@ function routerSource() {
1527
1531
  // The position belongs to the entry being left, and scrollToken still
1528
1532
  // names it here.
1529
1533
  rememberScroll();
1530
- if(mode==='replace'){history.replaceState(tokenState(),'',href);return}
1534
+ if(mode==='replace'){
1535
+ // A replaced entry is still the one it replaces: pushed by the app or
1536
+ // the one the app opened with.
1537
+ var replaced=tokenState();
1538
+ if(history.state&&history.state[PUSHED_MARK])replaced[PUSHED_MARK]=true;
1539
+ history.replaceState(replaced,'',href);
1540
+ return;
1541
+ }
1531
1542
  scrollToken=newScrollToken();
1532
- history.pushState(tokenState(),'',href);
1543
+ var pushed=tokenState();
1544
+ pushed[PUSHED_MARK]=true;
1545
+ history.pushState(pushed,'',href);
1533
1546
  }
1534
1547
  function tokenState(){var state={};state[SCROLL_TOKEN]=scrollToken;return state}
1535
1548
 
@@ -2836,6 +2849,22 @@ else {
2836
2849
  navigate(location.pathname+location.search+location.hash,false);
2837
2850
  });
2838
2851
 
2852
+ // \u2500\u2500 Offline stand-in \u2500\u2500
2853
+ // Without a network the offline worker answers a screen it has not kept
2854
+ // whole with the app's first screen, marked. A screen reached inside the
2855
+ // app was kept as a fragment, so ask for that and show it in place. Only
2856
+ // when it is there: a failed navigate reloads, and the reload would be
2857
+ // answered with the stand-in again.
2858
+ var standIn=document.querySelector('meta[name="stx-offline-fallback"]');
2859
+ if(standIn&&shouldUseFragmentResponse()){
2860
+ standIn.remove();
2861
+ var wanted=location.pathname+location.search;
2862
+ fetch(wanted,{headers:{'X-STX-Router':'true','Accept':'text/html'}}).then(function(r){
2863
+ if(r.ok&&r.headers.get('X-STX-Fragment')==='true'&&location.pathname+location.search===wanted)
2864
+ navigate(wanted+location.hash,false,true);
2865
+ }).catch(function(){});
2866
+ }
2867
+
2839
2868
  // \u2500\u2500 Prefetch \u2500\u2500
2840
2869
  // A link's page, fetched before it is followed into the cache navigate
2841
2870
  // reads, so following it is a swap rather than a round trip.
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-2fh2t5gw.js");
9803
+ const { Router } = await import("./chunk-ap1t4j02.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.393",
4
+ "version": "0.2.395",
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.393",
78
- "stx-router": "0.2.393"
77
+ "@stacksjs/stx": "0.2.395",
78
+ "stx-router": "0.2.395"
79
79
  }
80
80
  }