@stacksjs/stx 0.2.583 → 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 (241) hide show
  1. package/dist/{chunk-ck1yca7g.js → chunk-03qf2z4d.js} +1 -1
  2. package/dist/{chunk-hp9nxva6.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-ky1426s1.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-521pe0hb.js → chunk-5zg3xj45.js} +4 -4
  23. package/dist/{chunk-ye66wc53.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-4pmgr32a.js → chunk-6hgngmn0.js} +3 -3
  27. package/dist/chunk-71tnfe1n.js +2 -0
  28. package/dist/{chunk-mjj24qpb.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-02qaqamv.js → chunk-7ra30crf.js} +7 -7
  32. package/dist/{chunk-117xss52.js → chunk-7xw1e8t6.js} +2 -2
  33. package/dist/{chunk-w6wtxj54.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-qn8gdw21.js → chunk-8s7zbhdd.js} +4 -4
  37. package/dist/chunk-8zn83jfs.js +2 -0
  38. package/dist/{chunk-h3z9b6bw.js → chunk-96zgn94z.js} +11 -11
  39. package/dist/{chunk-6m3me7yj.js → chunk-9cpxzze0.js} +9 -9
  40. package/dist/{chunk-6fc8vw2v.js → chunk-9e091vkf.js} +3 -3
  41. package/dist/chunk-9pk5jhqa.js +3 -0
  42. package/dist/{chunk-09zwhsf9.js → chunk-9r5w6s80.js} +3 -3
  43. package/dist/{chunk-c0h2eqe0.js → chunk-a8n6mt7s.js} +2 -2
  44. package/dist/{chunk-ac6v3s3k.js → chunk-agy4mxn8.js} +2 -2
  45. package/dist/{chunk-mt9x626h.js → chunk-axz1x4r9.js} +5 -5
  46. package/dist/{chunk-07anexcg.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-dvc15djp.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-ym1sb5bg.js → chunk-d2jb1rkp.js} +5 -5
  56. package/dist/{chunk-nhd9m8h5.js → chunk-d4awfk42.js} +6 -6
  57. package/dist/chunk-d9vjsqs4.js +2 -0
  58. package/dist/{chunk-e809x7m0.js → chunk-e26pzdxy.js} +1 -1
  59. package/dist/{chunk-kfwmqacd.js → chunk-e556dvy4.js} +3 -3
  60. package/dist/{chunk-cby4mkjf.js → chunk-e6h7pzym.js} +1 -1
  61. package/dist/{chunk-0dfgefjv.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-vke73gts.js → chunk-fkq55rh7.js} +1 -1
  67. package/dist/chunk-fn4wwgnc.js +2 -0
  68. package/dist/{chunk-pbwk8tzz.js → chunk-g8mxprxj.js} +1 -1
  69. package/dist/chunk-h2534p6q.js +2 -0
  70. package/dist/{chunk-2nehykbm.js → chunk-h7atbtds.js} +5 -5
  71. package/dist/{chunk-nh3svtvj.js → chunk-h988fxh3.js} +5 -5
  72. package/dist/chunk-hr34x6sx.js +2 -0
  73. package/dist/{chunk-en7xxgtb.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-wyn5rfzk.js → chunk-j7kcjgxy.js} +115 -26
  77. package/dist/chunk-j87tntna.js +2 -0
  78. package/dist/{chunk-ycj0342k.js → chunk-jqbk6pfk.js} +2 -2
  79. package/dist/{chunk-vkc51n9m.js → chunk-k1szsenr.js} +2 -2
  80. package/dist/{chunk-xp7fxc6p.js → chunk-k3rnpjxf.js} +5 -5
  81. package/dist/{chunk-sv08pd66.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-je1as16r.js → chunk-m3w67x05.js} +5 -5
  85. package/dist/chunk-m5j8hht5.js +2 -0
  86. package/dist/chunk-mc8j6dwa.js +2 -0
  87. package/dist/{chunk-vpdx7qr3.js → chunk-mmbspaqh.js} +2 -2
  88. package/dist/{chunk-hzqyfdpy.js → chunk-n0t938d2.js} +7 -7
  89. package/dist/{chunk-8tq83fq7.js → chunk-n2gy2arh.js} +57 -57
  90. package/dist/chunk-n2j3pn9s.js +2 -0
  91. package/dist/{chunk-sv5nvfmb.js → chunk-np6nm4rq.js} +2 -2
  92. package/dist/chunk-ns1jqzqk.js +2 -0
  93. package/dist/chunk-p973efbe.js +2 -0
  94. package/dist/{chunk-m8tm44rq.js → chunk-pg164sdw.js} +2 -2
  95. package/dist/{chunk-x552npae.js → chunk-pxw4edw8.js} +4 -4
  96. package/dist/{chunk-1r1maqep.js → chunk-q1cvef6b.js} +3 -3
  97. package/dist/chunk-q765v7b2.js +2 -0
  98. package/dist/{chunk-96mb3brj.js → chunk-qebxzf9w.js} +3 -3
  99. package/dist/{chunk-jpqkm8tm.js → chunk-qf3axv86.js} +3 -3
  100. package/dist/{chunk-dhq80e4r.js → chunk-qhr1tkhj.js} +7 -7
  101. package/dist/chunk-qq59xzwc.js +2 -0
  102. package/dist/chunk-r0e743c3.js +2 -0
  103. package/dist/{chunk-qccgncp2.js → chunk-rdm5mfc5.js} +6 -6
  104. package/dist/chunk-s043hpvd.js +2 -0
  105. package/dist/{chunk-m417sp42.js → chunk-s1ptn02h.js} +3 -3
  106. package/dist/{chunk-g9zeybqh.js → chunk-s5vxxwg6.js} +2 -2
  107. package/dist/chunk-sckze59r.js +2 -0
  108. package/dist/chunk-sjkdpsca.js +3 -0
  109. package/dist/chunk-sr1md7vv.js +2845 -0
  110. package/dist/chunk-t431anrx.js +2 -0
  111. package/dist/chunk-t7mxbt40.js +2 -0
  112. package/dist/{chunk-r47cs92n.js → chunk-tc15vkfh.js} +2 -2
  113. package/dist/{chunk-6z3e1tyz.js → chunk-tnafnb23.js} +1 -1
  114. package/dist/{chunk-ah9xyss2.js → chunk-v8ze2q95.js} +2 -2
  115. package/dist/{chunk-xytkfa48.js → chunk-vf15db1j.js} +6 -6
  116. package/dist/chunk-vvqxbhfx.js +2 -0
  117. package/dist/{chunk-dm1qh2vq.js → chunk-w24qmxc3.js} +3 -3
  118. package/dist/chunk-w7zgftez.js +2 -0
  119. package/dist/chunk-wfp36qf4.js +2 -0
  120. package/dist/chunk-wn2gzwmv.js +2 -0
  121. package/dist/{chunk-wwj8zbzc.js → chunk-wywprjc5.js} +5 -5
  122. package/dist/chunk-x5qymgxa.js +2 -0
  123. package/dist/chunk-xfe2nzxd.js +2 -0
  124. package/dist/chunk-xjwgzp6s.js +2 -0
  125. package/dist/chunk-xyepqdjy.js +2 -0
  126. package/dist/chunk-y5ryjdpv.js +122 -0
  127. package/dist/{chunk-3e3dpp7w.js → chunk-y5x8xnnf.js} +3 -3
  128. package/dist/chunk-yhqaafsw.js +2 -0
  129. package/dist/{chunk-4pkpr5cg.js → chunk-z2mg470f.js} +4 -4
  130. package/dist/chunk-z7trbwn3.js +2 -0
  131. package/dist/{chunk-2943qhdt.js → chunk-zgv1h2np.js} +2 -2
  132. package/dist/{chunk-bj29pwm0.js → chunk-zrw1zf54.js} +3 -3
  133. package/dist/chunk-zxf8f71v.js +2 -0
  134. package/dist/chunk-zxt75k06.js +2 -0
  135. package/dist/cli.js +20 -20
  136. package/dist/client/signals-host-runtime.js +52 -1
  137. package/dist/client/signals-manifest-hydration-runtime.js +13 -0
  138. package/dist/client/signals-overlay-runtime.js +29 -6
  139. package/dist/client/signals-public-api-runtime.js +2 -0
  140. package/dist/client/signals-style-runtime.js +1 -1
  141. package/dist/component-renderer.js +26 -6
  142. package/dist/craft-entry.js +2 -2
  143. package/dist/craft.js +2 -2
  144. package/dist/native/compiler/design-tokens.d.ts +4 -0
  145. package/dist/native/compiler/design-tokens.js +28 -0
  146. package/dist/native/compiler/headwind-to-style.d.ts +5 -4
  147. package/dist/native/compiler/headwind-to-style.js +105 -65
  148. package/dist/native/compiler/html-to-ir.d.ts +3 -1
  149. package/dist/native/compiler/html-to-ir.js +47 -243
  150. package/dist/native/compiler/inline-style.d.ts +13 -0
  151. package/dist/native/compiler/inline-style.js +285 -0
  152. package/dist/native/compiler/ir.d.ts +5 -1
  153. package/dist/native/compiler/render-screen.js +3 -1
  154. package/dist/native/compiler/style-variables.d.ts +8 -0
  155. package/dist/native/compiler/style-variables.js +142 -0
  156. package/dist/native/compiler/stylesheet-theme.d.ts +6 -0
  157. package/dist/native/compiler/stylesheet-theme.js +110 -0
  158. package/dist/native/runtime/craft-bridge.js +3 -1
  159. package/dist/native/runtime/native-host.d.ts +13 -2
  160. package/dist/native/runtime/native-host.js +237 -36
  161. package/dist/native/runtime/overlay-presenter.d.ts +29 -0
  162. package/dist/native/runtime/overlay-presenter.js +69 -0
  163. package/dist/native/runtime/shared-screen.js +12 -1
  164. package/dist/native/runtime/view-operations.d.ts +20 -0
  165. package/dist/native/runtime/view-operations.js +35 -0
  166. package/dist/native/testing-mutations.d.ts +4 -0
  167. package/dist/native/testing-mutations.js +64 -0
  168. package/dist/native/testing.d.ts +2 -0
  169. package/dist/native/testing.js +18 -1
  170. package/dist/pwa.js +3 -3
  171. package/dist/ssg.js +9 -9
  172. package/dist/testing.js +2 -0
  173. package/dist/types/config-types.d.ts +2 -0
  174. package/dist/utils.d.ts +1 -1
  175. package/dist/utils.js +25 -5
  176. package/package.json +5 -5
  177. package/dist/chunk-00p22wzr.js +0 -3
  178. package/dist/chunk-0fx3ppnt.js +0 -2
  179. package/dist/chunk-0sfexf9t.js +0 -2
  180. package/dist/chunk-2927nax9.js +0 -2
  181. package/dist/chunk-2rj0ttas.js +0 -2
  182. package/dist/chunk-2rx9d75e.js +0 -4
  183. package/dist/chunk-3ae39ttg.js +0 -2
  184. package/dist/chunk-3x6p9me0.js +0 -2
  185. package/dist/chunk-440yjsk5.js +0 -2
  186. package/dist/chunk-58z26y07.js +0 -2
  187. package/dist/chunk-5db5sxy3.js +0 -3
  188. package/dist/chunk-5r9k9s3m.js +0 -2
  189. package/dist/chunk-76vza4ve.js +0 -2
  190. package/dist/chunk-84f9dnq5.js +0 -2
  191. package/dist/chunk-8tq5x4z8.js +0 -2
  192. package/dist/chunk-8y8bbsh5.js +0 -2
  193. package/dist/chunk-9kzycb15.js +0 -2
  194. package/dist/chunk-agfhb2qd.js +0 -2
  195. package/dist/chunk-ay6dzpt4.js +0 -2
  196. package/dist/chunk-b9njk81d.js +0 -2
  197. package/dist/chunk-bfbcmfww.js +0 -2
  198. package/dist/chunk-br01jvra.js +0 -2
  199. package/dist/chunk-c12y2bet.js +0 -2
  200. package/dist/chunk-c2nwchk0.js +0 -2
  201. package/dist/chunk-cxqrwvc5.js +0 -2
  202. package/dist/chunk-czea8zr1.js +0 -2
  203. package/dist/chunk-d99kfx3k.js +0 -2
  204. package/dist/chunk-dpn1pmxj.js +0 -2
  205. package/dist/chunk-dskrwa8f.js +0 -2
  206. package/dist/chunk-e6ycqvdm.js +0 -2
  207. package/dist/chunk-efgk2xv1.js +0 -2
  208. package/dist/chunk-fj70wq7k.js +0 -2
  209. package/dist/chunk-fvx6pd66.js +0 -2
  210. package/dist/chunk-hrbjapvr.js +0 -2
  211. package/dist/chunk-jc4mxq56.js +0 -2
  212. package/dist/chunk-jdpyxt8j.js +0 -2
  213. package/dist/chunk-k0zev8wc.js +0 -2
  214. package/dist/chunk-mhjwtkx9.js +0 -2
  215. package/dist/chunk-n4e02qdz.js +0 -2838
  216. package/dist/chunk-nx8rf4qd.js +0 -2
  217. package/dist/chunk-pe5bk9ns.js +0 -2
  218. package/dist/chunk-qb2j34sp.js +0 -2
  219. package/dist/chunk-qknfceta.js +0 -2
  220. package/dist/chunk-s932zfjz.js +0 -2
  221. package/dist/chunk-sf98zgw2.js +0 -2
  222. package/dist/chunk-sgsp4dph.js +0 -2
  223. package/dist/chunk-t48ws5j0.js +0 -2
  224. package/dist/chunk-tfxmzat6.js +0 -122
  225. package/dist/chunk-thbc9gtj.js +0 -2
  226. package/dist/chunk-tms7amrb.js +0 -2
  227. package/dist/chunk-tn9v10q2.js +0 -2
  228. package/dist/chunk-v0zgarvv.js +0 -2
  229. package/dist/chunk-v9jd283e.js +0 -2
  230. package/dist/chunk-vczw73ga.js +0 -2
  231. package/dist/chunk-webrqm20.js +0 -2
  232. package/dist/chunk-wg2w7zmt.js +0 -3
  233. package/dist/chunk-wgkxgsqx.js +0 -2
  234. package/dist/chunk-wngqr949.js +0 -2
  235. package/dist/chunk-xyzy84x0.js +0 -2
  236. package/dist/chunk-y1jffvkj.js +0 -2
  237. package/dist/chunk-yas134jv.js +0 -2
  238. package/dist/chunk-yd55vynh.js +0 -2
  239. package/dist/chunk-yygze2s0.js +0 -2
  240. package/dist/chunk-z732tf98.js +0 -2
  241. package/dist/chunk-ze86h6vp.js +0 -2
@@ -2,6 +2,9 @@ import { NATIVE_EVENT_NAMES as EVENT_NAMES } from "../event-names.js";
2
2
  import { NATIVE_BOOLEAN_PROPS, nativePropName } from "../prop-names.js";
3
3
  import { mapToNativeComponent } from "./component-mapping.js";
4
4
  import { resolveIconName } from "./icons.js";
5
+ import { parseNativeStyle } from "./inline-style.js";
6
+ import { createStyleVariables } from "./style-variables.js";
7
+ import { extractStylesheetTheme } from "./stylesheet-theme.js";
5
8
  import { parseViewBox, SVG_DROPPED, SVG_NODE_TYPES, SVG_TYPES, svgGeometry } from "./svg.js";
6
9
  import { compileClassStyles } from "./headwind-to-style.js";
7
10
  import { createDocument, createNode } from "./ir.js";
@@ -41,153 +44,7 @@ export const NATIVE_EVENTS = new Set([
41
44
  "onSubmitEditing",
42
45
  "onValueChange"
43
46
  ]);
44
- const STYLE_KEYS = new Set([
45
- "display",
46
- "gridColumns",
47
- "gridTemplateColumns",
48
- "gridAutoRows",
49
- "flex",
50
- "flexGrow",
51
- "flexShrink",
52
- "flexBasis",
53
- "flexDirection",
54
- "flexWrap",
55
- "justifyContent",
56
- "alignItems",
57
- "alignSelf",
58
- "alignContent",
59
- "position",
60
- "top",
61
- "right",
62
- "bottom",
63
- "left",
64
- "zIndex",
65
- "width",
66
- "height",
67
- "minWidth",
68
- "maxWidth",
69
- "minHeight",
70
- "maxHeight",
71
- "aspectRatio",
72
- "margin",
73
- "marginTop",
74
- "marginRight",
75
- "marginBottom",
76
- "marginLeft",
77
- "marginHorizontal",
78
- "marginVertical",
79
- "padding",
80
- "paddingTop",
81
- "paddingRight",
82
- "paddingBottom",
83
- "paddingLeft",
84
- "paddingHorizontal",
85
- "paddingVertical",
86
- "gap",
87
- "rowGap",
88
- "columnGap",
89
- "borderWidth",
90
- "borderTopWidth",
91
- "borderRightWidth",
92
- "borderBottomWidth",
93
- "borderLeftWidth",
94
- "borderColor",
95
- "borderTopColor",
96
- "borderRightColor",
97
- "borderBottomColor",
98
- "borderLeftColor",
99
- "borderRadius",
100
- "borderTopLeftRadius",
101
- "borderTopRightRadius",
102
- "borderBottomLeftRadius",
103
- "borderBottomRightRadius",
104
- "borderStyle",
105
- "backgroundColor",
106
- "backgroundImage",
107
- "opacity",
108
- "shadowColor",
109
- "shadowOffset",
110
- "shadowOpacity",
111
- "shadowRadius",
112
- "elevation",
113
- "color",
114
- "fontSize",
115
- "fontWeight",
116
- "fontStyle",
117
- "fontFamily",
118
- "lineHeight",
119
- "letterSpacing",
120
- "textAlign",
121
- "textDecorationLine",
122
- "textDecorationColor",
123
- "textTransform",
124
- "resizeMode",
125
- "tintColor",
126
- "transform",
127
- "overflow",
128
- "fill",
129
- "stroke",
130
- "strokeWidth",
131
- "gradientDirection",
132
- "gradientFrom",
133
- "gradientVia",
134
- "gradientTo"
135
- ]), NUMERIC_STYLE_KEYS = new Set([
136
- "gridColumns",
137
- "gridAutoRows",
138
- "flex",
139
- "flexGrow",
140
- "flexShrink",
141
- "zIndex",
142
- "aspectRatio",
143
- "gap",
144
- "rowGap",
145
- "columnGap",
146
- "borderWidth",
147
- "borderTopWidth",
148
- "borderRightWidth",
149
- "borderBottomWidth",
150
- "borderLeftWidth",
151
- "borderRadius",
152
- "borderTopLeftRadius",
153
- "borderTopRightRadius",
154
- "borderBottomLeftRadius",
155
- "borderBottomRightRadius",
156
- "opacity",
157
- "shadowOpacity",
158
- "shadowRadius",
159
- "elevation",
160
- "fontSize",
161
- "lineHeight",
162
- "letterSpacing",
163
- "strokeWidth"
164
- ]), DIMENSION_STYLE_KEYS = new Set([
165
- "top",
166
- "right",
167
- "bottom",
168
- "left",
169
- "width",
170
- "height",
171
- "minWidth",
172
- "maxWidth",
173
- "minHeight",
174
- "maxHeight",
175
- "flexBasis",
176
- "margin",
177
- "marginTop",
178
- "marginRight",
179
- "marginBottom",
180
- "marginLeft",
181
- "marginHorizontal",
182
- "marginVertical",
183
- "padding",
184
- "paddingTop",
185
- "paddingRight",
186
- "paddingBottom",
187
- "paddingLeft",
188
- "paddingHorizontal",
189
- "paddingVertical"
190
- ]), NATIVE_TYPES = new Set([
47
+ const NATIVE_TYPES = new Set([
191
48
  "Sidebar",
192
49
  "SplitView",
193
50
  "View",
@@ -248,21 +105,8 @@ function decodeEntities(text) {
248
105
  return whole;
249
106
  });
250
107
  }
251
- function camelCase(property) {
252
- return property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
253
- }
254
- function styleValue(raw) {
255
- const pixels = /^(-?[\d.]+)px$/.exec(raw);
256
- if (pixels)
257
- return Number.parseFloat(pixels[1]);
258
- const relative = /^(-?[\d.]+)r?em$/.exec(raw);
259
- if (relative)
260
- return Number.parseFloat(relative[1]) * 16;
261
- if (/^-?[\d.]+$/.test(raw))
262
- return Number.parseFloat(raw);
263
- return raw;
264
- }
265
- function readAttributes(tag, attributes, diagnostics) {
108
+ function readAttributes(tag, attributes, diagnostics, styleContext = {}) {
109
+ let variables = styleContext.inheritedVariables;
266
110
  const props = {}, events = {}, bindings = {};
267
111
  let classes = "", inline = {};
268
112
  for (const [rawName, value] of attributes) {
@@ -272,7 +116,10 @@ function readAttributes(tag, attributes, diagnostics) {
272
116
  continue;
273
117
  }
274
118
  if (name === "style") {
275
- inline = { ...inline, ...inlineStyle(tag, value, diagnostics) };
119
+ inline = { ...inline, ...inlineStyle(tag, value, diagnostics, { ...styleContext, onVariables(value) {
120
+ variables = value;
121
+ styleContext.onVariables?.(value);
122
+ } }) };
276
123
  continue;
277
124
  }
278
125
  if (name.startsWith(":") || name.startsWith("x-") && name !== "x-cloak") {
@@ -305,92 +152,26 @@ function readAttributes(tag, attributes, diagnostics) {
305
152
  props[prop] = decoded;
306
153
  }
307
154
  }
308
- const compiledClasses = classes ? compileClassStyles(classes) : void 0;
155
+ const compiledClasses = classes ? compileClassStyles(classes, variables) : void 0;
309
156
  for (const name of new Set(compiledClasses?.unknown ?? []))
310
157
  diagnostics.push({ kind: "unknown-class", tag, name });
311
158
  const style = { ...compiledClasses?.style, ...inline };
312
159
  return { props, style, events, bindings, classes, inline };
313
160
  }
314
- function structuredStyle(property, value) {
315
- if (property === "shadowOffset") {
316
- if (!value || typeof value !== "object" || Array.isArray(value))
317
- return;
318
- const { width, height } = value;
319
- return typeof width === "number" && typeof height === "number" ? { width, height } : void 0;
320
- }
321
- if (property === "transform") {
322
- if (!Array.isArray(value))
323
- return;
324
- const steps = value.filter((step) => Boolean(step) && typeof step === "object" && !Array.isArray(step) && Object.keys(step).length === 1).filter((step) => ["number", "string"].includes(typeof Object.values(step)[0]));
325
- return steps.length ? steps : void 0;
326
- }
327
- return;
328
- }
329
- function holdsString(property, value) {
330
- if (NUMERIC_STYLE_KEYS.has(property))
331
- return !1;
332
- if (DIMENSION_STYLE_KEYS.has(property))
333
- return /^-?[\d.]+%$/.test(value);
334
- return !0;
335
- }
336
- function inlineStyle(tag, css, diagnostics) {
337
- const style = {}, decoded = decodeEntities(css);
338
- try {
339
- const object = JSON.parse(decoded);
340
- if (object && typeof object === "object" && !Array.isArray(object)) {
341
- for (const [rawProperty, rawValue] of Object.entries(object)) {
342
- const property = STYLE_KEYS.has(rawProperty) ? rawProperty : camelCase(rawProperty.trim().toLowerCase());
343
- if (!STYLE_KEYS.has(property)) {
344
- diagnostics.push({ kind: "unknown-style", tag, name: property });
345
- continue;
346
- }
347
- if (rawValue === null || rawValue === void 0)
348
- continue;
349
- const translated = typeof rawValue === "string" ? styleValue(rawValue) : rawValue;
350
- if (typeof translated === "object") {
351
- const kept = structuredStyle(property, translated);
352
- if (kept === void 0)
353
- diagnostics.push({ kind: "non-numeric-style", tag, name: property });
354
- else
355
- style[property] = kept;
356
- continue;
357
- }
358
- if (typeof translated !== "string" && typeof translated !== "number")
359
- continue;
360
- if (typeof translated === "string" && !holdsString(property, translated)) {
361
- diagnostics.push({ kind: "non-numeric-style", tag, name: property });
362
- continue;
363
- }
364
- style[property] = translated;
365
- }
366
- return style;
367
- }
368
- } catch {}
369
- for (const declaration of decoded.split(";")) {
370
- const colon = declaration.indexOf(":");
371
- if (colon === -1)
372
- continue;
373
- const property = camelCase(declaration.slice(0, colon).trim().toLowerCase()), value = declaration.slice(colon + 1).trim();
374
- if (!property || !value)
375
- continue;
376
- if (!STYLE_KEYS.has(property)) {
377
- diagnostics.push({ kind: "unknown-style", tag, name: property });
378
- continue;
379
- }
380
- const translated = styleValue(value);
381
- if (typeof translated === "string" && !holdsString(property, translated)) {
382
- diagnostics.push({ kind: "non-numeric-style", tag, name: property });
383
- continue;
384
- }
385
- style[property] = translated;
386
- }
387
- return style;
161
+ function inlineStyle(tag, css, diagnostics, context) {
162
+ return parseNativeStyle(decodeEntities(css), (diagnostic) => diagnostics.push({ ...diagnostic, tag }), context);
388
163
  }
389
164
  function flattenText(node) {
390
165
  return node.children.map((child) => typeof child === "string" ? child : flattenText(child)).join("").replace(/\s+/g, " ").trim();
391
166
  }
392
167
  function settle(frame, diagnostics) {
393
168
  const node = frame.node, elements = node.children.filter((child) => typeof child !== "string"), text = node.children.filter((child) => typeof child === "string").join("").trim();
169
+ if (frame.tag === "button" && node.type === "Button" && !frame.declaredNative && elements.length > 0) {
170
+ node.type = "Pressable";
171
+ node.props.accessibilityRole ??= node.props.role ?? "button";
172
+ node.children = node.children.flatMap((child) => typeof child === "string" ? child.trim() ? [createNode("Text", {}, {}, {}, [child.trim()])] : [] : [child]);
173
+ return node;
174
+ }
394
175
  if (node.type === "Svg" || node.type === "G") {
395
176
  node.children = elements;
396
177
  return node;
@@ -426,7 +207,7 @@ function settle(frame, diagnostics) {
426
207
  return node;
427
208
  }
428
209
  export async function translateHtmlToIR(html, options = {}) {
429
- const diagnostics = [], roots = [], stack = [], seenUnmapped = new Set;
210
+ const diagnostics = [], stylesheetTheme = await extractStylesheetTheme(html, (name) => diagnostics.push({ kind: "unsupported-theme-rule", tag: "style", name })), stylesheetVariables = createStyleVariables(stylesheetTheme.light).computed(), roots = [], stack = [], seenUnmapped = new Set;
430
211
  function attach(node) {
431
212
  const parent = stack[stack.length - 1];
432
213
  if (!parent)
@@ -435,11 +216,16 @@ export async function translateHtmlToIR(html, options = {}) {
435
216
  parent.node.children.push(node);
436
217
  }
437
218
  function hoist(frame) {
219
+ const preserveVariables = (node) => {
220
+ if (frame.tag !== "html" && frame.node._styleSource)
221
+ node._styleAncestors = [frame.node._styleSource, ...node._styleAncestors ?? []];
222
+ };
438
223
  if (frame.node.bindings && Object.keys(frame.node.bindings).length > 0) {
439
224
  const children = frame.node.children, elements = children.filter((child) => typeof child !== "string"), target = elements.length === 1 && elements.length === children.length ? elements[0] : createNode("View", {}, {}, {}, children);
440
225
  target.bindings = { ...frame.node.bindings, ...target.bindings };
441
226
  if (target.bindingId === void 0 && frame.node.bindingId !== void 0)
442
227
  target.bindingId = frame.node.bindingId;
228
+ preserveVariables(target);
443
229
  attach(target);
444
230
  return;
445
231
  }
@@ -450,6 +236,7 @@ export async function translateHtmlToIR(html, options = {}) {
450
236
  parent.node.children.push(child);
451
237
  continue;
452
238
  }
239
+ preserveVariables(child);
453
240
  if (!parent)
454
241
  roots.push(child);
455
242
  else if (!parent.dropped)
@@ -460,7 +247,14 @@ export async function translateHtmlToIR(html, options = {}) {
460
247
  const parentFrame = stack[stack.length - 1];
461
248
  if (tag === "svg" || parentFrame?.svg)
462
249
  return openSvg(tag, attributes, parentFrame);
463
- const dropped = DROP_SUBTREE.has(tag) && !BOX_ONLY.has(tag), inheritedDrop = stack[stack.length - 1]?.dropped ?? !1, { props, style, events, bindings, classes, inline } = dropped || inheritedDrop ? { props: {}, style: {}, events: {}, bindings: {}, classes: "", inline: {} } : readAttributes(tag, attributes, diagnostics), declared = props["data-native"];
250
+ const dropped = DROP_SUBTREE.has(tag) && !BOX_ONLY.has(tag), inheritedDrop = stack[stack.length - 1]?.dropped ?? !1;
251
+ let variables = parentFrame?.variables ?? stylesheetVariables;
252
+ const { props, style, events, bindings, classes, inline } = dropped || inheritedDrop ? { props: {}, style: {}, events: {}, bindings: {}, classes: "", inline: {} } : readAttributes(tag, attributes, diagnostics, { inheritedVariables: variables, onVariables: (value) => {
253
+ variables = value;
254
+ } });
255
+ if (tag === "html")
256
+ variables = stylesheetVariables;
257
+ const declared = props["data-native"];
464
258
  let type;
465
259
  if (typeof declared === "string" && NATIVE_TYPES.has(declared)) {
466
260
  type = declared;
@@ -515,6 +309,7 @@ export async function translateHtmlToIR(html, options = {}) {
515
309
  }
516
310
  const node = createNode(type, props, style, events);
517
311
  node._inlineStyle = inline;
312
+ node._styleSource = decodeEntities(attributes.find(([name]) => name === "style")?.[1] ?? "");
518
313
  const bindingId = props["data-stx-b"];
519
314
  if (typeof bindingId === "number" && Number.isInteger(bindingId))
520
315
  node.bindingId = bindingId;
@@ -530,6 +325,8 @@ export async function translateHtmlToIR(html, options = {}) {
530
325
  return {
531
326
  tag,
532
327
  node,
328
+ variables,
329
+ declaredNative: typeof declared === "string" && NATIVE_TYPES.has(declared),
533
330
  dropped: dropped || inheritedDrop || BOX_ONLY.has(tag),
534
331
  discard: dropped || inheritedDrop,
535
332
  unwrap: UNWRAP.has(tag)
@@ -544,7 +341,10 @@ export async function translateHtmlToIR(html, options = {}) {
544
341
  }
545
342
  return { tag, node: createNode("G", {}, {}, {}), svg: !0, dropped: !0, discard: !0, unwrap: !1 };
546
343
  }
547
- const { props, style, events, bindings, classes, inline } = readAttributes(tag, attributes, diagnostics);
344
+ let variables = parent?.variables ?? stylesheetVariables;
345
+ const { props, style, events, bindings, classes, inline } = readAttributes(tag, attributes, diagnostics, { inheritedVariables: variables, onVariables: (value) => {
346
+ variables = value;
347
+ } });
548
348
  if (type === "Svg") {
549
349
  const viewBox = parseViewBox(props.viewBox);
550
350
  if (viewBox)
@@ -566,6 +366,7 @@ export async function translateHtmlToIR(html, options = {}) {
566
366
  props.geometry = geometry;
567
367
  const node = createNode(type, props, style, events);
568
368
  node._inlineStyle = inline;
369
+ node._styleSource = decodeEntities(attributes.find(([name]) => name === "style")?.[1] ?? "");
569
370
  const bindingId = props["data-stx-b"];
570
371
  if (typeof bindingId === "number" && Number.isInteger(bindingId))
571
372
  node.bindingId = bindingId;
@@ -578,7 +379,7 @@ export async function translateHtmlToIR(html, options = {}) {
578
379
  node.key = props.key;
579
380
  delete props.key;
580
381
  }
581
- return { tag, node, svg: !0, dropped: !1, discard: !1, unwrap: !1 };
382
+ return { tag, node, variables, svg: !0, dropped: !1, discard: !1, unwrap: !1 };
582
383
  }
583
384
  await new HTMLRewriter().on("*", {
584
385
  element(element) {
@@ -614,7 +415,10 @@ export async function translateHtmlToIR(html, options = {}) {
614
415
  }).transform(new Response(html)).text();
615
416
  if (roots.length === 0)
616
417
  throw Error(`No element to translate in the rendered output of ${options.source ?? "unknown"}`);
617
- return { root: roots.length === 1 ? roots[0] : createNode("View", {}, {}, {}, roots), diagnostics };
418
+ const root = roots.length === 1 ? roots[0] : createNode("View", {}, {}, {}, roots);
419
+ if (stylesheetTheme.light.length || stylesheetTheme.dark.length)
420
+ root._stylesheetTheme = stylesheetTheme;
421
+ return { root, diagnostics };
618
422
  }
619
423
  export async function translateHtmlToDocument(html, options = {}) {
620
424
  const { root, diagnostics } = await translateHtmlToIR(html, options), script = options.script ?? { exports: {}, functions: [], code: "" };
@@ -0,0 +1,13 @@
1
+ import { type NativeStyleVariables } from './style-variables';
2
+ import type { STXStyle } from './ir';
3
+ export declare function parseNativeStyle(input: unknown, report?: (diagnostic: NativeStyleDiagnostic) => void, context?: NativeStyleContext): STXStyle;
4
+ /** Resolve all same-element variable declarations before evaluating any style layer. */
5
+ export declare function parseNativeStyleLayers(inputs: unknown[], inheritedVariables: NativeStyleVariables | undefined, report: (diagnostic: NativeStyleDiagnostic) => void): { variables: NativeStyleVariables, styles: STXStyle[] };
6
+ export declare interface NativeStyleContext {
7
+ inheritedVariables?: NativeStyleVariables
8
+ onVariables?: (variables: NativeStyleVariables) => void
9
+ }
10
+ export declare interface NativeStyleDiagnostic {
11
+ kind: 'unknown-style' | 'non-numeric-style'
12
+ name: string
13
+ }