@stacksjs/stx 0.2.760 → 0.2.762

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 (249) hide show
  1. package/dist/chunk-00nz3pas.js +2 -0
  2. package/dist/{chunk-eazvp48w.js → chunk-02c46de1.js} +26 -9
  3. package/dist/chunk-05jdq9tw.js +177 -0
  4. package/dist/chunk-0cajfv7y.js +2 -0
  5. package/dist/{chunk-3nxe5xmy.js → chunk-0fs9kx0h.js} +3 -3
  6. package/dist/{chunk-42hcspws.js → chunk-0kq0k4pg.js} +2 -2
  7. package/dist/{chunk-y8srg0q3.js → chunk-0sd4td6z.js} +3 -3
  8. package/dist/{chunk-f4gqzg1y.js → chunk-0wj31pqy.js} +2 -2
  9. package/dist/chunk-13v3vgb6.js +2 -0
  10. package/dist/{chunk-v5afjcy3.js → chunk-18chz0q4.js} +1 -1
  11. package/dist/chunk-1p8t2ekg.js +2 -0
  12. package/dist/chunk-1rcntvgx.js +2 -0
  13. package/dist/chunk-1w5gtkd6.js +2 -0
  14. package/dist/chunk-28vtqwxh.js +2 -0
  15. package/dist/chunk-298gj90a.js +2 -0
  16. package/dist/{chunk-n8s5301s.js → chunk-2eamszdq.js} +2 -2
  17. package/dist/chunk-2gn6smrq.js +2 -0
  18. package/dist/{chunk-h692k9xn.js → chunk-2typf9dh.js} +4 -4
  19. package/dist/chunk-2wq0h5ye.js +2 -0
  20. package/dist/{chunk-prej5pk6.js → chunk-2zd51tj4.js} +2 -2
  21. package/dist/chunk-2zg3jmy7.js +2 -0
  22. package/dist/{chunk-ztdjdxjt.js → chunk-319aez2f.js} +3 -3
  23. package/dist/{chunk-7g9vd5fv.js → chunk-37y8sg48.js} +2 -2
  24. package/dist/{chunk-j2mpqa4p.js → chunk-3csfmhg0.js} +2 -2
  25. package/dist/{chunk-jb1dk0w7.js → chunk-3mz088mb.js} +2 -2
  26. package/dist/chunk-3wxb7mfb.js +2 -0
  27. package/dist/{chunk-cehjp06v.js → chunk-42zqmcnc.js} +3 -3
  28. package/dist/{chunk-89h4snzd.js → chunk-4833k99b.js} +2 -2
  29. package/dist/{chunk-jevd16gq.js → chunk-48g9wez2.js} +30 -30
  30. package/dist/chunk-4tgn1frg.js +3 -0
  31. package/dist/chunk-528cn6qm.js +2 -0
  32. package/dist/{chunk-afj19nsj.js → chunk-59k4xb92.js} +5 -5
  33. package/dist/chunk-5x0g7e9y.js +2 -0
  34. package/dist/{chunk-83ezv8yz.js → chunk-5yhv5eqq.js} +3 -3
  35. package/dist/chunk-633a53wg.js +2 -0
  36. package/dist/chunk-6b737vch.js +2 -0
  37. package/dist/chunk-72ns4q88.js +2 -0
  38. package/dist/chunk-736ex6r5.js +26 -0
  39. package/dist/chunk-86cg9qqm.js +2 -0
  40. package/dist/{chunk-gs6wc7sr.js → chunk-89801pjp.js} +5 -5
  41. package/dist/chunk-8czxtjwm.js +2 -0
  42. package/dist/chunk-8h5mqs28.js +2 -0
  43. package/dist/{chunk-yp6w740k.js → chunk-8rk79ha1.js} +2 -2
  44. package/dist/{chunk-kpr09x3g.js → chunk-8y54tpbr.js} +7 -7
  45. package/dist/{chunk-s4y26fk6.js → chunk-8yyq3nfg.js} +2 -2
  46. package/dist/{chunk-30j6mbrf.js → chunk-932zx5q4.js} +7 -7
  47. package/dist/chunk-940wny2b.js +2 -0
  48. package/dist/chunk-9fh4ah7t.js +2 -0
  49. package/dist/{chunk-sgm6tg8h.js → chunk-9k8ztdcc.js} +2 -2
  50. package/dist/{chunk-vvc39v6p.js → chunk-a222bwpc.js} +5 -5
  51. package/dist/chunk-a81rt2t4.js +3 -0
  52. package/dist/chunk-ad9dt9rk.js +2 -0
  53. package/dist/chunk-ak4w2emd.js +2 -0
  54. package/dist/{chunk-tb56j1zt.js → chunk-ak93e1zz.js} +5 -5
  55. package/dist/{chunk-jt28zh50.js → chunk-b0z2n941.js} +2 -2
  56. package/dist/{chunk-xgegyttg.js → chunk-b51p56k5.js} +2 -2
  57. package/dist/{chunk-r4sawwmp.js → chunk-b7x8b83z.js} +1 -1
  58. package/dist/chunk-b8dtz3v8.js +2 -0
  59. package/dist/{chunk-frk6rzrq.js → chunk-ben8bjnk.js} +4 -4
  60. package/dist/{chunk-w8p1y4c0.js → chunk-bvctccab.js} +4 -4
  61. package/dist/{chunk-hk98vptc.js → chunk-cdcrd33m.js} +2 -2
  62. package/dist/chunk-cenvzm5q.js +2 -0
  63. package/dist/chunk-d49pst1m.js +2 -0
  64. package/dist/{chunk-hfbzfrpv.js → chunk-d96xddt9.js} +14 -14
  65. package/dist/chunk-dj0qy19b.js +2 -0
  66. package/dist/{chunk-asp7ett1.js → chunk-dnsf934e.js} +9 -9
  67. package/dist/{chunk-7r7j7vwt.js → chunk-ds6mbfdq.js} +3 -3
  68. package/dist/{chunk-bsgg8zzk.js → chunk-dvpk4c1y.js} +2 -2
  69. package/dist/chunk-e2q79dfs.js +2 -0
  70. package/dist/{chunk-9s1qnf90.js → chunk-eb6p3p62.js} +2 -2
  71. package/dist/chunk-ebxncrd8.js +2 -0
  72. package/dist/{chunk-q49ykyq9.js → chunk-edhxg3rz.js} +14 -14
  73. package/dist/{chunk-rcfmwx8r.js → chunk-epa73jvs.js} +2 -2
  74. package/dist/{chunk-3cn9y08d.js → chunk-evxp3wmv.js} +7 -7
  75. package/dist/{chunk-z8k3fx4r.js → chunk-f8p8ggvw.js} +4 -4
  76. package/dist/{chunk-se28p2xy.js → chunk-fhpsf4z7.js} +6 -6
  77. package/dist/chunk-fht1zs1r.js +2 -0
  78. package/dist/chunk-fjfrgef4.js +2 -0
  79. package/dist/chunk-fmk9hjht.js +2 -0
  80. package/dist/{chunk-4s9kytdz.js → chunk-fxmc5006.js} +2 -2
  81. package/dist/chunk-fxnk5ee8.js +2 -0
  82. package/dist/{chunk-6ts3sthp.js → chunk-g4k0svq6.js} +2 -2
  83. package/dist/{chunk-2qz891k4.js → chunk-gwjh981q.js} +10 -10
  84. package/dist/chunk-hnen9b45.js +2 -0
  85. package/dist/{chunk-7v2srnpv.js → chunk-j1tsda22.js} +10 -10
  86. package/dist/chunk-j1z7tgdp.js +2 -0
  87. package/dist/{chunk-4zw118tn.js → chunk-jgk5j35w.js} +4 -4
  88. package/dist/chunk-jq1698j4.js +2 -0
  89. package/dist/{chunk-pwmkhs7z.js → chunk-jyp2mmts.js} +2 -2
  90. package/dist/chunk-k0jkpw0q.js +2 -0
  91. package/dist/{chunk-3kfbs0mw.js → chunk-k2ex94n8.js} +1 -1
  92. package/dist/chunk-k469ym7a.js +2 -0
  93. package/dist/{chunk-m00c7sh0.js → chunk-k9247v28.js} +1 -1
  94. package/dist/{chunk-rprewgyj.js → chunk-k9wr8xf5.js} +6 -6
  95. package/dist/chunk-m3z13f59.js +25 -0
  96. package/dist/chunk-m5740sd3.js +2 -0
  97. package/dist/{chunk-qw9kgzb3.js → chunk-m6rzsbas.js} +5 -5
  98. package/dist/{chunk-5vmbycy5.js → chunk-mbe4gqd3.js} +2 -2
  99. package/dist/{chunk-myynywry.js → chunk-mdvtermb.js} +2 -2
  100. package/dist/chunk-mdw96yhg.js +2 -0
  101. package/dist/chunk-mebf9vwb.js +2 -0
  102. package/dist/{chunk-ej1jkt9a.js → chunk-nm9tnxnw.js} +6 -6
  103. package/dist/chunk-p2se8s6r.js +2 -0
  104. package/dist/chunk-p7zrz0wb.js +2 -0
  105. package/dist/chunk-pdnyfk2v.js +2 -0
  106. package/dist/{chunk-fjxhga6w.js → chunk-pqbxa0r7.js} +2 -2
  107. package/dist/chunk-q245q8z1.js +2 -0
  108. package/dist/{chunk-5q9ss7ty.js → chunk-q3azy64b.js} +4 -4
  109. package/dist/chunk-qfhjtz2q.js +2 -0
  110. package/dist/chunk-qjbcp3tc.js +33 -0
  111. package/dist/{chunk-qwsgc5rc.js → chunk-qystt1qc.js} +1 -1
  112. package/dist/{chunk-dh9aagwm.js → chunk-r1tp2gnr.js} +1 -1
  113. package/dist/chunk-r5tsewzd.js +2 -0
  114. package/dist/{chunk-pes27snj.js → chunk-r8zhed35.js} +3 -3
  115. package/dist/{chunk-g4e6egrr.js → chunk-rd33qkfs.js} +8 -8
  116. package/dist/{chunk-hmydy949.js → chunk-rh2qth8r.js} +5 -5
  117. package/dist/chunk-rha8sv1h.js +3 -0
  118. package/dist/{chunk-n7s4n62j.js → chunk-rj3p5fdy.js} +3 -3
  119. package/dist/{chunk-94ymndc5.js → chunk-rmk8efc3.js} +43 -43
  120. package/dist/chunk-rnvrtcz6.js +2 -0
  121. package/dist/{chunk-xsf7ax50.js → chunk-rqd6b2nc.js} +3 -3
  122. package/dist/{chunk-vtv7165t.js → chunk-rxm1mjkb.js} +2 -2
  123. package/dist/chunk-s36cpnxa.js +2 -0
  124. package/dist/{chunk-0y2zzqsq.js → chunk-t1shvfhm.js} +76 -76
  125. package/dist/{chunk-vh1d5eqk.js → chunk-t2cq4bpe.js} +6 -6
  126. package/dist/chunk-tfy1m821.js +2 -0
  127. package/dist/{chunk-465resq9.js → chunk-tpfxvw4q.js} +17 -17
  128. package/dist/{chunk-t6qn1374.js → chunk-tshpcvcy.js} +2 -2
  129. package/dist/chunk-v1ff2dfp.js +7 -0
  130. package/dist/chunk-vc3ppphz.js +2 -0
  131. package/dist/chunk-vttx66q0.js +2 -0
  132. package/dist/chunk-vxs07119.js +2 -0
  133. package/dist/chunk-w2pch5xn.js +4 -0
  134. package/dist/{chunk-j4snweyz.js → chunk-wby7qzha.js} +3 -3
  135. package/dist/{chunk-19safa6y.js → chunk-wmnzapn8.js} +2 -2
  136. package/dist/chunk-wwnqbv9j.js +3 -0
  137. package/dist/chunk-x1x69g3s.js +2 -0
  138. package/dist/{chunk-gs373714.js → chunk-x5seqmrv.js} +2 -2
  139. package/dist/chunk-x8hz5gzb.js +2 -0
  140. package/dist/chunk-xfdtym3s.js +2 -0
  141. package/dist/{chunk-q9npggak.js → chunk-xgnmgjpv.js} +8 -8
  142. package/dist/{chunk-bsq9zg9j.js → chunk-xt034729.js} +6 -6
  143. package/dist/{chunk-m220n98m.js → chunk-xtwc2dbk.js} +2 -2
  144. package/dist/{chunk-0ggwm837.js → chunk-y4mp1rra.js} +101 -101
  145. package/dist/chunk-y6mqq78g.js +2 -0
  146. package/dist/chunk-y8pftjg8.js +12 -0
  147. package/dist/{chunk-wz5m7ybz.js → chunk-yb71b2d6.js} +2 -2
  148. package/dist/chunk-ycttwgpg.js +2 -0
  149. package/dist/chunk-yd6x9226.js +2 -0
  150. package/dist/{chunk-3m9vrhja.js → chunk-yk456jp4.js} +8 -8
  151. package/dist/chunk-yn3kff5k.js +2 -0
  152. package/dist/chunk-ynjm2tm0.js +2 -0
  153. package/dist/{chunk-j04v4rgf.js → chunk-zhrz4zvw.js} +5 -5
  154. package/dist/chunk-zpjdp0he.js +2 -0
  155. package/dist/cli.js +20 -20
  156. package/dist/client/signals-hydration-audit-runtime.js +2 -0
  157. package/dist/client/signals-process-element-runtime.js +17 -2
  158. package/dist/composable-loader.d.ts +1 -1
  159. package/dist/composable-loader.js +47 -10
  160. package/dist/composables/index.d.ts +3 -0
  161. package/dist/composables/index.js +1 -0
  162. package/dist/composables/use-completion.d.ts +29 -0
  163. package/dist/composables/use-completion.js +125 -0
  164. package/dist/craft-entry.js +2 -2
  165. package/dist/craft.js +2 -2
  166. package/dist/message-catalogs.d.ts +39 -0
  167. package/dist/message-catalogs.js +128 -0
  168. package/dist/native/compiler/bundle.js +3 -33
  169. package/dist/process.d.ts +1 -1
  170. package/dist/process.js +87 -22
  171. package/dist/pwa.js +3 -3
  172. package/dist/ssg.js +14 -14
  173. package/dist/store-loader.d.ts +27 -3
  174. package/dist/store-loader.js +115 -10
  175. package/dist/types/config-types.d.ts +1 -0
  176. package/dist/unresolved-identifiers.js +1 -0
  177. package/package.json +5 -5
  178. package/dist/chunk-0b7f2mby.js +0 -2
  179. package/dist/chunk-0j7e56zm.js +0 -2
  180. package/dist/chunk-1khg5vjs.js +0 -2
  181. package/dist/chunk-3h2yz805.js +0 -2
  182. package/dist/chunk-3kmwgpm1.js +0 -2
  183. package/dist/chunk-3wfewscj.js +0 -2
  184. package/dist/chunk-4tz00fkp.js +0 -2
  185. package/dist/chunk-52q8184e.js +0 -2
  186. package/dist/chunk-59ytzyp1.js +0 -2
  187. package/dist/chunk-5e2ez5n0.js +0 -2
  188. package/dist/chunk-6ndeycxk.js +0 -2
  189. package/dist/chunk-75r09rqt.js +0 -2
  190. package/dist/chunk-76679dw7.js +0 -33
  191. package/dist/chunk-7h5d35bf.js +0 -2
  192. package/dist/chunk-7kac7hdw.js +0 -2
  193. package/dist/chunk-7nz28a6c.js +0 -16
  194. package/dist/chunk-82ybmdqk.js +0 -2
  195. package/dist/chunk-8av44gw2.js +0 -2
  196. package/dist/chunk-8frs2dtp.js +0 -2
  197. package/dist/chunk-8prq9t3b.js +0 -2
  198. package/dist/chunk-8sxngenk.js +0 -2
  199. package/dist/chunk-9epeb4sn.js +0 -2
  200. package/dist/chunk-9zmb7dcv.js +0 -2
  201. package/dist/chunk-abs1k04e.js +0 -2
  202. package/dist/chunk-akgt21vw.js +0 -2
  203. package/dist/chunk-b561wv5x.js +0 -2
  204. package/dist/chunk-bfdd0nmc.js +0 -2
  205. package/dist/chunk-c05r0rzw.js +0 -3
  206. package/dist/chunk-c7yjhjr2.js +0 -2
  207. package/dist/chunk-c9xq89nt.js +0 -2
  208. package/dist/chunk-cpep999n.js +0 -2
  209. package/dist/chunk-cr7mn65s.js +0 -2
  210. package/dist/chunk-dqs4bgec.js +0 -2
  211. package/dist/chunk-e30kgg28.js +0 -2
  212. package/dist/chunk-e3fkq9gb.js +0 -2
  213. package/dist/chunk-e9kajy9a.js +0 -2
  214. package/dist/chunk-eab8na0z.js +0 -2
  215. package/dist/chunk-ec5q50ve.js +0 -2
  216. package/dist/chunk-ec8gn2m0.js +0 -2
  217. package/dist/chunk-ex2397dc.js +0 -2
  218. package/dist/chunk-exg7ry7b.js +0 -2
  219. package/dist/chunk-f4j42tsg.js +0 -2
  220. package/dist/chunk-fj105fff.js +0 -2
  221. package/dist/chunk-gk775pcy.js +0 -177
  222. package/dist/chunk-ha6tr22a.js +0 -2
  223. package/dist/chunk-htc7pasb.js +0 -2
  224. package/dist/chunk-jfvr1135.js +0 -2
  225. package/dist/chunk-k3wnmpt3.js +0 -2
  226. package/dist/chunk-kb8654dp.js +0 -4
  227. package/dist/chunk-kfqdx75m.js +0 -2
  228. package/dist/chunk-mmdfjmgk.js +0 -25
  229. package/dist/chunk-mreh1t5x.js +0 -2
  230. package/dist/chunk-n839v6az.js +0 -2
  231. package/dist/chunk-ptzzpf97.js +0 -2
  232. package/dist/chunk-py7g5hxd.js +0 -2
  233. package/dist/chunk-qgsrxyh9.js +0 -2
  234. package/dist/chunk-qmxcs806.js +0 -2
  235. package/dist/chunk-qvcs4f4v.js +0 -2
  236. package/dist/chunk-qz9fzz5k.js +0 -2
  237. package/dist/chunk-rh90yh1c.js +0 -2
  238. package/dist/chunk-s0wst4wj.js +0 -2
  239. package/dist/chunk-sj5t0tnv.js +0 -2
  240. package/dist/chunk-stddpecv.js +0 -2
  241. package/dist/chunk-t4mpq6t0.js +0 -3
  242. package/dist/chunk-tb6jcr2v.js +0 -2
  243. package/dist/chunk-tdjw105v.js +0 -2
  244. package/dist/chunk-tn40nh9e.js +0 -3
  245. package/dist/chunk-tp2g09ca.js +0 -3
  246. package/dist/chunk-wpgq0tq4.js +0 -2
  247. package/dist/chunk-xabs41cv.js +0 -12
  248. package/dist/chunk-yme43vbp.js +0 -2
  249. package/dist/chunk-zg5xh20b.js +0 -2
package/dist/cli.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import"./chunk-465resq9.js";import"./chunk-xgegyttg.js";import"./chunk-89h4snzd.js";import{Pe,oe}from"./chunk-0ggwm837.js";import"./chunk-gs373714.js";import"./chunk-bsgg8zzk.js";import"./chunk-yp6w740k.js";import"./chunk-z8k3fx4r.js";import"./chunk-q49ykyq9.js";import"./chunk-3cn9y08d.js";import"./chunk-5q9ss7ty.js";import"./chunk-0y2zzqsq.js";import"./chunk-wz5m7ybz.js";import"./chunk-g4e6egrr.js";import"./chunk-q9npggak.js";import"./chunk-2qz891k4.js";import"./chunk-n7s4n62j.js";import"./chunk-asp7ett1.js";import"./chunk-pes27snj.js";import"./chunk-myynywry.js";import"./chunk-hk98vptc.js";import"./chunk-prej5pk6.js";import"./chunk-j04v4rgf.js";import"./chunk-se28p2xy.js";import"./chunk-w8p1y4c0.js";import"./chunk-m220n98m.js";import"./chunk-eazvp48w.js";import"./chunk-t6qn1374.js";import"./chunk-7g9vd5fv.js";import"./chunk-5vmbycy5.js";import"./chunk-s4y26fk6.js";import"./chunk-3m9vrhja.js";import"./chunk-mmdfjmgk.js";import"./chunk-jt28zh50.js";import"./chunk-y8srg0q3.js";import"./chunk-tb56j1zt.js";import"./chunk-afj19nsj.js";import"./chunk-rcfmwx8r.js";import"./chunk-rprewgyj.js";import"./chunk-gs6wc7sr.js";import"./chunk-7r7j7vwt.js";import"./chunk-hmydy949.js";import"./chunk-19safa6y.js";import{Zt,Qt}from"./chunk-frk6rzrq.js";import"./chunk-76679dw7.js";import"./chunk-7v2srnpv.js";import"./chunk-vh1d5eqk.js";import"./chunk-bsq9zg9j.js";import"./chunk-dh9aagwm.js";import"./chunk-j4snweyz.js";import"./chunk-r4sawwmp.js";import"./chunk-7nz28a6c.js";import"./chunk-n8s5301s.js";import{zi,Hi,Vi,Ui,eo,Wi,qi,Ki,to,no,Mr,Lr,jr}from"./chunk-94ymndc5.js";import"./chunk-qw9kgzb3.js";import"./chunk-3nxe5xmy.js";import"./chunk-vtv7165t.js";import"./chunk-tp2g09ca.js";import"./chunk-sgm6tg8h.js";import"./chunk-30j6mbrf.js";import"./chunk-3kfbs0mw.js";import{dc}from"./chunk-xsf7ax50.js";import{g}from"./chunk-0dve54ne.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
4
- Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var U=n.argv.length>=3&&(W(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(U){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=E(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),i=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of i)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await Lr(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Mr(h,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let r=0;r<=e.length;r++)o[r]=[r];for(let r=0;r<=t.length;r++)o[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=t.length;s++)if(e.charAt(r-1)===t.charAt(s-1))o[r][s]=o[r-1][s-1];else o[r][s]=Math.min(o[r-1][s-1]+1,o[r][s-1]+1,o[r-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await Ui(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(t,e)=>{try{let{fetchCollections:o,generatePackage:r}=await import("./chunk-3wkgd883.js");if(t==="list"){console.log(`
3
+ import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import{Pe,oe}from"./chunk-y4mp1rra.js";import"./chunk-x5seqmrv.js";import"./chunk-dvpk4c1y.js";import"./chunk-8rk79ha1.js";import"./chunk-f8p8ggvw.js";import"./chunk-edhxg3rz.js";import"./chunk-evxp3wmv.js";import"./chunk-q3azy64b.js";import"./chunk-t1shvfhm.js";import"./chunk-yb71b2d6.js";import"./chunk-rd33qkfs.js";import"./chunk-xgnmgjpv.js";import"./chunk-gwjh981q.js";import"./chunk-rj3p5fdy.js";import"./chunk-dnsf934e.js";import"./chunk-r8zhed35.js";import"./chunk-mdvtermb.js";import"./chunk-cdcrd33m.js";import"./chunk-2zd51tj4.js";import"./chunk-zhrz4zvw.js";import"./chunk-fhpsf4z7.js";import"./chunk-bvctccab.js";import"./chunk-xtwc2dbk.js";import"./chunk-02c46de1.js";import"./chunk-tshpcvcy.js";import"./chunk-37y8sg48.js";import"./chunk-mbe4gqd3.js";import"./chunk-8yyq3nfg.js";import"./chunk-yk456jp4.js";import"./chunk-m3z13f59.js";import"./chunk-b0z2n941.js";import"./chunk-0sd4td6z.js";import"./chunk-ak93e1zz.js";import"./chunk-59k4xb92.js";import"./chunk-epa73jvs.js";import"./chunk-k9wr8xf5.js";import"./chunk-89801pjp.js";import"./chunk-ds6mbfdq.js";import"./chunk-rh2qth8r.js";import"./chunk-wmnzapn8.js";import{Qt,en}from"./chunk-ben8bjnk.js";import"./chunk-qjbcp3tc.js";import"./chunk-j1tsda22.js";import"./chunk-t2cq4bpe.js";import"./chunk-xt034729.js";import"./chunk-r1tp2gnr.js";import"./chunk-wby7qzha.js";import"./chunk-b7x8b83z.js";import"./chunk-736ex6r5.js";import"./chunk-2eamszdq.js";import{Vi,Ui,Wi,qi,to,Ki,Gi,Xi,no,ro,Lr,jr,Br}from"./chunk-rmk8efc3.js";import"./chunk-m6rzsbas.js";import"./chunk-0fs9kx0h.js";import"./chunk-rxm1mjkb.js";import"./chunk-a81rt2t4.js";import"./chunk-9k8ztdcc.js";import"./chunk-932zx5q4.js";import"./chunk-k2ex94n8.js";import{pc}from"./chunk-rqd6b2nc.js";import{g}from"./chunk-0dve54ne.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as z}from"@stacksjs/clapp";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new z("stx");function E(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),r=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:r}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function I(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),W=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function M(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function V(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let i=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(i.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...i),m.verbose)console.log(`Found ${i.length} file(s) matching pattern: ${c}`)}catch(i){return console.error(`Error expanding glob pattern ${c}:`,i),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let r=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(i)=>{let d=((performance.now()-r)/1000).toFixed(2);if(i===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
4
+ Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var U=n.argv.length>=3&&(W(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(U){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=E(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),i=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of i)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await jr(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else Lr(h,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let r=0;r<=e.length;r++)o[r]=[r];for(let r=0;r<=t.length;r++)o[0][r]=r;for(let r=1;r<=e.length;r++)for(let s=1;s<=t.length;s++)if(e.charAt(r-1)===t.charAt(s-1))o[r][s]=o[r-1][s-1];else o[r][s]=Math.min(o[r-1][s-1]+1,o[r][s-1]+1,o[r-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await qi(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(t,e)=>{try{let{fetchCollections:o,generatePackage:r}=await import("./chunk-3wkgd883.js");if(t==="list"){console.log(`
5
5
  \uD83D\uDCDA Fetching available icon collections...
6
6
  `);let s=await o(),c=Object.entries(s).sort((i,l)=>l[1].total-i[1].total);console.log(`Available collections:
7
7
  `);for(let[i,l]of c){let d=l;console.log(` ${i.padEnd(30)} ${d.name} (${d.total} icons)`)}console.log(`
8
8
  Total: ${c.length} collections`)}else if(t.startsWith("generate")){let s=t==="generate"?"":t.replace("generate:","").replace("generate-","").replace("generate","").trim();if(!s)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx iconify generate <prefix> [--icons icon1,icon2,...]"),n.exit(1);let c=e.output||f.join(n.cwd(),"packages/collections"),i=e.icons?e.icons.split(",").map((l)=>l.trim()):void 0;await r(s,c,i),console.log(`
9
9
  \u2713 Package generated successfully!`),console.log(`
10
- To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-75r09rqt.js"),{loadConfig:s}=await import("./chunk-c9xq89nt.js");console.log(`
10
+ To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:r}=await import("./chunk-fjfrgef4.js"),{loadConfig:s}=await import("./chunk-j1z7tgdp.js");console.log(`
11
11
  \uD83D\uDD0D Running PWA audit...
12
- `);let c=await s(),i=e.output||"dist",l=o(c,i);if(console.log(r(l)),l.failed>0)n.exit(1)}else console.error(`Unknown pwa command: ${t}`),console.error("Available commands: audit"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--pages <dir>",'Directory containing page templates (default: pagesDir from stx.config.ts, else "pages")').option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--titlebar-hidden","Hide the native titlebar but keep the traffic-light buttons (web content draws under a transparent full-size titlebar). Implies --native.").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev --pages src/pages").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(t,e)=>{try{if(e.port!==void 0){let r=E(e.port);if(!r.isValid)F(r);e.port=Number.parseInt(String(e.port),10)}if(e.timeout!==void 0){let r=I(e.timeout);if(!r.isValid)F(r)}let o={syntaxHighlighting:{enabled:e.highlight!==!1,serverSide:!0,defaultTheme:e.highlightTheme||"github-dark",highlightUnknownLanguages:e.highlightUnknown!==!1}};if(!t){if(!await jr(".",{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}if(!O(t))try{let r=await import("fs");if(r.existsSync(t)&&r.statSync(t).isDirectory()){if(!await jr(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}}catch{}if(O(t)){console.log(`Expanding glob pattern: ${t}`);let r=await oe.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?r.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?r.filter((d)=>d.endsWith(".md")):r.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",i=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((p)=>/\[.+\]/.test(f.basename(p)));for(let p of u)if(!s.includes(p))s.push(p)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await Lr(s,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}else{if(!O(t)){let s=A(t);if(!s.isValid)F(s)}if(!await Mr(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}}catch(o){console.error("Error starting dev server:",o),n.exit(1)}}),y.command("a11y [target]","Scan .stx files for accessibility issues (directory, file, or glob)").option("--no-recursive","Disable recursive scanning of directories").option("--ignore <paths>","Comma-separated paths to ignore",{default:""}).option("--json","Output results as JSON").option("--output <file>","Write results to a file instead of stdout").option("--fix","Automatically fix common accessibility issues").example("stx a11y ./templates").example('stx a11y "resources/**/*.stx"').example("stx a11y resources/emails/welcome.stx").example("stx a11y --json --output a11y-report.json").action(async(t=".",e)=>{try{console.log(`Scanning ${t} for accessibility issues...`);let o=e.ignore?e.ignore.split(",").map((l)=>l.trim()):[],{results:r,scannedFiles:s}=await dc(t,{recursive:e.recursive!==!1,ignorePaths:o});if(s.length===0)console.log(`
12
+ `);let c=await s(),i=e.output||"dist",l=o(c,i);if(console.log(r(l)),l.failed>0)n.exit(1)}else console.error(`Unknown pwa command: ${t}`),console.error("Available commands: audit"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--pages <dir>",'Directory containing page templates (default: pagesDir from stx.config.ts, else "pages")').option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--titlebar-hidden","Hide the native titlebar but keep the traffic-light buttons (web content draws under a transparent full-size titlebar). Implies --native.").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev --pages src/pages").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(t,e)=>{try{if(e.port!==void 0){let r=E(e.port);if(!r.isValid)F(r);e.port=Number.parseInt(String(e.port),10)}if(e.timeout!==void 0){let r=I(e.timeout);if(!r.isValid)F(r)}let o={syntaxHighlighting:{enabled:e.highlight!==!1,serverSide:!0,defaultTheme:e.highlightTheme||"github-dark",highlightUnknownLanguages:e.highlightUnknown!==!1}};if(!t){if(!await Br(".",{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}if(!O(t))try{let r=await import("fs");if(r.existsSync(t)&&r.statSync(t).isDirectory()){if(!await Br(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}}catch{}if(O(t)){console.log(`Expanding glob pattern: ${t}`);let r=await oe.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?r.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?r.filter((d)=>d.endsWith(".md")):r.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",i=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:i,onlyFiles:!0,absolute:!0}))).filter((p)=>/\[.+\]/.test(f.basename(p)));for(let p of u)if(!s.includes(p))s.push(p)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await jr(s,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}else{if(!O(t)){let s=A(t);if(!s.isValid)F(s)}if(!await Lr(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}}catch(o){console.error("Error starting dev server:",o),n.exit(1)}}),y.command("a11y [target]","Scan .stx files for accessibility issues (directory, file, or glob)").option("--no-recursive","Disable recursive scanning of directories").option("--ignore <paths>","Comma-separated paths to ignore",{default:""}).option("--json","Output results as JSON").option("--output <file>","Write results to a file instead of stdout").option("--fix","Automatically fix common accessibility issues").example("stx a11y ./templates").example('stx a11y "resources/**/*.stx"').example("stx a11y resources/emails/welcome.stx").example("stx a11y --json --output a11y-report.json").action(async(t=".",e)=>{try{console.log(`Scanning ${t} for accessibility issues...`);let o=e.ignore?e.ignore.split(",").map((l)=>l.trim()):[],{results:r,scannedFiles:s}=await pc(t,{recursive:e.recursive!==!1,ignorePaths:o});if(s.length===0)console.log(`
13
13
  No .stx files matched ${t}
14
14
  `),n.exit(1);let c=Object.keys(r).length,i=Object.values(r).reduce((l,d)=>l+d.length,0);if(e.json){let l=JSON.stringify(r,null,2);if(e.output)await Bun.write(e.output,l),console.log(`A11y scan results written to ${e.output}`);else console.log(l)}else if(c===0)console.log(`\u2713 No accessibility issues found in ${s.length} file(s)!`);else{console.log(`Found ${i} accessibility issues in ${c} files:
15
15
  `);for(let[l,d]of Object.entries(r)){let a=f.relative(n.cwd(),l);console.log(`
@@ -61,7 +61,7 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
61
61
  `).join("")}
62
62
  </body>
63
63
  </html>
64
- `.trim();await Bun.write(e.output,l),console.log(`A11y scan results written to ${e.output}`)}}n.exit(i>0?1:0)}catch(o){console.error("Error scanning for accessibility issues:",o),n.exit(1)}}),y.command("components:build [input]","Compile .stx files into a progressive web component library").option("--out <dir>","Output directory",{default:"dist/components"}).option("--prefix <name>","Prefix for inferred custom-element tags",{default:"stx"}).option("--shadow","Use open Shadow DOM by default").option("--no-progressive","Always render client templates on connection").option("--no-manifest","Skip custom-elements.json generation").option("--no-types","Skip TypeScript and JSX declarations").option("--no-css","Skip CSS output").option("--no-bundle","Skip bundle.js generation").option("--no-minify","Do not minify bundle.js and CSS").option("--sourcemap","Generate an external bundle source map").example("stx components:build components --out dist --prefix acme").example("stx components:build src/components --shadow --sourcemap").action(async(t,e)=>{try{let o=await Vi({inputDir:t||"components",outputDir:e.out,prefix:e.prefix,shadowDOM:e.shadow?"open":!1,progressive:e.progressive!==!1,manifest:e.manifest!==!1,declarations:e.types!==!1,css:e.css!==!1,bundle:e.bundle!==!1,minify:e.minify!==!1,sourcemap:e.sourcemap?"external":!1});console.log(`Built ${o.components.length} web component${o.components.length===1?"":"s"} to ${f.resolve(e.out)}`),console.log(`Generated ${o.files.length} files (${(o.totalBytes/1024).toFixed(1)} kB)`);for(let r of o.components)console.log(` ${r.tag} <- ${f.relative(n.cwd(),r.source)}`)}catch(o){console.error(`Component library build failed: ${o.message}`),n.exit(1)}}),y.command("build [input]","Generate static HTML files from STX templates (SSG)").option("--pages <dir>","Directory containing page templates",{default:"pages"}).option("--out <dir>","Output directory for generated files",{default:"dist"}).option("--domain <url>","Site domain for absolute URLs (e.g., https://example.com)").option("--base <path>","Base URL path for the site",{default:"/"}).option("--sitemap","Generate sitemap.xml",{default:!0}).option("--no-sitemap","Disable sitemap generation").option("--rss","Generate RSS feed").option("--minify","Minify HTML output",{default:!0}).option("--no-minify","Disable HTML minification").option("--no-cache","Disable build caching").option("--clean","Clean output directory before build",{default:!0}).option("--no-clean","Keep existing files in output directory").option("--concurrency <n>","Parallel page generation limit",{default:"10"}).option("--public <dir>","Directory with static assets to copy",{default:"public"}).option("--trailing-slash","Add trailing slashes to URLs").option("--verbose","Show detailed build output").option("--port <number>","Development server port for preview").option("--timeout <ms>","Build timeout in milliseconds").example("stx build").example("stx build --pages src/pages --out public").example("stx build --domain https://example.com --sitemap").example("stx build --no-minify --verbose").action(async(t,e)=>{try{let o=performance.now();if(e.port!==void 0){let d=Number.parseInt(e.port,10);if(d<1024||d>65535){if(d<1024)console.error(`
64
+ `.trim();await Bun.write(e.output,l),console.log(`A11y scan results written to ${e.output}`)}}n.exit(i>0?1:0)}catch(o){console.error("Error scanning for accessibility issues:",o),n.exit(1)}}),y.command("components:build [input]","Compile .stx files into a progressive web component library").option("--out <dir>","Output directory",{default:"dist/components"}).option("--prefix <name>","Prefix for inferred custom-element tags",{default:"stx"}).option("--shadow","Use open Shadow DOM by default").option("--no-progressive","Always render client templates on connection").option("--no-manifest","Skip custom-elements.json generation").option("--no-types","Skip TypeScript and JSX declarations").option("--no-css","Skip CSS output").option("--no-bundle","Skip bundle.js generation").option("--no-minify","Do not minify bundle.js and CSS").option("--sourcemap","Generate an external bundle source map").example("stx components:build components --out dist --prefix acme").example("stx components:build src/components --shadow --sourcemap").action(async(t,e)=>{try{let o=await Wi({inputDir:t||"components",outputDir:e.out,prefix:e.prefix,shadowDOM:e.shadow?"open":!1,progressive:e.progressive!==!1,manifest:e.manifest!==!1,declarations:e.types!==!1,css:e.css!==!1,bundle:e.bundle!==!1,minify:e.minify!==!1,sourcemap:e.sourcemap?"external":!1});console.log(`Built ${o.components.length} web component${o.components.length===1?"":"s"} to ${f.resolve(e.out)}`),console.log(`Generated ${o.files.length} files (${(o.totalBytes/1024).toFixed(1)} kB)`);for(let r of o.components)console.log(` ${r.tag} <- ${f.relative(n.cwd(),r.source)}`)}catch(o){console.error(`Component library build failed: ${o.message}`),n.exit(1)}}),y.command("build [input]","Generate static HTML files from STX templates (SSG)").option("--pages <dir>","Directory containing page templates",{default:"pages"}).option("--out <dir>","Output directory for generated files",{default:"dist"}).option("--domain <url>","Site domain for absolute URLs (e.g., https://example.com)").option("--base <path>","Base URL path for the site",{default:"/"}).option("--sitemap","Generate sitemap.xml",{default:!0}).option("--no-sitemap","Disable sitemap generation").option("--rss","Generate RSS feed").option("--minify","Minify HTML output",{default:!0}).option("--no-minify","Disable HTML minification").option("--no-cache","Disable build caching").option("--clean","Clean output directory before build",{default:!0}).option("--no-clean","Keep existing files in output directory").option("--concurrency <n>","Parallel page generation limit",{default:"10"}).option("--public <dir>","Directory with static assets to copy",{default:"public"}).option("--trailing-slash","Add trailing slashes to URLs").option("--verbose","Show detailed build output").option("--port <number>","Development server port for preview").option("--timeout <ms>","Build timeout in milliseconds").example("stx build").example("stx build --pages src/pages --out public").example("stx build --domain https://example.com --sitemap").example("stx build --no-minify --verbose").action(async(t,e)=>{try{let o=performance.now();if(e.port!==void 0){let d=Number.parseInt(e.port,10);if(d<1024||d>65535){if(d<1024)console.error(`
65
65
  Port must be between 1024 and 65535`),console.error(`
66
66
  suggestion: Try using a port between 1024 and 65535 (e.g., --port 3000)`);else console.error(`
67
67
  Port must be between 1024 and 65535`);n.exit(1)}}if(e.timeout!==void 0){let d=Number.parseInt(e.timeout,10);if(Number.isNaN(d))console.error(`
@@ -69,13 +69,13 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
69
69
  File not found: ${t}`),n.exit(1);if(!t.endsWith(".stx"))console.error(`
70
70
  File must have .stx extension: ${t}`),n.exit(1)}let r=f.resolve(e.pages),s=f.resolve(e.out);if(!t&&!S.existsSync(r))console.error(`
71
71
  Pages directory not found: ${r}`),console.log(`
72
- Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-f4j42tsg.js");Qt();let i=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
72
+ Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-zpjdp0he.js");en();let i=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(i.mode==="ssr"&&i.ssr)console.log(`
73
73
  Build complete! (SSR)
74
74
  `),console.log(` Pages compiled: ${i.ssr.pageCount}`),console.log(` Output: ${i.ssr.outputDir}`),console.log(` Duration: ${l}s
75
75
  `);else if(i.ssg){if(console.log(`
76
76
  Build complete! (SSG)
77
77
  `),console.log(` Pages generated: ${i.ssg.successCount}`),i.ssg.failedCount>0)console.log(` Failed: ${i.ssg.failedCount}`);if(i.ssg.cachedCount>0)console.log(` From cache: ${i.ssg.cachedCount}`);if(i.ssg.sitemapPath)console.log(` Sitemap: ${f.relative(n.cwd(),i.ssg.sitemapPath)}`);if(i.ssg.rssPath)console.log(` RSS: ${f.relative(n.cwd(),i.ssg.rssPath)}`);if(console.log(` Build time: ${l}s`),console.log(` Output: ${f.relative(n.cwd(),e.out||"dist")}/
78
- `),i.ssg.errors.length>0){console.log(" Errors:");for(let a of i.ssg.errors)console.error(` ${a.route}: ${a.error}`);console.log("")}if(e.verbose&&i.ssg.pages.length>0&&i.ssg.pages.length<=20){console.log(" Generated pages:");for(let a of i.ssg.pages){let u=f.relative(n.cwd(),a.outputPath),p=(a.size/1024).toFixed(1);console.log(` ${u} (${p} KB)${a.cached?" [cached]":""}`)}console.log("")}let d=Zt();if(d.length>0){console.error(`
78
+ `),i.ssg.errors.length>0){console.log(" Errors:");for(let a of i.ssg.errors)console.error(` ${a.route}: ${a.error}`);console.log("")}if(e.verbose&&i.ssg.pages.length>0&&i.ssg.pages.length<=20){console.log(" Generated pages:");for(let a of i.ssg.pages){let u=f.relative(n.cwd(),a.outputPath),p=(a.size/1024).toFixed(1);console.log(` ${u} (${p} KB)${a.cached?" [cached]":""}`)}console.log("")}let d=Qt();if(d.length>0){console.error(`
79
79
  ${d.length} client script(s) failed to bundle:
80
80
  `);for(let a of d)console.error(` ${f.relative(n.cwd(),a.filePath)}
81
81
  ${a.message}
@@ -84,8 +84,8 @@ Total: ${i} issues in ${c} files`),e.output){let l=`
84
84
  Build completed with ${i.ssg.failedCount} error(s). Fix the issues above and try again.
85
85
  `),n.exit(1);console.log(" To preview locally:"),console.log(` cd ${e.out||"dist"} && npx serve
86
86
  `)}}catch(o){console.error(`
87
- Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-7kac7hdw.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
88
- Failed to start production server:`,e instanceof Error?e.message:String(e)),n.exit(1)}}),y.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(t,e)=>{try{let{deploy:o,initNetlify:r,DeployError:s}=await import("./chunk-52q8184e.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Pe}\x1B[0m`),e.init){console.log(`
87
+ Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-fht1zs1r.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
88
+ Failed to start production server:`,e instanceof Error?e.message:String(e)),n.exit(1)}}),y.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(t,e)=>{try{let{deploy:o,initNetlify:r,DeployError:s}=await import("./chunk-yn3kff5k.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${Pe}\x1B[0m`),e.init){console.log(`
89
89
  \uD83D\uDCDD Initializing Netlify configuration...
90
90
  `);let i=await r({directory:t||n.cwd(),siteId:e.siteId});if(console.log(`\u2713 Created ${i.configPath}`),i.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
91
91
  You can now deploy with: stx deploy`);return}if(e.build!==!1){if(console.log(`
@@ -97,7 +97,7 @@ You can now deploy with: stx deploy`);return}if(e.build!==!1){if(console.log(`
97
97
  `),console.log(` ${e.dryRun?"Would deploy":"Draft URL"}: ${c.url}`),c.siteUrl)console.log(` Site URL: ${c.siteUrl}`);if(!e.dryRun)console.log(`
98
98
  Deploy ID: ${c.deployId}`),console.log(` Duration: ${(c.duration/1000).toFixed(1)}s`),console.log(` Files: ${c.filesUploaded}`)}}catch(o){if(o instanceof Error&&o.name==="DeployError")console.error(`
99
99
  \u274C ${o.message}`),n.exit(1);console.error(`
100
- \u274C Deploy failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(t,e)=>{try{let{optimizeDirectory:o,isSharpAvailable:r,formatSize:s}=await import("./chunk-kfqdx75m.js"),c=await import("fs"),i=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${Pe}\x1B[0m`),!await r())console.error(`
100
+ \u274C Deploy failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(t,e)=>{try{let{optimizeDirectory:o,isSharpAvailable:r,formatSize:s}=await import("./chunk-72ns4q88.js"),c=await import("fs"),i=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${Pe}\x1B[0m`),!await r())console.error(`
101
101
  \u274C sharp is required for image optimization.`),console.log(`
102
102
  Install sharp with:`),console.log(" bun add sharp"),n.exit(1);let d=e.widths.split(",").map((v)=>Number.parseInt(v.trim(),10)).filter((v)=>!Number.isNaN(v)),a=e.formats.split(",").map((v)=>v.trim().toLowerCase()),u=Number.parseInt(e.quality,10)||80,p=e.placeholder,b=i.resolve(t);if(!c.existsSync(b))console.error(`
103
103
  \u274C Input directory not found: ${b}`),n.exit(1);if(!c.statSync(b).isDirectory())console.error(`
@@ -116,17 +116,17 @@ Would generate ~${P} image variants`);return}console.log(`
116
116
  \u2713 Report generated: ${u.outputPath}`),e.open!==!1)console.log(" Opening in browser...")}else console.log(u.report);if(u.exceedsThreshold){let p=e.threshold;console.error(`
117
117
  \u274C Bundle size (${r(u.stats.totalSize)}) exceeds threshold (${p})`),n.exit(1)}if(a==="html"){if(console.log(`
118
118
  \uD83D\uDCCA Summary:`),console.log(` Total Size: ${r(u.stats.totalSize)}`),console.log(` Gzip Size: ${r(u.stats.totalGzipSize)}`),console.log(` Modules: ${u.stats.moduleCount}`),console.log(` Chunks: ${u.stats.chunks.length}`),u.stats.duplicates.length>0)console.log(` Duplicates: ${u.stats.duplicates.length}`)}}catch(o){console.error(`
119
- \u274C Bundle analysis failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(t,e)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${Pe} (${Ki})\x1B[0m`),e.timeout){let s=I(e.timeout);if(!s.isValid)F(s)}let o=typeof t==="string"?[t]:t||[];if(o.length===0)o.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(e.verbose)console.log("Test patterns:",o),console.log("Options:",JSON.stringify({watch:e.watch||!1,filter:e.filter||"none",reporter:e.reporter||"default",timeout:e.timeout||5000,coverage:e.coverage||!1,ui:e.ui||!1},null,2));if(!await oe.timeAsync("test-execution",()=>V(o,e))&&!e.watch)n.exit(1)}catch(o){console.error("Error running tests:",o),n.exit(1)}}),y.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(t="index.stx",e)=>{try{if(await qi(t,{force:e.force,template:e.template}))console.log(`
119
+ \u274C Bundle analysis failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(t,e)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${Pe} (${Xi})\x1B[0m`),e.timeout){let s=I(e.timeout);if(!s.isValid)F(s)}let o=typeof t==="string"?[t]:t||[];if(o.length===0)o.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(e.verbose)console.log("Test patterns:",o),console.log("Options:",JSON.stringify({watch:e.watch||!1,filter:e.filter||"none",reporter:e.reporter||"default",timeout:e.timeout||5000,coverage:e.coverage||!1,ui:e.ui||!1},null,2));if(!await oe.timeAsync("test-execution",()=>V(o,e))&&!e.watch)n.exit(1)}catch(o){console.error("Error running tests:",o),n.exit(1)}}),y.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(t="index.stx",e)=>{try{if(await Gi(t,{force:e.force,template:e.template}))console.log(`
120
120
  \u2728 Successfully created file: ${t}`),console.log(`
121
121
  To view it in the development server:`),console.log(` stx dev ${t}
122
122
  `);else console.error(`
123
- \u274C Failed to create file: ${t}`),n.exit(1)}catch(o){console.error("Error creating file:",o),n.exit(1)}}),y.command("format [patterns...]","Format STX and Markdown files automatically").option("--check","Check if files are formatted (exit with error if not)").option("--write","Write formatted files back to disk (default)").option("--diff","Show diff of changes that would be made").option("--ignore <patterns>","Comma-separated patterns to ignore").example("stx format").example("stx format **/*.stx").example("stx format **/*.md").example("stx format **/*.{stx,md}").example("stx format --check").example("stx format --diff --ignore node_modules/**").action(async(t,e)=>{try{if(e.check&&e.write)console.error("\u274C Options --check and --write are mutually exclusive"),console.error("\uD83D\uDCA1 Use --check to verify formatting or --write to apply changes, but not both"),n.exit(1);let o=t&&t.length>0?t:["**/*.stx","**/*.md"],r=e.ignore?e.ignore.split(",").map((a)=>a.trim()):["node_modules/**","dist/**",".git/**"],s=[];for(let a of o){let u=await Array.fromAsync(new Bun.Glob(a).scan({onlyFiles:!0,absolute:!0}));s.push(...u.filter((p)=>p.endsWith(".stx")||p.endsWith(".md")))}if(s=s.filter((a)=>!r.some((u)=>{let p=u.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*");return new RegExp(p).test(a)})),s.length===0){console.log("No STX or Markdown files found to format.");return}let c=s.filter((a)=>a.endsWith(".stx")),i=s.filter((a)=>a.endsWith(".md"));console.log(`Formatting ${s.length} files (${c.length} .stx, ${i.length} .md)...`);let l=0,d=0;for(let a of s)try{let u=await Bun.file(a).text(),b=a.endsWith(".md")?Wi(u):eo(u);if(u!==b)if(e.check)console.log(`\u274C ${f.relative(n.cwd(),a)} needs formatting`),d++;else if(e.diff)console.log(`
123
+ \u274C Failed to create file: ${t}`),n.exit(1)}catch(o){console.error("Error creating file:",o),n.exit(1)}}),y.command("format [patterns...]","Format STX and Markdown files automatically").option("--check","Check if files are formatted (exit with error if not)").option("--write","Write formatted files back to disk (default)").option("--diff","Show diff of changes that would be made").option("--ignore <patterns>","Comma-separated patterns to ignore").example("stx format").example("stx format **/*.stx").example("stx format **/*.md").example("stx format **/*.{stx,md}").example("stx format --check").example("stx format --diff --ignore node_modules/**").action(async(t,e)=>{try{if(e.check&&e.write)console.error("\u274C Options --check and --write are mutually exclusive"),console.error("\uD83D\uDCA1 Use --check to verify formatting or --write to apply changes, but not both"),n.exit(1);let o=t&&t.length>0?t:["**/*.stx","**/*.md"],r=e.ignore?e.ignore.split(",").map((a)=>a.trim()):["node_modules/**","dist/**",".git/**"],s=[];for(let a of o){let u=await Array.fromAsync(new Bun.Glob(a).scan({onlyFiles:!0,absolute:!0}));s.push(...u.filter((p)=>p.endsWith(".stx")||p.endsWith(".md")))}if(s=s.filter((a)=>!r.some((u)=>{let p=u.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*");return new RegExp(p).test(a)})),s.length===0){console.log("No STX or Markdown files found to format.");return}let c=s.filter((a)=>a.endsWith(".stx")),i=s.filter((a)=>a.endsWith(".md"));console.log(`Formatting ${s.length} files (${c.length} .stx, ${i.length} .md)...`);let l=0,d=0;for(let a of s)try{let u=await Bun.file(a).text(),b=a.endsWith(".md")?Ki(u):to(u);if(u!==b)if(e.check)console.log(`\u274C ${f.relative(n.cwd(),a)} needs formatting`),d++;else if(e.diff)console.log(`
124
124
  \uD83D\uDCDD ${f.relative(n.cwd(),a)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${f.basename(a)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(a,b),console.log(`\u2705 Formatted ${f.relative(n.cwd(),a)}`),l++}catch(u){console.error(`\u274C Error formatting ${f.relative(n.cwd(),a)}:`,u),d++}if(e.check&&d>0)console.log(`
125
125
  ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.check&&!e.diff)console.log(`\u2728 Formatted ${l} files successfully`)}catch(o){console.error("Error formatting files:",o),n.exit(1)}}),y.command("perf [command...]","Show performance statistics for STX operations").option("--clear","Clear performance statistics").option("--json","Output as JSON").example("stx perf").example("stx perf --clear").example("stx perf --json").action(async(t,e)=>{try{if(e.clear){oe.clear(),console.log("\u2705 Performance statistics cleared");return}let o=oe.getStats();if(Object.keys(o).length===0){if(e.json){console.log(JSON.stringify({},null,2));return}console.log("No performance data available. Run some STX commands first.");return}if(e.json)console.log(JSON.stringify(o,null,2));else{console.log(`
126
126
  \uD83D\uDCCA STX Performance Statistics
127
- `);for(let[r,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${r}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:r}=await import("./chunk-stddpecv.js"),{resolveStxTargets:s}=await import("./chunk-k3wnmpt3.js"),c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx"],l=await s(i);if(l.length===0){console.log(`
127
+ `);for(let[r,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${r}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:r}=await import("./chunk-vxs07119.js"),{resolveStxTargets:s}=await import("./chunk-tfy1m821.js"),c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx"],l=await s(i);if(l.length===0){console.log(`
128
128
  No .stx files matched ${i.join(", ")}
129
- `);return}let d=zi(n.argv,"--lib"),a=d.length>0?d:e.lib?Array.isArray(e.lib)?e.lib:[e.lib]:[],u=await r(l,{client:e.client!==!1,server:e.server!==!1,templates:e.templates!==!1,extraLibs:a});if(u.failure)console.error(`
129
+ `);return}let d=Vi(n.argv,"--lib"),a=d.length>0?d:e.lib?Array.isArray(e.lib)?e.lib:[e.lib]:[],u=await r(l,{client:e.client!==!1,server:e.server!==!1,templates:e.templates!==!1,extraLibs:a});if(u.failure)console.error(`
130
130
  Type-check did not run.
131
131
 
132
132
  ${u.failure.split(`
@@ -135,8 +135,8 @@ ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.chec
135
135
  `),n.exit(2);let p=u.diagnostics.filter((b)=>b.category==="error");if(u.diagnostics.length>0)console.error(`
136
136
  ${o(u.diagnostics)}
137
137
  `);if(console.log(` Checked ${u.blockCount} script block(s) and ${u.expressionCount} template expression(s) in ${u.checkedFiles.length} file(s) \u2014 `+`${p.length} error(s), ${u.diagnostics.length-p.length} warning(s)
138
- `),p.length>0)n.exit(1)}),y.command("codemod [patterns...]","Find hand-rolled code that an stx primitive already covers").option("--fix","Write the safe rewrites (default is report-only)").option("--rule <rule>","Run one rule only: confirm | tooltip (rewritable) \xB7 alert | route-params | search-params | navigate | "+"fetch | polling | debounce | click-outside | focus | clipboard | watch (report-only)").example("stx codemod").example("stx codemod --rule route-params").example('stx codemod --fix "resources/views/**/*.stx"').action(async(t,e)=>{let{codemodSource:o,formatCodemodFindings:r}=await import("./chunk-m00c7sh0.js"),s=globalThis.Bun.Glob,c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx","**/*.ts"],l=e.rule?[e.rule]:void 0;if(e.rule&&e.rule!=="confirm"&&e.rule!=="tooltip")console.error(`Unknown rule "${e.rule}". Expected: confirm | tooltip`),n.exit(1);let d=new Set,a=[],u=0,p=new Set;try{let b=Bun.spawnSync(["git","ls-files","--others","--ignored","--exclude-standard","-z"],{cwd:n.cwd(),stdout:"pipe",stderr:"pipe"});for(let w of new TextDecoder().decode(b.stdout).split("\x00"))if(w)p.add(f.resolve(n.cwd(),w))}catch{}for(let b of i)for await(let w of new s(b).scan({cwd:n.cwd(),absolute:!0})){if(w.includes("/node_modules/")||w.includes("/dist/")||d.has(w)||p.has(w))continue;d.add(w);let k=await Bun.file(w).text(),v=o(k,{file:w,rules:l});if(a.push(...v.findings),e.fix&&v.code!==k)await Bun.write(w,v.code),u++}if(console.error(r(a,Boolean(e.fix))),e.fix)console.error(`
139
- ${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let r=await import("./chunk-n839v6az.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await to({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(no(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
138
+ `),p.length>0)n.exit(1)}),y.command("codemod [patterns...]","Find hand-rolled code that an stx primitive already covers").option("--fix","Write the safe rewrites (default is report-only)").option("--rule <rule>","Run one rule only: confirm | tooltip (rewritable) \xB7 alert | route-params | search-params | navigate | "+"fetch | polling | debounce | click-outside | focus | clipboard | watch (report-only)").example("stx codemod").example("stx codemod --rule route-params").example('stx codemod --fix "resources/views/**/*.stx"').action(async(t,e)=>{let{codemodSource:o,formatCodemodFindings:r}=await import("./chunk-k9247v28.js"),s=globalThis.Bun.Glob,c=Array.isArray(t)?t:t?[t]:[],i=c.length?c:["**/*.stx","**/*.ts"],l=e.rule?[e.rule]:void 0;if(e.rule&&e.rule!=="confirm"&&e.rule!=="tooltip")console.error(`Unknown rule "${e.rule}". Expected: confirm | tooltip`),n.exit(1);let d=new Set,a=[],u=0,p=new Set;try{let b=Bun.spawnSync(["git","ls-files","--others","--ignored","--exclude-standard","-z"],{cwd:n.cwd(),stdout:"pipe",stderr:"pipe"});for(let w of new TextDecoder().decode(b.stdout).split("\x00"))if(w)p.add(f.resolve(n.cwd(),w))}catch{}for(let b of i)for await(let w of new s(b).scan({cwd:n.cwd(),absolute:!0})){if(w.includes("/node_modules/")||w.includes("/dist/")||d.has(w)||p.has(w))continue;d.add(w);let k=await Bun.file(w).text(),v=o(k,{file:w,rules:l});if(a.push(...v.findings),e.fix&&v.code!==k)await Bun.write(w,v.code),u++}if(console.error(r(a,Boolean(e.fix))),e.fix)console.error(`
139
+ ${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let r=await import("./chunk-p7zrz0wb.js");e=r.generateSignalsRuntime}catch{e=void 0}let o=await no({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(ro(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
140
140
  `);let r={};if(e.context)try{r=JSON.parse(e.context)}catch(i){console.error("\u274C Invalid JSON in --context option"),n.exit(1)}let s=await Bun.file(t).text();console.log(`\uD83D\uDCC4 Template Content (${s.length} chars):`),console.log("\u2500".repeat(50)),console.log(s.substring(0,500)+(s.length>500?`
141
141
  ...
142
142
  `:"")),console.log("\u2500".repeat(50));let c=s.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(c)console.log(`
@@ -151,7 +151,7 @@ ${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime
151
151
  \uD83D\uDCDD Markdown Files:`),i.forEach((d)=>{console.log(` ${f.relative(o,d)}`)})}}catch(o){console.error("Error getting project status:",o),n.exit(1)}}),y.command("watch [patterns...]","Watch STX files for changes and run commands").option("--command <cmd>","Command to run on file changes",{default:"build"}).option("--ignore <patterns>","Comma-separated patterns to ignore").option("--debounce <ms>","Debounce delay before running command after change",{default:300}).option("--output <dir>","Output directory for command results").option("--verbose","Show detailed file change information").option("--clear","Clear console before running command").example("stx watch").example('stx watch **/*.stx --command "stx build"').example('stx watch --ignore "node_modules/**,dist/**"').action(async(t,e)=>{try{if(!t||t.length===0)console.error("\u274C Input file or pattern is required"),console.error("\uD83D\uDCA1 Specify a file pattern to watch (e.g., stx watch *.stx)"),n.exit(1);let o=Array.isArray(t)?t:[t],r=e.ignore?e.ignore.split(",").map((p)=>p.trim()):["node_modules/**","dist/**",".git/**"];if(e.debounce!==void 0){if(!I(e.debounce).isValid)console.error("\u274C Debounce must be a valid number"),console.error("\uD83D\uDCA1 Specify debounce in milliseconds (e.g., --debounce 300)"),n.exit(1)}if(e.output){if((e.output.match(/\.\.\//g)||[]).length>=3)console.error("\u274C Invalid output directory"),console.error("\uD83D\uDCA1 Specify a valid output directory path"),n.exit(1)}let s=e.debounce||300;console.log(`\uD83D\uDC40 Watching files: ${o.join(", ")}`),console.log(`\uD83D\uDEAB Ignoring: ${r.join(", ")}`),console.log(`\u23F1\uFE0F Debounce: ${s}ms`),console.log(`\uD83D\uDD27 Command: ${e.command}`),console.log(`
152
152
  Press Ctrl+C to stop watching...
153
153
  `);let c,i=!1,l=new Set;l.add(n.cwd());for(let p of o)(await Array.fromAsync(new Bun.Glob(p).scan({onlyFiles:!0,absolute:!0}))).forEach((w)=>{l.add(f.dirname(w))});let d=async()=>{if(i)return;if(i=!0,e.clear)console.clear();console.log(`\uD83D\uDD04 Running: ${e.command}`);let p=Date.now();try{let[b,...w]=e.command.split(" ");R(b,w,{stdio:"inherit",shell:!0}).on("close",(v)=>{let T=Date.now()-p;if(v===0)console.log(`\u2705 Command completed successfully in ${T}ms`);else console.log(`\u274C Command failed with exit code ${v} after ${T}ms`);i=!1})}catch(b){console.error("\u274C Error running command:",b),i=!1}},a=(p,b)=>{if(!b)return;if(r.some((v)=>{if(v.includes("*"))return b.match(v.replace(/\*/g,".*"));return b.includes(v)})){if(e.verbose)console.log(`\uD83D\uDEAB Ignoring: ${b}`);return}if(!o.some((v)=>{if(v.includes("*"))return b.match(v.replace(/\*/g,".*"));return b.endsWith(v)})){if(e.verbose)console.log(`\u23ED\uFE0F Skipping: ${b} (doesn't match patterns)`);return}if(e.verbose)console.log(`\uD83D\uDCDD ${p.toUpperCase()}: ${b}`);if(c)clearTimeout(c);c=setTimeout(d,s)},u=[];for(let p of l)try{let b=S.watch(p,{recursive:!0},a);if(u.push(b),e.verbose)console.log(`\uD83D\uDCC1 Watching directory: ${p}`)}catch(b){console.warn(`\u26A0\uFE0F Could not watch directory: ${p}`)}n.on("SIGINT",()=>{console.log(`
154
- \uD83D\uDED1 Stopping file watcher...`),u.forEach((p)=>p.close()),n.exit(0)})}catch(o){console.error("Error setting up file watcher:",o),n.exit(1)}}),y.command("analyze [patterns...]","Analyze STX templates for performance and best practices").option("--json","Output results as JSON").option("--detailed","Show detailed analysis for each file").option("--only-issues","Only show files with issues").option("--save-report <file>","Save analysis report to file").option("--threshold <level>","Only show issues at or above this level (info, warning, error)",{default:"info"}).example("stx analyze").example("stx analyze **/*.stx --detailed").example("stx analyze --only-issues --threshold warning").action(async(t,e)=>{try{let o=t&&t.length>0?t:["**/*.stx"],r=e.threshold||"info",s={info:0,warning:1,error:2},c=s[r];if(!e.json)console.log("\uD83D\uDD0D Analyzing stx templates...");let{results:i,summary:l}=await Hi(o);if(i.length===0){console.log("No STX files found to analyze.");return}let d=e.onlyIssues?i.filter((a)=>a.issues.some((u)=>s[u.type]>=c)):i;if(e.json){let a={summary:l,results:d,generatedAt:new Date().toISOString()};if(e.saveReport)await Bun.write(e.saveReport,JSON.stringify(a,null,2)),console.log(`\uD83D\uDCCB Analysis report saved to: ${e.saveReport}`);else console.log(JSON.stringify(a,null,2));return}if(console.log(`
154
+ \uD83D\uDED1 Stopping file watcher...`),u.forEach((p)=>p.close()),n.exit(0)})}catch(o){console.error("Error setting up file watcher:",o),n.exit(1)}}),y.command("analyze [patterns...]","Analyze STX templates for performance and best practices").option("--json","Output results as JSON").option("--detailed","Show detailed analysis for each file").option("--only-issues","Only show files with issues").option("--save-report <file>","Save analysis report to file").option("--threshold <level>","Only show issues at or above this level (info, warning, error)",{default:"info"}).example("stx analyze").example("stx analyze **/*.stx --detailed").example("stx analyze --only-issues --threshold warning").action(async(t,e)=>{try{let o=t&&t.length>0?t:["**/*.stx"],r=e.threshold||"info",s={info:0,warning:1,error:2},c=s[r];if(!e.json)console.log("\uD83D\uDD0D Analyzing stx templates...");let{results:i,summary:l}=await Ui(o);if(i.length===0){console.log("No STX files found to analyze.");return}let d=e.onlyIssues?i.filter((a)=>a.issues.some((u)=>s[u.type]>=c)):i;if(e.json){let a={summary:l,results:d,generatedAt:new Date().toISOString()};if(e.saveReport)await Bun.write(e.saveReport,JSON.stringify(a,null,2)),console.log(`\uD83D\uDCCB Analysis report saved to: ${e.saveReport}`);else console.log(JSON.stringify(a,null,2));return}if(console.log(`
155
155
  \uD83D\uDCCA Analysis Summary`),console.log("\u2500".repeat(50)),console.log(`\uD83D\uDCC1 Files analyzed: ${l.totalFiles}`),console.log(`\uD83D\uDCCF Total lines: ${l.totalLines.toLocaleString()}`),console.log(`\uD83E\uDDEE Average complexity: ${l.avgComplexity}/10`),console.log(`\u26A0\uFE0F Total issues: ${l.totalIssues}`),console.log(`\uD83D\uDE80 Performance score: ${l.performanceScore}/10`),Object.keys(l.issuesByCategory).length>0){console.log(`
156
156
  \uD83D\uDCCB Issues by category:`);for(let[a,u]of Object.entries(l.issuesByCategory))console.log(` ${a}: ${u}`)}if(l.recommendations.length>0)console.log(`
157
157
  \uD83D\uDCA1 Project recommendations:`),l.recommendations.forEach((a)=>{console.log(` \u2022 ${a}`)});if(e.detailed){console.log(`
@@ -159,12 +159,12 @@ Press Ctrl+C to stop watching...
159
159
  \uD83D\uDCDD ${f.relative(n.cwd(),a.file)}`),console.log(` Lines: ${a.metrics.lines} | Complexity: ${a.metrics.complexity}/10 | Estimated render: ${a.performance.estimatedRenderTime}ms`),a.issues.length>0){let u=a.issues.filter((p)=>s[p.type]>=c);if(u.length>0)console.log(` Issues (${u.length}):`),u.forEach((p)=>{let b=p.type==="error"?"\u274C":p.type==="warning"?"\u26A0\uFE0F":"\u2139\uFE0F";if(console.log(` ${b} ${p.message}`),p.suggestion)console.log(` \uD83D\uDCA1 ${p.suggestion}`)})}if(a.suggestions.length>0)console.log(` Suggestions (${a.suggestions.length}):`),a.suggestions.forEach((u)=>{let p=u.impact==="high"?"\uD83D\uDD25":u.impact==="medium"?"\u26A1":"\uD83D\uDCAB";console.log(` ${p} ${u.message} (${u.impact} impact, ${u.effort} effort)`)})}}else if(d.length>0&&!e.onlyIssues)console.log(`
160
160
  \uD83D\uDCC4 Files with issues:`),d.forEach((a)=>{let u=a.issues.filter((p)=>s[p.type]>=c).length;if(u>0)console.log(` ${f.relative(n.cwd(),a.file)} (${u} issues)`)});if(e.saveReport){let a={summary:l,results:d,generatedAt:new Date().toISOString(),commandOptions:e};await Bun.write(e.saveReport,JSON.stringify(a,null,2)),console.log(`
161
161
  \uD83D\uDCCB Analysis report saved to: ${e.saveReport}`)}console.log(`
162
- \u2728 Analysis complete! Use --detailed for more information.`)}catch(o){console.error("Error analyzing templates:",o),n.exit(1)}}),y.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(t,e)=>{let{captureScreenshots:o}=await import("./chunk-tb6jcr2v.js"),r=t||"dist";try{let s=await o(r,e.out,{width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),waitMs:Number.parseInt(e.wait,10),timeoutMs:Number.parseInt(e.timeout,10),fullPage:Boolean(e.fullPage),waitSelector:e.waitSelector,format:e.format,backend:e.backend});for(let c of s)console.log(`\uD83D\uDCF8 ${c.output} (${(c.bytes/1024).toFixed(0)} KB)`);console.log(`
163
- \u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Pe)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-mreh1t5x.js"),o={};if(t.context){let r=f.resolve(t.context);if(S.existsSync(r))try{let s=S.readFileSync(r,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${r}`),n.exit(1)}await e({context:o,cwd:t.cwd?f.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:r,getAvailableFormats:s}=await import("./chunk-akgt21vw.js"),c=f.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let i=r();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${i.join(", ")}`),n.exit(1);let l=e.target||i[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
162
+ \u2728 Analysis complete! Use --detailed for more information.`)}catch(o){console.error("Error analyzing templates:",o),n.exit(1)}}),y.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(t,e)=>{let{captureScreenshots:o}=await import("./chunk-00nz3pas.js"),r=t||"dist";try{let s=await o(r,e.out,{width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),waitMs:Number.parseInt(e.wait,10),timeoutMs:Number.parseInt(e.timeout,10),fullPage:Boolean(e.fullPage),waitSelector:e.waitSelector,format:e.format,backend:e.backend});for(let c of s)console.log(`\uD83D\uDCF8 ${c.output} (${(c.bytes/1024).toFixed(0)} KB)`);console.log(`
163
+ \u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(Pe)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-6b737vch.js"),o={};if(t.context){let r=f.resolve(t.context);if(S.existsSync(r))try{let s=S.readFileSync(r,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${r}`),n.exit(1)}await e({context:o,cwd:t.cwd?f.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:r,getAvailableFormats:s}=await import("./chunk-0cajfv7y.js"),c=f.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let i=r();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${i.join(", ")}`),n.exit(1);let l=e.target||i[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
164
164
  \uD83D\uDD28 Building native app...`),console.log(` Input: ${t}`),console.log(` Target: ${l}`),console.log(` Format: ${e.format||"default"}`),console.log(` Output: ${e.output}
165
165
  `);let a=await o({input:c,output:f.resolve(e.output),target:l,format:e.format,name:e.name,version:e.version,description:e.description,author:e.author,bundleId:e.bundleId,icon:e.icon?f.resolve(e.icon):void 0,window:{title:e.title,width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),frameless:e.frameless,alwaysOnTop:e.alwaysOnTop},systemTray:e.systemTray,menubarOnly:e.menubarOnly,category:e.category,copyright:e.copyright,minimumSystemVersion:e.minSystemVersion,infoPlist:M(e.infoPlist),devTools:e.devTools,craftPath:e.craftPath,verbose:e.verbose});if(a.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${a.outputPath}`),a.duration)console.log(` Duration: ${(a.duration/1000).toFixed(2)}s`);if(l==="macos"&&a.format==="app")console.log(`
166
166
  \uD83D\uDCA1 To run: open "${a.outputPath}"`);else if(l==="linux"&&a.format==="appimage")console.log(`
167
- \uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-vvc39v6p.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-qwsgc5rc.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-6ndeycxk.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-v5afjcy3.js"),c=await e({mode:"build"});if(t.update){let i=await r(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${i} snapshots`)}else{let i=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(i)),i.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:r}=await import("./chunk-gk775pcy.js"),s=await r(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(r){console.error(r instanceof Error?r.message:String(r)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-8frs2dtp.js"),r=f.resolve(t);if(!S.existsSync(r))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
167
+ \uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-a222bwpc.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-qystt1qc.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-hnen9b45.js"),{runVisualTests:o,updateSnapshots:r,formatTestResults:s}=await import("./chunk-18chz0q4.js"),c=await e({mode:"build"});if(t.update){let i=await r(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${i} snapshots`)}else{let i=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(i)),i.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:r}=await import("./chunk-05jdq9tw.js"),s=await r(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(r){console.error(r instanceof Error?r.message:String(r)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-298gj90a.js"),r=f.resolve(t);if(!S.existsSync(r))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
168
168
  \uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${t}`),console.log(` Target: ${e.target}`),console.log(` Format: ${e.format}`),console.log(` Output: ${e.output}
169
169
  `);let i=S.readFileSync(r,"utf-8"),l=await o(i,{target:e.target,format:e.format,optimize:e.optimize,treeShake:e.treeShake,hotReload:e.hotReload,debug:e.verbose,sourceMaps:e.sourcemaps,bundle:e.bundle,minify:e.minify}),d=f.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=f.basename(t,f.extname(t)),u=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",p=f.join(d,`${a}.${u}`);S.writeFileSync(p,l.code);let b=f.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=f.join(d,`${a}.${u}.map`);S.writeFileSync(w,l.sourceMaps)}if(e.target==="universal"&&l.platformCode.size>0)for(let[w,k]of l.platformCode){let v=f.join(d,`${a}.${w}.${u}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${p}`),console.log(` Manifest: ${b}`),console.log(`
170
170
  \uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${l.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${l.stats.totalComponents}`),console.log(` Native components: ${l.stats.nativeComponents}`),console.log(` Web fallback components: ${l.stats.webComponents}`),console.log(` Bundle size: ${(l.stats.bundleSize/1024).toFixed(2)}KB`),l.stats.warnings.length>0){console.log(`
@@ -108,6 +108,8 @@ export const SIGNALS_HYDRATION_AUDIT_RUNTIME = ` // ===========================
108
108
  // missing String#indexOf method.
109
109
  var text = node.nodeValue == null ? '' : String(node.nodeValue);
110
110
  if (text.indexOf('{{') === -1 || text.indexOf('}}') === -1) continue;
111
+ // Text a binding wrote is data and may legitimately hold braces.
112
+ if (typeof isInertContent === 'function' && isInertContent(node)) continue;
111
113
  if (auditSkipped(node)) continue;
112
114
  found.push(text.trim().slice(0, 80));
113
115
  if (found.length >= 5) break;
@@ -1,5 +1,11 @@
1
1
  export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLiteral, handledXAttrsLiteral) {
2
- return ` // skipChildren: this element's bindings only, because something else already
2
+ return ` // True for text a binding wrote, or markup :html injected: data, never
3
+ // template. Checked only for text that holds braces, so the climb is rare.
4
+ function isInertContent(node) {
5
+ for (var n = node; n; n = n.parentNode) if (n.__stx_inert_content) return true;
6
+ return false;
7
+ }
8
+ // skipChildren: this element's bindings only, because something else already
3
9
  // knows where the rest are. The manifest path passes it for every entry, so
4
10
  // the tree is never walked; see processFromManifest.
5
11
  function processElement(el, scope = componentScope, skipChildren) {
@@ -65,6 +71,10 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
65
71
  // implementations and user-created nodes can retain a numeric value
66
72
  // assigned by a binding. Normalize before interpolation detection.
67
73
  const text = el.textContent == null ? '' : String(el.textContent);
74
+ // Text a binding wrote is data, never template: the scan below only
75
+ // reads what the author wrote. A binding marks the element (or text node)
76
+ // that owns its output, so a later pass over the same tree skips it.
77
+ if (text && text.includes('{{') && isInertContent(el)) return;
68
78
  if (text && text.includes('{{')) {
69
79
  const parts = text.split(/(\\{\\{[\\s\\S]+?\\}\\})/g);
70
80
  if (parts.length > 1) {
@@ -91,6 +101,7 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
91
101
  const bindingNode = isTextOnlyParent
92
102
  ? document.createTextNode('')
93
103
  : document.createElement('span');
104
+ bindingNode.__stx_inert_content = true;
94
105
  fragment.appendChild(bindingNode);
95
106
  // Use captured scope, not dynamic lookup
96
107
  effect(() => {
@@ -480,12 +491,16 @@ else if (name === '@style' || name === ':style' || name === 'x-style') {
480
491
  el.removeAttribute(name);
481
492
  }
482
493
  else if (name === '@text' || name === ':text' || name === 'x-text') {
494
+ el.__stx_inert_content = true;
483
495
  effect(() => {
484
496
  stxHost.setText(el, evalAttrExpr(value));
485
497
  });
486
498
  el.removeAttribute(name);
487
499
  }
488
500
  else if (name === '@html' || name === ':html' || name === 'x-html') {
501
+ // Injected markup is data: nothing in it is a binding, so the child
502
+ // walk below must not read its text or attributes as template syntax.
503
+ el.__stx_inert_content = true;
489
504
  effect(() => {
490
505
  // Coerce null/undefined to '' so a missing/unresolved binding renders
491
506
  // nothing rather than the literal string "undefined" (#1767).
@@ -700,7 +715,7 @@ catch (e) {
700
715
 
701
716
  // Process children (skip script/style elements \u2014 their text content is not template markup)
702
717
  // Skip elements that are roots of nested stx.mount() components \u2014 those have their own scope
703
- if (!skipChildren && el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE') {
718
+ if (!skipChildren && !el.__stx_inert_content && el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE') {
704
719
  var children = Array.from(el.childNodes);
705
720
  children.forEach(function(child) {
706
721
  if (child.nodeType !== Node.ELEMENT_NODE) { processElement(child, scope); return; }
@@ -4,7 +4,7 @@ export declare function listComposableModules(composablesDir?: string | string[]
4
4
  * reach. Omit to emit every composable, which is what a caller with no page in
5
5
  * hand needs.
6
6
  */
7
- export declare function getComposableScript(composablesDir?: string | string[], pageSource?: string, extraSources?: readonly string[]): Promise<string | null>;
7
+ export declare function getComposableScript(composablesDir?: string | string[], pageSource?: string, extraSources?: readonly string[], collectInputs?: string[]): Promise<string | null>;
8
8
  /**
9
9
  * Clear the cached composable script (for dev mode hot reload).
10
10
  */
@@ -100,24 +100,53 @@ function composableUses(text, names) {
100
100
  usesByText.set(key, used);
101
101
  return used;
102
102
  }
103
+ function isScriptType(type) {
104
+ return !type || /^(?:module|(?:text|application)\/(?:java|ecma)script|application\/stx-[\w-]+)$/i.test(type);
105
+ }
106
+ const pageUsesByScript = renderMemo(256);
107
+ function pageUses(page, names) {
108
+ const all = new Set(names);
109
+ let markup = "", last = 0;
110
+ const used = new Set;
111
+ for (const match of page.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)) {
112
+ markup += page.slice(last, match.index);
113
+ last = match.index + match[0].length;
114
+ const attrs = match[1] ?? "", body = match[2] ?? "", type = /\btype\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(attrs), typeName = type ? (type[1] ?? type[2] ?? type[3] ?? "").trim() : void 0;
115
+ if (!isScriptType(typeName)) {
116
+ if (!/json/i.test(typeName ?? ""))
117
+ markup += ` ${body} `;
118
+ continue;
119
+ }
120
+ const candidates = mentionedNames(body, all);
121
+ if (candidates.size === 0)
122
+ continue;
123
+ const key = contentKey(body, [...candidates].sort().join(","));
124
+ let uses = pageUsesByScript.get(key);
125
+ if (!uses) {
126
+ uses = composableUses(body, candidates);
127
+ pageUsesByScript.set(key, uses);
128
+ }
129
+ for (const name of uses)
130
+ used.add(name);
131
+ }
132
+ markup += page.slice(last);
133
+ for (const name of mentionedNames(markup, all))
134
+ used.add(name);
135
+ return used;
136
+ }
103
137
  function selectReachable(modules, codeByFile, pageSources) {
104
138
  const fileForName = new Map;
105
139
  for (const { file, names } of modules)
106
140
  for (const name of names)
107
141
  if (!fileForName.has(name))
108
142
  fileForName.set(name, file);
109
- const filesMentionedIn = (text) => {
110
- const found = [];
111
- for (const name of mentionedNames(text, fileForName.keys()))
112
- found.push(fileForName.get(name));
113
- return found;
114
- }, allNames = new Set(fileForName.keys()), filesUsedBy = (text) => {
143
+ const allNames = new Set(fileForName.keys()), filesUsedBy = (text) => {
115
144
  const found = [];
116
145
  for (const name of composableUses(text, allNames))
117
146
  found.push(fileForName.get(name));
118
147
  return found;
119
148
  }, selected = new Set;
120
- let frontier = pageSources.flatMap((source, index) => index === 0 ? filesMentionedIn(source) : filesUsedBy(source));
149
+ let frontier = pageSources.flatMap((source, index) => index === 0 ? [...pageUses(source, fileForName.keys())].map((name) => fileForName.get(name)) : filesUsedBy(source));
121
150
  while (frontier.length > 0) {
122
151
  const next = [];
123
152
  for (const file of frontier) {
@@ -132,7 +161,7 @@ function selectReachable(modules, codeByFile, pageSources) {
132
161
  }
133
162
  return selected;
134
163
  }
135
- export async function getComposableScript(composablesDir, pageSource, extraSources) {
164
+ export async function getComposableScript(composablesDir, pageSource, extraSources, collectInputs) {
136
165
  const { key: resolvedDir, files: composableFiles } = await composableSources(composablesDir);
137
166
  if (!resolvedDir)
138
167
  return null;
@@ -174,9 +203,16 @@ export async function getComposableScript(composablesDir, pageSource, extraSourc
174
203
  }
175
204
  if (selected.size === 0)
176
205
  return null;
177
- const includedFiles = composableFiles.filter((file) => selected.has(file)), cacheKey = `${resolvedDir}\x00${includedFiles.join("\x00")}\x00${moduleSubstitutionKey()}`, cached = readSigned(_cachedComposableScripts, cacheKey, signature);
178
- if (cached !== void 0)
206
+ const includedFiles = composableFiles.filter((file) => selected.has(file)), reportInputs = () => {
207
+ if (!collectInputs)
208
+ return;
209
+ for (const file of includedFiles)
210
+ collectInputs.push(file, ...clientBundleDependencies(file));
211
+ }, cacheKey = `${resolvedDir}\x00${includedFiles.join("\x00")}\x00${moduleSubstitutionKey()}`, cached = readSigned(_cachedComposableScripts, cacheKey, signature);
212
+ if (cached !== void 0) {
213
+ reportInputs();
179
214
  return cached || null;
215
+ }
180
216
  const chunks = [], exportedNames = new Set, declaredNames = new Set;
181
217
  for (const file of includedFiles)
182
218
  try {
@@ -242,6 +278,7 @@ ${assignments}
242
278
  })();`, code = isProduction() ? minifyClassicScript(assembled) : assembled;
243
279
  signature = sourceSignature(composableInputs());
244
280
  writeSigned(_cachedComposableScripts, cacheKey, signature, code);
281
+ reportInputs();
245
282
  return code;
246
283
  }
247
284
  export function clearComposableCache() {
@@ -444,6 +444,9 @@ export {
444
444
  // `framework-composables.ts` needs the entry to know to bundle it. One missing
445
445
  // re-export, two contradictory test suites. See #1849.
446
446
  export { defineForm, useForm } from './use-form';
447
+ // Inline AI-style ghost text for a text field: debounce, abort, stale discard, accept.
448
+ // Demand-bundled for client scripts like useForm.
449
+ export { useCompletion, type Completion, type CompletionContext, type CompletionMeta, type UseCompletionOptions } from './use-completion';
447
450
  // Authenticated server broadcasts, demand-bundled for client scripts.
448
451
  export { useBroadcastStream, type BroadcastStreamFrame, type BroadcastStreamClientOptions } from './use-broadcast-stream';
449
452
  // Breathing exercises: a step-by-step pacer and generated ambient sound,
@@ -238,6 +238,7 @@ export {
238
238
  useDark
239
239
  } from "./use-color-mode.js";
240
240
  export { defineForm, useForm } from "./use-form.js";
241
+ export { useCompletion } from "./use-completion.js";
241
242
  export { useBroadcastStream } from "./use-broadcast-stream.js";
242
243
  export {
243
244
  useBreathPacer
@@ -0,0 +1,29 @@
1
+ import type { Signal } from '../signals-api';
2
+ export declare function useCompletion(options: UseCompletionOptions): Completion;
3
+ export declare interface CompletionContext {
4
+ before: string
5
+ after: string
6
+ caret: number
7
+ }
8
+ /** What the host knows about the field that the text alone does not say. */
9
+ export declare interface CompletionMeta {
10
+ composing?: boolean
11
+ selecting?: boolean
12
+ blocked?: boolean
13
+ }
14
+ export declare interface UseCompletionOptions {
15
+ fetch: (context: CompletionContext, signal: AbortSignal) => Promise<string | null | undefined>
16
+ debounceMs?: number
17
+ minChars?: number
18
+ enabled?: boolean | string | (() => unknown)
19
+ }
20
+ export declare interface Completion {
21
+ ghost: Signal<string>
22
+ pending: Signal<boolean>
23
+ error: Signal<Error | null>
24
+ update: (before: string, after: string, caret: number, meta?: CompletionMeta) => void
25
+ accept: () => string
26
+ acceptWord: () => string
27
+ dismiss: () => void
28
+ destroy: () => void
29
+ }