@stacksjs/stx 0.2.630 → 0.2.631

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 (219) hide show
  1. package/dist/chunk-05zhvg8t.js +20 -0
  2. package/dist/chunk-0c31twby.js +2 -0
  3. package/dist/{chunk-0s1hpqas.js → chunk-0jeqp6yz.js} +2 -2
  4. package/dist/chunk-0nvb2x2f.js +2 -0
  5. package/dist/chunk-0whv8hnp.js +4 -0
  6. package/dist/{chunk-q1983d5e.js → chunk-179c1rdn.js} +2 -2
  7. package/dist/chunk-1e25xd0z.js +6 -0
  8. package/dist/{chunk-jp6yn9mj.js → chunk-1ma56c2h.js} +2 -2
  9. package/dist/{chunk-h9ymjtch.js → chunk-27h1xs4k.js} +12 -12
  10. package/dist/{chunk-5m0r0j79.js → chunk-2vqz7v37.js} +3 -3
  11. package/dist/{chunk-10s16tad.js → chunk-2wvz3fd2.js} +2 -2
  12. package/dist/chunk-3jda301z.js +2 -0
  13. package/dist/{chunk-gc1dzxee.js → chunk-3p2b88pd.js} +2 -2
  14. package/dist/chunk-46qg1tqe.js +2 -0
  15. package/dist/{chunk-66e4ga0z.js → chunk-4fv3jq16.js} +2 -2
  16. package/dist/{chunk-k1k2t4ez.js → chunk-4y06ekvt.js} +1 -1
  17. package/dist/chunk-5fjb6avv.js +2 -0
  18. package/dist/chunk-5kprybdd.js +2 -0
  19. package/dist/{chunk-n5xbv1a9.js → chunk-62kxavc5.js} +3 -3
  20. package/dist/{chunk-8q9b82ew.js → chunk-6684b8ym.js} +11 -11
  21. package/dist/{chunk-npvxq89e.js → chunk-6mtth8d1.js} +3 -3
  22. package/dist/chunk-6n6nnt33.js +2 -0
  23. package/dist/chunk-6per0k6j.js +2 -0
  24. package/dist/{chunk-hb46a5rr.js → chunk-70npkeh2.js} +2 -2
  25. package/dist/{chunk-y706tkyy.js → chunk-776f05vk.js} +4 -4
  26. package/dist/{chunk-szjgbjw1.js → chunk-7a8jkwah.js} +2 -2
  27. package/dist/{chunk-wbhzt74k.js → chunk-7cw0wkbx.js} +1 -1
  28. package/dist/chunk-7f1dw9r4.js +2 -0
  29. package/dist/{chunk-khzyc41k.js → chunk-7ky2ny63.js} +13 -13
  30. package/dist/{chunk-h431swg6.js → chunk-7mpv1a02.js} +9 -9
  31. package/dist/chunk-7zjv015g.js +2 -0
  32. package/dist/{chunk-q35z0cyg.js → chunk-85bbtv3m.js} +1 -1
  33. package/dist/{chunk-qb7a4am2.js → chunk-85g35me6.js} +2 -2
  34. package/dist/chunk-87nt0kty.js +2 -0
  35. package/dist/{chunk-3dth76ce.js → chunk-88d5s6v3.js} +3 -3
  36. package/dist/chunk-8a3sdg2y.js +2 -0
  37. package/dist/chunk-8e9hd2jq.js +4 -0
  38. package/dist/{chunk-0c7ss25y.js → chunk-8gksvwsm.js} +3 -3
  39. package/dist/chunk-8vbfbtke.js +2 -0
  40. package/dist/chunk-91ranpvz.js +2 -0
  41. package/dist/chunk-96ypgjm4.js +2 -0
  42. package/dist/{chunk-1gtrs8va.js → chunk-9b4e815s.js} +8 -8
  43. package/dist/chunk-9cg6q8mw.js +2 -0
  44. package/dist/{chunk-gd7vq083.js → chunk-a2ztn8cr.js} +1 -1
  45. package/dist/chunk-ag4eck6d.js +2 -0
  46. package/dist/chunk-aq02drjz.js +2 -0
  47. package/dist/{chunk-jsw5yby0.js → chunk-aqra0qcg.js} +3 -3
  48. package/dist/{chunk-cnvfh74t.js → chunk-av9zf0zb.js} +5 -5
  49. package/dist/chunk-ayt4qd82.js +2 -0
  50. package/dist/{chunk-m735gtc4.js → chunk-az1y9jks.js} +2 -2
  51. package/dist/chunk-b3mazye4.js +2 -0
  52. package/dist/chunk-b5cv9xp7.js +2852 -0
  53. package/dist/{chunk-dayjd2sj.js → chunk-b7p3yca7.js} +4 -4
  54. package/dist/chunk-bn6sarwd.js +2 -0
  55. package/dist/chunk-c7xt5gyb.js +2 -0
  56. package/dist/chunk-cac98pkx.js +2 -0
  57. package/dist/{chunk-q5w9cmr9.js → chunk-cbj2hmx5.js} +5 -5
  58. package/dist/chunk-czg6ewy3.js +2 -0
  59. package/dist/{chunk-sxpnpvt5.js → chunk-d1ya7f79.js} +4 -4
  60. package/dist/chunk-dcwmcqbr.js +2 -0
  61. package/dist/{chunk-19bhnbyn.js → chunk-dz4hrgw8.js} +83 -64
  62. package/dist/chunk-ed1qn902.js +2 -0
  63. package/dist/chunk-ev479f3z.js +2 -0
  64. package/dist/{chunk-x6pz1h3x.js → chunk-evs5gb3q.js} +10 -10
  65. package/dist/{chunk-w3c2c74q.js → chunk-fskpdva4.js} +46 -46
  66. package/dist/{chunk-5rtatjwq.js → chunk-gh34r6qb.js} +2 -2
  67. package/dist/chunk-gmg6aj7y.js +2 -0
  68. package/dist/{chunk-t455jpzx.js → chunk-h4ashx84.js} +1 -1
  69. package/dist/chunk-hc1m2psz.js +3 -0
  70. package/dist/{chunk-4hmdcmw1.js → chunk-hfe8g644.js} +6 -6
  71. package/dist/chunk-htaed68z.js +2 -0
  72. package/dist/{chunk-g8gzxhp8.js → chunk-j1rnhv0w.js} +3 -3
  73. package/dist/chunk-j2jm2nqz.js +2 -0
  74. package/dist/chunk-jb8d4n60.js +2 -0
  75. package/dist/{chunk-mktk70gq.js → chunk-k2nrx78c.js} +2 -2
  76. package/dist/chunk-kdnbxwkb.js +2 -0
  77. package/dist/{chunk-01hf94pa.js → chunk-kf2vas4j.js} +5 -5
  78. package/dist/chunk-kt5mzw2w.js +2 -0
  79. package/dist/chunk-kt994306.js +2 -0
  80. package/dist/{chunk-6qvskcwp.js → chunk-mer3aea0.js} +4 -4
  81. package/dist/chunk-mezphhpa.js +2 -0
  82. package/dist/{chunk-5wrmcbch.js → chunk-myhxapnn.js} +2 -2
  83. package/dist/chunk-n7d69a2q.js +2 -0
  84. package/dist/{chunk-z4te6223.js → chunk-nz6bzffm.js} +4 -4
  85. package/dist/{chunk-st71ar7s.js → chunk-pfas39mf.js} +9 -9
  86. package/dist/{chunk-j18z5nxq.js → chunk-phbnrw2h.js} +2 -2
  87. package/dist/{chunk-9g5sv1p6.js → chunk-q2p6y0cn.js} +7 -7
  88. package/dist/{chunk-6rxnh3th.js → chunk-qfppetcn.js} +1 -1
  89. package/dist/{chunk-wsbccxwy.js → chunk-qpbd2fwp.js} +9 -9
  90. package/dist/{chunk-y794qh69.js → chunk-qvqgbvfa.js} +6 -6
  91. package/dist/chunk-qz3tnvwm.js +2 -0
  92. package/dist/{chunk-dvbgbd06.js → chunk-rns21kkv.js} +2 -2
  93. package/dist/{chunk-08jyyegp.js → chunk-rq9cbw2y.js} +1 -1
  94. package/dist/{chunk-q7wj2ypd.js → chunk-s0ar60ng.js} +6 -6
  95. package/dist/chunk-sddytf9n.js +2 -0
  96. package/dist/chunk-spvr2vvh.js +2 -0
  97. package/dist/{chunk-0z189871.js → chunk-t84ww3qb.js} +2 -2
  98. package/dist/chunk-t91250ag.js +2 -0
  99. package/dist/{chunk-n8595zaf.js → chunk-tmbqz710.js} +1 -1
  100. package/dist/{chunk-hjp38m0w.js → chunk-tme29zh9.js} +2 -2
  101. package/dist/chunk-txkc9w9q.js +2 -0
  102. package/dist/chunk-ty1c2276.js +2 -0
  103. package/dist/{chunk-det49x62.js → chunk-v5500ews.js} +2 -2
  104. package/dist/chunk-vepjs3tg.js +2 -0
  105. package/dist/{chunk-v3anfm9d.js → chunk-vfbdxxbf.js} +2 -2
  106. package/dist/{chunk-7mehf3h5.js → chunk-w9c7z8p3.js} +2 -2
  107. package/dist/chunk-wfp754ya.js +2 -0
  108. package/dist/chunk-wp3qcfb4.js +3 -0
  109. package/dist/{chunk-ga48aas6.js → chunk-x17fpc0x.js} +6 -6
  110. package/dist/chunk-x3sbsxdq.js +2 -0
  111. package/dist/chunk-xdcvp8tt.js +2 -0
  112. package/dist/{chunk-ebkjpj5m.js → chunk-xh98er3b.js} +2 -2
  113. package/dist/{chunk-9z9f3d6b.js → chunk-xrj3tekf.js} +2 -2
  114. package/dist/chunk-xxnh7gv8.js +2 -0
  115. package/dist/{chunk-zswn0s45.js → chunk-y2t8xd39.js} +2 -2
  116. package/dist/chunk-y4egzqqf.js +2 -0
  117. package/dist/chunk-y4nm9wq4.js +2 -0
  118. package/dist/{chunk-ygkwp4sf.js → chunk-y5hdc1sb.js} +2 -2
  119. package/dist/chunk-ygx0akfn.js +2 -0
  120. package/dist/chunk-yn9fwnq2.js +2 -0
  121. package/dist/{chunk-3dcdgp1k.js → chunk-yq9rfnd6.js} +1 -1
  122. package/dist/chunk-z0gfb7b4.js +2 -0
  123. package/dist/chunk-z3e54btj.js +2 -0
  124. package/dist/{chunk-773vgw1k.js → chunk-z6fb4m1j.js} +3 -3
  125. package/dist/cli.js +21 -21
  126. package/dist/client/signals-class-runtime.js +1 -1
  127. package/dist/client/signals-component-hydration-runtime.js +1 -1
  128. package/dist/client/signals-component-props-runtime.js +3 -3
  129. package/dist/client/signals-container-cleanup-runtime.js +1 -1
  130. package/dist/client/signals-dom-ready-runtime.js +4 -4
  131. package/dist/client/signals-event-shorthand-runtime.js +2 -2
  132. package/dist/client/signals-expression-runtime.js +21 -2
  133. package/dist/client/signals-for-runtime.js +6 -6
  134. package/dist/client/signals-handler-runtime.js +1 -1
  135. package/dist/client/signals-hydration-audit-runtime.js +1 -1
  136. package/dist/client/signals-hydration-runtime.js +1 -1
  137. package/dist/client/signals-if-chain-runtime.js +3 -3
  138. package/dist/client/signals-if-runtime.js +7 -7
  139. package/dist/client/signals-lazy-hydration-runtime.js +1 -1
  140. package/dist/client/signals-manifest-hydration-runtime.js +1 -1
  141. package/dist/client/signals-model-runtime.js +1 -1
  142. package/dist/client/signals-mount-runtime.js +3 -3
  143. package/dist/client/signals-process-element-runtime.js +7 -7
  144. package/dist/client/signals-show-runtime.js +1 -1
  145. package/dist/client/signals-spa-load-runtime.js +5 -5
  146. package/dist/client/signals-style-runtime.js +1 -1
  147. package/dist/client-scope-bindings.d.ts +6 -0
  148. package/dist/client-scope-bindings.js +98 -0
  149. package/dist/client-script-bundler.js +9 -3
  150. package/dist/client-script.js +2 -1
  151. package/dist/craft-entry.js +2 -2
  152. package/dist/craft.js +2 -2
  153. package/dist/includes.js +4 -2
  154. package/dist/pwa.js +3 -3
  155. package/dist/signal-processing.d.ts +2 -6
  156. package/dist/signal-processing.js +4 -80
  157. package/dist/ssg.js +10 -10
  158. package/dist/utils.js +5 -3
  159. package/package.json +5 -5
  160. package/dist/chunk-0fgp13q4.js +0 -2
  161. package/dist/chunk-0v0q0960.js +0 -2
  162. package/dist/chunk-0xxjmnqc.js +0 -2
  163. package/dist/chunk-1peszdcc.js +0 -2
  164. package/dist/chunk-1v92x0we.js +0 -15
  165. package/dist/chunk-2340emvg.js +0 -2
  166. package/dist/chunk-2xy5p3n4.js +0 -2
  167. package/dist/chunk-6p57991f.js +0 -2
  168. package/dist/chunk-711zygzk.js +0 -2
  169. package/dist/chunk-74r2q9ab.js +0 -2
  170. package/dist/chunk-7h4mxhkh.js +0 -2
  171. package/dist/chunk-7zdefvrn.js +0 -2
  172. package/dist/chunk-847nyz30.js +0 -2
  173. package/dist/chunk-8898f767.js +0 -2
  174. package/dist/chunk-9c7wkq4t.js +0 -2
  175. package/dist/chunk-9g01gnz5.js +0 -6
  176. package/dist/chunk-9wbraw07.js +0 -2
  177. package/dist/chunk-apaqfgsx.js +0 -2
  178. package/dist/chunk-bdnahg9m.js +0 -2
  179. package/dist/chunk-bfste5zk.js +0 -2
  180. package/dist/chunk-by4ngspf.js +0 -4
  181. package/dist/chunk-c0yb755y.js +0 -2
  182. package/dist/chunk-chaee0vj.js +0 -2
  183. package/dist/chunk-cy1krwqy.js +0 -2
  184. package/dist/chunk-d57fh04e.js +0 -2
  185. package/dist/chunk-dcham5kg.js +0 -2
  186. package/dist/chunk-e876sg0j.js +0 -2
  187. package/dist/chunk-ekfmad19.js +0 -2
  188. package/dist/chunk-f0ghgkxs.js +0 -2
  189. package/dist/chunk-fnzv245x.js +0 -2
  190. package/dist/chunk-hjkm6k8c.js +0 -2
  191. package/dist/chunk-hpvkkke2.js +0 -2
  192. package/dist/chunk-jb683m9n.js +0 -2
  193. package/dist/chunk-jfqvmq5w.js +0 -2
  194. package/dist/chunk-k1vjhhd4.js +0 -2
  195. package/dist/chunk-k5kj93g7.js +0 -2
  196. package/dist/chunk-kp4j8vja.js +0 -2
  197. package/dist/chunk-mb8c650x.js +0 -2
  198. package/dist/chunk-mfcxhfhb.js +0 -2
  199. package/dist/chunk-mmqt6qkf.js +0 -2
  200. package/dist/chunk-n6ek151q.js +0 -2
  201. package/dist/chunk-ph3ttt90.js +0 -2
  202. package/dist/chunk-pk68a878.js +0 -2
  203. package/dist/chunk-ptas1qqx.js +0 -2850
  204. package/dist/chunk-pz5zh3tg.js +0 -2
  205. package/dist/chunk-q068mc46.js +0 -2
  206. package/dist/chunk-q4a2j4qr.js +0 -3
  207. package/dist/chunk-rfkrktt9.js +0 -2
  208. package/dist/chunk-rj0nyb2t.js +0 -2
  209. package/dist/chunk-smpyb21z.js +0 -2
  210. package/dist/chunk-swv69q75.js +0 -4
  211. package/dist/chunk-t9ww2z0r.js +0 -2
  212. package/dist/chunk-th9wcse5.js +0 -2
  213. package/dist/chunk-v1ck0wd3.js +0 -2
  214. package/dist/chunk-vgd3yq11.js +0 -3
  215. package/dist/chunk-w24zd7sj.js +0 -2
  216. package/dist/chunk-wfettff6.js +0 -2
  217. package/dist/chunk-xfvbm4pn.js +0 -2
  218. package/dist/chunk-z04480ar.js +0 -2
  219. package/dist/chunk-zemkt4kg.js +0 -2
package/dist/includes.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { extractExports as scopeExports, scopePropertyDescriptor } from "./client-scope-bindings.js";
1
2
  import { StxValidationError } from "./errors/types.js";
2
3
  import { validateClientScript } from "./script-validation.js";
3
4
  import { findSfcTemplateBlock } from "./sfc-template.js";
@@ -198,7 +199,7 @@ ${tail}})();
198
199
  `;
199
200
  }
200
201
  function buildScopeRegistrationTail(scriptContent, scopeId) {
201
- const scopeAssign = extractExports(scriptContent).split(",").map((s) => s.trim()).filter(Boolean).map((name) => ` try { __scopeRegistration[${JSON.stringify(name)}] = ${name}; } catch (e) { /* not actually top-level */ }`).join(`
202
+ const exportNames = extractExports(scriptContent).split(",").map((s) => s.trim()).filter(Boolean), mutable = new Set(scopeExports(scriptContent, !0).split(",").map((name) => name.trim())), scopeAssign = exportNames.map((name) => mutable.has(name) ? ` try { ${name}; Object.defineProperty(__scopeRegistration, ${JSON.stringify(name)}, ${scopePropertyDescriptor(name)}); } catch (e) { /* not actually top-level */ }` : ` try { __scopeRegistration[${JSON.stringify(name)}] = ${name}; } catch (e) { /* not actually top-level */ }`).join(`
202
203
  `);
203
204
  return `
204
205
  // Register scope variables for STX runtime
@@ -210,6 +211,7 @@ ${scopeAssign}
210
211
  // renamed declaration so it resolves to the component's value, not the
211
212
  // shadowing import. __stxScopeRenames is emitted by bundleClientScript.
212
213
  try { if (typeof __stxScopeRenames !== 'undefined' && __stxScopeRenames) { for (var __stxRK in __stxScopeRenames) __scopeRegistration[__stxRK] = __stxScopeRenames[__stxRK]; } } catch (e) { /* no renames */ }
214
+ if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeRegistration, Object.getOwnPropertyDescriptors(__stxLiveBindings));
213
215
  window.stx._scopes['${scopeId}'] = __scopeRegistration;
214
216
  `;
215
217
  }
@@ -728,7 +730,7 @@ ${scriptContent}`;
728
730
  const extraAttrs = scriptAttrs.replace(/\bclient\b/i, "").trim();
729
731
  signalScopeId = includeScopeId(includeFilePath, context);
730
732
  const resolvedContent = transformStoreImports(scriptContent), wrapped = transformScopedScript(resolvedContent, signalScopeId);
731
- if (/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=/.test(wrapped))
733
+ if (/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(wrapped))
732
734
  registersBindings = !0;
733
735
  preservedScript += `${vendorStyleTags}<script data-stx-scoped data-stx-run="always" data-stx-owner="${signalScopeId}"${extraAttrs ? ` ${extraAttrs}` : ""}>${wrapped}</script>
734
736
  `;
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{nr,Ue,ii,fc}from"./chunk-dayjd2sj.js";import{tr,cs,uc,dc,pc}from"./chunk-9g5sv1p6.js";import{ri,si,oi,cc,lc}from"./chunk-v3anfm9d.js";import{ue,_t,ls}from"./chunk-g8gzxhp8.js";import{ml,hl,yl,bl,Or,jd}from"./chunk-ygkwp4sf.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
- Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-pk68a878.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
2
+ import{rr,We,ai,gc}from"./chunk-b7p3yca7.js";import{nr,ls,dc,pc,fc}from"./chunk-q2p6y0cn.js";import{si,oi,ii,lc,uc}from"./chunk-vfbdxxbf.js";import{de,Et,us}from"./chunk-j1rnhv0w.js";import{ml,hl,yl,bl,Nr,jd}from"./chunk-y5hdc1sb.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
+ Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-wfp754ya.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8">
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
233
233
  }, 5000);
234
234
  </script>
235
235
  </body>
236
- </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ue(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=nr(n,t);if(a){let s=Ue(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return cs(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,si as auditBuildOutput,ri as auditConfig,re as buildPwaAssets,oi as calculateAuditResult,lc as formatAuditResult,ls as formatSize,j as generateManifest,_ as generateManifestJson,dc as generateManifestLink,F as generateOfflinePage,ue as generatePrecacheManifest,_t as generatePrecacheManifestJs,M as generatePwaIcons,tr as generatePwaTags,nr as generateServiceWorker,fc as generateServiceWorkerAuto,uc as generateSwRegistrationScript,pc as generateThemeColorMeta,N as getExpectedIconPaths,Ue as getServiceWorkerFileName,cs as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ii as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Or as pwaDirectives,ml as pwaInstallDirective,yl as pwaOfflineDirective,bl as pwaPushDirective,hl as pwaUpdateDirective,jd as registerPwaDirectives,cc as runPwaAudit,D as validateManifest};
236
+ </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=de(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=rr(n,t);if(a){let s=We(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return ls(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,oi as auditBuildOutput,si as auditConfig,re as buildPwaAssets,ii as calculateAuditResult,uc as formatAuditResult,us as formatSize,j as generateManifest,_ as generateManifestJson,pc as generateManifestLink,F as generateOfflinePage,de as generatePrecacheManifest,Et as generatePrecacheManifestJs,M as generatePwaIcons,nr as generatePwaTags,rr as generateServiceWorker,gc as generateServiceWorkerAuto,dc as generateSwRegistrationScript,fc as generateThemeColorMeta,N as getExpectedIconPaths,We as getServiceWorkerFileName,ls as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ai as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Nr as pwaDirectives,ml as pwaInstallDirective,yl as pwaOfflineDirective,bl as pwaPushDirective,hl as pwaUpdateDirective,jd as registerPwaDirectives,lc as runPwaAudit,D as validateManifest};
@@ -1,3 +1,4 @@
1
+ import { extractExports } from './client-scope-bindings';
1
2
  import type { StxOptions } from './types';
2
3
  /**
3
4
  * Drop cached script scans.
@@ -131,12 +132,6 @@ export declare function preEvalLiteralReactiveIfs(template: string): string;
131
132
  export declare function convertServerLoopAttributesToDirectives(template: string, context?: Record<string, any>): string;
132
133
  export declare function convertSignalLoopsToAttributes(template: string, context?: Record<string, any>): string;
133
134
  export declare function processScriptSetup(template: string, filePath?: string, serverData?: Record<string, unknown>, options?: { forceClientSetup?: boolean }): Promise<{ output: string, setupCode: string | null }>;
134
- /**
135
- * Extract exported variable names from setup script.
136
- * Returns variables that should be exposed to the template.
137
- * Only extracts TOP-LEVEL declarations, not variables inside nested functions.
138
- */
139
- export declare function extractExports(setupContent: string): string;
140
135
  /**
141
136
  * Main orchestrator for signal processing.
142
137
  *
@@ -224,3 +219,4 @@ export declare interface ParsedLoopExpression {
224
219
  itemVar: string | null
225
220
  indexVar: string | null
226
221
  }
222
+ export { extractExports } from './client-scope-bindings';
@@ -9,6 +9,8 @@ import { evictOldest, matchScriptElement, scanAtElementPosition } from "./html-m
9
9
  import { importOnce } from "./lazy-module.js";
10
10
  import { findBodyOpenTag } from "./find-body-tag.js";
11
11
  import { stripCommentsAndLiterals } from "./strip-literals.js";
12
+ import { extractExports, scopeObject } from "./client-scope-bindings.js";
13
+ export { extractExports } from "./client-scope-bindings.js";
12
14
  let signalSetupCounter = 0;
13
15
  const TAG_ATTR_RUN = `(?:"[^"]*"|'[^']*'|[^>"'])*`, SINGLE_ELEMENT_RE = /^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s, SCRIPT_SCAN_CACHE_MIN_BYTES = 65536, SCRIPT_SCAN_CACHE_MAX_ENTRIES = 4, scriptScanCache = new Map;
14
16
  export function clearScriptScanCache() {
@@ -849,96 +851,18 @@ ${resolved}`);
849
851
 
850
852
  `);
851
853
  mergedContent = dedupeTopLevelDeclarations(mergedContent);
852
- const mergedExports = extractExports(mergedContent), mergedExportNames = mergedExports.split(",").map((name) => name.trim()).filter(Boolean), bridge = generateServerDataBridge(mergedContent, serverData), setupCode = `
854
+ const mergedExportNames = extractExports(mergedContent).split(",").map((name) => name.trim()).filter(Boolean), bridge = generateServerDataBridge(mergedContent, serverData), setupCode = `
853
855
  <script data-stx-scoped>
854
856
  function ${setupFnName}() {
855
857
  ${buildRuntimeGlobalsDestructure("const", mergedExportNames)}
856
858
  ${escapeScriptBody(`${bridge}${mergedContent}`)}
857
- return { ${mergedExports} };
859
+ return ${scopeObject(mergedContent, mergedExportNames)};
858
860
  }
859
861
  window.__stx_latestSetup=${setupFnName};
860
862
  if(window.stx)window.stx._latestSetup=${setupFnName};
861
863
  </script>`, markerAt = findSetupMarkerInsertion(template, signalScripts);
862
864
  return { output: rebuildSetupOwner(template, signalScripts, markerAt, setupFnName), setupCode };
863
865
  }
864
- export function extractExports(setupContent) {
865
- const code = stripCommentsAndLiterals(setupContent), names = [], seen = new Set;
866
- let depth = 0, i = 0;
867
- const len = code.length, checkDeclaration = () => {
868
- if (depth !== 0)
869
- return;
870
- const declMatch = code.slice(i).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);
871
- if (declMatch) {
872
- const varName = declMatch[2];
873
- if (!seen.has(varName)) {
874
- names.push(varName);
875
- seen.add(varName);
876
- }
877
- return;
878
- }
879
- const destructMatch = code.slice(i).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);
880
- if (destructMatch) {
881
- destructMatch[1].split(",").forEach((s) => {
882
- const trimmed = s.trim();
883
- if (!trimmed)
884
- return;
885
- const colonIdx = trimmed.indexOf(":"), name = (colonIdx >= 0 ? trimmed.slice(colonIdx + 1).trim() : trimmed).split(/[\s=]/)[0];
886
- if (name && !seen.has(name)) {
887
- names.push(name);
888
- seen.add(name);
889
- }
890
- });
891
- return;
892
- }
893
- const arrayDestructMatch = code.slice(i).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);
894
- if (arrayDestructMatch) {
895
- arrayDestructMatch[1].split(",").forEach((s) => {
896
- const trimmed = s.trim().replace(/^\.\.\./, "");
897
- if (!trimmed)
898
- return;
899
- const name = trimmed.split(/[\s=]/)[0];
900
- if (name && !seen.has(name)) {
901
- names.push(name);
902
- seen.add(name);
903
- }
904
- });
905
- return;
906
- }
907
- const funcMatch = code.slice(i).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);
908
- if (funcMatch) {
909
- const funcName = funcMatch[1];
910
- if (!seen.has(funcName)) {
911
- names.push(funcName);
912
- seen.add(funcName);
913
- }
914
- return;
915
- }
916
- const asyncMatch = code.slice(i).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);
917
- if (asyncMatch) {
918
- const funcName = asyncMatch[1];
919
- if (!seen.has(funcName)) {
920
- names.push(funcName);
921
- seen.add(funcName);
922
- }
923
- }
924
- };
925
- while (i < len) {
926
- if (code[i] === "{") {
927
- depth++;
928
- i++;
929
- continue;
930
- }
931
- if (code[i] === "}") {
932
- depth--;
933
- i++;
934
- continue;
935
- }
936
- if (depth === 0 && /[a-z]/i.test(code[i]) && (i === 0 || /\s|[;{}()]/.test(code[i - 1])))
937
- checkDeclaration();
938
- i++;
939
- }
940
- return names.join(", ");
941
- }
942
866
  export async function processSignals(template, options, filePath, serverData) {
943
867
  if (!hasSignalsSyntax(template, filePath))
944
868
  return template;
package/dist/ssg.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-5rtatjwq.js";import"./chunk-1gtrs8va.js";import"./chunk-10s16tad.js";import{dt,pt,ft,gt,mt,ht}from"./chunk-sxpnpvt5.js";import"./chunk-dvbgbd06.js";import"./chunk-66e4ga0z.js";import{f,Xe,L,Z,n,o}from"./chunk-ptas1qqx.js";import"./chunk-x6pz1h3x.js";import{xr}from"./chunk-khzyc41k.js";import"./chunk-gc1dzxee.js";import"./chunk-hb46a5rr.js";import"./chunk-jp6yn9mj.js";import"./chunk-z4te6223.js";import"./chunk-9g01gnz5.js";import{de,Et,Tt}from"./chunk-1v92x0we.js";import{ei,ti,ni}from"./chunk-773vgw1k.js";import{Ct,fn,gn}from"./chunk-hjp38m0w.js";import"./chunk-n5xbv1a9.js";import{a}from"./chunk-q4a2j4qr.js";import x from"fs";import g from"path";import{createHash as bt}from"crypto";function Pt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var $t=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Dt(t){return Bun.hash(t).toString(16)}function it(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace($t,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Pt(h);let S=Dt(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${bt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Rt=new Set(["visible","idle"]);function st(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Rt.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var kt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function It(t){for(let i of kt){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function at(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function Bt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=at(e.default??e);if(l)return l}catch{}}return null}async function ot(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=at(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await Bt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=It(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ct(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
2
+ import"./chunk-gh34r6qb.js";import"./chunk-9b4e815s.js";import"./chunk-2wvz3fd2.js";import{pt,ft,gt,mt,ht,yt}from"./chunk-d1ya7f79.js";import"./chunk-rns21kkv.js";import"./chunk-4fv3jq16.js";import{f,Je,j,Q,n,o}from"./chunk-b5cv9xp7.js";import"./chunk-evs5gb3q.js";import{Sr}from"./chunk-7ky2ny63.js";import"./chunk-3p2b88pd.js";import"./chunk-70npkeh2.js";import"./chunk-1ma56c2h.js";import"./chunk-nz6bzffm.js";import"./chunk-1e25xd0z.js";import{pe,Tt,$t}from"./chunk-05zhvg8t.js";import{ti,ni,ri}from"./chunk-z6fb4m1j.js";import{Ct,gn,mn}from"./chunk-tme29zh9.js";import"./chunk-62kxavc5.js";import{a}from"./chunk-wp3qcfb4.js";import x from"fs";import g from"path";import{createHash as bt}from"crypto";function Pt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Dt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Rt(t){return Bun.hash(t).toString(16)}function it(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(Dt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Pt(h);let S=Rt(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${bt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var kt=new Set(["visible","idle"]);function st(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(kt.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var Et=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function It(t){for(let i of Et){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function at(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function Bt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=at(e.default??e);if(l)return l}catch{}}return null}async function ot(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=at(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await Bt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=It(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ct(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
3
  `)}class lt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class ut{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function jt(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
4
4
  return (async function getStaticPaths() {
5
5
  ${c[1]}
@@ -8,10 +8,10 @@ import"./chunk-5rtatjwq.js";import"./chunk-1gtrs8va.js";import"./chunk-10s16tad.
8
8
  return (async function getStaticProps() {
9
9
  ${e[1]}
10
10
  })()
11
- `)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function wt(t,i,s={},r,c){let e=await Bun.file(t.filePath).text(),l=await Ot(t.filePath),w=await At(e,i,t.filePath),y={...l||{},...w||{},...s,params:i,$route:{path:t.pattern,params:i}},h=new Set,S=[],P=[],D={...c,...r.partialsDir?{partialsDir:r.partialsDir}:{},...r.componentsDir?{componentsDir:r.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(b)=>{S.push(`${g.relative(process.cwd(),b.templatePath)}: ${b.message}
12
- resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(Lt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of de(b))h.add(B);if(Object.keys(i).length>0){let b=`<script>if(window.stx)window.stx._rp=${JSON.stringify(i)};else window.__stx_rp=${JSON.stringify(i)};</script>`;if(p.includes("</head>"))p=p.replace("</head>",`${b}
11
+ `)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function dt(t,i,s={},r,c){let e=await Bun.file(t.filePath).text(),l=await Ot(t.filePath),w=await At(e,i,t.filePath),y={...l||{},...w||{},...s,params:i,$route:{path:t.pattern,params:i}},h=new Set,S=[],P=[],D={...c,...r.partialsDir?{partialsDir:r.partialsDir}:{},...r.componentsDir?{componentsDir:r.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(b)=>{S.push(`${g.relative(process.cwd(),b.templatePath)}: ${b.message}
12
+ resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(Lt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of pe(b))h.add(B);if(Object.keys(i).length>0){let b=`<script>if(window.stx)window.stx._rp=${JSON.stringify(i)};else window.__stx_rp=${JSON.stringify(i)};</script>`;if(p.includes("</head>"))p=p.replace("</head>",`${b}
13
13
  </head>`);else p=`${b}
14
- ${p}`}if(p=await Z(p,{router:r.router}),p=await f(p),r.minify!==!1)return{html:Mt(p),dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P};return{html:p,dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P}}function Mt(t){let i=[],s=0,r=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=r.exec(t))!==null){let l=t.slice(s,c.index);i.push(l.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let w=c[1],y=c[2],h=c[3];y=y.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),i.push(w+y+h),s=c.index+c[0].length}let e=t.slice(s);return i.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),i.join("").trim()}function Ut(t){let i=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);i=(i<<5)-i+r,i=i&i}return`"${Math.abs(i).toString(36)}"`}function _t(t,i,s,r){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(i))return!0;return r.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Gt(t,i){return`<?xml version="1.0" encoding="UTF-8"?>
14
+ ${p}`}if(p=await Q(p,{router:r.router}),p=await f(p),r.minify!==!1)return{html:Mt(p),dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P};return{html:p,dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P}}function Mt(t){let i=[],s=0,r=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=r.exec(t))!==null){let l=t.slice(s,c.index);i.push(l.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let w=c[1],y=c[2],h=c[3];y=y.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),i.push(w+y+h),s=c.index+c[0].length}let e=t.slice(s);return i.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),i.join("").trim()}function Ut(t){let i=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);i=(i<<5)-i+r,i=i&i}return`"${Math.abs(i).toString(36)}"`}function _t(t,i,s,r){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(i))return!0;return r.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Gt(t,i){return`<?xml version="1.0" encoding="UTF-8"?>
15
15
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
16
16
  ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
17
17
  <loc>${I(c)}</loc>`;if(r.lastmod)e+=`
@@ -41,16 +41,16 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
41
41
  ${s.join(`
42
42
  `)}
43
43
  </channel>
44
- </rss>`}async function zt(t={}){let i=Date.now();Tt();let s=await o(process.cwd()),r=s.build||{},c=await ot({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ct());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-bdnahg9m.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-jb683m9n.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new lt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-bdnahg9m.js");await u('<div class="bg-black"></div>')}catch{}dt();let yt=s?.routeMiddleware?.dir||"middleware";await ft(process.cwd(),yt);let H=pt();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let St=s?.routeMiddleware?.global||[];ni(s?.layoutsDir,a(process.cwd()));let V=L(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${V.length} routes`);let G=[];for(let u of V){let m=await Ft(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],K=[];for(let u=0;u<G.length;u+=e.concurrency)K.push(G.slice(u,u+e.concurrency));for(let u of K)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:M,props:xt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),vt=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...St,...vt];if(tt.length>0){let C=gt(d,M,F||{}),O=mt(C,null,void 0,{isServer:!0}),E=await ht(tt,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,_),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(_),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
44
+ </rss>`}async function zt(t={}){let i=Date.now();$t();let s=await o(process.cwd()),r=s.build||{},c=await ot({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ct());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-t91250ag.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-aq02drjz.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new lt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-t91250ag.js");await u('<div class="bg-black"></div>')}catch{}pt();let wt=s?.routeMiddleware?.dir||"middleware";await gt(process.cwd(),wt);let H=ft();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let St=s?.routeMiddleware?.global||[];ri(s?.layoutsDir,a(process.cwd()));let V=j(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${V.length} routes`);let G=[];for(let u of V){let m=await Ft(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let L=[],K=[];for(let u=0;u<G.length;u+=e.concurrency)K.push(G.slice(u,u+e.concurrency));for(let u of K)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:M,props:xt,revalidate:Z}=m;try{await e.hooks.onPageStart?.(d);let F=await Bun.file(v.filePath).text(),O=Jt(F),vt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],tt=[...St,...vt];if(tt.length>0){let C=mt(d,M,O||{}),T=ht(C,null,void 0,{isServer:!0}),E=await yt(tt,T);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),A=Kt(d,e);await x.promises.mkdir(g.dirname(A),{recursive:!0}),await Bun.write(A,_),l.successCount++,l.pages.push({route:d,outputPath:A,size:Buffer.byteLength(_),cached:!1}),L.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=F.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
45
45
  const validate = ${et[1]};
46
46
  return validate(route);
47
- `)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,rt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)rt=!0,l.cachedCount++}if(!k){let C=await wt(v,M,xt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
47
+ `)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,rt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)rt=!0,l.cachedCount++}if(!k){let C=await dt(v,M,xt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
48
48
  ${C.includeFailures.join(`
49
49
  `)}
50
50
  Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&C.serverScriptFailures.length>0)throw Error(`${C.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
51
51
  ${C.serverScriptFailures.join(`
52
52
  `)}
53
- Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let U;if(e.trailingSlash)U=g.join(e.outputDir,d,"index.html");else U=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:O}=it(k,{integrity:e.integrityIslands,minify:e.minify});if(O.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of O){let _=g.join(E,`${R.hash}.js`);if(!await Bun.file(_).exists())await Bun.write(_,R.code);if(!w.has(R.hash)){w.add(R.hash);let T=Buffer.byteLength(R.code,"utf8");y+=T,h[R.hash]={bytes:T,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=O.map((R)=>R.hash),k=C,e.prefetchIslands)k=st(k)}}if(await x.promises.mkdir(g.dirname(U),{recursive:!0}),await Bun.write(U,k),!_t(d,k,F,e.sitemapExclude))A.push({loc:d,lastmod:new Date().toISOString().split("T")[0],priority:d==="/"?1:0.8});let nt={route:d,outputPath:U,size:Buffer.byteLength(k,"utf8"),cached:rt};if(Q!==!1)nt.revalidateAt=Date.now()+Q*1000;l.pages.push(nt),l.successCount++,await e.hooks.onPageEnd?.(d,k)}catch(j){l.failedCount++,l.errors.push({route:d,error:j}),await e.hooks.onError?.(j,d),console.error(`Error generating ${d}:`,j)}}));let X=Et();if(X.length>0){let u=X.map((m)=>`${m.filePath}: ${m.message}`).join(`
53
+ Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let U;if(e.trailingSlash)U=g.join(e.outputDir,d,"index.html");else U=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:T}=it(k,{integrity:e.integrityIslands,minify:e.minify});if(T.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of T){let _=g.join(E,`${R.hash}.js`);if(!await Bun.file(_).exists())await Bun.write(_,R.code);if(!w.has(R.hash)){w.add(R.hash);let A=Buffer.byteLength(R.code,"utf8");y+=A,h[R.hash]={bytes:A,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=T.map((R)=>R.hash),k=C,e.prefetchIslands)k=st(k)}}if(await x.promises.mkdir(g.dirname(U),{recursive:!0}),await Bun.write(U,k),!_t(d,k,O,e.sitemapExclude))L.push({loc:d,lastmod:new Date().toISOString().split("T")[0],priority:d==="/"?1:0.8});let nt={route:d,outputPath:U,size:Buffer.byteLength(k,"utf8"),cached:rt};if(Z!==!1)nt.revalidateAt=Date.now()+Z*1000;l.pages.push(nt),l.successCount++,await e.hooks.onPageEnd?.(d,k)}catch(F){l.failedCount++,l.errors.push({route:d,error:F}),await e.hooks.onError?.(F,d),console.error(`Error generating ${d}:`,F)}}));let X=Tt();if(X.length>0){let u=X.map((m)=>`${m.filePath}: ${m.message}`).join(`
54
54
  `);throw Error(`Client script bundling failed:
55
55
  ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.stx");if(await Bun.file(u).exists()){let m=new Set,v={...s,debug:!1,cache:!1},d=await n(await Bun.file(u).text(),{},u,v,m);await Bun.write(g.join(e.outputDir,"404.html"),d)}else await Bun.write(g.join(e.outputDir,"404.html"),`<!DOCTYPE html>
56
56
  <html lang="en">
@@ -73,7 +73,7 @@ ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.
73
73
  <a href="/">Go home</a>
74
74
  </div>
75
75
  </body>
76
- </html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=xr({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let N=ei(e.outputDir);if(N.assets>0)console.log(`Externalized ${N.assets} asset(s) from ${N.pages} page(s) (${(N.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=ti(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await J(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Y=gn();if(Y)await J(Y,g.join(e.outputDir,fn)),console.log(`Copied assets from ${Ct}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
76
+ </html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&L.length>0){let u=Gt(L,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${L.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=Sr({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let N=ti(e.outputDir);if(N.assets>0)console.log(`Externalized ${N.assets} asset(s) from ${N.pages} page(s) (${(N.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=ni(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await J(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Y=mn();if(Y)await J(Y,g.join(e.outputDir,gn)),console.log(`Copied assets from ${Ct}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
77
77
  Island chunks: ${l.islandChunks.count} (${(l.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
78
78
  Build complete!
79
79
  Total: ${l.totalPages} pages
@@ -81,8 +81,8 @@ Build complete!
81
81
  Cached: ${l.cachedCount}
82
82
  Failed: ${l.failedCount}
83
83
  Time: ${l.buildTime}ms${P}
84
- `),l}async function J(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await J(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new ut(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=L(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await wt(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:Ut(S)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Wt(t){return async()=>({paths:await t(),fallback:!1})}function qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let i=await Bun.file(t).text(),s=i.match(/^---\n([\s\S]*?)\n---/),r={},c=i;if(s){let h=s[1];c=i.slice(s[0].length).trim();for(let S of h.split(`
85
- `)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return Xe(t)}function Vt(t,i){return`<!DOCTYPE html>
84
+ `),l}async function J(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await J(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new ut(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=j(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await dt(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:Ut(S)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Wt(t){return async()=>({paths:await t(),fallback:!1})}function qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let i=await Bun.file(t).text(),s=i.match(/^---\n([\s\S]*?)\n---/),r={},c=i;if(s){let h=s[1];c=i.slice(s[0].length).trim();for(let S of h.split(`
85
+ `)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return Je(t)}function Vt(t,i){return`<!DOCTYPE html>
86
86
  <html>
87
87
  <head>
88
88
  <meta charset="utf-8">
package/dist/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { extractExports as scopeExports, scopePropertyDescriptor } from "./client-scope-bindings.js";
1
2
  import { pascalToKebab } from "./component-resolution.js";
2
3
  import fs from "node:fs";
3
4
  import path from "node:path";
@@ -1337,7 +1338,7 @@ async function buildComponentIsland(rawContent, componentFilePath, minify) {
1337
1338
  }
1338
1339
  const { stripStxRuntimeImports } = await importOnce("stx/signal-processing", () => import("./signal-processing.js"));
1339
1340
  bundledContent = stripStxRuntimeImports(bundledContent);
1340
- const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), factoryBody = `function(__scopeId) {
1341
+ const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), mutableLocals = new Set(scopeExports(content, !0).split(",").map((name) => name.trim())), factoryBody = `function(__scopeId) {
1341
1342
  ${buildRuntimeGlobalsDestructure("const", [...COMPONENT_SCOPE_LOCAL_GLOBALS, ...componentLocalNames], content)}
1342
1343
  const __scope = window.stx._scopes = window.stx._scopes || {};
1343
1344
  const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
@@ -1395,11 +1396,12 @@ ${content}
1395
1396
  // Register all defined signals and functions in this scope
1396
1397
  const __localVars = {};
1397
1398
  try {
1398
- ${componentLocalNames.map((v) => `if (typeof ${v} !== 'undefined') __localVars['${v}'] = ${v};`).join(`
1399
+ ${componentLocalNames.map((v) => mutableLocals.has(v) ? `Object.defineProperty(__localVars, '${v}', ${scopePropertyDescriptor(v)});` : `if (typeof ${v} !== 'undefined') __localVars['${v}'] = ${v};`).join(`
1399
1400
  `)}
1400
1401
  }
1401
1402
  catch (e) {}
1402
- Object.assign(__scopeVars, __localVars);
1403
+ Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
1404
+ if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
1403
1405
  }
1404
1406
  finally {
1405
1407
  __registeringSetupHooks = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.630",
4
+ "version": "0.2.631",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -128,12 +128,12 @@
128
128
  "dependencies": {
129
129
  "@stacksjs/ts-css": "^0.3.11",
130
130
  "@stacksjs/clapp": "^0.2.16",
131
- "@stacksjs/desktop": "0.2.630",
132
- "@stacksjs/sanitizer": "0.2.630",
131
+ "@stacksjs/desktop": "0.2.631",
132
+ "@stacksjs/sanitizer": "0.2.631",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
- "bun-plugin-stx": "0.2.630",
134
+ "bun-plugin-stx": "0.2.631",
135
135
  "bunfig": "^0.15.21",
136
- "stx-router": "0.2.630",
136
+ "stx-router": "0.2.631",
137
137
  "ts-broadcasting": "^0.0.11",
138
138
  "ts-images": "^0.2.22",
139
139
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{hn,pe}from"./chunk-5rtatjwq.js";export{hn as describeBuildFailure,pe as formatBuildFailure};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{u,Is,Ri,Ai,Xc,Jc,Yc,Zc,Qc,el,tt,j,nt,tl,fr,nl,Ni,Fs,rt,r,gr,Di,g,oe,vd}from"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{oe as clearComponentCache,Fs as componentClientSignalNames,Is as convertToCommonJS,g as createDetailedErrorMessage,Qc as extractDirectiveNames,Ri as extractScriptFromTemplate,u as extractVariables,r as fileExists,vd as getComponentCacheStats,Jc as getPositionInfo,j as getSharedTranspiler,Di as getSourceLineInfo,Zc as hasDirectives,Ai as hasVariables,nl as isHydrateTrigger,el as isJavaScriptScript,rt as renderComponentWithSlot,gr as resolveTemplatePath,tl as scopeOnRootElement,tt as shouldTranspileTypeScript,Ni as slotContentHasExpressions,nt as transpileTypeScript,fr as userComponentFileExists,Yc as validateDirective,Xc as validateTemplate};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Go,Ko,Xo,Gu}from"./chunk-h9ymjtch.js";import"./chunk-q5w9cmr9.js";import"./chunk-jsw5yby0.js";import"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Go as buildNative,Gu as default,Xo as getAvailableFormats,Ko as getAvailableTargets};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{or,Sc,Zu,kc,Qu,Cc,ir,b,Dt,Ce,_c,ws,Ec,ed,Y,Tc,td,x,nd}from"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Tc as applyFilters,Qu as clearCustomFilters,_c as clientLoopScopes,or as defaultFilters,b as escapeHtml,Dt as escapeHtmlValue,x as evaluateExpression,Cc as findMustacheEnd,kc as getAllFilters,Ec as interpolateScriptAttributes,ws as interpolateScriptExpressions,ed as interpolateScriptsInTemplate,Y as processExpressions,Sc as registerFilter,Zu as registerFilters,ir as replaceInterpolations,td as resetRejectedExpressionWarnings,nd as unescapeHtml,Ce as usesSignalsInScript};
@@ -1,15 +0,0 @@
1
- // @bun
2
- import{hn,pe}from"./chunk-5rtatjwq.js";import{m,yn,sr,w,qe,o,P}from"./chunk-ptas1qqx.js";import{ms}from"./chunk-9g01gnz5.js";import{s,$e}from"./chunk-6qvskcwp.js";import{a}from"./chunk-q4a2j4qr.js";import d from"path";import S from"fs";import{AsyncLocalStorage as ft}from"async_hooks";var mt=10;function W(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||ms(t,e,n)}var rt=2;function gc(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):a(t,"bundle-cache")}function et(t,e){let n=d.resolve(e);return n===d.sep?t:t.split(n).join("\x00root")}function gt(t,e){try{let n=S.statSync(t),c=d.resolve(e),u=t.startsWith(`${c}${d.sep}`);return{path:u?d.relative(c,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(S.readFileSync(t)).toString(36)}}catch{return null}}function it(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function ht(t,e){for(let n of t){let c=it(n,e);try{let u=S.statSync(c);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(S.readFileSync(c)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ot=new Map,J=600,xt=100,V=new Map;async function yt(t){let e=V.get(t)??0;if(e>0&&e<xt){V.set(t,e+1);return}V.set(t,1);try{let n=(await S.promises.readdir(t)).filter((p)=>p.endsWith(".js"));if(n.length<=J)return;let u=(await Promise.all(n.map(async(p)=>{try{return{name:p,at:(await S.promises.stat(d.join(t,p))).mtimeMs}}catch{return null}}))).filter((p)=>p!==null);u.sort((p,l)=>l.at-p.at);for(let p of u.slice(J)){let l=p.name.slice(0,-3);await S.promises.rm(d.join(t,`${l}.js`),{force:!0}),await S.promises.rm(d.join(t,`${l}.deps.json`),{force:!0})}D("pruned bundle cache to",J,"entries")}catch{}}function de(t){return ot.get(t)??[]}function G(t,e){if(t)ot.set(t,e)}function mc(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function D(...t){if(mc())console.log("[stx:bundler]",...t)}var Z=[];function ai(t,e,n){Z.push({filePath:t||"<inline>",message:e,details:n})}function Et(){return Z.slice()}function Tt(){Z.length=0}var H;function Xu(t){H=t}function ci(){if(H)return H;try{let t=P.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function $t(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!q.some((l)=>l.test(u)))return D("detected user import:",u),!0}let c=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=c.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!q.some((l)=>l.test(u)))return D("detected side-effect import:",u),!0}return!1}var mn="stx-module:",bt=/\.(?:[cm]?[jt]sx?|json)$/i;function hc(t,e){return d.relative(t,e).split(d.sep).join("/")}function yc(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,c,u,p)=>{let l=e.get(p);return l&&!p.startsWith(mn)?`${c}${u}${l}${u}`:n})}function bc(t,e){let n=0,c=(p)=>{let l=`__stxMod${n++}`,E=JSON.stringify(p);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${E}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(E)} + " is not registered on this page (#1957)");`),l},u=(p,l)=>{for(let E of p.split(",")){let R=E.trim();if(!R)continue;let j=R.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let f=j[1].startsWith('"')?JSON.parse(j[1]):j[1],r=j[2]??f;e.push(`var ${r} = ${l}[${JSON.stringify(f)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,l,E)=>{let R=E.slice(mn.length),j=c(R),f=l.trim(),r=f.match(/^([\w$]+)\s*(?:,\s*|$)/);if(r&&!f.startsWith("{")&&!f.startsWith("*"))e.push(`var ${r[1]} = ${j}.default;`),f=f.slice(r[0].length).trim();let i=f.match(/^\*\s*as\s+([\w$]+)$/);if(i)e.push(`var ${i[1]} = ${j};`);else if(f.startsWith("{"))u(f.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,l)=>(c(l.slice(mn.length)),"")),t}function nt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(S.existsSync(n)&&S.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var Y=new ft;function us(t,e){let n=new Bun.CryptoHasher("md5");for(let[c,u]of[...t].sort(([p],[l])=>p<l?-1:p>l?1:0))n.update(`${c}\x00${u}\x00`);return Y.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Rt(){return Y.getStore()?.key??""}function wt(t,e,n,c,u,p=new Map,l,E){let R=(f,r,i)=>{if(W(r,t,l))return null;if(!u||f!==n||!bt.test(r))return null;try{if(!S.statSync(r,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(r);let x=`${mn}${hc(process.cwd(),r)}`;return p.set(i,x),{path:x,external:!0}},j=(f,r)=>{let i=f===n?e:d.dirname(f),x=d.resolve(i,r);return nt(x)??x};return{name:"stx-client-bundle",setup(f){if(f.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(r)=>({path:r.path,external:!0})),f.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(r)=>({path:r.path,external:!0})),f.onResolve({filter:/^\//},(r)=>{let i=nt(r.path);if(i){let x=R(r.importer,i,r.path);if(x)return x;if(i!==n)c.add(i);return{path:i}}return{path:r.path,external:!0}}),f.onResolve({filter:/^\.\.?\//},(r)=>{let i=j(r.importer,r.path),x=R(r.importer,i,r.path);if(x)return x;return c.add(i),{path:i}}),f.onResolve({filter:/^[@~]\//},(r)=>{let i=d.resolve(t,r.path.slice(2)),x=[i,`${i}.ts`,`${i}.tsx`,`${i}.js`,`${i}.mjs`,`${i}.jsx`,d.join(i,"index.ts"),d.join(i,"index.tsx"),d.join(i,"index.js"),d.join(i,"index.mjs")];for(let _ of x)if(S.existsSync(_)&&S.statSync(_,{throwIfNoEntry:!1})?.isFile()){let B=R(r.importer,_,r.path);if(B)return B;return D(`resolved ${r.path[0]}/ import:`,r.path,"\u2192",_),c.add(_),{path:_}}return console.warn(`[stx:bundler] could not resolve ${r.path[0]}/ import:`,r.path),{path:i}}),u)f.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(r)=>{if(r.importer!==n)return;let i=`${mn}npm:${r.path}`;return p.set(r.path,i),{path:i,external:!0}});f.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(r)=>{if(W(r.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${r.path}`);let i=d.extname(r.path).toLowerCase(),x=i===".json"?"json":i===".tsx"?"tsx":i===".jsx"?"jsx":i===".ts"||i===".mts"||i===".cts"?"ts":"js";if(r.path!==n)c.add(r.path);let _=E?.get(r.path);if(_!==void 0)return{contents:_,loader:"js"};return{contents:S.readFileSync(r.path,"utf8"),loader:x}})}}}var X=new Map,U=m(64),st=Symbol.for("stx.client-bundle-build-queue");function vc(t){let e=globalThis,c=(e[st]??Promise.resolve()).then(t,t);return e[st]=c.then(()=>{return},()=>{return}),c}async function At(t,e,n={}){let c=n.projectRoot||process.cwd(),u=(await o(c)).serverApi,p=n.minify??!1,l=n.externalizeUserModules??!0,E=n.expose?.length?[...new Set(n.expose)].sort():void 0,R=n.cacheDir||gc(c),j=Y.getStore(),f=new Bun.CryptoHasher("md5");f.update(`${mt}\x00${qe()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${E?E.join(","):"*"}\x00${p?"minified":"readable"}\x00${j?.key??""}\x00${et(t,c)}\x00${et(e,c)}`);let r=f.digest("hex").slice(0,12),i=d.join(R,`${r}.js`),x=U.get(i);if(x){if(sr(x.files)&&x.files.every((M)=>!W(M.path,c,u))){D("memo hit:",r);let M=x.files.map((N)=>N.path);return G(e,M),n.collectInputs?.push(...M),x.code}U.delete(i),D("memo invalidated by dep change:",r)}let _=d.join(R,`${r}.deps.json`),B=Bun.file(i);if(await B.exists()){let M=Bun.file(_),N=!1,C=null;if(await M.exists())try{let F=JSON.parse(await M.text());if(F.metadataVersion===rt&&Array.isArray(F.files)&&ht(F.files,c))C=yn(F.files.map((g)=>it(g,c))),N=C.length===F.files.length&&!C.some((g)=>W(g.path,c,u))}catch{N=!1}if(N){if(D("cache hit:",r),C)G(e,C.map((g)=>g.path)),n.collectInputs?.push(...C.map((g)=>g.path));let F=await B.text();if(C)U.set(i,{code:F,files:C});return F}D("cache invalidated by dep change:",r)}let k=X.get(r);if(k){let M=await k;if(n.collectInputs)n.collectInputs.push(...(U.get(i)?.files??[]).map((N)=>N.path));return M}let L=vc(()=>vt(t,e,{projectRoot:c,minify:p,cacheDir:R,hash:r,cachePath:i,depsPath:_,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:E,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));X.set(r,L);try{return await L}finally{X.delete(r)}}var St=0;function wc(t){return`${t}-${process.pid}-${++St}`}async function vt(t,e,n){let{projectRoot:c,minify:u,cacheDir:p,hash:l,cachePath:E,depsPath:R,externalizeUserModules:j}=n,f=a(c,"bundle-tmp"),r=wc(l),i=d.join(f,`${r}.ts`),x=d.join(f,"out",r);S.mkdirSync(f,{recursive:!0}),S.mkdirSync(x,{recursive:!0});let _=d.dirname(e),B=new Set,k=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,L=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=s(t),{depths:N,balanced:C}=$e(M),F=(v)=>!C||N[v]===0,g;while((g=k.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;if(g[2])g[2].split(",").forEach((v)=>{let h=jt(v);if(h)B.add(h)});else if(g[3])B.add(g[3])}while((g=L.exec(M))!==null){if(g[1])continue;if(!F(g.index))continue;B.add(g[2])}let at=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=at.exec(M))!==null){if(!F(g.index))continue;let v=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(v&&q.some((h)=>h.test(v)))continue;if(g[1])B.add(g[1]);if(g[2])B.add(g[2]);for(let h of(g[3]??"").split(",")){let b=h.trim();if(!b||/^type\s/.test(b))continue;let O=/\bas\s+(\w+)\s*$/.exec(b)?.[1]??/^\w+$/.exec(b)?.[0];if(O)B.add(O)}}for(let v of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let h of v[1].split(",")){let b=/\bas\s+(\w+)\s*$/.exec(h)?.[1]??/^\s*(\w+)\s*$/.exec(h)?.[1];if(b)B.delete(b)}let ct=B.size>0?`
3
- export { ${[...B].join(", ")} }`:"";await Bun.write(i,t+ct),D("bundling:",l,"from:",d.basename(e));let Q=new Set,K=new Map;try{let v=await Bun.build({entrypoints:[i],outdir:x,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[wt(c,_,i,Q,j,K,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...w()},root:c});if(!v.success){let I=v.logs.filter((A)=>A.level==="error").map((A)=>A.message).join(", ")||`Unable to bundle ${d.basename(e)}`,T=hn(v.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",I),ai(e||"",I,T),n.throwOnFailure||ci()==="error")throw Error(I);return t}let h="";for(let y of v.outputs){h=await y.text();break}let b=[];for(let y of h.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of y[1].split(",")){let T=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(T){b.push([T[2],T[1]]);continue}let A=I.trim();if(/^[A-Za-z_$][\w$]*$/.test(A))b.push([A,A])}if(n.expose){let y=new Set(n.expose);for(let I=b.length-1;I>=0;I--)if(!y.has(b[I][0]))b.splice(I,1)}let O=[];h=bc(yc(h,K),O);let lt=h.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(h=h.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&h)try{h=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(h)}catch{}let tt=`__stxBundle_${l}`,ut=b.map(([y,I])=>`${JSON.stringify(y)}: ${I}`).join(", "),dt=b.map(([y])=>`var ${y} = undefined;`).join(`
4
- `),pt=b.map(([y])=>`${y} = ${tt}[${JSON.stringify(y)}];`).join(`
5
- `);if(h=`${lt.join(`
6
- `)}
7
- ${dt}
8
- var ${tt} = (function() {
9
- ${O.join(`
10
- `)}
11
- ${h}
12
- return { ${ut} };
13
- })();
14
- ${pt}`.trim(),D("bundled:",l,"output:",h.length,"bytes"),B.size>0&&b.length===0)return console.warn(`[stx:bundler] dropped every binding for ${d.basename(e)} (${l}); serving the unbundled source and not caching this result`),t;S.mkdirSync(p,{recursive:!0}),await Bun.write(E,h);let z=yn(Q);return await Bun.write(R,JSON.stringify({metadataVersion:rt,files:z.map((y)=>gt(y.path,c)).filter((y)=>y!==null)})),G(e,z.map((y)=>y.path)),n.collectInputs?.push(...z.map((y)=>y.path)),U.set(E,{code:h,files:z}),await yt(p),h}catch(v){let h=hn(v,e||void 0),b=pe(v,e||void 0);if(console.warn(`[stx:bundler] error: ${b}`),ai(e||"",b,h),n.throwOnFailure||ci()==="error")throw v;return t}finally{try{S.rmSync(i,{force:!0}),S.rmSync(x,{recursive:!0,force:!0})}catch{}}}function jt(t){let e=t.trim();if(!e)return null;let n=e.indexOf("=");if(n!==-1)e=e.slice(0,n).trim();let c=e.indexOf(":");if(c!==-1)e=e.slice(c+1).trim();if(e.startsWith("..."))e=e.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(e)?e:null}
15
- export{gc,de,mc,ai,Et,Tt,Xu,ci,$t,mn,hc,yc,bc,us,Rt,vc,At,wc};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ga,ko,ma,ha,Co,ya,ba,va,wa,_o,xa,kl}from"./chunk-h431swg6.js";import{Do,Ta}from"./chunk-5wrmcbch.js";import{B,F,z,Jt,ee,le,Jn,Fe,St,Yt,Zt,Qt,H,en,tn,Yn}from"./chunk-ebkjpj5m.js";import{sc}from"./chunk-7mehf3h5.js";import"./chunk-jsw5yby0.js";export{F as DEFAULT_FORMATS,z as DEFAULT_QUALITY,B as DEFAULT_WIDTHS,Yn as ImageProcessingError,ha as clearImageCache,Co as createImageDirective,Ta as createImageHandler,ba as createImagePlugin,kl as defaultImageConfig,tn as formatSize,_o as generateImageManifest,St as generateSizes,Fe as generateSrcSet,Yt as getFallbackVariant,Jn as getImageMetadata,H as getMimeType,en as getTotalSize,Zt as groupVariantsByFormat,Do as handleImageRequest,ya as imageDirective,ee as isImageBackendAvailable,Qt as isImageFile,Jt as isSharpAvailable,wa as optimizeDirectory,va as optimizeImage,ko as parseImageComponent,le as processImage,ma as processImageComponents,ga as renderImageComponent,sc as rewriteImagesWithSiblings,xa as writeImageManifest};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{J,hs,ys,xc,Ot,li,bs,ui,Yu,Se,bn,ke}from"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import{zi,s}from"./chunk-6qvskcwp.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{J as BROWSER_CORE_IMPORTS,xc as STX_AUTO_IMPORTS,hs as extractAndStripCssImports,Se as extractBridgeData,zi as findInterpolationEnd,ui as generateAutoImportDestructuring,Yu as generateBrowserAutoImportDestructuring,bn as generateServerDataBridge,Ot as injectBrowserCoreAutoImports,ke as processClientScript,bs as referencesName,ys as renderVendorStyleTags,s as stripCommentsAndLiterals,li as transformAutoImports};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{qe,$c,rd,sd,od,id,Rc,Ac,ad,cd,gi,ld,vn,wn,ar}from"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{id as __setSignalsGeneratorsForTest,qe as cacheEngineFingerprint,wn as cacheTemplate,vn as checkCache,ld as clearDevCaches,Ac as getCachedRouterScript,Rc as getCachedSignalsRuntime,ad as getServeClientAsset,gi as getServeModuleBundle,ar as hashFilePath,sd as invalidateFileCache,od as invalidateFileCacheByDir,rd as readFileCached,cd as registerServeModuleBundle,$c as templateCache};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Pt,ds,ps,gs,Ju,ms}from"./chunk-9g01gnz5.js";import"./chunk-z4te6223.js";import"./chunk-gc1dzxee.js";import"./chunk-sxpnpvt5.js";export{ps as buildServerApi,Ju as createServerApi,Pt as discoverServerApi,ds as generateApiTypes,ms as isServerApiSource,gs as productionApiDispatcher};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Pu,Ho,oc,Iu,Ou,Nu,Du,Mu,ic,ac,Lu,ju,Bu,Fu}from"./chunk-y794qh69.js";import"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{oc as SUSPENSE_RESOLVER_RUNTIME,Ho as buildSuspenseResolveScript,Mu as createStreamRenderer,Nu as extractStreamBoundaries,Fu as generateHydrationRuntime,ac as islandDirective,ju as processSectionDirectives,Ou as processStreamDirectives,Lu as registerStreamingDirectives,Iu as renderStreamingPage,Pu as streamTemplate,Du as streamTemplateSimple,Bu as streamToResponse,ic as streamingSuspenseDirective};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Gr,Kr,Xr,Ia,Oa,Na,Lo,Da,Ma}from"./chunk-q35z0cyg.js";export{Gr as ImageProcessorCache,Lo as applyTransformations,Ia as clearImageCache,Da as generateResponsiveVariants,Ma as generateSrcset,Kr as getCachedImageResult,Na as optimizeImage,Oa as processImage,Xr as setCachedImageResult};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Mo,zl}from"./chunk-n8595zaf.js";export{Mo as definePlugin,zl as pluginManager};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{A,rl,zs,o,P,wd,xd}from"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{P as config,A as defaultConfig,wd as defineStxConfig,zs as discoverConfig,o as loadStxConfig,rl as resolveStxDirectories,xd as validateConfig};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{zo,ec,on,eu,tc,nc,rc,tu}from"./chunk-5m0r0j79.js";export{on as Validator,ec as defineForm,tc as processErrorDirective,nc as processErrorsDirective,tu as processFormValidationDirectives,rc as processHasErrorsDirective,zo as useForm,eu as v};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Nt,Os,Pi,Gc}from"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Gc as declareBareLoopHead,Nt as parseLoopBinding,Pi as processLoops,Os as reportDeferredLoopWarnings};
@@ -1,6 +0,0 @@
1
- // @bun
2
- import{Q}from"./chunk-sxpnpvt5.js";import{ye,C}from"./chunk-gc1dzxee.js";import{Hi}from"./chunk-z4te6223.js";import{a}from"./chunk-q4a2j4qr.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function Pt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function ds(s,l){let o=a(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:p}=Q(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
3
- `);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function ps(s,l,o={}){let i=Pt(s,o);await ds(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
4
- `)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...Q(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function gs(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function Ju(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Pt(s,o);return await ds(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Pt(s,o);await ds(s,t);let{loadStxConfig:e}=await import("./chunk-847nyz30.js"),p=C((await e(s)).runtimeConfig);return await ye(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
5
- `));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function ms(s,l,o){if(Hi(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
6
- export{Pt,ds,ps,gs,Ju,ms};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ye,zt,br,Ws,C,ot}from"./chunk-gc1dzxee.js";export{zt as currentRuntimeConfig,ot as injectRuntimeConfig,C as resolveRuntimeConfig,Ws as useRuntimeConfig,br as useServerRuntimeConfig,ye as withRuntimeConfig};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Cn,Mc,Ts}from"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import{Pe}from"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Pe as freeIdentifiers,Ts as processComponents,Mc as processESImports,Cn as rendersAsElement};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ud,mi,dd,hi,Pc,Ic,Lt,kn,pd,Oc,Nc,fd,f}from"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Lt as buildCss,Oc as extractClassNames,Ic as fingerprintConfig,Nc as generateCss,pd as getCachedCSS,ud as getCssServeAsset,f as injectCss,mi as loadCssEngine,hi as loadCssEngineConfig,kn as rebuildCss,dd as resetCssCache,Pc as resolveUserCssConfig,fd as withLinkedModuleBundles};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Fl}from"./chunk-3dcdgp1k.js";import"./chunk-ptas1qqx.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-hb46a5rr.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Fl as buildApp};