@stacksjs/stx 0.2.448 → 0.2.449

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 (71) hide show
  1. package/dist/{chunk-237psdsd.js → chunk-1gwq5pgj.js} +1 -1
  2. package/dist/{chunk-g4hv6v3e.js → chunk-1h774y7j.js} +1 -1
  3. package/dist/chunk-2234az7m.js +2 -0
  4. package/dist/chunk-25pjn68v.js +2 -0
  5. package/dist/{chunk-bderms43.js → chunk-2rky7wgq.js} +1 -1
  6. package/dist/{chunk-13raxes0.js → chunk-307a5hmc.js} +1 -1
  7. package/dist/{chunk-yn3w9g2z.js → chunk-3bjvgk8p.js} +2 -2
  8. package/dist/{chunk-j19s8n7w.js → chunk-48dvw3fw.js} +1 -1
  9. package/dist/{chunk-fhpfe2s3.js → chunk-4af6khdc.js} +1 -1
  10. package/dist/{chunk-vnq2c0tg.js → chunk-4c33955p.js} +1 -1
  11. package/dist/{chunk-z4b0kr1z.js → chunk-4eq7ak70.js} +2 -2
  12. package/dist/{chunk-9xf7yk65.js → chunk-5jtzxt0c.js} +1 -1
  13. package/dist/{chunk-z72wwstp.js → chunk-60mc14b6.js} +1 -1
  14. package/dist/chunk-6x4wwnsy.js +2 -0
  15. package/dist/{chunk-qmfwhvcr.js → chunk-7758mtrv.js} +6 -6
  16. package/dist/{chunk-bxhzs857.js → chunk-888js6gw.js} +1 -1
  17. package/dist/{chunk-cs3507d0.js → chunk-8p3jc9pd.js} +1 -1
  18. package/dist/{chunk-brtvd5bs.js → chunk-9e73j3kx.js} +1 -1
  19. package/dist/{chunk-j1h2z4wh.js → chunk-atebr0qx.js} +1 -1
  20. package/dist/{chunk-get6k573.js → chunk-cac3vsxa.js} +1 -1
  21. package/dist/{chunk-fp6v2dq5.js → chunk-ff0csdfb.js} +2 -2
  22. package/dist/{chunk-j3se49h7.js → chunk-g231bs3w.js} +1 -1
  23. package/dist/{chunk-8bzc2v6z.js → chunk-gshjxgm1.js} +1 -1
  24. package/dist/{chunk-frv8bhmz.js → chunk-gxk09e0k.js} +5 -5
  25. package/dist/{chunk-5ftzrjpd.js → chunk-hk2qxa85.js} +1 -1
  26. package/dist/{chunk-bqc07550.js → chunk-hnf5n809.js} +1 -1
  27. package/dist/{chunk-gm7ewgf4.js → chunk-hx1dmj0e.js} +1 -1
  28. package/dist/{chunk-kwsw9tc4.js → chunk-jgdbyrqw.js} +1 -1
  29. package/dist/{chunk-8y4wrp43.js → chunk-k467ry8f.js} +1 -1
  30. package/dist/{chunk-m5298269.js → chunk-m9s92xgx.js} +1 -1
  31. package/dist/{chunk-sfvyfvbm.js → chunk-ms4arcga.js} +1 -1
  32. package/dist/{chunk-qmp7j5h4.js → chunk-n7jjqqbx.js} +1 -1
  33. package/dist/{chunk-mtctv02d.js → chunk-nbke0vc6.js} +1 -1
  34. package/dist/{chunk-rp69az5a.js → chunk-nkveg25t.js} +1 -1
  35. package/dist/{chunk-78wsn958.js → chunk-nnha3jpr.js} +1 -1
  36. package/dist/{chunk-y6zm894z.js → chunk-pm492kcm.js} +1 -1
  37. package/dist/{chunk-7417f610.js → chunk-qzgqg0bw.js} +85 -25
  38. package/dist/{chunk-2tpvt1c5.js → chunk-r4q52w84.js} +1 -1
  39. package/dist/{chunk-pgnr089q.js → chunk-r8vpah5h.js} +1 -1
  40. package/dist/{chunk-n7n9zxmh.js → chunk-rz4b20k1.js} +27 -27
  41. package/dist/{chunk-hdat2brj.js → chunk-t9x7ts0e.js} +1 -1
  42. package/dist/{chunk-ytq686vx.js → chunk-tfxn6w46.js} +1 -1
  43. package/dist/{chunk-vbzeeeax.js → chunk-tx28mc48.js} +1 -1
  44. package/dist/{chunk-h3gdfbmf.js → chunk-wtah2ty9.js} +1 -1
  45. package/dist/{chunk-t01a2dfe.js → chunk-x3ayv7n0.js} +1 -1
  46. package/dist/{chunk-dk3zazaw.js → chunk-x83n89g3.js} +1 -1
  47. package/dist/{chunk-7aspn183.js → chunk-xfpmac91.js} +1 -1
  48. package/dist/{chunk-5vgdbqbz.js → chunk-y0ny5xzw.js} +2 -2
  49. package/dist/{chunk-21ypr4t0.js → chunk-z939gvze.js} +1 -1
  50. package/dist/chunk-zqx4crbj.js +2 -0
  51. package/dist/cli.js +7 -7
  52. package/dist/component-renderer.js +6 -0
  53. package/dist/craft-entry.js +1 -1
  54. package/dist/craft.js +1 -1
  55. package/dist/native/compiler/html-to-ir.js +42 -1
  56. package/dist/native/compiler/ir.d.ts +15 -1
  57. package/dist/native/primitives/ActivityIndicator.stx +1 -1
  58. package/dist/native/primitives/DatePicker.stx +1 -1
  59. package/dist/native/primitives/Modal.stx +1 -1
  60. package/dist/native/primitives/RefreshControl.stx +1 -1
  61. package/dist/native/primitives/Slider.stx +1 -1
  62. package/dist/native/primitives/StatusBar.stx +1 -1
  63. package/dist/native/primitives/Switch.stx +1 -1
  64. package/dist/native/runtime/native-host.js +26 -1
  65. package/dist/pwa.js +1 -1
  66. package/dist/ssg.js +2 -2
  67. package/package.json +5 -5
  68. package/dist/chunk-4gjc61wn.js +0 -2
  69. package/dist/chunk-d3yrvve4.js +0 -2
  70. package/dist/chunk-nkzn1hqq.js +0 -2
  71. package/dist/chunk-t6d5zq7d.js +0 -2
@@ -803,15 +803,28 @@ import x from"fs";import u from"path";import p from"fs";import v from"path";var
803
803
  if(key)loadedExternalScripts[key]=1;
804
804
  return key;
805
805
  }
806
- // Returns a promise, or null when there is nothing to wait for \u2014 an already
807
- // loaded file, or an unparseable src. Resolves rather than rejects on error:
808
- // one 404 must not stop the rest of the page hydrating, matching what the
809
- // head-script path already does by sending failures to execScripts too.
806
+ // Returns a promise of whether the file loaded, or null when there is
807
+ // nothing to wait for \u2014 an already loaded file, or an unparseable src.
808
+ // Resolves rather than rejects on error: one 404 must not stop the rest of
809
+ // the page hydrating; the caller decides what a failure means.
810
+ //
811
+ // A file still on its way is not a loaded one. A prefetch starts loading
812
+ // the page's module registry (loadModuleRegistries), and this used to count
813
+ // it loaded the moment it was requested, so a tap that beat it swapped the
814
+ // page in and ran its setup ahead of the registry it imports from: "is not
815
+ // registered on this page", every binding dead. Locally a file loads in a
816
+ // millisecond and the tap never wins; on a phone far from the server it
817
+ // does. The tap now waits on the same request.
818
+ //
819
+ // And a file that failed is forgotten, so a fresh copy of the page that
820
+ // links it again (recoverUnbound) asks for it again rather than finding it
821
+ // "loaded" and running without it until the next reload.
822
+ var pendingExternalScripts={};
810
823
  function loadExternalScript(src,base){
811
824
  var key=externalScriptKey(src,base);
812
825
  if(!key||loadedExternalScripts[key])return null;
813
- loadedExternalScripts[key]=1;
814
- return new Promise(function(resolve){
826
+ if(pendingExternalScripts[key])return pendingExternalScripts[key];
827
+ return pendingExternalScripts[key]=new Promise(function(resolve){
815
828
  var el=ce('script');
816
829
  el.src=key;
817
830
  // Deliberately NOT data-stx-page: both swap paths clear those on every
@@ -822,11 +835,31 @@ import x from"fs";import u from"path";import p from"fs";import v from"path";var
822
835
  // In document order: a fragment's composables bundle reads the module
823
836
  // registry loaded beside it, and an inserted script is async by default.
824
837
  el.async=false;
825
- el.onload=function(){resolve()};
826
- el.onerror=function(){log('[router] container script failed:',key);resolve()};
838
+ el.onload=function(){delete pendingExternalScripts[key];loadedExternalScripts[key]=1;resolve(true)};
839
+ el.onerror=function(){
840
+ log('[router] container script failed:',key);
841
+ delete pendingExternalScripts[key];
842
+ if(el.parentNode)el.parentNode.removeChild(el);
843
+ resolve(false);
844
+ };
827
845
  dhead().appendChild(el);
828
846
  });
829
847
  }
848
+ // A page's module registry, stores or composables in serve mode: stx's own
849
+ // file, named by its content (registerServeModuleBundle). Without it the
850
+ // page's setup cannot run at all, unlike an app's own script, whose
851
+ // failure the rest of the page survives.
852
+ var MODULE_BUNDLE=/\\/_stx\\/modules\\.[0-9a-f]{16}\\.js(?:[?#]|$)/;
853
+ function isModuleBundle(src){return MODULE_BUNDLE.test(src||'')}
854
+ // Waits for the files a swap loads, then runs its scripts -- or, when one
855
+ // of them was a module bundle that did not load, recovers the page instead
856
+ // of running a setup that can only throw.
857
+ function afterExternalScripts(pending,run,url,ctx){
858
+ if(!pending.length){run();return}
859
+ var failed=false;
860
+ Promise.all(pending.map(function(p){return p.promise.then(function(ok){if(ok===false&&isModuleBundle(p.src))failed=true})}))
861
+ .then(function(){if(failed)recoverUnbound(url,ctx);else run()},run);
862
+ }
830
863
 
831
864
  // Record scripts from the initial page load
832
865
  qsa('script').forEach(function(s){
@@ -950,9 +983,13 @@ import x from"fs";import u from"path";import p from"fs";import v from"path";var
950
983
  location.href=away;
951
984
  return true;
952
985
  }
953
- function routerFetch(url,headers){
986
+ // fresh: past every cache, the offline worker's included (it hands a
987
+ // no-store request straight to the network). For recoverUnbound, whose
988
+ // whole point is that the kept copy is the broken one.
989
+ function routerFetch(url,headers,fresh){
954
990
  var init={headers:headers};
955
991
  if(navAbort)init.signal=navAbort.signal;
992
+ if(fresh)init.cache='no-store';
956
993
  return fetch(url,init);
957
994
  }
958
995
  function navigate(url,pushState,force){
@@ -1068,7 +1105,7 @@ else {
1068
1105
  // the page content. Custom app-shell containers need full documents so
1069
1106
  // the router does not inject a <main> fragment into the wrong element.
1070
1107
  var wantsFragment=shouldUseFragmentResponse();
1071
- return routerFetch(url,wantsFragment?{'X-STX-Router':'true','Accept':'text/html'}:{'Accept':'text/html'}).then(function(r){
1108
+ return routerFetch(url,wantsFragment?{'X-STX-Router':'true','Accept':'text/html'}:{'Accept':'text/html'},ctx.fresh).then(function(r){
1072
1109
  if(stale())return null;
1073
1110
  if(leaveOrigin(r))return null;
1074
1111
  if(!r.ok)throw httpError(r.status);
@@ -1102,7 +1139,7 @@ else {
1102
1139
  // Layout change? Fetch the FULL page (no X-STX-Router header) and do full document swap
1103
1140
  if(isFragment&&checkLayoutChange(newLayout,url,newGroup)){
1104
1141
  log('[router] layout change \u2014 fetching full page for document swap');
1105
- return routerFetch(url,{'Accept':'text/html'}).then(function(fullRes){
1142
+ return routerFetch(url,{'Accept':'text/html'},ctx.fresh).then(function(fullRes){
1106
1143
  log('[router] full page fetched:',fullRes.status,'ok:',fullRes.ok);
1107
1144
  if(leaveOrigin(fullRes))return null;
1108
1145
  if(!fullRes.ok)throw httpError(fullRes.status);
@@ -1151,6 +1188,33 @@ else {
1151
1188
  pendingCtx=ctx;
1152
1189
  return Promise.resolve(swap(html,cacheKey(url),pushState,hash)).then(function(){return false});
1153
1190
  }
1191
+ // \u2500\u2500 A page whose module bundle did not load \u2500\u2500
1192
+ // Serve mode links a page's registry, stores and composables as
1193
+ // /_stx/modules.<hash>.js, answered from what the server process has
1194
+ // rendered. Its HTML can outlive that process: the router's cache, a
1195
+ // prefetch, the offline worker's kept copy. After a deploy (a new release
1196
+ // directory, a new process that has never rendered the page) the hash is
1197
+ // answered 404, and the page was swapped in with nothing bound -- its
1198
+ // {{ }} empty, its :for lists empty, its :if buttons gone -- until a
1199
+ // revalidation happened to replace the copy (hq.training, a coach's
1200
+ // /coaches/athletes).
1201
+ //
1202
+ // So that copy is dropped and the page fetched again past every cache:
1203
+ // the process answering renders it, which registers the bundle it links,
1204
+ // and a newer build is caught by the skew check and loaded whole (#1772).
1205
+ // Once only. A fresh copy whose bundle fails too is loaded as a document,
1206
+ // where the browser and the server settle it without the router.
1207
+ //
1208
+ // Not a page whose own setup throws: that throws again on a fresh copy, so
1209
+ // retrying would only add a round trip and a reload to every visit.
1210
+ function recoverUnbound(url,ctx){
1211
+ if(ctx&&ctx.id&&ctx.id!==navSeq)return;
1212
+ evictCache(cacheKey(url));
1213
+ if(ctx&&ctx.fresh){log('[router] module bundle failed again \u2014 full navigation to:',url);location.href=url;return}
1214
+ log('[router] module bundle failed \u2014 fetching',url,'again past the caches');
1215
+ navCtxNext={direction:'replace',fresh:true};
1216
+ navigate(url,'replace',true);
1217
+ }
1154
1218
  function retryShown(){var root=activeRoot();var el=root&&root.querySelector?root.querySelector('[data-stx-retry]'):null;return el?el.getAttribute('data-stx-retry'):''}
1155
1219
  document.addEventListener('click',function(e){
1156
1220
  var b=e.target&&e.target.closest?e.target.closest('[data-stx-retry-button]'):null;
@@ -1585,10 +1649,9 @@ else {
1585
1649
  var fragPending=[];
1586
1650
  fragExternalScripts.forEach(function(src){
1587
1651
  var pending=loadExternalScript(src,url);
1588
- if(pending)fragPending.push(pending);
1652
+ if(pending)fragPending.push({src:src,promise:pending});
1589
1653
  });
1590
- if(fragPending.length)Promise.all(fragPending).then(runFragScripts).catch(runFragScripts);
1591
- else runFragScripts();
1654
+ afterExternalScripts(fragPending,runFragScripts,url+(hash||''),ctx);
1592
1655
  }
1593
1656
  // With screens retained, the outgoing page is kept (or disposed once it
1594
1657
  // has animated away) by screenBegin rather than cleaned up here.
@@ -1853,13 +1916,15 @@ else {
1853
1916
  var src=new URL(s.getAttribute('src'),docBase).href;
1854
1917
  if(loadedSrcs[src])return;
1855
1918
  loadedSrcs[src]=1;
1856
- extPromises.push(new Promise(function(resolve,reject){
1919
+ extPromises.push({src:src,promise:new Promise(function(resolve){
1857
1920
  var ns=ce('script');
1858
1921
  ns.src=src;
1859
- ns.onload=resolve;
1860
- ns.onerror=reject;
1922
+ ns.onload=function(){resolve(true)};
1923
+ // Settled either way, as before (a rejection ran the scripts at
1924
+ // once); afterExternalScripts tells a failed module bundle apart.
1925
+ ns.onerror=function(){if(ns.parentNode)ns.parentNode.removeChild(ns);resolve(false)};
1861
1926
  dhead().appendChild(ns);
1862
- }));
1927
+ })});
1863
1928
  });
1864
1929
 
1865
1930
  // Before the inline scripts, and through the same barrier: an inline
@@ -1867,7 +1932,7 @@ else {
1867
1932
  // so running it first would fail exactly the way this bug did.
1868
1933
  routedExternalScripts.forEach(function(src){
1869
1934
  var pending=loadExternalScript(src,docBase);
1870
- if(pending)extPromises.push(pending);
1935
+ if(pending)extPromises.push({src:src,promise:pending});
1871
1936
  });
1872
1937
 
1873
1938
  // \u2500\u2500 Script re-execution \u2500\u2500
@@ -2042,12 +2107,7 @@ else {
2042
2107
  window.dispatchEvent(new Event('stx:load'));
2043
2108
  }
2044
2109
 
2045
- if(extPromises.length>0){
2046
- Promise.all(extPromises).then(execScripts).catch(execScripts);
2047
- }
2048
- else {
2049
- execScripts();
2050
- }
2110
+ afterExternalScripts(extPromises,execScripts,url+(hash||''),ctx);
2051
2111
  }
2052
2112
 
2053
2113
  function startSwap(){
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Yl,ho,Ea,Zl,Ql,eu,tu,nu,Ta,_a,ru,su,ou,iu}from"./chunk-y6zm894z.js";import"./chunk-n7n9zxmh.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-gm7ewgf4.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-7417f610.js";import"./chunk-dqr5n49p.js";export{Ea as SUSPENSE_RESOLVER_RUNTIME,ho as buildSuspenseResolveScript,nu as createStreamRenderer,eu as extractStreamBoundaries,iu as generateHydrationRuntime,_a as islandDirective,su as processSectionDirectives,Ql as processStreamDirectives,ru as registerStreamingDirectives,Zl as renderStreamingPage,Yl as streamTemplate,tu as streamTemplateSimple,ou as streamToResponse,Ta as streamingSuspenseDirective};
2
+ import{Yl,ho,Ea,Zl,Ql,eu,tu,nu,Ta,_a,ru,su,ou,iu}from"./chunk-pm492kcm.js";import"./chunk-rz4b20k1.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-hx1dmj0e.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-qzgqg0bw.js";import"./chunk-dqr5n49p.js";export{Ea as SUSPENSE_RESOLVER_RUNTIME,ho as buildSuspenseResolveScript,nu as createStreamRenderer,eu as extractStreamBoundaries,iu as generateHydrationRuntime,_a as islandDirective,su as processSectionDirectives,Ql as processStreamDirectives,ru as registerStreamingDirectives,Zl as renderStreamingPage,Yl as streamTemplate,tu as streamTemplateSimple,ou as streamToResponse,Ta as streamingSuspenseDirective};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Au,Ho,Pu,Vo,Ya,Za,vt,en,Iu,Qa,ec,tc,f}from"./chunk-n7n9zxmh.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-gm7ewgf4.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-7417f610.js";import"./chunk-dqr5n49p.js";export{vt as buildCss,Qa as extractClassNames,Za as fingerprintConfig,ec as generateCss,Iu as getCachedCSS,Au as getCssServeAsset,f as injectCss,Ho as loadCssEngine,Vo as loadCssEngineConfig,en as rebuildCss,Pu as resetCssCache,Ya as resolveUserCssConfig,tc as withLinkedModuleBundles};
2
+ import{Au,Ho,Pu,Vo,Ya,Za,vt,en,Iu,Qa,ec,tc,f}from"./chunk-rz4b20k1.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-hx1dmj0e.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-qzgqg0bw.js";import"./chunk-dqr5n49p.js";export{vt as buildCss,Qa as extractClassNames,Za as fingerprintConfig,ec as generateCss,Iu as getCachedCSS,Au as getCssServeAsset,f as injectCss,Ho as loadCssEngine,Vo as loadCssEngineConfig,en as rebuildCss,Pu as resetCssCache,Ya as resolveUserCssConfig,tc as withLinkedModuleBundles};