@homebound/truss 2.1.0-next.8 → 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 -575
- 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,41 +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
|
-
}
|
|
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
|
-
});
|
|
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);
|
|
443
817
|
}
|
|
444
818
|
function formatBaseRule(rule) {
|
|
445
819
|
return formatRuleBlock(`.${rule.className}`, rule);
|
|
@@ -510,13 +884,11 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
510
884
|
const propGroups = /* @__PURE__ */ new Map();
|
|
511
885
|
for (const seg of segments) {
|
|
512
886
|
if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;
|
|
887
|
+
const { prefix } = segmentContext(seg, mapping);
|
|
513
888
|
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
889
|
for (const prop of seg.variableProps) {
|
|
517
|
-
const
|
|
518
|
-
const
|
|
519
|
-
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);
|
|
520
892
|
if (!propGroups.has(prop)) propGroups.set(prop, []);
|
|
521
893
|
propGroups.get(prop).push({
|
|
522
894
|
className,
|
|
@@ -529,19 +901,15 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
529
901
|
}
|
|
530
902
|
if (seg.variableExtraDefs) {
|
|
531
903
|
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
532
|
-
const extraBase = `${
|
|
904
|
+
const extraBase = `${seg.abbr}_${cssProp}`;
|
|
533
905
|
const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
|
|
534
906
|
if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
|
|
535
907
|
propGroups.get(cssProp).push({ className: extraName, isVariable: false });
|
|
536
908
|
}
|
|
537
909
|
}
|
|
538
910
|
} 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;
|
|
911
|
+
const isMultiProp = Object.keys(seg.defs).length > 1;
|
|
912
|
+
for (const [cssProp, val] of Object.entries(seg.defs)) {
|
|
545
913
|
const baseName = computeStaticBaseName(seg, cssProp, String(val), isMultiProp, mapping);
|
|
546
914
|
const className = prefix ? `${prefix}${baseName}` : baseName;
|
|
547
915
|
if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
|
|
@@ -577,8 +945,8 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
577
945
|
}
|
|
578
946
|
function toCssVariableName(className, baseKey, cssProp) {
|
|
579
947
|
const baseClassName = `${baseKey}_var`;
|
|
580
|
-
const
|
|
581
|
-
return `--${
|
|
948
|
+
const cp = className.endsWith(baseClassName) ? className.slice(0, -baseClassName.length) : "";
|
|
949
|
+
return `--${cp}${cssProp}`;
|
|
582
950
|
}
|
|
583
951
|
function buildMaybeIncDeclaration(helperName, increment) {
|
|
584
952
|
const incParam = t.identifier("inc");
|
|
@@ -623,7 +991,7 @@ import * as t4 from "@babel/types";
|
|
|
623
991
|
import { basename } from "path";
|
|
624
992
|
|
|
625
993
|
// src/plugin/resolve-chain.ts
|
|
626
|
-
function resolveFullChain(chain, mapping
|
|
994
|
+
function resolveFullChain(chain, mapping) {
|
|
627
995
|
const parts = [];
|
|
628
996
|
const markers = [];
|
|
629
997
|
const filteredChain = [];
|
|
@@ -651,22 +1019,14 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
651
1019
|
const elseIndex = findElseIndex(filteredChain, i + 1);
|
|
652
1020
|
if (elseIndex !== -1) {
|
|
653
1021
|
if (currentNodes.length > 0) {
|
|
654
|
-
|
|
655
|
-
parts.push({
|
|
656
|
-
type: "unconditional",
|
|
657
|
-
segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs)
|
|
658
|
-
});
|
|
1022
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
659
1023
|
currentNodes = [];
|
|
660
1024
|
}
|
|
661
1025
|
const thenNodes = mediaStart.thenNodes ? [...mediaStart.thenNodes, ...filteredChain.slice(i + 1, elseIndex)] : filteredChain.slice(i, elseIndex);
|
|
662
1026
|
const elseNodes = [makeMediaQueryNode(mediaStart.inverseMediaQuery), ...filteredChain.slice(elseIndex + 1)];
|
|
663
1027
|
const thenSegs = resolveChain(thenNodes, mapping);
|
|
664
1028
|
const elseSegs = resolveChain(elseNodes, mapping);
|
|
665
|
-
|
|
666
|
-
parts.push({
|
|
667
|
-
type: "unconditional",
|
|
668
|
-
segments: options?.skipMerge ? combinedSegs : mergeOverlappingConditions(combinedSegs)
|
|
669
|
-
});
|
|
1029
|
+
parts.push({ type: "unconditional", segments: [...thenSegs, ...elseSegs] });
|
|
670
1030
|
i = filteredChain.length;
|
|
671
1031
|
break;
|
|
672
1032
|
}
|
|
@@ -679,11 +1039,7 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
679
1039
|
continue;
|
|
680
1040
|
}
|
|
681
1041
|
if (currentNodes.length > 0) {
|
|
682
|
-
|
|
683
|
-
parts.push({
|
|
684
|
-
type: "unconditional",
|
|
685
|
-
segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs)
|
|
686
|
-
});
|
|
1042
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
687
1043
|
currentNodes = [];
|
|
688
1044
|
}
|
|
689
1045
|
const thenNodes = [];
|
|
@@ -711,8 +1067,8 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
711
1067
|
parts.push({
|
|
712
1068
|
type: "conditional",
|
|
713
1069
|
conditionNode: node.conditionNode,
|
|
714
|
-
thenSegments:
|
|
715
|
-
elseSegments:
|
|
1070
|
+
thenSegments: thenSegs,
|
|
1071
|
+
elseSegments: elseSegs
|
|
716
1072
|
});
|
|
717
1073
|
} else {
|
|
718
1074
|
currentNodes.push(node);
|
|
@@ -720,11 +1076,7 @@ function resolveFullChain(chain, mapping, options) {
|
|
|
720
1076
|
}
|
|
721
1077
|
}
|
|
722
1078
|
if (currentNodes.length > 0) {
|
|
723
|
-
|
|
724
|
-
parts.push({
|
|
725
|
-
type: "unconditional",
|
|
726
|
-
segments: options?.skipMerge ? remainingSegs : mergeOverlappingConditions(remainingSegs)
|
|
727
|
-
});
|
|
1079
|
+
parts.push({ type: "unconditional", segments: resolveChain(currentNodes, mapping) });
|
|
728
1080
|
}
|
|
729
1081
|
const segmentErrors = [];
|
|
730
1082
|
for (const part of parts) {
|
|
@@ -913,7 +1265,7 @@ function resolveChain(chain, mapping) {
|
|
|
913
1265
|
}
|
|
914
1266
|
} catch (err) {
|
|
915
1267
|
if (err instanceof UnsupportedPatternError) {
|
|
916
|
-
segments.push({
|
|
1268
|
+
segments.push({ abbr: "__error", defs: {}, error: err.message });
|
|
917
1269
|
} else {
|
|
918
1270
|
throw err;
|
|
919
1271
|
}
|
|
@@ -921,11 +1273,16 @@ function resolveChain(chain, mapping) {
|
|
|
921
1273
|
}
|
|
922
1274
|
return segments;
|
|
923
1275
|
}
|
|
924
|
-
function
|
|
1276
|
+
function typographyLookupKeySuffix(mediaQuery, pseudoClass, pseudoElement, breakpoints) {
|
|
925
1277
|
const parts = [];
|
|
926
|
-
if (pseudoElement) parts.push(
|
|
927
|
-
if (mediaQuery
|
|
928
|
-
|
|
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, "_"));
|
|
929
1286
|
return parts.join("_");
|
|
930
1287
|
}
|
|
931
1288
|
function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoElement) {
|
|
@@ -940,7 +1297,7 @@ function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoEle
|
|
|
940
1297
|
if (typography.length === 0) {
|
|
941
1298
|
throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);
|
|
942
1299
|
}
|
|
943
|
-
const suffix =
|
|
1300
|
+
const suffix = typographyLookupKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
944
1301
|
const lookupKey = suffix ? `typography__${suffix}` : "typography";
|
|
945
1302
|
const segmentsByName = {};
|
|
946
1303
|
for (const name of typography) {
|
|
@@ -948,7 +1305,7 @@ function resolveTypographyCall(node, mapping, mediaQuery, pseudoClass, pseudoEle
|
|
|
948
1305
|
}
|
|
949
1306
|
return [
|
|
950
1307
|
{
|
|
951
|
-
|
|
1308
|
+
abbr: lookupKey,
|
|
952
1309
|
defs: {},
|
|
953
1310
|
typographyLookup: {
|
|
954
1311
|
lookupKey,
|
|
@@ -974,32 +1331,13 @@ function resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoEl
|
|
|
974
1331
|
}
|
|
975
1332
|
return resolved;
|
|
976
1333
|
}
|
|
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
1334
|
function resolveEntry(abbr, entry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
992
1335
|
switch (entry.kind) {
|
|
993
1336
|
case "static": {
|
|
994
1337
|
if (whenPseudo) {
|
|
995
|
-
|
|
996
|
-
const key2 = `${abbr}__${suffix2}`;
|
|
997
|
-
return [{ key: key2, defs: entry.defs, whenPseudo }];
|
|
1338
|
+
return [{ abbr, defs: entry.defs, whenPseudo }];
|
|
998
1339
|
}
|
|
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 }];
|
|
1340
|
+
return [{ abbr, defs: entry.defs, mediaQuery, pseudoClass, pseudoElement }];
|
|
1003
1341
|
}
|
|
1004
1342
|
case "alias": {
|
|
1005
1343
|
const result = [];
|
|
@@ -1023,65 +1361,19 @@ function resolveVariableCall(abbr, entry, node, mapping, mediaQuery, pseudoClass
|
|
|
1023
1361
|
if (node.args.length !== 1) {
|
|
1024
1362
|
throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);
|
|
1025
1363
|
}
|
|
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
|
-
}
|
|
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
|
+
});
|
|
1085
1377
|
}
|
|
1086
1378
|
function resolveDelegateCall(abbr, entry, node, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
1087
1379
|
const targetEntry = mapping.abbreviations[entry.target];
|
|
@@ -1091,68 +1383,58 @@ function resolveDelegateCall(abbr, entry, node, mapping, mediaQuery, pseudoClass
|
|
|
1091
1383
|
if (node.args.length !== 1) {
|
|
1092
1384
|
throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);
|
|
1093
1385
|
}
|
|
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);
|
|
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;
|
|
1122
1403
|
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
1404
|
const defs = {};
|
|
1126
|
-
for (const prop of
|
|
1405
|
+
for (const prop of props) {
|
|
1127
1406
|
defs[prop] = literalValue;
|
|
1128
1407
|
}
|
|
1129
|
-
if (
|
|
1130
|
-
|
|
1408
|
+
if (extraDefs) Object.assign(defs, extraDefs);
|
|
1409
|
+
if (whenPseudo) {
|
|
1410
|
+
return { abbr, defs, whenPseudo, argResolved: literalValue };
|
|
1131
1411
|
}
|
|
1132
|
-
const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);
|
|
1133
1412
|
return {
|
|
1134
|
-
|
|
1135
|
-
defs
|
|
1136
|
-
mediaQuery,
|
|
1137
|
-
pseudoClass,
|
|
1138
|
-
pseudoElement,
|
|
1413
|
+
abbr,
|
|
1414
|
+
defs,
|
|
1415
|
+
mediaQuery: params.mediaQuery,
|
|
1416
|
+
pseudoClass: params.pseudoClass,
|
|
1417
|
+
pseudoElement: params.pseudoElement,
|
|
1139
1418
|
argResolved: literalValue
|
|
1140
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;
|
|
1141
1432
|
} 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
|
-
};
|
|
1433
|
+
base.mediaQuery = params.mediaQuery;
|
|
1434
|
+
base.pseudoClass = params.pseudoClass;
|
|
1435
|
+
base.pseudoElement = params.pseudoElement;
|
|
1155
1436
|
}
|
|
1437
|
+
return base;
|
|
1156
1438
|
}
|
|
1157
1439
|
function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
|
|
1158
1440
|
if (node.args.length === 1) {
|
|
@@ -1166,7 +1448,7 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
|
|
|
1166
1448
|
);
|
|
1167
1449
|
}
|
|
1168
1450
|
return {
|
|
1169
|
-
|
|
1451
|
+
abbr: "__composed_css_prop",
|
|
1170
1452
|
defs: {},
|
|
1171
1453
|
styleArrayArg: styleArg
|
|
1172
1454
|
};
|
|
@@ -1184,34 +1466,24 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
|
|
|
1184
1466
|
const valueArg = node.args[1];
|
|
1185
1467
|
const literalValue = tryEvaluateAddLiteral(valueArg);
|
|
1186
1468
|
if (whenPseudo) {
|
|
1187
|
-
const wpSuffix = whenPseudoKeyName(whenPseudo);
|
|
1188
1469
|
if (literalValue !== null) {
|
|
1189
|
-
|
|
1190
|
-
const key = `${propName}__${keySuffix}__${wpSuffix}`;
|
|
1191
|
-
return { key, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };
|
|
1470
|
+
return { abbr: propName, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };
|
|
1192
1471
|
} else {
|
|
1193
|
-
|
|
1194
|
-
return { key, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };
|
|
1472
|
+
return { abbr: propName, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };
|
|
1195
1473
|
}
|
|
1196
1474
|
}
|
|
1197
|
-
const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
1198
1475
|
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
1476
|
return {
|
|
1204
|
-
|
|
1205
|
-
defs:
|
|
1477
|
+
abbr: propName,
|
|
1478
|
+
defs: { [propName]: literalValue },
|
|
1206
1479
|
mediaQuery,
|
|
1207
1480
|
pseudoClass,
|
|
1208
1481
|
pseudoElement,
|
|
1209
1482
|
argResolved: literalValue
|
|
1210
1483
|
};
|
|
1211
1484
|
} else {
|
|
1212
|
-
const key = suffix ? `${propName}__${suffix}` : propName;
|
|
1213
1485
|
return {
|
|
1214
|
-
|
|
1486
|
+
abbr: propName,
|
|
1215
1487
|
defs: {},
|
|
1216
1488
|
mediaQuery,
|
|
1217
1489
|
pseudoClass,
|
|
@@ -1279,127 +1551,6 @@ function isPseudoMethod(name) {
|
|
|
1279
1551
|
function pseudoSelector(name) {
|
|
1280
1552
|
return PSEUDO_METHODS[name];
|
|
1281
1553
|
}
|
|
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
1554
|
function tryEvaluateLiteral(node, incremented, increment) {
|
|
1404
1555
|
if (node.type === "NumericLiteral") {
|
|
1405
1556
|
if (incremented) {
|
|
@@ -2078,7 +2229,7 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2078
2229
|
if (parentPath && parentPath.isMemberExpression() && t4.isIdentifier(parentPath.node.property, { name: "$" })) {
|
|
2079
2230
|
return;
|
|
2080
2231
|
}
|
|
2081
|
-
const resolvedChain = resolveFullChain(chain, mapping
|
|
2232
|
+
const resolvedChain = resolveFullChain(chain, mapping);
|
|
2082
2233
|
sites.push({ path, resolvedChain });
|
|
2083
2234
|
const line = path.node.loc?.start.line ?? null;
|
|
2084
2235
|
for (const err of resolvedChain.errors) {
|
|
@@ -2121,7 +2272,6 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2121
2272
|
needsTrussPropsHelper,
|
|
2122
2273
|
trussDebugInfoName,
|
|
2123
2274
|
needsTrussDebugInfo,
|
|
2124
|
-
skippedCssPropMessages: errorMessages,
|
|
2125
2275
|
runtimeLookupNames
|
|
2126
2276
|
});
|
|
2127
2277
|
const runtimeImports = [];
|
|
@@ -2416,7 +2566,7 @@ function resolveCssExpression(node, cssBindingName, mapping, filename) {
|
|
|
2416
2566
|
}
|
|
2417
2567
|
for (const [prop, value] of Object.entries(seg.defs)) {
|
|
2418
2568
|
if (typeof value === "string" || typeof value === "number") {
|
|
2419
|
-
declarations.push({ property:
|
|
2569
|
+
declarations.push({ property: camelToKebab(prop), value: String(value) });
|
|
2420
2570
|
} else {
|
|
2421
2571
|
return { error: `unexpected nested value for property "${prop}"` };
|
|
2422
2572
|
}
|
|
@@ -2425,9 +2575,6 @@ function resolveCssExpression(node, cssBindingName, mapping, filename) {
|
|
|
2425
2575
|
}
|
|
2426
2576
|
return { declarations };
|
|
2427
2577
|
}
|
|
2428
|
-
function camelToKebab2(s) {
|
|
2429
|
-
return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
2430
|
-
}
|
|
2431
2578
|
function formatCssRule(selector, declarations) {
|
|
2432
2579
|
if (declarations.length === 0) {
|
|
2433
2580
|
return `${selector} {}`;
|
|
@@ -2555,8 +2702,8 @@ function trussPlugin(opts) {
|
|
|
2555
2702
|
},
|
|
2556
2703
|
transformIndexHtml(html) {
|
|
2557
2704
|
if (isBuild) return html;
|
|
2558
|
-
const
|
|
2559
|
-
return html.replace("</head>", ` ${
|
|
2705
|
+
const tag = `<script type="module" src="/${VIRTUAL_RUNTIME_ID}"></script>`;
|
|
2706
|
+
return html.replace("</head>", ` ${tag}
|
|
2560
2707
|
</head>`);
|
|
2561
2708
|
},
|
|
2562
2709
|
handleHotUpdate(ctx) {
|