@stacksjs/stx 0.2.887 → 0.2.889

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 (242) hide show
  1. package/dist/{chunk-c0g30cjs.js → chunk-05x1rd86.js} +2 -2
  2. package/dist/chunk-0g9cceht.js +2 -0
  3. package/dist/chunk-0k437z3q.js +2 -0
  4. package/dist/{chunk-69ezjc8k.js → chunk-0ncafcs2.js} +4 -4
  5. package/dist/chunk-0rpj5t80.js +2 -0
  6. package/dist/{chunk-sc1gmts0.js → chunk-1gyxxfdf.js} +2 -2
  7. package/dist/{chunk-aaea157p.js → chunk-1knk403z.js} +2 -2
  8. package/dist/{chunk-q74affc4.js → chunk-1n33yrar.js} +2 -2
  9. package/dist/chunk-1p4q6t48.js +2 -0
  10. package/dist/chunk-1z6pqvmf.js +2 -0
  11. package/dist/{chunk-s29hp1qw.js → chunk-2a5g80mq.js} +3 -3
  12. package/dist/chunk-2ba4zfa0.js +2 -0
  13. package/dist/chunk-2gn2nc2j.js +2 -0
  14. package/dist/chunk-2nqmw4dv.js +2 -0
  15. package/dist/chunk-2wkpksg1.js +2 -0
  16. package/dist/chunk-3dqfjpz4.js +68 -0
  17. package/dist/{chunk-zpj6ggee.js → chunk-3hsv6ejp.js} +4 -4
  18. package/dist/{chunk-8e1cv1hh.js → chunk-3qk8vf9m.js} +3 -3
  19. package/dist/chunk-3yjyjq0m.js +2 -0
  20. package/dist/chunk-444haxxa.js +2 -0
  21. package/dist/{chunk-azf6tdq6.js → chunk-446tb2th.js} +28 -28
  22. package/dist/{chunk-4251fy7d.js → chunk-48rwqchc.js} +11 -11
  23. package/dist/chunk-4akw3bym.js +2 -0
  24. package/dist/{chunk-twmkz0xs.js → chunk-4kmg6g5n.js} +9 -9
  25. package/dist/chunk-4rvfeee5.js +2 -0
  26. package/dist/{chunk-4n45qa0b.js → chunk-51720m79.js} +5 -5
  27. package/dist/chunk-53kcqdjj.js +2 -0
  28. package/dist/{chunk-02qmvcmv.js → chunk-55tc5w32.js} +3 -3
  29. package/dist/{chunk-0mx7rg07.js → chunk-58qzyyyv.js} +3 -3
  30. package/dist/chunk-5aa83bpm.js +2 -0
  31. package/dist/{chunk-d2pexm3z.js → chunk-5kqezrjt.js} +2 -2
  32. package/dist/chunk-5ssv10ep.js +2 -0
  33. package/dist/chunk-67rppc5v.js +2 -0
  34. package/dist/{chunk-care745q.js → chunk-6gtecbe7.js} +2 -2
  35. package/dist/{chunk-km14pdrt.js → chunk-6kyqejnq.js} +22 -22
  36. package/dist/{chunk-32twt3wx.js → chunk-6pdy7ajr.js} +3 -3
  37. package/dist/{chunk-fg67643b.js → chunk-6pz5gq6v.js} +9 -9
  38. package/dist/{chunk-rsxxajv6.js → chunk-700m927w.js} +2 -2
  39. package/dist/{chunk-gvd8nb8z.js → chunk-7212fwzz.js} +2 -2
  40. package/dist/chunk-732gb689.js +2 -0
  41. package/dist/chunk-77c89d23.js +2 -0
  42. package/dist/chunk-79vbkez0.js +2 -0
  43. package/dist/{chunk-88tshy2f.js → chunk-7hpca9c7.js} +6 -6
  44. package/dist/chunk-80xzjxah.js +2 -0
  45. package/dist/chunk-8354mzpd.js +2 -0
  46. package/dist/{chunk-2v7v6jcs.js → chunk-87g5xmmr.js} +12 -12
  47. package/dist/{chunk-sv7fdqmc.js → chunk-8hwfdwgn.js} +6 -6
  48. package/dist/chunk-8ygf6jnt.js +2 -0
  49. package/dist/{chunk-0rdh8bw3.js → chunk-95sd8h5g.js} +7 -7
  50. package/dist/{chunk-50cnypys.js → chunk-967ydrq4.js} +6 -6
  51. package/dist/chunk-9afkttvz.js +2 -0
  52. package/dist/{chunk-7wqz32ay.js → chunk-9d91h636.js} +2 -2
  53. package/dist/{chunk-kwf3kfr0.js → chunk-9n5h4sqc.js} +2 -2
  54. package/dist/chunk-9ztn7w4y.js +2 -0
  55. package/dist/chunk-ah8az9vv.js +2 -0
  56. package/dist/chunk-ankap9pc.js +2 -0
  57. package/dist/chunk-asnd03sr.js +2 -0
  58. package/dist/chunk-b0b5yr97.js +2 -0
  59. package/dist/chunk-b0e7dgv8.js +3 -0
  60. package/dist/{chunk-zj5eq4b6.js → chunk-b15c4g3e.js} +5 -5
  61. package/dist/{chunk-czcx3nbx.js → chunk-b6bf0t02.js} +6 -6
  62. package/dist/chunk-b7jj45bz.js +2 -0
  63. package/dist/{chunk-ybjgnnyf.js → chunk-bgfs3mbg.js} +5 -5
  64. package/dist/{chunk-f2twg7ze.js → chunk-bqtj62ys.js} +8 -8
  65. package/dist/{chunk-a0q0kb0s.js → chunk-bw2m1e7g.js} +5 -5
  66. package/dist/chunk-bwx6w87c.js +2 -0
  67. package/dist/{chunk-ef9m5fjb.js → chunk-cgfjrgfw.js} +14 -14
  68. package/dist/{chunk-463weehv.js → chunk-ch9028z3.js} +1 -1
  69. package/dist/{chunk-57q4nvs9.js → chunk-cmg9x1ka.js} +3 -3
  70. package/dist/{chunk-9f31gs4m.js → chunk-cz1sdes5.js} +2 -2
  71. package/dist/{chunk-satrf398.js → chunk-dvjv4c3a.js} +1 -1
  72. package/dist/{chunk-dz7amds0.js → chunk-dymck524.js} +5 -5
  73. package/dist/chunk-dzqfv801.js +3 -0
  74. package/dist/{chunk-agd2b928.js → chunk-eceeqy74.js} +4 -4
  75. package/dist/{chunk-c47stwqj.js → chunk-eqffvse2.js} +1 -1
  76. package/dist/chunk-ery4tty7.js +20 -0
  77. package/dist/chunk-evwrxsxd.js +3 -0
  78. package/dist/{chunk-6t04tqvh.js → chunk-eyx92t9n.js} +2 -2
  79. package/dist/{chunk-6mfpns00.js → chunk-f3cyghnb.js} +5 -5
  80. package/dist/chunk-f60k8j9m.js +2 -0
  81. package/dist/chunk-fdqdz018.js +2 -0
  82. package/dist/chunk-g6ap4085.js +2 -0
  83. package/dist/chunk-gz9pknbw.js +1204 -0
  84. package/dist/{chunk-pgrm1vet.js → chunk-hgf7bc50.js} +7 -7
  85. package/dist/chunk-hjb4c8g2.js +2 -0
  86. package/dist/chunk-hk241gt2.js +2 -0
  87. package/dist/{chunk-yasdj4ve.js → chunk-hm9d40yf.js} +2 -2
  88. package/dist/{chunk-6df3j3qq.js → chunk-hpzje67q.js} +2 -2
  89. package/dist/{chunk-qt39mb2a.js → chunk-htx5yezj.js} +2 -2
  90. package/dist/{chunk-xpbakn6t.js → chunk-hxws025y.js} +3 -3
  91. package/dist/chunk-jhbj9ja2.js +2 -0
  92. package/dist/chunk-k4x680e3.js +2 -0
  93. package/dist/chunk-k9abxnpa.js +2 -0
  94. package/dist/{chunk-c73c0wf9.js → chunk-kbbbpae2.js} +2 -2
  95. package/dist/chunk-kfdmm240.js +2 -0
  96. package/dist/{chunk-xcsgpf83.js → chunk-kj43fbzm.js} +1 -1
  97. package/dist/{chunk-59er0fc7.js → chunk-kk2p2tgv.js} +3 -3
  98. package/dist/{chunk-dwyhpbpx.js → chunk-ksmn19qw.js} +2 -2
  99. package/dist/{chunk-16aqrwmk.js → chunk-kx09v9ya.js} +7 -7
  100. package/dist/{chunk-3bfheqe3.js → chunk-m95sygv4.js} +3 -3
  101. package/dist/{chunk-nzpzyz22.js → chunk-mctzpw0w.js} +1 -1
  102. package/dist/{chunk-y6eaqs8v.js → chunk-me4yq8c2.js} +3 -3
  103. package/dist/{chunk-n22xtagg.js → chunk-mgh5rst1.js} +2 -2
  104. package/dist/{chunk-zch65qrd.js → chunk-mhxg6j6s.js} +1 -1
  105. package/dist/{chunk-pc8dt8xs.js → chunk-mjp1z9kz.js} +1 -1
  106. package/dist/{chunk-gtv9jd68.js → chunk-mt8edb75.js} +49 -49
  107. package/dist/chunk-mvavjydq.js +2 -0
  108. package/dist/{chunk-e362e615.js → chunk-mw7hacm3.js} +30 -30
  109. package/dist/{chunk-cv4bfhn1.js → chunk-nbdscgvj.js} +6 -6
  110. package/dist/{chunk-qx1nbryq.js → chunk-njpva3zq.js} +2 -2
  111. package/dist/{chunk-6qpe4f8e.js → chunk-nkyff7v6.js} +11 -11
  112. package/dist/{chunk-mxvgft6p.js → chunk-p8shtje2.js} +32 -32
  113. package/dist/{chunk-cb0c6959.js → chunk-pctf14yw.js} +1 -1
  114. package/dist/{chunk-3cq4a4x7.js → chunk-pjj54ddk.js} +3 -3
  115. package/dist/{chunk-pdprhg5k.js → chunk-pnmafbv5.js} +1 -1
  116. package/dist/{chunk-kee5a3ce.js → chunk-pz554g43.js} +3 -3
  117. package/dist/{chunk-h63ma36g.js → chunk-q0y8gv18.js} +2 -2
  118. package/dist/{chunk-ws2h92mm.js → chunk-q9tc9rdv.js} +2 -2
  119. package/dist/chunk-qqng9545.js +2 -0
  120. package/dist/{chunk-8va3fs07.js → chunk-r5ecgcx2.js} +5 -5
  121. package/dist/{chunk-q1mb0fbt.js → chunk-ranjkpc8.js} +2 -2
  122. package/dist/{chunk-ssg6ne5b.js → chunk-rb2zbdqd.js} +4 -4
  123. package/dist/{chunk-e41pgmgk.js → chunk-rf0smj4c.js} +2 -2
  124. package/dist/chunk-rjm515e2.js +2 -0
  125. package/dist/chunk-rye4b2x3.js +2 -0
  126. package/dist/chunk-ryj8139z.js +2 -0
  127. package/dist/{chunk-q3epnfp4.js → chunk-s0mf56y1.js} +5 -5
  128. package/dist/{chunk-kaem8q20.js → chunk-s93yh7ed.js} +2 -2
  129. package/dist/chunk-s9b809n2.js +2 -0
  130. package/dist/chunk-sb67wg5x.js +2 -0
  131. package/dist/{chunk-rv0a3stz.js → chunk-sjjw6y49.js} +6 -6
  132. package/dist/chunk-snkbn5y8.js +2 -0
  133. package/dist/{chunk-7mcs59pr.js → chunk-snv80b1b.js} +2 -2
  134. package/dist/chunk-sqwx2g02.js +2 -0
  135. package/dist/{chunk-2r0nrvqe.js → chunk-t0ttxayz.js} +2 -2
  136. package/dist/chunk-tbh7r1wh.js +2 -0
  137. package/dist/chunk-tpyekw0q.js +2 -0
  138. package/dist/chunk-v2627s75.js +2 -0
  139. package/dist/chunk-v3jyb8k6.js +2 -0
  140. package/dist/chunk-v98n53nk.js +2 -0
  141. package/dist/{chunk-sfyyn0mg.js → chunk-vc432a0w.js} +9 -9
  142. package/dist/{chunk-a7ryj8z8.js → chunk-vf4ejngv.js} +6 -6
  143. package/dist/{chunk-hxhmhw23.js → chunk-vk2jy6mn.js} +3 -3
  144. package/dist/chunk-w34vvhm7.js +2 -0
  145. package/dist/chunk-w82nk19t.js +2 -0
  146. package/dist/{chunk-ezna4dhj.js → chunk-x5bn2svk.js} +2 -2
  147. package/dist/chunk-x6565mhk.js +2 -0
  148. package/dist/{chunk-gbncp2gp.js → chunk-xvncq3m5.js} +2 -2
  149. package/dist/chunk-xwgdcc7w.js +2 -0
  150. package/dist/{chunk-ram5944w.js → chunk-xy8smv5e.js} +2 -2
  151. package/dist/{chunk-yp4tn4zn.js → chunk-y1d3j2j7.js} +4 -4
  152. package/dist/chunk-yjwa7ktk.js +2 -0
  153. package/dist/{chunk-94ctmp0j.js → chunk-ytjn0gq2.js} +2 -2
  154. package/dist/chunk-z47p2gx8.js +2 -0
  155. package/dist/chunk-z4tdnfxd.js +2 -0
  156. package/dist/chunk-z6kw6sct.js +4 -0
  157. package/dist/{chunk-shcnt6aa.js → chunk-zf68afyh.js} +3 -3
  158. package/dist/chunk-zhywjwdr.js +2 -0
  159. package/dist/{chunk-g2xy0z0e.js → chunk-zwwhpxp7.js} +2 -2
  160. package/dist/cli.js +21 -21
  161. package/dist/component-library.d.ts +2 -1
  162. package/dist/component-library.js +126 -308
  163. package/dist/craft-entry.js +2 -2
  164. package/dist/craft.js +2 -2
  165. package/dist/directive-arguments.js +39 -6
  166. package/dist/parser/tokenizer.d.ts +2 -1
  167. package/dist/parser/tokenizer.js +7 -5
  168. package/dist/props-declaration.d.ts +64 -0
  169. package/dist/props-declaration.js +354 -0
  170. package/dist/pwa.js +3 -3
  171. package/dist/ssg.js +7 -7
  172. package/dist/utils.js +20 -109
  173. package/package.json +5 -5
  174. package/dist/chunk-08cb7cyw.js +0 -2
  175. package/dist/chunk-0gkxqcpj.js +0 -2
  176. package/dist/chunk-0h1dyd38.js +0 -2
  177. package/dist/chunk-0sew66hf.js +0 -2
  178. package/dist/chunk-13dgqekj.js +0 -2
  179. package/dist/chunk-15n20xwe.js +0 -2
  180. package/dist/chunk-1ta1pj1t.js +0 -2
  181. package/dist/chunk-1z3r2jjp.js +0 -2
  182. package/dist/chunk-1z6rrqvm.js +0 -2
  183. package/dist/chunk-295bykzd.js +0 -61
  184. package/dist/chunk-41353gyc.js +0 -2
  185. package/dist/chunk-4j50hrgq.js +0 -20
  186. package/dist/chunk-4pjqj54a.js +0 -2
  187. package/dist/chunk-53cc06w7.js +0 -2
  188. package/dist/chunk-5m02cbxg.js +0 -2
  189. package/dist/chunk-5rd0an89.js +0 -2
  190. package/dist/chunk-5s0w910j.js +0 -2
  191. package/dist/chunk-6fy11vfb.js +0 -2
  192. package/dist/chunk-6mjk28s3.js +0 -2
  193. package/dist/chunk-8h5nje66.js +0 -2
  194. package/dist/chunk-97kgrevs.js +0 -4
  195. package/dist/chunk-9h3qq2d2.js +0 -2
  196. package/dist/chunk-9kza7gxd.js +0 -2
  197. package/dist/chunk-a02gt4tz.js +0 -1199
  198. package/dist/chunk-a30zpnqp.js +0 -2
  199. package/dist/chunk-aq0fz4mr.js +0 -2
  200. package/dist/chunk-aqxh80vh.js +0 -2
  201. package/dist/chunk-axra1yas.js +0 -2
  202. package/dist/chunk-b2vhsyf9.js +0 -2
  203. package/dist/chunk-c42b1y7z.js +0 -2
  204. package/dist/chunk-c89wryyz.js +0 -2
  205. package/dist/chunk-cev5z6gj.js +0 -2
  206. package/dist/chunk-ch57kgb6.js +0 -2
  207. package/dist/chunk-cv1vm1w0.js +0 -2
  208. package/dist/chunk-d7b30bg6.js +0 -2
  209. package/dist/chunk-f3j1h3ch.js +0 -2
  210. package/dist/chunk-fz4c5e9m.js +0 -2
  211. package/dist/chunk-gd04nvj3.js +0 -2
  212. package/dist/chunk-gmp10259.js +0 -2
  213. package/dist/chunk-gr956aar.js +0 -2
  214. package/dist/chunk-h3fv0q25.js +0 -2
  215. package/dist/chunk-jghpzx5m.js +0 -2
  216. package/dist/chunk-kcqfrw10.js +0 -2
  217. package/dist/chunk-kfzvtzsz.js +0 -2
  218. package/dist/chunk-kqgspa3s.js +0 -2
  219. package/dist/chunk-mast9wb2.js +0 -2
  220. package/dist/chunk-mqy1wz09.js +0 -3
  221. package/dist/chunk-mv21mc9p.js +0 -2
  222. package/dist/chunk-n9bw9bsn.js +0 -2
  223. package/dist/chunk-ngzyzcrp.js +0 -2
  224. package/dist/chunk-nnqyn7db.js +0 -2
  225. package/dist/chunk-p5qac909.js +0 -2
  226. package/dist/chunk-p6hcrg3r.js +0 -3
  227. package/dist/chunk-pa2vt2ej.js +0 -2
  228. package/dist/chunk-pa6kgbmw.js +0 -2
  229. package/dist/chunk-pd089tq0.js +0 -2
  230. package/dist/chunk-pjjrx9pk.js +0 -2
  231. package/dist/chunk-pt3rp3zg.js +0 -2
  232. package/dist/chunk-qg1kw5yf.js +0 -2
  233. package/dist/chunk-s7xywsqd.js +0 -3
  234. package/dist/chunk-t8r40wgf.js +0 -2
  235. package/dist/chunk-w5zzwe2f.js +0 -2
  236. package/dist/chunk-wjafpvjv.js +0 -2
  237. package/dist/chunk-x44f0eq1.js +0 -2
  238. package/dist/chunk-xhr35ctb.js +0 -2
  239. package/dist/chunk-xk15vzb6.js +0 -2
  240. package/dist/chunk-xmmr0916.js +0 -2
  241. package/dist/chunk-ywnqjqns.js +0 -2
  242. package/dist/chunk-z7k1xn6k.js +0 -2
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import"./chunk-a02gt4tz.js";import{Fo,Ha,Va}from"./chunk-57q4nvs9.js";import"./chunk-e362e615.js";import"./chunk-s29hp1qw.js";import"./chunk-295bykzd.js";import"./chunk-n22xtagg.js";import"./chunk-hxhmhw23.js";import"./chunk-kwf3kfr0.js";import"./chunk-6t04tqvh.js";import"./chunk-kaem8q20.js";import"./chunk-h63ma36g.js";import"./chunk-agd2b928.js";import"./chunk-mxvgft6p.js";import"./chunk-0rdh8bw3.js";import"./chunk-ssg6ne5b.js";import"./chunk-7wqz32ay.js";import"./chunk-sfyyn0mg.js";import"./chunk-gtv9jd68.js";import"./chunk-pgrm1vet.js";import"./chunk-4251fy7d.js";import"./chunk-twmkz0xs.js";import"./chunk-dz7amds0.js";import"./chunk-c0g30cjs.js";import"./chunk-kee5a3ce.js";import{Fu,Ua,Kh,Gh,Wa,zo,ps,qa,Ka,Xh,Jh,Ga,Xa,Ja,Ya}from"./chunk-km14pdrt.js";import"./chunk-6mfpns00.js";import"./chunk-mqy1wz09.js";import"./chunk-d2pexm3z.js";import"./chunk-f2twg7ze.js";import"./chunk-cb0c6959.js";import"./chunk-c47stwqj.js";import"./chunk-0mx7rg07.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import"./chunk-gz9pknbw.js";import{Vo,Ua,Wa}from"./chunk-cmg9x1ka.js";import"./chunk-mw7hacm3.js";import"./chunk-2a5g80mq.js";import"./chunk-3dqfjpz4.js";import"./chunk-mgh5rst1.js";import"./chunk-vk2jy6mn.js";import"./chunk-9n5h4sqc.js";import"./chunk-eyx92t9n.js";import"./chunk-s93yh7ed.js";import"./chunk-q0y8gv18.js";import"./chunk-eceeqy74.js";import"./chunk-p8shtje2.js";import"./chunk-95sd8h5g.js";import"./chunk-rb2zbdqd.js";import"./chunk-9d91h636.js";import"./chunk-vc432a0w.js";import"./chunk-mt8edb75.js";import"./chunk-hgf7bc50.js";import"./chunk-48rwqchc.js";import"./chunk-4kmg6g5n.js";import"./chunk-dymck524.js";import"./chunk-05x1rd86.js";import"./chunk-pz554g43.js";import{Hu,qa,Xh,Jh,Ka,Uo,hs,Ga,Xa,Yh,Zh,Ja,Ya,Za,Qa}from"./chunk-6kyqejnq.js";import"./chunk-f3cyghnb.js";import"./chunk-b0e7dgv8.js";import"./chunk-5kqezrjt.js";import"./chunk-bqtj62ys.js";import"./chunk-pctf14yw.js";import"./chunk-eqffvse2.js";import"./chunk-58qzyyyv.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Fu as CRAFT_BRIDGE_SCRIPT,zo as CRAFT_COMPONENTS,qa as CRAFT_COMPONENT_RUNTIME,ps as CRAFT_COMPONENT_STYLES,Fo as NATIVE_COMPONENTS,Ga as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ha as compileToNative,Va as createHotReloadServer,Xa as findCraftBinary,Ua as generateCraftBridgeScript,V as generateCraftOptimizations,Ya as getAvailableFormats,Ja as getAvailableTargets,Jh as getCraftComponents,G as getSSRCacheStats,Wa as injectCraftBridge,Kh as isCraftEnvironment,Y as prerenderForCraft,Ka as processCraftComponents,Gh as processCraftDirective,Xh as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Hu as CRAFT_BRIDGE_SCRIPT,Uo as CRAFT_COMPONENTS,Ga as CRAFT_COMPONENT_RUNTIME,hs as CRAFT_COMPONENT_STYLES,Vo as NATIVE_COMPONENTS,Ja as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ua as compileToNative,Wa as createHotReloadServer,Ya as findCraftBinary,qa as generateCraftBridgeScript,V as generateCraftOptimizations,Qa as getAvailableFormats,Za as getAvailableTargets,Zh as getCraftComponents,G as getSSRCacheStats,Ka as injectCraftBridge,Xh as isCraftEnvironment,Y as prerenderForCraft,Xa as processCraftComponents,Jh as processCraftDirective,Yh as registerCraftComponent,Q as renderSSR};
@@ -74,19 +74,52 @@ export function parseStringLiteral(raw) {
74
74
  if (quote !== "'" && quote !== '"' && quote !== "`" || text.length < 2 || text.at(-1) !== quote)
75
75
  return null;
76
76
  let value = "";
77
+ const escapes = { b: "\b", f: "\f", n: `
78
+ `, r: "\r", t: "\t", v: "\v", 0: "\x00" };
77
79
  for (let i = 1;i < text.length - 1; i++) {
78
80
  const char = text[i];
79
- if (char === "\\" && i + 1 < text.length - 1) {
80
- const next = text[++i];
81
- value += next === "n" ? `
82
- ` : next === "t" ? "\t" : next;
81
+ if (char === "\\") {
82
+ if (++i >= text.length - 1)
83
+ return null;
84
+ const next = text[i];
85
+ if (/[1-9]/.test(next) || next === "0" && /\d/.test(text[i + 1] ?? ""))
86
+ return null;
87
+ if (next === `
88
+ ` || next === "\u2028" || next === "\u2029")
89
+ continue;
90
+ if (next === "\r") {
91
+ if (text[i + 1] === `
92
+ `)
93
+ i++;
94
+ continue;
95
+ }
96
+ if (next === "x" || next === "u") {
97
+ const point = next === "u" && text[i + 1] === "{", end = point ? text.indexOf("}", i + 2) : i + (next === "x" ? 2 : 4) + 1, digits = text.slice(i + (point ? 2 : 1), end);
98
+ if (end < 0 || end >= text.length || !/^[\da-f]+$/i.test(digits) || !point && digits.length !== (next === "x" ? 2 : 4))
99
+ return null;
100
+ const code = Number.parseInt(digits, 16);
101
+ if (code > 1114111)
102
+ return null;
103
+ value += String.fromCodePoint(code);
104
+ i = point ? end : end - 1;
105
+ continue;
106
+ }
107
+ value += Object.hasOwn(escapes, next) ? escapes[next] : next;
83
108
  continue;
84
109
  }
85
- if (char === quote)
110
+ if (char === quote || quote !== "`" && (char === `
111
+ ` || char === "\r"))
86
112
  return null;
87
113
  if (quote === "`" && char === "$" && text[i + 1] === "{")
88
114
  return null;
89
- value += char;
115
+ if (quote === "`" && char === "\r") {
116
+ if (text[i + 1] === `
117
+ `)
118
+ i++;
119
+ value += `
120
+ `;
121
+ } else
122
+ value += char;
90
123
  }
91
124
  return value;
92
125
  }
@@ -63,7 +63,8 @@ export declare class Tokenizer {
63
63
  private line;
64
64
  private column;
65
65
  private tokens;
66
- constructor(source: string);
66
+ private context;
67
+ constructor(source: string, context?: 'template' | 'javascript');
67
68
  tokenize(): Token[];
68
69
  private nextToken;
69
70
  private readWhitespace;
@@ -1,10 +1,12 @@
1
1
  export class Tokenizer {
2
+ context;
2
3
  source;
3
4
  pos = 0;
4
5
  line = 1;
5
6
  column = 0;
6
7
  tokens = [];
7
- constructor(source) {
8
+ constructor(source, context = "template") {
9
+ this.context = context;
8
10
  this.source = source;
9
11
  }
10
12
  tokenize() {
@@ -45,7 +47,7 @@ export class Tokenizer {
45
47
  return this.readNumber(start, startLine, startColumn);
46
48
  if (/[a-z_$]/i.test(char))
47
49
  return this.readIdentifier(start, startLine, startColumn);
48
- if (char === "{") {
50
+ if (this.context === "template" && char === "{") {
49
51
  if (this.peek(1) === "{" && this.peek(2) === "{") {
50
52
  this.advance(3);
51
53
  return { type: "RAW_START", value: "{{{", start, end: this.pos, line: startLine, column: startColumn };
@@ -59,7 +61,7 @@ export class Tokenizer {
59
61
  return { type: "RAW_START", value: "{!!", start, end: this.pos, line: startLine, column: startColumn };
60
62
  }
61
63
  }
62
- if (char === "}") {
64
+ if (this.context === "template" && char === "}") {
63
65
  if (this.peek(1) === "}" && this.peek(2) === "}") {
64
66
  this.advance(3);
65
67
  return { type: "RAW_END", value: "}}}", start, end: this.pos, line: startLine, column: startColumn };
@@ -69,7 +71,7 @@ export class Tokenizer {
69
71
  return { type: "EXPRESSION_END", value: "}}", start, end: this.pos, line: startLine, column: startColumn };
70
72
  }
71
73
  }
72
- if (char === "!" && this.peek(1) === "!" && this.peek(2) === "}") {
74
+ if (this.context === "template" && char === "!" && this.peek(1) === "!" && this.peek(2) === "}") {
73
75
  this.advance(3);
74
76
  return { type: "RAW_END", value: "!!}", start, end: this.pos, line: startLine, column: startColumn };
75
77
  }
@@ -249,7 +251,7 @@ export class Tokenizer {
249
251
  }
250
252
  while (this.pos < this.source.length && /[\d_]/.test(this.source[this.pos]))
251
253
  this.advance();
252
- if (this.source[this.pos] === "." && /\d/.test(this.peek(1) || "")) {
254
+ if (this.source[this.pos] === "." && (this.context === "javascript" || /\d/.test(this.peek(1) || ""))) {
253
255
  this.advance();
254
256
  while (this.pos < this.source.length && /[\d_]/.test(this.source[this.pos]))
255
257
  this.advance();
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The index just past a balanced bracket pair starting at `index`, or -1 when
3
+ * it never closes.
4
+ *
5
+ * Quotes and template literals are skipped, so a bracket inside a string
6
+ * default does not unbalance the scan.
7
+ */
8
+ export declare function skipBalanced(source: string, index: number, open: string, close: string): number;
9
+ /**
10
+ * Split a list on separators that are not nested inside brackets or quotes.
11
+ *
12
+ * `angles` decides whether `<` and `>` nest. They must in a type literal, so
13
+ * `Array<string, number>` stays one member, and must NOT in a value, where
14
+ * `>` is a comparison and `=>` an arrow and counting either unbalances
15
+ * everything after it.
16
+ */
17
+ export declare function splitTopLevel(body: string, separators: string, angles: boolean): string[];
18
+ /**
19
+ * Read a `defineProps` declaration, in every form it is written
20
+ * (stacksjs/stx#2009).
21
+ *
22
+ * This used to be one regex that required a destructuring assignment AND an
23
+ * explicit type argument, so four of the five documented spellings produced no
24
+ * properties at all and the component silently had no public surface. The one
25
+ * that did match split its names on `:` only, so
26
+ *
27
+ * const { label = 'Hello' } = defineProps<{ label?: string }>()
28
+ *
29
+ * produced a property literally named `label = 'Hello'`, documented as the
30
+ * attribute `label-hello`, and nothing a page wrote as `label="x"` ever
31
+ * arrived. That is worse than not reading it, because it looks like it worked.
32
+ *
33
+ * Handled here:
34
+ *
35
+ * const { a, b = 1 } = defineProps<{ a?: string, b?: number }>()
36
+ * const { a } = defineProps(['a'])
37
+ * const props = defineProps<{ a?: string }>()
38
+ * const props = defineProps<Props>()
39
+ * const props = withDefaults(defineProps<{ a?: string }>(), { a: 'x' })
40
+ * const props = defineProps({ a: { type: String, default: 'x' } })
41
+ *
42
+ * Names come from the destructuring pattern when there is one, since that is
43
+ * the author naming them, and otherwise from whichever of the type literal,
44
+ * the object form or the array form is present. Types come from the type
45
+ * literal or the object form's `type:`, never inferred from a default: a
46
+ * `title?: string` with no default was being typed as an object, and the
47
+ * attribute `"Revenue"` was then JSON-parsed, failed, and reached the page as
48
+ * `[object Object]`.
49
+ */
50
+ export declare function parsePropsDeclaration(source: string): PropsDeclaration | null;
51
+ export declare function parseDefaults(object: string): Array<[string, string]>;
52
+ /** Literal defaults only: no client functions, imports, identifiers or getters run in SSR. */
53
+ export declare function literalValue(source: string): unknown;
54
+ declare interface PropsDeclaration {
55
+ text: string
56
+ propNames: string[]
57
+ propBindings: Record<string, string>
58
+ localBindings: Record<string, string>
59
+ defaults: Record<string, string>
60
+ declared: Record<string, string>
61
+ typeName?: string
62
+ identifier?: string
63
+ }
64
+ export {};
@@ -0,0 +1,354 @@
1
+ import { topLevelDeclarationSites } from "./client-parameter-bindings.js";
2
+ import { Tokenizer } from "./parser/tokenizer.js";
3
+ import { parseStringLiteral } from "./directive-arguments.js";
4
+ function withoutComments(source) {
5
+ const tokens = new Tokenizer(source, "javascript").tokenize();
6
+ let code = source;
7
+ for (const token of tokens.reverse())
8
+ if (token.type === "COMMENT")
9
+ code = code.slice(0, token.start) + token.value.replace(/[^\r\n]/g, " ") + code.slice(token.end);
10
+ return code;
11
+ }
12
+ export function skipBalanced(source, index, open, close) {
13
+ if (source[index] !== open)
14
+ return -1;
15
+ let depth = 0, quote = null;
16
+ for (let i = index;i < source.length; i++) {
17
+ const char = source[i];
18
+ if (quote) {
19
+ if (char === "\\") {
20
+ i++;
21
+ continue;
22
+ }
23
+ if (char === quote)
24
+ quote = null;
25
+ continue;
26
+ }
27
+ if (char === "'" || char === '"' || char === "`") {
28
+ quote = char;
29
+ continue;
30
+ }
31
+ if (char === open)
32
+ depth++;
33
+ else if (char === close) {
34
+ if (close === ">" && source[i - 1] === "=")
35
+ continue;
36
+ depth--;
37
+ if (depth === 0)
38
+ return i + 1;
39
+ }
40
+ }
41
+ return -1;
42
+ }
43
+ export function splitTopLevel(body, separators, angles) {
44
+ const opening = angles ? "([{<" : "([{", closing = angles ? ")]}>" : ")]}", parts = [];
45
+ let depth = 0, quote = null, current = "";
46
+ for (let i = 0;i < body.length; i++) {
47
+ const char = body[i];
48
+ if (quote) {
49
+ current += char;
50
+ if (char === "\\") {
51
+ current += body[++i] ?? "";
52
+ continue;
53
+ }
54
+ if (char === quote)
55
+ quote = null;
56
+ continue;
57
+ }
58
+ if (char === "'" || char === '"' || char === "`") {
59
+ quote = char;
60
+ current += char;
61
+ continue;
62
+ }
63
+ if (opening.includes(char))
64
+ depth++;
65
+ else if (closing.includes(char) && !(angles && char === ">" && body[i - 1] === "="))
66
+ depth--;
67
+ if (depth === 0 && separators.includes(char)) {
68
+ parts.push(current);
69
+ current = "";
70
+ continue;
71
+ }
72
+ current += char;
73
+ }
74
+ parts.push(current);
75
+ return parts.map((part) => part.trim()).filter(Boolean);
76
+ }
77
+ function defaultAssignmentIndex(entry) {
78
+ let depth = 0, quote = null;
79
+ for (let i = 0;i < entry.length; i++) {
80
+ const char = entry[i];
81
+ if (quote) {
82
+ if (char === "\\") {
83
+ i++;
84
+ continue;
85
+ }
86
+ if (char === quote)
87
+ quote = null;
88
+ continue;
89
+ }
90
+ if (char === "'" || char === '"' || char === "`") {
91
+ quote = char;
92
+ continue;
93
+ }
94
+ if ("([{".includes(char))
95
+ depth++;
96
+ else if (")]}".includes(char))
97
+ depth--;
98
+ if (depth !== 0 || char !== "=")
99
+ continue;
100
+ const previous = entry[i - 1];
101
+ if (entry[i + 1] === "=" || previous === "=" || previous === "!" || previous === "<" || previous === ">")
102
+ continue;
103
+ return i;
104
+ }
105
+ return -1;
106
+ }
107
+ function typeFromConstructor(value) {
108
+ switch (value.trim()) {
109
+ case "String":
110
+ return "string";
111
+ case "Number":
112
+ return "number";
113
+ case "Boolean":
114
+ return "boolean";
115
+ case "Array":
116
+ return "unknown[]";
117
+ case "Object":
118
+ return "Record<string, unknown>";
119
+ default:
120
+ return;
121
+ }
122
+ }
123
+ export function parsePropsDeclaration(source) {
124
+ const code = withoutComments(source);
125
+ for (const start of new Set(topLevelDeclarationSites(code).map((site) => site.start))) {
126
+ const declaration = parsePropsAt(code, start);
127
+ if (declaration)
128
+ return { ...declaration, text: source.slice(start, start + declaration.text.length) };
129
+ }
130
+ return null;
131
+ }
132
+ function parsePropsAt(code, start) {
133
+ const declared = Object.create(null), defaults = Object.create(null), propNames = [], propBindings = Object.create(null), localBindings = Object.create(null);
134
+ let cursor = start + (/^(?:const|let|var)\s+/.exec(code.slice(start))?.[0].length ?? 0);
135
+ const skipSpace = () => {
136
+ while (cursor < code.length && /\s/.test(code[cursor]))
137
+ cursor++;
138
+ };
139
+ let pattern;
140
+ if (code[cursor] === "{") {
141
+ const end = skipBalanced(code, cursor, "{", "}");
142
+ if (end === -1)
143
+ return null;
144
+ pattern = code.slice(cursor, end);
145
+ cursor = end;
146
+ } else {
147
+ const identifier = /^[A-Za-z_$][\w$]*/.exec(code.slice(cursor));
148
+ if (!identifier)
149
+ return null;
150
+ pattern = identifier[0];
151
+ cursor += identifier[0].length;
152
+ }
153
+ skipSpace();
154
+ if (code[cursor] !== "=")
155
+ return null;
156
+ cursor++;
157
+ skipSpace();
158
+ const wrapper = /^withDefaults\s*\(\s*/.exec(code.slice(cursor)), wrapped = Boolean(wrapper);
159
+ if (wrapper)
160
+ cursor += wrapper[0].length;
161
+ const marker = /^defineProps\b/.exec(code.slice(cursor));
162
+ if (!marker)
163
+ return null;
164
+ cursor += marker[0].length;
165
+ let typeText = "";
166
+ skipSpace();
167
+ if (code[cursor] === "<") {
168
+ const end = skipBalanced(code, cursor, "<", ">");
169
+ if (end === -1)
170
+ return null;
171
+ typeText = code.slice(cursor + 1, end - 1).trim();
172
+ cursor = end;
173
+ }
174
+ skipSpace();
175
+ if (code[cursor] !== "(")
176
+ return null;
177
+ const callEnd = skipBalanced(code, cursor, "(", ")");
178
+ if (callEnd === -1)
179
+ return null;
180
+ const runtimeArgument = code.slice(cursor + 1, callEnd - 1).trim();
181
+ cursor = callEnd;
182
+ if (wrapped) {
183
+ skipSpace();
184
+ if (code[cursor] === ",") {
185
+ cursor++;
186
+ skipSpace();
187
+ }
188
+ if (code[cursor] === "{") {
189
+ const end = skipBalanced(code, cursor, "{", "}");
190
+ if (end === -1)
191
+ return null;
192
+ for (const [name, value] of parseDefaults(code.slice(cursor, end)))
193
+ defaults[name] = value;
194
+ cursor = end;
195
+ }
196
+ skipSpace();
197
+ if (code[cursor] === ",") {
198
+ cursor++;
199
+ skipSpace();
200
+ }
201
+ if (code[cursor] === ")")
202
+ cursor++;
203
+ }
204
+ if (code[cursor] === ";")
205
+ cursor++;
206
+ const typeName = /^[A-Za-z_$][\w$]*$/.test(typeText) ? typeText : void 0;
207
+ if (typeText.startsWith("{"))
208
+ for (const member of splitTopLevel(typeText.replace(/^\{/, "").replace(/\}$/, ""), ",;", !0)) {
209
+ const parsed = /^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(member);
210
+ if (parsed)
211
+ declared[parsed[1]] = parsed[2].trim();
212
+ }
213
+ if (runtimeArgument.startsWith("{"))
214
+ for (const [name, value] of parseDefaults(runtimeArgument)) {
215
+ propNames.push(name);
216
+ if (!value.startsWith("{")) {
217
+ const fromConstructor = typeFromConstructor(value);
218
+ if (fromConstructor)
219
+ declared[name] = fromConstructor;
220
+ continue;
221
+ }
222
+ for (const [key, inner] of parseDefaults(value))
223
+ if (key === "default")
224
+ defaults[name] = inner;
225
+ else if (key === "type") {
226
+ const fromConstructor = typeFromConstructor(inner);
227
+ if (fromConstructor)
228
+ declared[name] = fromConstructor;
229
+ }
230
+ }
231
+ else if (runtimeArgument.startsWith("["))
232
+ for (const entry of splitTopLevel(runtimeArgument.slice(1, -1), ",", !1))
233
+ propNames.push(entry.replace(/^['"`]/, "").replace(/['"`]$/, ""));
234
+ if (pattern.startsWith("{")) {
235
+ propNames.length = 0;
236
+ for (const entry of splitTopLevel(pattern.replace(/^\{/, "").replace(/\}$/, ""), ",", !1)) {
237
+ const assignment = defaultAssignmentIndex(entry), binding = assignment === -1 ? entry : entry.slice(0, assignment), name = binding.split(":")[0].trim().replace(/^\.\.\./, "");
238
+ if (!name)
239
+ continue;
240
+ propNames.push(name);
241
+ propBindings[name] = binding.trim();
242
+ const local = binding.split(":").at(-1).trim();
243
+ if (/^[A-Za-z_$][\w$]*$/.test(local))
244
+ localBindings[name] = local;
245
+ if (assignment !== -1)
246
+ defaults[name] = entry.slice(assignment + 1).trim();
247
+ }
248
+ } else if (propNames.length === 0)
249
+ propNames.push(...Object.keys(declared));
250
+ return { text: code.slice(start, cursor), propNames, propBindings, localBindings, defaults, declared, typeName, identifier: pattern.startsWith("{") ? void 0 : pattern };
251
+ }
252
+ export function parseDefaults(object) {
253
+ const body = object.trim().replace(/^\{/, "").replace(/\}$/, ""), pairs = [];
254
+ let index = 0;
255
+ while (index < body.length) {
256
+ const key = /\s*([A-Za-z_$][\w$]*)\s*:/y;
257
+ key.lastIndex = index;
258
+ const match = key.exec(body);
259
+ if (!match)
260
+ break;
261
+ index = key.lastIndex;
262
+ let depth = 0, quote = "";
263
+ const start = index;
264
+ while (index < body.length) {
265
+ const char = body[index];
266
+ if (quote) {
267
+ if (char === "\\")
268
+ index++;
269
+ else if (char === quote)
270
+ quote = "";
271
+ } else if (char === "'" || char === '"' || char === "`")
272
+ quote = char;
273
+ else if (char === "{" || char === "[" || char === "(")
274
+ depth++;
275
+ else if (char === "}" || char === "]" || char === ")")
276
+ depth--;
277
+ else if (char === "," && depth === 0)
278
+ break;
279
+ index++;
280
+ }
281
+ const value = body.slice(start, index).trim();
282
+ if (value)
283
+ pairs.push([match[1], value]);
284
+ index++;
285
+ }
286
+ return pairs;
287
+ }
288
+ function numberLiteral(source) {
289
+ const decimal = /^(?:(?:0|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?$/, radix = /^(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[bB][01](?:_?[01])*|0[oO][0-7](?:_?[0-7])*)$/;
290
+ if (!decimal.test(source) && !radix.test(source))
291
+ throw Error("Invalid prop number");
292
+ return Number(source.replaceAll("_", ""));
293
+ }
294
+ export function literalValue(source) {
295
+ const tokens = new Tokenizer(source, "javascript").tokenize().filter((token) => !["COMMENT", "WHITESPACE", "EOF"].includes(token.type));
296
+ let cursor = 0;
297
+ function read(depth) {
298
+ if (depth > 64)
299
+ throw Error("Prop literal too deep");
300
+ const token = tokens[cursor++];
301
+ if (!token)
302
+ throw Error("Missing prop literal");
303
+ if (token.type === "STRING" || token.type === "TEMPLATE_STRING") {
304
+ const value = parseStringLiteral(token.value);
305
+ if (value === null)
306
+ throw Error("Dynamic prop string");
307
+ return value;
308
+ }
309
+ if (token.type === "NUMBER")
310
+ return numberLiteral(token.value);
311
+ if (token.value === "-" || token.value === "+") {
312
+ const number = tokens[cursor++];
313
+ if (number?.type !== "NUMBER")
314
+ throw Error("Dynamic prop number");
315
+ return (token.value === "-" ? -1 : 1) * numberLiteral(number.value);
316
+ }
317
+ if (token.value === "true")
318
+ return !0;
319
+ if (token.value === "false")
320
+ return !1;
321
+ if (token.value === "null")
322
+ return null;
323
+ if (token.value === "undefined")
324
+ return;
325
+ if (token.value !== "[" && token.value !== "{")
326
+ throw Error("Dynamic prop default");
327
+ const array = token.value === "[", close = array ? "]" : "}", entries = [], values = [];
328
+ while (tokens[cursor]?.value !== close) {
329
+ if (array)
330
+ values.push(read(depth + 1));
331
+ else {
332
+ const key = tokens[cursor++];
333
+ if (!key || !["STRING", "IDENTIFIER", "NUMBER"].includes(key.type))
334
+ throw Error("Dynamic prop key");
335
+ const name = key.type === "STRING" ? parseStringLiteral(key.value) : key.type === "NUMBER" ? String(numberLiteral(key.value)) : key.value;
336
+ if (name === null || tokens[cursor++]?.value !== ":")
337
+ throw Error("Dynamic prop key");
338
+ entries.push([name, read(depth + 1)]);
339
+ }
340
+ if (tokens[cursor]?.value !== ",")
341
+ break;
342
+ cursor++;
343
+ }
344
+ if (tokens[cursor++]?.value !== close)
345
+ throw Error("Unclosed prop literal");
346
+ return array ? values : Object.fromEntries(entries);
347
+ }
348
+ try {
349
+ const result = read(0);
350
+ return cursor === tokens.length ? result : void 0;
351
+ } catch {
352
+ return;
353
+ }
354
+ }
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{bo,en,Xl,tm}from"./chunk-69ezjc8k.js";import{yo,ta,Zg,Qg,em}from"./chunk-50cnypys.js";import{ql,Kl,Gl,Jg,Yg}from"./chunk-e41pgmgk.js";import{tt,Fn,na}from"./chunk-02qmvcmv.js";import{nm,rm,sm,om,wo,Vy}from"./chunk-dwyhpbpx.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
- Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-xk15vzb6.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
2
+ import{xo,Qt,Yl,rm}from"./chunk-0ncafcs2.js";import{vo,ra,em,tm,nm}from"./chunk-967ydrq4.js";import{Gl,Xl,Jl,Zg,Qg}from"./chunk-rf0smj4c.js";import{tt,zn,sa}from"./chunk-55tc5w32.js";import{sm,om,im,am,So,Wy}from"./chunk-ksmn19qw.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
+ Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-8354mzpd.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8">
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
233
233
  }, 5000);
234
234
  </script>
235
235
  </body>
236
- </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=tt(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=bo(n,t);if(a){let s=en(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return ta(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Kl as auditBuildOutput,ql as auditConfig,re as buildPwaAssets,Gl as calculateAuditResult,Yg as formatAuditResult,na as formatSize,j as generateManifest,_ as generateManifestJson,Qg as generateManifestLink,F as generateOfflinePage,tt as generatePrecacheManifest,Fn as generatePrecacheManifestJs,M as generatePwaIcons,yo as generatePwaTags,bo as generateServiceWorker,tm as generateServiceWorkerAuto,Zg as generateSwRegistrationScript,em as generateThemeColorMeta,N as getExpectedIconPaths,en as getServiceWorkerFileName,ta as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Xl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,wo as pwaDirectives,nm as pwaInstallDirective,sm as pwaOfflineDirective,om as pwaPushDirective,rm as pwaUpdateDirective,Vy as registerPwaDirectives,Jg as runPwaAudit,D as validateManifest};
236
+ </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=tt(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=xo(n,t);if(a){let s=Qt(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return ra(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Xl as auditBuildOutput,Gl as auditConfig,re as buildPwaAssets,Jl as calculateAuditResult,Qg as formatAuditResult,sa as formatSize,j as generateManifest,_ as generateManifestJson,tm as generateManifestLink,F as generateOfflinePage,tt as generatePrecacheManifest,zn as generatePrecacheManifestJs,M as generatePwaIcons,vo as generatePwaTags,xo as generateServiceWorker,rm as generateServiceWorkerAuto,em as generateSwRegistrationScript,nm as generateThemeColorMeta,N as getExpectedIconPaths,Qt as getServiceWorkerFileName,ra as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Yl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,So as pwaDirectives,sm as pwaInstallDirective,im as pwaOfflineDirective,am as pwaPushDirective,om as pwaUpdateDirective,Wy as registerPwaDirectives,Zg as runPwaAudit,D as validateManifest};