@homebound/truss 2.1.0-next.8 → 2.1.0
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/build/plugin/index.js +749 -580
- package/build/plugin/index.js.map +1 -1
- package/package.json +1 -1
package/build/plugin/index.js
CHANGED
|
@@ -4,6 +4,579 @@ import { resolve, dirname, isAbsolute, join } from "path";
|
|
|
4
4
|
|
|
5
5
|
// src/plugin/emit-truss.ts
|
|
6
6
|
import * as t from "@babel/types";
|
|
7
|
+
|
|
8
|
+
// src/plugin/property-priorities.ts
|
|
9
|
+
var longHandPhysical = /* @__PURE__ */ new Set();
|
|
10
|
+
var longHandLogical = /* @__PURE__ */ new Set();
|
|
11
|
+
var shorthandsOfLonghands = /* @__PURE__ */ new Set();
|
|
12
|
+
var shorthandsOfShorthands = /* @__PURE__ */ new Set();
|
|
13
|
+
longHandLogical.add("background-blend-mode");
|
|
14
|
+
longHandLogical.add("isolation");
|
|
15
|
+
longHandLogical.add("mix-blend-mode");
|
|
16
|
+
shorthandsOfShorthands.add("animation");
|
|
17
|
+
longHandLogical.add("animation-composition");
|
|
18
|
+
longHandLogical.add("animation-delay");
|
|
19
|
+
longHandLogical.add("animation-direction");
|
|
20
|
+
longHandLogical.add("animation-duration");
|
|
21
|
+
longHandLogical.add("animation-fill-mode");
|
|
22
|
+
longHandLogical.add("animation-iteration-count");
|
|
23
|
+
longHandLogical.add("animation-name");
|
|
24
|
+
longHandLogical.add("animation-play-state");
|
|
25
|
+
shorthandsOfLonghands.add("animation-range");
|
|
26
|
+
longHandLogical.add("animation-range-end");
|
|
27
|
+
longHandLogical.add("animation-range-start");
|
|
28
|
+
longHandLogical.add("animation-timing-function");
|
|
29
|
+
longHandLogical.add("animation-timeline");
|
|
30
|
+
shorthandsOfLonghands.add("scroll-timeline");
|
|
31
|
+
longHandLogical.add("scroll-timeline-axis");
|
|
32
|
+
longHandLogical.add("scroll-timeline-name");
|
|
33
|
+
longHandLogical.add("timeline-scope");
|
|
34
|
+
shorthandsOfLonghands.add("view-timeline");
|
|
35
|
+
longHandLogical.add("view-timeline-axis");
|
|
36
|
+
longHandLogical.add("view-timeline-inset");
|
|
37
|
+
longHandLogical.add("view-timeline-name");
|
|
38
|
+
shorthandsOfShorthands.add("background");
|
|
39
|
+
longHandLogical.add("background-attachment");
|
|
40
|
+
longHandLogical.add("background-clip");
|
|
41
|
+
longHandLogical.add("background-color");
|
|
42
|
+
longHandLogical.add("background-image");
|
|
43
|
+
longHandLogical.add("background-origin");
|
|
44
|
+
longHandLogical.add("background-repeat");
|
|
45
|
+
longHandLogical.add("background-size");
|
|
46
|
+
shorthandsOfLonghands.add("background-position");
|
|
47
|
+
longHandLogical.add("background-position-x");
|
|
48
|
+
longHandLogical.add("background-position-y");
|
|
49
|
+
shorthandsOfShorthands.add("border");
|
|
50
|
+
shorthandsOfLonghands.add("border-color");
|
|
51
|
+
shorthandsOfLonghands.add("border-style");
|
|
52
|
+
shorthandsOfLonghands.add("border-width");
|
|
53
|
+
shorthandsOfShorthands.add("border-block");
|
|
54
|
+
longHandLogical.add("border-block-color");
|
|
55
|
+
longHandLogical.add("border-block-stylex");
|
|
56
|
+
longHandLogical.add("border-block-width");
|
|
57
|
+
shorthandsOfLonghands.add("border-block-start");
|
|
58
|
+
shorthandsOfLonghands.add("border-top");
|
|
59
|
+
longHandLogical.add("border-block-start-color");
|
|
60
|
+
longHandPhysical.add("border-top-color");
|
|
61
|
+
longHandLogical.add("border-block-start-style");
|
|
62
|
+
longHandPhysical.add("border-top-style");
|
|
63
|
+
longHandLogical.add("border-block-start-width");
|
|
64
|
+
longHandPhysical.add("border-top-width");
|
|
65
|
+
shorthandsOfLonghands.add("border-block-end");
|
|
66
|
+
shorthandsOfLonghands.add("border-bottom");
|
|
67
|
+
longHandLogical.add("border-block-end-color");
|
|
68
|
+
longHandPhysical.add("border-bottom-color");
|
|
69
|
+
longHandLogical.add("border-block-end-style");
|
|
70
|
+
longHandPhysical.add("border-bottom-style");
|
|
71
|
+
longHandLogical.add("border-block-end-width");
|
|
72
|
+
longHandPhysical.add("border-bottom-width");
|
|
73
|
+
shorthandsOfShorthands.add("border-inline");
|
|
74
|
+
shorthandsOfLonghands.add("border-inline-color");
|
|
75
|
+
shorthandsOfLonghands.add("border-inline-style");
|
|
76
|
+
shorthandsOfLonghands.add("border-inline-width");
|
|
77
|
+
shorthandsOfLonghands.add("border-inline-start");
|
|
78
|
+
shorthandsOfLonghands.add("border-left");
|
|
79
|
+
longHandLogical.add("border-inline-start-color");
|
|
80
|
+
longHandPhysical.add("border-left-color");
|
|
81
|
+
longHandLogical.add("border-inline-start-style");
|
|
82
|
+
longHandPhysical.add("border-left-style");
|
|
83
|
+
longHandLogical.add("border-inline-start-width");
|
|
84
|
+
longHandPhysical.add("border-left-width");
|
|
85
|
+
shorthandsOfLonghands.add("border-inline-end");
|
|
86
|
+
shorthandsOfLonghands.add("border-right");
|
|
87
|
+
longHandLogical.add("border-inline-end-color");
|
|
88
|
+
longHandPhysical.add("border-right-color");
|
|
89
|
+
longHandLogical.add("border-inline-end-style");
|
|
90
|
+
longHandPhysical.add("border-right-style");
|
|
91
|
+
longHandLogical.add("border-inline-end-width");
|
|
92
|
+
longHandPhysical.add("border-right-width");
|
|
93
|
+
shorthandsOfLonghands.add("border-image");
|
|
94
|
+
longHandLogical.add("border-image-outset");
|
|
95
|
+
longHandLogical.add("border-image-repeat");
|
|
96
|
+
longHandLogical.add("border-image-slice");
|
|
97
|
+
longHandLogical.add("border-image-source");
|
|
98
|
+
longHandLogical.add("border-image-width");
|
|
99
|
+
shorthandsOfLonghands.add("border-radius");
|
|
100
|
+
longHandLogical.add("border-start-end-radius");
|
|
101
|
+
longHandLogical.add("border-start-start-radius");
|
|
102
|
+
longHandLogical.add("border-end-end-radius");
|
|
103
|
+
longHandLogical.add("border-end-start-radius");
|
|
104
|
+
longHandPhysical.add("border-top-left-radius");
|
|
105
|
+
longHandPhysical.add("border-top-right-radius");
|
|
106
|
+
longHandPhysical.add("border-bottom-left-radius");
|
|
107
|
+
longHandPhysical.add("border-bottom-right-radius");
|
|
108
|
+
shorthandsOfLonghands.add("corner-shape");
|
|
109
|
+
longHandLogical.add("corner-start-start-shape");
|
|
110
|
+
longHandLogical.add("corner-start-end-shape");
|
|
111
|
+
longHandLogical.add("corner-end-start-shape");
|
|
112
|
+
longHandLogical.add("corner-end-end-shape");
|
|
113
|
+
longHandPhysical.add("corner-top-left-shape");
|
|
114
|
+
longHandPhysical.add("corner-top-right-shape");
|
|
115
|
+
longHandPhysical.add("corner-bottom-left-shape");
|
|
116
|
+
longHandPhysical.add("corner-bottom-right-shape");
|
|
117
|
+
longHandLogical.add("box-shadow");
|
|
118
|
+
longHandLogical.add("accent-color");
|
|
119
|
+
longHandLogical.add("appearance");
|
|
120
|
+
longHandLogical.add("aspect-ratio");
|
|
121
|
+
shorthandsOfLonghands.add("caret");
|
|
122
|
+
longHandLogical.add("caret-color");
|
|
123
|
+
longHandLogical.add("caret-shape");
|
|
124
|
+
longHandLogical.add("cursor");
|
|
125
|
+
longHandLogical.add("ime-mode");
|
|
126
|
+
longHandLogical.add("input-security");
|
|
127
|
+
shorthandsOfLonghands.add("outline");
|
|
128
|
+
longHandLogical.add("outline-color");
|
|
129
|
+
longHandLogical.add("outline-offset");
|
|
130
|
+
longHandLogical.add("outline-style");
|
|
131
|
+
longHandLogical.add("outline-width");
|
|
132
|
+
longHandLogical.add("pointer-events");
|
|
133
|
+
longHandLogical.add("resize");
|
|
134
|
+
longHandLogical.add("text-overflow");
|
|
135
|
+
longHandLogical.add("user-select");
|
|
136
|
+
shorthandsOfLonghands.add("grid-gap");
|
|
137
|
+
shorthandsOfLonghands.add("gap");
|
|
138
|
+
longHandLogical.add("grid-row-gap");
|
|
139
|
+
longHandLogical.add("row-gap");
|
|
140
|
+
longHandLogical.add("grid-column-gap");
|
|
141
|
+
longHandLogical.add("column-gap");
|
|
142
|
+
shorthandsOfLonghands.add("place-content");
|
|
143
|
+
longHandLogical.add("align-content");
|
|
144
|
+
longHandLogical.add("justify-content");
|
|
145
|
+
shorthandsOfLonghands.add("place-items");
|
|
146
|
+
longHandLogical.add("align-items");
|
|
147
|
+
longHandLogical.add("justify-items");
|
|
148
|
+
shorthandsOfLonghands.add("place-self");
|
|
149
|
+
longHandLogical.add("align-self");
|
|
150
|
+
longHandLogical.add("justify-self");
|
|
151
|
+
longHandLogical.add("box-sizing");
|
|
152
|
+
longHandLogical.add("block-size");
|
|
153
|
+
longHandPhysical.add("height");
|
|
154
|
+
longHandLogical.add("inline-size");
|
|
155
|
+
longHandPhysical.add("width");
|
|
156
|
+
longHandLogical.add("max-block-size");
|
|
157
|
+
longHandPhysical.add("max-height");
|
|
158
|
+
longHandLogical.add("max-inline-size");
|
|
159
|
+
longHandPhysical.add("max-width");
|
|
160
|
+
longHandLogical.add("min-block-size");
|
|
161
|
+
longHandPhysical.add("min-height");
|
|
162
|
+
longHandLogical.add("min-inline-size");
|
|
163
|
+
longHandPhysical.add("min-width");
|
|
164
|
+
shorthandsOfShorthands.add("margin");
|
|
165
|
+
shorthandsOfLonghands.add("margin-block");
|
|
166
|
+
longHandLogical.add("margin-block-start");
|
|
167
|
+
longHandPhysical.add("margin-top");
|
|
168
|
+
longHandLogical.add("margin-block-end");
|
|
169
|
+
longHandPhysical.add("margin-bottom");
|
|
170
|
+
shorthandsOfLonghands.add("margin-inline");
|
|
171
|
+
longHandLogical.add("margin-inline-start");
|
|
172
|
+
longHandPhysical.add("margin-left");
|
|
173
|
+
longHandLogical.add("margin-inline-end");
|
|
174
|
+
longHandPhysical.add("margin-right");
|
|
175
|
+
longHandLogical.add("margin-trim");
|
|
176
|
+
shorthandsOfLonghands.add("overscroll-behavior");
|
|
177
|
+
longHandLogical.add("overscroll-behavior-block");
|
|
178
|
+
longHandPhysical.add("overscroll-behavior-y");
|
|
179
|
+
longHandLogical.add("overscroll-behavior-inline");
|
|
180
|
+
longHandPhysical.add("overscroll-behavior-x");
|
|
181
|
+
shorthandsOfShorthands.add("padding");
|
|
182
|
+
shorthandsOfLonghands.add("padding-block");
|
|
183
|
+
longHandLogical.add("padding-block-start");
|
|
184
|
+
longHandPhysical.add("padding-top");
|
|
185
|
+
longHandLogical.add("padding-block-end");
|
|
186
|
+
longHandPhysical.add("padding-bottom");
|
|
187
|
+
shorthandsOfLonghands.add("padding-inline");
|
|
188
|
+
longHandLogical.add("padding-inline-start");
|
|
189
|
+
longHandPhysical.add("padding-left");
|
|
190
|
+
longHandLogical.add("padding-inline-end");
|
|
191
|
+
longHandPhysical.add("padding-right");
|
|
192
|
+
longHandLogical.add("visibility");
|
|
193
|
+
longHandLogical.add("color");
|
|
194
|
+
longHandLogical.add("color-scheme");
|
|
195
|
+
longHandLogical.add("forced-color-adjust");
|
|
196
|
+
longHandLogical.add("opacity");
|
|
197
|
+
longHandLogical.add("print-color-adjust");
|
|
198
|
+
shorthandsOfLonghands.add("columns");
|
|
199
|
+
longHandLogical.add("column-count");
|
|
200
|
+
longHandLogical.add("column-width");
|
|
201
|
+
longHandLogical.add("column-fill");
|
|
202
|
+
longHandLogical.add("column-span");
|
|
203
|
+
shorthandsOfLonghands.add("column-rule");
|
|
204
|
+
longHandLogical.add("column-rule-color");
|
|
205
|
+
longHandLogical.add("column-rule-style");
|
|
206
|
+
longHandLogical.add("column-rule-width");
|
|
207
|
+
longHandLogical.add("contain");
|
|
208
|
+
shorthandsOfLonghands.add("contain-intrinsic-size");
|
|
209
|
+
longHandLogical.add("contain-intrinsic-block-size");
|
|
210
|
+
longHandLogical.add("contain-intrinsic-width");
|
|
211
|
+
longHandLogical.add("contain-intrinsic-height");
|
|
212
|
+
longHandLogical.add("contain-intrinsic-inline-size");
|
|
213
|
+
shorthandsOfLonghands.add("container");
|
|
214
|
+
longHandLogical.add("container-name");
|
|
215
|
+
longHandLogical.add("container-type");
|
|
216
|
+
longHandLogical.add("content-visibility");
|
|
217
|
+
longHandLogical.add("counter-increment");
|
|
218
|
+
longHandLogical.add("counter-reset");
|
|
219
|
+
longHandLogical.add("counter-set");
|
|
220
|
+
longHandLogical.add("display");
|
|
221
|
+
shorthandsOfLonghands.add("flex");
|
|
222
|
+
longHandLogical.add("flex-basis");
|
|
223
|
+
longHandLogical.add("flex-grow");
|
|
224
|
+
longHandLogical.add("flex-shrink");
|
|
225
|
+
shorthandsOfLonghands.add("flex-flow");
|
|
226
|
+
longHandLogical.add("flex-direction");
|
|
227
|
+
longHandLogical.add("flex-wrap");
|
|
228
|
+
longHandLogical.add("order");
|
|
229
|
+
shorthandsOfShorthands.add("font");
|
|
230
|
+
longHandLogical.add("font-family");
|
|
231
|
+
longHandLogical.add("font-size");
|
|
232
|
+
longHandLogical.add("font-stretch");
|
|
233
|
+
longHandLogical.add("font-style");
|
|
234
|
+
longHandLogical.add("font-weight");
|
|
235
|
+
longHandLogical.add("line-height");
|
|
236
|
+
shorthandsOfLonghands.add("font-variant");
|
|
237
|
+
longHandLogical.add("font-variant-alternates");
|
|
238
|
+
longHandLogical.add("font-variant-caps");
|
|
239
|
+
longHandLogical.add("font-variant-east-asian");
|
|
240
|
+
longHandLogical.add("font-variant-emoji");
|
|
241
|
+
longHandLogical.add("font-variant-ligatures");
|
|
242
|
+
longHandLogical.add("font-variant-numeric");
|
|
243
|
+
longHandLogical.add("font-variant-position");
|
|
244
|
+
longHandLogical.add("font-feature-settings");
|
|
245
|
+
longHandLogical.add("font-kerning");
|
|
246
|
+
longHandLogical.add("font-language-override");
|
|
247
|
+
longHandLogical.add("font-optical-sizing");
|
|
248
|
+
longHandLogical.add("font-palette");
|
|
249
|
+
longHandLogical.add("font-variation-settings");
|
|
250
|
+
longHandLogical.add("font-size-adjust");
|
|
251
|
+
longHandLogical.add("font-smooth");
|
|
252
|
+
longHandLogical.add("font-synthesis-position");
|
|
253
|
+
longHandLogical.add("font-synthesis-small-caps");
|
|
254
|
+
longHandLogical.add("font-synthesis-style");
|
|
255
|
+
longHandLogical.add("font-synthesis-weight");
|
|
256
|
+
longHandLogical.add("line-height-step");
|
|
257
|
+
longHandLogical.add("box-decoration-break");
|
|
258
|
+
longHandLogical.add("break-after");
|
|
259
|
+
longHandLogical.add("break-before");
|
|
260
|
+
longHandLogical.add("break-inside");
|
|
261
|
+
longHandLogical.add("orphans");
|
|
262
|
+
longHandLogical.add("widows");
|
|
263
|
+
longHandLogical.add("content");
|
|
264
|
+
longHandLogical.add("quotes");
|
|
265
|
+
shorthandsOfShorthands.add("grid");
|
|
266
|
+
longHandLogical.add("grid-auto-flow");
|
|
267
|
+
longHandLogical.add("grid-auto-rows");
|
|
268
|
+
longHandLogical.add("grid-auto-columns");
|
|
269
|
+
shorthandsOfShorthands.add("grid-template");
|
|
270
|
+
shorthandsOfLonghands.add("grid-template-areas");
|
|
271
|
+
longHandLogical.add("grid-template-columns");
|
|
272
|
+
longHandLogical.add("grid-template-rows");
|
|
273
|
+
shorthandsOfShorthands.add("grid-area");
|
|
274
|
+
shorthandsOfLonghands.add("grid-row");
|
|
275
|
+
longHandLogical.add("grid-row-start");
|
|
276
|
+
longHandLogical.add("grid-row-end");
|
|
277
|
+
shorthandsOfLonghands.add("grid-column");
|
|
278
|
+
longHandLogical.add("grid-column-start");
|
|
279
|
+
longHandLogical.add("grid-column-end");
|
|
280
|
+
longHandLogical.add("align-tracks");
|
|
281
|
+
longHandLogical.add("justify-tracks");
|
|
282
|
+
longHandLogical.add("masonry-auto-flow");
|
|
283
|
+
longHandLogical.add("image-orientation");
|
|
284
|
+
longHandLogical.add("image-rendering");
|
|
285
|
+
longHandLogical.add("image-resolution");
|
|
286
|
+
longHandLogical.add("object-fit");
|
|
287
|
+
longHandLogical.add("object-position");
|
|
288
|
+
longHandLogical.add("initial-letter");
|
|
289
|
+
longHandLogical.add("initial-letter-align");
|
|
290
|
+
shorthandsOfLonghands.add("list-style");
|
|
291
|
+
longHandLogical.add("list-style-image");
|
|
292
|
+
longHandLogical.add("list-style-position");
|
|
293
|
+
longHandLogical.add("list-style-type");
|
|
294
|
+
longHandLogical.add("clip");
|
|
295
|
+
longHandLogical.add("clip-path");
|
|
296
|
+
shorthandsOfLonghands.add("mask");
|
|
297
|
+
longHandLogical.add("mask-clip");
|
|
298
|
+
longHandLogical.add("mask-composite");
|
|
299
|
+
longHandLogical.add("mask-image");
|
|
300
|
+
longHandLogical.add("mask-mode");
|
|
301
|
+
longHandLogical.add("mask-origin");
|
|
302
|
+
longHandLogical.add("mask-position");
|
|
303
|
+
longHandLogical.add("mask-repeat");
|
|
304
|
+
longHandLogical.add("mask-size");
|
|
305
|
+
longHandLogical.add("mask-type");
|
|
306
|
+
shorthandsOfLonghands.add("mask-border");
|
|
307
|
+
longHandLogical.add("mask-border-mode");
|
|
308
|
+
longHandLogical.add("mask-border-outset");
|
|
309
|
+
longHandLogical.add("mask-border-repeat");
|
|
310
|
+
longHandLogical.add("mask-border-slice");
|
|
311
|
+
longHandLogical.add("mask-border-source");
|
|
312
|
+
longHandLogical.add("mask-border-width");
|
|
313
|
+
shorthandsOfShorthands.add("all");
|
|
314
|
+
longHandLogical.add("text-rendering");
|
|
315
|
+
shorthandsOfLonghands.add("offset");
|
|
316
|
+
longHandLogical.add("offset-anchor");
|
|
317
|
+
longHandLogical.add("offset-distance");
|
|
318
|
+
longHandLogical.add("offset-path");
|
|
319
|
+
longHandLogical.add("offset-position");
|
|
320
|
+
longHandLogical.add("offset-rotate");
|
|
321
|
+
longHandLogical.add("-webkit-box-orient");
|
|
322
|
+
longHandLogical.add("-webkit-line-clamp");
|
|
323
|
+
shorthandsOfLonghands.add("overflow");
|
|
324
|
+
longHandLogical.add("overflow-block");
|
|
325
|
+
longHandPhysical.add("overflow-y");
|
|
326
|
+
longHandLogical.add("overflow-inline");
|
|
327
|
+
longHandPhysical.add("overflow-x");
|
|
328
|
+
longHandLogical.add("overflow-clip-margin");
|
|
329
|
+
longHandLogical.add("scroll-gutter");
|
|
330
|
+
longHandLogical.add("scroll-behavior");
|
|
331
|
+
longHandLogical.add("page");
|
|
332
|
+
longHandLogical.add("page-break-after");
|
|
333
|
+
longHandLogical.add("page-break-before");
|
|
334
|
+
longHandLogical.add("page-break-inside");
|
|
335
|
+
shorthandsOfShorthands.add("inset");
|
|
336
|
+
shorthandsOfLonghands.add("inset-block");
|
|
337
|
+
longHandLogical.add("inset-block-start");
|
|
338
|
+
longHandPhysical.add("top");
|
|
339
|
+
longHandLogical.add("inset-block-end");
|
|
340
|
+
longHandPhysical.add("bottom");
|
|
341
|
+
shorthandsOfLonghands.add("inset-inline");
|
|
342
|
+
longHandLogical.add("inset-inline-start");
|
|
343
|
+
longHandPhysical.add("left");
|
|
344
|
+
longHandLogical.add("inset-inline-end");
|
|
345
|
+
longHandPhysical.add("right");
|
|
346
|
+
longHandLogical.add("clear");
|
|
347
|
+
longHandLogical.add("float");
|
|
348
|
+
longHandLogical.add("position");
|
|
349
|
+
longHandLogical.add("z-index");
|
|
350
|
+
longHandLogical.add("ruby-align");
|
|
351
|
+
longHandLogical.add("ruby-merge");
|
|
352
|
+
longHandLogical.add("ruby-position");
|
|
353
|
+
longHandLogical.add("overflow-anchor");
|
|
354
|
+
shorthandsOfShorthands.add("scroll-margin");
|
|
355
|
+
shorthandsOfLonghands.add("scroll-margin-block");
|
|
356
|
+
longHandLogical.add("scroll-margin-block-start");
|
|
357
|
+
longHandPhysical.add("scroll-margin-top");
|
|
358
|
+
longHandLogical.add("scroll-margin-block-end");
|
|
359
|
+
longHandPhysical.add("scroll-margin-bottom");
|
|
360
|
+
shorthandsOfLonghands.add("scroll-margin-inline");
|
|
361
|
+
longHandLogical.add("scroll-margin-inline-start");
|
|
362
|
+
longHandPhysical.add("scroll-margin-left");
|
|
363
|
+
longHandLogical.add("scroll-margin-inline-end");
|
|
364
|
+
longHandPhysical.add("scroll-margin-right");
|
|
365
|
+
shorthandsOfShorthands.add("scroll-padding");
|
|
366
|
+
shorthandsOfLonghands.add("scroll-padding-block");
|
|
367
|
+
longHandLogical.add("scroll-padding-block-start");
|
|
368
|
+
longHandPhysical.add("scroll-padding-top");
|
|
369
|
+
longHandLogical.add("scroll-padding-block-end");
|
|
370
|
+
longHandPhysical.add("scroll-padding-bottom");
|
|
371
|
+
shorthandsOfLonghands.add("scroll-padding-inline");
|
|
372
|
+
longHandLogical.add("scroll-padding-inline-start");
|
|
373
|
+
longHandPhysical.add("scroll-padding-left");
|
|
374
|
+
longHandLogical.add("scroll-padding-inline-end");
|
|
375
|
+
longHandPhysical.add("scroll-padding-right");
|
|
376
|
+
longHandLogical.add("scroll-snap-align");
|
|
377
|
+
longHandLogical.add("scroll-snap-stop");
|
|
378
|
+
shorthandsOfLonghands.add("scroll-snap-type");
|
|
379
|
+
longHandLogical.add("scrollbar-color");
|
|
380
|
+
longHandLogical.add("scrollbar-width");
|
|
381
|
+
longHandLogical.add("shape-image-threshold");
|
|
382
|
+
longHandLogical.add("shape-margin");
|
|
383
|
+
longHandLogical.add("shape-outside");
|
|
384
|
+
longHandLogical.add("azimuth");
|
|
385
|
+
longHandLogical.add("border-collapse");
|
|
386
|
+
longHandLogical.add("border-spacing");
|
|
387
|
+
longHandLogical.add("caption-side");
|
|
388
|
+
longHandLogical.add("empty-cells");
|
|
389
|
+
longHandLogical.add("table-layout");
|
|
390
|
+
longHandLogical.add("vertical-align");
|
|
391
|
+
shorthandsOfLonghands.add("text-decoration");
|
|
392
|
+
longHandLogical.add("text-decoration-color");
|
|
393
|
+
longHandLogical.add("text-decoration-line");
|
|
394
|
+
longHandLogical.add("text-decoration-skip");
|
|
395
|
+
longHandLogical.add("text-decoration-skip-ink");
|
|
396
|
+
longHandLogical.add("text-decoration-style");
|
|
397
|
+
longHandLogical.add("text-decoration-thickness");
|
|
398
|
+
shorthandsOfLonghands.add("text-emphasis");
|
|
399
|
+
longHandLogical.add("text-emphasis-color");
|
|
400
|
+
longHandLogical.add("text-emphasis-position");
|
|
401
|
+
longHandLogical.add("text-emphasis-style");
|
|
402
|
+
longHandLogical.add("text-shadow");
|
|
403
|
+
longHandLogical.add("text-underline-offset");
|
|
404
|
+
longHandLogical.add("text-underline-position");
|
|
405
|
+
longHandLogical.add("hanging-punctuation");
|
|
406
|
+
longHandLogical.add("hyphenate-character");
|
|
407
|
+
longHandLogical.add("hyphenate-limit-chars");
|
|
408
|
+
longHandLogical.add("hyphens");
|
|
409
|
+
longHandLogical.add("letter-spacing");
|
|
410
|
+
longHandLogical.add("line-break");
|
|
411
|
+
longHandLogical.add("overflow-wrap");
|
|
412
|
+
longHandLogical.add("paint-order");
|
|
413
|
+
longHandLogical.add("tab-size");
|
|
414
|
+
longHandLogical.add("text-align");
|
|
415
|
+
longHandLogical.add("text-align-last");
|
|
416
|
+
longHandLogical.add("text-indent");
|
|
417
|
+
longHandLogical.add("text-justify");
|
|
418
|
+
longHandLogical.add("text-size-adjust");
|
|
419
|
+
longHandLogical.add("text-transform");
|
|
420
|
+
longHandLogical.add("text-wrap");
|
|
421
|
+
longHandLogical.add("white-space");
|
|
422
|
+
longHandLogical.add("white-space-collapse");
|
|
423
|
+
longHandLogical.add("word-break");
|
|
424
|
+
longHandLogical.add("word-spacing");
|
|
425
|
+
longHandLogical.add("word-wrap");
|
|
426
|
+
longHandLogical.add("backface-visibility");
|
|
427
|
+
longHandLogical.add("perspective");
|
|
428
|
+
longHandLogical.add("perspective-origin");
|
|
429
|
+
longHandLogical.add("rotate");
|
|
430
|
+
longHandLogical.add("scale");
|
|
431
|
+
longHandLogical.add("transform");
|
|
432
|
+
longHandLogical.add("transform-box");
|
|
433
|
+
longHandLogical.add("transform-origin");
|
|
434
|
+
longHandLogical.add("transform-style");
|
|
435
|
+
longHandLogical.add("translate");
|
|
436
|
+
shorthandsOfLonghands.add("transition");
|
|
437
|
+
longHandLogical.add("transition-delay");
|
|
438
|
+
longHandLogical.add("transition-duration");
|
|
439
|
+
longHandLogical.add("transition-property");
|
|
440
|
+
longHandLogical.add("transition-timing-function");
|
|
441
|
+
longHandLogical.add("view-transition-name");
|
|
442
|
+
longHandLogical.add("will-change");
|
|
443
|
+
longHandLogical.add("direction");
|
|
444
|
+
longHandLogical.add("text-combine-upright");
|
|
445
|
+
longHandLogical.add("text-orientation");
|
|
446
|
+
longHandLogical.add("unicode-bidi");
|
|
447
|
+
longHandLogical.add("writing-mode");
|
|
448
|
+
longHandLogical.add("backdrop-filter");
|
|
449
|
+
longHandLogical.add("filter");
|
|
450
|
+
longHandLogical.add("math-depth");
|
|
451
|
+
longHandLogical.add("math-shift");
|
|
452
|
+
longHandLogical.add("math-style");
|
|
453
|
+
longHandLogical.add("touch-action");
|
|
454
|
+
var PSEUDO_CLASS_PRIORITIES = {
|
|
455
|
+
":is": 40,
|
|
456
|
+
":where": 40,
|
|
457
|
+
":not": 40,
|
|
458
|
+
":has": 45,
|
|
459
|
+
":dir": 50,
|
|
460
|
+
":lang": 51,
|
|
461
|
+
":first-child": 52,
|
|
462
|
+
":first-of-type": 53,
|
|
463
|
+
":last-child": 54,
|
|
464
|
+
":last-of-type": 55,
|
|
465
|
+
":only-child": 56,
|
|
466
|
+
":only-of-type": 57,
|
|
467
|
+
":nth-child": 60,
|
|
468
|
+
":nth-last-child": 61,
|
|
469
|
+
":nth-of-type": 62,
|
|
470
|
+
":nth-last-of-type": 63,
|
|
471
|
+
":empty": 70,
|
|
472
|
+
":link": 80,
|
|
473
|
+
":any-link": 81,
|
|
474
|
+
":local-link": 82,
|
|
475
|
+
":target-within": 83,
|
|
476
|
+
":target": 84,
|
|
477
|
+
":visited": 85,
|
|
478
|
+
":enabled": 91,
|
|
479
|
+
":disabled": 92,
|
|
480
|
+
":required": 93,
|
|
481
|
+
":optional": 94,
|
|
482
|
+
":read-only": 95,
|
|
483
|
+
":read-write": 96,
|
|
484
|
+
":placeholder-shown": 97,
|
|
485
|
+
":in-range": 98,
|
|
486
|
+
":out-of-range": 99,
|
|
487
|
+
":default": 100,
|
|
488
|
+
":checked": 101,
|
|
489
|
+
":indeterminate": 101,
|
|
490
|
+
":blank": 102,
|
|
491
|
+
":valid": 103,
|
|
492
|
+
":invalid": 104,
|
|
493
|
+
":user-invalid": 105,
|
|
494
|
+
":autofill": 110,
|
|
495
|
+
":picture-in-picture": 120,
|
|
496
|
+
":modal": 121,
|
|
497
|
+
":fullscreen": 122,
|
|
498
|
+
":paused": 123,
|
|
499
|
+
":playing": 124,
|
|
500
|
+
":current": 125,
|
|
501
|
+
":past": 126,
|
|
502
|
+
":future": 127,
|
|
503
|
+
":hover": 130,
|
|
504
|
+
":focusWithin": 140,
|
|
505
|
+
":focus": 150,
|
|
506
|
+
":focusVisible": 160,
|
|
507
|
+
":active": 170
|
|
508
|
+
};
|
|
509
|
+
var AT_RULE_PRIORITIES = {
|
|
510
|
+
"@supports": 30,
|
|
511
|
+
"@media": 200,
|
|
512
|
+
"@container": 300
|
|
513
|
+
};
|
|
514
|
+
var PSEUDO_ELEMENT_PRIORITY = 5e3;
|
|
515
|
+
function getPropertyPriority(property) {
|
|
516
|
+
if (shorthandsOfShorthands.has(property)) return 1e3;
|
|
517
|
+
if (shorthandsOfLonghands.has(property)) return 2e3;
|
|
518
|
+
if (longHandLogical.has(property)) return 3e3;
|
|
519
|
+
if (longHandPhysical.has(property)) return 4e3;
|
|
520
|
+
return 3e3;
|
|
521
|
+
}
|
|
522
|
+
function getPseudoClassPriority(pseudo) {
|
|
523
|
+
const base = pseudo.split("(")[0];
|
|
524
|
+
return PSEUDO_CLASS_PRIORITIES[base] ?? 40;
|
|
525
|
+
}
|
|
526
|
+
function getAtRulePriority(atRule) {
|
|
527
|
+
if (atRule.startsWith("--")) return 1;
|
|
528
|
+
if (atRule.startsWith("@supports")) return AT_RULE_PRIORITIES["@supports"];
|
|
529
|
+
if (atRule.startsWith("@media")) return AT_RULE_PRIORITIES["@media"];
|
|
530
|
+
if (atRule.startsWith("@container")) return AT_RULE_PRIORITIES["@container"];
|
|
531
|
+
return 0;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// src/plugin/priority.ts
|
|
535
|
+
var RELATIONSHIP_BASE = {
|
|
536
|
+
ancestor: 10,
|
|
537
|
+
descendant: 15,
|
|
538
|
+
anySibling: 20,
|
|
539
|
+
siblingBefore: 30,
|
|
540
|
+
siblingAfter: 40
|
|
541
|
+
};
|
|
542
|
+
function computeRulePriority(rule) {
|
|
543
|
+
let priority = getPropertyPriority(rule.cssProperty);
|
|
544
|
+
if (rule.pseudoElement) {
|
|
545
|
+
priority += PSEUDO_ELEMENT_PRIORITY;
|
|
546
|
+
}
|
|
547
|
+
if (rule.pseudoClass) {
|
|
548
|
+
priority += getPseudoClassPriority(rule.pseudoClass);
|
|
549
|
+
}
|
|
550
|
+
if (rule.mediaQuery) {
|
|
551
|
+
priority += getAtRulePriority(rule.mediaQuery);
|
|
552
|
+
}
|
|
553
|
+
if (rule.whenSelector) {
|
|
554
|
+
const relBase = RELATIONSHIP_BASE[rule.whenSelector.relationship] ?? 10;
|
|
555
|
+
const pseudoFraction = getPseudoClassPriority(rule.whenSelector.pseudo) / 100;
|
|
556
|
+
priority += relBase + pseudoFraction;
|
|
557
|
+
}
|
|
558
|
+
if (isVariableRule(rule)) {
|
|
559
|
+
priority += 0.5;
|
|
560
|
+
}
|
|
561
|
+
return priority;
|
|
562
|
+
}
|
|
563
|
+
function isVariableRule(rule) {
|
|
564
|
+
if (rule.declarations) {
|
|
565
|
+
return rule.declarations.some(function(d) {
|
|
566
|
+
return d.cssVarName !== void 0;
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
return rule.cssVarName !== void 0;
|
|
570
|
+
}
|
|
571
|
+
function sortRulesByPriority(rules) {
|
|
572
|
+
rules.sort(function(a, b) {
|
|
573
|
+
const diff = computeRulePriority(a) - computeRulePriority(b);
|
|
574
|
+
if (diff !== 0) return diff;
|
|
575
|
+
return a.className < b.className ? -1 : a.className > b.className ? 1 : 0;
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/plugin/emit-truss.ts
|
|
7
580
|
var PSEUDO_SUFFIX = {
|
|
8
581
|
":hover": "_h",
|
|
9
582
|
":focus": "_f",
|
|
@@ -11,7 +584,6 @@ var PSEUDO_SUFFIX = {
|
|
|
11
584
|
":active": "_a",
|
|
12
585
|
":disabled": "_d"
|
|
13
586
|
};
|
|
14
|
-
var PSEUDO_ORDER = [":hover", ":focus", ":focus-visible", ":active", ":disabled"];
|
|
15
587
|
var RELATIONSHIP_SHORT = {
|
|
16
588
|
ancestor: "anc",
|
|
17
589
|
descendant: "desc",
|
|
@@ -57,7 +629,7 @@ function conditionPrefix(pseudoClass, mediaQuery, pseudoElement, breakpoints) {
|
|
|
57
629
|
return parts.join("");
|
|
58
630
|
}
|
|
59
631
|
function camelToKebab(s) {
|
|
60
|
-
return s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)
|
|
632
|
+
return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
61
633
|
}
|
|
62
634
|
function cleanValueForClassName(value) {
|
|
63
635
|
let cleaned = value;
|
|
@@ -91,24 +663,24 @@ function getLonghandLookup(mapping) {
|
|
|
91
663
|
return cachedLookup;
|
|
92
664
|
}
|
|
93
665
|
function computeStaticBaseName(seg, cssProp, cssValue, isMultiProp, mapping) {
|
|
94
|
-
const
|
|
666
|
+
const abbr = seg.abbr;
|
|
95
667
|
if (seg.argResolved !== void 0) {
|
|
96
668
|
const valuePart = cleanValueForClassName(seg.argResolved);
|
|
97
669
|
if (isMultiProp) {
|
|
98
670
|
const lookup = getLonghandLookup(mapping);
|
|
99
671
|
const canonical = lookup.get(`${cssProp}\0${cssValue}`);
|
|
100
672
|
if (canonical) return canonical;
|
|
101
|
-
return `${
|
|
673
|
+
return `${abbr}_${valuePart}_${cssProp}`;
|
|
102
674
|
}
|
|
103
|
-
return `${
|
|
675
|
+
return `${abbr}_${valuePart}`;
|
|
104
676
|
}
|
|
105
677
|
if (isMultiProp) {
|
|
106
678
|
const lookup = getLonghandLookup(mapping);
|
|
107
679
|
const canonical = lookup.get(`${cssProp}\0${cssValue}`);
|
|
108
680
|
if (canonical) return canonical;
|
|
109
|
-
return `${
|
|
681
|
+
return `${abbr}_${cssProp}`;
|
|
110
682
|
}
|
|
111
|
-
return
|
|
683
|
+
return abbr;
|
|
112
684
|
}
|
|
113
685
|
function collectAtomicRules(chains, mapping) {
|
|
114
686
|
const rules = /* @__PURE__ */ new Map();
|
|
@@ -118,17 +690,8 @@ function collectAtomicRules(chains, mapping) {
|
|
|
118
690
|
const segs = part.type === "unconditional" ? part.segments : [...part.thenSegments, ...part.elseSegments];
|
|
119
691
|
for (const seg of segs) {
|
|
120
692
|
if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;
|
|
121
|
-
if (seg.
|
|
122
|
-
if (seg.variableProps) {
|
|
123
|
-
if (seg.incremented) needsMaybeInc = true;
|
|
124
|
-
collectWhenVariableRules(rules, seg, mapping);
|
|
125
|
-
} else {
|
|
126
|
-
collectWhenStaticRules(rules, seg, mapping);
|
|
127
|
-
}
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
693
|
+
if (seg.incremented) needsMaybeInc = true;
|
|
130
694
|
if (seg.variableProps) {
|
|
131
|
-
if (seg.incremented) needsMaybeInc = true;
|
|
132
695
|
collectVariableRules(rules, seg, mapping);
|
|
133
696
|
} else {
|
|
134
697
|
collectStaticRules(rules, seg, mapping);
|
|
@@ -138,113 +701,50 @@ function collectAtomicRules(chains, mapping) {
|
|
|
138
701
|
}
|
|
139
702
|
return { rules, needsMaybeInc };
|
|
140
703
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (!rules.has(className)) {
|
|
151
|
-
rules.set(className, {
|
|
152
|
-
className,
|
|
153
|
-
cssProperty: camelToKebab(cssProp),
|
|
154
|
-
cssValue: String(cssValue),
|
|
155
|
-
pseudoClass: seg.pseudoClass ?? void 0,
|
|
156
|
-
mediaQuery: seg.mediaQuery ?? void 0,
|
|
157
|
-
pseudoElement: seg.pseudoElement ?? void 0
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function collectVariableRules(rules, seg, mapping) {
|
|
163
|
-
const prefix = conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);
|
|
164
|
-
const segmentBaseKey = seg.key.split("__")[0];
|
|
165
|
-
for (const prop of seg.variableProps) {
|
|
166
|
-
const baseKey = seg.key.split("__")[0];
|
|
167
|
-
const className = prefix ? `${prefix}${baseKey}_var` : `${baseKey}_var`;
|
|
168
|
-
const varName = toCssVariableName(className, baseKey, prop);
|
|
169
|
-
const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };
|
|
170
|
-
const existingRule = rules.get(className);
|
|
171
|
-
if (!existingRule) {
|
|
172
|
-
rules.set(className, {
|
|
173
|
-
className,
|
|
174
|
-
cssProperty: declaration.cssProperty,
|
|
175
|
-
cssValue: declaration.cssValue,
|
|
176
|
-
declarations: [declaration],
|
|
177
|
-
pseudoClass: seg.pseudoClass ?? void 0,
|
|
178
|
-
mediaQuery: seg.mediaQuery ?? void 0,
|
|
179
|
-
pseudoElement: seg.pseudoElement ?? void 0,
|
|
180
|
-
cssVarName: varName
|
|
181
|
-
});
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
existingRule.declarations ??= [
|
|
185
|
-
{
|
|
186
|
-
cssProperty: existingRule.cssProperty,
|
|
187
|
-
cssValue: existingRule.cssValue,
|
|
188
|
-
cssVarName: existingRule.cssVarName
|
|
189
|
-
}
|
|
190
|
-
];
|
|
191
|
-
if (!existingRule.declarations.some(function(entry) {
|
|
192
|
-
return entry.cssProperty === declaration.cssProperty;
|
|
193
|
-
})) {
|
|
194
|
-
existingRule.declarations.push(declaration);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (seg.variableExtraDefs) {
|
|
198
|
-
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
199
|
-
const extraBase = `${segmentBaseKey}_${cssProp}`;
|
|
200
|
-
const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
|
|
201
|
-
if (!rules.has(extraName)) {
|
|
202
|
-
rules.set(extraName, {
|
|
203
|
-
className: extraName,
|
|
204
|
-
cssProperty: camelToKebab(cssProp),
|
|
205
|
-
cssValue: String(value),
|
|
206
|
-
pseudoClass: seg.pseudoClass ?? void 0,
|
|
207
|
-
mediaQuery: seg.mediaQuery ?? void 0,
|
|
208
|
-
pseudoElement: seg.pseudoElement ?? void 0
|
|
209
|
-
});
|
|
704
|
+
function segmentContext(seg, mapping) {
|
|
705
|
+
if (seg.whenPseudo) {
|
|
706
|
+
const wp = seg.whenPseudo;
|
|
707
|
+
return {
|
|
708
|
+
prefix: whenPrefix(wp),
|
|
709
|
+
whenSelector: {
|
|
710
|
+
relationship: wp.relationship ?? "ancestor",
|
|
711
|
+
markerClass: markerClassName(wp.markerNode),
|
|
712
|
+
pseudo: wp.pseudo
|
|
210
713
|
}
|
|
211
|
-
}
|
|
714
|
+
};
|
|
212
715
|
}
|
|
716
|
+
return { prefix: conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints) };
|
|
213
717
|
}
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
718
|
+
function baseRuleFields(seg) {
|
|
719
|
+
return {
|
|
720
|
+
pseudoClass: seg.pseudoClass ?? void 0,
|
|
721
|
+
mediaQuery: seg.mediaQuery ?? void 0,
|
|
722
|
+
pseudoElement: seg.pseudoElement ?? void 0
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function collectStaticRules(rules, seg, mapping) {
|
|
726
|
+
const { prefix, whenSelector } = segmentContext(seg, mapping);
|
|
727
|
+
const isMultiProp = Object.keys(seg.defs).length > 1;
|
|
728
|
+
for (const [cssProp, value] of Object.entries(seg.defs)) {
|
|
729
|
+
const cssValue = String(value);
|
|
730
|
+
const baseName = computeStaticBaseName(seg, cssProp, cssValue, isMultiProp, mapping);
|
|
731
|
+
const className = prefix ? `${prefix}${baseName}` : baseName;
|
|
225
732
|
if (!rules.has(className)) {
|
|
226
733
|
rules.set(className, {
|
|
227
734
|
className,
|
|
228
735
|
cssProperty: camelToKebab(cssProp),
|
|
229
|
-
cssValue
|
|
230
|
-
whenSelector
|
|
231
|
-
|
|
232
|
-
markerClass: mClass,
|
|
233
|
-
pseudo: wp.pseudo
|
|
234
|
-
}
|
|
736
|
+
cssValue,
|
|
737
|
+
...!whenSelector && baseRuleFields(seg),
|
|
738
|
+
whenSelector
|
|
235
739
|
});
|
|
236
740
|
}
|
|
237
741
|
}
|
|
238
742
|
}
|
|
239
|
-
function
|
|
240
|
-
const
|
|
241
|
-
const prefix = whenPrefix(wp);
|
|
242
|
-
const segmentBaseKey = seg.key.split("__")[0];
|
|
243
|
-
const mClass = markerClassName(wp.markerNode);
|
|
743
|
+
function collectVariableRules(rules, seg, mapping) {
|
|
744
|
+
const { prefix, whenSelector } = segmentContext(seg, mapping);
|
|
244
745
|
for (const prop of seg.variableProps) {
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const varName = toCssVariableName(className, baseKey, prop);
|
|
746
|
+
const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;
|
|
747
|
+
const varName = toCssVariableName(className, seg.abbr, prop);
|
|
248
748
|
const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };
|
|
249
749
|
const existingRule = rules.get(className);
|
|
250
750
|
if (!existingRule) {
|
|
@@ -254,11 +754,8 @@ function collectWhenVariableRules(rules, seg, mapping) {
|
|
|
254
754
|
cssValue: declaration.cssValue,
|
|
255
755
|
declarations: [declaration],
|
|
256
756
|
cssVarName: varName,
|
|
257
|
-
whenSelector
|
|
258
|
-
|
|
259
|
-
markerClass: mClass,
|
|
260
|
-
pseudo: wp.pseudo
|
|
261
|
-
}
|
|
757
|
+
...!whenSelector && baseRuleFields(seg),
|
|
758
|
+
whenSelector
|
|
262
759
|
});
|
|
263
760
|
continue;
|
|
264
761
|
}
|
|
@@ -277,121 +774,26 @@ function collectWhenVariableRules(rules, seg, mapping) {
|
|
|
277
774
|
}
|
|
278
775
|
if (seg.variableExtraDefs) {
|
|
279
776
|
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
280
|
-
const
|
|
777
|
+
const extraBase = `${seg.abbr}_${cssProp}`;
|
|
778
|
+
const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
|
|
281
779
|
if (!rules.has(extraName)) {
|
|
282
780
|
rules.set(extraName, {
|
|
283
781
|
className: extraName,
|
|
284
782
|
cssProperty: camelToKebab(cssProp),
|
|
285
783
|
cssValue: String(value),
|
|
286
|
-
whenSelector
|
|
287
|
-
|
|
288
|
-
markerClass: mClass,
|
|
289
|
-
pseudo: wp.pseudo
|
|
290
|
-
}
|
|
784
|
+
...!whenSelector && baseRuleFields(seg),
|
|
785
|
+
whenSelector
|
|
291
786
|
});
|
|
292
787
|
}
|
|
293
788
|
}
|
|
294
789
|
}
|
|
295
790
|
}
|
|
296
|
-
function unwrapDefs(defs, pseudoElement) {
|
|
297
|
-
let result = defs;
|
|
298
|
-
if (pseudoElement && result[pseudoElement] && typeof result[pseudoElement] === "object") {
|
|
299
|
-
result = result[pseudoElement];
|
|
300
|
-
}
|
|
301
|
-
const unwrapped = {};
|
|
302
|
-
for (const [prop, val] of Object.entries(result)) {
|
|
303
|
-
unwrapped[prop] = extractLeafValue(val) ?? val;
|
|
304
|
-
}
|
|
305
|
-
return unwrapped;
|
|
306
|
-
}
|
|
307
|
-
function extractLeafValue(value) {
|
|
308
|
-
if (typeof value === "string" || typeof value === "number") return value;
|
|
309
|
-
if (value === null) return null;
|
|
310
|
-
if (typeof value === "object") {
|
|
311
|
-
const obj = value;
|
|
312
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
313
|
-
if (k === "default") continue;
|
|
314
|
-
if (typeof v === "string" || typeof v === "number") return v;
|
|
315
|
-
if (typeof v === "object" && v !== null) return extractLeafValue(v);
|
|
316
|
-
}
|
|
317
|
-
if ("default" in obj && obj.default !== null) {
|
|
318
|
-
return extractLeafValue(obj.default);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
791
|
function generateCssText(rules) {
|
|
324
792
|
const allRules = Array.from(rules.values());
|
|
325
|
-
|
|
326
|
-
const pseudo = /* @__PURE__ */ new Map();
|
|
327
|
-
const pseudoElement = [];
|
|
328
|
-
const whenRules = [];
|
|
329
|
-
const media = [];
|
|
330
|
-
const mediaPseudo = [];
|
|
331
|
-
const mediaPseudoElement = [];
|
|
332
|
-
for (const rule of allRules) {
|
|
333
|
-
if (rule.whenSelector) {
|
|
334
|
-
whenRules.push(rule);
|
|
335
|
-
} else if (rule.mediaQuery && rule.pseudoClass) {
|
|
336
|
-
mediaPseudo.push(rule);
|
|
337
|
-
} else if (rule.mediaQuery && rule.pseudoElement) {
|
|
338
|
-
mediaPseudoElement.push(rule);
|
|
339
|
-
} else if (rule.mediaQuery) {
|
|
340
|
-
media.push(rule);
|
|
341
|
-
} else if (rule.pseudoClass && rule.pseudoElement) {
|
|
342
|
-
const tier = pseudo.get(rule.pseudoClass) ?? [];
|
|
343
|
-
tier.push(rule);
|
|
344
|
-
pseudo.set(rule.pseudoClass, tier);
|
|
345
|
-
} else if (rule.pseudoElement) {
|
|
346
|
-
pseudoElement.push(rule);
|
|
347
|
-
} else if (rule.pseudoClass) {
|
|
348
|
-
const tier = pseudo.get(rule.pseudoClass) ?? [];
|
|
349
|
-
tier.push(rule);
|
|
350
|
-
pseudo.set(rule.pseudoClass, tier);
|
|
351
|
-
} else {
|
|
352
|
-
base.push(rule);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
sortRulesWithinPropertyTier(base);
|
|
356
|
-
sortRulesWithinPropertyTier(pseudoElement);
|
|
357
|
-
sortRulesWithinPropertyTier(whenRules);
|
|
358
|
-
sortRulesWithinPropertyTier(media);
|
|
359
|
-
sortRulesWithinPropertyTier(mediaPseudo);
|
|
360
|
-
sortRulesWithinPropertyTier(mediaPseudoElement);
|
|
361
|
-
for (const tier of pseudo.values()) {
|
|
362
|
-
sortRulesWithinPropertyTier(tier);
|
|
363
|
-
}
|
|
793
|
+
sortRulesByPriority(allRules);
|
|
364
794
|
const lines = [];
|
|
365
|
-
for (const rule of
|
|
366
|
-
lines.push(
|
|
367
|
-
}
|
|
368
|
-
for (const pc of PSEUDO_ORDER) {
|
|
369
|
-
const tier = pseudo.get(pc);
|
|
370
|
-
if (!tier) continue;
|
|
371
|
-
for (const rule of tier) {
|
|
372
|
-
lines.push(formatPseudoRule(rule));
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
for (const [pc, tier] of Array.from(pseudo.entries())) {
|
|
376
|
-
if (PSEUDO_ORDER.includes(pc)) continue;
|
|
377
|
-
for (const rule of tier) {
|
|
378
|
-
lines.push(formatPseudoRule(rule));
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
for (const rule of pseudoElement) {
|
|
382
|
-
lines.push(formatPseudoElementRule(rule));
|
|
383
|
-
}
|
|
384
|
-
for (const rule of whenRules) {
|
|
385
|
-
lines.push(formatWhenRule(rule));
|
|
386
|
-
}
|
|
387
|
-
for (const rule of media) {
|
|
388
|
-
lines.push(formatMediaRule(rule));
|
|
389
|
-
}
|
|
390
|
-
for (const rule of mediaPseudo) {
|
|
391
|
-
lines.push(formatMediaPseudoRule(rule));
|
|
392
|
-
}
|
|
393
|
-
for (const rule of mediaPseudoElement) {
|
|
394
|
-
lines.push(formatMediaPseudoElementRule(rule));
|
|
795
|
+
for (const rule of allRules) {
|
|
796
|
+
lines.push(formatRule(rule));
|
|
395
797
|
}
|
|
396
798
|
for (const rule of allRules) {
|
|
397
799
|
for (const declaration of getRuleDeclarations(rule)) {
|
|
@@ -405,41 +807,15 @@ function generateCssText(rules) {
|
|
|
405
807
|
}
|
|
406
808
|
return lines.join("\n");
|
|
407
809
|
}
|
|
408
|
-
function
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
const conflictingProps = /* @__PURE__ */ new Set();
|
|
419
|
-
for (const prop of variableProps) {
|
|
420
|
-
if (staticProps.has(prop)) {
|
|
421
|
-
conflictingProps.add(prop);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if (conflictingProps.size === 0) return;
|
|
425
|
-
const kept = [];
|
|
426
|
-
const deferred = [];
|
|
427
|
-
for (const rule of rules) {
|
|
428
|
-
if (conflictingProps.has(rule.cssProperty) && isVariableRule(rule)) {
|
|
429
|
-
deferred.push(rule);
|
|
430
|
-
} else {
|
|
431
|
-
kept.push(rule);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
const result = [...kept, ...deferred];
|
|
435
|
-
for (let i = 0; i < result.length; i++) {
|
|
436
|
-
rules[i] = result[i];
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
function isVariableRule(rule) {
|
|
440
|
-
return getRuleDeclarations(rule).some(function(declaration) {
|
|
441
|
-
return declaration.cssVarName !== void 0;
|
|
442
|
-
});
|
|
810
|
+
function formatRule(rule) {
|
|
811
|
+
if (rule.whenSelector) return formatWhenRule(rule);
|
|
812
|
+
if (rule.mediaQuery && rule.pseudoClass) return formatMediaPseudoRule(rule);
|
|
813
|
+
if (rule.mediaQuery && rule.pseudoElement) return formatMediaPseudoElementRule(rule);
|
|
814
|
+
if (rule.mediaQuery) return formatMediaRule(rule);
|
|
815
|
+
if (rule.pseudoClass && rule.pseudoElement) return formatPseudoRule(rule);
|
|
816
|
+
if (rule.pseudoElement) return formatPseudoElementRule(rule);
|
|
817
|
+
if (rule.pseudoClass) return formatPseudoRule(rule);
|
|
818
|
+
return formatBaseRule(rule);
|
|
443
819
|
}
|
|
444
820
|
function formatBaseRule(rule) {
|
|
445
821
|
return formatRuleBlock(`.${rule.className}`, rule);
|
|
@@ -510,13 +886,11 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
510
886
|
const propGroups = /* @__PURE__ */ new Map();
|
|
511
887
|
for (const seg of segments) {
|
|
512
888
|
if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;
|
|
889
|
+
const { prefix } = segmentContext(seg, mapping);
|
|
513
890
|
if (seg.variableProps) {
|
|
514
|
-
const prefix = seg.whenPseudo ? whenPrefix(seg.whenPseudo) : conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);
|
|
515
|
-
const segmentBaseKey = seg.key.split("__")[0];
|
|
516
891
|
for (const prop of seg.variableProps) {
|
|
517
|
-
const
|
|
518
|
-
const
|
|
519
|
-
const varName = toCssVariableName(className, baseKey, prop);
|
|
892
|
+
const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;
|
|
893
|
+
const varName = toCssVariableName(className, seg.abbr, prop);
|
|
520
894
|
if (!propGroups.has(prop)) propGroups.set(prop, []);
|
|
521
895
|
propGroups.get(prop).push({
|
|
522
896
|
className,
|
|
@@ -529,19 +903,15 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
529
903
|
}
|
|
530
904
|
if (seg.variableExtraDefs) {
|
|
531
905
|
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
532
|
-
const extraBase = `${
|
|
906
|
+
const extraBase = `${seg.abbr}_${cssProp}`;
|
|
533
907
|
const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
|
|
534
908
|
if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
|
|
535
909
|
propGroups.get(cssProp).push({ className: extraName, isVariable: false });
|
|
536
910
|
}
|
|
537
911
|
}
|
|
538
912
|
} else {
|
|
539
|
-
const
|
|
540
|
-
const
|
|
541
|
-
const isMultiProp = Object.keys(rawDefs).length > 1;
|
|
542
|
-
for (const cssProp of Object.keys(rawDefs)) {
|
|
543
|
-
const val = extractLeafValue(rawDefs[cssProp]);
|
|
544
|
-
if (val === null) continue;
|
|
913
|
+
const isMultiProp = Object.keys(seg.defs).length > 1;
|
|
914
|
+
for (const [cssProp, val] of Object.entries(seg.defs)) {
|
|
545
915
|
const baseName = computeStaticBaseName(seg, cssProp, String(val), isMultiProp, mapping);
|
|
546
916
|
const className = prefix ? `${prefix}${baseName}` : baseName;
|
|
547
917
|
if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
|
|
@@ -577,8 +947,8 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
577
947
|
}
|
|
578
948
|
function toCssVariableName(className, baseKey, cssProp) {
|
|
579
949
|
const baseClassName = `${baseKey}_var`;
|
|
580
|
-
const
|
|
581
|
-
return `--${
|
|
950
|
+
const cp = className.endsWith(baseClassName) ? className.slice(0, -baseClassName.length) : "";
|
|
951
|
+
return `--${cp}${cssProp}`;
|
|
582
952
|
}
|
|
583
953
|
function buildMaybeIncDeclaration(helperName, increment) {
|
|
584
954
|
const incParam = t.identifier("inc");
|
|
@@ -623,7 +993,7 @@ import * as t4 from "@babel/types";
|
|
|
623
993
|
import { basename } from "path";
|
|
624
994
|
|
|
625
995
|
// src/plugin/resolve-chain.ts
|
|
626
|
-
function resolveFullChain(chain, mapping
|
|
996
|
+
function resolveFullChain(chain, mapping) {
|
|
627
997
|
const parts = [];
|
|
628
998
|
const markers = [];
|
|
629
999
|
const filteredChain = [];
|
|
@@ -651,22 +1021,14 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
651
1021
|
const elseIndex = findElseIndex(filteredChain, i + 1);
|
|
652
1022
|
if (elseIndex !== -1) {
|
|
653
1023
|
if (currentNodes.length > 0) {
|
|
654
|
-
|
|
655
|
-
parts.push({
|
|
656
|
-
type: "unconditional",
|
|
657
|
-
segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs)
|
|
658
|
-
});
|
|
1024
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
659
1025
|
currentNodes = [];
|
|
660
1026
|
}
|
|
661
1027
|
const thenNodes = mediaStart.thenNodes ? [...mediaStart.thenNodes, ...filteredChain.slice(i + 1, elseIndex)] : filteredChain.slice(i, elseIndex);
|
|
662
1028
|
const elseNodes = [makeMediaQueryNode(mediaStart.inverseMediaQuery), ...filteredChain.slice(elseIndex + 1)];
|
|
663
1029
|
const thenSegs = resolveChain(thenNodes, mapping);
|
|
664
1030
|
const elseSegs = resolveChain(elseNodes, mapping);
|
|
665
|
-
|
|
666
|
-
parts.push({
|
|
667
|
-
type: "unconditional",
|
|
668
|
-
segments: options?.skipMerge ? combinedSegs : mergeOverlappingConditions(combinedSegs)
|
|
669
|
-
});
|
|
1031
|
+
parts.push({ type: "unconditional", segments: [...thenSegs, ...elseSegs] });
|
|
670
1032
|
i = filteredChain.length;
|
|
671
1033
|
break;
|
|
672
1034
|
}
|
|
@@ -679,11 +1041,7 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
679
1041
|
continue;
|
|
680
1042
|
}
|
|
681
1043
|
if (currentNodes.length > 0) {
|
|
682
|
-
|
|
683
|
-
parts.push({
|
|
684
|
-
type: "unconditional",
|
|
685
|
-
segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs)
|
|
686
|
-
});
|
|
1044
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
687
1045
|
currentNodes = [];
|
|
688
1046
|
}
|
|
689
1047
|
const thenNodes = [];
|
|
@@ -711,8 +1069,8 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
711
1069
|
parts.push({
|
|
712
1070
|
type: "conditional",
|
|
713
1071
|
conditionNode: node.conditionNode,
|
|
714
|
-
thenSegments:
|
|
715
|
-
elseSegments:
|
|
1072
|
+
thenSegments: thenSegs,
|
|
1073
|
+
elseSegments: elseSegs
|
|
716
1074
|
});
|
|
717
1075
|
} else {
|
|
718
1076
|
currentNodes.push(node);
|
|
@@ -720,11 +1078,7 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
720
1078
|
}
|
|
721
1079
|
}
|
|
722
1080
|
if (currentNodes.length > 0) {
|
|
723
|
-
|
|
724
|
-
parts.push({
|
|
725
|
-
type: "unconditional",
|
|
726
|
-
segments: options?.skipMerge ? remainingSegs : mergeOverlappingConditions(remainingSegs)
|
|
727
|
-
});
|
|
1081
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
728
1082
|
}
|
|
729
1083
|
const segmentErrors = [];
|
|
730
1084
|
for (const part of parts) {
|
|
@@ -913,7 +1267,7 @@ function resolveChain(chain, mapping) {
|
|
|
913
1267
|
}
|
|
914
1268
|
} catch (err) {
|
|
915
1269
|
if (err instanceof UnsupportedPatternError) {
|
|
916
|
-
segments.push({
|
|
1270
|
+
segments.push({ abbr: "__error", defs: {}, error: err.message });
|
|
917
1271
|
} else {
|
|
918
1272
|
throw err;
|
|
919
1273
|
}
|
|
@@ -921,11 +1275,16 @@ function resolveChain(chain, mapping) {
|
|
|
921
1275
|
}
|
|
922
1276
|
return segments;
|
|
923
1277
|
}
|
|
924
|
-
function
|
|
1278
|
+
function typographyLookupKeySuffix(mediaQuery, pseudoClass, pseudoElement, breakpoints) {
|
|
925
1279
|
const parts = [];
|
|
926
|
-
if (pseudoElement) parts.push(
|
|
927
|
-
if (mediaQuery
|
|
928
|
-
|
|
1280
|
+
if (pseudoElement) parts.push(pseudoElement.replace(/^::/, ""));
|
|
1281
|
+
if (mediaQuery && breakpoints) {
|
|
1282
|
+
const bp = Object.entries(breakpoints).find(([, v]) => v === mediaQuery)?.[0];
|
|
1283
|
+
parts.push(bp ? bp.replace(/^if/, "").replace(/^./, (c) => c.toLowerCase()) : "mq");
|
|
1284
|
+
} else if (mediaQuery) {
|
|
1285
|
+
parts.push("mq");
|
|
1286
|
+
}
|
|
1287
|
+
if (pseudoClass) parts.push(pseudoClass.replace(/^:+/, "").replace(/-/g, "_"));
|
|
929
1288
|
return parts.join("_");
|
|
930
1289
|
}
|
|
931
1290
|
function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoElement) {
|
|
@@ -940,7 +1299,7 @@ function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoEle
|
|
|
940
1299
|
if (typography.length === 0) {
|
|
941
1300
|
throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);
|
|
942
1301
|
}
|
|
943
|
-
const suffix =
|
|
1302
|
+
const suffix = typographyLookupKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
944
1303
|
const lookupKey = suffix ? `typography__${suffix}` : "typography";
|
|
945
1304
|
const segmentsByName = {};
|
|
946
1305
|
for (const name of typography) {
|
|
@@ -948,7 +1307,7 @@ function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoEle
|
|
|
948
1307
|
}
|
|
949
1308
|
return [
|
|
950
1309
|
{
|
|
951
|
-
|
|
1310
|
+
abbr: lookupKey,
|
|
952
1311
|
defs: {},
|
|
953
1312
|
typographyLookup: {
|
|
954
1313
|
lookupKey,
|
|
@@ -974,32 +1333,13 @@ function resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoEl
|
|
|
974
1333
|
}
|
|
975
1334
|
return resolved;
|
|
976
1335
|
}
|
|
977
|
-
function wrapDefsWithConditions(defs, mediaQuery, pseudoClass) {
|
|
978
|
-
if (!mediaQuery && !pseudoClass) return defs;
|
|
979
|
-
const result = {};
|
|
980
|
-
for (const [prop, value] of Object.entries(defs)) {
|
|
981
|
-
if (pseudoClass && mediaQuery) {
|
|
982
|
-
result[prop] = { default: null, [pseudoClass]: { default: null, [mediaQuery]: value } };
|
|
983
|
-
} else if (pseudoClass) {
|
|
984
|
-
result[prop] = { default: null, [pseudoClass]: value };
|
|
985
|
-
} else {
|
|
986
|
-
result[prop] = { default: null, [mediaQuery]: value };
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
return result;
|
|
990
|
-
}
|
|
991
1336
|
function resolveEntry(abbr, entry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
992
1337
|
switch (entry.kind) {
|
|
993
1338
|
case "static": {
|
|
994
1339
|
if (whenPseudo) {
|
|
995
|
-
|
|
996
|
-
const key2 = `${abbr}__${suffix2}`;
|
|
997
|
-
return [{ key: key2, defs: entry.defs, whenPseudo }];
|
|
1340
|
+
return [{ abbr, defs: entry.defs, whenPseudo }];
|
|
998
1341
|
}
|
|
999
|
-
|
|
1000
|
-
const key = suffix ? `${abbr}__${suffix}` : abbr;
|
|
1001
|
-
const defs = pseudoElement ? { [pseudoElement]: wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass) } : wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass);
|
|
1002
|
-
return [{ key, defs, mediaQuery, pseudoClass, pseudoElement }];
|
|
1342
|
+
return [{ abbr, defs: entry.defs, mediaQuery, pseudoClass, pseudoElement }];
|
|
1003
1343
|
}
|
|
1004
1344
|
case "alias": {
|
|
1005
1345
|
const result = [];
|
|
@@ -1023,65 +1363,19 @@ function resolveVariableCall(abbr, entry, node, mapping, mediaQuery, pseudoClass
|
|
|
1023
1363
|
if (node.args.length !== 1) {
|
|
1024
1364
|
throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);
|
|
1025
1365
|
}
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
} else {
|
|
1040
|
-
const key = `${abbr}__${wpSuffix}`;
|
|
1041
|
-
return {
|
|
1042
|
-
key,
|
|
1043
|
-
defs: {},
|
|
1044
|
-
whenPseudo,
|
|
1045
|
-
variableProps: entry.props,
|
|
1046
|
-
incremented: entry.incremented,
|
|
1047
|
-
variableExtraDefs: entry.extraDefs,
|
|
1048
|
-
argNode: argAst
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
1053
|
-
if (literalValue !== null) {
|
|
1054
|
-
const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, "_");
|
|
1055
|
-
const key = suffix ? `${abbr}__${keySuffix}__${suffix}` : `${abbr}__${keySuffix}`;
|
|
1056
|
-
const defs = {};
|
|
1057
|
-
for (const prop of entry.props) {
|
|
1058
|
-
defs[prop] = literalValue;
|
|
1059
|
-
}
|
|
1060
|
-
if (entry.extraDefs) {
|
|
1061
|
-
Object.assign(defs, entry.extraDefs);
|
|
1062
|
-
}
|
|
1063
|
-
const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);
|
|
1064
|
-
return {
|
|
1065
|
-
key,
|
|
1066
|
-
defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,
|
|
1067
|
-
mediaQuery,
|
|
1068
|
-
pseudoClass,
|
|
1069
|
-
pseudoElement,
|
|
1070
|
-
argResolved: literalValue
|
|
1071
|
-
};
|
|
1072
|
-
} else {
|
|
1073
|
-
const key = suffix ? `${abbr}__${suffix}` : abbr;
|
|
1074
|
-
return {
|
|
1075
|
-
key,
|
|
1076
|
-
defs: {},
|
|
1077
|
-
mediaQuery,
|
|
1078
|
-
pseudoClass,
|
|
1079
|
-
variableProps: entry.props,
|
|
1080
|
-
incremented: entry.incremented,
|
|
1081
|
-
variableExtraDefs: entry.extraDefs,
|
|
1082
|
-
argNode: argAst
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1366
|
+
const literalValue = tryEvaluateLiteral(node.args[0], entry.incremented, mapping.increment);
|
|
1367
|
+
return buildParameterizedSegment({
|
|
1368
|
+
abbr,
|
|
1369
|
+
props: entry.props,
|
|
1370
|
+
incremented: entry.incremented,
|
|
1371
|
+
extraDefs: entry.extraDefs,
|
|
1372
|
+
argAst: node.args[0],
|
|
1373
|
+
literalValue,
|
|
1374
|
+
mediaQuery,
|
|
1375
|
+
pseudoClass,
|
|
1376
|
+
pseudoElement,
|
|
1377
|
+
whenPseudo
|
|
1378
|
+
});
|
|
1085
1379
|
}
|
|
1086
1380
|
function resolveDelegateCall(abbr, entry, node, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
1087
1381
|
const targetEntry = mapping.abbreviations[entry.target];
|
|
@@ -1091,68 +1385,58 @@ function resolveDelegateCall(abbr, entry, node, mapping, mediaQuery, pseudoClass
|
|
|
1091
1385
|
if (node.args.length !== 1) {
|
|
1092
1386
|
throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);
|
|
1093
1387
|
}
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
defs: {},
|
|
1112
|
-
whenPseudo,
|
|
1113
|
-
variableProps: targetEntry.props,
|
|
1114
|
-
incremented: false,
|
|
1115
|
-
appendPx: true,
|
|
1116
|
-
variableExtraDefs: targetEntry.extraDefs,
|
|
1117
|
-
argNode: argAst
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
1388
|
+
const literalValue = tryEvaluatePxLiteral(node.args[0]);
|
|
1389
|
+
return buildParameterizedSegment({
|
|
1390
|
+
abbr: entry.target,
|
|
1391
|
+
props: targetEntry.props,
|
|
1392
|
+
incremented: false,
|
|
1393
|
+
appendPx: true,
|
|
1394
|
+
extraDefs: targetEntry.extraDefs,
|
|
1395
|
+
argAst: node.args[0],
|
|
1396
|
+
literalValue,
|
|
1397
|
+
mediaQuery,
|
|
1398
|
+
pseudoClass,
|
|
1399
|
+
pseudoElement,
|
|
1400
|
+
whenPseudo
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
function buildParameterizedSegment(params) {
|
|
1404
|
+
const { abbr, props, incremented, appendPx, extraDefs, argAst, literalValue, whenPseudo } = params;
|
|
1122
1405
|
if (literalValue !== null) {
|
|
1123
|
-
const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, "_");
|
|
1124
|
-
const key = suffix ? `${entry.target}__${keySuffix}__${suffix}` : `${entry.target}__${keySuffix}`;
|
|
1125
1406
|
const defs = {};
|
|
1126
|
-
for (const prop of
|
|
1407
|
+
for (const prop of props) {
|
|
1127
1408
|
defs[prop] = literalValue;
|
|
1128
1409
|
}
|
|
1129
|
-
if (
|
|
1130
|
-
|
|
1410
|
+
if (extraDefs) Object.assign(defs, extraDefs);
|
|
1411
|
+
if (whenPseudo) {
|
|
1412
|
+
return { abbr, defs, whenPseudo, argResolved: literalValue };
|
|
1131
1413
|
}
|
|
1132
|
-
const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);
|
|
1133
1414
|
return {
|
|
1134
|
-
|
|
1135
|
-
defs
|
|
1136
|
-
mediaQuery,
|
|
1137
|
-
pseudoClass,
|
|
1138
|
-
pseudoElement,
|
|
1415
|
+
abbr,
|
|
1416
|
+
defs,
|
|
1417
|
+
mediaQuery: params.mediaQuery,
|
|
1418
|
+
pseudoClass: params.pseudoClass,
|
|
1419
|
+
pseudoElement: params.pseudoElement,
|
|
1139
1420
|
argResolved: literalValue
|
|
1140
1421
|
};
|
|
1422
|
+
}
|
|
1423
|
+
const base = {
|
|
1424
|
+
abbr,
|
|
1425
|
+
defs: {},
|
|
1426
|
+
variableProps: props,
|
|
1427
|
+
incremented,
|
|
1428
|
+
variableExtraDefs: extraDefs,
|
|
1429
|
+
argNode: argAst
|
|
1430
|
+
};
|
|
1431
|
+
if (appendPx) base.appendPx = true;
|
|
1432
|
+
if (whenPseudo) {
|
|
1433
|
+
base.whenPseudo = whenPseudo;
|
|
1141
1434
|
} else {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
defs: {},
|
|
1146
|
-
mediaQuery,
|
|
1147
|
-
pseudoClass,
|
|
1148
|
-
pseudoElement,
|
|
1149
|
-
variableProps: targetEntry.props,
|
|
1150
|
-
incremented: false,
|
|
1151
|
-
appendPx: true,
|
|
1152
|
-
variableExtraDefs: targetEntry.extraDefs,
|
|
1153
|
-
argNode: argAst
|
|
1154
|
-
};
|
|
1435
|
+
base.mediaQuery = params.mediaQuery;
|
|
1436
|
+
base.pseudoClass = params.pseudoClass;
|
|
1437
|
+
base.pseudoElement = params.pseudoElement;
|
|
1155
1438
|
}
|
|
1439
|
+
return base;
|
|
1156
1440
|
}
|
|
1157
1441
|
function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
1158
1442
|
if (node.args.length === 1) {
|
|
@@ -1166,7 +1450,7 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
|
|
|
1166
1450
|
);
|
|
1167
1451
|
}
|
|
1168
1452
|
return {
|
|
1169
|
-
|
|
1453
|
+
abbr: "__composed_css_prop",
|
|
1170
1454
|
defs: {},
|
|
1171
1455
|
styleArrayArg: styleArg
|
|
1172
1456
|
};
|
|
@@ -1184,34 +1468,24 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
|
|
|
1184
1468
|
const valueArg = node.args[1];
|
|
1185
1469
|
const literalValue = tryEvaluateAddLiteral(valueArg);
|
|
1186
1470
|
if (whenPseudo) {
|
|
1187
|
-
const wpSuffix = whenPseudoKeyName(whenPseudo);
|
|
1188
1471
|
if (literalValue !== null) {
|
|
1189
|
-
|
|
1190
|
-
const key = `${propName}__${keySuffix}__${wpSuffix}`;
|
|
1191
|
-
return { key, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };
|
|
1472
|
+
return { abbr: propName, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };
|
|
1192
1473
|
} else {
|
|
1193
|
-
|
|
1194
|
-
return { key, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };
|
|
1474
|
+
return { abbr: propName, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };
|
|
1195
1475
|
}
|
|
1196
1476
|
}
|
|
1197
|
-
const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
1198
1477
|
if (literalValue !== null) {
|
|
1199
|
-
const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1200
|
-
const key = suffix ? `${propName}__${keySuffix}__${suffix}` : `${propName}__${keySuffix}`;
|
|
1201
|
-
const defs = { [propName]: literalValue };
|
|
1202
|
-
const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);
|
|
1203
1478
|
return {
|
|
1204
|
-
|
|
1205
|
-
defs:
|
|
1479
|
+
abbr: propName,
|
|
1480
|
+
defs: { [propName]: literalValue },
|
|
1206
1481
|
mediaQuery,
|
|
1207
1482
|
pseudoClass,
|
|
1208
1483
|
pseudoElement,
|
|
1209
1484
|
argResolved: literalValue
|
|
1210
1485
|
};
|
|
1211
1486
|
} else {
|
|
1212
|
-
const key = suffix ? `${propName}__${suffix}` : propName;
|
|
1213
1487
|
return {
|
|
1214
|
-
|
|
1488
|
+
abbr: propName,
|
|
1215
1489
|
defs: {},
|
|
1216
1490
|
mediaQuery,
|
|
1217
1491
|
pseudoClass,
|
|
@@ -1279,127 +1553,6 @@ function isPseudoMethod(name) {
|
|
|
1279
1553
|
function pseudoSelector(name) {
|
|
1280
1554
|
return PSEUDO_METHODS[name];
|
|
1281
1555
|
}
|
|
1282
|
-
function whenPseudoKeyName(ap) {
|
|
1283
|
-
const rel = ap.relationship ?? "ancestor";
|
|
1284
|
-
const pn = pseudoName(ap.pseudo);
|
|
1285
|
-
const base = `${rel}${pn.charAt(0).toUpperCase()}${pn.slice(1)}`;
|
|
1286
|
-
if (!ap.markerNode) return base;
|
|
1287
|
-
const suffix = ap.markerNode.type === "Identifier" ? ap.markerNode.name : "marker";
|
|
1288
|
-
return `${base}_${suffix}`;
|
|
1289
|
-
}
|
|
1290
|
-
function mergeOverlappingConditions(segments) {
|
|
1291
|
-
const propToIndices = /* @__PURE__ */ new Map();
|
|
1292
|
-
for (let i = 0; i < segments.length; i++) {
|
|
1293
|
-
const seg = segments[i];
|
|
1294
|
-
if (seg.variableProps || seg.styleArrayArg || seg.whenPseudo || seg.error) continue;
|
|
1295
|
-
for (const prop of Object.keys(seg.defs)) {
|
|
1296
|
-
if (!propToIndices.has(prop)) propToIndices.set(prop, []);
|
|
1297
|
-
propToIndices.get(prop).push(i);
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
const mergeableProps = /* @__PURE__ */ new Set();
|
|
1301
|
-
for (const [prop, indices] of propToIndices) {
|
|
1302
|
-
if (indices.length < 2) continue;
|
|
1303
|
-
const hasBase = indices.some((i) => !segments[i].mediaQuery && !segments[i].pseudoClass);
|
|
1304
|
-
const hasConditional = indices.some((i) => !!(segments[i].mediaQuery || segments[i].pseudoClass));
|
|
1305
|
-
if (hasBase && hasConditional) {
|
|
1306
|
-
mergeableProps.add(prop);
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
if (mergeableProps.size === 0) return segments;
|
|
1310
|
-
const consumedProps = /* @__PURE__ */ new Map();
|
|
1311
|
-
const mergedPropDefs = /* @__PURE__ */ new Map();
|
|
1312
|
-
for (const prop of mergeableProps) {
|
|
1313
|
-
const indices = propToIndices.get(prop);
|
|
1314
|
-
let merged = {};
|
|
1315
|
-
const keyParts = [];
|
|
1316
|
-
for (const idx of indices) {
|
|
1317
|
-
const seg = segments[idx];
|
|
1318
|
-
const value = seg.defs[prop];
|
|
1319
|
-
keyParts.push(seg.key);
|
|
1320
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
1321
|
-
merged.default = value;
|
|
1322
|
-
} else if (typeof value === "object" && value !== null) {
|
|
1323
|
-
for (const [k, v] of Object.entries(value)) {
|
|
1324
|
-
if (k === "default" && v === null && merged.default !== void 0) {
|
|
1325
|
-
continue;
|
|
1326
|
-
}
|
|
1327
|
-
merged[k] = v;
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
if (!consumedProps.has(idx)) consumedProps.set(idx, /* @__PURE__ */ new Set());
|
|
1331
|
-
consumedProps.get(idx).add(prop);
|
|
1332
|
-
}
|
|
1333
|
-
const finalValue = Object.keys(merged).length === 1 && "default" in merged ? merged.default : merged;
|
|
1334
|
-
const mergedKey = [...new Set(keyParts)].join("_");
|
|
1335
|
-
mergedPropDefs.set(prop, { defs: { [prop]: finalValue }, key: mergedKey });
|
|
1336
|
-
}
|
|
1337
|
-
const groupByIndices = /* @__PURE__ */ new Map();
|
|
1338
|
-
for (const prop of mergeableProps) {
|
|
1339
|
-
const indices = propToIndices.get(prop);
|
|
1340
|
-
const groupKey = indices.join(",");
|
|
1341
|
-
if (!groupByIndices.has(groupKey)) {
|
|
1342
|
-
groupByIndices.set(groupKey, { props: [], key: mergedPropDefs.get(prop).key });
|
|
1343
|
-
}
|
|
1344
|
-
groupByIndices.get(groupKey).props.push(prop);
|
|
1345
|
-
}
|
|
1346
|
-
const mergedSegments = [];
|
|
1347
|
-
for (const [, group] of groupByIndices) {
|
|
1348
|
-
const defs = {};
|
|
1349
|
-
for (const prop of group.props) {
|
|
1350
|
-
Object.assign(defs, mergedPropDefs.get(prop).defs);
|
|
1351
|
-
}
|
|
1352
|
-
mergedSegments.push({ key: group.key, defs });
|
|
1353
|
-
}
|
|
1354
|
-
const result = [];
|
|
1355
|
-
const mergedEmitted = /* @__PURE__ */ new Set();
|
|
1356
|
-
for (let i = 0; i < segments.length; i++) {
|
|
1357
|
-
const seg = segments[i];
|
|
1358
|
-
const consumed = consumedProps.get(i);
|
|
1359
|
-
if (!consumed) {
|
|
1360
|
-
result.push(seg);
|
|
1361
|
-
continue;
|
|
1362
|
-
}
|
|
1363
|
-
const remainingDefs = {};
|
|
1364
|
-
for (const [prop, value] of Object.entries(seg.defs)) {
|
|
1365
|
-
if (!consumed.has(prop)) {
|
|
1366
|
-
remainingDefs[prop] = value;
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
if (Object.keys(remainingDefs).length > 0) {
|
|
1370
|
-
result.push({ ...seg, defs: remainingDefs });
|
|
1371
|
-
}
|
|
1372
|
-
const indices = [...propToIndices.entries()].filter(([prop]) => consumed.has(prop) && mergeableProps.has(prop)).map(([, idxs]) => idxs.join(","));
|
|
1373
|
-
for (const groupKey of new Set(indices)) {
|
|
1374
|
-
if (!mergedEmitted.has(groupKey)) {
|
|
1375
|
-
const group = groupByIndices.get(groupKey);
|
|
1376
|
-
if (group) {
|
|
1377
|
-
const defs = {};
|
|
1378
|
-
for (const prop of group.props) {
|
|
1379
|
-
Object.assign(defs, mergedPropDefs.get(prop).defs);
|
|
1380
|
-
}
|
|
1381
|
-
result.push({ key: group.key, defs });
|
|
1382
|
-
mergedEmitted.add(groupKey);
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
return result;
|
|
1388
|
-
}
|
|
1389
|
-
function pseudoName(pseudo, breakpoints) {
|
|
1390
|
-
if (pseudo.startsWith("@media") && breakpoints) {
|
|
1391
|
-
for (const [getterName, mediaQuery] of Object.entries(breakpoints)) {
|
|
1392
|
-
if (mediaQuery === pseudo) {
|
|
1393
|
-
return getterName.replace(/^if/, "").replace(/^./, (c) => c.toLowerCase());
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
return pseudo.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1397
|
-
}
|
|
1398
|
-
if (pseudo.startsWith("@container")) {
|
|
1399
|
-
return pseudo.replace(/^@container\s*/, "container ").replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1400
|
-
}
|
|
1401
|
-
return pseudo.replace(/^:+/, "").replace(/-/g, "_");
|
|
1402
|
-
}
|
|
1403
1556
|
function tryEvaluateLiteral(node, incremented, increment) {
|
|
1404
1557
|
if (node.type === "NumericLiteral") {
|
|
1405
1558
|
if (incremented) {
|
|
@@ -1799,11 +1952,13 @@ function buildStyleHashFromChain(chain, options) {
|
|
|
1799
1952
|
} else {
|
|
1800
1953
|
const thenMembers = mergeConditionalBranchMembers(
|
|
1801
1954
|
buildStyleHashMembers(part.thenSegments, options),
|
|
1802
|
-
previousProperties
|
|
1955
|
+
previousProperties,
|
|
1956
|
+
collectConditionalOnlyProps(part.thenSegments)
|
|
1803
1957
|
);
|
|
1804
1958
|
const elseMembers = mergeConditionalBranchMembers(
|
|
1805
1959
|
buildStyleHashMembers(part.elseSegments, options),
|
|
1806
|
-
previousProperties
|
|
1960
|
+
previousProperties,
|
|
1961
|
+
collectConditionalOnlyProps(part.elseSegments)
|
|
1807
1962
|
);
|
|
1808
1963
|
members.push(
|
|
1809
1964
|
t3.spreadElement(
|
|
@@ -1848,13 +2003,31 @@ function buildStyleHashMembers(segments, options) {
|
|
|
1848
2003
|
flushNormal();
|
|
1849
2004
|
return members;
|
|
1850
2005
|
}
|
|
1851
|
-
function
|
|
2006
|
+
function collectConditionalOnlyProps(segments) {
|
|
2007
|
+
const allProps = /* @__PURE__ */ new Map();
|
|
2008
|
+
for (const seg of segments) {
|
|
2009
|
+
if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;
|
|
2010
|
+
const hasCondition = !!(seg.pseudoClass || seg.mediaQuery || seg.pseudoElement || seg.whenPseudo);
|
|
2011
|
+
const props = seg.variableProps ?? Object.keys(seg.defs);
|
|
2012
|
+
for (const prop of props) {
|
|
2013
|
+
const current = allProps.get(prop);
|
|
2014
|
+
allProps.set(prop, current === void 0 ? hasCondition : current && hasCondition);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
const result = /* @__PURE__ */ new Set();
|
|
2018
|
+
for (const [prop, isConditionalOnly] of allProps) {
|
|
2019
|
+
if (isConditionalOnly) result.add(prop);
|
|
2020
|
+
}
|
|
2021
|
+
return result;
|
|
2022
|
+
}
|
|
2023
|
+
function mergeConditionalBranchMembers(members, previousProperties, conditionalOnlyProps) {
|
|
1852
2024
|
return members.map(function(member) {
|
|
1853
2025
|
if (!t3.isObjectProperty(member)) {
|
|
1854
2026
|
return member;
|
|
1855
2027
|
}
|
|
1856
|
-
const
|
|
1857
|
-
|
|
2028
|
+
const prop = propertyName(member.key);
|
|
2029
|
+
const prior = previousProperties.get(prop);
|
|
2030
|
+
if (!prior || !conditionalOnlyProps.has(prop)) {
|
|
1858
2031
|
return member;
|
|
1859
2032
|
}
|
|
1860
2033
|
return t3.objectProperty(
|
|
@@ -2078,7 +2251,7 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2078
2251
|
if (parentPath && parentPath.isMemberExpression() && t4.isIdentifier(parentPath.node.property, { name: "$" })) {
|
|
2079
2252
|
return;
|
|
2080
2253
|
}
|
|
2081
|
-
const resolvedChain = resolveFullChain(chain, mapping
|
|
2254
|
+
const resolvedChain = resolveFullChain(chain, mapping);
|
|
2082
2255
|
sites.push({ path, resolvedChain });
|
|
2083
2256
|
const line = path.node.loc?.start.line ?? null;
|
|
2084
2257
|
for (const err of resolvedChain.errors) {
|
|
@@ -2121,7 +2294,6 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2121
2294
|
needsTrussPropsHelper,
|
|
2122
2295
|
trussDebugInfoName,
|
|
2123
2296
|
needsTrussDebugInfo,
|
|
2124
|
-
skippedCssPropMessages: errorMessages,
|
|
2125
2297
|
runtimeLookupNames
|
|
2126
2298
|
});
|
|
2127
2299
|
const runtimeImports = [];
|
|
@@ -2416,7 +2588,7 @@ function resolveCssExpression(node, cssBindingName, mapping, filename) {
|
|
|
2416
2588
|
}
|
|
2417
2589
|
for (const [prop, value] of Object.entries(seg.defs)) {
|
|
2418
2590
|
if (typeof value === "string" || typeof value === "number") {
|
|
2419
|
-
declarations.push({ property:
|
|
2591
|
+
declarations.push({ property: camelToKebab(prop), value: String(value) });
|
|
2420
2592
|
} else {
|
|
2421
2593
|
return { error: `unexpected nested value for property "${prop}"` };
|
|
2422
2594
|
}
|
|
@@ -2425,9 +2597,6 @@ function resolveCssExpression(node, cssBindingName, mapping, filename) {
|
|
|
2425
2597
|
}
|
|
2426
2598
|
return { declarations };
|
|
2427
2599
|
}
|
|
2428
|
-
function camelToKebab2(s) {
|
|
2429
|
-
return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
2430
|
-
}
|
|
2431
2600
|
function formatCssRule(selector, declarations) {
|
|
2432
2601
|
if (declarations.length === 0) {
|
|
2433
2602
|
return `${selector} {}`;
|
|
@@ -2555,8 +2724,8 @@ function trussPlugin(opts) {
|
|
|
2555
2724
|
},
|
|
2556
2725
|
transformIndexHtml(html) {
|
|
2557
2726
|
if (isBuild) return html;
|
|
2558
|
-
const
|
|
2559
|
-
return html.replace("</head>", ` ${
|
|
2727
|
+
const tag = `<script type="module" src="/${VIRTUAL_RUNTIME_ID}"></script>`;
|
|
2728
|
+
return html.replace("</head>", ` ${tag}
|
|
2560
2729
|
</head>`);
|
|
2561
2730
|
},
|
|
2562
2731
|
handleHotUpdate(ctx) {
|