@homebound/truss 2.1.0-next.7 → 2.1.0-next.9
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 +722 -563
- package/build/plugin/index.js.map +1 -1
- package/package.json +1 -1
package/build/plugin/index.js
CHANGED
|
@@ -4,6 +4,577 @@ 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
|
+
return computeRulePriority(a) - computeRulePriority(b);
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/plugin/emit-truss.ts
|
|
7
578
|
var PSEUDO_SUFFIX = {
|
|
8
579
|
":hover": "_h",
|
|
9
580
|
":focus": "_f",
|
|
@@ -11,7 +582,6 @@ var PSEUDO_SUFFIX = {
|
|
|
11
582
|
":active": "_a",
|
|
12
583
|
":disabled": "_d"
|
|
13
584
|
};
|
|
14
|
-
var PSEUDO_ORDER = [":hover", ":focus", ":focus-visible", ":active", ":disabled"];
|
|
15
585
|
var RELATIONSHIP_SHORT = {
|
|
16
586
|
ancestor: "anc",
|
|
17
587
|
descendant: "desc",
|
|
@@ -57,7 +627,7 @@ function conditionPrefix(pseudoClass, mediaQuery, pseudoElement, breakpoints) {
|
|
|
57
627
|
return parts.join("");
|
|
58
628
|
}
|
|
59
629
|
function camelToKebab(s) {
|
|
60
|
-
return s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)
|
|
630
|
+
return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
61
631
|
}
|
|
62
632
|
function cleanValueForClassName(value) {
|
|
63
633
|
let cleaned = value;
|
|
@@ -91,24 +661,24 @@ function getLonghandLookup(mapping) {
|
|
|
91
661
|
return cachedLookup;
|
|
92
662
|
}
|
|
93
663
|
function computeStaticBaseName(seg, cssProp, cssValue, isMultiProp, mapping) {
|
|
94
|
-
const
|
|
664
|
+
const abbr = seg.abbr;
|
|
95
665
|
if (seg.argResolved !== void 0) {
|
|
96
666
|
const valuePart = cleanValueForClassName(seg.argResolved);
|
|
97
667
|
if (isMultiProp) {
|
|
98
668
|
const lookup = getLonghandLookup(mapping);
|
|
99
669
|
const canonical = lookup.get(`${cssProp}\0${cssValue}`);
|
|
100
670
|
if (canonical) return canonical;
|
|
101
|
-
return `${
|
|
671
|
+
return `${abbr}_${valuePart}_${cssProp}`;
|
|
102
672
|
}
|
|
103
|
-
return `${
|
|
673
|
+
return `${abbr}_${valuePart}`;
|
|
104
674
|
}
|
|
105
675
|
if (isMultiProp) {
|
|
106
676
|
const lookup = getLonghandLookup(mapping);
|
|
107
677
|
const canonical = lookup.get(`${cssProp}\0${cssValue}`);
|
|
108
678
|
if (canonical) return canonical;
|
|
109
|
-
return `${
|
|
679
|
+
return `${abbr}_${cssProp}`;
|
|
110
680
|
}
|
|
111
|
-
return
|
|
681
|
+
return abbr;
|
|
112
682
|
}
|
|
113
683
|
function collectAtomicRules(chains, mapping) {
|
|
114
684
|
const rules = /* @__PURE__ */ new Map();
|
|
@@ -118,17 +688,8 @@ function collectAtomicRules(chains, mapping) {
|
|
|
118
688
|
const segs = part.type === "unconditional" ? part.segments : [...part.thenSegments, ...part.elseSegments];
|
|
119
689
|
for (const seg of segs) {
|
|
120
690
|
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
|
-
}
|
|
691
|
+
if (seg.incremented) needsMaybeInc = true;
|
|
130
692
|
if (seg.variableProps) {
|
|
131
|
-
if (seg.incremented) needsMaybeInc = true;
|
|
132
693
|
collectVariableRules(rules, seg, mapping);
|
|
133
694
|
} else {
|
|
134
695
|
collectStaticRules(rules, seg, mapping);
|
|
@@ -138,113 +699,50 @@ function collectAtomicRules(chains, mapping) {
|
|
|
138
699
|
}
|
|
139
700
|
return { rules, needsMaybeInc };
|
|
140
701
|
}
|
|
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
|
-
});
|
|
702
|
+
function segmentContext(seg, mapping) {
|
|
703
|
+
if (seg.whenPseudo) {
|
|
704
|
+
const wp = seg.whenPseudo;
|
|
705
|
+
return {
|
|
706
|
+
prefix: whenPrefix(wp),
|
|
707
|
+
whenSelector: {
|
|
708
|
+
relationship: wp.relationship ?? "ancestor",
|
|
709
|
+
markerClass: markerClassName(wp.markerNode),
|
|
710
|
+
pseudo: wp.pseudo
|
|
210
711
|
}
|
|
211
|
-
}
|
|
712
|
+
};
|
|
212
713
|
}
|
|
714
|
+
return { prefix: conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints) };
|
|
715
|
+
}
|
|
716
|
+
function baseRuleFields(seg) {
|
|
717
|
+
return {
|
|
718
|
+
pseudoClass: seg.pseudoClass ?? void 0,
|
|
719
|
+
mediaQuery: seg.mediaQuery ?? void 0,
|
|
720
|
+
pseudoElement: seg.pseudoElement ?? void 0
|
|
721
|
+
};
|
|
213
722
|
}
|
|
214
|
-
function
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const cssValue = typeof value === "string" || typeof value === "number" ? value : extractLeafValue(value);
|
|
222
|
-
if (cssValue === null) continue;
|
|
223
|
-
const baseName = computeStaticBaseName(seg, cssProp, String(cssValue), isMultiProp, mapping);
|
|
224
|
-
const className = `${prefix}${baseName}`;
|
|
723
|
+
function collectStaticRules(rules, seg, mapping) {
|
|
724
|
+
const { prefix, whenSelector } = segmentContext(seg, mapping);
|
|
725
|
+
const isMultiProp = Object.keys(seg.defs).length > 1;
|
|
726
|
+
for (const [cssProp, value] of Object.entries(seg.defs)) {
|
|
727
|
+
const cssValue = String(value);
|
|
728
|
+
const baseName = computeStaticBaseName(seg, cssProp, cssValue, isMultiProp, mapping);
|
|
729
|
+
const className = prefix ? `${prefix}${baseName}` : baseName;
|
|
225
730
|
if (!rules.has(className)) {
|
|
226
731
|
rules.set(className, {
|
|
227
732
|
className,
|
|
228
733
|
cssProperty: camelToKebab(cssProp),
|
|
229
|
-
cssValue
|
|
230
|
-
whenSelector
|
|
231
|
-
|
|
232
|
-
markerClass: mClass,
|
|
233
|
-
pseudo: wp.pseudo
|
|
234
|
-
}
|
|
734
|
+
cssValue,
|
|
735
|
+
...!whenSelector && baseRuleFields(seg),
|
|
736
|
+
whenSelector
|
|
235
737
|
});
|
|
236
738
|
}
|
|
237
739
|
}
|
|
238
740
|
}
|
|
239
|
-
function
|
|
240
|
-
const
|
|
241
|
-
const prefix = whenPrefix(wp);
|
|
242
|
-
const segmentBaseKey = seg.key.split("__")[0];
|
|
243
|
-
const mClass = markerClassName(wp.markerNode);
|
|
741
|
+
function collectVariableRules(rules, seg, mapping) {
|
|
742
|
+
const { prefix, whenSelector } = segmentContext(seg, mapping);
|
|
244
743
|
for (const prop of seg.variableProps) {
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const varName = toCssVariableName(className, baseKey, prop);
|
|
744
|
+
const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;
|
|
745
|
+
const varName = toCssVariableName(className, seg.abbr, prop);
|
|
248
746
|
const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };
|
|
249
747
|
const existingRule = rules.get(className);
|
|
250
748
|
if (!existingRule) {
|
|
@@ -254,11 +752,8 @@ function collectWhenVariableRules(rules, seg, mapping) {
|
|
|
254
752
|
cssValue: declaration.cssValue,
|
|
255
753
|
declarations: [declaration],
|
|
256
754
|
cssVarName: varName,
|
|
257
|
-
whenSelector
|
|
258
|
-
|
|
259
|
-
markerClass: mClass,
|
|
260
|
-
pseudo: wp.pseudo
|
|
261
|
-
}
|
|
755
|
+
...!whenSelector && baseRuleFields(seg),
|
|
756
|
+
whenSelector
|
|
262
757
|
});
|
|
263
758
|
continue;
|
|
264
759
|
}
|
|
@@ -277,121 +772,26 @@ function collectWhenVariableRules(rules, seg, mapping) {
|
|
|
277
772
|
}
|
|
278
773
|
if (seg.variableExtraDefs) {
|
|
279
774
|
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
280
|
-
const
|
|
775
|
+
const extraBase = `${seg.abbr}_${cssProp}`;
|
|
776
|
+
const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
|
|
281
777
|
if (!rules.has(extraName)) {
|
|
282
778
|
rules.set(extraName, {
|
|
283
779
|
className: extraName,
|
|
284
780
|
cssProperty: camelToKebab(cssProp),
|
|
285
781
|
cssValue: String(value),
|
|
286
|
-
whenSelector
|
|
287
|
-
|
|
288
|
-
markerClass: mClass,
|
|
289
|
-
pseudo: wp.pseudo
|
|
290
|
-
}
|
|
782
|
+
...!whenSelector && baseRuleFields(seg),
|
|
783
|
+
whenSelector
|
|
291
784
|
});
|
|
292
785
|
}
|
|
293
786
|
}
|
|
294
787
|
}
|
|
295
788
|
}
|
|
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
789
|
function generateCssText(rules) {
|
|
324
790
|
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
|
-
}
|
|
791
|
+
sortRulesByPriority(allRules);
|
|
364
792
|
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));
|
|
793
|
+
for (const rule of allRules) {
|
|
794
|
+
lines.push(formatRule(rule));
|
|
395
795
|
}
|
|
396
796
|
for (const rule of allRules) {
|
|
397
797
|
for (const declaration of getRuleDeclarations(rule)) {
|
|
@@ -405,29 +805,15 @@ function generateCssText(rules) {
|
|
|
405
805
|
}
|
|
406
806
|
return lines.join("\n");
|
|
407
807
|
}
|
|
408
|
-
function
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const rightIsVariable = isVariableRule(right.rule);
|
|
418
|
-
if (leftIsVariable !== rightIsVariable) {
|
|
419
|
-
return leftIsVariable ? 1 : -1;
|
|
420
|
-
}
|
|
421
|
-
return left.index - right.index;
|
|
422
|
-
});
|
|
423
|
-
for (let i = 0; i < indexedRules.length; i++) {
|
|
424
|
-
rules[i] = indexedRules[i].rule;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
function isVariableRule(rule) {
|
|
428
|
-
return getRuleDeclarations(rule).some(function(declaration) {
|
|
429
|
-
return declaration.cssVarName !== void 0;
|
|
430
|
-
});
|
|
808
|
+
function formatRule(rule) {
|
|
809
|
+
if (rule.whenSelector) return formatWhenRule(rule);
|
|
810
|
+
if (rule.mediaQuery && rule.pseudoClass) return formatMediaPseudoRule(rule);
|
|
811
|
+
if (rule.mediaQuery && rule.pseudoElement) return formatMediaPseudoElementRule(rule);
|
|
812
|
+
if (rule.mediaQuery) return formatMediaRule(rule);
|
|
813
|
+
if (rule.pseudoClass && rule.pseudoElement) return formatPseudoRule(rule);
|
|
814
|
+
if (rule.pseudoElement) return formatPseudoElementRule(rule);
|
|
815
|
+
if (rule.pseudoClass) return formatPseudoRule(rule);
|
|
816
|
+
return formatBaseRule(rule);
|
|
431
817
|
}
|
|
432
818
|
function formatBaseRule(rule) {
|
|
433
819
|
return formatRuleBlock(`.${rule.className}`, rule);
|
|
@@ -498,13 +884,11 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
498
884
|
const propGroups = /* @__PURE__ */ new Map();
|
|
499
885
|
for (const seg of segments) {
|
|
500
886
|
if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;
|
|
887
|
+
const { prefix } = segmentContext(seg, mapping);
|
|
501
888
|
if (seg.variableProps) {
|
|
502
|
-
const prefix = seg.whenPseudo ? whenPrefix(seg.whenPseudo) : conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);
|
|
503
|
-
const segmentBaseKey = seg.key.split("__")[0];
|
|
504
889
|
for (const prop of seg.variableProps) {
|
|
505
|
-
const
|
|
506
|
-
const
|
|
507
|
-
const varName = toCssVariableName(className, baseKey, prop);
|
|
890
|
+
const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;
|
|
891
|
+
const varName = toCssVariableName(className, seg.abbr, prop);
|
|
508
892
|
if (!propGroups.has(prop)) propGroups.set(prop, []);
|
|
509
893
|
propGroups.get(prop).push({
|
|
510
894
|
className,
|
|
@@ -517,19 +901,15 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
517
901
|
}
|
|
518
902
|
if (seg.variableExtraDefs) {
|
|
519
903
|
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
520
|
-
const extraBase = `${
|
|
904
|
+
const extraBase = `${seg.abbr}_${cssProp}`;
|
|
521
905
|
const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
|
|
522
906
|
if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
|
|
523
907
|
propGroups.get(cssProp).push({ className: extraName, isVariable: false });
|
|
524
908
|
}
|
|
525
909
|
}
|
|
526
910
|
} else {
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
const isMultiProp = Object.keys(rawDefs).length > 1;
|
|
530
|
-
for (const cssProp of Object.keys(rawDefs)) {
|
|
531
|
-
const val = extractLeafValue(rawDefs[cssProp]);
|
|
532
|
-
if (val === null) continue;
|
|
911
|
+
const isMultiProp = Object.keys(seg.defs).length > 1;
|
|
912
|
+
for (const [cssProp, val] of Object.entries(seg.defs)) {
|
|
533
913
|
const baseName = computeStaticBaseName(seg, cssProp, String(val), isMultiProp, mapping);
|
|
534
914
|
const className = prefix ? `${prefix}${baseName}` : baseName;
|
|
535
915
|
if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
|
|
@@ -565,8 +945,8 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
565
945
|
}
|
|
566
946
|
function toCssVariableName(className, baseKey, cssProp) {
|
|
567
947
|
const baseClassName = `${baseKey}_var`;
|
|
568
|
-
const
|
|
569
|
-
return `--${
|
|
948
|
+
const cp = className.endsWith(baseClassName) ? className.slice(0, -baseClassName.length) : "";
|
|
949
|
+
return `--${cp}${cssProp}`;
|
|
570
950
|
}
|
|
571
951
|
function buildMaybeIncDeclaration(helperName, increment) {
|
|
572
952
|
const incParam = t.identifier("inc");
|
|
@@ -611,7 +991,7 @@ import * as t4 from "@babel/types";
|
|
|
611
991
|
import { basename } from "path";
|
|
612
992
|
|
|
613
993
|
// src/plugin/resolve-chain.ts
|
|
614
|
-
function resolveFullChain(chain, mapping
|
|
994
|
+
function resolveFullChain(chain, mapping) {
|
|
615
995
|
const parts = [];
|
|
616
996
|
const markers = [];
|
|
617
997
|
const filteredChain = [];
|
|
@@ -639,22 +1019,14 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
639
1019
|
const elseIndex = findElseIndex(filteredChain, i + 1);
|
|
640
1020
|
if (elseIndex !== -1) {
|
|
641
1021
|
if (currentNodes.length > 0) {
|
|
642
|
-
|
|
643
|
-
parts.push({
|
|
644
|
-
type: "unconditional",
|
|
645
|
-
segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs)
|
|
646
|
-
});
|
|
1022
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
647
1023
|
currentNodes = [];
|
|
648
1024
|
}
|
|
649
1025
|
const thenNodes = mediaStart.thenNodes ? [...mediaStart.thenNodes, ...filteredChain.slice(i + 1, elseIndex)] : filteredChain.slice(i, elseIndex);
|
|
650
1026
|
const elseNodes = [makeMediaQueryNode(mediaStart.inverseMediaQuery), ...filteredChain.slice(elseIndex + 1)];
|
|
651
1027
|
const thenSegs = resolveChain(thenNodes, mapping);
|
|
652
1028
|
const elseSegs = resolveChain(elseNodes, mapping);
|
|
653
|
-
|
|
654
|
-
parts.push({
|
|
655
|
-
type: "unconditional",
|
|
656
|
-
segments: options?.skipMerge ? combinedSegs : mergeOverlappingConditions(combinedSegs)
|
|
657
|
-
});
|
|
1029
|
+
parts.push({ type: "unconditional", segments: [...thenSegs, ...elseSegs] });
|
|
658
1030
|
i = filteredChain.length;
|
|
659
1031
|
break;
|
|
660
1032
|
}
|
|
@@ -667,11 +1039,7 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
667
1039
|
continue;
|
|
668
1040
|
}
|
|
669
1041
|
if (currentNodes.length > 0) {
|
|
670
|
-
|
|
671
|
-
parts.push({
|
|
672
|
-
type: "unconditional",
|
|
673
|
-
segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs)
|
|
674
|
-
});
|
|
1042
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
675
1043
|
currentNodes = [];
|
|
676
1044
|
}
|
|
677
1045
|
const thenNodes = [];
|
|
@@ -699,8 +1067,8 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
699
1067
|
parts.push({
|
|
700
1068
|
type: "conditional",
|
|
701
1069
|
conditionNode: node.conditionNode,
|
|
702
|
-
thenSegments:
|
|
703
|
-
elseSegments:
|
|
1070
|
+
thenSegments: thenSegs,
|
|
1071
|
+
elseSegments: elseSegs
|
|
704
1072
|
});
|
|
705
1073
|
} else {
|
|
706
1074
|
currentNodes.push(node);
|
|
@@ -708,11 +1076,7 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
708
1076
|
}
|
|
709
1077
|
}
|
|
710
1078
|
if (currentNodes.length > 0) {
|
|
711
|
-
|
|
712
|
-
parts.push({
|
|
713
|
-
type: "unconditional",
|
|
714
|
-
segments: options?.skipMerge ? remainingSegs : mergeOverlappingConditions(remainingSegs)
|
|
715
|
-
});
|
|
1079
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
716
1080
|
}
|
|
717
1081
|
const segmentErrors = [];
|
|
718
1082
|
for (const part of parts) {
|
|
@@ -901,7 +1265,7 @@ function resolveChain(chain, mapping) {
|
|
|
901
1265
|
}
|
|
902
1266
|
} catch (err) {
|
|
903
1267
|
if (err instanceof UnsupportedPatternError) {
|
|
904
|
-
segments.push({
|
|
1268
|
+
segments.push({ abbr: "__error", defs: {}, error: err.message });
|
|
905
1269
|
} else {
|
|
906
1270
|
throw err;
|
|
907
1271
|
}
|
|
@@ -909,11 +1273,16 @@ function resolveChain(chain, mapping) {
|
|
|
909
1273
|
}
|
|
910
1274
|
return segments;
|
|
911
1275
|
}
|
|
912
|
-
function
|
|
1276
|
+
function typographyLookupKeySuffix(mediaQuery, pseudoClass, pseudoElement, breakpoints) {
|
|
913
1277
|
const parts = [];
|
|
914
|
-
if (pseudoElement) parts.push(
|
|
915
|
-
if (mediaQuery
|
|
916
|
-
|
|
1278
|
+
if (pseudoElement) parts.push(pseudoElement.replace(/^::/, ""));
|
|
1279
|
+
if (mediaQuery && breakpoints) {
|
|
1280
|
+
const bp = Object.entries(breakpoints).find(([, v]) => v === mediaQuery)?.[0];
|
|
1281
|
+
parts.push(bp ? bp.replace(/^if/, "").replace(/^./, (c) => c.toLowerCase()) : "mq");
|
|
1282
|
+
} else if (mediaQuery) {
|
|
1283
|
+
parts.push("mq");
|
|
1284
|
+
}
|
|
1285
|
+
if (pseudoClass) parts.push(pseudoClass.replace(/^:+/, "").replace(/-/g, "_"));
|
|
917
1286
|
return parts.join("_");
|
|
918
1287
|
}
|
|
919
1288
|
function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoElement) {
|
|
@@ -928,7 +1297,7 @@ function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoEle
|
|
|
928
1297
|
if (typography.length === 0) {
|
|
929
1298
|
throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);
|
|
930
1299
|
}
|
|
931
|
-
const suffix =
|
|
1300
|
+
const suffix = typographyLookupKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
932
1301
|
const lookupKey = suffix ? `typography__${suffix}` : "typography";
|
|
933
1302
|
const segmentsByName = {};
|
|
934
1303
|
for (const name of typography) {
|
|
@@ -936,7 +1305,7 @@ function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoEle
|
|
|
936
1305
|
}
|
|
937
1306
|
return [
|
|
938
1307
|
{
|
|
939
|
-
|
|
1308
|
+
abbr: lookupKey,
|
|
940
1309
|
defs: {},
|
|
941
1310
|
typographyLookup: {
|
|
942
1311
|
lookupKey,
|
|
@@ -962,32 +1331,13 @@ function resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoEl
|
|
|
962
1331
|
}
|
|
963
1332
|
return resolved;
|
|
964
1333
|
}
|
|
965
|
-
function wrapDefsWithConditions(defs, mediaQuery, pseudoClass) {
|
|
966
|
-
if (!mediaQuery && !pseudoClass) return defs;
|
|
967
|
-
const result = {};
|
|
968
|
-
for (const [prop, value] of Object.entries(defs)) {
|
|
969
|
-
if (pseudoClass && mediaQuery) {
|
|
970
|
-
result[prop] = { default: null, [pseudoClass]: { default: null, [mediaQuery]: value } };
|
|
971
|
-
} else if (pseudoClass) {
|
|
972
|
-
result[prop] = { default: null, [pseudoClass]: value };
|
|
973
|
-
} else {
|
|
974
|
-
result[prop] = { default: null, [mediaQuery]: value };
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
return result;
|
|
978
|
-
}
|
|
979
1334
|
function resolveEntry(abbr, entry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
980
1335
|
switch (entry.kind) {
|
|
981
1336
|
case "static": {
|
|
982
1337
|
if (whenPseudo) {
|
|
983
|
-
|
|
984
|
-
const key2 = `${abbr}__${suffix2}`;
|
|
985
|
-
return [{ key: key2, defs: entry.defs, whenPseudo }];
|
|
1338
|
+
return [{ abbr, defs: entry.defs, whenPseudo }];
|
|
986
1339
|
}
|
|
987
|
-
|
|
988
|
-
const key = suffix ? `${abbr}__${suffix}` : abbr;
|
|
989
|
-
const defs = pseudoElement ? { [pseudoElement]: wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass) } : wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass);
|
|
990
|
-
return [{ key, defs, mediaQuery, pseudoClass, pseudoElement }];
|
|
1340
|
+
return [{ abbr, defs: entry.defs, mediaQuery, pseudoClass, pseudoElement }];
|
|
991
1341
|
}
|
|
992
1342
|
case "alias": {
|
|
993
1343
|
const result = [];
|
|
@@ -1011,65 +1361,19 @@ function resolveVariableCall(abbr, entry, node, mapping, mediaQuery, pseudoClass
|
|
|
1011
1361
|
if (node.args.length !== 1) {
|
|
1012
1362
|
throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);
|
|
1013
1363
|
}
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
} else {
|
|
1028
|
-
const key = `${abbr}__${wpSuffix}`;
|
|
1029
|
-
return {
|
|
1030
|
-
key,
|
|
1031
|
-
defs: {},
|
|
1032
|
-
whenPseudo,
|
|
1033
|
-
variableProps: entry.props,
|
|
1034
|
-
incremented: entry.incremented,
|
|
1035
|
-
variableExtraDefs: entry.extraDefs,
|
|
1036
|
-
argNode: argAst
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
1041
|
-
if (literalValue !== null) {
|
|
1042
|
-
const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, "_");
|
|
1043
|
-
const key = suffix ? `${abbr}__${keySuffix}__${suffix}` : `${abbr}__${keySuffix}`;
|
|
1044
|
-
const defs = {};
|
|
1045
|
-
for (const prop of entry.props) {
|
|
1046
|
-
defs[prop] = literalValue;
|
|
1047
|
-
}
|
|
1048
|
-
if (entry.extraDefs) {
|
|
1049
|
-
Object.assign(defs, entry.extraDefs);
|
|
1050
|
-
}
|
|
1051
|
-
const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);
|
|
1052
|
-
return {
|
|
1053
|
-
key,
|
|
1054
|
-
defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,
|
|
1055
|
-
mediaQuery,
|
|
1056
|
-
pseudoClass,
|
|
1057
|
-
pseudoElement,
|
|
1058
|
-
argResolved: literalValue
|
|
1059
|
-
};
|
|
1060
|
-
} else {
|
|
1061
|
-
const key = suffix ? `${abbr}__${suffix}` : abbr;
|
|
1062
|
-
return {
|
|
1063
|
-
key,
|
|
1064
|
-
defs: {},
|
|
1065
|
-
mediaQuery,
|
|
1066
|
-
pseudoClass,
|
|
1067
|
-
variableProps: entry.props,
|
|
1068
|
-
incremented: entry.incremented,
|
|
1069
|
-
variableExtraDefs: entry.extraDefs,
|
|
1070
|
-
argNode: argAst
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1364
|
+
const literalValue = tryEvaluateLiteral(node.args[0], entry.incremented, mapping.increment);
|
|
1365
|
+
return buildParameterizedSegment({
|
|
1366
|
+
abbr,
|
|
1367
|
+
props: entry.props,
|
|
1368
|
+
incremented: entry.incremented,
|
|
1369
|
+
extraDefs: entry.extraDefs,
|
|
1370
|
+
argAst: node.args[0],
|
|
1371
|
+
literalValue,
|
|
1372
|
+
mediaQuery,
|
|
1373
|
+
pseudoClass,
|
|
1374
|
+
pseudoElement,
|
|
1375
|
+
whenPseudo
|
|
1376
|
+
});
|
|
1073
1377
|
}
|
|
1074
1378
|
function resolveDelegateCall(abbr, entry, node, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
1075
1379
|
const targetEntry = mapping.abbreviations[entry.target];
|
|
@@ -1079,68 +1383,58 @@ function resolveDelegateCall(abbr, entry, node, mapping, mediaQuery, pseudoClass
|
|
|
1079
1383
|
if (node.args.length !== 1) {
|
|
1080
1384
|
throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);
|
|
1081
1385
|
}
|
|
1082
|
-
const
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
defs: {},
|
|
1100
|
-
whenPseudo,
|
|
1101
|
-
variableProps: targetEntry.props,
|
|
1102
|
-
incremented: false,
|
|
1103
|
-
appendPx: true,
|
|
1104
|
-
variableExtraDefs: targetEntry.extraDefs,
|
|
1105
|
-
argNode: argAst
|
|
1106
|
-
};
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
1386
|
+
const literalValue = tryEvaluatePxLiteral(node.args[0]);
|
|
1387
|
+
return buildParameterizedSegment({
|
|
1388
|
+
abbr: entry.target,
|
|
1389
|
+
props: targetEntry.props,
|
|
1390
|
+
incremented: false,
|
|
1391
|
+
appendPx: true,
|
|
1392
|
+
extraDefs: targetEntry.extraDefs,
|
|
1393
|
+
argAst: node.args[0],
|
|
1394
|
+
literalValue,
|
|
1395
|
+
mediaQuery,
|
|
1396
|
+
pseudoClass,
|
|
1397
|
+
pseudoElement,
|
|
1398
|
+
whenPseudo
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
function buildParameterizedSegment(params) {
|
|
1402
|
+
const { abbr, props, incremented, appendPx, extraDefs, argAst, literalValue, whenPseudo } = params;
|
|
1110
1403
|
if (literalValue !== null) {
|
|
1111
|
-
const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, "_");
|
|
1112
|
-
const key = suffix ? `${entry.target}__${keySuffix}__${suffix}` : `${entry.target}__${keySuffix}`;
|
|
1113
1404
|
const defs = {};
|
|
1114
|
-
for (const prop of
|
|
1405
|
+
for (const prop of props) {
|
|
1115
1406
|
defs[prop] = literalValue;
|
|
1116
1407
|
}
|
|
1117
|
-
if (
|
|
1118
|
-
|
|
1408
|
+
if (extraDefs) Object.assign(defs, extraDefs);
|
|
1409
|
+
if (whenPseudo) {
|
|
1410
|
+
return { abbr, defs, whenPseudo, argResolved: literalValue };
|
|
1119
1411
|
}
|
|
1120
|
-
const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);
|
|
1121
1412
|
return {
|
|
1122
|
-
|
|
1123
|
-
defs
|
|
1124
|
-
mediaQuery,
|
|
1125
|
-
pseudoClass,
|
|
1126
|
-
pseudoElement,
|
|
1413
|
+
abbr,
|
|
1414
|
+
defs,
|
|
1415
|
+
mediaQuery: params.mediaQuery,
|
|
1416
|
+
pseudoClass: params.pseudoClass,
|
|
1417
|
+
pseudoElement: params.pseudoElement,
|
|
1127
1418
|
argResolved: literalValue
|
|
1128
1419
|
};
|
|
1420
|
+
}
|
|
1421
|
+
const base = {
|
|
1422
|
+
abbr,
|
|
1423
|
+
defs: {},
|
|
1424
|
+
variableProps: props,
|
|
1425
|
+
incremented,
|
|
1426
|
+
variableExtraDefs: extraDefs,
|
|
1427
|
+
argNode: argAst
|
|
1428
|
+
};
|
|
1429
|
+
if (appendPx) base.appendPx = true;
|
|
1430
|
+
if (whenPseudo) {
|
|
1431
|
+
base.whenPseudo = whenPseudo;
|
|
1129
1432
|
} else {
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
defs: {},
|
|
1134
|
-
mediaQuery,
|
|
1135
|
-
pseudoClass,
|
|
1136
|
-
pseudoElement,
|
|
1137
|
-
variableProps: targetEntry.props,
|
|
1138
|
-
incremented: false,
|
|
1139
|
-
appendPx: true,
|
|
1140
|
-
variableExtraDefs: targetEntry.extraDefs,
|
|
1141
|
-
argNode: argAst
|
|
1142
|
-
};
|
|
1433
|
+
base.mediaQuery = params.mediaQuery;
|
|
1434
|
+
base.pseudoClass = params.pseudoClass;
|
|
1435
|
+
base.pseudoElement = params.pseudoElement;
|
|
1143
1436
|
}
|
|
1437
|
+
return base;
|
|
1144
1438
|
}
|
|
1145
1439
|
function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
1146
1440
|
if (node.args.length === 1) {
|
|
@@ -1154,7 +1448,7 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
|
|
|
1154
1448
|
);
|
|
1155
1449
|
}
|
|
1156
1450
|
return {
|
|
1157
|
-
|
|
1451
|
+
abbr: "__composed_css_prop",
|
|
1158
1452
|
defs: {},
|
|
1159
1453
|
styleArrayArg: styleArg
|
|
1160
1454
|
};
|
|
@@ -1172,34 +1466,24 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
|
|
|
1172
1466
|
const valueArg = node.args[1];
|
|
1173
1467
|
const literalValue = tryEvaluateAddLiteral(valueArg);
|
|
1174
1468
|
if (whenPseudo) {
|
|
1175
|
-
const wpSuffix = whenPseudoKeyName(whenPseudo);
|
|
1176
1469
|
if (literalValue !== null) {
|
|
1177
|
-
|
|
1178
|
-
const key = `${propName}__${keySuffix}__${wpSuffix}`;
|
|
1179
|
-
return { key, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };
|
|
1470
|
+
return { abbr: propName, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };
|
|
1180
1471
|
} else {
|
|
1181
|
-
|
|
1182
|
-
return { key, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };
|
|
1472
|
+
return { abbr: propName, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };
|
|
1183
1473
|
}
|
|
1184
1474
|
}
|
|
1185
|
-
const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
1186
1475
|
if (literalValue !== null) {
|
|
1187
|
-
const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1188
|
-
const key = suffix ? `${propName}__${keySuffix}__${suffix}` : `${propName}__${keySuffix}`;
|
|
1189
|
-
const defs = { [propName]: literalValue };
|
|
1190
|
-
const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);
|
|
1191
1476
|
return {
|
|
1192
|
-
|
|
1193
|
-
defs:
|
|
1477
|
+
abbr: propName,
|
|
1478
|
+
defs: { [propName]: literalValue },
|
|
1194
1479
|
mediaQuery,
|
|
1195
1480
|
pseudoClass,
|
|
1196
1481
|
pseudoElement,
|
|
1197
1482
|
argResolved: literalValue
|
|
1198
1483
|
};
|
|
1199
1484
|
} else {
|
|
1200
|
-
const key = suffix ? `${propName}__${suffix}` : propName;
|
|
1201
1485
|
return {
|
|
1202
|
-
|
|
1486
|
+
abbr: propName,
|
|
1203
1487
|
defs: {},
|
|
1204
1488
|
mediaQuery,
|
|
1205
1489
|
pseudoClass,
|
|
@@ -1267,127 +1551,6 @@ function isPseudoMethod(name) {
|
|
|
1267
1551
|
function pseudoSelector(name) {
|
|
1268
1552
|
return PSEUDO_METHODS[name];
|
|
1269
1553
|
}
|
|
1270
|
-
function whenPseudoKeyName(ap) {
|
|
1271
|
-
const rel = ap.relationship ?? "ancestor";
|
|
1272
|
-
const pn = pseudoName(ap.pseudo);
|
|
1273
|
-
const base = `${rel}${pn.charAt(0).toUpperCase()}${pn.slice(1)}`;
|
|
1274
|
-
if (!ap.markerNode) return base;
|
|
1275
|
-
const suffix = ap.markerNode.type === "Identifier" ? ap.markerNode.name : "marker";
|
|
1276
|
-
return `${base}_${suffix}`;
|
|
1277
|
-
}
|
|
1278
|
-
function mergeOverlappingConditions(segments) {
|
|
1279
|
-
const propToIndices = /* @__PURE__ */ new Map();
|
|
1280
|
-
for (let i = 0; i < segments.length; i++) {
|
|
1281
|
-
const seg = segments[i];
|
|
1282
|
-
if (seg.variableProps || seg.styleArrayArg || seg.whenPseudo || seg.error) continue;
|
|
1283
|
-
for (const prop of Object.keys(seg.defs)) {
|
|
1284
|
-
if (!propToIndices.has(prop)) propToIndices.set(prop, []);
|
|
1285
|
-
propToIndices.get(prop).push(i);
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
const mergeableProps = /* @__PURE__ */ new Set();
|
|
1289
|
-
for (const [prop, indices] of propToIndices) {
|
|
1290
|
-
if (indices.length < 2) continue;
|
|
1291
|
-
const hasBase = indices.some((i) => !segments[i].mediaQuery && !segments[i].pseudoClass);
|
|
1292
|
-
const hasConditional = indices.some((i) => !!(segments[i].mediaQuery || segments[i].pseudoClass));
|
|
1293
|
-
if (hasBase && hasConditional) {
|
|
1294
|
-
mergeableProps.add(prop);
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
if (mergeableProps.size === 0) return segments;
|
|
1298
|
-
const consumedProps = /* @__PURE__ */ new Map();
|
|
1299
|
-
const mergedPropDefs = /* @__PURE__ */ new Map();
|
|
1300
|
-
for (const prop of mergeableProps) {
|
|
1301
|
-
const indices = propToIndices.get(prop);
|
|
1302
|
-
let merged = {};
|
|
1303
|
-
const keyParts = [];
|
|
1304
|
-
for (const idx of indices) {
|
|
1305
|
-
const seg = segments[idx];
|
|
1306
|
-
const value = seg.defs[prop];
|
|
1307
|
-
keyParts.push(seg.key);
|
|
1308
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
1309
|
-
merged.default = value;
|
|
1310
|
-
} else if (typeof value === "object" && value !== null) {
|
|
1311
|
-
for (const [k, v] of Object.entries(value)) {
|
|
1312
|
-
if (k === "default" && v === null && merged.default !== void 0) {
|
|
1313
|
-
continue;
|
|
1314
|
-
}
|
|
1315
|
-
merged[k] = v;
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
if (!consumedProps.has(idx)) consumedProps.set(idx, /* @__PURE__ */ new Set());
|
|
1319
|
-
consumedProps.get(idx).add(prop);
|
|
1320
|
-
}
|
|
1321
|
-
const finalValue = Object.keys(merged).length === 1 && "default" in merged ? merged.default : merged;
|
|
1322
|
-
const mergedKey = [...new Set(keyParts)].join("_");
|
|
1323
|
-
mergedPropDefs.set(prop, { defs: { [prop]: finalValue }, key: mergedKey });
|
|
1324
|
-
}
|
|
1325
|
-
const groupByIndices = /* @__PURE__ */ new Map();
|
|
1326
|
-
for (const prop of mergeableProps) {
|
|
1327
|
-
const indices = propToIndices.get(prop);
|
|
1328
|
-
const groupKey = indices.join(",");
|
|
1329
|
-
if (!groupByIndices.has(groupKey)) {
|
|
1330
|
-
groupByIndices.set(groupKey, { props: [], key: mergedPropDefs.get(prop).key });
|
|
1331
|
-
}
|
|
1332
|
-
groupByIndices.get(groupKey).props.push(prop);
|
|
1333
|
-
}
|
|
1334
|
-
const mergedSegments = [];
|
|
1335
|
-
for (const [, group] of groupByIndices) {
|
|
1336
|
-
const defs = {};
|
|
1337
|
-
for (const prop of group.props) {
|
|
1338
|
-
Object.assign(defs, mergedPropDefs.get(prop).defs);
|
|
1339
|
-
}
|
|
1340
|
-
mergedSegments.push({ key: group.key, defs });
|
|
1341
|
-
}
|
|
1342
|
-
const result = [];
|
|
1343
|
-
const mergedEmitted = /* @__PURE__ */ new Set();
|
|
1344
|
-
for (let i = 0; i < segments.length; i++) {
|
|
1345
|
-
const seg = segments[i];
|
|
1346
|
-
const consumed = consumedProps.get(i);
|
|
1347
|
-
if (!consumed) {
|
|
1348
|
-
result.push(seg);
|
|
1349
|
-
continue;
|
|
1350
|
-
}
|
|
1351
|
-
const remainingDefs = {};
|
|
1352
|
-
for (const [prop, value] of Object.entries(seg.defs)) {
|
|
1353
|
-
if (!consumed.has(prop)) {
|
|
1354
|
-
remainingDefs[prop] = value;
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
if (Object.keys(remainingDefs).length > 0) {
|
|
1358
|
-
result.push({ ...seg, defs: remainingDefs });
|
|
1359
|
-
}
|
|
1360
|
-
const indices = [...propToIndices.entries()].filter(([prop]) => consumed.has(prop) && mergeableProps.has(prop)).map(([, idxs]) => idxs.join(","));
|
|
1361
|
-
for (const groupKey of new Set(indices)) {
|
|
1362
|
-
if (!mergedEmitted.has(groupKey)) {
|
|
1363
|
-
const group = groupByIndices.get(groupKey);
|
|
1364
|
-
if (group) {
|
|
1365
|
-
const defs = {};
|
|
1366
|
-
for (const prop of group.props) {
|
|
1367
|
-
Object.assign(defs, mergedPropDefs.get(prop).defs);
|
|
1368
|
-
}
|
|
1369
|
-
result.push({ key: group.key, defs });
|
|
1370
|
-
mergedEmitted.add(groupKey);
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
return result;
|
|
1376
|
-
}
|
|
1377
|
-
function pseudoName(pseudo, breakpoints) {
|
|
1378
|
-
if (pseudo.startsWith("@media") && breakpoints) {
|
|
1379
|
-
for (const [getterName, mediaQuery] of Object.entries(breakpoints)) {
|
|
1380
|
-
if (mediaQuery === pseudo) {
|
|
1381
|
-
return getterName.replace(/^if/, "").replace(/^./, (c) => c.toLowerCase());
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
return pseudo.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1385
|
-
}
|
|
1386
|
-
if (pseudo.startsWith("@container")) {
|
|
1387
|
-
return pseudo.replace(/^@container\s*/, "container ").replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1388
|
-
}
|
|
1389
|
-
return pseudo.replace(/^:+/, "").replace(/-/g, "_");
|
|
1390
|
-
}
|
|
1391
1554
|
function tryEvaluateLiteral(node, incremented, increment) {
|
|
1392
1555
|
if (node.type === "NumericLiteral") {
|
|
1393
1556
|
if (incremented) {
|
|
@@ -2066,7 +2229,7 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2066
2229
|
if (parentPath && parentPath.isMemberExpression() && t4.isIdentifier(parentPath.node.property, { name: "$" })) {
|
|
2067
2230
|
return;
|
|
2068
2231
|
}
|
|
2069
|
-
const resolvedChain = resolveFullChain(chain, mapping
|
|
2232
|
+
const resolvedChain = resolveFullChain(chain, mapping);
|
|
2070
2233
|
sites.push({ path, resolvedChain });
|
|
2071
2234
|
const line = path.node.loc?.start.line ?? null;
|
|
2072
2235
|
for (const err of resolvedChain.errors) {
|
|
@@ -2109,7 +2272,6 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2109
2272
|
needsTrussPropsHelper,
|
|
2110
2273
|
trussDebugInfoName,
|
|
2111
2274
|
needsTrussDebugInfo,
|
|
2112
|
-
skippedCssPropMessages: errorMessages,
|
|
2113
2275
|
runtimeLookupNames
|
|
2114
2276
|
});
|
|
2115
2277
|
const runtimeImports = [];
|
|
@@ -2404,7 +2566,7 @@ function resolveCssExpression(node, cssBindingName, mapping, filename) {
|
|
|
2404
2566
|
}
|
|
2405
2567
|
for (const [prop, value] of Object.entries(seg.defs)) {
|
|
2406
2568
|
if (typeof value === "string" || typeof value === "number") {
|
|
2407
|
-
declarations.push({ property:
|
|
2569
|
+
declarations.push({ property: camelToKebab(prop), value: String(value) });
|
|
2408
2570
|
} else {
|
|
2409
2571
|
return { error: `unexpected nested value for property "${prop}"` };
|
|
2410
2572
|
}
|
|
@@ -2413,9 +2575,6 @@ function resolveCssExpression(node, cssBindingName, mapping, filename) {
|
|
|
2413
2575
|
}
|
|
2414
2576
|
return { declarations };
|
|
2415
2577
|
}
|
|
2416
|
-
function camelToKebab2(s) {
|
|
2417
|
-
return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
2418
|
-
}
|
|
2419
2578
|
function formatCssRule(selector, declarations) {
|
|
2420
2579
|
if (declarations.length === 0) {
|
|
2421
2580
|
return `${selector} {}`;
|
|
@@ -2543,8 +2702,8 @@ function trussPlugin(opts) {
|
|
|
2543
2702
|
},
|
|
2544
2703
|
transformIndexHtml(html) {
|
|
2545
2704
|
if (isBuild) return html;
|
|
2546
|
-
const
|
|
2547
|
-
return html.replace("</head>", ` ${
|
|
2705
|
+
const tag = `<script type="module" src="/${VIRTUAL_RUNTIME_ID}"></script>`;
|
|
2706
|
+
return html.replace("</head>", ` ${tag}
|
|
2548
2707
|
</head>`);
|
|
2549
2708
|
},
|
|
2550
2709
|
handleHotUpdate(ctx) {
|