@stacksjs/stx 0.2.645 → 0.2.648

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 (264) hide show
  1. package/dist/builtins/attrs.js +6 -6
  2. package/dist/builtins/escape.d.ts +0 -11
  3. package/dist/builtins/escape.js +2 -1
  4. package/dist/builtins/safe-image.js +1 -3
  5. package/dist/builtins/stx-image.js +1 -3
  6. package/dist/builtins/stx-link.d.ts +3 -0
  7. package/dist/builtins/stx-link.js +1 -3
  8. package/dist/{chunk-apeyn69a.js → chunk-04kg16qs.js} +4 -4
  9. package/dist/chunk-06w0z1cm.js +31 -0
  10. package/dist/chunk-0en5jwjy.js +2 -0
  11. package/dist/{chunk-ph8dqgr5.js → chunk-0h8tg21j.js} +14 -14
  12. package/dist/{chunk-g2mcw1r4.js → chunk-0jhdrgpr.js} +2 -2
  13. package/dist/chunk-0vkawews.js +21 -0
  14. package/dist/{chunk-hpggz2t4.js → chunk-120ze5ms.js} +3 -3
  15. package/dist/chunk-2a4szpje.js +3 -0
  16. package/dist/chunk-2f17h17f.js +2 -0
  17. package/dist/{chunk-a0ygyftk.js → chunk-2h8ea0we.js} +2 -2
  18. package/dist/{chunk-3ns5k9nf.js → chunk-2jh21f1n.js} +2 -2
  19. package/dist/chunk-2n3pa5gm.js +2 -0
  20. package/dist/{chunk-ktvr45qg.js → chunk-2qbvsvwc.js} +2 -2
  21. package/dist/chunk-354jmw2k.js +3 -0
  22. package/dist/chunk-3b5bphcn.js +2 -0
  23. package/dist/chunk-3p7mk3mw.js +2 -0
  24. package/dist/chunk-3q163st5.js +1312 -0
  25. package/dist/chunk-3zyjqvsq.js +42 -0
  26. package/dist/{chunk-mfd3fca7.js → chunk-481d4kr9.js} +11 -11
  27. package/dist/chunk-4q2dtxdk.js +2 -0
  28. package/dist/{chunk-1t0m4pwg.js → chunk-4yf1w261.js} +2 -2
  29. package/dist/chunk-4yt8tg4j.js +2 -0
  30. package/dist/chunk-52gp2xxk.js +2 -0
  31. package/dist/chunk-55zaxb4s.js +61 -0
  32. package/dist/chunk-57md41g9.js +2 -0
  33. package/dist/chunk-67kj14at.js +2 -0
  34. package/dist/chunk-67xhsacd.js +12 -0
  35. package/dist/{chunk-me1tdtzz.js → chunk-6ajahb2x.js} +3 -3
  36. package/dist/chunk-6ea6az61.js +4 -0
  37. package/dist/chunk-6vh8s0pg.js +2 -0
  38. package/dist/chunk-6vzktvyw.js +2 -0
  39. package/dist/{chunk-r2seygb5.js → chunk-7rta163c.js} +2 -2
  40. package/dist/chunk-84djpte6.js +3 -0
  41. package/dist/chunk-864qtx7y.js +2 -0
  42. package/dist/chunk-88z4wkrj.js +6 -0
  43. package/dist/chunk-89yj6tcd.js +2 -0
  44. package/dist/chunk-8d2f2e42.js +2 -0
  45. package/dist/chunk-8fsq2ynj.js +2 -0
  46. package/dist/chunk-8p9kpfk8.js +4 -0
  47. package/dist/chunk-8tpmz4as.js +2 -0
  48. package/dist/chunk-9121nkpj.js +11 -0
  49. package/dist/{chunk-rmj0n3ss.js → chunk-9p6efb17.js} +1 -1
  50. package/dist/chunk-9szxxgv5.js +2 -0
  51. package/dist/{chunk-4g8zase6.js → chunk-9txn4rvb.js} +2 -2
  52. package/dist/chunk-9x0zt65f.js +2 -0
  53. package/dist/chunk-a2bw46t9.js +2 -0
  54. package/dist/{chunk-gvr10eqb.js → chunk-a3d0g4mr.js} +2 -2
  55. package/dist/chunk-a4sggwcz.js +2 -0
  56. package/dist/chunk-ab7zqtax.js +3 -0
  57. package/dist/{chunk-v1mvbf82.js → chunk-aprhqxky.js} +5 -5
  58. package/dist/chunk-b0hpshvk.js +2 -0
  59. package/dist/chunk-b4fd2dtk.js +2 -0
  60. package/dist/chunk-c1479y92.js +2 -0
  61. package/dist/{chunk-kchphxkm.js → chunk-c1dkh0es.js} +3 -3
  62. package/dist/chunk-c9k40352.js +2 -0
  63. package/dist/{chunk-ahyq08mp.js → chunk-ce6zddpf.js} +3 -3
  64. package/dist/{chunk-9wbtj6tj.js → chunk-dgb4z4kw.js} +2 -2
  65. package/dist/chunk-e87xa4r3.js +4 -0
  66. package/dist/chunk-egg54kd0.js +12 -0
  67. package/dist/chunk-embejqx4.js +2 -0
  68. package/dist/chunk-er60h3j3.js +2 -0
  69. package/dist/{chunk-pp6ycfay.js → chunk-ewcrsyr7.js} +2 -2
  70. package/dist/chunk-eyfxw7ds.js +2 -0
  71. package/dist/chunk-f3y4fnaa.js +2 -0
  72. package/dist/chunk-f46ht5kq.js +20 -0
  73. package/dist/chunk-f7930sce.js +2 -0
  74. package/dist/chunk-fcn71bq1.js +2 -0
  75. package/dist/{chunk-38ngmh6h.js → chunk-fg3jw17w.js} +48 -48
  76. package/dist/chunk-fsbjat59.js +2 -0
  77. package/dist/chunk-g2jmwh7p.js +2 -0
  78. package/dist/chunk-g8r0km7g.js +106 -0
  79. package/dist/{chunk-qa625vwc.js → chunk-gv793yqq.js} +4 -4
  80. package/dist/chunk-gz90fqn8.js +2 -0
  81. package/dist/chunk-h15xb2vd.js +2 -0
  82. package/dist/chunk-h5nmf98w.js +2 -0
  83. package/dist/{chunk-w9zxb26s.js → chunk-hfpv56cp.js} +1 -1
  84. package/dist/chunk-hhmj9gpk.js +2 -0
  85. package/dist/chunk-hjm69qnj.js +2 -0
  86. package/dist/chunk-hvtzw1jh.js +2 -0
  87. package/dist/{chunk-4n24jbfs.js → chunk-hvzzhkhr.js} +2 -2
  88. package/dist/chunk-j0v970k3.js +2 -0
  89. package/dist/chunk-j393gsfd.js +20 -0
  90. package/dist/chunk-j5gd0e53.js +2 -0
  91. package/dist/chunk-jk41jwsc.js +2 -0
  92. package/dist/{chunk-kvn23sz5.js → chunk-jkaszw24.js} +4 -4
  93. package/dist/{chunk-6mnwvn9v.js → chunk-jkvr7e91.js} +2 -2
  94. package/dist/{chunk-2zcbx82x.js → chunk-jxda11cg.js} +2 -2
  95. package/dist/chunk-k2pa44rf.js +2 -0
  96. package/dist/{chunk-kad2cp0z.js → chunk-k79x96ra.js} +37 -37
  97. package/dist/{chunk-75c46b62.js → chunk-kgfgb971.js} +4 -4
  98. package/dist/chunk-m6qfqkbh.js +2 -0
  99. package/dist/{chunk-r7haw6r7.js → chunk-mmwedr93.js} +5 -5
  100. package/dist/chunk-mnp8ecj9.js +2 -0
  101. package/dist/{chunk-dyg6sadv.js → chunk-mrrrngzd.js} +1 -1
  102. package/dist/{chunk-fk1rs7jb.js → chunk-n38yb274.js} +6 -6
  103. package/dist/chunk-ncqh5qe5.js +2 -0
  104. package/dist/chunk-nj1t4g3a.js +25 -0
  105. package/dist/{chunk-3cqxtkqv.js → chunk-np4zm2ph.js} +7 -7
  106. package/dist/{chunk-7jgtphhg.js → chunk-nrvwejdw.js} +5 -5
  107. package/dist/{chunk-c96f3eq5.js → chunk-nt0n0vjm.js} +8 -8
  108. package/dist/chunk-p44kmbdg.js +65 -0
  109. package/dist/chunk-pbtkbe48.js +888 -0
  110. package/dist/{chunk-pf5s5gjp.js → chunk-pg0xzsss.js} +2 -2
  111. package/dist/{chunk-pvfx0dgz.js → chunk-prf164ct.js} +2 -2
  112. package/dist/chunk-pxs7sgnp.js +3 -0
  113. package/dist/chunk-qfe7ps3v.js +18 -0
  114. package/dist/chunk-qm4672dj.js +18 -0
  115. package/dist/{chunk-2bsrmqr8.js → chunk-qv6axke4.js} +2 -2
  116. package/dist/chunk-r1r6311d.js +14 -0
  117. package/dist/{chunk-n54c06wt.js → chunk-r3e6x87d.js} +3 -3
  118. package/dist/chunk-radggg3p.js +49 -0
  119. package/dist/{chunk-zm4s3n4p.js → chunk-rcadtv3x.js} +1 -1
  120. package/dist/{chunk-vbqts5sf.js → chunk-rjh2jwxx.js} +9 -9
  121. package/dist/chunk-sf0wsq74.js +2 -0
  122. package/dist/{chunk-kfq594fh.js → chunk-sgptbhrc.js} +2 -2
  123. package/dist/chunk-shpc1ttk.js +2 -0
  124. package/dist/chunk-sszhz1zh.js +2 -0
  125. package/dist/chunk-szyqxcfj.js +3 -0
  126. package/dist/{chunk-392pj66x.js → chunk-t1k9160w.js} +29 -29
  127. package/dist/{chunk-22hdbqad.js → chunk-t2pzy3x1.js} +3 -3
  128. package/dist/chunk-t6yjxhn8.js +2 -0
  129. package/dist/chunk-t82be9yf.js +2 -0
  130. package/dist/{chunk-g06qzkmp.js → chunk-tre98h62.js} +2 -2
  131. package/dist/{chunk-bsts9pr5.js → chunk-v2x9vzgw.js} +2 -2
  132. package/dist/chunk-vdxjy7j2.js +4 -0
  133. package/dist/{chunk-xbdbn3bf.js → chunk-vmwdt8fr.js} +5 -5
  134. package/dist/{chunk-fqg0espy.js → chunk-vqc4h16r.js} +2 -2
  135. package/dist/chunk-w2zceynt.js +2 -0
  136. package/dist/chunk-weqc0ssb.js +2 -0
  137. package/dist/chunk-wjt0kej9.js +3 -0
  138. package/dist/{chunk-9yk5rasj.js → chunk-wpm58d6p.js} +3 -3
  139. package/dist/{chunk-0zr1zxar.js → chunk-wpmrz872.js} +2 -2
  140. package/dist/chunk-wq6j2h32.js +33 -0
  141. package/dist/chunk-wq712sw1.js +2 -0
  142. package/dist/chunk-x34scshq.js +3 -0
  143. package/dist/{chunk-fb17t651.js → chunk-x5tjb4y4.js} +2 -2
  144. package/dist/chunk-xaa36b0x.js +3 -0
  145. package/dist/chunk-xfzcv0jc.js +2 -0
  146. package/dist/{chunk-dmg8dpah.js → chunk-xm2mee4a.js} +169 -169
  147. package/dist/chunk-xvs04cnp.js +2 -0
  148. package/dist/chunk-y9x4pyp2.js +2 -0
  149. package/dist/chunk-ye8tgmd3.js +2 -0
  150. package/dist/{chunk-febtq3xj.js → chunk-ym41ybz2.js} +6 -6
  151. package/dist/chunk-ymymwzt5.js +3 -0
  152. package/dist/{chunk-wpc04ygt.js → chunk-yq021b3r.js} +11 -11
  153. package/dist/chunk-z8p6tk5z.js +2 -0
  154. package/dist/chunk-zdnc7a4t.js +127 -0
  155. package/dist/chunk-zhf01af3.js +3 -0
  156. package/dist/chunk-zmh9p9aa.js +2 -0
  157. package/dist/{chunk-jtvcxbwd.js → chunk-zqtbtqbq.js} +2 -2
  158. package/dist/chunk-zsgcsqat.js +406 -0
  159. package/dist/chunk-zyqs6a3p.js +2 -0
  160. package/dist/cli.js +62 -62
  161. package/dist/craft-entry.js +2 -2
  162. package/dist/craft.js +2 -2
  163. package/dist/expressions.d.ts +6 -21
  164. package/dist/expressions.js +12 -41
  165. package/dist/forms-validation.d.ts +0 -16
  166. package/dist/forms-validation.js +4 -2
  167. package/dist/forms.js +8 -6
  168. package/dist/i18n.js +6 -4
  169. package/dist/interpolation-context.js +173 -29
  170. package/dist/loops.js +70 -90
  171. package/dist/mustache-span.d.ts +21 -0
  172. package/dist/mustache-span.js +35 -0
  173. package/dist/process.js +4 -3
  174. package/dist/pwa.js +3 -3
  175. package/dist/runtime-injection.js +9 -3
  176. package/dist/server-bindings.js +12 -6
  177. package/dist/ssg.js +28 -28
  178. package/dist/utils.js +1 -2
  179. package/package.json +5 -5
  180. package/dist/chunk-1jgsst0v.js +0 -2
  181. package/dist/chunk-1vrqmdfe.js +0 -2
  182. package/dist/chunk-1vx1ha9v.js +0 -2
  183. package/dist/chunk-1y9jphbg.js +0 -2
  184. package/dist/chunk-22kgdhxy.js +0 -2
  185. package/dist/chunk-2etamr31.js +0 -4
  186. package/dist/chunk-2s49ggrz.js +0 -12
  187. package/dist/chunk-2zbnc6jq.js +0 -2
  188. package/dist/chunk-39beqd1g.js +0 -2
  189. package/dist/chunk-3q5yn5r0.js +0 -6
  190. package/dist/chunk-3tcy2hdt.js +0 -2
  191. package/dist/chunk-3ycbhpa2.js +0 -2
  192. package/dist/chunk-3yqs2ekt.js +0 -2
  193. package/dist/chunk-4mm9ttc7.js +0 -2
  194. package/dist/chunk-4q4vy4g6.js +0 -2
  195. package/dist/chunk-4zapx8zt.js +0 -20
  196. package/dist/chunk-5zkwems4.js +0 -2
  197. package/dist/chunk-6e4es31t.js +0 -3
  198. package/dist/chunk-6hmbzqt8.js +0 -2
  199. package/dist/chunk-7a3kffqy.js +0 -2
  200. package/dist/chunk-7mkw98cr.js +0 -3
  201. package/dist/chunk-7xks65hg.js +0 -3
  202. package/dist/chunk-8k38mddf.js +0 -2
  203. package/dist/chunk-8q05cxzd.js +0 -2
  204. package/dist/chunk-a7y0fk20.js +0 -12
  205. package/dist/chunk-abwxa3tj.js +0 -2
  206. package/dist/chunk-ayjje1hk.js +0 -2
  207. package/dist/chunk-c93291jk.js +0 -2
  208. package/dist/chunk-cf6d5kgb.js +0 -65
  209. package/dist/chunk-crahn5xa.js +0 -4
  210. package/dist/chunk-d1jyxxcm.js +0 -3
  211. package/dist/chunk-d365tseq.js +0 -20
  212. package/dist/chunk-d67qvrzc.js +0 -24
  213. package/dist/chunk-dwnvqy3f.js +0 -4
  214. package/dist/chunk-dxb7jw7g.js +0 -2
  215. package/dist/chunk-e8483tnk.js +0 -2
  216. package/dist/chunk-eaphbqqx.js +0 -2
  217. package/dist/chunk-em0chjea.js +0 -18
  218. package/dist/chunk-ercd4pqc.js +0 -2
  219. package/dist/chunk-ewj4gqwe.js +0 -31
  220. package/dist/chunk-f7bgg2e4.js +0 -2
  221. package/dist/chunk-g6s0xdgb.js +0 -4
  222. package/dist/chunk-jxsgky4v.js +0 -2
  223. package/dist/chunk-k90yzxwp.js +0 -2
  224. package/dist/chunk-kfx4cte8.js +0 -127
  225. package/dist/chunk-kxbw0e2f.js +0 -3
  226. package/dist/chunk-ky043mkv.js +0 -2
  227. package/dist/chunk-mbqqc20a.js +0 -2
  228. package/dist/chunk-mq2kpg6w.js +0 -2
  229. package/dist/chunk-n58ky78d.js +0 -2
  230. package/dist/chunk-n80wh9b5.js +0 -2
  231. package/dist/chunk-p7sfjgtm.js +0 -2
  232. package/dist/chunk-ps9htxmp.js +0 -2
  233. package/dist/chunk-qhaw7f32.js +0 -2
  234. package/dist/chunk-rh33ra9e.js +0 -2
  235. package/dist/chunk-rzs2hpqa.js +0 -2
  236. package/dist/chunk-s3sckkvv.js +0 -2
  237. package/dist/chunk-s89pq4v1.js +0 -2
  238. package/dist/chunk-sdqgmcbk.js +0 -2
  239. package/dist/chunk-srmm69d4.js +0 -2852
  240. package/dist/chunk-t00y30w3.js +0 -2
  241. package/dist/chunk-t1a39rpd.js +0 -2
  242. package/dist/chunk-tj4rzy69.js +0 -2
  243. package/dist/chunk-tme51pg1.js +0 -2
  244. package/dist/chunk-tv1qtqab.js +0 -3
  245. package/dist/chunk-twh5ck5w.js +0 -2
  246. package/dist/chunk-v4tt3t1y.js +0 -2
  247. package/dist/chunk-v5ekdsw0.js +0 -2
  248. package/dist/chunk-vdsrae92.js +0 -2
  249. package/dist/chunk-w88mpbxk.js +0 -11
  250. package/dist/chunk-wg6n7txf.js +0 -2
  251. package/dist/chunk-wj4rf7sb.js +0 -2
  252. package/dist/chunk-wrd5me1w.js +0 -33
  253. package/dist/chunk-xbevgwks.js +0 -2
  254. package/dist/chunk-y2k3ynr2.js +0 -2
  255. package/dist/chunk-y51ndrdb.js +0 -2
  256. package/dist/chunk-y9wqzvxt.js +0 -2
  257. package/dist/chunk-yn2d8x8m.js +0 -3
  258. package/dist/chunk-ysmt4jpn.js +0 -2
  259. package/dist/chunk-zmccfvbf.js +0 -2
  260. package/dist/chunk-ztpqxs72.js +0 -2
  261. package/dist/chunk-ztwnn466.js +0 -2
  262. package/dist/chunk-zx7v6a4g.js +0 -40
  263. package/dist/chunk-zx94g4pg.js +0 -2
  264. package/dist/chunk-zze1ez1c.js +0 -2
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{us,ti,ni}from"./chunk-hpggz2t4.js";import"./chunk-zx7v6a4g.js";import"./chunk-gvr10eqb.js";import"./chunk-qa625vwc.js";import"./chunk-r2seygb5.js";import"./chunk-ahyq08mp.js";import"./chunk-srmm69d4.js";import"./chunk-d67qvrzc.js";import"./chunk-cf6d5kgb.js";import"./chunk-a0ygyftk.js";import"./chunk-fb17t651.js";import"./chunk-pvfx0dgz.js";import"./chunk-apeyn69a.js";import"./chunk-kchphxkm.js";import{qu,Go,Gu,Ku,Ko,ls,Xo,Xu,Jo,Ju,Yu,Yo,Zo,Qo,ei}from"./chunk-392pj66x.js";import"./chunk-em0chjea.js";import"./chunk-2etamr31.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{Ws,qi,Gi}from"./chunk-120ze5ms.js";import"./chunk-55zaxb4s.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import"./chunk-zsgcsqat.js";import"./chunk-2h8ea0we.js";import"./chunk-x5tjb4y4.js";import"./chunk-a3d0g4mr.js";import"./chunk-gv793yqq.js";import"./chunk-3q163st5.js";import"./chunk-p44kmbdg.js";import"./chunk-04kg16qs.js";import"./chunk-pxs7sgnp.js";import"./chunk-qfe7ps3v.js";import"./chunk-pbtkbe48.js";import"./chunk-3zyjqvsq.js";import"./chunk-radggg3p.js";import"./chunk-nj1t4g3a.js";import"./chunk-0vkawews.js";import"./chunk-prf164ct.js";import"./chunk-c1dkh0es.js";import{Xd,ji,Jd,Yd,Bi,Us,Fi,Zd,zi,Qd,ep,Hi,Vi,Ui,Wi}from"./chunk-t1k9160w.js";import"./chunk-qm4672dj.js";import"./chunk-ymymwzt5.js";import"./chunk-r1r6311d.js";import"./chunk-ye8tgmd3.js";import"./chunk-e87xa4r3.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{qu as CRAFT_BRIDGE_SCRIPT,ls as CRAFT_COMPONENTS,Xu as CRAFT_COMPONENT_RUNTIME,Xo as CRAFT_COMPONENT_STYLES,us as NATIVE_COMPONENTS,Yo as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ti as compileToNative,ni as createHotReloadServer,Zo as findCraftBinary,Go as generateCraftBridgeScript,V as generateCraftOptimizations,ei as getAvailableFormats,Qo as getAvailableTargets,Yu as getCraftComponents,G as getSSRCacheStats,Ko as injectCraftBridge,Gu as isCraftEnvironment,Y as prerenderForCraft,Jo as processCraftComponents,Ku as processCraftDirective,Ju 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{Xd as CRAFT_BRIDGE_SCRIPT,Us as CRAFT_COMPONENTS,Zd as CRAFT_COMPONENT_RUNTIME,Fi as CRAFT_COMPONENT_STYLES,Ws as NATIVE_COMPONENTS,Hi as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,qi as compileToNative,Gi as createHotReloadServer,Vi as findCraftBinary,ji as generateCraftBridgeScript,V as generateCraftOptimizations,Wi as getAvailableFormats,Ui as getAvailableTargets,ep as getCraftComponents,G as getSSRCacheStats,Bi as injectCraftBridge,Jd as isCraftEnvironment,Y as prerenderForCraft,zi as processCraftComponents,Yd as processCraftDirective,Qd as registerCraftComponent,Q as renderSSR};
@@ -1,3 +1,4 @@
1
+ import { findMustacheEnd } from './mustache-span';
1
2
  declare function getTranslateRegex(key: string): RegExp;
2
3
  /**
3
4
  * Register a custom filter
@@ -38,27 +39,6 @@ export declare function getAllFilters(): Record<string, FilterFunction>;
38
39
  * Clear all custom filters (useful for testing)
39
40
  */
40
41
  export declare function clearCustomFilters(): void;
41
- /**
42
- * The index of the `}` that starts the `}}` closing a mustache span opened at
43
- * `openIndex` (the index of its first `{`), or -1 when nothing closes it.
44
- *
45
- * Not to be confused with strip-literals' findInterpolationEnd, which closes a
46
- * JS `${ ... }` interpolation on a single brace.
47
- *
48
- * Braces inside the expression are counted and string literals are skipped, so
49
- * the span is read whole. The matchers here were `/\{\{([\s\S]*?)\}\}/`, which
50
- * is lazy and knows neither, so ONE level of object nesting ended the
51
- * expression early:
52
- *
53
- * {{ JSON.stringify({a:1}) }} worked
54
- * {{ JSON.stringify({a:{b:1}}) }} became `JSON.stringify({a:{b:1`
55
- *
56
- * The truncated expression failed to evaluate, which yields empty, and the rest
57
- * of it leaked as literal text -- pages shipped `) }}` where a value belonged,
58
- * including inside attribute values, with no error and no warning. A `}}` in a
59
- * string (`{{ "a}}b" }}`) ended it early the same way.
60
- */
61
- export declare function findMustacheEnd(input: string, openIndex: number, braces?: number): number;
62
42
  /**
63
43
  * Replace every `{{ expr }}` span in `input`, each read whole by
64
44
  * findMustacheEnd.
@@ -101,6 +81,10 @@ export declare function escapeHtml(unsafe: string): string;
101
81
  * decodes references before anything reads them.
102
82
  */
103
83
  export declare function escapeHtmlValue(unsafe: string): string;
84
+ /** Escape a value according to the HTML context it will occupy. */
85
+ export declare function escapeInterpolatedHtmlValue(source: string, offset: number, raw: string, attributeFragment?: boolean, interpolationLength?: number): string;
86
+ /** Serialize a resolved DOM value using the same policy as {{ value }}. */
87
+ export declare function escapeAttributeValue(name: string, value: string): string;
104
88
  export declare function usesSignalsInScript(template: string, filePath?: string): boolean;
105
89
  /**
106
90
  * Where each client-side loop in `html` is, and the names it binds.
@@ -220,3 +204,4 @@ export declare interface ExpressionRejection {
220
204
  */
221
205
  // eslint-disable-next-line pickier/no-unused-vars
222
206
  export type FilterFunction = (value: any, context: Record<string, any>, ...args: any[]) => any;
207
+ export { findMustacheEnd } from './mustache-span';
@@ -1,3 +1,5 @@
1
+ import { findMustacheEnd } from "./mustache-span.js";
2
+ export { findMustacheEnd } from "./mustache-span.js";
1
3
  import fs from "node:fs";
2
4
  import { isDevelopment } from "./env.js";
3
5
  import { stripCommentsAndLiterals } from "./strip-literals.js";
@@ -81,7 +83,7 @@ export const defaultFilters = {
81
83
  return fallbackToKey ? value : "";
82
84
  let result = String(translation);
83
85
  Object.entries(params).forEach(([paramKey, paramValue]) => {
84
- result = result.replace(getTranslateRegex(paramKey), String(paramValue));
86
+ result = result.replace(getTranslateRegex(paramKey), () => String(paramValue));
85
87
  });
86
88
  return result;
87
89
  },
@@ -241,41 +243,6 @@ export function clearCustomFilters() {
241
243
  for (const key of Object.keys(customFilters))
242
244
  delete customFilters[key];
243
245
  }
244
- export function findMustacheEnd(input, openIndex, braces = 2) {
245
- let depth = 0, quote = null;
246
- for (let i = openIndex + braces;i < input.length; i++) {
247
- const character = input[i];
248
- if (quote) {
249
- if (character === "\\") {
250
- i++;
251
- continue;
252
- }
253
- if (character === quote)
254
- quote = null;
255
- continue;
256
- }
257
- if (character === '"' || character === "'" || character === "`") {
258
- quote = character;
259
- continue;
260
- }
261
- if (character === "{") {
262
- depth++;
263
- continue;
264
- }
265
- if (character === "}") {
266
- if (depth > 0) {
267
- depth--;
268
- continue;
269
- }
270
- let run = 0;
271
- while (input[i + run] === "}")
272
- run++;
273
- if (run >= braces)
274
- return i;
275
- }
276
- }
277
- return -1;
278
- }
279
246
  export function replaceInterpolations(input, replacer, braces = 2) {
280
247
  const opener = "{".repeat(braces);
281
248
  if (!input.includes(opener))
@@ -317,7 +284,7 @@ function assertSafeCssInterpolation(value, attribute) {
317
284
  throw new UnsafeInterpolationContextError(attribute, "CSS URLs must be local paths or base64 raster images");
318
285
  }
319
286
  }
320
- function escapeInterpolatedHtmlValue(source, offset, raw, attributeFragment = !1, interpolationLength = 0) {
287
+ export function escapeInterpolatedHtmlValue(source, offset, raw, attributeFragment = !1, interpolationLength = 0) {
321
288
  const context = classifyHtmlInterpolation(source, offset, attributeFragment);
322
289
  let escaped = escapeHtmlValue(raw);
323
290
  if (!context)
@@ -347,6 +314,10 @@ function escapeInterpolatedHtmlValue(source, offset, raw, attributeFragment = !1
347
314
  return UNSAFE_URL_PREFIX + escaped;
348
315
  return sanitizeSubstitutedUrl(schemeWindow(source, offset), raw, escaped);
349
316
  }
317
+ export function escapeAttributeValue(name, value) {
318
+ const source = ` ${name}="`;
319
+ return escapeInterpolatedHtmlValue(source, source.length, value, !0);
320
+ }
350
321
  function clientScriptBodies(scripts) {
351
322
  return scripts.flatMap((script) => {
352
323
  const match = script.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);
@@ -494,7 +465,7 @@ export function interpolateScriptExpressions(scriptBody, context, filePath) {
494
465
  const value = evaluateExpression(expr, context);
495
466
  if (value === void 0)
496
467
  return looksLikeServerValue(trimmed) ? unresolvedServerValue(trimmed, filePath) : match;
497
- return JSON.stringify(value).replace(/</g, "\\u003c");
468
+ return JSON.stringify(value).replace(/</g, "\\u003c").replace(/@/g, "\\u0040").replace(/\{{2,}/g, (braces) => "\\u007b".repeat(braces.length)).replace(/\{(?=!)/g, "\\u007b");
498
469
  } catch {
499
470
  return match;
500
471
  }
@@ -537,10 +508,10 @@ export function interpolateScriptAttributes(attrs, context) {
537
508
  }
538
509
  export function interpolateScriptsInTemplate(template, context, options = {}) {
539
510
  const { output, scripts } = stashScriptElements(template), interpolatedScripts = scripts.map((full) => {
540
- const match = full.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i), opening = full.match(/^<script\b[^>]*>/i), closingStart = full.search(/<\/script\s*>$/i);
541
- if (!match || !opening || closingStart === -1)
511
+ const opening = full.match(/^<script\b((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/i), closingStart = full.search(/<\/script\s*>$/i);
512
+ if (!opening || closingStart === -1)
542
513
  return full;
543
- const attrs = match[1], body = match[2];
514
+ const attrs = opening[1], body = full.slice(opening[0].length, closingStart);
544
515
  if (/\bdata-raw\b/.test(attrs))
545
516
  return full;
546
517
  if (options.skipServer && /\bserver\b/.test(attrs))
@@ -80,22 +80,6 @@ declare interface FormState<T extends Record<string, Validator>> {
80
80
  getFieldState: (field: keyof T) => FieldState
81
81
  handleSubmit: (onSubmit: (values: { [K in keyof T]: unknown }) => void | Promise<void>) => (e?: Event) => Promise<void>
82
82
  }
83
- /**
84
- * STX Form Validation
85
- *
86
- * A simple, chainable form validation API.
87
- *
88
- * @example
89
- * ```typescript
90
- * import { useForm, v } from 'stx'
91
- *
92
- * const form = useForm({
93
- * email: v.required().email(),
94
- * password: v.required().min(8),
95
- * age: v.number().between(18, 100)
96
- * })
97
- * ```
98
- */
99
83
  // =============================================================================
100
84
  // Types
101
85
  // =============================================================================
@@ -1,3 +1,5 @@
1
+ import { processExpressions } from "./expressions.js";
2
+
1
3
  class Validator {
2
4
  rules = [];
3
5
  defaultValue = "";
@@ -361,7 +363,7 @@ export function processErrorDirective(content, context, _filePath) {
361
363
  if (!errors || !Array.isArray(errors) || errors.length === 0)
362
364
  return "";
363
365
  return errors.map((message) => {
364
- return body.replace(/\{\{\s*message\s*\}\}/g, message);
366
+ return processExpressions(body, { ...context, message }, _filePath);
365
367
  }).join(`
366
368
  `);
367
369
  } catch {
@@ -383,7 +385,7 @@ export function processErrorsDirective(content, context, _filePath) {
383
385
  const errors = current;
384
386
  if (!errors || !Array.isArray(errors) || errors.length === 0)
385
387
  return "";
386
- return errors.map((message) => body.replace(/\{\{\s*message\s*\}\}/g, message)).join(`
388
+ return errors.map((message) => processExpressions(body, { ...context, message }, _filePath)).join(`
387
389
  `);
388
390
  } catch {
389
391
  return "";
package/dist/forms.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import crypto from "node:crypto";
2
+ import { escapeHtmlValue, escapeInterpolatedHtmlValue } from "./expressions.js";
2
3
  import { isExpressionSafe, safeEvaluate } from "./safe-evaluator.js";
3
4
  function escapeAttr(str) {
4
- return String(str ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
5
+ return escapeHtmlValue(String(str ?? ""));
5
6
  }
6
7
  export const defaultFormClasses = {
7
8
  input: "form-control",
@@ -136,19 +137,20 @@ export function processErrorDirective(template, context, _classes = defaultFormC
136
137
  return template.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g, (match, field, content) => {
137
138
  try {
138
139
  if (hasFieldError(field, context)) {
139
- const rendered = content.replace(/\{\{([^}]+)\}\}/g, (_, expr) => {
140
+ const rendered = content.replace(/\{\{([^}]+)\}\}/g, (_, expr, offset) => {
141
+ const escape = (value) => escapeInterpolatedHtmlValue(content, offset, String(value ?? ""), !1, _.length);
140
142
  try {
141
143
  if (expr.trim() === "$message" || expr.trim() === "message")
142
- return getErrorMessage(field, context);
144
+ return escape(getErrorMessage(field, context));
143
145
  if (expr.trim().includes("errors.first") || expr.trim().includes("$errors.first")) {
144
146
  if (typeof context.errors?.first === "function")
145
- return context.errors.first(field);
146
- return getErrorMessage(field, context);
147
+ return escape(context.errors.first(field));
148
+ return escape(getErrorMessage(field, context));
147
149
  }
148
150
  const trimmedExpr = expr.trim();
149
151
  if (isExpressionSafe(trimmedExpr)) {
150
152
  const result = safeEvaluate(trimmedExpr, context);
151
- return result !== void 0 ? String(result) : trimmedExpr;
153
+ return result !== void 0 ? escape(result) : trimmedExpr;
152
154
  }
153
155
  return trimmedExpr;
154
156
  } catch {
package/dist/i18n.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { escapeInterpolatedHtmlValue } from "./expressions.js";
1
2
  import path from "node:path";
2
3
  import { ErrorCodes, inlineError } from "./error-handling.js";
3
4
  import { safeEvaluateObject } from "./safe-evaluator.js";
@@ -529,7 +530,7 @@ export function getTranslation(key, translations, fallbackToKey = !0, params = {
529
530
  }
530
531
  for (const [paramKey, paramValue] of Object.entries(params)) {
531
532
  const escapedKey = paramKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
532
- result = result.replace(new RegExp(`:${escapedKey}`, "g"), String(paramValue));
533
+ result = result.replace(new RegExp(`:${escapedKey}`, "g"), () => String(paramValue));
533
534
  }
534
535
  return result;
535
536
  }
@@ -612,7 +613,8 @@ export async function processTranslateDirective(template, context, filePath, opt
612
613
  if (options.debug)
613
614
  console.error("Error parsing parameters for @translate directive:", error);
614
615
  }
615
- return getTranslation(key, translations, i18nConfig.fallbackToKey, params) || content.trim();
616
+ const translation = getTranslation(key, translations, i18nConfig.fallbackToKey, params);
617
+ return translation ? escapeInterpolatedHtmlValue(output, _offset, translation, !1, _match.length) : content.trim();
616
618
  } catch (error) {
617
619
  if (options.debug)
618
620
  console.error("Error processing @translate directive:", error);
@@ -651,7 +653,7 @@ export async function processTranslateDirective(template, context, filePath, opt
651
653
  if (options.debug)
652
654
  console.error("Error parsing parameters for @translate directive:", error);
653
655
  }
654
- return getTranslation(key, translations, i18nConfig.fallbackToKey, params);
656
+ return escapeInterpolatedHtmlValue(output, _offset, getTranslation(key, translations, i18nConfig.fallbackToKey, params), !1, _match.length);
655
657
  } catch (error) {
656
658
  if (options.debug)
657
659
  console.error("Error processing @translate directive:", error);
@@ -670,7 +672,7 @@ async function replaceAsync(str, regex, asyncFn) {
670
672
  promises.push(promise);
671
673
  return match;
672
674
  });
673
- return (await Promise.all(promises)).reduce((str, { match, replacement }) => str.replace(match, replacement), str);
675
+ return (await Promise.all(promises)).reduce((str, { match, replacement }) => str.replace(match, () => replacement), str);
674
676
  }
675
677
  export function createTranslateFilter(translations, fallbackToKey = !0) {
676
678
  return (value, params = {}) => {
@@ -1,39 +1,183 @@
1
+ import { findMustacheEnd } from "./mustache-span.js";
1
2
  export function classifyHtmlInterpolation(source, offset, attributeFragment = !1) {
2
- const before = source.slice(0, offset), openTag = before.lastIndexOf("<"), closeTag = before.lastIndexOf(">");
3
- if (openTag >= 0 && closeTag > openTag)
4
- return null;
3
+ const { openTag, tail } = attributeFragment ? scanFragment(source, offset) : documentScanner(source).at(offset);
4
+ return classifyTail(tail, openTag, attributeFragment);
5
+ }
6
+ function scanFragment(source, offset) {
7
+ let before = "", start = 0;
8
+ for (let index = 0;index < offset; index++) {
9
+ if (!source.startsWith("{{", index))
10
+ continue;
11
+ const end = findMustacheEnd(source, index);
12
+ if (end < 0 || end + 2 > offset)
13
+ break;
14
+ before += source.slice(start, index) + "x";
15
+ index = end + 1;
16
+ start = end + 2;
17
+ }
18
+ before += source.slice(start, offset);
19
+ let openTag = -1, quote = null;
20
+ for (let index = 0;index < before.length; index++) {
21
+ const char = before[index];
22
+ if (quote) {
23
+ if (char === quote)
24
+ quote = null;
25
+ continue;
26
+ }
27
+ if (char === '"' || char === "'") {
28
+ quote = char;
29
+ continue;
30
+ }
31
+ if (char === ">") {
32
+ openTag = -1;
33
+ continue;
34
+ }
35
+ if (char === "<")
36
+ openTag = index;
37
+ }
38
+ return { openTag, tail: openTag >= 0 ? before.slice(openTag + 1) : before };
39
+ }
40
+ let lastScanner = null;
41
+ function documentScanner(source) {
42
+ if (lastScanner && lastScanner.source === source)
43
+ return lastScanner.scanner;
44
+ const scanner = createDocumentScanner(source);
45
+ lastScanner = { source, scanner };
46
+ return scanner;
47
+ }
48
+ function createDocumentScanner(source) {
49
+ let pos = 0, openTag = -1, quote = null, neverClosed = -1;
50
+ const step = (index, state) => {
51
+ const char = source[index];
52
+ if (state.quote) {
53
+ if (char === state.quote)
54
+ state.quote = null;
55
+ return;
56
+ }
57
+ if (state.openTag >= 0) {
58
+ if (char === '"' || char === "'") {
59
+ state.quote = char;
60
+ return;
61
+ }
62
+ if (char === ">") {
63
+ state.openTag = -1;
64
+ return;
65
+ }
66
+ }
67
+ if (char === "<")
68
+ state.openTag = index;
69
+ }, commentEnd = (index, state) => {
70
+ if (state.openTag >= 0 || !source.startsWith("<!--", index))
71
+ return -1;
72
+ const close = source.indexOf("-->", index + 4);
73
+ return close < 0 ? source.length : close + 3;
74
+ };
75
+ return {
76
+ at(offset) {
77
+ if (offset < pos) {
78
+ pos = 0;
79
+ openTag = -1;
80
+ quote = null;
81
+ neverClosed = -1;
82
+ }
83
+ const committed = { openTag, quote };
84
+ let inComment = !1;
85
+ while (pos < offset) {
86
+ if (neverClosed < 0 && source.startsWith("{{", pos)) {
87
+ const end = findMustacheEnd(source, pos);
88
+ if (end < 0)
89
+ neverClosed = pos;
90
+ else if (end + 2 <= offset) {
91
+ pos = end + 2;
92
+ continue;
93
+ } else
94
+ break;
95
+ }
96
+ const comment = commentEnd(pos, committed);
97
+ if (comment >= 0) {
98
+ if (comment > offset) {
99
+ inComment = !0;
100
+ break;
101
+ }
102
+ pos = comment;
103
+ continue;
104
+ }
105
+ step(pos, committed);
106
+ pos++;
107
+ }
108
+ openTag = committed.openTag;
109
+ quote = committed.quote;
110
+ if (inComment)
111
+ return { openTag: -1, tail: "" };
112
+ const textFrom = neverClosed >= 0 ? neverClosed : pos, current = { openTag, quote };
113
+ for (let index = pos;index < offset; index++) {
114
+ const comment = commentEnd(index, current);
115
+ if (comment >= 0) {
116
+ if (comment > offset)
117
+ return { openTag: -1, tail: "" };
118
+ index = comment - 1;
119
+ continue;
120
+ }
121
+ step(index, current);
122
+ }
123
+ if (current.openTag < 0)
124
+ return { openTag: -1, tail: "" };
125
+ let tail = "", start = current.openTag + 1;
126
+ for (let index = start;index < Math.min(offset, textFrom); index++) {
127
+ if (!source.startsWith("{{", index))
128
+ continue;
129
+ const end = findMustacheEnd(source, index);
130
+ tail += source.slice(start, index) + "x";
131
+ index = end + 1;
132
+ start = end + 2;
133
+ }
134
+ tail += source.slice(start, offset);
135
+ return { openTag: current.openTag, tail };
136
+ }
137
+ };
138
+ }
139
+ function classifyTail(tail, openTag, attributeFragment) {
5
140
  if (openTag < 0 && !attributeFragment)
6
141
  return null;
7
- const tail = openTag >= 0 ? before.slice(openTag + 1) : before;
8
142
  if (openTag >= 0 && /^\s*[!/?]/.test(tail))
9
143
  return /^\s*\/?\s*$/.test(tail) ? { kind: "tag-name" } : null;
10
144
  if (openTag >= 0 && /^\s*$/.test(tail))
11
145
  return { kind: "tag-name" };
12
- const doubleQuoted = /(?:^|\s)([^\s"'<>/=]+)\s*=\s*"([^"]*)$/.exec(tail);
13
- if (doubleQuoted)
14
- return {
15
- kind: "attribute",
16
- name: doubleQuoted[1],
17
- quote: '"',
18
- valuePrefix: doubleQuoted[2]
19
- };
20
- const singleQuoted = /(?:^|\s)([^\s"'<>/=]+)\s*=\s*'([^']*)$/.exec(tail);
21
- if (singleQuoted)
22
- return {
23
- kind: "attribute",
24
- name: singleQuoted[1],
25
- quote: "'",
26
- valuePrefix: singleQuoted[2]
27
- };
28
- const unquoted = /(?:^|\s)([^\s"'<>/=]+)\s*=\s*([^\s"'=<>`]*)$/.exec(tail);
29
- if (unquoted)
30
- return {
31
- kind: "attribute",
32
- name: unquoted[1],
33
- quote: null,
34
- valuePrefix: unquoted[2]
35
- };
36
- return openTag >= 0 || /^\s*[^<>]*$/.test(tail) ? { kind: "tag" } : null;
146
+ let cursor = 0;
147
+ if (openTag >= 0)
148
+ while (cursor < tail.length && !/\s/.test(tail[cursor]))
149
+ cursor++;
150
+ while (cursor < tail.length) {
151
+ while (/\s/.test(tail[cursor] ?? "") && cursor < tail.length)
152
+ cursor++;
153
+ const nameStart = cursor;
154
+ while (cursor < tail.length && !/[\s=/>]/.test(tail[cursor]))
155
+ cursor++;
156
+ const name = tail.slice(nameStart, cursor);
157
+ if (!name)
158
+ break;
159
+ while (cursor < tail.length && /\s/.test(tail[cursor]))
160
+ cursor++;
161
+ if (tail[cursor] !== "=")
162
+ continue;
163
+ cursor++;
164
+ while (cursor < tail.length && /\s/.test(tail[cursor]))
165
+ cursor++;
166
+ const delimiter = tail[cursor];
167
+ if (delimiter === '"' || delimiter === "'") {
168
+ const valueStart = ++cursor, end = tail.indexOf(delimiter, cursor);
169
+ if (end === -1)
170
+ return { kind: "attribute", name, quote: delimiter, valuePrefix: tail.slice(valueStart) };
171
+ cursor = end + 1;
172
+ } else {
173
+ const valueStart = cursor;
174
+ while (cursor < tail.length && !/\s/.test(tail[cursor]))
175
+ cursor++;
176
+ if (cursor === tail.length)
177
+ return { kind: "attribute", name, quote: null, valuePrefix: tail.slice(valueStart) };
178
+ }
179
+ }
180
+ return { kind: "tag" };
37
181
  }
38
182
 
39
183
  export class UnsafeInterpolationContextError extends Error {