@stacksjs/stx 0.2.582 → 0.2.584

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 (261) hide show
  1. package/dist/{chunk-qazn64pm.js → chunk-03qf2z4d.js} +1 -1
  2. package/dist/{chunk-yk3fbzx5.js → chunk-07869zev.js} +4 -4
  3. package/dist/chunk-08g5j4fq.js +2 -0
  4. package/dist/chunk-0hpw65yr.js +2 -0
  5. package/dist/chunk-11jmasqb.js +2 -0
  6. package/dist/chunk-2c7ysn9s.js +2 -0
  7. package/dist/chunk-2wb1w0p6.js +2 -0
  8. package/dist/chunk-2wx2aczp.js +2 -0
  9. package/dist/chunk-325dn55d.js +4 -0
  10. package/dist/chunk-34kxj258.js +2 -0
  11. package/dist/{chunk-ktyctev3.js → chunk-3y5tzxm6.js} +2 -2
  12. package/dist/{chunk-h0a2s340.js → chunk-49xtxzr8.js} +2 -2
  13. package/dist/chunk-4efqcpg5.js +2 -0
  14. package/dist/{chunk-5kh5ehfh.js → chunk-4h58as2c.js} +2 -2
  15. package/dist/chunk-4k6h00kk.js +2 -0
  16. package/dist/{chunk-y8q1n7hx.js → chunk-4myvw20e.js} +10 -10
  17. package/dist/chunk-4szz2esp.js +2 -0
  18. package/dist/chunk-4wkghwag.js +2 -0
  19. package/dist/chunk-53grq69s.js +2 -0
  20. package/dist/chunk-55n8mhq4.js +2 -0
  21. package/dist/chunk-5s229r1e.js +2 -0
  22. package/dist/chunk-5zg3xj45.js +18 -0
  23. package/dist/{chunk-hzfhn2vr.js → chunk-67m2prah.js} +2 -2
  24. package/dist/chunk-6djvj6hg.js +2 -0
  25. package/dist/chunk-6ebj7gfr.js +2 -0
  26. package/dist/{chunk-g4crr86j.js → chunk-6hgngmn0.js} +3 -3
  27. package/dist/chunk-71tnfe1n.js +2 -0
  28. package/dist/{chunk-101ekf6y.js → chunk-794v5crp.js} +2 -2
  29. package/dist/chunk-7dkwf9h5.js +2 -0
  30. package/dist/{chunk-cnknvvwm.js → chunk-7fghm9zy.js} +1 -1
  31. package/dist/{chunk-ayy9mmrw.js → chunk-7ra30crf.js} +7 -7
  32. package/dist/{chunk-117xss52.js → chunk-7xw1e8t6.js} +2 -2
  33. package/dist/{chunk-c0s3k64c.js → chunk-7ydavm3h.js} +2 -2
  34. package/dist/{chunk-qdyp2zqf.js → chunk-82bttwqm.js} +2 -2
  35. package/dist/chunk-8992smwz.js +2 -0
  36. package/dist/{chunk-0vnngvy1.js → chunk-8s7zbhdd.js} +4 -4
  37. package/dist/chunk-8zn83jfs.js +2 -0
  38. package/dist/{chunk-zz02hwec.js → chunk-96zgn94z.js} +26 -26
  39. package/dist/{chunk-43h8q2cm.js → chunk-9cpxzze0.js} +9 -9
  40. package/dist/{chunk-vx75fb0d.js → chunk-9e091vkf.js} +3 -3
  41. package/dist/chunk-9pk5jhqa.js +3 -0
  42. package/dist/{chunk-dvgvvy5b.js → chunk-9r5w6s80.js} +3 -3
  43. package/dist/{chunk-c0h2eqe0.js → chunk-a8n6mt7s.js} +2 -2
  44. package/dist/{chunk-djft0m5h.js → chunk-agy4mxn8.js} +2 -2
  45. package/dist/{chunk-ev5f79mg.js → chunk-axz1x4r9.js} +5 -5
  46. package/dist/{chunk-6w2yqtrd.js → chunk-b5van393.js} +2 -2
  47. package/dist/{chunk-w3rmepwy.js → chunk-bfbmdjh4.js} +2 -2
  48. package/dist/chunk-bqtph83n.js +2 -0
  49. package/dist/chunk-bs1bdhvp.js +2 -0
  50. package/dist/{chunk-0k5faspy.js → chunk-bsy10tz6.js} +6 -6
  51. package/dist/chunk-c1c4sh7t.js +2 -0
  52. package/dist/{chunk-zk2xk0wd.js → chunk-c6egfhy6.js} +2 -2
  53. package/dist/chunk-ce2d0hz9.js +2 -0
  54. package/dist/chunk-cjq9k1xb.js +2 -0
  55. package/dist/{chunk-k9th7hc4.js → chunk-d2jb1rkp.js} +5 -5
  56. package/dist/{chunk-yfq2v7x5.js → chunk-d4awfk42.js} +7 -7
  57. package/dist/chunk-d9vjsqs4.js +2 -0
  58. package/dist/{chunk-8v19753h.js → chunk-e26pzdxy.js} +1 -1
  59. package/dist/{chunk-nrfh7gaa.js → chunk-e556dvy4.js} +3 -3
  60. package/dist/{chunk-3qrrv6af.js → chunk-e6h7pzym.js} +1 -1
  61. package/dist/{chunk-cb2pyg5t.js → chunk-ebfpjnf3.js} +2 -2
  62. package/dist/chunk-ede39b7h.js +3 -0
  63. package/dist/chunk-f0fxyh3e.js +2 -0
  64. package/dist/{chunk-4srg0qbv.js → chunk-f29fk7dw.js} +2 -2
  65. package/dist/chunk-fjyhc41r.js +2 -0
  66. package/dist/{chunk-1v1mew46.js → chunk-fkq55rh7.js} +1 -1
  67. package/dist/chunk-fn4wwgnc.js +2 -0
  68. package/dist/{chunk-t8wpzqs4.js → chunk-g8mxprxj.js} +1 -1
  69. package/dist/chunk-h2534p6q.js +2 -0
  70. package/dist/{chunk-9jh2ake5.js → chunk-h7atbtds.js} +5 -5
  71. package/dist/{chunk-yy3ser06.js → chunk-h988fxh3.js} +5 -5
  72. package/dist/chunk-hr34x6sx.js +2 -0
  73. package/dist/{chunk-ta3wn842.js → chunk-hsy9rhct.js} +2 -2
  74. package/dist/chunk-hygxh993.js +2 -0
  75. package/dist/{chunk-s12bnv32.js → chunk-hz11wmx9.js} +2 -2
  76. package/dist/{chunk-71sdgv7e.js → chunk-j7kcjgxy.js} +215 -56
  77. package/dist/chunk-j87tntna.js +2 -0
  78. package/dist/{chunk-tszkg6sj.js → chunk-jqbk6pfk.js} +2 -2
  79. package/dist/{chunk-be2ba3hj.js → chunk-k1szsenr.js} +2 -2
  80. package/dist/{chunk-3wy8q3aq.js → chunk-k3rnpjxf.js} +5 -5
  81. package/dist/{chunk-jtbzmbzz.js → chunk-k71e38fk.js} +4 -4
  82. package/dist/chunk-kgtnfvqb.js +2 -0
  83. package/dist/chunk-krwrx9x9.js +2 -0
  84. package/dist/{chunk-t61vdbje.js → chunk-ktvr45qg.js} +6 -6
  85. package/dist/{chunk-4rkvwm6v.js → chunk-m3w67x05.js} +9 -9
  86. package/dist/chunk-m5j8hht5.js +2 -0
  87. package/dist/chunk-mc8j6dwa.js +2 -0
  88. package/dist/{chunk-vpdx7qr3.js → chunk-mmbspaqh.js} +2 -2
  89. package/dist/{chunk-pmpb34md.js → chunk-n0t938d2.js} +7 -7
  90. package/dist/{chunk-c1r7zq0q.js → chunk-n2gy2arh.js} +89 -89
  91. package/dist/chunk-n2j3pn9s.js +2 -0
  92. package/dist/{chunk-sv5nvfmb.js → chunk-np6nm4rq.js} +2 -2
  93. package/dist/chunk-ns1jqzqk.js +2 -0
  94. package/dist/chunk-p973efbe.js +2 -0
  95. package/dist/{chunk-m8tm44rq.js → chunk-pg164sdw.js} +2 -2
  96. package/dist/{chunk-yhpyqsbr.js → chunk-pxw4edw8.js} +4 -4
  97. package/dist/{chunk-1r1maqep.js → chunk-q1cvef6b.js} +3 -3
  98. package/dist/chunk-q765v7b2.js +2 -0
  99. package/dist/{chunk-620szfcp.js → chunk-qebxzf9w.js} +3 -3
  100. package/dist/{chunk-jpqkm8tm.js → chunk-qf3axv86.js} +3 -3
  101. package/dist/{chunk-7hkc96de.js → chunk-qhr1tkhj.js} +7 -7
  102. package/dist/chunk-qq59xzwc.js +2 -0
  103. package/dist/chunk-r0e743c3.js +2 -0
  104. package/dist/{chunk-qccgncp2.js → chunk-rdm5mfc5.js} +6 -6
  105. package/dist/chunk-s043hpvd.js +2 -0
  106. package/dist/{chunk-rr8a7d4q.js → chunk-s1ptn02h.js} +3 -3
  107. package/dist/{chunk-xpnpg967.js → chunk-s5vxxwg6.js} +2 -2
  108. package/dist/chunk-sckze59r.js +2 -0
  109. package/dist/chunk-sjkdpsca.js +3 -0
  110. package/dist/chunk-sr1md7vv.js +2845 -0
  111. package/dist/chunk-t431anrx.js +2 -0
  112. package/dist/chunk-t7mxbt40.js +2 -0
  113. package/dist/{chunk-r47cs92n.js → chunk-tc15vkfh.js} +2 -2
  114. package/dist/{chunk-6z3e1tyz.js → chunk-tnafnb23.js} +1 -1
  115. package/dist/{chunk-ah9xyss2.js → chunk-v8ze2q95.js} +2 -2
  116. package/dist/{chunk-t4g2fptt.js → chunk-vf15db1j.js} +6 -6
  117. package/dist/chunk-vvqxbhfx.js +2 -0
  118. package/dist/{chunk-cdgwkzms.js → chunk-w24qmxc3.js} +3 -3
  119. package/dist/chunk-w7zgftez.js +2 -0
  120. package/dist/chunk-wfp36qf4.js +2 -0
  121. package/dist/chunk-wn2gzwmv.js +2 -0
  122. package/dist/{chunk-wwj8zbzc.js → chunk-wywprjc5.js} +5 -5
  123. package/dist/chunk-x5qymgxa.js +2 -0
  124. package/dist/chunk-xfe2nzxd.js +2 -0
  125. package/dist/chunk-xjwgzp6s.js +2 -0
  126. package/dist/chunk-xyepqdjy.js +2 -0
  127. package/dist/chunk-y5ryjdpv.js +122 -0
  128. package/dist/{chunk-3e3dpp7w.js → chunk-y5x8xnnf.js} +3 -3
  129. package/dist/{chunk-74j18qk0.js → chunk-y8h823cb.js} +28 -28
  130. package/dist/chunk-yhqaafsw.js +2 -0
  131. package/dist/chunk-yn2d8x8m.js +3 -0
  132. package/dist/{chunk-kp0hg06s.js → chunk-z2mg470f.js} +4 -4
  133. package/dist/chunk-z7trbwn3.js +2 -0
  134. package/dist/{chunk-eww6sdzz.js → chunk-zgv1h2np.js} +2 -2
  135. package/dist/{chunk-bj29pwm0.js → chunk-zrw1zf54.js} +3 -3
  136. package/dist/chunk-zxf8f71v.js +2 -0
  137. package/dist/chunk-zxt75k06.js +2 -0
  138. package/dist/cli.js +46 -46
  139. package/dist/client/signals-authoring-runtime.js +13 -6
  140. package/dist/client/signals-binding-utils-runtime.js +14 -1
  141. package/dist/client/signals-component-api-runtime.js +3 -1
  142. package/dist/client/signals-event-shorthand-runtime.js +1 -1
  143. package/dist/client/signals-expression-runtime.js +1 -1
  144. package/dist/client/signals-host-runtime.js +72 -1
  145. package/dist/client/signals-manifest-hydration-runtime.js +20 -0
  146. package/dist/client/signals-model-runtime.js +2 -0
  147. package/dist/client/signals-mount-runtime.js +5 -1
  148. package/dist/client/signals-overlay-runtime.js +29 -6
  149. package/dist/client/signals-process-element-runtime.js +22 -7
  150. package/dist/client/signals-public-api-runtime.js +2 -0
  151. package/dist/client/signals-style-runtime.js +1 -1
  152. package/dist/component-model.d.ts +1 -1
  153. package/dist/component-model.js +6 -3
  154. package/dist/component-renderer.js +26 -6
  155. package/dist/composition-api.js +3 -2
  156. package/dist/craft-entry.js +2 -2
  157. package/dist/craft.js +2 -2
  158. package/dist/native/compiler/bundle.js +8 -3
  159. package/dist/native/compiler/design-tokens.d.ts +4 -0
  160. package/dist/native/compiler/design-tokens.js +28 -0
  161. package/dist/native/compiler/headwind-to-style.d.ts +5 -4
  162. package/dist/native/compiler/headwind-to-style.js +105 -65
  163. package/dist/native/compiler/html-to-ir.d.ts +5 -1
  164. package/dist/native/compiler/html-to-ir.js +75 -244
  165. package/dist/native/compiler/inline-style.d.ts +13 -0
  166. package/dist/native/compiler/inline-style.js +285 -0
  167. package/dist/native/compiler/ir.d.ts +5 -1
  168. package/dist/native/compiler/render-screen.js +3 -1
  169. package/dist/native/compiler/style-variables.d.ts +8 -0
  170. package/dist/native/compiler/style-variables.js +142 -0
  171. package/dist/native/compiler/stylesheet-theme.d.ts +6 -0
  172. package/dist/native/compiler/stylesheet-theme.js +110 -0
  173. package/dist/native/runtime/binding-tree.js +12 -0
  174. package/dist/native/runtime/craft-bridge.js +5 -2
  175. package/dist/native/runtime/jsc-globals.d.ts +10 -3
  176. package/dist/native/runtime/jsc-globals.js +23 -4
  177. package/dist/native/runtime/native-host.d.ts +17 -2
  178. package/dist/native/runtime/native-host.js +492 -39
  179. package/dist/native/runtime/overlay-presenter.d.ts +29 -0
  180. package/dist/native/runtime/overlay-presenter.js +69 -0
  181. package/dist/native/runtime/shared-screen.js +13 -1
  182. package/dist/native/runtime/view-operations.d.ts +20 -0
  183. package/dist/native/runtime/view-operations.js +35 -0
  184. package/dist/native/testing-mutations.d.ts +4 -0
  185. package/dist/native/testing-mutations.js +64 -0
  186. package/dist/native/testing.d.ts +2 -0
  187. package/dist/native/testing.js +19 -2
  188. package/dist/pwa.js +3 -3
  189. package/dist/ssg.js +8 -8
  190. package/dist/testing.js +2 -0
  191. package/dist/types/config-types.d.ts +2 -0
  192. package/dist/utils.d.ts +1 -1
  193. package/dist/utils.js +25 -5
  194. package/package.json +5 -5
  195. package/dist/chunk-0047meje.js +0 -2
  196. package/dist/chunk-00p22wzr.js +0 -3
  197. package/dist/chunk-1cat8kdj.js +0 -2
  198. package/dist/chunk-1dwnp35v.js +0 -2
  199. package/dist/chunk-2dnr5qfk.js +0 -2
  200. package/dist/chunk-2rx9d75e.js +0 -4
  201. package/dist/chunk-2v73cjbc.js +0 -2
  202. package/dist/chunk-30rf7k4n.js +0 -122
  203. package/dist/chunk-3akgppsy.js +0 -2
  204. package/dist/chunk-3x6p9me0.js +0 -2
  205. package/dist/chunk-4t67wmcg.js +0 -2
  206. package/dist/chunk-51zn42jy.js +0 -2
  207. package/dist/chunk-5702x95v.js +0 -2
  208. package/dist/chunk-5db5sxy3.js +0 -3
  209. package/dist/chunk-5pgbsc3a.js +0 -2
  210. package/dist/chunk-60c2bsh9.js +0 -2
  211. package/dist/chunk-79v4d9qh.js +0 -2
  212. package/dist/chunk-7pp2vx1g.js +0 -2
  213. package/dist/chunk-84f9dnq5.js +0 -2
  214. package/dist/chunk-8tq5x4z8.js +0 -2
  215. package/dist/chunk-8zm6tkqb.js +0 -2
  216. package/dist/chunk-a1z36dt5.js +0 -2
  217. package/dist/chunk-atsf1fe0.js +0 -2
  218. package/dist/chunk-b8qd6h1q.js +0 -2
  219. package/dist/chunk-ccxs40xy.js +0 -2
  220. package/dist/chunk-cg8hg6cs.js +0 -3
  221. package/dist/chunk-cp442y7a.js +0 -2
  222. package/dist/chunk-d4en5d3s.js +0 -2
  223. package/dist/chunk-dh80d57p.js +0 -2
  224. package/dist/chunk-dpn1pmxj.js +0 -2
  225. package/dist/chunk-dtcc09x1.js +0 -2
  226. package/dist/chunk-dyqte1xq.js +0 -2
  227. package/dist/chunk-e4n4v022.js +0 -2
  228. package/dist/chunk-efgk2xv1.js +0 -2
  229. package/dist/chunk-faghmmrs.js +0 -2838
  230. package/dist/chunk-fj70wq7k.js +0 -2
  231. package/dist/chunk-g2fw68zm.js +0 -2
  232. package/dist/chunk-hcgm37dy.js +0 -2
  233. package/dist/chunk-hd2bn5q7.js +0 -2
  234. package/dist/chunk-j1nqnmcd.js +0 -18
  235. package/dist/chunk-k7jqkt93.js +0 -2
  236. package/dist/chunk-mhjwtkx9.js +0 -2
  237. package/dist/chunk-mqy7g74k.js +0 -2
  238. package/dist/chunk-mxe21m6q.js +0 -2
  239. package/dist/chunk-ne03tfje.js +0 -2
  240. package/dist/chunk-p2sns0bn.js +0 -2
  241. package/dist/chunk-q2a58n2a.js +0 -2
  242. package/dist/chunk-s1sycp43.js +0 -2
  243. package/dist/chunk-s932zfjz.js +0 -2
  244. package/dist/chunk-sp46w7z9.js +0 -2
  245. package/dist/chunk-sy1bk1ry.js +0 -2
  246. package/dist/chunk-t48ws5j0.js +0 -2
  247. package/dist/chunk-thbc9gtj.js +0 -2
  248. package/dist/chunk-tn9v10q2.js +0 -2
  249. package/dist/chunk-tpd5nwa3.js +0 -2
  250. package/dist/chunk-tpt4bgs5.js +0 -2
  251. package/dist/chunk-v8p5p2kp.js +0 -2
  252. package/dist/chunk-v9jd283e.js +0 -2
  253. package/dist/chunk-vq0cb1m9.js +0 -2
  254. package/dist/chunk-wg2w7zmt.js +0 -3
  255. package/dist/chunk-wgkxgsqx.js +0 -2
  256. package/dist/chunk-y1bppxgw.js +0 -2
  257. package/dist/chunk-yv5rwthv.js +0 -2
  258. package/dist/chunk-yygze2s0.js +0 -2
  259. package/dist/chunk-z1r4tdqy.js +0 -2
  260. package/dist/chunk-z732tf98.js +0 -2
  261. package/dist/chunk-zv288w4e.js +0 -2
@@ -1,27 +1,49 @@
1
1
  import { compileClassStyles } from "../compiler/headwind-to-style.js";
2
2
  import { resolveIconName } from "../compiler/icons.js";
3
+ import { parseNativeStyleLayers } from "../compiler/inline-style.js";
4
+ import { createStyleVariables } from "../compiler/style-variables.js";
3
5
  import { affectsGeometry, parseSvgMarkup, parseViewBox, SVG_NODE_TYPES, svgGeometry } from "../compiler/svg.js";
4
6
  import { NATIVE_EVENT_NAMES } from "../event-names.js";
5
7
  import { nativePropName } from "../prop-names.js";
6
8
  import { cloneNativeBindingNode } from "./binding-tree.js";
9
+ import { NATIVE_FORM_ENTRIES } from "./jsc-globals.js";
10
+ import { createNativeOverlayPresenter } from "./overlay-presenter.js";
11
+ import { nativeViewError } from "./view-operations.js";
7
12
  function irDisplay(value) {
8
13
  return value === "none" || value === "grid" || value === "flex" ? value : "flex";
9
14
  }
10
- function eventAt(payload, node) {
11
- if (payload === void 0 || payload === null)
12
- return { target: node, currentTarget: node };
13
- if (typeof payload !== "object" || Array.isArray(payload))
15
+ function eventAt(payload, node, type = "") {
16
+ if (payload != null && (typeof payload !== "object" || Array.isArray(payload)))
14
17
  return payload;
15
- const event = payload;
16
- return { ...event, target: event.target ?? node, currentTarget: event.currentTarget ?? node };
18
+ return {
19
+ ...payload,
20
+ type,
21
+ target: node,
22
+ currentTarget: node,
23
+ bubbles: !0,
24
+ cancelBubble: !1,
25
+ defaultPrevented: !1,
26
+ preventDefault() {
27
+ this.defaultPrevented = !0;
28
+ },
29
+ stopPropagation() {
30
+ this.cancelBubble = !0;
31
+ }
32
+ };
17
33
  }
18
34
  export const HOST_METHODS = [
35
+ "parent",
36
+ "getAttribute",
37
+ "observeChildren",
19
38
  "setText",
20
39
  "setMarkup",
21
40
  "setAttribute",
22
41
  "removeAttribute",
42
+ "observeAttributes",
23
43
  "setStyle",
24
44
  "listen",
45
+ "emitComponentEvent",
46
+ "onFormReset",
25
47
  "scopeOf",
26
48
  "setVisible",
27
49
  "anchor",
@@ -32,9 +54,19 @@ export const HOST_METHODS = [
32
54
  "scopesIn"
33
55
  ];
34
56
  export function createNativeHost(options) {
35
- const records = new Map, handlers = new Map;
36
- let queue = [], scheduled = !1, counter = 0, colorScheme = options.colorScheme ?? "light";
57
+ const records = new Map, attributeObservers = new WeakMap, childObservers = new WeakMap, handlers = new Map, eventRegistrations = new WeakMap, componentListeners = new WeakMap, controlsWithDefaultListeners = new WeakSet, formResetCallbacks = new WeakMap;
58
+ let queue = [], scheduled = !1, counter = 0, colorScheme = options.colorScheme ?? "light", stylesheetVariables = createStyleVariables(options.stylesheetTheme?.[colorScheme] ?? []).computed(), disposed = !1;
37
59
  const schedule = options.schedule ?? ((flush) => queueMicrotask(flush)), nextId = (prefix) => `${prefix}${++counter}`;
60
+ function notifyAttributes(node, name) {
61
+ for (const observer of attributeObservers.get(node) ?? [])
62
+ if (observer.names.includes(name))
63
+ observer.notify();
64
+ }
65
+ function notifyChildren(node) {
66
+ for (let current = node;current; current = current.__stxOwner)
67
+ for (const notify of childObservers.get(current) ?? [])
68
+ notify();
69
+ }
38
70
  function flush() {
39
71
  scheduled = !1;
40
72
  if (queue.length === 0)
@@ -44,6 +76,8 @@ export function createNativeHost(options) {
44
76
  options.send(batch);
45
77
  }
46
78
  function emit(operation) {
79
+ if (disposed)
80
+ return;
47
81
  queue.push(operation);
48
82
  if (!scheduled) {
49
83
  scheduled = !0;
@@ -74,6 +108,7 @@ export function createNativeHost(options) {
74
108
  const record = descriptorOf(node);
75
109
  if (!record)
76
110
  return;
111
+ record.viewEpoch = (record.viewEpoch ?? 0) + 1;
77
112
  for (const handlerId of Object.values(record.events)) {
78
113
  const handler = handlers.get(handlerId);
79
114
  if (!handler)
@@ -98,28 +133,121 @@ export function createNativeHost(options) {
98
133
  return record;
99
134
  }
100
135
  function decorateControl(node, type) {
101
- if (type === "TextInput" || type === "Picker") {
136
+ const htmlCheckbox = type === "Checkbox" && descriptorOf(node)?.props.type === "checkbox", hidden = descriptorOf(node)?.props.type === "hidden";
137
+ if (type === "TextInput" || type === "Picker" || htmlCheckbox || hidden) {
102
138
  Object.defineProperty(node, "value", {
103
139
  configurable: !0,
104
140
  enumerable: !0,
105
- get: () => descriptorOf(node)?.props.value ?? "",
141
+ get: () => descriptorOf(node)?.props[type === "Checkbox" ? "formValue" : "value"] ?? "",
106
142
  set: (value) => {
107
- const record = recordOf(node);
108
- if (Object.is(record.props.value, value))
143
+ const record = recordOf(node), prop = type === "Checkbox" ? "formValue" : "value";
144
+ if (Object.is(record.props[prop], value))
109
145
  return;
110
- record.props.value = value;
146
+ record.props[prop] = value;
111
147
  if (record.materialized)
112
- emit({ op: "updateNode", id: node.__stxId, patch: { props: { value } } });
148
+ emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: value } } });
113
149
  }
114
150
  });
115
151
  Object.defineProperty(node, "type", { configurable: !0, get: () => descriptorOf(node)?.props.type ?? "text" });
152
+ Object.defineProperty(node, "name", { configurable: !0, get: () => descriptorOf(node)?.props.name ?? "" });
153
+ }
154
+ if (type === "Checkbox")
155
+ Object.defineProperty(node, "checked", {
156
+ configurable: !0,
157
+ get: () => Boolean(descriptorOf(node)?.props.checked ?? descriptorOf(node)?.props.value),
158
+ set: (value) => {
159
+ const record = recordOf(node), checked = Boolean(value);
160
+ if (record.props.checked === checked && record.props.value === checked)
161
+ return;
162
+ record.props.checked = checked;
163
+ record.props.value = checked;
164
+ if (record.materialized)
165
+ emit({ op: "updateNode", id: node.__stxId, patch: { props: { checked, value: checked } } });
166
+ }
167
+ });
168
+ if (descriptorOf(node)?.props["data-stx-form"]) {
169
+ Object.defineProperty(node, NATIVE_FORM_ENTRIES, { configurable: !0, value: () => formEntries(node) });
170
+ Object.defineProperty(node, "reset", { configurable: !0, value: () => resetForm(node) });
171
+ }
172
+ }
173
+ function formOwner(node) {
174
+ for (let current = node.__stxOwner;current; current = current.__stxOwner)
175
+ if (descriptorOf(current)?.props["data-stx-form"])
176
+ return current;
177
+ return null;
178
+ }
179
+ function disabled(record) {
180
+ return record.props.disabled === !0 || record.props.disabled === "" || record.props.disabled === "true";
181
+ }
182
+ function formEntries(form) {
183
+ const values = [];
184
+ for (const node of collectDescendants(form)) {
185
+ const record = descriptorOf(node);
186
+ if (!record?.materialized)
187
+ continue;
188
+ const name = record.props.name;
189
+ if (!name || disabled(record) || formOwner(node) !== form)
190
+ continue;
191
+ if (!["TextInput", "Picker", "Checkbox"].includes(record.type) && record.props.type !== "hidden")
192
+ continue;
193
+ if (["submit", "reset", "button", "file"].includes(String(record.props.type)))
194
+ continue;
195
+ if (record.type === "Checkbox" && !node.checked)
196
+ continue;
197
+ const value = record.type === "Checkbox" ? record.props.formValue ?? "on" : record.props.value ?? "";
198
+ for (const item of Array.isArray(value) ? value : [value])
199
+ values.push([String(name), item]);
116
200
  }
201
+ return values;
202
+ }
203
+ function resetForm(form) {
204
+ if (!host.emitComponentEvent(form, eventAt(null, form, "reset")))
205
+ return;
206
+ for (const node of collectDescendants(form)) {
207
+ const record = descriptorOf(node);
208
+ if (!record?.materialized || !record.controlDefaults || formOwner(node) !== form || !("value" in node) && record.type !== "Checkbox")
209
+ continue;
210
+ const control = node;
211
+ if (record.type === "Checkbox")
212
+ control.checked = record.controlDefaults.checked;
213
+ else
214
+ control.value = record.controlDefaults.value;
215
+ }
216
+ for (const node of collectDescendants(form)) {
217
+ if (formOwner(node) !== form)
218
+ continue;
219
+ for (const callback of formResetCallbacks.get(node) ?? [])
220
+ callback();
221
+ }
222
+ }
223
+ function installControlListeners(node) {
224
+ const record = descriptorOf(node);
225
+ if (!record || controlsWithDefaultListeners.has(node))
226
+ return;
227
+ let delegatedPress = !1;
228
+ if (record.type === "Button" || record.type === "Pressable") {
229
+ for (let owner = node.__stxOwner;owner; owner = owner.__stxOwner)
230
+ if (componentListeners.get(owner)?.some((listener) => (NATIVE_EVENT_NAMES[listener.event.toLowerCase()] ?? listener.event) === "onPress")) {
231
+ delegatedPress = !0;
232
+ break;
233
+ }
234
+ }
235
+ if (!formOwner(node) && !delegatedPress)
236
+ return;
237
+ controlsWithDefaultListeners.add(node);
238
+ if (record.type === "TextInput" || record.type === "Picker" || record.type === "Checkbox") {
239
+ host.listen(node, record.type === "TextInput" ? "input" : "change", () => {});
240
+ host.listen(node, "focusout", () => {});
241
+ }
242
+ if (record.type === "Button" || record.type === "Pressable")
243
+ host.listen(node, "click", () => {});
117
244
  }
118
245
  function materialize(node) {
119
246
  const record = recordOf(node);
120
247
  if (record.materialized || node.__stxAnchor !== void 0)
121
248
  return;
122
- record.style = resolveStyle(record);
249
+ installControlListeners(node);
250
+ record.style = resolveStyle(record, node.__stxId);
123
251
  record.materialized = !0;
124
252
  emit({
125
253
  op: "createNode",
@@ -141,16 +269,82 @@ export function createNativeHost(options) {
141
269
  emit({ op: "insertChild", parentId: node.__stxId, childId: child.__stxId, index: index++ });
142
270
  }
143
271
  }
144
- function resolveStyle(record) {
145
- const classes = compileClassStyles(record.classes);
146
- return { ...classes.style, ...colorScheme === "dark" ? classes.dark : {}, ...record.baseStyle };
272
+ function resolveStyle(record, id) {
273
+ const report = (diagnostic) => {
274
+ console.warn(`[STX Native] ${diagnostic.kind}: ${id}: ${diagnostic.name}`);
275
+ };
276
+ let inherited = record.inheritedVariables;
277
+ for (const source of record.styleAncestors ?? [])
278
+ inherited = parseNativeStyleLayers([source], inherited, report).variables;
279
+ const resolved = parseNativeStyleLayers([record.styleSource, record.boundStyle, record.forwardedStyle], inherited, report);
280
+ record.variables = resolved.variables;
281
+ const classes = compileClassStyles(`${record.classes} ${record.forwardedClasses ?? ""}`, record.variables);
282
+ return { ...classes.style, ...colorScheme === "dark" ? classes.dark : {}, ...resolved.styles[0], ...record.baseStyle, ...resolved.styles[1], ...resolved.styles[2], ...record.visible ? {} : { display: "none" } };
283
+ }
284
+ function refreshStyleTree(node, inherited = node.__stxOwner ? descriptorOf(node.__stxOwner)?.variables : stylesheetVariables, appearanceChanged = !1) {
285
+ if (node.__stxAnchor !== void 0)
286
+ return;
287
+ const record = recordOf(node), before = record.variables;
288
+ record.inheritedVariables = inherited;
289
+ applyClasses(node.__stxId, record, !0);
290
+ const after = record.variables;
291
+ if (!appearanceChanged && before?.size === after.size && [...after].every(([name, value]) => before.has(name) && before.get(name) === value))
292
+ return;
293
+ for (const child of record.children)
294
+ refreshStyleTree(child, after, appearanceChanged);
295
+ }
296
+ function forwardedHostRoot(node, name) {
297
+ if (!isBindingNode(node) || !(node.getAttribute("data-stx-native-forward") ?? "").split(/\s+/).includes(name))
298
+ return;
299
+ const find = (candidate) => {
300
+ if (isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-root"))
301
+ return candidate;
302
+ for (const child of recordOf(candidate).children) {
303
+ if (isBindingNode(child) && child.hasAttribute("data-stx-component-wrapper"))
304
+ continue;
305
+ const match = find(child);
306
+ if (match)
307
+ return match;
308
+ }
309
+ };
310
+ return find(node);
311
+ }
312
+ function applyForwardedStyle(node, name, value) {
313
+ const record = recordOf(node);
314
+ if (name === "class" || name === "class-name" || name === "className")
315
+ record.forwardedClasses = Array.isArray(value) ? value.filter(Boolean).join(" ") : value && typeof value === "object" ? Object.entries(value).filter(([, enabled]) => enabled).map(([classes]) => classes).join(" ") : String(value ?? "");
316
+ else if (name === "style")
317
+ record.forwardedStyle = value;
318
+ else
319
+ return !1;
320
+ refreshStyleTree(node);
321
+ return !0;
322
+ }
323
+ function reflectAttribute(node, name, value, remove = !1) {
324
+ if (!isBindingNode(node) || name === "class" || name === "className")
325
+ return;
326
+ if (remove) {
327
+ if (!node.hasAttribute(name))
328
+ return;
329
+ node.removeAttribute(name);
330
+ } else {
331
+ const serialized = typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
332
+ if (node.getAttribute(name) === serialized)
333
+ return;
334
+ node.setAttribute(name, serialized);
335
+ }
336
+ notifyAttributes(node, name);
147
337
  }
148
- function applyClasses(id, record) {
149
- const style = resolveStyle(record), patch = Object.fromEntries(Object.keys(record.style).filter((key) => !(key in style)).map((key) => [key, null]));
338
+ function applyClasses(id, record, onlyIfChanged = !1) {
339
+ const style = resolveStyle(record, id), patch = Object.fromEntries(Object.keys(record.style).filter((key) => !(key in style)).map((key) => [key, null])), changed = !onlyIfChanged || JSON.stringify(record.style) !== JSON.stringify(style);
150
340
  record.style = style;
151
- if (record.materialized)
341
+ if (record.materialized && changed)
152
342
  emit({ op: "updateNode", id, patch: { style: { ...patch, ...style } } });
153
- const classes = compileClassStyles(record.classes);
343
+ const classes = compileClassStyles(`${record.classes} ${record.forwardedClasses ?? ""}`, record.variables), unsupported = new Set(classes.unknown);
344
+ for (const name of unsupported)
345
+ if (!record.reportedClasses?.has(name))
346
+ console.warn(`[STX Native] unknown-class: ${id}: ${name}`);
347
+ record.reportedClasses = unsupported;
154
348
  if (record.type === "Icon" && classes.icon) {
155
349
  const icon = resolveIconName(classes.icon);
156
350
  record.props.symbol = icon.symbol;
@@ -186,6 +380,8 @@ export function createNativeHost(options) {
186
380
  if (target.__stxPositionDecorated)
187
381
  return;
188
382
  Object.defineProperties(target, {
383
+ focus: { configurable: !0, value: (focusOptions) => host.focus(node, focusOptions) },
384
+ measure: { configurable: !0, value: () => host.measure(node) },
189
385
  nextSibling: {
190
386
  configurable: !0,
191
387
  get() {
@@ -208,6 +404,24 @@ export function createNativeHost(options) {
208
404
  });
209
405
  target.__stxPositionDecorated = !0;
210
406
  }
407
+ async function withMountedView(node, request) {
408
+ await Promise.resolve();
409
+ if (disposed)
410
+ throw nativeViewError("SCREEN_CLOSED", "The native screen has closed");
411
+ const record = records.get(node.__stxId);
412
+ if (!record?.materialized || node.__stxAnchor !== void 0 || isBindingNode(node) && !node.isConnected)
413
+ throw nativeViewError("VIEW_NOT_MOUNTED", `Native view ${node.__stxId} is not mounted`);
414
+ if (!options.views)
415
+ throw nativeViewError("UNSUPPORTED", "Native view operations are unavailable");
416
+ const epoch = record.viewEpoch ?? 0;
417
+ flush();
418
+ const result = await request(options.views);
419
+ if (disposed)
420
+ throw nativeViewError("SCREEN_CLOSED", "The native screen has closed");
421
+ if (records.get(node.__stxId) !== record || (record.viewEpoch ?? 0) !== epoch)
422
+ throw nativeViewError("VIEW_NOT_MOUNTED", `Native view ${node.__stxId} changed while the operation was pending`);
423
+ return result;
424
+ }
211
425
  function setConnected(node, connected) {
212
426
  if ("isConnected" in node)
213
427
  node.isConnected = connected;
@@ -234,20 +448,24 @@ export function createNativeHost(options) {
234
448
  const suffix = /(?:^|\D)(\d+)$/.exec(node.__stxId)?.[1];
235
449
  if (suffix)
236
450
  counter = Math.max(counter, Number(suffix));
237
- const classes = descriptor?._classes ?? "", classStyle = compileClassStyles(classes).style, baseStyle = descriptor?._inlineStyle ? { ...descriptor._inlineStyle } : Object.fromEntries(Object.entries(descriptor?.style ?? {}).filter(([key, value]) => classStyle[key] !== value)), record = {
451
+ const classes = descriptor?._classes ?? "", classStyle = compileClassStyles(classes).style, baseStyle = descriptor?._styleSource !== void 0 ? {} : descriptor?._inlineStyle ? { ...descriptor._inlineStyle } : Object.fromEntries(Object.entries(descriptor?.style ?? {}).filter(([key, value]) => classStyle[key] !== value)), record = {
238
452
  type,
239
453
  key: descriptor?.key,
240
454
  props: { ...descriptor?.props ?? {} },
241
455
  style: { ...descriptor?.style ?? {} },
242
456
  baseStyle,
457
+ styleSource: descriptor?._styleSource,
458
+ styleAncestors: descriptor?._styleAncestors,
459
+ inheritedVariables: owner ? descriptorOf(owner)?.variables : stylesheetVariables,
243
460
  classes,
244
461
  events: { ...descriptor?.events ?? {} },
245
462
  text: descriptor?.children?.find((child) => typeof child === "string"),
246
463
  children: [],
247
464
  visible: !0,
248
- materialized: !0
465
+ materialized: !0,
466
+ controlDefaults: { value: descriptor?.props.value ?? "", checked: descriptor?.props.checked ?? descriptor?.props.value ?? !1 }
249
467
  };
250
- record.style = resolveStyle(record);
468
+ record.style = resolveStyle(record, node.__stxId);
251
469
  if (descriptor)
252
470
  descriptor.style = { ...record.style };
253
471
  records.set(node.__stxId, record);
@@ -259,26 +477,93 @@ export function createNativeHost(options) {
259
477
  if (!children.some((child) => child.__stxId === node.__stxId))
260
478
  children.push(node);
261
479
  }
480
+ installControlListeners(node);
262
481
  return node;
263
482
  }
264
- return {
483
+ const overlayPresenter = createNativeOverlayPresenter({
484
+ canFocus: options.views?.capabilities.focus === !0,
485
+ focus: (node, focusOptions) => host.focus(node, focusOptions),
486
+ descendants: collectDescendants,
487
+ hasAutofocus: (node) => {
488
+ const value = descriptorOf(node)?.props.autoFocus;
489
+ return value === !0 || value === "" || value === "true";
490
+ },
491
+ isAvailable: (node) => {
492
+ if (!records.has(node.__stxId) || disabled(recordOf(node)))
493
+ return !1;
494
+ for (let current = node;current; current = current.__stxOwner ?? null) {
495
+ const record = records.get(current.__stxId);
496
+ if (!record?.materialized || !record.visible || record.style.display === "none" || record.type === "Modal" && (record.props.visible === !1 || record.props.visible === "false"))
497
+ return !1;
498
+ }
499
+ return !0;
500
+ },
501
+ type: (node) => descriptorOf(node)?.type,
502
+ setAttribute: (node, name, value) => host.setAttribute(node, name, value),
503
+ setStyle: (node, value) => host.setStyle(node, value),
504
+ listen: (node, event, callback) => host.listen(node, event, callback)
505
+ }), host = {
265
506
  isNative: !0,
507
+ focus: (node, focusOptions) => withMountedView(node, (views) => views.focus(node.__stxId, focusOptions)),
508
+ measure: (node) => withMountedView(node, (views) => views.measure(node.__stxId)),
509
+ syncOverlays: (entries) => overlayPresenter.sync(entries),
510
+ parent(node) {
511
+ return node?.__stxOwner ?? null;
512
+ },
513
+ getAttribute(node, name) {
514
+ if (!node)
515
+ return null;
516
+ if (isBindingNode(node))
517
+ return node.getAttribute(name);
518
+ const value = descriptorOf(node)?.props[nativePropName(name)];
519
+ return value == null || value === !1 ? null : value === !0 ? "" : String(value);
520
+ },
521
+ observeChildren(node, callback) {
522
+ const observers = childObservers.get(node) ?? new Set;
523
+ childObservers.set(node, observers);
524
+ let active = !0, pending = !1;
525
+ const notify = () => {
526
+ if (!active || pending || disposed)
527
+ return;
528
+ pending = !0;
529
+ queueMicrotask(() => {
530
+ pending = !1;
531
+ if (active && !disposed)
532
+ callback();
533
+ });
534
+ };
535
+ observers.add(notify);
536
+ return () => {
537
+ active = !1;
538
+ observers.delete(notify);
539
+ };
540
+ },
266
541
  adopt,
267
542
  setColorScheme(scheme) {
268
543
  if (scheme === colorScheme)
269
544
  return;
270
545
  colorScheme = scheme;
271
- for (const [id, record] of records)
272
- applyClasses(id, record);
546
+ stylesheetVariables = createStyleVariables(options.stylesheetTheme?.[scheme] ?? []).computed();
547
+ const children = new Set([...records.values()].flatMap((record) => record.children.map((child) => child.__stxId)));
548
+ for (const id of records.keys())
549
+ if (!children.has(id))
550
+ refreshStyleTree({ __stxId: id }, stylesheetVariables, !0);
273
551
  },
274
552
  pending: () => queue.length,
275
553
  flush,
554
+ dispose() {
555
+ overlayPresenter.dispose();
556
+ disposed = !0;
557
+ queue = [];
558
+ handlers.clear();
559
+ records.clear();
560
+ },
276
561
  snapshot(root) {
277
562
  queue = [];
278
563
  const describe = (node) => {
279
564
  const record = recordOf(node);
280
565
  if (!record.materialized)
281
- record.style = resolveStyle(record);
566
+ record.style = resolveStyle(record, node.__stxId);
282
567
  record.materialized = !0;
283
568
  const children = record.children.filter((child) => child.__stxAnchor === void 0).map(describe);
284
569
  return {
@@ -320,6 +605,14 @@ export function createNativeHost(options) {
320
605
  }
321
606
  },
322
607
  setAttribute(node, name, value) {
608
+ const forwarded = forwardedHostRoot(node, name);
609
+ reflectAttribute(node, name, value);
610
+ if (forwarded) {
611
+ reflectAttribute(forwarded, name, value);
612
+ if (applyForwardedStyle(forwarded, name, value))
613
+ return;
614
+ node = forwarded;
615
+ }
323
616
  if (name === "class" || name === "className") {
324
617
  const record = recordOf(node);
325
618
  record.classes = String(value ?? "");
@@ -346,6 +639,14 @@ export function createNativeHost(options) {
346
639
  emit({ op: "updateNode", id: node.__stxId, patch: { props: patch } });
347
640
  },
348
641
  removeAttribute(node, name) {
642
+ const forwarded = forwardedHostRoot(node, name);
643
+ reflectAttribute(node, name, void 0, !0);
644
+ if (forwarded) {
645
+ reflectAttribute(forwarded, name, void 0, !0);
646
+ if (applyForwardedStyle(forwarded, name, void 0))
647
+ return;
648
+ node = forwarded;
649
+ }
349
650
  if (name === "class" || name === "className") {
350
651
  this.setAttribute(node, name, "");
351
652
  return;
@@ -358,32 +659,169 @@ export function createNativeHost(options) {
358
659
  if (record.materialized)
359
660
  emit({ op: "updateNode", id: node.__stxId, patch: { props: patch } });
360
661
  },
361
- setStyle(node, value) {
662
+ observeAttributes(node, names, callback) {
663
+ const observers = attributeObservers.get(node) ?? new Set;
664
+ attributeObservers.set(node, observers);
665
+ let active = !0, pending = !1;
666
+ const observer = { names, notify() {
667
+ if (pending || !active)
668
+ return;
669
+ pending = !0;
670
+ queueMicrotask(() => {
671
+ pending = !1;
672
+ if (active && !disposed)
673
+ callback();
674
+ });
675
+ } };
676
+ observers.add(observer);
677
+ return () => {
678
+ active = !1;
679
+ observers.delete(observer);
680
+ };
681
+ },
682
+ setStyle(node, value, replaceBinding = !1) {
683
+ const record = recordOf(node);
684
+ if (replaceBinding) {
685
+ record.boundStyle = value;
686
+ refreshStyleTree(node);
687
+ return;
688
+ }
362
689
  if (typeof value !== "object" || value === null || Array.isArray(value))
363
690
  return;
364
691
  const style = value;
365
- Object.assign(recordOf(node).baseStyle, style);
366
- Object.assign(recordOf(node).style, style);
367
- if (recordOf(node).materialized)
692
+ Object.assign(record.baseStyle, style);
693
+ Object.assign(record.style, style);
694
+ if (record.materialized)
368
695
  emit({ op: "updateNode", id: node.__stxId, patch: { style } });
369
696
  },
370
- listen(node, event, handler) {
371
- const id = nextId("h"), nativeEvent = NATIVE_EVENT_NAMES[event.toLowerCase()] ?? event;
697
+ emitComponentEvent(node, event) {
698
+ if (disposed || !descriptorOf(node)?.materialized)
699
+ return !0;
700
+ const ancestors = [];
701
+ for (let current = node;current; current = current.__stxOwner)
702
+ ancestors.push(current);
703
+ Object.defineProperty(event, "target", { configurable: !0, value: node });
704
+ const invoke = (current, capture) => {
705
+ Object.defineProperty(event, "currentTarget", { configurable: !0, value: current });
706
+ const listeners = componentListeners.get(current) ?? [];
707
+ for (const listener of [...listeners]) {
708
+ if (listener.event !== event.type || listener.capture !== capture)
709
+ continue;
710
+ if (listener.once)
711
+ listeners.splice(listeners.indexOf(listener), 1);
712
+ listener.handler(event);
713
+ }
714
+ };
715
+ try {
716
+ for (const current of ancestors.slice(1).reverse()) {
717
+ invoke(current, !0);
718
+ if (event.cancelBubble)
719
+ return !event.defaultPrevented;
720
+ }
721
+ invoke(node, !0);
722
+ invoke(node, !1);
723
+ if (!event.bubbles || event.cancelBubble)
724
+ return !event.defaultPrevented;
725
+ for (const current of ancestors.slice(1)) {
726
+ invoke(current, !1);
727
+ if (event.cancelBubble)
728
+ break;
729
+ }
730
+ return !event.defaultPrevented;
731
+ } finally {
732
+ Object.defineProperty(event, "currentTarget", { configurable: !0, value: null });
733
+ }
734
+ },
735
+ onFormReset(node, callback) {
736
+ const callbacks = formResetCallbacks.get(node) ?? new Set;
737
+ formResetCallbacks.set(node, callbacks);
738
+ callbacks.add(callback);
739
+ return () => {
740
+ callbacks.delete(callback);
741
+ };
742
+ },
743
+ listen(node, event, handler, options) {
744
+ const listenerOptions = options, listeners = componentListeners.get(node) ?? [], listener = { event, handler, once: !!listenerOptions?.once, capture: !!listenerOptions?.capture };
745
+ listeners.push(listener);
746
+ componentListeners.set(node, listeners);
747
+ const nativeEvent = NATIVE_EVENT_NAMES[event.toLowerCase()] ?? event, record = recordOf(node), registrations = eventRegistrations.get(node) ?? new Map;
748
+ eventRegistrations.set(node, registrations);
749
+ const existing = registrations.get(nativeEvent);
750
+ if (existing && handlers.has(existing))
751
+ return;
752
+ const id = nextId("h");
753
+ registrations.set(nativeEvent, id);
372
754
  handlers.set(id, (payload) => {
755
+ if (disabled(record))
756
+ return;
373
757
  if (nativeEvent === "onChangeText" || nativeEvent === "onValueChange") {
374
758
  const data = payload && typeof payload === "object" ? payload : {}, value = data.text ?? data.value ?? data.nativeEvent?.text ?? data.nativeEvent?.value, record = recordOf(node);
759
+ if (record.type === "Checkbox" && value !== void 0)
760
+ node.checked = Boolean(value);
375
761
  if (value !== void 0 && !Object.is(record.props.value, value) && (record.type === "TextInput" || record.type === "Picker")) {
376
762
  record.props.value = value;
377
763
  if (record.materialized)
378
764
  emit({ op: "updateNode", id: node.__stxId, patch: { props: { value } } });
379
765
  }
380
766
  }
381
- handler(eventAt(payload, node));
767
+ const delivered = eventAt(payload, node, event), physical = delivered && typeof delivered === "object" ? delivered : null, ancestors = [node];
768
+ if (physical && ["onPress", "onChangeText", "onValueChange", "onBlur", "onFocus"].includes(nativeEvent))
769
+ for (let owner = node.__stxOwner;owner; owner = owner.__stxOwner)
770
+ ancestors.push(owner);
771
+ const invoke = (target, capture) => {
772
+ if (physical)
773
+ Object.defineProperty(physical, "currentTarget", { configurable: !0, value: target });
774
+ const group = componentListeners.get(target) ?? [];
775
+ for (const current of [...group]) {
776
+ if ((NATIVE_EVENT_NAMES[current.event.toLowerCase()] ?? current.event) !== nativeEvent || current.capture !== capture)
777
+ continue;
778
+ if (target !== node && (current.event === "blur" || current.event === "focus"))
779
+ continue;
780
+ if (!group.includes(current))
781
+ continue;
782
+ if (current.once)
783
+ group.splice(group.indexOf(current), 1);
784
+ current.handler(delivered);
785
+ }
786
+ };
787
+ let reachedTarget = !0;
788
+ for (const target of ancestors.slice(1).reverse()) {
789
+ invoke(target, !0);
790
+ if (physical?.cancelBubble) {
791
+ reachedTarget = !1;
792
+ break;
793
+ }
794
+ }
795
+ if (reachedTarget) {
796
+ invoke(node, !0);
797
+ invoke(node, !1);
798
+ }
799
+ if (!physical?.cancelBubble)
800
+ for (const target of ancestors.slice(1)) {
801
+ invoke(target, !1);
802
+ if (physical?.cancelBubble)
803
+ break;
804
+ }
805
+ if (physical)
806
+ Object.defineProperty(physical, "currentTarget", { configurable: !0, value: node });
807
+ if (nativeEvent === "onValueChange" && (record.type === "Picker" || record.type === "Checkbox"))
808
+ host.emitComponentEvent(node, eventAt(payload, node, "input"));
809
+ const form = formOwner(node);
810
+ if (form && nativeEvent === "onPress" && !physical?.defaultPrevented && !disabled(record)) {
811
+ if (record.props.type === "submit")
812
+ host.emitComponentEvent(form, eventAt({ submitter: node }, form, "submit"));
813
+ if (record.props.type === "reset")
814
+ resetForm(form);
815
+ }
382
816
  });
383
- const record = recordOf(node);
384
817
  record.events[nativeEvent] = id;
385
818
  if (record.materialized)
386
819
  emit({ op: "updateNode", id: node.__stxId, patch: { events: { [nativeEvent]: id } } });
820
+ if (nativeEvent === "onPress") {
821
+ for (const child of collectDescendants(node))
822
+ if (["Button", "Pressable"].includes(descriptorOf(child)?.type ?? ""))
823
+ installControlListeners(child);
824
+ }
387
825
  },
388
826
  dispatch(handlerId, payload) {
389
827
  handlers.get(handlerId)?.(payload);
@@ -411,7 +849,8 @@ export function createNativeHost(options) {
411
849
  record.baseStyle.display = record.shownDisplay;
412
850
  record.shownDisplay = void 0;
413
851
  }
414
- const display = visible ? irDisplay(resolveStyle(record).display) : "none";
852
+ record.style = resolveStyle(record, node.__stxId);
853
+ const display = visible ? irDisplay(record.style.display) : "none";
415
854
  if (record.materialized)
416
855
  emit({ op: "updateNode", id: node.__stxId, patch: { style: { display } } });
417
856
  return was;
@@ -443,12 +882,20 @@ export function createNativeHost(options) {
443
882
  props: { ...descriptor.props, __stxId: copy.__stxId },
444
883
  style: { ...descriptor.style },
445
884
  baseStyle: { ...descriptor.baseStyle },
885
+ styleSource: descriptor.styleSource,
886
+ styleAncestors: descriptor.styleAncestors,
887
+ inheritedVariables: descriptor.inheritedVariables,
888
+ variables: descriptor.variables,
889
+ boundStyle: descriptor.boundStyle,
446
890
  classes: descriptor.classes,
891
+ forwardedClasses: descriptor.forwardedClasses,
892
+ forwardedStyle: descriptor.forwardedStyle,
447
893
  events: { ...descriptor.events },
448
894
  text: descriptor.text,
449
895
  children: [],
450
896
  visible: descriptor.visible,
451
- materialized: !1
897
+ materialized: !1,
898
+ controlDefaults: descriptor.controlDefaults
452
899
  });
453
900
  decorateControl(copy, descriptor.type);
454
901
  setConnected(copy, !1);
@@ -471,8 +918,12 @@ export function createNativeHost(options) {
471
918
  const index = before ? Math.max(0, record.children.findIndex((child) => child.__stxId === before.__stxId)) : record.children.length;
472
919
  record.children.splice(index, 0, node);
473
920
  node.__stxOwner = parent;
921
+ refreshStyleTree(node, record.variables);
474
922
  insertIntoBindingParent(parent, node, index);
475
923
  setConnected(node, record.materialized);
924
+ if (oldOwner && oldOwner !== parent)
925
+ notifyChildren(oldOwner);
926
+ notifyChildren(parent);
476
927
  if (node.__stxAnchor !== void 0 || !record.materialized)
477
928
  return;
478
929
  materialize(node);
@@ -515,9 +966,11 @@ export function createNativeHost(options) {
515
966
  setConnected(node, !1);
516
967
  releaseHandlers(node);
517
968
  retainDetachedDescriptors(node);
969
+ notifyChildren(owner);
518
970
  if (node.__stxAnchor !== void 0 || !wasMaterialized)
519
971
  return;
520
972
  emit({ op: "removeNode", id: node.__stxId });
521
973
  }
522
974
  };
975
+ return host;
523
976
  }