@stacksjs/stx 0.2.413 → 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 (345) hide show
  1. package/dist/appearance-bootstrap.js +1 -1
  2. package/dist/binding-manifest.d.ts +1 -1
  3. package/dist/bundle-analyzer.js +20 -20
  4. package/dist/chunk-020xyn9q.js +3 -0
  5. package/dist/chunk-04jhmfbz.js +2 -0
  6. package/dist/chunk-10957mcb.js +2 -0
  7. package/dist/chunk-1098mas0.js +2 -0
  8. package/dist/chunk-169n1vpx.js +12 -0
  9. package/dist/chunk-1b6t12hd.js +2 -0
  10. package/dist/chunk-1chw8xsw.js +2 -0
  11. package/dist/chunk-1xdzcy9d.js +14 -0
  12. package/dist/chunk-2ce7f416.js +2 -0
  13. package/dist/chunk-2gr351s0.js +7 -0
  14. package/dist/chunk-2mkcjw08.js +2 -0
  15. package/dist/chunk-2v8wztd5.js +2 -0
  16. package/dist/chunk-340a824p.js +2 -0
  17. package/dist/chunk-39g1134q.js +2 -0
  18. package/dist/chunk-3c74vag1.js +2 -0
  19. package/dist/chunk-3kthfs03.js +3 -0
  20. package/dist/chunk-3qn1wcdg.js +2 -0
  21. package/dist/chunk-3s2vnqcf.js +2 -0
  22. package/dist/chunk-48bwk47q.js +2 -0
  23. package/dist/chunk-4bjravgk.js +2 -0
  24. package/dist/chunk-4jjme6a5.js +2 -0
  25. package/dist/chunk-5g3y8kym.js +2 -0
  26. package/dist/chunk-5gsxpaqk.js +2 -0
  27. package/dist/{chunk-bwsxym3d.js → chunk-5qns2sdz.js} +17 -17
  28. package/dist/chunk-69mc2np8.js +2785 -0
  29. package/dist/chunk-6cfa3g0r.js +2 -0
  30. package/dist/{chunk-bjar18jd.js → chunk-6h38kkjf.js} +46 -52
  31. package/dist/chunk-6hc5vz20.js +3 -0
  32. package/dist/chunk-6q6g76vg.js +499 -0
  33. package/dist/{chunk-bwjxk1dw.js → chunk-6sgswrqw.js} +29 -29
  34. package/dist/chunk-6y8hnymb.js +2 -0
  35. package/dist/chunk-74j18qk0.js +930 -0
  36. package/dist/chunk-752hw7cd.js +4 -0
  37. package/dist/{chunk-kgd8kchy.js → chunk-765e1s44.js} +11 -76
  38. package/dist/chunk-7gkv67ky.js +4 -0
  39. package/dist/chunk-7z2ra0yf.js +2 -0
  40. package/dist/chunk-866n724v.js +2 -0
  41. package/dist/chunk-8nhshfz6.js +5 -0
  42. package/dist/chunk-92ps1xpk.js +2 -0
  43. package/dist/chunk-9g27ybyr.js +3 -0
  44. package/dist/{chunk-xq1acw1r.js → chunk-9pt8fd2n.js} +13 -13
  45. package/dist/{chunk-24zher49.js → chunk-9vrja6vp.js} +4 -4
  46. package/dist/chunk-9xrbve19.js +2 -0
  47. package/dist/chunk-a688m6js.js +3 -0
  48. package/dist/chunk-afhxw2t8.js +2 -0
  49. package/dist/chunk-ak1cgcah.js +5 -0
  50. package/dist/{chunk-4m7ajama.js → chunk-amd6ey3t.js} +14 -14
  51. package/dist/chunk-apg16xcn.js +2 -0
  52. package/dist/chunk-b52s5z0c.js +2 -0
  53. package/dist/chunk-b84h16er.js +61 -0
  54. package/dist/{chunk-hx998w7n.js → chunk-bay9s6rs.js} +13 -13
  55. package/dist/chunk-bmt7w2pk.js +2 -0
  56. package/dist/chunk-btmhj5t7.js +2 -0
  57. package/dist/chunk-ce1sejr3.js +3 -0
  58. package/dist/chunk-cg8hg6cs.js +3 -0
  59. package/dist/{chunk-4f9zyfdw.js → chunk-czxt605c.js} +4 -5
  60. package/dist/chunk-d44b9ktb.js +4 -0
  61. package/dist/chunk-daz5aqcf.js +24 -0
  62. package/dist/chunk-dgdm3hy3.js +2 -0
  63. package/dist/chunk-dvgv8nry.js +11 -0
  64. package/dist/chunk-dx7n22ed.js +2 -0
  65. package/dist/chunk-e57rhf65.js +3 -0
  66. package/dist/chunk-eed4fwps.js +3 -0
  67. package/dist/chunk-ej9j6k1q.js +3 -0
  68. package/dist/chunk-et0rr8c7.js +3 -0
  69. package/dist/chunk-f46qsp4m.js +4 -0
  70. package/dist/chunk-f6az0xj5.js +2 -0
  71. package/dist/{chunk-bjcsc6wx.js → chunk-fh1qrp68.js} +21 -21
  72. package/dist/chunk-fjs0a8h7.js +2 -0
  73. package/dist/chunk-fr2txj8q.js +829 -0
  74. package/dist/{chunk-xssw417m.js → chunk-ft4p6d28.js} +14 -14
  75. package/dist/chunk-fyzajkrx.js +2 -0
  76. package/dist/chunk-fzapbw9p.js +3 -0
  77. package/dist/chunk-g578mcb0.js +194 -0
  78. package/dist/chunk-gawrg4gb.js +216 -0
  79. package/dist/chunk-gw07qmjk.js +2 -0
  80. package/dist/chunk-h0atqq82.js +32 -0
  81. package/dist/chunk-h6zsqb9r.js +3 -0
  82. package/dist/{chunk-2snqdnk9.js → chunk-h85hrwkq.js} +13 -13
  83. package/dist/chunk-hbxz85wy.js +2 -0
  84. package/dist/chunk-hjg3ndgh.js +2 -0
  85. package/dist/chunk-hkxsewzk.js +2 -0
  86. package/dist/chunk-hrbbbtbn.js +2 -0
  87. package/dist/chunk-j03revz2.js +8 -0
  88. package/dist/chunk-j9qcrwbg.js +2 -0
  89. package/dist/chunk-jk4njz0w.js +2 -0
  90. package/dist/chunk-jmabeqfq.js +2 -0
  91. package/dist/chunk-jt0n43mk.js +2 -0
  92. package/dist/chunk-kjbv8a3m.js +2 -0
  93. package/dist/chunk-m1vdghnx.js +2 -0
  94. package/dist/chunk-m4sk62wb.js +5 -0
  95. package/dist/chunk-md8rqn48.js +30 -0
  96. package/dist/chunk-mepdnezf.js +17 -0
  97. package/dist/chunk-mhq0pjws.js +2 -0
  98. package/dist/chunk-mp6hy8g4.js +2 -0
  99. package/dist/chunk-ngc2wke4.js +3 -0
  100. package/dist/chunk-nn2vstke.js +2 -0
  101. package/dist/chunk-p2v2a68k.js +2 -0
  102. package/dist/{chunk-qn5srnj3.js → chunk-pbh4smw3.js} +16 -16
  103. package/dist/chunk-pdt69hpb.js +2 -0
  104. package/dist/chunk-pgzvyrv6.js +29 -0
  105. package/dist/chunk-pj1wg7jg.js +2 -0
  106. package/dist/chunk-pqxzp1bb.js +3 -0
  107. package/dist/chunk-px7fvbj6.js +3 -0
  108. package/dist/chunk-q4c06e8x.js +20 -0
  109. package/dist/chunk-q6vrb2pe.js +2 -0
  110. package/dist/chunk-q7qchkvk.js +2 -0
  111. package/dist/chunk-q9bdh4s5.js +8 -0
  112. package/dist/chunk-qet5gc6s.js +2033 -0
  113. package/dist/chunk-qz519eyp.js +2 -0
  114. package/dist/chunk-r3f9jcf7.js +5 -0
  115. package/dist/chunk-rs4v4fha.js +4 -0
  116. package/dist/chunk-s2x4wcrz.js +2 -0
  117. package/dist/chunk-s5xezjps.js +3 -0
  118. package/dist/chunk-scezfp0w.js +30 -0
  119. package/dist/chunk-sd321bn3.js +2 -0
  120. package/dist/{chunk-smcj3442.js → chunk-sd47dzs0.js} +79 -79
  121. package/dist/chunk-se7mwqd1.js +2 -0
  122. package/dist/chunk-shr559s7.js +3 -0
  123. package/dist/chunk-syaw6b75.js +2 -0
  124. package/dist/chunk-t4hzprsm.js +3 -0
  125. package/dist/{chunk-pv3d7sfn.js → chunk-t61vdbje.js} +89 -89
  126. package/dist/chunk-tfexmdkt.js +3 -0
  127. package/dist/chunk-thyt8ed8.js +6 -0
  128. package/dist/chunk-v091jft4.js +12 -0
  129. package/dist/chunk-v4vaqxrf.js +33 -0
  130. package/dist/chunk-vgvtnwxa.js +4 -0
  131. package/dist/chunk-x0q32ees.js +3 -0
  132. package/dist/chunk-x5bpeb4a.js +2 -0
  133. package/dist/chunk-x72tv2cg.js +3 -0
  134. package/dist/chunk-xfp7k0v8.js +64 -0
  135. package/dist/chunk-xtdw3692.js +6 -0
  136. package/dist/chunk-y1cmjvk3.js +43 -0
  137. package/dist/chunk-y5310237.js +311 -0
  138. package/dist/chunk-ya0qecph.js +27 -0
  139. package/dist/chunk-yazk54jr.js +8 -0
  140. package/dist/chunk-ydjfar14.js +2 -0
  141. package/dist/chunk-ym95v4nc.js +3 -0
  142. package/dist/chunk-ynvdvbat.js +18 -0
  143. package/dist/chunk-yvx1ap9b.js +3 -0
  144. package/dist/chunk-z0g9jvv0.js +40 -0
  145. package/dist/chunk-z6d0jmjb.js +2 -0
  146. package/dist/{chunk-8sdhs0zk.js → chunk-zhxdpzga.js} +4 -4
  147. package/dist/cli.js +110 -110
  148. package/dist/craft-entry.js +7 -7
  149. package/dist/craft.js +7 -7
  150. package/dist/database.js +2 -2
  151. package/dist/image-optimization/component.js +4 -4
  152. package/dist/media/image/component.js +5 -5
  153. package/dist/media/protected/component.js +2 -2
  154. package/dist/media/video/index.js +4 -4
  155. package/dist/native/bridge/protocol.d.ts +325 -0
  156. package/dist/native/bridge/protocol.js +219 -0
  157. package/dist/native/cli.d.ts +24 -0
  158. package/dist/native/cli.js +52 -0
  159. package/dist/native/compiler/bundle.d.ts +41 -0
  160. package/dist/native/compiler/bundle.js +90 -0
  161. package/dist/native/compiler/client-script.d.ts +8 -0
  162. package/dist/native/compiler/client-script.js +31 -0
  163. package/dist/native/compiler/codegen.d.ts +10 -0
  164. package/dist/native/compiler/codegen.js +145 -0
  165. package/dist/native/compiler/headwind-to-style.d.ts +395 -0
  166. package/dist/native/compiler/headwind-to-style.js +1163 -0
  167. package/dist/native/compiler/html-to-ir.d.ts +41 -0
  168. package/dist/native/compiler/html-to-ir.js +411 -0
  169. package/dist/native/compiler/icons.d.ts +220 -0
  170. package/dist/native/compiler/icons.js +208 -0
  171. package/dist/native/compiler/ir.d.ts +234 -0
  172. package/dist/native/compiler/ir.js +15 -0
  173. package/dist/native/compiler/parser.d.ts +88 -0
  174. package/dist/native/compiler/parser.js +753 -0
  175. package/dist/native/compiler/render-screen.d.ts +26 -0
  176. package/dist/native/compiler/render-screen.js +31 -0
  177. package/dist/native/components/primitives.d.ts +291 -0
  178. package/dist/native/components/primitives.js +22 -0
  179. package/dist/native/hot-reload/client.d.ts +62 -0
  180. package/dist/native/hot-reload/client.js +324 -0
  181. package/dist/native/index.d.ts +90 -0
  182. package/dist/native/index.js +34 -0
  183. package/dist/native/primitives/ActivityIndicator.stx +5 -0
  184. package/dist/native/primitives/Button.stx +5 -0
  185. package/dist/native/primitives/DatePicker.stx +5 -0
  186. package/dist/native/primitives/FlatList.stx +5 -0
  187. package/dist/native/primitives/Image.stx +5 -0
  188. package/dist/native/primitives/ImageBackground.stx +5 -0
  189. package/dist/native/primitives/KeyboardAvoidingView.stx +5 -0
  190. package/dist/native/primitives/Modal.stx +5 -0
  191. package/dist/native/primitives/Picker.stx +5 -0
  192. package/dist/native/primitives/Pressable.stx +5 -0
  193. package/dist/native/primitives/RefreshControl.stx +5 -0
  194. package/dist/native/primitives/SafeAreaView.stx +5 -0
  195. package/dist/native/primitives/ScrollView.stx +5 -0
  196. package/dist/native/primitives/SectionList.stx +5 -0
  197. package/dist/native/primitives/Slider.stx +5 -0
  198. package/dist/native/primitives/StatusBar.stx +5 -0
  199. package/dist/native/primitives/Switch.stx +5 -0
  200. package/dist/native/primitives/Text.stx +5 -0
  201. package/dist/native/primitives/TextInput.stx +5 -0
  202. package/dist/native/primitives/TouchableHighlight.stx +5 -0
  203. package/dist/native/primitives/TouchableOpacity.stx +5 -0
  204. package/dist/native/primitives/View.stx +5 -0
  205. package/dist/native/runtime/craft.d.ts +75 -0
  206. package/dist/native/runtime/craft.js +0 -0
  207. package/dist/native/runtime/entry.d.ts +1 -0
  208. package/dist/native/runtime/entry.js +3 -0
  209. package/dist/native/runtime/index.d.ts +45 -0
  210. package/dist/native/runtime/index.js +165 -0
  211. package/dist/native/runtime/native-host.d.ts +33 -0
  212. package/dist/native/runtime/native-host.js +184 -0
  213. package/dist/native/runtime/screen.d.ts +43 -0
  214. package/dist/native/runtime/screen.js +808 -0
  215. package/dist/pwa/service-worker.js +1 -1
  216. package/dist/pwa/workbox.js +1 -1
  217. package/dist/pwa.js +8 -8
  218. package/dist/site-url.d.ts +1 -1
  219. package/dist/ssg.js +53 -53
  220. package/dist/visual-testing.js +42 -42
  221. package/dist/web-components/reactive-generator.js +2 -2
  222. package/package.json +9 -5
  223. package/dist/chunk-0btmm4m2.js +0 -147
  224. package/dist/chunk-0c2h69k2.js +0 -4
  225. package/dist/chunk-0d0qeqvv.js +0 -2
  226. package/dist/chunk-0psndabd.js +0 -2
  227. package/dist/chunk-0qv8yf53.js +0 -2
  228. package/dist/chunk-0vkxyvsd.js +0 -2
  229. package/dist/chunk-0we9nw1d.js +0 -3
  230. package/dist/chunk-0xqdmemy.js +0 -3
  231. package/dist/chunk-0y46fbkx.js +0 -3
  232. package/dist/chunk-158wqccn.js +0 -4422
  233. package/dist/chunk-1cyxbb8y.js +0 -16
  234. package/dist/chunk-1enwnh2a.js +0 -2
  235. package/dist/chunk-213pzm0d.js +0 -3
  236. package/dist/chunk-21hzqyja.js +0 -12
  237. package/dist/chunk-266t58b8.js +0 -5
  238. package/dist/chunk-27fgag95.js +0 -4
  239. package/dist/chunk-2a9n102n.js +0 -2
  240. package/dist/chunk-2eqzrczk.js +0 -2
  241. package/dist/chunk-2ke37m54.js +0 -14
  242. package/dist/chunk-35ds08e7.js +0 -3
  243. package/dist/chunk-3mtwkjcg.js +0 -2
  244. package/dist/chunk-4xr8zwkp.js +0 -2
  245. package/dist/chunk-58v77x2c.js +0 -2
  246. package/dist/chunk-5mhq8605.js +0 -2
  247. package/dist/chunk-5se8xt9e.js +0 -64
  248. package/dist/chunk-5zh0h080.js +0 -2
  249. package/dist/chunk-62435225.js +0 -2
  250. package/dist/chunk-6kdrncsx.js +0 -30
  251. package/dist/chunk-6n2rr3x7.js +0 -2
  252. package/dist/chunk-6xk87qf2.js +0 -30
  253. package/dist/chunk-72rwcbp6.js +0 -3
  254. package/dist/chunk-76w34xne.js +0 -3
  255. package/dist/chunk-7ekd7zj9.js +0 -2
  256. package/dist/chunk-7pr3wdd5.js +0 -3
  257. package/dist/chunk-7rxvafwc.js +0 -24
  258. package/dist/chunk-7tnwfa7w.js +0 -8
  259. package/dist/chunk-8c5je0wf.js +0 -2
  260. package/dist/chunk-8dz6nyvx.js +0 -2
  261. package/dist/chunk-98zj3fv2.js +0 -7
  262. package/dist/chunk-9e8t0twa.js +0 -3
  263. package/dist/chunk-9fqp72ze.js +0 -5
  264. package/dist/chunk-anydpa34.js +0 -3
  265. package/dist/chunk-ay6zjq8v.js +0 -3
  266. package/dist/chunk-az4v4ard.js +0 -3
  267. package/dist/chunk-ba5erggg.js +0 -2
  268. package/dist/chunk-bnagrdz6.js +0 -2
  269. package/dist/chunk-by8wghtf.js +0 -2
  270. package/dist/chunk-cd7h4q51.js +0 -2
  271. package/dist/chunk-cjmv8hgp.js +0 -33
  272. package/dist/chunk-cthf912y.js +0 -2
  273. package/dist/chunk-cxbpmwq5.js +0 -4
  274. package/dist/chunk-d3sy16qn.js +0 -2
  275. package/dist/chunk-dh6s7mrj.js +0 -1199
  276. package/dist/chunk-dm2nzg7a.js +0 -2
  277. package/dist/chunk-e2sgcnxc.js +0 -2
  278. package/dist/chunk-e3b7jj74.js +0 -2
  279. package/dist/chunk-ec4wq2sv.js +0 -6
  280. package/dist/chunk-ekzg97dn.js +0 -29
  281. package/dist/chunk-epjt342x.js +0 -2
  282. package/dist/chunk-eqe26g14.js +0 -18
  283. package/dist/chunk-ev0v1yma.js +0 -2
  284. package/dist/chunk-f53psr2y.js +0 -5
  285. package/dist/chunk-f8p69dsg.js +0 -3
  286. package/dist/chunk-f95drhdb.js +0 -194
  287. package/dist/chunk-ff5a6hvb.js +0 -17
  288. package/dist/chunk-fs5fy4h8.js +0 -2
  289. package/dist/chunk-fzsygce3.js +0 -2
  290. package/dist/chunk-g465x63k.js +0 -2
  291. package/dist/chunk-g708ekh1.js +0 -2
  292. package/dist/chunk-gcr9e83g.js +0 -11
  293. package/dist/chunk-gdmyrsr8.js +0 -4
  294. package/dist/chunk-gkms2ngq.js +0 -2
  295. package/dist/chunk-gnfywmgs.js +0 -7
  296. package/dist/chunk-hpf8kq7e.js +0 -2
  297. package/dist/chunk-j4x3faf8.js +0 -2
  298. package/dist/chunk-jkavtw9f.js +0 -2
  299. package/dist/chunk-kg1rdena.js +0 -3
  300. package/dist/chunk-km91wx0v.js +0 -2
  301. package/dist/chunk-kmsyvaex.js +0 -8
  302. package/dist/chunk-mrahwn5v.js +0 -8
  303. package/dist/chunk-nk3czvnk.js +0 -2
  304. package/dist/chunk-nmw4eewb.js +0 -2
  305. package/dist/chunk-nq5zxrk0.js +0 -4
  306. package/dist/chunk-ny67c03k.js +0 -3
  307. package/dist/chunk-p4wdxp2c.js +0 -2
  308. package/dist/chunk-pcxp4r9n.js +0 -3
  309. package/dist/chunk-pdyeaxc1.js +0 -2
  310. package/dist/chunk-pf06ded4.js +0 -2
  311. package/dist/chunk-pfs0gpzm.js +0 -2
  312. package/dist/chunk-pshdwq44.js +0 -2
  313. package/dist/chunk-pwgv84pn.js +0 -32
  314. package/dist/chunk-pwsnafp3.js +0 -4367
  315. package/dist/chunk-q9n5swx7.js +0 -3
  316. package/dist/chunk-qr346wnp.js +0 -2
  317. package/dist/chunk-r02hke04.js +0 -2
  318. package/dist/chunk-ranshpyc.js +0 -3
  319. package/dist/chunk-rn194bhp.js +0 -20
  320. package/dist/chunk-rn1hgyc8.js +0 -930
  321. package/dist/chunk-s7z5dp70.js +0 -43
  322. package/dist/chunk-s8jd13nb.js +0 -3
  323. package/dist/chunk-sn7exv0n.js +0 -2
  324. package/dist/chunk-t1tdjjht.js +0 -216
  325. package/dist/chunk-t6qx04s8.js +0 -499
  326. package/dist/chunk-t6y6gyps.js +0 -2
  327. package/dist/chunk-tjfs7cc3.js +0 -2
  328. package/dist/chunk-tkyrk66a.js +0 -3
  329. package/dist/chunk-tntv9hvq.js +0 -2
  330. package/dist/chunk-v3nwkveg.js +0 -12
  331. package/dist/chunk-vd4cb5xr.js +0 -2
  332. package/dist/chunk-vkhdce50.js +0 -2
  333. package/dist/chunk-w183av08.js +0 -2
  334. package/dist/chunk-w2m02njv.js +0 -2
  335. package/dist/chunk-wpjrcrs5.js +0 -2
  336. package/dist/chunk-wqmppf6b.js +0 -3
  337. package/dist/chunk-wtb9fxdy.js +0 -2
  338. package/dist/chunk-xmzygmcz.js +0 -3
  339. package/dist/chunk-xsng1mtq.js +0 -3
  340. package/dist/chunk-xxzefj4j.js +0 -2
  341. package/dist/chunk-yq8x8bxq.js +0 -47
  342. package/dist/chunk-ytma76qe.js +0 -3
  343. package/dist/chunk-yw1m115e.js +0 -2
  344. package/dist/chunk-z64a924m.js +0 -2
  345. package/dist/chunk-zcz9rs6p.js +0 -3
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,3 @@
1
+ import { installRuntime } from "./screen.js";
2
+ const g = globalThis;
3
+ g.__stxNative = installRuntime(g.__stxNativeRuntimeOptions || {});
@@ -0,0 +1,45 @@
1
+ import type { STXDocument } from '../compiler/ir';
2
+ export type { RuntimeConfig };
3
+ /**
4
+ * Get or create the runtime instance
5
+ */
6
+ export declare function getRuntime(config?: RuntimeConfig): STXRuntime;
7
+ /**
8
+ * Initialize and start the runtime
9
+ */
10
+ export declare function startRuntime(config?: RuntimeConfig): Promise<STXRuntime>;
11
+ /**
12
+ * Render an STX document
13
+ */
14
+ export declare function render(document: STXDocument): Promise<void>;
15
+ /**
16
+ * Update application state
17
+ */
18
+ export declare function setState(key: string, value: unknown): void;
19
+ /**
20
+ * Get application state
21
+ */
22
+ export declare function getState<T>(key: string): T | undefined;
23
+ // ============================================================================
24
+ // Runtime Configuration
25
+ // ============================================================================
26
+ declare interface RuntimeConfig {
27
+ devServerUrl?: string
28
+ hotReload?: boolean
29
+ debug?: boolean
30
+ document?: STXDocument
31
+ }
32
+ // ============================================================================
33
+ // STX Runtime
34
+ // ============================================================================
35
+ declare class STXRuntime {
36
+ constructor(config?: RuntimeConfig);
37
+ initialize(): Promise<void>;
38
+ render(document: STXDocument): Promise<void>;
39
+ setState(key: string, value: unknown): void;
40
+ getState<T>(key: string): T | undefined;
41
+ }
42
+ // ============================================================================
43
+ // Exports
44
+ // ============================================================================
45
+ export { STXRuntime };
@@ -0,0 +1,165 @@
1
+ import { getBridge, createBridge, registerHandler, callHandler } from "../bridge/protocol.js";
2
+ import { initHotReload, getErrorOverlay } from "../hot-reload/client.js";
3
+
4
+ class STXRuntime {
5
+ config;
6
+ currentDocument = null;
7
+ state = new Map;
8
+ initialized = !1;
9
+ constructor(config = {}) {
10
+ this.config = {
11
+ devServerUrl: "ws://localhost:8081",
12
+ hotReload: __DEV__,
13
+ debug: __DEV__,
14
+ ...config
15
+ };
16
+ }
17
+ async initialize() {
18
+ if (this.initialized) {
19
+ this.log("Runtime already initialized");
20
+ return;
21
+ }
22
+ this.log("Initializing STX Native Runtime...");
23
+ createBridge();
24
+ const bridge = getBridge();
25
+ this.setupEventHandlers();
26
+ if (this.config.hotReload)
27
+ initHotReload(this.config.devServerUrl).onReload((doc) => {
28
+ this.handleHotReload(doc);
29
+ });
30
+ if (this.config.document)
31
+ await this.render(this.config.document);
32
+ this.initialized = !0;
33
+ this.log("Runtime initialized");
34
+ }
35
+ async render(document) {
36
+ this.currentDocument = document;
37
+ const bridge = getBridge();
38
+ if (document.script.code)
39
+ this.executeScript(document.script.code);
40
+ for (const funcName of document.script.functions) {
41
+ const func = this.getGlobalFunction(funcName);
42
+ if (func)
43
+ registerHandler(funcName, func);
44
+ }
45
+ for (const [key, value] of Object.entries(document.script.exports))
46
+ this.state.set(key, value);
47
+ bridge.render(document.root, { mode: "replace" });
48
+ this.log("Document rendered");
49
+ }
50
+ setState(key, value) {
51
+ const previousValue = this.state.get(key);
52
+ this.state.set(key, value);
53
+ this.setGlobal(key, value);
54
+ getBridge().send("STATE_UPDATE", {
55
+ key,
56
+ value,
57
+ previousValue
58
+ });
59
+ this.log(`State updated: ${key}`, value);
60
+ }
61
+ getState(key) {
62
+ return this.state.get(key);
63
+ }
64
+ setupEventHandlers() {
65
+ const bridge = getBridge();
66
+ bridge.on("EVENT", (message) => {
67
+ const payload = message.payload;
68
+ this.log(`Event: ${payload.eventType} -> ${payload.handlerName}`);
69
+ const result = callHandler(payload.handlerName, payload.nativeEvent);
70
+ });
71
+ bridge.on("APP_STATE", (message) => {
72
+ const payload = message.payload;
73
+ this.log(`App state: ${payload.state}`);
74
+ switch (payload.state) {
75
+ case "active":
76
+ callHandler("onAppForeground");
77
+ break;
78
+ case "background":
79
+ callHandler("onAppBackground");
80
+ break;
81
+ case "inactive":
82
+ callHandler("onAppInactive");
83
+ break;
84
+ }
85
+ });
86
+ bridge.on("HOT_RELOAD", (message) => {
87
+ const payload = message.payload;
88
+ if (payload.document)
89
+ this.handleHotReload(payload.document);
90
+ });
91
+ }
92
+ handleHotReload(document) {
93
+ this.log("Hot reload triggered");
94
+ const savedState = new Map(this.state);
95
+ this.render(document);
96
+ for (const [key, value] of savedState)
97
+ if (this.state.has(key))
98
+ this.setState(key, value);
99
+ this.log("Hot reload complete");
100
+ }
101
+ executeScript(code) {
102
+ try {
103
+ const wrappedCode = `
104
+ (function() {
105
+ ${code}
106
+ })();
107
+ `;
108
+ Function(wrappedCode)();
109
+ this.log("Script executed");
110
+ } catch (error) {
111
+ this.logError("Script execution failed:", error);
112
+ if (this.config.hotReload)
113
+ getErrorOverlay().show({
114
+ error,
115
+ source: this.currentDocument?.meta.source
116
+ });
117
+ }
118
+ }
119
+ getGlobalFunction(name) {
120
+ try {
121
+ const fn = globalThis[name];
122
+ if (typeof fn === "function")
123
+ return fn;
124
+ } catch {}
125
+ return null;
126
+ }
127
+ setGlobal(key, value) {
128
+ try {
129
+ globalThis[key] = value;
130
+ } catch {}
131
+ }
132
+ log(...args) {
133
+ if (this.config.debug)
134
+ console.log("[STXRuntime]", ...args);
135
+ }
136
+ logError(...args) {
137
+ console.error("[STXRuntime]", ...args);
138
+ }
139
+ }
140
+ if (typeof globalThis.__DEV__ > "u")
141
+ globalThis.__DEV__ = !0;
142
+ let runtimeInstance = null;
143
+ export function getRuntime(config) {
144
+ if (!runtimeInstance)
145
+ runtimeInstance = new STXRuntime(config);
146
+ return runtimeInstance;
147
+ }
148
+ export async function startRuntime(config) {
149
+ const runtime = getRuntime(config);
150
+ await runtime.initialize();
151
+ return runtime;
152
+ }
153
+ export async function render(document) {
154
+ const runtime = getRuntime();
155
+ await runtime.initialize();
156
+ await runtime.render(document);
157
+ }
158
+ export function setState(key, value) {
159
+ getRuntime().setState(key, value);
160
+ }
161
+ export function getState(key) {
162
+ return getRuntime().getState(key);
163
+ }
164
+
165
+ export { STXRuntime };
@@ -0,0 +1,33 @@
1
+ import type { NativeMutationOperation } from '../bridge/protocol';
2
+ export declare function createNativeHost(options: NativeHostOptions): NativeHost;
3
+ /** Every method the DOM host in `signals.ts` defines. The contract, in one place. */
4
+ export declare const HOST_METHODS: readonly string[];
5
+ /** A handle on a node in the native tree. Not an element; just an identity. */
6
+ export declare interface NativeNode {
7
+ __stxId: string
8
+ __stxScope?: string
9
+ __stxOwner?: NativeNode | null
10
+ __stxAnchor?: string
11
+ }
12
+ export declare interface NativeHostOptions {
13
+ send: (operations: NativeMutationOperation[]) => void
14
+ schedule?: (flush: () => void) => void
15
+ }
16
+ export declare interface NativeHost {
17
+ setText: (node: NativeNode, value: unknown) => void
18
+ setAttribute: (node: NativeNode, name: string, value: unknown) => void
19
+ removeAttribute: (node: NativeNode, name: string) => void
20
+ listen: (node: NativeNode, event: string, handler: (payload?: unknown) => void, options?: unknown) => void
21
+ scopeOf: (node: NativeNode, from?: boolean) => NativeNode | null
22
+ setVisible: (node: NativeNode, visible: boolean) => boolean
23
+ anchor: (label: string) => NativeNode
24
+ clone: (node: NativeNode) => NativeNode
25
+ insert: (parent: NativeNode, node: NativeNode, before?: NativeNode | null) => void
26
+ remove: (node: NativeNode) => void
27
+ descendants: (node: NativeNode) => NativeNode[]
28
+ scopesIn: (node: NativeNode) => string[]
29
+ adopt: (node: NativeNode, type: string, owner?: NativeNode | null) => NativeNode
30
+ flush: () => void
31
+ dispatch: (handlerId: string, payload?: unknown) => void
32
+ pending: () => number
33
+ }
@@ -0,0 +1,184 @@
1
+ export const HOST_METHODS = [
2
+ "setText",
3
+ "setAttribute",
4
+ "removeAttribute",
5
+ "listen",
6
+ "scopeOf",
7
+ "setVisible",
8
+ "anchor",
9
+ "clone",
10
+ "insert",
11
+ "remove",
12
+ "descendants",
13
+ "scopesIn"
14
+ ];
15
+ export function createNativeHost(options) {
16
+ const records = new Map, handlers = new Map;
17
+ let queue = [], scheduled = !1, counter = 0;
18
+ const schedule = options.schedule ?? ((flush) => queueMicrotask(flush)), nextId = (prefix) => `${prefix}${++counter}`;
19
+ function flush() {
20
+ scheduled = !1;
21
+ if (queue.length === 0)
22
+ return;
23
+ const batch = queue;
24
+ queue = [];
25
+ options.send(batch);
26
+ }
27
+ function emit(operation) {
28
+ queue.push(operation);
29
+ if (!scheduled) {
30
+ scheduled = !0;
31
+ schedule(flush);
32
+ }
33
+ }
34
+ function recordOf(node) {
35
+ let record = records.get(node.__stxId);
36
+ if (!record) {
37
+ record = { type: "View", props: {}, style: {}, events: {}, children: [], visible: !0 };
38
+ records.set(node.__stxId, record);
39
+ }
40
+ return record;
41
+ }
42
+ function collectDescendants(node) {
43
+ const out = [], visit = (current) => {
44
+ const record = records.get(current.__stxId);
45
+ if (!record)
46
+ return;
47
+ for (const child of record.children) {
48
+ out.push(child);
49
+ visit(child);
50
+ }
51
+ };
52
+ if (node)
53
+ visit(node);
54
+ return out;
55
+ }
56
+ function adopt(node, type, owner) {
57
+ records.set(node.__stxId, {
58
+ type,
59
+ props: {},
60
+ style: {},
61
+ events: {},
62
+ children: [],
63
+ visible: !0
64
+ });
65
+ node.__stxOwner = owner ?? null;
66
+ return node;
67
+ }
68
+ return {
69
+ adopt,
70
+ pending: () => queue.length,
71
+ flush,
72
+ setText(node, value) {
73
+ const text = value == null ? "" : String(value);
74
+ recordOf(node).text = text;
75
+ emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
76
+ },
77
+ setAttribute(node, name, value) {
78
+ recordOf(node).props[name] = value;
79
+ emit({ op: "updateNode", id: node.__stxId, patch: { props: { [name]: value } } });
80
+ },
81
+ removeAttribute(node, name) {
82
+ delete recordOf(node).props[name];
83
+ emit({ op: "updateNode", id: node.__stxId, patch: { props: { [name]: null } } });
84
+ },
85
+ listen(node, event, handler) {
86
+ const id = nextId("h");
87
+ handlers.set(id, handler);
88
+ recordOf(node).events[event] = id;
89
+ emit({ op: "updateNode", id: node.__stxId, patch: { events: { [event]: id } } });
90
+ },
91
+ dispatch(handlerId, payload) {
92
+ handlers.get(handlerId)?.(payload);
93
+ },
94
+ scopeOf(node, from) {
95
+ let current = from ? node?.__stxOwner : node;
96
+ while (current) {
97
+ if (current.__stxScope !== void 0)
98
+ return current;
99
+ current = current.__stxOwner;
100
+ }
101
+ return null;
102
+ },
103
+ setVisible(node, visible) {
104
+ const record = recordOf(node), was = record.visible;
105
+ record.visible = visible;
106
+ emit({ op: "updateNode", id: node.__stxId, patch: { style: { display: visible ? "flex" : "none" } } });
107
+ return was;
108
+ },
109
+ anchor(label) {
110
+ return { __stxId: nextId("a"), __stxAnchor: label };
111
+ },
112
+ clone(node) {
113
+ const source = records.get(node.__stxId), copy = { __stxId: nextId("n"), __stxOwner: node.__stxOwner };
114
+ if (node.__stxScope !== void 0)
115
+ copy.__stxScope = node.__stxScope;
116
+ const descriptor = source ?? { type: "View", props: {}, style: {}, events: {}, children: [], visible: !0 };
117
+ records.set(copy.__stxId, {
118
+ type: descriptor.type,
119
+ props: { ...descriptor.props },
120
+ style: { ...descriptor.style },
121
+ events: { ...descriptor.events },
122
+ text: descriptor.text,
123
+ children: [],
124
+ visible: descriptor.visible
125
+ });
126
+ emit({
127
+ op: "createNode",
128
+ id: copy.__stxId,
129
+ node: {
130
+ type: descriptor.type,
131
+ props: { ...descriptor.props },
132
+ style: { ...descriptor.style },
133
+ ...descriptor.text === void 0 ? {} : { children: [descriptor.text] }
134
+ }
135
+ });
136
+ for (const child of descriptor.children) {
137
+ const childCopy = this.clone(child);
138
+ this.insert(copy, childCopy);
139
+ }
140
+ return copy;
141
+ },
142
+ insert(parent, node, before) {
143
+ const record = recordOf(parent), existing = record.children.findIndex((child) => child.__stxId === node.__stxId);
144
+ if (existing !== -1)
145
+ record.children.splice(existing, 1);
146
+ const index = before ? Math.max(0, record.children.findIndex((child) => child.__stxId === before.__stxId)) : record.children.length;
147
+ record.children.splice(index, 0, node);
148
+ node.__stxOwner = parent;
149
+ if (node.__stxAnchor !== void 0)
150
+ return;
151
+ emit({
152
+ op: existing === -1 ? "insertChild" : "moveChild",
153
+ parentId: parent.__stxId,
154
+ childId: node.__stxId,
155
+ index
156
+ });
157
+ },
158
+ descendants: collectDescendants,
159
+ scopesIn(node) {
160
+ const ids = [];
161
+ if (!node)
162
+ return ids;
163
+ if (node.__stxScope !== void 0)
164
+ ids.push(node.__stxScope);
165
+ for (const child of collectDescendants(node))
166
+ if (child.__stxScope !== void 0)
167
+ ids.push(child.__stxScope);
168
+ return ids;
169
+ },
170
+ remove(node) {
171
+ const owner = node.__stxOwner;
172
+ if (owner) {
173
+ const record = recordOf(owner), at = record.children.findIndex((child) => child.__stxId === node.__stxId);
174
+ if (at !== -1)
175
+ record.children.splice(at, 1);
176
+ }
177
+ node.__stxOwner = null;
178
+ records.delete(node.__stxId);
179
+ if (node.__stxAnchor !== void 0)
180
+ return;
181
+ emit({ op: "removeNode", id: node.__stxId });
182
+ }
183
+ };
184
+ }
@@ -0,0 +1,43 @@
1
+ /** `:class` as Vue and Alpine take it: a string, an array, or `{ name: on }`. */
2
+ export declare function normalizeClass(value: Any): string;
3
+ /** `:style` as an object, or as CSS text (`left: 12px; width: 40%`). */
4
+ export declare function normalizeStyle(value: Any): Record<string, Any>;
5
+ export declare function createRuntime(bridge: Any, options?: RuntimeOptions): { mount: (screen: ScreenDefinition) => void };
6
+ /**
7
+ * The bundle's entry: installs the Craft APIs once, before any screen script
8
+ * runs, and hands each screen a `mount`. Without a bridge (a test importing a
9
+ * screen, a web build) there is nothing to render to, so mount does nothing.
10
+ */
11
+ export declare function installRuntime(options?: RuntimeOptions): { mount: (screen: ScreenDefinition) => void };
12
+ /** A template node as `codegen.ts` emits it. Numbers are expression indexes. */
13
+ export declare interface TemplateNode {
14
+ type: string
15
+ key?: Any
16
+ props: Record<string, Any>
17
+ style: Record<string, Any>
18
+ darkStyle?: Record<string, Any>
19
+ events: Record<string, number>
20
+ children: Array<TemplateNode | TemplateText>
21
+ directives?: {
22
+ if?: number
23
+ elseIf?: number
24
+ else?: boolean
25
+ for?: { source: number, item: string, index?: string }
26
+ show?: number
27
+ }
28
+ bindings?: { class?: number, style?: number }
29
+ }
30
+ export declare interface ScreenDefinition {
31
+ document: { root: TemplateNode }
32
+ expressions: Expression[]
33
+ functions?: Record<string, ((event?: Any) => Any) | undefined>
34
+ }
35
+ export declare interface RuntimeOptions {
36
+ routeName?: string
37
+ routeNames?: string[]
38
+ }
39
+ declare type Any = any // eslint-disable-line ts/no-explicit-any
40
+ type Scope = Record<string, Any>;
41
+ declare type Expression = (scope: Scope, event?: Any) => Any;
42
+ /** A text child: a literal, or an expression reference. */
43
+ export type TemplateText = string | { $x: number }