@webstudio-is/css-engine 0.191.4 → 0.192.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +953 -0
- package/lib/types/__generated__/types.d.ts +2 -0
- package/lib/types/core/atomic.d.ts +14 -0
- package/lib/types/core/atomic.test.d.ts +1 -0
- package/lib/types/core/compare-media.d.ts +6 -0
- package/lib/types/core/compare-media.test.d.ts +1 -0
- package/lib/types/core/create-style-sheet.d.ts +4 -0
- package/lib/types/core/css-engine.stories.d.ts +5 -0
- package/lib/types/core/equal-media.d.ts +2 -0
- package/lib/types/core/equal-media.test.d.ts +1 -0
- package/lib/types/core/find-applicable-media.d.ts +2 -0
- package/lib/types/core/find-applicable-media.test.d.ts +1 -0
- package/lib/types/core/index.d.ts +13 -0
- package/lib/types/core/match-media.d.ts +2 -0
- package/lib/types/core/match-media.test.d.ts +1 -0
- package/lib/types/core/merger.d.ts +274 -0
- package/lib/types/core/merger.test.d.ts +1 -0
- package/lib/types/core/prefixer.d.ts +2 -0
- package/lib/types/core/prefixer.test.d.ts +1 -0
- package/lib/types/core/rules.d.ts +104 -0
- package/lib/types/core/style-element.d.ts +10 -0
- package/lib/types/core/style-sheet-regular.d.ts +3 -0
- package/lib/types/core/style-sheet-regular.test.d.ts +1 -0
- package/lib/types/core/style-sheet.d.ts +24 -0
- package/lib/types/core/to-property.d.ts +4 -0
- package/lib/types/core/to-property.test.d.ts +1 -0
- package/lib/types/core/to-value.d.ts +3 -0
- package/lib/types/core/to-value.test.d.ts +1 -0
- package/lib/types/css.d.ts +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/schema.d.ts +3925 -0
- package/package.json +3 -3
package/lib/index.js
ADDED
|
@@ -0,0 +1,953 @@
|
|
|
1
|
+
// src/core/prefixer.ts
|
|
2
|
+
var prefixStyles = (styleMap) => {
|
|
3
|
+
const newStyleMap = /* @__PURE__ */ new Map();
|
|
4
|
+
for (const [property, value] of styleMap) {
|
|
5
|
+
if (property === "background-clip") {
|
|
6
|
+
newStyleMap.set("-webkit-background-clip", value);
|
|
7
|
+
}
|
|
8
|
+
if (property === "user-select") {
|
|
9
|
+
newStyleMap.set("-webkit-user-select", value);
|
|
10
|
+
}
|
|
11
|
+
if (property === "text-size-adjust") {
|
|
12
|
+
newStyleMap.set("-webkit-text-size-adjust", value);
|
|
13
|
+
}
|
|
14
|
+
if (property === "backdrop-filter") {
|
|
15
|
+
newStyleMap.set("-webkit-backdrop-filter", value);
|
|
16
|
+
}
|
|
17
|
+
newStyleMap.set(property, value);
|
|
18
|
+
}
|
|
19
|
+
return newStyleMap;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/schema.ts
|
|
23
|
+
import { z } from "zod";
|
|
24
|
+
|
|
25
|
+
// src/core/to-value.ts
|
|
26
|
+
import { captureError } from "@webstudio-is/error-utils";
|
|
27
|
+
import { DEFAULT_FONT_FALLBACK, SYSTEM_FONTS } from "@webstudio-is/fonts";
|
|
28
|
+
var fallbackTransform = (styleValue) => {
|
|
29
|
+
if (styleValue.type !== "fontFamily") {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let { value } = styleValue;
|
|
33
|
+
if (value.length === 0) {
|
|
34
|
+
value = [DEFAULT_FONT_FALLBACK];
|
|
35
|
+
}
|
|
36
|
+
if (value.length === 1) {
|
|
37
|
+
const stack = SYSTEM_FONTS.get(value[0])?.stack;
|
|
38
|
+
value = stack ?? [value[0], DEFAULT_FONT_FALLBACK];
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
type: "fontFamily",
|
|
42
|
+
value: Array.from(new Set(value))
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
var sanitizeCssUrl = (str) => JSON.stringify(str);
|
|
46
|
+
var toValue = (styleValue, transformValue) => {
|
|
47
|
+
if (styleValue === void 0) {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
const transformedValue = transformValue?.(styleValue) ?? fallbackTransform(styleValue);
|
|
51
|
+
const value = transformedValue ?? styleValue;
|
|
52
|
+
if (value.type === "unit") {
|
|
53
|
+
return value.value + (value.unit === "number" ? "" : value.unit);
|
|
54
|
+
}
|
|
55
|
+
if (value.type === "fontFamily") {
|
|
56
|
+
const families = [];
|
|
57
|
+
for (const family of value.value) {
|
|
58
|
+
families.push(family.includes(" ") ? `"${family}"` : family);
|
|
59
|
+
}
|
|
60
|
+
return families.join(", ");
|
|
61
|
+
}
|
|
62
|
+
if (value.type === "var") {
|
|
63
|
+
if (value.hidden) {
|
|
64
|
+
return "";
|
|
65
|
+
}
|
|
66
|
+
let fallbacksString = "";
|
|
67
|
+
if (value.fallback) {
|
|
68
|
+
fallbacksString = `, ${toValue(value.fallback, transformValue)}`;
|
|
69
|
+
}
|
|
70
|
+
return `var(--${value.value}${fallbacksString})`;
|
|
71
|
+
}
|
|
72
|
+
if (value.type === "keyword") {
|
|
73
|
+
if (value.hidden === true) {
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
return value.value;
|
|
77
|
+
}
|
|
78
|
+
if (value.type === "invalid") {
|
|
79
|
+
return value.value;
|
|
80
|
+
}
|
|
81
|
+
if (value.type === "unset") {
|
|
82
|
+
return value.value;
|
|
83
|
+
}
|
|
84
|
+
if (value.type === "rgb") {
|
|
85
|
+
return `rgba(${value.r}, ${value.g}, ${value.b}, ${value.alpha})`;
|
|
86
|
+
}
|
|
87
|
+
if (value.type === "image") {
|
|
88
|
+
if (value.hidden || value.value.type !== "url") {
|
|
89
|
+
return "none";
|
|
90
|
+
}
|
|
91
|
+
return `url(${sanitizeCssUrl(value.value.url)})`;
|
|
92
|
+
}
|
|
93
|
+
if (value.type === "unparsed") {
|
|
94
|
+
if (value.hidden === true) {
|
|
95
|
+
return "none";
|
|
96
|
+
}
|
|
97
|
+
return value.value;
|
|
98
|
+
}
|
|
99
|
+
if (value.type === "layers") {
|
|
100
|
+
const valueString = value.value.filter((layer) => layer.hidden !== true).map((layer) => toValue(layer, transformValue)).join(", ");
|
|
101
|
+
return valueString === "" ? "none" : valueString;
|
|
102
|
+
}
|
|
103
|
+
if (value.type === "tuple") {
|
|
104
|
+
if (value.hidden === true) {
|
|
105
|
+
return "none";
|
|
106
|
+
}
|
|
107
|
+
return value.value.filter((value2) => value2.hidden !== true).map((value2) => toValue(value2, transformValue)).join(" ");
|
|
108
|
+
}
|
|
109
|
+
if (value.type === "function") {
|
|
110
|
+
if (value.hidden === true) {
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
return `${value.name}(${toValue(value.args, transformValue)})`;
|
|
114
|
+
}
|
|
115
|
+
if (value.type === "guaranteedInvalid") {
|
|
116
|
+
return "";
|
|
117
|
+
}
|
|
118
|
+
return captureError(new Error("Unknown value type"), value);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// src/schema.ts
|
|
122
|
+
var Unit = z.string();
|
|
123
|
+
var UnitValue = z.object({
|
|
124
|
+
type: z.literal("unit"),
|
|
125
|
+
unit: Unit,
|
|
126
|
+
value: z.number(),
|
|
127
|
+
hidden: z.boolean().optional()
|
|
128
|
+
});
|
|
129
|
+
var KeywordValue = z.object({
|
|
130
|
+
type: z.literal("keyword"),
|
|
131
|
+
// @todo use exact type
|
|
132
|
+
value: z.string(),
|
|
133
|
+
hidden: z.boolean().optional()
|
|
134
|
+
});
|
|
135
|
+
var UnparsedValue = z.object({
|
|
136
|
+
type: z.literal("unparsed"),
|
|
137
|
+
value: z.string(),
|
|
138
|
+
// For the builder we want to be able to hide background-image
|
|
139
|
+
hidden: z.boolean().optional()
|
|
140
|
+
});
|
|
141
|
+
var FontFamilyValue = z.object({
|
|
142
|
+
type: z.literal("fontFamily"),
|
|
143
|
+
value: z.array(z.string()),
|
|
144
|
+
hidden: z.boolean().optional()
|
|
145
|
+
});
|
|
146
|
+
var RgbValue = z.object({
|
|
147
|
+
type: z.literal("rgb"),
|
|
148
|
+
r: z.number(),
|
|
149
|
+
g: z.number(),
|
|
150
|
+
b: z.number(),
|
|
151
|
+
alpha: z.number(),
|
|
152
|
+
hidden: z.boolean().optional()
|
|
153
|
+
});
|
|
154
|
+
var FunctionValue = z.object({
|
|
155
|
+
type: z.literal("function"),
|
|
156
|
+
name: z.string(),
|
|
157
|
+
args: z.lazy(() => StyleValue),
|
|
158
|
+
hidden: z.boolean().optional()
|
|
159
|
+
});
|
|
160
|
+
var ImageValue = z.object({
|
|
161
|
+
type: z.literal("image"),
|
|
162
|
+
value: z.union([
|
|
163
|
+
z.object({ type: z.literal("asset"), value: z.string() }),
|
|
164
|
+
// url is not stored in db and only used by css-engine transformValue
|
|
165
|
+
// to prepare image value for rendering
|
|
166
|
+
z.object({ type: z.literal("url"), url: z.string() })
|
|
167
|
+
]),
|
|
168
|
+
// For the builder we want to be able to hide images
|
|
169
|
+
hidden: z.boolean().optional()
|
|
170
|
+
});
|
|
171
|
+
var GuaranteedInvalidValue = z.object({
|
|
172
|
+
type: z.literal("guaranteedInvalid"),
|
|
173
|
+
hidden: z.boolean().optional()
|
|
174
|
+
});
|
|
175
|
+
var InvalidValue = z.object({
|
|
176
|
+
type: z.literal("invalid"),
|
|
177
|
+
value: z.string(),
|
|
178
|
+
hidden: z.boolean().optional()
|
|
179
|
+
});
|
|
180
|
+
var UnsetValue = z.object({
|
|
181
|
+
type: z.literal("unset"),
|
|
182
|
+
value: z.literal(""),
|
|
183
|
+
hidden: z.boolean().optional()
|
|
184
|
+
});
|
|
185
|
+
var VarFallback = z.union([
|
|
186
|
+
UnparsedValue,
|
|
187
|
+
KeywordValue,
|
|
188
|
+
UnitValue,
|
|
189
|
+
RgbValue
|
|
190
|
+
]);
|
|
191
|
+
var toVarFallback = (styleValue, transformValue) => {
|
|
192
|
+
if (styleValue.type === "unparsed" || styleValue.type === "keyword" || styleValue.type === "unit" || styleValue.type === "rgb") {
|
|
193
|
+
return styleValue;
|
|
194
|
+
}
|
|
195
|
+
styleValue;
|
|
196
|
+
return { type: "unparsed", value: toValue(styleValue, transformValue) };
|
|
197
|
+
};
|
|
198
|
+
var VarValue = z.object({
|
|
199
|
+
type: z.literal("var"),
|
|
200
|
+
value: z.string(),
|
|
201
|
+
fallback: VarFallback.optional(),
|
|
202
|
+
hidden: z.boolean().optional()
|
|
203
|
+
});
|
|
204
|
+
var TupleValueItem = z.union([
|
|
205
|
+
UnitValue,
|
|
206
|
+
KeywordValue,
|
|
207
|
+
UnparsedValue,
|
|
208
|
+
ImageValue,
|
|
209
|
+
RgbValue,
|
|
210
|
+
FunctionValue,
|
|
211
|
+
VarValue
|
|
212
|
+
]);
|
|
213
|
+
var TupleValue = z.object({
|
|
214
|
+
type: z.literal("tuple"),
|
|
215
|
+
value: z.array(TupleValueItem),
|
|
216
|
+
hidden: z.boolean().optional()
|
|
217
|
+
});
|
|
218
|
+
var LayerValueItem = z.union([
|
|
219
|
+
UnitValue,
|
|
220
|
+
KeywordValue,
|
|
221
|
+
UnparsedValue,
|
|
222
|
+
ImageValue,
|
|
223
|
+
TupleValue,
|
|
224
|
+
RgbValue,
|
|
225
|
+
InvalidValue,
|
|
226
|
+
FunctionValue,
|
|
227
|
+
VarValue
|
|
228
|
+
]);
|
|
229
|
+
var LayersValue = z.object({
|
|
230
|
+
type: z.literal("layers"),
|
|
231
|
+
value: z.array(LayerValueItem),
|
|
232
|
+
hidden: z.boolean().optional()
|
|
233
|
+
});
|
|
234
|
+
var StyleValue = z.union([
|
|
235
|
+
ImageValue,
|
|
236
|
+
LayersValue,
|
|
237
|
+
UnitValue,
|
|
238
|
+
KeywordValue,
|
|
239
|
+
FontFamilyValue,
|
|
240
|
+
RgbValue,
|
|
241
|
+
UnparsedValue,
|
|
242
|
+
TupleValue,
|
|
243
|
+
FunctionValue,
|
|
244
|
+
GuaranteedInvalidValue,
|
|
245
|
+
InvalidValue,
|
|
246
|
+
UnsetValue,
|
|
247
|
+
VarValue
|
|
248
|
+
]);
|
|
249
|
+
var Style = z.record(z.string(), StyleValue);
|
|
250
|
+
|
|
251
|
+
// src/css.ts
|
|
252
|
+
var cssWideKeywords = /* @__PURE__ */ new Set([
|
|
253
|
+
"initial",
|
|
254
|
+
"inherit",
|
|
255
|
+
"unset",
|
|
256
|
+
"revert",
|
|
257
|
+
"revert-layer"
|
|
258
|
+
]);
|
|
259
|
+
|
|
260
|
+
// src/core/merger.ts
|
|
261
|
+
var isLonghandValue = (value) => {
|
|
262
|
+
if (value === void 0) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
if (value.type === "keyword" && cssWideKeywords.has(value.value)) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
if (value.type === "var") {
|
|
269
|
+
const fallback = value.fallback;
|
|
270
|
+
if (fallback?.type === "keyword" && cssWideKeywords.has(fallback.value)) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return true;
|
|
275
|
+
};
|
|
276
|
+
var mergeBorder = (styleMap, base) => {
|
|
277
|
+
const width = styleMap.get(`${base}-width`);
|
|
278
|
+
const style = styleMap.get(`${base}-style`);
|
|
279
|
+
const color = styleMap.get(`${base}-color`);
|
|
280
|
+
if (isLonghandValue(width) && isLonghandValue(style) && isLonghandValue(color)) {
|
|
281
|
+
styleMap.delete(`${base}-width`);
|
|
282
|
+
styleMap.delete(`${base}-style`);
|
|
283
|
+
styleMap.delete(`${base}-color`);
|
|
284
|
+
styleMap.set(base, { type: "tuple", value: [width, style, color] });
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var mergeBox = (styleMap, base) => {
|
|
288
|
+
const topValue = styleMap.get(`${base}-top`);
|
|
289
|
+
const top = toValue(topValue);
|
|
290
|
+
const right = toValue(styleMap.get(`${base}-right`));
|
|
291
|
+
const bottom = toValue(styleMap.get(`${base}-bottom`));
|
|
292
|
+
const left = toValue(styleMap.get(`${base}-left`));
|
|
293
|
+
if (isLonghandValue(topValue) && top === right && top === bottom && top === left) {
|
|
294
|
+
styleMap.delete(`${base}-top`);
|
|
295
|
+
styleMap.delete(`${base}-right`);
|
|
296
|
+
styleMap.delete(`${base}-bottom`);
|
|
297
|
+
styleMap.delete(`${base}-left`);
|
|
298
|
+
styleMap.set(base, topValue);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
var mergeWhiteSpaceAndTextWrap = (styleMap) => {
|
|
302
|
+
const collapseValue = styleMap.get("white-space-collapse");
|
|
303
|
+
const collapse = toValue(collapseValue);
|
|
304
|
+
const modeValue = styleMap.get("text-wrap-mode");
|
|
305
|
+
const mode = toValue(modeValue);
|
|
306
|
+
const styleValue = styleMap.get("text-wrap-style");
|
|
307
|
+
const style = toValue(styleValue);
|
|
308
|
+
styleMap.delete("text-wrap-mode");
|
|
309
|
+
styleMap.delete("text-wrap-style");
|
|
310
|
+
if (collapse === "collapse" || collapse === "initial" || mode === "wrap" || mode === "initial") {
|
|
311
|
+
styleMap.set("white-space", { type: "keyword", value: "normal" });
|
|
312
|
+
}
|
|
313
|
+
if (mode === "nowrap") {
|
|
314
|
+
styleMap.set("white-space", { type: "keyword", value: "nowrap" });
|
|
315
|
+
}
|
|
316
|
+
if (collapse === "preserve") {
|
|
317
|
+
if (mode === "nowrap") {
|
|
318
|
+
styleMap.set("white-space", { type: "keyword", value: "pre" });
|
|
319
|
+
} else {
|
|
320
|
+
styleMap.set("white-space", { type: "keyword", value: "pre-wrap" });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (collapse === "preserve-breaks") {
|
|
324
|
+
styleMap.set("white-space", { type: "keyword", value: "pre-line" });
|
|
325
|
+
}
|
|
326
|
+
if (collapse === "break-spaces") {
|
|
327
|
+
styleMap.set("white-space", { type: "keyword", value: "break-spaces" });
|
|
328
|
+
}
|
|
329
|
+
if (style === "auto") {
|
|
330
|
+
styleMap.set("text-wrap", modeValue ?? { type: "keyword", value: "wrap" });
|
|
331
|
+
}
|
|
332
|
+
if (style === "balance" || style === "stable" || style === "pretty") {
|
|
333
|
+
styleMap.set("text-wrap", { type: "keyword", value: style });
|
|
334
|
+
}
|
|
335
|
+
const textWrap = (styleValue?.type !== "keyword" ? styleValue : void 0) ?? (modeValue?.type !== "keyword" ? modeValue : void 0);
|
|
336
|
+
if (textWrap) {
|
|
337
|
+
styleMap.set("text-wrap", textWrap);
|
|
338
|
+
}
|
|
339
|
+
if (collapseValue) {
|
|
340
|
+
styleMap.delete("white-space-collapse");
|
|
341
|
+
styleMap.set("white-space-collapse", collapseValue);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
var mergeBackgroundPosition = (styleMap) => {
|
|
345
|
+
const x = styleMap.get("background-position-x");
|
|
346
|
+
const y = styleMap.get("background-position-y");
|
|
347
|
+
if (x?.type === "layers" && y?.type === "layers" && x.value.length === y.value.length) {
|
|
348
|
+
const position = x.value.map((xValue, index) => {
|
|
349
|
+
const yValue = y.value[index];
|
|
350
|
+
return {
|
|
351
|
+
type: "tuple",
|
|
352
|
+
value: [xValue, yValue]
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
styleMap.delete("background-position-x");
|
|
356
|
+
styleMap.delete("background-position-y");
|
|
357
|
+
styleMap.set("background-position", {
|
|
358
|
+
type: "layers",
|
|
359
|
+
value: position
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
var mergeStyles = (styleMap) => {
|
|
364
|
+
const newStyle = new Map(styleMap);
|
|
365
|
+
mergeBorder(newStyle, "border-top");
|
|
366
|
+
mergeBorder(newStyle, "border-right");
|
|
367
|
+
mergeBorder(newStyle, "border-bottom");
|
|
368
|
+
mergeBorder(newStyle, "border-left");
|
|
369
|
+
mergeBorder(newStyle, "border");
|
|
370
|
+
mergeBorder(newStyle, "outline");
|
|
371
|
+
mergeBox(newStyle, "border");
|
|
372
|
+
mergeBox(newStyle, "margin");
|
|
373
|
+
mergeBox(newStyle, "padding");
|
|
374
|
+
mergeWhiteSpaceAndTextWrap(newStyle);
|
|
375
|
+
mergeBackgroundPosition(newStyle);
|
|
376
|
+
return newStyle;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
// src/core/to-property.ts
|
|
380
|
+
var hyphenateProperty = (property) => property.replace(/[A-Z]/g, (match) => "-" + match.toLowerCase());
|
|
381
|
+
|
|
382
|
+
// src/core/rules.ts
|
|
383
|
+
var mapGroupBy = (array, getKey) => {
|
|
384
|
+
const groups = /* @__PURE__ */ new Map();
|
|
385
|
+
for (const item of array) {
|
|
386
|
+
const key = getKey(item);
|
|
387
|
+
let group = groups.get(key);
|
|
388
|
+
if (group === void 0) {
|
|
389
|
+
group = [];
|
|
390
|
+
groups.set(key, group);
|
|
391
|
+
}
|
|
392
|
+
group.push(item);
|
|
393
|
+
}
|
|
394
|
+
return groups;
|
|
395
|
+
};
|
|
396
|
+
var mergeDeclarations = (declarations) => {
|
|
397
|
+
const newDeclarations = [];
|
|
398
|
+
const groups = mapGroupBy(
|
|
399
|
+
declarations,
|
|
400
|
+
(declaration) => declaration.breakpoint + declaration.selector
|
|
401
|
+
);
|
|
402
|
+
for (const groupDeclarations of groups.values()) {
|
|
403
|
+
const { breakpoint, selector } = groupDeclarations[0];
|
|
404
|
+
const merged = mergeStyles(
|
|
405
|
+
new Map(
|
|
406
|
+
groupDeclarations.map((item) => [item.property, item.value])
|
|
407
|
+
)
|
|
408
|
+
);
|
|
409
|
+
for (const [property, value] of merged) {
|
|
410
|
+
newDeclarations.push({
|
|
411
|
+
breakpoint,
|
|
412
|
+
selector,
|
|
413
|
+
property,
|
|
414
|
+
value
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return newDeclarations;
|
|
419
|
+
};
|
|
420
|
+
var generateStyleMap = ({
|
|
421
|
+
style,
|
|
422
|
+
indent = 0,
|
|
423
|
+
transformValue
|
|
424
|
+
}) => {
|
|
425
|
+
const spaces = " ".repeat(indent);
|
|
426
|
+
let lines = "";
|
|
427
|
+
for (const [property, value] of style) {
|
|
428
|
+
const propertyString = hyphenateProperty(property);
|
|
429
|
+
const valueString = toValue(value, transformValue);
|
|
430
|
+
const line = `${spaces}${propertyString}: ${valueString}`;
|
|
431
|
+
lines += lines === "" ? line : `;
|
|
432
|
+
${line}`;
|
|
433
|
+
}
|
|
434
|
+
return lines;
|
|
435
|
+
};
|
|
436
|
+
var normalizeDeclaration = (declaration) => ({
|
|
437
|
+
...declaration,
|
|
438
|
+
property: hyphenateProperty(declaration.property)
|
|
439
|
+
});
|
|
440
|
+
var getDeclarationKey = (declaraionKey) => {
|
|
441
|
+
const { breakpoint, selector, property } = declaraionKey;
|
|
442
|
+
return `${breakpoint}:${selector}:${property}`;
|
|
443
|
+
};
|
|
444
|
+
var MixinRule = class {
|
|
445
|
+
// use map to avoid duplicated properties
|
|
446
|
+
#declarations = /* @__PURE__ */ new Map();
|
|
447
|
+
#dirtyBreakpoints = /* @__PURE__ */ new Set();
|
|
448
|
+
/*
|
|
449
|
+
* check if breakpoint was updated
|
|
450
|
+
*/
|
|
451
|
+
isDirtyBreakpoint(breakpoint) {
|
|
452
|
+
return this.#dirtyBreakpoints.has(breakpoint);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* reset breakpoints invalidation
|
|
456
|
+
*/
|
|
457
|
+
clearBreakpoints() {
|
|
458
|
+
this.#dirtyBreakpoints.clear();
|
|
459
|
+
}
|
|
460
|
+
setDeclaration(declaration) {
|
|
461
|
+
declaration = normalizeDeclaration(declaration);
|
|
462
|
+
this.#declarations.set(getDeclarationKey(declaration), declaration);
|
|
463
|
+
this.#dirtyBreakpoints.add(declaration.breakpoint);
|
|
464
|
+
}
|
|
465
|
+
deleteDeclaration(declaration) {
|
|
466
|
+
declaration = normalizeDeclaration(declaration);
|
|
467
|
+
this.#declarations.delete(getDeclarationKey(declaration));
|
|
468
|
+
this.#dirtyBreakpoints.add(declaration.breakpoint);
|
|
469
|
+
}
|
|
470
|
+
getDeclarations() {
|
|
471
|
+
return this.#declarations.values();
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
var NestingRule = class {
|
|
475
|
+
#selector;
|
|
476
|
+
#descendantSuffix;
|
|
477
|
+
#mixinRules = /* @__PURE__ */ new Map();
|
|
478
|
+
#mixins = /* @__PURE__ */ new Set();
|
|
479
|
+
// use map to avoid duplicated properties
|
|
480
|
+
#declarations = /* @__PURE__ */ new Map();
|
|
481
|
+
// cached generated rule by breakpoint
|
|
482
|
+
#cache = /* @__PURE__ */ new Map();
|
|
483
|
+
constructor(mixinRules, selector, descendantSuffix) {
|
|
484
|
+
this.#selector = selector;
|
|
485
|
+
this.#descendantSuffix = descendantSuffix;
|
|
486
|
+
this.#mixinRules = mixinRules;
|
|
487
|
+
}
|
|
488
|
+
getSelector() {
|
|
489
|
+
return this.#selector;
|
|
490
|
+
}
|
|
491
|
+
setSelector(selector) {
|
|
492
|
+
this.#selector = selector;
|
|
493
|
+
this.#cache.clear();
|
|
494
|
+
}
|
|
495
|
+
getDescendantSuffix() {
|
|
496
|
+
return this.#descendantSuffix;
|
|
497
|
+
}
|
|
498
|
+
addMixin(mixin) {
|
|
499
|
+
this.#mixins.add(mixin);
|
|
500
|
+
this.#cache.clear();
|
|
501
|
+
}
|
|
502
|
+
applyMixins(mixins) {
|
|
503
|
+
this.#mixins = new Set(mixins);
|
|
504
|
+
this.#cache.clear();
|
|
505
|
+
}
|
|
506
|
+
setDeclaration(declaration) {
|
|
507
|
+
declaration = normalizeDeclaration(declaration);
|
|
508
|
+
this.#declarations.set(getDeclarationKey(declaration), declaration);
|
|
509
|
+
this.#cache.delete(declaration.breakpoint);
|
|
510
|
+
}
|
|
511
|
+
deleteDeclaration(declaration) {
|
|
512
|
+
declaration = normalizeDeclaration(declaration);
|
|
513
|
+
this.#declarations.delete(getDeclarationKey(declaration));
|
|
514
|
+
this.#cache.delete(declaration.breakpoint);
|
|
515
|
+
}
|
|
516
|
+
#getDeclarations() {
|
|
517
|
+
const declarations = /* @__PURE__ */ new Map();
|
|
518
|
+
for (const mixin of this.#mixins) {
|
|
519
|
+
const rule = this.#mixinRules.get(mixin);
|
|
520
|
+
if (rule === void 0) {
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
for (const declaration of rule.getDeclarations()) {
|
|
524
|
+
declarations.set(getDeclarationKey(declaration), declaration);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
for (const declaration of this.#declarations.values()) {
|
|
528
|
+
declarations.set(getDeclarationKey(declaration), declaration);
|
|
529
|
+
}
|
|
530
|
+
return declarations.values();
|
|
531
|
+
}
|
|
532
|
+
getMergedDeclarations() {
|
|
533
|
+
return mergeDeclarations(this.#getDeclarations());
|
|
534
|
+
}
|
|
535
|
+
toString({
|
|
536
|
+
breakpoint,
|
|
537
|
+
indent = 0,
|
|
538
|
+
transformValue
|
|
539
|
+
}) {
|
|
540
|
+
for (const mixin of this.#mixins) {
|
|
541
|
+
const rule = this.#mixinRules.get(mixin);
|
|
542
|
+
if (rule?.isDirtyBreakpoint(breakpoint)) {
|
|
543
|
+
this.#cache.delete(breakpoint);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
const cached = this.#cache.get(breakpoint);
|
|
547
|
+
if (cached && cached.indent === indent && cached.transformValue === transformValue) {
|
|
548
|
+
return cached.generated;
|
|
549
|
+
}
|
|
550
|
+
const styleBySelector = /* @__PURE__ */ new Map();
|
|
551
|
+
for (const declaration of this.getMergedDeclarations()) {
|
|
552
|
+
if (declaration.breakpoint !== breakpoint) {
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
const { selector: nestedSelector } = declaration;
|
|
556
|
+
const selector = this.#selector + this.#descendantSuffix + nestedSelector;
|
|
557
|
+
let style = styleBySelector.get(selector);
|
|
558
|
+
if (style === void 0) {
|
|
559
|
+
style = /* @__PURE__ */ new Map();
|
|
560
|
+
styleBySelector.set(selector, style);
|
|
561
|
+
}
|
|
562
|
+
style.set(declaration.property, declaration.value);
|
|
563
|
+
}
|
|
564
|
+
const spaces = " ".repeat(indent);
|
|
565
|
+
const generated = Array.from(styleBySelector).sort(
|
|
566
|
+
([leftSelector], [rightSelector]) => leftSelector.localeCompare(rightSelector)
|
|
567
|
+
).map(([selector, style]) => {
|
|
568
|
+
const content = generateStyleMap({
|
|
569
|
+
style: prefixStyles(style),
|
|
570
|
+
indent: indent + 2,
|
|
571
|
+
transformValue
|
|
572
|
+
});
|
|
573
|
+
return `${spaces}${selector} {
|
|
574
|
+
${content}
|
|
575
|
+
${spaces}}
|
|
576
|
+
`;
|
|
577
|
+
}).join("").trimEnd();
|
|
578
|
+
this.#cache.set(breakpoint, { generated, indent, transformValue });
|
|
579
|
+
return generated;
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
var MediaRule = class {
|
|
583
|
+
#name;
|
|
584
|
+
options;
|
|
585
|
+
rules;
|
|
586
|
+
#mediaType;
|
|
587
|
+
constructor(name, options = {}) {
|
|
588
|
+
this.#name = name;
|
|
589
|
+
this.options = options;
|
|
590
|
+
this.rules = /* @__PURE__ */ new Map();
|
|
591
|
+
this.#mediaType = options.mediaType ?? "all";
|
|
592
|
+
}
|
|
593
|
+
insertRule(rule) {
|
|
594
|
+
this.rules.set(rule.cssText, rule);
|
|
595
|
+
return rule;
|
|
596
|
+
}
|
|
597
|
+
get cssText() {
|
|
598
|
+
return this.toString();
|
|
599
|
+
}
|
|
600
|
+
toString() {
|
|
601
|
+
return this.generateRule({ nestingRules: [] });
|
|
602
|
+
}
|
|
603
|
+
generateRule({
|
|
604
|
+
nestingRules,
|
|
605
|
+
transformValue
|
|
606
|
+
}) {
|
|
607
|
+
if (this.rules.size === 0 && nestingRules.length === 0) {
|
|
608
|
+
return "";
|
|
609
|
+
}
|
|
610
|
+
const rules = [];
|
|
611
|
+
for (const rule of this.rules.values()) {
|
|
612
|
+
rules.push(rule.toString());
|
|
613
|
+
}
|
|
614
|
+
for (const rule of nestingRules) {
|
|
615
|
+
const generatedRule = rule.toString({
|
|
616
|
+
breakpoint: this.#name,
|
|
617
|
+
indent: 2,
|
|
618
|
+
transformValue
|
|
619
|
+
});
|
|
620
|
+
if (generatedRule !== "") {
|
|
621
|
+
rules.push(generatedRule);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
if (rules.length === 0) {
|
|
625
|
+
return "";
|
|
626
|
+
}
|
|
627
|
+
let conditionText = "";
|
|
628
|
+
const { minWidth, maxWidth } = this.options;
|
|
629
|
+
if (minWidth !== void 0) {
|
|
630
|
+
conditionText = ` and (min-width: ${minWidth}px)`;
|
|
631
|
+
}
|
|
632
|
+
if (maxWidth !== void 0) {
|
|
633
|
+
conditionText += ` and (max-width: ${maxWidth}px)`;
|
|
634
|
+
}
|
|
635
|
+
return `@media ${this.#mediaType}${conditionText} {
|
|
636
|
+
${rules.join(
|
|
637
|
+
"\n"
|
|
638
|
+
)}
|
|
639
|
+
}`;
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
var PlaintextRule = class {
|
|
643
|
+
cssText;
|
|
644
|
+
constructor(cssText) {
|
|
645
|
+
this.cssText = cssText;
|
|
646
|
+
}
|
|
647
|
+
toString() {
|
|
648
|
+
return this.cssText;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
var FontFaceRule = class {
|
|
652
|
+
#cached;
|
|
653
|
+
#options;
|
|
654
|
+
constructor(options) {
|
|
655
|
+
this.#options = options;
|
|
656
|
+
}
|
|
657
|
+
get cssText() {
|
|
658
|
+
return this.toString();
|
|
659
|
+
}
|
|
660
|
+
toString() {
|
|
661
|
+
if (this.#cached) {
|
|
662
|
+
return this.#cached;
|
|
663
|
+
}
|
|
664
|
+
const decls = [];
|
|
665
|
+
const { fontFamily, fontStyle, fontWeight, fontDisplay, src } = this.#options;
|
|
666
|
+
const value = toValue(
|
|
667
|
+
{ type: "fontFamily", value: [fontFamily] },
|
|
668
|
+
// Avoids adding a fallback automatically which needs to happen for font family in general but not for font face.
|
|
669
|
+
(value2) => value2
|
|
670
|
+
);
|
|
671
|
+
decls.push(`font-family: ${value}`);
|
|
672
|
+
decls.push(`font-style: ${fontStyle}`);
|
|
673
|
+
decls.push(`font-weight: ${fontWeight}`);
|
|
674
|
+
decls.push(`font-display: ${fontDisplay}`);
|
|
675
|
+
decls.push(`src: ${src}`);
|
|
676
|
+
this.#cached = `@font-face {
|
|
677
|
+
${decls.join("; ")};
|
|
678
|
+
}`;
|
|
679
|
+
return this.#cached;
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// src/core/compare-media.ts
|
|
684
|
+
var compareMedia = (optionA, optionB) => {
|
|
685
|
+
if (optionA.minWidth === void 0 && optionA.maxWidth === void 0) {
|
|
686
|
+
return -1;
|
|
687
|
+
}
|
|
688
|
+
if (optionB.minWidth === void 0 && optionB.maxWidth === void 0) {
|
|
689
|
+
return 1;
|
|
690
|
+
}
|
|
691
|
+
if (optionA.minWidth !== void 0 && optionB.minWidth !== void 0) {
|
|
692
|
+
return optionA.minWidth - optionB.minWidth;
|
|
693
|
+
}
|
|
694
|
+
if (optionA.maxWidth !== void 0 && optionB.maxWidth !== void 0) {
|
|
695
|
+
return optionB.maxWidth - optionA.maxWidth;
|
|
696
|
+
}
|
|
697
|
+
return "minWidth" in optionA ? 1 : -1;
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
// src/core/style-element.ts
|
|
701
|
+
var StyleElement = class {
|
|
702
|
+
#element;
|
|
703
|
+
#name;
|
|
704
|
+
constructor(name = "") {
|
|
705
|
+
this.#name = name;
|
|
706
|
+
}
|
|
707
|
+
get isMounted() {
|
|
708
|
+
return this.#element?.parentElement != null;
|
|
709
|
+
}
|
|
710
|
+
mount() {
|
|
711
|
+
if (this.isMounted === false) {
|
|
712
|
+
this.#element = document.createElement("style");
|
|
713
|
+
this.#element.setAttribute("data-webstudio", this.#name);
|
|
714
|
+
document.head.appendChild(this.#element);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
unmount() {
|
|
718
|
+
if (this.isMounted) {
|
|
719
|
+
this.#element?.parentElement?.removeChild(this.#element);
|
|
720
|
+
this.#element = void 0;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
render(cssText) {
|
|
724
|
+
if (this.#element) {
|
|
725
|
+
this.#element.textContent = cssText;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
setAttribute(name, value) {
|
|
729
|
+
if (this.#element) {
|
|
730
|
+
this.#element.setAttribute(name, value);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
getAttribute(name) {
|
|
734
|
+
if (this.#element) {
|
|
735
|
+
return this.#element.getAttribute(name);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
// src/core/style-sheet.ts
|
|
741
|
+
var StyleSheet = class {
|
|
742
|
+
#cssText = "";
|
|
743
|
+
#mediaRules = /* @__PURE__ */ new Map();
|
|
744
|
+
#plainRules = /* @__PURE__ */ new Map();
|
|
745
|
+
#mixinRules = /* @__PURE__ */ new Map();
|
|
746
|
+
nestingRules = /* @__PURE__ */ new Map();
|
|
747
|
+
#fontFaceRules = [];
|
|
748
|
+
#transformValue;
|
|
749
|
+
#element;
|
|
750
|
+
constructor(element) {
|
|
751
|
+
this.#element = element;
|
|
752
|
+
}
|
|
753
|
+
setTransformer(transformValue) {
|
|
754
|
+
this.#transformValue = transformValue;
|
|
755
|
+
}
|
|
756
|
+
addMediaRule(id, options) {
|
|
757
|
+
let mediaRule = this.#mediaRules.get(id);
|
|
758
|
+
if (mediaRule === void 0) {
|
|
759
|
+
mediaRule = new MediaRule(id, options);
|
|
760
|
+
this.#mediaRules.set(id, mediaRule);
|
|
761
|
+
return mediaRule;
|
|
762
|
+
}
|
|
763
|
+
if (options) {
|
|
764
|
+
mediaRule.options = options;
|
|
765
|
+
}
|
|
766
|
+
if (mediaRule === void 0) {
|
|
767
|
+
throw new Error("No media rule found");
|
|
768
|
+
}
|
|
769
|
+
return mediaRule;
|
|
770
|
+
}
|
|
771
|
+
addPlaintextRule(cssText) {
|
|
772
|
+
const rule = this.#plainRules.get(cssText);
|
|
773
|
+
if (rule !== void 0) {
|
|
774
|
+
return rule;
|
|
775
|
+
}
|
|
776
|
+
return this.#plainRules.set(cssText, new PlaintextRule(cssText));
|
|
777
|
+
}
|
|
778
|
+
addMixinRule(name) {
|
|
779
|
+
let rule = this.#mixinRules.get(name);
|
|
780
|
+
if (rule === void 0) {
|
|
781
|
+
rule = new MixinRule();
|
|
782
|
+
this.#mixinRules.set(name, rule);
|
|
783
|
+
}
|
|
784
|
+
return rule;
|
|
785
|
+
}
|
|
786
|
+
addNestingRule(selector, descendantSuffix = "") {
|
|
787
|
+
const key = selector + descendantSuffix;
|
|
788
|
+
let rule = this.nestingRules.get(key);
|
|
789
|
+
if (rule === void 0) {
|
|
790
|
+
rule = new NestingRule(this.#mixinRules, selector, descendantSuffix);
|
|
791
|
+
this.nestingRules.set(key, rule);
|
|
792
|
+
}
|
|
793
|
+
return rule;
|
|
794
|
+
}
|
|
795
|
+
addFontFaceRule(options) {
|
|
796
|
+
return this.#fontFaceRules.push(new FontFaceRule(options));
|
|
797
|
+
}
|
|
798
|
+
generateWith({
|
|
799
|
+
nestingRules,
|
|
800
|
+
transformValue
|
|
801
|
+
}) {
|
|
802
|
+
const css = [];
|
|
803
|
+
css.push(...this.#fontFaceRules.map((rule) => rule.cssText));
|
|
804
|
+
for (const plaintextRule of this.#plainRules.values()) {
|
|
805
|
+
css.push(plaintextRule.cssText);
|
|
806
|
+
}
|
|
807
|
+
const sortedMediaRules = Array.from(this.#mediaRules.values()).sort(
|
|
808
|
+
(ruleA, ruleB) => compareMedia(ruleA.options, ruleB.options)
|
|
809
|
+
);
|
|
810
|
+
for (const mediaRule of sortedMediaRules) {
|
|
811
|
+
const cssText = mediaRule.generateRule({
|
|
812
|
+
nestingRules,
|
|
813
|
+
transformValue
|
|
814
|
+
});
|
|
815
|
+
if (cssText !== "") {
|
|
816
|
+
css.push(cssText);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
for (const rule of this.#mixinRules.values()) {
|
|
820
|
+
rule.clearBreakpoints();
|
|
821
|
+
}
|
|
822
|
+
this.#cssText = css.join("\n");
|
|
823
|
+
return this.#cssText;
|
|
824
|
+
}
|
|
825
|
+
get cssText() {
|
|
826
|
+
return this.generateWith({
|
|
827
|
+
nestingRules: Array.from(this.nestingRules.values()),
|
|
828
|
+
transformValue: this.#transformValue
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
clear() {
|
|
832
|
+
this.#mediaRules.clear();
|
|
833
|
+
this.#mixinRules.clear();
|
|
834
|
+
this.nestingRules.clear();
|
|
835
|
+
this.#plainRules.clear();
|
|
836
|
+
this.#fontFaceRules = [];
|
|
837
|
+
}
|
|
838
|
+
render() {
|
|
839
|
+
this.#element.mount();
|
|
840
|
+
this.#element.render(this.cssText);
|
|
841
|
+
}
|
|
842
|
+
unmount() {
|
|
843
|
+
this.#element.unmount();
|
|
844
|
+
}
|
|
845
|
+
setAttribute(name, value) {
|
|
846
|
+
this.#element.setAttribute(name, value);
|
|
847
|
+
}
|
|
848
|
+
getAttribute(name) {
|
|
849
|
+
return this.#element.getAttribute(name);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
// src/core/style-sheet-regular.ts
|
|
854
|
+
var StyleSheetRegular = class extends StyleSheet {
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
// src/core/create-style-sheet.ts
|
|
858
|
+
var createRegularStyleSheet = (options) => {
|
|
859
|
+
const element = new StyleElement(options?.name);
|
|
860
|
+
return new StyleSheetRegular(element);
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
// src/core/match-media.ts
|
|
864
|
+
var matchMedia = (options, width) => {
|
|
865
|
+
const minWidth = options.minWidth ?? Number.MIN_SAFE_INTEGER;
|
|
866
|
+
const maxWidth = options.maxWidth ?? Number.MAX_SAFE_INTEGER;
|
|
867
|
+
return width >= minWidth && width <= maxWidth;
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
// src/core/equal-media.ts
|
|
871
|
+
var equalMedia = (left, right) => {
|
|
872
|
+
return left.minWidth === right.minWidth && left.maxWidth === right.maxWidth;
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
// src/core/find-applicable-media.ts
|
|
876
|
+
var findApplicableMedia = (media, width) => {
|
|
877
|
+
const sortedMedia = [...media].sort(compareMedia).reverse();
|
|
878
|
+
for (const options of sortedMedia) {
|
|
879
|
+
if (matchMedia(options, width)) {
|
|
880
|
+
return options;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
// src/core/atomic.ts
|
|
886
|
+
import hash from "@emotion/hash";
|
|
887
|
+
var generateAtomic = (sheet, options) => {
|
|
888
|
+
const { getKey, transformValue } = options;
|
|
889
|
+
const atomicRules = /* @__PURE__ */ new Map();
|
|
890
|
+
const classes = options.classes ?? /* @__PURE__ */ new Map();
|
|
891
|
+
for (const rule of sheet.nestingRules.values()) {
|
|
892
|
+
const descendantSuffix = rule.getDescendantSuffix();
|
|
893
|
+
const groupKey = getKey(rule);
|
|
894
|
+
if (groupKey === void 0) {
|
|
895
|
+
atomicRules.set(rule.getSelector(), rule);
|
|
896
|
+
continue;
|
|
897
|
+
}
|
|
898
|
+
let classList = classes.get(groupKey);
|
|
899
|
+
if (classList === void 0) {
|
|
900
|
+
classList = [];
|
|
901
|
+
classes.set(groupKey, classList);
|
|
902
|
+
}
|
|
903
|
+
for (const declaration of rule.getMergedDeclarations()) {
|
|
904
|
+
const atomicHash = hash(
|
|
905
|
+
descendantSuffix + declaration.breakpoint + declaration.selector + declaration.property + toValue(declaration.value, transformValue)
|
|
906
|
+
);
|
|
907
|
+
const className = `c${atomicHash}`;
|
|
908
|
+
let atomicRule = atomicRules.get(atomicHash);
|
|
909
|
+
if (atomicRule === void 0) {
|
|
910
|
+
atomicRule = new NestingRule(
|
|
911
|
+
/* @__PURE__ */ new Map(),
|
|
912
|
+
`.${className}`,
|
|
913
|
+
descendantSuffix
|
|
914
|
+
);
|
|
915
|
+
atomicRule.setDeclaration(declaration);
|
|
916
|
+
atomicRules.set(atomicHash, atomicRule);
|
|
917
|
+
}
|
|
918
|
+
classList.push(className);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
const cssText = sheet.generateWith({
|
|
922
|
+
nestingRules: Array.from(atomicRules.values()),
|
|
923
|
+
transformValue
|
|
924
|
+
});
|
|
925
|
+
return { cssText, classes };
|
|
926
|
+
};
|
|
927
|
+
export {
|
|
928
|
+
FunctionValue,
|
|
929
|
+
GuaranteedInvalidValue,
|
|
930
|
+
ImageValue,
|
|
931
|
+
InvalidValue,
|
|
932
|
+
KeywordValue,
|
|
933
|
+
LayersValue,
|
|
934
|
+
StyleValue,
|
|
935
|
+
TupleValue,
|
|
936
|
+
TupleValueItem,
|
|
937
|
+
UnitValue,
|
|
938
|
+
UnparsedValue,
|
|
939
|
+
VarFallback,
|
|
940
|
+
compareMedia,
|
|
941
|
+
createRegularStyleSheet,
|
|
942
|
+
cssWideKeywords,
|
|
943
|
+
equalMedia,
|
|
944
|
+
findApplicableMedia,
|
|
945
|
+
generateAtomic,
|
|
946
|
+
generateStyleMap,
|
|
947
|
+
hyphenateProperty,
|
|
948
|
+
matchMedia,
|
|
949
|
+
mergeStyles,
|
|
950
|
+
prefixStyles,
|
|
951
|
+
toValue,
|
|
952
|
+
toVarFallback
|
|
953
|
+
};
|