@stacksjs/stx 0.2.583 → 0.2.585
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.
- package/dist/{chunk-ck1yca7g.js → chunk-03qf2z4d.js} +1 -1
- package/dist/{chunk-6m3me7yj.js → chunk-03xsf9jm.js} +9 -9
- package/dist/{chunk-sv5nvfmb.js → chunk-048eyjyj.js} +2 -2
- package/dist/{chunk-je1as16r.js → chunk-076h7nb9.js} +5 -5
- package/dist/{chunk-hp9nxva6.js → chunk-07869zev.js} +4 -4
- package/dist/chunk-0hpw65yr.js +2 -0
- package/dist/chunk-11jmasqb.js +2 -0
- package/dist/chunk-2c7ysn9s.js +2 -0
- package/dist/chunk-2wb1w0p6.js +2 -0
- package/dist/chunk-2wx2aczp.js +2 -0
- package/dist/{chunk-pbwk8tzz.js → chunk-33q5zka4.js} +1 -1
- package/dist/chunk-3qmx12d3.js +2845 -0
- package/dist/{chunk-ktyctev3.js → chunk-3y5tzxm6.js} +2 -2
- package/dist/chunk-3ybbat49.js +2 -0
- package/dist/{chunk-2943qhdt.js → chunk-45x4myqe.js} +2 -2
- package/dist/chunk-4dpab4j6.js +2 -0
- package/dist/{chunk-5kh5ehfh.js → chunk-4h58as2c.js} +2 -2
- package/dist/chunk-4vnwge6p.js +2 -0
- package/dist/chunk-4w37cqg9.js +2 -0
- package/dist/chunk-51pz8cwa.js +2 -0
- package/dist/chunk-65agttgm.js +2 -0
- package/dist/{chunk-ye66wc53.js → chunk-67m2prah.js} +2 -2
- package/dist/{chunk-521pe0hb.js → chunk-6cg03r93.js} +4 -4
- package/dist/chunk-6djvj6hg.js +2 -0
- package/dist/{chunk-4pmgr32a.js → chunk-6hgngmn0.js} +3 -3
- package/dist/{chunk-09zwhsf9.js → chunk-751b5zv9.js} +3 -3
- package/dist/{chunk-mjj24qpb.js → chunk-794v5crp.js} +2 -2
- package/dist/chunk-7ae40484.js +2 -0
- package/dist/chunk-7dkwf9h5.js +2 -0
- package/dist/chunk-7dtyf7hq.js +2 -0
- package/dist/chunk-7ebt9n43.js +4 -0
- package/dist/{chunk-cnknvvwm.js → chunk-7fghm9zy.js} +1 -1
- package/dist/{chunk-117xss52.js → chunk-7xw1e8t6.js} +2 -2
- package/dist/{chunk-w6wtxj54.js → chunk-7ydavm3h.js} +2 -2
- package/dist/chunk-80g8kaes.js +2 -0
- package/dist/{chunk-qdyp2zqf.js → chunk-82bttwqm.js} +2 -2
- package/dist/chunk-8992smwz.js +2 -0
- package/dist/{chunk-qn8gdw21.js → chunk-8s7zbhdd.js} +4 -4
- package/dist/{chunk-02qaqamv.js → chunk-91pdg853.js} +7 -7
- package/dist/chunk-9j6hk72q.js +2 -0
- package/dist/{chunk-96mb3brj.js → chunk-9nt3q23a.js} +3 -3
- package/dist/chunk-9pk5jhqa.js +3 -0
- package/dist/{chunk-g9zeybqh.js → chunk-9qsnq026.js} +2 -2
- package/dist/{chunk-m417sp42.js → chunk-a30mtx17.js} +4 -4
- package/dist/chunk-a3k4nfq2.js +2 -0
- package/dist/{chunk-c0h2eqe0.js → chunk-a8n6mt7s.js} +2 -2
- package/dist/{chunk-xp7fxc6p.js → chunk-awgvt956.js} +5 -5
- package/dist/{chunk-mt9x626h.js → chunk-axz1x4r9.js} +5 -5
- package/dist/{chunk-8tq83fq7.js → chunk-b217d16p.js} +57 -57
- package/dist/{chunk-w3rmepwy.js → chunk-bfbmdjh4.js} +2 -2
- package/dist/chunk-bhg4pvtn.js +2 -0
- package/dist/{chunk-0k5faspy.js → chunk-bsy10tz6.js} +6 -6
- package/dist/{chunk-dvc15djp.js → chunk-c6egfhy6.js} +2 -2
- package/dist/chunk-c8fdccgp.js +2 -0
- package/dist/chunk-ce2d0hz9.js +2 -0
- package/dist/{chunk-4pkpr5cg.js → chunk-cqr5cv7h.js} +4 -4
- package/dist/chunk-cw76edds.js +2 -0
- package/dist/{chunk-ky1426s1.js → chunk-cy07dhqh.js} +10 -10
- package/dist/chunk-czrs87r9.js +2 -0
- package/dist/{chunk-ycj0342k.js → chunk-d0tmc6v5.js} +2 -2
- package/dist/chunk-d9vjsqs4.js +2 -0
- package/dist/chunk-ddgyj88h.js +2 -0
- package/dist/chunk-dj90w48e.js +2 -0
- package/dist/chunk-dngzks8e.js +2 -0
- package/dist/chunk-e01j75cr.js +122 -0
- package/dist/{chunk-kfwmqacd.js → chunk-e556dvy4.js} +3 -3
- package/dist/chunk-ede39b7h.js +3 -0
- package/dist/chunk-emxa2djv.js +2 -0
- package/dist/chunk-esj49jvz.js +2 -0
- package/dist/chunk-eztvhppz.js +2 -0
- package/dist/{chunk-4srg0qbv.js → chunk-f29fk7dw.js} +2 -2
- package/dist/{chunk-vke73gts.js → chunk-fkq55rh7.js} +1 -1
- package/dist/chunk-h2534p6q.js +2 -0
- package/dist/{chunk-2nehykbm.js → chunk-h7atbtds.js} +5 -5
- package/dist/chunk-h9gtc6bk.js +2 -0
- package/dist/{chunk-h0a2s340.js → chunk-haag5n42.js} +2 -2
- package/dist/{chunk-cby4mkjf.js → chunk-hj8tr9g0.js} +1 -1
- package/dist/{chunk-en7xxgtb.js → chunk-hsy9rhct.js} +2 -2
- package/dist/{chunk-qccgncp2.js → chunk-htcptqtn.js} +6 -6
- package/dist/chunk-hwnvfke9.js +2 -0
- package/dist/chunk-hygxh993.js +2 -0
- package/dist/{chunk-s12bnv32.js → chunk-hz11wmx9.js} +2 -2
- package/dist/{chunk-wyn5rfzk.js → chunk-j7kcjgxy.js} +115 -26
- package/dist/chunk-j8v5164e.js +2 -0
- package/dist/chunk-jqy5q8m0.js +2 -0
- package/dist/{chunk-0dfgefjv.js → chunk-jtx74677.js} +2 -2
- package/dist/chunk-jy7yzat1.js +2 -0
- package/dist/{chunk-vkc51n9m.js → chunk-k1szsenr.js} +2 -2
- package/dist/{chunk-sv08pd66.js → chunk-k71e38fk.js} +4 -4
- package/dist/{chunk-ac6v3s3k.js → chunk-kfhghjh6.js} +2 -2
- package/dist/{chunk-ym1sb5bg.js → chunk-m7ddgrsm.js} +5 -5
- package/dist/{chunk-vpdx7qr3.js → chunk-mmbspaqh.js} +2 -2
- package/dist/{chunk-6fc8vw2v.js → chunk-mnnxa3r7.js} +7 -7
- package/dist/chunk-n7yk4nc1.js +2 -0
- package/dist/chunk-ns1jqzqk.js +2 -0
- package/dist/chunk-p973efbe.js +2 -0
- package/dist/{chunk-m8tm44rq.js → chunk-pg164sdw.js} +2 -2
- package/dist/{chunk-x552npae.js → chunk-pxw4edw8.js} +4 -4
- package/dist/chunk-q03kn4d1.js +2 -0
- package/dist/{chunk-1r1maqep.js → chunk-q1cvef6b.js} +3 -3
- package/dist/{chunk-jpqkm8tm.js → chunk-qf3axv86.js} +3 -3
- package/dist/{chunk-dhq80e4r.js → chunk-qhr1tkhj.js} +7 -7
- package/dist/chunk-qq59xzwc.js +2 -0
- package/dist/{chunk-h3z9b6bw.js → chunk-qx0tcsdm.js} +11 -11
- package/dist/chunk-r0e743c3.js +2 -0
- package/dist/chunk-r90v2jz6.js +2 -0
- package/dist/chunk-rtgf9fgc.js +2 -0
- package/dist/chunk-s043hpvd.js +2 -0
- package/dist/{chunk-hzqyfdpy.js → chunk-s2h601k7.js} +7 -7
- package/dist/chunk-shzesarq.js +2 -0
- package/dist/chunk-sjkdpsca.js +3 -0
- package/dist/chunk-sqpme1hg.js +2 -0
- package/dist/{chunk-e809x7m0.js → chunk-t212h9zm.js} +1 -1
- package/dist/{chunk-r47cs92n.js → chunk-tc15vkfh.js} +2 -2
- package/dist/chunk-thydj877.js +2 -0
- package/dist/{chunk-6z3e1tyz.js → chunk-tnafnb23.js} +1 -1
- package/dist/{chunk-ah9xyss2.js → chunk-v8ze2q95.js} +2 -2
- package/dist/{chunk-xytkfa48.js → chunk-vf15db1j.js} +6 -6
- package/dist/chunk-vv1kr9dn.js +2 -0
- package/dist/{chunk-dm1qh2vq.js → chunk-w24qmxc3.js} +3 -3
- package/dist/{chunk-nhd9m8h5.js → chunk-wkrf41se.js} +6 -6
- package/dist/chunk-wm9nzg76.js +2 -0
- package/dist/chunk-wn2gzwmv.js +2 -0
- package/dist/{chunk-07anexcg.js → chunk-ww28zfwt.js} +2 -2
- package/dist/chunk-x5qymgxa.js +2 -0
- package/dist/chunk-xfe2nzxd.js +2 -0
- package/dist/chunk-xjwgzp6s.js +2 -0
- package/dist/chunk-xnbkyj4g.js +2 -0
- package/dist/chunk-xyepqdjy.js +2 -0
- package/dist/{chunk-wwj8zbzc.js → chunk-y09g63k0.js} +5 -5
- package/dist/{chunk-3e3dpp7w.js → chunk-y5x8xnnf.js} +3 -3
- package/dist/chunk-y93y2qat.js +2 -0
- package/dist/{chunk-nh3svtvj.js → chunk-yhhfxx17.js} +5 -5
- package/dist/{chunk-bj29pwm0.js → chunk-zrw1zf54.js} +3 -3
- package/dist/cli.js +20 -20
- package/dist/client/signals-host-runtime.js +52 -1
- package/dist/client/signals-manifest-hydration-runtime.js +13 -0
- package/dist/client/signals-overlay-runtime.js +29 -6
- package/dist/client/signals-public-api-runtime.js +2 -0
- package/dist/client/signals-style-runtime.js +1 -1
- package/dist/component-renderer.js +26 -6
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/accessibility.d.ts +18 -0
- package/dist/native/accessibility.js +89 -0
- package/dist/native/compiler/design-tokens.d.ts +4 -0
- package/dist/native/compiler/design-tokens.js +28 -0
- package/dist/native/compiler/headwind-to-style.d.ts +5 -4
- package/dist/native/compiler/headwind-to-style.js +105 -65
- package/dist/native/compiler/html-to-ir.d.ts +3 -1
- package/dist/native/compiler/html-to-ir.js +49 -243
- package/dist/native/compiler/inline-style.d.ts +13 -0
- package/dist/native/compiler/inline-style.js +285 -0
- package/dist/native/compiler/ir.d.ts +5 -1
- package/dist/native/compiler/render-screen.js +3 -1
- package/dist/native/compiler/style-variables.d.ts +8 -0
- package/dist/native/compiler/style-variables.js +142 -0
- package/dist/native/compiler/stylesheet-theme.d.ts +6 -0
- package/dist/native/compiler/stylesheet-theme.js +110 -0
- package/dist/native/runtime/craft-bridge.js +3 -1
- package/dist/native/runtime/native-host.d.ts +13 -2
- package/dist/native/runtime/native-host.js +242 -36
- package/dist/native/runtime/overlay-presenter.d.ts +29 -0
- package/dist/native/runtime/overlay-presenter.js +69 -0
- package/dist/native/runtime/shared-screen.js +12 -1
- package/dist/native/runtime/view-operations.d.ts +20 -0
- package/dist/native/runtime/view-operations.js +35 -0
- package/dist/native/testing-mutations.d.ts +4 -0
- package/dist/native/testing-mutations.js +64 -0
- package/dist/native/testing.d.ts +2 -0
- package/dist/native/testing.js +18 -1
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +9 -9
- package/dist/testing.js +2 -0
- package/dist/types/config-types.d.ts +2 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +25 -5
- package/package.json +5 -5
- package/dist/chunk-00p22wzr.js +0 -3
- package/dist/chunk-0fx3ppnt.js +0 -2
- package/dist/chunk-0sfexf9t.js +0 -2
- package/dist/chunk-2927nax9.js +0 -2
- package/dist/chunk-2rj0ttas.js +0 -2
- package/dist/chunk-2rx9d75e.js +0 -4
- package/dist/chunk-3ae39ttg.js +0 -2
- package/dist/chunk-3x6p9me0.js +0 -2
- package/dist/chunk-440yjsk5.js +0 -2
- package/dist/chunk-58z26y07.js +0 -2
- package/dist/chunk-5db5sxy3.js +0 -3
- package/dist/chunk-5r9k9s3m.js +0 -2
- package/dist/chunk-76vza4ve.js +0 -2
- package/dist/chunk-84f9dnq5.js +0 -2
- package/dist/chunk-8tq5x4z8.js +0 -2
- package/dist/chunk-8y8bbsh5.js +0 -2
- package/dist/chunk-9kzycb15.js +0 -2
- package/dist/chunk-agfhb2qd.js +0 -2
- package/dist/chunk-ay6dzpt4.js +0 -2
- package/dist/chunk-b9njk81d.js +0 -2
- package/dist/chunk-bfbcmfww.js +0 -2
- package/dist/chunk-br01jvra.js +0 -2
- package/dist/chunk-c12y2bet.js +0 -2
- package/dist/chunk-c2nwchk0.js +0 -2
- package/dist/chunk-cxqrwvc5.js +0 -2
- package/dist/chunk-czea8zr1.js +0 -2
- package/dist/chunk-d99kfx3k.js +0 -2
- package/dist/chunk-dpn1pmxj.js +0 -2
- package/dist/chunk-dskrwa8f.js +0 -2
- package/dist/chunk-e6ycqvdm.js +0 -2
- package/dist/chunk-efgk2xv1.js +0 -2
- package/dist/chunk-fj70wq7k.js +0 -2
- package/dist/chunk-fvx6pd66.js +0 -2
- package/dist/chunk-hrbjapvr.js +0 -2
- package/dist/chunk-jc4mxq56.js +0 -2
- package/dist/chunk-jdpyxt8j.js +0 -2
- package/dist/chunk-k0zev8wc.js +0 -2
- package/dist/chunk-mhjwtkx9.js +0 -2
- package/dist/chunk-n4e02qdz.js +0 -2838
- package/dist/chunk-nx8rf4qd.js +0 -2
- package/dist/chunk-pe5bk9ns.js +0 -2
- package/dist/chunk-qb2j34sp.js +0 -2
- package/dist/chunk-qknfceta.js +0 -2
- package/dist/chunk-s932zfjz.js +0 -2
- package/dist/chunk-sf98zgw2.js +0 -2
- package/dist/chunk-sgsp4dph.js +0 -2
- package/dist/chunk-t48ws5j0.js +0 -2
- package/dist/chunk-tfxmzat6.js +0 -122
- package/dist/chunk-thbc9gtj.js +0 -2
- package/dist/chunk-tms7amrb.js +0 -2
- package/dist/chunk-tn9v10q2.js +0 -2
- package/dist/chunk-v0zgarvv.js +0 -2
- package/dist/chunk-v9jd283e.js +0 -2
- package/dist/chunk-vczw73ga.js +0 -2
- package/dist/chunk-webrqm20.js +0 -2
- package/dist/chunk-wg2w7zmt.js +0 -3
- package/dist/chunk-wgkxgsqx.js +0 -2
- package/dist/chunk-wngqr949.js +0 -2
- package/dist/chunk-xyzy84x0.js +0 -2
- package/dist/chunk-y1jffvkj.js +0 -2
- package/dist/chunk-yas134jv.js +0 -2
- package/dist/chunk-yd55vynh.js +0 -2
- package/dist/chunk-yygze2s0.js +0 -2
- package/dist/chunk-z732tf98.js +0 -2
- package/dist/chunk-ze86h6vp.js +0 -2
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { createStyleVariables } from "./style-variables.js";
|
|
2
|
+
const STYLE_KEYS = new Set([
|
|
3
|
+
"display",
|
|
4
|
+
"gridColumns",
|
|
5
|
+
"gridTemplateColumns",
|
|
6
|
+
"gridTemplateRows",
|
|
7
|
+
"gridAutoRows",
|
|
8
|
+
"flex",
|
|
9
|
+
"flexGrow",
|
|
10
|
+
"flexShrink",
|
|
11
|
+
"flexBasis",
|
|
12
|
+
"flexDirection",
|
|
13
|
+
"flexWrap",
|
|
14
|
+
"justifyContent",
|
|
15
|
+
"alignItems",
|
|
16
|
+
"alignSelf",
|
|
17
|
+
"alignContent",
|
|
18
|
+
"position",
|
|
19
|
+
"top",
|
|
20
|
+
"right",
|
|
21
|
+
"bottom",
|
|
22
|
+
"left",
|
|
23
|
+
"zIndex",
|
|
24
|
+
"width",
|
|
25
|
+
"height",
|
|
26
|
+
"minWidth",
|
|
27
|
+
"maxWidth",
|
|
28
|
+
"minHeight",
|
|
29
|
+
"maxHeight",
|
|
30
|
+
"aspectRatio",
|
|
31
|
+
"margin",
|
|
32
|
+
"marginTop",
|
|
33
|
+
"marginRight",
|
|
34
|
+
"marginBottom",
|
|
35
|
+
"marginLeft",
|
|
36
|
+
"marginHorizontal",
|
|
37
|
+
"marginVertical",
|
|
38
|
+
"padding",
|
|
39
|
+
"paddingTop",
|
|
40
|
+
"paddingRight",
|
|
41
|
+
"paddingBottom",
|
|
42
|
+
"paddingLeft",
|
|
43
|
+
"paddingHorizontal",
|
|
44
|
+
"paddingVertical",
|
|
45
|
+
"gap",
|
|
46
|
+
"rowGap",
|
|
47
|
+
"columnGap",
|
|
48
|
+
"borderWidth",
|
|
49
|
+
"borderTopWidth",
|
|
50
|
+
"borderRightWidth",
|
|
51
|
+
"borderBottomWidth",
|
|
52
|
+
"borderLeftWidth",
|
|
53
|
+
"borderColor",
|
|
54
|
+
"borderTopColor",
|
|
55
|
+
"borderRightColor",
|
|
56
|
+
"borderBottomColor",
|
|
57
|
+
"borderLeftColor",
|
|
58
|
+
"borderRadius",
|
|
59
|
+
"borderTopLeftRadius",
|
|
60
|
+
"borderTopRightRadius",
|
|
61
|
+
"borderBottomLeftRadius",
|
|
62
|
+
"borderBottomRightRadius",
|
|
63
|
+
"borderStyle",
|
|
64
|
+
"backgroundColor",
|
|
65
|
+
"backgroundImage",
|
|
66
|
+
"opacity",
|
|
67
|
+
"shadowColor",
|
|
68
|
+
"shadowOffset",
|
|
69
|
+
"shadowOpacity",
|
|
70
|
+
"shadowRadius",
|
|
71
|
+
"elevation",
|
|
72
|
+
"color",
|
|
73
|
+
"fontSize",
|
|
74
|
+
"fontWeight",
|
|
75
|
+
"fontStyle",
|
|
76
|
+
"fontFamily",
|
|
77
|
+
"lineHeight",
|
|
78
|
+
"letterSpacing",
|
|
79
|
+
"textAlign",
|
|
80
|
+
"textDecorationLine",
|
|
81
|
+
"textDecorationColor",
|
|
82
|
+
"textTransform",
|
|
83
|
+
"resizeMode",
|
|
84
|
+
"tintColor",
|
|
85
|
+
"transform",
|
|
86
|
+
"overflow",
|
|
87
|
+
"fill",
|
|
88
|
+
"stroke",
|
|
89
|
+
"strokeWidth",
|
|
90
|
+
"gradientDirection",
|
|
91
|
+
"gradientFrom",
|
|
92
|
+
"gradientVia",
|
|
93
|
+
"gradientTo"
|
|
94
|
+
]), NUMERIC_STYLE_KEYS = new Set([
|
|
95
|
+
"gridColumns",
|
|
96
|
+
"gridAutoRows",
|
|
97
|
+
"flex",
|
|
98
|
+
"flexGrow",
|
|
99
|
+
"flexShrink",
|
|
100
|
+
"zIndex",
|
|
101
|
+
"aspectRatio",
|
|
102
|
+
"gap",
|
|
103
|
+
"rowGap",
|
|
104
|
+
"columnGap",
|
|
105
|
+
"borderWidth",
|
|
106
|
+
"borderTopWidth",
|
|
107
|
+
"borderRightWidth",
|
|
108
|
+
"borderBottomWidth",
|
|
109
|
+
"borderLeftWidth",
|
|
110
|
+
"borderRadius",
|
|
111
|
+
"borderTopLeftRadius",
|
|
112
|
+
"borderTopRightRadius",
|
|
113
|
+
"borderBottomLeftRadius",
|
|
114
|
+
"borderBottomRightRadius",
|
|
115
|
+
"opacity",
|
|
116
|
+
"shadowOpacity",
|
|
117
|
+
"shadowRadius",
|
|
118
|
+
"elevation",
|
|
119
|
+
"fontSize",
|
|
120
|
+
"lineHeight",
|
|
121
|
+
"letterSpacing",
|
|
122
|
+
"strokeWidth"
|
|
123
|
+
]), DIMENSION_STYLE_KEYS = new Set([
|
|
124
|
+
"top",
|
|
125
|
+
"right",
|
|
126
|
+
"bottom",
|
|
127
|
+
"left",
|
|
128
|
+
"width",
|
|
129
|
+
"height",
|
|
130
|
+
"minWidth",
|
|
131
|
+
"maxWidth",
|
|
132
|
+
"minHeight",
|
|
133
|
+
"maxHeight",
|
|
134
|
+
"flexBasis",
|
|
135
|
+
"margin",
|
|
136
|
+
"marginTop",
|
|
137
|
+
"marginRight",
|
|
138
|
+
"marginBottom",
|
|
139
|
+
"marginLeft",
|
|
140
|
+
"marginHorizontal",
|
|
141
|
+
"marginVertical",
|
|
142
|
+
"padding",
|
|
143
|
+
"paddingTop",
|
|
144
|
+
"paddingRight",
|
|
145
|
+
"paddingBottom",
|
|
146
|
+
"paddingLeft",
|
|
147
|
+
"paddingHorizontal",
|
|
148
|
+
"paddingVertical"
|
|
149
|
+
]), NUMBER = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i, LENGTH = /^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(px|rem|em)?$/i, ANGLE_TRANSFORMS = new Set(["rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY"]), NUMBER_TRANSFORMS = new Set(["perspective", "scale", "scaleX", "scaleY", "translateX", "translateY"]);
|
|
150
|
+
function numericValue(value) {
|
|
151
|
+
if (typeof value !== "string")
|
|
152
|
+
return value;
|
|
153
|
+
const match = LENGTH.exec(value);
|
|
154
|
+
return match ? Number(match[1]) * (/^r?em$/i.test(match[2] || "") ? 16 : 1) : value;
|
|
155
|
+
}
|
|
156
|
+
function finite(value) {
|
|
157
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
158
|
+
}
|
|
159
|
+
function structuredStyle(property, value) {
|
|
160
|
+
if (property === "shadowOffset" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
161
|
+
const { width, height } = value;
|
|
162
|
+
return finite(width) && finite(height) ? { width, height } : void 0;
|
|
163
|
+
}
|
|
164
|
+
if (property === "transform" && Array.isArray(value)) {
|
|
165
|
+
const steps = [];
|
|
166
|
+
for (const step of value) {
|
|
167
|
+
if (!step || typeof step !== "object" || Array.isArray(step) || Object.keys(step).length !== 1)
|
|
168
|
+
return;
|
|
169
|
+
const [key, raw] = Object.entries(step)[0];
|
|
170
|
+
if (NUMBER_TRANSFORMS.has(key) && finite(raw))
|
|
171
|
+
steps.push({ [key]: raw });
|
|
172
|
+
else if (ANGLE_TRANSFORMS.has(key) && typeof raw === "string" && /^[+-]?(?:\d+\.?\d*|\.\d+)(?:deg|rad)$/.test(raw))
|
|
173
|
+
steps.push({ [key]: raw });
|
|
174
|
+
else
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
return steps;
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
function declarations(css) {
|
|
182
|
+
const result = [];
|
|
183
|
+
let start = 0, depth = 0, quote = "";
|
|
184
|
+
for (let i = 0;i <= css.length; i++) {
|
|
185
|
+
const char = css[i];
|
|
186
|
+
if (char === "\\") {
|
|
187
|
+
i++;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (quote) {
|
|
191
|
+
if (char === quote)
|
|
192
|
+
quote = "";
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (char === '"' || char === "'") {
|
|
196
|
+
quote = char;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (char === "(")
|
|
200
|
+
depth++;
|
|
201
|
+
if (char === ")")
|
|
202
|
+
depth = Math.max(0, depth - 1);
|
|
203
|
+
if (i !== css.length && (char !== ";" || depth))
|
|
204
|
+
continue;
|
|
205
|
+
const declaration = css.slice(start, i), colon = declaration.indexOf(":");
|
|
206
|
+
if (colon !== -1)
|
|
207
|
+
result.push([declaration.slice(0, colon).trim(), declaration.slice(colon + 1).trim()]);
|
|
208
|
+
start = i + 1;
|
|
209
|
+
}
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
function styleEntries(input, report) {
|
|
213
|
+
let entries;
|
|
214
|
+
if (typeof input === "string") {
|
|
215
|
+
input = input.trim();
|
|
216
|
+
if (!input)
|
|
217
|
+
return [];
|
|
218
|
+
try {
|
|
219
|
+
input = JSON.parse(input);
|
|
220
|
+
} catch {}
|
|
221
|
+
}
|
|
222
|
+
if (typeof input === "string")
|
|
223
|
+
entries = declarations(input);
|
|
224
|
+
else if (input && typeof input === "object" && !Array.isArray(input))
|
|
225
|
+
entries = Object.entries(input);
|
|
226
|
+
else {
|
|
227
|
+
if (input != null && input !== !1)
|
|
228
|
+
report({ kind: "non-numeric-style", name: "style" });
|
|
229
|
+
return [];
|
|
230
|
+
}
|
|
231
|
+
return entries;
|
|
232
|
+
}
|
|
233
|
+
export function parseNativeStyle(input, report = () => {}, context = {}) {
|
|
234
|
+
const entries = styleEntries(input, report), variables = createStyleVariables(entries, context.inheritedVariables);
|
|
235
|
+
context.onVariables?.(variables.computed());
|
|
236
|
+
return parseEntries(entries, variables, report);
|
|
237
|
+
}
|
|
238
|
+
export function parseNativeStyleLayers(inputs, inheritedVariables, report) {
|
|
239
|
+
const layers = inputs.map((input) => styleEntries(input, report)), variables = createStyleVariables(layers.flat(), inheritedVariables);
|
|
240
|
+
return { variables: variables.computed(), styles: layers.map((entries) => parseEntries(entries, variables, report)) };
|
|
241
|
+
}
|
|
242
|
+
function parseEntries(entries, variables, report) {
|
|
243
|
+
const style = {}, declarationNames = [];
|
|
244
|
+
for (const [rawProperty, raw] of entries) {
|
|
245
|
+
if (rawProperty.trim().startsWith("--")) {
|
|
246
|
+
declarationNames.push(rawProperty.trim());
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const property = STYLE_KEYS.has(rawProperty) || rawProperty.trim().startsWith("--") ? rawProperty : rawProperty.trim().toLowerCase().replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
250
|
+
if (!STYLE_KEYS.has(property)) {
|
|
251
|
+
report({ kind: "unknown-style", name: property });
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (raw == null || raw === "")
|
|
255
|
+
continue;
|
|
256
|
+
const value = typeof raw === "string" ? variables.resolve(raw.trim()) : raw;
|
|
257
|
+
if (value === void 0) {
|
|
258
|
+
report({ kind: "non-numeric-style", name: property });
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (value === "")
|
|
262
|
+
continue;
|
|
263
|
+
let translated;
|
|
264
|
+
if (NUMERIC_STYLE_KEYS.has(property) || DIMENSION_STYLE_KEYS.has(property)) {
|
|
265
|
+
translated = numericValue(value);
|
|
266
|
+
if (!finite(translated) && !(DIMENSION_STYLE_KEYS.has(property) && typeof translated === "string" && translated.endsWith("%") && NUMBER.test(translated.slice(0, -1)) && Number.isFinite(Number(translated.slice(0, -1)))))
|
|
267
|
+
translated = void 0;
|
|
268
|
+
} else if (property === "shadowOffset" || property === "transform")
|
|
269
|
+
translated = structuredStyle(property, value);
|
|
270
|
+
else if (property === "gridTemplateColumns" || property === "gridTemplateRows")
|
|
271
|
+
translated = finite(value) || typeof value === "string" ? value : void 0;
|
|
272
|
+
else if (property === "fontWeight" && finite(value))
|
|
273
|
+
translated = String(value);
|
|
274
|
+
else if (typeof value === "string")
|
|
275
|
+
translated = value;
|
|
276
|
+
if (translated === void 0)
|
|
277
|
+
report({ kind: "non-numeric-style", name: property });
|
|
278
|
+
else
|
|
279
|
+
style[property] = translated;
|
|
280
|
+
}
|
|
281
|
+
for (const name of declarationNames)
|
|
282
|
+
if (!variables.used.has(name))
|
|
283
|
+
report({ kind: "unknown-style", name });
|
|
284
|
+
return style;
|
|
285
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NativeStylesheetTheme } from './stylesheet-theme';
|
|
1
2
|
// ============================================================================
|
|
2
3
|
// Factory Functions
|
|
3
4
|
// ============================================================================
|
|
@@ -16,6 +17,9 @@ export declare interface STXNode {
|
|
|
16
17
|
darkStyle?: STXStyle
|
|
17
18
|
children: (STXNode | string)[]
|
|
18
19
|
_inlineStyle?: STXStyle
|
|
20
|
+
_styleSource?: string
|
|
21
|
+
_styleAncestors?: string[]
|
|
22
|
+
_stylesheetTheme?: NativeStylesheetTheme
|
|
19
23
|
_classes?: string
|
|
20
24
|
_source?: {
|
|
21
25
|
file: string
|
|
@@ -41,6 +45,7 @@ export declare interface STXStyle {
|
|
|
41
45
|
display?: 'flex' | 'none' | 'grid'
|
|
42
46
|
gridColumns?: number
|
|
43
47
|
gridTemplateColumns?: string | number
|
|
48
|
+
gridTemplateRows?: string | number
|
|
44
49
|
gridAutoRows?: number
|
|
45
50
|
flex?: number
|
|
46
51
|
flexGrow?: number
|
|
@@ -176,7 +181,6 @@ export declare interface ConditionalStyle {
|
|
|
176
181
|
condition: string
|
|
177
182
|
style: STXStyle
|
|
178
183
|
}
|
|
179
|
-
/* eslint-disable style/max-statements-per-line */
|
|
180
184
|
/**
|
|
181
185
|
* STX Native Intermediate Representation (IR)
|
|
182
186
|
*
|
|
@@ -20,10 +20,12 @@ export function nativePrimitivesDir() {
|
|
|
20
20
|
export async function compileScreenSource(source, filePath, options = {}) {
|
|
21
21
|
const root = options.root ?? path.dirname(filePath), loaded = await loadStxConfig(root), config = {
|
|
22
22
|
root,
|
|
23
|
-
componentsDir: options.componentsDir ?? path.join(root, "components"),
|
|
23
|
+
componentsDir: options.componentsDir ?? loaded.componentsDir ?? path.join(root, "components"),
|
|
24
24
|
buildMode: "serve",
|
|
25
25
|
cache: !1,
|
|
26
26
|
_targetComponentDirs: [nativePrimitivesDir()],
|
|
27
|
+
_targetComponentFallbackNames: ["Button"],
|
|
28
|
+
_nativeHostAttrs: !0,
|
|
27
29
|
_pluginComponentDirs: loaded._pluginComponentDirs ?? []
|
|
28
30
|
}, context = { ...options.context ?? {}, __stx_inject_css: !1 }, dependencies = new Set([filePath]), renderedHtml = await processDirectives(source, context, filePath, config, dependencies), { html, manifest } = extractBindingManifest(renderedHtml), { document, diagnostics } = await translateHtmlToDocument(html, {
|
|
29
31
|
source: filePath,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Inherited values are already computed at their declaring element. */
|
|
2
|
+
export declare function createStyleVariables(entries: Array<[string, unknown]>, inherited?: NativeStyleVariables): NativeStyleVariableResolver;
|
|
3
|
+
export declare interface NativeStyleVariableResolver {
|
|
4
|
+
resolve: (text: string) => string | undefined
|
|
5
|
+
used: Set<string>
|
|
6
|
+
computed: () => NativeStyleVariables
|
|
7
|
+
}
|
|
8
|
+
export type NativeStyleVariables = ReadonlyMap<string, string | undefined>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
const NAME = /^--[\w\u0080-\uFFFF-]+$/u, LIMIT = 65536;
|
|
2
|
+
function substitute(input, lookup) {
|
|
3
|
+
if (!/var\(/i.test(input))
|
|
4
|
+
return input;
|
|
5
|
+
let output = "", quote = "", replaced = !1;
|
|
6
|
+
for (let i = 0;i < input.length; i++) {
|
|
7
|
+
const char = input[i];
|
|
8
|
+
if (char === "\\") {
|
|
9
|
+
output += input.slice(i, i + 2);
|
|
10
|
+
i++;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (quote) {
|
|
14
|
+
output += char;
|
|
15
|
+
if (char === quote)
|
|
16
|
+
quote = "";
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (char === '"' || char === "'") {
|
|
20
|
+
quote = char;
|
|
21
|
+
output += char;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (input.slice(i, i + 4).toLowerCase() !== "var(" || i > 0 && /[\w-]/.test(input[i - 1])) {
|
|
25
|
+
output += char;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
let depth = 1, comma = -1, innerQuote = "", end = i + 4;
|
|
29
|
+
for (;end < input.length; end++) {
|
|
30
|
+
const next = input[end];
|
|
31
|
+
if (next === "\\") {
|
|
32
|
+
end++;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (innerQuote) {
|
|
36
|
+
if (next === innerQuote)
|
|
37
|
+
innerQuote = "";
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (next === '"' || next === "'") {
|
|
41
|
+
innerQuote = next;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (next === "(")
|
|
45
|
+
depth++;
|
|
46
|
+
if (next === ")" && --depth === 0)
|
|
47
|
+
break;
|
|
48
|
+
if (next === "," && depth === 1 && comma === -1)
|
|
49
|
+
comma = end;
|
|
50
|
+
}
|
|
51
|
+
if (depth !== 0)
|
|
52
|
+
return;
|
|
53
|
+
const name = input.slice(i + 4, comma === -1 ? end : comma).trim();
|
|
54
|
+
if (!NAME.test(name))
|
|
55
|
+
return;
|
|
56
|
+
const replacement = lookup(name, comma === -1 ? void 0 : input.slice(comma + 1, end).trim());
|
|
57
|
+
if (replacement === void 0 || output.length + replacement.length > LIMIT)
|
|
58
|
+
return;
|
|
59
|
+
output += replacement;
|
|
60
|
+
replaced = !0;
|
|
61
|
+
i = end;
|
|
62
|
+
}
|
|
63
|
+
return replaced && output.length > LIMIT ? void 0 : output;
|
|
64
|
+
}
|
|
65
|
+
export function createStyleVariables(entries, inherited) {
|
|
66
|
+
const values = new Map, used = new Set;
|
|
67
|
+
for (const [rawName, value] of entries) {
|
|
68
|
+
const name = rawName.trim();
|
|
69
|
+
if (!NAME.test(name))
|
|
70
|
+
continue;
|
|
71
|
+
if (typeof value === "string" || typeof value === "number" && Number.isFinite(value))
|
|
72
|
+
values.set(name, String(value).trim());
|
|
73
|
+
}
|
|
74
|
+
const dependencies = new Map, invalid = new Set;
|
|
75
|
+
for (const [name, value] of values) {
|
|
76
|
+
const refs = new Set, inspect = (text, depth = 0) => depth > 64 ? void 0 : substitute(text, (ref, fallback) => {
|
|
77
|
+
refs.add(ref);
|
|
78
|
+
return fallback === void 0 ? "" : inspect(fallback, depth + 1);
|
|
79
|
+
});
|
|
80
|
+
if (inspect(value) === void 0)
|
|
81
|
+
invalid.add(name);
|
|
82
|
+
dependencies.set(name, refs);
|
|
83
|
+
}
|
|
84
|
+
const indices = new Map, lows = new Map, stack = [], active = new Set;
|
|
85
|
+
let index = 0;
|
|
86
|
+
function visit(name, depth = 0) {
|
|
87
|
+
if (depth > 64) {
|
|
88
|
+
invalid.add(name);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
indices.set(name, index);
|
|
92
|
+
lows.set(name, index++);
|
|
93
|
+
stack.push(name);
|
|
94
|
+
active.add(name);
|
|
95
|
+
for (const ref of dependencies.get(name) ?? []) {
|
|
96
|
+
if (!values.has(ref))
|
|
97
|
+
continue;
|
|
98
|
+
if (!indices.has(ref)) {
|
|
99
|
+
visit(ref, depth + 1);
|
|
100
|
+
if (lows.has(ref))
|
|
101
|
+
lows.set(name, Math.min(lows.get(name), lows.get(ref)));
|
|
102
|
+
} else if (active.has(ref))
|
|
103
|
+
lows.set(name, Math.min(lows.get(name), indices.get(ref)));
|
|
104
|
+
}
|
|
105
|
+
if (lows.get(name) !== indices.get(name))
|
|
106
|
+
return;
|
|
107
|
+
const group = [];
|
|
108
|
+
let member;
|
|
109
|
+
do {
|
|
110
|
+
member = stack.pop();
|
|
111
|
+
active.delete(member);
|
|
112
|
+
group.push(member);
|
|
113
|
+
} while (member !== name);
|
|
114
|
+
if (group.length > 1 || dependencies.get(name)?.has(name))
|
|
115
|
+
group.forEach((ref) => invalid.add(ref));
|
|
116
|
+
}
|
|
117
|
+
for (const name of values.keys())
|
|
118
|
+
if (!indices.has(name))
|
|
119
|
+
visit(name);
|
|
120
|
+
const cache = new Map;
|
|
121
|
+
function lookup(name, depth) {
|
|
122
|
+
used.add(name);
|
|
123
|
+
if (cache.has(name))
|
|
124
|
+
return cache.get(name);
|
|
125
|
+
const value = values.get(name), result = value === void 0 || /^(?:inherit|unset)$/i.test(value) ? inherited?.get(name) : invalid.has(name) || /^(?:initial|revert|revert-layer)$/i.test(value) ? void 0 : resolve(value, depth + 1);
|
|
126
|
+
cache.set(name, result);
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
function resolve(text, depth = 0) {
|
|
130
|
+
if (depth > 64)
|
|
131
|
+
return;
|
|
132
|
+
return substitute(text, (name, fallback) => {
|
|
133
|
+
return lookup(name, depth) ?? (fallback === void 0 ? void 0 : resolve(fallback, depth + 1));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return { resolve, used, computed() {
|
|
137
|
+
const result = new Map(inherited);
|
|
138
|
+
for (const name of values.keys())
|
|
139
|
+
result.set(name, lookup(name, 0));
|
|
140
|
+
return result;
|
|
141
|
+
} };
|
|
142
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Document-level variables only. Never promote a component selector to global scope. */
|
|
2
|
+
export declare function extractStylesheetTheme(html: string, report: (name: string) => void): Promise<NativeStylesheetTheme>;
|
|
3
|
+
export declare interface NativeStylesheetTheme {
|
|
4
|
+
light: Array<[string, string]>
|
|
5
|
+
dark: Array<[string, string]>
|
|
6
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { generate, parse } from "@stacksjs/ts-css/parse";
|
|
2
|
+
export async function extractStylesheetTheme(html, report) {
|
|
3
|
+
const schemes = { light: new Map, dark: new Map }, reported = new Set, warn = (name) => {
|
|
4
|
+
if (!reported.has(name)) {
|
|
5
|
+
reported.add(name);
|
|
6
|
+
report(name);
|
|
7
|
+
}
|
|
8
|
+
}, add = (name, candidate, active) => {
|
|
9
|
+
for (const scheme of active) {
|
|
10
|
+
const previous = schemes[scheme].get(name);
|
|
11
|
+
if (!previous || Number(candidate.important) > Number(previous.important) || candidate.important === previous.important && candidate.specificity >= previous.specificity)
|
|
12
|
+
schemes[scheme].set(name, candidate);
|
|
13
|
+
}
|
|
14
|
+
}, hasVariables = (node) => {
|
|
15
|
+
if (node.type === "Declaration")
|
|
16
|
+
return node.property.startsWith("--");
|
|
17
|
+
if (node.type === "Rule" || node.type === "Atrule")
|
|
18
|
+
return !!node.block && [...node.block.children].some(hasVariables);
|
|
19
|
+
return !1;
|
|
20
|
+
}, mediaSchemes = (query) => {
|
|
21
|
+
const normalized = query.replace(/\s+/g, "").toLowerCase();
|
|
22
|
+
if (!normalized || normalized === "all" || normalized === "screen")
|
|
23
|
+
return ["light", "dark"];
|
|
24
|
+
const match = /^(?:screenand)?\(prefers-color-scheme:(light|dark)\)$/.exec(normalized);
|
|
25
|
+
return match ? [match[1]] : void 0;
|
|
26
|
+
};
|
|
27
|
+
function visit(nodes, active) {
|
|
28
|
+
for (const node of nodes) {
|
|
29
|
+
if (!hasVariables(node))
|
|
30
|
+
continue;
|
|
31
|
+
if (node.type === "Atrule") {
|
|
32
|
+
const query = node.prelude ? generate(node.prelude) : "", enabled = node.name.toLowerCase() === "media" ? mediaSchemes(query) : void 0;
|
|
33
|
+
if (!enabled) {
|
|
34
|
+
warn(`@${node.name} ${query}`.trim());
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
visit(node.block.children, active.filter((scheme) => enabled.includes(scheme)));
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (node.type !== "Rule")
|
|
41
|
+
continue;
|
|
42
|
+
const selectors = node.prelude.type === "SelectorList" ? [...node.prelude.children].map(generate) : [generate(node.prelude)];
|
|
43
|
+
for (const selector of selectors) {
|
|
44
|
+
const match = /^(html|:root)?(?:\.(dark|light))?$/.exec(selector.trim());
|
|
45
|
+
if (!match || !match[1] && !match[2]) {
|
|
46
|
+
warn(selector);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const specificity = (match[1] === ":root" ? 10 : match[1] ? 1 : 0) + (match[2] ? 10 : 0);
|
|
50
|
+
for (const declaration of node.block.children) {
|
|
51
|
+
if (declaration.type !== "Declaration") {
|
|
52
|
+
if (hasVariables(declaration))
|
|
53
|
+
warn(`nested rule in ${selector}`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!declaration.property.startsWith("--"))
|
|
57
|
+
continue;
|
|
58
|
+
const candidate = { value: generate(declaration.value), important: !!declaration.important, specificity };
|
|
59
|
+
add(declaration.property, candidate, active.filter((scheme) => !match[2] || match[2] === scheme));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let css = "", active;
|
|
65
|
+
await new HTMLRewriter().on("html", {
|
|
66
|
+
element(element) {
|
|
67
|
+
const inline = element.getAttribute("style");
|
|
68
|
+
if (!inline)
|
|
69
|
+
return;
|
|
70
|
+
try {
|
|
71
|
+
const declarations = parse(inline, { context: "declarationList" });
|
|
72
|
+
if (declarations.type !== "DeclarationList")
|
|
73
|
+
return;
|
|
74
|
+
for (const declaration of declarations.children)
|
|
75
|
+
if (declaration.type === "Declaration" && declaration.property.startsWith("--"))
|
|
76
|
+
add(declaration.property, { value: generate(declaration.value), important: !!declaration.important, specificity: 1000 }, ["light", "dark"]);
|
|
77
|
+
} catch {
|
|
78
|
+
warn("invalid document inline theme");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}).on("style", {
|
|
82
|
+
element(element) {
|
|
83
|
+
css = "";
|
|
84
|
+
const type = element.getAttribute("type");
|
|
85
|
+
active = !type || type.toLowerCase() === "text/css" ? mediaSchemes(element.getAttribute("media") ?? "") : void 0;
|
|
86
|
+
element.onEndTag(() => {
|
|
87
|
+
try {
|
|
88
|
+
const ast = parse(css);
|
|
89
|
+
if (ast.type !== "StyleSheet")
|
|
90
|
+
return;
|
|
91
|
+
if (!active) {
|
|
92
|
+
if ([...ast.children].some(hasVariables))
|
|
93
|
+
warn("style type/media");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
visit(ast.children, active);
|
|
97
|
+
} catch {
|
|
98
|
+
warn("invalid stylesheet");
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
text(chunk) {
|
|
103
|
+
css += chunk.text;
|
|
104
|
+
}
|
|
105
|
+
}).transform(new Response(html)).text();
|
|
106
|
+
return {
|
|
107
|
+
light: [...schemes.light].map(([name, entry]) => [name, entry.value]),
|
|
108
|
+
dark: [...schemes.dark].map(([name, entry]) => [name, entry.value])
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -55,7 +55,9 @@ function capabilityFlags(capabilities) {
|
|
|
55
55
|
appleSignIn: capabilities.has("appleSignIn"),
|
|
56
56
|
background: capabilities.has("background"),
|
|
57
57
|
crashReporter: capabilities.has("crashReporter"),
|
|
58
|
-
animation: capabilities.has("animation")
|
|
58
|
+
animation: capabilities.has("animation"),
|
|
59
|
+
viewFocus: capabilities.has("viewFocus"),
|
|
60
|
+
viewMeasure: capabilities.has("viewMeasure")
|
|
59
61
|
};
|
|
60
62
|
}
|
|
61
63
|
function platformUserAgent(platform) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { type NativeFocusOptions, type NativeViewBounds, type NativeViewOperations } from './view-operations';
|
|
2
|
+
import { type NativeOverlayEntry } from './overlay-presenter';
|
|
1
3
|
import type { NativeMutationOperation } from '../bridge/protocol';
|
|
4
|
+
import type { NativeStylesheetTheme } from '../compiler/stylesheet-theme';
|
|
2
5
|
import type { STXNode } from '../compiler/ir';
|
|
3
6
|
export declare function createNativeHost(options: NativeHostOptions): NativeHost;
|
|
4
7
|
/** Every method the DOM host in `signals.ts` defines. The contract, in one place. */
|
|
@@ -11,19 +14,27 @@ export declare interface NativeNode {
|
|
|
11
14
|
__stxAnchor?: string
|
|
12
15
|
}
|
|
13
16
|
export declare interface NativeHostOptions {
|
|
17
|
+
views?: NativeViewOperations
|
|
14
18
|
colorScheme?: 'light' | 'dark'
|
|
19
|
+
stylesheetTheme?: NativeStylesheetTheme
|
|
15
20
|
send: (operations: NativeMutationOperation[]) => void
|
|
16
21
|
schedule?: (flush: () => void) => void
|
|
17
22
|
}
|
|
18
23
|
export declare interface NativeHost {
|
|
19
24
|
readonly isNative: true
|
|
25
|
+
focus: (node: NativeNode, options?: NativeFocusOptions) => Promise<true>
|
|
26
|
+
measure: (node: NativeNode) => Promise<NativeViewBounds>
|
|
27
|
+
syncOverlays: (entries: NativeOverlayEntry[]) => void
|
|
28
|
+
parent: (node: NativeNode) => NativeNode | null
|
|
29
|
+
getAttribute: (node: NativeNode, name: string) => string | null
|
|
30
|
+
observeChildren: (node: NativeNode, callback: () => void) => (() => void)
|
|
20
31
|
setColorScheme: (scheme: 'light' | 'dark') => void
|
|
21
32
|
setText: (node: NativeNode, value: unknown) => void
|
|
22
33
|
setMarkup: (node: NativeNode, value: unknown) => void
|
|
23
34
|
setAttribute: (node: NativeNode, name: string, value: unknown) => void
|
|
24
35
|
removeAttribute: (node: NativeNode, name: string) => void
|
|
25
36
|
observeAttributes: (node: NativeNode, names: string[], callback: () => void) => (() => void)
|
|
26
|
-
setStyle: (node: NativeNode, value: unknown) => void
|
|
37
|
+
setStyle: (node: NativeNode, value: unknown, replaceBinding?: boolean) => void
|
|
27
38
|
listen: (node: NativeNode, event: string, handler: (payload?: unknown) => void, options?: unknown) => void
|
|
28
39
|
emitComponentEvent: (node: NativeNode, event: Event) => boolean
|
|
29
40
|
onFormReset: (node: NativeNode, callback: () => void) => (() => void)
|
|
@@ -35,7 +46,7 @@ export declare interface NativeHost {
|
|
|
35
46
|
remove: (node: NativeNode) => void
|
|
36
47
|
descendants: (node: NativeNode) => NativeNode[]
|
|
37
48
|
scopesIn: (node: NativeNode) => string[]
|
|
38
|
-
adopt: (node: NativeNode, type: string, owner?: NativeNode | null, descriptor?: Pick<STXNode, 'key' | 'props' | 'style' | 'events' | 'children' | '_classes' | '_inlineStyle'>) => NativeNode
|
|
49
|
+
adopt: (node: NativeNode, type: string, owner?: NativeNode | null, descriptor?: Pick<STXNode, 'key' | 'props' | 'style' | 'events' | 'children' | '_classes' | '_inlineStyle' | '_styleSource' | '_styleAncestors'>) => NativeNode
|
|
39
50
|
flush: () => void
|
|
40
51
|
dispatch: (handlerId: string, payload?: unknown) => void
|
|
41
52
|
pending: () => number
|