stx-router 0.2.392 → 0.2.394

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.
Files changed (2) hide show
  1. package/dist/client.js +16 -0
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -2179,6 +2179,22 @@ else {
2179
2179
  navigate(location.pathname+location.search+location.hash,false);
2180
2180
  });
2181
2181
 
2182
+ // \u2500\u2500 Offline stand-in \u2500\u2500
2183
+ // Without a network the offline worker answers a screen it has not kept
2184
+ // whole with the app's first screen, marked. A screen reached inside the
2185
+ // app was kept as a fragment, so ask for that and show it in place. Only
2186
+ // when it is there: a failed navigate reloads, and the reload would be
2187
+ // answered with the stand-in again.
2188
+ var standIn=document.querySelector('meta[name="stx-offline-fallback"]');
2189
+ if(standIn&&shouldUseFragmentResponse()){
2190
+ standIn.remove();
2191
+ var wanted=location.pathname+location.search;
2192
+ fetch(wanted,{headers:{'X-STX-Router':'true','Accept':'text/html'}}).then(function(r){
2193
+ if(r.ok&&r.headers.get('X-STX-Fragment')==='true'&&location.pathname+location.search===wanted)
2194
+ navigate(wanted+location.hash,false,true);
2195
+ }).catch(function(){});
2196
+ }
2197
+
2182
2198
  // \u2500\u2500 Prefetch \u2500\u2500
2183
2199
  // A link's page, fetched before it is followed into the cache navigate
2184
2200
  // reads, so following it is a swap rather than a round trip.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stx-router",
3
3
  "type": "module",
4
- "version": "0.2.392",
4
+ "version": "0.2.394",
5
5
  "description": "File-based router for STX — .stx template discovery, nested layouts, typed route params, middleware, and client-side SPA navigation.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",