@stacksjs/stx 0.2.413 → 0.2.415

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 (346) 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.js +19 -11
  4. package/dist/bundle-analyzer.js +20 -20
  5. package/dist/chunk-020xyn9q.js +3 -0
  6. package/dist/chunk-04jhmfbz.js +2 -0
  7. package/dist/chunk-0pnj3zt2.js +2 -0
  8. package/dist/{chunk-bwjxk1dw.js → chunk-0zaess6f.js} +29 -29
  9. package/dist/chunk-1098mas0.js +2 -0
  10. package/dist/chunk-169n1vpx.js +12 -0
  11. package/dist/chunk-18vmfkcc.js +2 -0
  12. package/dist/chunk-1b6t12hd.js +2 -0
  13. package/dist/chunk-1xdzcy9d.js +14 -0
  14. package/dist/chunk-1zs30k3y.js +2 -0
  15. package/dist/chunk-2ce7f416.js +2 -0
  16. package/dist/chunk-340a824p.js +2 -0
  17. package/dist/chunk-393341w7.js +2 -0
  18. package/dist/chunk-39g1134q.js +2 -0
  19. package/dist/chunk-3efw27as.js +2785 -0
  20. package/dist/chunk-3kthfs03.js +3 -0
  21. package/dist/chunk-3qn1wcdg.js +2 -0
  22. package/dist/chunk-3s2vnqcf.js +2 -0
  23. package/dist/chunk-42wbs8vq.js +17 -0
  24. package/dist/chunk-4bjravgk.js +2 -0
  25. package/dist/chunk-5gsxpaqk.js +2 -0
  26. package/dist/{chunk-bwsxym3d.js → chunk-5qns2sdz.js} +17 -17
  27. package/dist/chunk-6cfa3g0r.js +2 -0
  28. package/dist/{chunk-bjar18jd.js → chunk-6h38kkjf.js} +46 -52
  29. package/dist/chunk-6hc5vz20.js +3 -0
  30. package/dist/chunk-6q6g76vg.js +499 -0
  31. package/dist/chunk-74j18qk0.js +930 -0
  32. package/dist/chunk-752hw7cd.js +4 -0
  33. package/dist/{chunk-kgd8kchy.js → chunk-765e1s44.js} +11 -76
  34. package/dist/chunk-7gkv67ky.js +4 -0
  35. package/dist/chunk-7z2ra0yf.js +2 -0
  36. package/dist/chunk-8eqrwj1k.js +20 -0
  37. package/dist/chunk-8nhshfz6.js +5 -0
  38. package/dist/chunk-92ps1xpk.js +2 -0
  39. package/dist/chunk-96k8s808.js +3 -0
  40. package/dist/chunk-9amp82bx.js +7 -0
  41. package/dist/chunk-9g27ybyr.js +3 -0
  42. package/dist/chunk-9p9qkbtg.js +3 -0
  43. package/dist/{chunk-xq1acw1r.js → chunk-9pt8fd2n.js} +13 -13
  44. package/dist/{chunk-24zher49.js → chunk-9vrja6vp.js} +4 -4
  45. package/dist/chunk-9xrbve19.js +2 -0
  46. package/dist/chunk-a688m6js.js +3 -0
  47. package/dist/chunk-ak1cgcah.js +5 -0
  48. package/dist/{chunk-4m7ajama.js → chunk-amd6ey3t.js} +14 -14
  49. package/dist/chunk-amtr3rmf.js +11 -0
  50. package/dist/chunk-atws6p5s.js +2 -0
  51. package/dist/chunk-b84h16er.js +61 -0
  52. package/dist/chunk-b98be3yp.js +32 -0
  53. package/dist/{chunk-hx998w7n.js → chunk-bay9s6rs.js} +13 -13
  54. package/dist/chunk-ce1sejr3.js +3 -0
  55. package/dist/chunk-cg8hg6cs.js +3 -0
  56. package/dist/{chunk-4f9zyfdw.js → chunk-czxt605c.js} +4 -5
  57. package/dist/chunk-dd8cja4h.js +2 -0
  58. package/dist/chunk-dgdm3hy3.js +2 -0
  59. package/dist/chunk-e9hs7kk6.js +12 -0
  60. package/dist/chunk-eed4fwps.js +3 -0
  61. package/dist/chunk-ej9j6k1q.js +3 -0
  62. package/dist/chunk-et0rr8c7.js +3 -0
  63. package/dist/chunk-f1sxycmv.js +2 -0
  64. package/dist/chunk-f46qsp4m.js +4 -0
  65. package/dist/chunk-fbcv4fes.js +2 -0
  66. package/dist/{chunk-bjcsc6wx.js → chunk-fh1qrp68.js} +21 -21
  67. package/dist/chunk-fjs0a8h7.js +2 -0
  68. package/dist/chunk-fpfzm238.js +2 -0
  69. package/dist/chunk-fr2txj8q.js +829 -0
  70. package/dist/{chunk-xssw417m.js → chunk-ft4p6d28.js} +14 -14
  71. package/dist/chunk-fyzajkrx.js +2 -0
  72. package/dist/chunk-fzapbw9p.js +3 -0
  73. package/dist/chunk-g03s93qr.js +3 -0
  74. package/dist/chunk-g186znp9.js +33 -0
  75. package/dist/chunk-gawrg4gb.js +216 -0
  76. package/dist/chunk-gc1drn2p.js +2 -0
  77. package/dist/chunk-gea5hf0v.js +2 -0
  78. package/dist/chunk-gqv3ta5d.js +2 -0
  79. package/dist/chunk-h6kp2m9r.js +2 -0
  80. package/dist/chunk-h6zsqb9r.js +3 -0
  81. package/dist/{chunk-2snqdnk9.js → chunk-h85hrwkq.js} +13 -13
  82. package/dist/chunk-hbxz85wy.js +2 -0
  83. package/dist/chunk-hepd9qgx.js +6 -0
  84. package/dist/chunk-hhnw2sn3.js +2 -0
  85. package/dist/chunk-hjg3ndgh.js +2 -0
  86. package/dist/chunk-hk1mj4tz.js +2 -0
  87. package/dist/{chunk-smcj3442.js → chunk-hkrmcbwy.js} +79 -79
  88. package/dist/chunk-hn9pkyv8.js +2 -0
  89. package/dist/chunk-hpgr4qgp.js +2 -0
  90. package/dist/chunk-hrbbbtbn.js +2 -0
  91. package/dist/chunk-j03revz2.js +8 -0
  92. package/dist/chunk-j9qcrwbg.js +2 -0
  93. package/dist/chunk-jk4njz0w.js +2 -0
  94. package/dist/chunk-jmabeqfq.js +2 -0
  95. package/dist/chunk-jnkrn913.js +4 -0
  96. package/dist/chunk-jp10q90g.js +2 -0
  97. package/dist/chunk-jt0n43mk.js +2 -0
  98. package/dist/chunk-kjbv8a3m.js +2 -0
  99. package/dist/chunk-m1vdghnx.js +2 -0
  100. package/dist/chunk-m4sk62wb.js +5 -0
  101. package/dist/chunk-md8rqn48.js +30 -0
  102. package/dist/chunk-mp6hy8g4.js +2 -0
  103. package/dist/chunk-nc8my58s.js +2 -0
  104. package/dist/chunk-ngc2wke4.js +3 -0
  105. package/dist/chunk-nn2vstke.js +2 -0
  106. package/dist/chunk-nppdrf0x.js +2 -0
  107. package/dist/chunk-p2v2a68k.js +2 -0
  108. package/dist/chunk-pazfr1a1.js +2 -0
  109. package/dist/{chunk-qn5srnj3.js → chunk-pbh4smw3.js} +16 -16
  110. package/dist/chunk-pdb5fw3r.js +2 -0
  111. package/dist/chunk-pdt69hpb.js +2 -0
  112. package/dist/chunk-pgzvyrv6.js +29 -0
  113. package/dist/chunk-px7fvbj6.js +3 -0
  114. package/dist/chunk-q6vrb2pe.js +2 -0
  115. package/dist/chunk-q7qchkvk.js +2 -0
  116. package/dist/chunk-q9bdh4s5.js +8 -0
  117. package/dist/chunk-qghxz7jm.js +194 -0
  118. package/dist/chunk-r3f9jcf7.js +5 -0
  119. package/dist/chunk-re8b5r9x.js +3 -0
  120. package/dist/chunk-s5xezjps.js +3 -0
  121. package/dist/chunk-sd321bn3.js +2 -0
  122. package/dist/chunk-shr559s7.js +3 -0
  123. package/dist/chunk-t4hzprsm.js +3 -0
  124. package/dist/chunk-t5pvq5mx.js +2 -0
  125. package/dist/{chunk-pv3d7sfn.js → chunk-t61vdbje.js} +89 -89
  126. package/dist/chunk-tafqyf2g.js +2033 -0
  127. package/dist/chunk-tfexmdkt.js +3 -0
  128. package/dist/chunk-thyt8ed8.js +6 -0
  129. package/dist/chunk-v91p6ekp.js +24 -0
  130. package/dist/chunk-vgvtnwxa.js +4 -0
  131. package/dist/chunk-w72qx0eb.js +2 -0
  132. package/dist/chunk-wfy1zq53.js +30 -0
  133. package/dist/chunk-wzx0164n.js +18 -0
  134. package/dist/chunk-x0q32ees.js +3 -0
  135. package/dist/chunk-xfp7k0v8.js +64 -0
  136. package/dist/chunk-xtvf6n6f.js +4 -0
  137. package/dist/chunk-xwzvfqcb.js +2 -0
  138. package/dist/chunk-y1cmjvk3.js +43 -0
  139. package/dist/chunk-y5310237.js +311 -0
  140. package/dist/chunk-ya0qecph.js +27 -0
  141. package/dist/chunk-yazk54jr.js +8 -0
  142. package/dist/chunk-ydjfar14.js +2 -0
  143. package/dist/chunk-ym95v4nc.js +3 -0
  144. package/dist/chunk-z0g9jvv0.js +40 -0
  145. package/dist/chunk-z23kaxq6.js +2 -0
  146. package/dist/chunk-z8xn5ta3.js +2 -0
  147. package/dist/{chunk-8sdhs0zk.js → chunk-zhxdpzga.js} +4 -4
  148. package/dist/cli.js +110 -110
  149. package/dist/craft-entry.js +7 -7
  150. package/dist/craft.js +7 -7
  151. package/dist/database.js +2 -2
  152. package/dist/image-optimization/component.js +4 -4
  153. package/dist/media/image/component.js +5 -5
  154. package/dist/media/protected/component.js +2 -2
  155. package/dist/media/video/index.js +4 -4
  156. package/dist/native/bridge/protocol.d.ts +325 -0
  157. package/dist/native/bridge/protocol.js +219 -0
  158. package/dist/native/cli.d.ts +24 -0
  159. package/dist/native/cli.js +52 -0
  160. package/dist/native/compiler/bundle.d.ts +41 -0
  161. package/dist/native/compiler/bundle.js +90 -0
  162. package/dist/native/compiler/client-script.d.ts +8 -0
  163. package/dist/native/compiler/client-script.js +31 -0
  164. package/dist/native/compiler/codegen.d.ts +10 -0
  165. package/dist/native/compiler/codegen.js +145 -0
  166. package/dist/native/compiler/headwind-to-style.d.ts +395 -0
  167. package/dist/native/compiler/headwind-to-style.js +1163 -0
  168. package/dist/native/compiler/html-to-ir.d.ts +41 -0
  169. package/dist/native/compiler/html-to-ir.js +411 -0
  170. package/dist/native/compiler/icons.d.ts +220 -0
  171. package/dist/native/compiler/icons.js +208 -0
  172. package/dist/native/compiler/ir.d.ts +234 -0
  173. package/dist/native/compiler/ir.js +15 -0
  174. package/dist/native/compiler/parser.d.ts +88 -0
  175. package/dist/native/compiler/parser.js +753 -0
  176. package/dist/native/compiler/render-screen.d.ts +26 -0
  177. package/dist/native/compiler/render-screen.js +31 -0
  178. package/dist/native/components/primitives.d.ts +291 -0
  179. package/dist/native/components/primitives.js +22 -0
  180. package/dist/native/hot-reload/client.d.ts +62 -0
  181. package/dist/native/hot-reload/client.js +324 -0
  182. package/dist/native/index.d.ts +90 -0
  183. package/dist/native/index.js +34 -0
  184. package/dist/native/primitives/ActivityIndicator.stx +5 -0
  185. package/dist/native/primitives/Button.stx +5 -0
  186. package/dist/native/primitives/DatePicker.stx +5 -0
  187. package/dist/native/primitives/FlatList.stx +5 -0
  188. package/dist/native/primitives/Image.stx +5 -0
  189. package/dist/native/primitives/ImageBackground.stx +5 -0
  190. package/dist/native/primitives/KeyboardAvoidingView.stx +5 -0
  191. package/dist/native/primitives/Modal.stx +5 -0
  192. package/dist/native/primitives/Picker.stx +5 -0
  193. package/dist/native/primitives/Pressable.stx +5 -0
  194. package/dist/native/primitives/RefreshControl.stx +5 -0
  195. package/dist/native/primitives/SafeAreaView.stx +5 -0
  196. package/dist/native/primitives/ScrollView.stx +5 -0
  197. package/dist/native/primitives/SectionList.stx +5 -0
  198. package/dist/native/primitives/Slider.stx +5 -0
  199. package/dist/native/primitives/StatusBar.stx +5 -0
  200. package/dist/native/primitives/Switch.stx +5 -0
  201. package/dist/native/primitives/Text.stx +5 -0
  202. package/dist/native/primitives/TextInput.stx +5 -0
  203. package/dist/native/primitives/TouchableHighlight.stx +5 -0
  204. package/dist/native/primitives/TouchableOpacity.stx +5 -0
  205. package/dist/native/primitives/View.stx +5 -0
  206. package/dist/native/runtime/craft.d.ts +75 -0
  207. package/dist/native/runtime/craft.js +0 -0
  208. package/dist/native/runtime/entry.d.ts +1 -0
  209. package/dist/native/runtime/entry.js +3 -0
  210. package/dist/native/runtime/index.d.ts +45 -0
  211. package/dist/native/runtime/index.js +165 -0
  212. package/dist/native/runtime/native-host.d.ts +33 -0
  213. package/dist/native/runtime/native-host.js +184 -0
  214. package/dist/native/runtime/screen.d.ts +43 -0
  215. package/dist/native/runtime/screen.js +808 -0
  216. package/dist/pwa/service-worker.js +1 -1
  217. package/dist/pwa/workbox.js +1 -1
  218. package/dist/pwa.js +8 -8
  219. package/dist/site-url.d.ts +1 -1
  220. package/dist/ssg.js +53 -53
  221. package/dist/visual-testing.js +42 -42
  222. package/dist/web-components/reactive-generator.js +2 -2
  223. package/package.json +9 -5
  224. package/dist/chunk-0btmm4m2.js +0 -147
  225. package/dist/chunk-0c2h69k2.js +0 -4
  226. package/dist/chunk-0d0qeqvv.js +0 -2
  227. package/dist/chunk-0psndabd.js +0 -2
  228. package/dist/chunk-0qv8yf53.js +0 -2
  229. package/dist/chunk-0vkxyvsd.js +0 -2
  230. package/dist/chunk-0we9nw1d.js +0 -3
  231. package/dist/chunk-0xqdmemy.js +0 -3
  232. package/dist/chunk-0y46fbkx.js +0 -3
  233. package/dist/chunk-158wqccn.js +0 -4422
  234. package/dist/chunk-1cyxbb8y.js +0 -16
  235. package/dist/chunk-1enwnh2a.js +0 -2
  236. package/dist/chunk-213pzm0d.js +0 -3
  237. package/dist/chunk-21hzqyja.js +0 -12
  238. package/dist/chunk-266t58b8.js +0 -5
  239. package/dist/chunk-27fgag95.js +0 -4
  240. package/dist/chunk-2a9n102n.js +0 -2
  241. package/dist/chunk-2eqzrczk.js +0 -2
  242. package/dist/chunk-2ke37m54.js +0 -14
  243. package/dist/chunk-35ds08e7.js +0 -3
  244. package/dist/chunk-3mtwkjcg.js +0 -2
  245. package/dist/chunk-4xr8zwkp.js +0 -2
  246. package/dist/chunk-58v77x2c.js +0 -2
  247. package/dist/chunk-5mhq8605.js +0 -2
  248. package/dist/chunk-5se8xt9e.js +0 -64
  249. package/dist/chunk-5zh0h080.js +0 -2
  250. package/dist/chunk-62435225.js +0 -2
  251. package/dist/chunk-6kdrncsx.js +0 -30
  252. package/dist/chunk-6n2rr3x7.js +0 -2
  253. package/dist/chunk-6xk87qf2.js +0 -30
  254. package/dist/chunk-72rwcbp6.js +0 -3
  255. package/dist/chunk-76w34xne.js +0 -3
  256. package/dist/chunk-7ekd7zj9.js +0 -2
  257. package/dist/chunk-7pr3wdd5.js +0 -3
  258. package/dist/chunk-7rxvafwc.js +0 -24
  259. package/dist/chunk-7tnwfa7w.js +0 -8
  260. package/dist/chunk-8c5je0wf.js +0 -2
  261. package/dist/chunk-8dz6nyvx.js +0 -2
  262. package/dist/chunk-98zj3fv2.js +0 -7
  263. package/dist/chunk-9e8t0twa.js +0 -3
  264. package/dist/chunk-9fqp72ze.js +0 -5
  265. package/dist/chunk-anydpa34.js +0 -3
  266. package/dist/chunk-ay6zjq8v.js +0 -3
  267. package/dist/chunk-az4v4ard.js +0 -3
  268. package/dist/chunk-ba5erggg.js +0 -2
  269. package/dist/chunk-bnagrdz6.js +0 -2
  270. package/dist/chunk-by8wghtf.js +0 -2
  271. package/dist/chunk-cd7h4q51.js +0 -2
  272. package/dist/chunk-cjmv8hgp.js +0 -33
  273. package/dist/chunk-cthf912y.js +0 -2
  274. package/dist/chunk-cxbpmwq5.js +0 -4
  275. package/dist/chunk-d3sy16qn.js +0 -2
  276. package/dist/chunk-dh6s7mrj.js +0 -1199
  277. package/dist/chunk-dm2nzg7a.js +0 -2
  278. package/dist/chunk-e2sgcnxc.js +0 -2
  279. package/dist/chunk-e3b7jj74.js +0 -2
  280. package/dist/chunk-ec4wq2sv.js +0 -6
  281. package/dist/chunk-ekzg97dn.js +0 -29
  282. package/dist/chunk-epjt342x.js +0 -2
  283. package/dist/chunk-eqe26g14.js +0 -18
  284. package/dist/chunk-ev0v1yma.js +0 -2
  285. package/dist/chunk-f53psr2y.js +0 -5
  286. package/dist/chunk-f8p69dsg.js +0 -3
  287. package/dist/chunk-f95drhdb.js +0 -194
  288. package/dist/chunk-ff5a6hvb.js +0 -17
  289. package/dist/chunk-fs5fy4h8.js +0 -2
  290. package/dist/chunk-fzsygce3.js +0 -2
  291. package/dist/chunk-g465x63k.js +0 -2
  292. package/dist/chunk-g708ekh1.js +0 -2
  293. package/dist/chunk-gcr9e83g.js +0 -11
  294. package/dist/chunk-gdmyrsr8.js +0 -4
  295. package/dist/chunk-gkms2ngq.js +0 -2
  296. package/dist/chunk-gnfywmgs.js +0 -7
  297. package/dist/chunk-hpf8kq7e.js +0 -2
  298. package/dist/chunk-j4x3faf8.js +0 -2
  299. package/dist/chunk-jkavtw9f.js +0 -2
  300. package/dist/chunk-kg1rdena.js +0 -3
  301. package/dist/chunk-km91wx0v.js +0 -2
  302. package/dist/chunk-kmsyvaex.js +0 -8
  303. package/dist/chunk-mrahwn5v.js +0 -8
  304. package/dist/chunk-nk3czvnk.js +0 -2
  305. package/dist/chunk-nmw4eewb.js +0 -2
  306. package/dist/chunk-nq5zxrk0.js +0 -4
  307. package/dist/chunk-ny67c03k.js +0 -3
  308. package/dist/chunk-p4wdxp2c.js +0 -2
  309. package/dist/chunk-pcxp4r9n.js +0 -3
  310. package/dist/chunk-pdyeaxc1.js +0 -2
  311. package/dist/chunk-pf06ded4.js +0 -2
  312. package/dist/chunk-pfs0gpzm.js +0 -2
  313. package/dist/chunk-pshdwq44.js +0 -2
  314. package/dist/chunk-pwgv84pn.js +0 -32
  315. package/dist/chunk-pwsnafp3.js +0 -4367
  316. package/dist/chunk-q9n5swx7.js +0 -3
  317. package/dist/chunk-qr346wnp.js +0 -2
  318. package/dist/chunk-r02hke04.js +0 -2
  319. package/dist/chunk-ranshpyc.js +0 -3
  320. package/dist/chunk-rn194bhp.js +0 -20
  321. package/dist/chunk-rn1hgyc8.js +0 -930
  322. package/dist/chunk-s7z5dp70.js +0 -43
  323. package/dist/chunk-s8jd13nb.js +0 -3
  324. package/dist/chunk-sn7exv0n.js +0 -2
  325. package/dist/chunk-t1tdjjht.js +0 -216
  326. package/dist/chunk-t6qx04s8.js +0 -499
  327. package/dist/chunk-t6y6gyps.js +0 -2
  328. package/dist/chunk-tjfs7cc3.js +0 -2
  329. package/dist/chunk-tkyrk66a.js +0 -3
  330. package/dist/chunk-tntv9hvq.js +0 -2
  331. package/dist/chunk-v3nwkveg.js +0 -12
  332. package/dist/chunk-vd4cb5xr.js +0 -2
  333. package/dist/chunk-vkhdce50.js +0 -2
  334. package/dist/chunk-w183av08.js +0 -2
  335. package/dist/chunk-w2m02njv.js +0 -2
  336. package/dist/chunk-wpjrcrs5.js +0 -2
  337. package/dist/chunk-wqmppf6b.js +0 -3
  338. package/dist/chunk-wtb9fxdy.js +0 -2
  339. package/dist/chunk-xmzygmcz.js +0 -3
  340. package/dist/chunk-xsng1mtq.js +0 -3
  341. package/dist/chunk-xxzefj4j.js +0 -2
  342. package/dist/chunk-yq8x8bxq.js +0 -47
  343. package/dist/chunk-ytma76qe.js +0 -3
  344. package/dist/chunk-yw1m115e.js +0 -2
  345. package/dist/chunk-z64a924m.js +0 -2
  346. package/dist/chunk-zcz9rs6p.js +0 -3
@@ -0,0 +1,324 @@
1
+ import { getBridge } from "../bridge/protocol.js";
2
+
3
+ class HotReloadClient {
4
+ ws = null;
5
+ serverUrl;
6
+ reconnectAttempts = 0;
7
+ maxReconnectAttempts = 10;
8
+ reconnectDelay = 1000;
9
+ callbacks = new Set;
10
+ savedState = null;
11
+ isConnected = !1;
12
+ constructor(serverUrl = "ws://localhost:8081") {
13
+ this.serverUrl = serverUrl;
14
+ }
15
+ connect() {
16
+ if (this.ws?.readyState === WebSocket.OPEN) {
17
+ console.log("[HotReload] Already connected");
18
+ return;
19
+ }
20
+ try {
21
+ this.ws = new WebSocket(this.serverUrl);
22
+ this.ws.onopen = () => {
23
+ console.log("[HotReload] Connected to dev server");
24
+ this.isConnected = !0;
25
+ this.reconnectAttempts = 0;
26
+ };
27
+ this.ws.onmessage = (event) => {
28
+ this.handleMessage(event.data);
29
+ };
30
+ this.ws.onerror = (error) => {
31
+ console.error("[HotReload] WebSocket error:", error);
32
+ };
33
+ this.ws.onclose = () => {
34
+ console.log("[HotReload] Disconnected from dev server");
35
+ this.isConnected = !1;
36
+ this.attemptReconnect();
37
+ };
38
+ } catch (error) {
39
+ console.error("[HotReload] Failed to connect:", error);
40
+ this.attemptReconnect();
41
+ }
42
+ }
43
+ disconnect() {
44
+ if (this.ws) {
45
+ this.ws.close();
46
+ this.ws = null;
47
+ }
48
+ this.isConnected = !1;
49
+ }
50
+ get connected() {
51
+ return this.isConnected;
52
+ }
53
+ attemptReconnect() {
54
+ if (this.reconnectAttempts >= this.maxReconnectAttempts) {
55
+ console.error("[HotReload] Max reconnect attempts reached");
56
+ return;
57
+ }
58
+ this.reconnectAttempts++;
59
+ const delay = this.reconnectDelay * Math.pow(1.5, this.reconnectAttempts - 1);
60
+ console.log(`[HotReload] Reconnecting in ${Math.round(delay)}ms (attempt ${this.reconnectAttempts})`);
61
+ setTimeout(() => {
62
+ this.connect();
63
+ }, delay);
64
+ }
65
+ handleMessage(data) {
66
+ try {
67
+ const message = JSON.parse(data);
68
+ switch (message.type) {
69
+ case "HOT_RELOAD":
70
+ this.handleHotReload(message.payload);
71
+ break;
72
+ case "FULL_RELOAD":
73
+ this.handleFullReload();
74
+ break;
75
+ case "ERROR":
76
+ this.handleError(message.payload.error || "Unknown error");
77
+ break;
78
+ default:
79
+ console.warn("[HotReload] Unknown message type:", message.type);
80
+ }
81
+ } catch (error) {
82
+ console.error("[HotReload] Failed to parse message:", error);
83
+ }
84
+ }
85
+ handleHotReload(payload) {
86
+ console.log("[HotReload] Received update for:", payload.changedFiles);
87
+ if (payload.preserveState)
88
+ this.saveState();
89
+ if (payload.document) {
90
+ for (const callback of this.callbacks)
91
+ try {
92
+ callback(payload.document);
93
+ } catch (error) {
94
+ console.error("[HotReload] Callback error:", error);
95
+ }
96
+ this.applyUpdate(payload.document);
97
+ if (payload.preserveState && this.savedState)
98
+ this.restoreState();
99
+ }
100
+ }
101
+ handleFullReload() {
102
+ console.log("[HotReload] Full reload requested");
103
+ if (typeof location < "u")
104
+ location.reload();
105
+ }
106
+ handleError(error) {
107
+ console.error("[HotReload] Server error:", error);
108
+ }
109
+ saveState() {
110
+ this.savedState = {
111
+ state: this.captureState(),
112
+ scrollPositions: this.captureScrollPositions(),
113
+ focusedKey: this.captureFocus(),
114
+ inputValues: this.captureInputValues()
115
+ };
116
+ console.log("[HotReload] State saved");
117
+ }
118
+ restoreState() {
119
+ if (!this.savedState)
120
+ return;
121
+ this.applyState(this.savedState.state);
122
+ setTimeout(() => {
123
+ this.applyScrollPositions(this.savedState.scrollPositions);
124
+ this.applyInputValues(this.savedState.inputValues);
125
+ this.applyFocus(this.savedState.focusedKey);
126
+ }, 100);
127
+ console.log("[HotReload] State restored");
128
+ this.savedState = null;
129
+ }
130
+ captureState() {
131
+ const state = {}, doc = globalThis.__STX_DOCUMENT__;
132
+ if (doc?.script?.exports)
133
+ Object.assign(state, doc.script.exports);
134
+ return state;
135
+ }
136
+ applyState(state) {
137
+ for (const [key, value] of Object.entries(state))
138
+ try {
139
+ if (typeof globalThis[key] < "u")
140
+ globalThis[key] = value;
141
+ } catch (error) {
142
+ console.warn(`[HotReload] Could not restore state for ${key}:`, error);
143
+ }
144
+ }
145
+ captureScrollPositions() {
146
+ return new Map;
147
+ }
148
+ applyScrollPositions(positions) {
149
+ for (const [key, pos] of positions)
150
+ getBridge().send("API_REQUEST", {
151
+ module: "scrollView",
152
+ method: "scrollTo",
153
+ args: [key, pos.x, pos.y]
154
+ });
155
+ }
156
+ captureFocus() {
157
+ return null;
158
+ }
159
+ applyFocus(key) {
160
+ if (key)
161
+ getBridge().send("API_REQUEST", {
162
+ module: "focus",
163
+ method: "requestFocus",
164
+ args: [key]
165
+ });
166
+ }
167
+ captureInputValues() {
168
+ return new Map;
169
+ }
170
+ applyInputValues(values) {
171
+ for (const [key, value] of values)
172
+ getBridge().update([{ key, props: { value } }]);
173
+ }
174
+ applyUpdate(document) {
175
+ const bridge = getBridge();
176
+ if (document.script.code)
177
+ try {} catch (error) {
178
+ console.error("[HotReload] Failed to execute script:", error);
179
+ }
180
+ bridge.render(document.root, { mode: "replace" });
181
+ console.log("[HotReload] UI updated");
182
+ }
183
+ onReload(callback) {
184
+ this.callbacks.add(callback);
185
+ return () => this.callbacks.delete(callback);
186
+ }
187
+ send(type, payload) {
188
+ if (this.ws?.readyState === WebSocket.OPEN)
189
+ this.ws.send(JSON.stringify({ type, payload }));
190
+ }
191
+ }
192
+
193
+ class ErrorOverlay {
194
+ visible = !1;
195
+ show(options) {
196
+ const bridge = getBridge(), errorMessage = typeof options.error === "string" ? options.error : options.error.message, errorStack = typeof options.error === "object" ? options.error.stack : void 0, overlayNode = {
197
+ type: "View",
198
+ props: {},
199
+ style: {
200
+ position: "absolute",
201
+ top: 0,
202
+ left: 0,
203
+ right: 0,
204
+ bottom: 0,
205
+ backgroundColor: "rgba(0, 0, 0, 0.9)",
206
+ padding: 20
207
+ },
208
+ events: {},
209
+ children: [
210
+ {
211
+ type: "SafeAreaView",
212
+ props: {},
213
+ style: { flex: 1 },
214
+ events: {},
215
+ children: [
216
+ {
217
+ type: "ScrollView",
218
+ props: {},
219
+ style: { flex: 1 },
220
+ events: {},
221
+ children: [
222
+ {
223
+ type: "Text",
224
+ props: {},
225
+ style: {
226
+ color: "#ff6b6b",
227
+ fontSize: 20,
228
+ fontWeight: "bold",
229
+ marginBottom: 16
230
+ },
231
+ events: {},
232
+ children: ["\u274C Build Error"]
233
+ },
234
+ {
235
+ type: "Text",
236
+ props: {},
237
+ style: {
238
+ color: "#ffffff",
239
+ fontSize: 16,
240
+ marginBottom: 8
241
+ },
242
+ events: {},
243
+ children: [errorMessage]
244
+ },
245
+ ...options.source ? [{
246
+ type: "Text",
247
+ props: {},
248
+ style: {
249
+ color: "#888888",
250
+ fontSize: 14,
251
+ marginBottom: 16
252
+ },
253
+ events: {},
254
+ children: [`at ${options.source}${options.line ? `:${options.line}` : ""}${options.column ? `:${options.column}` : ""}`]
255
+ }] : [],
256
+ ...errorStack ? [{
257
+ type: "Text",
258
+ props: {},
259
+ style: {
260
+ color: "#666666",
261
+ fontSize: 12,
262
+ fontFamily: "monospace"
263
+ },
264
+ events: {},
265
+ children: [errorStack]
266
+ }] : [],
267
+ {
268
+ type: "TouchableOpacity",
269
+ props: {},
270
+ style: {
271
+ backgroundColor: "#444444",
272
+ padding: 12,
273
+ borderRadius: 8,
274
+ marginTop: 20,
275
+ alignItems: "center"
276
+ },
277
+ events: { onPress: "__stx_dismiss_error__" },
278
+ children: [
279
+ {
280
+ type: "Text",
281
+ props: {},
282
+ style: { color: "#ffffff", fontSize: 14 },
283
+ events: {},
284
+ children: ["Dismiss"]
285
+ }
286
+ ]
287
+ }
288
+ ]
289
+ }
290
+ ]
291
+ }
292
+ ]
293
+ };
294
+ globalThis.__stxHandlers.__stx_dismiss_error__ = () => {
295
+ this.hide();
296
+ };
297
+ bridge.render(overlayNode, { containerId: "__error_overlay__", mode: "replace" });
298
+ this.visible = !0;
299
+ }
300
+ hide() {
301
+ if (!this.visible)
302
+ return;
303
+ getBridge().remove(["__error_overlay__"]);
304
+ this.visible = !1;
305
+ }
306
+ }
307
+ let hotReloadClient = null, errorOverlay = null;
308
+ export function getHotReloadClient(serverUrl) {
309
+ if (!hotReloadClient)
310
+ hotReloadClient = new HotReloadClient(serverUrl);
311
+ return hotReloadClient;
312
+ }
313
+ export function getErrorOverlay() {
314
+ if (!errorOverlay)
315
+ errorOverlay = new ErrorOverlay;
316
+ return errorOverlay;
317
+ }
318
+ export function initHotReload(serverUrl) {
319
+ const client = getHotReloadClient(serverUrl);
320
+ client.connect();
321
+ return client;
322
+ }
323
+
324
+ export { HotReloadClient, ErrorOverlay };
@@ -0,0 +1,90 @@
1
+ export type * from './runtime/craft';
2
+ // Re-export types
3
+ export type {
4
+ STXNode,
5
+ STXStyle,
6
+ STXDocument,
7
+ STXComponentType,
8
+ STXEventType,
9
+ } from './compiler/ir';
10
+ export type {
11
+ ViewProps,
12
+ TextProps,
13
+ ButtonProps,
14
+ ImageProps,
15
+ TextInputProps,
16
+ ScrollViewProps,
17
+ FlatListProps,
18
+ ModalProps,
19
+ SwitchProps,
20
+ SliderProps,
21
+ } from './components/primitives';
22
+ export type { Token, TokenType } from './compiler/parser';
23
+ export type {
24
+ HotReloadMessage,
25
+ HotReloadState,
26
+ HotReloadCallback,
27
+ ErrorOverlayOptions,
28
+ } from './hot-reload/client';
29
+ export type { RuntimeConfig } from './runtime/index';
30
+ /**
31
+ * `@stacksjs/stx/native`: stx templates as native iOS/Android screens.
32
+ *
33
+ * A `.stx` screen compiles to a JavaScriptCore bundle that Craft renders with
34
+ * UIKit (and Android views): the template becomes data, its expressions and
35
+ * handlers real functions, and every render re-evaluates them on the device.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { compileNativeBundle } from '@stacksjs/stx/native'
40
+ *
41
+ * const { outFile, diagnostics } = await compileNativeBundle({
42
+ * screens: { Today: 'resources/native/Today.stx' },
43
+ * initialScreen: 'Today',
44
+ * minify: true,
45
+ * outFile: 'dist/native-screen.js',
46
+ * })
47
+ * ```
48
+ *
49
+ * From the command line: `stx native compile --format bundle --output native-screen.js`.
50
+ */
51
+ // Compiler exports
52
+ export * from './compiler/ir';
53
+ export * from './compiler/headwind-to-style';
54
+ export * from './compiler/parser';
55
+ export * from './compiler/html-to-ir';
56
+ export * from './compiler/client-script';
57
+ export * from './compiler/render-screen';
58
+ export * from './compiler/bundle';
59
+ export * from './compiler/icons';
60
+ export * from './cli';
61
+ // Bridge exports
62
+ export * from './bridge/protocol';
63
+ // Component exports
64
+ export * from './components/primitives';
65
+ // Parser exports
66
+ export {
67
+ parseSTX,
68
+ parseSTXToNode,
69
+ compileSTX,
70
+ compileSTXFiles,
71
+ mapToNativeComponent,
72
+ transformToNativeComponents,
73
+ } from './compiler/parser';
74
+ // Hot Reload exports
75
+ export {
76
+ getHotReloadClient,
77
+ getErrorOverlay,
78
+ initHotReload,
79
+ HotReloadClient,
80
+ ErrorOverlay,
81
+ } from './hot-reload/client';
82
+ // Runtime exports
83
+ export {
84
+ getRuntime,
85
+ startRuntime,
86
+ render,
87
+ setState,
88
+ getState,
89
+ STXRuntime,
90
+ } from './runtime/index';
@@ -0,0 +1,34 @@
1
+ export * from "./compiler/ir.js";
2
+ export * from "./compiler/headwind-to-style.js";
3
+ export * from "./compiler/parser.js";
4
+ export * from "./compiler/html-to-ir.js";
5
+ export * from "./compiler/client-script.js";
6
+ export * from "./compiler/render-screen.js";
7
+ export * from "./compiler/bundle.js";
8
+ export * from "./compiler/icons.js";
9
+ export * from "./cli.js";
10
+ export * from "./bridge/protocol.js";
11
+ export * from "./components/primitives.js";
12
+ export {
13
+ parseSTX,
14
+ parseSTXToNode,
15
+ compileSTX,
16
+ compileSTXFiles,
17
+ mapToNativeComponent,
18
+ transformToNativeComponents
19
+ } from "./compiler/parser.js";
20
+ export {
21
+ getHotReloadClient,
22
+ getErrorOverlay,
23
+ initHotReload,
24
+ HotReloadClient,
25
+ ErrorOverlay
26
+ } from "./hot-reload/client.js";
27
+ export {
28
+ getRuntime,
29
+ startRuntime,
30
+ render,
31
+ setState,
32
+ getState,
33
+ STXRuntime
34
+ } from "./runtime/index.js";
@@ -0,0 +1,5 @@
1
+ {{-- ActivityIndicator: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="ActivityIndicator" class="{{ classes }}" role="status" />
@@ -0,0 +1,5 @@
1
+ {{-- Button: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <button data-native="Button" class="{{ classes }}" type="button"><slot /></button>
@@ -0,0 +1,5 @@
1
+ {{-- DatePicker: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="DatePicker" class="{{ classes }}" />
@@ -0,0 +1,5 @@
1
+ {{-- FlatList: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="FlatList" class="{{ classes }}" role="list"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- Image: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <img data-native="Image" class="{{ classes }}" />
@@ -0,0 +1,5 @@
1
+ {{-- ImageBackground: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="ImageBackground" class="{{ classes }}"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- KeyboardAvoidingView: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="KeyboardAvoidingView" class="{{ classes }}"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- Modal: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="Modal" class="{{ classes }}" role="dialog" />
@@ -0,0 +1,5 @@
1
+ {{-- Picker: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="Picker" class="{{ classes }}"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- Pressable: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="Pressable" class="{{ classes }}" role="button"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- RefreshControl: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="RefreshControl" class="{{ classes }}" />
@@ -0,0 +1,5 @@
1
+ {{-- SafeAreaView: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <header data-native="SafeAreaView" class="{{ classes }}"><slot /></header>
@@ -0,0 +1,5 @@
1
+ {{-- ScrollView: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="ScrollView" class="{{ classes }}"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- SectionList: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="SectionList" class="{{ classes }}" role="list"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- Slider: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="Slider" class="{{ classes }}" role="slider" />
@@ -0,0 +1,5 @@
1
+ {{-- StatusBar: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="StatusBar" class="{{ classes }}" />
@@ -0,0 +1,5 @@
1
+ {{-- Switch: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="Switch" class="{{ classes }}" role="switch" />
@@ -0,0 +1,5 @@
1
+ {{-- Text: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <span data-native="Text" class="{{ classes }}"><slot /></span>
@@ -0,0 +1,5 @@
1
+ {{-- TextInput: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <input data-native="TextInput" class="{{ classes }}" />
@@ -0,0 +1,5 @@
1
+ {{-- TouchableHighlight: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="TouchableHighlight" class="{{ classes }}" role="button"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- TouchableOpacity: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="TouchableOpacity" class="{{ classes }}" role="button"><slot /></div>
@@ -0,0 +1,5 @@
1
+ {{-- View: the native type, written as an ordinary stx component. --}}
2
+ <script server>
3
+ const classes = $props.class ?? $props.className ?? ''
4
+ </script>
5
+ <div data-native="View" class="{{ classes }}"><slot /></div>
@@ -0,0 +1,75 @@
1
+ /**
2
+ * The `craft` object a native screen's script sees, typed.
3
+ *
4
+ * The runtime (`screen.ts`) and the Craft host install it on `globalThis`
5
+ * before the script runs. A screen written in TypeScript can name it:
6
+ *
7
+ * ```ts
8
+ * import type { NativeCraft } from '@stacksjs/stx/native'
9
+ * const craft = (globalThis as unknown as { craft: NativeCraft }).craft
10
+ * craft.navigation.open(`/m/workout/${id}`)
11
+ * ```
12
+ */
13
+ export declare interface NativeNavigationButton {
14
+ id: string
15
+ symbol?: string
16
+ title?: string
17
+ color?: string
18
+ accessibilityLabel?: string
19
+ onPress?: (event: { id: string }) => unknown
20
+ }
21
+ export declare interface NativeNavigationOptions {
22
+ title?: string
23
+ largeTitle?: boolean
24
+ hidden?: boolean
25
+ backTitle?: string
26
+ rightButtons?: NativeNavigationButton[]
27
+ }
28
+ export declare interface NativeNavigation {
29
+ push: (screen: string, params?: Record<string, unknown>) => string
30
+ replace: (screen: string, params?: Record<string, unknown>) => string
31
+ back: () => string
32
+ open: (path: string) => string
33
+ setOptions: (options: NativeNavigationOptions) => unknown
34
+ onButton: (callback: (event: { id: string }) => unknown) => () => void
35
+ }
36
+ export declare interface NativeStorage {
37
+ get: <T = unknown>(key: string) => Promise<T | null>
38
+ set: (key: string, value: unknown) => Promise<unknown>
39
+ remove: (key: string) => Promise<unknown>
40
+ clear: () => Promise<unknown>
41
+ keys: () => Promise<string[]>
42
+ getSync: <T = unknown>(key: string) => T | null
43
+ setSync: (key: string, value: unknown) => void
44
+ }
45
+ export declare interface NativeSecureStorage {
46
+ get: (key: string) => Promise<string | null>
47
+ set: (key: string, value: string) => Promise<unknown>
48
+ remove: (key: string) => Promise<unknown>
49
+ delete: (key: string) => Promise<unknown>
50
+ clear: () => Promise<unknown>
51
+ getSync: (key: string) => string | null
52
+ }
53
+ export declare interface NativeSnapshots {
54
+ get: <T = unknown>(name: string) => T | null
55
+ set: (name: string, value: unknown) => Promise<unknown>
56
+ }
57
+ export declare interface NativeCraft {
58
+ platform: string
59
+ route: { name: string, params: Record<string, unknown> }
60
+ capabilities: Record<string, boolean>
61
+ navigation: NativeNavigation
62
+ storage: NativeStorage
63
+ secureStorage: NativeSecureStorage
64
+ snapshots: NativeSnapshots
65
+ appearance: { colorScheme: () => 'light' | 'dark' }
66
+ haptics: {
67
+ impact: (style?: string) => Promise<void>
68
+ notification: (type?: 'success' | 'warning' | 'error') => Promise<void>
69
+ selection: () => Promise<void>
70
+ }
71
+ clipboard: { write: (text: string) => Promise<unknown>, read: () => Promise<string> }
72
+ device: { getInfo: () => Promise<Record<string, unknown>> }
73
+ lifecycle: { getState: () => 'active' | 'inactive' | 'background', onStateChange: (callback: (state: string) => unknown) => () => void }
74
+ deepLinks: { getInitialURL: () => Promise<string | null>, onLink: (callback: (link: unknown) => unknown) => () => void }
75
+ }
File without changes