@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,325 @@
1
+ /**
2
+ * Auto-detect and initialize the bridge
3
+ */
4
+ export declare function createBridge(): STXBridge;
5
+ /**
6
+ * Get the global bridge instance
7
+ */
8
+ export declare function getBridge(): STXBridge;
9
+ /**
10
+ * Create an event handler that calls the bridge
11
+ */
12
+ export declare function createEventHandler(handlerName: string, targetKey: string): (nativeEvent: EventPayload['nativeEvent']) => void;
13
+ /**
14
+ * Register a JS function to be callable from native
15
+ */
16
+ export declare function registerHandler(name: string, handler: (...args: unknown[]) => unknown): void;
17
+ /**
18
+ * Call a registered handler (used by native)
19
+ */
20
+ export declare function callHandler(name: string, ...args: unknown[]): unknown;
21
+ /**
22
+ * Platform-specific native bridge implementations
23
+ * @defaultValue
24
+ * ```ts
25
+ * {
26
+ * ios: () => NativeBridgeInterface | null,
27
+ * android: () => NativeBridgeInterface | null,
28
+ * web: () => NativeBridgeInterface | null
29
+ * }
30
+ * ```
31
+ */
32
+ export declare const NativeBridges: {
33
+ /**
34
+ * iOS (JavaScriptCore)
35
+ */
36
+ ios: () => NativeBridgeInterface | null;
37
+ /**
38
+ * Android (JavaScriptInterface)
39
+ */
40
+ android: () => NativeBridgeInterface | null;
41
+ /**
42
+ * Web (PostMessage)
43
+ */
44
+ web: () => NativeBridgeInterface | null
45
+ };
46
+ /**
47
+ * Base message structure
48
+ */
49
+ export declare interface BridgeMessage<T = unknown> {
50
+ id: string
51
+ type: BridgeMessageType
52
+ timestamp: number
53
+ payload: T
54
+ correlationId?: string
55
+ source: 'js' | 'native'
56
+ }
57
+ /**
58
+ * RENDER message payload
59
+ */
60
+ export declare interface RenderPayload {
61
+ document: import('../compiler/ir').STXDocument | import('../compiler/ir').STXNode
62
+ containerId?: string
63
+ mode: 'replace' | 'append' | 'prepend'
64
+ }
65
+ export declare interface NativeMutationNode {
66
+ type: string
67
+ props?: Record<string, unknown>
68
+ style?: Partial<import('../compiler/ir').STXStyle>
69
+ events?: Record<string, string>
70
+ children?: string[]
71
+ }
72
+ export declare interface NativeMutationPayload {
73
+ version: 1
74
+ batchId: string
75
+ baseRevision: number
76
+ revision: number
77
+ operations: NativeMutationOperation[]
78
+ }
79
+ export declare interface NativeMutationAckPayload {
80
+ version: 1
81
+ batchId: string
82
+ revision: number
83
+ }
84
+ export declare interface NativeMutationErrorPayload {
85
+ version: 1
86
+ batchId: string
87
+ code: string
88
+ message: string
89
+ operationIndex?: number
90
+ }
91
+ /**
92
+ * UPDATE message payload
93
+ */
94
+ export declare interface UpdatePayload {
95
+ updates: Array<{
96
+ key: string
97
+ props?: Record<string, unknown>
98
+ style?: Partial<import('../compiler/ir').STXStyle>
99
+ children?: (import('../compiler/ir').STXNode | string)[]
100
+ }>
101
+ }
102
+ /**
103
+ * REMOVE message payload
104
+ */
105
+ export declare interface RemovePayload {
106
+ keys: string[]
107
+ }
108
+ /**
109
+ * EVENT message payload (Native → JS)
110
+ */
111
+ export declare interface EventPayload {
112
+ eventType: string
113
+ targetKey: string
114
+ handlerName: string
115
+ nativeEvent: {
116
+ timestamp: number
117
+ touches?: Array<{
118
+ x: number
119
+ y: number
120
+ force?: number
121
+ identifier: number
122
+ }>
123
+ contentOffset?: { x: number; y: number }
124
+ contentSize?: { width: number; height: number }
125
+ layoutMeasurement?: { width: number; height: number }
126
+ text?: string
127
+ selection?: { start: number; end: number }
128
+ layout?: { x: number; y: number; width: number; height: number }
129
+ [key: string]: unknown
130
+ }
131
+ }
132
+ /**
133
+ * STATE_UPDATE message payload
134
+ */
135
+ export declare interface StateUpdatePayload {
136
+ key: string
137
+ value: unknown
138
+ previousValue?: unknown
139
+ }
140
+ /**
141
+ * NAVIGATE message payload
142
+ */
143
+ export declare interface NavigatePayload {
144
+ screen: string
145
+ params?: Record<string, unknown>
146
+ animation?: 'push' | 'modal' | 'fade' | 'none'
147
+ }
148
+ /**
149
+ * APP_STATE message payload
150
+ */
151
+ export declare interface AppStatePayload {
152
+ state: 'active' | 'inactive' | 'background'
153
+ previousState?: 'active' | 'inactive' | 'background'
154
+ }
155
+ /** A normalized deep link delivered by either native host. */
156
+ export declare interface DeepLinkPayload {
157
+ url: string
158
+ scheme: string
159
+ host: string
160
+ path: string
161
+ query: string
162
+ queryParams?: Record<string, string>
163
+ initial?: boolean
164
+ }
165
+ /**
166
+ * API_REQUEST message payload
167
+ */
168
+ export declare interface ApiRequestPayload {
169
+ version: 1
170
+ module: string
171
+ method: string
172
+ args: unknown[]
173
+ }
174
+ /**
175
+ * The single argument of a `Network.fetch` capability request. The bundle's
176
+ * global `fetch` builds it; header names are lower-cased and bodies are text.
177
+ */
178
+ export declare interface NativeFetchRequest {
179
+ url: string
180
+ method: string
181
+ headers: Record<string, string>
182
+ body: string | null
183
+ }
184
+ /**
185
+ * The `API_RESPONSE` data for `Network.fetch`. HTTP error statuses are
186
+ * responses; transport failures are `API_ERROR`s with `NETWORK_ERROR`,
187
+ * `TIMEOUT`, `INVALID_ARGUMENT` or `RESPONSE_TOO_LARGE`.
188
+ */
189
+ export declare interface NativeFetchResponse {
190
+ url: string
191
+ status: number
192
+ statusText: string
193
+ redirected: boolean
194
+ headers: Record<string, string>
195
+ body: string
196
+ }
197
+ /** A request that no longer has a JavaScript consumer. */
198
+ export declare interface ApiCancelPayload {
199
+ version: 1
200
+ requestId: string
201
+ reason: 'timeout' | 'screen-closed' | 'aborted'
202
+ }
203
+ /**
204
+ * API_RESPONSE message payload
205
+ */
206
+ export declare interface ApiResponsePayload {
207
+ version: 1
208
+ requestId: string
209
+ data: unknown
210
+ }
211
+ /**
212
+ * API_ERROR message payload
213
+ */
214
+ export declare interface ApiErrorPayload {
215
+ version: 1
216
+ requestId: string
217
+ code: string
218
+ message: string
219
+ stack?: string
220
+ }
221
+ /**
222
+ * HOT_RELOAD message payload
223
+ */
224
+ export declare interface HotReloadPayload {
225
+ changedFiles: string[]
226
+ document?: import('../compiler/ir').STXDocument
227
+ preserveState: boolean
228
+ }
229
+ /**
230
+ * PERFORMANCE message payload
231
+ */
232
+ export declare interface PerformancePayload {
233
+ metric: 'fps' | 'memory' | 'render_time' | 'bridge_latency'
234
+ value: number
235
+ context?: Record<string, unknown>
236
+ }
237
+ /**
238
+ * Interface that native code must implement
239
+ */
240
+ export declare interface NativeBridgeInterface {
241
+ platform?: 'ios' | 'android'
242
+ capabilityProtocolVersion?: 1
243
+ capabilities?: string[]
244
+ capabilityTimeoutMs?: number
245
+ initialAppState?: 'active' | 'inactive' | 'background'
246
+ postMessage(message: string): void
247
+ onMessage(callback: (message: string) => void): void
248
+ }
249
+ /**
250
+ * All possible message types in the bridge protocol
251
+ */
252
+ export type BridgeMessageType = | 'RENDER' // Render a new component tree
253
+ | 'MUTATE' // Apply one atomic native-tree mutation batch
254
+ | 'MUTATION_ACK' // Native host committed a mutation batch
255
+ | 'MUTATION_ERROR' // Native host rejected a mutation batch
256
+ | 'UPDATE' // Update existing component(s)
257
+ | 'REMOVE' // Remove component(s) from tree
258
+
259
+ // Events
260
+ | 'EVENT' // Native event (touch, scroll, etc.)
261
+ | 'EVENT_RESPONSE' // JS response to event
262
+
263
+ // State
264
+ | 'STATE_UPDATE' // State changed, need re-render
265
+ | 'STATE_SYNC' // Sync state between JS and native
266
+
267
+ // Navigation
268
+ | 'NAVIGATE' // Navigate to a new screen
269
+ | 'NAVIGATE_BACK' // Go back
270
+ | 'NAVIGATE_REPLACE' // Replace current screen
271
+
272
+ // Lifecycle
273
+ | 'APP_STATE' // App foreground/background
274
+ | 'DEEP_LINK' // App opened or resumed through a URL
275
+ | 'SCREEN_FOCUS' // Screen gained/lost focus
276
+ | 'MEMORY_WARNING' // Low memory warning
277
+
278
+ // API
279
+ | 'API_REQUEST' // Call native API
280
+ | 'API_CANCEL' // Cancel an in-flight native API request
281
+ | 'API_RESPONSE' // Native API response
282
+ | 'API_ERROR' // Native API error
283
+
284
+ // Dev Tools
285
+ | 'HOT_RELOAD' // Hot reload triggered
286
+ | 'DEBUG_LOG' // Debug logging
287
+ | 'INSPECT' // Inspector request
288
+ | 'PERFORMANCE' // Performance metrics;
289
+ export type NativeMutationOperation = | { op: 'createNode', id: string, node: NativeMutationNode, root?: boolean }
290
+ | { op: 'updateNode', id: string, patch: Omit<NativeMutationNode, 'type'> }
291
+ | { op: 'insertChild', parentId: string, childId: string, index: number }
292
+ | { op: 'moveChild', parentId: string, childId: string, index: number }
293
+ | { op: 'removeNode', id: string }
294
+ // ============================================================================
295
+ // Bridge Implementation
296
+ // ============================================================================
297
+ // eslint-disable-next-line pickier/no-unused-vars
298
+ declare type MessageHandler<T = unknown> = (message: BridgeMessage<T>) => void | Promise<void>;
299
+ declare type PendingRequest = {
300
+ resolve: (value: unknown) => void
301
+ reject: (error: Error) => void
302
+ timeout: ReturnType<typeof setTimeout> | null
303
+ }
304
+ export declare class NativeCapabilityError extends Error {
305
+ public readonly code: string;
306
+ constructor(code: string, message: string);
307
+ }
308
+ /**
309
+ * Bridge class for JS side
310
+ */
311
+ export declare class STXBridge {
312
+ initialize(nativeBridge: NativeBridgeInterface): void;
313
+ send<T>(type: BridgeMessageType, payload: T): string;
314
+ request<T, R>(type: BridgeMessageType, payload: T, timeout?: unknown): Promise<R>;
315
+ on<T>(type: BridgeMessageType, handler: MessageHandler<T>): () => void;
316
+ once<T>(type: BridgeMessageType, handler: MessageHandler<T>): () => void;
317
+ render(document: import('../compiler/ir').STXDocument | import('../compiler/ir').STXNode, options?: { containerId?: string; mode?: 'replace' | 'append' | 'prepend' }): string;
318
+ mutate(payload: NativeMutationPayload): string;
319
+ update(updates: UpdatePayload['updates']): string;
320
+ remove(keys: string[]): string;
321
+ navigate(screen: string, params?: Record<string, unknown>, animation?: NavigatePayload['animation']): string;
322
+ goBack(): string;
323
+ callNativeAPI<T>(module: string, method: string, ...args: unknown[]): Promise<T>;
324
+ log(level: 'info' | 'warn' | 'error', message: string, data?: unknown): void;
325
+ }
@@ -0,0 +1,219 @@
1
+ export class NativeCapabilityError extends Error {
2
+ code;
3
+ constructor(code, message) {
4
+ super(message);
5
+ this.code = code;
6
+ this.name = "NativeCapabilityError";
7
+ }
8
+ }
9
+
10
+ export class STXBridge {
11
+ messageId = 0;
12
+ handlers = new Map;
13
+ pendingRequests = new Map;
14
+ nativeBridge = null;
15
+ defaultTimeout = 30000;
16
+ initialize(nativeBridge) {
17
+ this.nativeBridge = nativeBridge;
18
+ nativeBridge.onMessage((rawMessage) => {
19
+ try {
20
+ const message = JSON.parse(rawMessage);
21
+ this.handleIncomingMessage(message);
22
+ } catch (error) {
23
+ console.error("[STXBridge] Failed to parse message:", error);
24
+ }
25
+ });
26
+ }
27
+ send(type, payload) {
28
+ const message = this.createMessage(type, payload);
29
+ this.postToNative(message);
30
+ return message.id;
31
+ }
32
+ async request(type, payload, timeout = this.defaultTimeout) {
33
+ const message = this.createMessage(type, payload);
34
+ return new Promise((resolve, reject) => {
35
+ const scheduleTimeout = typeof globalThis.setTimeout === "function" ? globalThis.setTimeout.bind(globalThis) : null, timeoutId = scheduleTimeout ? scheduleTimeout(() => {
36
+ this.pendingRequests.delete(message.id);
37
+ if (type === "API_REQUEST")
38
+ this.postToNative(this.createMessage("API_CANCEL", {
39
+ version: 1,
40
+ requestId: message.id,
41
+ reason: "timeout"
42
+ }));
43
+ reject(new NativeCapabilityError("TIMEOUT", `Request ${message.id} timed out after ${timeout}ms`));
44
+ }, timeout) : null;
45
+ this.pendingRequests.set(message.id, {
46
+ resolve,
47
+ reject,
48
+ timeout: timeoutId
49
+ });
50
+ this.postToNative(message);
51
+ });
52
+ }
53
+ on(type, handler) {
54
+ if (!this.handlers.has(type))
55
+ this.handlers.set(type, new Set);
56
+ this.handlers.get(type).add(handler);
57
+ return () => {
58
+ this.handlers.get(type)?.delete(handler);
59
+ };
60
+ }
61
+ once(type, handler) {
62
+ const wrappedHandler = (message) => {
63
+ unsubscribe();
64
+ handler(message);
65
+ }, unsubscribe = this.on(type, wrappedHandler);
66
+ return unsubscribe;
67
+ }
68
+ render(document, options = {}) {
69
+ return this.send("RENDER", {
70
+ document,
71
+ containerId: options.containerId,
72
+ mode: options.mode || "replace"
73
+ });
74
+ }
75
+ mutate(payload) {
76
+ return this.send("MUTATE", payload);
77
+ }
78
+ update(updates) {
79
+ return this.send("UPDATE", { updates });
80
+ }
81
+ remove(keys) {
82
+ return this.send("REMOVE", { keys });
83
+ }
84
+ navigate(screen, params, animation) {
85
+ return this.send("NAVIGATE", { screen, params, animation });
86
+ }
87
+ goBack() {
88
+ return this.send("NAVIGATE_BACK", {});
89
+ }
90
+ async callNativeAPI(module, method, ...args) {
91
+ return this.request("API_REQUEST", {
92
+ version: 1,
93
+ module,
94
+ method,
95
+ args
96
+ });
97
+ }
98
+ log(level, message, data) {
99
+ this.send("DEBUG_LOG", { level, message, data });
100
+ }
101
+ createMessage(type, payload) {
102
+ return {
103
+ id: `js_${++this.messageId}_${Date.now()}`,
104
+ type,
105
+ timestamp: Date.now(),
106
+ payload,
107
+ source: "js"
108
+ };
109
+ }
110
+ postToNative(message) {
111
+ if (!this.nativeBridge) {
112
+ console.error("[STXBridge] Native bridge not initialized");
113
+ return;
114
+ }
115
+ try {
116
+ this.nativeBridge.postMessage(JSON.stringify(message));
117
+ } catch (error) {
118
+ console.error("[STXBridge] Failed to post message:", error);
119
+ }
120
+ }
121
+ handleIncomingMessage(message) {
122
+ if (message.correlationId && this.pendingRequests.has(message.correlationId)) {
123
+ const pending = this.pendingRequests.get(message.correlationId);
124
+ this.pendingRequests.delete(message.correlationId);
125
+ if (pending.timeout !== null && typeof globalThis.clearTimeout === "function")
126
+ globalThis.clearTimeout(pending.timeout);
127
+ if (message.type === "API_ERROR") {
128
+ const error = message.payload;
129
+ pending.reject(new NativeCapabilityError(error.code, error.message));
130
+ } else
131
+ pending.resolve(message.payload.data);
132
+ return;
133
+ }
134
+ const handlers = this.handlers.get(message.type);
135
+ if (handlers)
136
+ for (const handler of handlers)
137
+ try {
138
+ handler(message);
139
+ } catch (error) {
140
+ console.error(`[STXBridge] Handler error for ${message.type}:`, error);
141
+ }
142
+ }
143
+ }
144
+ export const NativeBridges = {
145
+ ios: () => {
146
+ if (typeof webkit < "u" && webkit.messageHandlers?.stx)
147
+ return {
148
+ postMessage: (message) => {
149
+ webkit.messageHandlers.stx.postMessage(message);
150
+ },
151
+ onMessage: (callback) => {
152
+ globalThis.__stxNativeCallback = callback;
153
+ }
154
+ };
155
+ return null;
156
+ },
157
+ android: () => {
158
+ if (typeof STXNative < "u")
159
+ return {
160
+ postMessage: (message) => {
161
+ STXNative.postMessage(message);
162
+ },
163
+ onMessage: (callback) => {
164
+ globalThis.__stxNativeCallback = callback;
165
+ }
166
+ };
167
+ return null;
168
+ },
169
+ web: () => {
170
+ if (typeof window < "u")
171
+ return {
172
+ postMessage: (message) => {
173
+ window.postMessage({ type: "stx", message }, "*");
174
+ },
175
+ onMessage: (callback) => {
176
+ window.addEventListener("message", (event) => {
177
+ if (event.data?.type === "stx-native")
178
+ callback(event.data.message);
179
+ });
180
+ }
181
+ };
182
+ return null;
183
+ }
184
+ };
185
+ export function createBridge() {
186
+ const bridge = new STXBridge, nativeBridge = NativeBridges.ios() || NativeBridges.android() || NativeBridges.web();
187
+ if (nativeBridge)
188
+ bridge.initialize(nativeBridge);
189
+ else
190
+ console.warn("[STXBridge] No native bridge available, running in mock mode");
191
+ return bridge;
192
+ }
193
+ let bridgeInstance = null;
194
+ export function getBridge() {
195
+ if (!bridgeInstance)
196
+ bridgeInstance = createBridge();
197
+ return bridgeInstance;
198
+ }
199
+ export function createEventHandler(handlerName, targetKey) {
200
+ return (nativeEvent) => {
201
+ getBridge().send("EVENT_RESPONSE", {
202
+ eventType: "callback",
203
+ targetKey,
204
+ handlerName,
205
+ nativeEvent
206
+ });
207
+ };
208
+ }
209
+ export function registerHandler(name, handler) {
210
+ globalThis.__stxHandlers = globalThis.__stxHandlers || {};
211
+ globalThis.__stxHandlers[name] = handler;
212
+ }
213
+ export function callHandler(name, ...args) {
214
+ const handler = globalThis.__stxHandlers?.[name];
215
+ if (handler)
216
+ return handler(...args);
217
+ console.warn(`[STXBridge] Handler not found: ${name}`);
218
+ return;
219
+ }
@@ -0,0 +1,24 @@
1
+ import type { NativeDiagnostic } from './compiler/bundle';
2
+ /** The screens config for a project, or null when it has none. */
3
+ export declare function loadNativeScreensConfig(cwd?: string, configFile?: string): NativeScreensConfig | null;
4
+ /** What `stx native compile` does, without the process around it. */
5
+ export declare function runNativeCompile(file: string | undefined, options?: NativeCompileOptions): Promise<NativeCompileResult>;
6
+ /** The config file names looked for, in order. The second is the old name. */
7
+ export declare const NATIVE_CONFIG_FILES: string[];
8
+ export declare interface NativeScreensConfig {
9
+ initialScreen: string
10
+ screens: Record<string, string>
11
+ file: string
12
+ }
13
+ export declare interface NativeCompileOptions {
14
+ format?: 'ir' | 'bundle'
15
+ output?: string
16
+ minify?: boolean
17
+ config?: string
18
+ cwd?: string
19
+ }
20
+ export declare interface NativeCompileResult {
21
+ output: string
22
+ written?: string
23
+ diagnostics: NativeDiagnostic[]
24
+ }
@@ -0,0 +1,52 @@
1
+ import { existsSync, mkdirSync, readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { compileNativeBundle, compileScreenBundle } from "./compiler/bundle.js";
4
+ import { parseSTX } from "./compiler/parser.js";
5
+ export const NATIVE_CONFIG_FILES = ["native.config.json", "stx-native.config.json"];
6
+ export function loadNativeScreensConfig(cwd = process.cwd(), configFile) {
7
+ const file = configFile ? path.resolve(cwd, configFile) : NATIVE_CONFIG_FILES.map((name) => path.join(cwd, name)).find((candidate) => existsSync(candidate));
8
+ if (!file)
9
+ return null;
10
+ if (!existsSync(file))
11
+ throw Error(`Native config not found: ${file}`);
12
+ const raw = JSON.parse(readFileSync(file, "utf8")), entries = Object.entries(raw.screens ?? {});
13
+ if (entries.length === 0)
14
+ throw Error(`${path.basename(file)} must name at least one screen in "screens"`);
15
+ const screens = {};
16
+ for (const [name, screen] of entries) {
17
+ if (!/^[A-Z][\w-]*$/i.test(name))
18
+ throw Error(`Invalid native screen name: ${name}`);
19
+ if (typeof screen !== "string" || !screen.endsWith(".stx"))
20
+ throw Error(`Screen ${name} must name a .stx file`);
21
+ screens[name] = path.resolve(path.dirname(file), screen);
22
+ if (!existsSync(screens[name]))
23
+ throw Error(`Screen ${name} not found: ${screens[name]}`);
24
+ }
25
+ const initialScreen = raw.initialScreen || entries[0][0];
26
+ if (!screens[initialScreen])
27
+ throw Error(`Initial screen ${initialScreen} is not in screens`);
28
+ return { initialScreen, screens, file };
29
+ }
30
+ export async function runNativeCompile(file, options = {}) {
31
+ const cwd = path.resolve(options.cwd ?? process.cwd()), format = options.format ?? "ir";
32
+ if (format !== "ir" && format !== "bundle")
33
+ throw Error(`Unknown compile format: ${format}. Expected ir or bundle.`);
34
+ const config = file ? null : loadNativeScreensConfig(cwd, options.config);
35
+ if (!file && !config)
36
+ throw Error(`Please specify an input file: stx native compile <file.stx>, or add ${NATIVE_CONFIG_FILES[0]}`);
37
+ let output, diagnostics = [];
38
+ if (format === "bundle") {
39
+ const bundle = config ? await compileNativeBundle({ screens: config.screens, initialScreen: config.initialScreen, minify: options.minify, root: cwd }) : await compileScreenBundle(path.resolve(cwd, file), { minify: options.minify });
40
+ output = bundle.code;
41
+ diagnostics = bundle.diagnostics;
42
+ } else {
43
+ const parse = (source) => parseSTX(readFileSync(source, "utf8"), source), ir = config ? { initialScreen: config.initialScreen, screens: Object.fromEntries(Object.entries(config.screens).map(([name, source]) => [name, parse(source)])) } : parse(path.resolve(cwd, file));
44
+ output = JSON.stringify(ir, null, 2);
45
+ }
46
+ if (!options.output)
47
+ return { output, diagnostics };
48
+ const written = path.resolve(cwd, options.output);
49
+ mkdirSync(path.dirname(written), { recursive: !0 });
50
+ await Bun.write(written, output);
51
+ return { output, written, diagnostics };
52
+ }
@@ -0,0 +1,41 @@
1
+ import { RUNTIME_SPECIFIER } from './codegen';
2
+ /**
3
+ * Build the bundle the host loads as `native-screen.js`.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { compileNativeBundle } from '@stacksjs/stx/native'
8
+ *
9
+ * const { outFile, diagnostics } = await compileNativeBundle({
10
+ * screens: { Today: 'resources/native/Today.stx' },
11
+ * initialScreen: 'Today',
12
+ * minify: true,
13
+ * outFile: 'storage/framework/native/native-screen.js',
14
+ * root: process.cwd(),
15
+ * })
16
+ * ```
17
+ */
18
+ export declare function compileNativeBundle(options: CompileNativeBundleOptions): Promise<NativeBundleResult>;
19
+ /** One `.stx` file, as the single-screen bundle `compile <file> --format bundle` writes. */
20
+ export declare function compileScreenBundle(file: string, options?: Pick<CompileNativeBundleOptions, 'minify' | 'outFile' | 'root'>): Promise<NativeBundleResult>;
21
+ export declare interface CompileNativeBundleOptions {
22
+ screens: Record<string, string>
23
+ initialScreen?: string
24
+ minify?: boolean
25
+ routed?: boolean
26
+ outFile?: string
27
+ root?: string
28
+ }
29
+ /** Something the compiler could not translate exactly: an unknown icon or class. */
30
+ export declare interface NativeDiagnostic {
31
+ level: 'warning'
32
+ message: string
33
+ }
34
+ export declare interface NativeBundleResult {
35
+ code: string
36
+ outFile?: string
37
+ diagnostics: NativeDiagnostic[]
38
+ }
39
+ /** @deprecated Use `CompileNativeBundleOptions`. */
40
+ export type BundleOptions = CompileNativeBundleOptions;
41
+ export { RUNTIME_SPECIFIER };