@stacksjs/stx 0.2.794 → 0.2.798

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 (247) hide show
  1. package/dist/{chunk-d6arvs57.js → chunk-0beyn8ak.js} +5 -5
  2. package/dist/{chunk-5a92srn2.js → chunk-0gsq8gps.js} +1 -1
  3. package/dist/chunk-0xnvjw7s.js +2 -0
  4. package/dist/chunk-1wyccmsr.js +2 -0
  5. package/dist/{chunk-7pk3t82j.js → chunk-20yz8bjp.js} +2 -2
  6. package/dist/{chunk-h0jnatd4.js → chunk-2ws2qe1k.js} +2 -2
  7. package/dist/{chunk-ssh2gycr.js → chunk-2z2bq2at.js} +3 -3
  8. package/dist/chunk-31qjy9xr.js +2 -0
  9. package/dist/chunk-33devn0s.js +2 -0
  10. package/dist/{chunk-c0ejyxfj.js → chunk-33vr7x2t.js} +3 -3
  11. package/dist/chunk-33wpv2n1.js +2 -0
  12. package/dist/{chunk-wk6xsyv3.js → chunk-3mby4nes.js} +3 -3
  13. package/dist/chunk-3p5gxc6t.js +2 -0
  14. package/dist/{chunk-j6255z7f.js → chunk-3x598qjt.js} +4 -4
  15. package/dist/chunk-4hgz9dkv.js +2 -0
  16. package/dist/{chunk-rrb9m2q2.js → chunk-4sesw88b.js} +5 -5
  17. package/dist/{chunk-94gyfwpz.js → chunk-4v50nafp.js} +14 -14
  18. package/dist/chunk-5kc9kjaa.js +2 -0
  19. package/dist/{chunk-vav9ktgm.js → chunk-5wwcgze3.js} +2 -2
  20. package/dist/chunk-5xd53dwe.js +2 -0
  21. package/dist/chunk-5y6518h8.js +2 -0
  22. package/dist/chunk-5y77pe7b.js +2 -0
  23. package/dist/chunk-6a97a9wk.js +2 -0
  24. package/dist/{chunk-5j619xgb.js → chunk-6b5zhtb3.js} +2 -2
  25. package/dist/chunk-6hre8cg4.js +2 -0
  26. package/dist/{chunk-4s5q1aea.js → chunk-6m4y5dh5.js} +6 -6
  27. package/dist/chunk-6pyweb05.js +2 -0
  28. package/dist/chunk-6tp7ys77.js +2 -0
  29. package/dist/chunk-6zxzr20d.js +2 -0
  30. package/dist/chunk-75ctpxr3.js +2 -0
  31. package/dist/{chunk-w9nwb8r3.js → chunk-7bxnjr3b.js} +7 -7
  32. package/dist/chunk-7gw96jpj.js +2 -0
  33. package/dist/chunk-7m4eesp0.js +2 -0
  34. package/dist/chunk-7na8bets.js +2 -0
  35. package/dist/{chunk-kr8qdg0r.js → chunk-7yb82rm6.js} +2 -2
  36. package/dist/{chunk-e3wmnjz8.js → chunk-810r5dk3.js} +3 -3
  37. package/dist/{chunk-e0wxcst7.js → chunk-89jn2jmf.js} +4 -4
  38. package/dist/{chunk-488kx8j5.js → chunk-8bzq2z0m.js} +5 -5
  39. package/dist/chunk-8k2n6abg.js +2 -0
  40. package/dist/chunk-8vqs94f3.js +2 -0
  41. package/dist/{chunk-dhqp3z4w.js → chunk-91htcq62.js} +2 -2
  42. package/dist/chunk-9736003n.js +2 -0
  43. package/dist/{chunk-agtvdtx4.js → chunk-9b6896tb.js} +2 -2
  44. package/dist/{chunk-y0pqpch2.js → chunk-9k6tza24.js} +7 -7
  45. package/dist/chunk-9w33k6f7.js +2 -0
  46. package/dist/{chunk-enep9r03.js → chunk-9x62j5f0.js} +52 -52
  47. package/dist/{chunk-b4r7d6me.js → chunk-a1ba9d2r.js} +5 -5
  48. package/dist/{chunk-efrc97by.js → chunk-a20wq8wf.js} +4 -4
  49. package/dist/{chunk-t3ptzpfc.js → chunk-a3xqfyb6.js} +2 -2
  50. package/dist/chunk-ag8j9ec2.js +2 -0
  51. package/dist/chunk-ak15dt1a.js +2 -0
  52. package/dist/{chunk-27rzdq3n.js → chunk-akcyaxwv.js} +2 -2
  53. package/dist/{chunk-w5hhqjwr.js → chunk-aw6369cx.js} +1 -1
  54. package/dist/chunk-b5ck6epd.js +177 -0
  55. package/dist/chunk-b98743ja.js +2 -0
  56. package/dist/{chunk-14ft0zc7.js → chunk-b9d70mgr.js} +6 -6
  57. package/dist/chunk-bskxswmn.js +2 -0
  58. package/dist/chunk-bv5h4etd.js +2 -0
  59. package/dist/chunk-c7x3bmvs.js +2 -0
  60. package/dist/{chunk-2gqhfge6.js → chunk-c84pxd2k.js} +2 -2
  61. package/dist/chunk-camm2hcx.js +2 -0
  62. package/dist/chunk-cd2wda5c.js +2 -0
  63. package/dist/chunk-cv6pqg85.js +2 -0
  64. package/dist/chunk-cy0mab8y.js +2 -0
  65. package/dist/chunk-d554f2fj.js +2 -0
  66. package/dist/chunk-dd1vqndp.js +2 -0
  67. package/dist/{chunk-0r61tkfe.js → chunk-ddhkhhc7.js} +2 -2
  68. package/dist/{chunk-9tqa8xvf.js → chunk-dsnggn3g.js} +2 -2
  69. package/dist/chunk-e14v1q9c.js +2 -0
  70. package/dist/{chunk-2m5h2mtr.js → chunk-e37g6ezw.js} +41 -41
  71. package/dist/chunk-e3xw2bzh.js +2 -0
  72. package/dist/{chunk-nps2whkz.js → chunk-eegb7f3t.js} +6 -6
  73. package/dist/chunk-eeztqt6f.js +2 -0
  74. package/dist/{chunk-1y9ez7nz.js → chunk-ef3w5thv.js} +2 -2
  75. package/dist/chunk-eh528njb.js +2 -0
  76. package/dist/chunk-en0wry1c.js +20 -0
  77. package/dist/chunk-eszpqrxy.js +2 -0
  78. package/dist/{chunk-2p4yad7w.js → chunk-fp0ew9n4.js} +4 -4
  79. package/dist/chunk-fyxkzs9c.js +2 -0
  80. package/dist/{chunk-d18xd9x5.js → chunk-gjf8cjdt.js} +3 -3
  81. package/dist/{chunk-7gdwvnwc.js → chunk-gvnfb6s2.js} +2 -2
  82. package/dist/{chunk-fpn4dren.js → chunk-gzfvj15b.js} +1 -1
  83. package/dist/chunk-hb4jkdfr.js +2 -0
  84. package/dist/{chunk-qp3xd98j.js → chunk-hg9mwgnr.js} +2 -2
  85. package/dist/{chunk-8q63njnd.js → chunk-hmt0vqhb.js} +1 -1
  86. package/dist/{chunk-v8rfeev5.js → chunk-hp9e8nz6.js} +2 -2
  87. package/dist/chunk-hzps1xya.js +2 -0
  88. package/dist/{chunk-985afhhy.js → chunk-j3st59hv.js} +2 -2
  89. package/dist/{chunk-7sartb04.js → chunk-jde0shn4.js} +2 -2
  90. package/dist/{chunk-15ckxpq7.js → chunk-jeprxn45.js} +6 -6
  91. package/dist/{chunk-bwcj9z19.js → chunk-jt0yn7ab.js} +4 -4
  92. package/dist/chunk-k8gpvg0w.js +2 -0
  93. package/dist/chunk-kgn911k7.js +2 -0
  94. package/dist/{chunk-jdj1358b.js → chunk-kj8dvzpc.js} +2 -2
  95. package/dist/chunk-km8c0j9g.js +2 -0
  96. package/dist/{chunk-w6taxq7d.js → chunk-mj3hzy1e.js} +5 -5
  97. package/dist/{chunk-66b56g2z.js → chunk-nw0v655w.js} +6 -6
  98. package/dist/{chunk-6v4b0xc1.js → chunk-p1mghe1h.js} +6 -6
  99. package/dist/{chunk-pa9zfbh6.js → chunk-p2a6dwj6.js} +6 -6
  100. package/dist/chunk-pw89m3re.js +2 -0
  101. package/dist/chunk-q38vjqv2.js +2 -0
  102. package/dist/{chunk-yyr7vb7k.js → chunk-q3ma4khe.js} +5 -5
  103. package/dist/{chunk-ne69yaak.js → chunk-q7q9e0gj.js} +10 -10
  104. package/dist/{chunk-kce6pzmj.js → chunk-qef2vv0m.js} +3 -3
  105. package/dist/{chunk-q14d714d.js → chunk-qjbpa1n4.js} +4 -4
  106. package/dist/{chunk-5gppagt3.js → chunk-qm2wmqre.js} +1 -1
  107. package/dist/{chunk-605b93pe.js → chunk-qpvwxppw.js} +4 -4
  108. package/dist/{chunk-8nb8b0nf.js → chunk-qxt6hdat.js} +1 -1
  109. package/dist/{chunk-1hajf3wc.js → chunk-r6d6jphq.js} +21 -21
  110. package/dist/chunk-rbv6fxtx.js +3 -0
  111. package/dist/chunk-rrketemm.js +2 -0
  112. package/dist/chunk-rwys552r.js +3 -0
  113. package/dist/chunk-s0bx4gjh.js +2 -0
  114. package/dist/{chunk-gv3bfkdm.js → chunk-s14jcqdf.js} +5 -5
  115. package/dist/{chunk-es006emk.js → chunk-s3fmmm98.js} +3 -3
  116. package/dist/chunk-s8s7b7rv.js +2 -0
  117. package/dist/{chunk-vkn133cs.js → chunk-s9b6abkb.js} +2 -2
  118. package/dist/{chunk-3gn1t0pa.js → chunk-sprgkk9j.js} +31 -31
  119. package/dist/chunk-sywqa4da.js +2 -0
  120. package/dist/{chunk-gb65t4n1.js → chunk-t65tn8ee.js} +2 -2
  121. package/dist/{chunk-vrbcdds3.js → chunk-trjhz9d9.js} +1 -1
  122. package/dist/chunk-txrbz95y.js +2 -0
  123. package/dist/{chunk-h0c6jtrj.js → chunk-v9hm1xv6.js} +5 -5
  124. package/dist/{chunk-bmfk3b29.js → chunk-w0zayhmg.js} +2 -2
  125. package/dist/{chunk-tnn0br4w.js → chunk-w58bnt44.js} +3 -3
  126. package/dist/chunk-w7681v48.js +2 -0
  127. package/dist/chunk-w7wz670a.js +2 -0
  128. package/dist/{chunk-epcy3r18.js → chunk-wp6bdac7.js} +113 -105
  129. package/dist/{chunk-8ztgy5y4.js → chunk-x8ckxemg.js} +107 -107
  130. package/dist/{chunk-74rf78w8.js → chunk-x8h81amr.js} +2 -2
  131. package/dist/{chunk-hh9t97hr.js → chunk-xa36escd.js} +3 -3
  132. package/dist/{chunk-7fr038wx.js → chunk-xskswvef.js} +4 -4
  133. package/dist/chunk-xzgtdcbg.js +2 -0
  134. package/dist/{chunk-k4bdf0dw.js → chunk-y9bj3566.js} +2 -2
  135. package/dist/chunk-yfdb3x3p.js +2 -0
  136. package/dist/{chunk-qv85c3qy.js → chunk-yv4dwdhc.js} +2 -2
  137. package/dist/{chunk-1stvxcjv.js → chunk-z1aq59qj.js} +3 -3
  138. package/dist/{chunk-nwbq8qvb.js → chunk-z1fb5k3h.js} +1305 -449
  139. package/dist/{chunk-tnkxww7b.js → chunk-z8wfvqbk.js} +5 -5
  140. package/dist/chunk-z9a80qqg.js +2 -0
  141. package/dist/chunk-za5kx15m.js +2 -0
  142. package/dist/{chunk-8e23zh2y.js → chunk-zbv8e4rq.js} +2 -2
  143. package/dist/{chunk-v1z6n7wz.js → chunk-znx5m1jv.js} +4 -4
  144. package/dist/{chunk-6pt4158p.js → chunk-zqsacq3r.js} +1 -1
  145. package/dist/{chunk-rgz797k3.js → chunk-zsy145ac.js} +3 -3
  146. package/dist/{chunk-j56mg28d.js → chunk-zx8tnhfr.js} +3 -3
  147. package/dist/cli.js +19 -19
  148. package/dist/client/signals-authoring-runtime.js +6 -3
  149. package/dist/client/signals-binding-utils-runtime.js +2 -4
  150. package/dist/client/signals-component-props-runtime.js +8 -2
  151. package/dist/client/signals-expression-compiler-runtime.js +1 -1
  152. package/dist/client/signals-for-runtime.js +34 -0
  153. package/dist/client/signals-handler-runtime.js +68 -24
  154. package/dist/client/signals-helpers-runtime.js +51 -0
  155. package/dist/client/signals-native-row-runtime.d.ts +26 -0
  156. package/dist/client/signals-native-row-runtime.js +661 -0
  157. package/dist/client/signals-pipe-runtime.js +16 -0
  158. package/dist/client/signals-process-element-runtime.js +305 -287
  159. package/dist/client/signals-proxy-runtime.js +56 -31
  160. package/dist/craft-entry.js +2 -2
  161. package/dist/craft.js +2 -2
  162. package/dist/native/accessibility.js +8 -0
  163. package/dist/native/compiler/bundle.js +1 -1
  164. package/dist/native/compiler/inline-style.js +93 -4
  165. package/dist/native/compiler/style-variables.js +9 -1
  166. package/dist/native/event-names.js +1 -0
  167. package/dist/native/prop-names.js +9 -1
  168. package/dist/native/runtime/binding-tree.d.ts +2 -0
  169. package/dist/native/runtime/binding-tree.js +12 -1
  170. package/dist/native/runtime/craft-bridge.js +66 -0
  171. package/dist/native/runtime/craft.d.ts +78 -2
  172. package/dist/native/runtime/native-host.d.ts +2 -0
  173. package/dist/native/runtime/native-host.js +315 -91
  174. package/dist/native-build.js +2 -23
  175. package/dist/pwa.js +3 -3
  176. package/dist/signals.d.ts +13 -10
  177. package/dist/signals.js +5 -3
  178. package/dist/ssg.js +15 -15
  179. package/dist/stx-virtual-ts.d.ts +25 -1
  180. package/dist/stx-virtual-ts.js +109 -6
  181. package/dist/typecheck.d.ts +3 -1
  182. package/dist/typecheck.js +28 -11
  183. package/package.json +6 -6
  184. package/dist/chunk-0675z8hj.js +0 -177
  185. package/dist/chunk-1brkqd5f.js +0 -2
  186. package/dist/chunk-1ds97d9m.js +0 -2
  187. package/dist/chunk-1tvb2stj.js +0 -2
  188. package/dist/chunk-2vxh8b8g.js +0 -2
  189. package/dist/chunk-33na85q2.js +0 -2
  190. package/dist/chunk-3t4t655h.js +0 -2
  191. package/dist/chunk-43ynckvh.js +0 -2
  192. package/dist/chunk-4v22nj67.js +0 -2
  193. package/dist/chunk-5v5w0cd2.js +0 -2
  194. package/dist/chunk-699t603m.js +0 -2
  195. package/dist/chunk-6f6xqzhb.js +0 -2
  196. package/dist/chunk-7mrr4ke5.js +0 -2
  197. package/dist/chunk-7tzzzvdg.js +0 -2
  198. package/dist/chunk-8a5txj4f.js +0 -2
  199. package/dist/chunk-8pphy0p1.js +0 -2
  200. package/dist/chunk-8rmb79zw.js +0 -2
  201. package/dist/chunk-8rwnzmvb.js +0 -2
  202. package/dist/chunk-90pxjq62.js +0 -2
  203. package/dist/chunk-9s4ggstz.js +0 -2
  204. package/dist/chunk-9wmjmas8.js +0 -2
  205. package/dist/chunk-9xdz8r73.js +0 -2
  206. package/dist/chunk-agvykxs8.js +0 -2
  207. package/dist/chunk-ajj56vrw.js +0 -2
  208. package/dist/chunk-ay4ep67v.js +0 -2
  209. package/dist/chunk-bwfncfe1.js +0 -3
  210. package/dist/chunk-cdsv4yrv.js +0 -2
  211. package/dist/chunk-d5e47gr4.js +0 -2
  212. package/dist/chunk-d910ytt2.js +0 -2
  213. package/dist/chunk-d9p7xaj7.js +0 -2
  214. package/dist/chunk-dsrn2vgp.js +0 -2
  215. package/dist/chunk-fkkdt6sj.js +0 -2
  216. package/dist/chunk-fpw03bhv.js +0 -2
  217. package/dist/chunk-fxy0cq7h.js +0 -2
  218. package/dist/chunk-g6smtcc0.js +0 -2
  219. package/dist/chunk-g747k4gg.js +0 -3
  220. package/dist/chunk-gryrg1c0.js +0 -2
  221. package/dist/chunk-gvj862m1.js +0 -2
  222. package/dist/chunk-h5nrnen8.js +0 -2
  223. package/dist/chunk-hagk74x6.js +0 -2
  224. package/dist/chunk-hv0whj8t.js +0 -2
  225. package/dist/chunk-k2brrhf8.js +0 -2
  226. package/dist/chunk-k6ncb5qm.js +0 -2
  227. package/dist/chunk-kn38mjpp.js +0 -2
  228. package/dist/chunk-kvmpc0sg.js +0 -2
  229. package/dist/chunk-nbjgytem.js +0 -2
  230. package/dist/chunk-nf2bzqaw.js +0 -2
  231. package/dist/chunk-nt7wqqax.js +0 -2
  232. package/dist/chunk-pq1qs7bp.js +0 -2
  233. package/dist/chunk-pvw58x2j.js +0 -20
  234. package/dist/chunk-qk9v0emh.js +0 -2
  235. package/dist/chunk-qnj444zc.js +0 -2
  236. package/dist/chunk-qzb0v08n.js +0 -2
  237. package/dist/chunk-s1wdzttg.js +0 -2
  238. package/dist/chunk-sq0qc9sk.js +0 -2
  239. package/dist/chunk-th5afzmv.js +0 -2
  240. package/dist/chunk-tktkj2dc.js +0 -2
  241. package/dist/chunk-vgzfsh1z.js +0 -2
  242. package/dist/chunk-wmh4yxcs.js +0 -2
  243. package/dist/chunk-wr3adhd8.js +0 -2
  244. package/dist/chunk-xmae29mn.js +0 -2
  245. package/dist/chunk-zdwnzq78.js +0 -2
  246. package/dist/chunk-zssf9fdg.js +0 -2
  247. package/dist/chunk-zyf6737j.js +0 -2
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Zs,Ht,vl,kg}from"./chunk-bwcj9z19.js";import{Ys,Ai,vg,xg,Sg}from"./chunk-4s5q1aea.js";import{yl,bl,wl,bg,wg}from"./chunk-dhqp3z4w.js";import{Ue,Tn,Pi}from"./chunk-k4bdf0dw.js";import{_g,Cg,Eg,Tg,Qs,ly}from"./chunk-7pk3t82j.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-1ds97d9m.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{eo,Ht,Sl,_g}from"./chunk-jt0yn7ab.js";import{Qs,Ii,xg,Sg,kg}from"./chunk-6m4y5dh5.js";import{wl,vl,xl,wg,vg}from"./chunk-91htcq62.js";import{Ue,Tn,Oi}from"./chunk-y9bj3566.js";import{Cg,Eg,Tg,$g,to,dy}from"./chunk-20yz8bjp.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-k8gpvg0w.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=Zs(n,t);if(a){let s=Ht(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 Ai(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,bl as auditBuildOutput,yl as auditConfig,re as buildPwaAssets,wl as calculateAuditResult,wg as formatAuditResult,Pi as formatSize,j as generateManifest,_ as generateManifestJson,xg as generateManifestLink,F as generateOfflinePage,Ue as generatePrecacheManifest,Tn as generatePrecacheManifestJs,M as generatePwaIcons,Ys as generatePwaTags,Zs as generateServiceWorker,kg as generateServiceWorkerAuto,vg as generateSwRegistrationScript,Sg as generateThemeColorMeta,N as getExpectedIconPaths,Ht as getServiceWorkerFileName,Ai as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,vl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Qs as pwaDirectives,_g as pwaInstallDirective,Eg as pwaOfflineDirective,Tg as pwaPushDirective,Cg as pwaUpdateDirective,ly as registerPwaDirectives,bg 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=Ue(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=eo(n,t);if(a){let s=Ht(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 Ii(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,vl as auditBuildOutput,wl as auditConfig,re as buildPwaAssets,xl as calculateAuditResult,vg as formatAuditResult,Oi as formatSize,j as generateManifest,_ as generateManifestJson,Sg as generateManifestLink,F as generateOfflinePage,Ue as generatePrecacheManifest,Tn as generatePrecacheManifestJs,M as generatePwaIcons,Qs as generatePwaTags,eo as generateServiceWorker,_g as generateServiceWorkerAuto,xg as generateSwRegistrationScript,kg as generateThemeColorMeta,N as getExpectedIconPaths,Ht as getServiceWorkerFileName,Ii as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Sl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,to as pwaDirectives,Cg as pwaInstallDirective,Tg as pwaOfflineDirective,$g as pwaPushDirective,Eg as pwaUpdateDirective,dy as registerPwaDirectives,wg as runPwaAudit,D as validateManifest};
package/dist/signals.d.ts CHANGED
@@ -1,19 +1,11 @@
1
1
  import { state, derived, effect, batch, onMount, onDestroy, isSignal, isDerived, untrack, peek } from './signals-api';
2
- /**
3
- * Generates the browser runtime for STX signals.
4
- *
5
- * This runtime is automatically injected into pages that use signals.
6
- * It provides the full reactivity system and template binding.
7
- *
8
- * @returns Minified JavaScript runtime code
9
- */
10
- export declare function generateSignalsRuntime(): string;
2
+ export declare function generateSignalsRuntime(options?: SignalsRuntimeOptions): string;
11
3
  /**
12
4
  * Generates readable (non-minified) runtime for development.
13
5
  *
14
6
  * @returns Human-readable JavaScript runtime code
15
7
  */
16
- export declare function generateSignalsRuntimeDev(): string;
8
+ export declare function generateSignalsRuntimeDev(options?: SignalsRuntimeOptions): string;
17
9
  declare const __dtsx_default_export__: {
18
10
  state: typeof state;
19
11
  derived: typeof derived;
@@ -28,6 +20,17 @@ declare const __dtsx_default_export__: {
28
20
  generateSignalsRuntime: typeof generateSignalsRuntime;
29
21
  generateSignalsRuntimeDev: typeof generateSignalsRuntimeDev
30
22
  };
23
+ /**
24
+ * Generates the browser runtime for STX signals.
25
+ *
26
+ * This runtime is automatically injected into pages that use signals.
27
+ * It provides the full reactivity system and template binding.
28
+ *
29
+ * @returns Minified JavaScript runtime code
30
+ */
31
+ export declare interface SignalsRuntimeOptions {
32
+ native?: boolean
33
+ }
31
34
  export * from './signals-api';
32
35
  // =============================================================================
33
36
  // Default Export
package/dist/signals.js CHANGED
@@ -30,6 +30,7 @@ import { SIGNALS_EXPRESSION_RUNTIME } from "./client/signals-expression-runtime.
30
30
  import { SIGNALS_FETCH_TRANSPORT_RUNTIME } from "./client/signals-fetch-transport-runtime.js";
31
31
  import { signalsFetchRuntime } from "./client/signals-fetch-runtime.js";
32
32
  import { SIGNALS_FOR_RUNTIME } from "./client/signals-for-runtime.js";
33
+ import { SIGNALS_NATIVE_ROW_RUNTIME } from "./client/signals-native-row-runtime.js";
33
34
  import { SIGNALS_GLOBALS_RUNTIME } from "./client/signals-globals-runtime.js";
34
35
  import { SIGNALS_HANDLER_RUNTIME } from "./client/signals-handler-runtime.js";
35
36
  import { SIGNALS_HEAD_RUNTIME } from "./client/signals-head-runtime.js";
@@ -76,8 +77,8 @@ import { SIGNALS_TRANSITION_GROUP_RUNTIME } from "./client/signals-transition-gr
76
77
  import { SIGNALS_WEBSOCKET_RUNTIME } from "./client/signals-websocket-runtime.js";
77
78
 
78
79
  export * from "./signals-api.js";
79
- export function generateSignalsRuntime() {
80
- const stripped = stripConsoleLog(generateSignalsRuntimeDev());
80
+ export function generateSignalsRuntime(options = {}) {
81
+ const stripped = stripConsoleLog(generateSignalsRuntimeDev(options));
81
82
  try {
82
83
  let minified = new Bun.Transpiler({ loader: "js", minifyWhitespace: !0 }).transformSync(stripped);
83
84
  minified = minified.replace(/\}(var |let |const |function )/g, "};$1");
@@ -122,7 +123,7 @@ function stripConsoleLog(src) {
122
123
  }
123
124
  return out.join("");
124
125
  }
125
- export function generateSignalsRuntimeDev() {
126
+ export function generateSignalsRuntimeDev(options = {}) {
126
127
  return `${SIGNALS_PREAMBLE_RUNTIME}${SIGNALS_HOST_RUNTIME}
127
128
  ${signalsReactiveCoreBootstrapRuntime(SIGNALS_CLOAK_RUNTIME, SIGNALS_EXPRESSION_COMPILER_RUNTIME, SIGNALS_FETCH_TRANSPORT_RUNTIME)}
128
129
 
@@ -162,6 +163,7 @@ ${SIGNALS_LOOP_COMPONENT_REMAP_RUNTIME}
162
163
  ${SIGNALS_COMPONENT_HYDRATION_RUNTIME}
163
164
  ${SIGNALS_LOOP_ROW_RUNTIME}
164
165
  ${SIGNALS_FOR_RUNTIME}
166
+ ${options.native ? SIGNALS_NATIVE_ROW_RUNTIME : ""}
165
167
  ${SIGNALS_LOOP_CONDITIONAL_RUNTIME}
166
168
  ${SIGNALS_CONDITIONAL_CHAIN_RUNTIME}
167
169
  ${SIGNALS_IF_CHAIN_RUNTIME}
package/dist/ssg.js CHANGED
@@ -1,22 +1,22 @@
1
1
  // @bun
2
- import"./chunk-7sh9fa3q.js";import{w,tl}from"./chunk-94gyfwpz.js";import"./chunk-gb65t4n1.js";import"./chunk-2yxva96k.js";import{Rt,S}from"./chunk-epcy3r18.js";import"./chunk-27rzdq3n.js";import"./chunk-8e23zh2y.js";import"./chunk-h0jnatd4.js";import{kt,_t,Ct,Et,Tt,$t}from"./chunk-q14d714d.js";import{a}from"./chunk-enep9r03.js";import{Cs}from"./chunk-w9nwb8r3.js";import"./chunk-605b93pe.js";import"./chunk-d6arvs57.js";import{he,en,tn}from"./chunk-j6255z7f.js";import"./chunk-bwfncfe1.js";import{y}from"./chunk-66b56g2z.js";import{yt,i}from"./chunk-2m5h2mtr.js";import"./chunk-e0wxcst7.js";import"./chunk-ne69yaak.js";import{ds}from"./chunk-y0pqpch2.js";import"./chunk-ssh2gycr.js";import"./chunk-2gqhfge6.js";import{Ga,Ja,Ya}from"./chunk-d18xd9x5.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{Qt}from"./chunk-5gppagt3.js";import"./chunk-g747k4gg.js";import"./chunk-qv85c3qy.js";import{X,we}from"./chunk-nps2whkz.js";import"./chunk-w5hhqjwr.js";import"./chunk-wk6xsyv3.js";import{l}from"./chunk-jdj1358b.js";import{s,ge}from"./chunk-14ft0zc7.js";import D from"fs";import f from"path";import{createHash as vt}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 It(t){return Bun.hash(t).toString(16)}function ot(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(Dt,(e,u,g,v)=>{let x=v.trim();if(!x)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)x=Pt(x);let p=It(x);if(!n.has(p))n.set(p,x);let P=r.integrity?` data-stx-integrity="sha384-${vt("sha384").update(x).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(n,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let r=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)r.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(r.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=S(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let x=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!x)return t;return t.slice(0,v)+x+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function K(t){let r=t.trim();if(!r)return null;let n=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(n).origin+new URL(n).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let r of jt){let n=t[r];if(!n)continue;let o=K(n);if(o)return{url:o,source:"env",via:r}}return null}function lt(t){if(!t||typeof t!=="object")return null;let r=t,n=r.site?.url??r.url??r.app?.url;return typeof n==="string"?K(n):null}async function At(t){let{existsSync:r}=await import("fs"),n=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=n.resolve(t,o);if(!r(c))continue;try{let e=await import(c),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let r=t.cwd??process.cwd(),n=t.env??process.env;if(t.explicit){let u=K(t.explicit);if(u)return{url:u,source:"option"}}let o=lt(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await At(r);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(n);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){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
- `)}function q(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=ge(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(r))!==null){if(n[c.index]!==0)continue;let u=w(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=w(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(r))!==null){if(n[c.index]!==0)continue;let u=tl(r,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function gt(t){let r="read";try{let n=await Bun.file(t).text();r="parse";let o=Qt(n),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(s(e.attrs))).sort((e,u)=>n.indexOf(e.fullTag)-n.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(s(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(s(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(s(g))&&Rt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(q);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let x=await v();r="result";let p=Array.isArray(x)?{paths:x}:x;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(n){return{kind:"error",phase:r,error:n instanceof Error?n:Error(String(n))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[n,o]of Object.entries(r))this.cache.set(n,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),r={};for(let[n,o]of this.cache)r[n]=o;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let n=D.statSync(t),o=`${this.salt}|${t}:${n.mtimeMs}`;for(let e of r)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,r){let n=this.cache.get(t);if(!n)return null;let o=ft(r).some((u)=>D.existsSync(u)),c=[r,...n.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&ds(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(r,n.dependencies??[]);if(n.hash!==e)return this.cache.delete(t),null;return n.html}set(t,r,n,o){let c=this.getHash(r,n);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:n})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",r)}async get(t){let r=this.getFilePath(t);if(!await Bun.file(r).exists())return null;try{return JSON.parse(await Bun.file(r).text())}catch{return null}}async set(t,r){let n=this.getFilePath(t);await D.promises.mkdir(f.dirname(n),{recursive:!0}),await Bun.write(n,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await D.promises.unlink(r)}async invalidatePattern(t){let r=f.join(this.cacheDir,"isr");if(!D.existsSync(r))return;let n=await D.promises.readdir(r);for(let o of n){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await D.promises.unlink(f.join(r,o))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function Ut(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let n=await gt(t.filePath);if(n.kind==="error")throw Error(`getStaticPaths ${n.phase} failed for ${t.pattern} (${t.filePath}): ${n.error.message}`,{cause:n.error});if(n.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),r;let o=n.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),r;for(let c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);r.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return r}function ft(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let r of ft(t))if(await Bun.file(r).exists())try{let n=await import(r);if(typeof n.default==="function")return await n.default();else if(typeof n.default==="object")return n.default;else if(typeof n.getData==="function")return await n.getData();else{let{default:o,...c}=n;return c}}catch(n){console.error(`Error loading data file ${r}:`,n)}return null}async function Gt(t,r,n){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
2
+ import"./chunk-7sh9fa3q.js";import{w,rl}from"./chunk-4v50nafp.js";import"./chunk-t65tn8ee.js";import"./chunk-2yxva96k.js";import{Rt,S}from"./chunk-wp6bdac7.js";import"./chunk-akcyaxwv.js";import"./chunk-zbv8e4rq.js";import"./chunk-2ws2qe1k.js";import{kt,_t,Ct,Et,Tt,$t}from"./chunk-qjbpa1n4.js";import{a}from"./chunk-9x62j5f0.js";import{Ts}from"./chunk-7bxnjr3b.js";import"./chunk-qpvwxppw.js";import"./chunk-0beyn8ak.js";import{he,en,tn}from"./chunk-3x598qjt.js";import"./chunk-rbv6fxtx.js";import{y}from"./chunk-nw0v655w.js";import{yt,i}from"./chunk-e37g6ezw.js";import"./chunk-89jn2jmf.js";import"./chunk-q7q9e0gj.js";import{gs}from"./chunk-9k6tza24.js";import"./chunk-2z2bq2at.js";import"./chunk-c84pxd2k.js";import{Za,Qa,ec}from"./chunk-gjf8cjdt.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{Qt}from"./chunk-qm2wmqre.js";import"./chunk-rwys552r.js";import"./chunk-yv4dwdhc.js";import{K,we}from"./chunk-eegb7f3t.js";import"./chunk-aw6369cx.js";import"./chunk-3mby4nes.js";import{l}from"./chunk-kj8dvzpc.js";import{r,ge}from"./chunk-b9d70mgr.js";import D from"fs";import f from"path";import{createHash as vt}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 It(t){return Bun.hash(t).toString(16)}function ot(t,n={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,o=t.replace(Dt,(e,u,g,v)=>{let x=v.trim();if(!x)return e;if(/\bdata-stx-src=/.test(g))return e;if(n.minify)x=Pt(x);let p=It(x);if(!s.has(p))s.set(p,x);let P=n.integrity?` data-stx-integrity="sha384-${vt("sha384").update(x).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(s,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let n=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=s.exec(t))!==null)n.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(n.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=S(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let x=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!x)return t;return t.slice(0,v)+x+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let n=t.trim();if(!n)return null;let s=/^https?:\/\//i.test(n)?n:`https://${n}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let n of jt){let s=t[n];if(!s)continue;let o=X(s);if(o)return{url:o,source:"env",via:n}}return null}function lt(t){if(!t||typeof t!=="object")return null;let n=t,s=n.site?.url??n.url??n.app?.url;return typeof s==="string"?X(s):null}async function At(t){let{existsSync:n}=await import("fs"),s=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,o);if(!n(c))continue;try{let e=await import(c),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let n=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let u=X(t.explicit);if(u)return{url:u,source:"option"}}let o=lt(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await At(n);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){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
+ `)}function q(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let n=r(t),{depths:s}=ge(n),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(n))!==null){if(s[c.index]!==0)continue;let u=w(n,"(",")",o.lastIndex-1),g=n.indexOf("{",u+1),v=w(n,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(n))!==null){if(s[c.index]!==0)continue;let u=rl(n,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function gt(t){let n="read";try{let s=await Bun.file(t).text();n="parse";let o=Qt(s),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(r(e.attrs))).sort((e,u)=>s.indexOf(e.fullTag)-s.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(r(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(r(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(r(g))&&Rt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let v=Function("defineStaticPaths",`return (${g})`)(q);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let x=await v();n="result";let p=Array.isArray(x)?{paths:x}:x;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(s){return{kind:"error",phase:n,error:s instanceof Error?s:Error(String(s))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,n=""){this.cacheDir=t,this.salt=n}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let n=JSON.parse(await Bun.file(t).text());for(let[s,o]of Object.entries(n))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),n={};for(let[s,o]of this.cache)n[s]=o;await Bun.write(t,JSON.stringify(n))}getHash(t,n){let s=D.statSync(t),o=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of n)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,n){let s=this.cache.get(t);if(!s)return null;let o=ft(n).some((u)=>D.existsSync(u)),c=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&gs(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(n,s.dependencies??[]);if(s.hash!==e)return this.cache.delete(t),null;return s.html}set(t,n,s,o){let c=this.getHash(n,s);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:s})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let n=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",n)}async get(t){let n=this.getFilePath(t);if(!await Bun.file(n).exists())return null;try{return JSON.parse(await Bun.file(n).text())}catch{return null}}async set(t,n){let s=this.getFilePath(t);await D.promises.mkdir(f.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(n))}async invalidate(t){let n=this.getFilePath(t);if(await Bun.file(n).exists())await D.promises.unlink(n)}async invalidatePattern(t){let n=f.join(this.cacheDir,"isr");if(!D.existsSync(n))return;let s=await D.promises.readdir(n);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await D.promises.unlink(f.join(n,o))}}async needsRevalidation(t){let n=await this.get(t);if(!n)return!0;return Date.now()>n.revalidateAfter}}async function Ut(t){let n=[];if(!t.isDynamic)n.push({url:t.pattern,params:{}});else{let s=await gt(t.filePath);if(s.kind==="error")throw Error(`getStaticPaths ${s.phase} failed for ${t.pattern} (${t.filePath}): ${s.error.message}`,{cause:s.error});if(s.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),n;let o=s.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),n;for(let c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);n.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return n}function ft(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let n of ft(t))if(await Bun.file(n).exists())try{let s=await import(n);if(typeof s.default==="function")return await s.default();else if(typeof s.default==="object")return s.default;else if(typeof s.getData==="function")return await s.getData();else{let{default:o,...c}=s;return c}}catch(s){console.error(`Error loading data file ${n}:`,s)}return null}async function Gt(t,n,s){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
4
4
  return (async function getStaticProps() {
5
5
  ${e[1]}
6
6
  })()
7
- `)(r)}catch(e){return console.error(`Error executing getStaticProps in ${n}:`,e),null}}function Nt(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 mt(t,r,n={},o,c){let e=await Bun.file(t.filePath).text(),u=await Mt(t.filePath),g=await Gt(e,r,t.filePath),v={...u||{},...g||{},...n,params:r,$route:{path:t.pattern,params:r}},x=new Set,p=[],P=[],E={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(R)=>{p.push(`${f.relative(process.cwd(),R.templatePath)}: ${R.message}
8
- resolved against partialsDir: ${R.partialsDir}`)},onServerScriptError:(R)=>{P.push(`${f.relative(process.cwd(),R.sourcePath)} (${R.kind}): ${R.message}`)}};if(Nt(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 b=await i(e,v,t.filePath,E,x);for(let R of[t.filePath,...x])for(let T of he(R))x.add(T);if(Object.keys(r).length>0){let R=`<script>if(window.stx)window.stx._rp=${JSON.stringify(r)};else window.__stx_rp=${JSON.stringify(r)};</script>`;if(b.includes("</head>"))b=b.replace("</head>",`${R}
7
+ `)(n)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Nt(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 mt(t,n,s={},o,c){let e=await Bun.file(t.filePath).text(),u=await Mt(t.filePath),g=await Gt(e,n,t.filePath),v={...u||{},...g||{},...s,params:n,$route:{path:t.pattern,params:n}},x=new Set,p=[],P=[],E={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(R)=>{p.push(`${f.relative(process.cwd(),R.templatePath)}: ${R.message}
8
+ resolved against partialsDir: ${R.partialsDir}`)},onServerScriptError:(R)=>{P.push(`${f.relative(process.cwd(),R.sourcePath)} (${R.kind}): ${R.message}`)}};if(Nt(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 b=await i(e,v,t.filePath,E,x);for(let R of[t.filePath,...x])for(let T of he(R))x.add(T);if(Object.keys(n).length>0){let R=`<script>if(window.stx)window.stx._rp=${JSON.stringify(n)};else window.__stx_rp=${JSON.stringify(n)};</script>`;if(b.includes("</head>"))b=b.replace("</head>",`${R}
9
9
  </head>`);else b=`${R}
10
- ${b}`}if(b=await we(b,{router:o.router}),b=await y(b),o.minify!==!1)return{html:Ht(b),dependencies:Array.from(x),includeFailures:p,serverScriptFailures:P};return{html:b,dependencies:Array.from(x),includeFailures:p,serverScriptFailures:P}}function Ht(t){let r=[],n=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=o.exec(t))!==null){let u=t.slice(n,c.index);r.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let g=c[1],v=c[2],x=c[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),r.push(g+v+x),n=c.index+c[0].length}let e=t.slice(n);return r.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),r.join("").trim()}function zt(t){let r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);r=(r<<5)-r+o,r=r&r}return`"${Math.abs(r).toString(36)}"`}function Wt(t,r,n,o){if(n?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(r))return!0;return o.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function qt(t,r){return`<?xml version="1.0" encoding="UTF-8"?>
10
+ ${b}`}if(b=await we(b,{router:o.router}),b=await y(b),o.minify!==!1)return{html:Ht(b),dependencies:Array.from(x),includeFailures:p,serverScriptFailures:P};return{html:b,dependencies:Array.from(x),includeFailures:p,serverScriptFailures:P}}function Ht(t){let n=[],s=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=o.exec(t))!==null){let u=t.slice(s,c.index);n.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let g=c[1],v=c[2],x=c[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),n.push(g+v+x),s=c.index+c[0].length}let e=t.slice(s);return n.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),n.join("").trim()}function zt(t){let n=0;for(let s=0;s<t.length;s++){let o=t.charCodeAt(s);n=(n<<5)-n+o,n=n&n}return`"${Math.abs(n).toString(36)}"`}function Wt(t,n,s,o){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(n))return!0;return o.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function qt(t,n){return`<?xml version="1.0" encoding="UTF-8"?>
11
11
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
12
- ${t.map((o)=>{let c=new URL(o.loc,r).href,e=` <url>
12
+ ${t.map((o)=>{let c=new URL(o.loc,n).href,e=` <url>
13
13
  <loc>${F(c)}</loc>`;if(o.lastmod)e+=`
14
14
  <lastmod>${o.lastmod}</lastmod>`;if(o.changefreq)e+=`
15
15
  <changefreq>${o.changefreq}</changefreq>`;if(o.priority!==void 0)e+=`
16
16
  <priority>${o.priority}</priority>`;return e+=`
17
17
  </url>`,e}).join(`
18
18
  `)}
19
- </urlset>`}function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Jt(t,r){let n=r.map((o)=>{let c=" <item>";if(c+=`
19
+ </urlset>`}function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Jt(t,n){let s=n.map((o)=>{let c=" <item>";if(c+=`
20
20
  <title>${F(o.title)}</title>`,c+=`
21
21
  <link>${F(o.link)}</link>`,o.description)c+=`
22
22
  <description>${F(o.description)}</description>`;if(o.pubDate)c+=`
@@ -34,13 +34,13 @@ ${t.map((o)=>{let c=new URL(o.loc,r).href,e=` <url>
34
34
  ${t.copyright?`<copyright>${F(t.copyright)}</copyright>`:""}
35
35
  <lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
36
36
  <atom:link href="${t.link}/rss.xml" rel="self" type="application/rss+xml"/>
37
- ${n.join(`
37
+ ${s.join(`
38
38
  `)}
39
39
  </channel>
40
- </rss>`}async function Vt(t={}){let r=Date.now();tn();let n=await a(process.cwd()),o=n.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:n});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??n?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||n?.partialsDir||"",componentsDir:t.componentsDir||n?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,x={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-7mrr4ke5.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-agvykxs8.js"),R=await b(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-7mrr4ke5.js");await d('<div class="bg-black"></div>')}catch{}kt();let wt=n?.routeMiddleware?.dir||"middleware";await Ct(process.cwd(),wt);let J=_t();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let St=n?.routeMiddleware?.global||[];Ya(n?.layoutsDir,l(process.cwd()));let Z=X(".",{pagesDir:e.pagesDir,pagesDirs:n?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)M.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:G,props:xt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=Yt(A),bt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...St,...bt];if(nt.length>0){let B=Et(h,G,O||{}),L=Tt(B,null,void 0,{isServer:!0}),j=await $t(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=te(String(C),h),U=ee(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,H),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(H),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${C}`);return}}let it=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
40
+ </rss>`}async function Vt(t={}){let n=Date.now();tn();let s=await a(process.cwd()),o=s.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.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},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,x={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-4hgz9dkv.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-s0bx4gjh.js"),R=await b(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-4hgz9dkv.js");await d('<div class="bg-black"></div>')}catch{}kt();let wt=s?.routeMiddleware?.dir||"middleware";await Ct(process.cwd(),wt);let J=_t();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let St=s?.routeMiddleware?.global||[];ec(s?.layoutsDir,l(process.cwd()));let Z=K(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)M.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:G,props:xt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=Yt(A),bt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...St,...bt];if(nt.length>0){let B=Et(h,G,O||{}),L=Tt(B,null,void 0,{isServer:!0}),j=await $t(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=te(String(C),h),U=ee(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,H),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(H),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${C}`);return}}let it=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
41
41
  const validate = ${it[1]};
42
42
  return validate(route);
43
- `)({params:G})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=T.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await mt(k,G,xt,e,n);if(I=B.html,e.failOnIncludeError&&B.includeFailures.length>0)throw Error(`${B.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
43
+ `)({params:G})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=T.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await mt(k,G,xt,e,s);if(I=B.html,e.failOnIncludeError&&B.includeFailures.length>0)throw Error(`${B.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
44
44
  ${B.includeFailures.join(`
45
45
  `)}
46
46
  Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&B.serverScriptFailures.length>0)throw Error(`${B.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
@@ -48,7 +48,7 @@ Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptEr
48
48
  `)}
49
49
  Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)T.set(h,k.filePath,B.dependencies,I)}let N;if(e.trailingSlash)N=f.join(e.outputDir,h,"index.html");else N=h==="/"?f.join(e.outputDir,"index.html"):f.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:B,chunks:L}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(L.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of L){let H=f.join(j,`${C.hash}.js`);if(!await Bun.file(H).exists())await Bun.write(H,C.code);if(!g.has(C.hash)){g.add(C.hash);let U=Buffer.byteLength(C.code,"utf8");v+=U,x[C.hash]={bytes:U,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=L.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(f.dirname(N),{recursive:!0}),await Bun.write(N,I),!Wt(h,I,O,e.sitemapExclude))_.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let at={route:h,outputPath:N,size:Buffer.byteLength(I,"utf8"),cached:st};if(rt!==!1)at.revalidateAt=Date.now()+rt*1000;u.pages.push(at),u.successCount++,await e.hooks.onPageEnd?.(h,I)}catch(A){u.failedCount++,u.errors.push({route:h,error:A}),await e.hooks.onError?.(A,h),console.error(`Error generating ${h}:`,A)}}));let tt=en();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
50
50
  `);throw Error(`Client script bundling failed:
51
- ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=f.join(e.pagesDir,"404.stx");if(await Bun.file(d).exists()){let m=new Set,k={...n,minifyClient:!0,debug:!1,cache:!1},h=await i(await Bun.file(d).text(),{},d,k,m);await Bun.write(f.join(e.outputDir,"404.html"),h)}else await Bun.write(f.join(e.outputDir,"404.html"),`<!DOCTYPE html>
51
+ ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=f.join(e.pagesDir,"404.stx");if(await Bun.file(d).exists()){let m=new Set,k={...s,minifyClient:!0,debug:!1,cache:!1},h=await i(await Bun.file(d).text(),{},d,k,m);await Bun.write(f.join(e.outputDir,"404.html"),h)}else await Bun.write(f.join(e.outputDir,"404.html"),`<!DOCTYPE html>
52
52
  <html lang="en">
53
53
  <head>
54
54
  <meta charset="UTF-8">
@@ -69,7 +69,7 @@ ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=f.join(e.pagesDir,"404.
69
69
  <a href="/">Go home</a>
70
70
  </div>
71
71
  </body>
72
- </html>`)}for(let d of[500]){let m=f.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,h={...n,minifyClient:!0,debug:!1,cache:!1},G=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),G)}}let V=f.join(e.pagesDir,"error.stx");if(await Bun.file(V).exists()){let d=new Set,m={...n,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(V).text(),{},V,m,d);await Bun.write(f.join(e.outputDir,"error.html"),k)}if(e.sitemap&&_.length>0){let d=qt(_,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],k=Cs({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...m.length>0?{disallow:m}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(f.join(e.outputDir,"robots.txt"),k),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(d.getItems)m=await d.getItems();let k=Jt(d,m),h=f.join(e.outputDir,"rss.xml");await Bun.write(h,k),u.rssPath=h,console.log(`Generated rss.xml with ${m.length} items`)}let z=Ga(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let W=Ja(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} repeated asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&D.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let et=Zn();if(et)await Y(et,f.join(e.outputDir,Yn)),console.log(`Copied assets from ${Zt}`)}catch(E){throw await e.hooks.onError?.(E),E}if(u.buildTime=Date.now()-r,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let E={generatedChunks:g.size,totalBytes:v,chunks:x,pages:p};await Bun.write(f.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(E,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
72
+ </html>`)}for(let d of[500]){let m=f.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},G=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),G)}}let V=f.join(e.pagesDir,"error.stx");if(await Bun.file(V).exists()){let d=new Set,m={...s,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(V).text(),{},V,m,d);await Bun.write(f.join(e.outputDir,"error.html"),k)}if(e.sitemap&&_.length>0){let d=qt(_,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],k=Ts({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...m.length>0?{disallow:m}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(f.join(e.outputDir,"robots.txt"),k),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(d.getItems)m=await d.getItems();let k=Jt(d,m),h=f.join(e.outputDir,"rss.xml");await Bun.write(h,k),u.rssPath=h,console.log(`Generated rss.xml with ${m.length} items`)}let z=Za(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let W=Qa(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} repeated asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&D.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let et=Zn();if(et)await Y(et,f.join(e.outputDir,Yn)),console.log(`Copied assets from ${Zt}`)}catch(E){throw await e.hooks.onError?.(E),E}if(u.buildTime=Date.now()-n,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let E={generatedChunks:g.size,totalBytes:v,chunks:x,pages:p};await Bun.write(f.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(E,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
73
73
  Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
74
74
  Build complete!
75
75
  Total: ${u.totalPages} pages
@@ -77,8 +77,8 @@ Build complete!
77
77
  Cached: ${u.cachedCount}
78
78
  Failed: ${u.failedCount}
79
79
  Time: ${u.buildTime}ms${P}
80
- `),u}async function Y(t,r){await D.promises.mkdir(r,{recursive:!0});let n=await D.promises.readdir(t,{withFileTypes:!0});for(let o of n){let c=f.join(t,o.name),e=f.join(r,o.name);if(o.isDirectory())await D.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await D.promises.copyFile(c,e)}}function Kt(t={}){let r=t.cacheDir||l(process.cwd(),"ssg-cache"),n=new ht(r),o=t.revalidate||3600;return{async get(c){let e=await n.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=${o}, stale-while-revalidate=${o*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=X(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let g=c.match(u.regex),v={};if(g)u.params.forEach((P,E)=>{v[P]=g[E+1]});let x=await a(),{html:p}=await mt(u,v,{},t,x);await n.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:zt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await n.invalidate(c);else await n.invalidatePattern(c)}}}function Xt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let r=await Bun.file(t).text(),n=r.match(/^---\n([\s\S]*?)\n---/),o={},c=r;if(n){let x=n[1];c=r.slice(n[0].length).trim();for(let p of x.split(`
81
- `)){let P=p.indexOf(":");if(P>0){let E=p.slice(0,P).trim(),b=p.slice(P+1).trim();if(b==="true")b=!0;else if(b==="false")b=!1;else if(/^\d+$/.test(b))b=parseInt(b,10);else if(/^\d+\.\d+$/.test(b))b=parseFloat(b);else if(b.startsWith("[")&&b.endsWith("]"))b=b.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));o[E]=b}}}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>"),u=[],g=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,v;while((v=g.exec(e))!==null){let x=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:x})}return{content:e,data:o,toc:u}}}}function Yt(t){return yt(t)}function te(t,r){return`<!DOCTYPE html>
80
+ `),u}async function Y(t,n){await D.promises.mkdir(n,{recursive:!0});let s=await D.promises.readdir(t,{withFileTypes:!0});for(let o of s){let c=f.join(t,o.name),e=f.join(n,o.name);if(o.isDirectory())await D.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await D.promises.copyFile(c,e)}}function Kt(t={}){let n=t.cacheDir||l(process.cwd(),"ssg-cache"),s=new ht(n),o=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=${o}, stale-while-revalidate=${o*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=K(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let g=c.match(u.regex),v={};if(g)u.params.forEach((P,E)=>{v[P]=g[E+1]});let x=await a(),{html:p}=await mt(u,v,{},t,x);await s.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:zt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Xt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let n=await Bun.file(t).text(),s=n.match(/^---\n([\s\S]*?)\n---/),o={},c=n;if(s){let x=s[1];c=n.slice(s[0].length).trim();for(let p of x.split(`
81
+ `)){let P=p.indexOf(":");if(P>0){let E=p.slice(0,P).trim(),b=p.slice(P+1).trim();if(b==="true")b=!0;else if(b==="false")b=!1;else if(/^\d+$/.test(b))b=parseInt(b,10);else if(/^\d+\.\d+$/.test(b))b=parseFloat(b);else if(b.startsWith("[")&&b.endsWith("]"))b=b.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));o[E]=b}}}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>"),u=[],g=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,v;while((v=g.exec(e))!==null){let x=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:x})}return{content:e,data:o,toc:u}}}}function Yt(t){return yt(t)}function te(t,n){return`<!DOCTYPE html>
82
82
  <html>
83
83
  <head>
84
84
  <meta charset="utf-8">
@@ -90,4 +90,4 @@ Build complete!
90
90
  <p>Redirecting to <a href="${t}">${t}</a>...</p>
91
91
  <script>window.location.replace('${t}')</script>
92
92
  </body>
93
- </html>`}function ee(t,r){if(t==="/"||t==="")return f.join(r.outputDir,"index.html");let n=t.replace(/^\/|\/$/g,"");if(r.trailingSlash)return f.join(r.outputDir,n,"index.html");return f.join(r.outputDir,`${n}.html`)}var Te={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:q,createMarkdownLoader:Xt};export{Kt as createISRHandler,Xt as createMarkdownLoader,Nt as declaresPageAction,Te as default,q as defineStaticPaths,Vt as generateStaticSite,Wt as isExcludedFromSitemap};
93
+ </html>`}function ee(t,n){if(t==="/"||t==="")return f.join(n.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(n.trailingSlash)return f.join(n.outputDir,s,"index.html");return f.join(n.outputDir,`${s}.html`)}var Te={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:q,createMarkdownLoader:Xt};export{Kt as createISRHandler,Xt as createMarkdownLoader,Nt as declaresPageAction,Te as default,q as defineStaticPaths,Vt as generateStaticSite,Wt as isExcludedFromSitemap};
@@ -25,7 +25,8 @@ export declare function maskNonTemplateRegions(source: string): string;
25
25
  export declare function stripFilterChain(expression: string): string;
26
26
  export declare function substituteInterpolations(value: string): string;
27
27
  /**
28
- * The same substitution, but the result occupies the same space as the source.
28
+ * Legacy text-only substitution; retained for callers that do not check types.
29
+ * The checker uses projectScriptInterpolations and its edit map instead.
29
30
  *
30
31
  * A `<script client>` block may take a server value through an interpolation —
31
32
  * `const duration = {{ duration }}` — and 48 of the framework's own 95
@@ -45,6 +46,16 @@ export declare function substituteInterpolations(value: string): string;
45
46
  * fit and would shift the line.
46
47
  */
47
48
  export declare function substituteInterpolationsInPlace(code: string): string;
49
+ /**
50
+ * Infer interpolations inside the server's lexical scope, never by running it.
51
+ * A long generated identifier may not fit in `{{a}}`; keep newlines in place
52
+ * and record the changed columns instead of fabricating a short numeric value.
53
+ */
54
+ export declare function projectScriptInterpolations(code: string, serverCode: string, key?: string): ScriptProjection;
55
+ /** Map a generated script column back across all preceding edits on its line. */
56
+ export declare function resolveScriptColumn(edits: readonly ScriptColumnEdit[], column: number): number;
57
+ /** The inverse used by editor hover/completions as well as diagnostics. */
58
+ export declare function projectScriptColumn(edits: readonly ScriptColumnEdit[], column: number): number;
48
59
  /**
49
60
  * Blank stx directives that a script body writes to generate JavaScript.
50
61
  *
@@ -403,6 +414,19 @@ export declare interface VirtualFile {
403
414
  referenced?: boolean
404
415
  lineMap: Map<number, MappedLine>
405
416
  sourceLineCount: number
417
+ scriptColumns?: Map<number, ScriptColumnEdit[]>
418
+ }
419
+ /** A width-changing edit on one script line; untouched columns keep their offset. */
420
+ export declare interface ScriptColumnEdit {
421
+ sourceStart: number
422
+ sourceEnd: number
423
+ generatedStart: number
424
+ generatedEnd: number
425
+ }
426
+ declare interface ScriptProjection {
427
+ code: string
428
+ columns: Map<number, ScriptColumnEdit[]>
429
+ declarations: Array<{ text: string, origin?: MappedLine }>
406
430
  }
407
431
  /**
408
432
  * Names a template introduces that no script block declares.
@@ -112,6 +112,98 @@ export function substituteInterpolationsInPlace(code) {
112
112
  `.repeat(newlines)}`;
113
113
  });
114
114
  }
115
+ export function projectScriptInterpolations(code, serverCode, key = "0") {
116
+ let prefix = `__stxScript${key}`;
117
+ while ((code + serverCode).includes(prefix))
118
+ prefix += "_";
119
+ const columns = new Map, declarations = [], expressions = [], searchable = stripCommentsAndLiterals(code), starts = lineStarts(code), chunks = [];
120
+ let cursor = 0;
121
+ for (const found of searchable.matchAll(/\{\{([\s\S]*?)\}\}|\{!!([\s\S]*?)!!\}/g)) {
122
+ const offset = found.index, match = code.slice(offset, offset + found[0].length), escaped = found[1] !== void 0, expression = match.slice(escaped ? 2 : 3, escaped ? -2 : -3), index = expressions.length, position = offsetToPosition(starts, offset), origin = offsetToPosition(starts, offset + (escaped ? 2 : 3));
123
+ expressions.push({ code: stripFilterChain(expression), ...origin });
124
+ const name = `${prefix}_${index}`, pieces = match.split(`
125
+ `), firstWidth = pieces[0].length;
126
+ pieces[0] = name + " ".repeat(Math.max(0, firstWidth - name.length));
127
+ for (let i = 1;i < pieces.length; i++)
128
+ pieces[i] = pieces[i].replace(/[^\r]/g, " ");
129
+ const edits = columns.get(position.line) ?? [], previous = edits.at(-1), generatedStart = position.column + (previous ? previous.generatedEnd - previous.sourceEnd : 0);
130
+ edits.push({ sourceStart: position.column, sourceEnd: position.column + firstWidth, generatedStart, generatedEnd: generatedStart + pieces[0].length });
131
+ columns.set(position.line, edits);
132
+ chunks.push(code.slice(cursor, offset), pieces.join(`
133
+ `));
134
+ cursor = offset + match.length;
135
+ }
136
+ chunks.push(code.slice(cursor));
137
+ const projected = chunks.join("");
138
+ if (!expressions.length)
139
+ return { code: projected, columns, declarations };
140
+ const { imports, body } = splitTopLevelImports(serverCode), aliases = [];
141
+ let moduleIndex = 0;
142
+ for (const statement of imports.split(/\n(?=import\b)/)) {
143
+ if (!statement.trim())
144
+ continue;
145
+ const from = /^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(statement);
146
+ if (!from) {
147
+ declarations.push({ text: statement });
148
+ continue;
149
+ }
150
+ const module = `${prefix}Module${moduleIndex++}`;
151
+ declarations.push({ text: `import * as ${module} from ${from[2]}` });
152
+ const clause = from[1], named = /\{([\s\S]*?)\}/.exec(clause);
153
+ for (const entry of named?.[1].split(",") ?? []) {
154
+ const [imported, local = imported] = entry.trim().replace(/^type\s+/, "").split(/\s+as\s+/);
155
+ if (imported === "default")
156
+ aliases.push(`const ${local} = ${module}.default; type ${local} = import(${from[2]}).default`);
157
+ else if (imported)
158
+ aliases.push(`import ${local} = ${module}.${imported}`);
159
+ }
160
+ const rest = clause.replace(/\{[\s\S]*?\}/, ""), namespace = /\*\s+as\s+(\w+)/.exec(rest);
161
+ if (namespace)
162
+ aliases.push(`import ${namespace[1]} = ${module}`);
163
+ const defaultName = /^\s*([\w$]+)/.exec(rest)?.[1];
164
+ if (defaultName)
165
+ aliases.push(`const ${defaultName} = ${module}.default; type ${defaultName} = import(${from[2]}).default`);
166
+ }
167
+ declarations.push({ text: `namespace ${prefix}Scope {
168
+ ${aliases.join(`
169
+ `)}
170
+ export async function read() {
171
+ ${blankScriptDirectives(body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm, "")}
172
+ return {` });
173
+ for (const [index, expression] of expressions.entries()) {
174
+ declarations.push({ text: `value${index}: (` });
175
+ declarations.push({ text: expression.code, origin: { line: expression.line, column: expression.column } });
176
+ declarations.push({ text: ")," });
177
+ }
178
+ declarations.push({ text: `}
179
+ }
180
+ }` });
181
+ for (let index = 0;index < expressions.length; index++)
182
+ declarations.push({ text: `declare var ${prefix}_${index}: Awaited<ReturnType<typeof ${prefix}Scope.read>>['value${index}']` });
183
+ return { code: projected, columns, declarations };
184
+ }
185
+ export function resolveScriptColumn(edits, column) {
186
+ let delta = 0;
187
+ for (const edit of edits) {
188
+ if (column < edit.generatedStart)
189
+ break;
190
+ if (column < edit.generatedEnd)
191
+ return edit.sourceStart + Math.min(column - edit.generatedStart, edit.sourceEnd - edit.sourceStart);
192
+ delta = edit.sourceEnd - edit.generatedEnd;
193
+ }
194
+ return column + delta;
195
+ }
196
+ export function projectScriptColumn(edits, column) {
197
+ let delta = 0;
198
+ for (const edit of edits) {
199
+ if (column < edit.sourceStart)
200
+ break;
201
+ if (column < edit.sourceEnd)
202
+ return edit.generatedStart + Math.min(column - edit.sourceStart, edit.generatedEnd - edit.generatedStart);
203
+ delta = edit.generatedEnd - edit.sourceEnd;
204
+ }
205
+ return column + delta;
206
+ }
115
207
  const SCRIPT_BODY_DIRECTIVES = [
116
208
  "foreach",
117
209
  "endforeach",
@@ -686,7 +778,8 @@ export function collectImportedNames(code) {
686
778
  }
687
779
  export function buildVirtualTypeScript(source, options = {}) {
688
780
  const blocks = extractScriptBlocks(source), sourceLines = source.split(`
689
- `), lines = Array.from({ length: sourceLines.length }, () => ""), lineMap = new Map, components = options.filePath && options.templateExpressions !== !1 ? componentContractChecks(source, maskNonTemplateRegions(source), {
781
+ `), lines = Array.from({ length: sourceLines.length }, () => ""), lineMap = new Map, scriptColumns = new Map, scriptDeclarations = [], serverCode = blocks.filter((block) => block.kind === "server").map((block) => block.code).join(`
782
+ `), components = options.filePath && options.templateExpressions !== !1 ? componentContractChecks(source, maskNonTemplateRegions(source), {
690
783
  filePath: options.filePath,
691
784
  componentsDir: options.componentsDir,
692
785
  projectRoot: options.projectRoot,
@@ -694,13 +787,21 @@ export function buildVirtualTypeScript(source, options = {}) {
694
787
  scriptCode: (text, file) => extractScriptBlocks(text).map((block) => absolutizeRelativeSpecifiers(block.code, path.dirname(file))).join(`
695
788
  `)
696
789
  }) : void 0, occupied = new Set, blockEnds = [];
697
- for (const block of blocks) {
698
- const code = blankScriptDirectives(substituteInterpolationsInPlace(block.code)), bodyLines = absolutizeRelativeSpecifiers(code, options.originDir ?? "").split(`
790
+ for (const [blockIndex, block] of blocks.entries()) {
791
+ const projection = projectScriptInterpolations(firstLinePadding(block) + block.code, serverCode, String(blockIndex));
792
+ for (const [line, edits] of projection.columns)
793
+ scriptColumns.set(block.startLine + line - 1, edits);
794
+ for (const declaration of projection.declarations)
795
+ scriptDeclarations.push({
796
+ text: absolutizeRelativeSpecifiers(declaration.text, options.originDir ?? ""),
797
+ origin: declaration.origin ? { ...declaration.origin, line: declaration.origin.line + block.startLine - 1 } : void 0
798
+ });
799
+ const code = blankScriptDirectives(projection.code), bodyLines = absolutizeRelativeSpecifiers(code, options.originDir ?? "").split(`
699
800
  `);
700
801
  bodyLines.forEach((text, i) => {
701
802
  const index = block.startLine - 1 + i;
702
803
  if (index < lines.length) {
703
- lines[index] = i === 0 ? firstLinePadding(block) + text : text;
804
+ lines[index] = text;
704
805
  occupied.add(index);
705
806
  }
706
807
  });
@@ -719,6 +820,8 @@ export function buildVirtualTypeScript(source, options = {}) {
719
820
  lineMap.set(lines.length, index === 0 ? origin : { ...origin, line: origin.line + index, column: 1, prefixLength: 0 });
720
821
  }
721
822
  };
823
+ for (const declaration of scriptDeclarations)
824
+ append(declaration.text, declaration.origin);
722
825
  if (options.globals !== !1) {
723
826
  append("");
724
827
  const bound = new Set([
@@ -806,7 +909,7 @@ export function buildVirtualTypeScript(source, options = {}) {
806
909
  }
807
910
  append("export {}");
808
911
  return { text: lines.join(`
809
- `), lineMap, sourceLineCount: sourceLines.length, componentDependencies: components?.dependencies, referenced };
912
+ `), lineMap, sourceLineCount: sourceLines.length, componentDependencies: components?.dependencies, referenced, scriptColumns };
810
913
  }
811
914
  export function lineStarts(text) {
812
915
  const starts = [0];
@@ -838,7 +941,7 @@ export function isTemplateArtefact(position, code) {
838
941
  export function resolvePosition(virtual, line, column) {
839
942
  const mapped = virtual.lineMap.get(line);
840
943
  if (!mapped)
841
- return line <= virtual.sourceLineCount ? { line, column } : null;
944
+ return line <= virtual.sourceLineCount ? { line, column: resolveScriptColumn(virtual.scriptColumns?.get(line) ?? [], column) } : null;
842
945
  const within = mapped.expression?.anchor ? 0 : Math.max(0, column - 1 - (mapped.prefixLength ?? 0));
843
946
  return {
844
947
  line: mapped.line,
@@ -1,5 +1,5 @@
1
1
  import { extractScriptBlocks } from './stx-virtual-ts';
2
- import type { ScriptBlock, ScriptKind } from './stx-virtual-ts';
2
+ import type { ScriptBlock, ScriptKind, VirtualFile } from './stx-virtual-ts';
3
3
  export type { ScriptBlock, ScriptKind } from './stx-virtual-ts';
4
4
  /**
5
5
  * Build the virtual TypeScript source for one block.
@@ -20,6 +20,8 @@ export type { ScriptBlock, ScriptKind } from './stx-virtual-ts';
20
20
  * against the file containing it — so without this, `../target` was looked for
21
21
  * next to `.stx/typecheck/` (#1928).
22
22
  */
23
+ export declare function buildScriptVirtualFile(block: ScriptBlock, serverCode?: string, originDir?: string): VirtualFile;
24
+ /** Compatibility string surface; checking also retains the source edit map. */
23
25
  export declare function buildVirtualSource(block: ScriptBlock, serverCode?: string, originDir?: string): string;
24
26
  /** Virtual path for a block, stable and traceable back to its origin. */
25
27
  export declare function virtualPathFor(filePath: string, kind: DiagnosticOrigin, index: number): string;