@stacksjs/stx 0.2.874 → 0.2.875

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 (244) hide show
  1. package/dist/chunk-003ph86a.js +2 -0
  2. package/dist/chunk-027meh1k.js +2 -0
  3. package/dist/chunk-0bc3mwqd.js +2 -0
  4. package/dist/{chunk-gbtbfg7e.js → chunk-0g2mg8cw.js} +3 -3
  5. package/dist/chunk-0gv2mmr0.js +2 -0
  6. package/dist/{chunk-c8jhskx8.js → chunk-0h6r7nvn.js} +38 -38
  7. package/dist/chunk-0j8zre1m.js +2 -0
  8. package/dist/{chunk-vxtx0khv.js → chunk-0qwbhv3f.js} +9 -9
  9. package/dist/{chunk-6mkn81pd.js → chunk-0sa9gqmc.js} +7 -7
  10. package/dist/chunk-1gfg6qmr.js +2 -0
  11. package/dist/{chunk-6ftee542.js → chunk-1q5w3xav.js} +2 -2
  12. package/dist/chunk-1tqp2s13.js +2 -0
  13. package/dist/chunk-1y7kfp5d.js +2 -0
  14. package/dist/chunk-1ztp5vkh.js +3 -0
  15. package/dist/chunk-24e4dapm.js +2 -0
  16. package/dist/{chunk-c3kanj1m.js → chunk-2qb9kp21.js} +3 -3
  17. package/dist/{chunk-01mwbg1r.js → chunk-2zaatnnh.js} +4 -4
  18. package/dist/chunk-32wvc376.js +2 -0
  19. package/dist/{chunk-gxan9w4e.js → chunk-3f9wctns.js} +2 -2
  20. package/dist/{chunk-v4xes880.js → chunk-3mz9bdf7.js} +3 -3
  21. package/dist/chunk-3te2y9qf.js +2 -0
  22. package/dist/{chunk-farh4p7f.js → chunk-3w7gacva.js} +2 -2
  23. package/dist/chunk-447jc6zc.js +2 -0
  24. package/dist/{chunk-s584xnzx.js → chunk-4517hny7.js} +2 -2
  25. package/dist/chunk-45rzd16g.js +1609 -0
  26. package/dist/{chunk-p1a1kbhz.js → chunk-4m11kcxz.js} +8 -8
  27. package/dist/chunk-51ymssz5.js +2 -0
  28. package/dist/{chunk-a0dsp485.js → chunk-644ckv6e.js} +10 -10
  29. package/dist/{chunk-2xc457bf.js → chunk-6az66mrc.js} +14 -14
  30. package/dist/chunk-6dz5za5z.js +2 -0
  31. package/dist/{chunk-fr72bsqd.js → chunk-6ezt9kbe.js} +11 -11
  32. package/dist/chunk-6grkdknk.js +2 -0
  33. package/dist/chunk-6q9a5bph.js +2 -0
  34. package/dist/chunk-6rqef7wp.js +2 -0
  35. package/dist/{chunk-atpscb2m.js → chunk-6ykfy7eh.js} +2 -2
  36. package/dist/{chunk-wa3z5c8j.js → chunk-72p5annm.js} +4 -4
  37. package/dist/chunk-74x6j229.js +4 -0
  38. package/dist/{chunk-n3jw3xpj.js → chunk-75v0yxeh.js} +2 -2
  39. package/dist/chunk-7j11vgm1.js +3 -0
  40. package/dist/chunk-7ngfcdv9.js +2 -0
  41. package/dist/chunk-7njy024g.js +2 -0
  42. package/dist/{chunk-b8z3vepm.js → chunk-88xayf21.js} +9 -9
  43. package/dist/{chunk-w5nw8e2p.js → chunk-95hbmv7k.js} +7 -7
  44. package/dist/{chunk-nack2xs5.js → chunk-976kgb3r.js} +5 -5
  45. package/dist/{chunk-ykapdv6d.js → chunk-9anqwafq.js} +3 -3
  46. package/dist/chunk-9e3ggwk7.js +2 -0
  47. package/dist/chunk-9mz2n39m.js +2 -0
  48. package/dist/chunk-a262spx7.js +2 -0
  49. package/dist/{chunk-xakypz4t.js → chunk-a5yb8w7s.js} +3 -3
  50. package/dist/chunk-a8wn0snv.js +2 -0
  51. package/dist/{chunk-55zq2ha8.js → chunk-ae8q4gze.js} +5 -5
  52. package/dist/{chunk-n56x7jg8.js → chunk-af6m1s2b.js} +1 -1
  53. package/dist/{chunk-hev4t4d5.js → chunk-afxfkb60.js} +6 -6
  54. package/dist/{chunk-kdmwy40c.js → chunk-az5rh7fs.js} +2 -2
  55. package/dist/chunk-b1tcym2x.js +2 -0
  56. package/dist/{chunk-j1efsjsb.js → chunk-b4d4tjvx.js} +5 -5
  57. package/dist/{chunk-pqgc8k6k.js → chunk-b61dq7pz.js} +1 -1
  58. package/dist/{chunk-j89p53vx.js → chunk-bdh73gxd.js} +2 -2
  59. package/dist/{chunk-4068rmzv.js → chunk-bjjfr7qt.js} +2 -2
  60. package/dist/chunk-bs7g6jtt.js +2 -0
  61. package/dist/chunk-bspj1rf1.js +2 -0
  62. package/dist/chunk-bx3hpsxn.js +2 -0
  63. package/dist/chunk-byq488g4.js +2 -0
  64. package/dist/chunk-c8pzj57b.js +2 -0
  65. package/dist/{chunk-79mmzprp.js → chunk-cmh0bfkb.js} +5 -5
  66. package/dist/{chunk-7j0qkye5.js → chunk-d3q0cg47.js} +2 -2
  67. package/dist/{chunk-b666d8m6.js → chunk-d6gqh2wv.js} +1 -1
  68. package/dist/{chunk-vvxcebpn.js → chunk-dbvsa5ya.js} +2 -2
  69. package/dist/{chunk-zt9j94ak.js → chunk-dw0ttj6p.js} +2 -2
  70. package/dist/chunk-e2b2f502.js +2 -0
  71. package/dist/chunk-ec6mrad6.js +2 -0
  72. package/dist/chunk-eh2gec79.js +2 -0
  73. package/dist/{chunk-8hhhmscy.js → chunk-eknm4jrm.js} +2 -2
  74. package/dist/chunk-em31p5pb.js +2 -0
  75. package/dist/chunk-eqfsw6x4.js +2 -0
  76. package/dist/{chunk-4nb7egk0.js → chunk-esjr9qhe.js} +2 -2
  77. package/dist/chunk-ey1vwfpc.js +24 -0
  78. package/dist/{chunk-wk2rge05.js → chunk-f4vgagjb.js} +3 -3
  79. package/dist/chunk-fa57bncd.js +2 -0
  80. package/dist/{chunk-qjey0jk6.js → chunk-fdjx4vs3.js} +2 -2
  81. package/dist/chunk-fk79jbzn.js +2 -0
  82. package/dist/{chunk-pqy58ps0.js → chunk-fnjm3xbf.js} +6 -6
  83. package/dist/{chunk-zfrzdje6.js → chunk-ft6em3wm.js} +6 -6
  84. package/dist/{chunk-bv9dbf4m.js → chunk-fy6ts0n4.js} +2 -2
  85. package/dist/{chunk-hr147ys5.js → chunk-g33ycxe3.js} +5 -5
  86. package/dist/{chunk-p219rr27.js → chunk-g7qpnmbm.js} +14 -14
  87. package/dist/chunk-g97krv0d.js +2 -0
  88. package/dist/chunk-gn16yq49.js +2 -0
  89. package/dist/{chunk-qcxrcypb.js → chunk-gqtb53s8.js} +2 -2
  90. package/dist/chunk-gvs61tqn.js +2 -0
  91. package/dist/chunk-h2928108.js +2 -0
  92. package/dist/chunk-hd5bny2c.js +2 -0
  93. package/dist/chunk-j1ytbd6r.js +1184 -0
  94. package/dist/chunk-jm7qa3v3.js +2 -0
  95. package/dist/chunk-jmjgj3nh.js +2 -0
  96. package/dist/chunk-jqtpzzz4.js +12 -0
  97. package/dist/{chunk-hmdkf6c6.js → chunk-jqxerj6k.js} +2 -2
  98. package/dist/{chunk-3z1mmar2.js → chunk-jt5tzddc.js} +2 -2
  99. package/dist/{chunk-q50x1gfd.js → chunk-k1ew643q.js} +2 -2
  100. package/dist/chunk-kq8mffgf.js +2 -0
  101. package/dist/chunk-kx06jzdw.js +2 -0
  102. package/dist/{chunk-ysfeg3cn.js → chunk-kywe0f1v.js} +2 -2
  103. package/dist/{chunk-60yppcbb.js → chunk-kzc2tqzr.js} +2 -2
  104. package/dist/{chunk-9zrvh3pz.js → chunk-mce3g2wb.js} +2 -2
  105. package/dist/{chunk-bbq79tap.js → chunk-mw0rb1sf.js} +4 -4
  106. package/dist/chunk-n344ss97.js +2 -0
  107. package/dist/chunk-n5pvdrkb.js +2 -0
  108. package/dist/chunk-ne8q191s.js +2 -0
  109. package/dist/{chunk-e7s109j6.js → chunk-nnp6rf4c.js} +1 -1
  110. package/dist/chunk-np8wgbsa.js +3 -0
  111. package/dist/{chunk-tyvm49be.js → chunk-nv4c25zj.js} +3 -3
  112. package/dist/{chunk-xdfmrv49.js → chunk-p4e8myzj.js} +6 -6
  113. package/dist/{chunk-dhbpbjt3.js → chunk-p5m1z6e1.js} +6 -6
  114. package/dist/{chunk-18a3vdnq.js → chunk-pk714ynv.js} +4 -4
  115. package/dist/{chunk-csymxc5a.js → chunk-pp99rmjm.js} +15 -15
  116. package/dist/chunk-pqmjeea6.js +2 -0
  117. package/dist/chunk-q0k2gmva.js +2 -0
  118. package/dist/{chunk-3z4p70t5.js → chunk-q7zc78az.js} +6 -6
  119. package/dist/chunk-qggwr60r.js +2 -0
  120. package/dist/chunk-qm3v4qb7.js +2 -0
  121. package/dist/{chunk-40h07m5w.js → chunk-qnwd5bz4.js} +1 -1
  122. package/dist/chunk-qrn1nza9.js +2 -0
  123. package/dist/chunk-qty0t69x.js +2 -0
  124. package/dist/{chunk-tabkp672.js → chunk-qvrew79n.js} +1 -1
  125. package/dist/{chunk-tnp2ta5q.js → chunk-r09kz9bf.js} +2 -2
  126. package/dist/{chunk-q1wxgw5s.js → chunk-r2bxjna3.js} +2 -2
  127. package/dist/chunk-rzadf7vx.js +20 -0
  128. package/dist/{chunk-6vgr5g6d.js → chunk-rzd9hyhv.js} +2 -2
  129. package/dist/{chunk-8tk8yf91.js → chunk-s7fhpkvf.js} +6 -6
  130. package/dist/{chunk-ew5cey88.js → chunk-saqzk45g.js} +1 -1
  131. package/dist/{chunk-srgnevws.js → chunk-stn7p7f1.js} +2 -2
  132. package/dist/{chunk-bast33qy.js → chunk-t4g3ka8c.js} +6 -6
  133. package/dist/chunk-ts37jw3s.js +2 -0
  134. package/dist/{chunk-cqhwzd9y.js → chunk-v0tdg16k.js} +5 -5
  135. package/dist/{chunk-0k11nsv1.js → chunk-vmssv78v.js} +3 -3
  136. package/dist/{chunk-ymdw4fhd.js → chunk-vnrbjbrw.js} +2 -2
  137. package/dist/{chunk-ttm0gvrc.js → chunk-vznf808n.js} +5 -5
  138. package/dist/chunk-wkb7dhp7.js +2 -0
  139. package/dist/{chunk-m131znxe.js → chunk-wm029dh0.js} +13 -13
  140. package/dist/{chunk-hhbt8grm.js → chunk-wp0qpa50.js} +4 -4
  141. package/dist/chunk-wxyqp6g9.js +2 -0
  142. package/dist/{chunk-01c16zw4.js → chunk-wzvdr4ta.js} +2 -2
  143. package/dist/{chunk-e2t7mk29.js → chunk-x2ftkaz3.js} +2 -2
  144. package/dist/chunk-x76qvq1n.js +2 -0
  145. package/dist/{chunk-v37zmez0.js → chunk-xmws1gaf.js} +2 -2
  146. package/dist/{chunk-a8164hnf.js → chunk-xtaq95em.js} +1 -1
  147. package/dist/{chunk-5a0d3048.js → chunk-y2e2zm6y.js} +3 -3
  148. package/dist/chunk-y4hn1qh0.js +2 -0
  149. package/dist/{chunk-pywz8q4k.js → chunk-y75bds1g.js} +31 -31
  150. package/dist/chunk-yc8ggeh2.js +2 -0
  151. package/dist/{chunk-r0v2chpn.js → chunk-ydppkb8y.js} +2 -2
  152. package/dist/chunk-ydy0tfar.js +2 -0
  153. package/dist/chunk-yfed67yc.js +2 -0
  154. package/dist/{chunk-7ayvybdy.js → chunk-ysfgabpf.js} +3 -3
  155. package/dist/{chunk-fd1bpv35.js → chunk-yxdhz4ps.js} +2 -2
  156. package/dist/{chunk-rw5492e2.js → chunk-zc8a2erc.js} +4 -4
  157. package/dist/{chunk-7cvbz4eq.js → chunk-zn6n075d.js} +3 -3
  158. package/dist/cli.js +22 -22
  159. package/dist/component-library.d.ts +31 -1
  160. package/dist/component-library.js +74 -54
  161. package/dist/craft-entry.js +2 -2
  162. package/dist/craft.js +2 -2
  163. package/dist/inherited-context.d.ts +14 -0
  164. package/dist/inherited-context.js +102 -0
  165. package/dist/native-component-context.d.ts +10 -0
  166. package/dist/native-component-context.js +94 -0
  167. package/dist/pwa.js +3 -3
  168. package/dist/ssg.js +12 -12
  169. package/dist/stx-virtual-ts.d.ts +14 -2
  170. package/dist/stx-virtual-ts.js +64 -34
  171. package/dist/typecheck.d.ts +5 -2
  172. package/dist/typecheck.js +29 -19
  173. package/package.json +5 -5
  174. package/dist/chunk-09jz09k9.js +0 -20
  175. package/dist/chunk-10h8v5d4.js +0 -2
  176. package/dist/chunk-19dsn6tp.js +0 -2
  177. package/dist/chunk-26vxgd2w.js +0 -2
  178. package/dist/chunk-277dpq3b.js +0 -2
  179. package/dist/chunk-2asyyky3.js +0 -2
  180. package/dist/chunk-2r9s38f6.js +0 -2
  181. package/dist/chunk-2xhwadvn.js +0 -2
  182. package/dist/chunk-46pxmpeb.js +0 -3
  183. package/dist/chunk-4es07dwb.js +0 -2
  184. package/dist/chunk-4pr29yrx.js +0 -2
  185. package/dist/chunk-4v70bs2q.js +0 -2
  186. package/dist/chunk-4ygesqbx.js +0 -2
  187. package/dist/chunk-54jx5hqh.js +0 -2
  188. package/dist/chunk-5nj2k8zf.js +0 -2
  189. package/dist/chunk-6pczzq5f.js +0 -2
  190. package/dist/chunk-73k579v7.js +0 -2
  191. package/dist/chunk-7c9pzpsw.js +0 -2
  192. package/dist/chunk-7etvn4dx.js +0 -2
  193. package/dist/chunk-7wqevtks.js +0 -2
  194. package/dist/chunk-93538x9s.js +0 -2
  195. package/dist/chunk-9fyw1xkh.js +0 -3
  196. package/dist/chunk-9waxasf6.js +0 -712
  197. package/dist/chunk-a5qxcz86.js +0 -4
  198. package/dist/chunk-asrzmw7w.js +0 -2
  199. package/dist/chunk-awmfyb3t.js +0 -2
  200. package/dist/chunk-ba91r7q9.js +0 -2
  201. package/dist/chunk-cvgbtmxp.js +0 -2
  202. package/dist/chunk-d0h18m2r.js +0 -2
  203. package/dist/chunk-d5zh2663.js +0 -2
  204. package/dist/chunk-djdganvr.js +0 -2
  205. package/dist/chunk-dmcmxf3a.js +0 -2
  206. package/dist/chunk-eczy00w6.js +0 -2
  207. package/dist/chunk-esb34a1r.js +0 -20
  208. package/dist/chunk-f4wezqh4.js +0 -2
  209. package/dist/chunk-f52b9hjv.js +0 -2
  210. package/dist/chunk-f8pp58kw.js +0 -2
  211. package/dist/chunk-g3tfct27.js +0 -2
  212. package/dist/chunk-g9m84nqk.js +0 -2
  213. package/dist/chunk-gc4bgven.js +0 -2
  214. package/dist/chunk-gvh45ddc.js +0 -2
  215. package/dist/chunk-gvz0kqkz.js +0 -2
  216. package/dist/chunk-h2qgqjkn.js +0 -2
  217. package/dist/chunk-hcaedzck.js +0 -2
  218. package/dist/chunk-j4zrq17p.js +0 -2
  219. package/dist/chunk-kz0txvqb.js +0 -2
  220. package/dist/chunk-m9cperj4.js +0 -2
  221. package/dist/chunk-me7cxs0e.js +0 -2
  222. package/dist/chunk-meqsd5bt.js +0 -2
  223. package/dist/chunk-p2kqsb5k.js +0 -2
  224. package/dist/chunk-pvrgv5cx.js +0 -2051
  225. package/dist/chunk-rqa92xm4.js +0 -2
  226. package/dist/chunk-s54e61xt.js +0 -2
  227. package/dist/chunk-s92j8k4z.js +0 -2
  228. package/dist/chunk-sw8ms82g.js +0 -2
  229. package/dist/chunk-swfvh1cz.js +0 -3
  230. package/dist/chunk-tp2ftck2.js +0 -2
  231. package/dist/chunk-vd679g2w.js +0 -2
  232. package/dist/chunk-vk98r75z.js +0 -2
  233. package/dist/chunk-vmq773pb.js +0 -2
  234. package/dist/chunk-vv65gsys.js +0 -2
  235. package/dist/chunk-w6ry02z8.js +0 -2
  236. package/dist/chunk-w8qr5414.js +0 -2
  237. package/dist/chunk-xjxcwrqs.js +0 -2
  238. package/dist/chunk-xye2mkbh.js +0 -2
  239. package/dist/chunk-ytzzth34.js +0 -2
  240. package/dist/chunk-yxpjj003.js +0 -2
  241. package/dist/chunk-z6c4c951.js +0 -2
  242. package/dist/chunk-z9xe3xkg.js +0 -12
  243. package/dist/chunk-zmfqx1b1.js +0 -2
  244. package/dist/chunk-zze8tw0h.js +0 -2
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{ao,Xt,Ml,Vg}from"./chunk-18a3vdnq.js";import{io,Hi,Fg,zg,Hg}from"./chunk-zfrzdje6.js";import{Ol,Nl,Dl,jg,Bg}from"./chunk-r0v2chpn.js";import{Ge,Nn,Vi}from"./chunk-tyvm49be.js";import{Ug,Wg,qg,Kg,co,Py}from"./chunk-srgnevws.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-g3tfct27.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{uo,Gt,Bl,qg}from"./chunk-pk714ynv.js";import{lo,Ki,Vg,Ug,Wg}from"./chunk-ft6em3wm.js";import{Ml,Ll,jl,zg,Hg}from"./chunk-ydppkb8y.js";import{Je,Dn,Gi}from"./chunk-nv4c25zj.js";import{Kg,Gg,Xg,Jg,po,Ny}from"./chunk-stn7p7f1.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-hd5bny2c.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=Ge(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=ao(n,t);if(a){let s=Xt(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 Hi(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,Nl as auditBuildOutput,Ol as auditConfig,re as buildPwaAssets,Dl as calculateAuditResult,Bg as formatAuditResult,Vi as formatSize,j as generateManifest,_ as generateManifestJson,zg as generateManifestLink,F as generateOfflinePage,Ge as generatePrecacheManifest,Nn as generatePrecacheManifestJs,M as generatePwaIcons,io as generatePwaTags,ao as generateServiceWorker,Vg as generateServiceWorkerAuto,Fg as generateSwRegistrationScript,Hg as generateThemeColorMeta,N as getExpectedIconPaths,Xt as getServiceWorkerFileName,Hi as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Ml as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,co as pwaDirectives,Ug as pwaInstallDirective,qg as pwaOfflineDirective,Kg as pwaPushDirective,Wg as pwaUpdateDirective,Py as registerPwaDirectives,jg 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=Je(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=uo(n,t);if(a){let s=Gt(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 Ki(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,Ll as auditBuildOutput,Ml as auditConfig,re as buildPwaAssets,jl as calculateAuditResult,Hg as formatAuditResult,Gi as formatSize,j as generateManifest,_ as generateManifestJson,Ug as generateManifestLink,F as generateOfflinePage,Je as generatePrecacheManifest,Dn as generatePrecacheManifestJs,M as generatePwaIcons,lo as generatePwaTags,uo as generateServiceWorker,qg as generateServiceWorkerAuto,Vg as generateSwRegistrationScript,Wg as generateThemeColorMeta,N as getExpectedIconPaths,Gt as getServiceWorkerFileName,Ki as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Bl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,po as pwaDirectives,Kg as pwaInstallDirective,Xg as pwaOfflineDirective,Jg as pwaPushDirective,Gg as pwaUpdateDirective,Ny as registerPwaDirectives,zg as runPwaAudit,D as validateManifest};
package/dist/ssg.js CHANGED
@@ -1,21 +1,21 @@
1
1
  // @bun
2
- import"./chunk-9zrvh3pz.js";import{k,yl}from"./chunk-csymxc5a.js";import"./chunk-qjey0jk6.js";import"./chunk-farh4p7f.js";import{Dt,w}from"./chunk-9waxasf6.js";import"./chunk-60yppcbb.js";import"./chunk-atpscb2m.js";import"./chunk-tnp2ta5q.js";import{Rt,At,Pt,It,Ot,Nt}from"./chunk-hhbt8grm.js";import{a}from"./chunk-2xc457bf.js";import{Os}from"./chunk-6mkn81pd.js";import"./chunk-rw5492e2.js";import"./chunk-79mmzprp.js";import{xe,cn,ln}from"./chunk-09jz09k9.js";import"./chunk-zt9j94ak.js";import{x}from"./chunk-a0dsp485.js";import{kt,i}from"./chunk-c8jhskx8.js";import"./chunk-b8z3vepm.js";import"./chunk-fr72bsqd.js";import{vs}from"./chunk-p1a1kbhz.js";import"./chunk-c3kanj1m.js";import"./chunk-q1wxgw5s.js";import{lc,uc,dc}from"./chunk-v4xes880.js";import{on,sr,or}from"./chunk-ymdw4fhd.js";import{an}from"./chunk-tabkp672.js";import"./chunk-swfvh1cz.js";import"./chunk-vvxcebpn.js";import{ee,_e}from"./chunk-w5nw8e2p.js";import"./chunk-a8164hnf.js";import"./chunk-xakypz4t.js";import{l}from"./chunk-46pxmpeb.js";import{r,Y}from"./chunk-z9xe3xkg.js";import{f}from"./chunk-fd1bpv35.js";import R from"fs";import m from"path";import{createHash as vt}from"crypto";function $t(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Et=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ct(t,n={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,o=t.replace(Et,(e,u,g,v)=>{let S=v.trim();if(!S)return e;if(/\bdata-stx-src=/.test(g))return e;if(n.minify)S=$t(S);let p=Ct(S);if(!s.has(p))s.set(p,S);let P=n.integrity?` data-stx-integrity="sha384-${vt("sha384").update(S).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 lt(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=w(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let S=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!S)return t;return t.slice(0,v)+S+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 ut(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 Tt(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=ut(e.default??e);if(u)return u}catch{}}return null}async function dt(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=ut(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await Tt(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 gt(){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 J(t){return async()=>({paths:await t(),fallback:!1})}var Lt;function Ut(t){let n=r(t),{depths:s}=Y(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=k(n,"(",")",o.lastIndex-1),g=n.indexOf("{",u+1),v=k(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=yl(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 pt(t){let n="read";try{let s=await Bun.file(t).text();n="parse";let o=an(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=(Lt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(r(u)))continue;let g=Ut(u);if(/\bdefineStaticPaths\b/.test(r(g))&&Dt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let S=await v();n="result";let p=Array.isArray(S)?{paths:S}:S;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 ft{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,n=""){this.cacheDir=t,this.salt=n}async load(){if(this.loaded)return;let t=m.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 R.promises.mkdir(this.cacheDir,{recursive:!0});let t=m.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=R.statSync(t),o=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of n)if(R.existsSync(e)){let u=R.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=mt(n).some((u)=>R.existsSync(u)),c=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&R.existsSync(u)&&vs(R.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 m.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 R.promises.mkdir(m.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 R.promises.unlink(n)}async invalidatePattern(t){let n=m.join(this.cacheDir,"isr");if(!R.existsSync(n))return;let s=await R.promises.readdir(n);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await R.promises.unlink(m.join(n,o))}}async needsRevalidation(t){let n=await this.get(t);if(!n)return!0;return Date.now()>n.revalidateAfter}}async function _t(t){let n=[];if(!t.isDynamic)n.push({url:t.pattern,params:{}});else{let s=await pt(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 mt(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 mt(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",`
2
+ import"./chunk-mce3g2wb.js";import{k,vl}from"./chunk-pp99rmjm.js";import"./chunk-fdjx4vs3.js";import"./chunk-3w7gacva.js";import{Dt,w}from"./chunk-j1ytbd6r.js";import"./chunk-kzc2tqzr.js";import"./chunk-6ykfy7eh.js";import"./chunk-r09kz9bf.js";import{Rt,At,Pt,It,Ot,Nt}from"./chunk-wp0qpa50.js";import{a}from"./chunk-6az66mrc.js";import{Ns}from"./chunk-0sa9gqmc.js";import"./chunk-zc8a2erc.js";import"./chunk-cmh0bfkb.js";import{ke,cn,ln}from"./chunk-rzadf7vx.js";import"./chunk-dw0ttj6p.js";import{x}from"./chunk-644ckv6e.js";import{kt,i}from"./chunk-0h6r7nvn.js";import"./chunk-88xayf21.js";import"./chunk-6ezt9kbe.js";import{xs}from"./chunk-4m11kcxz.js";import"./chunk-2qb9kp21.js";import"./chunk-r2bxjna3.js";import{pc,fc,gc}from"./chunk-3mz9bdf7.js";import{on,or,ir}from"./chunk-vnrbjbrw.js";import{an}from"./chunk-qvrew79n.js";import"./chunk-7j11vgm1.js";import"./chunk-dbvsa5ya.js";import{Q,Ee}from"./chunk-95hbmv7k.js";import"./chunk-xtaq95em.js";import"./chunk-a5yb8w7s.js";import{l}from"./chunk-np8wgbsa.js";import{n,se}from"./chunk-jqtpzzz4.js";import{f}from"./chunk-yxdhz4ps.js";import R from"fs";import m from"path";import{createHash as vt}from"crypto";function $t(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Et=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ct(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,o=t.replace(Et,(e,u,g,v)=>{let S=v.trim();if(!S)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)S=$t(S);let p=Ct(S);if(!s.has(p))s.set(p,S);let P=r.integrity?` data-stx-integrity="sha384-${vt("sha384").update(S).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 lt(t){if(!t.includes("data-stx-src="))return t;let r=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=s.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=w(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let S=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!S)return t;return t.slice(0,v)+S+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let r=t.trim();if(!r)return null;let s=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let r of jt){let s=t[r];if(!s)continue;let o=X(s);if(o)return{url:o,source:"env",via:r}}return null}function ut(t){if(!t||typeof t!=="object")return null;let r=t,s=r.site?.url??r.url??r.app?.url;return typeof s==="string"?X(s):null}async function Tt(t){let{existsSync:r}=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(!r(c))continue;try{let e=await import(c),u=ut(e.default??e);if(u)return u}catch{}}return null}async function dt(t={}){let r=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=ut(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await Tt(r);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 gt(){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 J(t){return async()=>({paths:await t(),fallback:!1})}var Lt;function Ut(t){let r=n(t),{depths:s}=se(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(r))!==null){if(s[c.index]!==0)continue;let u=k(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=k(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(s[c.index]!==0)continue;let u=vl(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 pt(t){let r="read";try{let s=await Bun.file(t).text();r="parse";let o=an(s),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(n(e.attrs))).sort((e,u)=>s.indexOf(e.fullTag)-s.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(n(e.content)))continue;let u=(Lt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(n(u)))continue;let g=Ut(u);if(/\bdefineStaticPaths\b/.test(n(g))&&Dt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let S=await v();r="result";let p=Array.isArray(S)?{paths:S}:S;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:r,error:s instanceof Error?s:Error(String(s))}}}class ft{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=m.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[s,o]of Object.entries(r))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await R.promises.mkdir(this.cacheDir,{recursive:!0});let t=m.join(this.cacheDir,"build-cache.json"),r={};for(let[s,o]of this.cache)r[s]=o;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let s=R.statSync(t),o=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of r)if(R.existsSync(e)){let u=R.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 s=this.cache.get(t);if(!s)return null;let o=mt(r).some((u)=>R.existsSync(u)),c=[r,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&R.existsSync(u)&&xs(R.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(r,s.dependencies??[]);if(s.hash!==e)return this.cache.delete(t),null;return s.html}set(t,r,s,o){let c=this.getHash(r,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 r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return m.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 s=this.getFilePath(t);await R.promises.mkdir(m.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await R.promises.unlink(r)}async invalidatePattern(t){let r=m.join(this.cacheDir,"isr");if(!R.existsSync(r))return;let s=await R.promises.readdir(r);for(let o of s){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await R.promises.unlink(m.join(r,o))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function _t(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let s=await pt(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`),r;let o=s.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 mt(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 mt(t))if(await Bun.file(r).exists())try{let s=await import(r);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 ${r}:`,s)}return null}async function Gt(t,r,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
- `)(n)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Ht(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function wt(t,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}},S=new Set,p=[],P=[],C={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(E)=>{p.push(`${m.relative(process.cwd(),E.templatePath)}: ${E.message}
8
- resolved against partialsDir: ${E.partialsDir}`)},onServerScriptError:(E)=>{P.push(`${m.relative(process.cwd(),E.sourcePath)} (${E.kind}): ${E.message}`)}};if(Ht(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,C,S);for(let E of[t.filePath,...S])for(let O of xe(E))S.add(O);if(Object.keys(n).length>0){let E=`<script>if(window.stx)window.stx._rp=${JSON.stringify(n)};else window.__stx_rp=${JSON.stringify(n)};</script>`;if(b.includes("</head>"))b=f(b,E);else b=`${E}
9
- ${b}`}if(b=await _e(b,{router:o.router}),b=await x(b),o.minify!==!1)return{html:zt(b),dependencies:Array.from(S),includeFailures:p,serverScriptFailures:P};return{html:b,dependencies:Array.from(S),includeFailures:p,serverScriptFailures:P}}function zt(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],S=c[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),n.push(g+v+S),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 Wt(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 qt(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 Jt(t,n){return`<?xml version="1.0" encoding="UTF-8"?>
7
+ `)(r)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Ht(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function wt(t,r,s={},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||{},...s,params:r,$route:{path:t.pattern,params:r}},S=new Set,p=[],P=[],C={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(E)=>{p.push(`${m.relative(process.cwd(),E.templatePath)}: ${E.message}
8
+ resolved against partialsDir: ${E.partialsDir}`)},onServerScriptError:(E)=>{P.push(`${m.relative(process.cwd(),E.sourcePath)} (${E.kind}): ${E.message}`)}};if(Ht(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,C,S);for(let E of[t.filePath,...S])for(let O of ke(E))S.add(O);if(Object.keys(r).length>0){let E=`<script>if(window.stx)window.stx._rp=${JSON.stringify(r)};else window.__stx_rp=${JSON.stringify(r)};</script>`;if(b.includes("</head>"))b=f(b,E);else b=`${E}
9
+ ${b}`}if(b=await Ee(b,{router:o.router}),b=await x(b),o.minify!==!1)return{html:zt(b),dependencies:Array.from(S),includeFailures:p,serverScriptFailures:P};return{html:b,dependencies:Array.from(S),includeFailures:p,serverScriptFailures:P}}function zt(t){let r=[],s=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=o.exec(t))!==null){let u=t.slice(s,c.index);r.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let g=c[1],v=c[2],S=c[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),r.push(g+v+S),s=c.index+c[0].length}let e=t.slice(s);return r.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),r.join("").trim()}function Wt(t){let r=0;for(let s=0;s<t.length;s++){let o=t.charCodeAt(s);r=(r<<5)-r+o,r=r&r}return`"${Math.abs(r).toString(36)}"`}function qt(t,r,s,o){if(s?.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 Jt(t,r){return`<?xml version="1.0" encoding="UTF-8"?>
10
10
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
11
- ${t.map((o)=>{let c=new URL(o.loc,n).href,e=` <url>
11
+ ${t.map((o)=>{let c=new URL(o.loc,r).href,e=` <url>
12
12
  <loc>${T(c)}</loc>`;if(o.lastmod)e+=`
13
13
  <lastmod>${o.lastmod}</lastmod>`;if(o.changefreq)e+=`
14
14
  <changefreq>${o.changefreq}</changefreq>`;if(o.priority!==void 0)e+=`
15
15
  <priority>${o.priority}</priority>`;return e+=`
16
16
  </url>`,e}).join(`
17
17
  `)}
18
- </urlset>`}function T(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Vt(t,n){let s=n.map((o)=>{let c=" <item>";if(c+=`
18
+ </urlset>`}function T(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Vt(t,r){let s=r.map((o)=>{let c=" <item>";if(c+=`
19
19
  <title>${T(o.title)}</title>`,c+=`
20
20
  <link>${T(o.link)}</link>`,o.description)c+=`
21
21
  <description>${T(o.description)}</description>`;if(o.pubDate)c+=`
@@ -36,7 +36,7 @@ ${t.map((o)=>{let c=new URL(o.loc,n).href,e=` <url>
36
36
  ${s.join(`
37
37
  `)}
38
38
  </channel>
39
- </rss>`}async function Kt(t={}){let n=Date.now();ln();let s=await a(process.cwd()),o=s.build||{},c=await dt({explicit:t.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(gt());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,S={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&R.existsSync(e.outputDir))await R.promises.rm(e.outputDir,{recursive:!0});await R.promises.mkdir(e.outputDir,{recursive:!0});let C=e.cacheSalt;if(!C){let{resolveUserCssConfig:d,fingerprintConfig:y}=await import("./chunk-gvh45ddc.js");try{C=y(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-dmcmxf3a.js"),E=await b(e.publicDir,e.outputDir);if(E.count>0)console.log(`Optimized ${E.count} image(s) for responsive delivery`),C=[C,E.fingerprint].filter(Boolean).join(":");let O=new ft(e.cacheDir,C);if(e.cache)await O.load();try{let{generateCss:d}=await import("./chunk-gvh45ddc.js");await d('<div class="bg-black"></div>')}catch{}Rt();let yt=s?.routeMiddleware?.dir||"middleware";await Pt(process.cwd(),yt);let V=At();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let St=s?.routeMiddleware?.global||[];dc(s?.layoutsDir,l(process.cwd()));let Q=ee(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Q.length} routes`);let U=[];for(let d of Q)try{let y=await _t(d);for(let D of y)U.push({route:d,url:D.url,params:D.params,props:D.props,revalidate:D.revalidate??e.revalidate})}catch(y){let D=y instanceof Error?y:Error(String(y));u.failedCount++,u.errors.push({route:d.pattern,error:D}),await e.hooks.onError?.(D,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,D)}u.totalPages=U.length+u.failedCount,console.log(`Generating ${U.length} pages...`);let _=[],tt=[];for(let d=0;d<U.length;d+=e.concurrency)tt.push(U.slice(d,d+e.concurrency));for(let d of tt)await Promise.all(d.map(async(y)=>{let{route:D,url:h,params:M,props:xt,revalidate:nt}=y;try{await e.hooks.onPageStart?.(h);let G=await Bun.file(D.filePath).text(),A=Zt(G),bt=A?.middleware?Array.isArray(A.middleware)?A.middleware:[A.middleware]:[],it=[...St,...bt];if(it.length>0){let j=It(h,M,A||{}),N=Ot(j,null,void 0,{isServer:!0}),F=await Nt(it,N);if(F.redirect){let I=typeof F.redirect==="string"?F.redirect:F.redirect.path||F.redirect,z=Qt(String(I),h),L=te(h,e);await R.promises.mkdir(m.dirname(L),{recursive:!0}),await Bun.write(L,z),u.successCount++,u.pages.push({route:h,outputPath:L,size:Buffer.byteLength(z),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${I}`);return}if(F.abort){let I=typeof F.abort==="string"?F.abort:F.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${I}`);return}}let st=A?.validate;if(typeof st==="function")try{if(!await st({params:M})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let B=null,at=!1;if(e.cache){if(B=O.get(h,D.filePath),B)at=!0,u.cachedCount++}if(!B){let j=await wt(D,M,xt,e,s);if(B=j.html,e.failOnIncludeError&&j.includeFailures.length>0)throw Error(`${j.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
39
+ </rss>`}async function Kt(t={}){let r=Date.now();ln();let s=await a(process.cwd()),o=s.build||{},c=await dt({explicit:t.domain||o.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(gt());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,S={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&R.existsSync(e.outputDir))await R.promises.rm(e.outputDir,{recursive:!0});await R.promises.mkdir(e.outputDir,{recursive:!0});let C=e.cacheSalt;if(!C){let{resolveUserCssConfig:d,fingerprintConfig:y}=await import("./chunk-c8pzj57b.js");try{C=y(await d(process.cwd()))}catch{}}let{prepareImageDelivery:b}=await import("./chunk-qrn1nza9.js"),E=await b(e.publicDir,e.outputDir);if(E.count>0)console.log(`Optimized ${E.count} image(s) for responsive delivery`),C=[C,E.fingerprint].filter(Boolean).join(":");let O=new ft(e.cacheDir,C);if(e.cache)await O.load();try{let{generateCss:d}=await import("./chunk-c8pzj57b.js");await d('<div class="bg-black"></div>')}catch{}Rt();let yt=s?.routeMiddleware?.dir||"middleware";await Pt(process.cwd(),yt);let V=At();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let St=s?.routeMiddleware?.global||[];gc(s?.layoutsDir,l(process.cwd()));let Z=Q(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Z.length} routes`);let U=[];for(let d of Z)try{let y=await _t(d);for(let D of y)U.push({route:d,url:D.url,params:D.params,props:D.props,revalidate:D.revalidate??e.revalidate})}catch(y){let D=y instanceof Error?y:Error(String(y));u.failedCount++,u.errors.push({route:d.pattern,error:D}),await e.hooks.onError?.(D,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,D)}u.totalPages=U.length+u.failedCount,console.log(`Generating ${U.length} pages...`);let _=[],tt=[];for(let d=0;d<U.length;d+=e.concurrency)tt.push(U.slice(d,d+e.concurrency));for(let d of tt)await Promise.all(d.map(async(y)=>{let{route:D,url:h,params:M,props:xt,revalidate:nt}=y;try{await e.hooks.onPageStart?.(h);let G=await Bun.file(D.filePath).text(),A=Zt(G),bt=A?.middleware?Array.isArray(A.middleware)?A.middleware:[A.middleware]:[],it=[...St,...bt];if(it.length>0){let j=It(h,M,A||{}),N=Ot(j,null,void 0,{isServer:!0}),F=await Nt(it,N);if(F.redirect){let I=typeof F.redirect==="string"?F.redirect:F.redirect.path||F.redirect,z=Qt(String(I),h),L=te(h,e);await R.promises.mkdir(m.dirname(L),{recursive:!0}),await Bun.write(L,z),u.successCount++,u.pages.push({route:h,outputPath:L,size:Buffer.byteLength(z),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${I}`);return}if(F.abort){let I=typeof F.abort==="string"?F.abort:F.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${I}`);return}}let st=A?.validate;if(typeof st==="function")try{if(!await st({params:M})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let B=null,at=!1;if(e.cache){if(B=O.get(h,D.filePath),B)at=!0,u.cachedCount++}if(!B){let j=await wt(D,M,xt,e,s);if(B=j.html,e.failOnIncludeError&&j.includeFailures.length>0)throw Error(`${j.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
40
40
  ${j.includeFailures.join(`
41
41
  `)}
42
42
  Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&j.serverScriptFailures.length>0)throw Error(`${j.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
@@ -65,7 +65,7 @@ ${d}`)}if(e.cache)await O.save();if(e.generate404){let d=m.join(e.pagesDir,"404.
65
65
  <a href="/">Go home</a>
66
66
  </div>
67
67
  </body>
68
- </html>`)}for(let d of[500]){let y=m.join(e.pagesDir,`${d}.stx`);if(await Bun.file(y).exists()){let D=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},M=await i(await Bun.file(y).text(),{},y,h,D);await Bun.write(m.join(e.outputDir,`${d}.html`),M)}}let K=m.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,y={...s,minifyClient:!0,debug:!1,cache:!1},D=await i(await Bun.file(K).text(),{},K,y,d);await Bun.write(m.join(e.outputDir,"error.html"),D)}if(e.sitemap&&_.length>0){let d=Jt(_,e.domain),y=m.join(e.outputDir,"sitemap.xml");await Bun.write(y,d),u.sitemapPath=y,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},y=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],D=Os({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...y.length>0?{disallow:y}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(m.join(e.outputDir,"robots.txt"),D),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},y=[];if(d.getItems)y=await d.getItems();let D=Vt(d,y),h=m.join(e.outputDir,"rss.xml");await Bun.write(h,D),u.rssPath=h,console.log(`Generated rss.xml with ${y.length} items`)}let W=lc(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=uc(e.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&R.existsSync(e.publicDir))await Z(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let rt=or();if(rt)await Z(rt,m.join(e.outputDir,sr)),console.log(`Copied assets from ${on}`)}catch(C){throw await e.hooks.onError?.(C),C}if(u.buildTime=Date.now()-n,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let C={generatedChunks:g.size,totalBytes:v,chunks:S,pages:p};await Bun.write(m.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(C,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
68
+ </html>`)}for(let d of[500]){let y=m.join(e.pagesDir,`${d}.stx`);if(await Bun.file(y).exists()){let D=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},M=await i(await Bun.file(y).text(),{},y,h,D);await Bun.write(m.join(e.outputDir,`${d}.html`),M)}}let K=m.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,y={...s,minifyClient:!0,debug:!1,cache:!1},D=await i(await Bun.file(K).text(),{},K,y,d);await Bun.write(m.join(e.outputDir,"error.html"),D)}if(e.sitemap&&_.length>0){let d=Jt(_,e.domain),y=m.join(e.outputDir,"sitemap.xml");await Bun.write(y,d),u.sitemapPath=y,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},y=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],D=Ns({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...y.length>0?{disallow:y}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(m.join(e.outputDir,"robots.txt"),D),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},y=[];if(d.getItems)y=await d.getItems();let D=Vt(d,y),h=m.join(e.outputDir,"rss.xml");await Bun.write(h,D),u.rssPath=h,console.log(`Generated rss.xml with ${y.length} items`)}let W=pc(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=fc(e.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&R.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let rt=ir();if(rt)await Y(rt,m.join(e.outputDir,or)),console.log(`Copied assets from ${on}`)}catch(C){throw await e.hooks.onError?.(C),C}if(u.buildTime=Date.now()-r,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let C={generatedChunks:g.size,totalBytes:v,chunks:S,pages:p};await Bun.write(m.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(C,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
69
69
  Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
70
70
  Build complete!
71
71
  Total: ${u.totalPages} pages
@@ -73,8 +73,8 @@ Build complete!
73
73
  Cached: ${u.cachedCount}
74
74
  Failed: ${u.failedCount}
75
75
  Time: ${u.buildTime}ms${P}
76
- `),u}async function Z(t,n){await R.promises.mkdir(n,{recursive:!0});let s=await R.promises.readdir(t,{withFileTypes:!0});for(let o of s){let c=m.join(t,o.name),e=m.join(n,o.name);if(o.isDirectory())await R.promises.mkdir(e,{recursive:!0}),await Z(c,e);else await R.promises.copyFile(c,e)}}function Xt(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=ee(".",{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,C)=>{v[P]=g[C+1]});let S=await a(),{html:p}=await wt(u,v,{},t,S);await s.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:Wt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Yt(){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 S=s[1];c=n.slice(s[0].length).trim();for(let p of S.split(`
77
- `)){let P=p.indexOf(":");if(P>0){let C=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((E)=>E.trim().replace(/^['"]|['"]$/g,""));o[C]=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 S=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:S})}return{content:e,data:o,toc:u}}}}function Zt(t){return kt(t)}function Qt(t,n){return`<!DOCTYPE html>
76
+ `),u}async function Y(t,r){await R.promises.mkdir(r,{recursive:!0});let s=await R.promises.readdir(t,{withFileTypes:!0});for(let o of s){let c=m.join(t,o.name),e=m.join(r,o.name);if(o.isDirectory())await R.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await R.promises.copyFile(c,e)}}function Xt(t={}){let r=t.cacheDir||l(process.cwd(),"ssg-cache"),s=new ht(r),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=Q(".",{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,C)=>{v[P]=g[C+1]});let S=await a(),{html:p}=await wt(u,v,{},t,S);await s.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:Wt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Yt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let r=await Bun.file(t).text(),s=r.match(/^---\n([\s\S]*?)\n---/),o={},c=r;if(s){let S=s[1];c=r.slice(s[0].length).trim();for(let p of S.split(`
77
+ `)){let P=p.indexOf(":");if(P>0){let C=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((E)=>E.trim().replace(/^['"]|['"]$/g,""));o[C]=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 S=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:S})}return{content:e,data:o,toc:u}}}}function Zt(t){return kt(t)}function Qt(t,r){return`<!DOCTYPE html>
78
78
  <html>
79
79
  <head>
80
80
  <meta charset="utf-8">
@@ -86,4 +86,4 @@ Build complete!
86
86
  <p>Redirecting to <a href="${t}">${t}</a>...</p>
87
87
  <script>window.location.replace('${t}')</script>
88
88
  </body>
89
- </html>`}function te(t,n){if(t==="/"||t==="")return m.join(n.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(n.trailingSlash)return m.join(n.outputDir,s,"index.html");return m.join(n.outputDir,`${s}.html`)}var Fe={generateStaticSite:Kt,createISRHandler:Xt,defineStaticPaths:J,createMarkdownLoader:Yt};export{Xt as createISRHandler,Yt as createMarkdownLoader,Ht as declaresPageAction,Fe as default,J as defineStaticPaths,Kt as generateStaticSite,qt as isExcludedFromSitemap};
89
+ </html>`}function te(t,r){if(t==="/"||t==="")return m.join(r.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(r.trailingSlash)return m.join(r.outputDir,s,"index.html");return m.join(r.outputDir,`${s}.html`)}var Te={generateStaticSite:Kt,createISRHandler:Xt,defineStaticPaths:J,createMarkdownLoader:Yt};export{Xt as createISRHandler,Yt as createMarkdownLoader,Ht as declaresPageAction,Te as default,J as defineStaticPaths,Kt as generateStaticSite,qt as isExcludedFromSitemap};
@@ -1,3 +1,4 @@
1
+ import type { ClientMethodValidator } from './component-library.js';
1
2
  /**
2
3
  * Pull the script blocks out of a `.stx` source, with the line each body starts on.
3
4
  *
@@ -47,6 +48,7 @@ export declare function substituteInterpolations(value: string): string;
47
48
  */
48
49
  export declare function substituteInterpolationsInPlace(code: string): string;
49
50
  export declare function projectScriptInterpolations(code: string, serverCode: string, key?: string): ScriptProjection;
51
+ export declare function typeScopeImports(code: string, prefix: string): { imports: string[], aliases: string[], body: string };
50
52
  /** Map a generated script column back across all preceding edits on its line. */
51
53
  export declare function resolveScriptColumn(edits: readonly ScriptColumnEdit[], column: number): number;
52
54
  /** The inverse used by editor hover/completions as well as diagnostics. */
@@ -349,9 +351,9 @@ export declare function rewriteRelativeSpecifiers(code: string, originDir: strin
349
351
  * therefore undoes the specifier rewrite before the interpolation one; doing
350
352
  * it in the other order reads the second map in coordinates it never used.
351
353
  */
352
- export declare function resolveVirtualColumn(virtual: Pick<VirtualFile, 'scriptColumns' | 'importColumns'>, line: number, column: number): number;
354
+ export declare function resolveVirtualColumn(virtual: Pick<VirtualFile, 'scriptColumns' | 'importColumns' | 'componentColumns'>, line: number, column: number): number;
353
355
  /** The inverse, in pipeline order, for editor hover and completions. */
354
- export declare function projectVirtualColumn(virtual: Pick<VirtualFile, 'scriptColumns' | 'importColumns'>, line: number, column: number): number;
356
+ export declare function projectVirtualColumn(virtual: Pick<VirtualFile, 'scriptColumns' | 'importColumns' | 'componentColumns'>, line: number, column: number): number;
355
357
  /**
356
358
  * Spaces that put a block's first line at the column it occupies in the file.
357
359
  *
@@ -460,6 +462,7 @@ export declare interface TemplateExpression {
460
462
  }
461
463
  /** A synthetic line's origin, for diagnostics that land outside the source. */
462
464
  export declare interface MappedLine {
465
+ diagnosticOrigin?: ScriptKind | 'component'
463
466
  line: number
464
467
  column: number
465
468
  expression?: TemplateExpression
@@ -473,6 +476,7 @@ export declare interface VirtualFile {
473
476
  lineMap: Map<number, MappedLine>
474
477
  sourceLineCount: number
475
478
  scriptColumns?: Map<number, ScriptColumnEdit[]>
479
+ componentColumns?: Map<number, ScriptColumnEdit[]>
476
480
  importColumns?: Map<number, ScriptColumnEdit[]>
477
481
  }
478
482
  /** A width-changing edit on one script line; untouched columns keep their offset. */
@@ -500,6 +504,13 @@ export declare interface TemplateBinding {
500
504
  iterable?: string
501
505
  }
502
506
  export declare interface BuildVirtualOptions {
507
+ declaredGlobals?: readonly string[]
508
+ componentMethodValidator?: ClientMethodValidator
509
+ scriptKinds?: ScriptKind[]
510
+ nativeChecks?: boolean
511
+ partialsDir?: string
512
+ layoutsDir?: string
513
+ inheritedContractsKnown?: boolean
503
514
  filePath?: string
504
515
  componentsDir?: string
505
516
  projectRoot?: string
@@ -513,6 +524,7 @@ export declare interface BuildVirtualOptions {
513
524
  }
514
525
  /** Where a diagnostic in a virtual buffer belongs in the `.stx` file. */
515
526
  export declare interface ResolvedPosition {
527
+ diagnosticOrigin?: ScriptKind | 'component'
516
528
  line: number
517
529
  column: number
518
530
  expression?: TemplateExpression
@@ -6,6 +6,8 @@ import { parseLoopBinding } from "./loop-binding.js";
6
6
  import { bracketDepths, stripCommentsAndLiterals } from "./strip-literals.js";
7
7
  import { STX_RUNTIME_GLOBALS } from "./runtime-globals.js";
8
8
  import { componentContractChecks } from "./component-contract-checks.js";
9
+ import { inheritedContextBindings, inheritedContextChecks } from "./inherited-context.js";
10
+ import { nativeComponentContext, nativeComponentLoops } from "./native-component-context.js";
9
11
  import { collectSlotScopes } from "./slot-scopes.js";
10
12
  const SCRIPT_RE = /<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;
11
13
  function blankCommentContents(source) {
@@ -18,7 +20,7 @@ export function extractScriptBlocks(source) {
18
20
  let match;
19
21
  while ((match = SCRIPT_RE.exec(scannable)) !== null) {
20
22
  const attrs = (match[1] || "").trim(), openLength = (match[0].match(/^<script(?:\s[^>]*)?>/i)?.[0] ?? "<script>").length, closeLength = (match[0].match(/<\/script\s*>$/i)?.[0] ?? "</script>").length, bodyStart = match.index + openLength, bodyEnd = match.index + match[0].length - closeLength, body = source.slice(bodyStart, bodyEnd);
21
- if (/\bsrc\s*=/.test(attrs))
23
+ if (/\bsrc\s*=/.test(attrs) || /\b(?:stx:)?component\b/.test(attrs))
22
24
  continue;
23
25
  const typeMatch = attrs.match(/\btype\s*=\s*["']([^"']+)["']/i);
24
26
  if (typeMatch && !/^(?:module|text\/(?:javascript|typescript))$/i.test(typeMatch[1]))
@@ -162,18 +164,40 @@ export function projectScriptInterpolations(code, serverCode, key = "0") {
162
164
  const projected = chunks.join("");
163
165
  if (!expressions.length)
164
166
  return { code: projected, columns, declarations };
165
- const { imports, body } = splitTopLevelImports(serverCode), aliases = [];
167
+ const { imports, aliases, body } = typeScopeImports(serverCode, prefix);
168
+ for (const text of imports)
169
+ declarations.push({ text });
170
+ declarations.push({ text: `namespace ${prefix}Scope {
171
+ ${aliases.join(`
172
+ `)}
173
+ export async function read() {
174
+ ${blankScriptDirectives(body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm, "")}
175
+ return {` });
176
+ for (const [index, expression] of expressions.entries()) {
177
+ declarations.push({ text: `value${index}: (` });
178
+ declarations.push({ text: expression.code, origin: { line: expression.line, column: expression.column } });
179
+ declarations.push({ text: ")," });
180
+ }
181
+ declarations.push({ text: `}
182
+ }
183
+ }` });
184
+ for (let index = 0;index < expressions.length; index++)
185
+ declarations.push({ text: `declare var ${prefix}_${index}: Awaited<ReturnType<typeof ${prefix}Scope.read>>['value${index}']` });
186
+ return { code: projected, columns, declarations };
187
+ }
188
+ export function typeScopeImports(code, prefix) {
189
+ const hoisted = [], { imports, body } = splitTopLevelImports(code), aliases = [];
166
190
  let moduleIndex = 0;
167
191
  for (const statement of imports.split(/\n(?=import\b)/)) {
168
192
  if (!statement.trim())
169
193
  continue;
170
194
  const from = /^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(statement);
171
195
  if (!from) {
172
- declarations.push({ text: statement });
196
+ hoisted.push(statement);
173
197
  continue;
174
198
  }
175
199
  const module = `${prefix}Module${moduleIndex++}`;
176
- declarations.push({ text: `import * as ${module} from ${from[2]}` });
200
+ hoisted.push(`import * as ${module} from ${from[2]}`);
177
201
  const clause = from[1], named = /\{([\s\S]*?)\}/.exec(clause);
178
202
  for (const entry of named?.[1].split(",") ?? []) {
179
203
  const [imported, local = imported] = entry.trim().replace(/^type\s+/, "").split(/\s+as\s+/);
@@ -189,23 +213,7 @@ export function projectScriptInterpolations(code, serverCode, key = "0") {
189
213
  if (defaultName)
190
214
  aliases.push(`const ${defaultName} = ${module}.default; type ${defaultName} = import(${from[2]}).default`);
191
215
  }
192
- declarations.push({ text: `namespace ${prefix}Scope {
193
- ${aliases.join(`
194
- `)}
195
- export async function read() {
196
- ${blankScriptDirectives(body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm, "")}
197
- return {` });
198
- for (const [index, expression] of expressions.entries()) {
199
- declarations.push({ text: `value${index}: (` });
200
- declarations.push({ text: expression.code, origin: { line: expression.line, column: expression.column } });
201
- declarations.push({ text: ")," });
202
- }
203
- declarations.push({ text: `}
204
- }
205
- }` });
206
- for (let index = 0;index < expressions.length; index++)
207
- declarations.push({ text: `declare var ${prefix}_${index}: Awaited<ReturnType<typeof ${prefix}Scope.read>>['value${index}']` });
208
- return { code: projected, columns, declarations };
216
+ return { imports: hoisted, aliases, body };
209
217
  }
210
218
  export function resolveScriptColumn(edits, column) {
211
219
  let delta = 0;
@@ -930,11 +938,11 @@ export function rewriteRelativeSpecifiers(code, originDir) {
930
938
  }
931
939
  export function resolveVirtualColumn(virtual, line, column) {
932
940
  const projected = resolveScriptColumn(virtual.importColumns?.get(line) ?? [], column);
933
- return resolveScriptColumn(virtual.scriptColumns?.get(line) ?? [], projected);
941
+ return resolveScriptColumn(virtual.scriptColumns?.get(line) ?? [], resolveScriptColumn(virtual.componentColumns?.get(line) ?? [], projected));
934
942
  }
935
943
  export function projectVirtualColumn(virtual, line, column) {
936
944
  const projected = projectScriptColumn(virtual.scriptColumns?.get(line) ?? [], column);
937
- return projectScriptColumn(virtual.importColumns?.get(line) ?? [], projected);
945
+ return projectScriptColumn(virtual.importColumns?.get(line) ?? [], projectScriptColumn(virtual.componentColumns?.get(line) ?? [], projected));
938
946
  }
939
947
  export function firstLinePadding(block) {
940
948
  return " ".repeat(Math.max(0, (block.startColumn ?? 1) - 1));
@@ -958,8 +966,8 @@ export function collectImportedNames(code) {
958
966
  return [...names].sort();
959
967
  }
960
968
  export function buildVirtualTypeScript(source, options = {}) {
961
- const blocks = extractScriptBlocks(source), sourceLines = source.split(`
962
- `), lines = Array.from({ length: sourceLines.length }, () => ""), lineMap = new Map, scriptColumns = new Map, importColumns = new Map, scriptDeclarations = [], serverCode = interpolationScopeCode(blocks), components = options.filePath && options.templateExpressions !== !1 ? componentContractChecks(source, maskNonTemplateRegions(source), {
969
+ const allBlocks = extractScriptBlocks(source), blocks = options.scriptKinds ? allBlocks.filter((block) => options.scriptKinds.includes(block.kind)) : allBlocks, component = nativeComponentContext(source, options.componentMethodValidator), inherited = options.filePath && options.templateExpressions !== !1 ? inheritedContextChecks(source, { filePath: options.filePath, partialsDir: options.partialsDir, layoutsDir: options.layoutsDir, contractsKnown: options.inheritedContractsKnown, readTemplate: options.readComponent }) : void 0, componentColumns = new Map, sourceLines = source.split(`
970
+ `), lines = Array.from({ length: sourceLines.length }, () => ""), lineMap = new Map, scriptColumns = new Map, importColumns = new Map, scriptDeclarations = [], serverCode = interpolationScopeCode(allBlocks), components = options.filePath && options.templateExpressions !== !1 ? componentContractChecks(source, maskNonTemplateRegions(source), {
963
971
  filePath: options.filePath,
964
972
  componentsDir: options.componentsDir,
965
973
  projectRoot: options.projectRoot,
@@ -976,7 +984,10 @@ export function buildVirtualTypeScript(source, options = {}) {
976
984
  text: absolutizeRelativeSpecifiers(declaration.text, options.originDir ?? ""),
977
985
  origin: declaration.origin ? { ...declaration.origin, line: declaration.origin.line + block.startLine - 1 } : void 0
978
986
  });
979
- const code = blankScriptDirectives(projection.code), rewritten = rewriteRelativeSpecifiers(code, options.originDir ?? "");
987
+ const nativeProjection = block.kind === "client" && component ? component.project(projection.code) : void 0;
988
+ for (const [line, edits] of nativeProjection?.columns ?? [])
989
+ componentColumns.set(block.startLine + line - 1, edits);
990
+ const code = blankScriptDirectives(nativeProjection?.code ?? projection.code), rewritten = rewriteRelativeSpecifiers(code, options.originDir ?? "");
980
991
  for (const [line, edits] of rewritten.columns)
981
992
  importColumns.set(block.startLine + line - 1, edits);
982
993
  const bodyLines = rewritten.code.split(`
@@ -1002,16 +1013,27 @@ export function buildVirtualTypeScript(source, options = {}) {
1002
1013
  if (origin)
1003
1014
  lineMap.set(lines.length, index === 0 ? origin : { ...origin, line: origin.line + index, column: 1, prefixLength: 0 });
1004
1015
  }
1005
- };
1016
+ }, inheritedBindings = inheritedContextBindings(blocks.filter((block) => block.kind === "server").map((block) => block.code).join(`
1017
+ `));
1018
+ if (inheritedBindings)
1019
+ append(inheritedBindings);
1020
+ if (inherited?.declarations)
1021
+ append(inherited.declarations);
1006
1022
  for (const declaration of scriptDeclarations)
1007
1023
  append(declaration.text, declaration.origin);
1024
+ if (component) {
1025
+ append(component.declarations);
1026
+ if (options.nativeChecks !== !1)
1027
+ for (const check of component.checks)
1028
+ append(check.text, { line: check.line, column: check.column, diagnosticOrigin: check.origin });
1029
+ }
1008
1030
  if (options.globals !== !1) {
1009
1031
  append("");
1010
1032
  const bound = new Set([
1011
1033
  ...blocks.flatMap((block) => collectBlockDeclarations(block.code)),
1012
1034
  ...blocks.flatMap((block) => collectImportedNames(block.code))
1013
1035
  ]), declareAny = (name) => {
1014
- if (!bound.has(name))
1036
+ if (!bound.has(name) && !options.declaredGlobals?.includes(name))
1015
1037
  append(`declare var ${name}: any`);
1016
1038
  };
1017
1039
  if (options.runtimeGlobals !== !1) {
@@ -1020,7 +1042,7 @@ export function buildVirtualTypeScript(source, options = {}) {
1020
1042
  for (const name of STX_RUNTIME_GLOBALS)
1021
1043
  declareAny(name);
1022
1044
  }
1023
- const contextNames = [...new Set([...STX_SERVER_CONTEXT, ...BROWSER_CORE_IMPORTS, ...STX_TEMPLATE_GLOBALS])].filter((name) => options.runtimeGlobals !== !1 || !STX_RUNTIME_GLOBALS.includes(name));
1045
+ const contextNames = [...new Set([...STX_SERVER_CONTEXT, ...BROWSER_CORE_IMPORTS, ...STX_TEMPLATE_GLOBALS])].filter((name) => !options.declaredGlobals?.includes(name) && (options.runtimeGlobals !== !1 || !STX_RUNTIME_GLOBALS.includes(name)));
1024
1046
  if (options.contextScope === "global") {
1025
1047
  append("declare global {");
1026
1048
  for (const name of contextNames)
@@ -1037,7 +1059,7 @@ export function buildVirtualTypeScript(source, options = {}) {
1037
1059
  append(`declare var ${INTERPOLATION_PLACEHOLDER}: any`);
1038
1060
  const declared = new Set(blocks.flatMap((block) => collectBlockDeclarations(block.code)));
1039
1061
  append(`type ${ELEMENT_HELPER}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);
1040
- for (const binding of collectTemplateBindings(source)) {
1062
+ for (const binding of component ? [] : collectTemplateBindings(source)) {
1041
1063
  if (declared.has(binding.name))
1042
1064
  continue;
1043
1065
  const type = binding.iterable && declared.has(binding.iterable) ? `${ELEMENT_HELPER}<typeof ${binding.iterable}>` : "any";
@@ -1058,10 +1080,15 @@ export function buildVirtualTypeScript(source, options = {}) {
1058
1080
  }
1059
1081
  return { expression, statement: expressionStatement(expression) };
1060
1082
  }).filter((entry) => entry.statement !== null);
1061
- statements.push(...components?.checks || []);
1083
+ statements.push(...components?.checks || [], ...inherited?.checks || []);
1062
1084
  if (statements.length > 0) {
1063
- const maskedSource = maskNonTemplateRegions(source), slotScopes = collectSlotScopes(maskedSource), conditionAliases = collectConditionAliases(blocks.map((block) => block.code)), shadowed = [...new Set(blocks.flatMap((block) => collectBlockDeclarations(block.code)))].filter((name) => /^[A-Z_$][\w$]*$/i.test(name));
1085
+ const maskedSource = maskNonTemplateRegions(source), slotScopes = collectSlotScopes(maskedSource), nativeLoops = component ? nativeComponentLoops(maskedSource) : [];
1086
+ if (component)
1087
+ append("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");
1088
+ const conditionAliases = collectConditionAliases(blocks.map((block) => block.code)), shadowed = [...new Set(blocks.flatMap((block) => collectBlockDeclarations(block.code)))].filter((name) => /^[A-Z_$][\w$]*$/i.test(name));
1064
1089
  let indent = 0;
1090
+ if (component)
1091
+ append("function __stxNativeTemplate(this: __StxNativeComponent) {");
1065
1092
  if (shadowed.length > 0) {
1066
1093
  append(UNWRAP_HELPER_DECL);
1067
1094
  for (const name of shadowed) {
@@ -1072,7 +1099,7 @@ export function buildVirtualTypeScript(source, options = {}) {
1072
1099
  indent = 1;
1073
1100
  }
1074
1101
  for (const { expression, statement } of statements) {
1075
- const pad = " ".repeat(indent), enclosingSlots = expression.offset === void 0 ? [] : slotScopes.filter((scope) => expression.offset >= scope.start && expression.offset < scope.end), slotPrefix = enclosingSlots.map((scope) => `;((${scope.binding.replace(/[\r\n]/g, " ")}: any) => { `).join(""), slotSuffix = " });".repeat(enclosingSlots.length), guards = expression.offset === void 0 ? [] : guardChainAt(maskedSource, expression.offset), guardPrefix = guards.length > 0 ? `${guards.map((condition) => `if (${expandConditionAliases(condition, conditionAliases)}) `).join("")}{ ` : "", guardSuffix = guards.length > 0 ? " }" : "";
1102
+ const pad = " ".repeat(indent), enclosingSlots = expression.offset === void 0 ? [] : slotScopes.filter((scope) => expression.offset >= scope.start && expression.offset < scope.end), loopScopes = expression.offset === void 0 ? [] : nativeLoops.filter((scope) => expression.offset >= scope.start && expression.offset < scope.end), loopPrefix = loopScopes.map((scope) => `;__stxEach(${scope.iterable}, (${scope.binding}) => { `).join(""), loopSuffix = " });".repeat(loopScopes.length), slotPrefix = loopPrefix + enclosingSlots.map((scope) => `;((${scope.binding.replace(/[\r\n]/g, " ")}: any) => { `).join(""), slotSuffix = " });".repeat(enclosingSlots.length) + loopSuffix, guards = expression.offset === void 0 ? [] : guardChainAt(maskedSource, expression.offset), guardPrefix = guards.length > 0 ? `${guards.map((condition) => `if (${expandConditionAliases(condition, conditionAliases)}) `).join("")}{ ` : "", guardSuffix = guards.length > 0 ? " }" : "";
1076
1103
  append(pad + slotPrefix + guardPrefix + statement.text + guardSuffix + slotSuffix, {
1077
1104
  line: expression.line,
1078
1105
  column: expression.column,
@@ -1083,6 +1110,8 @@ export function buildVirtualTypeScript(source, options = {}) {
1083
1110
  }
1084
1111
  if (indent > 0)
1085
1112
  append("});");
1113
+ if (component)
1114
+ append("}");
1086
1115
  }
1087
1116
  }
1088
1117
  let referenced = !1;
@@ -1092,7 +1121,7 @@ export function buildVirtualTypeScript(source, options = {}) {
1092
1121
  }
1093
1122
  append("export {}");
1094
1123
  return { text: lines.join(`
1095
- `), lineMap, sourceLineCount: sourceLines.length, componentDependencies: components?.dependencies, referenced, scriptColumns, importColumns };
1124
+ `), lineMap, sourceLineCount: sourceLines.length, componentDependencies: new Map([...components?.dependencies ?? [], ...inherited?.dependencies ?? []]), referenced, scriptColumns, importColumns, componentColumns };
1096
1125
  }
1097
1126
  export function lineStarts(text) {
1098
1127
  const starts = [0];
@@ -1130,6 +1159,7 @@ export function resolvePosition(virtual, line, column) {
1130
1159
  line: mapped.line,
1131
1160
  column: mapped.column + within,
1132
1161
  expression: mapped.expression,
1162
+ diagnosticOrigin: mapped.diagnosticOrigin,
1133
1163
  inGuard: column <= (mapped.guardPrefixLength ?? 0)
1134
1164
  };
1135
1165
  }
@@ -1,4 +1,5 @@
1
1
  import { extractScriptBlocks } from './stx-virtual-ts.js';
2
+ import type { NativeComponentContext } from './native-component-context.js';
2
3
  import type { ScriptBlock, ScriptKind, VirtualFile } from './stx-virtual-ts.js';
3
4
  export type { ScriptBlock, ScriptKind } from './stx-virtual-ts.js';
4
5
  /**
@@ -20,7 +21,7 @@ export type { ScriptBlock, ScriptKind } from './stx-virtual-ts.js';
20
21
  * against the file containing it — so without this, `../target` was looked for
21
22
  * next to `.stx/typecheck/` (#1928).
22
23
  */
23
- export declare function buildScriptVirtualFile(block: ScriptBlock, serverCode?: string, originDir?: string, interpolationScope?: unknown): VirtualFile;
24
+ export declare function buildScriptVirtualFile(block: ScriptBlock, serverCode?: string, originDir?: string, interpolationScope?: unknown, component?: NativeComponentContext): VirtualFile;
24
25
  /** Compatibility string surface; checking also retains the source edit map. */
25
26
  export declare function buildVirtualSource(block: ScriptBlock, serverCode?: string, originDir?: string): string;
26
27
  /** Virtual path for a block, stable and traceable back to its origin. */
@@ -63,6 +64,8 @@ export declare interface TypecheckDiagnostic {
63
64
  expression?: string
64
65
  }
65
66
  export declare interface TypecheckOptions {
67
+ partialsDir?: string
68
+ layoutsDir?: string
66
69
  componentsDir?: string
67
70
  extraLibs?: string[]
68
71
  client?: boolean
@@ -78,7 +81,7 @@ export declare interface TypecheckResult {
78
81
  expressionCount: number
79
82
  }
80
83
  /** Where a diagnostic came from: a script block, or the markup itself. */
81
- export type DiagnosticOrigin = ScriptKind | 'template';
84
+ export type DiagnosticOrigin = ScriptKind | 'template' | 'component';
82
85
  export {
83
86
  extractScriptBlocks,
84
87
  extractTemplateExpressions,