@stacksjs/stx 0.2.412 → 0.2.414

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 (350) hide show
  1. package/dist/appearance-bootstrap.js +1 -1
  2. package/dist/binding-manifest.d.ts +1 -1
  3. package/dist/builtins/image-delivery.d.ts +38 -0
  4. package/dist/builtins/image-delivery.js +17 -0
  5. package/dist/builtins/stx-image.js +1 -5
  6. package/dist/bundle-analyzer.js +20 -20
  7. package/dist/chunk-020xyn9q.js +3 -0
  8. package/dist/chunk-04jhmfbz.js +2 -0
  9. package/dist/chunk-10957mcb.js +2 -0
  10. package/dist/chunk-1098mas0.js +2 -0
  11. package/dist/chunk-169n1vpx.js +12 -0
  12. package/dist/chunk-1b6t12hd.js +2 -0
  13. package/dist/chunk-1chw8xsw.js +2 -0
  14. package/dist/chunk-1xdzcy9d.js +14 -0
  15. package/dist/chunk-2ce7f416.js +2 -0
  16. package/dist/chunk-2gr351s0.js +7 -0
  17. package/dist/chunk-2mkcjw08.js +2 -0
  18. package/dist/chunk-2v8wztd5.js +2 -0
  19. package/dist/chunk-340a824p.js +2 -0
  20. package/dist/chunk-39g1134q.js +2 -0
  21. package/dist/chunk-3c74vag1.js +2 -0
  22. package/dist/chunk-3kthfs03.js +3 -0
  23. package/dist/chunk-3qn1wcdg.js +2 -0
  24. package/dist/chunk-3s2vnqcf.js +2 -0
  25. package/dist/chunk-48bwk47q.js +2 -0
  26. package/dist/chunk-4bjravgk.js +2 -0
  27. package/dist/chunk-4jjme6a5.js +2 -0
  28. package/dist/chunk-5g3y8kym.js +2 -0
  29. package/dist/chunk-5gsxpaqk.js +2 -0
  30. package/dist/{chunk-bwsxym3d.js → chunk-5qns2sdz.js} +17 -17
  31. package/dist/chunk-69mc2np8.js +2785 -0
  32. package/dist/chunk-6cfa3g0r.js +2 -0
  33. package/dist/{chunk-bjar18jd.js → chunk-6h38kkjf.js} +46 -52
  34. package/dist/chunk-6hc5vz20.js +3 -0
  35. package/dist/chunk-6q6g76vg.js +499 -0
  36. package/dist/{chunk-dbc5awz9.js → chunk-6sgswrqw.js} +29 -29
  37. package/dist/chunk-6y8hnymb.js +2 -0
  38. package/dist/chunk-74j18qk0.js +930 -0
  39. package/dist/chunk-752hw7cd.js +4 -0
  40. package/dist/{chunk-t5ja7qkn.js → chunk-765e1s44.js} +11 -76
  41. package/dist/chunk-7gkv67ky.js +4 -0
  42. package/dist/chunk-7z2ra0yf.js +2 -0
  43. package/dist/chunk-866n724v.js +2 -0
  44. package/dist/chunk-8nhshfz6.js +5 -0
  45. package/dist/chunk-92ps1xpk.js +2 -0
  46. package/dist/chunk-9g27ybyr.js +3 -0
  47. package/dist/{chunk-xq1acw1r.js → chunk-9pt8fd2n.js} +13 -13
  48. package/dist/{chunk-qvnbnsv9.js → chunk-9vrja6vp.js} +4 -4
  49. package/dist/chunk-9xrbve19.js +2 -0
  50. package/dist/chunk-a688m6js.js +3 -0
  51. package/dist/chunk-afhxw2t8.js +2 -0
  52. package/dist/chunk-ak1cgcah.js +5 -0
  53. package/dist/{chunk-4m7ajama.js → chunk-amd6ey3t.js} +14 -14
  54. package/dist/chunk-apg16xcn.js +2 -0
  55. package/dist/chunk-b52s5z0c.js +2 -0
  56. package/dist/chunk-b84h16er.js +61 -0
  57. package/dist/{chunk-hx998w7n.js → chunk-bay9s6rs.js} +13 -13
  58. package/dist/chunk-bmt7w2pk.js +2 -0
  59. package/dist/chunk-btmhj5t7.js +2 -0
  60. package/dist/chunk-ce1sejr3.js +3 -0
  61. package/dist/chunk-cg8hg6cs.js +3 -0
  62. package/dist/{chunk-8wp64mym.js → chunk-czxt605c.js} +4 -5
  63. package/dist/chunk-d44b9ktb.js +4 -0
  64. package/dist/chunk-daz5aqcf.js +24 -0
  65. package/dist/chunk-dgdm3hy3.js +2 -0
  66. package/dist/chunk-dvgv8nry.js +11 -0
  67. package/dist/chunk-dx7n22ed.js +2 -0
  68. package/dist/chunk-e57rhf65.js +3 -0
  69. package/dist/chunk-eed4fwps.js +3 -0
  70. package/dist/chunk-ej9j6k1q.js +3 -0
  71. package/dist/chunk-et0rr8c7.js +3 -0
  72. package/dist/chunk-f46qsp4m.js +4 -0
  73. package/dist/chunk-f6az0xj5.js +2 -0
  74. package/dist/{chunk-bjcsc6wx.js → chunk-fh1qrp68.js} +21 -21
  75. package/dist/chunk-fjs0a8h7.js +2 -0
  76. package/dist/chunk-fr2txj8q.js +829 -0
  77. package/dist/{chunk-vx86cf4r.js → chunk-ft4p6d28.js} +14 -14
  78. package/dist/chunk-fyzajkrx.js +2 -0
  79. package/dist/chunk-fzapbw9p.js +3 -0
  80. package/dist/chunk-g578mcb0.js +194 -0
  81. package/dist/chunk-gawrg4gb.js +216 -0
  82. package/dist/chunk-gw07qmjk.js +2 -0
  83. package/dist/chunk-h0atqq82.js +32 -0
  84. package/dist/chunk-h6zsqb9r.js +3 -0
  85. package/dist/{chunk-hdysywd8.js → chunk-h85hrwkq.js} +13 -13
  86. package/dist/chunk-hbxz85wy.js +2 -0
  87. package/dist/chunk-hjg3ndgh.js +2 -0
  88. package/dist/chunk-hkxsewzk.js +2 -0
  89. package/dist/chunk-hrbbbtbn.js +2 -0
  90. package/dist/chunk-j03revz2.js +8 -0
  91. package/dist/chunk-j9qcrwbg.js +2 -0
  92. package/dist/chunk-jk4njz0w.js +2 -0
  93. package/dist/chunk-jmabeqfq.js +2 -0
  94. package/dist/chunk-jt0n43mk.js +2 -0
  95. package/dist/chunk-kjbv8a3m.js +2 -0
  96. package/dist/chunk-m1vdghnx.js +2 -0
  97. package/dist/chunk-m4sk62wb.js +5 -0
  98. package/dist/chunk-md8rqn48.js +30 -0
  99. package/dist/chunk-mepdnezf.js +17 -0
  100. package/dist/chunk-mhq0pjws.js +2 -0
  101. package/dist/chunk-mp6hy8g4.js +2 -0
  102. package/dist/chunk-ngc2wke4.js +3 -0
  103. package/dist/chunk-nn2vstke.js +2 -0
  104. package/dist/chunk-p2v2a68k.js +2 -0
  105. package/dist/{chunk-qn5srnj3.js → chunk-pbh4smw3.js} +16 -16
  106. package/dist/chunk-pdt69hpb.js +2 -0
  107. package/dist/chunk-pgzvyrv6.js +29 -0
  108. package/dist/chunk-pj1wg7jg.js +2 -0
  109. package/dist/chunk-pqxzp1bb.js +3 -0
  110. package/dist/chunk-px7fvbj6.js +3 -0
  111. package/dist/chunk-q4c06e8x.js +20 -0
  112. package/dist/chunk-q6vrb2pe.js +2 -0
  113. package/dist/chunk-q7qchkvk.js +2 -0
  114. package/dist/chunk-q9bdh4s5.js +8 -0
  115. package/dist/chunk-qet5gc6s.js +2033 -0
  116. package/dist/chunk-qz519eyp.js +2 -0
  117. package/dist/chunk-r3f9jcf7.js +5 -0
  118. package/dist/chunk-rs4v4fha.js +4 -0
  119. package/dist/chunk-s2x4wcrz.js +2 -0
  120. package/dist/chunk-s5xezjps.js +3 -0
  121. package/dist/chunk-scezfp0w.js +30 -0
  122. package/dist/chunk-sd321bn3.js +2 -0
  123. package/dist/{chunk-eenk6s3t.js → chunk-sd47dzs0.js} +79 -79
  124. package/dist/chunk-se7mwqd1.js +2 -0
  125. package/dist/chunk-shr559s7.js +3 -0
  126. package/dist/chunk-syaw6b75.js +2 -0
  127. package/dist/chunk-t4hzprsm.js +3 -0
  128. package/dist/{chunk-s9za1vvd.js → chunk-t61vdbje.js} +89 -89
  129. package/dist/chunk-tfexmdkt.js +3 -0
  130. package/dist/chunk-thyt8ed8.js +6 -0
  131. package/dist/chunk-v091jft4.js +12 -0
  132. package/dist/chunk-v4vaqxrf.js +33 -0
  133. package/dist/chunk-vgvtnwxa.js +4 -0
  134. package/dist/chunk-x0q32ees.js +3 -0
  135. package/dist/chunk-x5bpeb4a.js +2 -0
  136. package/dist/chunk-x72tv2cg.js +3 -0
  137. package/dist/chunk-xfp7k0v8.js +64 -0
  138. package/dist/chunk-xtdw3692.js +6 -0
  139. package/dist/chunk-y1cmjvk3.js +43 -0
  140. package/dist/chunk-y5310237.js +311 -0
  141. package/dist/chunk-ya0qecph.js +27 -0
  142. package/dist/chunk-yazk54jr.js +8 -0
  143. package/dist/chunk-ydjfar14.js +2 -0
  144. package/dist/chunk-ym95v4nc.js +3 -0
  145. package/dist/chunk-ynvdvbat.js +18 -0
  146. package/dist/chunk-yvx1ap9b.js +3 -0
  147. package/dist/chunk-z0g9jvv0.js +40 -0
  148. package/dist/chunk-z6d0jmjb.js +2 -0
  149. package/dist/{chunk-fpwzacpm.js → chunk-zhxdpzga.js} +4 -4
  150. package/dist/cli.js +110 -110
  151. package/dist/craft-entry.js +7 -7
  152. package/dist/craft.js +7 -7
  153. package/dist/database.js +2 -2
  154. package/dist/image-optimization/component.js +4 -4
  155. package/dist/index.d.ts +2 -0
  156. package/dist/index.js +1 -0
  157. package/dist/media/image/component.js +5 -5
  158. package/dist/media/protected/component.js +2 -2
  159. package/dist/media/video/index.js +4 -4
  160. package/dist/native/bridge/protocol.d.ts +325 -0
  161. package/dist/native/bridge/protocol.js +219 -0
  162. package/dist/native/cli.d.ts +24 -0
  163. package/dist/native/cli.js +52 -0
  164. package/dist/native/compiler/bundle.d.ts +41 -0
  165. package/dist/native/compiler/bundle.js +90 -0
  166. package/dist/native/compiler/client-script.d.ts +8 -0
  167. package/dist/native/compiler/client-script.js +31 -0
  168. package/dist/native/compiler/codegen.d.ts +10 -0
  169. package/dist/native/compiler/codegen.js +145 -0
  170. package/dist/native/compiler/headwind-to-style.d.ts +395 -0
  171. package/dist/native/compiler/headwind-to-style.js +1163 -0
  172. package/dist/native/compiler/html-to-ir.d.ts +41 -0
  173. package/dist/native/compiler/html-to-ir.js +411 -0
  174. package/dist/native/compiler/icons.d.ts +220 -0
  175. package/dist/native/compiler/icons.js +208 -0
  176. package/dist/native/compiler/ir.d.ts +234 -0
  177. package/dist/native/compiler/ir.js +15 -0
  178. package/dist/native/compiler/parser.d.ts +88 -0
  179. package/dist/native/compiler/parser.js +753 -0
  180. package/dist/native/compiler/render-screen.d.ts +26 -0
  181. package/dist/native/compiler/render-screen.js +31 -0
  182. package/dist/native/components/primitives.d.ts +291 -0
  183. package/dist/native/components/primitives.js +22 -0
  184. package/dist/native/hot-reload/client.d.ts +62 -0
  185. package/dist/native/hot-reload/client.js +324 -0
  186. package/dist/native/index.d.ts +90 -0
  187. package/dist/native/index.js +34 -0
  188. package/dist/native/primitives/ActivityIndicator.stx +5 -0
  189. package/dist/native/primitives/Button.stx +5 -0
  190. package/dist/native/primitives/DatePicker.stx +5 -0
  191. package/dist/native/primitives/FlatList.stx +5 -0
  192. package/dist/native/primitives/Image.stx +5 -0
  193. package/dist/native/primitives/ImageBackground.stx +5 -0
  194. package/dist/native/primitives/KeyboardAvoidingView.stx +5 -0
  195. package/dist/native/primitives/Modal.stx +5 -0
  196. package/dist/native/primitives/Picker.stx +5 -0
  197. package/dist/native/primitives/Pressable.stx +5 -0
  198. package/dist/native/primitives/RefreshControl.stx +5 -0
  199. package/dist/native/primitives/SafeAreaView.stx +5 -0
  200. package/dist/native/primitives/ScrollView.stx +5 -0
  201. package/dist/native/primitives/SectionList.stx +5 -0
  202. package/dist/native/primitives/Slider.stx +5 -0
  203. package/dist/native/primitives/StatusBar.stx +5 -0
  204. package/dist/native/primitives/Switch.stx +5 -0
  205. package/dist/native/primitives/Text.stx +5 -0
  206. package/dist/native/primitives/TextInput.stx +5 -0
  207. package/dist/native/primitives/TouchableHighlight.stx +5 -0
  208. package/dist/native/primitives/TouchableOpacity.stx +5 -0
  209. package/dist/native/primitives/View.stx +5 -0
  210. package/dist/native/runtime/craft.d.ts +75 -0
  211. package/dist/native/runtime/craft.js +0 -0
  212. package/dist/native/runtime/entry.d.ts +1 -0
  213. package/dist/native/runtime/entry.js +3 -0
  214. package/dist/native/runtime/index.d.ts +45 -0
  215. package/dist/native/runtime/index.js +165 -0
  216. package/dist/native/runtime/native-host.d.ts +33 -0
  217. package/dist/native/runtime/native-host.js +184 -0
  218. package/dist/native/runtime/screen.d.ts +43 -0
  219. package/dist/native/runtime/screen.js +808 -0
  220. package/dist/pwa/service-worker.js +1 -1
  221. package/dist/pwa/workbox.js +1 -1
  222. package/dist/pwa.js +8 -8
  223. package/dist/site-url.d.ts +1 -1
  224. package/dist/ssg.js +53 -53
  225. package/dist/visual-testing.js +42 -42
  226. package/dist/web-components/reactive-generator.js +2 -2
  227. package/package.json +9 -5
  228. package/dist/chunk-00g9x6w2.js +0 -2
  229. package/dist/chunk-04tgatyy.js +0 -2
  230. package/dist/chunk-097jnwd5.js +0 -2
  231. package/dist/chunk-0btmm4m2.js +0 -147
  232. package/dist/chunk-0c2h69k2.js +0 -4
  233. package/dist/chunk-0pkk226n.js +0 -2
  234. package/dist/chunk-0we9nw1d.js +0 -3
  235. package/dist/chunk-0y46fbkx.js +0 -3
  236. package/dist/chunk-18n1ftn0.js +0 -33
  237. package/dist/chunk-1a0v39k5.js +0 -3
  238. package/dist/chunk-1fs9jvpb.js +0 -2
  239. package/dist/chunk-1qq26zt0.js +0 -2
  240. package/dist/chunk-1te8k8gp.js +0 -3
  241. package/dist/chunk-1ws3xcea.js +0 -1199
  242. package/dist/chunk-213jwgpx.js +0 -3
  243. package/dist/chunk-24w86pek.js +0 -32
  244. package/dist/chunk-27fgag95.js +0 -4
  245. package/dist/chunk-2fw05hs2.js +0 -3
  246. package/dist/chunk-2tbez006.js +0 -2
  247. package/dist/chunk-38wvkv3s.js +0 -2
  248. package/dist/chunk-3rkejwjp.js +0 -2
  249. package/dist/chunk-3t65wb35.js +0 -2
  250. package/dist/chunk-3w6z6tw9.js +0 -2
  251. package/dist/chunk-4q1c6fw2.js +0 -7
  252. package/dist/chunk-50pszj17.js +0 -2
  253. package/dist/chunk-563shnkz.js +0 -3
  254. package/dist/chunk-5h104qh1.js +0 -2
  255. package/dist/chunk-5qjk7drw.js +0 -20
  256. package/dist/chunk-603x5gb2.js +0 -2
  257. package/dist/chunk-6kd5jjwc.js +0 -2
  258. package/dist/chunk-6kdrncsx.js +0 -30
  259. package/dist/chunk-6zggmce7.js +0 -4422
  260. package/dist/chunk-72rwcbp6.js +0 -3
  261. package/dist/chunk-76w34xne.js +0 -3
  262. package/dist/chunk-7dmgt8at.js +0 -2
  263. package/dist/chunk-82pd4b5w.js +0 -2
  264. package/dist/chunk-8d7nf67s.js +0 -2
  265. package/dist/chunk-8w2mqdnv.js +0 -2
  266. package/dist/chunk-90b2vt2n.js +0 -2
  267. package/dist/chunk-9e8t0twa.js +0 -3
  268. package/dist/chunk-9fqp72ze.js +0 -5
  269. package/dist/chunk-9xew0kgf.js +0 -2
  270. package/dist/chunk-a7bnvz91.js +0 -24
  271. package/dist/chunk-akwd34xt.js +0 -29
  272. package/dist/chunk-anydpa34.js +0 -3
  273. package/dist/chunk-aq1xq0r4.js +0 -16
  274. package/dist/chunk-bbt3tp6f.js +0 -499
  275. package/dist/chunk-bn1edb1y.js +0 -47
  276. package/dist/chunk-btd7ds3x.js +0 -2
  277. package/dist/chunk-c4511wng.js +0 -2
  278. package/dist/chunk-c4h579e3.js +0 -2
  279. package/dist/chunk-cj3adc77.js +0 -5
  280. package/dist/chunk-cs54ek9m.js +0 -6
  281. package/dist/chunk-ct1jwd4r.js +0 -2
  282. package/dist/chunk-cxrgxzxc.js +0 -2
  283. package/dist/chunk-de8t7sc9.js +0 -17
  284. package/dist/chunk-fcnrgxck.js +0 -2
  285. package/dist/chunk-fqzcft9d.js +0 -2
  286. package/dist/chunk-gbmeh7jg.js +0 -3
  287. package/dist/chunk-gc06g35w.js +0 -2
  288. package/dist/chunk-gs18069g.js +0 -194
  289. package/dist/chunk-gvbf1mhs.js +0 -930
  290. package/dist/chunk-h564hgzt.js +0 -2
  291. package/dist/chunk-h83jrhfq.js +0 -3
  292. package/dist/chunk-hj4vpyhp.js +0 -2
  293. package/dist/chunk-hrkvsj5c.js +0 -11
  294. package/dist/chunk-hyr4ag1k.js +0 -2
  295. package/dist/chunk-jxvmf02k.js +0 -2
  296. package/dist/chunk-k5ptvy0b.js +0 -4
  297. package/dist/chunk-k80sn8d1.js +0 -2
  298. package/dist/chunk-k8t2cmyd.js +0 -2
  299. package/dist/chunk-kmsyvaex.js +0 -8
  300. package/dist/chunk-kq4b6cwj.js +0 -2
  301. package/dist/chunk-kvmx7dnb.js +0 -2
  302. package/dist/chunk-kxc2h5vn.js +0 -5
  303. package/dist/chunk-mbxehgrq.js +0 -2
  304. package/dist/chunk-mgnq5de2.js +0 -2
  305. package/dist/chunk-mgrckqww.js +0 -2
  306. package/dist/chunk-mq5ewmz6.js +0 -2
  307. package/dist/chunk-mrahwn5v.js +0 -8
  308. package/dist/chunk-n2swas11.js +0 -3
  309. package/dist/chunk-n4299xgy.js +0 -2
  310. package/dist/chunk-naw4jt7j.js +0 -2
  311. package/dist/chunk-ny67c03k.js +0 -3
  312. package/dist/chunk-p4jb9v0w.js +0 -2
  313. package/dist/chunk-p4zrvt5f.js +0 -14
  314. package/dist/chunk-p5wp0ce6.js +0 -43
  315. package/dist/chunk-pcxp4r9n.js +0 -3
  316. package/dist/chunk-pjrn29gg.js +0 -2
  317. package/dist/chunk-prxwsp7n.js +0 -2
  318. package/dist/chunk-py2r6wtv.js +0 -2
  319. package/dist/chunk-q738pwv6.js +0 -2
  320. package/dist/chunk-q9n5swx7.js +0 -3
  321. package/dist/chunk-qmmp5kb5.js +0 -2
  322. package/dist/chunk-qqpqgwvb.js +0 -30
  323. package/dist/chunk-rcv2ehpq.js +0 -18
  324. package/dist/chunk-rq414kn5.js +0 -3
  325. package/dist/chunk-rz9f3zqz.js +0 -7
  326. package/dist/chunk-s6g8wksg.js +0 -2
  327. package/dist/chunk-s8jd13nb.js +0 -3
  328. package/dist/chunk-spxsw4mp.js +0 -2
  329. package/dist/chunk-strcy64y.js +0 -2
  330. package/dist/chunk-t1htzg9e.js +0 -4
  331. package/dist/chunk-t1tdjjht.js +0 -216
  332. package/dist/chunk-tat1cjec.js +0 -2
  333. package/dist/chunk-td08rnk3.js +0 -3
  334. package/dist/chunk-tgadbsd4.js +0 -2
  335. package/dist/chunk-tgrpp58r.js +0 -2
  336. package/dist/chunk-tkyrk66a.js +0 -3
  337. package/dist/chunk-tp8pzf94.js +0 -3
  338. package/dist/chunk-twz64kvy.js +0 -2
  339. package/dist/chunk-v3nwkveg.js +0 -12
  340. package/dist/chunk-vsbmc9kt.js +0 -2
  341. package/dist/chunk-vzgzaw66.js +0 -12
  342. package/dist/chunk-wc66mcn4.js +0 -4367
  343. package/dist/chunk-wkanrfb3.js +0 -2
  344. package/dist/chunk-x8f6wqxd.js +0 -2
  345. package/dist/chunk-xsng1mtq.js +0 -3
  346. package/dist/chunk-xwts5yky.js +0 -4
  347. package/dist/chunk-z5rwnnk1.js +0 -3
  348. package/dist/chunk-zcz9rs6p.js +0 -3
  349. package/dist/chunk-zpcnbdhn.js +0 -64
  350. package/dist/chunk-zq4ssxj9.js +0 -8
@@ -0,0 +1,753 @@
1
+ import { createNode, createDocument } from "./ir.js";
2
+ import { compileClassStyles } from "./headwind-to-style.js";
3
+ import { iconClassIn, resolveIconName } from "./icons.js";
4
+
5
+ class Lexer {
6
+ input;
7
+ pos = 0;
8
+ line = 1;
9
+ column = 1;
10
+ inTag = !1;
11
+ templates = [];
12
+ constructor(input) {
13
+ this.input = input;
14
+ }
15
+ tokenize() {
16
+ const tokens = [];
17
+ while (this.pos < this.input.length) {
18
+ const token = this.nextToken();
19
+ if (token)
20
+ tokens.push(token);
21
+ }
22
+ tokens.push({ type: "EOF", value: "", line: this.line, column: this.column });
23
+ return tokens;
24
+ }
25
+ nextToken() {
26
+ if (this.inTag)
27
+ this.skipWhitespace();
28
+ if (this.pos >= this.input.length)
29
+ return null;
30
+ const startLine = this.line, startColumn = this.column;
31
+ if (this.match("<!--")) {
32
+ const endIndex = this.input.indexOf("-->", this.pos);
33
+ if (endIndex === -1)
34
+ throw Error(`Unclosed comment at line ${startLine}`);
35
+ const value = this.input.slice(this.pos, endIndex);
36
+ this.advance(endIndex - this.pos + 3);
37
+ return { type: "COMMENT", value, line: startLine, column: startColumn };
38
+ }
39
+ if (this.match("<script")) {
40
+ const closeTag = "</script>", contentStart = this.input.indexOf(">", this.pos) + 1, contentEnd = this.input.indexOf(closeTag, contentStart);
41
+ if (contentEnd === -1)
42
+ throw Error(`Unclosed <script> block at line ${startLine}`);
43
+ const value = this.input.slice(contentStart, contentEnd).trim(), attributes = this.input.slice(this.pos + 7, contentStart - 1);
44
+ this.advance(contentEnd - this.pos + closeTag.length);
45
+ if (/\bserver\b/.test(attributes))
46
+ return null;
47
+ return { type: "SCRIPT_BLOCK", value, line: startLine, column: startColumn };
48
+ }
49
+ if (this.match("<style")) {
50
+ const closeTag = "</style>", contentStart = this.input.indexOf(">", this.pos) + 1, contentEnd = this.input.indexOf(closeTag, contentStart);
51
+ if (contentEnd === -1)
52
+ throw Error(`Unclosed <style> block at line ${startLine}`);
53
+ const value = this.input.slice(contentStart, contentEnd).trim();
54
+ this.advance(contentEnd - this.pos + closeTag.length);
55
+ return { type: "STYLE_BLOCK", value, line: startLine, column: startColumn };
56
+ }
57
+ if (this.match("<template>")) {
58
+ this.templates.push(!1);
59
+ this.advance(10);
60
+ return null;
61
+ }
62
+ if (this.match("<template"))
63
+ this.templates.push(!0);
64
+ if (this.match("</template>") && this.templates.pop() !== !0) {
65
+ this.advance(11);
66
+ return null;
67
+ }
68
+ if (this.match("</")) {
69
+ this.advance(2);
70
+ const tagName = this.readTagName();
71
+ this.skipWhitespace();
72
+ if (this.peek() !== ">")
73
+ throw Error(`Expected > at line ${this.line}`);
74
+ this.advance(1);
75
+ this.inTag = !1;
76
+ return { type: "TAG_CLOSE", value: tagName, line: startLine, column: startColumn };
77
+ }
78
+ if (this.peek() === "<") {
79
+ this.advance(1);
80
+ const tagName = this.readTagName();
81
+ this.inTag = !0;
82
+ return { type: "TAG_OPEN", value: tagName, line: startLine, column: startColumn };
83
+ }
84
+ if (this.match("/>")) {
85
+ this.advance(2);
86
+ this.inTag = !1;
87
+ return { type: "TAG_SELF_CLOSE", value: "/>", line: startLine, column: startColumn };
88
+ }
89
+ if (this.peek() === ">") {
90
+ this.advance(1);
91
+ this.inTag = !1;
92
+ return { type: "TAG_END", value: ">", line: startLine, column: startColumn };
93
+ }
94
+ if (!this.inTag && this.match("{{")) {
95
+ const end = this.input.indexOf("}}", this.pos + 2);
96
+ if (end !== -1) {
97
+ const value = this.input.slice(this.pos + 2, end);
98
+ this.advance(end - this.pos + 2);
99
+ return { type: "EXPRESSION", value: value.trim(), line: startLine, column: startColumn };
100
+ }
101
+ }
102
+ if (this.peek() === "{") {
103
+ this.advance(1);
104
+ let depth = 1, value = "";
105
+ while (depth > 0 && this.pos < this.input.length) {
106
+ const char = this.peek();
107
+ if (char === "{")
108
+ depth++;
109
+ else if (char === "}")
110
+ depth--;
111
+ if (depth > 0)
112
+ value += char;
113
+ this.advance(1);
114
+ }
115
+ return { type: "EXPRESSION", value: value.trim(), line: startLine, column: startColumn };
116
+ }
117
+ if (this.inTag && (this.isAlpha(this.peek()) || this.peek() === ":" || this.peek() === "@")) {
118
+ const attrName = this.readAttributeName();
119
+ this.skipWhitespace();
120
+ if (this.peek() === "=") {
121
+ this.advance(1);
122
+ this.skipWhitespace();
123
+ let attrValue, raw;
124
+ if (this.peek() === '"' || this.peek() === "'") {
125
+ const quote = this.peek();
126
+ this.advance(1);
127
+ attrValue = "";
128
+ while (this.peek() !== quote && this.pos < this.input.length) {
129
+ attrValue += this.peek();
130
+ this.advance(1);
131
+ }
132
+ this.advance(1);
133
+ } else if (this.peek() === "{") {
134
+ this.advance(1);
135
+ let depth = 1;
136
+ attrValue = "";
137
+ while (depth > 0 && this.pos < this.input.length) {
138
+ const char = this.peek();
139
+ if (char === "{")
140
+ depth++;
141
+ else if (char === "}")
142
+ depth--;
143
+ if (depth > 0)
144
+ attrValue += char;
145
+ this.advance(1);
146
+ }
147
+ raw = `{${attrValue}}`;
148
+ attrValue = attrValue.trim();
149
+ } else
150
+ throw Error(`Expected " or { after = at line ${this.line}`);
151
+ return {
152
+ type: "ATTRIBUTE",
153
+ value: `${attrName}=${attrValue}`,
154
+ raw,
155
+ line: startLine,
156
+ column: startColumn
157
+ };
158
+ }
159
+ return { type: "ATTRIBUTE", value: `${attrName}=true`, line: startLine, column: startColumn };
160
+ }
161
+ let text = "";
162
+ while (this.pos < this.input.length && this.peek() !== "<" && this.peek() !== "{") {
163
+ text += this.peek();
164
+ this.advance(1);
165
+ }
166
+ if (text.trim() || text && !text.includes(`
167
+ `))
168
+ return { type: "TEXT", value: text, line: startLine, column: startColumn };
169
+ return null;
170
+ }
171
+ match(str) {
172
+ return this.input.slice(this.pos, this.pos + str.length) === str;
173
+ }
174
+ peek() {
175
+ return this.input[this.pos] || "";
176
+ }
177
+ advance(n) {
178
+ for (let i = 0;i < n; i++) {
179
+ if (this.input[this.pos] === `
180
+ `) {
181
+ this.line++;
182
+ this.column = 1;
183
+ } else
184
+ this.column++;
185
+ this.pos++;
186
+ }
187
+ }
188
+ skipWhitespace() {
189
+ while (this.pos < this.input.length && /\s/.test(this.peek()))
190
+ this.advance(1);
191
+ }
192
+ readTagName() {
193
+ let name = "";
194
+ while (this.pos < this.input.length && /[a-zA-Z0-9_-]/.test(this.peek())) {
195
+ name += this.peek();
196
+ this.advance(1);
197
+ }
198
+ return name;
199
+ }
200
+ readAttributeName() {
201
+ let name = "";
202
+ while (this.pos < this.input.length && /[a-zA-Z0-9_\-:@]/.test(this.peek())) {
203
+ name += this.peek();
204
+ this.advance(1);
205
+ }
206
+ return name;
207
+ }
208
+ isAlpha(char) {
209
+ return /[a-zA-Z_]/.test(char);
210
+ }
211
+ }
212
+
213
+ class Parser {
214
+ ctx;
215
+ constructor(tokens, source) {
216
+ this.ctx = {
217
+ source,
218
+ tokens,
219
+ pos: 0,
220
+ scriptCode: "",
221
+ exports: {},
222
+ functions: [],
223
+ warnings: []
224
+ };
225
+ }
226
+ parse() {
227
+ this.extractScriptBlocks();
228
+ this.ctx.pos = 0;
229
+ const root = this.parseElement();
230
+ if (!root)
231
+ throw Error("No root element found in template");
232
+ const document = createDocument(root, {
233
+ exports: this.ctx.exports,
234
+ functions: this.ctx.functions,
235
+ code: this.ctx.scriptCode
236
+ }, {
237
+ source: this.ctx.source,
238
+ compiledAt: Date.now()
239
+ });
240
+ if (this.ctx.warnings.length)
241
+ document.meta.warnings = [...new Set(this.ctx.warnings)];
242
+ return document;
243
+ }
244
+ extractScriptBlocks() {
245
+ while (this.ctx.pos < this.ctx.tokens.length) {
246
+ const token = this.peek();
247
+ if (token.type === "SCRIPT_BLOCK") {
248
+ this.ctx.scriptCode += `${token.value}
249
+ `;
250
+ this.extractExportsAndFunctions(token.value);
251
+ }
252
+ this.advance();
253
+ }
254
+ }
255
+ extractExportsAndFunctions(code) {
256
+ const varPattern = /(?:let|const|var)\s+(\w+)\s*=\s*([^;\n]+)/g;
257
+ let match;
258
+ while ((match = varPattern.exec(code)) !== null) {
259
+ const [, name, value] = match;
260
+ try {
261
+ this.ctx.exports[name] = JSON.parse(value.trim());
262
+ } catch {
263
+ this.ctx.exports[name] = value.trim();
264
+ }
265
+ }
266
+ const funcPattern = /(?:function\s+(\w+)|const\s+(\w+)\s*=\s*(?:\([^)]*\)|[^=])\s*=>)/g;
267
+ while ((match = funcPattern.exec(code)) !== null) {
268
+ const name = match[1] || match[2];
269
+ if (name && !this.ctx.functions.includes(name))
270
+ this.ctx.functions.push(name);
271
+ }
272
+ const asyncFuncPattern = /async\s+function\s+(\w+)/g;
273
+ while ((match = asyncFuncPattern.exec(code)) !== null) {
274
+ const name = match[1];
275
+ if (name && !this.ctx.functions.includes(name))
276
+ this.ctx.functions.push(name);
277
+ }
278
+ }
279
+ parseElement() {
280
+ this.skipNonElements();
281
+ const token = this.peek();
282
+ if (token.type === "EOF")
283
+ return null;
284
+ if (token.type !== "TAG_OPEN") {
285
+ if (token.type === "TEXT") {
286
+ this.advance();
287
+ return createNode("Text", {}, {}, {}, [token.value]);
288
+ }
289
+ if (token.type === "EXPRESSION") {
290
+ this.advance();
291
+ return createNode("Text", {}, {}, {}, [`{${token.value}}`]);
292
+ }
293
+ return null;
294
+ }
295
+ const tagName = token.value, source = { file: this.ctx.source, line: token.line, column: token.column };
296
+ this.advance();
297
+ const attributes = this.parseAttributes(tagName, token.line), { props, style, events } = attributes, nextToken = this.peek();
298
+ if (nextToken.type === "TAG_SELF_CLOSE") {
299
+ this.advance();
300
+ const node = createNode(tagName, props, style, events, []);
301
+ this.finishNode(node, attributes, source);
302
+ return node;
303
+ }
304
+ if (nextToken.type !== "TAG_END")
305
+ throw Error(`Expected > or /> at line ${nextToken.line}, got ${nextToken.type}`);
306
+ this.advance();
307
+ const children = [];
308
+ while (!0) {
309
+ this.skipComments();
310
+ const childToken = this.peek();
311
+ if (childToken.type === "EOF")
312
+ throw Error(`Unclosed tag <${tagName}> at line ${token.line}`);
313
+ if (childToken.type === "TAG_CLOSE") {
314
+ if (childToken.value !== tagName)
315
+ throw Error(`Mismatched closing tag: expected </${tagName}>, got </${childToken.value}> at line ${childToken.line}`);
316
+ this.advance();
317
+ break;
318
+ }
319
+ if (childToken.type === "TEXT") {
320
+ children.push(childToken.value);
321
+ this.advance();
322
+ continue;
323
+ }
324
+ if (childToken.type === "EXPRESSION") {
325
+ children.push(`{${childToken.value}}`);
326
+ this.advance();
327
+ continue;
328
+ }
329
+ if (childToken.type === "TAG_OPEN") {
330
+ const childNode = this.parseElement();
331
+ if (childNode)
332
+ children.push(childNode);
333
+ continue;
334
+ }
335
+ this.advance();
336
+ }
337
+ const node = createNode(tagName, props, style, events, children);
338
+ this.finishNode(node, attributes, source);
339
+ return node;
340
+ }
341
+ finishNode(node, attributes, source) {
342
+ if (typeof node.props.__text === "string") {
343
+ node.children = [`{${node.props.__text}}`];
344
+ delete node.props.__text;
345
+ }
346
+ normalizeWhitespace(node);
347
+ if (attributes.classes)
348
+ node._classes = attributes.classes;
349
+ node._source = source;
350
+ if (attributes.darkStyle)
351
+ node.darkStyle = attributes.darkStyle;
352
+ if (Object.keys(attributes.directives).length)
353
+ node.directives = attributes.directives;
354
+ if (Object.keys(attributes.bindings).length)
355
+ node.bindings = attributes.bindings;
356
+ if (attributes.numberOfLines !== void 0 && node.props.numberOfLines === void 0)
357
+ node.props.numberOfLines = attributes.numberOfLines;
358
+ if (node.type === "Icon")
359
+ this.finishIcon(node, attributes.icon);
360
+ }
361
+ finishIcon(node, iconClass) {
362
+ const props = node.props, isExpression = (value) => typeof value === "string" && /\{[^}]*\}/.test(value);
363
+ if (props.size !== void 0) {
364
+ const size = Number(props.size);
365
+ if (Number.isFinite(size)) {
366
+ node.style.width ??= size;
367
+ node.style.height ??= size;
368
+ delete props.size;
369
+ }
370
+ }
371
+ node.children = [];
372
+ if (props.symbol !== void 0) {
373
+ delete props.name;
374
+ return;
375
+ }
376
+ const name = props.name ?? props.icon ?? iconClass;
377
+ delete props.icon;
378
+ if (name === void 0) {
379
+ if (!node.bindings?.class)
380
+ this.ctx.warnings.push(`<Icon> without symbol, name or an i-* class in ${this.ctx.source}; drawn as circle`);
381
+ return;
382
+ }
383
+ if (isExpression(name)) {
384
+ props.name = name;
385
+ return;
386
+ }
387
+ delete props.name;
388
+ const icon = resolveIconName(String(name));
389
+ props.symbol = icon.symbol;
390
+ if (icon.iconify)
391
+ props.iconify = icon.iconify;
392
+ if (!icon.known)
393
+ this.ctx.warnings.push(`Unknown icon ${name} in ${this.ctx.source}; drawn as ${icon.symbol}`);
394
+ }
395
+ parseAttributes(tagName, line) {
396
+ const props = {}, events = {}, directives = {}, bindings = {};
397
+ let classes = "", inlineStyle = {};
398
+ while (this.peek().type === "ATTRIBUTE") {
399
+ const token = this.peek();
400
+ this.advance();
401
+ const [rawName, ...valueParts] = token.value.split("="), value = valueParts.join("="), name = rawName.startsWith("x-bind:") ? `:${rawName.slice(7)}` : rawName.startsWith("x-on:") ? `@${rawName.slice(5)}` : rawName, bound = name.startsWith(":") || name.startsWith("x-") && name !== "x-cloak", binding = bound ? name.startsWith(":") ? name.slice(1) : name.slice(2) : "", boolean = !token.raw && value === "true" && !token.value.endsWith('="true"');
402
+ if (bound && binding === "if") {
403
+ directives.if = value;
404
+ continue;
405
+ }
406
+ if (bound && (binding === "else-if" || binding === "elseif")) {
407
+ directives.elseIf = value;
408
+ continue;
409
+ }
410
+ if (bound && binding === "else") {
411
+ directives.else = !0;
412
+ continue;
413
+ }
414
+ if (bound && binding === "show") {
415
+ directives.show = value;
416
+ continue;
417
+ }
418
+ if (bound && binding === "for") {
419
+ const loop = parseForExpression(value);
420
+ if (!loop)
421
+ throw Error(`Cannot read :for="${value}" at line ${line}: expected "item in items" or "(item, index) in items"`);
422
+ directives.for = loop;
423
+ continue;
424
+ }
425
+ if (bound && binding === "key") {
426
+ props.key = `{${value}}`;
427
+ continue;
428
+ }
429
+ if (bound && binding === "text") {
430
+ props.__text = value;
431
+ continue;
432
+ }
433
+ if (name === "x-cloak" || name === "x-data")
434
+ continue;
435
+ if (name === "class" || name === "className" || bound && (binding === "class" || binding === "className")) {
436
+ if (bound || token.raw)
437
+ bindings.class = value;
438
+ else
439
+ classes = classes ? `${classes} ${value}` : value;
440
+ continue;
441
+ }
442
+ if (name === "style" || bound && binding === "style") {
443
+ if (bound) {
444
+ bindings.style = value;
445
+ continue;
446
+ }
447
+ if (token.raw) {
448
+ try {
449
+ inlineStyle = { ...inlineStyle, ...JSON.parse(value) };
450
+ } catch {
451
+ bindings.style = value;
452
+ }
453
+ continue;
454
+ }
455
+ try {
456
+ if (value.startsWith("{") && value.endsWith("}"))
457
+ inlineStyle = { ...inlineStyle, ...JSON.parse(value) };
458
+ else
459
+ inlineStyle = { ...inlineStyle, ...JSON.parse(`{${value}}`) };
460
+ } catch {
461
+ inlineStyle = { ...inlineStyle, ...this.parseCSSInJS(value) };
462
+ }
463
+ continue;
464
+ }
465
+ if (/^on[A-Z]/.test(name) && !NOT_EVENTS.has(name) || name.startsWith("@")) {
466
+ const eventName = name.startsWith("@") ? nativeEventName(name.slice(1)) : name;
467
+ if (!boolean)
468
+ events[eventName] = value;
469
+ continue;
470
+ }
471
+ if (name === "key") {
472
+ props.key = token.raw ?? value;
473
+ continue;
474
+ }
475
+ if (bound) {
476
+ props[binding] = `{${value}}`;
477
+ continue;
478
+ }
479
+ if (token.raw) {
480
+ try {
481
+ props[name] = JSON.parse(value);
482
+ } catch {
483
+ props[name] = token.raw;
484
+ }
485
+ continue;
486
+ }
487
+ try {
488
+ props[name] = JSON.parse(value);
489
+ } catch {
490
+ props[name] = value;
491
+ }
492
+ }
493
+ const compiled = classes ? compileClassStyles(classes) : null;
494
+ if (compiled && compiled.unknown.length)
495
+ this.ctx.warnings.push(`Classes with no native style on <${tagName}> at line ${line}: ${compiled.unknown.join(" ")}`);
496
+ const style = { ...compiled?.style ?? {}, ...inlineStyle };
497
+ return {
498
+ props,
499
+ style,
500
+ events,
501
+ classes,
502
+ directives,
503
+ bindings,
504
+ darkStyle: compiled?.dark,
505
+ numberOfLines: compiled?.numberOfLines,
506
+ icon: compiled?.icon ?? (classes ? iconClassIn(classes) : void 0)
507
+ };
508
+ }
509
+ parseCSSInJS(value) {
510
+ const style = {}, pairs = value.split(",").map((p) => p.trim());
511
+ for (const pair of pairs) {
512
+ const colonIndex = pair.indexOf(":");
513
+ if (colonIndex === -1)
514
+ continue;
515
+ const key = pair.slice(0, colonIndex).trim();
516
+ let val = pair.slice(colonIndex + 1).trim();
517
+ if (val.startsWith("'") && val.endsWith("'") || val.startsWith('"') && val.endsWith('"'))
518
+ val = val.slice(1, -1);
519
+ const numVal = Number(val);
520
+ style[key] = Number.isNaN(numVal) ? val : numVal;
521
+ }
522
+ return style;
523
+ }
524
+ skipNonElements() {
525
+ while (this.peek().type === "SCRIPT_BLOCK" || this.peek().type === "STYLE_BLOCK" || this.peek().type === "COMMENT")
526
+ this.advance();
527
+ }
528
+ skipComments() {
529
+ while (this.peek().type === "COMMENT")
530
+ this.advance();
531
+ }
532
+ peek() {
533
+ return this.ctx.tokens[this.ctx.pos] || { type: "EOF", value: "", line: 0, column: 0 };
534
+ }
535
+ advance() {
536
+ this.ctx.pos++;
537
+ }
538
+ }
539
+ function normalizeWhitespace(node) {
540
+ const hasElements = node.children.some((child) => typeof child !== "string");
541
+ let children = node.children.map((child) => typeof child === "string" && !/^\{[\s\S]*\}$/.test(child) ? child.replace(/\s+/g, " ") : child).filter((child) => !(hasElements && typeof child === "string" && !child.trim()));
542
+ if (!hasElements && children.length) {
543
+ const first = children[0], last = children[children.length - 1];
544
+ if (typeof first === "string")
545
+ children[0] = first.replace(/^\s+/, "");
546
+ if (typeof last === "string")
547
+ children[children.length - 1] = children[children.length - 1].replace(/\s+$/, "");
548
+ children = children.filter((child) => child !== "");
549
+ }
550
+ node.children = children;
551
+ }
552
+ const NOT_EVENTS = new Set(["onEndReachedThreshold"]), NATIVE_EVENT_NAMES = {
553
+ click: "onPress",
554
+ press: "onPress",
555
+ tap: "onPress",
556
+ longpress: "onLongPress",
557
+ contextmenu: "onLongPress",
558
+ input: "onChangeText",
559
+ change: "onChange",
560
+ focus: "onFocus",
561
+ blur: "onBlur",
562
+ submit: "onSubmitEditing",
563
+ scroll: "onScroll",
564
+ refresh: "onRefresh",
565
+ close: "onRequestClose",
566
+ layout: "onLayout"
567
+ };
568
+ function nativeEventName(spelling) {
569
+ const [base] = spelling.split(".");
570
+ return NATIVE_EVENT_NAMES[base.toLowerCase()] ?? `on${base.charAt(0).toUpperCase()}${base.slice(1)}`;
571
+ }
572
+ export function parseForExpression(value) {
573
+ const trimmed = value.trim(), inForm = /^\(?\s*([$\w]+)\s*(?:,\s*([$\w]+)\s*)?\)?\s+(?:in|of)\s+([\s\S]+)$/.exec(trimmed);
574
+ if (inForm)
575
+ return { item: inForm[1], index: inForm[2], source: inForm[3].trim() };
576
+ const asForm = /^([\s\S]+?)\s+as\s+(?:([$\w]+)\s*=>\s*)?([$\w]+)$/.exec(trimmed);
577
+ if (asForm)
578
+ return { item: asForm[3], index: asForm[2], source: asForm[1].trim() };
579
+ return null;
580
+ }
581
+ function balancedParens(source, open) {
582
+ let depth = 0, quote = "";
583
+ for (let i = open;i < source.length; i++) {
584
+ const char = source[i];
585
+ if (quote) {
586
+ if (char === "\\")
587
+ i++;
588
+ else if (char === quote)
589
+ quote = "";
590
+ continue;
591
+ }
592
+ if (char === '"' || char === "'" || char === "`")
593
+ quote = char;
594
+ else if (char === "(")
595
+ depth++;
596
+ else if (char === ")" && --depth === 0)
597
+ return i;
598
+ }
599
+ return -1;
600
+ }
601
+ function attribute(name, expression) {
602
+ return expression.includes('"') ? `${name}={${expression}}` : `${name}="${expression}"`;
603
+ }
604
+ export function expandTextDirectives(source) {
605
+ const pattern = /<script\b[\s\S]*?<\/script>|<style\b[\s\S]*?<\/style>|@(if|elseif|unless|foreach|for)\s*\(|@(else|endif|endunless|endforeach|endfor)\b/g;
606
+ let out = "", last = 0;
607
+ for (let match = pattern.exec(source);match; match = pattern.exec(source)) {
608
+ if (match[0].startsWith("<"))
609
+ continue;
610
+ const before = source[match.index - 1];
611
+ if (before && /[\w@.]/.test(before))
612
+ continue;
613
+ out += source.slice(last, match.index);
614
+ if (match[1]) {
615
+ const open = match.index + match[0].length - 1, close = balancedParens(source, open);
616
+ if (close === -1)
617
+ throw Error(`Unclosed @${match[1]}( in template`);
618
+ const expression = source.slice(open + 1, close).trim();
619
+ if (match[1] === "if")
620
+ out += `<Fragment ${attribute(":if", expression)}>`;
621
+ else if (match[1] === "unless")
622
+ out += `<Fragment ${attribute(":if", `!(${expression})`)}>`;
623
+ else if (match[1] === "elseif")
624
+ out += `</Fragment><Fragment ${attribute(":else-if", expression)}>`;
625
+ else {
626
+ const loop = parseForExpression(expression);
627
+ if (!loop)
628
+ throw Error(`Cannot read @${match[1]}(${expression})`);
629
+ const head = loop.index ? `(${loop.item}, ${loop.index})` : loop.item;
630
+ out += `<Fragment ${attribute(":for", `${head} in ${loop.source}`)}>`;
631
+ }
632
+ last = close + 1;
633
+ pattern.lastIndex = last;
634
+ } else {
635
+ out += match[2] === "else" ? "</Fragment><Fragment :else>" : "</Fragment>";
636
+ last = match.index + match[0].length;
637
+ }
638
+ }
639
+ return out + source.slice(last);
640
+ }
641
+ export function parseSTX(template, source = "unknown.stx") {
642
+ const tokens = new Lexer(expandTextDirectives(template)).tokenize();
643
+ return new Parser(tokens, source).parse();
644
+ }
645
+ export function parseSTXToNode(template) {
646
+ return parseSTX(template).root;
647
+ }
648
+ export function compileSTX(template, source = "unknown.stx") {
649
+ const doc = parseSTX(template, source);
650
+ return JSON.stringify(doc, null, 2);
651
+ }
652
+ export function compileSTXFiles(files) {
653
+ const results = {};
654
+ for (const [path, content] of Object.entries(files))
655
+ results[path] = parseSTX(content, path);
656
+ return results;
657
+ }
658
+ export function mapToNativeComponent(tag) {
659
+ return {
660
+ view: "View",
661
+ text: "Text",
662
+ button: "Button",
663
+ image: "Image",
664
+ img: "Image",
665
+ input: "TextInput",
666
+ textarea: "TextInput",
667
+ scroll: "ScrollView",
668
+ scrollview: "ScrollView",
669
+ list: "FlatList",
670
+ flatlist: "FlatList",
671
+ modal: "Modal",
672
+ switch: "Switch",
673
+ slider: "Slider",
674
+ picker: "Picker",
675
+ select: "Picker",
676
+ loading: "ActivityIndicator",
677
+ spinner: "ActivityIndicator",
678
+ div: "View",
679
+ span: "Text",
680
+ p: "Text",
681
+ h1: "Text",
682
+ h2: "Text",
683
+ h3: "Text",
684
+ h4: "Text",
685
+ h5: "Text",
686
+ h6: "Text",
687
+ a: "TouchableOpacity",
688
+ section: "View",
689
+ article: "View",
690
+ header: "SafeAreaView",
691
+ footer: "View",
692
+ main: "View",
693
+ nav: "View",
694
+ aside: "View",
695
+ form: "View",
696
+ label: "Text",
697
+ fieldset: "View",
698
+ legend: "Text",
699
+ option: "Text",
700
+ dialog: "Modal",
701
+ figure: "View",
702
+ figcaption: "Text",
703
+ picture: "View",
704
+ hr: "View",
705
+ ul: "View",
706
+ ol: "View",
707
+ li: "View",
708
+ dl: "View",
709
+ dt: "Text",
710
+ dd: "Text",
711
+ table: "View",
712
+ thead: "View",
713
+ tbody: "View",
714
+ tfoot: "View",
715
+ tr: "View",
716
+ th: "Text",
717
+ td: "Text",
718
+ caption: "Text",
719
+ strong: "Text",
720
+ b: "Text",
721
+ em: "Text",
722
+ i: "Text",
723
+ u: "Text",
724
+ s: "Text",
725
+ small: "Text",
726
+ mark: "Text",
727
+ abbr: "Text",
728
+ time: "Text",
729
+ code: "Text",
730
+ kbd: "Text",
731
+ samp: "Text",
732
+ pre: "Text",
733
+ blockquote: "Text",
734
+ cite: "Text",
735
+ q: "Text",
736
+ sub: "Text",
737
+ sup: "Text"
738
+ }[tag.toLowerCase()] || tag;
739
+ }
740
+ export function transformToNativeComponents(node) {
741
+ const mappedType = mapToNativeComponent(node.type), transformedChildren = node.children.map((child) => {
742
+ if (typeof child === "string")
743
+ return child;
744
+ return transformToNativeComponents(child);
745
+ });
746
+ return {
747
+ ...node,
748
+ type: mappedType,
749
+ children: transformedChildren
750
+ };
751
+ }
752
+
753
+ export { Lexer, Parser };