@stacksjs/stx 0.2.759 → 0.2.761

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 (248) hide show
  1. package/dist/chunk-00nz3pas.js +2 -0
  2. package/dist/{chunk-3nxe5xmy.js → chunk-0fs9kx0h.js} +3 -3
  3. package/dist/{chunk-42hcspws.js → chunk-0kq0k4pg.js} +2 -2
  4. package/dist/chunk-0nynnmya.js +2 -0
  5. package/dist/{chunk-wp9y6x33.js → chunk-0q5dm9r2.js} +5 -5
  6. package/dist/{chunk-f4gqzg1y.js → chunk-0wj31pqy.js} +2 -2
  7. package/dist/chunk-13v3vgb6.js +2 -0
  8. package/dist/chunk-18gazs55.js +2 -0
  9. package/dist/chunk-1a9h6r9f.js +2 -0
  10. package/dist/chunk-1p8t2ekg.js +2 -0
  11. package/dist/chunk-1rcntvgx.js +2 -0
  12. package/dist/chunk-1w5gtkd6.js +2 -0
  13. package/dist/{chunk-fpagqrd1.js → chunk-23t9anc0.js} +75 -75
  14. package/dist/chunk-298gj90a.js +2 -0
  15. package/dist/{chunk-m5fjhrpd.js → chunk-2cbd1ew6.js} +101 -101
  16. package/dist/{chunk-h692k9xn.js → chunk-2typf9dh.js} +4 -4
  17. package/dist/chunk-2wnfqrv5.js +26 -0
  18. package/dist/chunk-2wq0h5ye.js +2 -0
  19. package/dist/{chunk-prej5pk6.js → chunk-2zd51tj4.js} +2 -2
  20. package/dist/chunk-2zg3jmy7.js +2 -0
  21. package/dist/{chunk-ztdjdxjt.js → chunk-319aez2f.js} +3 -3
  22. package/dist/{chunk-7g9vd5fv.js → chunk-37y8sg48.js} +2 -2
  23. package/dist/{chunk-j2mpqa4p.js → chunk-3csfmhg0.js} +2 -2
  24. package/dist/{chunk-jb1dk0w7.js → chunk-3mz088mb.js} +2 -2
  25. package/dist/chunk-3wxb7mfb.js +2 -0
  26. package/dist/{chunk-cehjp06v.js → chunk-42zqmcnc.js} +3 -3
  27. package/dist/{chunk-5ge5h2y3.js → chunk-45g1w1ct.js} +5 -5
  28. package/dist/{chunk-89h4snzd.js → chunk-4833k99b.js} +2 -2
  29. package/dist/{chunk-jevd16gq.js → chunk-48g9wez2.js} +30 -30
  30. package/dist/{chunk-t5gabs4x.js → chunk-4c0qcjac.js} +2 -2
  31. package/dist/{chunk-hmae7ha6.js → chunk-4rxmxc1p.js} +2 -2
  32. package/dist/chunk-4tgn1frg.js +3 -0
  33. package/dist/chunk-5fg8hqq0.js +2 -0
  34. package/dist/chunk-5x0g7e9y.js +2 -0
  35. package/dist/{chunk-83ezv8yz.js → chunk-5yhv5eqq.js} +3 -3
  36. package/dist/{chunk-6n195hvc.js → chunk-61qh74q1.js} +5 -5
  37. package/dist/chunk-64pdwfef.js +177 -0
  38. package/dist/{chunk-mcynmrbe.js → chunk-6fz2n9w6.js} +43 -43
  39. package/dist/chunk-72ns4q88.js +2 -0
  40. package/dist/chunk-7fwcnech.js +2 -0
  41. package/dist/{chunk-x9haxcsj.js → chunk-7y1rpd4g.js} +8 -8
  42. package/dist/chunk-7z2mebp5.js +2 -0
  43. package/dist/chunk-803qm5tk.js +2 -0
  44. package/dist/chunk-86cg9qqm.js +2 -0
  45. package/dist/{chunk-gs6wc7sr.js → chunk-89801pjp.js} +5 -5
  46. package/dist/chunk-8h5mqs28.js +2 -0
  47. package/dist/chunk-8jh2b5k2.js +2 -0
  48. package/dist/{chunk-yp6w740k.js → chunk-8rk79ha1.js} +2 -2
  49. package/dist/{chunk-2x112fxs.js → chunk-8vs5y4h7.js} +14 -14
  50. package/dist/{chunk-kpr09x3g.js → chunk-8y54tpbr.js} +7 -7
  51. package/dist/{chunk-s4y26fk6.js → chunk-8yyq3nfg.js} +2 -2
  52. package/dist/chunk-927ta2dn.js +2 -0
  53. package/dist/chunk-940wny2b.js +2 -0
  54. package/dist/{chunk-93j4atq9.js → chunk-98t1cv8x.js} +2 -2
  55. package/dist/{chunk-sgm6tg8h.js → chunk-9k8ztdcc.js} +2 -2
  56. package/dist/{chunk-4npabwne.js → chunk-9nhyq39s.js} +3 -3
  57. package/dist/{chunk-gz38jt5j.js → chunk-aa1y9j3p.js} +2 -2
  58. package/dist/chunk-ad9dt9rk.js +2 -0
  59. package/dist/chunk-ak4w2emd.js +2 -0
  60. package/dist/{chunk-tb56j1zt.js → chunk-ak93e1zz.js} +5 -5
  61. package/dist/{chunk-jt28zh50.js → chunk-b0z2n941.js} +2 -2
  62. package/dist/{chunk-qwds327k.js → chunk-b51p56k5.js} +2 -2
  63. package/dist/{chunk-r4sawwmp.js → chunk-b7x8b83z.js} +1 -1
  64. package/dist/chunk-b8dtz3v8.js +2 -0
  65. package/dist/{chunk-0e9xdrzx.js → chunk-bjhesw78.js} +8 -8
  66. package/dist/{chunk-w8p1y4c0.js → chunk-bvctccab.js} +4 -4
  67. package/dist/chunk-c5tkxjb0.js +2 -0
  68. package/dist/{chunk-hk98vptc.js → chunk-cdcrd33m.js} +2 -2
  69. package/dist/chunk-cgh0k52q.js +2 -0
  70. package/dist/chunk-ctdw7fh4.js +2 -0
  71. package/dist/{chunk-asp7ett1.js → chunk-dnsf934e.js} +9 -9
  72. package/dist/{chunk-7r7j7vwt.js → chunk-ds6mbfdq.js} +3 -3
  73. package/dist/chunk-e2q79dfs.js +2 -0
  74. package/dist/chunk-e5vn76f5.js +2 -0
  75. package/dist/{chunk-9s1qnf90.js → chunk-eb6p3p62.js} +2 -2
  76. package/dist/chunk-emhbj3xd.js +2 -0
  77. package/dist/{chunk-3cn9y08d.js → chunk-evxp3wmv.js} +7 -7
  78. package/dist/{chunk-z8k3fx4r.js → chunk-f8p8ggvw.js} +4 -4
  79. package/dist/chunk-fjfrgef4.js +2 -0
  80. package/dist/chunk-fke4s0kk.js +33 -0
  81. package/dist/{chunk-0dkd26t4.js → chunk-frybxj35.js} +7 -7
  82. package/dist/{chunk-4s9kytdz.js → chunk-fxmc5006.js} +2 -2
  83. package/dist/chunk-fxnk5ee8.js +2 -0
  84. package/dist/chunk-fys1patf.js +2 -0
  85. package/dist/{chunk-6ts3sthp.js → chunk-g4k0svq6.js} +2 -2
  86. package/dist/chunk-g9efdc5v.js +2 -0
  87. package/dist/chunk-gpvfswgj.js +2 -0
  88. package/dist/chunk-hnen9b45.js +2 -0
  89. package/dist/chunk-jacb7aw1.js +2 -0
  90. package/dist/{chunk-4zw118tn.js → chunk-jgk5j35w.js} +4 -4
  91. package/dist/{chunk-geb6zyxg.js → chunk-jn78c13y.js} +13 -13
  92. package/dist/chunk-jq1698j4.js +2 -0
  93. package/dist/{chunk-pwmkhs7z.js → chunk-jyp2mmts.js} +2 -2
  94. package/dist/{chunk-76fcwbe1.js → chunk-jzajpmke.js} +7 -7
  95. package/dist/chunk-k0jkpw0q.js +2 -0
  96. package/dist/{chunk-3kfbs0mw.js → chunk-k2ex94n8.js} +1 -1
  97. package/dist/{chunk-m00c7sh0.js → chunk-k9247v28.js} +1 -1
  98. package/dist/chunk-kdqnest3.js +2 -0
  99. package/dist/{chunk-1mfj2j5g.js → chunk-kj9m0vc6.js} +3 -3
  100. package/dist/chunk-krsg6dgz.js +3 -0
  101. package/dist/chunk-m5740sd3.js +2 -0
  102. package/dist/{chunk-myynywry.js → chunk-mdvtermb.js} +2 -2
  103. package/dist/chunk-mebf9vwb.js +2 -0
  104. package/dist/chunk-nm2r4se1.js +2 -0
  105. package/dist/chunk-p2j38381.js +2 -0
  106. package/dist/{chunk-3ajnrfa2.js → chunk-p88yh4wt.js} +2 -2
  107. package/dist/{chunk-fjxhga6w.js → chunk-pqbxa0r7.js} +2 -2
  108. package/dist/chunk-q245q8z1.js +2 -0
  109. package/dist/{chunk-5q9ss7ty.js → chunk-q3azy64b.js} +4 -4
  110. package/dist/chunk-qm3jbse5.js +2 -0
  111. package/dist/{chunk-yftw25sa.js → chunk-qx0np0hy.js} +2 -2
  112. package/dist/{chunk-qwsgc5rc.js → chunk-qystt1qc.js} +1 -1
  113. package/dist/{chunk-v20cwjgz.js → chunk-qyzjkvme.js} +6 -6
  114. package/dist/chunk-r13fwtas.js +2 -0
  115. package/dist/{chunk-dh9aagwm.js → chunk-r1tp2gnr.js} +1 -1
  116. package/dist/chunk-r5tsewzd.js +2 -0
  117. package/dist/{chunk-v2egd4zh.js → chunk-r6yb0540.js} +5 -5
  118. package/dist/{chunk-pes27snj.js → chunk-r8zhed35.js} +3 -3
  119. package/dist/{chunk-hmydy949.js → chunk-rh2qth8r.js} +5 -5
  120. package/dist/chunk-rha8sv1h.js +3 -0
  121. package/dist/{chunk-vh1d5eqk.js → chunk-t2cq4bpe.js} +6 -6
  122. package/dist/chunk-tfy1m821.js +2 -0
  123. package/dist/{chunk-465resq9.js → chunk-tpfxvw4q.js} +17 -17
  124. package/dist/{chunk-t6qn1374.js → chunk-tshpcvcy.js} +2 -2
  125. package/dist/{chunk-spjpdymh.js → chunk-ttqs99jj.js} +2 -2
  126. package/dist/chunk-v1ff2dfp.js +7 -0
  127. package/dist/chunk-vc3ppphz.js +2 -0
  128. package/dist/{chunk-x1q2ape8.js → chunk-vv8dn70r.js} +14 -14
  129. package/dist/{chunk-06zn167b.js → chunk-vvs28yqw.js} +8 -8
  130. package/dist/chunk-w2pch5xn.js +4 -0
  131. package/dist/chunk-w512gnft.js +2 -0
  132. package/dist/{chunk-j4snweyz.js → chunk-wby7qzha.js} +3 -3
  133. package/dist/{chunk-b6g24qj0.js → chunk-wghtdgwj.js} +2 -2
  134. package/dist/chunk-wk8y89q2.js +25 -0
  135. package/dist/{chunk-19safa6y.js → chunk-wmnzapn8.js} +2 -2
  136. package/dist/chunk-wmxsaxt0.js +2 -0
  137. package/dist/chunk-wq1vs94k.js +2 -0
  138. package/dist/chunk-wwnqbv9j.js +3 -0
  139. package/dist/{chunk-a5d888es.js → chunk-wycrtkw4.js} +6 -6
  140. package/dist/chunk-x1q7b7jg.js +2 -0
  141. package/dist/chunk-x1x69g3s.js +2 -0
  142. package/dist/{chunk-gs373714.js → chunk-x5seqmrv.js} +2 -2
  143. package/dist/{chunk-r5jytt0f.js → chunk-x7q4tp3f.js} +4 -4
  144. package/dist/{chunk-bsq9zg9j.js → chunk-xt034729.js} +6 -6
  145. package/dist/chunk-y5emxzbt.js +2 -0
  146. package/dist/chunk-y6mqq78g.js +2 -0
  147. package/dist/{chunk-11kejz35.js → chunk-yh5658q8.js} +1 -1
  148. package/dist/chunk-yhbsvf65.js +54 -0
  149. package/dist/{chunk-00ns0516.js → chunk-yjzk7rwt.js} +6 -6
  150. package/dist/chunk-yn3kff5k.js +2 -0
  151. package/dist/chunk-ynjm2tm0.js +2 -0
  152. package/dist/chunk-yp80rx17.js +2 -0
  153. package/dist/chunk-z5xermzg.js +2 -0
  154. package/dist/{chunk-j04v4rgf.js → chunk-zhrz4zvw.js} +5 -5
  155. package/dist/cli.js +20 -20
  156. package/dist/composable-loader.d.ts +1 -1
  157. package/dist/composable-loader.js +47 -10
  158. package/dist/craft-entry.js +2 -2
  159. package/dist/craft.js +2 -2
  160. package/dist/message-catalogs.d.ts +39 -0
  161. package/dist/message-catalogs.js +128 -0
  162. package/dist/native/compiler/bundle.js +11 -36
  163. package/dist/native/compiler/html-to-ir.js +32 -0
  164. package/dist/native/compiler/render-screen.js +1 -1
  165. package/dist/native/compiler/setup-script.d.ts +1 -0
  166. package/dist/native/compiler/shared-scripts.js +10 -0
  167. package/dist/native/runtime/compact-document.d.ts +20 -0
  168. package/dist/native/runtime/compact-document.js +101 -0
  169. package/dist/process.d.ts +1 -1
  170. package/dist/process.js +87 -22
  171. package/dist/pwa.js +3 -3
  172. package/dist/ssg.js +14 -14
  173. package/dist/store-loader.d.ts +27 -3
  174. package/dist/store-loader.js +144 -4
  175. package/dist/types/config-types.d.ts +1 -0
  176. package/package.json +5 -5
  177. package/dist/chunk-055v5qz2.js +0 -2
  178. package/dist/chunk-0b7f2mby.js +0 -2
  179. package/dist/chunk-0j7e56zm.js +0 -2
  180. package/dist/chunk-0jn79fkt.js +0 -25
  181. package/dist/chunk-0y44f9rk.js +0 -2
  182. package/dist/chunk-3h2yz805.js +0 -2
  183. package/dist/chunk-3jfes9b0.js +0 -2
  184. package/dist/chunk-4m8bexrn.js +0 -33
  185. package/dist/chunk-4tz00fkp.js +0 -2
  186. package/dist/chunk-52q8184e.js +0 -2
  187. package/dist/chunk-59ytzyp1.js +0 -2
  188. package/dist/chunk-5ffdtfwg.js +0 -2
  189. package/dist/chunk-5q551m4w.js +0 -2
  190. package/dist/chunk-6ndeycxk.js +0 -2
  191. package/dist/chunk-6xt3kvq1.js +0 -2
  192. package/dist/chunk-75r09rqt.js +0 -2
  193. package/dist/chunk-79y41h1d.js +0 -2
  194. package/dist/chunk-7h5d35bf.js +0 -2
  195. package/dist/chunk-82ybmdqk.js +0 -2
  196. package/dist/chunk-8frs2dtp.js +0 -2
  197. package/dist/chunk-8n2gj4q2.js +0 -11
  198. package/dist/chunk-8prq9t3b.js +0 -2
  199. package/dist/chunk-8sxngenk.js +0 -2
  200. package/dist/chunk-90er677t.js +0 -2
  201. package/dist/chunk-aakkjjgr.js +0 -2
  202. package/dist/chunk-abs1k04e.js +0 -2
  203. package/dist/chunk-c05r0rzw.js +0 -3
  204. package/dist/chunk-c7yjhjr2.js +0 -2
  205. package/dist/chunk-cpep999n.js +0 -2
  206. package/dist/chunk-cvwn6mga.js +0 -2
  207. package/dist/chunk-davr7z73.js +0 -2
  208. package/dist/chunk-dqs4bgec.js +0 -2
  209. package/dist/chunk-e30kgg28.js +0 -2
  210. package/dist/chunk-e3fkq9gb.js +0 -2
  211. package/dist/chunk-eab8na0z.js +0 -2
  212. package/dist/chunk-exg7ry7b.js +0 -2
  213. package/dist/chunk-f4mmk2cx.js +0 -2
  214. package/dist/chunk-fhwn8j9p.js +0 -2
  215. package/dist/chunk-fj105fff.js +0 -2
  216. package/dist/chunk-g387j1qv.js +0 -2
  217. package/dist/chunk-gefpzry6.js +0 -2
  218. package/dist/chunk-ghzycypz.js +0 -2
  219. package/dist/chunk-gvaee1w0.js +0 -170
  220. package/dist/chunk-k37472gm.js +0 -2
  221. package/dist/chunk-k3wnmpt3.js +0 -2
  222. package/dist/chunk-kb8654dp.js +0 -4
  223. package/dist/chunk-kfqdx75m.js +0 -2
  224. package/dist/chunk-mgx71bfg.js +0 -2
  225. package/dist/chunk-mmhbn7xt.js +0 -2
  226. package/dist/chunk-mzcbfra0.js +0 -2
  227. package/dist/chunk-nv9dy71x.js +0 -54
  228. package/dist/chunk-ny2qzraq.js +0 -2
  229. package/dist/chunk-pg15tx9c.js +0 -2
  230. package/dist/chunk-ppc5s12t.js +0 -2
  231. package/dist/chunk-ptzzpf97.js +0 -2
  232. package/dist/chunk-qgsrxyh9.js +0 -2
  233. package/dist/chunk-qmxcs806.js +0 -2
  234. package/dist/chunk-qn4gt8sx.js +0 -3
  235. package/dist/chunk-qryg0hgn.js +0 -2
  236. package/dist/chunk-qt17792g.js +0 -2
  237. package/dist/chunk-qz9fzz5k.js +0 -2
  238. package/dist/chunk-rh90yh1c.js +0 -2
  239. package/dist/chunk-rvc0pb16.js +0 -2
  240. package/dist/chunk-sj5t0tnv.js +0 -2
  241. package/dist/chunk-t4mpq6t0.js +0 -3
  242. package/dist/chunk-tb6jcr2v.js +0 -2
  243. package/dist/chunk-tn40nh9e.js +0 -3
  244. package/dist/chunk-xcq41ah8.js +0 -2
  245. package/dist/chunk-y3jbkk7a.js +0 -2
  246. package/dist/chunk-yme43vbp.js +0 -2
  247. package/dist/chunk-yv8jeqdn.js +0 -2
  248. package/dist/chunk-zq7g0687.js +0 -2
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{ho,xa,Sa}from"./chunk-ztdjdxjt.js";import"./chunk-jevd16gq.js";import"./chunk-465resq9.js";import"./chunk-qwds327k.js";import"./chunk-89h4snzd.js";import"./chunk-m5fjhrpd.js";import"./chunk-gs373714.js";import"./chunk-b6g24qj0.js";import"./chunk-yp6w740k.js";import"./chunk-z8k3fx4r.js";import"./chunk-x1q2ape8.js";import"./chunk-3cn9y08d.js";import"./chunk-5q9ss7ty.js";import"./chunk-hmae7ha6.js";import"./chunk-x9haxcsj.js";import"./chunk-fpagqrd1.js";import"./chunk-0e9xdrzx.js";import"./chunk-nv9dy71x.js";import"./chunk-06zn167b.js";import"./chunk-0jn79fkt.js";import"./chunk-jt28zh50.js";import"./chunk-pes27snj.js";import{au,fa,eh,th,ga,mo,Gr,ma,ha,nh,rh,ya,ba,va,wa}from"./chunk-2x112fxs.js";import"./chunk-wp9y6x33.js";import"./chunk-qn4gt8sx.js";import"./chunk-sgm6tg8h.js";import"./chunk-0dkd26t4.js";import"./chunk-3kfbs0mw.js";import"./chunk-1mfj2j5g.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{yo,ga,ma}from"./chunk-319aez2f.js";import"./chunk-48g9wez2.js";import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import"./chunk-2cbd1ew6.js";import"./chunk-x5seqmrv.js";import"./chunk-wghtdgwj.js";import"./chunk-8rk79ha1.js";import"./chunk-f8p8ggvw.js";import"./chunk-vv8dn70r.js";import"./chunk-evxp3wmv.js";import"./chunk-q3azy64b.js";import"./chunk-4rxmxc1p.js";import"./chunk-7y1rpd4g.js";import"./chunk-23t9anc0.js";import"./chunk-bjhesw78.js";import"./chunk-yhbsvf65.js";import"./chunk-vvs28yqw.js";import"./chunk-wk8y89q2.js";import"./chunk-b0z2n941.js";import"./chunk-r8zhed35.js";import{cu,ha,lh,uh,ya,bo,Xr,ba,wa,dh,ph,va,xa,Sa,ka}from"./chunk-8vs5y4h7.js";import"./chunk-0q5dm9r2.js";import"./chunk-krsg6dgz.js";import"./chunk-9k8ztdcc.js";import"./chunk-frybxj35.js";import"./chunk-k2ex94n8.js";import"./chunk-kj9m0vc6.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{au as CRAFT_BRIDGE_SCRIPT,mo as CRAFT_COMPONENTS,ma as CRAFT_COMPONENT_RUNTIME,Gr as CRAFT_COMPONENT_STYLES,ho as NATIVE_COMPONENTS,ya as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,xa as compileToNative,Sa as createHotReloadServer,ba as findCraftBinary,fa as generateCraftBridgeScript,V as generateCraftOptimizations,wa as getAvailableFormats,va as getAvailableTargets,rh as getCraftComponents,G as getSSRCacheStats,ga as injectCraftBridge,eh as isCraftEnvironment,Y as prerenderForCraft,ha as processCraftComponents,th as processCraftDirective,nh 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{cu as CRAFT_BRIDGE_SCRIPT,bo as CRAFT_COMPONENTS,ba as CRAFT_COMPONENT_RUNTIME,Xr as CRAFT_COMPONENT_STYLES,yo as NATIVE_COMPONENTS,va as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ga as compileToNative,ma as createHotReloadServer,xa as findCraftBinary,ha as generateCraftBridgeScript,V as generateCraftOptimizations,ka as getAvailableFormats,Sa as getAvailableTargets,ph as getCraftComponents,G as getSSRCacheStats,ya as injectCraftBridge,lh as isCraftEnvironment,Y as prerenderForCraft,wa as processCraftComponents,uh as processCraftDirective,dh as registerCraftComponent,Q as renderSSR};
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{ho,xa,Sa}from"./chunk-ztdjdxjt.js";import"./chunk-jevd16gq.js";import"./chunk-465resq9.js";import"./chunk-qwds327k.js";import"./chunk-89h4snzd.js";import"./chunk-m5fjhrpd.js";import"./chunk-gs373714.js";import"./chunk-b6g24qj0.js";import"./chunk-yp6w740k.js";import"./chunk-z8k3fx4r.js";import"./chunk-x1q2ape8.js";import"./chunk-3cn9y08d.js";import"./chunk-5q9ss7ty.js";import"./chunk-hmae7ha6.js";import"./chunk-x9haxcsj.js";import"./chunk-fpagqrd1.js";import"./chunk-0e9xdrzx.js";import"./chunk-nv9dy71x.js";import"./chunk-06zn167b.js";import"./chunk-0jn79fkt.js";import"./chunk-jt28zh50.js";import"./chunk-pes27snj.js";import{au,fa,eh,th,ga,mo,Gr,ma,ha,nh,rh,ya,ba,va,wa}from"./chunk-2x112fxs.js";import"./chunk-wp9y6x33.js";import"./chunk-qn4gt8sx.js";import"./chunk-sgm6tg8h.js";import"./chunk-0dkd26t4.js";import"./chunk-3kfbs0mw.js";import"./chunk-1mfj2j5g.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{yo,ga,ma}from"./chunk-319aez2f.js";import"./chunk-48g9wez2.js";import"./chunk-tpfxvw4q.js";import"./chunk-b51p56k5.js";import"./chunk-4833k99b.js";import"./chunk-2cbd1ew6.js";import"./chunk-x5seqmrv.js";import"./chunk-wghtdgwj.js";import"./chunk-8rk79ha1.js";import"./chunk-f8p8ggvw.js";import"./chunk-vv8dn70r.js";import"./chunk-evxp3wmv.js";import"./chunk-q3azy64b.js";import"./chunk-4rxmxc1p.js";import"./chunk-7y1rpd4g.js";import"./chunk-23t9anc0.js";import"./chunk-bjhesw78.js";import"./chunk-yhbsvf65.js";import"./chunk-vvs28yqw.js";import"./chunk-wk8y89q2.js";import"./chunk-b0z2n941.js";import"./chunk-r8zhed35.js";import{cu,ha,lh,uh,ya,bo,Xr,ba,wa,dh,ph,va,xa,Sa,ka}from"./chunk-8vs5y4h7.js";import"./chunk-0q5dm9r2.js";import"./chunk-krsg6dgz.js";import"./chunk-9k8ztdcc.js";import"./chunk-frybxj35.js";import"./chunk-k2ex94n8.js";import"./chunk-kj9m0vc6.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{au as CRAFT_BRIDGE_SCRIPT,mo as CRAFT_COMPONENTS,ma as CRAFT_COMPONENT_RUNTIME,Gr as CRAFT_COMPONENT_STYLES,ho as NATIVE_COMPONENTS,ya as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,xa as compileToNative,Sa as createHotReloadServer,ba as findCraftBinary,fa as generateCraftBridgeScript,V as generateCraftOptimizations,wa as getAvailableFormats,va as getAvailableTargets,rh as getCraftComponents,G as getSSRCacheStats,ga as injectCraftBridge,eh as isCraftEnvironment,Y as prerenderForCraft,ha as processCraftComponents,th as processCraftDirective,nh 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{cu as CRAFT_BRIDGE_SCRIPT,bo as CRAFT_COMPONENTS,ba as CRAFT_COMPONENT_RUNTIME,Xr as CRAFT_COMPONENT_STYLES,yo as NATIVE_COMPONENTS,va as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ga as compileToNative,ma as createHotReloadServer,xa as findCraftBinary,ha as generateCraftBridgeScript,V as generateCraftOptimizations,ka as getAvailableFormats,Sa as getAvailableTargets,ph as getCraftComponents,G as getSSRCacheStats,ya as injectCraftBridge,lh as isCraftEnvironment,Y as prerenderForCraft,wa as processCraftComponents,uh as processCraftDirective,dh as registerCraftComponent,Q as renderSSR};
@@ -0,0 +1,39 @@
1
+ /** Read every language's message modules, at build time. */
2
+ export declare function collectMessageCatalogs(root: string, options: MessageCatalogsOptions): Promise<CollectedMessages>;
3
+ /**
4
+ * Whether web pages ship messages a language at a time: with the `messages`
5
+ * option, in production. `STX_PAGE_MESSAGES=0` turns it off; `=1` turns it
6
+ * on outside production too (a development server re-reads a catalog only
7
+ * when it restarts, so it is off there by default).
8
+ */
9
+ export declare function pageMessagesEnabled(options: { messages?: PageMessagesOptions }, env?: Record<string, string | undefined>): boolean;
10
+ /** The app's message catalogs, read once per version of the language directories. */
11
+ export declare function loadPageMessages(root: string, options: PageMessagesOptions): Promise<PageMessages>;
12
+ /** The areas built code imports messages for (its stubs' keys), whatever the language. */
13
+ export declare function messageAreasIn(...codes: Array<string | null | undefined>): Set<string>;
14
+ /**
15
+ * The languages a page ships: the one `<html lang>` names and the fallback.
16
+ * Every language when the page names none of them, since nothing then says
17
+ * which one its scripts will read.
18
+ */
19
+ export declare function pageLanguages(html: string, messages: Pick<PageMessages, 'languages' | 'fallback'>): string[];
20
+ export declare function pageMessagesScript(messages: PageMessages, languages: string[], areas: Iterable<string>): string | null;
21
+ /** Where an app keeps its messages, a directory per language. */
22
+ export declare interface MessageCatalogsOptions {
23
+ dir: string
24
+ languages: string[]
25
+ }
26
+ /** The web pages' `messages` option. */
27
+ export declare interface PageMessagesOptions extends MessageCatalogsOptions {
28
+ fallback?: string
29
+ }
30
+ export declare interface CollectedMessages {
31
+ files: Map<string, { language: string, area: string }>
32
+ data: Map<string, Map<string, string>>
33
+ }
34
+ /** A collection, with the stub for every message module (by path as written and as Bun resolves it). */
35
+ export declare interface PageMessages extends CollectedMessages {
36
+ stubs: Map<string, string>
37
+ languages: string[]
38
+ fallback: string
39
+ }
@@ -0,0 +1,128 @@
1
+ import { existsSync, realpathSync, statSync } from "node:fs";
2
+ import path from "node:path";
3
+ import process from "node:process";
4
+ const MESSAGE_AREA = /^[\w-]+(?:\/[\w-]+)*$/, MESSAGE_LANGUAGE = /^[\w-]+$/;
5
+ export async function collectMessageCatalogs(root, options) {
6
+ const dir = path.resolve(root, options.dir);
7
+ if (!options.languages?.length)
8
+ throw Error("messages.languages must name at least one language");
9
+ const files = new Map, data = new Map;
10
+ for (const language of options.languages) {
11
+ if (!MESSAGE_LANGUAGE.test(language))
12
+ throw Error(`messages: "${language}" is not a language directory name`);
13
+ const base = path.join(dir, language);
14
+ if (!existsSync(base))
15
+ throw Error(`messages: ${path.relative(root, base)} does not exist`);
16
+ const areas = new Map;
17
+ for (const relative of [...new Bun.Glob("**/*.{ts,js,mjs,json}").scanSync({ cwd: base })].sort()) {
18
+ if (/\.(?:test|spec|d)\.[^.]+$/.test(relative))
19
+ continue;
20
+ const area = relative.replace(/\.[^./]+$/, "").split(path.sep).join("/");
21
+ if (!MESSAGE_AREA.test(area))
22
+ throw Error(`messages: ${language}/${relative} is not an area name`);
23
+ if (areas.has(area))
24
+ throw Error(`messages: ${language}/${area} is defined twice`);
25
+ const file = path.join(base, relative), module = await import(file), others = Object.keys(module).filter((name) => name !== "default");
26
+ if (others.length)
27
+ throw Error(`messages: ${language}/${relative} exports ${others.join(", ")}; a message module exports its messages as default, and nothing else`);
28
+ const value = module.default, json = value !== null && typeof value === "object" && !Array.isArray(value) ? JSON.stringify(value) : void 0;
29
+ if (json === void 0 || !Bun.deepEquals(JSON.parse(json), value, !0))
30
+ throw Error(`messages: ${language}/${relative} must export plain data (an object JSON can hold) as default`);
31
+ areas.set(area, json);
32
+ files.set(file, { language, area });
33
+ }
34
+ data.set(language, areas);
35
+ }
36
+ return { files, data };
37
+ }
38
+ function messagesKey(language, area) {
39
+ return `stx-messages:${language}:${area}`;
40
+ }
41
+ function pageMessagesStub(language, area) {
42
+ const key = JSON.stringify(messagesKey(language, area));
43
+ return `var kept = globalThis.__stxMessages || (globalThis.__stxMessages = {});
44
+ export default kept[${key}] || (kept[${key}] = {});`;
45
+ }
46
+ const collected = new Map;
47
+ export function pageMessagesEnabled(options, env = process.env) {
48
+ if (!options.messages || env.STX_PAGE_MESSAGES === "0")
49
+ return !1;
50
+ return env.STX_PAGE_MESSAGES === "1" || env.NODE_ENV === "production";
51
+ }
52
+ export async function loadPageMessages(root, options) {
53
+ const dir = path.resolve(root, options.dir), signature = options.languages.map((language) => {
54
+ try {
55
+ return `${language}:${statSync(path.join(dir, language)).mtimeMs}`;
56
+ } catch {
57
+ return `${language}:-`;
58
+ }
59
+ }).join("|"), cacheKey = `${dir}\x00${options.languages.join(",")}\x00${options.fallback ?? ""}`, cached = collected.get(cacheKey);
60
+ if (cached && cached.signature === signature)
61
+ return cached.messages;
62
+ const catalogs = await collectMessageCatalogs(root, options), stubs = new Map;
63
+ for (const [file, { language, area }] of catalogs.files) {
64
+ const stub = pageMessagesStub(language, area), names = [file];
65
+ try {
66
+ names.push(realpathSync(file));
67
+ } catch {}
68
+ for (const named of [...names])
69
+ if (named.startsWith("/private/"))
70
+ names.push(named.slice(8));
71
+ for (const named of names)
72
+ stubs.set(named, stub);
73
+ }
74
+ const fallback = options.fallback ?? options.languages[0];
75
+ if (!options.languages.includes(fallback))
76
+ throw Error(`messages.fallback "${fallback}" is not one of messages.languages`);
77
+ const messages = { ...catalogs, stubs, languages: [...options.languages], fallback };
78
+ collected.set(cacheKey, { signature, messages });
79
+ return messages;
80
+ }
81
+ export function messageAreasIn(...codes) {
82
+ const areas = new Set;
83
+ for (const code of codes) {
84
+ if (!code || !code.includes("stx-messages:"))
85
+ continue;
86
+ for (const match of code.matchAll(/stx-messages:[\w-]+:([\w/-]+)/g))
87
+ areas.add(match[1]);
88
+ }
89
+ return areas;
90
+ }
91
+ export function pageLanguages(html, messages) {
92
+ const htmlTag = /<html\b[^>]*>/i.exec(html)?.[0] ?? "", lang = /\slang\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(htmlTag), value = (lang ? lang[1] ?? lang[2] ?? lang[3] ?? "" : "").trim().toLowerCase(), known = new Map(messages.languages.map((language) => [language.toLowerCase(), language])), language = known.get(value) ?? known.get(value.split(/[-_]/)[0] ?? "");
93
+ if (!language)
94
+ return [...messages.languages];
95
+ return [...new Set([language, messages.fallback])];
96
+ }
97
+ const scripts = new WeakMap;
98
+ export function pageMessagesScript(messages, languages, areas) {
99
+ const wanted = [...areas].sort();
100
+ let built = scripts.get(messages);
101
+ if (!built)
102
+ scripts.set(messages, built = new Map);
103
+ const key = `${languages.join(",")}\x00${wanted.join(",")}`;
104
+ if (built.has(key))
105
+ return built.get(key);
106
+ const code = buildPageMessagesScript(messages, languages, wanted);
107
+ built.set(key, code);
108
+ return code;
109
+ }
110
+ function buildPageMessagesScript(messages, languages, wanted) {
111
+ const puts = [];
112
+ for (const language of languages) {
113
+ const catalog = messages.data.get(language);
114
+ if (!catalog)
115
+ continue;
116
+ for (const area of wanted) {
117
+ const json = catalog.get(area);
118
+ if (json !== void 0)
119
+ puts.push(`put(${JSON.stringify(messagesKey(language, area))},${JSON.stringify(json)})`);
120
+ }
121
+ }
122
+ if (puts.length === 0)
123
+ return null;
124
+ return `;(function(){var kept=globalThis.__stxMessages||(globalThis.__stxMessages={}),filled=globalThis.__stxMessagesFilled||(globalThis.__stxMessagesFilled={});function put(key,json){if(filled[key])return;filled[key]=1;var into=kept[key]||(kept[key]={}),data=JSON.parse(json);for(var name in data)into[name]=data[name]}
125
+ ${puts.join(`;
126
+ `)};
127
+ })();`;
128
+ }
@@ -5,7 +5,9 @@ import { nativeStyleConfigFrom, withNativeStyleConfig } from "./style-config.js"
5
5
  import { NATIVE_APP_ROUTE } from "../runtime/shared-screen.js";
6
6
  import { generateSignalsRuntime } from "../../signals.js";
7
7
  import { withModuleSubstitutes } from "../../client-script-bundler.js";
8
+ import { collectMessageCatalogs } from "../../message-catalogs.js";
8
9
  import { shareComponentScripts } from "./shared-scripts.js";
10
+ import { compactDocument, compactManifest } from "../runtime/compact-document.js";
9
11
  import { buildSharedModuleRegistries, registeredModuleIdsIn, registeredModuleNamesIn } from "../../client-module-registry.js";
10
12
  export async function projectStyleConfig(root) {
11
13
  try {
@@ -49,39 +51,8 @@ ${messages}`);
49
51
  }
50
52
  return (await result.outputs[0].text()).trim();
51
53
  }
52
- const MESSAGE_AREA = /^[\w-]+(?:\/[\w-]+)*$/, MESSAGE_LANGUAGE = /^[\w-]+$/;
53
- async function collectMessages(root, options) {
54
- const dir = path.resolve(root, options.dir);
55
- if (!options.languages?.length)
56
- throw Error("messages.languages must name at least one language");
57
- const files = new Map, data = new Map;
58
- for (const language of options.languages) {
59
- if (!MESSAGE_LANGUAGE.test(language))
60
- throw Error(`messages: "${language}" is not a language directory name`);
61
- const base = path.join(dir, language);
62
- if (!existsSync(base))
63
- throw Error(`messages: ${path.relative(root, base)} does not exist`);
64
- const areas = new Map;
65
- for (const relative of [...new Bun.Glob("**/*.{ts,js,mjs,json}").scanSync({ cwd: base })].sort()) {
66
- if (/\.(?:test|spec|d)\.[^.]+$/.test(relative))
67
- continue;
68
- const area = relative.replace(/\.[^./]+$/, "").split(path.sep).join("/");
69
- if (!MESSAGE_AREA.test(area))
70
- throw Error(`messages: ${language}/${relative} is not an area name`);
71
- if (areas.has(area))
72
- throw Error(`messages: ${language}/${area} is defined twice`);
73
- const file = path.join(base, relative), module = await import(file), others = Object.keys(module).filter((name) => name !== "default");
74
- if (others.length)
75
- throw Error(`messages: ${language}/${relative} exports ${others.join(", ")}; a message module exports its messages as default, and nothing else`);
76
- const value = module.default, json = value !== null && typeof value === "object" && !Array.isArray(value) ? JSON.stringify(value) : void 0;
77
- if (json === void 0 || !Bun.deepEquals(JSON.parse(json), value, !0))
78
- throw Error(`messages: ${language}/${relative} must export plain data (an object JSON can hold) as default`);
79
- areas.set(area, json);
80
- files.set(file, { language, area });
81
- }
82
- data.set(language, areas);
83
- }
84
- return { files, data };
54
+ function collectMessages(root, options) {
55
+ return collectMessageCatalogs(root, options);
85
56
  }
86
57
  function messagesStub(language, area) {
87
58
  return `export default globalThis.__stxNativeRuntime.messages(${JSON.stringify(language)}, ${JSON.stringify(area)});`;
@@ -204,12 +175,12 @@ var isApp = ${appFile ? `routeName === ${JSON.stringify(NATIVE_APP_ROUTE)}` : "f
204
175
  if (!isApp && routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));
205
176
  if (isApp ? ${!withApp} : ${JSON.stringify(bundled.map(({ name }) => name))}.indexOf(routeName) === -1) throw new Error(['This bundle does not hold the native screen', routeName].join(' '));` : `var routeName = 'main';
206
177
  var isApp = false;`, selections = bundled.map(({ name, compiled }, index) => {
207
- const sheet = runtimeVersion ? sharedSheets.screens.get(name) : void 0, document = runtimeDocument(sheet ? withoutStylesheet(compiled.document) : compiled.document, root);
178
+ const sheet = runtimeVersion ? sharedSheets.screens.get(name) : void 0, document = runtimeDocument(sheet ? withoutStylesheet(compiled.document) : compiled.document, root), compactDoc = runtimeVersion ? compactDocument(document) : null, compactBindings = runtimeVersion ? compactManifest(compiled.manifest) : null;
208
179
  return `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
209
- nativeDocument = ${JSON.stringify(document)};${sheet ? `
180
+ nativeDocument = ${compactDoc ? `runtime.document(${JSON.stringify(compactDoc)})` : JSON.stringify(document)};${sheet ? `
210
181
  nativeDocument.root._stylesheetRules = runtime.stylesheetRules(${JSON.stringify(sheet.order)}, ${JSON.stringify(sheet.own)});${sheet.theme ? `
211
182
  nativeDocument.root._stylesheetTheme = runtime.themes[${JSON.stringify(sheet.theme)}];` : ""}` : ""}
212
- manifest = ${JSON.stringify(compiled.manifest)};
183
+ manifest = ${compactBindings ? `runtime.manifest(${JSON.stringify(compactBindings)})` : JSON.stringify(compiled.manifest)};
213
184
  }`;
214
185
  }).join(`
215
186
  `), setups = bundled.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
@@ -301,6 +272,7 @@ g.addEventListener('pagehide', function(event) { if (!event.persisted) g.__stxNa
301
272
  const prelude = `
302
273
  import { installJSCGlobals } from ${JSON.stringify(runtimeGlobals)};
303
274
  import { prepareNativeApp, prepareSharedNativeScreen } from ${JSON.stringify(sharedScreen)};
275
+ ${options.sharedRuntime ? `import { expandDocument, expandManifest } from ${JSON.stringify(nativeRuntimeModule("compact-document"))};` : "var expandDocument = null, expandManifest = null;"}
304
276
  globalThis.__stxNativeRuntime = {
305
277
  version: '__STX_NATIVE_RUNTIME_VERSION__',
306
278
  // What every route of this build shares, held once instead of in each
@@ -331,6 +303,9 @@ ${JSON.stringify(hash)}: ${body}`).join(",") : ""}},
331
303
  var runtime = this;
332
304
  return (loaded[name] = this.chunks[name](function(chunk) { return runtime.chunk(chunk); }));
333
305
  },
306
+ // A route's document and binding manifest, as compact as it carries them (compact-document.ts).
307
+ document: expandDocument,
308
+ manifest: expandManifest,
334
309
  installJSCGlobals: installJSCGlobals,
335
310
  prepareNativeApp: prepareNativeApp,
336
311
  prepareSharedNativeScreen: prepareSharedNativeScreen,
@@ -592,7 +592,39 @@ export async function translateHtmlToDocument(html, options = {}) {
592
592
  diagnostics
593
593
  };
594
594
  }
595
+ function removeSelfClosedExcludedTags(html) {
596
+ let out = "", last = 0;
597
+ for (let start = html.indexOf("<");start !== -1; start = html.indexOf("<", start + 1)) {
598
+ if (!/[a-z]/i.test(html[start + 1] ?? ""))
599
+ continue;
600
+ let end = start + 1, quote = "";
601
+ for (;end < html.length; end++) {
602
+ const char = html[end];
603
+ if (quote) {
604
+ if (char === quote)
605
+ quote = "";
606
+ continue;
607
+ }
608
+ if (char === '"' || char === "'")
609
+ quote = char;
610
+ else if (char === ">" || char === "<")
611
+ break;
612
+ }
613
+ if (html[end] !== ">" || html[end - 1] !== "/")
614
+ continue;
615
+ const unquoted = html.slice(start, end + 1).replace(/"[^"]*"|'[^']*'/g, '""');
616
+ if (!/\sdata-native-exclude(?=[\s=/>])/i.test(unquoted))
617
+ continue;
618
+ out += html.slice(last, start);
619
+ last = end + 1;
620
+ start = end;
621
+ }
622
+ return last ? out + html.slice(last) : html;
623
+ }
595
624
  export async function excludeNativeSubtrees(html) {
625
+ if (!/\bdata-native-exclude\b/i.test(html))
626
+ return html;
627
+ html = removeSelfClosedExcludedTags(html);
596
628
  if (!/\bdata-native-exclude\b/i.test(html))
597
629
  return html;
598
630
  return new HTMLRewriter().on("[data-native-exclude]", { element(element) {
@@ -72,7 +72,7 @@ export async function compileScreenSource(source, filePath, options = {}) {
72
72
  if (stores.stores.join() === kept)
73
73
  break;
74
74
  kept = stores.stores.join();
75
- scripts.splice(0, scripts.length, { code: stores.code }, ...own);
75
+ scripts.splice(0, scripts.length, { code: stores.code, ...stores.functions ? { stores: stores.functions } : {} }, ...own);
76
76
  for (const file of new Bun.Glob("*.ts").scanSync({ cwd: config.storesDir, absolute: !0 }))
77
77
  dependencies.add(file);
78
78
  modules = await registry();
@@ -11,4 +11,5 @@ export declare interface NativeClientScript {
11
11
  code: string
12
12
  owner?: string
13
13
  registry?: boolean
14
+ stores?: string[]
14
15
  }
@@ -51,6 +51,8 @@ export function shareComponentScripts(screens) {
51
51
  const component = componentOf(script);
52
52
  if (component)
53
53
  count(name, component.body);
54
+ for (const store of script.stores ?? [])
55
+ count(name, store);
54
56
  }
55
57
  const bodies = new Map, result = new Map;
56
58
  for (const { name, scripts } of screens)
@@ -72,6 +74,14 @@ export function shareComponentScripts(screens) {
72
74
  })();`
73
75
  };
74
76
  }
77
+ if (script.stores?.some(common)) {
78
+ for (const store of script.stores.filter(common))
79
+ bodies.set(keyOf(store), store);
80
+ return { code: `;(function() {
81
+ ${script.stores.map((store) => common(store) ? `runtime.components[${JSON.stringify(keyOf(store))}]();` : `(${store})();`).join(`
82
+ `)}
83
+ })();` };
84
+ }
75
85
  const component = componentOf(script);
76
86
  if (component && common(component.body)) {
77
87
  bodies.set(keyOf(component.body), component.body);
@@ -0,0 +1,20 @@
1
+ import type { BindingManifest, Binding } from '../../binding-manifest';
2
+ import type { STXDocument } from '../compiler/ir';
3
+ /** The kind a binding's name gives it, which a compact binding leaves out. */
4
+ export declare function kindOfBindingName(name: string): Binding['kind'];
5
+ /** The document without the fields every node has empty; null for one this form cannot hold. */
6
+ export declare function compactDocument(document: STXDocument): unknown;
7
+ /** A compact document as the screen reads it. It is changed in place. */
8
+ export declare function expandDocument<T>(document: T): T;
9
+ /**
10
+ * Each entry as `[id, bindings, template?]`, each binding as `[name, value, kind?]`;
11
+ * null for a manifest with anything else in it, which goes as it is.
12
+ */
13
+ export declare function compactManifest(manifest: BindingManifest): unknown;
14
+ /** A compact manifest as the screen reads it. */
15
+ export declare function expandManifest(compact: unknown): BindingManifest;
16
+ declare type CompactBinding = [name: string, value: string, kind?: string];
17
+ declare type CompactEntry = [id: number, bindings: CompactBinding[], template?: 1];
18
+ declare class NotCompactable extends Error {
19
+
20
+ }
@@ -0,0 +1,101 @@
1
+ const NODE_DEFAULTS = [
2
+ ["props", () => ({})],
3
+ ["style", () => ({})],
4
+ ["events", () => ({})],
5
+ ["children", () => []],
6
+ ["_inlineStyle", () => ({})],
7
+ ["_styleSource", () => ""]
8
+ ], ABSENT = "~", BOUND_KINDS = new Set(["text", "html", "show", "if", "for", "model", "class", "style", "ref"]);
9
+ export function kindOfBindingName(name) {
10
+ if (name.startsWith("@"))
11
+ return "event";
12
+ if (name.startsWith(":") && BOUND_KINDS.has(name.slice(1)))
13
+ return name.slice(1);
14
+ return "attr";
15
+ }
16
+ function isEmpty(value, fallback) {
17
+ if (typeof fallback === "string")
18
+ return value === "";
19
+ if (Array.isArray(fallback))
20
+ return Array.isArray(value) && value.length === 0;
21
+ return !!value && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype && Object.keys(value).length === 0;
22
+ }
23
+
24
+ class NotCompactable extends Error {
25
+ }
26
+ function compactNode(node) {
27
+ const out = { ...node };
28
+ if (Object.prototype.hasOwnProperty.call(out, ABSENT))
29
+ throw new NotCompactable;
30
+ let absent = 0;
31
+ NODE_DEFAULTS.forEach(([key, make], bit) => {
32
+ if (!Object.prototype.hasOwnProperty.call(out, key))
33
+ absent |= 1 << bit;
34
+ else if (isEmpty(out[key], make()))
35
+ delete out[key];
36
+ });
37
+ if (Array.isArray(out.children))
38
+ out.children = out.children.map((child) => typeof child === "string" ? child : compactNode(child));
39
+ if (absent)
40
+ out[ABSENT] = absent;
41
+ return out;
42
+ }
43
+ function expandNode(node) {
44
+ const absent = node[ABSENT] ?? 0;
45
+ delete node[ABSENT];
46
+ for (let bit = 0;bit < NODE_DEFAULTS.length; bit++) {
47
+ const [key, make] = NODE_DEFAULTS[bit];
48
+ if (!(absent & 1 << bit) && !Object.prototype.hasOwnProperty.call(node, key))
49
+ node[key] = make();
50
+ }
51
+ const children = node.children;
52
+ if (Array.isArray(children)) {
53
+ for (const child of children)
54
+ if (child && typeof child === "object")
55
+ expandNode(child);
56
+ }
57
+ }
58
+ export function compactDocument(document) {
59
+ try {
60
+ return { ...document, root: compactNode(document.root) };
61
+ } catch (error) {
62
+ if (error instanceof NotCompactable)
63
+ return null;
64
+ throw error;
65
+ }
66
+ }
67
+ export function expandDocument(document) {
68
+ expandNode(document.root);
69
+ return document;
70
+ }
71
+ const BINDING_KEYS = ["kind", "name", "value"].join();
72
+ export function compactManifest(manifest) {
73
+ if (Object.keys(manifest).some((key) => key !== "entries"))
74
+ return null;
75
+ const entries = [];
76
+ for (const entry of manifest.entries) {
77
+ if (Object.keys(entry).some((key) => key !== "id" && key !== "bindings" && !(key === "template" && entry.template === !0)))
78
+ return null;
79
+ const bindings = [];
80
+ for (const binding of entry.bindings) {
81
+ if (Object.keys(binding).sort().join() !== BINDING_KEYS || typeof binding.value !== "string")
82
+ return null;
83
+ bindings.push(binding.kind === kindOfBindingName(binding.name) ? [binding.name, binding.value] : [binding.name, binding.value, binding.kind]);
84
+ }
85
+ entries.push(entry.template ? [entry.id, bindings, 1] : [entry.id, bindings]);
86
+ }
87
+ return entries;
88
+ }
89
+ export function expandManifest(compact) {
90
+ return {
91
+ entries: compact.map((item) => {
92
+ const entry = {
93
+ id: item[0],
94
+ bindings: item[1].map((binding) => ({ name: binding[0], value: binding[1], kind: binding[2] ?? kindOfBindingName(binding[0]) }))
95
+ };
96
+ if (item[2])
97
+ entry.template = !0;
98
+ return entry;
99
+ })
100
+ };
101
+ }
package/dist/process.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { processJsonDirective, processOnceDirective } from './misc-directives';
2
2
  import { validateClientScript } from './script-validation';
3
3
  import type { StxOptions } from './types';
4
- export declare function buildModulesTag(sources: Array<string | null>, options: StxOptions, dependencies?: Set<string>): Promise<string | null>;
4
+ export declare function buildModulesTag(sources: Array<string | null>, options: StxOptions, dependencies?: Set<string>, built?: { code?: string, inputs?: string[] }): Promise<string | null>;
5
5
  export declare function processDirectives(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
6
6
  // Re-export public API from extracted modules (preserves backwards compatibility)
7
7
  export { injectRouterScript } from './runtime-injection';